FreeBSD/Linux Kernel Cross Reference
sys/dev/auconv.h
1 /* $NetBSD: auconv.h,v 1.14 2005/12/11 12:20:53 christos Exp $ */
2
3 /*-
4 * Copyright (c) 1997 The NetBSD Foundation, Inc.
5 * All rights reserved.
6 *
7 * This code is derived from software contributed to The NetBSD Foundation
8 * by Lennart Augustsson.
9 *
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
12 * are met:
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the NetBSD
21 * Foundation, Inc. and its contributors.
22 * 4. Neither the name of The NetBSD Foundation nor the names of its
23 * contributors may be used to endorse or promote products derived
24 * from this software without specific prior written permission.
25 *
26 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
27 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
28 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
29 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
30 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
31 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
32 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
33 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
34 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
35 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
36 * POSSIBILITY OF SUCH DAMAGE.
37 */
38
39 #ifndef _SYS_DEV_AUCONV_H_
40 #define _SYS_DEV_AUCONV_H_
41 #include <dev/audio_if.h>
42
43 /* common routines for stream_filter_t */
44 extern void stream_filter_set_fetcher(stream_filter_t *, stream_fetcher_t *);
45 extern void stream_filter_set_inputbuffer(stream_filter_t *, audio_stream_t *);
46 extern stream_filter_t *auconv_nocontext_filter_factory
47 (int (*)(stream_fetcher_t *, audio_stream_t *, int));
48 extern void auconv_nocontext_filter_dtor(struct stream_filter *);
49 #define FILTER_LOOP_PROLOGUE(SRC, SRCFRAME, DST, DSTFRAME, MAXUSED) \
50 do { \
51 const uint8_t *s; \
52 uint8_t *d; \
53 s = (SRC)->outp; \
54 d = (DST)->inp; \
55 for (; audio_stream_get_used(DST) < MAXUSED \
56 && audio_stream_get_used(SRC) >= SRCFRAME; \
57 s = audio_stream_add_outp(SRC, s, SRCFRAME), \
58 d = audio_stream_add_inp(DST, d, DSTFRAME))
59 #define FILTER_LOOP_EPILOGUE(SRC, DST) \
60 (SRC)->outp = s; \
61 (DST)->inp = d; \
62 } while (/*CONSTCOND*/0)
63
64
65 /* Convert between signed and unsigned. */
66 extern stream_filter_factory_t change_sign8;
67 extern stream_filter_factory_t change_sign16;
68 /* Convert between little and big endian. */
69 extern stream_filter_factory_t swap_bytes;
70 extern stream_filter_factory_t swap_bytes_change_sign16;
71 /* Byte expansion/contraction */
72 extern stream_filter_factory_t linear8_to_linear16;
73 extern stream_filter_factory_t linear16_to_linear8;
74 /* sampling rate conversion (aurateconv.c) */
75 extern stream_filter_factory_t aurateconv;
76
77 struct audio_format {
78 /**
79 * Device-dependent audio drivers may use this field freely.
80 */
81 void *driver_data;
82
83 /**
84 * combination of AUMODE_PLAY and AUMODE_RECORD
85 */
86 int32_t mode;
87
88 /**
89 * Encoding type. AUDIO_ENCODING_*.
90 * Don't use AUDIO_ENCODING_SLINEAR/ULINEAR/LINEAR/LINEAR8
91 */
92 u_int encoding;
93
94 /**
95 * The size of valid bits in one sample.
96 * It must be <= precision.
97 */
98 u_int validbits;
99
100 /**
101 * The bit size of one sample.
102 * It must be >= validbits, and is usualy a multiple of 8.
103 */
104 u_int precision;
105
106 /**
107 * The number of channels. >= 1
108 */
109 u_int channels;
110
111 u_int channel_mask;
112 #define AUFMT_UNKNOWN_POSITION 0U
113 #define AUFMT_FRONT_LEFT 0x00001U /* USB audio compatible */
114 #define AUFMT_FRONT_RIGHT 0x00002U /* USB audio compatible */
115 #define AUFMT_FRONT_CENTER 0x00004U /* USB audio compatible */
116 #define AUFMT_LOW_FREQUENCY 0x00008U /* USB audio compatible */
117 #define AUFMT_BACK_LEFT 0x00010U /* USB audio compatible */
118 #define AUFMT_BACK_RIGHT 0x00020U /* USB audio compatible */
119 #define AUFMT_FRONT_LEFT_OF_CENTER 0x00040U /* USB audio compatible */
120 #define AUFMT_FRONT_RIGHT_OF_CENTER 0x00080U /* USB audio compatible */
121 #define AUFMT_BACK_CENTER 0x00100U /* USB audio compatible */
122 #define AUFMT_SIDE_LEFT 0x00200U /* USB audio compatible */
123 #define AUFMT_SIDE_RIGHT 0x00400U /* USB audio compatible */
124 #define AUFMT_TOP_CENTER 0x00800U /* USB audio compatible */
125 #define AUFMT_TOP_FRONT_LEFT 0x01000U
126 #define AUFMT_TOP_FRONT_CENTER 0x02000U
127 #define AUFMT_TOP_FRONT_RIGHT 0x04000U
128 #define AUFMT_TOP_BACK_LEFT 0x08000U
129 #define AUFMT_TOP_BACK_CENTER 0x10000U
130 #define AUFMT_TOP_BACK_RIGHT 0x20000U
131
132 #define AUFMT_MONAURAL AUFMT_FRONT_CENTER
133 #define AUFMT_STEREO (AUFMT_FRONT_LEFT | AUFMT_FRONT_RIGHT)
134 #define AUFMT_SURROUND4 (AUFMT_STEREO | AUFMT_BACK_LEFT \
135 | AUFMT_BACK_RIGHT)
136 #define AUFMT_DOLBY_5_1 (AUFMT_SURROUND4 | AUFMT_FRONT_CENTER \
137 | AUFMT_LOW_FREQUENCY)
138
139 /**
140 * 0: frequency[0] is lower limit, and frequency[1] is higher limit.
141 * 1-16: frequency[0] to frequency[frequency_type-1] are valid.
142 */
143 u_int frequency_type;
144
145 #define AUFMT_MAX_FREQUENCIES 16
146 /**
147 * sampling rates
148 */
149 u_int frequency[AUFMT_MAX_FREQUENCIES];
150 };
151
152 #define AUFMT_INVALIDATE(fmt) (fmt)->mode |= 0x80000000
153 #define AUFMT_VALIDATE(fmt) (fmt)->mode &= 0x7fffffff
154 #define AUFMT_IS_VALID(fmt) (((fmt)->mode & 0x80000000) == 0)
155
156 struct audio_encoding_set;
157 extern int auconv_set_converter(const struct audio_format *, int,
158 int, const audio_params_t *, int,
159 stream_filter_list_t *);
160 extern int auconv_create_encodings(const struct audio_format *, int,
161 struct audio_encoding_set **);
162 extern int auconv_delete_encodings(struct audio_encoding_set *);
163 extern int auconv_query_encoding(const struct audio_encoding_set *,
164 audio_encoding_t *);
165
166 #endif /* !_SYS_DEV_AUCONV_H_ */
Cache object: 0d748d4f65b91f7e24a3712a0edc05c4
|