[alsa-devel] [PATCH 2/3] swarm_cs4297: Rename AC97 registers to use sound/ac97_codec.h definitions

Takashi Iwai tiwai at suse.de
Mon Jun 18 16:04:56 CEST 2012


At Mon, 11 Jun 2012 16:58:50 -0300,
Ezequiel Garcia wrote:
> 
> This patch removes the last usage of linux/ac97_codec.h
> by renaming ac97 registers to use sound/ac97_codec.h definitions.
> This will enable us to remove linux/ac97_codec.h.
> 
> Not even compilation tested.
> 
> Cc: Ralf Baechle <ralf at linux-mips.org>
> Cc: Jaroslav Kysela <perex at perex.cz>
> Cc: Takashi Iwai <tiwai at suse.de>
> Cc: Clemens Ladisch <clemens at ladisch.de>
> Signed-off-by: Ezequiel Garcia <elezegarcia at gmail.com>
> ---
> Hi all,
> 
> This patch is important so we can remove linux/ac97_codec.h usage.
> Since this driver is mips related, I can't test it until I install
> a mips toolchain.
> If someone can compile this for me, or even test it with real
> hardware I think it would be better.
> If not then I can install a mips toolchain and compile it myself,
> but I won't be able to test it on real hardware.
> 
> This patch should be treated with carefully and be applied only
> if someone manages to test it.

A slight concern by this change is that the driver includes
sound/ac97_codec.h although it's based on OSS framework. 
sound/ac97_codec.h is the header for ALSA ac97 structs, and this can't
be mixed up with OSS.

If the intention is only about AC97 register definition, we may split
ac97_codec.h into ac97_regs.h and ac97_codecs.h where the former
contains only the register definitions (thus framework-neutral) and
the latter includes the former.


thanks,

Takashi


