patch_hdmi.c 48 KB

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