All of lore.kernel.org
 help / color / mirror / Atom feed
From: Takashi Iwai <tiwai@suse.de>
To: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>
Cc: linux-kernel@vger.kernel.org
Subject: Re: [PATCH] ALSA: Don't cold reset AC97 codecs in some ICH chipsets
Date: Wed, 28 Jan 2009 16:20:12 +0100	[thread overview]
Message-ID: <s5hr62nv4nn.wl%tiwai@suse.de> (raw)
In-Reply-To: <1233153642-4882-1-git-send-email-cascardo@holoscopio.com>

At Wed, 28 Jan 2009 12:40:42 -0200,
Thadeu Lima de Souza Cascardo wrote:
> 
> Check in a quirk list if it should do cold reset when AC97 power saving
> is enabled. Some devices do not resume properly when cold reset,
> although power saving works OK.
> 
> Signed-off-by: Thadeu Lima de Souza Cascardo <cascardo@holoscopio.com>

Thanks, applied now.

... and soon I found a build error when CONFIG_SND_AC97_POWERSAVE=n.
Fixed, too :)


Takashi

> ---
>  sound/pci/intel8x0.c |   68 ++++++++++++++++++++++++++++++++++++++-----------
>  1 files changed, 52 insertions(+), 16 deletions(-)
> 
> diff --git a/sound/pci/intel8x0.c b/sound/pci/intel8x0.c
> index 19d3391..b37bd26 100644
> --- a/sound/pci/intel8x0.c
> +++ b/sound/pci/intel8x0.c
> @@ -2287,23 +2287,23 @@ static void do_ali_reset(struct intel8x0 *chip)
>  	iputdword(chip, ICHREG(ALI_INTERRUPTSR), 0x00000000);
>  }
>  
> -static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
> -{
> -	unsigned long end_time;
> -	unsigned int cnt, status, nstatus;
> -	
> -	/* put logic to right state */
> -	/* first clear status bits */
> -	status = ICH_RCS | ICH_MCINT | ICH_POINT | ICH_PIINT;
> -	if (chip->device_type == DEVICE_NFORCE)
> -		status |= ICH_NVSPINT;
> -	cnt = igetdword(chip, ICHREG(GLOB_STA));
> -	iputdword(chip, ICHREG(GLOB_STA), cnt & status);
> +#ifdef CONFIG_SND_AC97_POWER_SAVE
> +static struct snd_pci_quirk ich_chip_reset_mode[] = {
> +	SND_PCI_QUIRK(0x1014, 0x051f, "Thinkpad R32", 1),
> +	{ } /* end */
> +};
>  
> +static int snd_intel8x0_ich_chip_cold_reset(struct intel8x0 *chip)
> +{
> +	unsigned int cnt;
>  	/* ACLink on, 2 channels */
> +
> +	if (snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
> +		return -EIO;
> +
>  	cnt = igetdword(chip, ICHREG(GLOB_CNT));
>  	cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
> -#ifdef CONFIG_SND_AC97_POWER_SAVE
> +
>  	/* do cold reset - the full ac97 powerdown may leave the controller
>  	 * in a warm state but actually it cannot communicate with the codec.
>  	 */
> @@ -2312,22 +2312,58 @@ static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
>  	udelay(10);
>  	iputdword(chip, ICHREG(GLOB_CNT), cnt | ICH_AC97COLD);
>  	msleep(1);
> +	return 0;
> +}
> +#define snd_intel8x0_ich_chip_can_cold_reset(chip) \
> +	(!snd_pci_quirk_lookup(chip->pci, ich_chip_reset_mode))
>  #else
> +#define snd_intel8x0_ich_chip_cold_reset(x) do { } while (0)
> +#define snd_intel8x0_ich_chip_can_cold_reset(chip) (0)
> +#endif
> +
> +static int snd_intel8x0_ich_chip_reset(struct intel8x0 *chip)
> +{
> +	unsigned long end_time;
> +	unsigned int cnt;
> +	/* ACLink on, 2 channels */
> +	cnt = igetdword(chip, ICHREG(GLOB_CNT));
> +	cnt &= ~(ICH_ACLINK | ICH_PCM_246_MASK);
>  	/* finish cold or do warm reset */
>  	cnt |= (cnt & ICH_AC97COLD) == 0 ? ICH_AC97COLD : ICH_AC97WARM;
>  	iputdword(chip, ICHREG(GLOB_CNT), cnt);
>  	end_time = (jiffies + (HZ / 4)) + 1;
>  	do {
>  		if ((igetdword(chip, ICHREG(GLOB_CNT)) & ICH_AC97WARM) == 0)
> -			goto __ok;
> +			return 0;
>  		schedule_timeout_uninterruptible(1);
>  	} while (time_after_eq(end_time, jiffies));
>  	snd_printk(KERN_ERR "AC'97 warm reset still in progress? [0x%x]\n",
>  		   igetdword(chip, ICHREG(GLOB_CNT)));
>  	return -EIO;
> +}
> +
> +static int snd_intel8x0_ich_chip_init(struct intel8x0 *chip, int probing)
> +{
> +	unsigned long end_time;
> +	unsigned int status, nstatus;
> +	unsigned int cnt;
> +	int err;
> +
> +	/* put logic to right state */
> +	/* first clear status bits */
> +	status = ICH_RCS | ICH_MCINT | ICH_POINT | ICH_PIINT;
> +	if (chip->device_type == DEVICE_NFORCE)
> +		status |= ICH_NVSPINT;
> +	cnt = igetdword(chip, ICHREG(GLOB_STA));
> +	iputdword(chip, ICHREG(GLOB_STA), cnt & status);
> +
> +	if (snd_intel8x0_ich_chip_can_cold_reset(chip))
> +		err = snd_intel8x0_ich_chip_cold_reset(chip);
> +	else
> +		err = snd_intel8x0_ich_chip_reset(chip);
> +	if (err < 0)
> +		return err;
>  
> -      __ok:
> -#endif
>  	if (probing) {
>  		/* wait for any codec ready status.
>  		 * Once it becomes ready it should remain ready
> -- 
> 1.6.0.6
> 

  reply	other threads:[~2009-01-28 15:20 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-01-28 14:40 [PATCH] ALSA: Don't cold reset AC97 codecs in some ICH chipsets Thadeu Lima de Souza Cascardo
2009-01-28 15:20 ` Takashi Iwai [this message]
2009-01-28 15:52   ` Thadeu Lima de Souza Cascardo
2009-01-29  7:37     ` Takashi Iwai
  -- strict thread matches above, loose matches on Subject: below --
2009-01-28 10:02 Thadeu Lima de Souza Cascardo
2009-01-28 12:06 ` Takashi Iwai
2009-01-28 12:27   ` Thadeu Lima de Souza Cascardo
2009-01-28 13:02     ` Takashi Iwai

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=s5hr62nv4nn.wl%tiwai@suse.de \
    --to=tiwai@suse.de \
    --cc=cascardo@holoscopio.com \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.