> 
> Regards,
> Ezequiel.
> ---
>  sound/oss/swarm_cs4297a.c |   28 ++++++++++++++--------------
>  1 files changed, 14 insertions(+), 14 deletions(-)
> 
> diff --git a/sound/oss/swarm_cs4297a.c b/sound/oss/swarm_cs4297a.c
> index 09d4648..d0a1000 100644
> --- a/sound/oss/swarm_cs4297a.c
> +++ b/sound/oss/swarm_cs4297a.c
> @@ -69,7 +69,6 @@
>  #include <linux/sound.h>
>  #include <linux/slab.h>
>  #include <linux/soundcard.h>
> -#include <linux/ac97_codec.h>
>  #include <linux/pci.h>
>  #include <linux/bitops.h>
>  #include <linux/interrupt.h>
> @@ -77,6 +76,7 @@
>  #include <linux/poll.h>
>  #include <linux/mutex.h>
>  #include <linux/kernel.h>
> +#include <sound/ac97_codec.h>
>  
>  #include <asm/byteorder.h>
>  #include <asm/dma.h>
> @@ -1162,10 +1162,10 @@ static int mixer_ioctl(struct cs4297a_state *s, unsigned int cmd,
>  	};
>  
>  	static const unsigned mixreg[] = {
> -		AC97_PCMOUT_VOL,
> -		AC97_AUX_VOL,
> -		AC97_CD_VOL,
> -		AC97_LINEIN_VOL
> +		AC97_PCM,
> +		AC97_AUX,
> +		AC97_CD,
> +		AC97_LINE
>  	};
>  	unsigned char l, r, rl, rr, vidx;
>  	unsigned char attentbl[11] =
> @@ -1264,7 +1264,7 @@ static int mixer_ioctl(struct cs4297a_state *s, unsigned int cmd,
>  	if (_SIOC_DIR(cmd) == _SIOC_READ) {
>  		switch (_IOC_NR(cmd)) {
>  		case SOUND_MIXER_RECSRC:	// Arg contains a bit for each recording source 
> -			cs4297a_read_ac97(s, AC97_RECORD_SELECT,
> +			cs4297a_read_ac97(s, AC97_REC_SEL,
>  					 &temp1);
>  			return put_user(mixer_src[temp1 & 7], (int *) arg);
>  
> @@ -1314,7 +1314,7 @@ static int mixer_ioctl(struct cs4297a_state *s, unsigned int cmd,
>  			if (val == mixer_src[i]) {
>  				temp1 = (i << 8) | i;
>  				cs4297a_write_ac97(s,
> -						  AC97_RECORD_SELECT,
> +						  AC97_REC_SEL,
>  						  temp1);
>  				return 0;
>  			}
> @@ -1349,8 +1349,8 @@ static int mixer_ioctl(struct cs4297a_state *s, unsigned int cmd,
>  
>  		temp1 |= (rl << 8) | rr;
>  
> -		cs4297a_write_ac97(s, AC97_MASTER_VOL_STEREO, temp1);
> -		cs4297a_write_ac97(s, AC97_PHONE_VOL, temp1);
> +		cs4297a_write_ac97(s, AC97_MASTER, temp1);
> +		cs4297a_write_ac97(s, AC97_PHONE, temp1);
>  
>  #ifdef OSS_DOCUMENTED_MIXER_SEMANTICS
>  		s->mix.vol[8] = ((unsigned int) r << 8) | l;
> @@ -1380,7 +1380,7 @@ static int mixer_ioctl(struct cs4297a_state *s, unsigned int cmd,
>  			temp1 = 0;
>  		rl = 15 - rl;	// Convert volume to attenuation.
>  		temp1 |= rl << 1;
> -		cs4297a_write_ac97(s, AC97_PCBEEP_VOL, temp1);
> +		cs4297a_write_ac97(s, AC97_PC_BEEP, temp1);
>  
>  #ifdef OSS_DOCUMENTED_MIXER_SEMANTICS
>  		s->mix.vol[6] = l << 8;
> @@ -1406,7 +1406,7 @@ static int mixer_ioctl(struct cs4297a_state *s, unsigned int cmd,
>  			temp1 = 0;
>  
>  		temp1 = temp1 | (rl << 8) | rr;
> -		cs4297a_write_ac97(s, AC97_RECORD_GAIN, temp1);
> +		cs4297a_write_ac97(s, AC97_REC_GAIN, temp1);
>  
>  #ifdef OSS_DOCUMENTED_MIXER_SEMANTICS
>  		s->mix.vol[7] = ((unsigned int) r << 8) | l;
> @@ -1428,7 +1428,7 @@ static int mixer_ioctl(struct cs4297a_state *s, unsigned int cmd,
>  			rl = ((unsigned) l * 5 - 4) / 16;	// Convert 0-100 range to 0-31.
>  			l = (rl * 16 + 4) / 5;
>  		}
> -		cs4297a_read_ac97(s, AC97_MIC_VOL, &temp1);
> +		cs4297a_read_ac97(s, AC97_MIC, &temp1);
>  		temp1 &= 0x40;	// Isolate 20db gain bit.
>  		if (rl < 3) {
>  			temp1 |= 0x8000;
> @@ -1436,7 +1436,7 @@ static int mixer_ioctl(struct cs4297a_state *s, unsigned int cmd,
>  		}
>  		rl = 31 - rl;	// Convert volume to attenuation.
>  		temp1 |= rl;
> -		cs4297a_write_ac97(s, AC97_MIC_VOL, temp1);
> +		cs4297a_write_ac97(s, AC97_MIC, temp1);
>  
>  #ifdef OSS_DOCUMENTED_MIXER_SEMANTICS
>  		s->mix.vol[5] = val << 8;
> @@ -2690,7 +2690,7 @@ static int __init cs4297a_init(void)
>  
>          do {
>                  udelay(4000);
> -                rval = cs4297a_read_ac97(s, AC97_POWER_CONTROL, &pwr);
> +		 rval = cs4297a_read_ac97(s, AC97_POWERDOWN, &pwr);
>          } while (!rval && (pwr != 0xf));
>  
>          if (!rval) {
> -- 
> 1.7.4.4
> 


More information about the Alsa-devel mailing list