Re: [RFC] Add dB scale information to AK4xxx codec

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



At Thu, 7 Sep 2006 12:00:30 +0100,
Jochen Voss wrote:
> 
> Hello Takashi,
> 
> On Thu, Sep 07, 2006 at 12:33:18PM +0200, Takashi Iwai wrote:
> > Yes.  Then we need to take the controls back to a single one.
> > Will do later.
> Ok.
> 
> > I still wonder whether this is also true for AK4524...
> No idea about this, I do not have an AK4524 so I cannot test.
> 
> > > > Also, it's possible that I did make a silly mistake.  Put a debug
> > > > printk around ak->ops.write() in snd_akm4xxx_write() to check what
> > > > values are written to register 4 and 5.
> > > 
> > > I will try this in the evening.
> 
> This sounded more fun than the simulation I am supposed to do for work,
> so I sneaked away and did this first ;-)
> 
> I used the following printk:
> 
> ======================================================================
> --- ak4xxx-adda.c~      2006-08-31 01:00:11.000000000 +0100
> +++ ak4xxx-adda.c       2006-09-07 11:49:57.394999424 +0100
> @@ -40,6 +40,9 @@
>                        unsigned char val)
>  {
>         ak->ops.lock(ak, chip);
> +       if (ak->type == SND_AK5365 && (reg==4 || reg==5)) {
> +         printk (KERN_INFO "reg%d <- %02x\n", reg, val);
> +       }
>         ak->ops.write(ak, chip, reg, val);
>  
>         /* save the data */
> ======================================================================
> 
> Results from my second test (s2.sh vs s3.sh):
> 
> s2.sh: The commands
> 
>     amixer set "PCM Capture Gain" 0
>     amixer set "PCM Capture Gain" 20
>     amixer set "PCM" 0
>     amixer set "PCM" 80%
> 
> translate into
> 
>     reg4 <- 80
>     reg5 <- 80
>     reg4 <- 94
>     reg5 <- 94
>     reg4 <- 00
>     reg5 <- 00
>     reg4 <- 5e
>     reg5 <- 5e
> 
> s3.sh: The commands
> 
>     amixer set "PCM" 0
>     amixer set "PCM" 80%
>     amixer set "PCM Capture Gain" 0
>     amixer set "PCM Capture Gain" 20
> 
> translate into
> 
>     reg4 <- 00
>     reg5 <- 00
>     reg4 <- 5e
>     reg5 <- 5e
>     reg4 <- 80
>     reg5 <- 80
>     reg4 <- 94
>     reg5 <- 94
> 
> This seems to be the expected register assignments.  As stated before,
> these settings lead to different recording volume.

OK, thanks for confirmation.

The untested patch for removing IPGA is below.  Please give it a
shot. 

I'll check a board with AK4524 (well I have to dig the boxes) whether
it shows shows the same behavior like AK5365.


Takashi

diff -r 4f27a5064cda i2c/other/ak4xxx-adda.c
--- a/i2c/other/ak4xxx-adda.c	Thu Sep 07 12:40:00 2006 +0200
+++ b/i2c/other/ak4xxx-adda.c	Thu Sep 07 14:46:39 2006 +0200
@@ -324,13 +324,15 @@ EXPORT_SYMBOL(snd_akm4xxx_init);
 /*
  * Mixer callbacks
  */
+#define AK_IPGA 			(1<<20)	/* including IPGA */
 #define AK_VOL_CVT 			(1<<21)	/* need dB conversion */
 #define AK_NEEDSMSB 			(1<<22)	/* need MSB update bit */
 #define AK_INVERT 			(1<<23)	/* data is inverted */
 #define AK_GET_CHIP(val)		(((val) >> 8) & 0xff)
 #define AK_GET_ADDR(val)		((val) & 0xff)
-#define AK_GET_SHIFT(val)		(((val) >> 16) & 0x1f)
+#define AK_GET_SHIFT(val)		(((val) >> 16) & 0x0f)
 #define AK_GET_VOL_CVT(val)		(((val) >> 21) & 1)
+#define AK_GET_IPGA(val)		(((val) >> 20) & 1)
 #define AK_GET_NEEDSMSB(val)		(((val) >> 22) & 1)
 #define AK_GET_INVERT(val)		(((val) >> 23) & 1)
 #define AK_GET_MASK(val)		(((val) >> 24) & 0xff)
@@ -371,8 +373,10 @@ static int put_ak_reg(struct snd_kcontro
 		return 0;
 
 	snd_akm4xxx_set_vol(ak, chip, addr, nval);
-	if (AK_GET_VOL_CVT(kcontrol->private_value))
+	if (AK_GET_VOL_CVT(kcontrol->private_value) && nval < 128)
 		nval = vol_cvt_datt[nval];
+	if (AK_GET_IPGA(kcontrol->private_value) && nval >= 128)
+		nval++;
 	if (AK_GET_INVERT(kcontrol->private_value))
 		nval = mask - nval;
 	if (AK_GET_NEEDSMSB(kcontrol->private_value))
@@ -702,13 +706,21 @@ static int build_adc_controls(struct snd
 			knew.put = snd_akm4xxx_volume_put;
 		}
 		/* register 4 & 5 */
-		knew.private_value =
-			AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127) |
-			AK_VOL_CVT;
+		if (ak->type == SND_AK5365)
+			knew.private_value =
+				AK_COMPOSE(idx/2, (idx%2) + 4, 0, 151) |
+				AK_VOL_CVT | AK_IPGA;
+		else
+			knew.private_value =
+				AK_COMPOSE(idx/2, (idx%2) + 4, 0, 127) |
+				AK_VOL_CVT;
 		knew.tlv.p = db_scale_vol_datt;
 		err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak));
 		if (err < 0)
 			return err;
+
+		if (ak->type == SND_AK5365)
+			goto no_ipga;
 
 		if (! ak->adc_info || ! ak->adc_info[mixer_ch].gain_name)
 			knew.name = "IPGA Analog Capture Volume";
@@ -723,18 +735,13 @@ static int build_adc_controls(struct snd
 			knew.get = snd_akm4xxx_ipga_gain_get;
 			knew.put = snd_akm4xxx_ipga_gain_put;
 		}
-		/* register 4 & 5 */
-		if (ak->type == SND_AK4524)
-			knew.private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0,
-							24);
-		else /* AK5365 */
-			knew.private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0,
-							36);
+		knew.private_value = AK_COMPOSE(idx/2, (idx%2) + 4, 0, 36);
 		knew.tlv.p = db_scale_ipga;
 		err = snd_ctl_add(ak->card, snd_ctl_new1(&knew, ak));
 		if (err < 0)
 			return err;
 
+	no_ipga:
 		if (ak->type == SND_AK5365 && (idx % 2) == 0) {
 			if (! ak->adc_info || 
 			    ! ak->adc_info[mixer_ch].switch_name)

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
Alsa-devel mailing list
Alsa-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.sourceforge.net/lists/listinfo/alsa-devel

[Index of Archives]     [ALSA User]     [Linux Audio Users]     [Kernel Archive]     [Asterisk PBX]     [Photo Sharing]     [Linux Sound]     [Video 4 Linux]     [Gimp]     [Yosemite News]

  Powered by Linux