Changeset 7ca22e5 in mainline for uspace/drv/audio/sb16/dsp.c
- 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
- File:
-
- 1 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;
Note:
See TracChangeset
for help on using the changeset viewer.