Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 413225d in mainline


Ignore:
Timestamp:
2011-11-30T21:25:05Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
ed3f8d5
Parents:
427069d
Message:

sb16: Ack interrupts in irq pseudocode.

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

Legend:

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

    r427069d r413225d  
    194194{
    195195        assert(dsp);
    196         /* We don't really care about the mode of transport, so ack both */
    197         // TODO: Move irq ACK to irq_code
    198         if (dsp->version.major >= 4) {
    199                 /* ACK dma16 transfer interrupt */
    200                 pio_read_8(&dsp->regs->dma16_ack);
    201         }
    202         /* ACK dma8 transfer interrupt */
    203         pio_read_8(&dsp->regs->dsp_read_status);
    204 
    205         const size_t remain_size = dsp->playing.size -
    206             (dsp->playing.position - dsp->playing.data);
     196        const size_t remain_size =
     197            dsp->playing.size - (dsp->playing.position - dsp->playing.data);
    207198
    208199        if (remain_size == 0) {
  • uspace/drv/audio/sb16/main.c

    r427069d r413225d  
    114114            "Failed to get resources: %s.\n", str_error(ret));
    115115
    116         irq_code_t *irq_code = sb16_irq_code();
    117         ret = register_interrupt_handler(device, irq, irq_handler, irq_code);
     116        const size_t irq_cmd_count = sb16_irq_code_size();
     117        irq_cmd_t irq_cmds[irq_cmd_count];
     118        sb16_irq_code((void*)sb_regs, dma8, dma16, irq_cmds);
     119        irq_code_t irq_code = { .cmdcount = irq_cmd_count, .cmds = irq_cmds };
     120
     121        ret = register_interrupt_handler(device, irq, irq_handler, &irq_code);
    118122        CHECK_RET_RETURN(ret,
    119123            "Failed to register irq handler: %s.\n", str_error(ret));
  • uspace/drv/audio/sb16/sb16.c

    r427069d r413225d  
    4444
    4545/* ISA interrupts should be edge-triggered so there should be no need for
    46  * irq code magic */
    47 static const irq_cmd_t irq_cmds[] = {{ .cmd = CMD_ACCEPT }};
    48 static const irq_code_t irq_code =
    49     { .cmdcount = 1, .cmds = (irq_cmd_t*)irq_cmds }; // FIXME: Remove cast
     46 * irq code magic, but we still need to ack those interrupts ASAP. */
     47static const irq_cmd_t irq_cmds[] = {
     48        { .cmd = CMD_PIO_READ_8, .dstarg = 1 }, /* Address patched at runtime */
     49        { .cmd = CMD_PIO_READ_8, .dstarg = 1 }, /* Address patched at runtime */
     50        { .cmd = CMD_ACCEPT },
     51};
    5052
    5153static inline sb_mixer_type_t sb_mixer_type_by_dsp_version(
     
    6264}
    6365/*----------------------------------------------------------------------------*/
    64 irq_code_t * sb16_irq_code(void)
     66size_t sb16_irq_code_size(void)
    6567{
    66         // FIXME: Remove this cast
    67         return (irq_code_t*)&irq_code;
     68        return sizeof(irq_cmds) / sizeof(irq_cmds[0]);
     69}
     70/*----------------------------------------------------------------------------*/
     71void sb16_irq_code(void *regs, int dma8, int dma16, irq_cmd_t cmds[])
     72{
     73        assert(regs);
     74        assert(dma8 > 0 && dma8 < 4);
     75        sb16_regs_t *registers = regs;
     76        memcpy(cmds, irq_cmds, sizeof(irq_cmds));
     77        cmds[0].addr = (void*)&registers->dsp_read_status;
     78        if (dma16 > 4 && dma16 < 8) {
     79                /* Valid dma16 */
     80                cmds[1].addr = (void*)&registers->dma16_ack;
     81        } else {
     82                cmds[1].cmd = CMD_ACCEPT;
     83        }
    6884}
    6985/*----------------------------------------------------------------------------*/
  • uspace/drv/audio/sb16/sb16.h

    r427069d r413225d  
    5050} sb16_t;
    5151
    52 irq_code_t * sb16_irq_code(void);
     52size_t sb16_irq_code_size(void);
     53void sb16_irq_code(void *regs, int dma8, int dma16, irq_cmd_t cmds[]);
    5354int sb16_init_sb16(sb16_t *sb, void *regs, size_t size,
    5455    ddf_dev_t *dev, int dma8, int dma16);
Note: See TracChangeset for help on using the changeset viewer.