[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 | }
|
---|
[b7c080c] | 48 | static int sb_test_format(ddf_fun_t *fun, unsigned *channels, unsigned *rate,
|
---|
| 49 | pcm_sample_format_t *format)
|
---|
| 50 | {
|
---|
| 51 | assert(fun);
|
---|
| 52 | assert(fun->driver_data);
|
---|
| 53 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 54 | return sb_dsp_test_format(dsp, channels, rate, format);
|
---|
| 55 | }
|
---|
[b497018] | 56 | static int sb_get_buffer(ddf_fun_t *fun, void **buffer, size_t *size)
|
---|
[9808edd] | 57 | {
|
---|
| 58 | assert(fun);
|
---|
| 59 | assert(fun->driver_data);
|
---|
| 60 | sb_dsp_t *dsp = fun->driver_data;
|
---|
[b497018] | 61 | return sb_dsp_get_buffer(dsp, buffer, size);
|
---|
[9808edd] | 62 | }
|
---|
[b497018] | 63 | static int sb_set_event_session(ddf_fun_t *fun, async_sess_t *sess)
|
---|
[7ca22e5] | 64 | {
|
---|
| 65 | assert(fun);
|
---|
| 66 | assert(fun->driver_data);
|
---|
| 67 | sb_dsp_t *dsp = fun->driver_data;
|
---|
[b497018] | 68 | return sb_dsp_set_event_session(dsp, sess);
|
---|
[7ca22e5] | 69 | }
|
---|
[e941bf8] | 70 |
|
---|
[b497018] | 71 | static int sb_release_buffer(ddf_fun_t *fun)
|
---|
[9808edd] | 72 | {
|
---|
| 73 | assert(fun);
|
---|
| 74 | assert(fun->driver_data);
|
---|
| 75 | sb_dsp_t *dsp = fun->driver_data;
|
---|
[b497018] | 76 | return sb_dsp_release_buffer(dsp);
|
---|
[9808edd] | 77 | }
|
---|
[e941bf8] | 78 |
|
---|
[57e8b3b] | 79 | static int sb_start_playback(ddf_fun_t *fun, unsigned frames,
|
---|
[346643c] | 80 | unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
|
---|
[9808edd] | 81 | {
|
---|
| 82 | assert(fun);
|
---|
| 83 | assert(fun->driver_data);
|
---|
| 84 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 85 | return sb_dsp_start_playback(
|
---|
[57e8b3b] | 86 | dsp, frames, channels, sample_rate, format);
|
---|
[9808edd] | 87 | }
|
---|
[e941bf8] | 88 |
|
---|
[b497018] | 89 | static int sb_stop_playback(ddf_fun_t *fun)
|
---|
[9808edd] | 90 | {
|
---|
| 91 | assert(fun);
|
---|
| 92 | assert(fun->driver_data);
|
---|
| 93 | sb_dsp_t *dsp = fun->driver_data;
|
---|
[b497018] | 94 | return sb_dsp_stop_playback(dsp);
|
---|
[9808edd] | 95 | }
|
---|
[e941bf8] | 96 |
|
---|
[57e8b3b] | 97 | static int sb_start_record(ddf_fun_t *fun, unsigned frames,
|
---|
[346643c] | 98 | unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
|
---|
[9808edd] | 99 | {
|
---|
| 100 | assert(fun);
|
---|
| 101 | assert(fun->driver_data);
|
---|
| 102 | sb_dsp_t *dsp = fun->driver_data;
|
---|
| 103 | return sb_dsp_start_record(
|
---|
[57e8b3b] | 104 | dsp, frames, channels, sample_rate, format);
|
---|
[9808edd] | 105 | }
|
---|
[e941bf8] | 106 |
|
---|
[b497018] | 107 | static int sb_stop_record(ddf_fun_t *fun)
|
---|
[9808edd] | 108 | {
|
---|
| 109 | assert(fun);
|
---|
| 110 | assert(fun->driver_data);
|
---|
| 111 | sb_dsp_t *dsp = fun->driver_data;
|
---|
[b497018] | 112 | return sb_dsp_stop_record(dsp);
|
---|
[9808edd] | 113 | }
|
---|
| 114 |
|
---|
[90f05b0f] | 115 | audio_pcm_iface_t sb_pcm_iface = {
|
---|
[9808edd] | 116 | .get_info_str = sb_get_info_str,
|
---|
[b7c080c] | 117 | .test_format = sb_test_format,
|
---|
[9808edd] | 118 |
|
---|
| 119 | .get_buffer = sb_get_buffer,
|
---|
| 120 | .release_buffer = sb_release_buffer,
|
---|
[7ca22e5] | 121 | .set_event_session = sb_set_event_session,
|
---|
[9808edd] | 122 |
|
---|
| 123 | .start_playback = sb_start_playback,
|
---|
| 124 | .stop_playback = sb_stop_playback,
|
---|
| 125 |
|
---|
| 126 | .start_record = sb_start_record,
|
---|
| 127 | .stop_record = sb_stop_record
|
---|
| 128 | };
|
---|
| 129 | /**
|
---|
| 130 | * @}
|
---|
| 131 | */
|
---|