Subject: Re: autri0: Codec timeout. Busy reading AC'97 codec.
To: <>
From: tedu <grendel@zeitbombe.org>
List: tech-kern
Date: 09/11/2002 09:35:34
On Wed, 11 Sep 2002, Hubert Feyrer wrote:

> I tried the patch below, but it seems that ac97_write() never gets invoked
> with ac97_writethrough=1. While playing a divx w/ mplayer, there don't
> seem to be any calls to ac97_write(), at least no printf traces are in
> dmesg. I get a few at bootup, but none when using mplayer. No idea what's
> going on, I don't know the guts of the driver.

The problem isn't actually mplayer writing to the mixer, it's reading.
Whenever possible, you want ac97 to read the shadow registers.

I think you picked the wrong part of the patch to try. :)  You want the
one-liner
-       if (((as->host_flags & AC97_HOST_DONT_READ) &&
+       if ((
in ac97_read().

The real fix is to have as->host_flags set to AC97_HOST_DONT_READ, but the
autri driver doesn't set any flags.  I was interested in making sound work
more than doing it right. :(


ted

>
> I tried looking at the OpenBSD ac97.c, but it seems quite different from
> ours. ;(
>
>
>   - Hubert
>
>
> Index: ac97.c
> ===================================================================
> RCS file: /cvsroot/syssrc/sys/dev/ic/ac97.c,v
> retrieving revision 1.24
> diff -u -r1.24 ac97.c
> --- ac97.c	2002/01/23 14:50:45	1.24
> +++ ac97.c	2002/09/11 16:47:34
> @@ -392,6 +392,8 @@
>  #define DPRINTFN(n,x)
>  #endif
>
> +static int ac97_writethrough;
> +
>  void
>  ac97_read(as, reg, val)
>  	struct ac97_softc *as;
> @@ -418,6 +420,11 @@
>  	u_int8_t reg;
>  	u_int16_t val;
>  {
> +	printf ("ac97_write: ac97_writethrough=%d, val=%d, reg=%d\n", ac97_writethrough, val, reg); /*HF*/
> +
> +	if(ac97_writethrough == 0 && as->shadow_reg[reg >> 1] == val) {
> +		return 0;
> +	}
>
>  	as->shadow_reg[reg >> 1] = val;
>
> @@ -433,10 +440,12 @@
>
>  	memset(as->shadow_reg, 0, sizeof(as->shadow_reg));
>
> +	ac97_writethrough = 1;
>  	for (idx = 0; idx < SOURCE_INFO_SIZE; idx++) {
>  		si = &source_info[idx];
>  		ac97_write(as, si->reg, si->default_value);
>  	}
> +	ac97_writethrough = 0;
>  }
>
>  void
> @@ -447,10 +456,12 @@
>  	int idx;
>  	const struct ac97_source_info *si;
>
> +	ac97_writethrough = 1;
>  	for (idx = 0; idx < SOURCE_INFO_SIZE; idx++) {
>  		si = &source_info[idx];
>  		ac97_write(as, si->reg, as->shadow_reg[si->reg >> 1]);
>  	}
> +	ac97_writethrough = 0;
>  }
>
>  int
>
>

--
Mediocrity is a sin.