atv_demod: modify atv demod support multi tuner load [1/3]
authornengwen.chen <nengwen.chen@amlogic.com>
Wed, 9 Jan 2019 12:41:49 +0000 (20:41 +0800)
committerJianxin Pan <jianxin.pan@amlogic.com>
Mon, 18 Mar 2019 12:17:33 +0000 (04:17 -0800)
PD#TV-1539

Problem:
modify atv demod support multi tuner load.

Solution:
1.add fine tune.
2.add set/get if info.
3.add tuner type set/get.
4.add multi tuner config in dts.
5.atv demod ver: V2.09.

Verify:
verified by x301

Change-Id: I23328bfab3d3508db67cef3e327002563eb1a87e
Signed-off-by: nengwen.chen <nengwen.chen@amlogic.com>
36 files changed:
arch/arm/boot/dts/amlogic/tl1_pxp.dts
arch/arm/boot/dts/amlogic/tl1_t962x2_skt.dts
arch/arm/boot/dts/amlogic/tl1_t962x2_t309.dts
arch/arm/boot/dts/amlogic/tl1_t962x2_x301.dts
arch/arm/boot/dts/amlogic/txl_t950_p341.dts
arch/arm/boot/dts/amlogic/txl_t960_p346.dts
arch/arm/boot/dts/amlogic/txl_t962_p320.dts
arch/arm/boot/dts/amlogic/txl_t962_p321.dts
arch/arm/boot/dts/amlogic/txl_t962_p321_720p.dts
arch/arm/boot/dts/amlogic/txlx_t962e_r321.dts
arch/arm/boot/dts/amlogic/txlx_t962e_r321_buildroot.dts
arch/arm/boot/dts/amlogic/txlx_t962x_r311_1g.dts
arch/arm/boot/dts/amlogic/txlx_t962x_r311_2g.dts
arch/arm/boot/dts/amlogic/txlx_t962x_r311_720p.dts
arch/arm/boot/dts/amlogic/txlx_t962x_r314.dts
arch/arm64/boot/dts/amlogic/tl1_t962x2_t309.dts
arch/arm64/boot/dts/amlogic/tl1_t962x2_x301.dts
arch/arm64/boot/dts/amlogic/txl_t950_p341.dts
arch/arm64/boot/dts/amlogic/txl_t960_p346.dts
arch/arm64/boot/dts/amlogic/txl_t962_p320.dts
arch/arm64/boot/dts/amlogic/txl_t962_p321.dts
arch/arm64/boot/dts/amlogic/txl_t962_p321_720p.dts
arch/arm64/boot/dts/amlogic/txlx_t962e_r321.dts
arch/arm64/boot/dts/amlogic/txlx_t962e_r321_buildroot.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_1g.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_2g.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r311_720p.dts
arch/arm64/boot/dts/amlogic/txlx_t962x_r314.dts
drivers/amlogic/atv_demod/atv_demod_driver.c
drivers/amlogic/atv_demod/atv_demod_driver.h
drivers/amlogic/atv_demod/atv_demod_ops.c
drivers/amlogic/atv_demod/atv_demod_ops.h
drivers/amlogic/atv_demod/atv_demod_v4l2.c
drivers/amlogic/atv_demod/atv_demod_v4l2.h
drivers/amlogic/atv_demod/atvdemod_func.c
include/linux/amlogic/aml_atvdemod.h

index 10c2bfe..2093bc2 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c0>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <3>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c0>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <3>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(3)
                                         */
