Changeset f14e6ea in mainline


Ignore:
Timestamp:
2011-10-21T20:57:40Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
dce7e41
Parents:
7257eea6
Message:

sb16: Add interrupt handler.

Set buffer alignment to something that memalign can handle (might be wrong).

Location:
uspace/drv/audio/sb16
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/dma.h

    r7257eea6 rf14e6ea  
    4141#include <as.h>
    4242
    43 #define DMA_ALIGNENT 65536
     43#define DMA_ALIGNENT 1024
    4444
    4545/** Get physical address translation
     
    7474        if (size > PAGE_SIZE)
    7575                return NULL;
    76         /* Calculate alignment to make sure the block won't cross page
    77          * boundary */
    7876        return memalign(DMA_ALIGNENT, size);
    7977}
  • uspace/drv/audio/sb16/dsp.c

    r7257eea6 rf14e6ea  
    4242#include "dsp.h"
    4343
     44#define BUFFER_SIZE (PAGE_SIZE / 4)
    4445
    4546#ifndef DSP_RETRY_COUNT
     
    9697{
    9798        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
    99105
    100106        const uintptr_t pa = addr_to_phys(buffer);
     107        assert(pa < (1 << 25));
     108//      assert((pa & 0xffff) == 0);
    101109        /* 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);
    103111        if (ret == EOK) {
    104112                dsp->buffer.buffer_data = buffer;
    105113                dsp->buffer.buffer_position = buffer;
    106                 dsp->buffer.buffer_size = PAGE_SIZE;
     114                dsp->buffer.buffer_size = BUFFER_SIZE;
    107115                dma_prepare_channel(SB_DMA_CHAN_16, false, true, BLOCK_DMA);
    108116                /* 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);
    110118                if (ret == EOK) {
    111119                        dma_prepare_channel(
     
    154162}
    155163/*----------------------------------------------------------------------------*/
     164void 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/*----------------------------------------------------------------------------*/
    156176int sb_dsp_play_direct(sb_dsp_t *dsp, const uint8_t *data, size_t size,
    157177    unsigned sampling_rate, unsigned channels, unsigned bit_depth)
  • uspace/drv/audio/sb16/dsp.h

    r7257eea6 rf14e6ea  
    5454
    5555int sb_dsp_init(sb_dsp_t *dsp, sb16_regs_t *regs);
     56void sb_dsp_interrupt(sb_dsp_t *dsp);
    5657int sb_dsp_play_direct(sb_dsp_t *dsp, const uint8_t *data, size_t size,
    5758    unsigned sample_rate, unsigned channels, unsigned bit_depth);
  • uspace/drv/audio/sb16/dsp_commands.h

    r7257eea6 rf14e6ea  
    142142        SINGLE_DMA_16B_DA = 0xb0,     /* Followed by mode, size.low, size.high*/
    143143        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        */
    148148        AUTO_DMA_16B_AD = 0xbc,       /* Size is -1. Terminate by EXIT        */
    149149        AUTO_DMA_16B_AD_FIFO = 0xbe,  /* or switch to SINGLE_DMA              */
     
    151151        SINGLE_DMA_8B_DA = 0xc0,     /* Followed by mode, size.low, size.high */
    152152        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         */
    157157        AUTO_DMA_8B_AD = 0xcc,       /* Size is -1. Terminate by EXIT         */
    158158        AUTO_DMA_8B_AD_FIFO = 0xce,  /* or switch to SINGLE_DMA               */
  • uspace/drv/audio/sb16/main.c

    r7257eea6 rf14e6ea  
    8080static void irq_handler(ddf_dev_t *dev, ipc_callid_t iid, ipc_call_t *call)
    8181{
    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);
    8386}
    8487/*----------------------------------------------------------------------------*/
  • uspace/drv/audio/sb16/registers.h

    r7257eea6 rf14e6ea  
    4444        ioport8_t afm_data;
    4545        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 */
    4648        ioport8_t mixer_data;
    4749        ioport8_t dsp_reset;
     
    5658        ioport8_t dsp_read_status; /* Bit 7 */
    5759#define DSP_READ_READY (1 << 7)
    58         ioport8_t __reserved4; /*0xf*/
     60        ioport8_t dma16_ack; /*0xf*/
    5961        ioport8_t cd_command_data;
    6062        ioport8_t cd_status;
  • uspace/drv/audio/sb16/sb16.c

    r7257eea6 rf14e6ea  
    9696int sb16_init_mpu(sb16_drv_t *drv, void *regs, size_t size)
    9797{
     98        drv->mpu_regs = NULL;
    9899        return ENOTSUP;
    99100}
     101/*----------------------------------------------------------------------------*/
     102void 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  
    5353int sb16_init_sb16(sb16_drv_t *drv, void *regs, size_t size);
    5454int sb16_init_mpu(sb16_drv_t *drv, void *regs, size_t size);
     55void sb16_interrupt(sb16_drv_t *drv);
    5556
    5657#endif
Note: See TracChangeset for help on using the changeset viewer.