diff mbox

cx25840 6.5MHz carrier detection fixes

Message ID 20090925211621.GA15452@moon (mailing list archive)
State Accepted
Headers show

Commit Message

Aleksandr V. Piskunov Sept. 25, 2009, 9:16 p.m. UTC
cx25840:
Disable 6.5MHz carrier autodetection for PAL, always assume its DK.
Only try to autodetect 6.5MHz carrier for SECAM if user accepts both
system DK and L.

Signed-off-by: Aleksandr V. Piskunov <alexandr.v.piskunov@gmail.com>


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Comments

Andy Walls Sept. 26, 2009, 8:12 p.m. UTC | #1
On Sat, 2009-09-26 at 00:16 +0300, Aleksandr V. Piskunov wrote:
> cx25840:
> Disable 6.5MHz carrier autodetection for PAL, always assume its DK.
> Only try to autodetect 6.5MHz carrier for SECAM if user accepts both
> system DK and L.
> 
> Signed-off-by: Aleksandr V. Piskunov <alexandr.v.piskunov@gmail.com>

Aleksandr,

I would like a little more time to look at your patch.

However, in the mean time, could you test the DK vs. L autodetection,
without your patch, using the cx25840 firmware in

http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware-20070217.tar.gz

?

The MD5 sum of that firmware is:

$ md5sum /lib/firmware/v4l-cx25840.fw 
99836e41ccb28c7b373e87686f93712a  /lib/firmware/v4l-cx25840.fw

The cx25840 firmware in

http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware-20080701.tar.gz
http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware.tar.gz

is probably wrong to use for the CX2584[0123] chips as it it actually
CX23148 A/V core firmware - very similar but not the same.


Hans or Axel,

Could one of you put the correct v4l-cx25840.fw image found in 

http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware-20070217.tar.gz

in the archive at:

http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware.tar.gz

?

The v4l-cx25840.fw image currently in that archive, which is actually
for the CX23418, is not good to use with CX2584[0123].


Regards,
Andy


> diff --git a/linux/drivers/media/video/cx25840/cx25840-core.c b/linux/drivers/media/video/cx25840/cx25840-core.c
> --- a/linux/drivers/media/video/cx25840/cx25840-core.c
> +++ b/linux/drivers/media/video/cx25840/cx25840-core.c
> @@ -647,13 +647,30 @@
>                 }
>                 cx25840_write(client, 0x80b, 0x00);
>         } else if (std & V4L2_STD_PAL) {
> -               /* Follow tuner change procedure for PAL */
> +               /* Autodetect audio standard and audio system */
>                 cx25840_write(client, 0x808, 0xff);
> -               cx25840_write(client, 0x80b, 0x10);
> +               /* Since system PAL-L is pretty much non-existant and
> +                  not used by any public broadcast network, force
> +                  6.5 MHz carrier to be interpreted as System DK,
> +                  this avoids DK audio detection instability */
> +               cx25840_write(client, 0x80b, 0x00);
>         } else if (std & V4L2_STD_SECAM) {
> -               /* Select autodetect for SECAM */
> +               /* Autodetect audio standard and audio system */
>                 cx25840_write(client, 0x808, 0xff);
> -               cx25840_write(client, 0x80b, 0x10);
> +               /* If only one of SECAM-DK / SECAM-L is required, then force
> +                  6.5MHz carrier, else autodetect it */
> +               if ((std & V4L2_STD_SECAM_DK) &&
> +                   !(std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) {
> +                       /* 6.5 MHz carrier to be interpreted as System DK */
> +                       cx25840_write(client, 0x80b, 0x00);
> +               } else if (!(std & V4L2_STD_SECAM_DK) &&
> +                          (std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) {
> +                       /* 6.5 MHz carrier to be interpreted as System L */
> +                       cx25840_write(client, 0x80b, 0x08);
> +               } else {
> +                       /* 6.5 MHz carrier to be autodetected */
> +                       cx25840_write(client, 0x80b, 0x10);
> +               }
>         }
> 
>         cx25840_and_or(client, 0x810, ~0x01, 0);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Aleksandr V. Piskunov Sept. 26, 2009, 10:21 p.m. UTC | #2
On Sat, Sep 26, 2009 at 04:12:59PM -0400, Andy Walls wrote:
> On Sat, 2009-09-26 at 00:16 +0300, Aleksandr V. Piskunov wrote:
> > cx25840:
> > Disable 6.5MHz carrier autodetection for PAL, always assume its DK.
> > Only try to autodetect 6.5MHz carrier for SECAM if user accepts both
> > system DK and L.
> > 
> > Signed-off-by: Aleksandr V. Piskunov <alexandr.v.piskunov@gmail.com>
> 
> Aleksandr,
> 
> I would like a little more time to look at your patch.

PAL part of the patch shouldn't affect any users IMHO, its the SECAM
part where we got SECAM-L users in France and SECAM-DK in Russia.

> 
> However, in the mean time, could you test the DK vs. L autodetection,
> without your patch, using the cx25840 firmware in
> 
> http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware-20070217.tar.gz
> 
> ?
> 
> The MD5 sum of that firmware is:
> 
> $ md5sum /lib/firmware/v4l-cx25840.fw 
> 99836e41ccb28c7b373e87686f93712a  /lib/firmware/v4l-cx25840.fw
> 
> The cx25840 firmware in
> 
> http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware-20080701.tar.gz
> http://dl.ivtvdriver.org/ivtv/firmware/ivtv-firmware.tar.gz
> 
> is probably wrong to use for the CX2584[0123] chips as it it actually
> CX23148 A/V core firmware - very similar but not the same.
> 

Tested following versions of v4l-cx25840.fw, no patch:

99836e41ccb28c7b373e87686f93712a
b3704908fd058485f3ef136941b2e513
647d818c6fc82f385ebfbbd4fb2def6d (comes as makoaudc.rom with win driver)

Same issue with all 3 versions of firmware tested, cold shutdown between
every test.
Quick description: PAL-DK source from cable, strong and clear signal.
On channel switch there are 3 typical outcomes
a) ~50% - DK audio system detected
b) ~40 - controller fails to detect standard, muted, may detect
   something later
