patch_cirrus.c 30 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205
  1. /*
  2. * HD audio interface patch for Cirrus Logic CS420x chip
  3. *
  4. * Copyright (c) 2009 Takashi Iwai <tiwai@suse.de>
  5. *
  6. * This driver is free software; you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation; either version 2 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This driver is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  19. */
  20. #include <linux/init.h>
  21. #include <linux/delay.h>
  22. #include <linux/slab.h>
  23. #include <linux/pci.h>
  24. #include <sound/core.h>
  25. #include "hda_codec.h"
  26. #include "hda_local.h"
  27. /*
  28. */
  29. struct cs_spec {
  30. int board_config;
  31. struct auto_pin_cfg autocfg;
  32. struct hda_multi_out multiout;
  33. struct snd_kcontrol *vmaster_sw;
  34. struct snd_kcontrol *vmaster_vol;
  35. hda_nid_t dac_nid[AUTO_CFG_MAX_OUTS];
  36. hda_nid_t slave_dig_outs[2];
  37. unsigned int input_idx[AUTO_PIN_LAST];
  38. unsigned int capsrc_idx[AUTO_PIN_LAST];
  39. hda_nid_t adc_nid[AUTO_PIN_LAST];
  40. unsigned int adc_idx[AUTO_PIN_LAST];
  41. unsigned int num_inputs;
  42. unsigned int cur_input;
  43. unsigned int automic_idx;
  44. hda_nid_t cur_adc;
  45. unsigned int cur_adc_stream_tag;
  46. unsigned int cur_adc_format;
  47. hda_nid_t dig_in;
  48. struct hda_bind_ctls *capture_bind[2];
  49. unsigned int gpio_mask;
  50. unsigned int gpio_dir;
  51. unsigned int gpio_data;
  52. struct hda_pcm pcm_rec[2]; /* PCM information */
  53. unsigned int hp_detect:1;
  54. unsigned int mic_detect:1;
  55. };
  56. /* available models */
  57. enum {
  58. CS420X_MBP55,
  59. CS420X_IMAC27,
  60. CS420X_AUTO,
  61. CS420X_MODELS
  62. };
  63. /* Vendor-specific processing widget */
  64. #define CS420X_VENDOR_NID 0x11
  65. #define CS_DIG_OUT1_PIN_NID 0x10
  66. #define CS_DIG_OUT2_PIN_NID 0x15
  67. #define CS_DMIC1_PIN_NID 0x12
  68. #define CS_DMIC2_PIN_NID 0x0e
  69. /* coef indices */
  70. #define IDX_SPDIF_STAT 0x0000
  71. #define IDX_SPDIF_CTL 0x0001
  72. #define IDX_ADC_CFG 0x0002
  73. /* SZC bitmask, 4 modes below:
  74. * 0 = immediate,
  75. * 1 = digital immediate, analog zero-cross
  76. * 2 = digtail & analog soft-ramp
  77. * 3 = digital soft-ramp, analog zero-cross
  78. */
  79. #define CS_COEF_ADC_SZC_MASK (3 << 0)
  80. #define CS_COEF_ADC_MIC_SZC_MODE (3 << 0) /* SZC setup for mic */
  81. #define CS_COEF_ADC_LI_SZC_MODE (3 << 0) /* SZC setup for line-in */
  82. /* PGA mode: 0 = differential, 1 = signle-ended */
  83. #define CS_COEF_ADC_MIC_PGA_MODE (1 << 5) /* PGA setup for mic */
  84. #define CS_COEF_ADC_LI_PGA_MODE (1 << 6) /* PGA setup for line-in */
  85. #define IDX_DAC_CFG 0x0003
  86. /* SZC bitmask, 4 modes below:
  87. * 0 = Immediate
  88. * 1 = zero-cross
  89. * 2 = soft-ramp
  90. * 3 = soft-ramp on zero-cross
  91. */
  92. #define CS_COEF_DAC_HP_SZC_MODE (3 << 0) /* nid 0x02 */
  93. #define CS_COEF_DAC_LO_SZC_MODE (3 << 2) /* nid 0x03 */
  94. #define CS_COEF_DAC_SPK_SZC_MODE (3 << 4) /* nid 0x04 */
  95. #define IDX_BEEP_CFG 0x0004
  96. /* 0x0008 - test reg key */
  97. /* 0x0009 - 0x0014 -> 12 test regs */
  98. /* 0x0015 - visibility reg */
  99. static inline int cs_vendor_coef_get(struct hda_codec *codec, unsigned int idx)
  100. {
  101. snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0,
  102. AC_VERB_SET_COEF_INDEX, idx);
  103. return snd_hda_codec_read(codec, CS420X_VENDOR_NID, 0,
  104. AC_VERB_GET_PROC_COEF, 0);
  105. }
  106. static inline void cs_vendor_coef_set(struct hda_codec *codec, unsigned int idx,
  107. unsigned int coef)
  108. {
  109. snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0,
  110. AC_VERB_SET_COEF_INDEX, idx);
  111. snd_hda_codec_write(codec, CS420X_VENDOR_NID, 0,
  112. AC_VERB_SET_PROC_COEF, coef);
  113. }
  114. #define HP_EVENT 1
  115. #define MIC_EVENT 2
  116. /*
  117. * PCM callbacks
  118. */
  119. static int cs_playback_pcm_open(struct hda_pcm_stream *hinfo,
  120. struct hda_codec *codec,
  121. struct snd_pcm_substream *substream)
  122. {
  123. struct cs_spec *spec = codec->spec;
  124. return snd_hda_multi_out_analog_open(codec, &spec->multiout, substream,
  125. hinfo);
  126. }
  127. static int cs_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  128. struct hda_codec *codec,
  129. unsigned int stream_tag,
  130. unsigned int format,
  131. struct snd_pcm_substream *substream)
  132. {
  133. struct cs_spec *spec = codec->spec;
  134. return snd_hda_multi_out_analog_prepare(codec, &spec->multiout,
  135. stream_tag, format, substream);
  136. }
  137. static int cs_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  138. struct hda_codec *codec,
  139. struct snd_pcm_substream *substream)
  140. {
  141. struct cs_spec *spec = codec->spec;
  142. return snd_hda_multi_out_analog_cleanup(codec, &spec->multiout);
  143. }
  144. /*
  145. * Digital out
  146. */
  147. static int cs_dig_playback_pcm_open(struct hda_pcm_stream *hinfo,
  148. struct hda_codec *codec,
  149. struct snd_pcm_substream *substream)
  150. {
  151. struct cs_spec *spec = codec->spec;
  152. return snd_hda_multi_out_dig_open(codec, &spec->multiout);
  153. }
  154. static int cs_dig_playback_pcm_close(struct hda_pcm_stream *hinfo,
  155. struct hda_codec *codec,
  156. struct snd_pcm_substream *substream)
  157. {
  158. struct cs_spec *spec = codec->spec;
  159. return snd_hda_multi_out_dig_close(codec, &spec->multiout);
  160. }
  161. static int cs_dig_playback_pcm_prepare(struct hda_pcm_stream *hinfo,
  162. struct hda_codec *codec,
  163. unsigned int stream_tag,
  164. unsigned int format,
  165. struct snd_pcm_substream *substream)
  166. {
  167. struct cs_spec *spec = codec->spec;
  168. return snd_hda_multi_out_dig_prepare(codec, &spec->multiout, stream_tag,
  169. format, substream);
  170. }
  171. static int cs_dig_playback_pcm_cleanup(struct hda_pcm_stream *hinfo,
  172. struct hda_codec *codec,
  173. struct snd_pcm_substream *substream)
  174. {
  175. struct cs_spec *spec = codec->spec;
  176. return snd_hda_multi_out_dig_cleanup(codec, &spec->multiout);
  177. }
  178. /*
  179. * Analog capture
  180. */
  181. static int cs_capture_pcm_prepare(struct hda_pcm_stream *hinfo,
  182. struct hda_codec *codec,
  183. unsigned int stream_tag,
  184. unsigned int format,
  185. struct snd_pcm_substream *substream)
  186. {
  187. struct cs_spec *spec = codec->spec;
  188. spec->cur_adc = spec->adc_nid[spec->cur_input];
  189. spec->cur_adc_stream_tag = stream_tag;
  190. spec->cur_adc_format = format;
  191. snd_hda_codec_setup_stream(codec, spec->cur_adc, stream_tag, 0, format);
  192. return 0;
  193. }
  194. static int cs_capture_pcm_cleanup(struct hda_pcm_stream *hinfo,
  195. struct hda_codec *codec,
  196. struct snd_pcm_substream *substream)
  197. {
  198. struct cs_spec *spec = codec->spec;
  199. snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
  200. spec->cur_adc = 0;
  201. return 0;
  202. }
  203. /*
  204. */
  205. static struct hda_pcm_stream cs_pcm_analog_playback = {
  206. .substreams = 1,
  207. .channels_min = 2,
  208. .channels_max = 2,
  209. .ops = {
  210. .open = cs_playback_pcm_open,
  211. .prepare = cs_playback_pcm_prepare,
  212. .cleanup = cs_playback_pcm_cleanup
  213. },
  214. };
  215. static struct hda_pcm_stream cs_pcm_analog_capture = {
  216. .substreams = 1,
  217. .channels_min = 2,
  218. .channels_max = 2,
  219. .ops = {
  220. .prepare = cs_capture_pcm_prepare,
  221. .cleanup = cs_capture_pcm_cleanup
  222. },
  223. };
  224. static struct hda_pcm_stream cs_pcm_digital_playback = {
  225. .substreams = 1,
  226. .channels_min = 2,
  227. .channels_max = 2,
  228. .ops = {
  229. .open = cs_dig_playback_pcm_open,
  230. .close = cs_dig_playback_pcm_close,
  231. .prepare = cs_dig_playback_pcm_prepare,
  232. .cleanup = cs_dig_playback_pcm_cleanup
  233. },
  234. };
  235. static struct hda_pcm_stream cs_pcm_digital_capture = {
  236. .substreams = 1,
  237. .channels_min = 2,
  238. .channels_max = 2,
  239. };
  240. static int cs_build_pcms(struct hda_codec *codec)
  241. {
  242. struct cs_spec *spec = codec->spec;
  243. struct hda_pcm *info = spec->pcm_rec;
  244. codec->pcm_info = info;
  245. codec->num_pcms = 0;
  246. info->name = "Cirrus Analog";
  247. info->stream[SNDRV_PCM_STREAM_PLAYBACK] = cs_pcm_analog_playback;
  248. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid = spec->dac_nid[0];
  249. info->stream[SNDRV_PCM_STREAM_PLAYBACK].channels_max =
  250. spec->multiout.max_channels;
  251. info->stream[SNDRV_PCM_STREAM_CAPTURE] = cs_pcm_analog_capture;
  252. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid =
  253. spec->adc_nid[spec->cur_input];
  254. codec->num_pcms++;
  255. if (!spec->multiout.dig_out_nid && !spec->dig_in)
  256. return 0;
  257. info++;
  258. info->name = "Cirrus Digital";
  259. info->pcm_type = spec->autocfg.dig_out_type[0];
  260. if (!info->pcm_type)
  261. info->pcm_type = HDA_PCM_TYPE_SPDIF;
  262. if (spec->multiout.dig_out_nid) {
  263. info->stream[SNDRV_PCM_STREAM_PLAYBACK] =
  264. cs_pcm_digital_playback;
  265. info->stream[SNDRV_PCM_STREAM_PLAYBACK].nid =
  266. spec->multiout.dig_out_nid;
  267. }
  268. if (spec->dig_in) {
  269. info->stream[SNDRV_PCM_STREAM_CAPTURE] =
  270. cs_pcm_digital_capture;
  271. info->stream[SNDRV_PCM_STREAM_CAPTURE].nid = spec->dig_in;
  272. }
  273. codec->num_pcms++;
  274. return 0;
  275. }
  276. /*
  277. * parse codec topology
  278. */
  279. static hda_nid_t get_dac(struct hda_codec *codec, hda_nid_t pin)
  280. {
  281. hda_nid_t dac;
  282. if (!pin)
  283. return 0;
  284. if (snd_hda_get_connections(codec, pin, &dac, 1) != 1)
  285. return 0;
  286. return dac;
  287. }
  288. static int is_ext_mic(struct hda_codec *codec, unsigned int idx)
  289. {
  290. struct cs_spec *spec = codec->spec;
  291. struct auto_pin_cfg *cfg = &spec->autocfg;
  292. hda_nid_t pin = cfg->input_pins[idx];
  293. unsigned int val = snd_hda_query_pin_caps(codec, pin);
  294. if (!(val & AC_PINCAP_PRES_DETECT))
  295. return 0;
  296. val = snd_hda_codec_get_pincfg(codec, pin);
  297. return (get_defcfg_connect(val) == AC_JACK_PORT_COMPLEX);
  298. }
  299. static hda_nid_t get_adc(struct hda_codec *codec, hda_nid_t pin,
  300. unsigned int *idxp)
  301. {
  302. int i;
  303. hda_nid_t nid;
  304. nid = codec->start_nid;
  305. for (i = 0; i < codec->num_nodes; i++, nid++) {
  306. hda_nid_t pins[2];
  307. unsigned int type;
  308. int j, nums;
  309. type = (get_wcaps(codec, nid) & AC_WCAP_TYPE)
  310. >> AC_WCAP_TYPE_SHIFT;
  311. if (type != AC_WID_AUD_IN)
  312. continue;
  313. nums = snd_hda_get_connections(codec, nid, pins,
  314. ARRAY_SIZE(pins));
  315. if (nums <= 0)
  316. continue;
  317. for (j = 0; j < nums; j++) {
  318. if (pins[j] == pin) {
  319. *idxp = j;
  320. return nid;
  321. }
  322. }
  323. }
  324. return 0;
  325. }
  326. static int is_active_pin(struct hda_codec *codec, hda_nid_t nid)
  327. {
  328. unsigned int val;
  329. val = snd_hda_codec_get_pincfg(codec, nid);
  330. return (get_defcfg_connect(val) != AC_JACK_PORT_NONE);
  331. }
  332. static int parse_output(struct hda_codec *codec)
  333. {
  334. struct cs_spec *spec = codec->spec;
  335. struct auto_pin_cfg *cfg = &spec->autocfg;
  336. int i, extra_nids;
  337. hda_nid_t dac;
  338. for (i = 0; i < cfg->line_outs; i++) {
  339. dac = get_dac(codec, cfg->line_out_pins[i]);
  340. if (!dac)
  341. break;
  342. spec->dac_nid[i] = dac;
  343. }
  344. spec->multiout.num_dacs = i;
  345. spec->multiout.dac_nids = spec->dac_nid;
  346. spec->multiout.max_channels = i * 2;
  347. /* add HP and speakers */
  348. extra_nids = 0;
  349. for (i = 0; i < cfg->hp_outs; i++) {
  350. dac = get_dac(codec, cfg->hp_pins[i]);
  351. if (!dac)
  352. break;
  353. if (!i)
  354. spec->multiout.hp_nid = dac;
  355. else
  356. spec->multiout.extra_out_nid[extra_nids++] = dac;
  357. }
  358. for (i = 0; i < cfg->speaker_outs; i++) {
  359. dac = get_dac(codec, cfg->speaker_pins[i]);
  360. if (!dac)
  361. break;
  362. spec->multiout.extra_out_nid[extra_nids++] = dac;
  363. }
  364. if (cfg->line_out_type == AUTO_PIN_SPEAKER_OUT) {
  365. cfg->speaker_outs = cfg->line_outs;
  366. memcpy(cfg->speaker_pins, cfg->line_out_pins,
  367. sizeof(cfg->speaker_pins));
  368. cfg->line_outs = 0;
  369. }
  370. return 0;
  371. }
  372. static int parse_input(struct hda_codec *codec)
  373. {
  374. struct cs_spec *spec = codec->spec;
  375. struct auto_pin_cfg *cfg = &spec->autocfg;
  376. int i;
  377. for (i = 0; i < AUTO_PIN_LAST; i++) {
  378. hda_nid_t pin = cfg->input_pins[i];
  379. if (!pin)
  380. continue;
  381. spec->input_idx[spec->num_inputs] = i;
  382. spec->capsrc_idx[i] = spec->num_inputs++;
  383. spec->cur_input = i;
  384. spec->adc_nid[i] = get_adc(codec, pin, &spec->adc_idx[i]);
  385. }
  386. if (!spec->num_inputs)
  387. return 0;
  388. /* check whether the automatic mic switch is available */
  389. if (spec->num_inputs == 2 &&
  390. spec->adc_nid[AUTO_PIN_MIC] && spec->adc_nid[AUTO_PIN_FRONT_MIC]) {
  391. if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_FRONT_MIC])) {
  392. if (!is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) {
  393. spec->mic_detect = 1;
  394. spec->automic_idx = AUTO_PIN_FRONT_MIC;
  395. }
  396. } else {
  397. if (is_ext_mic(codec, cfg->input_pins[AUTO_PIN_MIC])) {
  398. spec->mic_detect = 1;
  399. spec->automic_idx = AUTO_PIN_MIC;
  400. }
  401. }
  402. }
  403. return 0;
  404. }
  405. static int parse_digital_output(struct hda_codec *codec)
  406. {
  407. struct cs_spec *spec = codec->spec;
  408. struct auto_pin_cfg *cfg = &spec->autocfg;
  409. hda_nid_t nid;
  410. if (!cfg->dig_outs)
  411. return 0;
  412. if (snd_hda_get_connections(codec, cfg->dig_out_pins[0], &nid, 1) < 1)
  413. return 0;
  414. spec->multiout.dig_out_nid = nid;
  415. spec->multiout.share_spdif = 1;
  416. if (cfg->dig_outs > 1 &&
  417. snd_hda_get_connections(codec, cfg->dig_out_pins[1], &nid, 1) > 0) {
  418. spec->slave_dig_outs[0] = nid;
  419. codec->slave_dig_outs = spec->slave_dig_outs;
  420. }
  421. return 0;
  422. }
  423. static int parse_digital_input(struct hda_codec *codec)
  424. {
  425. struct cs_spec *spec = codec->spec;
  426. struct auto_pin_cfg *cfg = &spec->autocfg;
  427. int idx;
  428. if (cfg->dig_in_pin)
  429. spec->dig_in = get_adc(codec, cfg->dig_in_pin, &idx);
  430. return 0;
  431. }
  432. /*
  433. * create mixer controls
  434. */
  435. static const char *dir_sfx[2] = { "Playback", "Capture" };
  436. static int add_mute(struct hda_codec *codec, const char *name, int index,
  437. unsigned int pval, int dir, struct snd_kcontrol **kctlp)
  438. {
  439. char tmp[44];
  440. struct snd_kcontrol_new knew =
  441. HDA_CODEC_MUTE_IDX(tmp, index, 0, 0, HDA_OUTPUT);
  442. knew.private_value = pval;
  443. snprintf(tmp, sizeof(tmp), "%s %s Switch", name, dir_sfx[dir]);
  444. *kctlp = snd_ctl_new1(&knew, codec);
  445. return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp);
  446. }
  447. static int add_volume(struct hda_codec *codec, const char *name,
  448. int index, unsigned int pval, int dir,
  449. struct snd_kcontrol **kctlp)
  450. {
  451. char tmp[32];
  452. struct snd_kcontrol_new knew =
  453. HDA_CODEC_VOLUME_IDX(tmp, index, 0, 0, HDA_OUTPUT);
  454. knew.private_value = pval;
  455. snprintf(tmp, sizeof(tmp), "%s %s Volume", name, dir_sfx[dir]);
  456. *kctlp = snd_ctl_new1(&knew, codec);
  457. return snd_hda_ctl_add(codec, get_amp_nid_(pval), *kctlp);
  458. }
  459. static void fix_volume_caps(struct hda_codec *codec, hda_nid_t dac)
  460. {
  461. unsigned int caps;
  462. /* set the upper-limit for mixer amp to 0dB */
  463. caps = query_amp_caps(codec, dac, HDA_OUTPUT);
  464. caps &= ~(0x7f << AC_AMPCAP_NUM_STEPS_SHIFT);
  465. caps |= ((caps >> AC_AMPCAP_OFFSET_SHIFT) & 0x7f)
  466. << AC_AMPCAP_NUM_STEPS_SHIFT;
  467. snd_hda_override_amp_caps(codec, dac, HDA_OUTPUT, caps);
  468. }
  469. static int add_vmaster(struct hda_codec *codec, hda_nid_t dac)
  470. {
  471. struct cs_spec *spec = codec->spec;
  472. unsigned int tlv[4];
  473. int err;
  474. spec->vmaster_sw =
  475. snd_ctl_make_virtual_master("Master Playback Switch", NULL);
  476. err = snd_hda_ctl_add(codec, dac, spec->vmaster_sw);
  477. if (err < 0)
  478. return err;
  479. snd_hda_set_vmaster_tlv(codec, dac, HDA_OUTPUT, tlv);
  480. spec->vmaster_vol =
  481. snd_ctl_make_virtual_master("Master Playback Volume", tlv);
  482. err = snd_hda_ctl_add(codec, dac, spec->vmaster_vol);
  483. if (err < 0)
  484. return err;
  485. return 0;
  486. }
  487. static int add_output(struct hda_codec *codec, hda_nid_t dac, int idx,
  488. int num_ctls, int type)
  489. {
  490. struct cs_spec *spec = codec->spec;
  491. const char *name;
  492. int err, index;
  493. struct snd_kcontrol *kctl;
  494. static char *speakers[] = {
  495. "Front Speaker", "Surround Speaker", "Bass Speaker"
  496. };
  497. static char *line_outs[] = {
  498. "Front Line-Out", "Surround Line-Out", "Bass Line-Out"
  499. };
  500. fix_volume_caps(codec, dac);
  501. if (!spec->vmaster_sw) {
  502. err = add_vmaster(codec, dac);
  503. if (err < 0)
  504. return err;
  505. }
  506. index = 0;
  507. switch (type) {
  508. case AUTO_PIN_HP_OUT:
  509. name = "Headphone";
  510. index = idx;
  511. break;
  512. case AUTO_PIN_SPEAKER_OUT:
  513. if (num_ctls > 1)
  514. name = speakers[idx];
  515. else
  516. name = "Speaker";
  517. break;
  518. default:
  519. if (num_ctls > 1)
  520. name = line_outs[idx];
  521. else
  522. name = "Line-Out";
  523. break;
  524. }
  525. err = add_mute(codec, name, index,
  526. HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl);
  527. if (err < 0)
  528. return err;
  529. err = snd_ctl_add_slave(spec->vmaster_sw, kctl);
  530. if (err < 0)
  531. return err;
  532. err = add_volume(codec, name, index,
  533. HDA_COMPOSE_AMP_VAL(dac, 3, 0, HDA_OUTPUT), 0, &kctl);
  534. if (err < 0)
  535. return err;
  536. err = snd_ctl_add_slave(spec->vmaster_vol, kctl);
  537. if (err < 0)
  538. return err;
  539. return 0;
  540. }
  541. static int build_output(struct hda_codec *codec)
  542. {
  543. struct cs_spec *spec = codec->spec;
  544. struct auto_pin_cfg *cfg = &spec->autocfg;
  545. int i, err;
  546. for (i = 0; i < cfg->line_outs; i++) {
  547. err = add_output(codec, get_dac(codec, cfg->line_out_pins[i]),
  548. i, cfg->line_outs, cfg->line_out_type);
  549. if (err < 0)
  550. return err;
  551. }
  552. for (i = 0; i < cfg->hp_outs; i++) {
  553. err = add_output(codec, get_dac(codec, cfg->hp_pins[i]),
  554. i, cfg->hp_outs, AUTO_PIN_HP_OUT);
  555. if (err < 0)
  556. return err;
  557. }
  558. for (i = 0; i < cfg->speaker_outs; i++) {
  559. err = add_output(codec, get_dac(codec, cfg->speaker_pins[i]),
  560. i, cfg->speaker_outs, AUTO_PIN_SPEAKER_OUT);
  561. if (err < 0)
  562. return err;
  563. }
  564. return 0;
  565. }
  566. /*
  567. */
  568. static struct snd_kcontrol_new cs_capture_ctls[] = {
  569. HDA_BIND_SW("Capture Switch", 0),
  570. HDA_BIND_VOL("Capture Volume", 0),
  571. };
  572. static int change_cur_input(struct hda_codec *codec, unsigned int idx,
  573. int force)
  574. {
  575. struct cs_spec *spec = codec->spec;
  576. if (spec->cur_input == idx && !force)
  577. return 0;
  578. if (spec->cur_adc && spec->cur_adc != spec->adc_nid[idx]) {
  579. /* stream is running, let's swap the current ADC */
  580. snd_hda_codec_cleanup_stream(codec, spec->cur_adc);
  581. spec->cur_adc = spec->adc_nid[idx];
  582. snd_hda_codec_setup_stream(codec, spec->cur_adc,
  583. spec->cur_adc_stream_tag, 0,
  584. spec->cur_adc_format);
  585. }
  586. snd_hda_codec_write(codec, spec->cur_adc, 0,
  587. AC_VERB_SET_CONNECT_SEL,
  588. spec->adc_idx[idx]);
  589. spec->cur_input = idx;
  590. return 1;
  591. }
  592. static int cs_capture_source_info(struct snd_kcontrol *kcontrol,
  593. struct snd_ctl_elem_info *uinfo)
  594. {
  595. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  596. struct cs_spec *spec = codec->spec;
  597. unsigned int idx;
  598. uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED;
  599. uinfo->count = 1;
  600. uinfo->value.enumerated.items = spec->num_inputs;
  601. if (uinfo->value.enumerated.item >= spec->num_inputs)
  602. uinfo->value.enumerated.item = spec->num_inputs - 1;
  603. idx = spec->input_idx[uinfo->value.enumerated.item];
  604. strcpy(uinfo->value.enumerated.name, auto_pin_cfg_labels[idx]);
  605. return 0;
  606. }
  607. static int cs_capture_source_get(struct snd_kcontrol *kcontrol,
  608. struct snd_ctl_elem_value *ucontrol)
  609. {
  610. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  611. struct cs_spec *spec = codec->spec;
  612. ucontrol->value.enumerated.item[0] = spec->capsrc_idx[spec->cur_input];
  613. return 0;
  614. }
  615. static int cs_capture_source_put(struct snd_kcontrol *kcontrol,
  616. struct snd_ctl_elem_value *ucontrol)
  617. {
  618. struct hda_codec *codec = snd_kcontrol_chip(kcontrol);
  619. struct cs_spec *spec = codec->spec;
  620. unsigned int idx = ucontrol->value.enumerated.item[0];
  621. if (idx >= spec->num_inputs)
  622. return -EINVAL;
  623. idx = spec->input_idx[idx];
  624. return change_cur_input(codec, idx, 0);
  625. }
  626. static struct snd_kcontrol_new cs_capture_source = {
  627. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  628. .name = "Capture Source",
  629. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  630. .info = cs_capture_source_info,
  631. .get = cs_capture_source_get,
  632. .put = cs_capture_source_put,
  633. };
  634. static struct hda_bind_ctls *make_bind_capture(struct hda_codec *codec,
  635. struct hda_ctl_ops *ops)
  636. {
  637. struct cs_spec *spec = codec->spec;
  638. struct hda_bind_ctls *bind;
  639. int i, n;
  640. bind = kzalloc(sizeof(*bind) + sizeof(long) * (spec->num_inputs + 1),
  641. GFP_KERNEL);
  642. if (!bind)
  643. return NULL;
  644. bind->ops = ops;
  645. n = 0;
  646. for (i = 0; i < AUTO_PIN_LAST; i++) {
  647. if (!spec->adc_nid[i])
  648. continue;
  649. bind->values[n++] =
  650. HDA_COMPOSE_AMP_VAL(spec->adc_nid[i], 3,
  651. spec->adc_idx[i], HDA_INPUT);
  652. }
  653. return bind;
  654. }
  655. static int build_input(struct hda_codec *codec)
  656. {
  657. struct cs_spec *spec = codec->spec;
  658. int i, err;
  659. if (!spec->num_inputs)
  660. return 0;
  661. /* make bind-capture */
  662. spec->capture_bind[0] = make_bind_capture(codec, &snd_hda_bind_sw);
  663. spec->capture_bind[1] = make_bind_capture(codec, &snd_hda_bind_vol);
  664. for (i = 0; i < 2; i++) {
  665. struct snd_kcontrol *kctl;
  666. if (!spec->capture_bind[i])
  667. return -ENOMEM;
  668. kctl = snd_ctl_new1(&cs_capture_ctls[i], codec);
  669. if (!kctl)
  670. return -ENOMEM;
  671. kctl->private_value = (long)spec->capture_bind[i];
  672. err = snd_hda_ctl_add(codec, 0, kctl);
  673. if (err < 0)
  674. return err;
  675. }
  676. if (spec->num_inputs > 1 && !spec->mic_detect) {
  677. err = snd_hda_ctl_add(codec, 0,
  678. snd_ctl_new1(&cs_capture_source, codec));
  679. if (err < 0)
  680. return err;
  681. }
  682. return 0;
  683. }
  684. /*
  685. */
  686. static int build_digital_output(struct hda_codec *codec)
  687. {
  688. struct cs_spec *spec = codec->spec;
  689. int err;
  690. if (!spec->multiout.dig_out_nid)
  691. return 0;
  692. err = snd_hda_create_spdif_out_ctls(codec, spec->multiout.dig_out_nid);
  693. if (err < 0)
  694. return err;
  695. err = snd_hda_create_spdif_share_sw(codec, &spec->multiout);
  696. if (err < 0)
  697. return err;
  698. return 0;
  699. }
  700. static int build_digital_input(struct hda_codec *codec)
  701. {
  702. struct cs_spec *spec = codec->spec;
  703. if (spec->dig_in)
  704. return snd_hda_create_spdif_in_ctls(codec, spec->dig_in);
  705. return 0;
  706. }
  707. /*
  708. * auto-mute and auto-mic switching
  709. */
  710. static void cs_automute(struct hda_codec *codec)
  711. {
  712. struct cs_spec *spec = codec->spec;
  713. struct auto_pin_cfg *cfg = &spec->autocfg;
  714. unsigned int caps, hp_present;
  715. hda_nid_t nid;
  716. int i;
  717. hp_present = 0;
  718. for (i = 0; i < cfg->hp_outs; i++) {
  719. nid = cfg->hp_pins[i];
  720. caps = snd_hda_query_pin_caps(codec, nid);
  721. if (!(caps & AC_PINCAP_PRES_DETECT))
  722. continue;
  723. hp_present = snd_hda_jack_detect(codec, nid);
  724. if (hp_present)
  725. break;
  726. }
  727. for (i = 0; i < cfg->speaker_outs; i++) {
  728. nid = cfg->speaker_pins[i];
  729. snd_hda_codec_write(codec, nid, 0,
  730. AC_VERB_SET_PIN_WIDGET_CONTROL,
  731. hp_present ? 0 : PIN_OUT);
  732. }
  733. if (spec->board_config == CS420X_MBP55 ||
  734. spec->board_config == CS420X_IMAC27) {
  735. unsigned int gpio = hp_present ? 0x02 : 0x08;
  736. snd_hda_codec_write(codec, 0x01, 0,
  737. AC_VERB_SET_GPIO_DATA, gpio);
  738. }
  739. }
  740. static void cs_automic(struct hda_codec *codec)
  741. {
  742. struct cs_spec *spec = codec->spec;
  743. struct auto_pin_cfg *cfg = &spec->autocfg;
  744. hda_nid_t nid;
  745. unsigned int present;
  746. nid = cfg->input_pins[spec->automic_idx];
  747. present = snd_hda_jack_detect(codec, nid);
  748. if (present)
  749. change_cur_input(codec, spec->automic_idx, 0);
  750. else {
  751. unsigned int imic = (spec->automic_idx == AUTO_PIN_MIC) ?
  752. AUTO_PIN_FRONT_MIC : AUTO_PIN_MIC;
  753. change_cur_input(codec, imic, 0);
  754. }
  755. }
  756. /*
  757. */
  758. static void init_output(struct hda_codec *codec)
  759. {
  760. struct cs_spec *spec = codec->spec;
  761. struct auto_pin_cfg *cfg = &spec->autocfg;
  762. int i;
  763. /* mute first */
  764. for (i = 0; i < spec->multiout.num_dacs; i++)
  765. snd_hda_codec_write(codec, spec->multiout.dac_nids[i], 0,
  766. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
  767. if (spec->multiout.hp_nid)
  768. snd_hda_codec_write(codec, spec->multiout.hp_nid, 0,
  769. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
  770. for (i = 0; i < ARRAY_SIZE(spec->multiout.extra_out_nid); i++) {
  771. if (!spec->multiout.extra_out_nid[i])
  772. break;
  773. snd_hda_codec_write(codec, spec->multiout.extra_out_nid[i], 0,
  774. AC_VERB_SET_AMP_GAIN_MUTE, AMP_OUT_MUTE);
  775. }
  776. /* set appropriate pin controls */
  777. for (i = 0; i < cfg->line_outs; i++)
  778. snd_hda_codec_write(codec, cfg->line_out_pins[i], 0,
  779. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  780. for (i = 0; i < cfg->hp_outs; i++) {
  781. hda_nid_t nid = cfg->hp_pins[i];
  782. snd_hda_codec_write(codec, nid, 0,
  783. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_HP);
  784. if (!cfg->speaker_outs)
  785. continue;
  786. if (get_wcaps(codec, nid) & AC_WCAP_UNSOL_CAP) {
  787. snd_hda_codec_write(codec, nid, 0,
  788. AC_VERB_SET_UNSOLICITED_ENABLE,
  789. AC_USRSP_EN | HP_EVENT);
  790. spec->hp_detect = 1;
  791. }
  792. }
  793. for (i = 0; i < cfg->speaker_outs; i++)
  794. snd_hda_codec_write(codec, cfg->speaker_pins[i], 0,
  795. AC_VERB_SET_PIN_WIDGET_CONTROL, PIN_OUT);
  796. if (spec->hp_detect)
  797. cs_automute(codec);
  798. }
  799. static void init_input(struct hda_codec *codec)
  800. {
  801. struct cs_spec *spec = codec->spec;
  802. struct auto_pin_cfg *cfg = &spec->autocfg;
  803. unsigned int coef;
  804. int i;
  805. for (i = 0; i < AUTO_PIN_LAST; i++) {
  806. unsigned int ctl;
  807. hda_nid_t pin = cfg->input_pins[i];
  808. if (!pin || !spec->adc_nid[i])
  809. continue;
  810. /* set appropriate pin control and mute first */
  811. ctl = PIN_IN;
  812. if (i <= AUTO_PIN_FRONT_MIC) {
  813. unsigned int caps = snd_hda_query_pin_caps(codec, pin);
  814. caps >>= AC_PINCAP_VREF_SHIFT;
  815. if (caps & AC_PINCAP_VREF_80)
  816. ctl = PIN_VREF80;
  817. }
  818. snd_hda_codec_write(codec, pin, 0,
  819. AC_VERB_SET_PIN_WIDGET_CONTROL, ctl);
  820. snd_hda_codec_write(codec, spec->adc_nid[i], 0,
  821. AC_VERB_SET_AMP_GAIN_MUTE,
  822. AMP_IN_MUTE(spec->adc_idx[i]));
  823. if (spec->mic_detect && spec->automic_idx == i)
  824. snd_hda_codec_write(codec, pin, 0,
  825. AC_VERB_SET_UNSOLICITED_ENABLE,
  826. AC_USRSP_EN | MIC_EVENT);
  827. }
  828. change_cur_input(codec, spec->cur_input, 1);
  829. if (spec->mic_detect)
  830. cs_automic(codec);
  831. coef = 0x000a; /* ADC1/2 - Digital and Analog Soft Ramp */
  832. if (is_active_pin(codec, CS_DMIC2_PIN_NID))
  833. coef |= 0x0500; /* DMIC2 enable 2 channels, disable GPIO1 */
  834. if (is_active_pin(codec, CS_DMIC1_PIN_NID))
  835. coef |= 0x1800; /* DMIC1 enable 2 channels, disable GPIO0
  836. * No effect if SPDIF_OUT2 is selected in
  837. * IDX_SPDIF_CTL.
  838. */
  839. cs_vendor_coef_set(codec, IDX_ADC_CFG, coef);
  840. }
  841. static struct hda_verb cs_coef_init_verbs[] = {
  842. {0x11, AC_VERB_SET_PROC_STATE, 1},
  843. {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG},
  844. {0x11, AC_VERB_SET_PROC_COEF,
  845. (0x002a /* DAC1/2/3 SZCMode Soft Ramp */
  846. | 0x0040 /* Mute DACs on FIFO error */
  847. | 0x1000 /* Enable DACs High Pass Filter */
  848. | 0x0400 /* Disable Coefficient Auto increment */
  849. )},
  850. /* Beep */
  851. {0x11, AC_VERB_SET_COEF_INDEX, IDX_DAC_CFG},
  852. {0x11, AC_VERB_SET_PROC_COEF, 0x0007}, /* Enable Beep thru DAC1/2/3 */
  853. {} /* terminator */
  854. };
  855. /* SPDIF setup */
  856. static void init_digital(struct hda_codec *codec)
  857. {
  858. unsigned int coef;
  859. coef = 0x0002; /* SRC_MUTE soft-mute on SPDIF (if no lock) */
  860. coef |= 0x0008; /* Replace with mute on error */
  861. if (is_active_pin(codec, CS_DIG_OUT2_PIN_NID))
  862. coef |= 0x4000; /* RX to TX1 or TX2 Loopthru / SPDIF2
  863. * SPDIF_OUT2 is shared with GPIO1 and
  864. * DMIC_SDA2.
  865. */
  866. cs_vendor_coef_set(codec, IDX_SPDIF_CTL, coef);
  867. }
  868. static int cs_init(struct hda_codec *codec)
  869. {
  870. struct cs_spec *spec = codec->spec;
  871. snd_hda_sequence_write(codec, cs_coef_init_verbs);
  872. if (spec->gpio_mask) {
  873. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_MASK,
  874. spec->gpio_mask);
  875. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DIRECTION,
  876. spec->gpio_dir);
  877. snd_hda_codec_write(codec, 0x01, 0, AC_VERB_SET_GPIO_DATA,
  878. spec->gpio_data);
  879. }
  880. init_output(codec);
  881. init_input(codec);
  882. init_digital(codec);
  883. return 0;
  884. }
  885. static int cs_build_controls(struct hda_codec *codec)
  886. {
  887. int err;
  888. err = build_output(codec);
  889. if (err < 0)
  890. return err;
  891. err = build_input(codec);
  892. if (err < 0)
  893. return err;
  894. err = build_digital_output(codec);
  895. if (err < 0)
  896. return err;
  897. err = build_digital_input(codec);
  898. if (err < 0)
  899. return err;
  900. return cs_init(codec);
  901. }
  902. static void cs_free(struct hda_codec *codec)
  903. {
  904. struct cs_spec *spec = codec->spec;
  905. kfree(spec->capture_bind[0]);
  906. kfree(spec->capture_bind[1]);
  907. kfree(codec->spec);
  908. }
  909. static void cs_unsol_event(struct hda_codec *codec, unsigned int res)
  910. {
  911. switch ((res >> 26) & 0x7f) {
  912. case HP_EVENT:
  913. cs_automute(codec);
  914. break;
  915. case MIC_EVENT:
  916. cs_automic(codec);
  917. break;
  918. }
  919. }
  920. static struct hda_codec_ops cs_patch_ops = {
  921. .build_controls = cs_build_controls,
  922. .build_pcms = cs_build_pcms,
  923. .init = cs_init,
  924. .free = cs_free,
  925. .unsol_event = cs_unsol_event,
  926. };
  927. static int cs_parse_auto_config(struct hda_codec *codec)
  928. {
  929. struct cs_spec *spec = codec->spec;
  930. int err;
  931. err = snd_hda_parse_pin_def_config(codec, &spec->autocfg, NULL);
  932. if (err < 0)
  933. return err;
  934. err = parse_output(codec);
  935. if (err < 0)
  936. return err;
  937. err = parse_input(codec);
  938. if (err < 0)
  939. return err;
  940. err = parse_digital_output(codec);
  941. if (err < 0)
  942. return err;
  943. err = parse_digital_input(codec);
  944. if (err < 0)
  945. return err;
  946. return 0;
  947. }
  948. static const char *cs420x_models[CS420X_MODELS] = {
  949. [CS420X_MBP55] = "mbp55",
  950. [CS420X_IMAC27] = "imac27",
  951. [CS420X_AUTO] = "auto",
  952. };
  953. static struct snd_pci_quirk cs420x_cfg_tbl[] = {
  954. SND_PCI_QUIRK(0x10de, 0xcb79, "MacBookPro 5,5", CS420X_MBP55),
  955. SND_PCI_QUIRK(0x8086, 0x7270, "IMac 27 Inch", CS420X_IMAC27),
  956. {} /* terminator */
  957. };
  958. struct cs_pincfg {
  959. hda_nid_t nid;
  960. u32 val;
  961. };
  962. static struct cs_pincfg mbp55_pincfgs[] = {
  963. { 0x09, 0x012b4030 },
  964. { 0x0a, 0x90100121 },
  965. { 0x0b, 0x90100120 },
  966. { 0x0c, 0x400000f0 },
  967. { 0x0d, 0x90a00110 },
  968. { 0x0e, 0x400000f0 },
  969. { 0x0f, 0x400000f0 },
  970. { 0x10, 0x014be040 },
  971. { 0x12, 0x400000f0 },
  972. { 0x15, 0x400000f0 },
  973. {} /* terminator */
  974. };
  975. static struct cs_pincfg imac27_pincfgs[] = {
  976. { 0x09, 0x012b4050 },
  977. { 0x0a, 0x90100140 },
  978. { 0x0b, 0x90100142 },
  979. { 0x0c, 0x018b3020 },
  980. { 0x0d, 0x90a00110 },
  981. { 0x0e, 0x400000f0 },
  982. { 0x0f, 0x01cbe030 },
  983. { 0x10, 0x014be060 },
  984. { 0x12, 0x01ab9070 },
  985. { 0x15, 0x400000f0 },
  986. {} /* terminator */
  987. };
  988. static struct cs_pincfg *cs_pincfgs[CS420X_MODELS] = {
  989. [CS420X_MBP55] = mbp55_pincfgs,
  990. [CS420X_IMAC27] = imac27_pincfgs,
  991. };
  992. static void fix_pincfg(struct hda_codec *codec, int model)
  993. {
  994. const struct cs_pincfg *cfg = cs_pincfgs[model];
  995. if (!cfg)
  996. return;
  997. for (; cfg->nid; cfg++)
  998. snd_hda_codec_set_pincfg(codec, cfg->nid, cfg->val);
  999. }
  1000. static int patch_cs420x(struct hda_codec *codec)
  1001. {
  1002. struct cs_spec *spec;
  1003. int err;
  1004. spec = kzalloc(sizeof(*spec), GFP_KERNEL);
  1005. if (!spec)
  1006. return -ENOMEM;
  1007. codec->spec = spec;
  1008. spec->board_config =
  1009. snd_hda_check_board_config(codec, CS420X_MODELS,
  1010. cs420x_models, cs420x_cfg_tbl);
  1011. if (spec->board_config >= 0)
  1012. fix_pincfg(codec, spec->board_config);
  1013. switch (spec->board_config) {
  1014. case CS420X_IMAC27:
  1015. case CS420X_MBP55:
  1016. /* GPIO1 = headphones */
  1017. /* GPIO3 = speakers */
  1018. spec->gpio_mask = 0x0a;
  1019. spec->gpio_dir = 0x0a;
  1020. break;
  1021. }
  1022. err = cs_parse_auto_config(codec);
  1023. if (err < 0)
  1024. goto error;
  1025. codec->patch_ops = cs_patch_ops;
  1026. return 0;
  1027. error:
  1028. kfree(codec->spec);
  1029. codec->spec = NULL;
  1030. return err;
  1031. }
  1032. /*
  1033. * patch entries
  1034. */
  1035. static struct hda_codec_preset snd_hda_preset_cirrus[] = {
  1036. { .id = 0x10134206, .name = "CS4206", .patch = patch_cs420x },
  1037. { .id = 0x10134207, .name = "CS4207", .patch = patch_cs420x },
  1038. {} /* terminator */
  1039. };
  1040. MODULE_ALIAS("snd-hda-codec-id:10134206");
  1041. MODULE_ALIAS("snd-hda-codec-id:10134207");
  1042. MODULE_LICENSE("GPL");
  1043. MODULE_DESCRIPTION("Cirrus Logic HD-audio codec");
  1044. static struct hda_codec_preset_list cirrus_list = {
  1045. .preset = snd_hda_preset_cirrus,
  1046. .owner = THIS_MODULE,
  1047. };
  1048. static int __init patch_cirrus_init(void)
  1049. {
  1050. return snd_hda_add_codec_preset(&cirrus_list);
  1051. }
  1052. static void __exit patch_cirrus_exit(void)
  1053. {
  1054. snd_hda_delete_codec_preset(&cirrus_list);
  1055. }
  1056. module_init(patch_cirrus_init)
  1057. module_exit(patch_cirrus_exit)