Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] xc3028: fix center frequency calculation for DTV78 firmware

This patch replaces the previous one proposed in the thread "xc3028:
force reload of DTV7 firmware in VHF band with Zarlink demodulator",
at the linux-media@vger.kernel.org ML.

The problem is that the firmware DTV78 works fine in UHF band (8 MHz
bandwidth) but is not working at all in VHF band (7 MHz bandwidth).
Reading the comments inside the code, I figured out that the real
problem could be connected to the formula used to calculate the center
frequency offset in VHF band.

In fact, removing this adjustment fixes the problem:

if ((priv->cur_fw.type & DTV78) && freq < 470000000)
offset -= 500000;

This is coherent to what was implemented for the DTV7 firmware by an
Australian user:

if (priv->cur_fw.type & DTV7)
offset += 500000;

In the end, now the center frequency is the same for all firmwares
(DTV7, DTV8, DTV78) and doesn't depend on channel bandwidth.

The final code looks clean and simple, and there is no need for any
"magic" adjustment:

if (priv->cur_fw.type & DTV6)
offset = 1750000;
else /* DTV7 or DTV8 or DTV78 */
offset = 2750000;

Signed-off-by: Gianluca Gennari <gennarone@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Gianluca Gennari and committed by
Mauro Carvalho Chehab
98ab8550 0abffb94

+16 -10
+16 -10
drivers/media/common/tuners/tuner-xc2028.c
··· 962 962 * For DTV 7/8, the firmware uses BW = 8000, so it needs a 963 963 * further adjustment to get the frequency center on VHF 964 964 */ 965 + 966 + /* 967 + * The firmware DTV78 used to work fine in UHF band (8 MHz 968 + * bandwidth) but not at all in VHF band (7 MHz bandwidth). 969 + * The real problem was connected to the formula used to 970 + * calculate the center frequency offset in VHF band. 971 + * In fact, removing the 500KHz adjustment fixed the problem. 972 + * This is coherent to what was implemented for the DTV7 973 + * firmware. 974 + * In the end, now the center frequency is the same for all 3 975 + * firmwares (DTV7, DTV8, DTV78) and doesn't depend on channel 976 + * bandwidth. 977 + */ 978 + 965 979 if (priv->cur_fw.type & DTV6) 966 980 offset = 1750000; 967 - else if (priv->cur_fw.type & DTV7) 968 - offset = 2250000; 969 - else /* DTV8 or DTV78 */ 981 + else /* DTV7 or DTV8 or DTV78 */ 970 982 offset = 2750000; 971 - if ((priv->cur_fw.type & DTV78) && freq < 470000000) 972 - offset -= 500000; 973 983 974 984 /* 975 985 * xc3028 additional "magic" ··· 989 979 * newer firmwares 990 980 */ 991 981 992 - #if 1 993 982 /* 994 983 * The proper adjustment would be to do it at s-code table. 995 984 * However, this didn't work, as reported by 996 985 * Robert Lowery <rglowery@exemail.com.au> 997 986 */ 998 987 999 - if (priv->cur_fw.type & DTV7) 1000 - offset += 500000; 1001 - 1002 - #else 988 + #if 0 1003 989 /* 1004 990 * Still need tests for XC3028L (firmware 3.2 or upper) 1005 991 * So, for now, let's just comment the per-firmware