Commit f1ff1f85 authored by Jaroslav Kysela's avatar Jaroslav Kysela

ALSA CVS update - Jaroslav Kysela <perex@suse.cz>

AC97 Codec Core,Intel8x0 driver,VIA82xx driver
Add AC97 quick manual override module parameter.
parent f734a14c
......@@ -479,6 +479,8 @@ void snd_ac97_resume(ac97_t *ac97);
/* quirk types */
enum {
AC97_TUNE_DEFAULT = -1, /* use default from quirk list (not valid in list) */
AC97_TUNE_NONE = 0, /* nothing extra to do */
AC97_TUNE_HP_ONLY, /* headphone (true line-out) control as master only */
AC97_TUNE_SWAP_HP, /* swap headphone and master controls */
AC97_TUNE_SWAP_SURROUND, /* swap master and surround controls */
......@@ -493,7 +495,7 @@ struct ac97_quirk {
int type; /* quirk type above */
};
int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk);
int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk, int override);
int snd_ac97_set_rate(ac97_t *ac97, int reg, unsigned short rate);
int snd_ac97_pcm_assign(ac97_bus_t *ac97,
......
......@@ -2140,10 +2140,28 @@ static int tune_ad_sharing(ac97_t *ac97)
return 0;
}
static int apply_quirk(ac97_t *ac97, int quirk)
{
switch (quirk) {
case AC97_TUNE_NONE:
return 0;
case AC97_TUNE_HP_ONLY:
return swap_headphone(ac97, 1);
case AC97_TUNE_SWAP_HP:
return swap_headphone(ac97, 0);
case AC97_TUNE_SWAP_SURROUND:
return swap_surround(ac97);
case AC97_TUNE_AD_SHARING:
return tune_ad_sharing(ac97);
}
return -EINVAL;
}
/**
* snd_ac97_tune_hardware - tune up the hardware
* @ac97: the ac97 instance
* @quirk: quirk list
* @override: explicit quirk value (overrides the list if not AC97_TUNE_DEFAULT)
*
* Do some workaround for each pci device, such as renaming of the
* headphone (true line-out) control as "Master".
......@@ -2152,28 +2170,29 @@ static int tune_ad_sharing(ac97_t *ac97)
* Returns zero if successful, or a negative error code on failure.
*/
int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk)
int snd_ac97_tune_hardware(ac97_t *ac97, struct ac97_quirk *quirk, int override)
{
int result;
snd_assert(quirk, return -EINVAL);
if (override != AC97_TUNE_DEFAULT) {
result = apply_quirk(ac97, override);
if (result < 0)
snd_printk(KERN_ERR "applying quirk type %d failed (%d)\n", override, result);
return result;
}
for (; quirk->vendor; quirk++) {
if (quirk->vendor != ac97->subsystem_vendor)
continue;
if ((! quirk->mask && quirk->device == ac97->subsystem_device) ||
quirk->device == (quirk->mask & ac97->subsystem_device)) {
snd_printdd("ac97 quirk for %s (%04x:%04x)\n", quirk->name, ac97->subsystem_vendor, ac97->subsystem_device);
switch (quirk->type) {
case AC97_TUNE_HP_ONLY:
return swap_headphone(ac97, 1);
case AC97_TUNE_SWAP_HP:
return swap_headphone(ac97, 0);
case AC97_TUNE_SWAP_SURROUND:
return swap_surround(ac97);
case AC97_TUNE_AD_SHARING:
return tune_ad_sharing(ac97);
}
snd_printk(KERN_ERR "invalid quirk type %d for %s\n", quirk->type, quirk->name);
return -EINVAL;
result = apply_quirk(ac97, quirk->type);
if (result < 0)
snd_printk(KERN_ERR "applying quirk type %d for %s failed (%d)\n", quirk->type, quirk->name, result);
return result;
}
}
return 0;
......
......@@ -72,6 +72,7 @@ static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */
static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */
static int enable[SNDRV_CARDS] = SNDRV_DEFAULT_ENABLE_PNP; /* Enable this card */
static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 0};
static int ac97_quirk[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = AC97_TUNE_DEFAULT};
#ifdef SUPPORT_JOYSTICK
static int joystick[SNDRV_CARDS];
#endif
......@@ -91,6 +92,9 @@ MODULE_PARM_SYNTAX(enable, SNDRV_ENABLE_DESC);
MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (0 = auto-detect).");
MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:0");
MODULE_PARM(ac97_quirk, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
MODULE_PARM_SYNTAX(ac97_quirk, SNDRV_ENABLED ",default:-1");
#ifdef SUPPORT_JOYSTICK
MODULE_PARM(joystick, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
MODULE_PARM_DESC(joystick, "Enable joystick for Intel i8x0 soundcard.");
......@@ -1765,7 +1769,7 @@ static struct ac97_quirk ac97_quirks[] __devinitdata = {
{ } /* terminator */
};
static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock, int ac97_quirk)
{
ac97_bus_t bus, *pbus;
ac97_t ac97, *x97;
......@@ -1855,7 +1859,7 @@ static int __devinit snd_intel8x0_mixer(intel8x0_t *chip, int ac97_clock)
chip->ac97[i] = x97;
}
/* tune up the primary codec */
snd_ac97_tune_hardware(chip->ac97[0], ac97_quirks);
snd_ac97_tune_hardware(chip->ac97[0], ac97_quirks, ac97_quirk);
/* enable separate SDINs for ICH4 */
if (chip->device_type == DEVICE_INTEL_ICH4)
pbus->isdin = 1;
......@@ -2613,7 +2617,7 @@ static int __devinit snd_intel8x0_probe(struct pci_dev *pci,
return err;
}
if ((err = snd_intel8x0_mixer(chip, ac97_clock[dev])) < 0) {
if ((err = snd_intel8x0_mixer(chip, ac97_clock[dev], ac97_quirk[dev])) < 0) {
snd_card_free(card);
return err;
}
......@@ -2798,7 +2802,7 @@ module_exit(alsa_card_intel8x0_exit)
#ifndef MODULE
/* format is: snd-intel8x0=enable,index,id,ac97_clock,mpu_port,joystick */
/* format is: snd-intel8x0=enable,index,id,ac97_clock,ac97_quirk,mpu_port,joystick */
static int __init alsa_card_intel8x0_setup(char *str)
{
......@@ -2810,6 +2814,7 @@ static int __init alsa_card_intel8x0_setup(char *str)
get_option(&str,&index[nr_dev]) == 2 &&
get_id(&str,&id[nr_dev]) == 2 &&
get_option(&str,&ac97_clock[nr_dev]) == 2
get_option(&str,&ac97_quirk[nr_dev]) == 2
#ifdef SUPPORT_MIDI
&& get_option(&str,&mpu_port[nr_dev]) == 2
#endif
......
......@@ -82,6 +82,7 @@ static long mpu_port[SNDRV_CARDS];
static int joystick[SNDRV_CARDS];
#endif
static int ac97_clock[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 48000};
static int ac97_quirk[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = AC97_TUNE_DEFAULT};
static int dxs_support[SNDRV_CARDS];
MODULE_PARM(index, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
......@@ -104,6 +105,9 @@ MODULE_PARM_SYNTAX(joystick, SNDRV_ENABLE_DESC "," SNDRV_BOOLEAN_FALSE_DESC);
MODULE_PARM(ac97_clock, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
MODULE_PARM_DESC(ac97_clock, "AC'97 codec clock (default 48000Hz).");
MODULE_PARM_SYNTAX(ac97_clock, SNDRV_ENABLED ",default:48000");
MODULE_PARM(ac97_quirk, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
MODULE_PARM_DESC(ac97_quirk, "AC'97 workaround for strange hardware.");
MODULE_PARM_SYNTAX(ac97_quirk, SNDRV_ENABLED ",default:-1");
MODULE_PARM(dxs_support, "1-" __MODULE_STRING(SNDRV_CARDS) "i");
MODULE_PARM_DESC(dxs_support, "Support for DXS channels (0 = auto, 1 = enable, 2 = disable, 3 = 48k only, 4 = no VRA)");
MODULE_PARM_SYNTAX(dxs_support, SNDRV_ENABLED ",allows:{{0,4}},dialog:list");
......@@ -1559,7 +1563,7 @@ static struct ac97_quirk ac97_quirks[] = {
{ } /* terminator */
};
static int __devinit snd_via82xx_mixer_new(via82xx_t *chip)
static int __devinit snd_via82xx_mixer_new(via82xx_t *chip, int ac97_quirk)
{
ac97_bus_t bus;
ac97_t ac97;
......@@ -1582,7 +1586,7 @@ static int __devinit snd_via82xx_mixer_new(via82xx_t *chip)
if ((err = snd_ac97_mixer(chip->ac97_bus, &ac97, &chip->ac97)) < 0)
return err;
snd_ac97_tune_hardware(chip->ac97, ac97_quirks);
snd_ac97_tune_hardware(chip->ac97, ac97_quirks, ac97_quirk);
if (chip->chip_type != TYPE_VIA686) {
/* use slot 10/11 */
......@@ -2087,7 +2091,7 @@ static int __devinit snd_via82xx_probe(struct pci_dev *pci,
if ((err = snd_via82xx_create(card, pci, chip_type, revision, ac97_clock[dev], &chip)) < 0)
goto __error;
if ((err = snd_via82xx_mixer_new(chip)) < 0)
if ((err = snd_via82xx_mixer_new(chip, ac97_quirk[dev])) < 0)
goto __error;
if (chip_type == TYPE_VIA686) {
......@@ -2169,7 +2173,8 @@ module_exit(alsa_card_via82xx_exit)
#ifndef MODULE
/* format is: snd-via82xx=enable,index,id,
mpu_port,joystick,ac97_clock,dxs_support */
mpu_port,joystick,
ac97_quirk,ac97_clock,dxs_support */
static int __init alsa_card_via82xx_setup(char *str)
{
......@@ -2184,6 +2189,7 @@ static int __init alsa_card_via82xx_setup(char *str)
#ifdef SUPPORT_JOYSTICK
get_option(&str,&joystick[nr_dev]) == 2 &&
#endif
get_option(&str,&ac97_quirk[nr_dev]) == 2 &&
get_option(&str,&ac97_clock[nr_dev]) == 2 &&
get_option(&str,&dxs_support[nr_dev]) == 2);
nr_dev++;
......
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