aboutsummaryrefslogtreecommitdiffstats
path: root/sound/pci/ac97/ac97_patch.c
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2006-08-21 12:44:31 -0400
committerJaroslav Kysela <perex@suse.cz>2006-09-23 04:42:51 -0400
commit2f3482fbbd5dac7d0e86fe5b7ac5c1e51d52b084 (patch)
treea7f8c3192208f840e6af7322efc0e565221120ca /sound/pci/ac97/ac97_patch.c
parent7376d013fc6d3a45d748e0ce758ca9412b01b9dd (diff)
[ALSA] Add TLV support to AC97 codec driver
Added the TLV support to AC97 codec driver for addition of dB range information. Signed-off-by: Takashi Iwai <tiwai@suse.de> Signed-off-by: Jaroslav Kysela <perex@suse.cz>
Diffstat (limited to 'sound/pci/ac97/ac97_patch.c')
-rw-r--r--sound/pci/ac97/ac97_patch.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/sound/pci/ac97/ac97_patch.c b/sound/pci/ac97/ac97_patch.c
index 37c6be481c4a..392f6ccace5d 100644
--- a/sound/pci/ac97/ac97_patch.c
+++ b/sound/pci/ac97/ac97_patch.c
@@ -32,6 +32,7 @@
32#include <sound/core.h> 32#include <sound/core.h>
33#include <sound/pcm.h> 33#include <sound/pcm.h>
34#include <sound/control.h> 34#include <sound/control.h>
35#include <sound/tlv.h>
35#include <sound/ac97_codec.h> 36#include <sound/ac97_codec.h>
36#include "ac97_patch.h" 37#include "ac97_patch.h"
37#include "ac97_id.h" 38#include "ac97_id.h"
@@ -51,6 +52,20 @@ static int patch_build_controls(struct snd_ac97 * ac97, const struct snd_kcontro
51 return 0; 52 return 0;
52} 53}
53 54
55/* replace with a new TLV */
56static void reset_tlv(struct snd_ac97 *ac97, const char *name,
57 unsigned int *tlv)
58{
59 struct snd_ctl_elem_id sid;
60 struct snd_kcontrol *kctl;
61 memset(&sid, 0, sizeof(sid));
62 strcpy(sid.name, name);
63 sid.iface = SNDRV_CTL_ELEM_IFACE_MIXER;
64 kctl = snd_ctl_find_id(ac97->bus->card, &sid);
65 if (kctl && kctl->tlv.p)
66 kctl->tlv.p = tlv;
67}
68
54/* set to the page, update bits and restore the page */ 69/* set to the page, update bits and restore the page */
55static int ac97_update_bits_page(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value, unsigned short page) 70static int ac97_update_bits_page(struct snd_ac97 *ac97, unsigned short reg, unsigned short mask, unsigned short value, unsigned short page)
56{ 71{
@@ -1522,12 +1537,16 @@ static const struct snd_kcontrol_new snd_ac97_controls_ad1885[] = {
1522 AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 8, 1, 1), /* inverted */ 1537 AC97_SINGLE("Line Jack Sense", AC97_AD_JACK_SPDIF, 8, 1, 1), /* inverted */
1523}; 1538};
1524 1539
1540static DECLARE_TLV_DB_SCALE(db_scale_6bit_6db_max, -8850, 150, 0);
1541
1525static int patch_ad1885_specific(struct snd_ac97 * ac97) 1542static int patch_ad1885_specific(struct snd_ac97 * ac97)
1526{ 1543{
1527 int err; 1544 int err;
1528 1545
1529 if ((err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885))) < 0) 1546 if ((err = patch_build_controls(ac97, snd_ac97_controls_ad1885, ARRAY_SIZE(snd_ac97_controls_ad1885))) < 0)
1530 return err; 1547 return err;
1548 reset_tlv(ac97, "Headphone Playback Volume",
1549 db_scale_6bit_6db_max);
1531 return 0; 1550 return 0;
1532} 1551}
1533 1552
@@ -1551,12 +1570,27 @@ int patch_ad1885(struct snd_ac97 * ac97)
1551 return 0; 1570 return 0;
1552} 1571}
1553 1572
1573static int patch_ad1886_specific(struct snd_ac97 * ac97)
1574{
1575 reset_tlv(ac97, "Headphone Playback Volume",
1576 db_scale_6bit_6db_max);
1577 return 0;
1578}
1579
1580static struct snd_ac97_build_ops patch_ad1886_build_ops = {
1581 .build_specific = &patch_ad1886_specific,
1582#ifdef CONFIG_PM
1583 .resume = ad18xx_resume
1584#endif
1585};
1586
1554int patch_ad1886(struct snd_ac97 * ac97) 1587int patch_ad1886(struct snd_ac97 * ac97)
1555{ 1588{
1556 patch_ad1881(ac97); 1589 patch_ad1881(ac97);
1557 /* Presario700 workaround */ 1590 /* Presario700 workaround */
1558 /* for Jack Sense/SPDIF Register misetting causing */ 1591 /* for Jack Sense/SPDIF Register misetting causing */
1559 snd_ac97_write_cache(ac97, AC97_AD_JACK_SPDIF, 0x0010); 1592 snd_ac97_write_cache(ac97, AC97_AD_JACK_SPDIF, 0x0010);
1593 ac97->build_ops = &patch_ad1886_build_ops;
1560 return 0; 1594 return 0;
1561} 1595}
1562 1596
@@ -2015,6 +2049,8 @@ static const struct snd_kcontrol_new snd_ac97_spdif_controls_alc650[] = {
2015 /* AC97_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 13, 1, 0), */ 2049 /* AC97_SINGLE("IEC958 Input Monitor", AC97_ALC650_MULTICH, 13, 1, 0), */
2016}; 2050};
2017 2051
2052static DECLARE_TLV_DB_SCALE(db_scale_5bit_3db_max, -4350, 150, 0);
2053
2018static int patch_alc650_specific(struct snd_ac97 * ac97) 2054static int patch_alc650_specific(struct snd_ac97 * ac97)
2019{ 2055{
2020 int err; 2056 int err;
@@ -2025,6 +2061,9 @@ static int patch_alc650_specific(struct snd_ac97 * ac97)
2025 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650))) < 0) 2061 if ((err = patch_build_controls(ac97, snd_ac97_spdif_controls_alc650, ARRAY_SIZE(snd_ac97_spdif_controls_alc650))) < 0)
2026 return err; 2062 return err;
2027 } 2063 }
2064 if (ac97->id != AC97_ID_ALC650F)
2065 reset_tlv(ac97, "Master Playback Volume",
2066 db_scale_5bit_3db_max);
2028 return 0; 2067 return 0;
2029} 2068}
2030 2069