Changeset cf083e8 in mainline


Ignore:
Timestamp:
2011-09-25T11:23:06Z (13 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
01282fc
Parents:
7d5057e
Message:

sb16: Move DSP routines to separate header.

Location:
uspace/drv/audio/sb16
Files:
1 added
1 edited

Legend:

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

    r7d5057e rcf083e8  
    3232#include "ddf_log.h"
    3333#include "dsp_commands.h"
     34#include "dsp.h"
    3435#include "sb16.h"
    3536
    36 #define PIO_DELAY udelay(10)
    37 
    38 
    39 static inline void sb16_dsp_write(sb16_drv_t *drv, uint8_t data)
    40 {
    41         assert(drv);
    42         uint8_t status;
    43         do {
    44                 PIO_DELAY;
    45                 status = pio_read_8(&drv->regs->dsp_write);
    46         } while ((status & DSP_WRITE_BUSY) != 0);
    47         PIO_DELAY;
    48         pio_write_8(&drv->regs->dsp_write, data);
    49 }
    50 /*----------------------------------------------------------------------------*/
    51 static inline uint8_t sb16_dsp_read(sb16_drv_t *drv)
    52 {
    53         assert(drv);
    54         uint8_t status;
    55         do {
    56                 PIO_DELAY;
    57                 status = pio_read_8(&drv->regs->dsp_read_status);
    58         } while ((status & DSP_READ_READY) == 0);
    59 
    60         PIO_DELAY;
    61         return pio_read_8(&drv->regs->dsp_data_read);
    62 }
    63 /*----------------------------------------------------------------------------*/
    6437/* ISA interrupts should be edge-triggered so there should be no need for
    6538 * irq code magic */
     
    8356        ddf_log_debug("PIO registers at %p accessible.\n", drv->regs);
    8457
    85         /* Reset DSP, see Chapter 2 of Sound Blaster HW programming guide */
    86         pio_write_8(&drv->regs->dsp_reset, 1);
    87         udelay(3); /* Keep reset for 3 us */
    88         pio_write_8(&drv->regs->dsp_reset, 0);
    89 
     58        dsp_reset(drv->regs);
    9059        /* "DSP takes about 100 microseconds to initialize itself" */
    9160        udelay(100);
    9261
     62        uint8_t response;
     63        ret = dsp_read(drv->regs, &response);
     64        if (ret != EOK) {
     65                ddf_log_error("Failed to read DSP reset response value.\n");
     66                return ret;
     67        }
    9368
    94         unsigned attempts = 100;
    95         uint8_t status;
    96         do {
    97                 PIO_DELAY;
    98                 status = pio_read_8(&drv->regs->dsp_read_status);
    99         } while (--attempts && ((status & DSP_READ_READY) == 0));
    100 
    101         if (status & DSP_READ_READY) {
    102                 const uint8_t response = sb16_dsp_read(drv);
    103                 if (response != 0xaa) {
    104                         ddf_log_error("Invalid DSP reset response: %x.\n",
    105                             response);
    106                         return EIO;
    107                 }
    108         } else {
    109                 ddf_log_error("Failed to reset Sound Blaster DSP.\n");
     69        if (response != DSP_RESET_RESPONSE) {
     70                ddf_log_error("Invalid DSP reset response: %x.\n", response);
    11071                return EIO;
    11172        }
    11273
    11374        /* Get DSP version number */
    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);
     75        dsp_write(drv->regs, DSP_VERSION);
     76        dsp_read(drv->regs, &drv->dsp_version.major);
     77        dsp_read(drv->regs, &drv->dsp_version.minor);
    11778        ddf_log_note("Sound blaster DSP (%x.%x) Initialized.\n",
    11879            drv->dsp_version.major, drv->dsp_version.minor);
Note: See TracChangeset for help on using the changeset viewer.