diff options
author | Takashi Iwai <tiwai@suse.de> | 2005-11-17 04:40:18 -0500 |
---|---|---|
committer | Jaroslav Kysela <perex@suse.cz> | 2006-01-03 06:17:01 -0500 |
commit | 95a98265eb7b112b3268761053d643635171e219 (patch) | |
tree | daf88b4858b1ba856609c2a3138522ea4a2b6269 /sound/pci/ca0106/ca0106_mixer.c | |
parent | 954bea35571461b083390a82b03f077f901fe678 (diff) |
[ALSA] ca0106 - Code clean up
Modules: CA0106 driver
Clean up snd-ca0106 driver code:
- Fix spaces and indents
- Remove unnecessary spinlocks
- Clean up the mixer callbacks using private_value
- Clean up mixer constructors using an array
Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/ca0106/ca0106_mixer.c')
-rw-r--r-- | sound/pci/ca0106/ca0106_mixer.c | 417 |
1 files changed, 101 insertions, 316 deletions
diff --git a/sound/pci/ca0106/ca0106_mixer.c b/sound/pci/ca0106/ca0106_mixer.c index c10e4a54301b..0730dc7c66e5 100644 --- a/sound/pci/ca0106/ca0106_mixer.c +++ b/sound/pci/ca0106/ca0106_mixer.c | |||
@@ -125,18 +125,11 @@ static int snd_ca0106_shared_spdif_put(snd_kcontrol_t * kcontrol, | |||
125 | return change; | 125 | return change; |
126 | } | 126 | } |
127 | 127 | ||
128 | static snd_kcontrol_new_t snd_ca0106_shared_spdif __devinitdata = | ||
129 | { | ||
130 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
131 | .name = "SPDIF Out", | ||
132 | .info = snd_ca0106_shared_spdif_info, | ||
133 | .get = snd_ca0106_shared_spdif_get, | ||
134 | .put = snd_ca0106_shared_spdif_put | ||
135 | }; | ||
136 | |||
137 | static int snd_ca0106_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 128 | static int snd_ca0106_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) |
138 | { | 129 | { |
139 | static char *texts[6] = { "SPDIF out", "i2s mixer out", "SPDIF in", "i2s in", "AC97 in", "SRC out" }; | 130 | static char *texts[6] = { |
131 | "SPDIF out", "i2s mixer out", "SPDIF in", "i2s in", "AC97 in", "SRC out" | ||
132 | }; | ||
140 | 133 | ||
141 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; | 134 | uinfo->type = SNDRV_CTL_ELEM_TYPE_ENUMERATED; |
142 | uinfo->count = 1; | 135 | uinfo->count = 1; |
@@ -176,15 +169,6 @@ static int snd_ca0106_capture_source_put(snd_kcontrol_t * kcontrol, | |||
176 | return change; | 169 | return change; |
177 | } | 170 | } |
178 | 171 | ||
179 | static snd_kcontrol_new_t snd_ca0106_capture_source __devinitdata = | ||
180 | { | ||
181 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
182 | .name = "Capture Source", | ||
183 | .info = snd_ca0106_capture_source_info, | ||
184 | .get = snd_ca0106_capture_source_get, | ||
185 | .put = snd_ca0106_capture_source_put | ||
186 | }; | ||
187 | |||
188 | static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 172 | static int snd_ca0106_capture_mic_line_in_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) |
189 | { | 173 | { |
190 | static char *texts[2] = { "Line in", "Mic in" }; | 174 | static char *texts[2] = { "Line in", "Mic in" }; |
@@ -294,26 +278,6 @@ static int snd_ca0106_spdif_put(snd_kcontrol_t * kcontrol, | |||
294 | return change; | 278 | return change; |
295 | } | 279 | } |
296 | 280 | ||
297 | static snd_kcontrol_new_t snd_ca0106_spdif_mask_control = | ||
298 | { | ||
299 | .access = SNDRV_CTL_ELEM_ACCESS_READ, | ||
300 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
301 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), | ||
302 | .count = 4, | ||
303 | .info = snd_ca0106_spdif_info, | ||
304 | .get = snd_ca0106_spdif_get_mask | ||
305 | }; | ||
306 | |||
307 | static snd_kcontrol_new_t snd_ca0106_spdif_control = | ||
308 | { | ||
309 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | ||
310 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), | ||
311 | .count = 4, | ||
312 | .info = snd_ca0106_spdif_info, | ||
313 | .get = snd_ca0106_spdif_get, | ||
314 | .put = snd_ca0106_spdif_put | ||
315 | }; | ||
316 | |||
317 | static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) | 281 | static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t * uinfo) |
318 | { | 282 | { |
319 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; | 283 | uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; |
@@ -324,10 +288,14 @@ static int snd_ca0106_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t | |||
324 | } | 288 | } |
325 | 289 | ||
326 | static int snd_ca0106_volume_get(snd_kcontrol_t * kcontrol, | 290 | static int snd_ca0106_volume_get(snd_kcontrol_t * kcontrol, |
327 | snd_ctl_elem_value_t * ucontrol, int reg, int channel_id) | 291 | snd_ctl_elem_value_t * ucontrol) |
328 | { | 292 | { |
329 | ca0106_t *emu = snd_kcontrol_chip(kcontrol); | 293 | ca0106_t *emu = snd_kcontrol_chip(kcontrol); |
330 | unsigned int value; | 294 | unsigned int value; |
295 | int channel_id, reg; | ||
296 | |||
297 | channel_id = (kcontrol->private_value >> 8) & 0xff; | ||
298 | reg = kcontrol->private_value & 0xff; | ||
331 | 299 | ||
332 | value = snd_ca0106_ptr_read(emu, reg, channel_id); | 300 | value = snd_ca0106_ptr_read(emu, reg, channel_id); |
333 | ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */ | 301 | ucontrol->value.integer.value[0] = 0xff - ((value >> 24) & 0xff); /* Left */ |
@@ -335,226 +303,92 @@ static int snd_ca0106_volume_get(snd_kcontrol_t * kcontrol, | |||
335 | return 0; | 303 | return 0; |
336 | } | 304 | } |
337 | 305 | ||
338 | static int snd_ca0106_volume_get_spdif_front(snd_kcontrol_t * kcontrol, | ||
339 | snd_ctl_elem_value_t * ucontrol) | ||
340 | { | ||
341 | int channel_id = CONTROL_FRONT_CHANNEL; | ||
342 | int reg = PLAYBACK_VOLUME1; | ||
343 | return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); | ||
344 | } | ||
345 | |||
346 | static int snd_ca0106_volume_get_spdif_center_lfe(snd_kcontrol_t * kcontrol, | ||
347 | snd_ctl_elem_value_t * ucontrol) | ||
348 | { | ||
349 | int channel_id = CONTROL_CENTER_LFE_CHANNEL; | ||
350 | int reg = PLAYBACK_VOLUME1; | ||
351 | return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); | ||
352 | } | ||
353 | static int snd_ca0106_volume_get_spdif_unknown(snd_kcontrol_t * kcontrol, | ||
354 | snd_ctl_elem_value_t * ucontrol) | ||
355 | { | ||
356 | int channel_id = CONTROL_UNKNOWN_CHANNEL; | ||
357 | int reg = PLAYBACK_VOLUME1; | ||
358 | return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); | ||
359 | } | ||
360 | static int snd_ca0106_volume_get_spdif_rear(snd_kcontrol_t * kcontrol, | ||
361 | snd_ctl_elem_value_t * ucontrol) | ||
362 | { | ||
363 | int channel_id = CONTROL_REAR_CHANNEL; | ||
364 | int reg = PLAYBACK_VOLUME1; | ||
365 | return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); | ||
366 | } | ||
367 | static int snd_ca0106_volume_get_analog_front(snd_kcontrol_t * kcontrol, | ||
368 | snd_ctl_elem_value_t * ucontrol) | ||
369 | { | ||
370 | int channel_id = CONTROL_FRONT_CHANNEL; | ||
371 | int reg = PLAYBACK_VOLUME2; | ||
372 | return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); | ||
373 | } | ||
374 | |||
375 | static int snd_ca0106_volume_get_analog_center_lfe(snd_kcontrol_t * kcontrol, | ||
376 | snd_ctl_elem_value_t * ucontrol) | ||
377 | { | ||
378 | int channel_id = CONTROL_CENTER_LFE_CHANNEL; | ||
379 | int reg = PLAYBACK_VOLUME2; | ||
380 | return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); | ||
381 | } | ||
382 | static int snd_ca0106_volume_get_analog_unknown(snd_kcontrol_t * kcontrol, | ||
383 | snd_ctl_elem_value_t * ucontrol) | ||
384 | { | ||
385 | int channel_id = CONTROL_UNKNOWN_CHANNEL; | ||
386 | int reg = PLAYBACK_VOLUME2; | ||
387 | return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); | ||
388 | } | ||
389 | static int snd_ca0106_volume_get_analog_rear(snd_kcontrol_t * kcontrol, | ||
390 | snd_ctl_elem_value_t * ucontrol) | ||
391 | { | ||
392 | int channel_id = CONTROL_REAR_CHANNEL; | ||
393 | int reg = PLAYBACK_VOLUME2; | ||
394 | return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); | ||
395 | } | ||
396 | |||
397 | static int snd_ca0106_volume_get_feedback(snd_kcontrol_t * kcontrol, | ||
398 | snd_ctl_elem_value_t * ucontrol) | ||
399 | { | ||
400 | int channel_id = 1; | ||
401 | int reg = CAPTURE_CONTROL; | ||
402 | return snd_ca0106_volume_get(kcontrol, ucontrol, reg, channel_id); | ||
403 | } | ||
404 | |||
405 | static int snd_ca0106_volume_put(snd_kcontrol_t * kcontrol, | 306 | static int snd_ca0106_volume_put(snd_kcontrol_t * kcontrol, |
406 | snd_ctl_elem_value_t * ucontrol, int reg, int channel_id) | 307 | snd_ctl_elem_value_t * ucontrol) |
407 | { | 308 | { |
408 | ca0106_t *emu = snd_kcontrol_chip(kcontrol); | 309 | ca0106_t *emu = snd_kcontrol_chip(kcontrol); |
409 | unsigned int value; | 310 | unsigned int oval, nval; |
410 | //value = snd_ca0106_ptr_read(emu, reg, channel_id); | 311 | int channel_id, reg; |
411 | //value = value & 0xffff; | 312 | |
412 | value = ((0xff - ucontrol->value.integer.value[0]) << 24) | ((0xff - ucontrol->value.integer.value[1]) << 16); | 313 | channel_id = (kcontrol->private_value >> 8) & 0xff; |
413 | value = value | ((0xff - ucontrol->value.integer.value[0]) << 8) | ((0xff - ucontrol->value.integer.value[1]) ); | 314 | reg = kcontrol->private_value & 0xff; |
414 | snd_ca0106_ptr_write(emu, reg, channel_id, value); | 315 | |
415 | return 1; | 316 | oval = snd_ca0106_ptr_read(emu, reg, channel_id); |
416 | } | 317 | nval = ((0xff - ucontrol->value.integer.value[0]) << 24) | |
417 | static int snd_ca0106_volume_put_spdif_front(snd_kcontrol_t * kcontrol, | 318 | ((0xff - ucontrol->value.integer.value[1]) << 16); |
418 | snd_ctl_elem_value_t * ucontrol) | 319 | nval |= ((0xff - ucontrol->value.integer.value[0]) << 8) | |
419 | { | 320 | ((0xff - ucontrol->value.integer.value[1]) ); |
420 | int channel_id = CONTROL_FRONT_CHANNEL; | 321 | if (oval == nval) |
421 | int reg = PLAYBACK_VOLUME1; | 322 | return 0; |
422 | return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); | 323 | snd_ca0106_ptr_write(emu, reg, channel_id, nval); |
423 | } | 324 | return 1; |
424 | static int snd_ca0106_volume_put_spdif_center_lfe(snd_kcontrol_t * kcontrol, | 325 | } |
425 | snd_ctl_elem_value_t * ucontrol) | 326 | |
426 | { | 327 | #define CA_VOLUME(xname,chid,reg) \ |
427 | int channel_id = CONTROL_CENTER_LFE_CHANNEL; | 328 | { \ |
428 | int reg = PLAYBACK_VOLUME1; | 329 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, \ |
429 | return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); | 330 | .info = snd_ca0106_volume_info, \ |
430 | } | 331 | .get = snd_ca0106_volume_get, \ |
431 | static int snd_ca0106_volume_put_spdif_unknown(snd_kcontrol_t * kcontrol, | 332 | .put = snd_ca0106_volume_put, \ |
432 | snd_ctl_elem_value_t * ucontrol) | 333 | .private_value = ((chid) << 8) | (reg) \ |
433 | { | 334 | } |
434 | int channel_id = CONTROL_UNKNOWN_CHANNEL; | 335 | |
435 | int reg = PLAYBACK_VOLUME1; | 336 | |
436 | return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); | 337 | static snd_kcontrol_new_t snd_ca0106_volume_ctls[] __devinitdata = { |
437 | } | 338 | CA_VOLUME("Analog Front Playback Volume", |
438 | static int snd_ca0106_volume_put_spdif_rear(snd_kcontrol_t * kcontrol, | 339 | CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME2), |
439 | snd_ctl_elem_value_t * ucontrol) | 340 | CA_VOLUME("Analog Rear Playback Volume", |
440 | { | 341 | CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME2), |
441 | int channel_id = CONTROL_REAR_CHANNEL; | 342 | CA_VOLUME("Analog Center/LFE Playback Volume", |
442 | int reg = PLAYBACK_VOLUME1; | 343 | CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME2), |
443 | return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); | 344 | CA_VOLUME("Analog Side Playback Volume", |
444 | } | 345 | CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME2), |
445 | static int snd_ca0106_volume_put_analog_front(snd_kcontrol_t * kcontrol, | 346 | |
446 | snd_ctl_elem_value_t * ucontrol) | 347 | CA_VOLUME("SPDIF Front Playback Volume", |
447 | { | 348 | CONTROL_FRONT_CHANNEL, PLAYBACK_VOLUME1), |
448 | int channel_id = CONTROL_FRONT_CHANNEL; | 349 | CA_VOLUME("SPDIF Rear Playback Volume", |
449 | int reg = PLAYBACK_VOLUME2; | 350 | CONTROL_REAR_CHANNEL, PLAYBACK_VOLUME1), |
450 | return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); | 351 | CA_VOLUME("SPDIF Center/LFE Playback Volume", |
451 | } | 352 | CONTROL_CENTER_LFE_CHANNEL, PLAYBACK_VOLUME1), |
452 | static int snd_ca0106_volume_put_analog_center_lfe(snd_kcontrol_t * kcontrol, | 353 | CA_VOLUME("SPDIF Unknown Playback Volume", |
453 | snd_ctl_elem_value_t * ucontrol) | 354 | CONTROL_UNKNOWN_CHANNEL, PLAYBACK_VOLUME1), |
454 | { | 355 | |
455 | int channel_id = CONTROL_CENTER_LFE_CHANNEL; | 356 | CA_VOLUME("CAPTURE feedback Playback Volume", |
456 | int reg = PLAYBACK_VOLUME2; | 357 | 1, CAPTURE_CONTROL), |
457 | return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); | 358 | |
458 | } | 359 | { |
459 | static int snd_ca0106_volume_put_analog_unknown(snd_kcontrol_t * kcontrol, | 360 | .access = SNDRV_CTL_ELEM_ACCESS_READ, |
460 | snd_ctl_elem_value_t * ucontrol) | 361 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, |
461 | { | 362 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,MASK), |
462 | int channel_id = CONTROL_UNKNOWN_CHANNEL; | 363 | .count = 4, |
463 | int reg = PLAYBACK_VOLUME2; | 364 | .info = snd_ca0106_spdif_info, |
464 | return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); | 365 | .get = snd_ca0106_spdif_get_mask |
465 | } | 366 | }, |
466 | static int snd_ca0106_volume_put_analog_rear(snd_kcontrol_t * kcontrol, | 367 | { |
467 | snd_ctl_elem_value_t * ucontrol) | 368 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
468 | { | 369 | .name = "SPDIF Out", |
469 | int channel_id = CONTROL_REAR_CHANNEL; | 370 | .info = snd_ca0106_shared_spdif_info, |
470 | int reg = PLAYBACK_VOLUME2; | 371 | .get = snd_ca0106_shared_spdif_get, |
471 | return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); | 372 | .put = snd_ca0106_shared_spdif_put |
472 | } | 373 | }, |
473 | 374 | { | |
474 | static int snd_ca0106_volume_put_feedback(snd_kcontrol_t * kcontrol, | 375 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, |
475 | snd_ctl_elem_value_t * ucontrol) | 376 | .name = "Capture Source", |
476 | { | 377 | .info = snd_ca0106_capture_source_info, |
477 | int channel_id = 1; | 378 | .get = snd_ca0106_capture_source_get, |
478 | int reg = CAPTURE_CONTROL; | 379 | .put = snd_ca0106_capture_source_put |
479 | return snd_ca0106_volume_put(kcontrol, ucontrol, reg, channel_id); | 380 | }, |
480 | } | 381 | { |
481 | 382 | .iface = SNDRV_CTL_ELEM_IFACE_PCM, | |
482 | static snd_kcontrol_new_t snd_ca0106_volume_control_analog_front = | 383 | .name = SNDRV_CTL_NAME_IEC958("",PLAYBACK,DEFAULT), |
483 | { | 384 | .count = 4, |
484 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | 385 | .info = snd_ca0106_spdif_info, |
485 | .name = "Analog Front Playback Volume", | 386 | .get = snd_ca0106_spdif_get, |
486 | .info = snd_ca0106_volume_info, | 387 | .put = snd_ca0106_spdif_put |
487 | .get = snd_ca0106_volume_get_analog_front, | 388 | }, |
488 | .put = snd_ca0106_volume_put_analog_front | ||
489 | }; | ||
490 | static snd_kcontrol_new_t snd_ca0106_volume_control_analog_center_lfe = | ||
491 | { | ||
492 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
493 | .name = "Analog Center/LFE Playback Volume", | ||
494 | .info = snd_ca0106_volume_info, | ||
495 | .get = snd_ca0106_volume_get_analog_center_lfe, | ||
496 | .put = snd_ca0106_volume_put_analog_center_lfe | ||
497 | }; | ||
498 | static snd_kcontrol_new_t snd_ca0106_volume_control_analog_unknown = | ||
499 | { | ||
500 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
501 | .name = "Analog Side Playback Volume", | ||
502 | .info = snd_ca0106_volume_info, | ||
503 | .get = snd_ca0106_volume_get_analog_unknown, | ||
504 | .put = snd_ca0106_volume_put_analog_unknown | ||
505 | }; | ||
506 | static snd_kcontrol_new_t snd_ca0106_volume_control_analog_rear = | ||
507 | { | ||
508 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
509 | .name = "Analog Rear Playback Volume", | ||
510 | .info = snd_ca0106_volume_info, | ||
511 | .get = snd_ca0106_volume_get_analog_rear, | ||
512 | .put = snd_ca0106_volume_put_analog_rear | ||
513 | }; | ||
514 | static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_front = | ||
515 | { | ||
516 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
517 | .name = "SPDIF Front Playback Volume", | ||
518 | .info = snd_ca0106_volume_info, | ||
519 | .get = snd_ca0106_volume_get_spdif_front, | ||
520 | .put = snd_ca0106_volume_put_spdif_front | ||
521 | }; | ||
522 | static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_center_lfe = | ||
523 | { | ||
524 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
525 | .name = "SPDIF Center/LFE Playback Volume", | ||
526 | .info = snd_ca0106_volume_info, | ||
527 | .get = snd_ca0106_volume_get_spdif_center_lfe, | ||
528 | .put = snd_ca0106_volume_put_spdif_center_lfe | ||
529 | }; | ||
530 | static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_unknown = | ||
531 | { | ||
532 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
533 | .name = "SPDIF Unknown Playback Volume", | ||
534 | .info = snd_ca0106_volume_info, | ||
535 | .get = snd_ca0106_volume_get_spdif_unknown, | ||
536 | .put = snd_ca0106_volume_put_spdif_unknown | ||
537 | }; | ||
538 | static snd_kcontrol_new_t snd_ca0106_volume_control_spdif_rear = | ||
539 | { | ||
540 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
541 | .name = "SPDIF Rear Playback Volume", | ||
542 | .info = snd_ca0106_volume_info, | ||
543 | .get = snd_ca0106_volume_get_spdif_rear, | ||
544 | .put = snd_ca0106_volume_put_spdif_rear | ||
545 | }; | ||
546 | |||
547 | static snd_kcontrol_new_t snd_ca0106_volume_control_feedback = | ||
548 | { | ||
549 | .iface = SNDRV_CTL_ELEM_IFACE_MIXER, | ||
550 | .name = "CAPTURE feedback Playback Volume", | ||
551 | .info = snd_ca0106_volume_info, | ||
552 | .get = snd_ca0106_volume_get_feedback, | ||
553 | .put = snd_ca0106_volume_put_feedback | ||
554 | }; | 389 | }; |
555 | 390 | ||
556 | 391 | static int __devinit remove_ctl(snd_card_t *card, const char *name) | |
557 | static int remove_ctl(snd_card_t *card, const char *name) | ||
558 | { | 392 | { |
559 | snd_ctl_elem_id_t id; | 393 | snd_ctl_elem_id_t id; |
560 | memset(&id, 0, sizeof(id)); | 394 | memset(&id, 0, sizeof(id)); |
@@ -563,7 +397,7 @@ static int remove_ctl(snd_card_t *card, const char *name) | |||
563 | return snd_ctl_remove_id(card, &id); | 397 | return snd_ctl_remove_id(card, &id); |
564 | } | 398 | } |
565 | 399 | ||
566 | static snd_kcontrol_t *ctl_find(snd_card_t *card, const char *name) | 400 | static snd_kcontrol_t __devinit *ctl_find(snd_card_t *card, const char *name) |
567 | { | 401 | { |
568 | snd_ctl_elem_id_t sid; | 402 | snd_ctl_elem_id_t sid; |
569 | memset(&sid, 0, sizeof(sid)); | 403 | memset(&sid, 0, sizeof(sid)); |
@@ -573,7 +407,7 @@ static snd_kcontrol_t *ctl_find(snd_card_t *card, const char *name) | |||
573 | return snd_ctl_find_id(card, &sid); | 407 | return snd_ctl_find_id(card, &sid); |
574 | } | 408 | } |
575 | 409 | ||
576 | static int rename_ctl(snd_card_t *card, const char *src, const char *dst) | 410 | static int __devinit rename_ctl(snd_card_t *card, const char *src, const char *dst) |
577 | { | 411 | { |
578 | snd_kcontrol_t *kctl = ctl_find(card, src); | 412 | snd_kcontrol_t *kctl = ctl_find(card, src); |
579 | if (kctl) { | 413 | if (kctl) { |
@@ -585,8 +419,7 @@ static int rename_ctl(snd_card_t *card, const char *src, const char *dst) | |||
585 | 419 | ||
586 | int __devinit snd_ca0106_mixer(ca0106_t *emu) | 420 | int __devinit snd_ca0106_mixer(ca0106_t *emu) |
587 | { | 421 | { |
588 | int err; | 422 | int i, err; |
589 | snd_kcontrol_t *kctl; | ||
590 | snd_card_t *card = emu->card; | 423 | snd_card_t *card = emu->card; |
591 | char **c; | 424 | char **c; |
592 | static char *ca0106_remove_ctls[] = { | 425 | static char *ca0106_remove_ctls[] = { |
@@ -627,70 +460,22 @@ int __devinit snd_ca0106_mixer(ca0106_t *emu) | |||
627 | NULL | 460 | NULL |
628 | }; | 461 | }; |
629 | #if 1 | 462 | #if 1 |
630 | for (c=ca0106_remove_ctls; *c; c++) | 463 | for (c = ca0106_remove_ctls; *c; c++) |
631 | remove_ctl(card, *c); | 464 | remove_ctl(card, *c); |
632 | for (c=ca0106_rename_ctls; *c; c += 2) | 465 | for (c = ca0106_rename_ctls; *c; c += 2) |
633 | rename_ctl(card, c[0], c[1]); | 466 | rename_ctl(card, c[0], c[1]); |
634 | #endif | 467 | #endif |
635 | 468 | ||
636 | if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_front, emu)) == NULL) | 469 | for (i = 0; i < ARRAY_SIZE(snd_ca0106_volume_ctls); i++) { |
637 | return -ENOMEM; | 470 | err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_volume_ctls[i], emu)); |
638 | if ((err = snd_ctl_add(card, kctl))) | 471 | if (err < 0) |
639 | return err; | 472 | return err; |
640 | if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_rear, emu)) == NULL) | 473 | } |
641 | return -ENOMEM; | ||
642 | if ((err = snd_ctl_add(card, kctl))) | ||
643 | return err; | ||
644 | if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_center_lfe, emu)) == NULL) | ||
645 | return -ENOMEM; | ||
646 | if ((err = snd_ctl_add(card, kctl))) | ||
647 | return err; | ||
648 | if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_analog_unknown, emu)) == NULL) | ||
649 | return -ENOMEM; | ||
650 | if ((err = snd_ctl_add(card, kctl))) | ||
651 | return err; | ||
652 | if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_front, emu)) == NULL) | ||
653 | return -ENOMEM; | ||
654 | if ((err = snd_ctl_add(card, kctl))) | ||
655 | return err; | ||
656 | if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_rear, emu)) == NULL) | ||
657 | return -ENOMEM; | ||
658 | if ((err = snd_ctl_add(card, kctl))) | ||
659 | return err; | ||
660 | if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_center_lfe, emu)) == NULL) | ||
661 | return -ENOMEM; | ||
662 | if ((err = snd_ctl_add(card, kctl))) | ||
663 | return err; | ||
664 | if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_spdif_unknown, emu)) == NULL) | ||
665 | return -ENOMEM; | ||
666 | if ((err = snd_ctl_add(card, kctl))) | ||
667 | return err; | ||
668 | if ((kctl = snd_ctl_new1(&snd_ca0106_volume_control_feedback, emu)) == NULL) | ||
669 | return -ENOMEM; | ||
670 | if ((err = snd_ctl_add(card, kctl))) | ||
671 | return err; | ||
672 | if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_mask_control, emu)) == NULL) | ||
673 | return -ENOMEM; | ||
674 | if ((err = snd_ctl_add(card, kctl))) | ||
675 | return err; | ||
676 | if ((kctl = snd_ctl_new1(&snd_ca0106_shared_spdif, emu)) == NULL) | ||
677 | return -ENOMEM; | ||
678 | if ((err = snd_ctl_add(card, kctl))) | ||
679 | return err; | ||
680 | if ((kctl = snd_ctl_new1(&snd_ca0106_capture_source, emu)) == NULL) | ||
681 | return -ENOMEM; | ||
682 | if ((err = snd_ctl_add(card, kctl))) | ||
683 | return err; | ||
684 | if (emu->details->i2c_adc == 1) { | 474 | if (emu->details->i2c_adc == 1) { |
685 | if ((kctl = snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)) == NULL) | 475 | err = snd_ctl_add(card, snd_ctl_new1(&snd_ca0106_capture_mic_line_in, emu)); |
686 | return -ENOMEM; | 476 | if (err < 0) |
687 | if ((err = snd_ctl_add(card, kctl))) | ||
688 | return err; | 477 | return err; |
689 | } | 478 | } |
690 | if ((kctl = snd_ctl_new1(&snd_ca0106_spdif_control, emu)) == NULL) | ||
691 | return -ENOMEM; | ||
692 | if ((err = snd_ctl_add(card, kctl))) | ||
693 | return err; | ||
694 | return 0; | 479 | return 0; |
695 | } | 480 | } |
696 | 481 | ||