hda_codec.h 37 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241
  1. /*
  2. * Universal Interface for Intel High Definition Audio Codec
  3. *
  4. * Copyright (c) 2004 Takashi Iwai <tiwai@suse.de>
  5. *
  6. * This program is free software; you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the Free
  8. * Software Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but WITHOUT
  12. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13. * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  14. * more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along with
  17. * this program; if not, write to the Free Software Foundation, Inc., 59
  18. * Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  19. */
  20. #ifndef __SOUND_HDA_CODEC_H
  21. #define __SOUND_HDA_CODEC_H
  22. #include <sound/info.h>
  23. #include <sound/control.h>
  24. #include <sound/pcm.h>
  25. #include <sound/hwdep.h>
  26. /*
  27. * nodes
  28. */
  29. #define AC_NODE_ROOT 0x00
  30. /*
  31. * function group types
  32. */
  33. enum {
  34. AC_GRP_AUDIO_FUNCTION = 0x01,
  35. AC_GRP_MODEM_FUNCTION = 0x02,
  36. };
  37. /*
  38. * widget types
  39. */
  40. enum {
  41. AC_WID_AUD_OUT, /* Audio Out */
  42. AC_WID_AUD_IN, /* Audio In */
  43. AC_WID_AUD_MIX, /* Audio Mixer */
  44. AC_WID_AUD_SEL, /* Audio Selector */
  45. AC_WID_PIN, /* Pin Complex */
  46. AC_WID_POWER, /* Power */
  47. AC_WID_VOL_KNB, /* Volume Knob */
  48. AC_WID_BEEP, /* Beep Generator */
  49. AC_WID_VENDOR = 0x0f /* Vendor specific */
  50. };
  51. /*
  52. * GET verbs
  53. */
  54. #define AC_VERB_GET_STREAM_FORMAT 0x0a00
  55. #define AC_VERB_GET_AMP_GAIN_MUTE 0x0b00
  56. #define AC_VERB_GET_PROC_COEF 0x0c00
  57. #define AC_VERB_GET_COEF_INDEX 0x0d00
  58. #define AC_VERB_PARAMETERS 0x0f00
  59. #define AC_VERB_GET_CONNECT_SEL 0x0f01
  60. #define AC_VERB_GET_CONNECT_LIST 0x0f02
  61. #define AC_VERB_GET_PROC_STATE 0x0f03
  62. #define AC_VERB_GET_SDI_SELECT 0x0f04
  63. #define AC_VERB_GET_POWER_STATE 0x0f05
  64. #define AC_VERB_GET_CONV 0x0f06
  65. #define AC_VERB_GET_PIN_WIDGET_CONTROL 0x0f07
  66. #define AC_VERB_GET_UNSOLICITED_RESPONSE 0x0f08
  67. #define AC_VERB_GET_PIN_SENSE 0x0f09
  68. #define AC_VERB_GET_BEEP_CONTROL 0x0f0a
  69. #define AC_VERB_GET_EAPD_BTLENABLE 0x0f0c
  70. #define AC_VERB_GET_DIGI_CONVERT_1 0x0f0d
  71. #define AC_VERB_GET_DIGI_CONVERT_2 0x0f0e /* unused */
  72. #define AC_VERB_GET_VOLUME_KNOB_CONTROL 0x0f0f
  73. /* f10-f1a: GPIO */
  74. #define AC_VERB_GET_GPIO_DATA 0x0f15
  75. #define AC_VERB_GET_GPIO_MASK 0x0f16
  76. #define AC_VERB_GET_GPIO_DIRECTION 0x0f17
  77. #define AC_VERB_GET_GPIO_WAKE_MASK 0x0f18
  78. #define AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK 0x0f19
  79. #define AC_VERB_GET_GPIO_STICKY_MASK 0x0f1a
  80. #define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c
  81. /* f20: AFG/MFG */
  82. #define AC_VERB_GET_SUBSYSTEM_ID 0x0f20
  83. #define AC_VERB_GET_CVT_CHAN_COUNT 0x0f2d
  84. #define AC_VERB_GET_HDMI_DIP_SIZE 0x0f2e
  85. #define AC_VERB_GET_HDMI_ELDD 0x0f2f
  86. #define AC_VERB_GET_HDMI_DIP_INDEX 0x0f30
  87. #define AC_VERB_GET_HDMI_DIP_DATA 0x0f31
  88. #define AC_VERB_GET_HDMI_DIP_XMIT 0x0f32
  89. #define AC_VERB_GET_HDMI_CP_CTRL 0x0f33
  90. #define AC_VERB_GET_HDMI_CHAN_SLOT 0x0f34
  91. #define AC_VERB_GET_DEVICE_SEL 0xf35
  92. #define AC_VERB_GET_DEVICE_LIST 0xf36
  93. /*
  94. * SET verbs
  95. */
  96. #define AC_VERB_SET_STREAM_FORMAT 0x200
  97. #define AC_VERB_SET_AMP_GAIN_MUTE 0x300
  98. #define AC_VERB_SET_PROC_COEF 0x400
  99. #define AC_VERB_SET_COEF_INDEX 0x500
  100. #define AC_VERB_SET_CONNECT_SEL 0x701
  101. #define AC_VERB_SET_PROC_STATE 0x703
  102. #define AC_VERB_SET_SDI_SELECT 0x704
  103. #define AC_VERB_SET_POWER_STATE 0x705
  104. #define AC_VERB_SET_CHANNEL_STREAMID 0x706
  105. #define AC_VERB_SET_PIN_WIDGET_CONTROL 0x707
  106. #define AC_VERB_SET_UNSOLICITED_ENABLE 0x708
  107. #define AC_VERB_SET_PIN_SENSE 0x709
  108. #define AC_VERB_SET_BEEP_CONTROL 0x70a
  109. #define AC_VERB_SET_EAPD_BTLENABLE 0x70c
  110. #define AC_VERB_SET_DIGI_CONVERT_1 0x70d
  111. #define AC_VERB_SET_DIGI_CONVERT_2 0x70e
  112. #define AC_VERB_SET_VOLUME_KNOB_CONTROL 0x70f
  113. #define AC_VERB_SET_GPIO_DATA 0x715
  114. #define AC_VERB_SET_GPIO_MASK 0x716
  115. #define AC_VERB_SET_GPIO_DIRECTION 0x717
  116. #define AC_VERB_SET_GPIO_WAKE_MASK 0x718
  117. #define AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK 0x719
  118. #define AC_VERB_SET_GPIO_STICKY_MASK 0x71a
  119. #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 0x71c
  120. #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d
  121. #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e
  122. #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_3 0x71f
  123. #define AC_VERB_SET_EAPD 0x788
  124. #define AC_VERB_SET_CODEC_RESET 0x7ff
  125. #define AC_VERB_SET_CVT_CHAN_COUNT 0x72d
  126. #define AC_VERB_SET_HDMI_DIP_INDEX 0x730
  127. #define AC_VERB_SET_HDMI_DIP_DATA 0x731
  128. #define AC_VERB_SET_HDMI_DIP_XMIT 0x732
  129. #define AC_VERB_SET_HDMI_CP_CTRL 0x733
  130. #define AC_VERB_SET_HDMI_CHAN_SLOT 0x734
  131. #define AC_VERB_SET_DEVICE_SEL 0x735
  132. /*
  133. * Parameter IDs
  134. */
  135. #define AC_PAR_VENDOR_ID 0x00
  136. #define AC_PAR_SUBSYSTEM_ID 0x01
  137. #define AC_PAR_REV_ID 0x02
  138. #define AC_PAR_NODE_COUNT 0x04
  139. #define AC_PAR_FUNCTION_TYPE 0x05
  140. #define AC_PAR_AUDIO_FG_CAP 0x08
  141. #define AC_PAR_AUDIO_WIDGET_CAP 0x09
  142. #define AC_PAR_PCM 0x0a
  143. #define AC_PAR_STREAM 0x0b
  144. #define AC_PAR_PIN_CAP 0x0c
  145. #define AC_PAR_AMP_IN_CAP 0x0d
  146. #define AC_PAR_CONNLIST_LEN 0x0e
  147. #define AC_PAR_POWER_STATE 0x0f
  148. #define AC_PAR_PROC_CAP 0x10
  149. #define AC_PAR_GPIO_CAP 0x11
  150. #define AC_PAR_AMP_OUT_CAP 0x12
  151. #define AC_PAR_VOL_KNB_CAP 0x13
  152. #define AC_PAR_DEVLIST_LEN 0x15
  153. #define AC_PAR_HDMI_LPCM_CAP 0x20
  154. /*
  155. * AC_VERB_PARAMETERS results (32bit)
  156. */
  157. /* Function Group Type */
  158. #define AC_FGT_TYPE (0xff<<0)
  159. #define AC_FGT_TYPE_SHIFT 0
  160. #define AC_FGT_UNSOL_CAP (1<<8)
  161. /* Audio Function Group Capabilities */
  162. #define AC_AFG_OUT_DELAY (0xf<<0)
  163. #define AC_AFG_IN_DELAY (0xf<<8)
  164. #define AC_AFG_BEEP_GEN (1<<16)
  165. /* Audio Widget Capabilities */
  166. #define AC_WCAP_STEREO (1<<0) /* stereo I/O */
  167. #define AC_WCAP_IN_AMP (1<<1) /* AMP-in present */
  168. #define AC_WCAP_OUT_AMP (1<<2) /* AMP-out present */
  169. #define AC_WCAP_AMP_OVRD (1<<3) /* AMP-parameter override */
  170. #define AC_WCAP_FORMAT_OVRD (1<<4) /* format override */
  171. #define AC_WCAP_STRIPE (1<<5) /* stripe */
  172. #define AC_WCAP_PROC_WID (1<<6) /* Proc Widget */
  173. #define AC_WCAP_UNSOL_CAP (1<<7) /* Unsol capable */
  174. #define AC_WCAP_CONN_LIST (1<<8) /* connection list */
  175. #define AC_WCAP_DIGITAL (1<<9) /* digital I/O */
  176. #define AC_WCAP_POWER (1<<10) /* power control */
  177. #define AC_WCAP_LR_SWAP (1<<11) /* L/R swap */
  178. #define AC_WCAP_CP_CAPS (1<<12) /* content protection */
  179. #define AC_WCAP_CHAN_CNT_EXT (7<<13) /* channel count ext */
  180. #define AC_WCAP_DELAY (0xf<<16)
  181. #define AC_WCAP_DELAY_SHIFT 16
  182. #define AC_WCAP_TYPE (0xf<<20)
  183. #define AC_WCAP_TYPE_SHIFT 20
  184. /* supported PCM rates and bits */
  185. #define AC_SUPPCM_RATES (0xfff << 0)
  186. #define AC_SUPPCM_BITS_8 (1<<16)
  187. #define AC_SUPPCM_BITS_16 (1<<17)
  188. #define AC_SUPPCM_BITS_20 (1<<18)
  189. #define AC_SUPPCM_BITS_24 (1<<19)
  190. #define AC_SUPPCM_BITS_32 (1<<20)
  191. /* supported PCM stream format */
  192. #define AC_SUPFMT_PCM (1<<0)
  193. #define AC_SUPFMT_FLOAT32 (1<<1)
  194. #define AC_SUPFMT_AC3 (1<<2)
  195. /* GP I/O count */
  196. #define AC_GPIO_IO_COUNT (0xff<<0)
  197. #define AC_GPIO_O_COUNT (0xff<<8)
  198. #define AC_GPIO_O_COUNT_SHIFT 8
  199. #define AC_GPIO_I_COUNT (0xff<<16)
  200. #define AC_GPIO_I_COUNT_SHIFT 16
  201. #define AC_GPIO_UNSOLICITED (1<<30)
  202. #define AC_GPIO_WAKE (1<<31)
  203. /* Converter stream, channel */
  204. #define AC_CONV_CHANNEL (0xf<<0)
  205. #define AC_CONV_STREAM (0xf<<4)
  206. #define AC_CONV_STREAM_SHIFT 4
  207. /* Input converter SDI select */
  208. #define AC_SDI_SELECT (0xf<<0)
  209. /* stream format id */
  210. #define AC_FMT_CHAN_SHIFT 0
  211. #define AC_FMT_CHAN_MASK (0x0f << 0)
  212. #define AC_FMT_BITS_SHIFT 4
  213. #define AC_FMT_BITS_MASK (7 << 4)
  214. #define AC_FMT_BITS_8 (0 << 4)
  215. #define AC_FMT_BITS_16 (1 << 4)
  216. #define AC_FMT_BITS_20 (2 << 4)
  217. #define AC_FMT_BITS_24 (3 << 4)
  218. #define AC_FMT_BITS_32 (4 << 4)
  219. #define AC_FMT_DIV_SHIFT 8
  220. #define AC_FMT_DIV_MASK (7 << 8)
  221. #define AC_FMT_MULT_SHIFT 11
  222. #define AC_FMT_MULT_MASK (7 << 11)
  223. #define AC_FMT_BASE_SHIFT 14
  224. #define AC_FMT_BASE_48K (0 << 14)
  225. #define AC_FMT_BASE_44K (1 << 14)
  226. #define AC_FMT_TYPE_SHIFT 15
  227. #define AC_FMT_TYPE_PCM (0 << 15)
  228. #define AC_FMT_TYPE_NON_PCM (1 << 15)
  229. /* Unsolicited response control */
  230. #define AC_UNSOL_TAG (0x3f<<0)
  231. #define AC_UNSOL_ENABLED (1<<7)
  232. #define AC_USRSP_EN AC_UNSOL_ENABLED
  233. /* Unsolicited responses */
  234. #define AC_UNSOL_RES_TAG (0x3f<<26)
  235. #define AC_UNSOL_RES_TAG_SHIFT 26
  236. #define AC_UNSOL_RES_SUBTAG (0x1f<<21)
  237. #define AC_UNSOL_RES_SUBTAG_SHIFT 21
  238. #define AC_UNSOL_RES_DE (0x3f<<15) /* Device Entry
  239. * (for DP1.2 MST)
  240. */
  241. #define AC_UNSOL_RES_DE_SHIFT 15
  242. #define AC_UNSOL_RES_IA (1<<2) /* Inactive (for DP1.2 MST) */
  243. #define AC_UNSOL_RES_ELDV (1<<1) /* ELD Data valid (for HDMI) */
  244. #define AC_UNSOL_RES_PD (1<<0) /* pinsense detect */
  245. #define AC_UNSOL_RES_CP_STATE (1<<1) /* content protection */
  246. #define AC_UNSOL_RES_CP_READY (1<<0) /* content protection */
  247. /* Pin widget capabilies */
  248. #define AC_PINCAP_IMP_SENSE (1<<0) /* impedance sense capable */
  249. #define AC_PINCAP_TRIG_REQ (1<<1) /* trigger required */
  250. #define AC_PINCAP_PRES_DETECT (1<<2) /* presence detect capable */
  251. #define AC_PINCAP_HP_DRV (1<<3) /* headphone drive capable */
  252. #define AC_PINCAP_OUT (1<<4) /* output capable */
  253. #define AC_PINCAP_IN (1<<5) /* input capable */
  254. #define AC_PINCAP_BALANCE (1<<6) /* balanced I/O capable */
  255. /* Note: This LR_SWAP pincap is defined in the Realtek ALC883 specification,
  256. * but is marked reserved in the Intel HDA specification.
  257. */
  258. #define AC_PINCAP_LR_SWAP (1<<7) /* L/R swap */
  259. /* Note: The same bit as LR_SWAP is newly defined as HDMI capability
  260. * in HD-audio specification
  261. */
  262. #define AC_PINCAP_HDMI (1<<7) /* HDMI pin */
  263. #define AC_PINCAP_DP (1<<24) /* DisplayPort pin, can
  264. * coexist with AC_PINCAP_HDMI
  265. */
  266. #define AC_PINCAP_VREF (0x37<<8)
  267. #define AC_PINCAP_VREF_SHIFT 8
  268. #define AC_PINCAP_EAPD (1<<16) /* EAPD capable */
  269. #define AC_PINCAP_HBR (1<<27) /* High Bit Rate */
  270. /* Vref status (used in pin cap) */
  271. #define AC_PINCAP_VREF_HIZ (1<<0) /* Hi-Z */
  272. #define AC_PINCAP_VREF_50 (1<<1) /* 50% */
  273. #define AC_PINCAP_VREF_GRD (1<<2) /* ground */
  274. #define AC_PINCAP_VREF_80 (1<<4) /* 80% */
  275. #define AC_PINCAP_VREF_100 (1<<5) /* 100% */
  276. /* Amplifier capabilities */
  277. #define AC_AMPCAP_OFFSET (0x7f<<0) /* 0dB offset */
  278. #define AC_AMPCAP_OFFSET_SHIFT 0
  279. #define AC_AMPCAP_NUM_STEPS (0x7f<<8) /* number of steps */
  280. #define AC_AMPCAP_NUM_STEPS_SHIFT 8
  281. #define AC_AMPCAP_STEP_SIZE (0x7f<<16) /* step size 0-32dB
  282. * in 0.25dB
  283. */
  284. #define AC_AMPCAP_STEP_SIZE_SHIFT 16
  285. #define AC_AMPCAP_MUTE (1<<31) /* mute capable */
  286. #define AC_AMPCAP_MUTE_SHIFT 31
  287. /* driver-specific amp-caps: using bits 24-30 */
  288. #define AC_AMPCAP_MIN_MUTE (1 << 30) /* min-volume = mute */
  289. /* Connection list */
  290. #define AC_CLIST_LENGTH (0x7f<<0)
  291. #define AC_CLIST_LONG (1<<7)
  292. /* Supported power status */
  293. #define AC_PWRST_D0SUP (1<<0)
  294. #define AC_PWRST_D1SUP (1<<1)
  295. #define AC_PWRST_D2SUP (1<<2)
  296. #define AC_PWRST_D3SUP (1<<3)
  297. #define AC_PWRST_D3COLDSUP (1<<4)
  298. #define AC_PWRST_S3D3COLDSUP (1<<29)
  299. #define AC_PWRST_CLKSTOP (1<<30)
  300. #define AC_PWRST_EPSS (1U<<31)
  301. /* Power state values */
  302. #define AC_PWRST_SETTING (0xf<<0)
  303. #define AC_PWRST_ACTUAL (0xf<<4)
  304. #define AC_PWRST_ACTUAL_SHIFT 4
  305. #define AC_PWRST_D0 0x00
  306. #define AC_PWRST_D1 0x01
  307. #define AC_PWRST_D2 0x02
  308. #define AC_PWRST_D3 0x03
  309. #define AC_PWRST_ERROR (1<<8)
  310. #define AC_PWRST_CLK_STOP_OK (1<<9)
  311. #define AC_PWRST_SETTING_RESET (1<<10)
  312. /* Processing capabilies */
  313. #define AC_PCAP_BENIGN (1<<0)
  314. #define AC_PCAP_NUM_COEF (0xff<<8)
  315. #define AC_PCAP_NUM_COEF_SHIFT 8
  316. /* Volume knobs capabilities */
  317. #define AC_KNBCAP_NUM_STEPS (0x7f<<0)
  318. #define AC_KNBCAP_DELTA (1<<7)
  319. /* HDMI LPCM capabilities */
  320. #define AC_LPCMCAP_48K_CP_CHNS (0x0f<<0) /* max channels w/ CP-on */
  321. #define AC_LPCMCAP_48K_NO_CHNS (0x0f<<4) /* max channels w/o CP-on */
  322. #define AC_LPCMCAP_48K_20BIT (1<<8) /* 20b bitrate supported */
  323. #define AC_LPCMCAP_48K_24BIT (1<<9) /* 24b bitrate supported */
  324. #define AC_LPCMCAP_96K_CP_CHNS (0x0f<<10) /* max channels w/ CP-on */
  325. #define AC_LPCMCAP_96K_NO_CHNS (0x0f<<14) /* max channels w/o CP-on */
  326. #define AC_LPCMCAP_96K_20BIT (1<<18) /* 20b bitrate supported */
  327. #define AC_LPCMCAP_96K_24BIT (1<<19) /* 24b bitrate supported */
  328. #define AC_LPCMCAP_192K_CP_CHNS (0x0f<<20) /* max channels w/ CP-on */
  329. #define AC_LPCMCAP_192K_NO_CHNS (0x0f<<24) /* max channels w/o CP-on */
  330. #define AC_LPCMCAP_192K_20BIT (1<<28) /* 20b bitrate supported */
  331. #define AC_LPCMCAP_192K_24BIT (1<<29) /* 24b bitrate supported */
  332. #define AC_LPCMCAP_44K (1<<30) /* 44.1kHz support */
  333. #define AC_LPCMCAP_44K_MS (1<<31) /* 44.1kHz-multiplies support */
  334. /* Display pin's device list length */
  335. #define AC_DEV_LIST_LEN_MASK 0x3f
  336. #define AC_MAX_DEV_LIST_LEN 64
  337. /*
  338. * Control Parameters
  339. */
  340. /* Amp gain/mute */
  341. #define AC_AMP_MUTE (1<<7)
  342. #define AC_AMP_GAIN (0x7f)
  343. #define AC_AMP_GET_INDEX (0xf<<0)
  344. #define AC_AMP_GET_LEFT (1<<13)
  345. #define AC_AMP_GET_RIGHT (0<<13)
  346. #define AC_AMP_GET_OUTPUT (1<<15)
  347. #define AC_AMP_GET_INPUT (0<<15)
  348. #define AC_AMP_SET_INDEX (0xf<<8)
  349. #define AC_AMP_SET_INDEX_SHIFT 8
  350. #define AC_AMP_SET_RIGHT (1<<12)
  351. #define AC_AMP_SET_LEFT (1<<13)
  352. #define AC_AMP_SET_INPUT (1<<14)
  353. #define AC_AMP_SET_OUTPUT (1<<15)
  354. /* DIGITAL1 bits */
  355. #define AC_DIG1_ENABLE (1<<0)
  356. #define AC_DIG1_V (1<<1)
  357. #define AC_DIG1_VCFG (1<<2)
  358. #define AC_DIG1_EMPHASIS (1<<3)
  359. #define AC_DIG1_COPYRIGHT (1<<4)
  360. #define AC_DIG1_NONAUDIO (1<<5)
  361. #define AC_DIG1_PROFESSIONAL (1<<6)
  362. #define AC_DIG1_LEVEL (1<<7)
  363. /* DIGITAL2 bits */
  364. #define AC_DIG2_CC (0x7f<<0)
  365. /* DIGITAL3 bits */
  366. #define AC_DIG3_ICT (0xf<<0)
  367. #define AC_DIG3_KAE (1<<7)
  368. /* Pin widget control - 8bit */
  369. #define AC_PINCTL_EPT (0x3<<0)
  370. #define AC_PINCTL_EPT_NATIVE 0
  371. #define AC_PINCTL_EPT_HBR 3
  372. #define AC_PINCTL_VREFEN (0x7<<0)
  373. #define AC_PINCTL_VREF_HIZ 0 /* Hi-Z */
  374. #define AC_PINCTL_VREF_50 1 /* 50% */
  375. #define AC_PINCTL_VREF_GRD 2 /* ground */
  376. #define AC_PINCTL_VREF_80 4 /* 80% */
  377. #define AC_PINCTL_VREF_100 5 /* 100% */
  378. #define AC_PINCTL_IN_EN (1<<5)
  379. #define AC_PINCTL_OUT_EN (1<<6)
  380. #define AC_PINCTL_HP_EN (1<<7)
  381. /* Pin sense - 32bit */
  382. #define AC_PINSENSE_IMPEDANCE_MASK (0x7fffffff)
  383. #define AC_PINSENSE_PRESENCE (1<<31)
  384. #define AC_PINSENSE_ELDV (1<<30) /* ELD valid (HDMI) */
  385. /* EAPD/BTL enable - 32bit */
  386. #define AC_EAPDBTL_BALANCED (1<<0)
  387. #define AC_EAPDBTL_EAPD (1<<1)
  388. #define AC_EAPDBTL_LR_SWAP (1<<2)
  389. /* HDMI ELD data */
  390. #define AC_ELDD_ELD_VALID (1<<31)
  391. #define AC_ELDD_ELD_DATA 0xff
  392. /* HDMI DIP size */
  393. #define AC_DIPSIZE_ELD_BUF (1<<3) /* ELD buf size of packet size */
  394. #define AC_DIPSIZE_PACK_IDX (0x07<<0) /* packet index */
  395. /* HDMI DIP index */
  396. #define AC_DIPIDX_PACK_IDX (0x07<<5) /* packet idnex */
  397. #define AC_DIPIDX_BYTE_IDX (0x1f<<0) /* byte index */
  398. /* HDMI DIP xmit (transmit) control */
  399. #define AC_DIPXMIT_MASK (0x3<<6)
  400. #define AC_DIPXMIT_DISABLE (0x0<<6) /* disable xmit */
  401. #define AC_DIPXMIT_ONCE (0x2<<6) /* xmit once then disable */
  402. #define AC_DIPXMIT_BEST (0x3<<6) /* best effort */
  403. /* HDMI content protection (CP) control */
  404. #define AC_CPCTRL_CES (1<<9) /* current encryption state */
  405. #define AC_CPCTRL_READY (1<<8) /* ready bit */
  406. #define AC_CPCTRL_SUBTAG (0x1f<<3) /* subtag for unsol-resp */
  407. #define AC_CPCTRL_STATE (3<<0) /* current CP request state */
  408. /* Converter channel <-> HDMI slot mapping */
  409. #define AC_CVTMAP_HDMI_SLOT (0xf<<0) /* HDMI slot number */
  410. #define AC_CVTMAP_CHAN (0xf<<4) /* converter channel number */
  411. /* configuration default - 32bit */
  412. #define AC_DEFCFG_SEQUENCE (0xf<<0)
  413. #define AC_DEFCFG_DEF_ASSOC (0xf<<4)
  414. #define AC_DEFCFG_ASSOC_SHIFT 4
  415. #define AC_DEFCFG_MISC (0xf<<8)
  416. #define AC_DEFCFG_MISC_SHIFT 8
  417. #define AC_DEFCFG_MISC_NO_PRESENCE (1<<0)
  418. #define AC_DEFCFG_COLOR (0xf<<12)
  419. #define AC_DEFCFG_COLOR_SHIFT 12
  420. #define AC_DEFCFG_CONN_TYPE (0xf<<16)
  421. #define AC_DEFCFG_CONN_TYPE_SHIFT 16
  422. #define AC_DEFCFG_DEVICE (0xf<<20)
  423. #define AC_DEFCFG_DEVICE_SHIFT 20
  424. #define AC_DEFCFG_LOCATION (0x3f<<24)
  425. #define AC_DEFCFG_LOCATION_SHIFT 24
  426. #define AC_DEFCFG_PORT_CONN (0x3<<30)
  427. #define AC_DEFCFG_PORT_CONN_SHIFT 30
  428. /* Display pin's device list entry */
  429. #define AC_DE_PD (1<<0)
  430. #define AC_DE_ELDV (1<<1)
  431. #define AC_DE_IA (1<<2)
  432. /* device device types (0x0-0xf) */
  433. enum {
  434. AC_JACK_LINE_OUT,
  435. AC_JACK_SPEAKER,
  436. AC_JACK_HP_OUT,
  437. AC_JACK_CD,
  438. AC_JACK_SPDIF_OUT,
  439. AC_JACK_DIG_OTHER_OUT,
  440. AC_JACK_MODEM_LINE_SIDE,
  441. AC_JACK_MODEM_HAND_SIDE,
  442. AC_JACK_LINE_IN,
  443. AC_JACK_AUX,
  444. AC_JACK_MIC_IN,
  445. AC_JACK_TELEPHONY,
  446. AC_JACK_SPDIF_IN,
  447. AC_JACK_DIG_OTHER_IN,
  448. AC_JACK_OTHER = 0xf,
  449. };
  450. /* jack connection types (0x0-0xf) */
  451. enum {
  452. AC_JACK_CONN_UNKNOWN,
  453. AC_JACK_CONN_1_8,
  454. AC_JACK_CONN_1_4,
  455. AC_JACK_CONN_ATAPI,
  456. AC_JACK_CONN_RCA,
  457. AC_JACK_CONN_OPTICAL,
  458. AC_JACK_CONN_OTHER_DIGITAL,
  459. AC_JACK_CONN_OTHER_ANALOG,
  460. AC_JACK_CONN_DIN,
  461. AC_JACK_CONN_XLR,
  462. AC_JACK_CONN_RJ11,
  463. AC_JACK_CONN_COMB,
  464. AC_JACK_CONN_OTHER = 0xf,
  465. };
  466. /* jack colors (0x0-0xf) */
  467. enum {
  468. AC_JACK_COLOR_UNKNOWN,
  469. AC_JACK_COLOR_BLACK,
  470. AC_JACK_COLOR_GREY,
  471. AC_JACK_COLOR_BLUE,
  472. AC_JACK_COLOR_GREEN,
  473. AC_JACK_COLOR_RED,
  474. AC_JACK_COLOR_ORANGE,
  475. AC_JACK_COLOR_YELLOW,
  476. AC_JACK_COLOR_PURPLE,
  477. AC_JACK_COLOR_PINK,
  478. AC_JACK_COLOR_WHITE = 0xe,
  479. AC_JACK_COLOR_OTHER,
  480. };
  481. /* Jack location (0x0-0x3f) */
  482. /* common case */
  483. enum {
  484. AC_JACK_LOC_NONE,
  485. AC_JACK_LOC_REAR,
  486. AC_JACK_LOC_FRONT,
  487. AC_JACK_LOC_LEFT,
  488. AC_JACK_LOC_RIGHT,
  489. AC_JACK_LOC_TOP,
  490. AC_JACK_LOC_BOTTOM,
  491. };
  492. /* bits 4-5 */
  493. enum {
  494. AC_JACK_LOC_EXTERNAL = 0x00,
  495. AC_JACK_LOC_INTERNAL = 0x10,
  496. AC_JACK_LOC_SEPARATE = 0x20,
  497. AC_JACK_LOC_OTHER = 0x30,
  498. };
  499. enum {
  500. /* external on primary chasis */
  501. AC_JACK_LOC_REAR_PANEL = 0x07,
  502. AC_JACK_LOC_DRIVE_BAY,
  503. /* internal */
  504. AC_JACK_LOC_RISER = 0x17,
  505. AC_JACK_LOC_HDMI,
  506. AC_JACK_LOC_ATAPI,
  507. /* others */
  508. AC_JACK_LOC_MOBILE_IN = 0x37,
  509. AC_JACK_LOC_MOBILE_OUT,
  510. };
  511. /* Port connectivity (0-3) */
  512. enum {
  513. AC_JACK_PORT_COMPLEX,
  514. AC_JACK_PORT_NONE,
  515. AC_JACK_PORT_FIXED,
  516. AC_JACK_PORT_BOTH,
  517. };
  518. /* max. codec address */
  519. #define HDA_MAX_CODEC_ADDRESS 0x0f
  520. /*
  521. * generic arrays
  522. */
  523. struct snd_array {
  524. unsigned int used;
  525. unsigned int alloced;
  526. unsigned int elem_size;
  527. unsigned int alloc_align;
  528. void *list;
  529. };
  530. void *snd_array_new(struct snd_array *array);
  531. void snd_array_free(struct snd_array *array);
  532. static inline void snd_array_init(struct snd_array *array, unsigned int size,
  533. unsigned int align)
  534. {
  535. array->elem_size = size;
  536. array->alloc_align = align;
  537. }
  538. static inline void *snd_array_elem(struct snd_array *array, unsigned int idx)
  539. {
  540. return array->list + idx * array->elem_size;
  541. }
  542. static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
  543. {
  544. return (unsigned long)(ptr - array->list) / array->elem_size;
  545. }
  546. /*
  547. * Structures
  548. */
  549. struct hda_bus;
  550. struct hda_beep;
  551. struct hda_codec;
  552. struct hda_pcm;
  553. struct hda_pcm_stream;
  554. struct hda_bus_unsolicited;
  555. /* NID type */
  556. typedef u16 hda_nid_t;
  557. /* bus operators */
  558. struct hda_bus_ops {
  559. /* send a single command */
  560. int (*command)(struct hda_bus *bus, unsigned int cmd);
  561. /* get a response from the last command */
  562. unsigned int (*get_response)(struct hda_bus *bus, unsigned int addr);
  563. /* free the private data */
  564. void (*private_free)(struct hda_bus *);
  565. /* attach a PCM stream */
  566. int (*attach_pcm)(struct hda_bus *bus, struct hda_codec *codec,
  567. struct hda_pcm *pcm);
  568. /* reset bus for retry verb */
  569. void (*bus_reset)(struct hda_bus *bus);
  570. #ifdef CONFIG_PM
  571. /* notify power-up/down from codec to controller */
  572. void (*pm_notify)(struct hda_bus *bus, bool power_up);
  573. #endif
  574. #ifdef CONFIG_SND_HDA_DSP_LOADER
  575. /* prepare DSP transfer */
  576. int (*load_dsp_prepare)(struct hda_bus *bus, unsigned int format,
  577. unsigned int byte_size,
  578. struct snd_dma_buffer *bufp);
  579. /* start/stop DSP transfer */
  580. void (*load_dsp_trigger)(struct hda_bus *bus, bool start);
  581. /* clean up DSP transfer */
  582. void (*load_dsp_cleanup)(struct hda_bus *bus,
  583. struct snd_dma_buffer *dmab);
  584. #endif
  585. };
  586. /* template to pass to the bus constructor */
  587. struct hda_bus_template {
  588. void *private_data;
  589. struct pci_dev *pci;
  590. const char *modelname;
  591. int *power_save;
  592. struct hda_bus_ops ops;
  593. };
  594. /*
  595. * codec bus
  596. *
  597. * each controller needs to creata a hda_bus to assign the accessor.
  598. * A hda_bus contains several codecs in the list codec_list.
  599. */
  600. struct hda_bus {
  601. struct snd_card *card;
  602. /* copied from template */
  603. void *private_data;
  604. struct pci_dev *pci;
  605. const char *modelname;
  606. int *power_save;
  607. struct hda_bus_ops ops;
  608. /* codec linked list */
  609. struct list_head codec_list;
  610. /* link caddr -> codec */
  611. struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1];
  612. struct mutex cmd_mutex;
  613. struct mutex prepare_mutex;
  614. /* unsolicited event queue */
  615. struct hda_bus_unsolicited *unsol;
  616. char workq_name[16];
  617. struct workqueue_struct *workq; /* common workqueue for codecs */
  618. /* assigned PCMs */
  619. DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);
  620. /* misc op flags */
  621. unsigned int needs_damn_long_delay :1;
  622. unsigned int allow_bus_reset:1; /* allow bus reset at fatal error */
  623. unsigned int sync_write:1; /* sync after verb write */
  624. /* status for codec/controller */
  625. unsigned int shutdown :1; /* being unloaded */
  626. unsigned int rirb_error:1; /* error in codec communication */
  627. unsigned int response_reset:1; /* controller was reset */
  628. unsigned int in_reset:1; /* during reset operation */
  629. unsigned int power_keep_link_on:1; /* don't power off HDA link */
  630. unsigned int no_response_fallback:1; /* don't fallback at RIRB error */
  631. unsigned int avoid_link_reset:1; /* don't reset link at runtime PM */
  632. int primary_dig_out_type; /* primary digital out PCM type */
  633. };
  634. /*
  635. * codec preset
  636. *
  637. * Known codecs have the patch to build and set up the controls/PCMs
  638. * better than the generic parser.
  639. */
  640. struct hda_codec_preset {
  641. unsigned int id;
  642. unsigned int mask;
  643. unsigned int subs;
  644. unsigned int subs_mask;
  645. unsigned int rev;
  646. hda_nid_t afg, mfg;
  647. const char *name;
  648. int (*patch)(struct hda_codec *codec);
  649. };
  650. struct hda_codec_preset_list {
  651. const struct hda_codec_preset *preset;
  652. struct module *owner;
  653. struct list_head list;
  654. };
  655. /* initial hook */
  656. int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset);
  657. int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset);
  658. /* ops set by the preset patch */
  659. struct hda_codec_ops {
  660. int (*build_controls)(struct hda_codec *codec);
  661. int (*build_pcms)(struct hda_codec *codec);
  662. int (*init)(struct hda_codec *codec);
  663. void (*free)(struct hda_codec *codec);
  664. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  665. void (*set_power_state)(struct hda_codec *codec, hda_nid_t fg,
  666. unsigned int power_state);
  667. #ifdef CONFIG_PM
  668. int (*suspend)(struct hda_codec *codec);
  669. int (*resume)(struct hda_codec *codec);
  670. int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid);
  671. #endif
  672. void (*reboot_notify)(struct hda_codec *codec);
  673. };
  674. /* record for amp information cache */
  675. struct hda_cache_head {
  676. u32 key:31; /* hash key */
  677. u32 dirty:1;
  678. u16 val; /* assigned value */
  679. u16 next;
  680. };
  681. struct hda_amp_info {
  682. struct hda_cache_head head;
  683. u32 amp_caps; /* amp capabilities */
  684. u16 vol[2]; /* current volume & mute */
  685. };
  686. struct hda_cache_rec {
  687. u16 hash[64]; /* hash table for index */
  688. struct snd_array buf; /* record entries */
  689. };
  690. /* PCM callbacks */
  691. struct hda_pcm_ops {
  692. int (*open)(struct hda_pcm_stream *info, struct hda_codec *codec,
  693. struct snd_pcm_substream *substream);
  694. int (*close)(struct hda_pcm_stream *info, struct hda_codec *codec,
  695. struct snd_pcm_substream *substream);
  696. int (*prepare)(struct hda_pcm_stream *info, struct hda_codec *codec,
  697. unsigned int stream_tag, unsigned int format,
  698. struct snd_pcm_substream *substream);
  699. int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec,
  700. struct snd_pcm_substream *substream);
  701. unsigned int (*get_delay)(struct hda_pcm_stream *info,
  702. struct hda_codec *codec,
  703. struct snd_pcm_substream *substream);
  704. };
  705. /* PCM information for each substream */
  706. struct hda_pcm_stream {
  707. unsigned int substreams; /* number of substreams, 0 = not exist*/
  708. unsigned int channels_min; /* min. number of channels */
  709. unsigned int channels_max; /* max. number of channels */
  710. hda_nid_t nid; /* default NID to query rates/formats/bps, or set up */
  711. u32 rates; /* supported rates */
  712. u64 formats; /* supported formats (SNDRV_PCM_FMTBIT_) */
  713. unsigned int maxbps; /* supported max. bit per sample */
  714. const struct snd_pcm_chmap_elem *chmap; /* chmap to override */
  715. struct hda_pcm_ops ops;
  716. };
  717. /* PCM types */
  718. enum {
  719. HDA_PCM_TYPE_AUDIO,
  720. HDA_PCM_TYPE_SPDIF,
  721. HDA_PCM_TYPE_HDMI,
  722. HDA_PCM_TYPE_MODEM,
  723. HDA_PCM_NTYPES
  724. };
  725. /* for PCM creation */
  726. struct hda_pcm {
  727. char *name;
  728. struct hda_pcm_stream stream[2];
  729. unsigned int pcm_type; /* HDA_PCM_TYPE_XXX */
  730. int device; /* device number to assign */
  731. struct snd_pcm *pcm; /* assigned PCM instance */
  732. bool own_chmap; /* codec driver provides own channel maps */
  733. };
  734. /* codec information */
  735. struct hda_codec {
  736. struct hda_bus *bus;
  737. unsigned int addr; /* codec addr*/
  738. struct list_head list; /* list point */
  739. hda_nid_t afg; /* AFG node id */
  740. hda_nid_t mfg; /* MFG node id */
  741. /* ids */
  742. u8 afg_function_id;
  743. u8 mfg_function_id;
  744. u8 afg_unsol;
  745. u8 mfg_unsol;
  746. u32 vendor_id;
  747. u32 subsystem_id;
  748. u32 revision_id;
  749. /* detected preset */
  750. const struct hda_codec_preset *preset;
  751. struct module *owner;
  752. const char *vendor_name; /* codec vendor name */
  753. const char *chip_name; /* codec chip name */
  754. const char *modelname; /* model name for preset */
  755. /* set by patch */
  756. struct hda_codec_ops patch_ops;
  757. /* PCM to create, set by patch_ops.build_pcms callback */
  758. unsigned int num_pcms;
  759. struct hda_pcm *pcm_info;
  760. /* codec specific info */
  761. void *spec;
  762. /* beep device */
  763. struct hda_beep *beep;
  764. unsigned int beep_mode;
  765. /* widget capabilities cache */
  766. unsigned int num_nodes;
  767. hda_nid_t start_nid;
  768. u32 *wcaps;
  769. struct snd_array mixers; /* list of assigned mixer elements */
  770. struct snd_array nids; /* list of mapped mixer elements */
  771. struct hda_cache_rec amp_cache; /* cache for amp access */
  772. struct hda_cache_rec cmd_cache; /* cache for other commands */
  773. struct list_head conn_list; /* linked-list of connection-list */
  774. struct mutex spdif_mutex;
  775. struct mutex control_mutex;
  776. struct mutex hash_mutex;
  777. struct snd_array spdif_out;
  778. unsigned int spdif_in_enable; /* SPDIF input enable? */
  779. const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
  780. struct snd_array init_pins; /* initial (BIOS) pin configurations */
  781. struct snd_array driver_pins; /* pin configs set by codec parser */
  782. struct snd_array cvt_setups; /* audio convert setups */
  783. #ifdef CONFIG_SND_HDA_HWDEP
  784. struct mutex user_mutex;
  785. struct snd_hwdep *hwdep; /* assigned hwdep device */
  786. struct snd_array init_verbs; /* additional init verbs */
  787. struct snd_array hints; /* additional hints */
  788. struct snd_array user_pins; /* default pin configs to override */
  789. #endif
  790. /* misc flags */
  791. unsigned int spdif_status_reset :1; /* needs to toggle SPDIF for each
  792. * status change
  793. * (e.g. Realtek codecs)
  794. */
  795. unsigned int pin_amp_workaround:1; /* pin out-amp takes index
  796. * (e.g. Conexant codecs)
  797. */
  798. unsigned int single_adc_amp:1; /* adc in-amp takes no index
  799. * (e.g. CX20549 codec)
  800. */
  801. unsigned int no_sticky_stream:1; /* no sticky-PCM stream assignment */
  802. unsigned int pins_shutup:1; /* pins are shut up */
  803. unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */
  804. unsigned int no_jack_detect:1; /* Machine has no jack-detection */
  805. unsigned int inv_eapd:1; /* broken h/w: inverted EAPD control */
  806. unsigned int inv_jack_detect:1; /* broken h/w: inverted detection bit */
  807. unsigned int pcm_format_first:1; /* PCM format must be set first */
  808. unsigned int epss:1; /* supporting EPSS? */
  809. unsigned int cached_write:1; /* write only to caches */
  810. unsigned int dp_mst:1; /* support DP1.2 Multi-stream transport */
  811. #ifdef CONFIG_PM
  812. unsigned int power_on :1; /* current (global) power-state */
  813. unsigned int d3_stop_clk:1; /* support D3 operation without BCLK */
  814. unsigned int pm_down_notified:1; /* PM notified to controller */
  815. unsigned int in_pm:1; /* suspend/resume being performed */
  816. int power_transition; /* power-state in transition */
  817. int power_count; /* current (global) power refcount */
  818. struct delayed_work power_work; /* delayed task for powerdown */
  819. unsigned long power_on_acct;
  820. unsigned long power_off_acct;
  821. unsigned long power_jiffies;
  822. spinlock_t power_lock;
  823. #endif
  824. /* filter the requested power state per nid */
  825. unsigned int (*power_filter)(struct hda_codec *codec, hda_nid_t nid,
  826. unsigned int power_state);
  827. /* codec-specific additional proc output */
  828. void (*proc_widget_hook)(struct snd_info_buffer *buffer,
  829. struct hda_codec *codec, hda_nid_t nid);
  830. /* jack detection */
  831. struct snd_array jacktbl;
  832. unsigned long jackpoll_interval; /* In jiffies. Zero means no poll, rely on unsol events */
  833. struct delayed_work jackpoll_work;
  834. #ifdef CONFIG_SND_HDA_INPUT_JACK
  835. /* jack detection */
  836. struct snd_array jacks;
  837. #endif
  838. /* fix-up list */
  839. int fixup_id;
  840. const struct hda_fixup *fixup_list;
  841. const char *fixup_name;
  842. /* additional init verbs */
  843. struct snd_array verbs;
  844. };
  845. /* direction */
  846. enum {
  847. HDA_INPUT, HDA_OUTPUT
  848. };
  849. /* snd_hda_codec_read/write optional flags */
  850. #define HDA_RW_NO_RESPONSE_FALLBACK (1 << 0)
  851. /*
  852. * constructors
  853. */
  854. int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
  855. struct hda_bus **busp);
  856. int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
  857. struct hda_codec **codecp);
  858. int snd_hda_codec_configure(struct hda_codec *codec);
  859. int snd_hda_codec_update_widgets(struct hda_codec *codec);
  860. /*
  861. * low level functions
  862. */
  863. unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
  864. int flags,
  865. unsigned int verb, unsigned int parm);
  866. int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int flags,
  867. unsigned int verb, unsigned int parm);
  868. #define snd_hda_param_read(codec, nid, param) \
  869. snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param)
  870. int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
  871. hda_nid_t *start_id);
  872. int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
  873. hda_nid_t *conn_list, int max_conns);
  874. static inline int
  875. snd_hda_get_num_conns(struct hda_codec *codec, hda_nid_t nid)
  876. {
  877. return snd_hda_get_connections(codec, nid, NULL, 0);
  878. }
  879. int snd_hda_get_num_raw_conns(struct hda_codec *codec, hda_nid_t nid);
  880. int snd_hda_get_raw_connections(struct hda_codec *codec, hda_nid_t nid,
  881. hda_nid_t *conn_list, int max_conns);
  882. int snd_hda_get_conn_list(struct hda_codec *codec, hda_nid_t nid,
  883. const hda_nid_t **listp);
  884. int snd_hda_override_conn_list(struct hda_codec *codec, hda_nid_t nid, int nums,
  885. const hda_nid_t *list);
  886. int snd_hda_get_conn_index(struct hda_codec *codec, hda_nid_t mux,
  887. hda_nid_t nid, int recursive);
  888. int snd_hda_get_devices(struct hda_codec *codec, hda_nid_t nid,
  889. u8 *dev_list, int max_devices);
  890. int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
  891. u32 *ratesp, u64 *formatsp, unsigned int *bpsp);
  892. struct hda_verb {
  893. hda_nid_t nid;
  894. u32 verb;
  895. u32 param;
  896. };
  897. void snd_hda_sequence_write(struct hda_codec *codec,
  898. const struct hda_verb *seq);
  899. /* unsolicited event */
  900. int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex);
  901. /* cached write */
  902. int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
  903. int flags, unsigned int verb, unsigned int parm);
  904. void snd_hda_sequence_write_cache(struct hda_codec *codec,
  905. const struct hda_verb *seq);
  906. int snd_hda_codec_update_cache(struct hda_codec *codec, hda_nid_t nid,
  907. int flags, unsigned int verb, unsigned int parm);
  908. void snd_hda_codec_resume_cache(struct hda_codec *codec);
  909. /* both for cmd & amp caches */
  910. void snd_hda_codec_flush_cache(struct hda_codec *codec);
  911. /* the struct for codec->pin_configs */
  912. struct hda_pincfg {
  913. hda_nid_t nid;
  914. unsigned char ctrl; /* original pin control value */
  915. unsigned char target; /* target pin control value */
  916. unsigned int cfg; /* default configuration */
  917. };
  918. unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid);
  919. int snd_hda_codec_set_pincfg(struct hda_codec *codec, hda_nid_t nid,
  920. unsigned int cfg);
  921. int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
  922. hda_nid_t nid, unsigned int cfg); /* for hwdep */
  923. void snd_hda_shutup_pins(struct hda_codec *codec);
  924. /* SPDIF controls */
  925. struct hda_spdif_out {
  926. hda_nid_t nid; /* Converter nid values relate to */
  927. unsigned int status; /* IEC958 status bits */
  928. unsigned short ctls; /* SPDIF control bits */
  929. };
  930. struct hda_spdif_out *snd_hda_spdif_out_of_nid(struct hda_codec *codec,
  931. hda_nid_t nid);
  932. void snd_hda_spdif_ctls_unassign(struct hda_codec *codec, int idx);
  933. void snd_hda_spdif_ctls_assign(struct hda_codec *codec, int idx, hda_nid_t nid);
  934. /*
  935. * Mixer
  936. */
  937. int snd_hda_build_controls(struct hda_bus *bus);
  938. int snd_hda_codec_build_controls(struct hda_codec *codec);
  939. /*
  940. * PCM
  941. */
  942. int snd_hda_build_pcms(struct hda_bus *bus);
  943. int snd_hda_codec_build_pcms(struct hda_codec *codec);
  944. int snd_hda_codec_prepare(struct hda_codec *codec,
  945. struct hda_pcm_stream *hinfo,
  946. unsigned int stream,
  947. unsigned int format,
  948. struct snd_pcm_substream *substream);
  949. void snd_hda_codec_cleanup(struct hda_codec *codec,
  950. struct hda_pcm_stream *hinfo,
  951. struct snd_pcm_substream *substream);
  952. void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
  953. u32 stream_tag,
  954. int channel_id, int format);
  955. void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid,
  956. int do_now);
  957. #define snd_hda_codec_cleanup_stream(codec, nid) \
  958. __snd_hda_codec_cleanup_stream(codec, nid, 0)
  959. unsigned int snd_hda_calc_stream_format(unsigned int rate,
  960. unsigned int channels,
  961. unsigned int format,
  962. unsigned int maxbps,
  963. unsigned short spdif_ctls);
  964. int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
  965. unsigned int format);
  966. extern const struct snd_pcm_chmap_elem snd_pcm_2_1_chmaps[];
  967. /*
  968. * Misc
  969. */
  970. void snd_hda_get_codec_name(struct hda_codec *codec, char *name, int namelen);
  971. void snd_hda_bus_reboot_notify(struct hda_bus *bus);
  972. void snd_hda_codec_set_power_to_all(struct hda_codec *codec, hda_nid_t fg,
  973. unsigned int power_state);
  974. int snd_hda_lock_devices(struct hda_bus *bus);
  975. void snd_hda_unlock_devices(struct hda_bus *bus);
  976. /*
  977. * power management
  978. */
  979. #ifdef CONFIG_PM
  980. int snd_hda_suspend(struct hda_bus *bus);
  981. int snd_hda_resume(struct hda_bus *bus);
  982. #endif
  983. static inline
  984. int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  985. {
  986. #ifdef CONFIG_PM
  987. if (codec->patch_ops.check_power_status)
  988. return codec->patch_ops.check_power_status(codec, nid);
  989. #endif
  990. return 0;
  991. }
  992. /*
  993. * get widget information
  994. */
  995. const char *snd_hda_get_jack_connectivity(u32 cfg);
  996. const char *snd_hda_get_jack_type(u32 cfg);
  997. const char *snd_hda_get_jack_location(u32 cfg);
  998. /*
  999. * power saving
  1000. */
  1001. #ifdef CONFIG_PM
  1002. void snd_hda_power_save(struct hda_codec *codec, int delta, bool d3wait);
  1003. void snd_hda_update_power_acct(struct hda_codec *codec);
  1004. #else
  1005. static inline void snd_hda_power_save(struct hda_codec *codec, int delta,
  1006. bool d3wait) {}
  1007. #endif
  1008. /**
  1009. * snd_hda_power_up - Power-up the codec
  1010. * @codec: HD-audio codec
  1011. *
  1012. * Increment the power-up counter and power up the hardware really when
  1013. * not turned on yet.
  1014. */
  1015. static inline void snd_hda_power_up(struct hda_codec *codec)
  1016. {
  1017. snd_hda_power_save(codec, 1, false);
  1018. }
  1019. /**
  1020. * snd_hda_power_up_d3wait - Power-up the codec after waiting for any pending
  1021. * D3 transition to complete. This differs from snd_hda_power_up() when
  1022. * power_transition == -1. snd_hda_power_up sees this case as a nop,
  1023. * snd_hda_power_up_d3wait waits for the D3 transition to complete then powers
  1024. * back up.
  1025. * @codec: HD-audio codec
  1026. *
  1027. * Cancel any power down operation hapenning on the work queue, then power up.
  1028. */
  1029. static inline void snd_hda_power_up_d3wait(struct hda_codec *codec)
  1030. {
  1031. snd_hda_power_save(codec, 1, true);
  1032. }
  1033. /**
  1034. * snd_hda_power_down - Power-down the codec
  1035. * @codec: HD-audio codec
  1036. *
  1037. * Decrement the power-up counter and schedules the power-off work if
  1038. * the counter rearches to zero.
  1039. */
  1040. static inline void snd_hda_power_down(struct hda_codec *codec)
  1041. {
  1042. snd_hda_power_save(codec, -1, false);
  1043. }
  1044. /**
  1045. * snd_hda_power_sync - Synchronize the power-save status
  1046. * @codec: HD-audio codec
  1047. *
  1048. * Synchronize the actual power state with the power account;
  1049. * called when power_save parameter is changed
  1050. */
  1051. static inline void snd_hda_power_sync(struct hda_codec *codec)
  1052. {
  1053. snd_hda_power_save(codec, 0, false);
  1054. }
  1055. #ifdef CONFIG_SND_HDA_PATCH_LOADER
  1056. /*
  1057. * patch firmware
  1058. */
  1059. int snd_hda_load_patch(struct hda_bus *bus, size_t size, const void *buf);
  1060. #endif
  1061. #ifdef CONFIG_SND_HDA_DSP_LOADER
  1062. static inline int
  1063. snd_hda_codec_load_dsp_prepare(struct hda_codec *codec, unsigned int format,
  1064. unsigned int size,
  1065. struct snd_dma_buffer *bufp)
  1066. {
  1067. return codec->bus->ops.load_dsp_prepare(codec->bus, format, size, bufp);
  1068. }
  1069. static inline void
  1070. snd_hda_codec_load_dsp_trigger(struct hda_codec *codec, bool start)
  1071. {
  1072. return codec->bus->ops.load_dsp_trigger(codec->bus, start);
  1073. }
  1074. static inline void
  1075. snd_hda_codec_load_dsp_cleanup(struct hda_codec *codec,
  1076. struct snd_dma_buffer *dmab)
  1077. {
  1078. return codec->bus->ops.load_dsp_cleanup(codec->bus, dmab);
  1079. }
  1080. #else
  1081. static inline int
  1082. snd_hda_codec_load_dsp_prepare(struct hda_codec *codec, unsigned int format,
  1083. unsigned int size,
  1084. struct snd_dma_buffer *bufp)
  1085. {
  1086. return -ENOSYS;
  1087. }
  1088. static inline void
  1089. snd_hda_codec_load_dsp_trigger(struct hda_codec *codec, bool start) {}
  1090. static inline void
  1091. snd_hda_codec_load_dsp_cleanup(struct hda_codec *codec,
  1092. struct snd_dma_buffer *dmab) {}
  1093. #endif
  1094. /*
  1095. * Codec modularization
  1096. */
  1097. /* Export symbols only for communication with codec drivers;
  1098. * When built in kernel, all HD-audio drivers are supposed to be statically
  1099. * linked to the kernel. Thus, the symbols don't have to (or shouldn't) be
  1100. * exported unless it's built as a module.
  1101. */
  1102. #ifdef MODULE
  1103. #define EXPORT_SYMBOL_HDA(sym) EXPORT_SYMBOL_GPL(sym)
  1104. #else
  1105. #define EXPORT_SYMBOL_HDA(sym)
  1106. #endif
  1107. #endif /* __SOUND_HDA_CODEC_H */