FreeBSD kernel sound device code
feeder.h
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2005-2009 Ariff Abdullah <ariff@FreeBSD.org>
5 * Copyright (c) 1999 Cameron Grant <cg@FreeBSD.org>
6 * All rights reserved.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * $FreeBSD$
30 */
31
33 u_int32_t type;
34 u_int32_t in, out;
35 u_int32_t flags;
36 int idx;
37};
38
42 void *data;
43};
44
45struct pcm_feeder {
47 int align;
49 void *data;
50 struct feeder_class *class;
52
53};
54
55void feeder_register(void *p);
57
58u_int32_t snd_fmtscore(u_int32_t fmt);
59u_int32_t snd_fmtbestbit(u_int32_t fmt, u_int32_t *fmts);
60u_int32_t snd_fmtbestchannel(u_int32_t fmt, u_int32_t *fmts);
61u_int32_t snd_fmtbest(u_int32_t fmt, u_int32_t *fmts);
62
63int chn_addfeeder(struct pcm_channel *c, struct feeder_class *fc,
64 struct pcm_feederdesc *desc);
65int chn_removefeeder(struct pcm_channel *c);
66struct pcm_feeder *chn_findfeeder(struct pcm_channel *c, u_int32_t type);
67void feeder_printchain(struct pcm_feeder *head);
68int feeder_chain(struct pcm_channel *);
69
70#define FEEDER_DECLARE(feeder, pdata) \
71static struct feeder_class feeder ## _class = { \
72 .name = #feeder, \
73 .methods = feeder ## _methods, \
74 .size = sizeof(struct pcm_feeder), \
75 .desc = feeder ## _desc, \
76 .data = pdata, \
77}; \
78SYSINIT(feeder, SI_SUB_DRIVERS, SI_ORDER_ANY, feeder_register, \
79 &feeder ## _class)
80
81enum {
90};
91
92/* feeder_format */
93enum {
95};
96
97/* feeder_mixer */
98enum {
101
102/* feeder_rate */
103enum {
109
110#define FEEDRATE_RATEMIN 1
111#define FEEDRATE_RATEMAX 2016000 /* 48000 * 42 */
112#define FEEDRATE_MIN 1
113#define FEEDRATE_MAX 0x7fffff /* sign 24bit ~ 8ghz ! */
114#define FEEDRATE_ROUNDHZ 25
115#define FEEDRATE_ROUNDHZ_MIN 0
116#define FEEDRATE_ROUNDHZ_MAX 500
117
118extern int feeder_rate_min;
119extern int feeder_rate_max;
120extern int feeder_rate_round;
121extern int feeder_rate_quality;
122
123/* feeder_eq */
124enum {
136
137int feeder_eq_validrate(uint32_t);
138void feeder_eq_initsys(device_t);
139
140/* feeder_volume */
141enum {
148
150
151/* feeder_matrix */
152int feeder_matrix_default_id(uint32_t);
154
155uint32_t feeder_matrix_default_format(uint32_t);
156
157int feeder_matrix_format_id(uint32_t);
159
161
162int feeder_matrix_setup(struct pcm_feeder *, struct pcmchan_matrix *,
163 struct pcmchan_matrix *);
165
166/* 4Front OSS stuffs */
168 unsigned long long *);
170 unsigned long long *);
171
172#if 0
173/* feeder_matrix */
174enum {
175 FEEDMATRIX_TYPE,
176 FEEDMATRIX_RESET,
177 FEEDMATRIX_CHANNELS_IN,
178 FEEDMATRIX_CHANNELS_OUT,
179 FEEDMATRIX_SET_MAP
180};
181
182enum {
183 FEEDMATRIX_TYPE_NONE,
184 FEEDMATRIX_TYPE_AUTO,
185 FEEDMATRIX_TYPE_2X1,
186 FEEDMATRIX_TYPE_1X2,
187 FEEDMATRIX_TYPE_2X2
188};
189
190#define FEEDMATRIX_TYPE_STEREO_TO_MONO FEEDMATRIX_TYPE_2X1
191#define FEEDMATRIX_TYPE_MONO_TO_STEREO FEEDMATRIX_TYPE_1X2
192#define FEEDMATRIX_TYPE_SWAP_STEREO FEEDMATRIX_TYPE_2X2
193#define FEEDMATRIX_MAP(x, y) ((((x) & 0x3f) << 6) | ((y) & 0x3f))
194#define FEEDMATRIX_MAP_SRC(x) ((x) & 0x3f)
195#define FEEDMATRIX_MAP_DST(x) (((x) >> 6) & 0x3f)
196#endif
197
198/*
199 * By default, various feeders only deal with sign 16/32 bit native-endian
200 * since it should provide the fastest processing path. Processing 8bit samples
201 * is too noisy due to limited dynamic range, while 24bit is quite slow due to
202 * unnatural per-byte read/write. However, for debugging purposes, ensuring
203 * implementation correctness and torture test, the following can be defined:
204 *
205 * SND_FEEDER_MULTIFORMAT - Compile all type of converters, but force
206 * 8bit samples to be converted to 16bit
207 * native-endian for better dynamic range.
208 * Process 24bit samples natively.
209 * SND_FEEDER_FULL_MULTIFORMAT - Ditto, but process 8bit samples natively.
210 */
211#ifdef SND_FEEDER_FULL_MULTIFORMAT
212#undef SND_FEEDER_MULTIFORMAT
213#define SND_FEEDER_MULTIFORMAT 1
214#endif
char * desc
Definition: atiixp.c:174
unsigned int fmt
Definition: audio_soc.c:91
struct pcm_channel * c
Definition: channel_if.m:106
int type
Definition: dsp.c:386
int feeder_matrix_format_id(uint32_t)
u_int32_t snd_fmtbestchannel(u_int32_t fmt, u_int32_t *fmts)
Definition: feeder.c:402
@ FEEDRATE_QUALITY
Definition: feeder.h:106
@ FEEDRATE_CHANNELS
Definition: feeder.h:107
@ FEEDRATE_SRC
Definition: feeder.h:104
@ FEEDRATE_DST
Definition: feeder.h:105
void feeder_register(void *p)
struct feeder_class * feeder_getclass(struct pcm_feederdesc *desc)
Definition: feeder.c:224
int feeder_matrix_setup(struct pcm_feeder *, struct pcmchan_matrix *, struct pcmchan_matrix *)
@ FEEDFORMAT_CHANNELS
Definition: feeder.h:94
struct pcm_feeder * chn_findfeeder(struct pcm_channel *c, u_int32_t type)
Definition: feeder.c:270
u_int32_t snd_fmtbest(u_int32_t fmt, u_int32_t *fmts)
Definition: feeder.c:408
@ FEEDEQ_RATE
Definition: feeder.h:126
@ FEEDEQ_BYPASS
Definition: feeder.h:133
@ FEEDEQ_BASS
Definition: feeder.h:128
@ FEEDEQ_CHANNELS
Definition: feeder.h:125
@ FEEDEQ_DISABLE
Definition: feeder.h:131
@ FEEDEQ_UNKNOWN
Definition: feeder.h:134
@ FEEDEQ_PREAMP
Definition: feeder.h:129
@ FEEDEQ_TREBLE
Definition: feeder.h:127
@ FEEDEQ_ENABLE
Definition: feeder.h:132
@ FEEDEQ_STATE
Definition: feeder.h:130
void feeder_eq_initsys(device_t)
Definition: feeder_eq.c:664
@ FEEDER_MIXER
Definition: feeder.h:84
@ FEEDER_ROOT
Definition: feeder.h:82
@ FEEDER_FORMAT
Definition: feeder.h:83
@ FEEDER_LAST
Definition: feeder.h:89
@ FEEDER_VOLUME
Definition: feeder.h:87
@ FEEDER_EQ
Definition: feeder.h:86
@ FEEDER_MATRIX
Definition: feeder.h:88
@ FEEDER_RATE
Definition: feeder.h:85
uint32_t feeder_matrix_default_format(uint32_t)
int feeder_rate_max
Definition: feeder_rate.c:157
int chn_addfeeder(struct pcm_channel *c, struct feeder_class *fc, struct pcm_feederdesc *desc)
Definition: feeder.c:238
u_int32_t snd_fmtscore(u_int32_t fmt)
Definition: feeder.c:320
@ FEEDMIXER_CHANNELS
Definition: feeder.h:99
struct pcmchan_matrix * feeder_matrix_id_map(int)
void feeder_printchain(struct pcm_feeder *head)
Definition: feeder.c:442
int feeder_rate_round
Definition: feeder_rate.c:158
int feeder_matrix_default_id(uint32_t)
int feeder_matrix_oss_get_channel_order(struct pcmchan_matrix *, unsigned long long *)
struct pcmchan_matrix * feeder_matrix_format_map(uint32_t)
int feeder_rate_quality
Definition: feeder_rate.c:159
int chn_removefeeder(struct pcm_channel *c)
Definition: feeder.c:256
u_int32_t snd_fmtbestbit(u_int32_t fmt, u_int32_t *fmts)
Definition: feeder.c:396
struct pcmchan_matrix * feeder_matrix_default_channel_map(uint32_t)
int feeder_rate_min
Definition: feeder_rate.c:156
int feeder_matrix_oss_set_channel_order(struct pcmchan_matrix *, unsigned long long *)
int feeder_matrix_compare(struct pcmchan_matrix *, struct pcmchan_matrix *)
int feeder_chain(struct pcm_channel *)
Definition: feeder_chain.c:581
int feeder_eq_validrate(uint32_t)
Definition: feeder_eq.c:299
int feeder_volume_apply_matrix(struct pcm_feeder *, struct pcmchan_matrix *)
@ FEEDVOLUME_ENABLE
Definition: feeder.h:145
@ FEEDVOLUME_CLASS
Definition: feeder.h:142
@ FEEDVOLUME_BYPASS
Definition: feeder.h:146
@ FEEDVOLUME_STATE
Definition: feeder.h:144
@ FEEDVOLUME_CHANNELS
Definition: feeder.h:143
static u_int32_t fmts[]
Definition: fm801.c:112
KOBJ_CLASS_FIELDS
Definition: feeder.h:40
void * data
Definition: feeder.h:42
struct pcm_feederdesc * desc
Definition: feeder.h:41
struct pcm_feeder * source
Definition: feeder.h:51
struct pcm_feederdesc desc_static
Definition: feeder.h:48
struct pcm_feeder * parent
Definition: feeder.h:51
void * data
Definition: feeder.h:49
struct pcm_feederdesc * desc
Definition: feeder.h:48
KOBJ_FIELDS
Definition: feeder.h:46
int align
Definition: feeder.h:47
u_int32_t out
Definition: feeder.h:34
u_int32_t in
Definition: feeder.h:34
u_int32_t flags
Definition: feeder.h:35
u_int32_t type
Definition: feeder.h:33