patch_hdmi.c 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720
  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. struct snd_pcm_runtime *runtime = substream->runtime;
  709. unsigned int idx;
  710. for (idx = 0; idx < spec->num_cvts; idx++)
  711. if (hinfo->nid == spec->cvt[idx])
  712. break;
  713. if (snd_BUG_ON(idx >= spec->num_cvts) ||
  714. snd_BUG_ON(idx >= spec->num_pins))
  715. return -EINVAL;
  716. /* save the PCM info the codec provides */
  717. codec_pars = &spec->codec_pcm_pars[idx];
  718. if (!codec_pars->rates)
  719. *codec_pars = *hinfo;
  720. eld = &spec->sink_eld[idx];
  721. if (!static_hdmi_pcm && eld->eld_valid && eld->sad_count > 0) {
  722. hdmi_eld_update_pcm_info(eld, hinfo, codec_pars);
  723. if (hinfo->channels_min > hinfo->channels_max ||
  724. !hinfo->rates || !hinfo->formats)
  725. return -ENODEV;
  726. } else {
  727. /* fallback to the codec default */
  728. hinfo->channels_max = codec_pars->channels_max;
  729. hinfo->rates = codec_pars->rates;
  730. hinfo->formats = codec_pars->formats;
  731. hinfo->maxbps = codec_pars->maxbps;
  732. }
  733. /* store the updated parameters */
  734. runtime->hw.channels_min = hinfo->channels_min;
  735. runtime->hw.channels_max = hinfo->channels_max;
  736. runtime->hw.formats = hinfo->formats;
  737. runtime->hw.rates = hinfo->rates;
  738. snd_pcm_hw_constraint_step(substream->runtime, 0,
  739. SNDRV_PCM_HW_PARAM_CHANNELS, 2);
  740. return 0;
  741. }
  742. /*
  743. * HDA/HDMI auto parsing
  744. */
  745. static int hdmi_read_pin_conn(struct hda_codec *codec, hda_nid_t pin_nid)
  746. {
  747. struct hdmi_spec *spec = codec->spec;
  748. hda_nid_t conn_list[HDA_MAX_CONNECTIONS];
  749. int conn_len, curr;
  750. int index;
  751. if (!(get_wcaps(codec, pin_nid) & AC_WCAP_CONN_LIST)) {
  752. snd_printk(KERN_WARNING
  753. "HDMI: pin %d wcaps %#x "
  754. "does not support connection list\n",
  755. pin_nid, get_wcaps(codec, pin_nid));
  756. return -EINVAL;
  757. }
  758. conn_len = snd_hda_get_connections(codec, pin_nid, conn_list,
  759. HDA_MAX_CONNECTIONS);
  760. if (conn_len > 1)
  761. curr = snd_hda_codec_read(codec, pin_nid, 0,
  762. AC_VERB_GET_CONNECT_SEL, 0);
  763. else
  764. curr = 0;
  765. index = hda_node_index(spec->pin, pin_nid);
  766. if (index < 0)
  767. return -EINVAL;
  768. spec->pin_cvt[index] = conn_list[curr];
  769. return 0;
  770. }
  771. static void hdmi_present_sense(struct hda_codec *codec, hda_nid_t pin_nid,
  772. struct hdmi_eld *eld)
  773. {
  774. int present = snd_hda_pin_sense(codec, pin_nid);
  775. eld->monitor_present = !!(present & AC_PINSENSE_PRESENCE);
  776. eld->eld_valid = !!(present & AC_PINSENSE_ELDV);
  777. if (present & AC_PINSENSE_ELDV)
  778. hdmi_get_show_eld(codec, pin_nid, eld);
  779. }
  780. static int hdmi_add_pin(struct hda_codec *codec, hda_nid_t pin_nid)
  781. {
  782. struct hdmi_spec *spec = codec->spec;
  783. if (spec->num_pins >= MAX_HDMI_PINS) {
  784. snd_printk(KERN_WARNING
  785. "HDMI: no space for pin %d\n", pin_nid);
  786. return -E2BIG;
  787. }
  788. hdmi_present_sense(codec, pin_nid, &spec->sink_eld[spec->num_pins]);
  789. spec->pin[spec->num_pins] = pin_nid;
  790. spec->num_pins++;
  791. return hdmi_read_pin_conn(codec, pin_nid);
  792. }
  793. static int hdmi_add_cvt(struct hda_codec *codec, hda_nid_t nid)
  794. {
  795. int i, found_pin = 0;
  796. struct hdmi_spec *spec = codec->spec;
  797. for (i = 0; i < spec->num_pins; i++)
  798. if (nid == spec->pin_cvt[i]) {
  799. found_pin = 1;
  800. break;
  801. }
  802. if (!found_pin) {
  803. snd_printdd("HDMI: Skipping node %d (no connection)\n", nid);
  804. return -EINVAL;
  805. }
  806. if (snd_BUG_ON(spec->num_cvts >= MAX_HDMI_CVTS))
  807. return -E2BIG;
  808. spec->cvt[spec->num_cvts] = nid;
  809. spec->num_cvts++;
  810. return 0;
  811. }
  812. static int hdmi_parse_codec(struct hda_codec *codec)
  813. {
  814. hda_nid_t nid;
  815. int i, nodes;
  816. int num_tmp_cvts = 0;
  817. hda_nid_t tmp_cvt[MAX_HDMI_CVTS];
  818. nodes = snd_hda_get_sub_nodes(codec, codec->afg, &nid);
  819. if (!nid || nodes < 0) {
  820. snd_printk(KERN_WARNING "HDMI: failed to get afg sub nodes\n");
  821. return -EINVAL;
  822. }
  823. for (i = 0; i < nodes; i++, nid++) {
  824. unsigned int caps;
  825. unsigned int type;
  826. unsigned int config;
  827. caps = snd_hda_param_read(codec, nid, AC_PAR_AUDIO_WIDGET_CAP);
  828. type = get_wcaps_type(caps);
  829. if (!(caps & AC_WCAP_DIGITAL))
  830. continue;
  831. switch (type) {
  832. case AC_WID_AUD_OUT:
  833. if (num_tmp_cvts >= MAX_HDMI_CVTS) {
  834. snd_printk(KERN_WARNING
  835. "HDMI: no space for converter %d\n", nid);
  836. continue;
  837. }
  838. tmp_cvt[num_tmp_cvts] = nid;
  839. num_tmp_cvts++;
  840. break;
  841. case AC_WID_PIN:
  842. caps = snd_hda_param_read(codec, nid, AC_PAR_PIN_CAP);
  843. if (!(caps & (AC_PINCAP_HDMI | AC_PINCAP_DP)))
  844. continue;
  845. config = snd_hda_codec_read(codec, nid, 0,
  846. AC_VERB_GET_CONFIG_DEFAULT, 0);
  847. if (get_defcfg_connect(config) == AC_JACK_PORT_NONE)
  848. continue;
  849. hdmi_add_pin(codec, nid);
  850. break;
  851. }
  852. }
  853. for (i = 0; i < num_tmp_cvts; i++)
  854. hdmi_add_cvt(codec, tmp_cvt[i]);
  855. /*
  856. * G45/IbexPeak don't support EPSS: the unsolicited pin hot plug event
  857. * can be lost and presence sense verb will become inaccurate if the
  858. * HDA link is powered off at hot plug or hw initialization time.
  859. */
  860. #ifdef CONFIG_SND_HDA_POWER_SAVE
  861. if (!(snd_hda_param_read(codec, codec->afg, AC_PAR_POWER_STATE) &
  862. AC_PWRST_EPSS))
  863. codec->bus->power_keep_link_on = 1;
  864. #endif
  865. return 0;
  866. }
  867. /*
  868. */
  869. static char *generic_hdmi_pcm_names[MAX_HDMI_CVTS] = {
  870. "HDMI 0",
  871. "HDMI 1",
  872. "HDMI 2",
  873. };
  874. /*
  875. * HDMI callbacks
  876. */
  877. static int generic_hdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  878. struct hda_codec *codec,
  879. unsigned int stream_tag,
  880. unsigned int format,
  881. struct snd_pcm_substream *substream)
  882. {
  883. hdmi_set_channel_count(codec, hinfo->nid,
  884. substream->runtime->channels);
  885. hdmi_setup_audio_infoframe(codec, hinfo->nid, substream);
  886. return hdmi_setup_stream(codec, hinfo->nid, stream_tag, format);
  887. }
  888. static struct hda_pcm_stream generic_hdmi_pcm_playback = {
  889. .substreams = 1,
  890. .channels_min = 2,
  891. .ops = {
  892. .open = hdmi_pcm_open,
  893. .prepare = generic_hdmi_playback_pcm_prepare,
  894. },
  895. };
  896. static int generic_hdmi_build_pcms(struct hda_codec *codec)
  897. {
  898. struct hdmi_spec *spec = codec->spec;
  899. struct hda_pcm *info = spec->pcm_rec;
  900. int i;
  901. codec->num_pcms = spec->num_cvts;
  902. codec->pcm_info = info;
  903. for (i = 0; i < codec->num_pcms; i++, info++) {
  904. unsigned int chans;
  905. struct hda_pcm_stream *pstr;
  906. chans = get_wcaps(codec, spec->cvt[i]);
  907. chans = get_wcaps_channels(chans);
  908. info->name = generic_hdmi_pcm_names[i];
  909. info->pcm_type = HDA_PCM_TYPE_HDMI;
  910. pstr = &info->stream[SNDRV_PCM_STREAM_PLAYBACK];
  911. if (spec->pcm_playback)
  912. *pstr = *spec->pcm_playback;
  913. else
  914. *pstr = generic_hdmi_pcm_playback;
  915. pstr->nid = spec->cvt[i];
  916. if (pstr->channels_max <= 2 && chans && chans <= 16)
  917. pstr->channels_max = chans;
  918. }
  919. return 0;
  920. }
  921. static int generic_hdmi_build_controls(struct hda_codec *codec)
  922. {
  923. struct hdmi_spec *spec = codec->spec;
  924. int err;
  925. int i;
  926. for (i = 0; i < codec->num_pcms; i++) {
  927. err = snd_hda_create_spdif_out_ctls(codec, spec->cvt[i]);
  928. if (err < 0)
  929. return err;
  930. }
  931. return 0;
  932. }
  933. static int generic_hdmi_init(struct hda_codec *codec)
  934. {
  935. struct hdmi_spec *spec = codec->spec;
  936. int i;
  937. for (i = 0; spec->pin[i]; i++) {
  938. hdmi_enable_output(codec, spec->pin[i]);
  939. snd_hda_codec_write(codec, spec->pin[i], 0,
  940. AC_VERB_SET_UNSOLICITED_ENABLE,
  941. AC_USRSP_EN | spec->pin[i]);
  942. }
  943. return 0;
  944. }
  945. static void generic_hdmi_free(struct hda_codec *codec)
  946. {
  947. struct hdmi_spec *spec = codec->spec;
  948. int i;
  949. for (i = 0; i < spec->num_pins; i++)
  950. snd_hda_eld_proc_free(codec, &spec->sink_eld[i]);
  951. kfree(spec);
  952. }
  953. static struct hda_codec_ops generic_hdmi_patch_ops = {
  954. .init = generic_hdmi_init,
  955. .free = generic_hdmi_free,
  956. .build_pcms = generic_hdmi_build_pcms,
  957. .build_controls = generic_hdmi_build_controls,
  958. .unsol_event = hdmi_unsol_event,
  959. };
  960. static int patch_generic_hdmi(struct hda_codec *codec)
  961. {
  962. struct hdmi_spec *spec;
  963. int i;
  964. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  965. if (spec == NULL)
  966. return -ENOMEM;
  967. codec->spec = spec;
  968. if (hdmi_parse_codec(codec) < 0) {
  969. codec->spec = NULL;
  970. kfree(spec);
  971. return -EINVAL;
  972. }
  973. codec->patch_ops = generic_hdmi_patch_ops;
  974. for (i = 0; i < spec->num_pins; i++)
  975. snd_hda_eld_proc_new(codec, &spec->sink_eld[i], i);
  976. init_channel_allocations();
  977. return 0;
  978. }
  979. /*
  980. * Nvidia specific implementations
  981. */
  982. #define Nv_VERB_SET_Channel_Allocation 0xF79
  983. #define Nv_VERB_SET_Info_Frame_Checksum 0xF7A
  984. #define Nv_VERB_SET_Audio_Protection_On 0xF98
  985. #define Nv_VERB_SET_Audio_Protection_Off 0xF99
  986. #define nvhdmi_master_con_nid_7x 0x04
  987. #define nvhdmi_master_pin_nid_7x 0x05
  988. static hda_nid_t nvhdmi_con_nids_7x[4] = {
  989. /*front, rear, clfe, rear_surr */
  990. 0x6, 0x8, 0xa, 0xc,
  991. };
  992. static struct hda_verb nvhdmi_basic_init_7x[] = {
  993. /* set audio protect on */
  994. { 0x1, Nv_VERB_SET_Audio_Protection_On, 0x1},
  995. /* enable digital output on pin widget */
  996. { 0x5, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  997. { 0x7, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  998. { 0x9, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  999. { 0xb, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  1000. { 0xd, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT | 0x5 },
  1001. {} /* terminator */
  1002. };
  1003. #ifdef LIMITED_RATE_FMT_SUPPORT
  1004. /* support only the safe format and rate */
  1005. #define SUPPORTED_RATES SNDRV_PCM_RATE_48000
  1006. #define SUPPORTED_MAXBPS 16
  1007. #define SUPPORTED_FORMATS SNDRV_PCM_FMTBIT_S16_LE
  1008. #else
  1009. /* support all rates and formats */
  1010. #define SUPPORTED_RATES \
  1011. (SNDRV_PCM_RATE_32000 | SNDRV_PCM_RATE_44100 | SNDRV_PCM_RATE_48000 |\
  1012. SNDRV_PCM_RATE_88200 | SNDRV_PCM_RATE_96000 | SNDRV_PCM_RATE_176400 |\
  1013. SNDRV_PCM_RATE_192000)
  1014. #define SUPPORTED_MAXBPS 24
  1015. #define SUPPORTED_FORMATS \
  1016. (SNDRV_PCM_FMTBIT_S16_LE | SNDRV_PCM_FMTBIT_S32_LE)
  1017. #endif
  1018. static int nvhdmi_7x_init(struct hda_codec *codec)
  1019. {
  1020. snd_hda_sequence_write(codec, nvhdmi_basic_init_7x);
  1021. return 0;
  1022. }
  1023. static unsigned int channels_2_6_8[] = {
  1024. 2, 6, 8
  1025. };
  1026. static unsigned int channels_2_8[] = {
  1027. 2, 8
  1028. };
  1029. static struct snd_pcm_hw_constraint_list hw_constraints_2_6_8_channels = {
  1030. .count = ARRAY_SIZE(channels_2_6_8),
  1031. .list = channels_2_6_8,
  1032. .mask = 0,
  1033. };
  1034. static struct snd_pcm_hw_constraint_list hw_constraints_2_8_channels = {
  1035. .count = ARRAY_SIZE(channels_2_8),
  1036. .list = channels_2_8,
  1037. .mask = 0,
  1038. };
  1039. static int simple_playback_pcm_open(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. struct snd_pcm_hw_constraint_list *hw_constraints_channels = NULL;
  1045. switch (codec->preset->id) {
  1046. case 0x10de0002:
  1047. case 0x10de0003:
  1048. case 0x10de0005:
  1049. case 0x10de0006:
  1050. hw_constraints_channels = &hw_constraints_2_8_channels;
  1051. break;
  1052. case 0x10de0007:
  1053. hw_constraints_channels = &hw_constraints_2_6_8_channels;
  1054. break;
  1055. default:
  1056. break;
  1057. }
  1058. if (hw_constraints_channels != NULL) {
  1059. snd_pcm_hw_constraint_list(substream->runtime, 0,
  1060. SNDRV_PCM_HW_PARAM_CHANNELS,
  1061. hw_constraints_channels);
  1062. } else {
  1063. snd_pcm_hw_constraint_step(substream->runtime, 0,
  1064. SNDRV_PCM_HW_PARAM_CHANNELS, 2);
  1065. }
  1066. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  1067. }
  1068. static int simple_playback_pcm_close(struct hda_pcm_stream *hinfo,
  1069. struct hda_codec *codec,
  1070. struct snd_pcm_substream *substream)
  1071. {
  1072. struct hdmi_spec *spec = codec->spec;
  1073. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1074. }
  1075. static int simple_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1076. struct hda_codec *codec,
  1077. unsigned int stream_tag,
  1078. unsigned int format,
  1079. struct snd_pcm_substream *substream)
  1080. {
  1081. struct hdmi_spec *spec = codec->spec;
  1082. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout,
  1083. stream_tag, format, substream);
  1084. }
  1085. static int nvhdmi_8ch_7x_pcm_close(struct hda_pcm_stream *hinfo,
  1086. struct hda_codec *codec,
  1087. struct snd_pcm_substream *substream)
  1088. {
  1089. struct hdmi_spec *spec = codec->spec;
  1090. int i;
  1091. snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x,
  1092. 0, AC_VERB_SET_CHANNEL_STREAMID, 0);
  1093. for (i = 0; i < 4; i++) {
  1094. /* set the stream id */
  1095. snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0,
  1096. AC_VERB_SET_CHANNEL_STREAMID, 0);
  1097. /* set the stream format */
  1098. snd_hda_codec_write(codec, nvhdmi_con_nids_7x[i], 0,
  1099. AC_VERB_SET_STREAM_FORMAT, 0);
  1100. }
  1101. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  1102. }
  1103. static int nvhdmi_8ch_7x_pcm_prepare(struct hda_pcm_stream *hinfo,
  1104. struct hda_codec *codec,
  1105. unsigned int stream_tag,
  1106. unsigned int format,
  1107. struct snd_pcm_substream *substream)
  1108. {
  1109. int chs;
  1110. unsigned int dataDCC1, dataDCC2, chan, chanmask, channel_id;
  1111. int i;
  1112. mutex_lock(&codec->spdif_mutex);
  1113. chs = substream->runtime->channels;
  1114. chan = chs ? (chs - 1) : 1;
  1115. switch (chs) {
  1116. default:
  1117. case 0:
  1118. case 2:
  1119. chanmask = 0x00;
  1120. break;
  1121. case 4:
  1122. chanmask = 0x08;
  1123. break;
  1124. case 6:
  1125. chanmask = 0x0b;
  1126. break;
  1127. case 8:
  1128. chanmask = 0x13;
  1129. break;
  1130. }
  1131. dataDCC1 = AC_DIG1_ENABLE | AC_DIG1_COPYRIGHT;
  1132. dataDCC2 = 0x2;
  1133. /* set the Audio InforFrame Channel Allocation */
  1134. snd_hda_codec_write(codec, 0x1, 0,
  1135. Nv_VERB_SET_Channel_Allocation, chanmask);
  1136. /* turn off SPDIF once; otherwise the IEC958 bits won't be updated */
  1137. if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE))
  1138. snd_hda_codec_write(codec,
  1139. nvhdmi_master_con_nid_7x,
  1140. 0,
  1141. AC_VERB_SET_DIGI_CONVERT_1,
  1142. codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
  1143. /* set the stream id */
  1144. snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
  1145. AC_VERB_SET_CHANNEL_STREAMID, (stream_tag << 4) | 0x0);
  1146. /* set the stream format */
  1147. snd_hda_codec_write(codec, nvhdmi_master_con_nid_7x, 0,
  1148. AC_VERB_SET_STREAM_FORMAT, format);
  1149. /* turn on again (if needed) */
  1150. /* enable and set the channel status audio/data flag */
  1151. if (codec->spdif_status_reset && (codec->spdif_ctls & AC_DIG1_ENABLE)) {
  1152. snd_hda_codec_write(codec,
  1153. nvhdmi_master_con_nid_7x,
  1154. 0,
  1155. AC_VERB_SET_DIGI_CONVERT_1,
  1156. codec->spdif_ctls & 0xff);
  1157. snd_hda_codec_write(codec,
  1158. nvhdmi_master_con_nid_7x,
  1159. 0,
  1160. AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);
  1161. }
  1162. for (i = 0; i < 4; i++) {
  1163. if (chs == 2)
  1164. channel_id = 0;
  1165. else
  1166. channel_id = i * 2;
  1167. /* turn off SPDIF once;
  1168. *otherwise the IEC958 bits won't be updated
  1169. */
  1170. if (codec->spdif_status_reset &&
  1171. (codec->spdif_ctls & AC_DIG1_ENABLE))
  1172. snd_hda_codec_write(codec,
  1173. nvhdmi_con_nids_7x[i],
  1174. 0,
  1175. AC_VERB_SET_DIGI_CONVERT_1,
  1176. codec->spdif_ctls & ~AC_DIG1_ENABLE & 0xff);
  1177. /* set the stream id */
  1178. snd_hda_codec_write(codec,
  1179. nvhdmi_con_nids_7x[i],
  1180. 0,
  1181. AC_VERB_SET_CHANNEL_STREAMID,
  1182. (stream_tag << 4) | channel_id);
  1183. /* set the stream format */
  1184. snd_hda_codec_write(codec,
  1185. nvhdmi_con_nids_7x[i],
  1186. 0,
  1187. AC_VERB_SET_STREAM_FORMAT,
  1188. format);
  1189. /* turn on again (if needed) */
  1190. /* enable and set the channel status audio/data flag */
  1191. if (codec->spdif_status_reset &&
  1192. (codec->spdif_ctls & AC_DIG1_ENABLE)) {
  1193. snd_hda_codec_write(codec,
  1194. nvhdmi_con_nids_7x[i],
  1195. 0,
  1196. AC_VERB_SET_DIGI_CONVERT_1,
  1197. codec->spdif_ctls & 0xff);
  1198. snd_hda_codec_write(codec,
  1199. nvhdmi_con_nids_7x[i],
  1200. 0,
  1201. AC_VERB_SET_DIGI_CONVERT_2, dataDCC2);
  1202. }
  1203. }
  1204. /* set the Audio Info Frame Checksum */
  1205. snd_hda_codec_write(codec, 0x1, 0,
  1206. Nv_VERB_SET_Info_Frame_Checksum,
  1207. (0x71 - chan - chanmask));
  1208. mutex_unlock(&codec->spdif_mutex);
  1209. return 0;
  1210. }
  1211. static struct hda_pcm_stream nvhdmi_pcm_playback_8ch_7x = {
  1212. .substreams = 1,
  1213. .channels_min = 2,
  1214. .channels_max = 8,
  1215. .nid = nvhdmi_master_con_nid_7x,
  1216. .rates = SUPPORTED_RATES,
  1217. .maxbps = SUPPORTED_MAXBPS,
  1218. .formats = SUPPORTED_FORMATS,
  1219. .ops = {
  1220. .open = simple_playback_pcm_open,
  1221. .close = nvhdmi_8ch_7x_pcm_close,
  1222. .prepare = nvhdmi_8ch_7x_pcm_prepare
  1223. },
  1224. };
  1225. static struct hda_pcm_stream nvhdmi_pcm_playback_2ch = {
  1226. .substreams = 1,
  1227. .channels_min = 2,
  1228. .channels_max = 2,
  1229. .nid = nvhdmi_master_con_nid_7x,
  1230. .rates = SUPPORTED_RATES,
  1231. .maxbps = SUPPORTED_MAXBPS,
  1232. .formats = SUPPORTED_FORMATS,
  1233. .ops = {
  1234. .open = simple_playback_pcm_open,
  1235. .close = simple_playback_pcm_close,
  1236. .prepare = simple_playback_pcm_prepare
  1237. },
  1238. };
  1239. static struct hda_codec_ops nvhdmi_patch_ops_8ch_7x = {
  1240. .build_controls = generic_hdmi_build_controls,
  1241. .build_pcms = generic_hdmi_build_pcms,
  1242. .init = nvhdmi_7x_init,
  1243. .free = generic_hdmi_free,
  1244. };
  1245. static struct hda_codec_ops nvhdmi_patch_ops_2ch = {
  1246. .build_controls = generic_hdmi_build_controls,
  1247. .build_pcms = generic_hdmi_build_pcms,
  1248. .init = nvhdmi_7x_init,
  1249. .free = generic_hdmi_free,
  1250. };
  1251. static int patch_nvhdmi_8ch_89(struct hda_codec *codec)
  1252. {
  1253. struct hdmi_spec *spec;
  1254. int err = patch_generic_hdmi(codec);
  1255. if (err < 0)
  1256. return err;
  1257. spec = codec->spec;
  1258. spec->old_pin_detect = 1;
  1259. return 0;
  1260. }
  1261. static int patch_nvhdmi_2ch(struct hda_codec *codec)
  1262. {
  1263. struct hdmi_spec *spec;
  1264. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1265. if (spec == NULL)
  1266. return -ENOMEM;
  1267. codec->spec = spec;
  1268. spec->multiout.num_dacs = 0; /* no analog */
  1269. spec->multiout.max_channels = 2;
  1270. spec->multiout.dig_out_nid = nvhdmi_master_con_nid_7x;
  1271. spec->old_pin_detect = 1;
  1272. spec->num_cvts = 1;
  1273. spec->cvt[0] = nvhdmi_master_con_nid_7x;
  1274. spec->pcm_playback = &nvhdmi_pcm_playback_2ch;
  1275. codec->patch_ops = nvhdmi_patch_ops_2ch;
  1276. return 0;
  1277. }
  1278. static int patch_nvhdmi_8ch_7x(struct hda_codec *codec)
  1279. {
  1280. struct hdmi_spec *spec;
  1281. int err = patch_nvhdmi_2ch(codec);
  1282. if (err < 0)
  1283. return err;
  1284. spec = codec->spec;
  1285. spec->multiout.max_channels = 8;
  1286. spec->pcm_playback = &nvhdmi_pcm_playback_8ch_7x;
  1287. codec->patch_ops = nvhdmi_patch_ops_8ch_7x;
  1288. return 0;
  1289. }
  1290. /*
  1291. * ATI-specific implementations
  1292. *
  1293. * FIXME: we may omit the whole this and use the generic code once after
  1294. * it's confirmed to work.
  1295. */
  1296. #define ATIHDMI_CVT_NID 0x02 /* audio converter */
  1297. #define ATIHDMI_PIN_NID 0x03 /* HDMI output pin */
  1298. static int atihdmi_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  1299. struct hda_codec *codec,
  1300. unsigned int stream_tag,
  1301. unsigned int format,
  1302. struct snd_pcm_substream *substream)
  1303. {
  1304. struct hdmi_spec *spec = codec->spec;
  1305. int chans = substream->runtime->channels;
  1306. int i, err;
  1307. err = simple_playback_pcm_prepare(hinfo, codec, stream_tag, format,
  1308. substream);
  1309. if (err < 0)
  1310. return err;
  1311. snd_hda_codec_write(codec, spec->cvt[0], 0, AC_VERB_SET_CVT_CHAN_COUNT,
  1312. chans - 1);
  1313. /* FIXME: XXX */
  1314. for (i = 0; i < chans; i++) {
  1315. snd_hda_codec_write(codec, spec->cvt[0], 0,
  1316. AC_VERB_SET_HDMI_CHAN_SLOT,
  1317. (i << 4) | i);
  1318. }
  1319. return 0;
  1320. }
  1321. static struct hda_pcm_stream atihdmi_pcm_digital_playback = {
  1322. .substreams = 1,
  1323. .channels_min = 2,
  1324. .channels_max = 2,
  1325. .nid = ATIHDMI_CVT_NID,
  1326. .ops = {
  1327. .open = simple_playback_pcm_open,
  1328. .close = simple_playback_pcm_close,
  1329. .prepare = atihdmi_playback_pcm_prepare
  1330. },
  1331. };
  1332. static struct hda_verb atihdmi_basic_init[] = {
  1333. /* enable digital output on pin widget */
  1334. { 0x03, AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT },
  1335. {} /* terminator */
  1336. };
  1337. static int atihdmi_init(struct hda_codec *codec)
  1338. {
  1339. struct hdmi_spec *spec = codec->spec;
  1340. snd_hda_sequence_write(codec, atihdmi_basic_init);
  1341. /* SI codec requires to unmute the pin */
  1342. if (get_wcaps(codec, spec->pin[0]) & AC_WCAP_OUT_AMP)
  1343. snd_hda_codec_write(codec, spec->pin[0], 0,
  1344. AC_VERB_SET_AMP_GAIN_MUTE,
  1345. AMP_OUT_UNMUTE);
  1346. return 0;
  1347. }
  1348. static struct hda_codec_ops atihdmi_patch_ops = {
  1349. .build_controls = generic_hdmi_build_controls,
  1350. .build_pcms = generic_hdmi_build_pcms,
  1351. .init = atihdmi_init,
  1352. .free = generic_hdmi_free,
  1353. };
  1354. static int patch_atihdmi(struct hda_codec *codec)
  1355. {
  1356. struct hdmi_spec *spec;
  1357. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1358. if (spec == NULL)
  1359. return -ENOMEM;
  1360. codec->spec = spec;
  1361. spec->multiout.num_dacs = 0; /* no analog */
  1362. spec->multiout.max_channels = 2;
  1363. spec->multiout.dig_out_nid = ATIHDMI_CVT_NID;
  1364. spec->num_cvts = 1;
  1365. spec->cvt[0] = ATIHDMI_CVT_NID;
  1366. spec->pin[0] = ATIHDMI_PIN_NID;
  1367. spec->pcm_playback = &atihdmi_pcm_digital_playback;
  1368. codec->patch_ops = atihdmi_patch_ops;
  1369. return 0;
  1370. }
  1371. /*
  1372. * patch entries
  1373. */
  1374. static struct hda_codec_preset snd_hda_preset_hdmi[] = {
  1375. { .id = 0x1002793c, .name = "RS600 HDMI", .patch = patch_atihdmi },
  1376. { .id = 0x10027919, .name = "RS600 HDMI", .patch = patch_atihdmi },
  1377. { .id = 0x1002791a, .name = "RS690/780 HDMI", .patch = patch_atihdmi },
  1378. { .id = 0x1002aa01, .name = "R6xx HDMI", .patch = patch_generic_hdmi },
  1379. { .id = 0x10951390, .name = "SiI1390 HDMI", .patch = patch_generic_hdmi },
  1380. { .id = 0x10951392, .name = "SiI1392 HDMI", .patch = patch_generic_hdmi },
  1381. { .id = 0x17e80047, .name = "Chrontel HDMI", .patch = patch_generic_hdmi },
  1382. { .id = 0x10de0002, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
  1383. { .id = 0x10de0003, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
  1384. { .id = 0x10de0005, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
  1385. { .id = 0x10de0006, .name = "MCP77/78 HDMI", .patch = patch_nvhdmi_8ch_7x },
  1386. { .id = 0x10de0007, .name = "MCP79/7A HDMI", .patch = patch_nvhdmi_8ch_7x },
  1387. { .id = 0x10de000a, .name = "GPU 0a HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1388. { .id = 0x10de000b, .name = "GPU 0b HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1389. { .id = 0x10de000c, .name = "MCP89 HDMI", .patch = patch_nvhdmi_8ch_89 },
  1390. { .id = 0x10de000d, .name = "GPU 0d HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1391. { .id = 0x10de0010, .name = "GPU 10 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1392. { .id = 0x10de0011, .name = "GPU 11 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1393. { .id = 0x10de0012, .name = "GPU 12 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1394. { .id = 0x10de0013, .name = "GPU 13 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1395. { .id = 0x10de0014, .name = "GPU 14 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1396. { .id = 0x10de0018, .name = "GPU 18 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1397. { .id = 0x10de0019, .name = "GPU 19 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1398. { .id = 0x10de001a, .name = "GPU 1a HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1399. { .id = 0x10de001b, .name = "GPU 1b HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1400. { .id = 0x10de001c, .name = "GPU 1c HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1401. { .id = 0x10de0040, .name = "GPU 40 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1402. { .id = 0x10de0041, .name = "GPU 41 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1403. { .id = 0x10de0042, .name = "GPU 42 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1404. { .id = 0x10de0043, .name = "GPU 43 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1405. { .id = 0x10de0044, .name = "GPU 44 HDMI/DP", .patch = patch_nvhdmi_8ch_89 },
  1406. { .id = 0x10de0067, .name = "MCP67 HDMI", .patch = patch_nvhdmi_2ch },
  1407. { .id = 0x10de8001, .name = "MCP73 HDMI", .patch = patch_nvhdmi_2ch },
  1408. { .id = 0x80860054, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi },
  1409. { .id = 0x80862801, .name = "Bearlake HDMI", .patch = patch_generic_hdmi },
  1410. { .id = 0x80862802, .name = "Cantiga HDMI", .patch = patch_generic_hdmi },
  1411. { .id = 0x80862803, .name = "Eaglelake HDMI", .patch = patch_generic_hdmi },
  1412. { .id = 0x80862804, .name = "IbexPeak HDMI", .patch = patch_generic_hdmi },
  1413. { .id = 0x80862805, .name = "CougarPoint HDMI", .patch = patch_generic_hdmi },
  1414. { .id = 0x808629fb, .name = "Crestline HDMI", .patch = patch_generic_hdmi },
  1415. {} /* terminator */
  1416. };
  1417. MODULE_ALIAS("snd-hda-codec-id:1002793c");
  1418. MODULE_ALIAS("snd-hda-codec-id:10027919");
  1419. MODULE_ALIAS("snd-hda-codec-id:1002791a");
  1420. MODULE_ALIAS("snd-hda-codec-id:1002aa01");
  1421. MODULE_ALIAS("snd-hda-codec-id:10951390");
  1422. MODULE_ALIAS("snd-hda-codec-id:10951392");
  1423. MODULE_ALIAS("snd-hda-codec-id:10de0002");
  1424. MODULE_ALIAS("snd-hda-codec-id:10de0003");
  1425. MODULE_ALIAS("snd-hda-codec-id:10de0005");
  1426. MODULE_ALIAS("snd-hda-codec-id:10de0006");
  1427. MODULE_ALIAS("snd-hda-codec-id:10de0007");
  1428. MODULE_ALIAS("snd-hda-codec-id:10de000a");
  1429. MODULE_ALIAS("snd-hda-codec-id:10de000b");
  1430. MODULE_ALIAS("snd-hda-codec-id:10de000c");
  1431. MODULE_ALIAS("snd-hda-codec-id:10de000d");
  1432. MODULE_ALIAS("snd-hda-codec-id:10de0010");
  1433. MODULE_ALIAS("snd-hda-codec-id:10de0011");
  1434. MODULE_ALIAS("snd-hda-codec-id:10de0012");
  1435. MODULE_ALIAS("snd-hda-codec-id:10de0013");
  1436. MODULE_ALIAS("snd-hda-codec-id:10de0014");
  1437. MODULE_ALIAS("snd-hda-codec-id:10de0018");
  1438. MODULE_ALIAS("snd-hda-codec-id:10de0019");
  1439. MODULE_ALIAS("snd-hda-codec-id:10de001a");
  1440. MODULE_ALIAS("snd-hda-codec-id:10de001b");
  1441. MODULE_ALIAS("snd-hda-codec-id:10de001c");
  1442. MODULE_ALIAS("snd-hda-codec-id:10de0040");
  1443. MODULE_ALIAS("snd-hda-codec-id:10de0041");
  1444. MODULE_ALIAS("snd-hda-codec-id:10de0042");
  1445. MODULE_ALIAS("snd-hda-codec-id:10de0043");
  1446. MODULE_ALIAS("snd-hda-codec-id:10de0044");
  1447. MODULE_ALIAS("snd-hda-codec-id:10de0067");
  1448. MODULE_ALIAS("snd-hda-codec-id:10de8001");
  1449. MODULE_ALIAS("snd-hda-codec-id:17e80047");
  1450. MODULE_ALIAS("snd-hda-codec-id:80860054");
  1451. MODULE_ALIAS("snd-hda-codec-id:80862801");
  1452. MODULE_ALIAS("snd-hda-codec-id:80862802");
  1453. MODULE_ALIAS("snd-hda-codec-id:80862803");
  1454. MODULE_ALIAS("snd-hda-codec-id:80862804");
  1455. MODULE_ALIAS("snd-hda-codec-id:80862805");
  1456. MODULE_ALIAS("snd-hda-codec-id:808629fb");
  1457. MODULE_LICENSE("GPL");
  1458. MODULE_DESCRIPTION("HDMI HD-audio codec");
  1459. MODULE_ALIAS("snd-hda-codec-intelhdmi");
  1460. MODULE_ALIAS("snd-hda-codec-nvhdmi");
  1461. MODULE_ALIAS("snd-hda-codec-atihdmi");
  1462. static struct hda_codec_preset_list intel_list = {
  1463. .preset = snd_hda_preset_hdmi,
  1464. .owner = THIS_MODULE,
  1465. };
  1466. static int __init patch_hdmi_init(void)
  1467. {
  1468. return snd_hda_add_codec_preset(&intel_list);
  1469. }
  1470. static void __exit patch_hdmi_exit(void)
  1471. {
  1472. snd_hda_delete_codec_preset(&intel_list);
  1473. }
  1474. module_init(patch_hdmi_init)
  1475. module_exit(patch_hdmi_exit)