Changeset c885a21 in mainline for uspace/drv/audio/sb16/sb16.c
- Timestamp:
- 2011-11-14T12:38:50Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1269160
- Parents:
- 1b93658
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/sb16.c
r1b93658 rc885a21 40 40 static const irq_cmd_t irq_cmds[] = {{ .cmd = CMD_ACCEPT }}; 41 41 static const irq_code_t irq_code = 42 { .cmdcount = 1, .cmds = (irq_cmd_t*)irq_cmds }; 42 { .cmdcount = 1, .cmds = (irq_cmd_t*)irq_cmds }; // FIXME: Remove cast 43 43 44 44 static inline sb_mixer_type_t sb_mixer_type_by_dsp_version( … … 57 57 irq_code_t * sb16_irq_code(void) 58 58 { 59 // FIXME: Remove this cast 59 60 return (irq_code_t*)&irq_code; 60 61 } 61 62 /*----------------------------------------------------------------------------*/ 62 int sb16_init_sb16(sb16_drv_t *drv, void *regs, size_t size) 63 int sb16_init_sb16(sb16_t *sb, void *regs, size_t size, 64 ddf_dev_t *dev, int dma8, int dma16) 63 65 { 64 assert( drv);66 assert(sb); 65 67 /* Setup registers */ 66 int ret = pio_enable(regs, size, (void**)& drv->regs);68 int ret = pio_enable(regs, size, (void**)&sb->regs); 67 69 if (ret != EOK) 68 70 return ret; 69 ddf_log_debug("PIO registers at %p accessible.\n", drv->regs);71 ddf_log_debug("PIO registers at %p accessible.\n", sb->regs); 70 72 71 73 /* Initialize DSP */ 72 ret = sb_dsp_init(& drv->dsp, drv->regs);74 ret = sb_dsp_init(&sb->dsp, sb->regs, dev, dma8, dma16); 73 75 if (ret != EOK) { 74 76 ddf_log_error("Failed to initialize SB DSP: %s.\n", … … 77 79 } 78 80 ddf_log_note("Sound blaster DSP (%x.%x) initialized.\n", 79 drv->dsp.version.major, drv->dsp.version.minor);81 sb->dsp.version.major, sb->dsp.version.minor); 80 82 81 83 /* Initialize mixer */ 82 84 const sb_mixer_type_t mixer_type = sb_mixer_type_by_dsp_version( 83 drv->dsp.version.major, drv->dsp.version.minor);85 sb->dsp.version.major, sb->dsp.version.minor); 84 86 85 ret = sb_mixer_init(& drv->mixer, drv->regs, mixer_type);87 ret = sb_mixer_init(&sb->mixer, sb->regs, mixer_type); 86 88 if (ret != EOK) { 87 89 ddf_log_error("Failed to initialize SB mixer: %s.\n", … … 90 92 } 91 93 ddf_log_note("Initialized mixer: %s.\n", 92 sb_mixer_type_str( drv->mixer.type));94 sb_mixer_type_str(sb->mixer.type)); 93 95 94 96 ddf_log_note("Playing startup sound.\n"); 95 sb_dsp_play(& drv->dsp, beep, beep_size, 44100, 1, 8);97 sb_dsp_play(&sb->dsp, beep, beep_size, 44100, 1, 8); 96 98 97 99 return EOK; 98 100 } 99 101 /*----------------------------------------------------------------------------*/ 100 int sb16_init_mpu(sb16_ drv_t *drv, void *regs, size_t size)102 int sb16_init_mpu(sb16_t *sb, void *regs, size_t size) 101 103 { 102 drv->mpu_regs = NULL;104 sb->mpu_regs = NULL; 103 105 return ENOTSUP; 104 106 } 105 107 /*----------------------------------------------------------------------------*/ 106 void sb16_interrupt(sb16_ drv_t *drv)108 void sb16_interrupt(sb16_t *sb) 107 109 { 108 assert( drv);110 assert(sb); 109 111 /* The acknowledgment of interrupts on DSP version 4.xx is different; 110 112 * It can contain MPU-401 indicator and DMA16 transfers are acked 111 113 * differently */ 112 if ( drv->dsp.version.major >= 4) {113 pio_write_8(& drv->regs->mixer_address, MIXER_IRQ_STATUS_ADDRESS);114 const uint8_t irq_mask = pio_read_8(& drv->regs->mixer_data);114 if (sb->dsp.version.major >= 4) { 115 pio_write_8(&sb->regs->mixer_address, MIXER_IRQ_STATUS_ADDRESS); 116 const uint8_t irq_mask = pio_read_8(&sb->regs->mixer_data); 115 117 /* Third bit is MPU-401 interrupt */ 116 118 if (irq_mask & 0x4) { … … 120 122 ddf_log_debug("SB16 interrupt.\n"); 121 123 } 122 sb_dsp_interrupt(& drv->dsp);124 sb_dsp_interrupt(&sb->dsp); 123 125 }
Note:
See TracChangeset
for help on using the changeset viewer.