Changeset c885a21 in mainline for uspace/drv/audio/sb16/sb16.c


Ignore:
Timestamp:
2011-11-14T12:38:50Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
1269160
Parents:
1b93658
Message:

sb16: Switch to new ISA bus provided DMA controller access.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/sb16.c

    r1b93658 rc885a21  
    4040static const irq_cmd_t irq_cmds[] = {{ .cmd = CMD_ACCEPT }};
    4141static 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
    4343
    4444static inline sb_mixer_type_t sb_mixer_type_by_dsp_version(
     
    5757irq_code_t * sb16_irq_code(void)
    5858{
     59        // FIXME: Remove this cast
    5960        return (irq_code_t*)&irq_code;
    6061}
    6162/*----------------------------------------------------------------------------*/
    62 int sb16_init_sb16(sb16_drv_t *drv, void *regs, size_t size)
     63int sb16_init_sb16(sb16_t *sb, void *regs, size_t size,
     64    ddf_dev_t *dev, int dma8, int dma16)
    6365{
    64         assert(drv);
     66        assert(sb);
    6567        /* Setup registers */
    66         int ret = pio_enable(regs, size, (void**)&drv->regs);
     68        int ret = pio_enable(regs, size, (void**)&sb->regs);
    6769        if (ret != EOK)
    6870                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);
    7072
    7173        /* Initialize DSP */
    72         ret = sb_dsp_init(&drv->dsp, drv->regs);
     74        ret = sb_dsp_init(&sb->dsp, sb->regs, dev, dma8, dma16);
    7375        if (ret != EOK) {
    7476                ddf_log_error("Failed to initialize SB DSP: %s.\n",
     
    7779        }
    7880        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);
    8082
    8183        /* Initialize mixer */
    8284        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);
    8486
    85         ret = sb_mixer_init(&drv->mixer, drv->regs, mixer_type);
     87        ret = sb_mixer_init(&sb->mixer, sb->regs, mixer_type);
    8688        if (ret != EOK) {
    8789                ddf_log_error("Failed to initialize SB mixer: %s.\n",
     
    9092        }
    9193        ddf_log_note("Initialized mixer: %s.\n",
    92             sb_mixer_type_str(drv->mixer.type));
     94            sb_mixer_type_str(sb->mixer.type));
    9395
    9496        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);
    9698
    9799        return EOK;
    98100}
    99101/*----------------------------------------------------------------------------*/
    100 int sb16_init_mpu(sb16_drv_t *drv, void *regs, size_t size)
     102int sb16_init_mpu(sb16_t *sb, void *regs, size_t size)
    101103{
    102         drv->mpu_regs = NULL;
     104        sb->mpu_regs = NULL;
    103105        return ENOTSUP;
    104106}
    105107/*----------------------------------------------------------------------------*/
    106 void sb16_interrupt(sb16_drv_t *drv)
     108void sb16_interrupt(sb16_t *sb)
    107109{
    108         assert(drv);
     110        assert(sb);
    109111        /* The acknowledgment of interrupts on DSP version 4.xx is different;
    110112         * It can contain MPU-401 indicator and DMA16 transfers are acked
    111113         * 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);
    115117                /* Third bit is MPU-401 interrupt */
    116118                if (irq_mask & 0x4) {
     
    120122                ddf_log_debug("SB16 interrupt.\n");
    121123        }
    122         sb_dsp_interrupt(&drv->dsp);
     124        sb_dsp_interrupt(&sb->dsp);
    123125}
Note: See TracChangeset for help on using the changeset viewer.