c) ~10% - AM-L audio detected, playing some bogus static, may detect DK
   later

Of course there is a possibility that CX25843 doesn't like something
in IF that comes from xc2028 tuner, but as I said, signal ir very good
and picture/audio on every of 50+ channels is crisp and clear.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Andy Walls Sept. 27, 2009, 2:56 p.m. UTC | #3
On Sat, 2009-09-26 at 00:16 +0300, Aleksandr V. Piskunov wrote:
> cx25840:
> Disable 6.5MHz carrier autodetection for PAL, always assume its DK.
> Only try to autodetect 6.5MHz carrier for SECAM if user accepts both
> system DK and L.
> 
> Signed-off-by: Aleksandr V. Piskunov <alexandr.v.piskunov@gmail.com>

Aleksandr,

Looks good for CX2584[0123] chips.

It is not right for CX2388[578] or CX2310[12] chips, but the original
code doesn't do the right thing anyway for those chips, AFAICT.  In
those chips auto-detection of DK vs. L for 6.5 MHz sound carriers
doesn't appear to exist, and hence the bit positions and meanings have
changed slightly.  Your fix get us closer to doing the right thing for
those devices.  The rest of the fix for those devices is for another
day...

Reviewed-by: Andy Walls <awalls@radix.net>


> diff --git a/linux/drivers/media/video/cx25840/cx25840-core.c b/linux/drivers/media/video/cx25840/cx25840-core.c
> --- a/linux/drivers/media/video/cx25840/cx25840-core.c
> +++ b/linux/drivers/media/video/cx25840/cx25840-core.c
> @@ -647,13 +647,30 @@
>                 }
>                 cx25840_write(client, 0x80b, 0x00);
>         } else if (std & V4L2_STD_PAL) {
> -               /* Follow tuner change procedure for PAL */
> +               /* Autodetect audio standard and audio system */
>                 cx25840_write(client, 0x808, 0xff);
> -               cx25840_write(client, 0x80b, 0x10);
> +               /* Since system PAL-L is pretty much non-existant and
> +                  not used by any public broadcast network, force
> +                  6.5 MHz carrier to be interpreted as System DK,
> +                  this avoids DK audio detection instability */
> +               cx25840_write(client, 0x80b, 0x00);
>         } else if (std & V4L2_STD_SECAM) {
> -               /* Select autodetect for SECAM */
> +               /* Autodetect audio standard and audio system */
>                 cx25840_write(client, 0x808, 0xff);
> -               cx25840_write(client, 0x80b, 0x10);
> +               /* If only one of SECAM-DK / SECAM-L is required, then force
> +                  6.5MHz carrier, else autodetect it */
> +               if ((std & V4L2_STD_SECAM_DK) &&
> +                   !(std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) {
> +                       /* 6.5 MHz carrier to be interpreted as System DK */
> +                       cx25840_write(client, 0x80b, 0x00);
> +               } else if (!(std & V4L2_STD_SECAM_DK) &&
> +                          (std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) {
> +                       /* 6.5 MHz carrier to be interpreted as System L */
> +                       cx25840_write(client, 0x80b, 0x08);
> +               } else {
> +                       /* 6.5 MHz carrier to be autodetected */
> +                       cx25840_write(client, 0x80b, 0x10);
> +               }
>         }
> 
>         cx25840_and_or(client, 0x810, ~0x01, 0);
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/linux/drivers/media/video/cx25840/cx25840-core.c b/linux/drivers/media/video/cx25840/cx25840-core.c
--- a/linux/drivers/media/video/cx25840/cx25840-core.c
+++ b/linux/drivers/media/video/cx25840/cx25840-core.c
@@ -647,13 +647,30 @@ 
                }
                cx25840_write(client, 0x80b, 0x00);
        } else if (std & V4L2_STD_PAL) {
-               /* Follow tuner change procedure for PAL */
+               /* Autodetect audio standard and audio system */
                cx25840_write(client, 0x808, 0xff);
-               cx25840_write(client, 0x80b, 0x10);
+               /* Since system PAL-L is pretty much non-existant and
+                  not used by any public broadcast network, force
+                  6.5 MHz carrier to be interpreted as System DK,
+                  this avoids DK audio detection instability */
+               cx25840_write(client, 0x80b, 0x00);
        } else if (std & V4L2_STD_SECAM) {
-               /* Select autodetect for SECAM */
+               /* Autodetect audio standard and audio system */
                cx25840_write(client, 0x808, 0xff);
-               cx25840_write(client, 0x80b, 0x10);
+               /* If only one of SECAM-DK / SECAM-L is required, then force
+                  6.5MHz carrier, else autodetect it */
+               if ((std & V4L2_STD_SECAM_DK) &&
+                   !(std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) {
+                       /* 6.5 MHz carrier to be interpreted as System DK */
+                       cx25840_write(client, 0x80b, 0x00);
+               } else if (!(std & V4L2_STD_SECAM_DK) &&
+                          (std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC))) {
+                       /* 6.5 MHz carrier to be interpreted as System L */
+                       cx25840_write(client, 0x80b, 0x08);
+               } else {
+                       /* 6.5 MHz carrier to be autodetected */
+                       cx25840_write(client, 0x80b, 0x10);
+               }
        }

        cx25840_and_or(client, 0x810, ~0x01, 0);