[PATCH] V4L: Fixes nicam sound

- Resolved problem of sporadic buzz after setting Nicam stereo
- improved setting audio standard with dma reset
- cleaned up comments format
- more sensitive Nicam detection

Signed-off-by: Ian Pickworth <ian@pickworth.me.uk>
Signed-off-by: Michal Pytasz <pytasz@lodz.home.pl>
Signed-off-by: Marcin Rudowski <mar_rud@poczta.onet.pl>
Signed-off-by: Torsten Seeboth <Torsten.Seeboth@t-online.de>
Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
diff --git a/drivers/media/video/cx88/cx88-tvaudio.c b/drivers/media/video/cx88/cx88-tvaudio.c
index 6d9bec1..a9059c5 100644
--- a/drivers/media/video/cx88/cx88-tvaudio.c
+++ b/drivers/media/video/cx88/cx88-tvaudio.c
@@ -119,13 +119,10 @@
 
 static void set_audio_start(struct cx88_core *core, u32 mode)
 {
-	// mute
+	/* mute */
 	cx_write(AUD_VOL_CTL, (1 << 6));
 
-	// start programming
-	cx_write(MO_AUD_DMACNTRL, 0x0000);
-	msleep(100);
-	//cx_write(AUD_CTL, 0x0000);
+	/* start programming */
 	cx_write(AUD_INIT, mode);
 	cx_write(AUD_INIT_LD, 0x0001);
 	cx_write(AUD_SOFT_RESET, 0x0001);
@@ -135,17 +132,18 @@
 {
 	u32 volume;
 
+	cx_write(AUD_RATE_THRES_DMD, 0x000000C0);
+
 	if (cx88_boards[core->board].blackbird) {
-		// sets sound input from external adc
+		/* sets sound input from external adc */
 		cx_set(AUD_CTL, EN_I2SIN_ENABLE);
-		//cx_write(AUD_I2SINPUTCNTL, 0);
 		cx_write(AUD_I2SINPUTCNTL, 4);
 		cx_write(AUD_BAUDRATE, 1);
-		// 'pass-thru mode': this enables the i2s output to the mpeg encoder
+		/* 'pass-thru mode': this enables the i2s output to the mpeg encoder */
 		cx_set(AUD_CTL, EN_I2SOUT_ENABLE);
 		cx_write(AUD_I2SOUTPUTCNTL, 1);
 		cx_write(AUD_I2SCNTL, 0);
-		//cx_write(AUD_APB_IN_RATE_ADJ, 0);
+		/* cx_write(AUD_APB_IN_RATE_ADJ, 0); */
 	} else {
 		ctl |= EN_DAC_ENABLE;
 		cx_write(AUD_CTL, ctl);
@@ -153,7 +151,6 @@
 
 	/* finish programming */
 	cx_write(AUD_SOFT_RESET, 0x0000);
-	cx_write(MO_AUD_DMACNTRL, 0x0003);
 
 	/* unmute */
 	volume = cx_sread(SHADOW_AUD_VOL_CTL);
@@ -313,7 +310,6 @@
 		{AUD_RATE_ADJ3, 0x00000100},
 		{AUD_RATE_ADJ4, 0x00000400},
 		{AUD_RATE_ADJ5, 0x00001000},
-		//{ AUD_DMD_RA_DDS,        0x00c0d5ce },
 		{AUD_ERRLOGPERIOD_R, 0x00000fff},
 		{AUD_ERRINTRPTTHSHLD1_R, 0x000003ff},
 		{AUD_ERRINTRPTTHSHLD2_R, 0x000000ff},
@@ -351,12 +347,12 @@
 		set_audio_registers(core, nicam_l);
 		break;
 	case WW_I:
-		dprintk("%s PAL-I NICAM (status: devel)\n", __FUNCTION__);
+		dprintk("%s PAL-I NICAM (status: known-good)\n", __FUNCTION__);
 		set_audio_registers(core, nicam_bgdki_common);
 		set_audio_registers(core, nicam_i);
 		break;
 	default:
-		dprintk("%s PAL-BGDK NICAM (status: unknown)\n", __FUNCTION__);
+		dprintk("%s PAL-BGDK NICAM (status: known-good)\n", __FUNCTION__);
 		set_audio_registers(core, nicam_bgdki_common);
 		set_audio_registers(core, nicam_default);
 		break;
@@ -715,8 +711,7 @@
 		/* if bit1=1 then nicam is detected */
 		j += ((cx_read(AUD_NICAM_STATUS2) & 0x02) >> 1);
 
-		/* 3x detected: absolutly sure now */
-		if (j == 3) {
+		if (j == 1) {
 			dprintk("nicam is detected.\n");
 			return 1;
 		}