patch_hdmi.c 49 KB

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