Changeset ed3f8d5 in mainline for uspace/drv/audio/sb16/dsp.c


Ignore:
Timestamp:
2011-11-30T21:58:26Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
5c62b5f
Parents:
413225d
Message:

sb16: Rework AUTO_DMA_MODE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/dsp.c

    r413225d red3f8d5  
    5656#define AUTO_DMA_MODE
    5757
    58 #ifdef AUTO_DMA_MODE
    59 #undef AUTO_DMA_MODE
    60 #define AUTO_DMA_MODE true
    61 #else
    62 #define AUTO_DMA_MODE false
    63 #endif
    64 
    6558static inline int sb_dsp_read(sb_dsp_t *dsp, uint8_t *data)
    6659{
     
    198191
    199192        if (remain_size == 0) {
     193#ifdef AUTO_DMA_MODE
     194                sb_dsp_write(dsp, DMA_16B_EXIT);
     195#endif
    200196                ddf_log_note("Nothing more to play");
    201                 if (AUTO_DMA_MODE) {
    202                         sb_dsp_write(dsp, DMA_16B_EXIT);
    203                 }
    204197                sb_clear_buffer(dsp);
    205198                return;
     
    220213                return;
    221214        }
     215        /* Copy new data */
    222216        memcpy(dsp->buffer.position, dsp->playing.position, PLAY_BLOCK_SIZE);
    223217        write_barrier();
     218        /* Adjust position */
    224219        dsp->playing.position += PLAY_BLOCK_SIZE;
    225220        dsp->buffer.position += PLAY_BLOCK_SIZE;
     
    227222        if (dsp->buffer.position == (dsp->buffer.data + dsp->buffer.size))
    228223                dsp->buffer.position = dsp->buffer.data;
    229         if (!AUTO_DMA_MODE) {
    230                 sb_dsp_write(dsp, SINGLE_DMA_16B_DA_FIFO);
    231                 sb_dsp_write(dsp, dsp->playing.mode);
    232                 sb_dsp_write(dsp, (PLAY_BLOCK_SIZE - 1) & 0xff);
    233                 sb_dsp_write(dsp, (PLAY_BLOCK_SIZE - 1) >> 8);
    234         }
     224#ifndef AUTO_DMA_MODE
     225        const size_t samples = sample_count(dsp->playing.mode, PLAY_BLOCK_SIZE);
     226        sb_dsp_write(dsp, SINGLE_DMA_16B_DA_FIFO);
     227        sb_dsp_write(dsp, dsp->playing.mode);
     228        sb_dsp_write(dsp, (samples - 1) & 0xff);
     229        sb_dsp_write(dsp, (samples - 1) >> 8);
     230#endif
    235231
    236232}
     
    270266                return ret;
    271267
     268        const size_t copy_size = size < BUFFER_SIZE ? size : BUFFER_SIZE;
    272269        const size_t play_size =
    273270            size < PLAY_BLOCK_SIZE ? size : PLAY_BLOCK_SIZE;
    274         const size_t copy_size =
    275             size < BUFFER_SIZE ? size : BUFFER_SIZE;
    276271
    277272        dsp->playing.data = data;
     
    279274        dsp->playing.size = size;
    280275        dsp->playing.mode = 0;
     276
    281277        if (sample_size == 16)
    282278                dsp->playing.mode |= DSP_MODE_16BIT;
     
    299295            sampling_rate >> 8, sampling_rate & 0xff);
    300296
    301         if (!AUTO_DMA_MODE || play_size == size) {
     297#ifdef AUTO_DMA_MODE
     298        if (play_size < size) {
     299                sb_dsp_write(dsp, AUTO_DMA_16B_DA_FIFO);
     300        } else {
    302301                sb_dsp_write(dsp, SINGLE_DMA_16B_DA_FIFO);
    303         } else {
    304                 sb_dsp_write(dsp, AUTO_DMA_16B_DA_FIFO);
    305         }
     302        }
     303#else
     304        sb_dsp_write(dsp, SINGLE_DMA_16B_DA_FIFO);
     305#endif
     306
    306307        sb_dsp_write(dsp, dsp->playing.mode);
    307308        sb_dsp_write(dsp, (samples - 1) & 0xff);
Note: See TracChangeset for help on using the changeset viewer.