patch_hdmi.c 46 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639
  1. /*
  2. *
  3. * patch_hdmi.c - routines for HDMI/DisplayPort codecs
  4. *
  5. * Copyright(c) 2008-2010 Intel Corporation. All rights reserved.
  6. * Copyright (c) 2006 ATI Technologies Inc.
  7. * Copyright (c) 2008 NVIDIA Corp. All rights reserved.
  8. * Copyright (c) 2008 Wei Ni <wni@nvidia.com>
  9. *
  10. * Authors:
  11. * Wu Fengguang <wfg@linux.intel.com>
  12. *
  13. * Maintained by:
  14. * Wu Fengguang <wfg@linux.intel.com>
  15. *
  16. * This program is free software; you can redistribute it and/or modify it
  17. * under the terms of the GNU General Public License as published by the Free
  18. * Software Foundation; either version 2 of the License, or (at your option)
  19. * any later version.
  20. *
  21. * This program is distributed in the hope that it will be useful, but
  22. * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
  23. * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
  24. * for more details.
  25. *
  26. * You should have received a copy of the GNU General Public License
  27. * along with this program; if not, write to the Free Software Foundation,
  28. * Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  29. */
  30. #include <linux/init.h>
  31. #include <linux/delay.h>
  32. #include <linux/slab.h>
  33. #include <sound/core.h>
  34. #include "hda_codec.h"
  35. #include "hda_local.h"
  36. /*
  37. * The HDMI/DisplayPort configuration can be highly dynamic. A graphics device
  38. * could support two independent pipes, each of them can be connected to one or
  39. * more ports (DVI, HDMI or DisplayPort).
  40. *
  41. * The HDA correspondence of pipes/ports are converter/pin nodes.
  42. */
  43. #define MAX_HDMI_CVTS 3
  44. #define MAX_HDMI_PINS 3
  45. struct hdmi_spec {
  46. int num_cvts;
  47. int num_pins;
  48. hda_nid_t cvt[MAX_HDMI_CVTS+1]; /* audio sources */
  49. hda_nid_t pin[MAX_HDMI_PINS+1]; /* audio sinks */
  50. /*
  51. * source connection for each pin
  52. */
  53. hda_nid_t pin_cvt[MAX_HDMI_PINS+1];
  54. /*
  55. * HDMI sink attached to each pin
  56. */
  57. struct hdmi_eld sink_eld[MAX_HDMI_PINS];
  58. /*
  59. * export one pcm per pipe
  60. */
  61. struct hda_pcm pcm_rec[MAX_HDMI_CVTS];
  62. struct hda_pcm_stream codec_pcm_pars[MAX_HDMI_CVTS];
  63. /*
  64. * ati/nvhdmi specific
  65. */
  66. struct hda_multi_out multiout;
  67. struct hda_pcm_stream *pcm_playback;
  68. /* misc flags */
  69. /* PD bit indicates only the update, not the current state */
  70. unsigned int old_pin_detect:1;
  71. };
  72. struct hdmi_audio_infoframe {
  73. u8 type; /* 0x84 */
  74. u8 ver; /* 0x01 */
  75. u8 len; /* 0x0a */
  76. u8 checksum;
  77. u8 CC02_CT47; /* CC in bits 0:2, CT in 4:7 */
  78. u8 SS01_SF24;
  79. u8 CXT04;
  80. u8 CA;
  81. u8 LFEPBL01_LSV36_DM_INH7;
  82. };
  83. struct dp_audio_infoframe {
  84. u8 type; /* 0x84 */
  85. u8 len; /* 0x1b */
  86. u8 ver; /* 0x11 << 2 */
  87. u8 CC02_CT47; /* match with HDMI infoframe from this on */
  88. u8 SS01_SF24;
  89. u8 CXT04;
  90. u8 CA;
  91. u8 LFEPBL01_LSV36_DM_INH7;
  92. };
  93. /*
  94. * CEA speaker placement:
  95. *
  96. * FLH FCH FRH
  97. * FLW FL FLC FC FRC FR FRW
  98. *
  99. * LFE
  100. * TC
  101. *
  102. * RL RLC RC RRC RR
  103. *
  104. * The Left/Right Surround channel _notions_ LS/RS in SMPTE 320M corresponds to
  105. * CEA RL/RR; The SMPTE channel _assignment_ C/LFE is swapped to CEA LFE/FC.
  106. */
  107. enum cea_speaker_placement {
  108. FL = (1 << 0), /* Front Left */
  109. FC = (1 << 1), /* Front Center */
  110. FR = (1 << 2), /* Front Right */
  111. FLC = (1 << 3), /* Front Left Center */
  112. FRC = (1 << 4), /* Front Right Center */
  113. RL = (1 << 5), /* Rear Left */
  114. RC = (1 << 6), /* Rear Center */
  115. RR = (1 << 7), /* Rear Right */
  116. RLC = (1 << 8), /* Rear Left Center */
  117. RRC = (1 << 9), /* Rear Right Center */
  118. LFE = (1 << 10), /* Low Frequency Effect */
  119. FLW = (1 << 11), /* Front Left Wide */
  120. FRW = (1 << 12), /* Front Right Wide */
  121. FLH = (1 << 13), /* Front Left High */
  122. FCH = (1 << 14), /* Front Center High */
  123. FRH = (1 << 15), /* Front Right High */
  124. TC = (1 << 16), /* Top Center */
  125. };
  126. /*
  127. * ELD SA bits in the CEA Speaker Allocation data block
  128. */
  129. static int eld_speaker_allocation_bits[] = {
  130. [0] = FL | FR,
  131. [1] = LFE,
  132. [2] = FC,
  133. [3] = RL | RR,
  134. [4] = RC,
  135. [5] = FLC | FRC,
  136. [6] = RLC | RRC,
  137. /* the following are not defined in ELD yet */
  138. [7] = FLW | FRW,
  139. [8] = FLH | FRH,
  140. [9] = TC,
  141. [10] = FCH,
  142. };
  143. struct cea_channel_speaker_allocation {
  144. int ca_index;
  145. int speakers[8];
  146. /* derived values, just for convenience */
  147. int channels;
  148. int spk_mask;
  149. };
  150. /*
  151. * ALSA sequence is:
  152. *
  153. * surround40 surround41 surround50 surround51 surround71
  154. * ch0 front left = = = =
  155. * ch1 front right = = = =
  156. * ch2 rear left = = = =
  157. * ch3 rear right = = = =
  158. * ch4 LFE center center center
  159. * ch5 LFE LFE
  160. * ch6 side left
  161. * ch7 side right
  162. *
  163. * surround71 = {FL, FR, RLC, RRC, FC, LFE, RL, RR}
  164. */
  165. static int hdmi_channel_mapping[0x32][8] = {
  166. /* stereo */
  167. [0x00] = { 0x00, 0x11, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
  168. /* 2.1 */
  169. [0x01] = { 0x00, 0x11, 0x22, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7 },
  170. /* Dolby Surround */
  171. [0x02] = { 0x00, 0x11, 0x23, 0xf2, 0xf4, 0xf5, 0xf6, 0xf7 },
  172. /* surround40 */
  173. [0x08] = { 0x00, 0x11, 0x24, 0x35, 0xf3, 0xf2, 0xf6, 0xf7 },
  174. /* 4ch */
  175. [0x03] = { 0x00, 0x11, 0x23, 0x32, 0x44, 0xf5, 0xf6, 0xf7 },
  176. /* surround41 */
  177. [0x09] = { 0x00, 0x11, 0x24, 0x35, 0x42, 0xf3, 0xf6, 0xf7 },
  178. /* surround50 */
  179. [0x0a] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0xf2, 0xf6, 0xf7 },
  180. /* surround51 */
  181. [0x0b] = { 0x00, 0x11, 0x24, 0x35, 0x43, 0x52, 0xf6, 0xf7 },
  182. /* 7.1 */
  183. [0x13] = { 0x00, 0x11, 0x26, 0x37, 0x43, 0x52, 0x64, 0x75 },
  184. };
  185. /*
  186. * This is an ordered list!
  187. *
  188. * The preceding ones have better chances to be selected by
  189. * hdmi_channel_allocation().
  190. */
  191. static struct cea_channel_speaker_allocation channel_allocations[] = {
  192. /* channel: 7 6 5 4 3 2 1 0 */
  193. { .ca_index = 0x00, .speakers = { 0, 0, 0, 0, 0, 0, FR, FL } },
  194. /* 2.1 */
  195. { .ca_index = 0x01, .speakers = { 0, 0, 0, 0, 0, LFE, FR, FL } },
  196. /* Dolby Surround */
  197. { .ca_index = 0x02, .speakers = { 0, 0, 0, 0, FC, 0, FR, FL } },
  198. /* surround40 */
  199. { .ca_index = 0x08, .speakers = { 0, 0, RR, RL, 0, 0, FR, FL } },
  200. /* surround41 */
  201. { .ca_index = 0x09, .speakers = { 0, 0, RR, RL, 0, LFE, FR, FL } },
  202. /* surround50 */
  203. { .ca_index = 0x0a, .speakers = { 0, 0, RR, RL, FC, 0, FR, FL } },
  204. /* surround51 */
  205. { .ca_index = 0x0b, .speakers = { 0, 0, RR, RL, FC, LFE, FR, FL } },
  206. /* 6.1 */
  207. { .ca_index = 0x0f, .speakers = { 0, RC, RR, RL, FC, LFE, FR, FL } },
  208. /* surround71 */
  209. { .ca_index = 0x13, .speakers = { RRC, RLC, RR, RL, FC, LFE, FR, FL } },
  210. { .ca_index = 0x03, .speakers = { 0, 0, 0, 0, FC, LFE, FR, FL } },
  211. { .ca_index = 0x04, .speakers = { 0, 0, 0, RC, 0, 0, FR, FL } },
  212. { .ca_index = 0x05, .speakers = { 0, 0, 0, RC, 0, LFE, FR, FL } },
  213. { .ca_index = 0x06, .speakers = { 0, 0, 0, RC, FC, 0, FR, FL } },
  214. { .ca_index = 0x07, .speakers = { 0, 0, 0, RC, FC, LFE, FR, FL } },
  215. { .ca_index = 0x0c, .speakers = { 0, RC, RR, RL, 0, 0, FR, FL } },
  216. { .ca_index = 0x0d, .speakers = { 0, RC, RR, RL, 0, LFE, FR, FL } },
  217. { .ca_index = 0x0e, .speakers = { 0, RC, RR, RL, FC, 0, FR, FL } },
  218. { .ca_index = 0x10, .speakers = { RRC, RLC, RR, RL, 0, 0, FR, FL } },
  219. { .ca_index = 0x11, .speakers = { RRC, RLC, RR, RL, 0, LFE, FR, FL } },
  220. { .ca_index = 0x12, .speakers = { RRC, RLC, RR, RL, FC, 0, FR, FL } },
  221. { .ca_index = 0x14, .speakers = { FRC, FLC, 0, 0, 0, 0, FR, FL } },
  222. { .ca_index = 0x15, .speakers = { FRC, FLC, 0, 0, 0, LFE, FR, FL } },
  223. { .ca_index = 0x16, .speakers = { FRC, FLC, 0, 0, FC, 0, FR, FL } },
  224. { .ca_index = 0x17, .speakers = { FRC, FLC, 0, 0, FC, LFE, FR, FL } },
  225. { .ca_index = 0x18, .speakers = { FRC, FLC, 0, RC, 0, 0, FR, FL } },
  226. { .ca_index = 0x19, .speakers = { FRC, FLC, 0, RC, 0, LFE, FR, FL } },
  227. { .ca_index = 0x1a, .speakers = { FRC, FLC, 0, RC, FC, 0, FR, FL } },
  228. { .ca_index = 0x1b, .speakers = { FRC, FLC, 0, RC, FC, LFE, FR, FL } },
  229. { .ca_index = 0x1c, .speakers = { FRC, FLC, RR, RL, 0, 0, FR, FL } },
  230. { .ca_index = 0x1d, .speakers = { FRC, FLC, RR, RL, 0, LFE, FR, FL } },
  231. { .ca_index = 0x1e, .speakers = { FRC, FLC, RR, RL, FC, 0, FR, FL } },
  232. { .ca_index = 0x1f, .speakers = { FRC, FLC, RR, RL, FC, LFE, FR, FL } },
  233. { .ca_index = 0x20, .speakers = { 0, FCH, RR, RL, FC, 0, FR, FL } },
  234. { .ca_index = 0x21, .speakers = { 0, FCH, RR, RL, FC, LFE, FR, FL } },
  235. { .ca_index = 0x22, .speakers = { TC, 0, RR, RL, FC, 0, FR, FL } },
  236. { .ca_index = 0x23, .speakers = { TC, 0, RR, RL, FC, LFE, FR, FL } },
  237. { .ca_index = 0x24, .speakers = { FRH, FLH, RR, RL, 0, 0, FR, FL } },
  238. { .ca_index = 0x25, .speakers = { FRH, FLH, RR, RL, 0, LFE, FR, FL } },
  239. { .ca_index = 0x26, .speakers = { FRW, FLW, RR, RL, 0, 0, FR, FL } },
  240. { .ca_index = 0x27, .speakers = { FRW, FLW, RR, RL, 0, LFE, FR, FL } },
  241. { .ca_index = 0x28, .speakers = { TC, RC, RR, RL, FC, 0, FR, FL } },
  242. { .ca_index = 0x29, .speakers = { TC, RC, RR, RL, FC, LFE, FR, FL } },
  243. { .ca_index = 0x2a, .speakers = { FCH, RC, RR, RL, FC, 0, FR, FL } },
  244. { .ca_index = 0x2b, .speakers = { FCH, RC, RR, RL, FC, LFE, FR, FL } },
  245. { .ca_index = 0x2c, .speakers = { TC, FCH, RR, RL, FC, 0, FR, FL } },
  246. { .ca_index = 0x2d, .speakers = { TC, FCH, RR, RL, FC, LFE, FR, FL } },
  247. { .ca_index = 0x2e, .speakers = { FRH, FLH, RR, RL, FC, 0, FR, FL } },
  248. { .ca_index = 0x2f, .speakers = { FRH, FLH, RR, RL, FC, LFE, FR, FL } },
  249. { .ca_index = 0x30, .speakers = { FRW, FLW, RR, RL, FC, 0, FR, FL } },
  250. { .ca_index = 0x31, .speakers = { FRW, FLW, RR, RL, FC, LFE, FR, FL } },
  251. };
  252. /*
  253. * HDMI routines
  254. */
  255. static int hda_node_index(hda_nid_t *nids, hda_nid_t nid)
  256. {
  257. int i;
  258. for (i = 0; nids[i]; i++)
  259. if (nids[i] == nid)
  260. return i;
  261. snd_printk(KERN_WARNING "HDMI: nid %d not registered\n", nid);
  262. return -EINVAL;
  263. }
  264. static void hdmi_get_show_eld(struct hda_codec *codec, hda_nid_t pin_nid,
  265. struct hdmi_eld *eld)
  266. {
  267. if (!snd_hdmi_get_eld(eld, codec, pin_nid))
  268. snd_hdmi_show_eld(eld);
  269. }
  270. #ifdef BE_PARANOID
  271. static void hdmi_get_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
  272. int *packet_index, int *byte_index)
  273. {
  274. int val;
  275. val = snd_hda_codec_read(codec, pin_nid, 0,
  276. AC_VERB_GET_HDMI_DIP_INDEX, 0);
  277. *packet_index = val >> 5;
  278. *byte_index = val & 0x1f;
  279. }
  280. #endif
  281. static void hdmi_set_dip_index(struct hda_codec *codec, hda_nid_t pin_nid,
  282. int packet_index, int byte_index)
  283. {
  284. int val;
  285. val = (packet_index << 5) | (byte_index & 0x1f);
  286. snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_INDEX, val);
  287. }
  288. static void hdmi_write_dip_byte(struct hda_codec *codec, hda_nid_t pin_nid,
  289. unsigned char val)
  290. {
  291. snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_DATA, val);
  292. }
  293. static void hdmi_enable_output(struct hda_codec *codec, hda_nid_t pin_nid)
  294. {
  295. /* Unmute */
  296. if (get_wcaps(codec, pin_nid) & AC_WCAP_OUT_AMP)
  297. snd_hda_codec_write(codec, pin_nid, 0,
  298. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_UNMUTE);
  299. /* Enable pin out */
  300. snd_hda_codec_write(codec, pin_nid, 0,
  301. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  302. }
  303. static int hdmi_get_channel_count(struct hda_codec *codec, hda_nid_t nid)
  304. {
  305. return 1 + snd_hda_codec_read(codec, nid, 0,
  306. AC_VERB_GET_CVT_CHAN_COUNT, 0);
  307. }
  308. static void hdmi_set_channel_count(struct hda_codec *codec,
  309. hda_nid_t nid, int chs)
  310. {
  311. if (chs != hdmi_get_channel_count(codec, nid))
  312. snd_hda_codec_write(codec, nid, 0,
  313. AC_VERB_SET_CVT_CHAN_COUNT, chs - 1);
  314. }
  315. /*
  316. * Channel mapping routines
  317. */
  318. /*
  319. * Compute derived values in channel_allocations[].
  320. */
  321. static void init_channel_allocations(void)
  322. {
  323. int i, j;
  324. struct cea_channel_speaker_allocation *p;
  325. for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
  326. p = channel_allocations + i;
  327. p->channels = 0;
  328. p->spk_mask = 0;
  329. for (j = 0; j < ARRAY_SIZE(p->speakers); j++)
  330. if (p->speakers[j]) {
  331. p->channels++;
  332. p->spk_mask |= p->speakers[j];
  333. }
  334. }
  335. }
  336. /*
  337. * The transformation takes two steps:
  338. *
  339. * eld->spk_alloc => (eld_speaker_allocation_bits[]) => spk_mask
  340. * spk_mask => (channel_allocations[]) => ai->CA
  341. *
  342. * TODO: it could select the wrong CA from multiple candidates.
  343. */
  344. static int hdmi_channel_allocation(struct hda_codec *codec, hda_nid_t nid,
  345. int channels)
  346. {
  347. struct hdmi_spec *spec = codec->spec;
  348. struct hdmi_eld *eld;
  349. int i;
  350. int ca = 0;
  351. int spk_mask = 0;
  352. char buf[SND_PRINT_CHANNEL_ALLOCATION_ADVISED_BUFSIZE];
  353. /*
  354. * CA defaults to 0 for basic stereo audio
  355. */
  356. if (channels <= 2)
  357. return 0;
  358. i = hda_node_index(spec->pin_cvt, nid);
  359. if (i < 0)
  360. return 0;
  361. eld = &spec->sink_eld[i];
  362. /*
  363. * HDMI sink's ELD info cannot always be retrieved for now, e.g.
  364. * in console or for audio devices. Assume the highest speakers
  365. * configuration, to _not_ prohibit multi-channel audio playback.
  366. */
  367. if (!eld->spk_alloc)
  368. eld->spk_alloc = 0xffff;
  369. /*
  370. * expand ELD's speaker allocation mask
  371. *
  372. * ELD tells the speaker mask in a compact(paired) form,
  373. * expand ELD's notions to match the ones used by Audio InfoFrame.
  374. */
  375. for (i = 0; i < ARRAY_SIZE(eld_speaker_allocation_bits); i++) {
  376. if (eld->spk_alloc & (1 << i))
  377. spk_mask |= eld_speaker_allocation_bits[i];
  378. }
  379. /* search for the first working match in the CA table */
  380. for (i = 0; i < ARRAY_SIZE(channel_allocations); i++) {
  381. if (channels == channel_allocations[i].channels &&
  382. (spk_mask & channel_allocations[i].spk_mask) ==
  383. channel_allocations[i].spk_mask) {
  384. ca = channel_allocations[i].ca_index;
  385. break;
  386. }
  387. }
  388. snd_print_channel_allocation(eld->spk_alloc, buf, sizeof(buf));
  389. snd_printdd("HDMI: select CA 0x%x for %d-channel allocation: %s\n",
  390. ca, channels, buf);
  391. return ca;
  392. }
  393. static void hdmi_debug_channel_mapping(struct hda_codec *codec,
  394. hda_nid_t pin_nid)
  395. {
  396. #ifdef CONFIG_SND_DEBUG_VERBOSE
  397. int i;
  398. int slot;
  399. for (i = 0; i < 8; i++) {
  400. slot = snd_hda_codec_read(codec, pin_nid, 0,
  401. AC_VERB_GET_HDMI_CHAN_SLOT, i);
  402. printk(KERN_DEBUG "HDMI: ASP channel %d => slot %d\n",
  403. slot >> 4, slot & 0xf);
  404. }
  405. #endif
  406. }
  407. static void hdmi_setup_channel_mapping(struct hda_codec *codec,
  408. hda_nid_t pin_nid,
  409. int ca)
  410. {
  411. int i;
  412. int err;
  413. if (hdmi_channel_mapping[ca][1] == 0) {
  414. for (i = 0; i < channel_allocations[ca].channels; i++)
  415. hdmi_channel_mapping[ca][i] = i | (i << 4);
  416. for (; i < 8; i++)
  417. hdmi_channel_mapping[ca][i] = 0xf | (i << 4);
  418. }
  419. for (i = 0; i < 8; i++) {
  420. err = snd_hda_codec_write(codec, pin_nid, 0,
  421. AC_VERB_SET_HDMI_CHAN_SLOT,
  422. hdmi_channel_mapping[ca][i]);
  423. if (err) {
  424. snd_printdd(KERN_NOTICE
  425. "HDMI: channel mapping failed\n");
  426. break;
  427. }
  428. }
  429. hdmi_debug_channel_mapping(codec, pin_nid);
  430. }
  431. /*
  432. * Audio InfoFrame routines
  433. */
  434. /*
  435. * Enable Audio InfoFrame Transmission
  436. */
  437. static void hdmi_start_infoframe_trans(struct hda_codec *codec,
  438. hda_nid_t pin_nid)
  439. {
  440. hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
  441. snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
  442. AC_DIPXMIT_BEST);
  443. }
  444. /*
  445. * Disable Audio InfoFrame Transmission
  446. */
  447. static void hdmi_stop_infoframe_trans(struct hda_codec *codec,
  448. hda_nid_t pin_nid)
  449. {
  450. hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
  451. snd_hda_codec_write(codec, pin_nid, 0, AC_VERB_SET_HDMI_DIP_XMIT,
  452. AC_DIPXMIT_DISABLE);
  453. }
  454. static void hdmi_debug_dip_size(struct hda_codec *codec, hda_nid_t pin_nid)
  455. {
  456. #ifdef CONFIG_SND_DEBUG_VERBOSE
  457. int i;
  458. int size;
  459. size = snd_hdmi_get_eld_size(codec, pin_nid);
  460. printk(KERN_DEBUG "HDMI: ELD buf size is %d\n", size);
  461. for (i = 0; i < 8; i++) {
  462. size = snd_hda_codec_read(codec, pin_nid, 0,
  463. AC_VERB_GET_HDMI_DIP_SIZE, i);
  464. printk(KERN_DEBUG "HDMI: DIP GP[%d] buf size is %d\n", i, size);
  465. }
  466. #endif
  467. }
  468. static void hdmi_clear_dip_buffers(struct hda_codec *codec, hda_nid_t pin_nid)
  469. {
  470. #ifdef BE_PARANOID
  471. int i, j;
  472. int size;
  473. int pi, bi;
  474. for (i = 0; i < 8; i++) {
  475. size = snd_hda_codec_read(codec, pin_nid, 0,
  476. AC_VERB_GET_HDMI_DIP_SIZE, i);
  477. if (size == 0)
  478. continue;
  479. hdmi_set_dip_index(codec, pin_nid, i, 0x0);
  480. for (j = 1; j < 1000; j++) {
  481. hdmi_write_dip_byte(codec, pin_nid, 0x0);
  482. hdmi_get_dip_index(codec, pin_nid, &pi, &bi);
  483. if (pi != i)
  484. snd_printd(KERN_INFO "dip index %d: %d != %d\n",
  485. bi, pi, i);
  486. if (bi == 0) /* byte index wrapped around */
  487. break;
  488. }
  489. snd_printd(KERN_INFO
  490. "HDMI: DIP GP[%d] buf reported size=%d, written=%d\n",
  491. i, size, j);
  492. }
  493. #endif
  494. }
  495. static void hdmi_checksum_audio_infoframe(struct hdmi_audio_infoframe *hdmi_ai)
  496. {
  497. u8 *bytes = (u8 *)hdmi_ai;
  498. u8 sum = 0;
  499. int i;
  500. hdmi_ai->checksum = 0;
  501. for (i = 0; i < sizeof(*hdmi_ai); i++)
  502. sum += bytes[i];
  503. hdmi_ai->checksum = -sum;
  504. }
  505. static void hdmi_fill_audio_infoframe(struct hda_codec *codec,
  506. hda_nid_t pin_nid,
  507. u8 *dip, int size)
  508. {
  509. int i;
  510. hdmi_debug_dip_size(codec, pin_nid);
  511. hdmi_clear_dip_buffers(codec, pin_nid); /* be paranoid */
  512. hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
  513. for (i = 0; i < size; i++)
  514. hdmi_write_dip_byte(codec, pin_nid, dip[i]);
  515. }
  516. static bool hdmi_infoframe_uptodate(struct hda_codec *codec, hda_nid_t pin_nid,
  517. u8 *dip, int size)
  518. {
  519. u8 val;
  520. int i;
  521. if (snd_hda_codec_read(codec, pin_nid, 0, AC_VERB_GET_HDMI_DIP_XMIT, 0)
  522. != AC_DIPXMIT_BEST)
  523. return false;
  524. hdmi_set_dip_index(codec, pin_nid, 0x0, 0x0);
  525. for (i = 0; i < size; i++) {
  526. val = snd_hda_codec_read(codec, pin_nid, 0,
  527. AC_VERB_GET_HDMI_DIP_DATA, 0);
  528. if (val != dip[i])
  529. return false;
  530. }
  531. return true;
  532. }
  533. static void hdmi_setup_audio_infoframe(struct hda_codec *codec, hda_nid_t nid,
  534. struct snd_pcm_substream *substream)
  535. {
  536. struct hdmi_spec *spec = codec->spec;
  537. hda_nid_t pin_nid;
  538. int channels = substream->runtime->channels;
  539. int ca;
  540. int i;
  541. u8 ai[max(sizeof(struct hdmi_audio_infoframe),
  542. sizeof(struct dp_audio_infoframe))];
  543. ca = hdmi_channel_allocation(codec, nid, channels);
  544. for (i = 0; i < spec->num_pins; i++) {
  545. if (spec->pin_cvt[i] != nid)
  546. continue;
  547. if (!spec->sink_eld[i].monitor_present)
  548. continue;
  549. pin_nid = spec->pin[i];
  550. memset(ai, 0, sizeof(ai));
  551. if (spec->sink_eld[i].conn_type == 0) { /* HDMI */
  552. struct hdmi_audio_infoframe *hdmi_ai;
  553. hdmi_ai = (struct hdmi_audio_infoframe *)ai;
  554. hdmi_ai->type = 0x84;
  555. hdmi_ai->ver = 0x01;
  556. hdmi_ai->len = 0x0a;
  557. hdmi_ai->CC02_CT47 = channels - 1;
  558. hdmi_checksum_audio_infoframe(hdmi_ai);
  559. } else if (spec->sink_eld[i].conn_type == 1) { /* DisplayPort */
  560. struct dp_audio_infoframe *dp_ai;
  561. dp_ai = (struct dp_audio_infoframe *)ai;
  562. dp_ai->type = 0x84;
  563. dp_ai->len = 0x1b;
  564. dp_ai->ver = 0x11 << 2;
  565. dp_ai->CC02_CT47 = channels - 1;
  566. } else {
  567. snd_printd("HDMI: unknown connection type at pin %d\n",
  568. pin_nid);
  569. continue;
  570. }
  571. /*
  572. * sizeof(ai) is used instead of sizeof(*hdmi_ai) or
  573. * sizeof(*dp_ai) to avoid partial match/update problems when
  574. * the user switches between HDMI/DP monitors.
  575. */
  576. if (!hdmi_infoframe_uptodate(codec, pin_nid, ai, sizeof(ai))) {
  577. snd_printdd("hdmi_setup_audio_infoframe: "
  578. "cvt=%d pin=%d channels=%d\n",
  579. nid, pin_nid,
  580. channels);
  581. hdmi_setup_channel_mapping(codec, pin_nid, ca);
  582. hdmi_stop_infoframe_trans(codec, pin_nid);
  583. hdmi_fill_audio_infoframe(codec, pin_nid,
  584. ai, sizeof(ai));
  585. hdmi_start_infoframe_trans(codec, pin_nid);
  586. }
  587. }
  588. }
  589. /*
  590. * Unsolicited events
  591. */
  592. static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
  593. struct hdmi_eld *eld);
  594. static void hdmi_intrinsic_event(struct hda_codec *codec, unsigned int res)
  595. {
  596. struct hdmi_spec *spec = codec->spec;
  597. int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
  598. int pind = !!(res & AC_UNSOL_RES_PD);
  599. int eldv = !!(res & AC_UNSOL_RES_ELDV);
  600. int index;
  601. printk(KERN_INFO
  602. "HDMI hot plug event: Pin=%d Presence_Detect=%d ELD_Valid=%d\n",
  603. tag, pind, eldv);
  604. index = hda_node_index(spec->pin, tag);
  605. if (index < 0)
  606. return;
  607. if (spec->old_pin_detect) {
  608. if (pind)
  609. hdmi_present_sense(codec, tag, &spec->sink_eld[index]);
  610. pind = spec->sink_eld[index].monitor_present;
  611. }
  612. spec->sink_eld[index].monitor_present = pind;
  613. spec->sink_eld[index].eld_valid = eldv;
  614. if (pind && eldv) {
  615. hdmi_get_show_eld(codec, spec->pin[index],
  616. &spec->sink_eld[index]);
  617. /* TODO: do real things about ELD */
  618. }
  619. }
  620. static void hdmi_non_intrinsic_event(struct hda_codec *codec, unsigned int res)
  621. {
  622. int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
  623. int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
  624. int cp_state = !!(res & AC_UNSOL_RES_CP_STATE);
  625. int cp_ready = !!(res & AC_UNSOL_RES_CP_READY);
  626. printk(KERN_INFO
  627. "HDMI CP event: PIN=%d SUBTAG=0x%x CP_STATE=%d CP_READY=%d\n",
  628. tag,
  629. subtag,
  630. cp_state,
  631. cp_ready);
  632. /* TODO */
  633. if (cp_state)
  634. ;
  635. if (cp_ready)
  636. ;
  637. }
  638. static void hdmi_unsol_event(struct hda_codec *codec, unsigned int res)
  639. {
  640. struct hdmi_spec *spec = codec->spec;
  641. int tag = res >> AC_UNSOL_RES_TAG_SHIFT;
  642. int subtag = (res & AC_UNSOL_RES_SUBTAG) >> AC_UNSOL_RES_SUBTAG_SHIFT;
  643. if (hda_node_index(spec->pin, tag) < 0) {
  644. snd_printd(KERN_INFO "Unexpected HDMI event tag 0x%x\n", tag);
  645. return;
  646. }
  647. if (subtag == 0)
  648. hdmi_intrinsic_event(codec, res);
  649. else
  650. hdmi_non_intrinsic_event(codec, res);
  651. }
  652. /*
  653. * Callbacks
  654. */
  655. /* HBR should be Non-PCM, 8 channels */
  656. #define is_hbr_format(format) \
  657. ((format & AC_FMT_TYPE_NON_PCM) && (format & AC_FMT_CHAN_MASK) == 7)
  658. static int hdmi_setup_stream(struct hda_codec *codec, hda_nid_t nid,
  659. u32 stream_tag, int format)
  660. {
  661. struct hdmi_spec *spec = codec->spec;
  662. int pinctl;
  663. int new_pinctl = 0;
  664. int i;
  665. for (i = 0; i < spec->num_pins; i++) {
  666. if (spec->pin_cvt[i] != nid)
  667. continue;
  668. if (!(snd_hda_query_pin_caps(codec, spec->pin[i]) & AC_PINCAP_HBR))
  669. continue;
  670. pinctl = snd_hda_codec_read(codec, spec->pin[i], 0,
  671. AC_VERB_GET_PIN_WIDGET_CONTROL, 0);
  672. new_pinctl = pinctl & ~AC_PINCTL_EPT;
  673. if (is_hbr_format(format))
  674. new_pinctl |= AC_PINCTL_EPT_HBR;
  675. else
  676. new_pinctl |= AC_PINCTL_EPT_NATIVE;
  677. snd_printdd("hdmi_setup_stream: "
  678. "NID=0x%x, %spinctl=0x%x\n",
  679. spec->pin[i],
  680. pinctl == new_pinctl ? "" : "new-",
  681. new_pinctl);
  682. if (pinctl != new_pinctl)
  683. snd_hda_codec_write(codec, spec->pin[i], 0,
  684. AC_VERB_SET_PIN_WIDGET_CONTROL,
  685. new_pinctl);
  686. }
  687. if (is_hbr_format(format) && !new_pinctl) {
  688. snd_printdd("hdmi_setup_stream: HBR is not supported\n");
  689. return -EINVAL;
  690. }
  691. snd_hda_codec_setup_stream(codec, nid, stream_tag, 0, format);
  692. return 0;
  693. }
  694. /*
  695. * HDA PCM callbacks
  696. */
  697. static int hdmi_pcm_open(struct hda_pcm_stream *hinfo,
  698. struct hda_codec *codec,
  699. struct snd_pcm_substream *substream)
  700. {
  701. struct hdmi_spec *spec = codec->spec;
  702. struct hdmi_eld *eld;
  703. struct hda_pcm_stream *codec_pars;
  704. unsigned int idx;
  705. for (idx = 0; idx < spec->num_cvts; idx++)
  706. if (hinfo->nid == spec->cvt[idx])
  707. break;
  708. if (snd_BUG_ON(idx >= spec->num_cvts) ||
  709. snd_BUG_ON(idx >= spec->num_pins))
  710. return -EINVAL;
  711. /* save the PCM info the codec provides */
  712. codec_pars = &spec->codec_pcm_pars[idx];
  713. if (!codec_pars->rates)
  714. *codec_pars = *hinfo;
  715. eld = &spec->sink_eld[idx];
  716. if (eld->sad_count > 0) {
  717. hdmi_eld_update_pcm_info(eld, hinfo, codec_pars);
  718. if (hinfo->channels_min > hinfo->channels_max ||
  719. !hinfo->rates || !hinfo->formats)
  720. return -ENODEV;
  721. } else {
  722. /* fallback to the codec default */
  723. hinfo->channels_min = codec_pars->channels_min;
  724. hinfo->channels_max = codec_pars->channels_max;
  725. hinfo->rates = codec_pars->rates;
  726. hinfo->formats = codec_pars->formats;
  727. hinfo->maxbps = codec_pars->maxbps;
  728. }
  729. return 0;
  730. }
  731. /*
  732. * HDA/HDMI auto parsing
  733. */
  734. static int hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid)
  735. {
  736. struct hdmi_spec *spec = codec->spec;
  737. hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
  738. int conn_len, curr;
  739. int index;
  740. if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
  741. snd_printk(KERN_WARNING
  742. "HDMI: pin %d wcaps %#x "
  743. "does not support connection list\n",
  744. pin_nid, get_wcaps(codec, pin_nid));
  745. return -EINVAL;
  746. }
  747. conn_len = snd_hda_get_connections(codec, pin_nid, conn_list,
  748. HDA_MAX_CONNECTIONS);
  749. if (conn_len > 1)
  750. curr = snd_hda_codec_read(codec, pin_nid, 0,
  751. AC_VERB_GET_CONNECT_SEL, 0);
  752. else
  753. curr = 0;
  754. index = hda_node_index(spec->pin, pin_nid);
  755. if (index < 0)
  756. return -EINVAL;
  757. spec->pin_cvt[index] = conn_list[curr];
  758. return 0;
  759. }
  760. static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
  761. struct hdmi_eld *eld)
  762. {
  763. int present = snd_hda_pin_sense(codec, pin_nid);
  764. eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
  765. eld->eld_valid = !!(present & AC_PINSENSE_ELDV);
  766. if (present & AC_PINSENSE_ELDV)
  767. hdmi_get_show_eld(codec, pin_nid, eld);
  768. }
  769. static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
  770. {
  771. struct hdmi_spec *spec = codec->spec;
  772. if (spec->num_pins >= MAX_HDMI_PINS) {
  773. snd_printk(KERN_WARNING
  774. "HDMI: no space for pin %d\n", pin_nid);
  775. return -E2BIG;
  776. }
  777. hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]);
  778. spec->pin[spec->num_pins] = pin_nid;
  779. spec->num_pins++;
  780. /*
  781. * It is assumed that converter nodes come first in the node list and
  782. * hence have been registered and usable now.
  783. */
  784. return hdmi_read_pin_conn(codec, pin_nid);
  785. }
  786. static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid)
  787. {
  788. struct hdmi_spec *spec = codec->spec;
  789. if (spec->num_cvts >= MAX_HDMI_CVTS) {
  790. snd_printk(KERN_WARNING
  791. "HDMI: no space for converter %d\n", nid);
  792. return -E2BIG;
  793. }
  794. spec->cvt[spec->num_cvts] = nid;
  795. spec->num_cvts++;
  796. return 0;
  797. }
  798. static int hdmi_parse_codec(struct hda_codec *codec)
  799. {
  800. hda_nid_t nid;
  801. int i, nodes;
  802. nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
  803. if (!nid || nodes < 0) {
  804. snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n");
  805. return -EINVAL;
  806. }
  807. for (i = 0; i < nodes; i++, nid++) {
  808. unsigned int caps;
  809. unsigned int type;
  810. caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
  811. type = get_wcaps_type(caps);
  812. if (!(caps & AC_WCAP_DIGITAL))
  813. continue;
  814. switch (type) {
  815. case AC_WID_AUD_OUT:
  816. hdmi_add_cvt(codec, nid);
  817. break;
  818. case AC_WID_PIN:
  819. caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
  820. if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP)))
  821. continue;
  822. hdmi_add_pin(codec, nid);
  823. break;
  824. }
  825. }
  826. /*
  827. * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event
  828. * can be lost and presence sense verb will become inaccurate if the
  829. * HDA link is powered off at hot plug or hw initialization time.
  830. */
  831. #ifdef CONFIG_SND_HDA_POWER_SAVE
  832. if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) &
  833. AC_PWRST_EPSS))
  834. codec->bus->power_keep_link_on = 1;
  835. #endif
  836. return 0;
  837. }
  838. /*
  839. */
  840. static char *generic_hdmi_pcm_names[MAX_HDMI_CVTS] = {
  841. "HDMI 0",
  842. "HDMI 1",
  843. "HDMI 2",
  844. };
  845. /*
  846. * HDMI callbacks
  847. */
  848. static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  849. struct hda_codec *codec,
  850. unsigned int stream_tag,
  851. unsigned int format,
  852. struct snd_pcm_substream *substream)
  853. {
  854. hdmi_set_channel_count(codec, hinfo->nid,
  855. substream->runtime->channels);
  856. hdmi_setup_audio_infoframe(codec, hinfo->nid, substream);
  857. return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format);
  858. }
  859. static struct hda_pcm_stream generic_hdmi_pcm_playback = {
  860. .substreams = 1,
  861. .channels_min = 2,
  862. .ops = {
  863. .open = hdmi_pcm_open,
  864. .prepare = generic_hdmi_playback_pcm_prepare,
  865. },
  866. };
  867. static int generic_hdmi_build_pcms(struct hda_codec *codec)
  868. {
  869. struct hdmi_spec *spec = codec->spec;
  870. struct hda_pcm *info = spec->pcm_rec;
  871. int i;
  872. codec->num_pcms = spec->num_cvts;
  873. codec->pcm_info = info;
  874. for (i = 0; i < codec->num_pcms; i++, info++) {
  875. unsigned int chans;
  876. struct hda_pcm_stream *pstr;
  877. chans = get_wcaps(codec, spec->cvt[i]);
  878. chans = get_wcaps_channels(chans);
  879. info->name = generic_hdmi_pcm_names[i];
  880. info->pcm_type = HDA_PCM_TYPE_HDMI;
  881. pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
  882. if (spec->pcm_playback)
  883. *pstr = *spec->pcm_playback;
  884. else
  885. *pstr = generic_hdmi_pcm_playback;
  886. pstr->nid = spec->cvt[i];
  887. if (pstr->channels_max <= 2 && chans && chans <= 16)
  888. pstr->channels_max = chans;
  889. }
  890. return 0;
  891. }
  892. static int generic_hdmi_build_controls(struct hda_codec *codec)
  893. {
  894. struct hdmi_spec *spec = codec->spec;
  895. int err;
  896. int i;
  897. for (i = 0; i < codec->num_pcms; i++) {
  898. err = snd_hda_create_spdif_out_ctls(codec, spec->cvt[i]);
  899. if (err < 0)
  900. return err;
  901. }
  902. return 0;
  903. }
  904. static int generic_hdmi_init(struct hda_codec *codec)
  905. {
  906. struct hdmi_spec *spec = codec->spec;
  907. int i;
  908. for (i = 0; spec->pin[i]; i++) {
  909. hdmi_enable_output(codec, spec->pin[i]);
  910. snd_hda_codec_write(codec, spec->pin[i], 0,
  911. AC_VERB_SET_UNSOLICITED_ENABLE,
  912. AC_USRSP_EN | spec->pin[i]);
  913. }
  914. return 0;
  915. }
  916. static void generic_hdmi_free(struct hda_codec *codec)
  917. {
  918. struct hdmi_spec *spec = codec->spec;
  919. int i;
  920. for (i = 0; i < spec->num_pins; i++)
  921. snd_hda_eld_proc_free(codec, &spec->sink_eld[i]);
  922. kfree(spec);
  923. }
  924. static struct hda_codec_ops generic_hdmi_patch_ops = {
  925. .init = generic_hdmi_init,
  926. .free = generic_hdmi_free,
  927. .build_pcms = generic_hdmi_build_pcms,
  928. .build_controls = generic_hdmi_build_controls,
  929. .unsol_event = hdmi_unsol_event,
  930. };
  931. static int patch_generic_hdmi(struct hda_codec *codec)
  932. {
  933. struct hdmi_spec *spec;
  934. int i;
  935. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  936. if (spec == NULL)
  937. return -ENOMEM;
  938. codec->spec = spec;
  939. if (hdmi_parse_codec(codec) < 0) {
  940. codec->spec = NULL;
  941. kfree(spec);
  942. return -EINVAL;
  943. }
  944. codec->patch_ops = generic_hdmi_patch_ops;
  945. for (i = 0; i < spec->num_pins; i++)
  946. snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i);
  947. init_channel_allocations();
  948. return 0;
  949. }
  950. /*
  951. * Nvidia specific implementations
  952. */
  953. #define Nv_VERB_SET_Channel_Allocation 0xF79
  954. #define Nv_VERB_SET_Info_Frame_Checksum 0xF7A
  955. #define Nv_VERB_SET_Audio_Protection_On 0xF98
  956. #define Nv_VERB_SET_Audio_Protection_Off 0xF99
  957. #define nvhdmi_master_con_nid_7x 0x04
  958. #define nvhdmi_master_pin_nid_7x 0x05
  959. static hda_nid_t nvhdmi_con_nids_7x[4] = {
  960. /*front, rear, clfe, rear_surr */
  961. 0x6, 0x8, 0xa, 0xc,
  962. };
  963. static struct hda_verb nvhdmi_basic_init_7x[] = {
  964. /* set audio protect on */
  965. { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
  966. /* enable digital output on pin widget */
  967. { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  968. { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  969. { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  970. { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  971. { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  972. {} /* terminator */
  973. };
  974. #ifdef LIMITED_RATE_FMT_SUPPORT
  975. /* support only the safe format and rate */
  976. #define SUPPORTED_RATES SNDRV_PCM_RATE_48000
  977. #define SUPPORTED_MAXBPS 16
  978. #define SUPPORTED_FORMATS SNDRV_PCM_FMTBIT_S16_LE
  979. #else
  980. /* support all rates and formats */
  981. #define SUPPORTED_RATES \
  982. (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
  983. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\
  984. SNDRV_PCM_RATE_192000)
  985. #define SUPPORTED_MAXBPS 24
  986. #define SUPPORTED_FORMATS \
  987. (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
  988. #endif
  989. static int nvhdmi_7x_init(struct hda_codec *codec)
  990. {
  991. snd_hda_sequence_write(codec, nvhdmi_basic_init_7x);
  992. return 0;
  993. }
  994. static int simple_playback_pcm_open(struct hda_pcm_stream *hinfo,
  995. struct hda_codec *codec,
  996. struct snd_pcm_substream *substream)
  997. {
  998. struct hdmi_spec *spec = codec->spec;
  999. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1000. }
  1001. static int simple_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1002. struct hda_codec *codec,
  1003. struct snd_pcm_substream *substream)
  1004. {
  1005. struct hdmi_spec *spec = codec->spec;
  1006. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1007. }
  1008. static int simple_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1009. struct hda_codec *codec,
  1010. unsigned int stream_tag,
  1011. unsigned int format,
  1012. struct snd_pcm_substream *substream)
  1013. {
  1014. struct hdmi_spec *spec = codec->spec;
  1015. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1016. stream_tag, format, substream);
  1017. }
  1018. static int nvhdmi_8ch_7x_pcm_close(struct hda_pcm_stream *hinfo,
  1019. struct hda_codec *codec,
  1020. struct snd_pcm_substream *substream)
  1021. {
  1022. struct hdmi_spec *spec = codec->spec;
  1023. int i;
  1024. snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x,
  1025. 0, AC_VERB_SET_CHANNEL_STREAMID, 0);
  1026. for (i = 0; i < 4; i++) {
  1027. /* set the stream id */
  1028. snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0,
  1029. AC_VERB_SET_CHANNEL_STREAMID, 0);
  1030. /* set the stream format */
  1031. snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0,
  1032. AC_VERB_SET_STREAM_FORMAT, 0);
  1033. }
  1034. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1035. }
  1036. static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,
  1037. struct hda_codec *codec,
  1038. unsigned int stream_tag,
  1039. unsigned int format,
  1040. struct snd_pcm_substream *substream)
  1041. {
  1042. int chs;
  1043. unsigned int dataDCC1, dataDCC2, chan, chanmask, channel_id;
  1044. int i;
  1045. mutex_lock(&codec->spdif_mutex);
  1046. chs = substream->runtime->channels;
  1047. chan = chs ? (chs - 1) : 1;
  1048. switch (chs) {
  1049. default:
  1050. case 0:
  1051. case 2:
  1052. chanmask = 0x00;
  1053. break;
  1054. case 4:
  1055. chanmask = 0x08;
  1056. break;
  1057. case 6:
  1058. chanmask = 0x0b;
  1059. break;
  1060. case 8:
  1061. chanmask = 0x13;
  1062. break;
  1063. }
  1064. dataDCC1 = AC_DIG1_ENABLE | AC_DIG1_COPYRIGHT;
  1065. dataDCC2 = 0x2;
  1066. /* set the Audio InforFrame Channel Allocation */
  1067. snd_hda_codec_write(codec, 0x1, 0,
  1068. Nv_VERB_SET_Channel_Allocation, chanmask);
  1069. /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
  1070. if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE))
  1071. snd_hda_codec_write(codec,
  1072. nvhdmi_master_con_nid_7x,
  1073. 0,
  1074. AC_VERB_SET_DIGI_CONVERT_1,
  1075. codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
  1076. /* set the stream id */
  1077. snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
  1078. AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0);
  1079. /* set the stream format */
  1080. snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
  1081. AC_VERB_SET_STREAM_FORMAT, format);
  1082. /* turn on again (if needed) */
  1083. /* enable and set the channel status audio/data flag */
  1084. if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) {
  1085. snd_hda_codec_write(codec,
  1086. nvhdmi_master_con_nid_7x,
  1087. 0,
  1088. AC_VERB_SET_DIGI_CONVERT_1,
  1089. codec->spdif_ctls & 0xff);
  1090. snd_hda_codec_write(codec,
  1091. nvhdmi_master_con_nid_7x,
  1092. 0,
  1093. AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);
  1094. }
  1095. for (i = 0; i < 4; i++) {
  1096. if (chs == 2)
  1097. channel_id = 0;
  1098. else
  1099. channel_id = i * 2;
  1100. /* turn off SPDIF once;
  1101. *otherwise the IEC958 bits won't be updated
  1102. */
  1103. if (codec->spdif_status_reset &&
  1104. (codec->spdif_ctls & AC_DIG1_ENABLE))
  1105. snd_hda_codec_write(codec,
  1106. nvhdmi_con_nids_7x[i],
  1107. 0,
  1108. AC_VERB_SET_DIGI_CONVERT_1,
  1109. codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
  1110. /* set the stream id */
  1111. snd_hda_codec_write(codec,
  1112. nvhdmi_con_nids_7x[i],
  1113. 0,
  1114. AC_VERB_SET_CHANNEL_STREAMID,
  1115. (stream_tag << 4) | channel_id);
  1116. /* set the stream format */
  1117. snd_hda_codec_write(codec,
  1118. nvhdmi_con_nids_7x[i],
  1119. 0,
  1120. AC_VERB_SET_STREAM_FORMAT,
  1121. format);
  1122. /* turn on again (if needed) */
  1123. /* enable and set the channel status audio/data flag */
  1124. if (codec->spdif_status_reset &&
  1125. (codec->spdif_ctls & AC_DIG1_ENABLE)) {
  1126. snd_hda_codec_write(codec,
  1127. nvhdmi_con_nids_7x[i],
  1128. 0,
  1129. AC_VERB_SET_DIGI_CONVERT_1,
  1130. codec->spdif_ctls & 0xff);
  1131. snd_hda_codec_write(codec,
  1132. nvhdmi_con_nids_7x[i],
  1133. 0,
  1134. AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);
  1135. }
  1136. }
  1137. /* set the Audio Info Frame Checksum */
  1138. snd_hda_codec_write(codec, 0x1, 0,
  1139. Nv_VERB_SET_Info_Frame_Checksum,
  1140. (0x71 - chan - chanmask));
  1141. mutex_unlock(&codec->spdif_mutex);
  1142. return 0;
  1143. }
  1144. static struct hda_pcm_stream nvhdmi_pcm_playback_8ch_7x = {
  1145. .substreams = 1,
  1146. .channels_min = 2,
  1147. .channels_max = 8,
  1148. .nid = nvhdmi_master_con_nid_7x,
  1149. .rates = SUPPORTED_RATES,
  1150. .maxbps = SUPPORTED_MAXBPS,
  1151. .formats = SUPPORTED_FORMATS,
  1152. .ops = {
  1153. .open = simple_playback_pcm_open,
  1154. .close = nvhdmi_8ch_7x_pcm_close,
  1155. .prepare = nvhdmi_8ch_7x_pcm_prepare
  1156. },
  1157. };
  1158. static struct hda_pcm_stream nvhdmi_pcm_playback_2ch = {
  1159. .substreams = 1,
  1160. .channels_min = 2,
  1161. .channels_max = 2,
  1162. .nid = nvhdmi_master_con_nid_7x,
  1163. .rates = SUPPORTED_RATES,
  1164. .maxbps = SUPPORTED_MAXBPS,
  1165. .formats = SUPPORTED_FORMATS,
  1166. .ops = {
  1167. .open = simple_playback_pcm_open,
  1168. .close = simple_playback_pcm_close,
  1169. .prepare = simple_playback_pcm_prepare
  1170. },
  1171. };
  1172. static struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = {
  1173. .build_controls = generic_hdmi_build_controls,
  1174. .build_pcms = generic_hdmi_build_pcms,
  1175. .init = nvhdmi_7x_init,
  1176. .free = generic_hdmi_free,
  1177. };
  1178. static struct hda_codec_ops nvhdmi_patch_ops_2ch = {
  1179. .build_controls = generic_hdmi_build_controls,
  1180. .build_pcms = generic_hdmi_build_pcms,
  1181. .init = nvhdmi_7x_init,
  1182. .free = generic_hdmi_free,
  1183. };
  1184. static int patch_nvhdmi_8ch_89(struct hda_codec *codec)
  1185. {
  1186. struct hdmi_spec *spec;
  1187. int err = patch_generic_hdmi(codec);
  1188. if (err < 0)
  1189. return err;
  1190. spec = codec->spec;
  1191. spec->old_pin_detect = 1;
  1192. return 0;
  1193. }
  1194. static int patch_nvhdmi_2ch(struct hda_codec *codec)
  1195. {
  1196. struct hdmi_spec *spec;
  1197. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1198. if (spec == NULL)
  1199. return -ENOMEM;
  1200. codec->spec = spec;
  1201. spec->multiout.num_dacs = 0; /* no analog */
  1202. spec->multiout.max_channels = 2;
  1203. spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x;
  1204. spec->old_pin_detect = 1;
  1205. spec->num_cvts = 1;
  1206. spec->cvt[0] = nvhdmi_master_con_nid_7x;
  1207. spec->pcm_playback = &nvhdmi_pcm_playback_2ch;
  1208. codec->patch_ops = nvhdmi_patch_ops_2ch;
  1209. return 0;
  1210. }
  1211. static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
  1212. {
  1213. struct hdmi_spec *spec;
  1214. int err = patch_nvhdmi_2ch(codec);
  1215. if (err < 0)
  1216. return err;
  1217. spec = codec->spec;
  1218. spec->multiout.max_channels = 8;
  1219. spec->pcm_playback = &nvhdmi_pcm_playback_8ch_7x;
  1220. codec->patch_ops = nvhdmi_patch_ops_8ch_7x;
  1221. return 0;
  1222. }
  1223. /*
  1224. * ATI-specific implementations
  1225. *
  1226. * FIXME: we may omit the whole this and use the generic code once after
  1227. * it's confirmed to work.
  1228. */
  1229. #define ATIHDMI_CVT_NID 0x02 /* audio converter */
  1230. #define ATIHDMI_PIN_NID 0x03 /* HDMI output pin */
  1231. static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1232. struct hda_codec *codec,
  1233. unsigned int stream_tag,
  1234. unsigned int format,
  1235. struct snd_pcm_substream *substream)
  1236. {
  1237. struct hdmi_spec *spec = codec->spec;
  1238. int chans = substream->runtime->channels;
  1239. int i, err;
  1240. err = simple_playback_pcm_prepare(hinfo, codec, stream_tag, format,
  1241. substream);
  1242. if (err < 0)
  1243. return err;
  1244. snd_hda_codec_write(codec, spec->cvt[0], 0, AC_VERB_SET_CVT_CHAN_COUNT,
  1245. chans - 1);
  1246. /* FIXME: XXX */
  1247. for (i = 0; i < chans; i++) {
  1248. snd_hda_codec_write(codec, spec->cvt[0], 0,
  1249. AC_VERB_SET_HDMI_CHAN_SLOT,
  1250. (i << 4) | i);
  1251. }
  1252. return 0;
  1253. }
  1254. static struct hda_pcm_stream atihdmi_pcm_digital_playback = {
  1255. .substreams = 1,
  1256. .channels_min = 2,
  1257. .channels_max = 2,
  1258. .nid = ATIHDMI_CVT_NID,
  1259. .ops = {
  1260. .open = simple_playback_pcm_open,
  1261. .close = simple_playback_pcm_close,
  1262. .prepare = atihdmi_playback_pcm_prepare
  1263. },
  1264. };
  1265. static struct hda_verb atihdmi_basic_init[] = {
  1266. /* enable digital output on pin widget */
  1267. { 0x03, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  1268. {} /* terminator */
  1269. };
  1270. static int atihdmi_init(struct hda_codec *codec)
  1271. {
  1272. struct hdmi_spec *spec = codec->spec;
  1273. snd_hda_sequence_write(codec, atihdmi_basic_init);
  1274. /* SI codec requires to unmute the pin */
  1275. if (get_wcaps(codec, spec->pin[0]) & AC_WCAP_OUT_AMP)
  1276. snd_hda_codec_write(codec, spec->pin[0], 0,
  1277. AC_VERB_SET_AMP_GAIN_MUTE,
  1278. AMP_OUT_UNMUTE);
  1279. return 0;
  1280. }
  1281. static struct hda_codec_ops atihdmi_patch_ops = {
  1282. .build_controls = generic_hdmi_build_controls,
  1283. .build_pcms = generic_hdmi_build_pcms,
  1284. .init = atihdmi_init,
  1285. .free = generic_hdmi_free,
  1286. };
  1287. static int patch_atihdmi(struct hda_codec *codec)
  1288. {
  1289. struct hdmi_spec *spec;
  1290. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1291. if (spec == NULL)
  1292. return -ENOMEM;
  1293. codec->spec = spec;
  1294. spec->multiout.num_dacs = 0; /* no analog */
  1295. spec->multiout.max_channels = 2;
  1296. spec->multiout.dig_out_nid = ATIHDMI_CVT_NID;
  1297. spec->num_cvts = 1;
  1298. spec->cvt[0] = ATIHDMI_CVT_NID;
  1299. spec->pin[0] = ATIHDMI_PIN_NID;
  1300. spec->pcm_playback = &atihdmi_pcm_digital_playback;
  1301. codec->patch_ops = atihdmi_patch_ops;
  1302. return 0;
  1303. }
  1304. /*
  1305. * patch entries
  1306. */
  1307. static struct hda_codec_preset snd_hda_preset_hdmi[] = {
  1308. { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi },
  1309. { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi },
  1310. { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi },
  1311. { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_atihdmi },
  1312. { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_generic_hdmi },
  1313. { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_generic_hdmi },
  1314. { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_generic_hdmi },
  1315. { .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
  1316. { .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
  1317. { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
  1318. { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
  1319. { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x },
  1320. { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1321. { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1322. { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi_8ch_89 },
  1323. { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1324. { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1325. { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1326. { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1327. { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1328. { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1329. { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1330. { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1331. { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1332. { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1333. { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1334. { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1335. { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1336. { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1337. { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1338. { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1339. { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
  1340. { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
  1341. { .id = 0x80860054, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi },
  1342. { .id = 0x80862801, .name = "Bearlake HDMI", .patch = patch_generic_hdmi },
  1343. { .id = 0x80862802, .name = "Cantiga HDMI", .patch = patch_generic_hdmi },
  1344. { .id = 0x80862803, .name = "Eaglelake HDMI", .patch = patch_generic_hdmi },
  1345. { .id = 0x80862804, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi },
  1346. { .id = 0x80862805, .name = "CougarPoint HDMI", .patch = patch_generic_hdmi },
  1347. { .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi },
  1348. {} /* terminator */
  1349. };
  1350. MODULE_ALIAS("snd-hda-codec-id:1002793c");
  1351. MODULE_ALIAS("snd-hda-codec-id:10027919");
  1352. MODULE_ALIAS("snd-hda-codec-id:1002791a");
  1353. MODULE_ALIAS("snd-hda-codec-id:1002aa01");
  1354. MODULE_ALIAS("snd-hda-codec-id:10951390");
  1355. MODULE_ALIAS("snd-hda-codec-id:10951392");
  1356. MODULE_ALIAS("snd-hda-codec-id:10de0002");
  1357. MODULE_ALIAS("snd-hda-codec-id:10de0003");
  1358. MODULE_ALIAS("snd-hda-codec-id:10de0005");
  1359. MODULE_ALIAS("snd-hda-codec-id:10de0006");
  1360. MODULE_ALIAS("snd-hda-codec-id:10de0007");
  1361. MODULE_ALIAS("snd-hda-codec-id:10de000a");
  1362. MODULE_ALIAS("snd-hda-codec-id:10de000b");
  1363. MODULE_ALIAS("snd-hda-codec-id:10de000c");
  1364. MODULE_ALIAS("snd-hda-codec-id:10de000d");
  1365. MODULE_ALIAS("snd-hda-codec-id:10de0010");
  1366. MODULE_ALIAS("snd-hda-codec-id:10de0011");
  1367. MODULE_ALIAS("snd-hda-codec-id:10de0012");
  1368. MODULE_ALIAS("snd-hda-codec-id:10de0013");
  1369. MODULE_ALIAS("snd-hda-codec-id:10de0014");
  1370. MODULE_ALIAS("snd-hda-codec-id:10de0018");
  1371. MODULE_ALIAS("snd-hda-codec-id:10de0019");
  1372. MODULE_ALIAS("snd-hda-codec-id:10de001a");
  1373. MODULE_ALIAS("snd-hda-codec-id:10de001b");
  1374. MODULE_ALIAS("snd-hda-codec-id:10de001c");
  1375. MODULE_ALIAS("snd-hda-codec-id:10de0040");
  1376. MODULE_ALIAS("snd-hda-codec-id:10de0041");
  1377. MODULE_ALIAS("snd-hda-codec-id:10de0042");
  1378. MODULE_ALIAS("snd-hda-codec-id:10de0043");
  1379. MODULE_ALIAS("snd-hda-codec-id:10de0044");
  1380. MODULE_ALIAS("snd-hda-codec-id:10de0067");
  1381. MODULE_ALIAS("snd-hda-codec-id:10de8001");
  1382. MODULE_ALIAS("snd-hda-codec-id:17e80047");
  1383. MODULE_ALIAS("snd-hda-codec-id:80860054");
  1384. MODULE_ALIAS("snd-hda-codec-id:80862801");
  1385. MODULE_ALIAS("snd-hda-codec-id:80862802");
  1386. MODULE_ALIAS("snd-hda-codec-id:80862803");
  1387. MODULE_ALIAS("snd-hda-codec-id:80862804");
  1388. MODULE_ALIAS("snd-hda-codec-id:80862805");
  1389. MODULE_ALIAS("snd-hda-codec-id:808629fb");
  1390. MODULE_LICENSE("GPL");
  1391. MODULE_DESCRIPTION("HDMI HD-audio codec");
  1392. MODULE_ALIAS("snd-hda-codec-intelhdmi");
  1393. MODULE_ALIAS("snd-hda-codec-nvhdmi");
  1394. MODULE_ALIAS("snd-hda-codec-atihdmi");
  1395. static struct hda_codec_preset_list intel_list = {
  1396. .preset = snd_hda_preset_hdmi,
  1397. .owner = THIS_MODULE,
  1398. };
  1399. static int __init patch_hdmi_init(void)
  1400. {
  1401. return snd_hda_add_codec_preset(&intel_list);
  1402. }
  1403. static void __exit patch_hdmi_exit(void)
  1404. {
  1405. snd_hda_delete_codec_preset(&intel_list);
  1406. }
  1407. module_init(patch_hdmi_init)
  1408. module_exit(patch_hdmi_exit)