-               tuner_xtal_cap = <25>; /* when tuner_xtal_mode = 3, set 25 */
+               tuner_xtal_cap_0 = <25>; /* when tuner_xtal_mode = 3, set 25 */
        };
 
        atv-demod {
index 4921204..028d8a8 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c0>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <0>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c0>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <0>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(3)
                                         */
-               tuner_xtal_cap = <25>; /* when tuner_xtal_mode = 3, set 25 */
+               tuner_xtal_cap_0 = <25>; /* when tuner_xtal_mode = 3, set 25 */
        };
 
        atv-demod {
index 0581714..bec1a97 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c0>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c0>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <38>; /* when tuner_xtal_mode = 3, set 25 */
+               tuner_xtal_cap_0 = <38>; /* when tuner_xtal_mode = 3, set 25 */
        };
 
        atv-demod {
index cc63381..a5913c3 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c0>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <3>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c0>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <3>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(3)
                                         */
-               tuner_xtal_cap = <25>; /* when tuner_xtal_mode = 3, set 25 */
+               tuner_xtal_cap_0 = <25>; /* when tuner_xtal_mode = 3, set 25 */
        };
 
        atv-demod {
index 15ff9f5..9e1a530 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
-               tuner_xtal_mode = <3>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
+               tuner_xtal_mode_0 = <3>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <0>; /* 0 ~ 41 (pf) */
+               tuner_xtal_cap_0 = <0>; /* 0 ~ 41 (pf) */
        };
 
        atv-demod {
index aebfe42..61b671d 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
-               tuner_xtal_mode = <3>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
+               tuner_xtal_mode_0 = <3>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <0>; /* 0 ~ 41 (pf) */
+               tuner_xtal_cap_0 = <0>; /* 0 ~ 41 (pf) */
        };
 
        atv-demod {
index 7da1261..ecd169a 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "si2151_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               /* tuner_xtal = <0>; */ /* unuse for si2151 */
-               /* tuner_xtal_mode = <0>; */
-               /* tuner_xtal_cap = <0>; */
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "si2151_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               /* tuner_xtal_0 = <0>; */ /* unuse for si2151 */
+               /* tuner_xtal_mode_0 = <0>; */
+               /* tuner_xtal_cap_0 = <0>; */
        };
 
        atv-demod {
index e11afc2..78f91e2 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <38>; /* 0 ~ 41 (pf) */
+               tuner_xtal_cap_0 = <38>; /* 0 ~ 41 (pf) */
        };
 
        atv-demod {
index d0ae1ba..e40940b 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <38>; /* 0 ~ 41 (pf) */
+               tuner_xtal_cap_0 = <38>; /* 0 ~ 41 (pf) */
        };
 
        atv-demod {
index 05a3a8b..852b21a 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "si2151_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               /* tuner_xtal = <0>; */ /* unuse for si2151 */
-               /* tuner_xtal_mode = <0>; */
-               /* tuner_xtal_cap = <0>; */
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "si2151_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               /* tuner_xtal_0 = <0>; */ /* unuse for si2151 */
+               /* tuner_xtal_mode_0 = <0>; */
+               /* tuner_xtal_cap_0 = <0>; */
        };
 
        atv-demod {
index 2aa7588..7567223 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "si2151_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               /* tuner_xtal = <0>; */ /* unuse for si2151 */
-               /* tuner_xtal_mode = <0>; */
-               /* tuner_xtal_cap = <0>; */
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "si2151_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               /* tuner_xtal_0 = <0>; */ /* unuse for si2151 */
+               /* tuner_xtal_mode_0 = <0>; */
+               /* tuner_xtal_cap_0 = <0>; */
        };
 
        atv-demod {
index d40e6f0..2f6c3d6 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <0>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <0>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(1)
                                         */
-               tuner_xtal_cap = <30>; /* when tuner_xtal_mode = 1, set 25 */
+               tuner_xtal_cap_0 = <30>; /* when tuner_xtal_mode = 1, set 25 */
        };
 
        atv-demod {
index 261102d..b550763 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <0>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <0>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(1)
                                         */
-               tuner_xtal_cap = <30>; /* when tuner_xtal_mode = 1, set 25 */
+               tuner_xtal_cap_0 = <30>; /* when tuner_xtal_mode = 1, set 25 */
        };
 
        atv-demod {
index b35156d..14a3f55 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <0>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <0>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(1)
                                         */
-               tuner_xtal_cap = <30>; /* when tuner_xtal_mode = 1, set 25 */
+               tuner_xtal_cap_0 = <30>; /* when tuner_xtal_mode = 1, set 25 */
        };
 
        atv-demod {
index eb5a9c4..f3827f4 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "disabled";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <0>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <0>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(1)
                                         */
-               tuner_xtal_cap = <30>; /* when tuner_xtal_mode = 1, set 25 */
+               tuner_xtal_cap_0 = <30>; /* when tuner_xtal_mode = 1, set 25 */
        };
 
        atv-demod {
index 03660b4..8d99594 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c0>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c0>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <38>; /* when tuner_xtal_mode = 3, set 25 */
+               tuner_xtal_cap_0 = <38>; /* when tuner_xtal_mode = 3, set 25 */
        };
 
        atv-demod {
index c30924a..7006bcb 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c0>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <3>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c0>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <3>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(3)
                                         */
-               tuner_xtal_cap = <25>; /* when tuner_xtal_mode = 3, set 25 */
+               tuner_xtal_cap_0 = <25>; /* when tuner_xtal_mode = 3, set 25 */
        };
 
        atv-demod {
index 64028ec..9f4ed5e 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
-               tuner_xtal_mode = <3>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
+               tuner_xtal_mode_0 = <3>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <0>; /* 0 ~ 41 (pf) */
+               tuner_xtal_cap_0 = <0>; /* 0 ~ 41 (pf) */
        };
 
        atv-demod {
index b6a0896..8afac0d 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
-               tuner_xtal_mode = <3>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
+               tuner_xtal_mode_0 = <3>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <0>; /* 0 ~ 41 (pf) */
+               tuner_xtal_cap_0 = <0>; /* 0 ~ 41 (pf) */
        };
 
        atv-demod {
index 2ed7d17..e3d205b 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "si2151_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               /* tuner_xtal = <0>; */ /* unuse for si2151 */
-               /* tuner_xtal_mode = <0>; */
-               /* tuner_xtal_cap = <0>; */
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "si2151_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               /* tuner_xtal_0 = <0>; */ /* unuse for si2151 */
+               /* tuner_xtal_mode_0 = <0>; */
+               /* tuner_xtal_cap_0 = <0>; */
        };
 
        atv-demod {
index e2d776e..09ea7f8 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <38>; /* 0 ~ 41 (pf) */
+               tuner_xtal_cap_0 = <38>; /* 0 ~ 41 (pf) */
        };
 
        atv-demod {
index 3872619..cb5e8ef 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "r842_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0xf6>;
-               tuner_xtal = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "r842_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0xf6>;
+               tuner_xtal_0 = <1>; /* 0: 16MHz, 1: 24MHz, 3: 27MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * MASTER_TO_SLAVE_XTAL_IN(1)
                                         * MASTER_TO_SLAVE_XTAL_OUT(2)
                                         * SLAVE_XTAL_OUT(3)
                                         */
-               tuner_xtal_cap = <38>; /* 0 ~ 41 (pf) */
+               tuner_xtal_cap_0 = <38>; /* 0 ~ 41 (pf) */
        };
 
        atv-demod {
index 7d6b5a8..b9bad64 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "si2151_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               /* tuner_xtal = <0>; */ /* unuse for si2151 */
-               /* tuner_xtal_mode = <0>; */
-               /* tuner_xtal_cap = <0>; */
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "si2151_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               /* tuner_xtal_0 = <0>; */ /* unuse for si2151 */
+               /* tuner_xtal_mode_0 = <0>; */
+               /* tuner_xtal_cap_0 = <0>; */
        };
 
        atv-demod {
index d0f142b..27d6b6f 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "si2151_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               /* tuner_xtal = <0>; */ /* unuse for si2151 */
-               /* tuner_xtal_mode = <0>; */
-               /* tuner_xtal_cap = <0>; */
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "si2151_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               /* tuner_xtal_0 = <0>; */ /* unuse for si2151 */
+               /* tuner_xtal_mode_0 = <0>; */
+               /* tuner_xtal_cap_0 = <0>; */
        };
 
        atv-demod {
index 02ab284..2bb09c9 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <0>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <0>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(1)
                                         */
-               tuner_xtal_cap = <30>; /* when tuner_xtal_mode = 1, set 25 */
+               tuner_xtal_cap_0 = <30>; /* when tuner_xtal_mode = 1, set 25 */
        };
 
        atv-demod {
index 9bc18c9..7201861 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <0>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <0>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(1)
                                         */
-               tuner_xtal_cap = <30>; /* when tuner_xtal_mode = 1, set 25 */
+               tuner_xtal_cap_0 = <30>; /* when tuner_xtal_mode = 1, set 25 */
        };
 
        atv-demod {
index 987345c..16ff8e5 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "okay";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <0>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <0>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(1)
                                         */
-               tuner_xtal_cap = <30>; /* when tuner_xtal_mode = 1, set 25 */
+               tuner_xtal_cap_0 = <30>; /* when tuner_xtal_mode = 1, set 25 */
        };
 
        atv-demod {
index c1a5363..3c25f45 100644 (file)
        tuner: tuner {
                compatible = "amlogic, tuner";
                status = "disabled";
-               tuner_name = "mxl661_tuner";
-               tuner_i2c_adap = <&i2c1>;
-               tuner_i2c_addr = <0x60>;
-               tuner_xtal = <0>; /* 0: 16MHz, 1: 24MHz */
-               tuner_xtal_mode = <0>;
+               tuner_cur = <0>; /* default use tuner */
+               tuner_num = <1>; /* tuner number, multi tuner support */
+               tuner_name_0 = "mxl661_tuner";
+               tuner_i2c_adap_0 = <&i2c1>;
+               tuner_i2c_addr_0 = <0x60>;
+               tuner_xtal_0 = <0>; /* 0: 16MHz, 1: 24MHz */
+               tuner_xtal_mode_0 = <0>;
                                        /* NO_SHARE_XTAL(0)
                                         * SLAVE_XTAL_SHARE(1)
                                         */
-               tuner_xtal_cap = <30>; /* when tuner_xtal_mode = 1, set 25 */
+               tuner_xtal_cap_0 = <30>; /* when tuner_xtal_mode = 1, set 25 */
        };
 
        atv-demod {
index c9da1c2..c16cd6a 100644 (file)
@@ -45,7 +45,7 @@
 #include "atvauddemod_func.h"
 
 
-#define AMLATVDEMOD_VER "V2.08"
+#define AMLATVDEMOD_VER "V2.09"
 
 struct aml_atvdemod_device *amlatvdemod_devp;
 
@@ -66,7 +66,7 @@ static ssize_t aml_atvdemod_store(struct class *class,
        unsigned long tmp = 0, data = 0;
        struct aml_atvdemod_device *dev =
                        container_of(class, struct aml_atvdemod_device, cls);
-       struct atv_demod_priv *priv = dev->v4l2_fe.fe.analog_demod_priv;
+       /*struct atv_demod_priv *priv = dev->v4l2_fe.fe.analog_demod_priv;*/
 
        buf_orig = kstrdup(buf, GFP_KERNEL);
        ps = buf_orig;
@@ -82,11 +82,12 @@ static ssize_t aml_atvdemod_store(struct class *class,
 
        if (parm[0] == NULL)
                goto EXIT;
-
+#if 0
        if (priv->state != ATVDEMOD_STATE_WORK) {
                pr_info("atvdemod_state not work  ....\n");
                goto EXIT;
        }
+#endif
 
        if (!strncmp(parm[0], "init", 4)) {
                ret = atv_demod_enter_mode(&dev->v4l2_fe.fe);
@@ -274,6 +275,7 @@ static ssize_t aml_atvdemod_store(struct class *class,
                struct analog_parameters params;
                struct v4l2_analog_parameters *p = NULL;
                unsigned int std = 0;
+               unsigned int freq = 0;
 
                fe = &dev->v4l2_fe.fe;
                p = &dev->v4l2_fe.params;
@@ -283,7 +285,12 @@ static ssize_t aml_atvdemod_store(struct class *class,
                else
                        std = p->std;
 
-               params.frequency = p->frequency;
+               if (parm[2] && kstrtoul(parm[2], 0, &tmp) == 0)
+                       freq = tmp;
+               else
+                       freq = p->frequency;
+
+               params.frequency = freq;
                params.mode = p->afc_range;
                params.audmode = p->audmode;
                params.std = std;
@@ -313,11 +320,40 @@ static ssize_t aml_atvdemod_store(struct class *class,
                                v4l2_std_to_str((0xffffff & dev->std)));
                pr_info("[atvdemod] audmode: 0x%x\n", dev->audmode);
                pr_info("[atvdemod] flag: %d\n", p->flag);
-               pr_info("[atvdemod] tuner_id: %d\n", dev->tuner_id);
+               pr_info("[atvdemod] tuner_cur: %d\n", dev->tuner_cur);
+               pr_info("[atvdemod] tuner_id: %d\n",
+                               dev->tuners[dev->tuner_cur].cfg.id);
                pr_info("[atvdemod] if_freq: %d\n", dev->if_freq);
                pr_info("[atvdemod] if_inv: %d\n", dev->if_inv);
                pr_info("[atvdemod] fre_offset: %d\n", dev->fre_offset);
                pr_info("[atvdemod] version: %s.\n", AMLATVDEMOD_VER);
+       } else if (!strncmp(parm[0], "attach_tuner", 12)) {
+               int tuner_id = 0;
+
+               if (parm[1] && kstrtoul(parm[1], 10, &tmp) == 0) {
+                       val = tmp;
+
+                       for (i = 0; i < dev->tuner_num; ++i) {
+                               if (dev->tuners[i].cfg.id == val) {
+                                       tuner_id = dev->tuners[i].cfg.id;
+                                       break;
+                               }
+                       }
+
+                       if (tuner_id == 0 || dev->tuner_cur == i) {
+                               pr_err("%s: set nonsupport or the same tuner %d.\n",
+                                               __func__, val);
+                               goto EXIT;
+                       }
+
+                       dev->tuner_cur = i;
+
+                       ret = aml_attach_tuner(dev);
+                       if (ret)
+                               pr_info("attach_tuner error.\n");
+                       else
+                               pr_info("attach_tuner %d done.\n", tuner_id);
+               }
        } else
                pr_dbg("invalid command\n");
 
@@ -353,7 +389,9 @@ static void aml_atvdemod_dt_parse(struct aml_atvdemod_device *pdev)
        struct device_node *node_i2c = NULL;
        unsigned int val = 0;
        const char *str = NULL;
+       char buf[20] = { 0 };
        int ret = 0;
+       int i = 0;
 
        node = pdev->dev->of_node;
        if (node == NULL) {
@@ -385,8 +423,7 @@ static void aml_atvdemod_dt_parse(struct aml_atvdemod_device *pdev)
                pdev->agc_pin = NULL;
                pr_err("can't find agc pinmux.\n");
        } else {
-               pr_err("atvdemod agc pinmux name: %s\n",
-                               pdev->pin_name);
+               pr_err("atvdemod agc pinmux name: %s\n", pdev->pin_name);
        }
 
        ret = of_property_read_u32(node, "btsc_sap_mode", &val);
@@ -397,119 +434,176 @@ static void aml_atvdemod_dt_parse(struct aml_atvdemod_device *pdev)
 
        /* get tuner config node */
        node_tuner = of_parse_phandle(node, "tuner", 0);
-       if (node_tuner) {
-               ret = of_property_read_string(node_tuner, "tuner_name", &str);
-               if (ret)
-                       pr_err("can't find tuner.\n");
+       if (!node_tuner) {
+               pr_err("can't find tuner node.\n");
+               return;
+       }
+
+       ret = of_property_read_u32(node_tuner, "tuner_num", &val);
+       if (ret == 0)
+               pdev->tuner_num = val;
+       else {
+               pr_err("can't find tuner_num.\n");
+               return;
+       }
+
+       pdev->tuners = kcalloc(pdev->tuner_num, sizeof(struct aml_tuner),
+                       GFP_KERNEL);
+       if (!pdev->tuners) {
+               /* pr_err("can't kcalloc for tuners.\n"); */
+               return;
+       }
+
+       ret = of_property_read_u32(node_tuner, "tuner_cur", &val);
+       if (ret) {
+               pr_err("can't find tuner_cur, use default 0.\n");
+               pdev->tuner_cur = -1;
+       } else
+               pdev->tuner_cur = val;
+
+       for (i = 0; i < pdev->tuner_num; ++i) {
+               snprintf(buf, sizeof(buf), "tuner_name_%d", i);
+               ret = of_property_read_string(node_tuner, buf, &str);
+               if (ret) {
+                       pr_err("can't find tuner %d.\n", i);
+                       continue;
+               }
+
+               if (!strncmp(str, "mxl661_tuner", 12))
+                       pdev->tuners[i].cfg.id = AM_TUNER_MXL661;
+               else if (!strncmp(str, "si2151_tuner", 12))
+                       pdev->tuners[i].cfg.id = AM_TUNER_SI2151;
+               else if (!strncmp(str, "si2159_tuner", 12))
+                       pdev->tuners[i].cfg.id = AM_TUNER_SI2159;
+               else if (!strncmp(str, "r840_tuner", 10))
+                       pdev->tuners[i].cfg.id = AM_TUNER_R840;
+               else if (!strncmp(str, "r842_tuner", 10))
+                       pdev->tuners[i].cfg.id = AM_TUNER_R842;
                else {
-                       if (!strncmp(str, "mxl661_tuner", 12))
-                               pdev->tuner_id = AM_TUNER_MXL661;
-                       else if (!strncmp(str, "si2151_tuner", 12))
-                               pdev->tuner_id = AM_TUNER_SI2151;
-                       else if (!strncmp(str, "si2159_tuner", 12))
-                               pdev->tuner_id = AM_TUNER_SI2159;
-                       else if (!strncmp(str, "r840_tuner", 10))
-                               pdev->tuner_id = AM_TUNER_R840;
-                       else if (!strncmp(str, "r842_tuner", 10))
-                               pdev->tuner_id = AM_TUNER_R842;
-                       else
-                               pr_err("nonsupport tuner: %s.\n", str);
+                       pr_err("can't support tuner: %s.\n", str);
+                       pdev->tuners[i].cfg.id = AM_TUNER_NONE;
                }
 
-               node_i2c = of_parse_phandle(node_tuner, "tuner_i2c_adap", 0);
+               snprintf(buf, sizeof(buf), "tuner_i2c_adap_%d", i);
+               node_i2c = of_parse_phandle(node_tuner, buf, 0);
                if (node_i2c) {
-                       pdev->i2c_adp = of_find_i2c_adapter_by_node(node_i2c);
+                       pdev->tuners[i].i2c_adp =
+                                       of_find_i2c_adapter_by_node(node_i2c);
                        of_node_put(node_i2c);
 
-                       if (!pdev->i2c_adp)
+                       if (!pdev->tuners[i].i2c_adp)
                                pr_err("can't find tuner_i2c_adap.\n");
                }
 
-               ret = of_property_read_u32(node_tuner, "tuner_i2c_addr", &val);
+               snprintf(buf, sizeof(buf), "tuner_i2c_addr_%d", i);
+               ret = of_property_read_u32(node_tuner, buf, &val);
                if (ret)
                        pr_err("can't find tuner_i2c_addr.\n");
                else
-                       pdev->i2c_addr = val;
+                       pdev->tuners[i].cfg.i2c_addr = val;
 
-               ret = of_property_read_u32(node_tuner, "tuner_xtal", &val);
+               snprintf(buf, sizeof(buf), "tuner_xtal_%d", i);
+               ret = of_property_read_u32(node_tuner, buf, &val);
                if (ret)
                        pr_err("can't find tuner_xtal.\n");
                else
-                       pdev->tuner_xtal = val;
+                       pdev->tuners[i].cfg.xtal = val;
 
-               ret = of_property_read_u32(node_tuner, "tuner_xtal_mode", &val);
+               snprintf(buf, sizeof(buf), "tuner_xtal_mode_%d", i);
+               ret = of_property_read_u32(node_tuner, buf, &val);
                if (ret)
                        pr_err("can't find tuner_xtal_mode.\n");
                else
-                       pdev->tuner_xtal_mode = val;
+                       pdev->tuners[i].cfg.xtal_mode = val;
 
-               ret = of_property_read_u32(node_tuner, "tuner_xtal_cap", &val);
+               snprintf(buf, sizeof(buf), "tuner_xtal_cap_%d", i);
+               ret = of_property_read_u32(node_tuner, buf, &val);
                if (ret)
                        pr_err("can't find tuner_xtal_cap.\n");
                else
-                       pdev->tuner_xtal_cap = val;
+                       pdev->tuners[i].cfg.xtal_cap = val;
 
-               of_node_put(node_tuner);
+               pr_err("find tuner %d.\n", i);
        }
+
+       of_node_put(node_tuner);
 }
 
-int aml_attach_demod_tuner(struct aml_atvdemod_device *dev)
+int aml_attach_demod(struct aml_atvdemod_device *dev)
 {
        void *p = NULL;
        struct v4l2_frontend *v4l2_fe = &dev->v4l2_fe;
        struct dvb_frontend *fe = &v4l2_fe->fe;
-       struct tuner_config cfg = { 0 };
 
-       if (!dev->analog_attached) {
-               p = v4l2_attach(aml_atvdemod_attach, fe, v4l2_fe,
-                               dev->i2c_adp, dev->i2c_addr, dev->tuner_id);
-               if (p != NULL)
-                       dev->analog_attached = true;
-               else {
-                       pr_err("%s: attach demod error.\n", __func__);
-                       return -1;
-               }
+       if (dev->tuner_cur < 0) {
+               pr_err("%s: dev->tuner_cur [%d] error.\n",
+                               __func__, dev->tuner_cur);
+               return -1;
        }
 
-       p = NULL;
+       p = v4l2_attach(aml_atvdemod_attach, fe, v4l2_fe,
+                               dev->tuners[dev->tuner_cur].i2c_adp,
+                               dev->tuners[dev->tuner_cur].cfg.i2c_addr,
+                               dev->tuners[dev->tuner_cur].cfg.id);
+       if (p != NULL)
+               dev->analog_attached = true;
+       else {
+               pr_err("%s: attach demod error.\n", __func__);
+               return -1;
+       }
 
-       cfg.id = dev->tuner_id;
-       cfg.i2c_addr = dev->i2c_addr;
-       cfg.xtal = dev->tuner_xtal;
-       cfg.xtal_mode = dev->tuner_xtal_mode;
-       cfg.xtal_cap = dev->tuner_xtal_cap;
+       return 0;
+}
 
-       if (!dev->tuner_attached) {
-               switch (dev->tuner_id) {
-               case AM_TUNER_R840:
-                       p = v4l2_attach(r840_attach, fe,
-                                       dev->i2c_adp, &cfg);
-                       break;
-               case AM_TUNER_R842:
-                       p = v4l2_attach(r842_attach, fe,
-                                       dev->i2c_adp, &cfg);
-                       break;
-               case AM_TUNER_SI2151:
-                       p = v4l2_attach(si2151_attach, fe,
-                                       dev->i2c_adp, &cfg);
-                       break;
-               case AM_TUNER_SI2159:
-                       p = v4l2_attach(si2159_attach, fe,
-                                       dev->i2c_adp, &cfg);
-                       break;
-               case AM_TUNER_MXL661:
-                       p = v4l2_attach(mxl661_attach, fe,
-                                       dev->i2c_adp, &cfg);
-                       break;
-               }
+int aml_attach_tuner(struct aml_atvdemod_device *dev)
+{
+       void *p = NULL;
+       struct v4l2_frontend *v4l2_fe = &dev->v4l2_fe;
+       struct dvb_frontend *fe = &v4l2_fe->fe;
+       struct tuner_config *cfg = NULL;
 
-               if (p != NULL)
-                       dev->tuner_attached = true;
-               else {
-                       pr_err("%s: attach tuner [%d] error.\n",
-                                       __func__, dev->tuner_id);
-                       return -1;
-               }
+       if (dev->tuner_cur < 0) {
+               pr_err("%s: dev->tuner_cur [%d] error.\n",
+                               __func__, dev->tuner_cur);
+               return -1;
+       }
+
+       cfg = &dev->tuners[dev->tuner_cur].cfg;
+
+       switch (cfg->id) {
+       case AM_TUNER_R840:
+               p = v4l2_attach(r840_attach, fe,
+                               dev->tuners[dev->tuner_cur].i2c_adp, cfg);
+               break;
+       case AM_TUNER_R842:
+               p = v4l2_attach(r842_attach, fe,
+                               dev->tuners[dev->tuner_cur].i2c_adp, cfg);
+               break;
+       case AM_TUNER_SI2151:
+               p = v4l2_attach(si2151_attach, fe,
+                               dev->tuners[dev->tuner_cur].i2c_adp, cfg);
+               break;
+       case AM_TUNER_SI2159:
+               p = v4l2_attach(si2159_attach, fe,
+                               dev->tuners[dev->tuner_cur].i2c_adp, cfg);
+               break;
+       case AM_TUNER_MXL661:
+               p = v4l2_attach(mxl661_attach, fe,
+                               dev->tuners[dev->tuner_cur].i2c_adp, cfg);
+               break;
+       default:
+               pr_err("%s: Nonsupport tuner [%d].\n", __func__, cfg->id);
+               break;
+       }
+
+       if (p != NULL) {
+               dev->tuner_attached = true;
+               v4l2_fe->tuner_id = cfg->id;
+               v4l2_fe->i2c.addr = cfg->i2c_addr;
+               v4l2_fe->i2c.adapter = dev->tuners[dev->tuner_cur].i2c_adp;
+       } else {
+               pr_err("%s: attach tuner [%d] error.\n", __func__, cfg->id);
+               return -1;
        }
 
        return 0;
@@ -634,12 +728,11 @@ static int aml_atvdemod_probe(struct platform_device *pdev)
 
        aml_atvdemod_dt_parse(dev);
 
-       aml_attach_demod_tuner(dev);
+       aml_attach_demod(dev);
+       aml_attach_tuner(dev);
 
        dev->v4l2_fe.dev = dev->dev;
-       dev->v4l2_fe.tuner_id = dev->tuner_id;
-       dev->v4l2_fe.i2c.addr = dev->i2c_addr;
-       dev->v4l2_fe.i2c.adapter = dev->i2c_adp;
+
        ret = v4l2_resister_frontend(&dev->v4l2_fe);
        if (ret < 0) {
                pr_err("resister v4l2 fail.\n");
@@ -658,6 +751,7 @@ fail_register_v4l2:
 fail_get_resource:
        class_unregister(&dev->cls);
 fail_class_register:
+       kfree(dev->tuners);
        kfree(dev);
 
        pr_info("%s: fail.\n", __func__);
@@ -679,6 +773,7 @@ static int aml_atvdemod_remove(struct platform_device *pdev)
 
        amlatvdemod_devp = NULL;
 
+       kfree(dev->tuners);
        kfree(dev);
 
        pr_info("%s: OK.\n", __func__);
index d4ac1ef..60a3685 100644 (file)
@@ -38,18 +38,20 @@ struct aml_atvdemod_parameters {
        unsigned int reserved;
 };
 
+struct aml_tuner {
+       struct tuner_config cfg;
+       unsigned int i2c_adapter_id;
+       struct i2c_adapter *i2c_adp;
+};
+
 struct aml_atvdemod_device {
        char *name;
        struct class cls;
        struct device *dev;
 
-       unsigned int tuner_id;
-       unsigned int tuner_xtal;
-       unsigned int tuner_xtal_mode;
-       unsigned int tuner_xtal_cap;
-       unsigned int i2c_addr;
-       unsigned int i2c_adapter_id;
-       struct i2c_adapter *i2c_adp;
+       unsigned int tuner_num;
+       int tuner_cur;
+       struct aml_tuner *tuners;
 
        unsigned int if_freq;
        unsigned int if_inv;
@@ -94,6 +96,7 @@ struct aml_atvdemod_device {
 
 extern struct aml_atvdemod_device *amlatvdemod_devp;
 
-extern int aml_attach_demod_tuner(struct aml_atvdemod_device *dev);
+extern int aml_attach_demod(struct aml_atvdemod_device *dev);
+extern int aml_attach_tuner(struct aml_atvdemod_device *dev);
 
 #endif /* __ATV_DEMOD_DRIVER_H__ */
index f783cf0..49cb204 100644 (file)
@@ -256,14 +256,12 @@ static void atv_demod_set_params(struct dvb_frontend *fe,
                amlatvdemod_devp->std != p->param.std ||
                amlatvdemod_devp->audmode != p->param.audmode ||
                amlatvdemod_devp->if_freq != p->if_freq ||
-               amlatvdemod_devp->if_inv != p->if_inv ||
-               amlatvdemod_devp->tuner_id != p->tuner_id) {
+               amlatvdemod_devp->if_inv != p->if_inv) {
 
                amlatvdemod_devp->std = p->param.std;
                amlatvdemod_devp->audmode = p->param.audmode;
                amlatvdemod_devp->if_freq = p->if_freq;
                amlatvdemod_devp->if_inv = p->if_inv;
-               amlatvdemod_devp->tuner_id = p->tuner_id;
 
                atv_dmd_set_std();
                atvdemod_init(!priv->scanning);
@@ -873,7 +871,11 @@ static int atvdemod_fe_set_property(struct v4l2_frontend *v4l2_fe,
                break;
 
        case V4L2_SLOW_SEARCH_MODE:
-               tvp->data = slow_mode;
+               slow_mode = tvp->data;
+               break;
+
+       case V4L2_SIF_OVER_MODULATION:
+               priv->sound_sys.sif_over_modulation = tvp->data;
                break;
 
        default:
@@ -898,7 +900,7 @@ static int atvdemod_fe_get_property(struct v4l2_frontend *v4l2_fe,
                break;
 
        case V4L2_SLOW_SEARCH_MODE:
-               slow_mode = tvp->data;
+               tvp->data = slow_mode;
                break;
 
        default:
index 775c5ec..8417722 100644 (file)
@@ -49,6 +49,7 @@ struct atv_demod_sound_system {
        unsigned int audio_std;
        unsigned int input_mode;
        unsigned int output_mode;
+       int sif_over_modulation;
 };
 
 struct atv_demod_priv {
index 4844750..7e4fb01 100644 (file)
@@ -456,12 +456,11 @@ static int v4l2_frontend_read_status(struct v4l2_frontend *v4l2_fe,
 
        if (!status)
                return -1;
-#if 0
-       if (analog_ops->tuner_status)
-               analog_ops->tuner_status(&v4l2_fe->fe, status);
+
+       if (analog_ops->has_signal)
+               analog_ops->has_signal(&v4l2_fe->fe, (u16 *) status);
        else if (tuner_ops->get_status)
-               tuner_ops->get_status(&v4l2_fe->fe, status);
-#endif
+               tuner_ops->get_status(&v4l2_fe->fe, (u32 *) status);
 
        return ret;
 }
@@ -538,6 +537,10 @@ static int v4l2_property_process_set(struct v4l2_frontend *v4l2_fe,
                struct v4l2_property *tvp, struct file *file)
 {
        int r = 0;
+#if 0
+       int i = 0;
+       int id = 0;
+#endif
        struct v4l2_analog_parameters *params = &v4l2_fe->params;
 
        v4l2_property_dump(v4l2_fe, true, tvp);
@@ -548,6 +551,7 @@ static int v4l2_property_process_set(struct v4l2_frontend *v4l2_fe,
                break;
        case V4L2_SOUND_SYS:
        case V4L2_SLOW_SEARCH_MODE:
+       case V4L2_SIF_OVER_MODULATION:
                /* Allow the frontend to override outgoing properties */
                if (v4l2_fe->ops.set_property) {
                        r = v4l2_fe->ops.set_property(v4l2_fe, tvp);
@@ -569,6 +573,45 @@ static int v4l2_property_process_set(struct v4l2_frontend *v4l2_fe,
                                        | (params->audmode);
                }
                break;
+       case V4L2_FINE_TUNE:
+               params->frequency += tvp->data;
+               break;
+       case V4L2_TUNER_TYPE:
+#if 0 /* This supports dynamically setting the tuner type */
+               for (i = 0; i < amlatvdemod_devp->tuner_num; ++i) {
+                       if (amlatvdemod_devp->tuners[i].cfg.id == tvp->data) {
+                               id = amlatvdemod_devp->tuners[i].cfg.id;
+                               break;
+                       }
+               }
+
+               if (id == 0) {
+                       pr_err("%s: nonsupport tuner %d.\n",
+                                       __func__, tvp->data);
+                       return -EINVAL;
+               }
+
+               if (amlatvdemod_devp->tuner_cur == i) {
+                       pr_err("%s: the same tuner %d.\n",
+                                       __func__, i);
+                       break;
+               }
+
+               if (amlatvdemod_devp->tuner_attached) {
+                       if (v4l2_fe->fe.ops.tuner_ops.release)
+                               v4l2_fe->fe.ops.tuner_ops.release(&v4l2_fe->fe);
+               }
+
+               v4l2_fe->tuner_id = id;
+               if (aml_attach_tuner(amlatvdemod_devp) < 0) {
+                       pr_err("%s: attach tuner %d error.\n",
+                                       __func__, id);
+                       return -EINVAL;
+               }
+#endif
+               break;
+       case V4L2_TUNER_IF_FREQ:
+               break;
        default:
                return -EINVAL;
        }
@@ -580,6 +623,7 @@ static int v4l2_property_process_get(struct v4l2_frontend *v4l2_fe,
                struct v4l2_property *tvp, struct file *file)
 {
        int r = 0;
+       int i = 0;
        struct v4l2_analog_parameters *params = &v4l2_fe->params;
 
        switch (tvp->cmd) {
@@ -600,6 +644,18 @@ static int v4l2_property_process_get(struct v4l2_frontend *v4l2_fe,
                /* std & 0x00FFFFFF: audio std */
                tvp->data = params->std;
                break;
+       case V4L2_TUNER_TYPE:
+               i = amlatvdemod_devp->tuner_cur;
+               if (i < 0) {
+                       pr_err("%s: Has not been set tuner type.\n", __func__);
+                       tvp->data = 0;
+                       return -EINVAL;
+               }
+               tvp->data = amlatvdemod_devp->tuners[i].cfg.id;
+               break;
+       case V4L2_TUNER_IF_FREQ:
+               tvp->data = amlatvdemod_devp->if_freq;
+               break;
        default:
                pr_dbg("%s: V4L2 property %d doesn't exist\n",
                                __func__, tvp->cmd);
@@ -764,11 +820,19 @@ static int v4l2_frontend_open(struct file *filp)
        struct v4l2_frontend_private *fepriv = v4l2_fe->frontend_priv;
 
        /* Because tuner ko insmod after demod, so need check */
-       if (!amlatvdemod_devp->tuner_attached
-                       || !amlatvdemod_devp->analog_attached) {
-               ret = aml_attach_demod_tuner(amlatvdemod_devp);
+       if (!amlatvdemod_devp->analog_attached) {
+               ret = aml_attach_demod(amlatvdemod_devp);
+               if (ret < 0) {
+                       pr_err("%s: attach demod %d error.\n",
+                                       __func__, v4l2_fe->tuner_id);
+                       return -EBUSY;
+               }
+       }
+
+       if (!amlatvdemod_devp->tuner_attached) {
+               ret = aml_attach_tuner(amlatvdemod_devp);
                if (ret < 0) {
-                       pr_err("%s: attach demod or tuner %d error.\n",
+                       pr_err("%s: attach tuner %d error.\n",
                                        __func__, v4l2_fe->tuner_id);
                        return -EBUSY;
                }
index ba31acc..6fc3078 100644 (file)
 #define V4L2_SLOW_SEARCH_MODE    3
 #define V4L2_FREQUENCY           4
 #define V4L2_STD                 5
+#define V4L2_FINE_TUNE           6
+#define V4L2_SIF_OVER_MODULATION 7
+#define V4L2_TUNER_TYPE          8
+#define V4L2_TUNER_IF_FREQ       9
 
 struct v4l2_frontend;
 
index efb7378..a4a9f9d 100644 (file)
@@ -201,8 +201,10 @@ void atv_dmd_misc(void)
        atv_dmd_wr_byte(APB_BLOCK_ADDR_VDAGC, 0x45, 0x90);      /*zhuangwei*/
 
        atv_dmd_wr_long(APB_BLOCK_ADDR_VDAGC, 0x44, 0x5c8808c1);/*zhuangwei*/
-       if (amlatvdemod_devp->tuner_id == AM_TUNER_R840 ||
-               amlatvdemod_devp->tuner_id == AM_TUNER_R842) {
+       if (amlatvdemod_devp->tuners[amlatvdemod_devp->tuner_cur].cfg.id
+                       == AM_TUNER_R840 ||
+               amlatvdemod_devp->tuners[amlatvdemod_devp->tuner_cur].cfg.id
+                       == AM_TUNER_R842) {
                /*zhuangwei*/
                atv_dmd_wr_long(APB_BLOCK_ADDR_VDAGC, 0x3c, reg_23cf);
                /*guanzhong@20150804a*/
@@ -230,7 +232,8 @@ void atv_dmd_misc(void)
                atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0x08, 0x46170200);
        }
 
-       if (amlatvdemod_devp->tuner_id == AM_TUNER_MXL661) {
+       if (amlatvdemod_devp->tuners[amlatvdemod_devp->tuner_cur].cfg.id
+                       == AM_TUNER_MXL661) {
                /*test in sky*/
                atv_dmd_wr_long(APB_BLOCK_ADDR_DAC_UPS, 0x04, 0xbffa0000);
                atv_dmd_wr_long(APB_BLOCK_ADDR_DAC_UPS, 0x00, 0x6f4000);
@@ -1020,8 +1023,10 @@ void configure_receiver(int Broadcast_Standard, unsigned int Tuner_IF_Frequency,
                atv_dmd_wr_long(APB_BLOCK_ADDR_ADC_SE, 0x0, 0x03180e0f);
        else
                atv_dmd_wr_long(APB_BLOCK_ADDR_ADC_SE, 0x0, 0x03150e0f);
-       if (amlatvdemod_devp->tuner_id == AM_TUNER_R840 ||
-               amlatvdemod_devp->tuner_id == AM_TUNER_R842) {
+       if (amlatvdemod_devp->tuners[amlatvdemod_devp->tuner_cur].cfg.id
+                       == AM_TUNER_R840 ||
+               amlatvdemod_devp->tuners[amlatvdemod_devp->tuner_cur].cfg.id
+                       == AM_TUNER_R842) {
                /*config pwm for tuner r840*/
                atv_dmd_wr_byte(APB_BLOCK_ADDR_ADC_SE, 1, 0xf);
        }
@@ -1298,8 +1303,10 @@ void configure_receiver(int Broadcast_Standard, unsigned int Tuner_IF_Frequency,
        atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0x04, 0xc8);
        /*26 dB dynamic range*/
        atv_dmd_wr_byte(APB_BLOCK_ADDR_AGC_PWM, 0x09, 0xa);
-       if (amlatvdemod_devp->tuner_id == AM_TUNER_R840 ||
-               amlatvdemod_devp->tuner_id == AM_TUNER_R842) {
+       if (amlatvdemod_devp->tuners[amlatvdemod_devp->tuner_cur].cfg.id
+                       == AM_TUNER_R840 ||
+               amlatvdemod_devp->tuners[amlatvdemod_devp->tuner_cur].cfg.id
+                       == AM_TUNER_R842) {
                /*config pwm for tuner r840*/
                atv_dmd_wr_long(APB_BLOCK_ADDR_AGC_PWM, 0, 0xc80);
                /* guanzhong for Tuner AGC shock */
@@ -1990,6 +1997,8 @@ void atvdemod_uninit(void)
 void atv_dmd_set_std(void)
 {
        v4l2_std_id ptstd = amlatvdemod_devp->std;
+       int tuner_index = amlatvdemod_devp->tuner_cur;
+       int tuner_id = amlatvdemod_devp->tuners[tuner_index].cfg.id;
 
        /* set broad standard of tuner*/
        if (((ptstd & V4L2_COLOR_STD_PAL)
@@ -2066,11 +2075,11 @@ void atv_dmd_set_std(void)
        }
 
        /* Tuner returns the if and signal inverted states */
-       if ((amlatvdemod_devp->tuner_id == AM_TUNER_R840) ||
-               (amlatvdemod_devp->tuner_id == AM_TUNER_R842) ||
-               (amlatvdemod_devp->tuner_id == AM_TUNER_SI2151) ||
-               (amlatvdemod_devp->tuner_id == AM_TUNER_SI2159) ||
-               (amlatvdemod_devp->tuner_id == AM_TUNER_MXL661)) {
+       if ((tuner_id == AM_TUNER_R840) ||
+               (tuner_id == AM_TUNER_R842) ||
+               (tuner_id == AM_TUNER_SI2151) ||
+               (tuner_id == AM_TUNER_SI2159) ||
+               (tuner_id == AM_TUNER_MXL661)) {
                if_freq = amlatvdemod_devp->if_freq;
                if_inv = amlatvdemod_devp->if_inv;
        }
index 29519f0..ad6914a 100644 (file)
@@ -124,6 +124,7 @@ extern void aml_fe_get_atvaudio_state(int *state);
 
 /* For attach tuner driver start*/
 enum tuner_type {
+       AM_TUNER_NONE = 0,
        AM_TUNER_SI2176 = 1,
        AM_TUNER_SI2196 = 2,
        AM_TUNER_FQ1216 = 3,