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

Changeset 25c98a8e in mainline


Ignore:
Timestamp:
2011-11-25T22:11:00Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
b67968c
Parents:
53a7fda
Message:

sb16: Implement audio mixer interface.

Move mixer fun creation and initialization to sb_init.

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

Legend:

Unmodified
Added
Removed
  • uspace/drv/audio/sb16/Makefile

    r53a7fda r25c98a8e  
    4242        main.c \
    4343        mixer.c \
     44        mixer_iface.c \
    4445        sb16.c
    4546
  • uspace/drv/audio/sb16/main.c

    r53a7fda r25c98a8e  
    120120
    121121
    122         ddf_fun_t *dsp_fun = NULL, *mixer_fun = NULL;
     122        ddf_fun_t *dsp_fun = NULL;
    123123#define CHECK_RET_UNREG_DEST_RETURN(ret, msg...) \
    124124if (ret != EOK) { \
     
    126126        if (dsp_fun) \
    127127                ddf_fun_destroy(dsp_fun); \
    128         if (mixer_fun) \
    129                 ddf_fun_destroy(mixer_fun); \
    130128        unregister_interrupt_handler(device, irq); \
    131129        return ret; \
     
    139137        ret = dsp_fun ? EOK : ENOMEM;
    140138        CHECK_RET_UNREG_DEST_RETURN(ret, "Failed to create dsp function.");
    141 
    142 
    143         mixer_fun = ddf_fun_create(device, fun_exposed, "mixer");
    144         ret = dsp_fun ? EOK : ENOMEM;
    145         CHECK_RET_UNREG_DEST_RETURN(ret, "Failed to create mixer function.");
    146139
    147140        ret = sb16_init_sb16(
     
    154147            "Failed to bind dsp function: %s.\n", str_error(ret));
    155148
    156         ret = ddf_fun_bind(mixer_fun);
    157         CHECK_RET_UNREG_DEST_RETURN(ret,
    158             "Failed to bind mixer function: %s.\n", str_error(ret));
    159 
    160149        /* Everything's OK assign driver_data. */
    161         mixer_fun->driver_data = soft_state;
    162150        dsp_fun->driver_data = soft_state;
    163151
  • uspace/drv/audio/sb16/sb16.c

    r53a7fda r25c98a8e  
    2929#include <errno.h>
    3030#include <str_error.h>
     31#include <audio_mixer_iface.h>
    3132
    3233#include "beep.h"
     
    3536#include "dsp.h"
    3637#include "sb16.h"
     38
     39extern audio_mixer_iface_t sb_mixer_iface;
     40
     41static ddf_dev_ops_t sb_mixer_ops = {
     42        .interfaces[AUDIO_MIXER_IFACE] = &sb_mixer_iface,
     43};
    3744
    3845/* ISA interrupts should be edge-triggered so there should be no need for
     
    8592            sb->dsp.version.major, sb->dsp.version.minor);
    8693
     94        ddf_fun_t *mixer_fun = ddf_fun_create(dev, fun_exposed, "mixer");
     95        if (!mixer_fun) {
     96                ddf_log_error("Failed to create mixer function.\n");
     97                return ENOMEM;
     98        }
    8799        ret = sb_mixer_init(&sb->mixer, sb->regs, mixer_type);
    88100        if (ret != EOK) {
     
    91103                return ret;
    92104        }
     105
    93106        ddf_log_note("Initialized mixer: %s.\n",
    94107            sb_mixer_type_str(sb->mixer.type));
     108        mixer_fun->driver_data = &sb->mixer;
     109        mixer_fun->ops = &sb_mixer_ops;
     110
     111        ret = ddf_fun_bind(mixer_fun);
     112        if (ret != EOK) {
     113                ddf_log_error(
     114                    "Failed to bind mixer function: %s.\n", str_error(ret));
     115                mixer_fun->driver_data = NULL;
     116                ddf_fun_destroy(mixer_fun);
     117                return ret;
     118        }
    95119
    96120        ddf_log_note("Playing startup sound.\n");
Note: See TracChangeset for help on using the changeset viewer.