patch_hdmi.c 48 KB

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