[media] Added support for AVerTV Hybrid Express Slim HC81R
authorOleh Kravchenko <oleg@kaa.org.ua>
Sat, 8 Dec 2012 21:20:59 +0000 (18:20 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Thu, 27 Dec 2012 18:03:12 +0000 (16:03 -0200)
This patch provide only analog support.
The device is based on AF9013 demodulator, XC3028 tuner
and CX23885 chipset; subsystem id: 1461:d939

Signed-off-by: Oleh Kravchenko <oleg@kaa.org.ua>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/pci/cx23885/cx23885-cards.c
drivers/media/pci/cx23885/cx23885-video.c
drivers/media/pci/cx23885/cx23885.h

index 8d96ae4ebbdd9ca3839ce78d35ee4c7bac212452..7e923f8dd2f513152b7c56a9afb3f0c5659bb42a 100644 (file)
@@ -577,6 +577,35 @@ struct cx23885_board cx23885_boards[] = {
                .name           = "Hauppauge WinTV-HVR4400",
                .portb          = CX23885_MPEG_DVB,
        },
+       [CX23885_BOARD_AVERMEDIA_HC81R] = {
+               .name           = "AVerTV Hybrid Express Slim HC81R",
+               .tuner_type     = TUNER_XC2028,
+               .tuner_addr     = 0x61, /* 0xc2 >> 1 */
+               .tuner_bus      = 1,
+               .porta          = CX23885_ANALOG_VIDEO,
+               .input          = {{
+                       .type   = CX23885_VMUX_TELEVISION,
+                       .vmux   = CX25840_VIN2_CH1 |
+                                 CX25840_VIN5_CH2 |
+                                 CX25840_NONE0_CH3 |
+                                 CX25840_NONE1_CH3,
+                       .amux   = CX25840_AUDIO8,
+               }, {
+                       .type   = CX23885_VMUX_SVIDEO,
+                       .vmux   = CX25840_VIN8_CH1 |
+                                 CX25840_NONE_CH2 |
+                                 CX25840_VIN7_CH3 |
+                                 CX25840_SVIDEO_ON,
+                       .amux   = CX25840_AUDIO6,
+               }, {
+                       .type   = CX23885_VMUX_COMPONENT,
+                       .vmux   = CX25840_VIN1_CH1 |
+                                 CX25840_NONE_CH2 |
+                                 CX25840_NONE0_CH3 |
+                                 CX25840_NONE1_CH3,
+                       .amux   = CX25840_AUDIO6,
+               } },
+       }
 };
 const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
 
@@ -808,6 +837,10 @@ struct cx23885_subid cx23885_subids[] = {
                .subvendor = 0x0070,
                .subdevice = 0xc1f8,
                .card      = CX23885_BOARD_HAUPPAUGE_HVR4400,
+       }, {
+               .subvendor = 0x1461,
+               .subdevice = 0xd939,
+               .card      = CX23885_BOARD_AVERMEDIA_HC81R,
        },
 };
 const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1032,6 +1065,10 @@ int cx23885_tuner_callback(void *priv, int component, int command, int arg)
        case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
                altera_ci_tuner_reset(dev, port->nr);
                break;
+       case CX23885_BOARD_AVERMEDIA_HC81R:
+               /* XC3028L Reset Command */
+               bitmask = 1 << 2;
+               break;
        }
 
        if (bitmask) {
@@ -1331,6 +1368,32 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
                cx23885_gpio_set(dev, GPIO_8);
                mdelay(100);
                break;
+       case CX23885_BOARD_AVERMEDIA_HC81R:
+               cx_clear(MC417_CTL, 1);
+               /* GPIO-0,1,2 setup direction as output */
+               cx_set(GP0_IO, 0x00070000);
+               mdelay(10);
+               /* AF9013 demod reset */
+               cx_set(GP0_IO, 0x00010001);
+               mdelay(10);
+               cx_clear(GP0_IO, 0x00010001);
+               mdelay(10);
+               cx_set(GP0_IO, 0x00010001);
+               mdelay(10);
+               /* demod tune? */
+               cx_clear(GP0_IO, 0x00030003);
+               mdelay(10);
+               cx_set(GP0_IO, 0x00020002);
+               mdelay(10);
+               cx_set(GP0_IO, 0x00010001);
+               mdelay(10);
+               cx_clear(GP0_IO, 0x00020002);
+               /* XC3028L tuner reset */
+               cx_set(GP0_IO, 0x00040004);
+               cx_clear(GP0_IO, 0x00040004);
+               cx_set(GP0_IO, 0x00040004);
+               mdelay(60);
+               break;
        }
 }
 
