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