Changeset 7d5057e in mainline


Ignore:
Timestamp:
2011-09-24T20:32:09Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
cf083e8
Parents:
61013bd
Message:

sb16: Fix DSP writing logic, add DSP version to main structure.

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

Legend:

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

    r61013bd r7d5057e  
    5050        ioport8_t __reserved2; /*0xb*/
    5151        ioport8_t dsp_write; /* Both command and data, bit 7 is write status */
    52 #define DSP_WRITE_READY (1 << 7)
     52#define DSP_WRITE_BUSY (1 << 7)
    5353        ioport8_t __reserved3; /*0xd*/
    5454        ioport8_t dsp_read_status; /* Bit 7 */
  • uspace/drv/audio/sb16/sb16.c

    r61013bd r7d5057e  
    3434#include "sb16.h"
    3535
     36#define PIO_DELAY udelay(10)
    3637
    37 static inline void sb16_dsp_command(sb16_drv_t *drv, dsp_command_t command)
     38
     39static inline void sb16_dsp_write(sb16_drv_t *drv, uint8_t data)
    3840{
    3941        assert(drv);
    4042        uint8_t status;
    4143        do {
     44                PIO_DELAY;
    4245                status = pio_read_8(&drv->regs->dsp_write);
    43         } while ((status & DSP_WRITE_READY) == 0);
    44 
    45         pio_write_8(&drv->regs->dsp_write, command);
     46        } while ((status & DSP_WRITE_BUSY) != 0);
     47        PIO_DELAY;
     48        pio_write_8(&drv->regs->dsp_write, data);
    4649}
    4750/*----------------------------------------------------------------------------*/
     
    5154        uint8_t status;
    5255        do {
     56                PIO_DELAY;
    5357                status = pio_read_8(&drv->regs->dsp_read_status);
    5458        } while ((status & DSP_READ_READY) == 0);
     59
     60        PIO_DELAY;
    5561        return pio_read_8(&drv->regs->dsp_data_read);
    5662}
     
    7985        /* Reset DSP, see Chapter 2 of Sound Blaster HW programming guide */
    8086        pio_write_8(&drv->regs->dsp_reset, 1);
    81         udelay(3);
     87        udelay(3); /* Keep reset for 3 us */
    8288        pio_write_8(&drv->regs->dsp_reset, 0);
     89
     90        /* "DSP takes about 100 microseconds to initialize itself" */
    8391        udelay(100);
     92
    8493
    8594        unsigned attempts = 100;
    8695        uint8_t status;
    8796        do {
     97                PIO_DELAY;
    8898                status = pio_read_8(&drv->regs->dsp_read_status);
    89                 udelay(10);
    9099        } while (--attempts && ((status & DSP_READ_READY) == 0));
    91100
     
    101110                return EIO;
    102111        }
    103         ddf_log_note("Sound blaster reset!\n");
    104 
    105112
    106113        /* Get DSP version number */
    107         sb16_dsp_command(drv, DSP_VERSION);
    108         const uint8_t major = sb16_dsp_read(drv);
    109         const uint8_t minor = sb16_dsp_read(drv);
    110         ddf_log_note("Sound blaster DSP version: %x.%x.\n", major, minor);
     114        sb16_dsp_write(drv, DSP_VERSION);
     115        drv->dsp_version.major = sb16_dsp_read(drv);
     116        drv->dsp_version.minor = sb16_dsp_read(drv);
     117        ddf_log_note("Sound blaster DSP (%x.%x) Initialized.\n",
     118            drv->dsp_version.major, drv->dsp_version.minor);
    111119
    112120
  • uspace/drv/audio/sb16/sb16.h

    r61013bd r7d5057e  
    4343        sb16_regs_t *regs;
    4444        mpu_regs_t *mpu_regs;
     45        struct {
     46                uint8_t major;
     47                uint8_t minor;
     48        } dsp_version;
    4549} sb16_drv_t;
    4650
Note: See TracChangeset for help on using the changeset viewer.