I spent my morning looking at why the audio on my svideo and composite
inputs has clicks and stuff in it. I've modified our
cx25840_set_audio_input to more closely match the windows driver. The
main difference is the mutes on line-in; we now unmute AC97, PAR, and
SRC1 like the windows version does.
I've also removed a lot of places where we toggle the microcontroller on
and off, and only turn it on after selecting tuner audio. This is also
came from the windows driver.
Third, I fixed where I had a typo in my 5/31 email. I meant to say
0x478 write4 0x6650021f, but I said 0x64... The difference that a 2line
luma comb filter can be used by the adaptation algorithm in addition to
the 3line.
I've also got:
-- CH2_SRC is now set to 0 instead of 3 when selecting the tuner input.
This is because CH2 isn't actually used, and I think it reads a little
better this way. The line could actually be removed altogether.
-- CH2 or CH3 is powered down when not in use by the selected input.
-- A function to power down all units is included but #defined out.
I can break these up, but I don't see any potential problems except for
all the changes to the MICROCTRL on/off.
Index: ivtv/driver/cx25840-driver.c
===================================================================
--- ivtv/driver/cx25840-driver.c (revision 283)
+++ ivtv/driver/cx25840-driver.c (working copy)
@@ -233,7 +233,7 @@
cx25840_write(client, 0x0478, 0x1f);
cx25840_write(client, 0x0479, 0x02);
cx25840_write(client, 0x047a, 0x50);
- cx25840_write(client, 0x047b, 0x64);
+ cx25840_write(client, 0x047b, 0x66);
cx25840_write(client, 0x047c, 0x1f);
cx25840_write(client, 0x047d, 0x7c);
@@ -441,23 +441,38 @@
cx25840_initialize(client);
#if 1
- CX25840_SET_START_MICROCNTL(0x0000); // FW Stop
+ //CX25840_SET_START_MICROCNTL(0x0000); // FW Stop
CX25840_SET_SOFT_RESET(0x0001); // Soft reset assert.
CX25840_SET_VD_SOFT_RST(0x0001); // Video assert
- CX25840_SET_START_MICROCNTL(0x0001); // FW Start
+ //CX25840_SET_START_MICROCNTL(0x0001); // FW Start
CX25840_SET_SOFT_RESET(0x0000); // Deassert soft reset
CX25840_SET_VD_SOFT_RST(0x0000); // Deassert video reset
#endif
/* Setup VBI */
- CX25840_SET_START_MICROCNTL(0x0000);
+ //CX25840_SET_START_MICROCNTL(0x0000);
vbi_reg_setup(client);
- CX25840_SET_START_MICROCNTL(0x0001);
+ //CX25840_SET_START_MICROCNTL(0x0001);
return;
}
+#if 0
+static void cx25840_set_low_power(struct i2c_client *client, int down)
+{
+ int pwr_dn = (down) ? 0x01 : 0x00;
+ DEBUG(1, "cx25840_set_low_power: %d %d\n", down, pwr_dn);
+ CX25840_SET_PWR_DN_CH1(pwr_dn);
+ // Don't change power to CH2 or CH3, since they are input-dependant
+ CX25840_SET_PWR_DN_ADC1(pwr_dn);
+ CX25840_SET_PWR_DN_ADC2(pwr_dn);
+ CX25840_SET_PWR_DN_DLL1(pwr_dn);
+ CX25840_SET_PWR_DN_DLL2(pwr_dn);
+ CX25840_SET_PWR_DN_TUNING(pwr_dn);
+}
+#endif
+
static int cx25840_command(struct i2c_client *client, unsigned int cmd,
void *arg)
{
@@ -642,7 +657,7 @@
break;
CX25840_SET_SOFT_RESET(0x0001);
- CX25840_SET_START_MICROCNTL(0x0000);
+ //CX25840_SET_START_MICROCNTL(0x0000);
switch (*iarg) {
case VIDEO_MODE_NTSC:
@@ -660,13 +675,13 @@
default:
DEBUG(1, "Unknown video mode!!!");
CX25840_SET_SOFT_RESET(0x0000);
- CX25840_SET_START_MICROCNTL(0x0001);
+ //CX25840_SET_START_MICROCNTL(0x0001);
return -EINVAL;
}
state->norm = *iarg;
CX25840_SET_SOFT_RESET(0x0000);
- CX25840_SET_START_MICROCNTL(0x0001);
+ //CX25840_SET_START_MICROCNTL(0x0001);
break;
}
@@ -692,7 +707,9 @@
DEBUG(1, "now setting Composite input");
CX25840_SET_CH_1__SOURCE(0x0002);
CX25840_SET_CH_2__SOURCE(0x0000);
+ CX25840_SET_PWR_DN_CH2(0x01);
CX25840_SET_CH_3__SOURCE(0x0000);
+ CX25840_SET_PWR_DN_CH3(0x00);
CX25840_SET_CH_SEL_ADC2(0x0001);
CX25840_SET_INPUT_MODE(0x0000);
break;
@@ -701,7 +718,9 @@
DEBUG(1, "now setting S-Video input");
CX25840_SET_CH_1__SOURCE(0x0000);
CX25840_SET_CH_2__SOURCE(0x0001);
+ CX25840_SET_PWR_DN_CH2(0x00);
CX25840_SET_CH_3__SOURCE(0x0000);
+ CX25840_SET_PWR_DN_CH3(0x01);
CX25840_SET_CH_SEL_ADC2(0x0000);
CX25840_SET_INPUT_MODE(0x0001);
CX25840_SET_VGA_SEL_CH2(0x00);
@@ -712,8 +731,10 @@
case CX25840_TUNER:
DEBUG(1, "now setting Tuner input");
CX25840_SET_CH_1__SOURCE(cardtype==1 ? 0x0001:0x0006);
- CX25840_SET_CH_2__SOURCE(0x0003);
+ CX25840_SET_CH_2__SOURCE(0x0000);
+ CX25840_SET_PWR_DN_CH2(0x01);
CX25840_SET_CH_3__SOURCE(0x0001);
+ CX25840_SET_PWR_DN_CH3(0x00);
CX25840_SET_CH_SEL_ADC2(0x0001);
CX25840_SET_INPUT_MODE(0x0000);
break;
@@ -772,7 +793,7 @@
DECODER_SET_VBI, &vbi_mode);
CX25840_SET_SOFT_RESET(0x0001);
- CX25840_SET_START_MICROCNTL(0x0000);
+ //CX25840_SET_START_MICROCNTL(0x0000);
cx25840_write(client, 0x0115,
(cx25840_read(client, 0x0115)|0x04));
@@ -780,10 +801,10 @@
(cx25840_read(client, 0x0116)|0x04));
CX25840_SET_SOFT_RESET(0x0000);
- CX25840_SET_START_MICROCNTL(0x0001);
+ //CX25840_SET_START_MICROCNTL(0x0001);
} else {
CX25840_SET_SOFT_RESET(0x0001);
- CX25840_SET_START_MICROCNTL(0x0000);
+ //CX25840_SET_START_MICROCNTL(0x0000);
cx25840_write(client, 0x0115,
(cx25840_read(client, 0x0115)&0xfb));
@@ -791,7 +812,7 @@
(cx25840_read(client, 0x0116)&0xfb));
CX25840_SET_SOFT_RESET(0x0000);
- CX25840_SET_START_MICROCNTL(0x0001);
+ //CX25840_SET_START_MICROCNTL(0x0001);
}
}
break;
@@ -862,7 +883,7 @@
for (x = 0; x <= 18; x++)
lcr[x] = 0x00;
- CX25840_SET_START_MICROCNTL(0x0000);
+ //CX25840_SET_START_MICROCNTL(0x0000);
/* Raw VBI */
if (set == 0) {
/*for (x = 0, i = 0x0424; i <= 0x0434; i++, x++) {
@@ -875,7 +896,7 @@
cx25840_write(client, 0x047F, vbi_offset);
cx25840_write(client, 0x0404, 0x2e);
- CX25840_SET_START_MICROCNTL(0x0001);
+ //CX25840_SET_START_MICROCNTL(0x0001);
break;
}
@@ -942,7 +963,7 @@
for (x = 1, i = 0x0424; i <= 0x0434; i++, x++) {
cx25840_write(client, i, lcr[x]);
}
- CX25840_SET_START_MICROCNTL(0x0001);
+ //CX25840_SET_START_MICROCNTL(0x0001);
break;
}
Index: ivtv/driver/cx25840-audio.c
===================================================================
--- ivtv/driver/cx25840-audio.c (revision 283)
+++ ivtv/driver/cx25840-audio.c (working copy)
@@ -11,7 +11,6 @@
if(audio_input <= 4) {
DEBUG(1, "set audio input (%d)", audio_input);
- CX25840_SET_SOFT_RESET(0x0001);
CX25840_SET_START_MICROCNTL(0x0000);
switch (audio_input) {
@@ -35,6 +34,8 @@
CX25840_SET_SA_MUTE_EN(0x0001);
CX25840_SET_SRC1_MUTE_EN(0x0000);
CX25840_SET_SOFT1_MUTE_EN(0x0001);
+
+ CX25840_SET_START_MICROCNTL(0x0001);
break;
case 1: // external line-in (???)
@@ -55,17 +56,14 @@
CX25840_SET_PATH1_AVC_RT(0x0001);
// 01
- CX25840_SET_AC97_MUTE_EN(0x0001);
- CX25840_SET_PAR_MUTE_EN(0x0001);
+ CX25840_SET_AC97_MUTE_EN(0x0000);
+ CX25840_SET_PAR_MUTE_EN(0x0000);
CX25840_SET_SA_MUTE_EN(0x0000);
- CX25840_SET_SRC1_MUTE_EN(0x0001);
+ CX25840_SET_SRC1_MUTE_EN(0x0000);
CX25840_SET_SOFT1_MUTE_EN(0x0001);
break;
}
- CX25840_SET_SOFT_RESET(0x0000);
- CX25840_SET_START_MICROCNTL(0x0001);
-
state->audio_input = audio_input;
return 0;
}
@@ -83,7 +81,6 @@
// assert soft reset
CX25840_SET_SOFT_RESET(0x0001);
- CX25840_SET_START_MICROCNTL(0x0000);
// common for all inputs and rates
CX25840_SET_VID_PLL_INT(0x000f);
@@ -260,7 +257,6 @@
// deassert soft reset
CX25840_SET_SOFT_RESET(0x0000);
- CX25840_SET_START_MICROCNTL(0x0001);
state->audio = audio;