Changeset f14e6ea in mainline
- Timestamp:
- 2011-10-21T20:57:40Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- dce7e41
- Parents:
- 7257eea6
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/dma.h
r7257eea6 rf14e6ea 41 41 #include <as.h> 42 42 43 #define DMA_ALIGNENT 6553643 #define DMA_ALIGNENT 1024 44 44 45 45 /** Get physical address translation … … 74 74 if (size > PAGE_SIZE) 75 75 return NULL; 76 /* Calculate alignment to make sure the block won't cross page77 * boundary */78 76 return memalign(DMA_ALIGNENT, size); 79 77 } -
uspace/drv/audio/sb16/dsp.c
r7257eea6 rf14e6ea 42 42 #include "dsp.h" 43 43 44 #define BUFFER_SIZE (PAGE_SIZE / 4) 44 45 45 46 #ifndef DSP_RETRY_COUNT … … 96 97 { 97 98 assert(dsp); 98 uint8_t *buffer = malloc24(PAGE_SIZE); 99 uint8_t *buffer = malloc24(BUFFER_SIZE); 100 if (buffer == NULL) { 101 ddf_log_error("Failed to allocate buffer.\n"); 102 return ENOMEM; 103 } 104 99 105 100 106 const uintptr_t pa = addr_to_phys(buffer); 107 assert(pa < (1 << 25)); 108 // assert((pa & 0xffff) == 0); 101 109 /* Set 16 bit channel */ 102 const int ret = dma_setup_channel(SB_DMA_CHAN_16, pa, PAGE_SIZE);110 const int ret = dma_setup_channel(SB_DMA_CHAN_16, pa, BUFFER_SIZE); 103 111 if (ret == EOK) { 104 112 dsp->buffer.buffer_data = buffer; 105 113 dsp->buffer.buffer_position = buffer; 106 dsp->buffer.buffer_size = PAGE_SIZE;114 dsp->buffer.buffer_size = BUFFER_SIZE; 107 115 dma_prepare_channel(SB_DMA_CHAN_16, false, true, BLOCK_DMA); 108 116 /* Set 8bit channel */ 109 const int ret = dma_setup_channel(SB_DMA_CHAN_8, pa, PAGE_SIZE);117 const int ret = dma_setup_channel(SB_DMA_CHAN_8, pa, BUFFER_SIZE); 110 118 if (ret == EOK) { 111 119 dma_prepare_channel( … … 154 162 } 155 163 /*----------------------------------------------------------------------------*/ 164 void sb_dsp_interrupt(sb_dsp_t *dsp) 165 { 166 assert(dsp); 167 /* We don't really care about the mode of transport, so ack both */ 168 if (dsp->version.major >= 4) { 169 /* ACK dma16 transfer interrupt */ 170 pio_read_8(&dsp->regs->dma16_ack); 171 } 172 /* ACK dma8 transfer interrupt */ 173 pio_read_8(&dsp->regs->dsp_read_status); 174 } 175 /*----------------------------------------------------------------------------*/ 156 176 int sb_dsp_play_direct(sb_dsp_t *dsp, const uint8_t *data, size_t size, 157 177 unsigned sampling_rate, unsigned channels, unsigned bit_depth) -
uspace/drv/audio/sb16/dsp.h
r7257eea6 rf14e6ea 54 54 55 55 int sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs); 56 void sb_dsp_interrupt(sb_dsp_t *dsp); 56 57 int sb_dsp_play_direct(sb_dsp_t *dsp, const uint8_t *data, size_t size, 57 58 unsigned sample_rate, unsigned channels, unsigned bit_depth); -
uspace/drv/audio/sb16/dsp_commands.h
r7257eea6 rf14e6ea 142 142 SINGLE_DMA_16B_DA = 0xb0, /* Followed by mode, size.low, size.high*/ 143 143 SINGLE_DMA_16B_DA_FIFO = 0xb2,/* mode format is: */ 144 AUTO_DMA_16B_DA = 0xb4, /* 0x00 - unsigned mono 145 AUTO_DMA_16B_DA_FIFO = 0xb6, /* 0x10 - signed mono 146 SINGLE_DMA_16B_AD = 0xb8, /* 0x20 - unsigned stereo 147 SINGLE_DMA_16B_AD_FIFO = 0xba,/* 0x30 - signed stereo 144 AUTO_DMA_16B_DA = 0xb4, /* 0x00 - unsigned mono 8bit */ 145 AUTO_DMA_16B_DA_FIFO = 0xb6, /* 0x10 - signed mono 16bit */ 146 SINGLE_DMA_16B_AD = 0xb8, /* 0x20 - unsigned stereo 8bit */ 147 SINGLE_DMA_16B_AD_FIFO = 0xba,/* 0x30 - signed stereo 16bit */ 148 148 AUTO_DMA_16B_AD = 0xbc, /* Size is -1. Terminate by EXIT */ 149 149 AUTO_DMA_16B_AD_FIFO = 0xbe, /* or switch to SINGLE_DMA */ … … 151 151 SINGLE_DMA_8B_DA = 0xc0, /* Followed by mode, size.low, size.high */ 152 152 SINGLE_DMA_8B_DA_FIFO = 0xc2,/* mode format is: */ 153 AUTO_DMA_8B_DA = 0xc4, /* 0x00 - unsigned mono 154 AUTO_DMA_8B_DA_FIFO = 0xc6, /* 0x10 - signed mono 155 SINGLE_DMA_8B_AD = 0xc8, /* 0x20 - unsigned stereo 156 SINGLE_DMA_8B_AD_FIFO = 0xca,/* 0x30 - signed stereo 153 AUTO_DMA_8B_DA = 0xc4, /* 0x00 - unsigned mono 8bit */ 154 AUTO_DMA_8B_DA_FIFO = 0xc6, /* 0x10 - signed mono 16bit */ 155 SINGLE_DMA_8B_AD = 0xc8, /* 0x20 - unsigned stereo 8bit */ 156 SINGLE_DMA_8B_AD_FIFO = 0xca,/* 0x30 - signed stereo 16bit */ 157 157 AUTO_DMA_8B_AD = 0xcc, /* Size is -1. Terminate by EXIT */ 158 158 AUTO_DMA_8B_AD_FIFO = 0xce, /* or switch to SINGLE_DMA */ -
uspace/drv/audio/sb16/main.c
r7257eea6 rf14e6ea 80 80 static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call) 81 81 { 82 ddf_log_note("SB16 IRQ handler.\n"); 82 assert(dev); 83 sb16_drv_t *sb = dev->driver_data; 84 assert(sb); 85 sb16_interrupt(sb); 83 86 } 84 87 /*----------------------------------------------------------------------------*/ -
uspace/drv/audio/sb16/registers.h
r7257eea6 rf14e6ea 44 44 ioport8_t afm_data; 45 45 ioport8_t mixer_address; 46 #define MIXER_IRQ_ADDRESS 0x82 /* The Interrupt Status register, addressed as 47 * register 82h on the Mixer register map p.27 */ 46 48 ioport8_t mixer_data; 47 49 ioport8_t dsp_reset; … … 56 58 ioport8_t dsp_read_status; /* Bit 7 */ 57 59 #define DSP_READ_READY (1 << 7) 58 ioport8_t __reserved4; /*0xf*/60 ioport8_t dma16_ack; /*0xf*/ 59 61 ioport8_t cd_command_data; 60 62 ioport8_t cd_status; -
uspace/drv/audio/sb16/sb16.c
r7257eea6 rf14e6ea 96 96 int sb16_init_mpu(sb16_drv_t *drv, void *regs, size_t size) 97 97 { 98 drv->mpu_regs = NULL; 98 99 return ENOTSUP; 99 100 } 101 /*----------------------------------------------------------------------------*/ 102 void sb16_interrupt(sb16_drv_t *drv) 103 { 104 assert(drv); 105 ddf_log_note("SB16 interrupt.\n"); 106 /* The acknowledgment of interrupts on DSP version 4.xx is different; 107 * It can contain MPU-401 indicator and DMA16 transfers are acked 108 * differently */ 109 if (drv->dsp.version.major >= 4) { 110 pio_write_8(&drv->regs->mixer_address, MIXER_IRQ_ADDRESS); 111 const uint8_t irq_mask = pio_read_8(&drv->regs->mixer_data); 112 ddf_log_note("SB16 IRQ mask %hhx.\n", irq_mask); 113 /* Third bit is MPU-401 interrupt */ 114 if (irq_mask & 0x4) { 115 return; 116 } 117 } 118 sb_dsp_interrupt(&drv->dsp); 119 120 } -
uspace/drv/audio/sb16/sb16.h
r7257eea6 rf14e6ea 53 53 int sb16_init_sb16(sb16_drv_t *drv, void *regs, size_t size); 54 54 int sb16_init_mpu(sb16_drv_t *drv, void *regs, size_t size); 55 void sb16_interrupt(sb16_drv_t *drv); 55 56 56 57 #endif
Note:
See TracChangeset
for help on using the changeset viewer.