Commit 723b2b0d authored by Takashi Iwai's avatar Takashi Iwai Committed by Jaroslav Kysela

[ALSA] Clean up and add TLV support to AK4xxx i2c driver

- Clean up the code in AK4xxx-ADDA i2c code.
- Fix capture gain controls for AK5365
- Changed the static table for DAC/ADC mixer labels to use
  structs
- Implemented TLV entries for each AK codec
  The volumes in AK4524, AK4528 and AK5365 are corrected with
  a table to be suitable for dB conversion.
Signed-off-by: default avatarTakashi Iwai <tiwai@suse.de>
Signed-off-by: default avatarJaroslav Kysela <perex@suse.cz>
parent d0ae4847
...@@ -39,14 +39,26 @@ struct snd_ak4xxx_ops { ...@@ -39,14 +39,26 @@ struct snd_ak4xxx_ops {
#define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */ #define AK4XXX_IMAGE_SIZE (AK4XXX_MAX_CHIPS * 16) /* 64 bytes */
/* DAC label and channels */
struct snd_akm4xxx_dac_channel {
char *name; /* mixer volume name */
unsigned int num_channels;
};
/* ADC labels and channels */
struct snd_akm4xxx_adc_channel {
char *name; /* capture gain volume label */
char *gain_name; /* IPGA */
char *switch_name; /* capture switch */
unsigned int num_channels;
};
struct snd_akm4xxx { struct snd_akm4xxx {
struct snd_card *card; struct snd_card *card;
unsigned int num_adcs; /* AK4524 or AK4528 ADCs */ unsigned int num_adcs; /* AK4524 or AK4528 ADCs */
unsigned int num_dacs; /* AK4524 or AK4528 DACs */ unsigned int num_dacs; /* AK4524 or AK4528 DACs */
unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */ unsigned char images[AK4XXX_IMAGE_SIZE]; /* saved register image */
unsigned char ipga_gain[AK4XXX_MAX_CHIPS][2]; /* saved register image unsigned char volumes[AK4XXX_IMAGE_SIZE]; /* saved volume values */
* for IPGA (AK4528)
*/
unsigned long private_value[AK4XXX_MAX_CHIPS]; /* helper for driver */ unsigned long private_value[AK4XXX_MAX_CHIPS]; /* helper for driver */
void *private_data[AK4XXX_MAX_CHIPS]; /* helper for driver */ void *private_data[AK4XXX_MAX_CHIPS]; /* helper for driver */
/* template should fill the following fields */ /* template should fill the following fields */
...@@ -56,10 +68,11 @@ struct snd_akm4xxx { ...@@ -56,10 +68,11 @@ struct snd_akm4xxx {
SND_AK4355, SND_AK4358, SND_AK4381, SND_AK4355, SND_AK4358, SND_AK4381,
SND_AK5365 SND_AK5365
} type; } type;
unsigned int *num_stereo; /* array of combined counts
* for the mixer /* (array) information of combined codecs */
*/ struct snd_akm4xxx_dac_channel *dac_info;
char **channel_names; /* array of mixer channel names */ struct snd_akm4xxx_adc_channel *adc_info;
struct snd_ak4xxx_ops ops; struct snd_ak4xxx_ops ops;
}; };
...@@ -73,9 +86,18 @@ int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak); ...@@ -73,9 +86,18 @@ int snd_akm4xxx_build_controls(struct snd_akm4xxx *ak);
(ak)->images[(chip) * 16 + (reg)] (ak)->images[(chip) * 16 + (reg)]
#define snd_akm4xxx_set(ak,chip,reg,val) \ #define snd_akm4xxx_set(ak,chip,reg,val) \
((ak)->images[(chip) * 16 + (reg)] = (val)) ((ak)->images[(chip) * 16 + (reg)] = (val))
#define snd_akm4xxx_get_vol(ak,chip,reg) \
(ak)->volumes[(chip) * 16 + (reg)]
#define snd_akm4xxx_set_vol(ak,chip,reg,val) \
((ak)->volumes[(chip) * 16 + (reg)] = (val))
/* Warning: IPGA is tricky - we assume the addr + 4 is unused
* so far, it's OK for all AK codecs with IPGA:
* AK4524, AK4528 and EK5365
*/
#define snd_akm4xxx_get_ipga(ak,chip,reg) \ #define snd_akm4xxx_get_ipga(ak,chip,reg) \
(ak)->ipga_gain[chip][(reg)-4] snd_akm4xxx_get_vol(ak, chip, (reg) + 4)
#define snd_akm4xxx_set_ipga(ak,chip,reg,val) \ #define snd_akm4xxx_set_ipga(ak,chip,reg,val) \
((ak)->ipga_gain[chip][(reg)-4] = (val)) snd_akm4xxx_set_vol(ak, chip, (reg) + 4, val)
#endif /* __SOUND_AK4XXX_ADDA_H */ #endif /* __SOUND_AK4XXX_ADDA_H */
This diff is collapsed.
...@@ -87,19 +87,34 @@ static void revo_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate) ...@@ -87,19 +87,34 @@ static void revo_set_rate_val(struct snd_akm4xxx *ak, unsigned int rate)
* initialize the chips on M-Audio Revolution cards * initialize the chips on M-Audio Revolution cards
*/ */
static unsigned int revo71_num_stereo_front[] = {2}; #define AK_DAC(xname,xch) { .name = xname, .num_channels = xch }
static char *revo71_channel_names_front[] = {"PCM Playback Volume"};
static unsigned int revo71_num_stereo_surround[] = {1, 1, 2, 2}; static struct snd_akm4xxx_dac_channel revo71_front[] = {
static char *revo71_channel_names_surround[] = {"PCM Center Playback Volume", "PCM LFE Playback Volume", AK_DAC("PCM Playback Volume", 2)
"PCM Side Playback Volume", "PCM Rear Playback Volume"}; };
static struct snd_akm4xxx_dac_channel revo71_surround[] = {
AK_DAC("PCM Center Playback Volume", 1),
AK_DAC("PCM LFE Playback Volume", 1),
AK_DAC("PCM Side Playback Volume", 2),
AK_DAC("PCM Rear Playback Volume", 2),
};
static unsigned int revo51_num_stereo[] = {2, 1, 1, 2}; static struct snd_akm4xxx_dac_channel revo51_dac[] = {
static char *revo51_channel_names[] = {"PCM Playback Volume", "PCM Center Playback Volume", AK_DAC("PCM Playback Volume", 2),
"PCM LFE Playback Volume", "PCM Rear Playback Volume"}; AK_DAC("PCM Center Playback Volume", 1),
AK_DAC("PCM LFE Playback Volume", 1),
AK_DAC("PCM Rear Playback Volume", 2),
};
static unsigned int revo51_adc_num_stereo[] = {2}; static struct snd_akm4xxx_adc_channel revo51_adc[] = {
static char *revo51_adc_channel_names[] = {"PCM Capture Volume","PCM Capture Switch"}; {
.name = "PCM Capture Volume",
.gain_name = "PCM Capture Gain Volume",
.switch_name = "PCM Capture Switch",
.num_channels = 2
},
};
static struct snd_akm4xxx akm_revo_front __devinitdata = { static struct snd_akm4xxx akm_revo_front __devinitdata = {
.type = SND_AK4381, .type = SND_AK4381,
...@@ -107,8 +122,7 @@ static struct snd_akm4xxx akm_revo_front __devinitdata = { ...@@ -107,8 +122,7 @@ static struct snd_akm4xxx akm_revo_front __devinitdata = {
.ops = { .ops = {
.set_rate_val = revo_set_rate_val .set_rate_val = revo_set_rate_val
}, },
.num_stereo = revo71_num_stereo_front, .dac_info = revo71_front,
.channel_names = revo71_channel_names_front
}; };
static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = { static struct snd_ak4xxx_private akm_revo_front_priv __devinitdata = {
...@@ -130,8 +144,7 @@ static struct snd_akm4xxx akm_revo_surround __devinitdata = { ...@@ -130,8 +144,7 @@ static struct snd_akm4xxx akm_revo_surround __devinitdata = {
.ops = { .ops = {
.set_rate_val = revo_set_rate_val .set_rate_val = revo_set_rate_val
}, },
.num_stereo = revo71_num_stereo_surround, .dac_info = revo71_surround,
.channel_names = revo71_channel_names_surround
}; };
static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = { static struct snd_ak4xxx_private akm_revo_surround_priv __devinitdata = {
...@@ -152,8 +165,7 @@ static struct snd_akm4xxx akm_revo51 __devinitdata = { ...@@ -152,8 +165,7 @@ static struct snd_akm4xxx akm_revo51 __devinitdata = {
.ops = { .ops = {
.set_rate_val = revo_set_rate_val .set_rate_val = revo_set_rate_val
}, },
.num_stereo = revo51_num_stereo, .dac_info = revo51_dac,
.channel_names = revo51_channel_names
}; };
static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = { static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
...@@ -171,8 +183,7 @@ static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = { ...@@ -171,8 +183,7 @@ static struct snd_ak4xxx_private akm_revo51_priv __devinitdata = {
static struct snd_akm4xxx akm_revo51_adc __devinitdata = { static struct snd_akm4xxx akm_revo51_adc __devinitdata = {
.type = SND_AK5365, .type = SND_AK5365,
.num_adcs = 2, .num_adcs = 2,
.num_stereo = revo51_adc_num_stereo, .adc_info = revo51_adc,
.channel_names = revo51_adc_channel_names
}; };
static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = { static struct snd_ak4xxx_private akm_revo51_adc_priv __devinitdata = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment