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