patch_cirrus.c 30 KB

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