source: mainline/uspace/drv/audio/sb16/pcm_iface.c@ 350274a

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 350274a was 03362fbd, checked in by Jan Vesely <jano.vesely@…>, 13 years ago

Merge mainline changes.

Conflict resulting from bool.h → stdbool.h move and ddf structs turning opaque.
Fails to boot to shell console.

  • Property mode set to 100644
File size: 4.0 KB
Line 
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
42static inline sb_dsp_t * fun_to_dsp(ddf_fun_t *fun)
43{
44 assert(fun);
45 sb_dsp_t *dsp = ddf_fun_data_get(fun);
46 assert(dsp);
47 return dsp;
48}
49
50static 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}
56
57static unsigned sb_query_cap(ddf_fun_t *fun, audio_cap_t cap)
58{
59 return sb_dsp_query_cap(fun_to_dsp(fun), cap);
60}
61
62static int sb_test_format(ddf_fun_t *fun, unsigned *channels, unsigned *rate,
63 pcm_sample_format_t *format)
64{
65 return sb_dsp_test_format(fun_to_dsp(fun), channels, rate, format);
66}
67static int sb_get_buffer(ddf_fun_t *fun, void **buffer, size_t *size)
68{
69 return sb_dsp_get_buffer(fun_to_dsp(fun), buffer, size);
70}
71
72static int sb_get_buffer_position(ddf_fun_t *fun, size_t *size)
73{
74 return sb_dsp_get_buffer_position(fun_to_dsp(fun), size);
75}
76
77static int sb_set_event_session(ddf_fun_t *fun, async_sess_t *sess)
78{
79 return sb_dsp_set_event_session(fun_to_dsp(fun), sess);
80}
81
82static async_sess_t * sb_get_event_session(ddf_fun_t *fun)
83{
84 return sb_dsp_get_event_session(fun_to_dsp(fun));
85}
86
87static int sb_release_buffer(ddf_fun_t *fun)
88{
89 return sb_dsp_release_buffer(fun_to_dsp(fun));
90}
91
92static int sb_start_playback(ddf_fun_t *fun, unsigned frames,
93 unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
94{
95 return sb_dsp_start_playback(
96 fun_to_dsp(fun), frames, channels, sample_rate, format);
97}
98
99static int sb_stop_playback(ddf_fun_t *fun, bool immediate)
100{
101 return sb_dsp_stop_playback(fun_to_dsp(fun), immediate);
102}
103
104static int sb_start_capture(ddf_fun_t *fun, unsigned frames,
105 unsigned channels, unsigned sample_rate, pcm_sample_format_t format)
106{
107 return sb_dsp_start_capture(
108 fun_to_dsp(fun), frames, channels, sample_rate, format);
109}
110
111static int sb_stop_capture(ddf_fun_t *fun, bool immediate)
112{
113 return sb_dsp_stop_capture(fun_to_dsp(fun), immediate);
114}
115
116audio_pcm_iface_t sb_pcm_iface = {
117 .get_info_str = sb_get_info_str,
118 .test_format = sb_test_format,
119 .query_cap = sb_query_cap,
120
121 .get_buffer = sb_get_buffer,
122 .release_buffer = sb_release_buffer,
123 .set_event_session = sb_set_event_session,
124 .get_event_session = sb_get_event_session,
125 .get_buffer_pos = sb_get_buffer_position,
126
127 .start_playback = sb_start_playback,
128 .stop_playback = sb_stop_playback,
129
130 .start_capture = sb_start_capture,
131 .stop_capture = sb_stop_capture,
132};
133/**
134 * @}
135 */
Note: See TracBrowser for help on using the repository browser.