18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci// tm6000-stds.c - driver for TM5600/TM6000/TM6010 USB video capture devices
38c2ecf20Sopenharmony_ci//
48c2ecf20Sopenharmony_ci// Copyright (c) 2007 Mauro Carvalho Chehab <mchehab@kernel.org>
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ci#include <linux/module.h>
78c2ecf20Sopenharmony_ci#include <linux/kernel.h>
88c2ecf20Sopenharmony_ci#include "tm6000.h"
98c2ecf20Sopenharmony_ci#include "tm6000-regs.h"
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_cistatic unsigned int tm6010_a_mode;
128c2ecf20Sopenharmony_cimodule_param(tm6010_a_mode, int, 0644);
138c2ecf20Sopenharmony_ciMODULE_PARM_DESC(tm6010_a_mode, "set tm6010 sif audio mode");
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_cistruct tm6000_reg_settings {
168c2ecf20Sopenharmony_ci	unsigned char req;
178c2ecf20Sopenharmony_ci	unsigned char reg;
188c2ecf20Sopenharmony_ci	unsigned char value;
198c2ecf20Sopenharmony_ci};
208c2ecf20Sopenharmony_ci
218c2ecf20Sopenharmony_ci
228c2ecf20Sopenharmony_cistruct tm6000_std_settings {
238c2ecf20Sopenharmony_ci	v4l2_std_id id;
248c2ecf20Sopenharmony_ci	struct tm6000_reg_settings *common;
258c2ecf20Sopenharmony_ci};
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings composite_pal_m[] = {
288c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
298c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x04 },
308c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e },
318c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
328c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00 },
338c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31 },
348c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e },
358c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83 },
368c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a },
378c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0 },
388c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
398c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
408c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
418c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
428c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88 },
438c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x20 },
448c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61 },
458c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c },
468c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c },
478c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52 },
488c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6f },
498c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc },
508c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
518c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
528c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
538c2ecf20Sopenharmony_ci};
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings composite_pal_nc[] = {
568c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
578c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x36 },
588c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e },
598c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
608c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02 },
618c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31 },
628c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e },
638c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91 },
648c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f },
658c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c },
668c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
678c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
688c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
698c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
708c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c },
718c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c },
728c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1 },
738c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c },
748c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c },
758c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52 },
768c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6f },
778c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc },
788c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
798c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
808c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
818c2ecf20Sopenharmony_ci};
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings composite_pal[] = {
848c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
858c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x32 },
868c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e },
878c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
888c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02 },
898c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31 },
908c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25 },
918c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5 },
928c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63 },
938c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50 },
948c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
958c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
968c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
978c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
988c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c },
998c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c },
1008c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1 },
1018c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c },
1028c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c },
1038c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52 },
1048c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6f },
1058c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc },
1068c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
1078c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
1088c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
1098c2ecf20Sopenharmony_ci};
1108c2ecf20Sopenharmony_ci
1118c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings composite_secam[] = {
1128c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
1138c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x38 },
1148c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e },
1158c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
1168c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x02 },
1178c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31 },
1188c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24 },
1198c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92 },
1208c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8 },
1218c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed },
1228c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
1238c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
1248c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
1258c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
1268c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c },
1278c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2c },
1288c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1 },
1298c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c },
1308c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18 },
1318c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42 },
1328c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xff },
1338c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
1348c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
1358c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
1368c2ecf20Sopenharmony_ci};
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings composite_ntsc[] = {
1398c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
1408c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x00 },
1418c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f },
1428c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
1438c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x00 },
1448c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31 },
1458c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e },
1468c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b },
1478c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2 },
1488c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9 },
1498c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
1508c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
1518c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
1528c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
1538c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88 },
1548c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22 },
1558c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61 },
1568c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c },
1578c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c },
1588c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42 },
1598c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6f },
1608c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd },
1618c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
1628c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
1638c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
1648c2ecf20Sopenharmony_ci};
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_cistatic struct tm6000_std_settings composite_stds[] = {
1678c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_PAL_M, .common = composite_pal_m, },
1688c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_PAL_Nc, .common = composite_pal_nc, },
1698c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_PAL, .common = composite_pal, },
1708c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_SECAM, .common = composite_secam, },
1718c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_NTSC, .common = composite_ntsc, },
1728c2ecf20Sopenharmony_ci};
1738c2ecf20Sopenharmony_ci
1748c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings svideo_pal_m[] = {
1758c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
1768c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x05 },
1778c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e },
1788c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
1798c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04 },
1808c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31 },
1818c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e },
1828c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x83 },
1838c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x0a },
1848c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe0 },
1858c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
1868c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
1878c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
1888c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
1898c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88 },
1908c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22 },
1918c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61 },
1928c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c },
1938c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c },
1948c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52 },
1958c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6f },
1968c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc },
1978c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
1988c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
1998c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
2008c2ecf20Sopenharmony_ci};
2018c2ecf20Sopenharmony_ci
2028c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings svideo_pal_nc[] = {
2038c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
2048c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x37 },
2058c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e },
2068c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
2078c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04 },
2088c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31 },
2098c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e },
2108c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x91 },
2118c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x1f },
2128c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x0c },
2138c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
2148c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
2158c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
2168c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
2178c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88 },
2188c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22 },
2198c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1 },
2208c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c },
2218c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c },
2228c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52 },
2238c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6f },
2248c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc },
2258c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
2268c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
2278c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
2288c2ecf20Sopenharmony_ci};
2298c2ecf20Sopenharmony_ci
2308c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings svideo_pal[] = {
2318c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
2328c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x33 },
2338c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e },
2348c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
2358c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x04 },
2368c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30 },
2378c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x25 },
2388c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0xd5 },
2398c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0x63 },
2408c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0x50 },
2418c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
2428c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
2438c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
2448c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
2458c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c },
2468c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a },
2478c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1 },
2488c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x0c },
2498c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c },
2508c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x52 },
2518c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6f },
2528c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdc },
2538c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
2548c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
2558c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
2568c2ecf20Sopenharmony_ci};
2578c2ecf20Sopenharmony_ci
2588c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings svideo_secam[] = {
2598c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
2608c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x39 },
2618c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0e },
2628c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
2638c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03 },
2648c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x31 },
2658c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x24 },
2668c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x92 },
2678c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xe8 },
2688c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xed },
2698c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
2708c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
2718c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
2728c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
2738c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x8c },
2748c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x2a },
2758c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0xc1 },
2768c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x2c },
2778c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x18 },
2788c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42 },
2798c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0xff },
2808c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
2818c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
2828c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
2838c2ecf20Sopenharmony_ci};
2848c2ecf20Sopenharmony_ci
2858c2ecf20Sopenharmony_cistatic struct tm6000_reg_settings svideo_ntsc[] = {
2868c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x01 },
2878c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R00_VIDEO_CONTROL0, 0x01 },
2888c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R01_VIDEO_CONTROL1, 0x0f },
2898c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R02_VIDEO_CONTROL2, 0x5f },
2908c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R03_YC_SEP_CONTROL, 0x03 },
2918c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R07_OUTPUT_CONTROL, 0x30 },
2928c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R17_HLOOP_MAXSTATE, 0x8b },
2938c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R18_CHROMA_DTO_INCREMENT3, 0x1e },
2948c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R19_CHROMA_DTO_INCREMENT2, 0x8b },
2958c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1A_CHROMA_DTO_INCREMENT1, 0xa2 },
2968c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1B_CHROMA_DTO_INCREMENT0, 0xe9 },
2978c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1C_HSYNC_DTO_INCREMENT3, 0x1c },
2988c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1D_HSYNC_DTO_INCREMENT2, 0xcc },
2998c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1E_HSYNC_DTO_INCREMENT1, 0xcc },
3008c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R1F_HSYNC_DTO_INCREMENT0, 0xcd },
3018c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R2E_ACTIVE_VIDEO_HSTART, 0x88 },
3028c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R30_ACTIVE_VIDEO_VSTART, 0x22 },
3038c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R31_ACTIVE_VIDEO_VHIGHT, 0x61 },
3048c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R33_VSYNC_HLOCK_MAX, 0x1c },
3058c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R35_VSYNC_AGC_MAX, 0x1c },
3068c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R82_COMB_FILTER_CONFIG, 0x42 },
3078c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R83_CHROMA_LOCK_CONFIG, 0x6f },
3088c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R04_LUMA_HAGC_CONTROL, 0xdd },
3098c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R0D_CHROMA_KILL_LEVEL, 0x07 },
3108c2ecf20Sopenharmony_ci	{ TM6010_REQ07_R3F_RESET, 0x00 },
3118c2ecf20Sopenharmony_ci	{ 0, 0, 0 }
3128c2ecf20Sopenharmony_ci};
3138c2ecf20Sopenharmony_ci
3148c2ecf20Sopenharmony_cistatic struct tm6000_std_settings svideo_stds[] = {
3158c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_PAL_M, .common = svideo_pal_m, },
3168c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_PAL_Nc, .common = svideo_pal_nc, },
3178c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_PAL, .common = svideo_pal, },
3188c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_SECAM, .common = svideo_secam, },
3198c2ecf20Sopenharmony_ci	{ .id = V4L2_STD_NTSC, .common = svideo_ntsc, },
3208c2ecf20Sopenharmony_ci};
3218c2ecf20Sopenharmony_ci
3228c2ecf20Sopenharmony_cistatic int tm6000_set_audio_std(struct tm6000_core *dev)
3238c2ecf20Sopenharmony_ci{
3248c2ecf20Sopenharmony_ci	uint8_t areg_02 = 0x04; /* GC1 Fixed gain 0dB */
3258c2ecf20Sopenharmony_ci	uint8_t areg_05 = 0x01; /* Auto 4.5 = M Japan, Auto 6.5 = DK */
3268c2ecf20Sopenharmony_ci	uint8_t areg_06 = 0x02; /* Auto de-emphasis, manual channel mode */
3278c2ecf20Sopenharmony_ci
3288c2ecf20Sopenharmony_ci	if (dev->radio) {
3298c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
3308c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, 0x04);
3318c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
3328c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0x80);
3338c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, 0x0c);
3348c2ecf20Sopenharmony_ci		/* set mono or stereo */
3358c2ecf20Sopenharmony_ci		if (dev->amode == V4L2_TUNER_MODE_MONO)
3368c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x00);
3378c2ecf20Sopenharmony_ci		else if (dev->amode == V4L2_TUNER_MODE_STEREO)
3388c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, 0x02);
3398c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x18);
3408c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x0a);
3418c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x40);
3428c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, 0xfe);
3438c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
3448c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
3458c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ07_RFE_POWER_DOWN, 0xff);
3468c2ecf20Sopenharmony_ci		return 0;
3478c2ecf20Sopenharmony_ci	}
3488c2ecf20Sopenharmony_ci
3498c2ecf20Sopenharmony_ci	/*
3508c2ecf20Sopenharmony_ci	 * STD/MN shouldn't be affected by tm6010_a_mode, as there's just one
3518c2ecf20Sopenharmony_ci	 * audio standard for each V4L2_STD type.
3528c2ecf20Sopenharmony_ci	 */
3538c2ecf20Sopenharmony_ci	if ((dev->norm & V4L2_STD_NTSC) == V4L2_STD_NTSC_M_KR) {
3548c2ecf20Sopenharmony_ci		areg_05 |= 0x04;
3558c2ecf20Sopenharmony_ci	} else if ((dev->norm & V4L2_STD_NTSC) == V4L2_STD_NTSC_M_JP) {
3568c2ecf20Sopenharmony_ci		areg_05 |= 0x43;
3578c2ecf20Sopenharmony_ci	} else if (dev->norm & V4L2_STD_MN) {
3588c2ecf20Sopenharmony_ci		areg_05 |= 0x22;
3598c2ecf20Sopenharmony_ci	} else switch (tm6010_a_mode) {
3608c2ecf20Sopenharmony_ci	/* auto */
3618c2ecf20Sopenharmony_ci	case 0:
3628c2ecf20Sopenharmony_ci		if ((dev->norm & V4L2_STD_SECAM) == V4L2_STD_SECAM_L)
3638c2ecf20Sopenharmony_ci			areg_05 |= 0x00;
3648c2ecf20Sopenharmony_ci		else	/* Other PAL/SECAM standards */
3658c2ecf20Sopenharmony_ci			areg_05 |= 0x10;
3668c2ecf20Sopenharmony_ci		break;
3678c2ecf20Sopenharmony_ci	/* A2 */
3688c2ecf20Sopenharmony_ci	case 1:
3698c2ecf20Sopenharmony_ci		if (dev->norm & V4L2_STD_DK)
3708c2ecf20Sopenharmony_ci			areg_05 = 0x09;
3718c2ecf20Sopenharmony_ci		else
3728c2ecf20Sopenharmony_ci			areg_05 = 0x05;
3738c2ecf20Sopenharmony_ci		break;
3748c2ecf20Sopenharmony_ci	/* NICAM */
3758c2ecf20Sopenharmony_ci	case 2:
3768c2ecf20Sopenharmony_ci		if (dev->norm & V4L2_STD_DK) {
3778c2ecf20Sopenharmony_ci			areg_05 = 0x06;
3788c2ecf20Sopenharmony_ci		} else if (dev->norm & V4L2_STD_PAL_I) {
3798c2ecf20Sopenharmony_ci			areg_05 = 0x08;
3808c2ecf20Sopenharmony_ci		} else if (dev->norm & V4L2_STD_SECAM_L) {
3818c2ecf20Sopenharmony_ci			areg_05 = 0x0a;
3828c2ecf20Sopenharmony_ci			areg_02 = 0x02;
3838c2ecf20Sopenharmony_ci		} else {
3848c2ecf20Sopenharmony_ci			areg_05 = 0x07;
3858c2ecf20Sopenharmony_ci		}
3868c2ecf20Sopenharmony_ci		break;
3878c2ecf20Sopenharmony_ci	/* other */
3888c2ecf20Sopenharmony_ci	case 3:
3898c2ecf20Sopenharmony_ci		if (dev->norm & V4L2_STD_DK) {
3908c2ecf20Sopenharmony_ci			areg_05 = 0x0b;
3918c2ecf20Sopenharmony_ci		} else {
3928c2ecf20Sopenharmony_ci			areg_05 = 0x02;
3938c2ecf20Sopenharmony_ci		}
3948c2ecf20Sopenharmony_ci		break;
3958c2ecf20Sopenharmony_ci	}
3968c2ecf20Sopenharmony_ci
3978c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x00);
3988c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R02_A_FIX_GAIN_CTRL, areg_02);
3998c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R03_A_AUTO_GAIN_CTRL, 0x00);
4008c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R04_A_SIF_AMP_CTRL, 0xa0);
4018c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R05_A_STANDARD_MOD, areg_05);
4028c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R06_A_SOUND_MOD, areg_06);
4038c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R07_A_LEFT_VOL, 0x00);
4048c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R08_A_RIGHT_VOL, 0x00);
4058c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R09_A_MAIN_VOL, 0x08);
4068c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R0A_A_I2S_MOD, 0x91);
4078c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R0B_A_ASD_THRES1, 0x20);
4088c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R0C_A_ASD_THRES2, 0x12);
4098c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R0D_A_AMD_THRES, 0x20);
4108c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R0E_A_MONO_THRES1, 0xf0);
4118c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R0F_A_MONO_THRES2, 0x80);
4128c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R10_A_MUTE_THRES1, 0xc0);
4138c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R11_A_MUTE_THRES2, 0x80);
4148c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R12_A_AGC_U, 0x12);
4158c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R13_A_AGC_ERR_T, 0xfe);
4168c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R14_A_AGC_GAIN_INIT, 0x20);
4178c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R15_A_AGC_STEP_THR, 0x14);
4188c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R16_A_AGC_GAIN_MAX, 0xfe);
4198c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R17_A_AGC_GAIN_MIN, 0x01);
4208c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R18_A_TR_CTRL, 0xa0);
4218c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R19_A_FH_2FH_GAIN, 0x32);
4228c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R1A_A_NICAM_SER_MAX, 0x64);
4238c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R1B_A_NICAM_SER_MIN, 0x20);
4248c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1c, 0x00);
4258c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, REQ_08_SET_GET_AVREG_BIT, 0x1d, 0x00);
4268c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R1E_A_GAIN_DEEMPH_OUT, 0x13);
4278c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R1F_A_TEST_INTF_SEL, 0x00);
4288c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R20_A_TEST_PIN_SEL, 0x00);
4298c2ecf20Sopenharmony_ci	tm6000_set_reg(dev, TM6010_REQ08_R01_A_INIT, 0x80);
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ci	return 0;
4328c2ecf20Sopenharmony_ci}
4338c2ecf20Sopenharmony_ci
4348c2ecf20Sopenharmony_civoid tm6000_get_std_res(struct tm6000_core *dev)
4358c2ecf20Sopenharmony_ci{
4368c2ecf20Sopenharmony_ci	/* Currently, those are the only supported resoltions */
4378c2ecf20Sopenharmony_ci	if (dev->norm & V4L2_STD_525_60)
4388c2ecf20Sopenharmony_ci		dev->height = 480;
4398c2ecf20Sopenharmony_ci	else
4408c2ecf20Sopenharmony_ci		dev->height = 576;
4418c2ecf20Sopenharmony_ci
4428c2ecf20Sopenharmony_ci	dev->width = 720;
4438c2ecf20Sopenharmony_ci}
4448c2ecf20Sopenharmony_ci
4458c2ecf20Sopenharmony_cistatic int tm6000_load_std(struct tm6000_core *dev, struct tm6000_reg_settings *set)
4468c2ecf20Sopenharmony_ci{
4478c2ecf20Sopenharmony_ci	int i, rc;
4488c2ecf20Sopenharmony_ci
4498c2ecf20Sopenharmony_ci	/* Load board's initialization table */
4508c2ecf20Sopenharmony_ci	for (i = 0; set[i].req; i++) {
4518c2ecf20Sopenharmony_ci		rc = tm6000_set_reg(dev, set[i].req, set[i].reg, set[i].value);
4528c2ecf20Sopenharmony_ci		if (rc < 0) {
4538c2ecf20Sopenharmony_ci			printk(KERN_ERR "Error %i while setting req %d, reg %d to value %d\n",
4548c2ecf20Sopenharmony_ci			       rc, set[i].req, set[i].reg, set[i].value);
4558c2ecf20Sopenharmony_ci			return rc;
4568c2ecf20Sopenharmony_ci		}
4578c2ecf20Sopenharmony_ci	}
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ci	return 0;
4608c2ecf20Sopenharmony_ci}
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ciint tm6000_set_standard(struct tm6000_core *dev)
4638c2ecf20Sopenharmony_ci{
4648c2ecf20Sopenharmony_ci	struct tm6000_input *input;
4658c2ecf20Sopenharmony_ci	int i, rc = 0;
4668c2ecf20Sopenharmony_ci	u8 reg_07_fe = 0x8a;
4678c2ecf20Sopenharmony_ci	u8 reg_08_f1 = 0xfc;
4688c2ecf20Sopenharmony_ci	u8 reg_08_e2 = 0xf0;
4698c2ecf20Sopenharmony_ci	u8 reg_08_e6 = 0x0f;
4708c2ecf20Sopenharmony_ci
4718c2ecf20Sopenharmony_ci	tm6000_get_std_res(dev);
4728c2ecf20Sopenharmony_ci
4738c2ecf20Sopenharmony_ci	if (!dev->radio)
4748c2ecf20Sopenharmony_ci		input = &dev->vinput[dev->input];
4758c2ecf20Sopenharmony_ci	else
4768c2ecf20Sopenharmony_ci		input = &dev->rinput;
4778c2ecf20Sopenharmony_ci
4788c2ecf20Sopenharmony_ci	if (dev->dev_type == TM6010) {
4798c2ecf20Sopenharmony_ci		switch (input->vmux) {
4808c2ecf20Sopenharmony_ci		case TM6000_VMUX_VIDEO_A:
4818c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf4);
4828c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1);
4838c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0);
4848c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2);
4858c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe8);
4868c2ecf20Sopenharmony_ci			reg_07_fe |= 0x01;
4878c2ecf20Sopenharmony_ci			break;
4888c2ecf20Sopenharmony_ci		case TM6000_VMUX_VIDEO_B:
4898c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xf8);
4908c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf1);
4918c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xe0);
4928c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2);
4938c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe8);
4948c2ecf20Sopenharmony_ci			reg_07_fe |= 0x01;
4958c2ecf20Sopenharmony_ci			break;
4968c2ecf20Sopenharmony_ci		case TM6000_VMUX_VIDEO_AB:
4978c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_RE3_ADC_IN1_SEL, 0xfc);
4988c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf8);
4998c2ecf20Sopenharmony_ci			reg_08_e6 = 0x00;
5008c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_REA_BUFF_DRV_CTRL, 0xf2);
5018c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_REB_SIF_GAIN_CTRL, 0xf0);
5028c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_REC_REVERSE_YC_CTRL, 0xc2);
5038c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_RED_GAIN_SEL, 0xe0);
5048c2ecf20Sopenharmony_ci			break;
5058c2ecf20Sopenharmony_ci		default:
5068c2ecf20Sopenharmony_ci			break;
5078c2ecf20Sopenharmony_ci		}
5088c2ecf20Sopenharmony_ci		switch (input->amux) {
5098c2ecf20Sopenharmony_ci		case TM6000_AMUX_ADC1:
5108c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
5118c2ecf20Sopenharmony_ci				0x00, 0x0f);
5128c2ecf20Sopenharmony_ci			/* Mux overflow workaround */
5138c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL,
5148c2ecf20Sopenharmony_ci				0x10, 0xf0);
5158c2ecf20Sopenharmony_ci			break;
5168c2ecf20Sopenharmony_ci		case TM6000_AMUX_ADC2:
5178c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
5188c2ecf20Sopenharmony_ci				0x08, 0x0f);
5198c2ecf20Sopenharmony_ci			/* Mux overflow workaround */
5208c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL,
5218c2ecf20Sopenharmony_ci				0x10, 0xf0);
5228c2ecf20Sopenharmony_ci			break;
5238c2ecf20Sopenharmony_ci		case TM6000_AMUX_SIF1:
5248c2ecf20Sopenharmony_ci			reg_08_e2 |= 0x02;
5258c2ecf20Sopenharmony_ci			reg_08_e6 = 0x08;
5268c2ecf20Sopenharmony_ci			reg_07_fe |= 0x40;
5278c2ecf20Sopenharmony_ci			reg_08_f1 |= 0x02;
5288c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf3);
5298c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
5308c2ecf20Sopenharmony_ci				0x02, 0x0f);
5318c2ecf20Sopenharmony_ci			/* Mux overflow workaround */
5328c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL,
5338c2ecf20Sopenharmony_ci				0x30, 0xf0);
5348c2ecf20Sopenharmony_ci			break;
5358c2ecf20Sopenharmony_ci		case TM6000_AMUX_SIF2:
5368c2ecf20Sopenharmony_ci			reg_08_e2 |= 0x02;
5378c2ecf20Sopenharmony_ci			reg_08_e6 = 0x08;
5388c2ecf20Sopenharmony_ci			reg_07_fe |= 0x40;
5398c2ecf20Sopenharmony_ci			reg_08_f1 |= 0x02;
5408c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6010_REQ08_RE4_ADC_IN2_SEL, 0xf7);
5418c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev, TM6010_REQ08_RF0_DAUDIO_INPUT_CONFIG,
5428c2ecf20Sopenharmony_ci				0x02, 0x0f);
5438c2ecf20Sopenharmony_ci			/* Mux overflow workaround */
5448c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev, TM6010_REQ07_R07_OUTPUT_CONTROL,
5458c2ecf20Sopenharmony_ci				0x30, 0xf0);
5468c2ecf20Sopenharmony_ci			break;
5478c2ecf20Sopenharmony_ci		default:
5488c2ecf20Sopenharmony_ci			break;
5498c2ecf20Sopenharmony_ci		}
5508c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_RE2_POWER_DOWN_CTRL1, reg_08_e2);
5518c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_RE6_POWER_DOWN_CTRL2, reg_08_e6);
5528c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ08_RF1_AADC_POWER_DOWN, reg_08_f1);
5538c2ecf20Sopenharmony_ci		tm6000_set_reg(dev, TM6010_REQ07_RFE_POWER_DOWN, reg_07_fe);
5548c2ecf20Sopenharmony_ci	} else {
5558c2ecf20Sopenharmony_ci		switch (input->vmux) {
5568c2ecf20Sopenharmony_ci		case TM6000_VMUX_VIDEO_A:
5578c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6000_REQ07_RE3_VADC_INP_LPF_SEL1, 0x10);
5588c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6000_REQ07_RE5_VADC_INP_LPF_SEL2, 0x00);
5598c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6000_REQ07_RE8_VADC_PWDOWN_CTL, 0x0f);
5608c2ecf20Sopenharmony_ci			tm6000_set_reg(dev,
5618c2ecf20Sopenharmony_ci			    REQ_03_SET_GET_MCU_PIN, input->v_gpio, 0);
5628c2ecf20Sopenharmony_ci			break;
5638c2ecf20Sopenharmony_ci		case TM6000_VMUX_VIDEO_B:
5648c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6000_REQ07_RE3_VADC_INP_LPF_SEL1, 0x00);
5658c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6000_REQ07_RE5_VADC_INP_LPF_SEL2, 0x00);
5668c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6000_REQ07_RE8_VADC_PWDOWN_CTL, 0x0f);
5678c2ecf20Sopenharmony_ci			tm6000_set_reg(dev,
5688c2ecf20Sopenharmony_ci			    REQ_03_SET_GET_MCU_PIN, input->v_gpio, 0);
5698c2ecf20Sopenharmony_ci			break;
5708c2ecf20Sopenharmony_ci		case TM6000_VMUX_VIDEO_AB:
5718c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6000_REQ07_RE3_VADC_INP_LPF_SEL1, 0x10);
5728c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6000_REQ07_RE5_VADC_INP_LPF_SEL2, 0x10);
5738c2ecf20Sopenharmony_ci			tm6000_set_reg(dev, TM6000_REQ07_RE8_VADC_PWDOWN_CTL, 0x00);
5748c2ecf20Sopenharmony_ci			tm6000_set_reg(dev,
5758c2ecf20Sopenharmony_ci			    REQ_03_SET_GET_MCU_PIN, input->v_gpio, 1);
5768c2ecf20Sopenharmony_ci			break;
5778c2ecf20Sopenharmony_ci		default:
5788c2ecf20Sopenharmony_ci			break;
5798c2ecf20Sopenharmony_ci		}
5808c2ecf20Sopenharmony_ci		switch (input->amux) {
5818c2ecf20Sopenharmony_ci		case TM6000_AMUX_ADC1:
5828c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev,
5838c2ecf20Sopenharmony_ci				TM6000_REQ07_REB_VADC_AADC_MODE, 0x00, 0x0f);
5848c2ecf20Sopenharmony_ci			break;
5858c2ecf20Sopenharmony_ci		case TM6000_AMUX_ADC2:
5868c2ecf20Sopenharmony_ci			tm6000_set_reg_mask(dev,
5878c2ecf20Sopenharmony_ci				TM6000_REQ07_REB_VADC_AADC_MODE, 0x04, 0x0f);
5888c2ecf20Sopenharmony_ci			break;
5898c2ecf20Sopenharmony_ci		default:
5908c2ecf20Sopenharmony_ci			break;
5918c2ecf20Sopenharmony_ci		}
5928c2ecf20Sopenharmony_ci	}
5938c2ecf20Sopenharmony_ci	if (input->type == TM6000_INPUT_SVIDEO) {
5948c2ecf20Sopenharmony_ci		for (i = 0; i < ARRAY_SIZE(svideo_stds); i++) {
5958c2ecf20Sopenharmony_ci			if (dev->norm & svideo_stds[i].id) {
5968c2ecf20Sopenharmony_ci				rc = tm6000_load_std(dev, svideo_stds[i].common);
5978c2ecf20Sopenharmony_ci				goto ret;
5988c2ecf20Sopenharmony_ci			}
5998c2ecf20Sopenharmony_ci		}
6008c2ecf20Sopenharmony_ci		return -EINVAL;
6018c2ecf20Sopenharmony_ci	} else {
6028c2ecf20Sopenharmony_ci		for (i = 0; i < ARRAY_SIZE(composite_stds); i++) {
6038c2ecf20Sopenharmony_ci			if (dev->norm & composite_stds[i].id) {
6048c2ecf20Sopenharmony_ci				rc = tm6000_load_std(dev, composite_stds[i].common);
6058c2ecf20Sopenharmony_ci				goto ret;
6068c2ecf20Sopenharmony_ci			}
6078c2ecf20Sopenharmony_ci		}
6088c2ecf20Sopenharmony_ci		return -EINVAL;
6098c2ecf20Sopenharmony_ci	}
6108c2ecf20Sopenharmony_ci
6118c2ecf20Sopenharmony_ciret:
6128c2ecf20Sopenharmony_ci	if (rc < 0)
6138c2ecf20Sopenharmony_ci		return rc;
6148c2ecf20Sopenharmony_ci
6158c2ecf20Sopenharmony_ci	if ((dev->dev_type == TM6010) &&
6168c2ecf20Sopenharmony_ci	    ((input->amux == TM6000_AMUX_SIF1) ||
6178c2ecf20Sopenharmony_ci	    (input->amux == TM6000_AMUX_SIF2)))
6188c2ecf20Sopenharmony_ci		tm6000_set_audio_std(dev);
6198c2ecf20Sopenharmony_ci
6208c2ecf20Sopenharmony_ci	msleep(40);
6218c2ecf20Sopenharmony_ci
6228c2ecf20Sopenharmony_ci	return 0;
6238c2ecf20Sopenharmony_ci}
624