aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ac97
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2005-09-13 05:47:07 -0400
committerJaroslav Kysela <perex@suse.cz>2005-11-04 07:15:39 -0500
commit4525c9f31f4606881ed49d822b44c2c5d6080ef4 (patch)
tree09af0ed72514fd79b42dd969199a733a6ac29eb9 /sound/pci/ac97
parentedf8e4565c44bffbb4d09e8984df941d0ae9e6e8 (diff)
[ALSA] Fix surround control of CMI9761
Modules: AC97 Codec - Fixed surround controls of CMI9761 (model 83) in update_jacks callback. - Clean up ad1888 and ad1985 update_jacks callbacks. Signed-off-by: Takashi Iwai <tiwai@suse.de>
Diffstat (limited to 'sound/pci/ac97')
-rw-r--r--sound/pci/ac97/ac97_patch.c77
1 files changed, 50 insertions, 27 deletions
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 0238cc65d32a..ffc8d6521073 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -163,14 +163,24 @@ static int ac97_channel_mode_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t
163 .private_value = 1, \ 163 .private_value = 1, \
164 } 164 }
165 165
166static inline int is_surround_on(ac97_t *ac97)
167{
168 return ac97->channel_mode >= 1;
169}
170
171static inline int is_clfe_on(ac97_t *ac97)
172{
173 return a97->channel_mode >= 2;
174}
175
166static inline int is_shared_linein(ac97_t *ac97) 176static inline int is_shared_linein(ac97_t *ac97)
167{ 177{
168 return ! ac97->indep_surround && ac97->channel_mode >= 1; 178 return ! ac97->indep_surround && is_surround_on(ac97);
169} 179}
170 180
171static inline int is_shared_micin(ac97_t *ac97) 181static inline int is_shared_micin(ac97_t *ac97)
172{ 182{
173 return ! ac97->indep_surround && ac97->channel_mode >= 2; 183 return ! ac97->indep_surround && is_clfe_on(ac97);
174} 184}
175 185
176 186
@@ -1753,12 +1763,13 @@ static int snd_ac97_ad1888_downmix_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_va
1753 1763
1754static void ad1888_update_jacks(ac97_t *ac97) 1764static void ad1888_update_jacks(ac97_t *ac97)
1755{ 1765{
1766 unsigned short val = 0;
1767 if (! is_shared_linein(ac97))
1768 val |= (1 << 12);
1769 if (! is_shared_micin(ac97))
1770 val |= (1 << 11);
1756 /* shared Line-In */ 1771 /* shared Line-In */
1757 snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 12, 1772 snd_ac97_update_bits(ac97, AC97_AD_MISC, (1 << 11) | (1 << 12), val);
1758 is_shared_linein(ac97) ? 0 : 1 << 12);
1759 /* shared Mic */
1760 snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 11,
1761 is_shared_micin(ac97) ? 0 : 1 << 11);
1762} 1773}
1763 1774
1764static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = { 1775static const snd_kcontrol_new_t snd_ac97_ad1888_controls[] = {
@@ -1852,12 +1863,7 @@ static const snd_kcontrol_new_t snd_ac97_ad1985_controls[] = {
1852 1863
1853static void ad1985_update_jacks(ac97_t *ac97) 1864static void ad1985_update_jacks(ac97_t *ac97)
1854{ 1865{
1855 /* shared Line-In */ 1866 ad1888_update_jacks(ac97);
1856 snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 12,
1857 is_shared_linein(ac97) ? 0 : 1 << 12);
1858 /* shared Mic */
1859 snd_ac97_update_bits(ac97, AC97_AD_MISC, 1 << 11,
1860 is_shared_micin(ac97) ? 0 : 1 << 11);
1861 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9, 1867 snd_ac97_update_bits(ac97, AC97_AD_SERIAL_CFG, 1 << 9,
1862 is_shared_micin(ac97) ? 0 : 1 << 9); 1868 is_shared_micin(ac97) ? 0 : 1 << 9);
1863} 1869}
@@ -2442,21 +2448,37 @@ int patch_cm9739(ac97_t * ac97)
2442 2448
2443static void cm9761_update_jacks(ac97_t *ac97) 2449static void cm9761_update_jacks(ac97_t *ac97)
2444{ 2450{
2445 unsigned short surr_vals[2][2] = { 2451 /* FIXME: check the bits for each model
2446 { 0x0008, 0x0400 }, /* off, on */ 2452 * model 83 is confirmed to work
2447 { 0x0000, 0x0408 }, /* off, on (9761-82 rev.B) */ 2453 */
2454 static unsigned short surr_on[3][2] = {
2455 { 0x0008, 0x0000 }, /* 9761-78 & 82 */
2456 { 0x0000, 0x0008 }, /* 9761-82 rev.B */
2457 { 0x0000, 0x0008 }, /* 9761-83 */
2458 };
2459 static unsigned short clfe_on[3][2] = {
2460 { 0x0000, 0x1000 }, /* 9761-78 & 82 */
2461 { 0x1000, 0x0000 }, /* 9761-82 rev.B */
2462 { 0x0000, 0x1000 }, /* 9761-83 */
2463 };
2464 static unsigned short surr_shared[3][2] = {
2465 { 0x0000, 0x0400 }, /* 9761-78 & 82 */
2466 { 0x0000, 0x0400 }, /* 9761-82 rev.B */
2467 { 0x0000, 0x0400 }, /* 9761-83 */
2448 }; 2468 };
2449 unsigned short clfe_vals[2][2] = { 2469 static unsigned short clfe_shared[3][2] = {
2450 { 0x2000, 0x1880 }, /* off, on */ 2470 { 0x2000, 0x0880 }, /* 9761-78 & 82 */
2451 { 0x1000, 0x2880 }, /* off, on (9761-82 rev.B) */ 2471 { 0x0000, 0x2880 }, /* 9761-82 rev.B */
2472 { 0x2000, 0x0800 }, /* 9761-83 */
2452 }; 2473 };
2474 unsigned short val = 0;
2453 2475
2454 /* shared Line-In */ 2476 val |= surr_on[ac97->spec.dev_flags][is_surround_on(ac97)];
2455 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x0408, 2477 val |= clfe_on[ac97->spec.dev_flags][is_clfe_on(ac97)];
2456 surr_vals[ac97->spec.dev_flags][is_shared_linein(ac97)]); 2478 val |= surr_shared[ac97->spec.dev_flags][is_shared_linein(ac97)];
2457 /* shared Mic */ 2479 val |= clfe_shared[ac97->spec.dev_flags][is_shared_micin(ac97)];
2458 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3880, 2480
2459 clfe_vals[ac97->spec.dev_flags][is_shared_micin(ac97)]); 2481 snd_ac97_update_bits(ac97, AC97_CM9761_MULTI_CHAN, 0x3c88, val);
2460} 2482}
2461 2483
2462static const snd_kcontrol_new_t snd_ac97_cm9761_controls[] = { 2484static const snd_kcontrol_new_t snd_ac97_cm9761_controls[] = {
@@ -2551,7 +2573,7 @@ int patch_cm9761(ac97_t *ac97)
2551 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8808); 2573 snd_ac97_write_cache(ac97, AC97_MASTER, 0x8808);
2552 snd_ac97_write_cache(ac97, AC97_PCM, 0x8808); 2574 snd_ac97_write_cache(ac97, AC97_PCM, 0x8808);
2553 2575
2554 ac97->spec.dev_flags = 0; /* 1 = model 82 revision B */ 2576 ac97->spec.dev_flags = 0; /* 1 = model 82 revision B, 2 = model 83 */
2555 if (ac97->id == AC97_ID_CM9761_82) { 2577 if (ac97->id == AC97_ID_CM9761_82) {
2556 unsigned short tmp; 2578 unsigned short tmp;
2557 /* check page 1, reg 0x60 */ 2579 /* check page 1, reg 0x60 */
@@ -2560,7 +2582,8 @@ int patch_cm9761(ac97_t *ac97)
2560 tmp = snd_ac97_read(ac97, 0x60); 2582 tmp = snd_ac97_read(ac97, 0x60);
2561 ac97->spec.dev_flags = tmp & 1; /* revision B? */ 2583 ac97->spec.dev_flags = tmp & 1; /* revision B? */
2562 snd_ac97_write_cache(ac97, AC97_INT_PAGING, val); 2584 snd_ac97_write_cache(ac97, AC97_INT_PAGING, val);
2563 } 2585 } else if (ac97->id == AC97_ID_CM9761_83)
2586 ac97->spec.dev_flags = 2;
2564 2587
2565 ac97->build_ops = &patch_cm9761_ops; 2588 ac97->build_ops = &patch_cm9761_ops;
2566 2589