Changeset b7fd2a0 in mainline for uspace/drv/audio
- Timestamp:
- 2018-01-13T03:10:29Z (8 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- a53ed3a
- Parents:
- 36f0738
- Location:
- uspace/drv/audio
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/hdaudio/codec.c
r36f0738 rb7fd2a0 46 46 #include "stream.h" 47 47 48 static int hda_ccmd(hda_codec_t *codec, int node, uint32_t vid, uint32_t payload,48 static errno_t hda_ccmd(hda_codec_t *codec, int node, uint32_t vid, uint32_t payload, 49 49 uint32_t *resp) 50 50 { … … 66 66 (payload & 0xffff); 67 67 } 68 int rc = hda_cmd(codec->hda, verb, resp);68 errno_t rc = hda_cmd(codec->hda, verb, resp); 69 69 /* 70 70 if (resp != NULL) { … … 78 78 } 79 79 80 static int hda_get_parameter(hda_codec_t *codec, int node, hda_param_id_t param,80 static errno_t hda_get_parameter(hda_codec_t *codec, int node, hda_param_id_t param, 81 81 uint32_t *resp) 82 82 { … … 84 84 } 85 85 86 static int hda_get_subnc(hda_codec_t *codec, int node, int *startnode,86 static errno_t hda_get_subnc(hda_codec_t *codec, int node, int *startnode, 87 87 int *nodecount) 88 88 { 89 int rc;89 errno_t rc; 90 90 uint32_t resp; 91 91 … … 103 103 104 104 /** Get Function Group Type */ 105 static int hda_get_fgrp_type(hda_codec_t *codec, int node, bool *unsol,105 static errno_t hda_get_fgrp_type(hda_codec_t *codec, int node, bool *unsol, 106 106 hda_fgrp_type_t *type) 107 107 { 108 int rc;108 errno_t rc; 109 109 uint32_t resp; 110 110 … … 119 119 } 120 120 121 static int hda_get_clist_len(hda_codec_t *codec, int node, bool *longform,121 static errno_t hda_get_clist_len(hda_codec_t *codec, int node, bool *longform, 122 122 int *items) 123 123 { 124 int rc;124 errno_t rc; 125 125 uint32_t resp; 126 126 … … 135 135 } 136 136 137 static int hda_get_clist_entry(hda_codec_t *codec, int node, int n, uint32_t *resp)137 static errno_t hda_get_clist_entry(hda_codec_t *codec, int node, int n, uint32_t *resp) 138 138 { 139 139 return hda_ccmd(codec, node, hda_clist_entry_get, n, resp); 140 140 } 141 141 142 static int hda_get_eapd_btl_enable(hda_codec_t *codec, int node, uint32_t *resp)142 static errno_t hda_get_eapd_btl_enable(hda_codec_t *codec, int node, uint32_t *resp) 143 143 { 144 144 return hda_ccmd(codec, node, hda_eapd_btl_enable_get, 0, resp); 145 145 } 146 146 147 static int hda_set_eapd_btl_enable(hda_codec_t *codec, int node, uint8_t payload)147 static errno_t hda_set_eapd_btl_enable(hda_codec_t *codec, int node, uint8_t payload) 148 148 { 149 149 return hda_ccmd(codec, node, hda_eapd_btl_enable_set, payload, NULL); … … 151 151 152 152 /** Get Suppported PCM Size, Rates */ 153 static int hda_get_supp_rates(hda_codec_t *codec, int node, uint32_t *rates)153 static errno_t hda_get_supp_rates(hda_codec_t *codec, int node, uint32_t *rates) 154 154 { 155 155 return hda_get_parameter(codec, node, hda_supp_rates, rates); … … 157 157 158 158 /** Get Suppported Stream Formats */ 159 static int hda_get_supp_formats(hda_codec_t *codec, int node, uint32_t *fmts)159 static errno_t hda_get_supp_formats(hda_codec_t *codec, int node, uint32_t *fmts) 160 160 { 161 161 return hda_get_parameter(codec, node, hda_supp_formats, fmts); 162 162 } 163 163 164 static int hda_set_converter_fmt(hda_codec_t *codec, int node, uint16_t fmt)164 static errno_t hda_set_converter_fmt(hda_codec_t *codec, int node, uint16_t fmt) 165 165 { 166 166 return hda_ccmd(codec, node, hda_converter_fmt_set, fmt, NULL); 167 167 } 168 168 169 static int hda_set_converter_ctl(hda_codec_t *codec, int node, uint8_t stream,169 static errno_t hda_set_converter_ctl(hda_codec_t *codec, int node, uint8_t stream, 170 170 uint8_t channel) 171 171 { … … 176 176 } 177 177 178 static int hda_set_pin_ctl(hda_codec_t *codec, int node, uint8_t pctl)178 static errno_t hda_set_pin_ctl(hda_codec_t *codec, int node, uint8_t pctl) 179 179 { 180 180 return hda_ccmd(codec, node, hda_pin_ctl_set, pctl, NULL); 181 181 } 182 182 183 static int hda_get_pin_ctl(hda_codec_t *codec, int node, uint8_t *pctl)184 { 185 int rc;183 static errno_t hda_get_pin_ctl(hda_codec_t *codec, int node, uint8_t *pctl) 184 { 185 errno_t rc; 186 186 uint32_t resp; 187 187 … … 195 195 196 196 /** Get Audio Widget Capabilities */ 197 static int hda_get_aw_caps(hda_codec_t *codec, int node,197 static errno_t hda_get_aw_caps(hda_codec_t *codec, int node, 198 198 hda_awidget_type_t *type, uint32_t *caps) 199 199 { 200 int rc;200 errno_t rc; 201 201 uint32_t resp; 202 202 … … 212 212 213 213 /** Get Pin Capabilities */ 214 static int hda_get_pin_caps(hda_codec_t *codec, int node, uint32_t *caps)214 static errno_t hda_get_pin_caps(hda_codec_t *codec, int node, uint32_t *caps) 215 215 { 216 216 return hda_get_parameter(codec, node, hda_pin_caps, caps); … … 218 218 219 219 /** Get Power State */ 220 static int hda_get_power_state(hda_codec_t *codec, int node, uint32_t *pstate)220 static errno_t hda_get_power_state(hda_codec_t *codec, int node, uint32_t *pstate) 221 221 { 222 222 return hda_ccmd(codec, node, hda_power_state_get, 0, pstate); … … 224 224 225 225 /** Get Configuration Default */ 226 static int hda_get_cfg_def(hda_codec_t *codec, int node, uint32_t *cfgdef)226 static errno_t hda_get_cfg_def(hda_codec_t *codec, int node, uint32_t *cfgdef) 227 227 { 228 228 return hda_ccmd(codec, node, hda_cfg_def_get, 0, cfgdef); 229 229 } 230 230 231 static int hda_get_conn_sel(hda_codec_t *codec, int node, uint32_t *conn)231 static errno_t hda_get_conn_sel(hda_codec_t *codec, int node, uint32_t *conn) 232 232 { 233 233 return hda_ccmd(codec, node, hda_conn_sel_get, 0, conn); … … 235 235 236 236 /** Get Amplifier Gain / Mute */ 237 static int hda_get_amp_gain_mute(hda_codec_t *codec, int node, uint16_t payload,237 static errno_t hda_get_amp_gain_mute(hda_codec_t *codec, int node, uint16_t payload, 238 238 uint32_t *resp) 239 239 { 240 240 // ddf_msg(LVL_NOTE, "hda_get_amp_gain_mute(codec, %d, %x)", 241 241 // node, payload); 242 int rc = hda_ccmd(codec, node, hda_amp_gain_mute_get, payload, resp);242 errno_t rc = hda_ccmd(codec, node, hda_amp_gain_mute_get, payload, resp); 243 243 // ddf_msg(LVL_NOTE, "hda_get_amp_gain_mute(codec, %d, %x, resp=%x)", 244 244 // node, payload, *resp); … … 247 247 248 248 /** Get GP I/O Count */ 249 static int hda_get_gpio_cnt(hda_codec_t *codec, int node, uint32_t *resp)249 static errno_t hda_get_gpio_cnt(hda_codec_t *codec, int node, uint32_t *resp) 250 250 { 251 251 return hda_get_parameter(codec, node, hda_gpio_cnt, resp); 252 252 } 253 253 254 static int hda_set_amp_gain_mute(hda_codec_t *codec, int node, uint16_t payload)254 static errno_t hda_set_amp_gain_mute(hda_codec_t *codec, int node, uint16_t payload) 255 255 { 256 256 // ddf_msg(LVL_NOTE, "hda_set_amp_gain_mute(codec, %d, %x)", … … 259 259 } 260 260 261 static int hda_set_out_amp_max(hda_codec_t *codec, uint8_t aw)261 static errno_t hda_set_out_amp_max(hda_codec_t *codec, uint8_t aw) 262 262 { 263 263 uint32_t ampcaps; 264 264 uint32_t gmleft, gmright; 265 265 uint32_t offset; 266 int rc;266 errno_t rc; 267 267 268 268 rc = hda_get_parameter(codec, aw, … … 294 294 } 295 295 296 static int hda_set_in_amp_max(hda_codec_t *codec, uint8_t aw)296 static errno_t hda_set_in_amp_max(hda_codec_t *codec, uint8_t aw) 297 297 { 298 298 uint32_t ampcaps; … … 300 300 uint32_t offset; 301 301 int i; 302 int rc;302 errno_t rc; 303 303 304 304 rc = hda_get_parameter(codec, aw, … … 332 332 } 333 333 334 static int hda_clist_dump(hda_codec_t *codec, uint8_t aw)335 { 336 int rc;334 static errno_t hda_clist_dump(hda_codec_t *codec, uint8_t aw) 335 { 336 errno_t rc; 337 337 bool longform; 338 338 int len; … … 394 394 } 395 395 396 static int hda_pin_init(hda_codec_t *codec, uint8_t aw)397 { 398 int rc;396 static errno_t hda_pin_init(hda_codec_t *codec, uint8_t aw) 397 { 398 errno_t rc; 399 399 uint32_t cfgdef; 400 400 uint32_t pcaps; … … 471 471 472 472 /** Init power-control in wiget capable of doing so. */ 473 static int hda_power_ctl_init(hda_codec_t *codec, uint8_t aw)474 { 475 int rc;473 static errno_t hda_power_ctl_init(hda_codec_t *codec, uint8_t aw) 474 { 475 errno_t rc; 476 476 uint32_t pwrstate; 477 477 … … 491 491 { 492 492 hda_codec_t *codec; 493 int rc;493 errno_t rc; 494 494 int sfg, nfg; 495 495 int saw, naw; … … 639 639 } 640 640 641 int hda_out_converter_setup(hda_codec_t *codec, hda_stream_t *stream)642 { 643 int rc;641 errno_t hda_out_converter_setup(hda_codec_t *codec, hda_stream_t *stream) 642 { 643 errno_t rc; 644 644 int out_aw; 645 645 int i; … … 666 666 } 667 667 668 int hda_in_converter_setup(hda_codec_t *codec, hda_stream_t *stream)669 { 670 int rc;668 errno_t hda_in_converter_setup(hda_codec_t *codec, hda_stream_t *stream) 669 { 670 errno_t rc; 671 671 672 672 /* Configure converter */ -
uspace/drv/audio/hdaudio/codec.h
r36f0738 rb7fd2a0 52 52 extern hda_codec_t *hda_codec_init(hda_t *, uint8_t); 53 53 extern void hda_codec_fini(hda_codec_t *); 54 extern int hda_out_converter_setup(hda_codec_t *, hda_stream_t *);55 extern int hda_in_converter_setup(hda_codec_t *, hda_stream_t *);54 extern errno_t hda_out_converter_setup(hda_codec_t *, hda_stream_t *); 55 extern errno_t hda_in_converter_setup(hda_codec_t *, hda_stream_t *); 56 56 57 57 #endif -
uspace/drv/audio/hdaudio/hdactl.c
r36f0738 rb7fd2a0 64 64 * to read as 0. 65 65 */ 66 static int hda_ctl_reg16_set_reset(uint16_t *reg, uint16_t mask)66 static errno_t hda_ctl_reg16_set_reset(uint16_t *reg, uint16_t mask) 67 67 { 68 68 uint16_t val; … … 116 116 * 117 117 */ 118 static int hda_rb_size_select(uint8_t sizecap, uint8_t *selsz)118 static errno_t hda_rb_size_select(uint8_t sizecap, uint8_t *selsz) 119 119 { 120 120 int i; … … 146 146 147 147 /** Initialize the CORB */ 148 static int hda_corb_init(hda_t *hda)148 static errno_t hda_corb_init(hda_t *hda) 149 149 { 150 150 uint8_t ctl; … … 152 152 uint8_t sizecap; 153 153 uint8_t selsz; 154 int rc;154 errno_t rc; 155 155 156 156 ddf_msg(LVL_NOTE, "hda_corb_init()"); … … 237 237 238 238 /** Initialize the RIRB */ 239 static int hda_rirb_init(hda_t *hda)239 static errno_t hda_rirb_init(hda_t *hda) 240 240 { 241 241 uint8_t ctl; … … 243 243 uint8_t sizecap; 244 244 uint8_t selsz; 245 int rc;245 errno_t rc; 246 246 247 247 ddf_msg(LVL_NOTE, "hda_rirb_init()"); … … 372 372 373 373 /** Write to CORB */ 374 static int hda_corb_write(hda_t *hda, uint32_t *data, size_t count)374 static errno_t hda_corb_write(hda_t *hda, uint32_t *data, size_t count) 375 375 { 376 376 size_t avail; … … 414 414 } 415 415 416 static int hda_rirb_read(hda_t *hda, hda_rirb_entry_t *data)416 static errno_t hda_rirb_read(hda_t *hda, hda_rirb_entry_t *data) 417 417 { 418 418 size_t wp; … … 436 436 } 437 437 438 static int hda_solrb_read(hda_t *hda, hda_rirb_entry_t *data, size_t count)438 static errno_t hda_solrb_read(hda_t *hda, hda_rirb_entry_t *data, size_t count) 439 439 { 440 440 hda_rirb_entry_t resp; … … 490 490 uint32_t intctl; 491 491 int cnt; 492 int rc;492 errno_t rc; 493 493 494 494 ctl = calloc(1, sizeof(hda_ctl_t)); … … 615 615 } 616 616 617 int hda_cmd(hda_t *hda, uint32_t verb, uint32_t *resp)618 { 619 int rc;617 errno_t hda_cmd(hda_t *hda, uint32_t verb, uint32_t *resp) 618 { 619 errno_t rc; 620 620 hda_rirb_entry_t rentry; 621 621 … … 639 639 { 640 640 hda_rirb_entry_t resp; 641 int rc;641 errno_t rc; 642 642 643 643 while (true) { -
uspace/drv/audio/hdaudio/hdactl.h
r36f0738 rb7fd2a0 78 78 extern void hda_ctl_fini(hda_ctl_t *); 79 79 extern void hda_ctl_interrupt(hda_ctl_t *); 80 extern int hda_cmd(hda_t *, uint32_t, uint32_t *);80 extern errno_t hda_cmd(hda_t *, uint32_t, uint32_t *); 81 81 extern void hda_ctl_dump_info(hda_ctl_t *); 82 82 -
uspace/drv/audio/hdaudio/hdaudio.c
r36f0738 rb7fd2a0 52 52 #define NAME "hdaudio" 53 53 54 static int hda_dev_add(ddf_dev_t *dev);55 static int hda_dev_remove(ddf_dev_t *dev);56 static int hda_dev_gone(ddf_dev_t *dev);57 static int hda_fun_online(ddf_fun_t *fun);58 static int hda_fun_offline(ddf_fun_t *fun);54 static errno_t hda_dev_add(ddf_dev_t *dev); 55 static errno_t hda_dev_remove(ddf_dev_t *dev); 56 static errno_t hda_dev_gone(ddf_dev_t *dev); 57 static errno_t hda_fun_online(ddf_fun_t *fun); 58 static errno_t hda_fun_offline(ddf_fun_t *fun); 59 59 60 60 static void hdaudio_interrupt(ipc_call_t *, ddf_dev_t *); … … 148 148 }; 149 149 150 static int hda_dev_add(ddf_dev_t *dev)150 static errno_t hda_dev_add(ddf_dev_t *dev) 151 151 { 152 152 ddf_fun_t *fun_pcm = NULL; … … 160 160 int i; 161 161 void *regs = NULL; 162 int rc;162 errno_t rc; 163 163 164 164 ddf_msg(LVL_NOTE, "hda_dev_add()"); … … 318 318 } 319 319 320 static int hda_dev_remove(ddf_dev_t *dev)320 static errno_t hda_dev_remove(ddf_dev_t *dev) 321 321 { 322 322 hda_t *hda = (hda_t *)ddf_dev_data_get(dev); 323 int rc;323 errno_t rc; 324 324 325 325 ddf_msg(LVL_DEBUG, "hda_dev_remove(%p)", dev); … … 340 340 } 341 341 342 static int hda_dev_gone(ddf_dev_t *dev)342 static errno_t hda_dev_gone(ddf_dev_t *dev) 343 343 { 344 344 hda_t *hda = (hda_t *)ddf_dev_data_get(dev); 345 int rc;345 errno_t rc; 346 346 347 347 ddf_msg(LVL_DEBUG, "hda_dev_remove(%p)", dev); … … 356 356 } 357 357 358 static int hda_fun_online(ddf_fun_t *fun)358 static errno_t hda_fun_online(ddf_fun_t *fun) 359 359 { 360 360 ddf_msg(LVL_DEBUG, "hda_fun_online()"); … … 362 362 } 363 363 364 static int hda_fun_offline(ddf_fun_t *fun)364 static errno_t hda_fun_offline(ddf_fun_t *fun) 365 365 { 366 366 ddf_msg(LVL_DEBUG, "hda_fun_offline()"); -
uspace/drv/audio/hdaudio/pcm_iface.c
r36f0738 rb7fd2a0 47 47 #include "stream.h" 48 48 49 static int hda_get_info_str(ddf_fun_t *, const char **);49 static errno_t hda_get_info_str(ddf_fun_t *, const char **); 50 50 static unsigned hda_query_cap(ddf_fun_t *, audio_cap_t); 51 static int hda_test_format(ddf_fun_t *, unsigned *, unsigned *,51 static errno_t hda_test_format(ddf_fun_t *, unsigned *, unsigned *, 52 52 pcm_sample_format_t *); 53 static int hda_get_buffer(ddf_fun_t *, void **, size_t *);54 static int hda_get_buffer_position(ddf_fun_t *, size_t *);55 static int hda_set_event_session(ddf_fun_t *, async_sess_t *);53 static errno_t hda_get_buffer(ddf_fun_t *, void **, size_t *); 54 static errno_t hda_get_buffer_position(ddf_fun_t *, size_t *); 55 static errno_t hda_set_event_session(ddf_fun_t *, async_sess_t *); 56 56 static async_sess_t *hda_get_event_session(ddf_fun_t *); 57 static int hda_release_buffer(ddf_fun_t *);58 static int hda_start_playback(ddf_fun_t *, unsigned, unsigned, unsigned,57 static errno_t hda_release_buffer(ddf_fun_t *); 58 static errno_t hda_start_playback(ddf_fun_t *, unsigned, unsigned, unsigned, 59 59 pcm_sample_format_t); 60 static int hda_stop_playback(ddf_fun_t *, bool);61 static int hda_start_capture(ddf_fun_t *, unsigned, unsigned, unsigned,60 static errno_t hda_stop_playback(ddf_fun_t *, bool); 61 static errno_t hda_start_capture(ddf_fun_t *, unsigned, unsigned, unsigned, 62 62 pcm_sample_format_t); 63 static int hda_stop_capture(ddf_fun_t *, bool);63 static errno_t hda_stop_capture(ddf_fun_t *, bool); 64 64 65 65 audio_pcm_iface_t hda_pcm_iface = { … … 90 90 } 91 91 92 static int hda_get_info_str(ddf_fun_t *fun, const char **name)92 static errno_t hda_get_info_str(ddf_fun_t *fun, const char **name) 93 93 { 94 94 ddf_msg(LVL_NOTE, "hda_get_info_str()"); … … 124 124 } 125 125 126 static int hda_test_format(ddf_fun_t *fun, unsigned *channels,126 static errno_t hda_test_format(ddf_fun_t *fun, unsigned *channels, 127 127 unsigned *rate, pcm_sample_format_t *format) 128 128 { 129 int rc = EOK;129 errno_t rc = EOK; 130 130 131 131 ddf_msg(LVL_NOTE, "hda_test_format(%u, %u, %d)\n", … … 150 150 } 151 151 152 static int hda_get_buffer(ddf_fun_t *fun, void **buffer, size_t *size)153 { 154 hda_t *hda = fun_to_hda(fun); 155 int rc;152 static errno_t hda_get_buffer(ddf_fun_t *fun, void **buffer, size_t *size) 153 { 154 hda_t *hda = fun_to_hda(fun); 155 errno_t rc; 156 156 157 157 hda_lock(hda); … … 183 183 } 184 184 185 static int hda_get_buffer_position(ddf_fun_t *fun, size_t *pos)185 static errno_t hda_get_buffer_position(ddf_fun_t *fun, size_t *pos) 186 186 { 187 187 ddf_msg(LVL_NOTE, "hda_get_buffer_position()"); … … 189 189 } 190 190 191 static int hda_set_event_session(ddf_fun_t *fun, async_sess_t *sess)191 static errno_t hda_set_event_session(ddf_fun_t *fun, async_sess_t *sess) 192 192 { 193 193 hda_t *hda = fun_to_hda(fun); … … 215 215 } 216 216 217 static int hda_release_buffer(ddf_fun_t *fun)217 static errno_t hda_release_buffer(ddf_fun_t *fun) 218 218 { 219 219 hda_t *hda = fun_to_hda(fun); … … 234 234 } 235 235 236 static int hda_start_playback(ddf_fun_t *fun, unsigned frames,236 static errno_t hda_start_playback(ddf_fun_t *fun, unsigned frames, 237 237 unsigned channels, unsigned rate, pcm_sample_format_t format) 238 238 { 239 239 hda_t *hda = fun_to_hda(fun); 240 int rc;240 errno_t rc; 241 241 242 242 ddf_msg(LVL_NOTE, "hda_start_playback()"); … … 275 275 } 276 276 277 static int hda_stop_playback(ddf_fun_t *fun, bool immediate)277 static errno_t hda_stop_playback(ddf_fun_t *fun, bool immediate) 278 278 { 279 279 hda_t *hda = fun_to_hda(fun); … … 293 293 } 294 294 295 static int hda_start_capture(ddf_fun_t *fun, unsigned frames, unsigned channels,295 static errno_t hda_start_capture(ddf_fun_t *fun, unsigned frames, unsigned channels, 296 296 unsigned rate, pcm_sample_format_t format) 297 297 { 298 298 hda_t *hda = fun_to_hda(fun); 299 int rc;299 errno_t rc; 300 300 301 301 ddf_msg(LVL_NOTE, "hda_start_capture()"); … … 334 334 } 335 335 336 static int hda_stop_capture(ddf_fun_t *fun, bool immediate)336 static errno_t hda_stop_capture(ddf_fun_t *fun, bool immediate) 337 337 { 338 338 hda_t *hda = fun_to_hda(fun); -
uspace/drv/audio/hdaudio/stream.c
r36f0738 rb7fd2a0 49 49 #include "stream.h" 50 50 51 int hda_stream_buffers_alloc(hda_t *hda, hda_stream_buffers_t **rbufs)51 errno_t hda_stream_buffers_alloc(hda_t *hda, hda_stream_buffers_t **rbufs) 52 52 { 53 53 void *bdl; … … 57 57 size_t i; 58 58 // size_t j, k; 59 int rc;59 errno_t rc; 60 60 61 61 bufs = calloc(1, sizeof(hda_stream_buffers_t)); -
uspace/drv/audio/hdaudio/stream.h
r36f0738 rb7fd2a0 77 77 } hda_stream_t; 78 78 79 extern int hda_stream_buffers_alloc(hda_t *, hda_stream_buffers_t **);79 extern errno_t hda_stream_buffers_alloc(hda_t *, hda_stream_buffers_t **); 80 80 extern void hda_stream_buffers_free(hda_stream_buffers_t *); 81 81 extern hda_stream_t *hda_stream_create(hda_t *, hda_stream_dir_t, -
uspace/drv/audio/sb16/dsp.c
r36f0738 rb7fd2a0 89 89 } 90 90 91 static inline int dsp_read(sb_dsp_t *dsp, uint8_t *data)91 static inline errno_t dsp_read(sb_dsp_t *dsp, uint8_t *data) 92 92 { 93 93 assert(data); … … 106 106 } 107 107 108 static inline int dsp_write(sb_dsp_t *dsp, uint8_t data)108 static inline errno_t dsp_write(sb_dsp_t *dsp, uint8_t data) 109 109 { 110 110 assert(dsp); … … 159 159 } 160 160 161 static inline int setup_dma(sb_dsp_t *dsp, uintptr_t pa, size_t size)161 static inline errno_t setup_dma(sb_dsp_t *dsp, uintptr_t pa, size_t size) 162 162 { 163 163 async_sess_t *sess = ddf_dev_parent_sess_get(dsp->sb_dev); … … 168 168 } 169 169 170 static inline int setup_buffer(sb_dsp_t *dsp, size_t size)170 static inline errno_t setup_buffer(sb_dsp_t *dsp, size_t size) 171 171 { 172 172 assert(dsp); … … 178 178 void *buffer = AS_AREA_ANY; 179 179 180 int ret = dmamem_map_anonymous(size, DMAMEM_16MiB | 0x0000ffff,180 errno_t ret = dmamem_map_anonymous(size, DMAMEM_16MiB | 0x0000ffff, 181 181 AS_AREA_WRITE | AS_AREA_READ, 0, &pa, &buffer); 182 182 if (ret != EOK) { … … 202 202 } 203 203 204 int sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs, ddf_dev_t *dev,204 errno_t sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs, ddf_dev_t *dev, 205 205 int dma8, int dma16) 206 206 { … … 215 215 dsp_reset(dsp); 216 216 uint8_t response; 217 const int ret = dsp_read(dsp, &response);217 const errno_t ret = dsp_read(dsp, &response); 218 218 if (ret != EOK) { 219 219 ddf_log_error("Failed to read DSP reset response value."); … … 294 294 } 295 295 296 int sb_dsp_get_buffer_position(sb_dsp_t *dsp, size_t *pos)296 errno_t sb_dsp_get_buffer_position(sb_dsp_t *dsp, size_t *pos) 297 297 { 298 298 if (dsp->state == DSP_NO_BUFFER) … … 304 304 // TODO: Assumes DMA 16 305 305 size_t remain; 306 int rc = hw_res_dma_channel_remain(sess, dsp->dma16_channel, &remain);306 errno_t rc = hw_res_dma_channel_remain(sess, dsp->dma16_channel, &remain); 307 307 if (rc == EOK) { 308 308 *pos = dsp->buffer.size - remain; … … 311 311 } 312 312 313 int sb_dsp_test_format(sb_dsp_t *dsp, unsigned *channels, unsigned *rate,313 errno_t sb_dsp_test_format(sb_dsp_t *dsp, unsigned *channels, unsigned *rate, 314 314 pcm_sample_format_t *format) 315 315 { 316 int ret = EOK;316 errno_t ret = EOK; 317 317 if (*channels == 0 || *channels > 2) { 318 318 *channels = 2; … … 336 336 } 337 337 338 int sb_dsp_set_event_session(sb_dsp_t *dsp, async_sess_t *session)338 errno_t sb_dsp_set_event_session(sb_dsp_t *dsp, async_sess_t *session) 339 339 { 340 340 assert(dsp); … … 353 353 } 354 354 355 int sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size)355 errno_t sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size) 356 356 { 357 357 assert(dsp); … … 364 364 assert(dsp->buffer.data == NULL); 365 365 366 const int ret = setup_buffer(dsp, *size);366 const errno_t ret = setup_buffer(dsp, *size); 367 367 if (ret == EOK) { 368 368 ddf_log_debug("Providing buffer: %p, %zu B.", … … 378 378 } 379 379 380 int sb_dsp_release_buffer(sb_dsp_t *dsp)380 errno_t sb_dsp_release_buffer(sb_dsp_t *dsp) 381 381 { 382 382 assert(dsp); … … 392 392 } 393 393 394 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned frames,394 errno_t sb_dsp_start_playback(sb_dsp_t *dsp, unsigned frames, 395 395 unsigned channels, unsigned sampling_rate, pcm_sample_format_t format) 396 396 { … … 441 441 } 442 442 443 int sb_dsp_stop_playback(sb_dsp_t *dsp, bool immediate)443 errno_t sb_dsp_stop_playback(sb_dsp_t *dsp, bool immediate) 444 444 { 445 445 assert(dsp); … … 471 471 } 472 472 473 int sb_dsp_start_capture(sb_dsp_t *dsp, unsigned frames,473 errno_t sb_dsp_start_capture(sb_dsp_t *dsp, unsigned frames, 474 474 unsigned channels, unsigned sampling_rate, pcm_sample_format_t format) 475 475 { … … 517 517 } 518 518 519 int sb_dsp_stop_capture(sb_dsp_t *dsp, bool immediate)519 errno_t sb_dsp_stop_capture(sb_dsp_t *dsp, bool immediate) 520 520 { 521 521 assert(dsp); -
uspace/drv/audio/sb16/dsp.h
r36f0738 rb7fd2a0 76 76 } sb_dsp_t; 77 77 78 int sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs, ddf_dev_t *dev,78 errno_t sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs, ddf_dev_t *dev, 79 79 int dma8, int dma16); 80 80 void sb_dsp_interrupt(sb_dsp_t *dsp); 81 81 unsigned sb_dsp_query_cap(sb_dsp_t *dsp, audio_cap_t cap); 82 int sb_dsp_get_buffer_position(sb_dsp_t *dsp, size_t *size);83 int sb_dsp_test_format(sb_dsp_t *dsp, unsigned *channels, unsigned *rate,82 errno_t sb_dsp_get_buffer_position(sb_dsp_t *dsp, size_t *size); 83 errno_t sb_dsp_test_format(sb_dsp_t *dsp, unsigned *channels, unsigned *rate, 84 84 pcm_sample_format_t *format); 85 int sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size);86 int sb_dsp_set_event_session(sb_dsp_t *dsp, async_sess_t *session);85 errno_t sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size); 86 errno_t sb_dsp_set_event_session(sb_dsp_t *dsp, async_sess_t *session); 87 87 async_sess_t * sb_dsp_get_event_session(sb_dsp_t *dsp); 88 int sb_dsp_release_buffer(sb_dsp_t *dsp);89 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned frames,88 errno_t sb_dsp_release_buffer(sb_dsp_t *dsp); 89 errno_t sb_dsp_start_playback(sb_dsp_t *dsp, unsigned frames, 90 90 unsigned channels, unsigned sample_rate, pcm_sample_format_t format); 91 int sb_dsp_stop_playback(sb_dsp_t *dsp, bool immediate);92 int sb_dsp_start_capture(sb_dsp_t *dsp, unsigned frames,91 errno_t sb_dsp_stop_playback(sb_dsp_t *dsp, bool immediate); 92 errno_t sb_dsp_start_capture(sb_dsp_t *dsp, unsigned frames, 93 93 unsigned channels, unsigned sample_rate, pcm_sample_format_t format); 94 int sb_dsp_stop_capture(sb_dsp_t *dsp, bool immediate);94 errno_t sb_dsp_stop_capture(sb_dsp_t *dsp, bool immediate); 95 95 96 96 #endif -
uspace/drv/audio/sb16/main.c
r36f0738 rb7fd2a0 47 47 #define NAME "sb16" 48 48 49 static int sb_add_device(ddf_dev_t *device);50 static int sb_get_res(ddf_dev_t *device, addr_range_t **pp_sb_regs,49 static errno_t sb_add_device(ddf_dev_t *device); 50 static errno_t sb_get_res(ddf_dev_t *device, addr_range_t **pp_sb_regs, 51 51 addr_range_t **pp_mpu_regs, int *irq, int *dma8, int *dma16); 52 static int sb_enable_interrupt(ddf_dev_t *device, int irq);52 static errno_t sb_enable_interrupt(ddf_dev_t *device, int irq); 53 53 54 54 static driver_ops_t sb_driver_ops = { … … 87 87 * @return Error code. 88 88 */ 89 static int sb_add_device(ddf_dev_t *device)89 static errno_t sb_add_device(ddf_dev_t *device) 90 90 { 91 91 bool handler_regd = false; … … 96 96 97 97 sb16_t *soft_state = ddf_dev_data_alloc(device, sizeof(sb16_t)); 98 int rc = soft_state ? EOK : ENOMEM;98 errno_t rc = soft_state ? EOK : ENOMEM; 99 99 if (rc != EOK) { 100 100 ddf_log_error("Failed to allocate sb16 structure."); … … 173 173 } 174 174 175 static int sb_get_res(ddf_dev_t *device, addr_range_t **pp_sb_regs,175 static errno_t sb_get_res(ddf_dev_t *device, addr_range_t **pp_sb_regs, 176 176 addr_range_t **pp_mpu_regs, int *irq, int *dma8, int *dma16) 177 177 { … … 184 184 hw_res_list_parsed_t hw_res; 185 185 hw_res_list_parsed_init(&hw_res); 186 const int ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0);186 const errno_t ret = hw_res_get_list_parsed(parent_sess, &hw_res, 0); 187 187 if (ret != EOK) { 188 188 return ret; … … 241 241 } 242 242 243 static int sb_enable_interrupt(ddf_dev_t *device, int irq)243 static errno_t sb_enable_interrupt(ddf_dev_t *device, int irq) 244 244 { 245 245 async_sess_t *parent_sess = ddf_dev_parent_sess_get(device); -
uspace/drv/audio/sb16/mixer.c
r36f0738 rb7fd2a0 123 123 } 124 124 125 int sb_mixer_init(sb_mixer_t *mixer, sb16_regs_t *regs, sb_mixer_type_t type)125 errno_t sb_mixer_init(sb_mixer_t *mixer, sb16_regs_t *regs, sb_mixer_type_t type) 126 126 { 127 127 assert(mixer); … … 149 149 } 150 150 151 int sb_mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned item,151 errno_t sb_mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned item, 152 152 const char** name, unsigned *levels) 153 153 { … … 171 171 * @return Error code. 172 172 */ 173 int sb_mixer_get_control_item_value(const sb_mixer_t *mixer, unsigned item,173 errno_t sb_mixer_get_control_item_value(const sb_mixer_t *mixer, unsigned item, 174 174 unsigned *value) 175 175 { … … 194 194 * @return Error code. 195 195 */ 196 int sb_mixer_set_control_item_value(const sb_mixer_t *mixer, unsigned item,196 errno_t sb_mixer_set_control_item_value(const sb_mixer_t *mixer, unsigned item, 197 197 unsigned value) 198 198 { -
uspace/drv/audio/sb16/mixer.h
r36f0738 rb7fd2a0 51 51 52 52 const char * sb_mixer_type_str(sb_mixer_type_t type); 53 int sb_mixer_init(sb_mixer_t *mixer, sb16_regs_t *regs, sb_mixer_type_t type);53 errno_t sb_mixer_init(sb_mixer_t *mixer, sb16_regs_t *regs, sb_mixer_type_t type); 54 54 int sb_mixer_get_control_item_count(const sb_mixer_t *mixer); 55 int sb_mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned index,55 errno_t sb_mixer_get_control_item_info(const sb_mixer_t *mixer, unsigned index, 56 56 const char **name, unsigned *levels); 57 int sb_mixer_get_control_item_value(const sb_mixer_t *mixer, unsigned index,57 errno_t sb_mixer_get_control_item_value(const sb_mixer_t *mixer, unsigned index, 58 58 unsigned *value); 59 int sb_mixer_set_control_item_value(const sb_mixer_t *mixer, unsigned index,59 errno_t sb_mixer_set_control_item_value(const sb_mixer_t *mixer, unsigned index, 60 60 unsigned value); 61 61 #endif -
uspace/drv/audio/sb16/mixer_iface.c
r36f0738 rb7fd2a0 46 46 } 47 47 48 static int sb_get_info(ddf_fun_t *fun, const char** name, unsigned *items)48 static errno_t sb_get_info(ddf_fun_t *fun, const char** name, unsigned *items) 49 49 { 50 50 sb_mixer_t *mixer = fun_to_mixer(fun); … … 58 58 } 59 59 60 static int sb_get_item_info(ddf_fun_t *fun, unsigned item, const char** name,60 static errno_t sb_get_item_info(ddf_fun_t *fun, unsigned item, const char** name, 61 61 unsigned *max_level) 62 62 { … … 65 65 } 66 66 67 static int sb_set_item_level(ddf_fun_t *fun, unsigned item, unsigned value)67 static errno_t sb_set_item_level(ddf_fun_t *fun, unsigned item, unsigned value) 68 68 { 69 69 sb_mixer_t *mixer = fun_to_mixer(fun); … … 71 71 } 72 72 73 static int sb_get_item_level(ddf_fun_t *fun, unsigned item, unsigned *value)73 static errno_t sb_get_item_level(ddf_fun_t *fun, unsigned item, unsigned *value) 74 74 { 75 75 sb_mixer_t *mixer = fun_to_mixer(fun); -
uspace/drv/audio/sb16/pcm_iface.c
r36f0738 rb7fd2a0 47 47 } 48 48 49 static int sb_get_info_str(ddf_fun_t *fun, const char** name)49 static errno_t sb_get_info_str(ddf_fun_t *fun, const char** name) 50 50 { 51 51 if (name) … … 59 59 } 60 60 61 static int sb_test_format(ddf_fun_t *fun, unsigned *channels, unsigned *rate,61 static errno_t sb_test_format(ddf_fun_t *fun, unsigned *channels, unsigned *rate, 62 62 pcm_sample_format_t *format) 63 63 { 64 64 return sb_dsp_test_format(fun_to_dsp(fun), channels, rate, format); 65 65 } 66 static int sb_get_buffer(ddf_fun_t *fun, void **buffer, size_t *size)66 static errno_t sb_get_buffer(ddf_fun_t *fun, void **buffer, size_t *size) 67 67 { 68 68 return sb_dsp_get_buffer(fun_to_dsp(fun), buffer, size); 69 69 } 70 70 71 static int sb_get_buffer_position(ddf_fun_t *fun, size_t *size)71 static errno_t sb_get_buffer_position(ddf_fun_t *fun, size_t *size) 72 72 { 73 73 return sb_dsp_get_buffer_position(fun_to_dsp(fun), size); 74 74 } 75 75 76 static int sb_set_event_session(ddf_fun_t *fun, async_sess_t *sess)76 static errno_t sb_set_event_session(ddf_fun_t *fun, async_sess_t *sess) 77 77 { 78 78 return sb_dsp_set_event_session(fun_to_dsp(fun), sess); … … 84 84 } 85 85 86 static int sb_release_buffer(ddf_fun_t *fun)86 static errno_t sb_release_buffer(ddf_fun_t *fun) 87 87 { 88 88 return sb_dsp_release_buffer(fun_to_dsp(fun)); 89 89 } 90 90 91 static int sb_start_playback(ddf_fun_t *fun, unsigned frames,91 static errno_t sb_start_playback(ddf_fun_t *fun, unsigned frames, 92 92 unsigned channels, unsigned sample_rate, pcm_sample_format_t format) 93 93 { … … 96 96 } 97 97 98 static int sb_stop_playback(ddf_fun_t *fun, bool immediate)98 static errno_t sb_stop_playback(ddf_fun_t *fun, bool immediate) 99 99 { 100 100 return sb_dsp_stop_playback(fun_to_dsp(fun), immediate); 101 101 } 102 102 103 static int sb_start_capture(ddf_fun_t *fun, unsigned frames,103 static errno_t sb_start_capture(ddf_fun_t *fun, unsigned frames, 104 104 unsigned channels, unsigned sample_rate, pcm_sample_format_t format) 105 105 { … … 108 108 } 109 109 110 static int sb_stop_capture(ddf_fun_t *fun, bool immediate)110 static errno_t sb_stop_capture(ddf_fun_t *fun, bool immediate) 111 111 { 112 112 return sb_dsp_stop_capture(fun_to_dsp(fun), immediate); -
uspace/drv/audio/sb16/sb16.c
r36f0738 rb7fd2a0 94 94 } 95 95 96 int sb16_init_sb16(sb16_t *sb, addr_range_t *regs, ddf_dev_t *dev, int dma8,96 errno_t sb16_init_sb16(sb16_t *sb, addr_range_t *regs, ddf_dev_t *dev, int dma8, 97 97 int dma16) 98 98 { … … 100 100 101 101 /* Setup registers */ 102 int ret = pio_enable_range(regs, (void **) &sb->regs);102 errno_t ret = pio_enable_range(regs, (void **) &sb->regs); 103 103 if (ret != EOK) 104 104 return ret; … … 179 179 } 180 180 181 int sb16_init_mpu(sb16_t *sb, addr_range_t *regs)181 errno_t sb16_init_mpu(sb16_t *sb, addr_range_t *regs) 182 182 { 183 183 sb->mpu_regs = NULL; -
uspace/drv/audio/sb16/sb16.h
r36f0738 rb7fd2a0 53 53 size_t sb16_irq_code_size(void); 54 54 void sb16_irq_code(addr_range_t *regs, int dma8, int dma16, irq_cmd_t cmds[], irq_pio_range_t ranges[]); 55 int sb16_init_sb16(sb16_t *sb, addr_range_t *regs, ddf_dev_t *dev, int dma8, int dma16);56 int sb16_init_mpu(sb16_t *sb, addr_range_t *regs);55 errno_t sb16_init_sb16(sb16_t *sb, addr_range_t *regs, ddf_dev_t *dev, int dma8, int dma16); 56 errno_t sb16_init_mpu(sb16_t *sb, addr_range_t *regs); 57 57 void sb16_interrupt(sb16_t *sb); 58 58
Note:
See TracChangeset
for help on using the changeset viewer.