forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-10-22 8ac6c7a54ed1b98d142dce24b11c6de6a1e239a5
kernel/drivers/media/usb/pvrusb2/pvrusb2-devattr.c
....@@ -1,17 +1,7 @@
1
+// SPDX-License-Identifier: GPL-2.0-only
12 /*
23 *
3
- *
44 * Copyright (C) 2007 Mike Isely <isely@pobox.com>
5
- *
6
- * This program is free software; you can redistribute it and/or modify
7
- * it under the terms of the GNU General Public License as published by
8
- * the Free Software Foundation; either version 2 of the License
9
- *
10
- * This program is distributed in the hope that it will be useful,
11
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
- * GNU General Public License for more details.
14
- *
155 */
166
177 /*
....@@ -37,6 +27,9 @@
3727 #include "tda18271.h"
3828 #include "tda8290.h"
3929 #include "tuner-simple.h"
30
+#include "si2157.h"
31
+#include "lgdt3306a.h"
32
+#include "si2168.h"
4033 #endif
4134
4235
....@@ -188,10 +181,10 @@
188181
189182 static int pvr2_lgdt3303_attach(struct pvr2_dvb_adapter *adap)
190183 {
191
- adap->fe = dvb_attach(lgdt330x_attach, &pvr2_lgdt3303_config,
192
- 0x0e,
193
- &adap->channel.hdw->i2c_adap);
194
- if (adap->fe)
184
+ adap->fe[0] = dvb_attach(lgdt330x_attach, &pvr2_lgdt3303_config,
185
+ 0x0e,
186
+ &adap->channel.hdw->i2c_adap);
187
+ if (adap->fe[0])
195188 return 0;
196189
197190 return -EIO;
....@@ -199,7 +192,7 @@
199192
200193 static int pvr2_lgh06xf_attach(struct pvr2_dvb_adapter *adap)
201194 {
202
- dvb_attach(simple_tuner_attach, adap->fe,
195
+ dvb_attach(simple_tuner_attach, adap->fe[0],
203196 &adap->channel.hdw->i2c_adap, 0x61,
204197 TUNER_LG_TDVS_H06XF);
205198
....@@ -248,10 +241,10 @@
248241
249242 static int pvr2_lgdt3302_attach(struct pvr2_dvb_adapter *adap)
250243 {
251
- adap->fe = dvb_attach(lgdt330x_attach, &pvr2_lgdt3302_config,
252
- 0x0e,
253
- &adap->channel.hdw->i2c_adap);
254
- if (adap->fe)
244
+ adap->fe[0] = dvb_attach(lgdt330x_attach, &pvr2_lgdt3302_config,
245
+ 0x0e,
246
+ &adap->channel.hdw->i2c_adap);
247
+ if (adap->fe[0])
255248 return 0;
256249
257250 return -EIO;
....@@ -259,7 +252,7 @@
259252
260253 static int pvr2_fcv1236d_attach(struct pvr2_dvb_adapter *adap)
261254 {
262
- dvb_attach(simple_tuner_attach, adap->fe,
255
+ dvb_attach(simple_tuner_attach, adap->fe[0],
263256 &adap->channel.hdw->i2c_adap, 0x61,
264257 TUNER_PHILIPS_FCV1236D);
265258
....@@ -335,9 +328,9 @@
335328
336329 static int pvr2_tda10048_attach(struct pvr2_dvb_adapter *adap)
337330 {
338
- adap->fe = dvb_attach(tda10048_attach, &hauppauge_tda10048_config,
339
- &adap->channel.hdw->i2c_adap);
340
- if (adap->fe)
331
+ adap->fe[0] = dvb_attach(tda10048_attach, &hauppauge_tda10048_config,
332
+ &adap->channel.hdw->i2c_adap);
333
+ if (adap->fe[0])
341334 return 0;
342335
343336 return -EIO;
....@@ -345,10 +338,10 @@
345338
346339 static int pvr2_73xxx_tda18271_8295_attach(struct pvr2_dvb_adapter *adap)
347340 {
348
- dvb_attach(tda829x_attach, adap->fe,
341
+ dvb_attach(tda829x_attach, adap->fe[0],
349342 &adap->channel.hdw->i2c_adap, 0x42,
350343 &tda829x_no_probe);
351
- dvb_attach(tda18271_attach, adap->fe, 0x60,
344
+ dvb_attach(tda18271_attach, adap->fe[0], 0x60,
352345 &adap->channel.hdw->i2c_adap,
353346 &hauppauge_tda18271_dvb_config);
354347
....@@ -433,9 +426,9 @@
433426
434427 static int pvr2_s5h1409_attach(struct pvr2_dvb_adapter *adap)
435428 {
436
- adap->fe = dvb_attach(s5h1409_attach, &pvr2_s5h1409_config,
437
- &adap->channel.hdw->i2c_adap);
438
- if (adap->fe)
429
+ adap->fe[0] = dvb_attach(s5h1409_attach, &pvr2_s5h1409_config,
430
+ &adap->channel.hdw->i2c_adap);
431
+ if (adap->fe[0])
439432 return 0;
440433
441434 return -EIO;
....@@ -443,9 +436,9 @@
443436
444437 static int pvr2_s5h1411_attach(struct pvr2_dvb_adapter *adap)
445438 {
446
- adap->fe = dvb_attach(s5h1411_attach, &pvr2_s5h1411_config,
447
- &adap->channel.hdw->i2c_adap);
448
- if (adap->fe)
439
+ adap->fe[0] = dvb_attach(s5h1411_attach, &pvr2_s5h1411_config,
440
+ &adap->channel.hdw->i2c_adap);
441
+ if (adap->fe[0])
449442 return 0;
450443
451444 return -EIO;
....@@ -453,10 +446,10 @@
453446
454447 static int pvr2_tda18271_8295_attach(struct pvr2_dvb_adapter *adap)
455448 {
456
- dvb_attach(tda829x_attach, adap->fe,
449
+ dvb_attach(tda829x_attach, adap->fe[0],
457450 &adap->channel.hdw->i2c_adap, 0x42,
458451 &tda829x_no_probe);
459
- dvb_attach(tda18271_attach, adap->fe, 0x60,
452
+ dvb_attach(tda18271_attach, adap->fe[0], 0x60,
460453 &adap->channel.hdw->i2c_adap,
461454 &hauppauge_tda18271_config);
462455
....@@ -525,7 +518,166 @@
525518 #endif
526519 };
527520
521
+/*------------------------------------------------------------------------*/
522
+/* Hauppauge PVR-USB2 Model 160000 / 160111 -- HVR-1955 / HVR-1975 */
528523
524
+#ifdef CONFIG_VIDEO_PVRUSB2_DVB
525
+static int pvr2_si2157_attach(struct pvr2_dvb_adapter *adap);
526
+static int pvr2_si2168_attach(struct pvr2_dvb_adapter *adap);
527
+static int pvr2_dual_fe_attach(struct pvr2_dvb_adapter *adap);
528
+static int pvr2_lgdt3306a_attach(struct pvr2_dvb_adapter *adap);
529
+
530
+static const struct pvr2_dvb_props pvr2_160000_dvb_props = {
531
+ .frontend_attach = pvr2_dual_fe_attach,
532
+ .tuner_attach = pvr2_si2157_attach,
533
+};
534
+
535
+static const struct pvr2_dvb_props pvr2_160111_dvb_props = {
536
+ .frontend_attach = pvr2_lgdt3306a_attach,
537
+ .tuner_attach = pvr2_si2157_attach,
538
+};
539
+
540
+static int pvr2_si2157_attach(struct pvr2_dvb_adapter *adap)
541
+{
542
+ struct si2157_config si2157_config = {};
543
+
544
+ si2157_config.inversion = 1;
545
+ si2157_config.fe = adap->fe[0];
546
+
547
+ adap->i2c_client_tuner = dvb_module_probe("si2157", "si2177",
548
+ &adap->channel.hdw->i2c_adap,
549
+ 0x60, &si2157_config);
550
+
551
+ if (!adap->i2c_client_tuner)
552
+ return -ENODEV;
553
+
554
+ return 0;
555
+}
556
+
557
+static int pvr2_si2168_attach(struct pvr2_dvb_adapter *adap)
558
+{
559
+ struct si2168_config si2168_config = {};
560
+ struct i2c_adapter *adapter;
561
+
562
+ pr_debug("%s()\n", __func__);
563
+
564
+ si2168_config.fe = &adap->fe[1];
565
+ si2168_config.i2c_adapter = &adapter;
566
+ si2168_config.ts_mode = SI2168_TS_PARALLEL; /*2, 1-serial, 2-parallel.*/
567
+ si2168_config.ts_clock_gapped = 1; /*0-disabled, 1-enabled.*/
568
+ si2168_config.ts_clock_inv = 0; /*0-not-invert, 1-invert*/
569
+ si2168_config.spectral_inversion = 1; /*0-not-invert, 1-invert*/
570
+
571
+ adap->i2c_client_demod[1] = dvb_module_probe("si2168", NULL,
572
+ &adap->channel.hdw->i2c_adap,
573
+ 0x64, &si2168_config);
574
+
575
+ if (!adap->i2c_client_demod[1])
576
+ return -ENODEV;
577
+
578
+ return 0;
579
+}
580
+
581
+static int pvr2_lgdt3306a_attach(struct pvr2_dvb_adapter *adap)
582
+{
583
+ struct lgdt3306a_config lgdt3306a_config;
584
+ struct i2c_adapter *adapter;
585
+
586
+ pr_debug("%s()\n", __func__);
587
+
588
+ lgdt3306a_config.fe = &adap->fe[0];
589
+ lgdt3306a_config.i2c_adapter = &adapter;
590
+ lgdt3306a_config.deny_i2c_rptr = 1;
591
+ lgdt3306a_config.spectral_inversion = 1;
592
+ lgdt3306a_config.qam_if_khz = 4000;
593
+ lgdt3306a_config.vsb_if_khz = 3250;
594
+ lgdt3306a_config.mpeg_mode = LGDT3306A_MPEG_PARALLEL;
595
+ lgdt3306a_config.tpclk_edge = LGDT3306A_TPCLK_FALLING_EDGE;
596
+ lgdt3306a_config.tpvalid_polarity = LGDT3306A_TP_VALID_LOW;
597
+ lgdt3306a_config.xtalMHz = 25, /* demod clock MHz; 24/25 supported */
598
+
599
+ adap->i2c_client_demod[0] = dvb_module_probe("lgdt3306a", NULL,
600
+ &adap->channel.hdw->i2c_adap,
601
+ 0x59, &lgdt3306a_config);
602
+
603
+ if (!adap->i2c_client_demod[0])
604
+ return -ENODEV;
605
+
606
+ return 0;
607
+}
608
+
609
+static int pvr2_dual_fe_attach(struct pvr2_dvb_adapter *adap)
610
+{
611
+ pr_debug("%s()\n", __func__);
612
+
613
+ if (pvr2_lgdt3306a_attach(adap) != 0)
614
+ return -ENODEV;
615
+
616
+ if (pvr2_si2168_attach(adap) != 0) {
617
+ dvb_module_release(adap->i2c_client_demod[0]);
618
+ return -ENODEV;
619
+ }
620
+
621
+ return 0;
622
+}
623
+#endif
624
+
625
+#define PVR2_FIRMWARE_160xxx "v4l-pvrusb2-160xxx-01.fw"
626
+static const char *pvr2_fw1_names_160xxx[] = {
627
+ PVR2_FIRMWARE_160xxx,
628
+};
629
+
630
+static const struct pvr2_device_client_desc pvr2_cli_160xxx[] = {
631
+ { .module_id = PVR2_CLIENT_ID_CX25840 },
632
+};
633
+
634
+static const struct pvr2_device_desc pvr2_device_160000 = {
635
+ .description = "WinTV HVR-1975 Model 160000",
636
+ .shortname = "160000",
637
+ .client_table.lst = pvr2_cli_160xxx,
638
+ .client_table.cnt = ARRAY_SIZE(pvr2_cli_160xxx),
639
+ .fx2_firmware.lst = pvr2_fw1_names_160xxx,
640
+ .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_160xxx),
641
+ .default_tuner_type = TUNER_ABSENT,
642
+ .flag_has_cx25840 = 1,
643
+ .flag_has_hauppauge_rom = 1,
644
+ .flag_has_analogtuner = 1,
645
+ .flag_has_composite = 1,
646
+ .flag_has_svideo = 1,
647
+ .flag_fx2_16kb = 1,
648
+ .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
649
+ .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
650
+ .default_std_mask = V4L2_STD_NTSC_M,
651
+ .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
652
+ .ir_scheme = PVR2_IR_SCHEME_ZILOG,
653
+#ifdef CONFIG_VIDEO_PVRUSB2_DVB
654
+ .dvb_props = &pvr2_160000_dvb_props,
655
+#endif
656
+};
657
+
658
+static const struct pvr2_device_desc pvr2_device_160111 = {
659
+ .description = "WinTV HVR-1955 Model 160111",
660
+ .shortname = "160111",
661
+ .client_table.lst = pvr2_cli_160xxx,
662
+ .client_table.cnt = ARRAY_SIZE(pvr2_cli_160xxx),
663
+ .fx2_firmware.lst = pvr2_fw1_names_160xxx,
664
+ .fx2_firmware.cnt = ARRAY_SIZE(pvr2_fw1_names_160xxx),
665
+ .default_tuner_type = TUNER_ABSENT,
666
+ .flag_has_cx25840 = 1,
667
+ .flag_has_hauppauge_rom = 1,
668
+ .flag_has_analogtuner = 1,
669
+ .flag_has_composite = 1,
670
+ .flag_has_svideo = 1,
671
+ .flag_fx2_16kb = 1,
672
+ .signal_routing_scheme = PVR2_ROUTING_SCHEME_HAUPPAUGE,
673
+ .digital_control_scheme = PVR2_DIGITAL_SCHEME_HAUPPAUGE,
674
+ .default_std_mask = V4L2_STD_NTSC_M,
675
+ .led_scheme = PVR2_LED_SCHEME_HAUPPAUGE,
676
+ .ir_scheme = PVR2_IR_SCHEME_ZILOG,
677
+#ifdef CONFIG_VIDEO_PVRUSB2_DVB
678
+ .dvb_props = &pvr2_160111_dvb_props,
679
+#endif
680
+};
529681
530682 /*------------------------------------------------------------------------*/
531683
....@@ -552,6 +704,10 @@
552704 .driver_info = (kernel_ulong_t)&pvr2_device_751xx},
553705 { USB_DEVICE(0x0ccd, 0x0039),
554706 .driver_info = (kernel_ulong_t)&pvr2_device_av400},
707
+ { USB_DEVICE(0x2040, 0x7502),
708
+ .driver_info = (kernel_ulong_t)&pvr2_device_160111},
709
+ { USB_DEVICE(0x2040, 0x7510),
710
+ .driver_info = (kernel_ulong_t)&pvr2_device_160000},
555711 { }
556712 };
557713