@@ -1549,6 +1612,17 @@ void cx23885_card_setup(struct cx23885_dev *dev)
        }
 
        switch (dev->board) {
+       case CX23885_BOARD_AVERMEDIA_HC81R:
+               /* Defaults for VID B */
+               ts1->gen_ctrl_val  = 0x4; /* Parallel */
+               ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
+               ts1->src_sel_val   = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+               /* Defaults for VID C */
+               /* DREQ_POL, SMODE, PUNC_CLK, MCLK_POL Serial bus + punc clk */
+               ts2->gen_ctrl_val  = 0x10e;
+               ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
+               ts2->src_sel_val     = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
+               break;
        case CX23885_BOARD_DVICO_FUSIONHDTV_7_DUAL_EXP:
        case CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP:
                ts2->gen_ctrl_val  = 0xc; /* Serial bus + punctured clock */
@@ -1675,6 +1749,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
        case CX23885_BOARD_MPX885:
        case CX23885_BOARD_MYGICA_X8507:
        case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
+       case CX23885_BOARD_AVERMEDIA_HC81R:
                dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
                                &dev->i2c_bus[2].i2c_adap,
                                "cx25840", 0x88 >> 1, NULL);
index 83975313e0f2fb85e12ab1e6de70b89984e83993..0e80ba4ca4dda2ce893f486acc9e1b4e03d74bfa 100644 (file)
@@ -509,7 +509,8 @@ static int cx23885_video_mux(struct cx23885_dev *dev, unsigned int input)
                (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255) ||
                (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1255_22111) ||
                (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1850) ||
-               (dev->board == CX23885_BOARD_MYGICA_X8507)) {
+               (dev->board == CX23885_BOARD_MYGICA_X8507) ||
+               (dev->board == CX23885_BOARD_AVERMEDIA_HC81R)) {
                /* Configure audio routing */
                v4l2_subdev_call(dev->sd_cx25840, audio, s_routing,
                        INPUT(input)->amux, 0, 0);
@@ -1878,6 +1879,18 @@ int cx23885_video_register(struct cx23885_dev *dev)
                                };
                                v4l2_subdev_call(sd, tuner, s_config, &cfg);
                        }
+
+                       if (dev->board == CX23885_BOARD_AVERMEDIA_HC81R) {
+                               struct xc2028_ctrl ctrl = {
+                                       .fname = "xc3028L-v36.fw",
+                                       .max_len = 64
+                               };
+                               struct v4l2_priv_tun_config cfg = {
+                                       .tuner = dev->tuner_type,
+                                       .priv = &ctrl
+                               };
+                               v4l2_subdev_call(sd, tuner, s_config, &cfg);
+                       }
                }
        }
 
index 61889b25a2afc761e2280a4d1788088065a459a0..59c322d870f2e8216463d0063843c24d74e930ce 100644 (file)
@@ -92,6 +92,7 @@
 #define CX23885_BOARD_HAUPPAUGE_HVR1255_22111  36
 #define CX23885_BOARD_PROF_8000                37
 #define CX23885_BOARD_HAUPPAUGE_HVR4400        38
+#define CX23885_BOARD_AVERMEDIA_HC81R          39
 
 #define GPIO_0 0x00000001
 #define GPIO_1 0x00000002