Changeset cf083e8 in mainline
- Timestamp:
- 2011-09-25T11:23:06Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 01282fc
- Parents:
- 7d5057e
- Location:
- uspace/drv/audio/sb16
- Files:
-
- 1 added
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/audio/sb16/sb16.c
r7d5057e rcf083e8 32 32 #include "ddf_log.h" 33 33 #include "dsp_commands.h" 34 #include "dsp.h" 34 35 #include "sb16.h" 35 36 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 /*----------------------------------------------------------------------------*/64 37 /* ISA interrupts should be edge-triggered so there should be no need for 65 38 * irq code magic */ … … 83 56 ddf_log_debug("PIO registers at %p accessible.\n", drv->regs); 84 57 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); 90 59 /* "DSP takes about 100 microseconds to initialize itself" */ 91 60 udelay(100); 92 61 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 } 93 68 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); 110 71 return EIO; 111 72 } 112 73 113 74 /* Get DSP version number */ 114 sb16_dsp_write(drv, DSP_VERSION);115 d rv->dsp_version.major = sb16_dsp_read(drv);116 d rv->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); 117 78 ddf_log_note("Sound blaster DSP (%x.%x) Initialized.\n", 118 79 drv->dsp_version.major, drv->dsp_version.minor);
Note:
See TracChangeset
for help on using the changeset viewer.