patch_hdmi.c 46 KB

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