[9808edd] | 1 | /*
|
---|
| 2 | * Copyright (c) 2011 Jan Vesely
|
---|
| 3 | * All rights reserved.
|
---|
| 4 | *
|
---|
| 5 | * Redistribution and use in source and binary forms, with or without
|
---|
| 6 | * modification, are permitted provided that the following conditions
|
---|
| 7 | * are met:
|
---|
| 8 | *
|
---|
| 9 | * - Redistributions of source code must retain the above copyright
|
---|
| 10 | * notice, this list of conditions and the following disclaimer.
|
---|
| 11 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 13 | * documentation and/or other materials provided with the distribution.
|
---|
| 14 | * - The name of the author may not be used to endorse or promote products
|
---|
| 15 | * derived from this software without specific prior written permission.
|
---|
| 16 | *
|
---|
| 17 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 18 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 19 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 20 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 21 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 22 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 23 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 24 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 25 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 26 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 27 | */
|
---|
| 28 | /** @addtogroup drvaudiosb16
|
---|
| 29 | * @{
|
---|
| 30 | */
|
---|
| 31 | /** @file
|
---|
| 32 | * Main routines of Creative Labs SoundBlaster 16 driver
|
---|
| 33 | */
|
---|
| 34 |
|
---|
[7ca22e5] | 35 | #include <async.h>
|
---|
[9808edd] | 36 | #include <errno.h>
|
---|
[90f05b0f] | 37 | #include <audio_pcm_iface.h>
|
---|
[346643c] | 38 | #include <pcm_sample_format.h>
|
---|
[9808edd] | 39 |
|
---|
| 40 | #include "dsp.h"
|
---|
| 41 |
|
---|
| 42 | static int sb_get_info_str(ddf_fun_t *fun, const char** name)
|
---|
| 43 | {
|
---|
| 44 | if (name)
|
---|
| 45 | *name = "SB 16 DSP";
|
---|
| 46 | return EOK;
|
---|
| 47 | }
|
---|
[e941bf8] | 48 |
|
---|
[9808edd] | 49 | static int sb_get_buffer(ddf_fun_t *fun,
|
---|
| 50 | void **buffer, size_t *size, unsigned *id)
|
---|
| 51 | {
|
---|
| 52 | assert(fun);
|
---|
| 53 | assert(fun->driver_data);
|
---|
| 54 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 55 | return sb_dsp_get_buffer(dsp, buffer, size, id);
|
---|
| 56 | }
|
---|
[7ca22e5] | 57 | static int sb_set_event_session(ddf_fun_t *fun, unsigned id, async_sess_t *sess)
|
---|
| 58 | {
|
---|
| 59 | assert(fun);
|
---|
| 60 | assert(fun->driver_data);
|
---|
| 61 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 62 | return sb_dsp_set_event_session(dsp, id, sess);
|
---|
| 63 | }
|
---|
[e941bf8] | 64 |
|
---|
[9808edd] | 65 | static int sb_release_buffer(ddf_fun_t *fun, unsigned id)
|
---|
| 66 | {
|
---|
| 67 | assert(fun);
|
---|
| 68 | assert(fun->driver_data);
|
---|
| 69 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 70 | return sb_dsp_release_buffer(dsp, id);
|
---|
| 71 | }
|
---|
[e941bf8] | 72 |
|
---|
[7ca22e5] | 73 | static int sb_start_playback(ddf_fun_t *fun, unsigned id, unsigned parts,
|
---|
[346643c] | 74 | unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
|
---|
[9808edd] | 75 | {
|
---|
| 76 | assert(fun);
|
---|
| 77 | assert(fun->driver_data);
|
---|
| 78 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 79 | return sb_dsp_start_playback(
|
---|
[346643c] | 80 | dsp, id, parts, channels, sample_rate, format);
|
---|
[9808edd] | 81 | }
|
---|
[e941bf8] | 82 |
|
---|
[9808edd] | 83 | static int sb_stop_playback(ddf_fun_t *fun, unsigned id)
|
---|
| 84 | {
|
---|
| 85 | assert(fun);
|
---|
| 86 | assert(fun->driver_data);
|
---|
| 87 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 88 | return sb_dsp_stop_playback(dsp, id);
|
---|
| 89 | }
|
---|
[e941bf8] | 90 |
|
---|
[a3ab774] | 91 | static int sb_start_record(ddf_fun_t *fun, unsigned id, unsigned parts,
|
---|
[346643c] | 92 | unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
|
---|
[9808edd] | 93 | {
|
---|
| 94 | assert(fun);
|
---|
| 95 | assert(fun->driver_data);
|
---|
| 96 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 97 | return sb_dsp_start_record(
|
---|
[346643c] | 98 | dsp, id, parts, channels, sample_rate, format);
|
---|
[9808edd] | 99 | }
|
---|
[e941bf8] | 100 |
|
---|
[9808edd] | 101 | static int sb_stop_record(ddf_fun_t *fun, unsigned id)
|
---|
| 102 | {
|
---|
| 103 | assert(fun);
|
---|
| 104 | assert(fun->driver_data);
|
---|
| 105 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 106 | return sb_dsp_stop_record(dsp, id);
|
---|
| 107 | }
|
---|
| 108 |
|
---|
[90f05b0f] | 109 | audio_pcm_iface_t sb_pcm_iface = {
|
---|
[9808edd] | 110 | .get_info_str = sb_get_info_str,
|
---|
| 111 |
|
---|
| 112 | .get_buffer = sb_get_buffer,
|
---|
| 113 | .release_buffer = sb_release_buffer,
|
---|
[7ca22e5] | 114 | .set_event_session = sb_set_event_session,
|
---|
[9808edd] | 115 |
|
---|
| 116 | .start_playback = sb_start_playback,
|
---|
| 117 | .stop_playback = sb_stop_playback,
|
---|
| 118 |
|
---|
| 119 | .start_record = sb_start_record,
|
---|
| 120 | .stop_record = sb_stop_record
|
---|
| 121 | };
|
---|
| 122 | /**
|
---|
| 123 | * @}
|
---|
| 124 | */
|
---|