hda_codec.h 36 KB

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