FreeBSD kernel sound device code
hdaa.h
Go to the documentation of this file.
1/*-
2 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
3 *
4 * Copyright (c) 2006 Stephane E. Potvin <sepotvin@videotron.ca>
5 * Copyright (c) 2006 Ariff Abdullah <ariff@FreeBSD.org>
6 * Copyright (c) 2008-2012 Alexander Motin <mav@FreeBSD.org>
7 * All rights reserved.
8 *
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
11 * are met:
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
19 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
24 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
25 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
26 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
27 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
28 * SUCH DAMAGE.
29 *
30 * $FreeBSD$
31 */
32
33/*
34 * Intel High Definition Audio (Audio function quirks) driver for FreeBSD.
35 */
36
37#ifndef _HDAA_QUIRKS_H_
38#define _HDAA_QUIRKS_H_
39
40#define HDAA_GPIO_SHIFT(n) (n * 3)
41#define HDAA_GPIO_MASK(n) (0x7 << (n * 3))
42#define HDAA_GPIO_KEEP(n) (0x0 << (n * 3))
43#define HDAA_GPIO_SET(n) (0x1 << (n * 3))
44#define HDAA_GPIO_CLEAR(n) (0x2 << (n * 3))
45#define HDAA_GPIO_DISABLE(n) (0x3 << (n * 3))
46#define HDAA_GPIO_INPUT(n) (0x4 << (n * 3))
47
48/* 9 - 25 = anything else */
49#define HDAA_QUIRK_SOFTPCMVOL (1 << 9)
50#define HDAA_QUIRK_FIXEDRATE (1 << 10)
51#define HDAA_QUIRK_FORCESTEREO (1 << 11)
52#define HDAA_QUIRK_EAPDINV (1 << 12)
53#define HDAA_QUIRK_SENSEINV (1 << 14)
54
55/* 26 - 31 = vrefs */
56#define HDAA_QUIRK_IVREF50 (1 << 26)
57#define HDAA_QUIRK_IVREF80 (1 << 27)
58#define HDAA_QUIRK_IVREF100 (1 << 28)
59#define HDAA_QUIRK_OVREF50 (1 << 29)
60#define HDAA_QUIRK_OVREF80 (1 << 30)
61#define HDAA_QUIRK_OVREF100 (1U << 31)
62
63#define HDAA_QUIRK_IVREF (HDAA_QUIRK_IVREF50 | HDAA_QUIRK_IVREF80 | \
64 HDAA_QUIRK_IVREF100)
65#define HDAA_QUIRK_OVREF (HDAA_QUIRK_OVREF50 | HDAA_QUIRK_OVREF80 | \
66 HDAA_QUIRK_OVREF100)
67#define HDAA_QUIRK_VREF (HDAA_QUIRK_IVREF | HDAA_QUIRK_OVREF)
68
69#define HDAA_AMP_VOL_DEFAULT (-1)
70#define HDAA_AMP_MUTE_DEFAULT (0xffffffff)
71#define HDAA_AMP_MUTE_NONE (0)
72#define HDAA_AMP_MUTE_LEFT (1 << 0)
73#define HDAA_AMP_MUTE_RIGHT (1 << 1)
74#define HDAA_AMP_MUTE_ALL (HDAA_AMP_MUTE_LEFT | HDAA_AMP_MUTE_RIGHT)
75
76#define HDAA_AMP_LEFT_MUTED(v) ((v) & (HDAA_AMP_MUTE_LEFT))
77#define HDAA_AMP_RIGHT_MUTED(v) (((v) & HDAA_AMP_MUTE_RIGHT) >> 1)
78
79/* Widget in playback receiving signal from recording. */
80#define HDAA_ADC_MONITOR (1 << 0)
81/* Input mixer widget needs volume control as destination. */
82#define HDAA_IMIX_AS_DST (2 << 0)
83
84#define HDAA_CTL_OUT 1
85#define HDAA_CTL_IN 2
86
87#define HDA_MAX_CONNS 32
88#define HDA_MAX_NAMELEN 32
89
90struct hdaa_audio_as;
91struct hdaa_audio_ctl;
92struct hdaa_chan;
93struct hdaa_devinfo;
94struct hdaa_pcm_devinfo;
95struct hdaa_widget;
96
99 int type;
103 uint32_t pflags;
107 uint32_t ossmask;
108 int unsol;
112 uint8_t *eld;
115 struct {
116 uint32_t widget_cap;
117 uint32_t outamp_cap;
118 uint32_t inamp_cap;
121 uint32_t eapdbtl;
123 union {
124 struct {
125 uint32_t config;
126 uint32_t original;
127 uint32_t newconf;
128 uint32_t cap;
129 uint32_t ctrl;
132 struct {
133 uint8_t stripecap;
136};
137
144 uint32_t muted;
145 uint32_t ossmask; /* OSS devices that may affect control. */
146 int devleft[SOUND_MIXER_NRDEVICES]; /* Left ampl in 1/4dB. */
147 int devright[SOUND_MIXER_NRDEVICES]; /* Right ampl in 1/4dB. */
148 int devmute[SOUND_MIXER_NRDEVICES]; /* Mutes per OSS device. */
149};
150
151/* Association is a group of pins bound for some special function. */
153 u_char enable;
154 u_char index;
155 u_char dir;
156 u_char pincnt;
157 u_char fakeredir;
158 u_char digital;
159 uint16_t pinset;
162 nid_t dacs[2][16];
164 int chans[2];
165 int location; /* Pins location, if all have the same */
166 int mixed; /* Mixed/multiplexed recording, not multichannel. */
168};
169
171 device_t dev;
174 int index;
177 u_char left[SOUND_MIXER_NRDEVICES];
178 u_char right[SOUND_MIXER_NRDEVICES];
179 int minamp[SOUND_MIXER_NRDEVICES]; /* Minimal amps in 1/4dB. */
180 int maxamp[SOUND_MIXER_NRDEVICES]; /* Maximal amps in 1/4dB. */
183 u_char digital;
184 uint32_t ossmask; /* Mask of supported OSS devices. */
185 uint32_t recsrc; /* Mask of supported OSS sources. */
187};
188
190 device_t dev;
191 struct mtx *lock;
194 uint32_t outamp_cap;
195 uint32_t inamp_cap;
198 uint32_t gpio_cap;
199 uint32_t quirks;
200 uint32_t newquirks;
201 uint32_t gpio;
202 uint32_t newgpio;
203 uint32_t gpo;
204 uint32_t newgpo;
207 int ascnt;
215 struct callout poll_jack;
217 uint32_t init_clear;
218};
219
220#define HDAA_CHN_RUNNING 0x00000001
221#define HDAA_CHN_SUSPEND 0x00000002
222
223struct hdaa_chan {
224 struct snd_dbuf *b;
225 struct pcm_channel *c;
229 uint32_t spd, fmt, fmtlist[32], pcmrates[16];
231 uint32_t blkcnt, blksz;
232 uint32_t *dmapos;
233 uint32_t flags;
234 int dir;
235 int off;
236 int sid;
238 int channels; /* Number of audio channels. */
239 int as; /* Number of association. */
240 int asindex; /* Index within association. */
242 uint8_t stripecap; /* AND of stripecap of all ios. */
243 uint8_t stripectl; /* stripe to use to all ios. */
244};
245
246#define MINQDB(ctl) \
247 ((0 - (ctl)->offset) * ((ctl)->size + 1))
248
249#define MAXQDB(ctl) \
250 (((ctl)->step - (ctl)->offset) * ((ctl)->size + 1))
251
252#define RANGEQDB(ctl) \
253 ((ctl)->step * ((ctl)->size + 1))
254
255#define VAL2QDB(ctl, val) \
256 (((ctl)->size + 1) * ((int)(val) - (ctl)->offset))
257
258#define QDB2VAL(ctl, qdb) \
259 imax(imin((((qdb) + (ctl)->size / 2 * ((qdb) > 0 ? 1 : -1)) / \
260 ((ctl)->size + 1) + (ctl)->offset), (ctl)->step), 0)
261
262#define hdaa_codec_id(devinfo) \
263 (((uint32_t)hda_get_vendor_id(devinfo->dev) << 16) + \
264 hda_get_device_id(devinfo->dev))
265
266#define hdaa_card_id(devinfo) \
267 (((uint32_t)hda_get_subdevice_id(devinfo->dev) << 16) + \
268 hda_get_subvendor_id(devinfo->dev))
269
271uint32_t hdaa_widget_pin_patch(uint32_t config, const char *str);
272uint32_t hdaa_gpio_patch(uint32_t gpio, const char *str);
273
274void hdaa_patch(struct hdaa_devinfo *devinfo);
276
277#endif
void * devinfo
Definition: ac97_if.m:47
void hdaa_patch_direct(struct hdaa_devinfo *devinfo)
Definition: hdaa_patches.c:667
struct hdaa_widget * hdaa_widget_get(struct hdaa_devinfo *, nid_t)
Definition: hdaa.c:1639
void hdaa_patch(struct hdaa_devinfo *devinfo)
Definition: hdaa_patches.c:431
#define HDA_MAX_CONNS
Definition: hdaa.h:87
uint32_t hdaa_gpio_patch(uint32_t gpio, const char *str)
Definition: hdaa.c:915
uint32_t hdaa_widget_pin_patch(uint32_t config, const char *str)
Definition: hdaa.c:821
#define HDA_MAX_NAMELEN
Definition: hdaa.h:88
uint32_t gpio
Definition: hdaa_patches.c:57
int nid_t
Definition: hdac.h:937
u_char enable
Definition: hdaa.h:153
struct hdaa_pcm_devinfo * pdevinfo
Definition: hdaa.h:167
int chans[2]
Definition: hdaa.h:164
int mixed
Definition: hdaa.h:166
u_char fakeredir
Definition: hdaa.h:157
nid_t dacs[2][16]
Definition: hdaa.h:162
nid_t pins[16]
Definition: hdaa.h:161
u_char index
Definition: hdaa.h:154
u_char pincnt
Definition: hdaa.h:156
int num_chans
Definition: hdaa.h:163
uint16_t pinset
Definition: hdaa.h:159
nid_t hpredir
Definition: hdaa.h:160
int location
Definition: hdaa.h:165
u_char dir
Definition: hdaa.h:155
u_char digital
Definition: hdaa.h:158
uint32_t muted
Definition: hdaa.h:144
int right
Definition: hdaa.h:143
uint32_t ossmask
Definition: hdaa.h:145
int size
Definition: hdaa.h:142
int devleft[SOUND_MIXER_NRDEVICES]
Definition: hdaa.h:146
int step
Definition: hdaa.h:142
struct hdaa_widget * childwidget
Definition: hdaa.h:139
int index
Definition: hdaa.h:141
struct hdaa_widget * widget
Definition: hdaa.h:139
int enable
Definition: hdaa.h:140
int left
Definition: hdaa.h:143
int devmute[SOUND_MIXER_NRDEVICES]
Definition: hdaa.h:148
int devright[SOUND_MIXER_NRDEVICES]
Definition: hdaa.h:147
int mute
Definition: hdaa.h:142
int ndir
Definition: hdaa.h:141
int offset
Definition: hdaa.h:142
int forcemute
Definition: hdaa.h:143
uint32_t * dmapos
Definition: hdaa.h:232
int channels
Definition: hdaa.h:238
int off
Definition: hdaa.h:235
struct hdaa_devinfo * devinfo
Definition: hdaa.h:227
int sid
Definition: hdaa.h:236
uint32_t pcmrates[16]
Definition: hdaa.h:229
uint32_t blksz
Definition: hdaa.h:231
uint32_t fmtlist[32]
Definition: hdaa.h:229
uint8_t stripecap
Definition: hdaa.h:242
struct snd_dbuf * b
Definition: hdaa.h:224
uint32_t spd
Definition: hdaa.h:229
uint32_t supp_stream_formats
Definition: hdaa.h:230
uint32_t supp_pcm_size_rate
Definition: hdaa.h:230
int as
Definition: hdaa.h:239
struct pcm_channel * c
Definition: hdaa.h:225
int bit16
Definition: hdaa.h:237
struct hdaa_pcm_devinfo * pdevinfo
Definition: hdaa.h:228
int bit32
Definition: hdaa.h:237
nid_t io[16]
Definition: hdaa.h:241
int asindex
Definition: hdaa.h:240
uint32_t flags
Definition: hdaa.h:233
struct pcmchan_caps caps
Definition: hdaa.h:226
uint8_t stripectl
Definition: hdaa.h:243
int dir
Definition: hdaa.h:234
uint32_t blkcnt
Definition: hdaa.h:231
uint32_t fmt
Definition: hdaa.h:229
uint32_t newquirks
Definition: hdaa.h:200
uint32_t outamp_cap
Definition: hdaa.h:194
uint32_t gpio_cap
Definition: hdaa.h:198
uint32_t newgpio
Definition: hdaa.h:202
nid_t nid
Definition: hdaa.h:192
uint32_t supp_stream_formats
Definition: hdaa.h:196
struct mtx * lock
Definition: hdaa.h:191
int poll_ival
Definition: hdaa.h:216
nid_t startnode
Definition: hdaa.h:193
uint32_t gpio
Definition: hdaa.h:201
uint32_t supp_pcm_size_rate
Definition: hdaa.h:197
nid_t endnode
Definition: hdaa.h:193
int ascnt
Definition: hdaa.h:207
int nodecnt
Definition: hdaa.h:205
int ctlcnt
Definition: hdaa.h:206
struct hdaa_chan * chans
Definition: hdaa.h:214
int num_chans
Definition: hdaa.h:209
struct hdaa_audio_ctl * ctl
Definition: hdaa.h:211
uint32_t inamp_cap
Definition: hdaa.h:195
int num_devs
Definition: hdaa.h:208
uint32_t newgpo
Definition: hdaa.h:204
struct hdaa_pcm_devinfo * devs
Definition: hdaa.h:213
uint32_t quirks
Definition: hdaa.h:199
device_t dev
Definition: hdaa.h:190
struct hdaa_audio_as * as
Definition: hdaa.h:212
uint32_t init_clear
Definition: hdaa.h:217
struct callout poll_jack
Definition: hdaa.h:215
struct hdaa_widget * widget
Definition: hdaa.h:210
uint32_t gpo
Definition: hdaa.h:203
int minamp[SOUND_MIXER_NRDEVICES]
Definition: hdaa.h:179
uint32_t recsrc
Definition: hdaa.h:185
int maxamp[SOUND_MIXER_NRDEVICES]
Definition: hdaa.h:180
int chan_size
Definition: hdaa.h:181
struct snd_mixer * mixer
Definition: hdaa.h:173
uint32_t ossmask
Definition: hdaa.h:184
int autorecsrc
Definition: hdaa.h:186
int registered
Definition: hdaa.h:175
struct hdaa_devinfo * devinfo
Definition: hdaa.h:172
u_char left[SOUND_MIXER_NRDEVICES]
Definition: hdaa.h:177
device_t dev
Definition: hdaa.h:171
int chan_blkcnt
Definition: hdaa.h:182
u_char digital
Definition: hdaa.h:183
u_char right[SOUND_MIXER_NRDEVICES]
Definition: hdaa.h:178
uint32_t ctrl
Definition: hdaa.h:129
uint32_t supp_pcm_size_rate
Definition: hdaa.h:120
nid_t nid
Definition: hdaa.h:98
uint32_t pflags
Definition: hdaa.h:103
uint32_t config
Definition: hdaa.h:125
uint32_t widget_cap
Definition: hdaa.h:116
int type
Definition: hdaa.h:99
struct hdaa_widget::@12::@14 conv
uint32_t supp_stream_formats
Definition: hdaa.h:119
int unsol
Definition: hdaa.h:108
uint32_t inamp_cap
Definition: hdaa.h:118
int waspin
Definition: hdaa.h:102
u_char connsenable[HDA_MAX_CONNS]
Definition: hdaa.h:110
int ossdev
Definition: hdaa.h:106
uint32_t outamp_cap
Definition: hdaa.h:117
struct hdaa_devinfo * devinfo
Definition: hdaa.h:114
int bindseqmask
Definition: hdaa.h:105
int nconns
Definition: hdaa.h:101
uint8_t stripecap
Definition: hdaa.h:133
uint32_t newconf
Definition: hdaa.h:127
int enable
Definition: hdaa.h:100
uint8_t * eld
Definition: hdaa.h:112
int selconn
Definition: hdaa.h:101
nid_t conns[HDA_MAX_CONNS]
Definition: hdaa.h:109
uint32_t original
Definition: hdaa.h:126
int bindas
Definition: hdaa.h:104
int connected
Definition: hdaa.h:130
uint32_t ossmask
Definition: hdaa.h:107
union hdaa_widget::@12 wclass
int eld_len
Definition: hdaa.h:113
struct hdaa_widget::@11 param
uint32_t cap
Definition: hdaa.h:128
uint32_t eapdbtl
Definition: hdaa.h:121
char name[HDA_MAX_NAMELEN]
Definition: hdaa.h:111
struct hdaa_widget::@12::@13 pin