Changeset bf38143 in mainline for uspace/drv/audio/sb16/dsp.h
- Timestamp:
- 2011-09-26T15:26:48Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ce1e5ea
- Parents:
- bde691c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dsp.h
rbde691c rbf38143 39 39 40 40 #include "registers.h" 41 #include "dsp_commands.h"42 41 43 #ifndef DSP_PIO_DELAY 44 #define DSP_PIO_DELAY udelay(10) 45 #endif 42 typedef 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; 46 52 47 #ifndef DSP_RETRY_COUNT48 #define DSP_RETRY_COUNT 10049 #endif50 53 51 #define DSP_RESET_RESPONSE 0xaa52 54 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(®s->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(®s->dsp_write, data);65 return EOK;66 }67 55 /*----------------------------------------------------------------------------*/ 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(®s->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(®s->dsp_data_read); 83 return EOK; 84 } 56 int sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs); 85 57 /*----------------------------------------------------------------------------*/ 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(®s->dsp_reset, 1); 90 udelay(3); /* Keep reset for 3 us */ 91 pio_write_8(®s->dsp_reset, 0); 92 } 93 /*----------------------------------------------------------------------------*/ 94 int dsp_play_direct(sb16_regs_t *regs, const uint8_t *data, size_t size, 58 int sb_dsp_play_direct(sb_dsp_t *dsp, const uint8_t *data, size_t size, 95 59 unsigned sample_rate, unsigned channels, unsigned bit_depth); 96 60 #endif
Note:
See TracChangeset
for help on using the changeset viewer.