xref: /freebsd/share/man/man4/snd_hda.4 (revision 5e3190f700637fcfc1a52daeaa4a031fdd2557c7)
1.\" Copyright (c) 2006-2008 Joel Dahl <joel@FreeBSD.org>
2.\" Copyright (c) 2008 Alexander Motin <mav@FreeBSD.org>
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.\" 1. Redistributions of source code must retain the above copyright
9.\"    notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\"    notice, this list of conditions and the following disclaimer in the
12.\"    documentation and/or other materials provided with the distribution.
13.\"
14.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24.\" SUCH DAMAGE.
25.\"
26.Dd July 16, 2019
27.Dt SND_HDA 4
28.Os
29.Sh NAME
30.Nm snd_hda
31.Nd "Intel High Definition Audio bridge device driver"
32.Sh SYNOPSIS
33To compile this driver into the kernel, place the following lines in your
34kernel configuration file:
35.Bd -ragged -offset indent
36.Cd "device sound"
37.Cd "device snd_hda"
38.Ed
39.Pp
40Alternatively, to load the driver as a module at boot time, place the
41following line in
42.Xr loader.conf 5 :
43.Bd -literal -offset indent
44snd_hda_load="YES"
45.Ed
46.Sh DESCRIPTION
47The High Definition (HD) Audio specification was developed by Intel as the
48logical successor of the old AC'97 specification and has several advantages,
49such as higher bandwidth which allows more channels and more detailed formats,
50support for several logical audio devices, and general purpose DMA channels.
51.Pp
52The
53.Nm
54driver includes HDA bus controller driver (hdac), HDA codec driver (hdacc)
55and HDA codecs audio functions bridge driver (hdaa) that allows
56the generic audio driver,
57.Xr sound 4 ,
58to be used with this hardware.
59Only audio functions are supported by
60.Nm .
61Modem and other possible functions are not implemented.
62.Pp
63The
64.Nm
65driver supports hardware that conforms with revision 1.0 of the Intel High
66Definition Audio specification and tries to behave much like the Microsoft
67Universal Audio Architecture (UAA) draft (revision 0.7b) for handling audio
68devices.
69.Pp
70According to HDA and UAA specifications, depending on the number of HDA buses
71and codecs present in system, their audio capabilities and BIOS provided
72configuration, the
73.Nm
74driver often provides several PCM audio devices.
75For example, one device for main rear 7.1 output and inputs, one device
76for independent headset connectors at front and one device for SPDIF or
77HDMI audio input/output.
78The assignment of audio inputs and outputs may be tuned with
79.Xr device.hints 5
80or
81.Xr sysctl 8 .
82The driver's verbose boot messages provide a lot of information about
83the operation of the driver and present audio setup.
84.Pp
85The default audio device may be tuned by setting the
86.Ar hw.snd.default_unit
87sysctl, as described in
88.Xr sound 4 ,
89or explicitly specified in application settings.
90.Ss Boot-time Configuration
91The following variables are available at boot-time through the
92.Xr device.hints 5
93file:
94.Bl -tag -width ".Va hint.hdac.%d.config"-offset indent
95.It Va hint.hdac.%d.config
96Configures a range of possible controller options.
97Possible values are:
98.Dq Li 64bit ,
99.Dq Li dmapos ,
100.Dq Li msi .
101An option prefixed with
102.Dq Li no ,
103such as
104.Dq Li nomsi ,
105will do the opposite and takes precedence.
106Options can be separated by whitespace and commas.
107.It Va hint.hdac.%d.msi
108Controls MSI (Message Signaled Interrupts) support.
109.It Va hint.hdac.%d.cad%d.nid%d.config
110Same as
111.Va hint.hdaa.%d.nid%d.config
112.It Va hint.hdaa.%d.config
113Configures a range of possible audio function options.
114Possible values are:
115.Dq Li eapdinv ,
116.Dq Li ivref ,
117.Dq Li ivref50 ,
118.Dq Li ivref80 ,
119.Dq Li ivref100 ,
120.Dq Li fixedrate ,
121.Dq Li forcestereo ,
122.Dq Li ovref ,
123.Dq Li ovref50 ,
124.Dq Li ovref80 ,
125.Dq Li ovref100 ,
126.Dq Li senseinv ,
127.Dq Li softpcmvol ,
128and
129.Dq Li vref .
130An option prefixed with
131.Dq Li no ,
132such as
133.Dq Li nofixedrate ,
134will do the opposite and takes precedence.
135Options can be separated by whitespace and commas.
136.Pp
137The
138.Dq Li eapdinv
139option inverts External Amplifier Power Down signal.
140The
141.Dq Li fixedrate
142denies all sampling rates except 48KHz.
143The
144.Dq Li forcestereo
145denies mono playback/recording.
146The
147.Dq Li senseinv
148option inverts jack sensing logic.
149The
150.Dq Li ivref Ns Ar X
151and
152.Dq Li ovref Ns Ar X
153options control the voltage used to power external microphones.
154.It Va dev.hdaa.%d.init_clear
155Zero out the pin widget config setup by the system.
156Some systems seem to have unusable audio devices if the pin widget
157configuration is cleared.
158Set this value to 0 to accept the default configuration values setup by the
159BIOS.
160.It Va hint.hdaa.%d.gpio_config
161Overrides audio function GPIO pins configuration set by BIOS.
162May be specified as a set of space-separated
163.Dq Ar num Ns = Ns Ar value
164pairs, where
165.Ar num
166is GPIO line number, and
167.Ar value
168is one of:
169.Dq Li keep ,
170.Dq Li set ,
171.Dq Li clear ,
172.Dq Li disable
173and
174.Dq Li input .
175.Pp
176.Dq Li GPIO Ns s
177are a codec's General Purpose I/O pins which system integrators sometimes
178use to control external muters, amplifiers and so on.
179If you have no sound, or sound volume is not adequate, you may have to
180experiment a bit with the GPIO setup to find the optimal setup for your
181system.
182.It Va hint.hdaa.%d.nid%d.config
183Overrides audio function pin configuration set by BIOS.
184May be specified as a 32-bit hexadecimal value with a leading
185.Dq 0x ,
186or as a set of space-separated
187.Dq Ar option Ns = Ns Ar value
188pairs.
189.It Va hint.pcm.%d.rec.autosrc
190Controls automatic recording source feature:
191.Bl -tag -width 2n -compact
192.It 0
193disabled,
194.It 1
195once on attach,
196.It 2
197enabled.
198.El
199When enabled, driver will automatically set recording source of the mixer to
200connected input using jack presence detection statuses.
201.El
202.Pp
203Pin configuration is the UAA driver's main source of information about codec
204usage.
205This information is usually provided by the codec manufacturer and tuned
206by system integrators for specific system requirements.
207The
208.Nm
209driver allows users to override it to fix integrator mistakes or to use the
210available codec in alternative ways (for example to get stereo output and 2
211inputs instead of a single 5.1 output).
212.Pp
213The following options are supported:
214.Bl -tag -width ".Va device=" -offset indent
215.It Va as
216Association number.
217Associations are used to group individual pins to form a complex multi-pin
218device.
219For example, to group 4 connectors for 7.1 input/output, or to treat several
220input connectors as sources for the same input device.
221Association numbers can be specified as numeric values from 0 to 15.
222A value of 0 means disabled pin.
223A value of 15 is a set of independent unassociated pins.
224Each association includes only pins of the same direction (in/out) and is
225detected atomically (all pins or none).
226A separate PCM audio device is created for every pair of input and
227output associations.
228.It Va seq
229Sequence number.
230A unique, per-association number used to order pins inside the
231particular association.
232Sequence numbers can be specified as numeric values from 0 to 15.
233.Pp
234The sequence number 15 has a special meaning for output associations.
235Output pins with this number and device type
236.Dq Ar Headphones
237will duplicate (with automatic mute if jack detection is supported) the
238first pin in that association.
239.Pp
240The sequence numbers 14 and 15 has a special meaning for input associations.
241Their presence in association defines it as multiplexed or mixed respectively.
242If none of them are present and there are more than one pin in association,
243the association will provide multichannel input.
244.Pp
245For multichannel input/output associations sequence numbers encode
246channel pairs positions:
2470 - Front, 1 - Center/LFE, 2 - Back, 3 - Front Wide Center, 4 - Side.
248Standard combinations are: (0) - Stereo; (0, 2), (0, 4) - Quadro;
249(0, 1, 2), (0, 1, 4) - 5.1; (0, 1, 2, 4) - 7.1.
250.It Va device
251Device type.
252Can be specified as a number from 0 to 15 or as a name:
253.Dq Li Line-out ,
254.Dq Li Speaker ,
255.Dq Li Headphones,
256.Dq Li CD ,
257.Dq Li SPDIF-out ,
258.Dq Li Digital-out ,
259.Dq Li Modem-line ,
260.Dq Li Modem-handset ,
261.Dq Li Line-in ,
262.Dq Li AUX ,
263.Dq Li Mic ,
264.Dq Li Telephony ,
265.Dq Li SPDIF-in ,
266.Dq Li Digital-in ,
267.Dq Li Res.E ,
268or
269.Dq Li Other .
270The device type also describes the pin direction (in/out).
271For example,
272.Dq Li CD
273always means an input pin, while
274.Dq Li Headphones
275always means an output.
276.It Va conn
277Connection type.
278Can be specified as a number from 0 to 3.
279The connection type can also be specified as one of the special names
280.Dq Li Jack ,
281.Dq Li None ,
282.Dq Li Fixed ,
283or
284.Dq Li Both .
285Pins with a connection type of
286.Dq Li None
287are disabled.
288.It Va ctype
289Connector physical type.
290Can be specified as a number from 0 to 15.
291This is a reference only value.
292It is ignored by the
293.Nm
294driver.
295.It Va color
296Connector color.
297Can be specified as a number from 0 to 15 or as one of the names
298.Dq Li Unknown ,
299.Dq Li Black ,
300.Dq Li Grey ,
301.Dq Li Blue ,
302.Dq Li Green ,
303.Dq Li Red ,
304.Dq Li Orange ,
305.Dq Li Yellow ,
306.Dq Li Purple ,
307.Dq Li Pink ,
308.Dq Li Res.A ,
309.Dq Li Res.B ,
310.Dq Li Res.C ,
311.Dq Li Res.D ,
312.Dq Li White ,
313or
314.Dq Li Other .
315This is a reference only value.
316It is ignored by the
317.Nm
318driver.
319.It Va loc
320Connector physical location.
321Can be specified as a number from 0 to 63.
322This is a reference only value.
323It is ignored by the
324.Nm
325driver.
326.It Va misc
327Misc bits.
328Can be specified as a number from 0 to 15.
329Bit 0 has a special meaning.
330When set it means that jack detection is not implemented in hardware.
331.El
332.Ss Runtime Configuration
333The following
334.Xr sysctl 8
335variables are available in addition to those available to all
336.Xr sound 4
337devices:
338.Bl -tag -width ".Va dev.hdaa.%d.nid%d_original" -offset indent
339.It Va dev.hdac.%d.pindump
340Setting this to a non-zero value dumps the current pin configuration, main
341capabilities and jack sense status of all audio functions on the controller
342to console and syslog.
343.It Va dev.hdac.%d.polling
344Enables polling mode.
345In this mode the driver operates by querying the device state on timer
346ticks using
347.Xr callout 9
348instead of interrupts.
349Polling is disabled by default.
350Do not enable it unless you are facing weird interrupt problems or if the
351device cannot generate interrupts at all.
352.It Va dev.hdaa.%d.config
353Run-time equivalent of the
354.Va hint.hdaa.%d.config
355tunable.
356.It Va dev.hdaa.%d.gpi_state
357Current state of GPI lines.
358.It Va dev.hdaa.%d.gpio_state
359Current state of GPIO lines.
360.It Va dev.hdaa.%d.gpio_config
361Run-time equivalent of the
362.Va hint.hdaa.%d.gpio.config
363tunable.
364.It Va dev.hdaa.%d.gpo_state
365Current state of GPO lines.
366.It Va dev.hdaa.%d.nid%d_config
367Run-time equivalent of the
368.Va hint.hdaa.%d.nid%d.config
369tunable.
370.It Va dev.hdaa.%d.nid%d_original
371Original pin configuration written by BIOS.
372.It Va dev.hdaa.%d.reconfig
373Setting this to a non-zero value makes driver to destroy existing pcm devices
374and process new pins configuration set via
375.Va dev.hdaa.%d.nid%d_config .
376.It Va dev.pcm.%d.play.32bit , dev.pcm.%d.rec.32bit
377HDA controller uses 32bit representation for all samples of more then 16 bits.
378These variables allow to specify how many bits of these 32 should be
379used by CODEC.
380Depending on codec capabilities, possible values are 20, 24 and 32 bit.
381The default value is 24.
382.It Va dev.pcm.%d.rec.autosrc
383Run-time equivalent of the
384.Va hint.pcm.%d.rec.autosrc
385tunable.
386.El
387.Sh EXAMPLES
388Taking HP Compaq DX2300 with Realtek ALC888 HDA codec for example.
389This system has two audio connectors on a front side, three audio connectors
390on a rear side and one internal speaker.
391According to verbose driver output and the codec datasheet,
392this codec has five stereo DACs and two stereo ADCs, all of them are routable to
393any codec pin (external connector).
394All codec pins are reversible (could be configured either as input or output).
395.Pp
396So high codec uniformity and flexibility allow driver to configure it in many
397different ways, depending on requested pins usage described by pins configuration.
398The driver reports such default pin configuration when verbose messages enabled:
399.Bd -literal
400hdaa0: nid   0x    as seq device       conn  jack    loc        color   misc
401hdaa0: 20 01014020 2  0  Line-out      Jack  1/8     Rear       Green   0
402hdaa0: 21 99130110 1  0  Speaker       Fixed ATAPI   Onboard    Unknown 1
403hdaa0: 22 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
404hdaa0: 23 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
405hdaa0: 24 01a19830 3  0  Mic           Jack  1/8     Rear       Pink    8
406hdaa0: 25 02a1983f 3  15 Mic           Jack  1/8     Front      Pink    8
407hdaa0: 26 01813031 3  1  Line-in       Jack  1/8     Rear       Blue    0
408hdaa0: 27 0221401f 1  15 Headphones    Jack  1/8     Front      Green   0
409hdaa0: 28 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
410hdaa0: 30 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
411hdaa0: 31 411111f0 15 0  Speaker       None  1/8     Rear       Black   1 DISA
412.Ed
413.Pp
414Here we can see, that the nodes with ID (nid) 25 and 27 are front panel
415connectors (Jack, Front), nids 20, 24 and 26 are rear panel connectors
416(Jack, Rear) and nid 21 is a built-in speaker (Fixed, Onboard).
417Pins with nids 22, 23, 28, 30 and 31 will be disabled by driver due to "None"
418connectivity.
419So the pin count and description matches to connectors that we have.
420.Pp
421Using association (as) and sequence (seq) fields values pins are grouped into
4223 associations:
423.Bd -literal
424hdaa0: Association 0 (1) out:
425hdaa0:   Pin nid=21 seq=0
426hdaa0:   Pin nid=27 seq=15
427hdaa0: Association 1 (2) out:
428hdaa0:   Pin nid=20 seq=0
429hdaa0: Association 2 (3) in:
430hdaa0:   Pin nid=24 seq=0
431hdaa0:   Pin nid=26 seq=1
432hdaa0:   Pin nid=25 seq=15
433.Ed
434.Pp
435Each
436.Xr pcm 4
437device uses two associations: one for playback and one for recording.
438Associations processed and assigned to
439.Xr pcm 4
440devices in increasing numerical order.
441In this case association #0 (1) will become
442.Li pcm0
443device playback, using the internal speakers and
444.Ar Headphones
445jack with speaker automute on the headphones jack connection.
446Association #1 (2) will become
447.Li pcm1
448playback, using the
449.Ar Line-out
450jack.
451Association #2 (3) will become
452.Li pcm0
453recording, using the external microphones and the
454.Ar Line-in
455jack.
456.Pp
457The
458.Nm
459driver provides extensive verbose messages to diagnose its operation
460logic and describe its current codec configuration.
461.Pp
462Using
463.Xr device.hints 5
464it is possible to modify the configuration of the existing pins,
465allowing a broad range of different audio setups.
466Here are a few examples of some setups possible for this particular
467hardware:
468.Ss Example 1
469Setting the
470.Xr device.hints 5
471options
472.Bd -literal
473hint.hdac.0.cad0.nid20.config="as=1"
474hint.hdac.0.cad0.nid21.config="as=2"
475.Ed
476.Pp
477will swap line-out and speaker functions.
478So the
479.Li pcm0
480device will play to the line-out and headphones jacks.
481Line-out will be muted on the headphones jack connection.
482Recording on
483.Li pcm0
484will go from two external microphones and line-in jacks.
485.Li pcm1
486playback will go to the internal speaker.
487.Ss Example 2
488Setting the
489.Xr device.hints 5
490options
491.Bd -literal
492hint.hdac.0.cad0.nid20.config="as=1 seq=15 device=Headphones"
493hint.hdac.0.cad0.nid27.config="as=2 seq=0"
494hint.hdac.0.cad0.nid25.config="as=4 seq=0"
495.Ed
496.Pp
497will split the headphones and one of the microphones to a separate device.
498The
499.Li pcm0
500device will play to the internal speaker and to the line-out jack, with
501speaker automute on the line-out jack connection.
502Recording on
503.Li pcm0
504will use input from one external microphone and the line-in jacks.
505The
506.Li pcm1
507device will be completely dedicated to a headset (headphones and mic)
508connected to the front connectors.
509.Ss Example 3
510Setting the
511.Xr device.hints 5
512options
513.Bd -literal
514hint.hdac.0.cad0.nid20.config="as=1 seq=0"
515hint.hdac.0.cad0.nid26.config="as=2 seq=0"
516hint.hdac.0.cad0.nid27.config="as=3 seq=0"
517hint.hdac.0.cad0.nid25.config="as=4 seq=0"
518hint.hdac.0.cad0.nid24.config="as=5 seq=0 device=Line-out"
519hint.hdac.0.cad0.nid21.config="as=6 seq=0"
520.Ed
521.Pp
522will give 4 independent devices:
523.Li pcm0
524.Pq line-out and line-in ,
525.Li pcm1
526.Pq headphones and mic ,
527.Li pcm2
528.Pq additional line-out via retasked rear mic jack ,
529and
530.Li pcm3
531.Pq internal speaker .
532.Ss Example 4
533Setting the
534.Xr device.hints 5
535options
536.Bd -literal
537hint.hdac.0.cad0.nid20.config="as=1 seq=0"
538hint.hdac.0.cad0.nid24.config="as=1 seq=1 device=Line-out"
539hint.hdac.0.cad0.nid26.config="as=1 seq=2 device=Line-out"
540hint.hdac.0.cad0.nid21.config="as=2 seq=0"
541.Ed
542.Pp
543will give 2 devices:
544.Li pcm0
545for 5.1 playback via 3 rear connectors (line-out and retasked
546mic and line-in) and headset (headphones and mic) at front connectors.
547.Li pcm1
548for internal speaker playback.
549On headphones connection rear connectors will be muted.
550.Sh MIXER CONTROLS
551Depending on codec configuration, these controls and signal sources could be
552reported to
553.Xr sound 4 :
554.Bl -tag -width ".Va speaker" -offset indent
555.It Va vol
556overall output level (volume)
557.It Va rec
558overall recording level
559.It Va igain
560input-to-output monitoring loopback level
561.It Va ogain
562external amplifier control
563.It Va pcm
564PCM playback
565.It Va mix
566input mix
567.It Va mic
568first external or second internal microphone input
569.It Va monitor
570first internal or second external microphone input
571.It Va line , Va line1 , Va line2 , Va line3
572analog (line) inputs
573.It Va dig1 , Va dig2 , Va dig3
574digital (S/PDIF, HDMI or DisplayPort) inputs
575.It Va cd
576CD input
577.It Va speaker
578PC speaker input
579.It Va phin , Va phout , Va radio , Va video
580other random inputs
581.El
582.Pp
583Controls have different precision.
584Some could be just an on/off triggers.
585Most of controls use logarithmic scale.
586.Sh HARDWARE
587The
588.Nm
589driver supports controllers having PCI class 4 (multimedia) and
590subclass 3 (HDA), compatible with Intel HDA specification.
591.Pp
592The
593.Nm
594driver supports more than two hundred different controllers and CODECs.
595There is no sense to list all of them here, as in most cases specific CODEC
596configuration and wiring are more important then type of the CODEC itself.
597.Sh SEE ALSO
598.Xr snd_ich 4 ,
599.Xr sound 4 ,
600.Xr device.hints 5 ,
601.Xr loader.conf 5 ,
602.Xr sysctl 8
603.Sh HISTORY
604The
605.Nm
606device driver first appeared in
607.Fx 6.3 .
608.Sh AUTHORS
609.An -nosplit
610The
611.Nm
612driver was written by
613.An Stephane E. Potvin Aq Mt sepotvin@videotron.ca ,
614.An Ariff Abdullah Aq Mt ariff@FreeBSD.org
615and
616.An Alexander Motin Aq Mt mav@FreeBSD.org .
617This manual page was written by
618.An Joel Dahl Aq Mt joel@FreeBSD.org ,
619.An Alexander Motin Aq Mt mav@FreeBSD.org
620and
621.An Giorgos Keramidas Aq Mt keramida@FreeBSD.org .
622.Sh BUGS
623Some Hardware/OEM vendors tend to screw up BIOS settings or use custom
624unusual CODEC wiring that create problems to the driver.
625This may result in missing pcm devices, or a state where the
626.Nm
627driver seems to attach and work, but no sound is played.
628Some cases can be solved by tuning
629.Pa loader.conf
630variables.
631But before trying to fix problem that way, make sure that there really is
632a problem and that the PCM audio device in use really corresponds to the
633expected audio connector.
634.Pp
635Some vendors use non-standardized General Purpose I/O (GPIO) pins of the codec
636to control external amplifiers.
637In some cases setting a combination of GPIO bits may be needed to make
638sound work on a specific device.
639.Pp
640HDMI and DisplayPort audio may also require support from video driver.
641