patch_hdmi.c 45 KB

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