ctmixer.c 28 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  1. /**
  2. * Copyright (C) 2008, Creative Technology Ltd. All Rights Reserved.
  3. *
  4. * This source file is released under GPL v2 license (no other versions).
  5. * See the COPYING file included in the main directory of this source
  6. * distribution for the license terms and conditions.
  7. *
  8. * @File ctmixer.c
  9. *
  10. * @Brief
  11. * This file contains the implementation of alsa mixer device functions.
  12. *
  13. * @Author Liu Chun
  14. * @Date May 28 2008
  15. *
  16. */
  17. #include "ctmixer.h"
  18. #include "ctamixer.h"
  19. #include <linux/slab.h>
  20. #include <sound/core.h>
  21. #include <sound/control.h>
  22. #include <sound/asoundef.h>
  23. #include <sound/pcm.h>
  24. #include <sound/tlv.h>
  25. enum CT_SUM_CTL {
  26. SUM_IN_F,
  27. SUM_IN_R,
  28. SUM_IN_C,
  29. SUM_IN_S,
  30. SUM_IN_F_C,
  31. NUM_CT_SUMS
  32. };
  33. enum CT_AMIXER_CTL {
  34. /* volume control mixers */
  35. AMIXER_MASTER_F,
  36. AMIXER_MASTER_R,
  37. AMIXER_MASTER_C,
  38. AMIXER_MASTER_S,
  39. AMIXER_PCM_F,
  40. AMIXER_PCM_R,
  41. AMIXER_PCM_C,
  42. AMIXER_PCM_S,
  43. AMIXER_SPDIFI,
  44. AMIXER_LINEIN,
  45. AMIXER_MIC,
  46. AMIXER_SPDIFO,
  47. AMIXER_WAVE_F,
  48. AMIXER_WAVE_R,
  49. AMIXER_WAVE_C,
  50. AMIXER_WAVE_S,
  51. AMIXER_MASTER_F_C,
  52. AMIXER_PCM_F_C,
  53. AMIXER_SPDIFI_C,
  54. AMIXER_LINEIN_C,
  55. AMIXER_MIC_C,
  56. /* this should always be the last one */
  57. NUM_CT_AMIXERS
  58. };
  59. enum CTALSA_MIXER_CTL {
  60. /* volume control mixers */
  61. MIXER_MASTER_P,
  62. MIXER_PCM_P,
  63. MIXER_LINEIN_P,
  64. MIXER_MIC_P,
  65. MIXER_SPDIFI_P,
  66. MIXER_SPDIFO_P,
  67. MIXER_WAVEF_P,
  68. MIXER_WAVER_P,
  69. MIXER_WAVEC_P,
  70. MIXER_WAVES_P,
  71. MIXER_MASTER_C,
  72. MIXER_PCM_C,
  73. MIXER_LINEIN_C,
  74. MIXER_MIC_C,
  75. MIXER_SPDIFI_C,
  76. /* switch control mixers */
  77. MIXER_PCM_C_S,
  78. MIXER_LINEIN_C_S,
  79. MIXER_MIC_C_S,
  80. MIXER_SPDIFI_C_S,
  81. MIXER_LINEIN_P_S,
  82. MIXER_SPDIFO_P_S,
  83. MIXER_SPDIFI_P_S,
  84. MIXER_WAVEF_P_S,
  85. MIXER_WAVER_P_S,
  86. MIXER_WAVEC_P_S,
  87. MIXER_WAVES_P_S,
  88. MIXER_DIGITAL_IO_S,
  89. MIXER_IEC958_MASK,
  90. MIXER_IEC958_DEFAULT,
  91. MIXER_IEC958_STREAM,
  92. /* this should always be the last one */
  93. NUM_CTALSA_MIXERS
  94. };
  95. #define VOL_MIXER_START MIXER_MASTER_P
  96. #define VOL_MIXER_END MIXER_SPDIFI_C
  97. #define VOL_MIXER_NUM (VOL_MIXER_END - VOL_MIXER_START + 1)
  98. #define SWH_MIXER_START MIXER_PCM_C_S
  99. #define SWH_MIXER_END MIXER_DIGITAL_IO_S
  100. #define SWH_CAPTURE_START MIXER_PCM_C_S
  101. #define SWH_CAPTURE_END MIXER_SPDIFI_C_S
  102. #define CHN_NUM 2
  103. struct ct_kcontrol_init {
  104. unsigned char ctl;
  105. char *name;
  106. };
  107. static struct ct_kcontrol_init
  108. ct_kcontrol_init_table[NUM_CTALSA_MIXERS] = {
  109. [MIXER_MASTER_P] = {
  110. .ctl = 1,
  111. .name = "Master Playback Volume",
  112. },
  113. [MIXER_MASTER_C] = {
  114. .ctl = 1,
  115. .name = "Master Capture Volume",
  116. },
  117. [MIXER_PCM_P] = {
  118. .ctl = 1,
  119. .name = "PCM Playback Volume",
  120. },
  121. [MIXER_PCM_C] = {
  122. .ctl = 1,
  123. .name = "PCM Capture Volume",
  124. },
  125. [MIXER_LINEIN_P] = {
  126. .ctl = 1,
  127. .name = "Line-in Playback Volume",
  128. },
  129. [MIXER_LINEIN_C] = {
  130. .ctl = 1,
  131. .name = "Line-in Capture Volume",
  132. },
  133. [MIXER_MIC_P] = {
  134. .ctl = 1,
  135. .name = "Mic Playback Volume",
  136. },
  137. [MIXER_MIC_C] = {
  138. .ctl = 1,
  139. .name = "Mic Capture Volume",
  140. },
  141. [MIXER_SPDIFI_P] = {
  142. .ctl = 1,
  143. .name = "S/PDIF-in Playback Volume",
  144. },
  145. [MIXER_SPDIFI_C] = {
  146. .ctl = 1,
  147. .name = "S/PDIF-in Capture Volume",
  148. },
  149. [MIXER_SPDIFO_P] = {
  150. .ctl = 1,
  151. .name = "S/PDIF-out Playback Volume",
  152. },
  153. [MIXER_WAVEF_P] = {
  154. .ctl = 1,
  155. .name = "Front Playback Volume",
  156. },
  157. [MIXER_WAVES_P] = {
  158. .ctl = 1,
  159. .name = "Side Playback Volume",
  160. },
  161. [MIXER_WAVEC_P] = {
  162. .ctl = 1,
  163. .name = "Center/LFE Playback Volume",
  164. },
  165. [MIXER_WAVER_P] = {
  166. .ctl = 1,
  167. .name = "Surround Playback Volume",
  168. },
  169. [MIXER_PCM_C_S] = {
  170. .ctl = 1,
  171. .name = "PCM Capture Switch",
  172. },
  173. [MIXER_LINEIN_C_S] = {
  174. .ctl = 1,
  175. .name = "Line-in Capture Switch",
  176. },
  177. [MIXER_MIC_C_S] = {
  178. .ctl = 1,
  179. .name = "Mic Capture Switch",
  180. },
  181. [MIXER_SPDIFI_C_S] = {
  182. .ctl = 1,
  183. .name = "S/PDIF-in Capture Switch",
  184. },
  185. [MIXER_LINEIN_P_S] = {
  186. .ctl = 1,
  187. .name = "Line-in Playback Switch",
  188. },
  189. [MIXER_SPDIFO_P_S] = {
  190. .ctl = 1,
  191. .name = "S/PDIF-out Playback Switch",
  192. },
  193. [MIXER_SPDIFI_P_S] = {
  194. .ctl = 1,
  195. .name = "S/PDIF-in Playback Switch",
  196. },
  197. [MIXER_WAVEF_P_S] = {
  198. .ctl = 1,
  199. .name = "Front Playback Switch",
  200. },
  201. [MIXER_WAVES_P_S] = {
  202. .ctl = 1,
  203. .name = "Side Playback Switch",
  204. },
  205. [MIXER_WAVEC_P_S] = {
  206. .ctl = 1,
  207. .name = "Center/LFE Playback Switch",
  208. },
  209. [MIXER_WAVER_P_S] = {
  210. .ctl = 1,
  211. .name = "Surround Playback Switch",
  212. },
  213. [MIXER_DIGITAL_IO_S] = {
  214. .ctl = 0,
  215. .name = "Digit-IO Playback Switch",
  216. },
  217. };
  218. static void
  219. ct_mixer_recording_select(struct ct_mixer *mixer, enum CT_AMIXER_CTL type);
  220. static void
  221. ct_mixer_recording_unselect(struct ct_mixer *mixer, enum CT_AMIXER_CTL type);
  222. static struct snd_kcontrol *kctls[2] = {NULL};
  223. static enum CT_AMIXER_CTL get_amixer_index(enum CTALSA_MIXER_CTL alsa_index)
  224. {
  225. switch (alsa_index) {
  226. case MIXER_MASTER_P: return AMIXER_MASTER_F;
  227. case MIXER_MASTER_C: return AMIXER_MASTER_F_C;
  228. case MIXER_PCM_P: return AMIXER_PCM_F;
  229. case MIXER_PCM_C:
  230. case MIXER_PCM_C_S: return AMIXER_PCM_F_C;
  231. case MIXER_LINEIN_P: return AMIXER_LINEIN;
  232. case MIXER_LINEIN_C:
  233. case MIXER_LINEIN_C_S: return AMIXER_LINEIN_C;
  234. case MIXER_MIC_P: return AMIXER_MIC;
  235. case MIXER_MIC_C:
  236. case MIXER_MIC_C_S: return AMIXER_MIC_C;
  237. case MIXER_SPDIFI_P: return AMIXER_SPDIFI;
  238. case MIXER_SPDIFI_C:
  239. case MIXER_SPDIFI_C_S: return AMIXER_SPDIFI_C;
  240. case MIXER_SPDIFO_P: return AMIXER_SPDIFO;
  241. case MIXER_WAVEF_P: return AMIXER_WAVE_F;
  242. case MIXER_WAVES_P: return AMIXER_WAVE_S;
  243. case MIXER_WAVEC_P: return AMIXER_WAVE_C;
  244. case MIXER_WAVER_P: return AMIXER_WAVE_R;
  245. default: return NUM_CT_AMIXERS;
  246. }
  247. }
  248. static enum CT_AMIXER_CTL get_recording_amixer(enum CT_AMIXER_CTL index)
  249. {
  250. switch (index) {
  251. case AMIXER_MASTER_F: return AMIXER_MASTER_F_C;
  252. case AMIXER_PCM_F: return AMIXER_PCM_F_C;
  253. case AMIXER_SPDIFI: return AMIXER_SPDIFI_C;
  254. case AMIXER_LINEIN: return AMIXER_LINEIN_C;
  255. case AMIXER_MIC: return AMIXER_MIC_C;
  256. default: return NUM_CT_AMIXERS;
  257. }
  258. }
  259. static unsigned char
  260. get_switch_state(struct ct_mixer *mixer, enum CTALSA_MIXER_CTL type)
  261. {
  262. return (mixer->switch_state & (0x1 << (type - SWH_MIXER_START)))
  263. ? 1 : 0;
  264. }
  265. static void
  266. set_switch_state(struct ct_mixer *mixer,
  267. enum CTALSA_MIXER_CTL type, unsigned char state)
  268. {
  269. if (state)
  270. mixer->switch_state |= (0x1 << (type - SWH_MIXER_START));
  271. else
  272. mixer->switch_state &= ~(0x1 << (type - SWH_MIXER_START));
  273. }
  274. #if 0 /* not used */
  275. /* Map integer value ranging from 0 to 65535 to 14-bit float value ranging
  276. * from 2^-6 to (1+1023/1024) */
  277. static unsigned int uint16_to_float14(unsigned int x)
  278. {
  279. unsigned int i;
  280. if (x < 17)
  281. return 0;
  282. x *= 2031;
  283. x /= 65535;
  284. x += 16;
  285. /* i <= 6 */
  286. for (i = 0; !(x & 0x400); i++)
  287. x <<= 1;
  288. x = (((7 - i) & 0x7) << 10) | (x & 0x3ff);
  289. return x;
  290. }
  291. static unsigned int float14_to_uint16(unsigned int x)
  292. {
  293. unsigned int e;
  294. if (!x)
  295. return x;
  296. e = (x >> 10) & 0x7;
  297. x &= 0x3ff;
  298. x += 1024;
  299. x >>= (7 - e);
  300. x -= 16;
  301. x *= 65535;
  302. x /= 2031;
  303. return x;
  304. }
  305. #endif /* not used */
  306. #define VOL_SCALE 0x1c
  307. #define VOL_MAX 0x100
  308. static const DECLARE_TLV_DB_SCALE(ct_vol_db_scale, -6400, 25, 1);
  309. static int ct_alsa_mix_volume_info(struct snd_kcontrol *kcontrol,
  310. struct snd_ctl_elem_info *uinfo)
  311. {
  312. uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER;
  313. uinfo->count = 2;
  314. uinfo->value.integer.min = 0;
  315. uinfo->value.integer.max = VOL_MAX;
  316. return 0;
  317. }
  318. static int ct_alsa_mix_volume_get(struct snd_kcontrol *kcontrol,
  319. struct snd_ctl_elem_value *ucontrol)
  320. {
  321. struct ct_atc *atc = snd_kcontrol_chip(kcontrol);
  322. enum CT_AMIXER_CTL type = get_amixer_index(kcontrol->private_value);
  323. struct amixer *amixer;
  324. int i, val;
  325. for (i = 0; i < 2; i++) {
  326. amixer = ((struct ct_mixer *)atc->mixer)->
  327. amixers[type*CHN_NUM+i];
  328. val = amixer->ops->get_scale(amixer) / VOL_SCALE;
  329. if (val < 0)
  330. val = 0;
  331. else if (val > VOL_MAX)
  332. val = VOL_MAX;
  333. ucontrol->value.integer.value[i] = val;
  334. }
  335. return 0;
  336. }
  337. static int ct_alsa_mix_volume_put(struct snd_kcontrol *kcontrol,
  338. struct snd_ctl_elem_value *ucontrol)
  339. {
  340. struct ct_atc *atc = snd_kcontrol_chip(kcontrol);
  341. struct ct_mixer *mixer = atc->mixer;
  342. enum CT_AMIXER_CTL type = get_amixer_index(kcontrol->private_value);
  343. struct amixer *amixer;
  344. int i, j, val, oval, change = 0;
  345. for (i = 0; i < 2; i++) {
  346. val = ucontrol->value.integer.value[i];
  347. if (val < 0)
  348. val = 0;
  349. else if (val > VOL_MAX)
  350. val = VOL_MAX;
  351. val *= VOL_SCALE;
  352. amixer = mixer->amixers[type*CHN_NUM+i];
  353. oval = amixer->ops->get_scale(amixer);
  354. if (val != oval) {
  355. amixer->ops->set_scale(amixer, val);
  356. amixer->ops->commit_write(amixer);
  357. change = 1;
  358. /* Synchronize Master/PCM playback AMIXERs. */
  359. if (AMIXER_MASTER_F == type || AMIXER_PCM_F == type) {
  360. for (j = 1; j < 4; j++) {
  361. amixer = mixer->
  362. amixers[(type+j)*CHN_NUM+i];
  363. amixer->ops->set_scale(amixer, val);
  364. amixer->ops->commit_write(amixer);
  365. }
  366. }
  367. }
  368. }
  369. return change;
  370. }
  371. static struct snd_kcontrol_new vol_ctl = {
  372. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE |
  373. SNDRV_CTL_ELEM_ACCESS_TLV_READ,
  374. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  375. .info = ct_alsa_mix_volume_info,
  376. .get = ct_alsa_mix_volume_get,
  377. .put = ct_alsa_mix_volume_put,
  378. .tlv = { .p = ct_vol_db_scale },
  379. };
  380. static void
  381. do_line_mic_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type)
  382. {
  383. if (MIXER_LINEIN_C_S == type) {
  384. atc->select_line_in(atc);
  385. set_switch_state(atc->mixer, MIXER_MIC_C_S, 0);
  386. snd_ctl_notify(atc->card, SNDRV_CTL_EVENT_MASK_VALUE,
  387. &kctls[1]->id);
  388. } else if (MIXER_MIC_C_S == type) {
  389. atc->select_mic_in(atc);
  390. set_switch_state(atc->mixer, MIXER_LINEIN_C_S, 0);
  391. snd_ctl_notify(atc->card, SNDRV_CTL_EVENT_MASK_VALUE,
  392. &kctls[0]->id);
  393. }
  394. }
  395. static void
  396. do_digit_io_switch(struct ct_atc *atc, int state)
  397. {
  398. struct ct_mixer *mixer = atc->mixer;
  399. if (state) {
  400. atc->select_digit_io(atc);
  401. atc->spdif_out_unmute(atc,
  402. get_switch_state(mixer, MIXER_SPDIFO_P_S));
  403. atc->spdif_in_unmute(atc, 1);
  404. atc->line_in_unmute(atc, 0);
  405. return;
  406. }
  407. if (get_switch_state(mixer, MIXER_LINEIN_C_S))
  408. atc->select_line_in(atc);
  409. else if (get_switch_state(mixer, MIXER_MIC_C_S))
  410. atc->select_mic_in(atc);
  411. atc->spdif_out_unmute(atc, 0);
  412. atc->spdif_in_unmute(atc, 0);
  413. atc->line_in_unmute(atc, 1);
  414. return;
  415. }
  416. static void do_switch(struct ct_atc *atc, enum CTALSA_MIXER_CTL type, int state)
  417. {
  418. struct ct_mixer *mixer = atc->mixer;
  419. /* Do changes in mixer. */
  420. if ((SWH_CAPTURE_START <= type) && (SWH_CAPTURE_END >= type)) {
  421. if (state) {
  422. ct_mixer_recording_select(mixer,
  423. get_amixer_index(type));
  424. } else {
  425. ct_mixer_recording_unselect(mixer,
  426. get_amixer_index(type));
  427. }
  428. }
  429. /* Do changes out of mixer. */
  430. if (state && (MIXER_LINEIN_C_S == type || MIXER_MIC_C_S == type))
  431. do_line_mic_switch(atc, type);
  432. else if (MIXER_WAVEF_P_S == type)
  433. atc->line_front_unmute(atc, state);
  434. else if (MIXER_WAVES_P_S == type)
  435. atc->line_surround_unmute(atc, state);
  436. else if (MIXER_WAVEC_P_S == type)
  437. atc->line_clfe_unmute(atc, state);
  438. else if (MIXER_WAVER_P_S == type)
  439. atc->line_rear_unmute(atc, state);
  440. else if (MIXER_LINEIN_P_S == type)
  441. atc->line_in_unmute(atc, state);
  442. else if (MIXER_SPDIFO_P_S == type)
  443. atc->spdif_out_unmute(atc, state);
  444. else if (MIXER_SPDIFI_P_S == type)
  445. atc->spdif_in_unmute(atc, state);
  446. else if (MIXER_DIGITAL_IO_S == type)
  447. do_digit_io_switch(atc, state);
  448. return;
  449. }
  450. static int ct_alsa_mix_switch_info(struct snd_kcontrol *kcontrol,
  451. struct snd_ctl_elem_info *uinfo)
  452. {
  453. uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
  454. uinfo->count = 1;
  455. uinfo->value.integer.min = 0;
  456. uinfo->value.integer.max = 1;
  457. uinfo->value.integer.step = 1;
  458. return 0;
  459. }
  460. static int ct_alsa_mix_switch_get(struct snd_kcontrol *kcontrol,
  461. struct snd_ctl_elem_value *ucontrol)
  462. {
  463. struct ct_mixer *mixer =
  464. ((struct ct_atc *)snd_kcontrol_chip(kcontrol))->mixer;
  465. enum CTALSA_MIXER_CTL type = kcontrol->private_value;
  466. ucontrol->value.integer.value[0] = get_switch_state(mixer, type);
  467. return 0;
  468. }
  469. static int ct_alsa_mix_switch_put(struct snd_kcontrol *kcontrol,
  470. struct snd_ctl_elem_value *ucontrol)
  471. {
  472. struct ct_atc *atc = snd_kcontrol_chip(kcontrol);
  473. struct ct_mixer *mixer = atc->mixer;
  474. enum CTALSA_MIXER_CTL type = kcontrol->private_value;
  475. int state;
  476. state = ucontrol->value.integer.value[0];
  477. if (get_switch_state(mixer, type) == state)
  478. return 0;
  479. set_switch_state(mixer, type, state);
  480. do_switch(atc, type, state);
  481. return 1;
  482. }
  483. static struct snd_kcontrol_new swh_ctl = {
  484. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  485. .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
  486. .info = ct_alsa_mix_switch_info,
  487. .get = ct_alsa_mix_switch_get,
  488. .put = ct_alsa_mix_switch_put
  489. };
  490. static int ct_spdif_info(struct snd_kcontrol *kcontrol,
  491. struct snd_ctl_elem_info *uinfo)
  492. {
  493. uinfo->type = SNDRV_CTL_ELEM_TYPE_IEC958;
  494. uinfo->count = 1;
  495. return 0;
  496. }
  497. static int ct_spdif_get_mask(struct snd_kcontrol *kcontrol,
  498. struct snd_ctl_elem_value *ucontrol)
  499. {
  500. ucontrol->value.iec958.status[0] = 0xff;
  501. ucontrol->value.iec958.status[1] = 0xff;
  502. ucontrol->value.iec958.status[2] = 0xff;
  503. ucontrol->value.iec958.status[3] = 0xff;
  504. return 0;
  505. }
  506. static int ct_spdif_get(struct snd_kcontrol *kcontrol,
  507. struct snd_ctl_elem_value *ucontrol)
  508. {
  509. struct ct_atc *atc = snd_kcontrol_chip(kcontrol);
  510. unsigned int status;
  511. atc->spdif_out_get_status(atc, &status);
  512. if (status == 0)
  513. status = SNDRV_PCM_DEFAULT_CON_SPDIF;
  514. ucontrol->value.iec958.status[0] = (status >> 0) & 0xff;
  515. ucontrol->value.iec958.status[1] = (status >> 8) & 0xff;
  516. ucontrol->value.iec958.status[2] = (status >> 16) & 0xff;
  517. ucontrol->value.iec958.status[3] = (status >> 24) & 0xff;
  518. return 0;
  519. }
  520. static int ct_spdif_put(struct snd_kcontrol *kcontrol,
  521. struct snd_ctl_elem_value *ucontrol)
  522. {
  523. struct ct_atc *atc = snd_kcontrol_chip(kcontrol);
  524. int change;
  525. unsigned int status, old_status;
  526. status = (ucontrol->value.iec958.status[0] << 0) |
  527. (ucontrol->value.iec958.status[1] << 8) |
  528. (ucontrol->value.iec958.status[2] << 16) |
  529. (ucontrol->value.iec958.status[3] << 24);
  530. atc->spdif_out_get_status(atc, &old_status);
  531. change = (old_status != status);
  532. if (change)
  533. atc->spdif_out_set_status(atc, status);
  534. return change;
  535. }
  536. static struct snd_kcontrol_new iec958_mask_ctl = {
  537. .access = SNDRV_CTL_ELEM_ACCESS_READ,
  538. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  539. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, MASK),
  540. .count = 1,
  541. .info = ct_spdif_info,
  542. .get = ct_spdif_get_mask,
  543. .private_value = MIXER_IEC958_MASK
  544. };
  545. static struct snd_kcontrol_new iec958_default_ctl = {
  546. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  547. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, DEFAULT),
  548. .count = 1,
  549. .info = ct_spdif_info,
  550. .get = ct_spdif_get,
  551. .put = ct_spdif_put,
  552. .private_value = MIXER_IEC958_DEFAULT
  553. };
  554. static struct snd_kcontrol_new iec958_ctl = {
  555. .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
  556. .iface = SNDRV_CTL_ELEM_IFACE_PCM,
  557. .name = SNDRV_CTL_NAME_IEC958("", PLAYBACK, PCM_STREAM),
  558. .count = 1,
  559. .info = ct_spdif_info,
  560. .get = ct_spdif_get,
  561. .put = ct_spdif_put,
  562. .private_value = MIXER_IEC958_STREAM
  563. };
  564. #define NUM_IEC958_CTL 3
  565. static int
  566. ct_mixer_kcontrol_new(struct ct_mixer *mixer, struct snd_kcontrol_new *new)
  567. {
  568. struct snd_kcontrol *kctl;
  569. int err;
  570. kctl = snd_ctl_new1(new, mixer->atc);
  571. if (!kctl)
  572. return -ENOMEM;
  573. if (SNDRV_CTL_ELEM_IFACE_PCM == kctl->id.iface)
  574. kctl->id.device = IEC958;
  575. err = snd_ctl_add(mixer->atc->card, kctl);
  576. if (err)
  577. return err;
  578. switch (new->private_value) {
  579. case MIXER_LINEIN_C_S:
  580. kctls[0] = kctl; break;
  581. case MIXER_MIC_C_S:
  582. kctls[1] = kctl; break;
  583. default:
  584. break;
  585. }
  586. return 0;
  587. }
  588. static int ct_mixer_kcontrols_create(struct ct_mixer *mixer)
  589. {
  590. enum CTALSA_MIXER_CTL type;
  591. struct ct_atc *atc = mixer->atc;
  592. int err;
  593. /* Create snd kcontrol instances on demand */
  594. for (type = VOL_MIXER_START; type <= VOL_MIXER_END; type++) {
  595. if (ct_kcontrol_init_table[type].ctl) {
  596. vol_ctl.name = ct_kcontrol_init_table[type].name;
  597. vol_ctl.private_value = (unsigned long)type;
  598. err = ct_mixer_kcontrol_new(mixer, &vol_ctl);
  599. if (err)
  600. return err;
  601. }
  602. }
  603. ct_kcontrol_init_table[MIXER_DIGITAL_IO_S].ctl =
  604. atc->have_digit_io_switch(atc);
  605. for (type = SWH_MIXER_START; type <= SWH_MIXER_END; type++) {
  606. if (ct_kcontrol_init_table[type].ctl) {
  607. swh_ctl.name = ct_kcontrol_init_table[type].name;
  608. swh_ctl.private_value = (unsigned long)type;
  609. err = ct_mixer_kcontrol_new(mixer, &swh_ctl);
  610. if (err)
  611. return err;
  612. }
  613. }
  614. err = ct_mixer_kcontrol_new(mixer, &iec958_mask_ctl);
  615. if (err)
  616. return err;
  617. err = ct_mixer_kcontrol_new(mixer, &iec958_default_ctl);
  618. if (err)
  619. return err;
  620. err = ct_mixer_kcontrol_new(mixer, &iec958_ctl);
  621. if (err)
  622. return err;
  623. atc->line_front_unmute(atc, 1);
  624. set_switch_state(mixer, MIXER_WAVEF_P_S, 1);
  625. atc->line_surround_unmute(atc, 0);
  626. set_switch_state(mixer, MIXER_WAVES_P_S, 0);
  627. atc->line_clfe_unmute(atc, 0);
  628. set_switch_state(mixer, MIXER_WAVEC_P_S, 0);
  629. atc->line_rear_unmute(atc, 0);
  630. set_switch_state(mixer, MIXER_WAVER_P_S, 0);
  631. atc->spdif_out_unmute(atc, 0);
  632. set_switch_state(mixer, MIXER_SPDIFO_P_S, 0);
  633. atc->line_in_unmute(atc, 0);
  634. set_switch_state(mixer, MIXER_LINEIN_P_S, 0);
  635. atc->spdif_in_unmute(atc, 0);
  636. set_switch_state(mixer, MIXER_SPDIFI_P_S, 0);
  637. set_switch_state(mixer, MIXER_PCM_C_S, 1);
  638. set_switch_state(mixer, MIXER_LINEIN_C_S, 1);
  639. set_switch_state(mixer, MIXER_SPDIFI_C_S, 1);
  640. return 0;
  641. }
  642. static void
  643. ct_mixer_recording_select(struct ct_mixer *mixer, enum CT_AMIXER_CTL type)
  644. {
  645. struct amixer *amix_d;
  646. struct sum *sum_c;
  647. int i;
  648. for (i = 0; i < 2; i++) {
  649. amix_d = mixer->amixers[type*CHN_NUM+i];
  650. sum_c = mixer->sums[SUM_IN_F_C*CHN_NUM+i];
  651. amix_d->ops->set_sum(amix_d, sum_c);
  652. amix_d->ops->commit_write(amix_d);
  653. }
  654. }
  655. static void
  656. ct_mixer_recording_unselect(struct ct_mixer *mixer, enum CT_AMIXER_CTL type)
  657. {
  658. struct amixer *amix_d;
  659. int i;
  660. for (i = 0; i < 2; i++) {
  661. amix_d = mixer->amixers[type*CHN_NUM+i];
  662. amix_d->ops->set_sum(amix_d, NULL);
  663. amix_d->ops->commit_write(amix_d);
  664. }
  665. }
  666. static int ct_mixer_get_resources(struct ct_mixer *mixer)
  667. {
  668. struct sum_mgr *sum_mgr;
  669. struct sum *sum;
  670. struct sum_desc sum_desc = {0};
  671. struct amixer_mgr *amixer_mgr;
  672. struct amixer *amixer;
  673. struct amixer_desc am_desc = {0};
  674. int err;
  675. int i;
  676. /* Allocate sum resources for mixer obj */
  677. sum_mgr = (struct sum_mgr *)mixer->atc->rsc_mgrs[SUM];
  678. sum_desc.msr = mixer->atc->msr;
  679. for (i = 0; i < (NUM_CT_SUMS * CHN_NUM); i++) {
  680. err = sum_mgr->get_sum(sum_mgr, &sum_desc, &sum);
  681. if (err) {
  682. printk(KERN_ERR "ctxfi:Failed to get sum resources for "
  683. "front output!\n");
  684. break;
  685. }
  686. mixer->sums[i] = sum;
  687. }
  688. if (err)
  689. goto error1;
  690. /* Allocate amixer resources for mixer obj */
  691. amixer_mgr = (struct amixer_mgr *)mixer->atc->rsc_mgrs[AMIXER];
  692. am_desc.msr = mixer->atc->msr;
  693. for (i = 0; i < (NUM_CT_AMIXERS * CHN_NUM); i++) {
  694. err = amixer_mgr->get_amixer(amixer_mgr, &am_desc, &amixer);
  695. if (err) {
  696. printk(KERN_ERR "ctxfi:Failed to get amixer resources "
  697. "for mixer obj!\n");
  698. break;
  699. }
  700. mixer->amixers[i] = amixer;
  701. }
  702. if (err)
  703. goto error2;
  704. return 0;
  705. error2:
  706. for (i = 0; i < (NUM_CT_AMIXERS * CHN_NUM); i++) {
  707. if (NULL != mixer->amixers[i]) {
  708. amixer = mixer->amixers[i];
  709. amixer_mgr->put_amixer(amixer_mgr, amixer);
  710. mixer->amixers[i] = NULL;
  711. }
  712. }
  713. error1:
  714. for (i = 0; i < (NUM_CT_SUMS * CHN_NUM); i++) {
  715. if (NULL != mixer->sums[i]) {
  716. sum_mgr->put_sum(sum_mgr, (struct sum *)mixer->sums[i]);
  717. mixer->sums[i] = NULL;
  718. }
  719. }
  720. return err;
  721. }
  722. static int ct_mixer_get_mem(struct ct_mixer **rmixer)
  723. {
  724. struct ct_mixer *mixer;
  725. int err;
  726. *rmixer = NULL;
  727. /* Allocate mem for mixer obj */
  728. mixer = kzalloc(sizeof(*mixer), GFP_KERNEL);
  729. if (!mixer)
  730. return -ENOMEM;
  731. mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM),
  732. GFP_KERNEL);
  733. if (!mixer->amixers) {
  734. err = -ENOMEM;
  735. goto error1;
  736. }
  737. mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL);
  738. if (!mixer->sums) {
  739. err = -ENOMEM;
  740. goto error2;
  741. }
  742. *rmixer = mixer;
  743. return 0;
  744. error2:
  745. kfree(mixer->amixers);
  746. error1:
  747. kfree(mixer);
  748. return err;
  749. }
  750. static int ct_mixer_topology_build(struct ct_mixer *mixer)
  751. {
  752. struct sum *sum;
  753. struct amixer *amix_d, *amix_s;
  754. enum CT_AMIXER_CTL i, j;
  755. /* Build topology from destination to source */
  756. /* Set up Master mixer */
  757. for (i = AMIXER_MASTER_F, j = SUM_IN_F;
  758. i <= AMIXER_MASTER_S; i++, j++) {
  759. amix_d = mixer->amixers[i*CHN_NUM];
  760. sum = mixer->sums[j*CHN_NUM];
  761. amix_d->ops->setup(amix_d, &sum->rsc, INIT_VOL, NULL);
  762. amix_d = mixer->amixers[i*CHN_NUM+1];
  763. sum = mixer->sums[j*CHN_NUM+1];
  764. amix_d->ops->setup(amix_d, &sum->rsc, INIT_VOL, NULL);
  765. }
  766. /* Set up Wave-out mixer */
  767. for (i = AMIXER_WAVE_F, j = AMIXER_MASTER_F;
  768. i <= AMIXER_WAVE_S; i++, j++) {
  769. amix_d = mixer->amixers[i*CHN_NUM];
  770. amix_s = mixer->amixers[j*CHN_NUM];
  771. amix_d->ops->setup(amix_d, &amix_s->rsc, INIT_VOL, NULL);
  772. amix_d = mixer->amixers[i*CHN_NUM+1];
  773. amix_s = mixer->amixers[j*CHN_NUM+1];
  774. amix_d->ops->setup(amix_d, &amix_s->rsc, INIT_VOL, NULL);
  775. }
  776. /* Set up S/PDIF-out mixer */
  777. amix_d = mixer->amixers[AMIXER_SPDIFO*CHN_NUM];
  778. amix_s = mixer->amixers[AMIXER_MASTER_F*CHN_NUM];
  779. amix_d->ops->setup(amix_d, &amix_s->rsc, INIT_VOL, NULL);
  780. amix_d = mixer->amixers[AMIXER_SPDIFO*CHN_NUM+1];
  781. amix_s = mixer->amixers[AMIXER_MASTER_F*CHN_NUM+1];
  782. amix_d->ops->setup(amix_d, &amix_s->rsc, INIT_VOL, NULL);
  783. /* Set up PCM-in mixer */
  784. for (i = AMIXER_PCM_F, j = SUM_IN_F; i <= AMIXER_PCM_S; i++, j++) {
  785. amix_d = mixer->amixers[i*CHN_NUM];
  786. sum = mixer->sums[j*CHN_NUM];
  787. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  788. amix_d = mixer->amixers[i*CHN_NUM+1];
  789. sum = mixer->sums[j*CHN_NUM+1];
  790. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  791. }
  792. /* Set up Line-in mixer */
  793. amix_d = mixer->amixers[AMIXER_LINEIN*CHN_NUM];
  794. sum = mixer->sums[SUM_IN_F*CHN_NUM];
  795. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  796. amix_d = mixer->amixers[AMIXER_LINEIN*CHN_NUM+1];
  797. sum = mixer->sums[SUM_IN_F*CHN_NUM+1];
  798. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  799. /* Set up Mic-in mixer */
  800. amix_d = mixer->amixers[AMIXER_MIC*CHN_NUM];
  801. sum = mixer->sums[SUM_IN_F*CHN_NUM];
  802. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  803. amix_d = mixer->amixers[AMIXER_MIC*CHN_NUM+1];
  804. sum = mixer->sums[SUM_IN_F*CHN_NUM+1];
  805. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  806. /* Set up S/PDIF-in mixer */
  807. amix_d = mixer->amixers[AMIXER_SPDIFI*CHN_NUM];
  808. sum = mixer->sums[SUM_IN_F*CHN_NUM];
  809. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  810. amix_d = mixer->amixers[AMIXER_SPDIFI*CHN_NUM+1];
  811. sum = mixer->sums[SUM_IN_F*CHN_NUM+1];
  812. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  813. /* Set up Master recording mixer */
  814. amix_d = mixer->amixers[AMIXER_MASTER_F_C*CHN_NUM];
  815. sum = mixer->sums[SUM_IN_F_C*CHN_NUM];
  816. amix_d->ops->setup(amix_d, &sum->rsc, INIT_VOL, NULL);
  817. amix_d = mixer->amixers[AMIXER_MASTER_F_C*CHN_NUM+1];
  818. sum = mixer->sums[SUM_IN_F_C*CHN_NUM+1];
  819. amix_d->ops->setup(amix_d, &sum->rsc, INIT_VOL, NULL);
  820. /* Set up PCM-in recording mixer */
  821. amix_d = mixer->amixers[AMIXER_PCM_F_C*CHN_NUM];
  822. sum = mixer->sums[SUM_IN_F_C*CHN_NUM];
  823. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  824. amix_d = mixer->amixers[AMIXER_PCM_F_C*CHN_NUM+1];
  825. sum = mixer->sums[SUM_IN_F_C*CHN_NUM+1];
  826. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  827. /* Set up Line-in recording mixer */
  828. amix_d = mixer->amixers[AMIXER_LINEIN_C*CHN_NUM];
  829. sum = mixer->sums[SUM_IN_F_C*CHN_NUM];
  830. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  831. amix_d = mixer->amixers[AMIXER_LINEIN_C*CHN_NUM+1];
  832. sum = mixer->sums[SUM_IN_F_C*CHN_NUM+1];
  833. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  834. /* Set up Mic-in recording mixer */
  835. amix_d = mixer->amixers[AMIXER_MIC_C*CHN_NUM];
  836. sum = mixer->sums[SUM_IN_F_C*CHN_NUM];
  837. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  838. amix_d = mixer->amixers[AMIXER_MIC_C*CHN_NUM+1];
  839. sum = mixer->sums[SUM_IN_F_C*CHN_NUM+1];
  840. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  841. /* Set up S/PDIF-in recording mixer */
  842. amix_d = mixer->amixers[AMIXER_SPDIFI_C*CHN_NUM];
  843. sum = mixer->sums[SUM_IN_F_C*CHN_NUM];
  844. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  845. amix_d = mixer->amixers[AMIXER_SPDIFI_C*CHN_NUM+1];
  846. sum = mixer->sums[SUM_IN_F_C*CHN_NUM+1];
  847. amix_d->ops->setup(amix_d, NULL, INIT_VOL, sum);
  848. return 0;
  849. }
  850. static int mixer_set_input_port(struct amixer *amixer, struct rsc *rsc)
  851. {
  852. amixer->ops->set_input(amixer, rsc);
  853. amixer->ops->commit_write(amixer);
  854. return 0;
  855. }
  856. static enum CT_AMIXER_CTL port_to_amixer(enum MIXER_PORT_T type)
  857. {
  858. switch (type) {
  859. case MIX_WAVE_FRONT: return AMIXER_WAVE_F;
  860. case MIX_WAVE_SURROUND: return AMIXER_WAVE_S;
  861. case MIX_WAVE_CENTLFE: return AMIXER_WAVE_C;
  862. case MIX_WAVE_REAR: return AMIXER_WAVE_R;
  863. case MIX_PCMO_FRONT: return AMIXER_MASTER_F_C;
  864. case MIX_SPDIF_OUT: return AMIXER_SPDIFO;
  865. case MIX_LINE_IN: return AMIXER_LINEIN;
  866. case MIX_MIC_IN: return AMIXER_MIC;
  867. case MIX_SPDIF_IN: return AMIXER_SPDIFI;
  868. case MIX_PCMI_FRONT: return AMIXER_PCM_F;
  869. case MIX_PCMI_SURROUND: return AMIXER_PCM_S;
  870. case MIX_PCMI_CENTLFE: return AMIXER_PCM_C;
  871. case MIX_PCMI_REAR: return AMIXER_PCM_R;
  872. default: return 0;
  873. }
  874. }
  875. static int mixer_get_output_ports(struct ct_mixer *mixer,
  876. enum MIXER_PORT_T type,
  877. struct rsc **rleft, struct rsc **rright)
  878. {
  879. enum CT_AMIXER_CTL amix = port_to_amixer(type);
  880. if (NULL != rleft)
  881. *rleft = &((struct amixer *)mixer->amixers[amix*CHN_NUM])->rsc;
  882. if (NULL != rright)
  883. *rright =
  884. &((struct amixer *)mixer->amixers[amix*CHN_NUM+1])->rsc;
  885. return 0;
  886. }
  887. static int mixer_set_input_left(struct ct_mixer *mixer,
  888. enum MIXER_PORT_T type, struct rsc *rsc)
  889. {
  890. enum CT_AMIXER_CTL amix = port_to_amixer(type);
  891. mixer_set_input_port(mixer->amixers[amix*CHN_NUM], rsc);
  892. amix = get_recording_amixer(amix);
  893. if (amix < NUM_CT_AMIXERS)
  894. mixer_set_input_port(mixer->amixers[amix*CHN_NUM], rsc);
  895. return 0;
  896. }
  897. static int
  898. mixer_set_input_right(struct ct_mixer *mixer,
  899. enum MIXER_PORT_T type, struct rsc *rsc)
  900. {
  901. enum CT_AMIXER_CTL amix = port_to_amixer(type);
  902. mixer_set_input_port(mixer->amixers[amix*CHN_NUM+1], rsc);
  903. amix = get_recording_amixer(amix);
  904. if (amix < NUM_CT_AMIXERS)
  905. mixer_set_input_port(mixer->amixers[amix*CHN_NUM+1], rsc);
  906. return 0;
  907. }
  908. #ifdef CONFIG_PM
  909. static int mixer_resume(struct ct_mixer *mixer)
  910. {
  911. int i, state;
  912. struct amixer *amixer;
  913. /* resume topology and volume gain. */
  914. for (i = 0; i < NUM_CT_AMIXERS*CHN_NUM; i++) {
  915. amixer = mixer->amixers[i];
  916. amixer->ops->commit_write(amixer);
  917. }
  918. /* resume switch state. */
  919. for (i = SWH_MIXER_START; i <= SWH_MIXER_END; i++) {
  920. state = get_switch_state(mixer, i);
  921. do_switch(mixer->atc, i, state);
  922. }
  923. return 0;
  924. }
  925. #endif
  926. int ct_mixer_destroy(struct ct_mixer *mixer)
  927. {
  928. struct sum_mgr *sum_mgr = (struct sum_mgr *)mixer->atc->rsc_mgrs[SUM];
  929. struct amixer_mgr *amixer_mgr =
  930. (struct amixer_mgr *)mixer->atc->rsc_mgrs[AMIXER];
  931. struct amixer *amixer;
  932. int i = 0;
  933. /* Release amixer resources */
  934. for (i = 0; i < (NUM_CT_AMIXERS * CHN_NUM); i++) {
  935. if (NULL != mixer->amixers[i]) {
  936. amixer = mixer->amixers[i];
  937. amixer_mgr->put_amixer(amixer_mgr, amixer);
  938. }
  939. }
  940. /* Release sum resources */
  941. for (i = 0; i < (NUM_CT_SUMS * CHN_NUM); i++) {
  942. if (NULL != mixer->sums[i])
  943. sum_mgr->put_sum(sum_mgr, (struct sum *)mixer->sums[i]);
  944. }
  945. /* Release mem assigned to mixer object */
  946. kfree(mixer->sums);
  947. kfree(mixer->amixers);
  948. kfree(mixer);
  949. return 0;
  950. }
  951. int ct_mixer_create(struct ct_atc *atc, struct ct_mixer **rmixer)
  952. {
  953. struct ct_mixer *mixer;
  954. int err;
  955. *rmixer = NULL;
  956. /* Allocate mem for mixer obj */
  957. err = ct_mixer_get_mem(&mixer);
  958. if (err)
  959. return err;
  960. mixer->switch_state = 0;
  961. mixer->atc = atc;
  962. /* Set operations */
  963. mixer->get_output_ports = mixer_get_output_ports;
  964. mixer->set_input_left = mixer_set_input_left;
  965. mixer->set_input_right = mixer_set_input_right;
  966. #ifdef CONFIG_PM
  967. mixer->resume = mixer_resume;
  968. #endif
  969. /* Allocate chip resources for mixer obj */
  970. err = ct_mixer_get_resources(mixer);
  971. if (err)
  972. goto error;
  973. /* Build internal mixer topology */
  974. ct_mixer_topology_build(mixer);
  975. *rmixer = mixer;
  976. return 0;
  977. error:
  978. ct_mixer_destroy(mixer);
  979. return err;
  980. }
  981. int ct_alsa_mix_create(struct ct_atc *atc,
  982. enum CTALSADEVS device,
  983. const char *device_name)
  984. {
  985. int err;
  986. /* Create snd kcontrol instances on demand */
  987. /* vol_ctl.device = swh_ctl.device = device; */ /* better w/ device 0 */
  988. err = ct_mixer_kcontrols_create((struct ct_mixer *)atc->mixer);
  989. if (err)
  990. return err;
  991. strcpy(atc->card->mixername, device_name);
  992. return 0;
  993. }