hda_codec.h 31 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055
  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. #if defined(CONFIG_PM) || defined(CONFIG_SND_HDA_POWER_SAVE)
  27. #define SND_HDA_NEEDS_RESUME /* resume control code is required */
  28. #endif
  29. /*
  30. * nodes
  31. */
  32. #define AC_NODE_ROOT 0x00
  33. /*
  34. * function group types
  35. */
  36. enum {
  37. AC_GRP_AUDIO_FUNCTION = 0x01,
  38. AC_GRP_MODEM_FUNCTION = 0x02,
  39. };
  40. /*
  41. * widget types
  42. */
  43. enum {
  44. AC_WID_AUD_OUT, /* Audio Out */
  45. AC_WID_AUD_IN, /* Audio In */
  46. AC_WID_AUD_MIX, /* Audio Mixer */
  47. AC_WID_AUD_SEL, /* Audio Selector */
  48. AC_WID_PIN, /* Pin Complex */
  49. AC_WID_POWER, /* Power */
  50. AC_WID_VOL_KNB, /* Volume Knob */
  51. AC_WID_BEEP, /* Beep Generator */
  52. AC_WID_VENDOR = 0x0f /* Vendor specific */
  53. };
  54. /*
  55. * GET verbs
  56. */
  57. #define AC_VERB_GET_STREAM_FORMAT 0x0a00
  58. #define AC_VERB_GET_AMP_GAIN_MUTE 0x0b00
  59. #define AC_VERB_GET_PROC_COEF 0x0c00
  60. #define AC_VERB_GET_COEF_INDEX 0x0d00
  61. #define AC_VERB_PARAMETERS 0x0f00
  62. #define AC_VERB_GET_CONNECT_SEL 0x0f01
  63. #define AC_VERB_GET_CONNECT_LIST 0x0f02
  64. #define AC_VERB_GET_PROC_STATE 0x0f03
  65. #define AC_VERB_GET_SDI_SELECT 0x0f04
  66. #define AC_VERB_GET_POWER_STATE 0x0f05
  67. #define AC_VERB_GET_CONV 0x0f06
  68. #define AC_VERB_GET_PIN_WIDGET_CONTROL 0x0f07
  69. #define AC_VERB_GET_UNSOLICITED_RESPONSE 0x0f08
  70. #define AC_VERB_GET_PIN_SENSE 0x0f09
  71. #define AC_VERB_GET_BEEP_CONTROL 0x0f0a
  72. #define AC_VERB_GET_EAPD_BTLENABLE 0x0f0c
  73. #define AC_VERB_GET_DIGI_CONVERT_1 0x0f0d
  74. #define AC_VERB_GET_DIGI_CONVERT_2 0x0f0e /* unused */
  75. #define AC_VERB_GET_VOLUME_KNOB_CONTROL 0x0f0f
  76. /* f10-f1a: GPIO */
  77. #define AC_VERB_GET_GPIO_DATA 0x0f15
  78. #define AC_VERB_GET_GPIO_MASK 0x0f16
  79. #define AC_VERB_GET_GPIO_DIRECTION 0x0f17
  80. #define AC_VERB_GET_GPIO_WAKE_MASK 0x0f18
  81. #define AC_VERB_GET_GPIO_UNSOLICITED_RSP_MASK 0x0f19
  82. #define AC_VERB_GET_GPIO_STICKY_MASK 0x0f1a
  83. #define AC_VERB_GET_CONFIG_DEFAULT 0x0f1c
  84. /* f20: AFG/MFG */
  85. #define AC_VERB_GET_SUBSYSTEM_ID 0x0f20
  86. #define AC_VERB_GET_CVT_CHAN_COUNT 0x0f2d
  87. #define AC_VERB_GET_HDMI_DIP_SIZE 0x0f2e
  88. #define AC_VERB_GET_HDMI_ELDD 0x0f2f
  89. #define AC_VERB_GET_HDMI_DIP_INDEX 0x0f30
  90. #define AC_VERB_GET_HDMI_DIP_DATA 0x0f31
  91. #define AC_VERB_GET_HDMI_DIP_XMIT 0x0f32
  92. #define AC_VERB_GET_HDMI_CP_CTRL 0x0f33
  93. #define AC_VERB_GET_HDMI_CHAN_SLOT 0x0f34
  94. /*
  95. * SET verbs
  96. */
  97. #define AC_VERB_SET_STREAM_FORMAT 0x200
  98. #define AC_VERB_SET_AMP_GAIN_MUTE 0x300
  99. #define AC_VERB_SET_PROC_COEF 0x400
  100. #define AC_VERB_SET_COEF_INDEX 0x500
  101. #define AC_VERB_SET_CONNECT_SEL 0x701
  102. #define AC_VERB_SET_PROC_STATE 0x703
  103. #define AC_VERB_SET_SDI_SELECT 0x704
  104. #define AC_VERB_SET_POWER_STATE 0x705
  105. #define AC_VERB_SET_CHANNEL_STREAMID 0x706
  106. #define AC_VERB_SET_PIN_WIDGET_CONTROL 0x707
  107. #define AC_VERB_SET_UNSOLICITED_ENABLE 0x708
  108. #define AC_VERB_SET_PIN_SENSE 0x709
  109. #define AC_VERB_SET_BEEP_CONTROL 0x70a
  110. #define AC_VERB_SET_EAPD_BTLENABLE 0x70c
  111. #define AC_VERB_SET_DIGI_CONVERT_1 0x70d
  112. #define AC_VERB_SET_DIGI_CONVERT_2 0x70e
  113. #define AC_VERB_SET_VOLUME_KNOB_CONTROL 0x70f
  114. #define AC_VERB_SET_GPIO_DATA 0x715
  115. #define AC_VERB_SET_GPIO_MASK 0x716
  116. #define AC_VERB_SET_GPIO_DIRECTION 0x717
  117. #define AC_VERB_SET_GPIO_WAKE_MASK 0x718
  118. #define AC_VERB_SET_GPIO_UNSOLICITED_RSP_MASK 0x719
  119. #define AC_VERB_SET_GPIO_STICKY_MASK 0x71a
  120. #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_0 0x71c
  121. #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_1 0x71d
  122. #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_2 0x71e
  123. #define AC_VERB_SET_CONFIG_DEFAULT_BYTES_3 0x71f
  124. #define AC_VERB_SET_EAPD 0x788
  125. #define AC_VERB_SET_CODEC_RESET 0x7ff
  126. #define AC_VERB_SET_CVT_CHAN_COUNT 0x72d
  127. #define AC_VERB_SET_HDMI_DIP_INDEX 0x730
  128. #define AC_VERB_SET_HDMI_DIP_DATA 0x731
  129. #define AC_VERB_SET_HDMI_DIP_XMIT 0x732
  130. #define AC_VERB_SET_HDMI_CP_CTRL 0x733
  131. #define AC_VERB_SET_HDMI_CHAN_SLOT 0x734
  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_HDMI_LPCM_CAP 0x20
  153. /*
  154. * AC_VERB_PARAMETERS results (32bit)
  155. */
  156. /* Function Group Type */
  157. #define AC_FGT_TYPE (0xff<<0)
  158. #define AC_FGT_TYPE_SHIFT 0
  159. #define AC_FGT_UNSOL_CAP (1<<8)
  160. /* Audio Function Group Capabilities */
  161. #define AC_AFG_OUT_DELAY (0xf<<0)
  162. #define AC_AFG_IN_DELAY (0xf<<8)
  163. #define AC_AFG_BEEP_GEN (1<<16)
  164. /* Audio Widget Capabilities */
  165. #define AC_WCAP_STEREO (1<<0) /* stereo I/O */
  166. #define AC_WCAP_IN_AMP (1<<1) /* AMP-in present */
  167. #define AC_WCAP_OUT_AMP (1<<2) /* AMP-out present */
  168. #define AC_WCAP_AMP_OVRD (1<<3) /* AMP-parameter override */
  169. #define AC_WCAP_FORMAT_OVRD (1<<4) /* format override */
  170. #define AC_WCAP_STRIPE (1<<5) /* stripe */
  171. #define AC_WCAP_PROC_WID (1<<6) /* Proc Widget */
  172. #define AC_WCAP_UNSOL_CAP (1<<7) /* Unsol capable */
  173. #define AC_WCAP_CONN_LIST (1<<8) /* connection list */
  174. #define AC_WCAP_DIGITAL (1<<9) /* digital I/O */
  175. #define AC_WCAP_POWER (1<<10) /* power control */
  176. #define AC_WCAP_LR_SWAP (1<<11) /* L/R swap */
  177. #define AC_WCAP_CP_CAPS (1<<12) /* content protection */
  178. #define AC_WCAP_CHAN_CNT_EXT (7<<13) /* channel count ext */
  179. #define AC_WCAP_DELAY (0xf<<16)
  180. #define AC_WCAP_DELAY_SHIFT 16
  181. #define AC_WCAP_TYPE (0xf<<20)
  182. #define AC_WCAP_TYPE_SHIFT 20
  183. /* supported PCM rates and bits */
  184. #define AC_SUPPCM_RATES (0xfff << 0)
  185. #define AC_SUPPCM_BITS_8 (1<<16)
  186. #define AC_SUPPCM_BITS_16 (1<<17)
  187. #define AC_SUPPCM_BITS_20 (1<<18)
  188. #define AC_SUPPCM_BITS_24 (1<<19)
  189. #define AC_SUPPCM_BITS_32 (1<<20)
  190. /* supported PCM stream format */
  191. #define AC_SUPFMT_PCM (1<<0)
  192. #define AC_SUPFMT_FLOAT32 (1<<1)
  193. #define AC_SUPFMT_AC3 (1<<2)
  194. /* GP I/O count */
  195. #define AC_GPIO_IO_COUNT (0xff<<0)
  196. #define AC_GPIO_O_COUNT (0xff<<8)
  197. #define AC_GPIO_O_COUNT_SHIFT 8
  198. #define AC_GPIO_I_COUNT (0xff<<16)
  199. #define AC_GPIO_I_COUNT_SHIFT 16
  200. #define AC_GPIO_UNSOLICITED (1<<30)
  201. #define AC_GPIO_WAKE (1<<31)
  202. /* Converter stream, channel */
  203. #define AC_CONV_CHANNEL (0xf<<0)
  204. #define AC_CONV_STREAM (0xf<<4)
  205. #define AC_CONV_STREAM_SHIFT 4
  206. /* Input converter SDI select */
  207. #define AC_SDI_SELECT (0xf<<0)
  208. /* stream format id */
  209. #define AC_FMT_CHAN_SHIFT 0
  210. #define AC_FMT_CHAN_MASK (0x0f << 0)
  211. #define AC_FMT_BITS_SHIFT 4
  212. #define AC_FMT_BITS_MASK (7 << 4)
  213. #define AC_FMT_BITS_8 (0 << 4)
  214. #define AC_FMT_BITS_16 (1 << 4)
  215. #define AC_FMT_BITS_20 (2 << 4)
  216. #define AC_FMT_BITS_24 (3 << 4)
  217. #define AC_FMT_BITS_32 (4 << 4)
  218. #define AC_FMT_DIV_SHIFT 8
  219. #define AC_FMT_DIV_MASK (7 << 8)
  220. #define AC_FMT_MULT_SHIFT 11
  221. #define AC_FMT_MULT_MASK (7 << 11)
  222. #define AC_FMT_BASE_SHIFT 14
  223. #define AC_FMT_BASE_48K (0 << 14)
  224. #define AC_FMT_BASE_44K (1 << 14)
  225. #define AC_FMT_TYPE_SHIFT 15
  226. #define AC_FMT_TYPE_PCM (0 << 15)
  227. #define AC_FMT_TYPE_NON_PCM (1 << 15)
  228. /* Unsolicited response control */
  229. #define AC_UNSOL_TAG (0x3f<<0)
  230. #define AC_UNSOL_ENABLED (1<<7)
  231. #define AC_USRSP_EN AC_UNSOL_ENABLED
  232. /* Unsolicited responses */
  233. #define AC_UNSOL_RES_TAG (0x3f<<26)
  234. #define AC_UNSOL_RES_TAG_SHIFT 26
  235. #define AC_UNSOL_RES_SUBTAG (0x1f<<21)
  236. #define AC_UNSOL_RES_SUBTAG_SHIFT 21
  237. #define AC_UNSOL_RES_ELDV (1<<1) /* ELD Data valid (for HDMI) */
  238. #define AC_UNSOL_RES_PD (1<<0) /* pinsense detect */
  239. #define AC_UNSOL_RES_CP_STATE (1<<1) /* content protection */
  240. #define AC_UNSOL_RES_CP_READY (1<<0) /* content protection */
  241. /* Pin widget capabilies */
  242. #define AC_PINCAP_IMP_SENSE (1<<0) /* impedance sense capable */
  243. #define AC_PINCAP_TRIG_REQ (1<<1) /* trigger required */
  244. #define AC_PINCAP_PRES_DETECT (1<<2) /* presence detect capable */
  245. #define AC_PINCAP_HP_DRV (1<<3) /* headphone drive capable */
  246. #define AC_PINCAP_OUT (1<<4) /* output capable */
  247. #define AC_PINCAP_IN (1<<5) /* input capable */
  248. #define AC_PINCAP_BALANCE (1<<6) /* balanced I/O capable */
  249. /* Note: This LR_SWAP pincap is defined in the Realtek ALC883 specification,
  250. * but is marked reserved in the Intel HDA specification.
  251. */
  252. #define AC_PINCAP_LR_SWAP (1<<7) /* L/R swap */
  253. /* Note: The same bit as LR_SWAP is newly defined as HDMI capability
  254. * in HD-audio specification
  255. */
  256. #define AC_PINCAP_HDMI (1<<7) /* HDMI pin */
  257. #define AC_PINCAP_DP (1<<24) /* DisplayPort pin, can
  258. * coexist with AC_PINCAP_HDMI
  259. */
  260. #define AC_PINCAP_VREF (0x37<<8)
  261. #define AC_PINCAP_VREF_SHIFT 8
  262. #define AC_PINCAP_EAPD (1<<16) /* EAPD capable */
  263. #define AC_PINCAP_HBR (1<<27) /* High Bit Rate */
  264. /* Vref status (used in pin cap) */
  265. #define AC_PINCAP_VREF_HIZ (1<<0) /* Hi-Z */
  266. #define AC_PINCAP_VREF_50 (1<<1) /* 50% */
  267. #define AC_PINCAP_VREF_GRD (1<<2) /* ground */
  268. #define AC_PINCAP_VREF_80 (1<<4) /* 80% */
  269. #define AC_PINCAP_VREF_100 (1<<5) /* 100% */
  270. /* Amplifier capabilities */
  271. #define AC_AMPCAP_OFFSET (0x7f<<0) /* 0dB offset */
  272. #define AC_AMPCAP_OFFSET_SHIFT 0
  273. #define AC_AMPCAP_NUM_STEPS (0x7f<<8) /* number of steps */
  274. #define AC_AMPCAP_NUM_STEPS_SHIFT 8
  275. #define AC_AMPCAP_STEP_SIZE (0x7f<<16) /* step size 0-32dB
  276. * in 0.25dB
  277. */
  278. #define AC_AMPCAP_STEP_SIZE_SHIFT 16
  279. #define AC_AMPCAP_MUTE (1<<31) /* mute capable */
  280. #define AC_AMPCAP_MUTE_SHIFT 31
  281. /* Connection list */
  282. #define AC_CLIST_LENGTH (0x7f<<0)
  283. #define AC_CLIST_LONG (1<<7)
  284. /* Supported power status */
  285. #define AC_PWRST_D0SUP (1<<0)
  286. #define AC_PWRST_D1SUP (1<<1)
  287. #define AC_PWRST_D2SUP (1<<2)
  288. #define AC_PWRST_D3SUP (1<<3)
  289. #define AC_PWRST_D3COLDSUP (1<<4)
  290. #define AC_PWRST_S3D3COLDSUP (1<<29)
  291. #define AC_PWRST_CLKSTOP (1<<30)
  292. #define AC_PWRST_EPSS (1U<<31)
  293. /* Power state values */
  294. #define AC_PWRST_SETTING (0xf<<0)
  295. #define AC_PWRST_ACTUAL (0xf<<4)
  296. #define AC_PWRST_ACTUAL_SHIFT 4
  297. #define AC_PWRST_D0 0x00
  298. #define AC_PWRST_D1 0x01
  299. #define AC_PWRST_D2 0x02
  300. #define AC_PWRST_D3 0x03
  301. /* Processing capabilies */
  302. #define AC_PCAP_BENIGN (1<<0)
  303. #define AC_PCAP_NUM_COEF (0xff<<8)
  304. #define AC_PCAP_NUM_COEF_SHIFT 8
  305. /* Volume knobs capabilities */
  306. #define AC_KNBCAP_NUM_STEPS (0x7f<<0)
  307. #define AC_KNBCAP_DELTA (1<<7)
  308. /* HDMI LPCM capabilities */
  309. #define AC_LPCMCAP_48K_CP_CHNS (0x0f<<0) /* max channels w/ CP-on */
  310. #define AC_LPCMCAP_48K_NO_CHNS (0x0f<<4) /* max channels w/o CP-on */
  311. #define AC_LPCMCAP_48K_20BIT (1<<8) /* 20b bitrate supported */
  312. #define AC_LPCMCAP_48K_24BIT (1<<9) /* 24b bitrate supported */
  313. #define AC_LPCMCAP_96K_CP_CHNS (0x0f<<10) /* max channels w/ CP-on */
  314. #define AC_LPCMCAP_96K_NO_CHNS (0x0f<<14) /* max channels w/o CP-on */
  315. #define AC_LPCMCAP_96K_20BIT (1<<18) /* 20b bitrate supported */
  316. #define AC_LPCMCAP_96K_24BIT (1<<19) /* 24b bitrate supported */
  317. #define AC_LPCMCAP_192K_CP_CHNS (0x0f<<20) /* max channels w/ CP-on */
  318. #define AC_LPCMCAP_192K_NO_CHNS (0x0f<<24) /* max channels w/o CP-on */
  319. #define AC_LPCMCAP_192K_20BIT (1<<28) /* 20b bitrate supported */
  320. #define AC_LPCMCAP_192K_24BIT (1<<29) /* 24b bitrate supported */
  321. #define AC_LPCMCAP_44K (1<<30) /* 44.1kHz support */
  322. #define AC_LPCMCAP_44K_MS (1<<31) /* 44.1kHz-multiplies support */
  323. /*
  324. * Control Parameters
  325. */
  326. /* Amp gain/mute */
  327. #define AC_AMP_MUTE (1<<7)
  328. #define AC_AMP_GAIN (0x7f)
  329. #define AC_AMP_GET_INDEX (0xf<<0)
  330. #define AC_AMP_GET_LEFT (1<<13)
  331. #define AC_AMP_GET_RIGHT (0<<13)
  332. #define AC_AMP_GET_OUTPUT (1<<15)
  333. #define AC_AMP_GET_INPUT (0<<15)
  334. #define AC_AMP_SET_INDEX (0xf<<8)
  335. #define AC_AMP_SET_INDEX_SHIFT 8
  336. #define AC_AMP_SET_RIGHT (1<<12)
  337. #define AC_AMP_SET_LEFT (1<<13)
  338. #define AC_AMP_SET_INPUT (1<<14)
  339. #define AC_AMP_SET_OUTPUT (1<<15)
  340. /* DIGITAL1 bits */
  341. #define AC_DIG1_ENABLE (1<<0)
  342. #define AC_DIG1_V (1<<1)
  343. #define AC_DIG1_VCFG (1<<2)
  344. #define AC_DIG1_EMPHASIS (1<<3)
  345. #define AC_DIG1_COPYRIGHT (1<<4)
  346. #define AC_DIG1_NONAUDIO (1<<5)
  347. #define AC_DIG1_PROFESSIONAL (1<<6)
  348. #define AC_DIG1_LEVEL (1<<7)
  349. /* DIGITAL2 bits */
  350. #define AC_DIG2_CC (0x7f<<0)
  351. /* Pin widget control - 8bit */
  352. #define AC_PINCTL_EPT (0x3<<0)
  353. #define AC_PINCTL_EPT_NATIVE 0
  354. #define AC_PINCTL_EPT_HBR 3
  355. #define AC_PINCTL_VREFEN (0x7<<0)
  356. #define AC_PINCTL_VREF_HIZ 0 /* Hi-Z */
  357. #define AC_PINCTL_VREF_50 1 /* 50% */
  358. #define AC_PINCTL_VREF_GRD 2 /* ground */
  359. #define AC_PINCTL_VREF_80 4 /* 80% */
  360. #define AC_PINCTL_VREF_100 5 /* 100% */
  361. #define AC_PINCTL_IN_EN (1<<5)
  362. #define AC_PINCTL_OUT_EN (1<<6)
  363. #define AC_PINCTL_HP_EN (1<<7)
  364. /* Pin sense - 32bit */
  365. #define AC_PINSENSE_IMPEDANCE_MASK (0x7fffffff)
  366. #define AC_PINSENSE_PRESENCE (1<<31)
  367. #define AC_PINSENSE_ELDV (1<<30) /* ELD valid (HDMI) */
  368. /* EAPD/BTL enable - 32bit */
  369. #define AC_EAPDBTL_BALANCED (1<<0)
  370. #define AC_EAPDBTL_EAPD (1<<1)
  371. #define AC_EAPDBTL_LR_SWAP (1<<2)
  372. /* HDMI ELD data */
  373. #define AC_ELDD_ELD_VALID (1<<31)
  374. #define AC_ELDD_ELD_DATA 0xff
  375. /* HDMI DIP size */
  376. #define AC_DIPSIZE_ELD_BUF (1<<3) /* ELD buf size of packet size */
  377. #define AC_DIPSIZE_PACK_IDX (0x07<<0) /* packet index */
  378. /* HDMI DIP index */
  379. #define AC_DIPIDX_PACK_IDX (0x07<<5) /* packet idnex */
  380. #define AC_DIPIDX_BYTE_IDX (0x1f<<0) /* byte index */
  381. /* HDMI DIP xmit (transmit) control */
  382. #define AC_DIPXMIT_MASK (0x3<<6)
  383. #define AC_DIPXMIT_DISABLE (0x0<<6) /* disable xmit */
  384. #define AC_DIPXMIT_ONCE (0x2<<6) /* xmit once then disable */
  385. #define AC_DIPXMIT_BEST (0x3<<6) /* best effort */
  386. /* HDMI content protection (CP) control */
  387. #define AC_CPCTRL_CES (1<<9) /* current encryption state */
  388. #define AC_CPCTRL_READY (1<<8) /* ready bit */
  389. #define AC_CPCTRL_SUBTAG (0x1f<<3) /* subtag for unsol-resp */
  390. #define AC_CPCTRL_STATE (3<<0) /* current CP request state */
  391. /* Converter channel <-> HDMI slot mapping */
  392. #define AC_CVTMAP_HDMI_SLOT (0xf<<0) /* HDMI slot number */
  393. #define AC_CVTMAP_CHAN (0xf<<4) /* converter channel number */
  394. /* configuration default - 32bit */
  395. #define AC_DEFCFG_SEQUENCE (0xf<<0)
  396. #define AC_DEFCFG_DEF_ASSOC (0xf<<4)
  397. #define AC_DEFCFG_ASSOC_SHIFT 4
  398. #define AC_DEFCFG_MISC (0xf<<8)
  399. #define AC_DEFCFG_MISC_SHIFT 8
  400. #define AC_DEFCFG_MISC_NO_PRESENCE (1<<0)
  401. #define AC_DEFCFG_COLOR (0xf<<12)
  402. #define AC_DEFCFG_COLOR_SHIFT 12
  403. #define AC_DEFCFG_CONN_TYPE (0xf<<16)
  404. #define AC_DEFCFG_CONN_TYPE_SHIFT 16
  405. #define AC_DEFCFG_DEVICE (0xf<<20)
  406. #define AC_DEFCFG_DEVICE_SHIFT 20
  407. #define AC_DEFCFG_LOCATION (0x3f<<24)
  408. #define AC_DEFCFG_LOCATION_SHIFT 24
  409. #define AC_DEFCFG_PORT_CONN (0x3<<30)
  410. #define AC_DEFCFG_PORT_CONN_SHIFT 30
  411. /* device device types (0x0-0xf) */
  412. enum {
  413. AC_JACK_LINE_OUT,
  414. AC_JACK_SPEAKER,
  415. AC_JACK_HP_OUT,
  416. AC_JACK_CD,
  417. AC_JACK_SPDIF_OUT,
  418. AC_JACK_DIG_OTHER_OUT,
  419. AC_JACK_MODEM_LINE_SIDE,
  420. AC_JACK_MODEM_HAND_SIDE,
  421. AC_JACK_LINE_IN,
  422. AC_JACK_AUX,
  423. AC_JACK_MIC_IN,
  424. AC_JACK_TELEPHONY,
  425. AC_JACK_SPDIF_IN,
  426. AC_JACK_DIG_OTHER_IN,
  427. AC_JACK_OTHER = 0xf,
  428. };
  429. /* jack connection types (0x0-0xf) */
  430. enum {
  431. AC_JACK_CONN_UNKNOWN,
  432. AC_JACK_CONN_1_8,
  433. AC_JACK_CONN_1_4,
  434. AC_JACK_CONN_ATAPI,
  435. AC_JACK_CONN_RCA,
  436. AC_JACK_CONN_OPTICAL,
  437. AC_JACK_CONN_OTHER_DIGITAL,
  438. AC_JACK_CONN_OTHER_ANALOG,
  439. AC_JACK_CONN_DIN,
  440. AC_JACK_CONN_XLR,
  441. AC_JACK_CONN_RJ11,
  442. AC_JACK_CONN_COMB,
  443. AC_JACK_CONN_OTHER = 0xf,
  444. };
  445. /* jack colors (0x0-0xf) */
  446. enum {
  447. AC_JACK_COLOR_UNKNOWN,
  448. AC_JACK_COLOR_BLACK,
  449. AC_JACK_COLOR_GREY,
  450. AC_JACK_COLOR_BLUE,
  451. AC_JACK_COLOR_GREEN,
  452. AC_JACK_COLOR_RED,
  453. AC_JACK_COLOR_ORANGE,
  454. AC_JACK_COLOR_YELLOW,
  455. AC_JACK_COLOR_PURPLE,
  456. AC_JACK_COLOR_PINK,
  457. AC_JACK_COLOR_WHITE = 0xe,
  458. AC_JACK_COLOR_OTHER,
  459. };
  460. /* Jack location (0x0-0x3f) */
  461. /* common case */
  462. enum {
  463. AC_JACK_LOC_NONE,
  464. AC_JACK_LOC_REAR,
  465. AC_JACK_LOC_FRONT,
  466. AC_JACK_LOC_LEFT,
  467. AC_JACK_LOC_RIGHT,
  468. AC_JACK_LOC_TOP,
  469. AC_JACK_LOC_BOTTOM,
  470. };
  471. /* bits 4-5 */
  472. enum {
  473. AC_JACK_LOC_EXTERNAL = 0x00,
  474. AC_JACK_LOC_INTERNAL = 0x10,
  475. AC_JACK_LOC_SEPARATE = 0x20,
  476. AC_JACK_LOC_OTHER = 0x30,
  477. };
  478. enum {
  479. /* external on primary chasis */
  480. AC_JACK_LOC_REAR_PANEL = 0x07,
  481. AC_JACK_LOC_DRIVE_BAY,
  482. /* internal */
  483. AC_JACK_LOC_RISER = 0x17,
  484. AC_JACK_LOC_HDMI,
  485. AC_JACK_LOC_ATAPI,
  486. /* others */
  487. AC_JACK_LOC_MOBILE_IN = 0x37,
  488. AC_JACK_LOC_MOBILE_OUT,
  489. };
  490. /* Port connectivity (0-3) */
  491. enum {
  492. AC_JACK_PORT_COMPLEX,
  493. AC_JACK_PORT_NONE,
  494. AC_JACK_PORT_FIXED,
  495. AC_JACK_PORT_BOTH,
  496. };
  497. /* max. connections to a widget */
  498. #define HDA_MAX_CONNECTIONS 32
  499. /* max. codec address */
  500. #define HDA_MAX_CODEC_ADDRESS 0x0f
  501. /* max number of PCM devics per card */
  502. #define HDA_MAX_PCMS 10
  503. /*
  504. * generic arrays
  505. */
  506. struct snd_array {
  507. unsigned int used;
  508. unsigned int alloced;
  509. unsigned int elem_size;
  510. unsigned int alloc_align;
  511. void *list;
  512. };
  513. void *snd_array_new(struct snd_array *array);
  514. void snd_array_free(struct snd_array *array);
  515. static inline void snd_array_init(struct snd_array *array, unsigned int size,
  516. unsigned int align)
  517. {
  518. array->elem_size = size;
  519. array->alloc_align = align;
  520. }
  521. static inline void *snd_array_elem(struct snd_array *array, unsigned int idx)
  522. {
  523. return array->list + idx * array->elem_size;
  524. }
  525. static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
  526. {
  527. return (unsigned long)(ptr - array->list) / array->elem_size;
  528. }
  529. /*
  530. * Structures
  531. */
  532. struct hda_bus;
  533. struct hda_beep;
  534. struct hda_codec;
  535. struct hda_pcm;
  536. struct hda_pcm_stream;
  537. struct hda_bus_unsolicited;
  538. /* NID type */
  539. typedef u16 hda_nid_t;
  540. /* bus operators */
  541. struct hda_bus_ops {
  542. /* send a single command */
  543. int (*command)(struct hda_bus *bus, unsigned int cmd);
  544. /* get a response from the last command */
  545. unsigned int (*get_response)(struct hda_bus *bus, unsigned int addr);
  546. /* free the private data */
  547. void (*private_free)(struct hda_bus *);
  548. /* attach a PCM stream */
  549. int (*attach_pcm)(struct hda_bus *bus, struct hda_codec *codec,
  550. struct hda_pcm *pcm);
  551. /* reset bus for retry verb */
  552. void (*bus_reset)(struct hda_bus *bus);
  553. #ifdef CONFIG_SND_HDA_POWER_SAVE
  554. /* notify power-up/down from codec to controller */
  555. void (*pm_notify)(struct hda_bus *bus);
  556. #endif
  557. };
  558. /* template to pass to the bus constructor */
  559. struct hda_bus_template {
  560. void *private_data;
  561. struct pci_dev *pci;
  562. const char *modelname;
  563. int *power_save;
  564. struct hda_bus_ops ops;
  565. };
  566. /*
  567. * codec bus
  568. *
  569. * each controller needs to creata a hda_bus to assign the accessor.
  570. * A hda_bus contains several codecs in the list codec_list.
  571. */
  572. struct hda_bus {
  573. struct snd_card *card;
  574. /* copied from template */
  575. void *private_data;
  576. struct pci_dev *pci;
  577. const char *modelname;
  578. int *power_save;
  579. struct hda_bus_ops ops;
  580. /* codec linked list */
  581. struct list_head codec_list;
  582. /* link caddr -> codec */
  583. struct hda_codec *caddr_tbl[HDA_MAX_CODEC_ADDRESS + 1];
  584. struct mutex cmd_mutex;
  585. struct mutex prepare_mutex;
  586. /* unsolicited event queue */
  587. struct hda_bus_unsolicited *unsol;
  588. char workq_name[16];
  589. struct workqueue_struct *workq; /* common workqueue for codecs */
  590. /* assigned PCMs */
  591. DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);
  592. /* misc op flags */
  593. unsigned int needs_damn_long_delay :1;
  594. unsigned int allow_bus_reset:1; /* allow bus reset at fatal error */
  595. unsigned int sync_write:1; /* sync after verb write */
  596. /* status for codec/controller */
  597. unsigned int shutdown :1; /* being unloaded */
  598. unsigned int rirb_error:1; /* error in codec communication */
  599. unsigned int response_reset:1; /* controller was reset */
  600. unsigned int in_reset:1; /* during reset operation */
  601. unsigned int power_keep_link_on:1; /* don't power off HDA link */
  602. };
  603. /*
  604. * codec preset
  605. *
  606. * Known codecs have the patch to build and set up the controls/PCMs
  607. * better than the generic parser.
  608. */
  609. struct hda_codec_preset {
  610. unsigned int id;
  611. unsigned int mask;
  612. unsigned int subs;
  613. unsigned int subs_mask;
  614. unsigned int rev;
  615. hda_nid_t afg, mfg;
  616. const char *name;
  617. int (*patch)(struct hda_codec *codec);
  618. };
  619. struct hda_codec_preset_list {
  620. const struct hda_codec_preset *preset;
  621. struct module *owner;
  622. struct list_head list;
  623. };
  624. /* initial hook */
  625. int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset);
  626. int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset);
  627. /* ops set by the preset patch */
  628. struct hda_codec_ops {
  629. int (*build_controls)(struct hda_codec *codec);
  630. int (*build_pcms)(struct hda_codec *codec);
  631. int (*init)(struct hda_codec *codec);
  632. void (*free)(struct hda_codec *codec);
  633. void (*unsol_event)(struct hda_codec *codec, unsigned int res);
  634. #ifdef SND_HDA_NEEDS_RESUME
  635. int (*suspend)(struct hda_codec *codec, pm_message_t state);
  636. int (*resume)(struct hda_codec *codec);
  637. #endif
  638. #ifdef CONFIG_SND_HDA_POWER_SAVE
  639. int (*check_power_status)(struct hda_codec *codec, hda_nid_t nid);
  640. #endif
  641. void (*reboot_notify)(struct hda_codec *codec);
  642. };
  643. /* record for amp information cache */
  644. struct hda_cache_head {
  645. u32 key; /* hash key */
  646. u16 val; /* assigned value */
  647. u16 next; /* next link; -1 = terminal */
  648. };
  649. struct hda_amp_info {
  650. struct hda_cache_head head;
  651. u32 amp_caps; /* amp capabilities */
  652. u16 vol[2]; /* current volume & mute */
  653. };
  654. struct hda_cache_rec {
  655. u16 hash[64]; /* hash table for index */
  656. struct snd_array buf; /* record entries */
  657. };
  658. /* PCM callbacks */
  659. struct hda_pcm_ops {
  660. int (*open)(struct hda_pcm_stream *info, struct hda_codec *codec,
  661. struct snd_pcm_substream *substream);
  662. int (*close)(struct hda_pcm_stream *info, struct hda_codec *codec,
  663. struct snd_pcm_substream *substream);
  664. int (*prepare)(struct hda_pcm_stream *info, struct hda_codec *codec,
  665. unsigned int stream_tag, unsigned int format,
  666. struct snd_pcm_substream *substream);
  667. int (*cleanup)(struct hda_pcm_stream *info, struct hda_codec *codec,
  668. struct snd_pcm_substream *substream);
  669. };
  670. /* PCM information for each substream */
  671. struct hda_pcm_stream {
  672. unsigned int substreams; /* number of substreams, 0 = not exist*/
  673. unsigned int channels_min; /* min. number of channels */
  674. unsigned int channels_max; /* max. number of channels */
  675. hda_nid_t nid; /* default NID to query rates/formats/bps, or set up */
  676. u32 rates; /* supported rates */
  677. u64 formats; /* supported formats (SNDRV_PCM_FMTBIT_) */
  678. unsigned int maxbps; /* supported max. bit per sample */
  679. struct hda_pcm_ops ops;
  680. };
  681. /* PCM types */
  682. enum {
  683. HDA_PCM_TYPE_AUDIO,
  684. HDA_PCM_TYPE_SPDIF,
  685. HDA_PCM_TYPE_HDMI,
  686. HDA_PCM_TYPE_MODEM,
  687. HDA_PCM_NTYPES
  688. };
  689. /* for PCM creation */
  690. struct hda_pcm {
  691. char *name;
  692. struct hda_pcm_stream stream[2];
  693. unsigned int pcm_type; /* HDA_PCM_TYPE_XXX */
  694. int device; /* device number to assign */
  695. struct snd_pcm *pcm; /* assigned PCM instance */
  696. };
  697. /* codec information */
  698. struct hda_codec {
  699. struct hda_bus *bus;
  700. unsigned int addr; /* codec addr*/
  701. struct list_head list; /* list point */
  702. hda_nid_t afg; /* AFG node id */
  703. hda_nid_t mfg; /* MFG node id */
  704. /* ids */
  705. u8 afg_function_id;
  706. u8 mfg_function_id;
  707. u8 afg_unsol;
  708. u8 mfg_unsol;
  709. u32 vendor_id;
  710. u32 subsystem_id;
  711. u32 revision_id;
  712. /* detected preset */
  713. const struct hda_codec_preset *preset;
  714. struct module *owner;
  715. const char *vendor_name; /* codec vendor name */
  716. const char *chip_name; /* codec chip name */
  717. const char *modelname; /* model name for preset */
  718. /* set by patch */
  719. struct hda_codec_ops patch_ops;
  720. /* PCM to create, set by patch_ops.build_pcms callback */
  721. unsigned int num_pcms;
  722. struct hda_pcm *pcm_info;
  723. /* codec specific info */
  724. void *spec;
  725. /* beep device */
  726. struct hda_beep *beep;
  727. unsigned int beep_mode;
  728. /* widget capabilities cache */
  729. unsigned int num_nodes;
  730. hda_nid_t start_nid;
  731. u32 *wcaps;
  732. struct snd_array mixers; /* list of assigned mixer elements */
  733. struct snd_array nids; /* list of mapped mixer elements */
  734. struct hda_cache_rec amp_cache; /* cache for amp access */
  735. struct hda_cache_rec cmd_cache; /* cache for other commands */
  736. struct snd_array conn_lists; /* connection-list array */
  737. struct mutex spdif_mutex;
  738. struct mutex control_mutex;
  739. unsigned int spdif_status; /* IEC958 status bits */
  740. unsigned short spdif_ctls; /* SPDIF control bits */
  741. unsigned int spdif_in_enable; /* SPDIF input enable? */
  742. const hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
  743. struct snd_array init_pins; /* initial (BIOS) pin configurations */
  744. struct snd_array driver_pins; /* pin configs set by codec parser */
  745. struct snd_array cvt_setups; /* audio convert setups */
  746. #ifdef CONFIG_SND_HDA_HWDEP
  747. struct snd_hwdep *hwdep; /* assigned hwdep device */
  748. struct snd_array init_verbs; /* additional init verbs */
  749. struct snd_array hints; /* additional hints */
  750. struct snd_array user_pins; /* default pin configs to override */
  751. #endif
  752. /* misc flags */
  753. unsigned int spdif_status_reset :1; /* needs to toggle SPDIF for each
  754. * status change
  755. * (e.g. Realtek codecs)
  756. */
  757. unsigned int pin_amp_workaround:1; /* pin out-amp takes index
  758. * (e.g. Conexant codecs)
  759. */
  760. unsigned int no_sticky_stream:1; /* no sticky-PCM stream assignment */
  761. unsigned int pins_shutup:1; /* pins are shut up */
  762. unsigned int no_trigger_sense:1; /* don't trigger at pin-sensing */
  763. #ifdef CONFIG_SND_HDA_POWER_SAVE
  764. unsigned int power_on :1; /* current (global) power-state */
  765. unsigned int power_transition :1; /* power-state in transition */
  766. int power_count; /* current (global) power refcount */
  767. struct delayed_work power_work; /* delayed task for powerdown */
  768. unsigned long power_on_acct;
  769. unsigned long power_off_acct;
  770. unsigned long power_jiffies;
  771. #endif
  772. /* codec-specific additional proc output */
  773. void (*proc_widget_hook)(struct snd_info_buffer *buffer,
  774. struct hda_codec *codec, hda_nid_t nid);
  775. #ifdef CONFIG_SND_HDA_INPUT_JACK
  776. /* jack detection */
  777. struct snd_array jacks;
  778. #endif
  779. };
  780. /* direction */
  781. enum {
  782. HDA_INPUT, HDA_OUTPUT
  783. };
  784. /*
  785. * constructors
  786. */
  787. int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
  788. struct hda_bus **busp);
  789. int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
  790. struct hda_codec **codecp);
  791. int snd_hda_codec_configure(struct hda_codec *codec);
  792. /*
  793. * low level functions
  794. */
  795. unsigned int snd_hda_codec_read(struct hda_codec *codec, hda_nid_t nid,
  796. int direct,
  797. unsigned int verb, unsigned int parm);
  798. int snd_hda_codec_write(struct hda_codec *codec, hda_nid_t nid, int direct,
  799. unsigned int verb, unsigned int parm);
  800. #define snd_hda_param_read(codec, nid, param) \
  801. snd_hda_codec_read(codec, nid, 0, AC_VERB_PARAMETERS, param)
  802. int snd_hda_get_sub_nodes(struct hda_codec *codec, hda_nid_t nid,
  803. hda_nid_t *start_id);
  804. int snd_hda_get_connections(struct hda_codec *codec, hda_nid_t nid,
  805. hda_nid_t *conn_list, int max_conns);
  806. struct hda_verb {
  807. hda_nid_t nid;
  808. u32 verb;
  809. u32 param;
  810. };
  811. void snd_hda_sequence_write(struct hda_codec *codec,
  812. const struct hda_verb *seq);
  813. /* unsolicited event */
  814. int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex);
  815. /* cached write */
  816. #ifdef SND_HDA_NEEDS_RESUME
  817. int snd_hda_codec_write_cache(struct hda_codec *codec, hda_nid_t nid,
  818. int direct, unsigned int verb, unsigned int parm);
  819. void snd_hda_sequence_write_cache(struct hda_codec *codec,
  820. const struct hda_verb *seq);
  821. int snd_hda_codec_update_cache(struct hda_codec *codec, hda_nid_t nid,
  822. int direct, unsigned int verb, unsigned int parm);
  823. void snd_hda_codec_resume_cache(struct hda_codec *codec);
  824. #else
  825. #define snd_hda_codec_write_cache snd_hda_codec_write
  826. #define snd_hda_codec_update_cache snd_hda_codec_write
  827. #define snd_hda_sequence_write_cache snd_hda_sequence_write
  828. #endif
  829. /* the struct for codec->pin_configs */
  830. struct hda_pincfg {
  831. hda_nid_t nid;
  832. unsigned char ctrl; /* current pin control value */
  833. unsigned char pad; /* reserved */
  834. unsigned int cfg; /* default configuration */
  835. };
  836. unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid);
  837. int snd_hda_codec_set_pincfg(struct hda_codec *codec, hda_nid_t nid,
  838. unsigned int cfg);
  839. int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
  840. hda_nid_t nid, unsigned int cfg); /* for hwdep */
  841. void snd_hda_shutup_pins(struct hda_codec *codec);
  842. /*
  843. * Mixer
  844. */
  845. int snd_hda_build_controls(struct hda_bus *bus);
  846. int snd_hda_codec_build_controls(struct hda_codec *codec);
  847. /*
  848. * PCM
  849. */
  850. int snd_hda_build_pcms(struct hda_bus *bus);
  851. int snd_hda_codec_build_pcms(struct hda_codec *codec);
  852. int snd_hda_codec_prepare(struct hda_codec *codec,
  853. struct hda_pcm_stream *hinfo,
  854. unsigned int stream,
  855. unsigned int format,
  856. struct snd_pcm_substream *substream);
  857. void snd_hda_codec_cleanup(struct hda_codec *codec,
  858. struct hda_pcm_stream *hinfo,
  859. struct snd_pcm_substream *substream);
  860. void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
  861. u32 stream_tag,
  862. int channel_id, int format);
  863. void __snd_hda_codec_cleanup_stream(struct hda_codec *codec, hda_nid_t nid,
  864. int do_now);
  865. #define snd_hda_codec_cleanup_stream(codec, nid) \
  866. __snd_hda_codec_cleanup_stream(codec, nid, 0)
  867. unsigned int snd_hda_calc_stream_format(unsigned int rate,
  868. unsigned int channels,
  869. unsigned int format,
  870. unsigned int maxbps,
  871. unsigned short spdif_ctls);
  872. int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
  873. unsigned int format);
  874. /*
  875. * Misc
  876. */
  877. void snd_hda_get_codec_name(struct hda_codec *codec, char *name, int namelen);
  878. void snd_hda_bus_reboot_notify(struct hda_bus *bus);
  879. /*
  880. * power management
  881. */
  882. #ifdef CONFIG_PM
  883. int snd_hda_suspend(struct hda_bus *bus);
  884. int snd_hda_resume(struct hda_bus *bus);
  885. #endif
  886. #ifdef CONFIG_SND_HDA_POWER_SAVE
  887. static inline
  888. int hda_call_check_power_status(struct hda_codec *codec, hda_nid_t nid)
  889. {
  890. if (codec->patch_ops.check_power_status)
  891. return codec->patch_ops.check_power_status(codec, nid);
  892. return 0;
  893. }
  894. #else
  895. #define hda_call_check_power_status(codec, nid) 0
  896. #endif
  897. /*
  898. * get widget information
  899. */
  900. const char *snd_hda_get_jack_connectivity(u32 cfg);
  901. const char *snd_hda_get_jack_type(u32 cfg);
  902. const char *snd_hda_get_jack_location(u32 cfg);
  903. /*
  904. * power saving
  905. */
  906. #ifdef CONFIG_SND_HDA_POWER_SAVE
  907. void snd_hda_power_up(struct hda_codec *codec);
  908. void snd_hda_power_down(struct hda_codec *codec);
  909. #define snd_hda_codec_needs_resume(codec) codec->power_count
  910. void snd_hda_update_power_acct(struct hda_codec *codec);
  911. #else
  912. static inline void snd_hda_power_up(struct hda_codec *codec) {}
  913. static inline void snd_hda_power_down(struct hda_codec *codec) {}
  914. #define snd_hda_codec_needs_resume(codec) 1
  915. #endif
  916. #ifdef CONFIG_SND_HDA_PATCH_LOADER
  917. /*
  918. * patch firmware
  919. */
  920. int snd_hda_load_patch(struct hda_bus *bus, const char *patch);
  921. #endif
  922. /*
  923. * Codec modularization
  924. */
  925. /* Export symbols only for communication with codec drivers;
  926. * When built in kernel, all HD-audio drivers are supposed to be statically
  927. * linked to the kernel. Thus, the symbols don't have to (or shouldn't) be
  928. * exported unless it's built as a module.
  929. */
  930. #ifdef MODULE
  931. #define EXPORT_SYMBOL_HDA(sym) EXPORT_SYMBOL_GPL(sym)
  932. #else
  933. #define EXPORT_SYMBOL_HDA(sym)
  934. #endif
  935. #endif /* __SOUND_HDA_CODEC_H */