Changeset bf38143 in mainline for uspace/drv/audio/sb16/dsp.h


Ignore:
Timestamp:
2011-09-26T15:26:48Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
ce1e5ea
Parents:
bde691c
Message:

sb16: Use new sb_dsp_t structure.

File:
1 edited

Legend:

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

    rbde691c rbf38143  
    3939
    4040#include "registers.h"
    41 #include "dsp_commands.h"
    4241
    43 #ifndef DSP_PIO_DELAY
    44 #define DSP_PIO_DELAY udelay(10)
    45 #endif
     42typedef struct sb_dsp_t {
     43        sb16_regs_t *regs;
     44        struct {
     45                uint8_t major;
     46                uint8_t minor;
     47        } version;
     48        uint8_t *data_buffer;
     49        uint8_t *buffer_position;
     50        size_t buffer_size;
     51} sb_dsp_t;
    4652
    47 #ifndef DSP_RETRY_COUNT
    48 #define DSP_RETRY_COUNT 100
    49 #endif
    5053
    51 #define DSP_RESET_RESPONSE 0xaa
    5254
    53 static inline int dsp_write(sb16_regs_t *regs, uint8_t data)
    54 {
    55         uint8_t status;
    56         size_t attempts = DSP_RETRY_COUNT;
    57         do {
    58                 DSP_PIO_DELAY;
    59                 status = pio_read_8(&regs->dsp_write);
    60         } while (--attempts && ((status & DSP_WRITE_BUSY) != 0));
    61         if ((status & DSP_WRITE_BUSY))
    62                 return EIO;
    63         DSP_PIO_DELAY;
    64         pio_write_8(&regs->dsp_write, data);
    65         return EOK;
    66 }
    6755/*----------------------------------------------------------------------------*/
    68 static inline int dsp_read(sb16_regs_t *regs, uint8_t *data)
    69 {
    70         assert(data);
    71         uint8_t status;
    72         size_t attempts = DSP_RETRY_COUNT;
    73         do {
    74                 DSP_PIO_DELAY;
    75                 status = pio_read_8(&regs->dsp_read_status);
    76         } while (--attempts && ((status & DSP_READ_READY) == 0));
    77 
    78         if ((status & DSP_READ_READY) == 0)
    79                 return EIO;
    80 
    81         DSP_PIO_DELAY;
    82         *data = pio_read_8(&regs->dsp_data_read);
    83         return EOK;
    84 }
     56int sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs);
    8557/*----------------------------------------------------------------------------*/
    86 static inline void dsp_reset(sb16_regs_t *regs)
    87 {
    88         /* Reset DSP, see Chapter 2 of Sound Blaster HW programming guide */
    89         pio_write_8(&regs->dsp_reset, 1);
    90         udelay(3); /* Keep reset for 3 us */
    91         pio_write_8(&regs->dsp_reset, 0);
    92 }
    93 /*----------------------------------------------------------------------------*/
    94 int dsp_play_direct(sb16_regs_t *regs, const uint8_t *data, size_t size,
     58int sb_dsp_play_direct(sb_dsp_t *dsp, const uint8_t *data, size_t size,
    9559    unsigned sample_rate, unsigned channels, unsigned bit_depth);
    9660#endif
Note: See TracChangeset for help on using the changeset viewer.