[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>
|
---|
[ea6c838] | 38 | #include <pcm/sample_format.h>
|
---|
[9808edd] | 39 |
|
---|
| 40 | #include "dsp.h"
|
---|
| 41 |
|
---|
[aae11d0] | 42 | static inline sb_dsp_t * fun_to_dsp(ddf_fun_t *fun)
|
---|
| 43 | {
|
---|
| 44 | assert(fun);
|
---|
[03362fbd] | 45 | sb_dsp_t *dsp = ddf_fun_data_get(fun);
|
---|
| 46 | assert(dsp);
|
---|
| 47 | return dsp;
|
---|
[aae11d0] | 48 | }
|
---|
| 49 |
|
---|
[9808edd] | 50 | static int sb_get_info_str(ddf_fun_t *fun, const char** name)
|
---|
| 51 | {
|
---|
| 52 | if (name)
|
---|
| 53 | *name = "SB 16 DSP";
|
---|
| 54 | return EOK;
|
---|
| 55 | }
|
---|
[f0241bda] | 56 |
|
---|
| 57 | static unsigned sb_query_cap(ddf_fun_t *fun, audio_cap_t cap)
|
---|
| 58 | {
|
---|
[aae11d0] | 59 | return sb_dsp_query_cap(fun_to_dsp(fun), cap);
|
---|
[f0241bda] | 60 | }
|
---|
| 61 |
|
---|
[b7c080c] | 62 | static int sb_test_format(ddf_fun_t *fun, unsigned *channels, unsigned *rate,
|
---|
| 63 | pcm_sample_format_t *format)
|
---|
| 64 | {
|
---|
[aae11d0] | 65 | return sb_dsp_test_format(fun_to_dsp(fun), channels, rate, format);
|
---|
[b7c080c] | 66 | }
|
---|
[b497018] | 67 | static int sb_get_buffer(ddf_fun_t *fun, void **buffer, size_t *size)
|
---|
[9808edd] | 68 | {
|
---|
[aae11d0] | 69 | return sb_dsp_get_buffer(fun_to_dsp(fun), buffer, size);
|
---|
[9808edd] | 70 | }
|
---|
[1ba95ba] | 71 |
|
---|
| 72 | static int sb_get_buffer_position(ddf_fun_t *fun, size_t *size)
|
---|
| 73 | {
|
---|
[aae11d0] | 74 | return sb_dsp_get_buffer_position(fun_to_dsp(fun), size);
|
---|
[1ba95ba] | 75 | }
|
---|
| 76 |
|
---|
[b497018] | 77 | static int sb_set_event_session(ddf_fun_t *fun, async_sess_t *sess)
|
---|
[7ca22e5] | 78 | {
|
---|
[aae11d0] | 79 | return sb_dsp_set_event_session(fun_to_dsp(fun), sess);
|
---|
[7ca22e5] | 80 | }
|
---|
[e941bf8] | 81 |
|
---|
[018ab50] | 82 | static async_sess_t * sb_get_event_session(ddf_fun_t *fun)
|
---|
| 83 | {
|
---|
[aae11d0] | 84 | return sb_dsp_get_event_session(fun_to_dsp(fun));
|
---|
[018ab50] | 85 | }
|
---|
| 86 |
|
---|
[b497018] | 87 | static int sb_release_buffer(ddf_fun_t *fun)
|
---|
[9808edd] | 88 | {
|
---|
[aae11d0] | 89 | return sb_dsp_release_buffer(fun_to_dsp(fun));
|
---|
[9808edd] | 90 | }
|
---|
[e941bf8] | 91 |
|
---|
[57e8b3b] | 92 | static int sb_start_playback(ddf_fun_t *fun, unsigned frames,
|
---|
[346643c] | 93 | unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
|
---|
[9808edd] | 94 | {
|
---|
| 95 | return sb_dsp_start_playback(
|
---|
[aae11d0] | 96 | fun_to_dsp(fun), frames, channels, sample_rate, format);
|
---|
[9808edd] | 97 | }
|
---|
[e941bf8] | 98 |
|
---|
[92b638c] | 99 | static int sb_stop_playback(ddf_fun_t *fun, bool immediate)
|
---|
[9808edd] | 100 | {
|
---|
[92b638c] | 101 | return sb_dsp_stop_playback(fun_to_dsp(fun), immediate);
|
---|
[9808edd] | 102 | }
|
---|
[e941bf8] | 103 |
|
---|
[d86c9736] | 104 | static int sb_start_capture(ddf_fun_t *fun, unsigned frames,
|
---|
[346643c] | 105 | unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
|
---|
[9808edd] | 106 | {
|
---|
[d86c9736] | 107 | return sb_dsp_start_capture(
|
---|
[aae11d0] | 108 | fun_to_dsp(fun), frames, channels, sample_rate, format);
|
---|
[9808edd] | 109 | }
|
---|
[e941bf8] | 110 |
|
---|
[92b638c] | 111 | static int sb_stop_capture(ddf_fun_t *fun, bool immediate)
|
---|
[9808edd] | 112 | {
|
---|
[92b638c] | 113 | return sb_dsp_stop_capture(fun_to_dsp(fun), immediate);
|
---|
[9808edd] | 114 | }
|
---|
| 115 |
|
---|
[90f05b0f] | 116 | audio_pcm_iface_t sb_pcm_iface = {
|
---|
[9808edd] | 117 | .get_info_str = sb_get_info_str,
|
---|
[b7c080c] | 118 | .test_format = sb_test_format,
|
---|
[f0241bda] | 119 | .query_cap = sb_query_cap,
|
---|
[9808edd] | 120 |
|
---|
| 121 | .get_buffer = sb_get_buffer,
|
---|
| 122 | .release_buffer = sb_release_buffer,
|
---|
[7ca22e5] | 123 | .set_event_session = sb_set_event_session,
|
---|
[018ab50] | 124 | .get_event_session = sb_get_event_session,
|
---|
[1ba95ba] | 125 | .get_buffer_pos = sb_get_buffer_position,
|
---|
[9808edd] | 126 |
|
---|
| 127 | .start_playback = sb_start_playback,
|
---|
| 128 | .stop_playback = sb_stop_playback,
|
---|
| 129 |
|
---|
[d86c9736] | 130 | .start_capture = sb_start_capture,
|
---|
| 131 | .stop_capture = sb_stop_capture,
|
---|
[9808edd] | 132 | };
|
---|
| 133 | /**
|
---|
| 134 | * @}
|
---|
| 135 | */
|
---|