Changeset 7ca22e5 in mainline
- Timestamp:
- 2012-07-05T19:32:58Z (12 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 725d038
- Parents:
- 8de7ef2
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.c
r8de7ef2 r7ca22e5 162 162 dsp->dma8_channel = dma8; 163 163 dsp->dma16_channel = dma16; 164 dsp->event_session = NULL; 165 dsp->event_exchange = NULL; 164 166 dsp->sb_dev = dev; 165 167 sb_dsp_reset(dsp); … … 187 189 void sb_dsp_interrupt(sb_dsp_t *dsp) 188 190 { 191 assert(dsp); 192 if (dsp->event_exchange) { 193 async_msg_0(dsp->event_exchange, IPC_FIRST_USER_METHOD); 194 } else { 195 ddf_log_warning("Interrupt with no event consumer."); 196 } 189 197 #ifndef AUTO_DMA_MODE 190 assert(dsp);191 198 sb_dsp_write(dsp, SINGLE_DMA_16B_DA); 192 199 sb_dsp_write(dsp, dsp->playing.mode); … … 200 207 assert(dsp); 201 208 assert(size); 209 210 /* buffer is already setup by for someone, refuse to work until 211 * it's released */ 212 if (dsp->buffer.data) 213 return EBUSY; 202 214 203 215 const int ret = sb_setup_buffer(dsp, *size); … … 213 225 return ret; 214 226 } 227 228 int sb_dsp_set_event_session(sb_dsp_t *dsp, unsigned id, async_sess_t *session) 229 { 230 assert(dsp); 231 assert(session); 232 if (id != BUFFER_ID) 233 return ENOENT; 234 if (dsp->event_session) 235 return EBUSY; 236 dsp->event_session = session; 237 return EOK; 238 } 215 239 /*----------------------------------------------------------------------------*/ 216 240 int sb_dsp_release_buffer(sb_dsp_t *dsp, unsigned id) … … 220 244 return ENOENT; 221 245 sb_clear_buffer(dsp); 222 return EOK; 223 } 224 /*----------------------------------------------------------------------------*/ 225 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned id, unsigned sampling_rate, 226 unsigned sample_size, unsigned channels, bool sign) 227 { 228 assert(dsp); 246 if (dsp->event_exchange) 247 async_exchange_end(dsp->event_exchange); 248 dsp->event_exchange = NULL; 249 if (dsp->event_session) 250 async_hangup(dsp->event_session); 251 dsp->event_session = NULL; 252 return EOK; 253 } 254 /*----------------------------------------------------------------------------*/ 255 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned id, unsigned parts, 256 unsigned sampling_rate, unsigned sample_size, unsigned channels, bool sign) 257 { 258 assert(dsp); 259 260 if (!dsp->event_session) 261 return EINVAL; 262 263 /* Play block size must be even number (we use DMA 16)*/ 264 if (dsp->buffer.size % (parts * 2)) 265 return EINVAL; 266 267 const unsigned play_block_size = dsp->buffer.size / parts; 229 268 230 269 /* Check supported parameters */ … … 241 280 return ENOTSUP; 242 281 282 dsp->event_exchange = async_exchange_begin(dsp->event_session); 283 if (!dsp->event_exchange) 284 return ENOMEM; 243 285 244 286 sb_dsp_write(dsp, SET_SAMPLING_RATE_OUTPUT); … … 259 301 sb_dsp_write(dsp, dsp->playing.mode); 260 302 261 dsp->playing.samples = sample_count(sample_size, PLAY_BLOCK_SIZE);303 dsp->playing.samples = sample_count(sample_size, play_block_size); 262 304 sb_dsp_write(dsp, (dsp->playing.samples - 1) & 0xff); 263 305 sb_dsp_write(dsp, (dsp->playing.samples - 1) >> 8); 264 306 265 307 return EOK; 266 return ENOTSUP;267 308 } 268 309 /*----------------------------------------------------------------------------*/ … … 272 313 if (id != BUFFER_ID) 273 314 return ENOENT; 315 async_exchange_end(dsp->event_exchange); 274 316 sb_dsp_write(dsp, DMA_16B_EXIT); 275 317 return EOK; -
uspace/drv/audio/sb16/dsp.h
r8de7ef2 r7ca22e5 57 57 uint16_t samples; 58 58 } playing; 59 async_sess_t *event_session; 60 async_exch_t *event_exchange; 59 61 ddf_dev_t *sb_dev; 60 62 } sb_dsp_t; … … 65 67 66 68 int sb_dsp_get_buffer(sb_dsp_t *dsp, void **buffer, size_t *size, unsigned *id); 69 int sb_dsp_set_event_session(sb_dsp_t *dsp, unsigned id, async_sess_t *session); 67 70 int sb_dsp_release_buffer(sb_dsp_t *dsp, unsigned id); 68 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned id, unsigned sample_rate,69 unsigned sample_ size, unsigned channels, bool sign);71 int sb_dsp_start_playback(sb_dsp_t *dsp, unsigned id, unsigned parts, 72 unsigned sample_rate, unsigned sample_size, unsigned channels, bool sign); 70 73 int sb_dsp_stop_playback(sb_dsp_t *dsp, unsigned id); 71 74 int sb_dsp_start_record(sb_dsp_t *dsp, unsigned id, unsigned sample_rate, -
uspace/drv/audio/sb16/pcm_iface.c
r8de7ef2 r7ca22e5 33 33 */ 34 34 35 #include <async.h> 35 36 #include <errno.h> 36 37 #include <audio_pcm_buffer_iface.h> … … 53 54 return sb_dsp_get_buffer(dsp, buffer, size, id); 54 55 } 56 static int sb_set_event_session(ddf_fun_t *fun, unsigned id, async_sess_t *sess) 57 { 58 assert(fun); 59 assert(fun->driver_data); 60 sb_dsp_t *dsp = fun->driver_data; 61 return sb_dsp_set_event_session(dsp, id, sess); 62 } 55 63 /*----------------------------------------------------------------------------*/ 56 64 static int sb_release_buffer(ddf_fun_t *fun, unsigned id) … … 62 70 } 63 71 /*----------------------------------------------------------------------------*/ 64 static int sb_start_playback(ddf_fun_t *fun, unsigned id, 72 static int sb_start_playback(ddf_fun_t *fun, unsigned id, unsigned parts, 65 73 unsigned sample_rate, unsigned sample_size, unsigned channels, bool sign) 66 74 { … … 69 77 sb_dsp_t *dsp = fun->driver_data; 70 78 return sb_dsp_start_playback( 71 dsp, id, sample_rate, sample_size, channels, sign);79 dsp, id, parts, sample_rate, sample_size, channels, sign); 72 80 } 73 81 /*----------------------------------------------------------------------------*/ … … 104 112 .get_buffer = sb_get_buffer, 105 113 .release_buffer = sb_release_buffer, 114 .set_event_session = sb_set_event_session, 106 115 107 116 .start_playback = sb_start_playback,
Note:
See TracChangeset
for help on using the changeset viewer.