Changeset 01aef43 in mainline
- Timestamp:
- 2011-10-21T16:48:27Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9f351c8
- Parents:
- 1a11a16
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dma_controller.c
r1a11a16 r01aef43 151 151 152 152 typedef struct dma_controller { 153 dma_channel_t channel [8];153 dma_channel_t channels[8]; 154 154 dma_page_regs_t *page_table; 155 155 dma_controller_regs_first_t *first; … … 157 157 } dma_controller_t; 158 158 159 static constdma_controller_t controller_8237 = {160 .channel = {159 static dma_controller_t controller_8237 = { 160 .channels = { 161 161 { (uint8_t*)0x00, (uint8_t*)0x01, (uint8_t*)0x87 }, 162 162 { (uint8_t*)0x02, (uint8_t*)0x03, (uint8_t*)0x83 }, … … 209 209 /* Low byte */ 210 210 value = pa & 0xff; 211 pio_write_8(controller->channel [channel].offset_reg_address, value);211 pio_write_8(controller->channels[channel].offset_reg_address, value); 212 212 213 213 /* High byte */ 214 214 value = (pa >> 8) & 0xff; 215 pio_write_8(controller->channel [channel].offset_reg_address, value);215 pio_write_8(controller->channels[channel].offset_reg_address, value); 216 216 217 217 /* Page address - third byte */ 218 218 value = (pa >> 16) & 0xff; 219 pio_write_8(controller->channel [channel].offset_reg_address, value);219 pio_write_8(controller->channels[channel].offset_reg_address, value); 220 220 221 221 /* Set size -- reset flip-flop */ … … 224 224 /* Low byte */ 225 225 value = size & 0xff; 226 pio_write_8(controller->channel [channel].offset_reg_address, value);226 pio_write_8(controller->channels[channel].offset_reg_address, value); 227 227 228 228 /* High byte */ 229 229 value = (size >> 8) & 0xff; 230 pio_write_8(controller->channel [channel].offset_reg_address, value);230 pio_write_8(controller->channels[channel].offset_reg_address, value); 231 231 232 232 /* Unmask DMA request */ … … 253 253 /* Low byte */ 254 254 value = pa & 0xff; 255 pio_write_8(controller->channel [channel].offset_reg_address, value);255 pio_write_8(controller->channels[channel].offset_reg_address, value); 256 256 257 257 /* High byte */ 258 258 value = (pa >> 8) & 0xff; 259 pio_write_8(controller->channel [channel].offset_reg_address, value);259 pio_write_8(controller->channels[channel].offset_reg_address, value); 260 260 261 261 /* Page address - third byte */ 262 262 value = (pa >> 16) & 0xff; 263 pio_write_8(controller->channel [channel].offset_reg_address, value);263 pio_write_8(controller->channels[channel].offset_reg_address, value); 264 264 265 265 /* Set size -- reset flip-flop */ … … 268 268 /* Low byte */ 269 269 value = size & 0xff; 270 pio_write_8(controller->channel [channel].offset_reg_address, value);270 pio_write_8(controller->channels[channel].offset_reg_address, value); 271 271 272 272 /* High byte */ 273 273 value = (size >> 8) & 0xff; 274 pio_write_8(controller->channel [channel].offset_reg_address, value);274 pio_write_8(controller->channels[channel].offset_reg_address, value); 275 275 276 276 /* Unmask DMA request */ -
uspace/drv/audio/sb16/dsp.c
r1a11a16 r01aef43 34 34 35 35 #include <libarch/ddi.h> 36 #include <str_error.h> 36 37 37 38 #include "dma.h" … … 47 48 48 49 #define DSP_RESET_RESPONSE 0xaa 50 #define SB_DMA_CHAN_16 5 51 #define SB_DMA_CHAN_8 1 49 52 50 53 static inline int sb_dsp_read(sb_dsp_t *dsp, uint8_t *data) … … 90 93 } 91 94 /*----------------------------------------------------------------------------*/ 95 static inline int sb_setup_buffer(sb_dsp_t *dsp) 96 { 97 assert(dsp); 98 uint8_t *buffer = malloc24(PAGE_SIZE); 99 100 const uintptr_t pa = addr_to_phys(buffer); 101 const int ret = dma_setup_channel(SB_DMA_CHAN_16, pa, PAGE_SIZE); 102 if (ret == EOK) { 103 dsp->buffer.buffer_data = buffer; 104 dsp->buffer.buffer_position = buffer; 105 dsp->buffer.buffer_size = PAGE_SIZE; 106 } else { 107 ddf_log_error("Failed to setup DMA buffer %s.\n", 108 str_error(ret)); 109 free24(buffer); 110 } 111 return ret; 112 } 113 /*----------------------------------------------------------------------------*/ 92 114 int sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs) 93 115 { … … 112 134 sb_dsp_read(dsp, &dsp->version.major); 113 135 sb_dsp_read(dsp, &dsp->version.minor); 114 return EOK; 136 137 return ret; 115 138 } 116 139 /*----------------------------------------------------------------------------*/ … … 130 153 return EOK; 131 154 } 155 /*----------------------------------------------------------------------------*/ 156 int sb_dsp_play(sb_dsp_t *dsp, const uint8_t *data, size_t size, 157 unsigned sampling_rate, unsigned channels, unsigned bit_depth) 158 { 159 assert(dsp); 160 if (!data) 161 return EOK; 162 163 /* Check supported parameters */ 164 if (bit_depth != 8 && bit_depth != 16) 165 return ENOTSUP; 166 if (channels != 1 && channels != 2) 167 return ENOTSUP; 168 169 const int ret = sb_setup_buffer(dsp); 170 171 return ret; 172 } 132 173 /** 133 174 * @} -
uspace/drv/audio/sb16/dsp.h
r1a11a16 r01aef43 46 46 uint8_t minor; 47 47 } version; 48 uint8_t *data_buffer; 49 uint8_t *buffer_position; 50 size_t buffer_size; 48 struct { 49 uint8_t *buffer_data; 50 uint8_t *buffer_position; 51 size_t buffer_size; 52 } buffer; 51 53 } sb_dsp_t; 52 54 53 54 55 /*----------------------------------------------------------------------------*/56 55 int sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs); 57 /*----------------------------------------------------------------------------*/58 56 int sb_dsp_play_direct(sb_dsp_t *dsp, const uint8_t *data, size_t size, 59 57 unsigned sample_rate, unsigned channels, unsigned bit_depth); 58 int sb_dsp_play(sb_dsp_t *dsp, const uint8_t *data, size_t size, 59 unsigned sample_rate, unsigned channels, unsigned bit_depth); 60 60 61 #endif 61 62 /**
Note:
See TracChangeset
for help on using the changeset viewer.