Changeset 9808edd in mainline for uspace/drv/audio/sb16/sb16.c


Ignore:
Timestamp:
2011-12-05T00:53:38Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
46117de0
Parents:
e44385d
Message:

sb16: Implement audio pcm buffer interface.

Remove startup sound.
Move dsp function initialization to sb16.c.

File:
1 edited

Legend:

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

    re44385d r9808edd  
    3030#include <str_error.h>
    3131#include <audio_mixer_iface.h>
     32#include <audio_pcm_buffer_iface.h>
    3233
    3334#include "beep.h"
     
    3839
    3940extern audio_mixer_iface_t sb_mixer_iface;
     41extern audio_pcm_buffer_iface_t sb_pcm_iface;
    4042
    4143static ddf_dev_ops_t sb_mixer_ops = {
    4244        .interfaces[AUDIO_MIXER_IFACE] = &sb_mixer_iface,
     45};
     46
     47static ddf_dev_ops_t sb_pcm_ops = {
     48        .interfaces[AUDIO_PCM_BUFFER_IFACE] = &sb_pcm_iface,
    4349};
    4450
     
    95101
    96102        /* Initialize DSP */
     103        ddf_fun_t *dsp_fun = ddf_fun_create(dev, fun_exposed, "dsp");
     104        if (!dsp_fun) {
     105                ddf_log_error("Failed to create dsp function.\n");
     106                return ENOMEM;
     107        }
     108
    97109        ret = sb_dsp_init(&sb->dsp, sb->regs, dev, dma8, dma16);
    98110        if (ret != EOK) {
     
    101113                return ret;
    102114        }
     115        dsp_fun->driver_data = &sb->dsp;
     116        dsp_fun->ops = &sb_pcm_ops;
    103117        ddf_log_note("Sound blaster DSP (%x.%x) initialized.\n",
    104118            sb->dsp.version.major, sb->dsp.version.minor);
     119
     120        ret = ddf_fun_bind(dsp_fun);
     121        if (ret != EOK) {
     122                ddf_log_error(
     123                    "Failed to bind DSP function: %s.\n", str_error(ret));
     124                dsp_fun->driver_data = NULL;
     125                ddf_fun_destroy(dsp_fun);
     126                return ret;
     127        }
    105128
    106129        /* Initialize mixer */
     
    111134        if (!mixer_fun) {
    112135                ddf_log_error("Failed to create mixer function.\n");
     136                ddf_fun_unbind(dsp_fun);
     137                dsp_fun->driver_data = NULL;
     138                ddf_fun_destroy(dsp_fun);
    113139                return ENOMEM;
    114140        }
     
    117143                ddf_log_error("Failed to initialize SB mixer: %s.\n",
    118144                    str_error(ret));
     145                ddf_fun_unbind(dsp_fun);
     146                dsp_fun->driver_data = NULL;
     147                ddf_fun_destroy(dsp_fun);
     148                ddf_fun_destroy(mixer_fun);
    119149                return ret;
    120150        }
     
    131161                mixer_fun->driver_data = NULL;
    132162                ddf_fun_destroy(mixer_fun);
     163
     164                ddf_fun_unbind(dsp_fun);
     165                dsp_fun->driver_data = NULL;
     166                ddf_fun_destroy(dsp_fun);
    133167                return ret;
    134168        }
    135 
    136         ddf_log_note("Playing startup sound.\n");
    137         sb_dsp_play(&sb->dsp, beep, beep_size, 44100, channels, 16);
    138169
    139170        return EOK;
Note: See TracChangeset for help on using the changeset viewer.