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