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