aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/cx23885
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/pci/cx23885')
-rw-r--r--drivers/media/pci/cx23885/cx23885-417.c4
-rw-r--r--drivers/media/pci/cx23885/cx23885-cards.c131
-rw-r--r--drivers/media/pci/cx23885/cx23885-core.c21
-rw-r--r--drivers/media/pci/cx23885/cx23885-dvb.c691
-rw-r--r--drivers/media/pci/cx23885/cx23885-input.c31
-rw-r--r--drivers/media/pci/cx23885/cx23885-vbi.c10
-rw-r--r--drivers/media/pci/cx23885/cx23885-video.c12
-rw-r--r--drivers/media/pci/cx23885/cx23885.h8
8 files changed, 724 insertions, 184 deletions
diff --git a/drivers/media/pci/cx23885/cx23885-417.c b/drivers/media/pci/cx23885/cx23885-417.c
index 3948db386fb5..e4901a503c73 100644
--- a/drivers/media/pci/cx23885/cx23885-417.c
+++ b/drivers/media/pci/cx23885/cx23885-417.c
@@ -1148,6 +1148,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
1148 dev->ts1.ts_packet_count = mpeglines; 1148 dev->ts1.ts_packet_count = mpeglines;
1149 *num_planes = 1; 1149 *num_planes = 1;
1150 sizes[0] = mpeglinesize * mpeglines; 1150 sizes[0] = mpeglinesize * mpeglines;
1151 alloc_ctxs[0] = dev->alloc_ctx;
1151 *num_buffers = mpegbufs; 1152 *num_buffers = mpegbufs;
1152 return 0; 1153 return 0;
1153} 1154}
@@ -1166,11 +1167,8 @@ static void buffer_finish(struct vb2_buffer *vb)
1166 struct cx23885_dev *dev = vb->vb2_queue->drv_priv; 1167 struct cx23885_dev *dev = vb->vb2_queue->drv_priv;
1167 struct cx23885_buffer *buf = container_of(vb, 1168 struct cx23885_buffer *buf = container_of(vb,
1168 struct cx23885_buffer, vb); 1169 struct cx23885_buffer, vb);
1169 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
1170 1170
1171 cx23885_free_buffer(dev, buf); 1171 cx23885_free_buffer(dev, buf);
1172
1173 dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
1174} 1172}
1175 1173
1176static void buffer_queue(struct vb2_buffer *vb) 1174static void buffer_queue(struct vb2_buffer *vb)
diff --git a/drivers/media/pci/cx23885/cx23885-cards.c b/drivers/media/pci/cx23885/cx23885-cards.c
index 88c257d1161b..db99ca2613ba 100644
--- a/drivers/media/pci/cx23885/cx23885-cards.c
+++ b/drivers/media/pci/cx23885/cx23885-cards.c
@@ -680,6 +680,32 @@ struct cx23885_board cx23885_boards[] = {
680 .portb = CX23885_MPEG_DVB, 680 .portb = CX23885_MPEG_DVB,
681 .portc = CX23885_MPEG_DVB, 681 .portc = CX23885_MPEG_DVB,
682 }, 682 },
683 [CX23885_BOARD_DVBSKY_T980C] = {
684 .name = "DVBSky T980C",
685 .portb = CX23885_MPEG_DVB,
686 },
687 [CX23885_BOARD_DVBSKY_S950C] = {
688 .name = "DVBSky S950C",
689 .portb = CX23885_MPEG_DVB,
690 },
691 [CX23885_BOARD_TT_CT2_4500_CI] = {
692 .name = "Technotrend TT-budget CT2-4500 CI",
693 .portb = CX23885_MPEG_DVB,
694 },
695 [CX23885_BOARD_DVBSKY_S950] = {
696 .name = "DVBSky S950",
697 .portb = CX23885_MPEG_DVB,
698 },
699 [CX23885_BOARD_DVBSKY_S952] = {
700 .name = "DVBSky S952",
701 .portb = CX23885_MPEG_DVB,
702 .portc = CX23885_MPEG_DVB,
703 },
704 [CX23885_BOARD_DVBSKY_T982] = {
705 .name = "DVBSky T982",
706 .portb = CX23885_MPEG_DVB,
707 .portc = CX23885_MPEG_DVB,
708 },
683}; 709};
684const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards); 710const unsigned int cx23885_bcount = ARRAY_SIZE(cx23885_boards);
685 711
@@ -939,6 +965,30 @@ struct cx23885_subid cx23885_subids[] = {
939 .subvendor = 0x4254, 965 .subvendor = 0x4254,
940 .subdevice = 0x9580, 966 .subdevice = 0x9580,
941 .card = CX23885_BOARD_DVBSKY_T9580, 967 .card = CX23885_BOARD_DVBSKY_T9580,
968 }, {
969 .subvendor = 0x4254,
970 .subdevice = 0x980c,
971 .card = CX23885_BOARD_DVBSKY_T980C,
972 }, {
973 .subvendor = 0x4254,
974 .subdevice = 0x950c,
975 .card = CX23885_BOARD_DVBSKY_S950C,
976 }, {
977 .subvendor = 0x13c2,
978 .subdevice = 0x3013,
979 .card = CX23885_BOARD_TT_CT2_4500_CI,
980 }, {
981 .subvendor = 0x4254,
982 .subdevice = 0x0950,
983 .card = CX23885_BOARD_DVBSKY_S950,
984 }, {
985 .subvendor = 0x4254,
986 .subdevice = 0x0952,
987 .card = CX23885_BOARD_DVBSKY_S952,
988 }, {
989 .subvendor = 0x4254,
990 .subdevice = 0x0982,
991 .card = CX23885_BOARD_DVBSKY_T982,
942 }, 992 },
943}; 993};
944const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids); 994const unsigned int cx23885_idcount = ARRAY_SIZE(cx23885_subids);
@@ -1534,6 +1584,8 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
1534 mdelay(60); 1584 mdelay(60);
1535 break; 1585 break;
1536 case CX23885_BOARD_DVBSKY_T9580: 1586 case CX23885_BOARD_DVBSKY_T9580:
1587 case CX23885_BOARD_DVBSKY_S952:
1588 case CX23885_BOARD_DVBSKY_T982:
1537 /* enable GPIO3-18 pins */ 1589 /* enable GPIO3-18 pins */
1538 cx_write(MC417_CTL, 0x00000037); 1590 cx_write(MC417_CTL, 0x00000037);
1539 cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1); 1591 cx23885_gpio_enable(dev, GPIO_2 | GPIO_11, 1);
@@ -1541,6 +1593,45 @@ void cx23885_gpio_setup(struct cx23885_dev *dev)
1541 mdelay(100); 1593 mdelay(100);
1542 cx23885_gpio_set(dev, GPIO_2 | GPIO_11); 1594 cx23885_gpio_set(dev, GPIO_2 | GPIO_11);
1543 break; 1595 break;
1596 case CX23885_BOARD_DVBSKY_T980C:
1597 case CX23885_BOARD_DVBSKY_S950C:
1598 case CX23885_BOARD_TT_CT2_4500_CI:
1599 /*
1600 * GPIO-0 INTA from CiMax, input
1601 * GPIO-1 reset CiMax, output, high active
1602 * GPIO-2 reset demod, output, low active
1603 * GPIO-3 to GPIO-10 data/addr for CAM
1604 * GPIO-11 ~CS0 to CiMax1
1605 * GPIO-12 ~CS1 to CiMax2
1606 * GPIO-13 ADL0 load LSB addr
1607 * GPIO-14 ADL1 load MSB addr
1608 * GPIO-15 ~RDY from CiMax
1609 * GPIO-17 ~RD to CiMax
1610 * GPIO-18 ~WR to CiMax
1611 */
1612
1613 cx_set(GP0_IO, 0x00060002); /* GPIO 1/2 as output */
1614 cx_clear(GP0_IO, 0x00010004); /* GPIO 0 as input */
1615 mdelay(100); /* reset delay */
1616 cx_set(GP0_IO, 0x00060004); /* GPIO as out, reset high */
1617 cx_clear(GP0_IO, 0x00010002);
1618 cx_write(MC417_CTL, 0x00000037); /* enable GPIO3-18 pins */
1619
1620 /* GPIO-15 IN as ~ACK, rest as OUT */
1621 cx_write(MC417_OEN, 0x00001000);
1622
1623 /* ~RD, ~WR high; ADL0, ADL1 low; ~CS0, ~CS1 high */
1624 cx_write(MC417_RWD, 0x0000c300);
1625
1626 /* enable irq */
1627 cx_write(GPIO_ISM, 0x00000000); /* INTERRUPTS active low */
1628 break;
1629 case CX23885_BOARD_DVBSKY_S950:
1630 cx23885_gpio_enable(dev, GPIO_2, 1);
1631 cx23885_gpio_clear(dev, GPIO_2);
1632 msleep(100);
1633 cx23885_gpio_set(dev, GPIO_2);
1634 break;
1544 } 1635 }
1545} 1636}
1546 1637
@@ -1621,6 +1712,13 @@ int cx23885_ir_init(struct cx23885_dev *dev)
1621 case CX23885_BOARD_MYGICA_X8507: 1712 case CX23885_BOARD_MYGICA_X8507:
1622 case CX23885_BOARD_TBS_6980: 1713 case CX23885_BOARD_TBS_6980:
1623 case CX23885_BOARD_TBS_6981: 1714 case CX23885_BOARD_TBS_6981:
1715 case CX23885_BOARD_DVBSKY_T9580:
1716 case CX23885_BOARD_DVBSKY_T980C:
1717 case CX23885_BOARD_DVBSKY_S950C:
1718 case CX23885_BOARD_TT_CT2_4500_CI:
1719 case CX23885_BOARD_DVBSKY_S950:
1720 case CX23885_BOARD_DVBSKY_S952:
1721 case CX23885_BOARD_DVBSKY_T982:
1624 if (!enable_885_ir) 1722 if (!enable_885_ir)
1625 break; 1723 break;
1626 dev->sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE); 1724 dev->sd_ir = cx23885_find_hw(dev, CX23885_HW_AV_CORE);
@@ -1667,6 +1765,13 @@ void cx23885_ir_fini(struct cx23885_dev *dev)
1667 case CX23885_BOARD_MYGICA_X8507: 1765 case CX23885_BOARD_MYGICA_X8507:
1668 case CX23885_BOARD_TBS_6980: 1766 case CX23885_BOARD_TBS_6980:
1669 case CX23885_BOARD_TBS_6981: 1767 case CX23885_BOARD_TBS_6981:
1768 case CX23885_BOARD_DVBSKY_T9580:
1769 case CX23885_BOARD_DVBSKY_T980C:
1770 case CX23885_BOARD_DVBSKY_S950C:
1771 case CX23885_BOARD_TT_CT2_4500_CI:
1772 case CX23885_BOARD_DVBSKY_S950:
1773 case CX23885_BOARD_DVBSKY_S952:
1774 case CX23885_BOARD_DVBSKY_T982:
1670 cx23885_irq_remove(dev, PCI_MSK_AV_CORE); 1775 cx23885_irq_remove(dev, PCI_MSK_AV_CORE);
1671 /* sd_ir is a duplicate pointer to the AV Core, just clear it */ 1776 /* sd_ir is a duplicate pointer to the AV Core, just clear it */
1672 dev->sd_ir = NULL; 1777 dev->sd_ir = NULL;
@@ -1714,6 +1819,13 @@ void cx23885_ir_pci_int_enable(struct cx23885_dev *dev)
1714 case CX23885_BOARD_MYGICA_X8507: 1819 case CX23885_BOARD_MYGICA_X8507:
1715 case CX23885_BOARD_TBS_6980: 1820 case CX23885_BOARD_TBS_6980:
1716 case CX23885_BOARD_TBS_6981: 1821 case CX23885_BOARD_TBS_6981:
1822 case CX23885_BOARD_DVBSKY_T9580:
1823 case CX23885_BOARD_DVBSKY_T980C:
1824 case CX23885_BOARD_DVBSKY_S950C:
1825 case CX23885_BOARD_TT_CT2_4500_CI:
1826 case CX23885_BOARD_DVBSKY_S950:
1827 case CX23885_BOARD_DVBSKY_S952:
1828 case CX23885_BOARD_DVBSKY_T982:
1717 if (dev->sd_ir) 1829 if (dev->sd_ir)
1718 cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE); 1830 cx23885_irq_add_enable(dev, PCI_MSK_AV_CORE);
1719 break; 1831 break;
@@ -1817,6 +1929,10 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1817 case CX23885_BOARD_TEVII_S471: 1929 case CX23885_BOARD_TEVII_S471:
1818 case CX23885_BOARD_DVBWORLD_2005: 1930 case CX23885_BOARD_DVBWORLD_2005:
1819 case CX23885_BOARD_PROF_8000: 1931 case CX23885_BOARD_PROF_8000:
1932 case CX23885_BOARD_DVBSKY_T980C:
1933 case CX23885_BOARD_DVBSKY_S950C:
1934 case CX23885_BOARD_TT_CT2_4500_CI:
1935 case CX23885_BOARD_DVBSKY_S950:
1820 ts1->gen_ctrl_val = 0x5; /* Parallel */ 1936 ts1->gen_ctrl_val = 0x5; /* Parallel */
1821 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ 1937 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
1822 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; 1938 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
@@ -1865,6 +1981,7 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1865 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; 1981 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
1866 break; 1982 break;
1867 case CX23885_BOARD_DVBSKY_T9580: 1983 case CX23885_BOARD_DVBSKY_T9580:
1984 case CX23885_BOARD_DVBSKY_T982:
1868 ts1->gen_ctrl_val = 0x5; /* Parallel */ 1985 ts1->gen_ctrl_val = 0x5; /* Parallel */
1869 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */ 1986 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
1870 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; 1987 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
@@ -1872,6 +1989,14 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1872 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */ 1989 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
1873 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO; 1990 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
1874 break; 1991 break;
1992 case CX23885_BOARD_DVBSKY_S952:
1993 ts1->gen_ctrl_val = 0x5; /* Parallel */
1994 ts1->ts_clk_en_val = 0x1; /* Enable TS_CLK */
1995 ts1->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
1996 ts2->gen_ctrl_val = 0xe; /* Serial bus */
1997 ts2->ts_clk_en_val = 0x1; /* Enable TS_CLK */
1998 ts2->src_sel_val = CX23885_SRC_SEL_PARALLEL_MPEG_VIDEO;
1999 break;
1875 case CX23885_BOARD_HAUPPAUGE_HVR1250: 2000 case CX23885_BOARD_HAUPPAUGE_HVR1250:
1876 case CX23885_BOARD_HAUPPAUGE_HVR1500: 2001 case CX23885_BOARD_HAUPPAUGE_HVR1500:
1877 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 2002 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
@@ -1935,6 +2060,12 @@ void cx23885_card_setup(struct cx23885_dev *dev)
1935 case CX23885_BOARD_TBS_6980: 2060 case CX23885_BOARD_TBS_6980:
1936 case CX23885_BOARD_TBS_6981: 2061 case CX23885_BOARD_TBS_6981:
1937 case CX23885_BOARD_DVBSKY_T9580: 2062 case CX23885_BOARD_DVBSKY_T9580:
2063 case CX23885_BOARD_DVBSKY_T980C:
2064 case CX23885_BOARD_DVBSKY_S950C:
2065 case CX23885_BOARD_TT_CT2_4500_CI:
2066 case CX23885_BOARD_DVBSKY_S950:
2067 case CX23885_BOARD_DVBSKY_S952:
2068 case CX23885_BOARD_DVBSKY_T982:
1938 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev, 2069 dev->sd_cx25840 = v4l2_i2c_new_subdev(&dev->v4l2_dev,
1939 &dev->i2c_bus[2].i2c_adap, 2070 &dev->i2c_bus[2].i2c_adap,
1940 "cx25840", 0x88 >> 1, NULL); 2071 "cx25840", 0x88 >> 1, NULL);
diff --git a/drivers/media/pci/cx23885/cx23885-core.c b/drivers/media/pci/cx23885/cx23885-core.c
index 331eddac7222..1d9d0f86ca8c 100644
--- a/drivers/media/pci/cx23885/cx23885-core.c
+++ b/drivers/media/pci/cx23885/cx23885-core.c
@@ -1078,7 +1078,7 @@ static __le32 *cx23885_risc_field(__le32 *rp, struct scatterlist *sglist,
1078 for (line = 0; line < lines; line++) { 1078 for (line = 0; line < lines; line++) {
1079 while (offset && offset >= sg_dma_len(sg)) { 1079 while (offset && offset >= sg_dma_len(sg)) {
1080 offset -= sg_dma_len(sg); 1080 offset -= sg_dma_len(sg);
1081 sg++; 1081 sg = sg_next(sg);
1082 } 1082 }
1083 1083
1084 if (lpi && line > 0 && !(line % lpi)) 1084 if (lpi && line > 0 && !(line % lpi))
@@ -1101,14 +1101,14 @@ static __le32 *cx23885_risc_field(__le32 *rp, struct scatterlist *sglist,
1101 *(rp++) = cpu_to_le32(0); /* bits 63-32 */ 1101 *(rp++) = cpu_to_le32(0); /* bits 63-32 */
1102 todo -= (sg_dma_len(sg)-offset); 1102 todo -= (sg_dma_len(sg)-offset);
1103 offset = 0; 1103 offset = 0;
1104 sg++; 1104 sg = sg_next(sg);
1105 while (todo > sg_dma_len(sg)) { 1105 while (todo > sg_dma_len(sg)) {
1106 *(rp++) = cpu_to_le32(RISC_WRITE| 1106 *(rp++) = cpu_to_le32(RISC_WRITE|
1107 sg_dma_len(sg)); 1107 sg_dma_len(sg));
1108 *(rp++) = cpu_to_le32(sg_dma_address(sg)); 1108 *(rp++) = cpu_to_le32(sg_dma_address(sg));
1109 *(rp++) = cpu_to_le32(0); /* bits 63-32 */ 1109 *(rp++) = cpu_to_le32(0); /* bits 63-32 */
1110 todo -= sg_dma_len(sg); 1110 todo -= sg_dma_len(sg);
1111 sg++; 1111 sg = sg_next(sg);
1112 } 1112 }
1113 *(rp++) = cpu_to_le32(RISC_WRITE|RISC_EOL|todo); 1113 *(rp++) = cpu_to_le32(RISC_WRITE|RISC_EOL|todo);
1114 *(rp++) = cpu_to_le32(sg_dma_address(sg)); 1114 *(rp++) = cpu_to_le32(sg_dma_address(sg));
@@ -1453,17 +1453,12 @@ int cx23885_buf_prepare(struct cx23885_buffer *buf, struct cx23885_tsport *port)
1453 struct cx23885_dev *dev = port->dev; 1453 struct cx23885_dev *dev = port->dev;
1454 int size = port->ts_packet_size * port->ts_packet_count; 1454 int size = port->ts_packet_size * port->ts_packet_count;
1455 struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vb, 0); 1455 struct sg_table *sgt = vb2_dma_sg_plane_desc(&buf->vb, 0);
1456 int rc;
1457 1456
1458 dprintk(1, "%s: %p\n", __func__, buf); 1457 dprintk(1, "%s: %p\n", __func__, buf);
1459 if (vb2_plane_size(&buf->vb, 0) < size) 1458 if (vb2_plane_size(&buf->vb, 0) < size)
1460 return -EINVAL; 1459 return -EINVAL;
1461 vb2_set_plane_payload(&buf->vb, 0, size); 1460 vb2_set_plane_payload(&buf->vb, 0, size);
1462 1461
1463 rc = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
1464 if (!rc)
1465 return -EIO;
1466
1467 cx23885_risc_databuffer(dev->pci, &buf->risc, 1462 cx23885_risc_databuffer(dev->pci, &buf->risc,
1468 sgt->sgl, 1463 sgt->sgl,
1469 port->ts_packet_size, port->ts_packet_count, 0); 1464 port->ts_packet_size, port->ts_packet_count, 0);
@@ -1997,9 +1992,14 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
1997 if (!pci_dma_supported(pci_dev, 0xffffffff)) { 1992 if (!pci_dma_supported(pci_dev, 0xffffffff)) {
1998 printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name); 1993 printk("%s/0: Oops: no 32bit PCI DMA ???\n", dev->name);
1999 err = -EIO; 1994 err = -EIO;
2000 goto fail_irq; 1995 goto fail_context;
2001 } 1996 }
2002 1997
1998 dev->alloc_ctx = vb2_dma_sg_init_ctx(&pci_dev->dev);
1999 if (IS_ERR(dev->alloc_ctx)) {
2000 err = PTR_ERR(dev->alloc_ctx);
2001 goto fail_context;
2002 }
2003 err = request_irq(pci_dev->irq, cx23885_irq, 2003 err = request_irq(pci_dev->irq, cx23885_irq,
2004 IRQF_SHARED, dev->name, dev); 2004 IRQF_SHARED, dev->name, dev);
2005 if (err < 0) { 2005 if (err < 0) {
@@ -2028,6 +2028,8 @@ static int cx23885_initdev(struct pci_dev *pci_dev,
2028 return 0; 2028 return 0;
2029 2029
2030fail_irq: 2030fail_irq:
2031 vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
2032fail_context:
2031 cx23885_dev_unregister(dev); 2033 cx23885_dev_unregister(dev);
2032fail_ctrl: 2034fail_ctrl:
2033 v4l2_ctrl_handler_free(hdl); 2035 v4l2_ctrl_handler_free(hdl);
@@ -2053,6 +2055,7 @@ static void cx23885_finidev(struct pci_dev *pci_dev)
2053 free_irq(pci_dev->irq, dev); 2055 free_irq(pci_dev->irq, dev);
2054 2056
2055 cx23885_dev_unregister(dev); 2057 cx23885_dev_unregister(dev);
2058 vb2_dma_sg_cleanup_ctx(dev->alloc_ctx);
2056 v4l2_ctrl_handler_free(&dev->ctrl_handler); 2059 v4l2_ctrl_handler_free(&dev->ctrl_handler);
2057 v4l2_device_unregister(v4l2_dev); 2060 v4l2_device_unregister(v4l2_dev);
2058 kfree(dev); 2061 kfree(dev);
diff --git a/drivers/media/pci/cx23885/cx23885-dvb.c b/drivers/media/pci/cx23885/cx23885-dvb.c
index 4cb90317ff45..c47d18270cfc 100644
--- a/drivers/media/pci/cx23885/cx23885-dvb.c
+++ b/drivers/media/pci/cx23885/cx23885-dvb.c
@@ -71,6 +71,7 @@
71#include "si2165.h" 71#include "si2165.h"
72#include "si2168.h" 72#include "si2168.h"
73#include "si2157.h" 73#include "si2157.h"
74#include "sp2.h"
74#include "m88ds3103.h" 75#include "m88ds3103.h"
75#include "m88ts2022.h" 76#include "m88ts2022.h"
76 77
@@ -101,6 +102,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
101 port->ts_packet_count = 32; 102 port->ts_packet_count = 32;
102 *num_planes = 1; 103 *num_planes = 1;
103 sizes[0] = port->ts_packet_size * port->ts_packet_count; 104 sizes[0] = port->ts_packet_size * port->ts_packet_count;
105 alloc_ctxs[0] = port->dev->alloc_ctx;
104 *num_buffers = 32; 106 *num_buffers = 32;
105 return 0; 107 return 0;
106} 108}
@@ -121,11 +123,8 @@ static void buffer_finish(struct vb2_buffer *vb)
121 struct cx23885_dev *dev = port->dev; 123 struct cx23885_dev *dev = port->dev;
122 struct cx23885_buffer *buf = container_of(vb, 124 struct cx23885_buffer *buf = container_of(vb,
123 struct cx23885_buffer, vb); 125 struct cx23885_buffer, vb);
124 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
125 126
126 cx23885_free_buffer(dev, buf); 127 cx23885_free_buffer(dev, buf);
127
128 dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
129} 128}
130 129
131static void buffer_queue(struct vb2_buffer *vb) 130static void buffer_queue(struct vb2_buffer *vb)
@@ -616,6 +615,103 @@ static int dvbsky_t9580_set_voltage(struct dvb_frontend *fe,
616 return 0; 615 return 0;
617} 616}
618 617
618static int dvbsky_s952_portc_set_voltage(struct dvb_frontend *fe,
619 fe_sec_voltage_t voltage)
620{
621 struct cx23885_tsport *port = fe->dvb->priv;
622 struct cx23885_dev *dev = port->dev;
623
624 cx23885_gpio_enable(dev, GPIO_12 | GPIO_13, 1);
625
626 switch (voltage) {
627 case SEC_VOLTAGE_13:
628 cx23885_gpio_set(dev, GPIO_13);
629 cx23885_gpio_clear(dev, GPIO_12);
630 break;
631 case SEC_VOLTAGE_18:
632 cx23885_gpio_set(dev, GPIO_13);
633 cx23885_gpio_set(dev, GPIO_12);
634 break;
635 case SEC_VOLTAGE_OFF:
636 cx23885_gpio_clear(dev, GPIO_13);
637 cx23885_gpio_clear(dev, GPIO_12);
638 break;
639 }
640 /* call the frontend set_voltage function */
641 return port->fe_set_voltage(fe, voltage);
642}
643
644static int cx23885_sp2_ci_ctrl(void *priv, u8 read, int addr,
645 u8 data, int *mem)
646{
647 /* MC417 */
648 #define SP2_DATA 0x000000ff
649 #define SP2_WR 0x00008000
650 #define SP2_RD 0x00004000
651 #define SP2_ACK 0x00001000
652 #define SP2_ADHI 0x00000800
653 #define SP2_ADLO 0x00000400
654 #define SP2_CS1 0x00000200
655 #define SP2_CS0 0x00000100
656 #define SP2_EN_ALL 0x00001000
657 #define SP2_CTRL_OFF (SP2_CS1 | SP2_CS0 | SP2_WR | SP2_RD)
658
659 struct cx23885_tsport *port = priv;
660 struct cx23885_dev *dev = port->dev;
661 int ret;
662 int tmp = 0;
663 unsigned long timeout;
664
665 mutex_lock(&dev->gpio_lock);
666
667 /* write addr */
668 cx_write(MC417_OEN, SP2_EN_ALL);
669 cx_write(MC417_RWD, SP2_CTRL_OFF |
670 SP2_ADLO | (0xff & addr));
671 cx_clear(MC417_RWD, SP2_ADLO);
672 cx_write(MC417_RWD, SP2_CTRL_OFF |
673 SP2_ADHI | (0xff & (addr >> 8)));
674 cx_clear(MC417_RWD, SP2_ADHI);
675
676 if (read)
677 /* data in */
678 cx_write(MC417_OEN, SP2_EN_ALL | SP2_DATA);
679 else
680 /* data out */
681 cx_write(MC417_RWD, SP2_CTRL_OFF | data);
682
683 /* chip select 0 */
684 cx_clear(MC417_RWD, SP2_CS0);
685
686 /* read/write */
687 cx_clear(MC417_RWD, (read) ? SP2_RD : SP2_WR);
688
689 /* wait for a maximum of 1 msec */
690 timeout = jiffies + msecs_to_jiffies(1);
691 while (!time_after(jiffies, timeout)) {
692 tmp = cx_read(MC417_RWD);
693 if ((tmp & SP2_ACK) == 0)
694 break;
695 usleep_range(50, 100);
696 }
697
698 cx_set(MC417_RWD, SP2_CTRL_OFF);
699 *mem = tmp & 0xff;
700
701 mutex_unlock(&dev->gpio_lock);
702
703 if (!read) {
704 if (*mem < 0) {
705 ret = -EREMOTEIO;
706 goto err;
707 }
708 }
709
710 return 0;
711err:
712 return ret;
713}
714
619static int cx23885_dvb_set_frontend(struct dvb_frontend *fe) 715static int cx23885_dvb_set_frontend(struct dvb_frontend *fe)
620{ 716{
621 struct dtv_frontend_properties *p = &fe->dtv_property_cache; 717 struct dtv_frontend_properties *p = &fe->dtv_property_cache;
@@ -793,6 +889,32 @@ static const struct m88ds3103_config dvbsky_t9580_m88ds3103_config = {
793 .agc = 0x99, 889 .agc = 0x99,
794}; 890};
795 891
892static const struct m88ds3103_config dvbsky_s950c_m88ds3103_config = {
893 .i2c_addr = 0x68,
894 .clock = 27000000,
895 .i2c_wr_max = 33,
896 .clock_out = 0,
897 .ts_mode = M88DS3103_TS_CI,
898 .ts_clk = 10000,
899 .ts_clk_pol = 1,
900 .lnb_en_pol = 1,
901 .lnb_hv_pol = 0,
902 .agc = 0x99,
903};
904
905static const struct m88ds3103_config dvbsky_s952_portc_m88ds3103_config = {
906 .i2c_addr = 0x68,
907 .clock = 27000000,
908 .i2c_wr_max = 33,
909 .clock_out = 0,
910 .ts_mode = M88DS3103_TS_SERIAL,
911 .ts_clk = 96000,
912 .ts_clk_pol = 0,
913 .lnb_en_pol = 1,
914 .lnb_hv_pol = 0,
915 .agc = 0x99,
916};
917
796static int netup_altera_fpga_rw(void *device, int flag, int data, int read) 918static int netup_altera_fpga_rw(void *device, int flag, int data, int read)
797{ 919{
798 struct cx23885_dev *dev = (struct cx23885_dev *)device; 920 struct cx23885_dev *dev = (struct cx23885_dev *)device;
@@ -944,11 +1066,13 @@ static int dvb_register(struct cx23885_tsport *port)
944 struct vb2_dvb_frontend *fe0, *fe1 = NULL; 1066 struct vb2_dvb_frontend *fe0, *fe1 = NULL;
945 struct si2168_config si2168_config; 1067 struct si2168_config si2168_config;
946 struct si2157_config si2157_config; 1068 struct si2157_config si2157_config;
1069 struct sp2_config sp2_config;
947 struct m88ts2022_config m88ts2022_config; 1070 struct m88ts2022_config m88ts2022_config;
948 struct i2c_board_info info; 1071 struct i2c_board_info info;
949 struct i2c_adapter *adapter; 1072 struct i2c_adapter *adapter;
950 struct i2c_client *client_demod; 1073 struct i2c_client *client_demod = NULL, *client_tuner = NULL, *client_ci = NULL;
951 struct i2c_client *client_tuner; 1074 const struct m88ds3103_config *p_m88ds3103_config = NULL;
1075 int (*p_set_voltage)(struct dvb_frontend *fe, fe_sec_voltage_t voltage) = NULL;
952 int mfe_shared = 0; /* bus not shared by default */ 1076 int mfe_shared = 0; /* bus not shared by default */
953 int ret; 1077 int ret;
954 1078
@@ -973,11 +1097,11 @@ static int dvb_register(struct cx23885_tsport *port)
973 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1097 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
974 &hauppauge_generic_config, 1098 &hauppauge_generic_config,
975 &i2c_bus->i2c_adap); 1099 &i2c_bus->i2c_adap);
976 if (fe0->dvb.frontend != NULL) { 1100 if (fe0->dvb.frontend == NULL)
977 dvb_attach(mt2131_attach, fe0->dvb.frontend, 1101 break;
978 &i2c_bus->i2c_adap, 1102 dvb_attach(mt2131_attach, fe0->dvb.frontend,
979 &hauppauge_generic_tunerconfig, 0); 1103 &i2c_bus->i2c_adap,
980 } 1104 &hauppauge_generic_tunerconfig, 0);
981 break; 1105 break;
982 case CX23885_BOARD_HAUPPAUGE_HVR1270: 1106 case CX23885_BOARD_HAUPPAUGE_HVR1270:
983 case CX23885_BOARD_HAUPPAUGE_HVR1275: 1107 case CX23885_BOARD_HAUPPAUGE_HVR1275:
@@ -985,11 +1109,11 @@ static int dvb_register(struct cx23885_tsport *port)
985 fe0->dvb.frontend = dvb_attach(lgdt3305_attach, 1109 fe0->dvb.frontend = dvb_attach(lgdt3305_attach,
986 &hauppauge_lgdt3305_config, 1110 &hauppauge_lgdt3305_config,
987 &i2c_bus->i2c_adap); 1111 &i2c_bus->i2c_adap);
988 if (fe0->dvb.frontend != NULL) { 1112 if (fe0->dvb.frontend == NULL)
989 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1113 break;
990 0x60, &dev->i2c_bus[1].i2c_adap, 1114 dvb_attach(tda18271_attach, fe0->dvb.frontend,
991 &hauppauge_hvr127x_config); 1115 0x60, &dev->i2c_bus[1].i2c_adap,
992 } 1116 &hauppauge_hvr127x_config);
993 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275) 1117 if (dev->board == CX23885_BOARD_HAUPPAUGE_HVR1275)
994 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1118 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
995 break; 1119 break;
@@ -999,11 +1123,12 @@ static int dvb_register(struct cx23885_tsport *port)
999 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1123 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1000 &hcw_s5h1411_config, 1124 &hcw_s5h1411_config,
1001 &i2c_bus->i2c_adap); 1125 &i2c_bus->i2c_adap);
1002 if (fe0->dvb.frontend != NULL) { 1126 if (fe0->dvb.frontend == NULL)
1003 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1127 break;
1004 0x60, &dev->i2c_bus[1].i2c_adap, 1128
1005 &hauppauge_tda18271_config); 1129 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1006 } 1130 0x60, &dev->i2c_bus[1].i2c_adap,
1131 &hauppauge_tda18271_config);
1007 1132
1008 tda18271_attach(&dev->ts1.analog_fe, 1133 tda18271_attach(&dev->ts1.analog_fe,
1009 0x60, &dev->i2c_bus[1].i2c_adap, 1134 0x60, &dev->i2c_bus[1].i2c_adap,
@@ -1018,14 +1143,15 @@ static int dvb_register(struct cx23885_tsport *port)
1018 dvb_attach(s5h1409_attach, 1143 dvb_attach(s5h1409_attach,
1019 &hauppauge_ezqam_config, 1144 &hauppauge_ezqam_config,
1020 &i2c_bus->i2c_adap); 1145 &i2c_bus->i2c_adap);
1021 if (fe0->dvb.frontend != NULL) { 1146 if (fe0->dvb.frontend == NULL)
1022 dvb_attach(tda829x_attach, fe0->dvb.frontend, 1147 break;
1023 &dev->i2c_bus[1].i2c_adap, 0x42, 1148
1024 &tda829x_no_probe); 1149 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1025 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1150 &dev->i2c_bus[1].i2c_adap, 0x42,
1026 0x60, &dev->i2c_bus[1].i2c_adap, 1151 &tda829x_no_probe);
1027 &hauppauge_tda18271_config); 1152 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1028 } 1153 0x60, &dev->i2c_bus[1].i2c_adap,
1154 &hauppauge_tda18271_config);
1029 break; 1155 break;
1030 case 0: 1156 case 0:
1031 default: 1157 default:
@@ -1033,11 +1159,11 @@ static int dvb_register(struct cx23885_tsport *port)
1033 dvb_attach(s5h1409_attach, 1159 dvb_attach(s5h1409_attach,
1034 &hauppauge_generic_config, 1160 &hauppauge_generic_config,
1035 &i2c_bus->i2c_adap); 1161 &i2c_bus->i2c_adap);
1036 if (fe0->dvb.frontend != NULL) 1162 if (fe0->dvb.frontend == NULL)
1037 dvb_attach(mt2131_attach, fe0->dvb.frontend, 1163 break;
1038 &i2c_bus->i2c_adap, 1164 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1039 &hauppauge_generic_tunerconfig, 0); 1165 &i2c_bus->i2c_adap,
1040 break; 1166 &hauppauge_generic_tunerconfig, 0);
1041 } 1167 }
1042 break; 1168 break;
1043 case CX23885_BOARD_HAUPPAUGE_HVR1800lp: 1169 case CX23885_BOARD_HAUPPAUGE_HVR1800lp:
@@ -1045,32 +1171,33 @@ static int dvb_register(struct cx23885_tsport *port)
1045 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1171 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1046 &hauppauge_hvr1800lp_config, 1172 &hauppauge_hvr1800lp_config,
1047 &i2c_bus->i2c_adap); 1173 &i2c_bus->i2c_adap);
1048 if (fe0->dvb.frontend != NULL) { 1174 if (fe0->dvb.frontend == NULL)
1049 dvb_attach(mt2131_attach, fe0->dvb.frontend, 1175 break;
1050 &i2c_bus->i2c_adap, 1176 dvb_attach(mt2131_attach, fe0->dvb.frontend,
1051 &hauppauge_generic_tunerconfig, 0); 1177 &i2c_bus->i2c_adap,
1052 } 1178 &hauppauge_generic_tunerconfig, 0);
1053 break; 1179 break;
1054 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP: 1180 case CX23885_BOARD_DVICO_FUSIONHDTV_5_EXP:
1055 i2c_bus = &dev->i2c_bus[0]; 1181 i2c_bus = &dev->i2c_bus[0];
1056 fe0->dvb.frontend = dvb_attach(lgdt330x_attach, 1182 fe0->dvb.frontend = dvb_attach(lgdt330x_attach,
1057 &fusionhdtv_5_express, 1183 &fusionhdtv_5_express,
1058 &i2c_bus->i2c_adap); 1184 &i2c_bus->i2c_adap);
1059 if (fe0->dvb.frontend != NULL) { 1185 if (fe0->dvb.frontend == NULL)
1060 dvb_attach(simple_tuner_attach, fe0->dvb.frontend, 1186 break;
1061 &i2c_bus->i2c_adap, 0x61, 1187 dvb_attach(simple_tuner_attach, fe0->dvb.frontend,
1062 TUNER_LG_TDVS_H06XF); 1188 &i2c_bus->i2c_adap, 0x61,
1063 } 1189 TUNER_LG_TDVS_H06XF);
1064 break; 1190 break;
1065 case CX23885_BOARD_HAUPPAUGE_HVR1500Q: 1191 case CX23885_BOARD_HAUPPAUGE_HVR1500Q:
1066 i2c_bus = &dev->i2c_bus[1]; 1192 i2c_bus = &dev->i2c_bus[1];
1067 fe0->dvb.frontend = dvb_attach(s5h1409_attach, 1193 fe0->dvb.frontend = dvb_attach(s5h1409_attach,
1068 &hauppauge_hvr1500q_config, 1194 &hauppauge_hvr1500q_config,
1069 &dev->i2c_bus[0].i2c_adap); 1195 &dev->i2c_bus[0].i2c_adap);
1070 if (fe0->dvb.frontend != NULL) 1196 if (fe0->dvb.frontend == NULL)
1071 dvb_attach(xc5000_attach, fe0->dvb.frontend, 1197 break;
1072 &i2c_bus->i2c_adap, 1198 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1073 &hauppauge_hvr1500q_tunerconfig); 1199 &i2c_bus->i2c_adap,
1200 &hauppauge_hvr1500q_tunerconfig);
1074 break; 1201 break;
1075 case CX23885_BOARD_HAUPPAUGE_HVR1500: 1202 case CX23885_BOARD_HAUPPAUGE_HVR1500:
1076 i2c_bus = &dev->i2c_bus[1]; 1203 i2c_bus = &dev->i2c_bus[1];
@@ -1101,14 +1228,14 @@ static int dvb_register(struct cx23885_tsport *port)
1101 fe0->dvb.frontend = dvb_attach(tda10048_attach, 1228 fe0->dvb.frontend = dvb_attach(tda10048_attach,
1102 &hauppauge_hvr1200_config, 1229 &hauppauge_hvr1200_config,
1103 &i2c_bus->i2c_adap); 1230 &i2c_bus->i2c_adap);
1104 if (fe0->dvb.frontend != NULL) { 1231 if (fe0->dvb.frontend == NULL)
1105 dvb_attach(tda829x_attach, fe0->dvb.frontend, 1232 break;
1106 &dev->i2c_bus[1].i2c_adap, 0x42, 1233 dvb_attach(tda829x_attach, fe0->dvb.frontend,
1107 &tda829x_no_probe); 1234 &dev->i2c_bus[1].i2c_adap, 0x42,
1108 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1235 &tda829x_no_probe);
1109 0x60, &dev->i2c_bus[1].i2c_adap, 1236 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1110 &hauppauge_hvr1200_tuner_config); 1237 0x60, &dev->i2c_bus[1].i2c_adap,
1111 } 1238 &hauppauge_hvr1200_tuner_config);
1112 break; 1239 break;
1113 case CX23885_BOARD_HAUPPAUGE_HVR1210: 1240 case CX23885_BOARD_HAUPPAUGE_HVR1210:
1114 i2c_bus = &dev->i2c_bus[0]; 1241 i2c_bus = &dev->i2c_bus[0];
@@ -1367,12 +1494,10 @@ static int dvb_register(struct cx23885_tsport *port)
1367 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, 1494 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1368 &mygica_x8506_lgs8gl5_config, 1495 &mygica_x8506_lgs8gl5_config,
1369 &i2c_bus->i2c_adap); 1496 &i2c_bus->i2c_adap);
1370 if (fe0->dvb.frontend != NULL) { 1497 if (fe0->dvb.frontend == NULL)
1371 dvb_attach(xc5000_attach, 1498 break;
1372 fe0->dvb.frontend, 1499 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1373 &i2c_bus2->i2c_adap, 1500 &i2c_bus2->i2c_adap, &mygica_x8506_xc5000_config);
1374 &mygica_x8506_xc5000_config);
1375 }
1376 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1501 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1377 break; 1502 break;
1378 case CX23885_BOARD_MYGICA_X8507: 1503 case CX23885_BOARD_MYGICA_X8507:
@@ -1381,12 +1506,12 @@ static int dvb_register(struct cx23885_tsport *port)
1381 fe0->dvb.frontend = dvb_attach(mb86a20s_attach, 1506 fe0->dvb.frontend = dvb_attach(mb86a20s_attach,
1382 &mygica_x8507_mb86a20s_config, 1507 &mygica_x8507_mb86a20s_config,
1383 &i2c_bus->i2c_adap); 1508 &i2c_bus->i2c_adap);
1384 if (fe0->dvb.frontend != NULL) { 1509 if (fe0->dvb.frontend == NULL)
1385 dvb_attach(xc5000_attach, 1510 break;
1386 fe0->dvb.frontend, 1511
1387 &i2c_bus2->i2c_adap, 1512 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1388 &mygica_x8507_xc5000_config); 1513 &i2c_bus2->i2c_adap,
1389 } 1514 &mygica_x8507_xc5000_config);
1390 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1515 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1391 break; 1516 break;
1392 case CX23885_BOARD_MAGICPRO_PROHDTVE2: 1517 case CX23885_BOARD_MAGICPRO_PROHDTVE2:
@@ -1395,12 +1520,11 @@ static int dvb_register(struct cx23885_tsport *port)
1395 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach, 1520 fe0->dvb.frontend = dvb_attach(lgs8gxx_attach,
1396 &magicpro_prohdtve2_lgs8g75_config, 1521 &magicpro_prohdtve2_lgs8g75_config,
1397 &i2c_bus->i2c_adap); 1522 &i2c_bus->i2c_adap);
1398 if (fe0->dvb.frontend != NULL) { 1523 if (fe0->dvb.frontend == NULL)
1399 dvb_attach(xc5000_attach, 1524 break;
1400 fe0->dvb.frontend, 1525 dvb_attach(xc5000_attach, fe0->dvb.frontend,
1401 &i2c_bus2->i2c_adap, 1526 &i2c_bus2->i2c_adap,
1402 &magicpro_prohdtve2_xc5000_config); 1527 &magicpro_prohdtve2_xc5000_config);
1403 }
1404 cx23885_set_frontend_hook(port, fe0->dvb.frontend); 1528 cx23885_set_frontend_hook(port, fe0->dvb.frontend);
1405 break; 1529 break;
1406 case CX23885_BOARD_HAUPPAUGE_HVR1850: 1530 case CX23885_BOARD_HAUPPAUGE_HVR1850:
@@ -1408,10 +1532,11 @@ static int dvb_register(struct cx23885_tsport *port)
1408 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1532 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1409 &hcw_s5h1411_config, 1533 &hcw_s5h1411_config,
1410 &i2c_bus->i2c_adap); 1534 &i2c_bus->i2c_adap);
1411 if (fe0->dvb.frontend != NULL) 1535 if (fe0->dvb.frontend == NULL)
1412 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1536 break;
1413 0x60, &dev->i2c_bus[0].i2c_adap, 1537 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1414 &hauppauge_tda18271_config); 1538 0x60, &dev->i2c_bus[0].i2c_adap,
1539 &hauppauge_tda18271_config);
1415 1540
1416 tda18271_attach(&dev->ts1.analog_fe, 1541 tda18271_attach(&dev->ts1.analog_fe,
1417 0x60, &dev->i2c_bus[1].i2c_adap, 1542 0x60, &dev->i2c_bus[1].i2c_adap,
@@ -1423,10 +1548,11 @@ static int dvb_register(struct cx23885_tsport *port)
1423 fe0->dvb.frontend = dvb_attach(s5h1411_attach, 1548 fe0->dvb.frontend = dvb_attach(s5h1411_attach,
1424 &hcw_s5h1411_config, 1549 &hcw_s5h1411_config,
1425 &i2c_bus->i2c_adap); 1550 &i2c_bus->i2c_adap);
1426 if (fe0->dvb.frontend != NULL) 1551 if (fe0->dvb.frontend == NULL)
1427 dvb_attach(tda18271_attach, fe0->dvb.frontend, 1552 break;
1428 0x60, &dev->i2c_bus[0].i2c_adap, 1553 dvb_attach(tda18271_attach, fe0->dvb.frontend,
1429 &hauppauge_tda18271_config); 1554 0x60, &dev->i2c_bus[0].i2c_adap,
1555 &hauppauge_tda18271_config);
1430 break; 1556 break;
1431 case CX23885_BOARD_MYGICA_X8558PRO: 1557 case CX23885_BOARD_MYGICA_X8558PRO:
1432 switch (port->nr) { 1558 switch (port->nr) {
@@ -1436,12 +1562,11 @@ static int dvb_register(struct cx23885_tsport *port)
1436 fe0->dvb.frontend = dvb_attach(atbm8830_attach, 1562 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1437 &mygica_x8558pro_atbm8830_cfg1, 1563 &mygica_x8558pro_atbm8830_cfg1,
1438 &i2c_bus->i2c_adap); 1564 &i2c_bus->i2c_adap);
1439 if (fe0->dvb.frontend != NULL) { 1565 if (fe0->dvb.frontend == NULL)
1440 dvb_attach(max2165_attach, 1566 break;
1441 fe0->dvb.frontend, 1567 dvb_attach(max2165_attach, fe0->dvb.frontend,
1442 &i2c_bus->i2c_adap, 1568 &i2c_bus->i2c_adap,
1443 &mygic_x8558pro_max2165_cfg1); 1569 &mygic_x8558pro_max2165_cfg1);
1444 }
1445 break; 1570 break;
1446 /* port C */ 1571 /* port C */
1447 case 2: 1572 case 2:
@@ -1449,13 +1574,11 @@ static int dvb_register(struct cx23885_tsport *port)
1449 fe0->dvb.frontend = dvb_attach(atbm8830_attach, 1574 fe0->dvb.frontend = dvb_attach(atbm8830_attach,
1450 &mygica_x8558pro_atbm8830_cfg2, 1575 &mygica_x8558pro_atbm8830_cfg2,
1451 &i2c_bus->i2c_adap); 1576 &i2c_bus->i2c_adap);
1452 if (fe0->dvb.frontend != NULL) { 1577 if (fe0->dvb.frontend == NULL)
1453 dvb_attach(max2165_attach, 1578 break;
1454 fe0->dvb.frontend, 1579 dvb_attach(max2165_attach, fe0->dvb.frontend,
1455 &i2c_bus->i2c_adap, 1580 &i2c_bus->i2c_adap,
1456 &mygic_x8558pro_max2165_cfg2); 1581 &mygic_x8558pro_max2165_cfg2);
1457 }
1458 break;
1459 } 1582 }
1460 break; 1583 break;
1461 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF: 1584 case CX23885_BOARD_NETUP_DUAL_DVB_T_C_CI_RF:
@@ -1467,15 +1590,15 @@ static int dvb_register(struct cx23885_tsport *port)
1467 fe0->dvb.frontend = dvb_attach(stv0367ter_attach, 1590 fe0->dvb.frontend = dvb_attach(stv0367ter_attach,
1468 &netup_stv0367_config[port->nr - 1], 1591 &netup_stv0367_config[port->nr - 1],
1469 &i2c_bus->i2c_adap); 1592 &i2c_bus->i2c_adap);
1470 if (fe0->dvb.frontend != NULL) { 1593 if (fe0->dvb.frontend == NULL)
1471 if (NULL == dvb_attach(xc5000_attach, 1594 break;
1472 fe0->dvb.frontend, 1595 if (NULL == dvb_attach(xc5000_attach, fe0->dvb.frontend,
1473 &i2c_bus->i2c_adap, 1596 &i2c_bus->i2c_adap,
1474 &netup_xc5000_config[port->nr - 1])) 1597 &netup_xc5000_config[port->nr - 1]))
1475 goto frontend_detach; 1598 goto frontend_detach;
1476 /* load xc5000 firmware */ 1599 /* load xc5000 firmware */
1477 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend); 1600 fe0->dvb.frontend->ops.tuner_ops.init(fe0->dvb.frontend);
1478 } 1601
1479 /* MFE frontend 2 */ 1602 /* MFE frontend 2 */
1480 fe1 = vb2_dvb_get_frontend(&port->frontends, 2); 1603 fe1 = vb2_dvb_get_frontend(&port->frontends, 2);
1481 if (fe1 == NULL) 1604 if (fe1 == NULL)
@@ -1484,14 +1607,15 @@ static int dvb_register(struct cx23885_tsport *port)
1484 fe1->dvb.frontend = dvb_attach(stv0367cab_attach, 1607 fe1->dvb.frontend = dvb_attach(stv0367cab_attach,
1485 &netup_stv0367_config[port->nr - 1], 1608 &netup_stv0367_config[port->nr - 1],
1486 &i2c_bus->i2c_adap); 1609 &i2c_bus->i2c_adap);
1487 if (fe1->dvb.frontend != NULL) { 1610 if (fe1->dvb.frontend == NULL)
1488 fe1->dvb.frontend->id = 1; 1611 break;
1489 if (NULL == dvb_attach(xc5000_attach, 1612
1490 fe1->dvb.frontend, 1613 fe1->dvb.frontend->id = 1;
1491 &i2c_bus->i2c_adap, 1614 if (NULL == dvb_attach(xc5000_attach,
1492 &netup_xc5000_config[port->nr - 1])) 1615 fe1->dvb.frontend,
1493 goto frontend_detach; 1616 &i2c_bus->i2c_adap,
1494 } 1617 &netup_xc5000_config[port->nr - 1]))
1618 goto frontend_detach;
1495 break; 1619 break;
1496 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL: 1620 case CX23885_BOARD_TERRATEC_CINERGY_T_PCIE_DUAL:
1497 i2c_bus = &dev->i2c_bus[0]; 1621 i2c_bus = &dev->i2c_bus[0];
@@ -1503,26 +1627,26 @@ static int dvb_register(struct cx23885_tsport *port)
1503 fe0->dvb.frontend = dvb_attach(drxk_attach, 1627 fe0->dvb.frontend = dvb_attach(drxk_attach,
1504 &terratec_drxk_config[0], 1628 &terratec_drxk_config[0],
1505 &i2c_bus->i2c_adap); 1629 &i2c_bus->i2c_adap);
1506 if (fe0->dvb.frontend != NULL) { 1630 if (fe0->dvb.frontend == NULL)
1507 if (!dvb_attach(mt2063_attach, 1631 break;
1508 fe0->dvb.frontend, 1632 if (!dvb_attach(mt2063_attach,
1509 &terratec_mt2063_config[0], 1633 fe0->dvb.frontend,
1510 &i2c_bus2->i2c_adap)) 1634 &terratec_mt2063_config[0],
1511 goto frontend_detach; 1635 &i2c_bus2->i2c_adap))
1512 } 1636 goto frontend_detach;
1513 break; 1637 break;
1514 /* port c */ 1638 /* port c */
1515 case 2: 1639 case 2:
1516 fe0->dvb.frontend = dvb_attach(drxk_attach, 1640 fe0->dvb.frontend = dvb_attach(drxk_attach,
1517 &terratec_drxk_config[1], 1641 &terratec_drxk_config[1],
1518 &i2c_bus->i2c_adap); 1642 &i2c_bus->i2c_adap);
1519 if (fe0->dvb.frontend != NULL) { 1643 if (fe0->dvb.frontend == NULL)
1520 if (!dvb_attach(mt2063_attach, 1644 break;
1521 fe0->dvb.frontend, 1645 if (!dvb_attach(mt2063_attach,
1522 &terratec_mt2063_config[1], 1646 fe0->dvb.frontend,
1523 &i2c_bus2->i2c_adap)) 1647 &terratec_mt2063_config[1],
1524 goto frontend_detach; 1648 &i2c_bus2->i2c_adap))
1525 } 1649 goto frontend_detach;
1526 break; 1650 break;
1527 } 1651 }
1528 break; 1652 break;
@@ -1532,10 +1656,10 @@ static int dvb_register(struct cx23885_tsport *port)
1532 fe0->dvb.frontend = dvb_attach(ds3000_attach, 1656 fe0->dvb.frontend = dvb_attach(ds3000_attach,
1533 &tevii_ds3000_config, 1657 &tevii_ds3000_config,
1534 &i2c_bus->i2c_adap); 1658 &i2c_bus->i2c_adap);
1535 if (fe0->dvb.frontend != NULL) { 1659 if (fe0->dvb.frontend == NULL)
1536 dvb_attach(ts2020_attach, fe0->dvb.frontend, 1660 break;
1537 &tevii_ts2020_config, &i2c_bus->i2c_adap); 1661 dvb_attach(ts2020_attach, fe0->dvb.frontend,
1538 } 1662 &tevii_ts2020_config, &i2c_bus->i2c_adap);
1539 break; 1663 break;
1540 case CX23885_BOARD_PROF_8000: 1664 case CX23885_BOARD_PROF_8000:
1541 i2c_bus = &dev->i2c_bus[0]; 1665 i2c_bus = &dev->i2c_bus[0];
@@ -1544,15 +1668,15 @@ static int dvb_register(struct cx23885_tsport *port)
1544 &prof_8000_stv090x_config, 1668 &prof_8000_stv090x_config,
1545 &i2c_bus->i2c_adap, 1669 &i2c_bus->i2c_adap,
1546 STV090x_DEMODULATOR_0); 1670 STV090x_DEMODULATOR_0);
1547 if (fe0->dvb.frontend != NULL) { 1671 if (fe0->dvb.frontend == NULL)
1548 if (!dvb_attach(stb6100_attach, 1672 break;
1549 fe0->dvb.frontend, 1673 if (!dvb_attach(stb6100_attach,
1550 &prof_8000_stb6100_config, 1674 fe0->dvb.frontend,
1551 &i2c_bus->i2c_adap)) 1675 &prof_8000_stb6100_config,
1552 goto frontend_detach; 1676 &i2c_bus->i2c_adap))
1677 goto frontend_detach;
1553 1678
1554 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage; 1679 fe0->dvb.frontend->ops.set_voltage = p8000_set_voltage;
1555 }
1556 break; 1680 break;
1557 case CX23885_BOARD_HAUPPAUGE_HVR4400: 1681 case CX23885_BOARD_HAUPPAUGE_HVR4400:
1558 i2c_bus = &dev->i2c_bus[0]; 1682 i2c_bus = &dev->i2c_bus[0];
@@ -1563,30 +1687,31 @@ static int dvb_register(struct cx23885_tsport *port)
1563 fe0->dvb.frontend = dvb_attach(tda10071_attach, 1687 fe0->dvb.frontend = dvb_attach(tda10071_attach,
1564 &hauppauge_tda10071_config, 1688 &hauppauge_tda10071_config,
1565 &i2c_bus->i2c_adap); 1689 &i2c_bus->i2c_adap);
1566 if (fe0->dvb.frontend != NULL) { 1690 if (fe0->dvb.frontend == NULL)
1567 if (!dvb_attach(a8293_attach, fe0->dvb.frontend, 1691 break;
1568 &i2c_bus->i2c_adap, 1692 if (!dvb_attach(a8293_attach, fe0->dvb.frontend,
1569 &hauppauge_a8293_config)) 1693 &i2c_bus->i2c_adap,
1570 goto frontend_detach; 1694 &hauppauge_a8293_config))
1571 } 1695 goto frontend_detach;
1572 break; 1696 break;
1573 /* port c */ 1697 /* port c */
1574 case 2: 1698 case 2:
1575 fe0->dvb.frontend = dvb_attach(si2165_attach, 1699 fe0->dvb.frontend = dvb_attach(si2165_attach,
1576 &hauppauge_hvr4400_si2165_config, 1700 &hauppauge_hvr4400_si2165_config,
1577 &i2c_bus->i2c_adap); 1701 &i2c_bus->i2c_adap);
1578 if (fe0->dvb.frontend != NULL) { 1702 if (fe0->dvb.frontend == NULL)
1579 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL; 1703 break;
1580 if (!dvb_attach(tda18271_attach, 1704 fe0->dvb.frontend->ops.i2c_gate_ctrl = NULL;
1581 fe0->dvb.frontend, 1705 if (!dvb_attach(tda18271_attach,
1582 0x60, &i2c_bus2->i2c_adap, 1706 fe0->dvb.frontend,
1583 &hauppauge_hvr4400_tuner_config)) 1707 0x60, &i2c_bus2->i2c_adap,
1584 goto frontend_detach; 1708 &hauppauge_hvr4400_tuner_config))
1585 } 1709 goto frontend_detach;
1586 break; 1710 break;
1587 } 1711 }
1588 break; 1712 break;
1589 case CX23885_BOARD_DVBSKY_T9580: 1713 case CX23885_BOARD_DVBSKY_T9580:
1714 case CX23885_BOARD_DVBSKY_S950:
1590 i2c_bus = &dev->i2c_bus[0]; 1715 i2c_bus = &dev->i2c_bus[0];
1591 i2c_bus2 = &dev->i2c_bus[1]; 1716 i2c_bus2 = &dev->i2c_bus[1];
1592 switch (port->nr) { 1717 switch (port->nr) {
@@ -1680,6 +1805,201 @@ static int dvb_register(struct cx23885_tsport *port)
1680 break; 1805 break;
1681 } 1806 }
1682 break; 1807 break;
1808 case CX23885_BOARD_DVBSKY_T980C:
1809 case CX23885_BOARD_TT_CT2_4500_CI:
1810 i2c_bus = &dev->i2c_bus[1];
1811 i2c_bus2 = &dev->i2c_bus[0];
1812
1813 /* attach frontend */
1814 memset(&si2168_config, 0, sizeof(si2168_config));
1815 si2168_config.i2c_adapter = &adapter;
1816 si2168_config.fe = &fe0->dvb.frontend;
1817 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1818 memset(&info, 0, sizeof(struct i2c_board_info));
1819 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1820 info.addr = 0x64;
1821 info.platform_data = &si2168_config;
1822 request_module(info.type);
1823 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1824 if (client_demod == NULL ||
1825 client_demod->dev.driver == NULL)
1826 goto frontend_detach;
1827 if (!try_module_get(client_demod->dev.driver->owner)) {
1828 i2c_unregister_device(client_demod);
1829 goto frontend_detach;
1830 }
1831 port->i2c_client_demod = client_demod;
1832
1833 /* attach tuner */
1834 memset(&si2157_config, 0, sizeof(si2157_config));
1835 si2157_config.fe = fe0->dvb.frontend;
1836 memset(&info, 0, sizeof(struct i2c_board_info));
1837 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1838 info.addr = 0x60;
1839 info.platform_data = &si2157_config;
1840 request_module(info.type);
1841 client_tuner = i2c_new_device(adapter, &info);
1842 if (client_tuner == NULL ||
1843 client_tuner->dev.driver == NULL) {
1844 module_put(client_demod->dev.driver->owner);
1845 i2c_unregister_device(client_demod);
1846 goto frontend_detach;
1847 }
1848 if (!try_module_get(client_tuner->dev.driver->owner)) {
1849 i2c_unregister_device(client_tuner);
1850 module_put(client_demod->dev.driver->owner);
1851 i2c_unregister_device(client_demod);
1852 goto frontend_detach;
1853 }
1854 port->i2c_client_tuner = client_tuner;
1855 break;
1856 case CX23885_BOARD_DVBSKY_S950C:
1857 i2c_bus = &dev->i2c_bus[1];
1858 i2c_bus2 = &dev->i2c_bus[0];
1859
1860 /* attach frontend */
1861 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1862 &dvbsky_s950c_m88ds3103_config,
1863 &i2c_bus->i2c_adap, &adapter);
1864 if (fe0->dvb.frontend == NULL)
1865 break;
1866
1867 /* attach tuner */
1868 memset(&m88ts2022_config, 0, sizeof(m88ts2022_config));
1869 m88ts2022_config.fe = fe0->dvb.frontend;
1870 m88ts2022_config.clock = 27000000;
1871 memset(&info, 0, sizeof(struct i2c_board_info));
1872 strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE);
1873 info.addr = 0x60;
1874 info.platform_data = &m88ts2022_config;
1875 request_module(info.type);
1876 client_tuner = i2c_new_device(adapter, &info);
1877 if (client_tuner == NULL ||
1878 client_tuner->dev.driver == NULL)
1879 goto frontend_detach;
1880 if (!try_module_get(client_tuner->dev.driver->owner)) {
1881 i2c_unregister_device(client_tuner);
1882 goto frontend_detach;
1883 }
1884
1885 /* delegate signal strength measurement to tuner */
1886 fe0->dvb.frontend->ops.read_signal_strength =
1887 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1888
1889 port->i2c_client_tuner = client_tuner;
1890 break;
1891 case CX23885_BOARD_DVBSKY_S952:
1892 switch (port->nr) {
1893 /* port b */
1894 case 1:
1895 i2c_bus = &dev->i2c_bus[1];
1896 p_m88ds3103_config = &dvbsky_t9580_m88ds3103_config;
1897 p_set_voltage = dvbsky_t9580_set_voltage;
1898 break;
1899 /* port c */
1900 case 2:
1901 i2c_bus = &dev->i2c_bus[0];
1902 p_m88ds3103_config = &dvbsky_s952_portc_m88ds3103_config;
1903 p_set_voltage = dvbsky_s952_portc_set_voltage;
1904 break;
1905 }
1906
1907 /* attach frontend */
1908 fe0->dvb.frontend = dvb_attach(m88ds3103_attach,
1909 p_m88ds3103_config,
1910 &i2c_bus->i2c_adap, &adapter);
1911 if (fe0->dvb.frontend == NULL)
1912 break;
1913
1914 /* attach tuner */
1915 memset(&m88ts2022_config, 0, sizeof(m88ts2022_config));
1916 m88ts2022_config.fe = fe0->dvb.frontend;
1917 m88ts2022_config.clock = 27000000;
1918 memset(&info, 0, sizeof(struct i2c_board_info));
1919 strlcpy(info.type, "m88ts2022", I2C_NAME_SIZE);
1920 info.addr = 0x60;
1921 info.platform_data = &m88ts2022_config;
1922 request_module(info.type);
1923 client_tuner = i2c_new_device(adapter, &info);
1924 if (client_tuner == NULL ||
1925 client_tuner->dev.driver == NULL)
1926 goto frontend_detach;
1927 if (!try_module_get(client_tuner->dev.driver->owner)) {
1928 i2c_unregister_device(client_tuner);
1929 goto frontend_detach;
1930 }
1931
1932 /* delegate signal strength measurement to tuner */
1933 fe0->dvb.frontend->ops.read_signal_strength =
1934 fe0->dvb.frontend->ops.tuner_ops.get_rf_strength;
1935
1936 /*
1937 * for setting the voltage we need to set GPIOs on
1938 * the card.
1939 */
1940 port->fe_set_voltage =
1941 fe0->dvb.frontend->ops.set_voltage;
1942 fe0->dvb.frontend->ops.set_voltage = p_set_voltage;
1943
1944 port->i2c_client_tuner = client_tuner;
1945 break;
1946 case CX23885_BOARD_DVBSKY_T982:
1947 memset(&si2168_config, 0, sizeof(si2168_config));
1948 switch (port->nr) {
1949 /* port b */
1950 case 1:
1951 i2c_bus = &dev->i2c_bus[1];
1952 si2168_config.ts_mode = SI2168_TS_PARALLEL;
1953 break;
1954 /* port c */
1955 case 2:
1956 i2c_bus = &dev->i2c_bus[0];
1957 si2168_config.ts_mode = SI2168_TS_SERIAL;
1958 break;
1959 }
1960
1961 /* attach frontend */
1962 si2168_config.i2c_adapter = &adapter;
1963 si2168_config.fe = &fe0->dvb.frontend;
1964 memset(&info, 0, sizeof(struct i2c_board_info));
1965 strlcpy(info.type, "si2168", I2C_NAME_SIZE);
1966 info.addr = 0x64;
1967 info.platform_data = &si2168_config;
1968 request_module(info.type);
1969 client_demod = i2c_new_device(&i2c_bus->i2c_adap, &info);
1970 if (client_demod == NULL ||
1971 client_demod->dev.driver == NULL)
1972 goto frontend_detach;
1973 if (!try_module_get(client_demod->dev.driver->owner)) {
1974 i2c_unregister_device(client_demod);
1975 goto frontend_detach;
1976 }
1977 port->i2c_client_demod = client_demod;
1978
1979 /* attach tuner */
1980 memset(&si2157_config, 0, sizeof(si2157_config));
1981 si2157_config.fe = fe0->dvb.frontend;
1982 memset(&info, 0, sizeof(struct i2c_board_info));
1983 strlcpy(info.type, "si2157", I2C_NAME_SIZE);
1984 info.addr = 0x60;
1985 info.platform_data = &si2157_config;
1986 request_module(info.type);
1987 client_tuner = i2c_new_device(adapter, &info);
1988 if (client_tuner == NULL ||
1989 client_tuner->dev.driver == NULL) {
1990 module_put(client_demod->dev.driver->owner);
1991 i2c_unregister_device(client_demod);
1992 goto frontend_detach;
1993 }
1994 if (!try_module_get(client_tuner->dev.driver->owner)) {
1995 i2c_unregister_device(client_tuner);
1996 module_put(client_demod->dev.driver->owner);
1997 i2c_unregister_device(client_demod);
1998 port->i2c_client_demod = NULL;
1999 goto frontend_detach;
2000 }
2001 port->i2c_client_tuner = client_tuner;
2002 break;
1683 default: 2003 default:
1684 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card " 2004 printk(KERN_INFO "%s: The frontend of your DVB/ATSC card "
1685 " isn't supported yet\n", 2005 " isn't supported yet\n",
@@ -1754,7 +2074,10 @@ static int dvb_register(struct cx23885_tsport *port)
1754 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6); 2074 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xa0, 6);
1755 break; 2075 break;
1756 } 2076 }
1757 case CX23885_BOARD_DVBSKY_T9580: { 2077 case CX23885_BOARD_DVBSKY_T9580:
2078 case CX23885_BOARD_DVBSKY_S950:
2079 case CX23885_BOARD_DVBSKY_S952:
2080 case CX23885_BOARD_DVBSKY_T982: {
1758 u8 eeprom[256]; /* 24C02 i2c eeprom */ 2081 u8 eeprom[256]; /* 24C02 i2c eeprom */
1759 2082
1760 if (port->nr > 2) 2083 if (port->nr > 2)
@@ -1764,12 +2087,67 @@ static int dvb_register(struct cx23885_tsport *port)
1764 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1; 2087 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
1765 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom, 2088 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
1766 sizeof(eeprom)); 2089 sizeof(eeprom));
1767 printk(KERN_INFO "DVBSky T9580 port %d MAC address: %pM\n", 2090 printk(KERN_INFO "%s port %d MAC address: %pM\n",
1768 port->nr, eeprom + 0xc0 + (port->nr-1) * 8); 2091 cx23885_boards[dev->board].name, port->nr,
2092 eeprom + 0xc0 + (port->nr-1) * 8);
1769 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 + 2093 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0 +
1770 (port->nr-1) * 8, 6); 2094 (port->nr-1) * 8, 6);
1771 break; 2095 break;
1772 } 2096 }
2097 case CX23885_BOARD_DVBSKY_S950C:
2098 case CX23885_BOARD_DVBSKY_T980C:
2099 case CX23885_BOARD_TT_CT2_4500_CI: {
2100 u8 eeprom[256]; /* 24C02 i2c eeprom */
2101
2102 /* attach CI */
2103 memset(&sp2_config, 0, sizeof(sp2_config));
2104 sp2_config.dvb_adap = &port->frontends.adapter;
2105 sp2_config.priv = port;
2106 sp2_config.ci_control = cx23885_sp2_ci_ctrl;
2107 memset(&info, 0, sizeof(struct i2c_board_info));
2108 strlcpy(info.type, "sp2", I2C_NAME_SIZE);
2109 info.addr = 0x40;
2110 info.platform_data = &sp2_config;
2111 request_module(info.type);
2112 client_ci = i2c_new_device(&i2c_bus2->i2c_adap, &info);
2113 if (client_ci == NULL ||
2114 client_ci->dev.driver == NULL) {
2115 if (client_tuner) {
2116 module_put(client_tuner->dev.driver->owner);
2117 i2c_unregister_device(client_tuner);
2118 }
2119 if (client_demod) {
2120 module_put(client_demod->dev.driver->owner);
2121 i2c_unregister_device(client_demod);
2122 }
2123 goto frontend_detach;
2124 }
2125 if (!try_module_get(client_ci->dev.driver->owner)) {
2126 i2c_unregister_device(client_ci);
2127 if (client_tuner) {
2128 module_put(client_tuner->dev.driver->owner);
2129 i2c_unregister_device(client_tuner);
2130 }
2131 if (client_demod) {
2132 module_put(client_demod->dev.driver->owner);
2133 i2c_unregister_device(client_demod);
2134 }
2135 goto frontend_detach;
2136 }
2137 port->i2c_client_ci = client_ci;
2138
2139 if (port->nr != 1)
2140 break;
2141
2142 /* Read entire EEPROM */
2143 dev->i2c_bus[0].i2c_client.addr = 0xa0 >> 1;
2144 tveeprom_read(&dev->i2c_bus[0].i2c_client, eeprom,
2145 sizeof(eeprom));
2146 printk(KERN_INFO "%s MAC address: %pM\n",
2147 cx23885_boards[dev->board].name, eeprom + 0xc0);
2148 memcpy(port->frontends.adapter.proposed_mac, eeprom + 0xc0, 6);
2149 break;
2150 }
1773 } 2151 }
1774 2152
1775 return ret; 2153 return ret;
@@ -1810,7 +2188,7 @@ int cx23885_dvb_register(struct cx23885_tsport *port)
1810 2188
1811 fe0 = vb2_dvb_get_frontend(&port->frontends, i); 2189 fe0 = vb2_dvb_get_frontend(&port->frontends, i);
1812 if (!fe0) 2190 if (!fe0)
1813 err = -EINVAL; 2191 return -EINVAL;
1814 2192
1815 dprintk(1, "%s\n", __func__); 2193 dprintk(1, "%s\n", __func__);
1816 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n", 2194 dprintk(1, " ->probed by Card=%d Name=%s, PCI %02x:%02x\n",
@@ -1853,6 +2231,13 @@ int cx23885_dvb_unregister(struct cx23885_tsport *port)
1853 struct vb2_dvb_frontend *fe0; 2231 struct vb2_dvb_frontend *fe0;
1854 struct i2c_client *client; 2232 struct i2c_client *client;
1855 2233
2234 /* remove I2C client for CI */
2235 client = port->i2c_client_ci;
2236 if (client) {
2237 module_put(client->dev.driver->owner);
2238 i2c_unregister_device(client);
2239 }
2240
1856 /* remove I2C client for tuner */ 2241 /* remove I2C client for tuner */
1857 client = port->i2c_client_tuner; 2242 client = port->i2c_client_tuner;
1858 if (client) { 2243 if (client) {
diff --git a/drivers/media/pci/cx23885/cx23885-input.c b/drivers/media/pci/cx23885/cx23885-input.c
index 9d37fe661691..088799c3b49b 100644
--- a/drivers/media/pci/cx23885/cx23885-input.c
+++ b/drivers/media/pci/cx23885/cx23885-input.c
@@ -87,6 +87,13 @@ void cx23885_input_rx_work_handler(struct cx23885_dev *dev, u32 events)
87 case CX23885_BOARD_MYGICA_X8507: 87 case CX23885_BOARD_MYGICA_X8507:
88 case CX23885_BOARD_TBS_6980: 88 case CX23885_BOARD_TBS_6980:
89 case CX23885_BOARD_TBS_6981: 89 case CX23885_BOARD_TBS_6981:
90 case CX23885_BOARD_DVBSKY_T9580:
91 case CX23885_BOARD_DVBSKY_T980C:
92 case CX23885_BOARD_DVBSKY_S950C:
93 case CX23885_BOARD_TT_CT2_4500_CI:
94 case CX23885_BOARD_DVBSKY_S950:
95 case CX23885_BOARD_DVBSKY_S952:
96 case CX23885_BOARD_DVBSKY_T982:
90 /* 97 /*
91 * The only boards we handle right now. However other boards 98 * The only boards we handle right now. However other boards
92 * using the CX2388x integrated IR controller should be similar 99 * using the CX2388x integrated IR controller should be similar
@@ -139,6 +146,13 @@ static int cx23885_input_ir_start(struct cx23885_dev *dev)
139 case CX23885_BOARD_HAUPPAUGE_HVR1290: 146 case CX23885_BOARD_HAUPPAUGE_HVR1290:
140 case CX23885_BOARD_HAUPPAUGE_HVR1250: 147 case CX23885_BOARD_HAUPPAUGE_HVR1250:
141 case CX23885_BOARD_MYGICA_X8507: 148 case CX23885_BOARD_MYGICA_X8507:
149 case CX23885_BOARD_DVBSKY_T9580:
150 case CX23885_BOARD_DVBSKY_T980C:
151 case CX23885_BOARD_DVBSKY_S950C:
152 case CX23885_BOARD_TT_CT2_4500_CI:
153 case CX23885_BOARD_DVBSKY_S950:
154 case CX23885_BOARD_DVBSKY_S952:
155 case CX23885_BOARD_DVBSKY_T982:
142 /* 156 /*
143 * The IR controller on this board only returns pulse widths. 157 * The IR controller on this board only returns pulse widths.
144 * Any other mode setting will fail to set up the device. 158 * Any other mode setting will fail to set up the device.
@@ -305,6 +319,23 @@ int cx23885_input_init(struct cx23885_dev *dev)
305 /* A guess at the remote */ 319 /* A guess at the remote */
306 rc_map = RC_MAP_TBS_NEC; 320 rc_map = RC_MAP_TBS_NEC;
307 break; 321 break;
322 case CX23885_BOARD_DVBSKY_T9580:
323 case CX23885_BOARD_DVBSKY_T980C:
324 case CX23885_BOARD_DVBSKY_S950C:
325 case CX23885_BOARD_DVBSKY_S950:
326 case CX23885_BOARD_DVBSKY_S952:
327 case CX23885_BOARD_DVBSKY_T982:
328 /* Integrated CX23885 IR controller */
329 driver_type = RC_DRIVER_IR_RAW;
330 allowed_protos = RC_BIT_ALL;
331 rc_map = RC_MAP_DVBSKY;
332 break;
333 case CX23885_BOARD_TT_CT2_4500_CI:
334 /* Integrated CX23885 IR controller */
335 driver_type = RC_DRIVER_IR_RAW;
336 allowed_protos = RC_BIT_ALL;
337 rc_map = RC_MAP_TT_1500;
338 break;
308 default: 339 default:
309 return -ENODEV; 340 return -ENODEV;
310 } 341 }
diff --git a/drivers/media/pci/cx23885/cx23885-vbi.c b/drivers/media/pci/cx23885/cx23885-vbi.c
index a7c6ef8f3ea3..d362d3838c84 100644
--- a/drivers/media/pci/cx23885/cx23885-vbi.c
+++ b/drivers/media/pci/cx23885/cx23885-vbi.c
@@ -132,6 +132,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
132 lines = VBI_NTSC_LINE_COUNT; 132 lines = VBI_NTSC_LINE_COUNT;
133 *num_planes = 1; 133 *num_planes = 1;
134 sizes[0] = lines * VBI_LINE_LENGTH * 2; 134 sizes[0] = lines * VBI_LINE_LENGTH * 2;
135 alloc_ctxs[0] = dev->alloc_ctx;
135 return 0; 136 return 0;
136} 137}
137 138
@@ -142,7 +143,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
142 struct cx23885_buffer, vb); 143 struct cx23885_buffer, vb);
143 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); 144 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
144 unsigned lines = VBI_PAL_LINE_COUNT; 145 unsigned lines = VBI_PAL_LINE_COUNT;
145 int ret;
146 146
147 if (dev->tvnorm & V4L2_STD_525_60) 147 if (dev->tvnorm & V4L2_STD_525_60)
148 lines = VBI_NTSC_LINE_COUNT; 148 lines = VBI_NTSC_LINE_COUNT;
@@ -151,10 +151,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
151 return -EINVAL; 151 return -EINVAL;
152 vb2_set_plane_payload(vb, 0, lines * VBI_LINE_LENGTH * 2); 152 vb2_set_plane_payload(vb, 0, lines * VBI_LINE_LENGTH * 2);
153 153
154 ret = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
155 if (!ret)
156 return -EIO;
157
158 cx23885_risc_vbibuffer(dev->pci, &buf->risc, 154 cx23885_risc_vbibuffer(dev->pci, &buf->risc,
159 sgt->sgl, 155 sgt->sgl,
160 0, VBI_LINE_LENGTH * lines, 156 0, VBI_LINE_LENGTH * lines,
@@ -165,14 +161,10 @@ static int buffer_prepare(struct vb2_buffer *vb)
165 161
166static void buffer_finish(struct vb2_buffer *vb) 162static void buffer_finish(struct vb2_buffer *vb)
167{ 163{
168 struct cx23885_dev *dev = vb->vb2_queue->drv_priv;
169 struct cx23885_buffer *buf = container_of(vb, 164 struct cx23885_buffer *buf = container_of(vb,
170 struct cx23885_buffer, vb); 165 struct cx23885_buffer, vb);
171 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
172 166
173 cx23885_free_buffer(vb->vb2_queue->drv_priv, buf); 167 cx23885_free_buffer(vb->vb2_queue->drv_priv, buf);
174
175 dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
176} 168}
177 169
178/* 170/*
diff --git a/drivers/media/pci/cx23885/cx23885-video.c b/drivers/media/pci/cx23885/cx23885-video.c
index 682a4f95df6b..5e93c682a3f5 100644
--- a/drivers/media/pci/cx23885/cx23885-video.c
+++ b/drivers/media/pci/cx23885/cx23885-video.c
@@ -323,6 +323,7 @@ static int queue_setup(struct vb2_queue *q, const struct v4l2_format *fmt,
323 323
324 *num_planes = 1; 324 *num_planes = 1;
325 sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3; 325 sizes[0] = (dev->fmt->depth * dev->width * dev->height) >> 3;
326 alloc_ctxs[0] = dev->alloc_ctx;
326 return 0; 327 return 0;
327} 328}
328 329
@@ -334,7 +335,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
334 u32 line0_offset, line1_offset; 335 u32 line0_offset, line1_offset;
335 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0); 336 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
336 int field_tff; 337 int field_tff;
337 int ret;
338 338
339 buf->bpl = (dev->width * dev->fmt->depth) >> 3; 339 buf->bpl = (dev->width * dev->fmt->depth) >> 3;
340 340
@@ -342,10 +342,6 @@ static int buffer_prepare(struct vb2_buffer *vb)
342 return -EINVAL; 342 return -EINVAL;
343 vb2_set_plane_payload(vb, 0, dev->height * buf->bpl); 343 vb2_set_plane_payload(vb, 0, dev->height * buf->bpl);
344 344
345 ret = dma_map_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
346 if (!ret)
347 return -EIO;
348
349 switch (dev->field) { 345 switch (dev->field) {
350 case V4L2_FIELD_TOP: 346 case V4L2_FIELD_TOP:
351 cx23885_risc_buffer(dev->pci, &buf->risc, 347 cx23885_risc_buffer(dev->pci, &buf->risc,
@@ -413,14 +409,10 @@ static int buffer_prepare(struct vb2_buffer *vb)
413 409
414static void buffer_finish(struct vb2_buffer *vb) 410static void buffer_finish(struct vb2_buffer *vb)
415{ 411{
416 struct cx23885_dev *dev = vb->vb2_queue->drv_priv;
417 struct cx23885_buffer *buf = container_of(vb, 412 struct cx23885_buffer *buf = container_of(vb,
418 struct cx23885_buffer, vb); 413 struct cx23885_buffer, vb);
419 struct sg_table *sgt = vb2_dma_sg_plane_desc(vb, 0);
420 414
421 cx23885_free_buffer(vb->vb2_queue->drv_priv, buf); 415 cx23885_free_buffer(vb->vb2_queue->drv_priv, buf);
422
423 dma_unmap_sg(&dev->pci->dev, sgt->sgl, sgt->nents, DMA_FROM_DEVICE);
424} 416}
425 417
426/* 418/*
@@ -608,7 +600,7 @@ static int vidioc_s_fmt_vid_cap(struct file *file, void *priv,
608 dev->field = f->fmt.pix.field; 600 dev->field = f->fmt.pix.field;
609 dprintk(2, "%s() width=%d height=%d field=%d\n", __func__, 601 dprintk(2, "%s() width=%d height=%d field=%d\n", __func__,
610 dev->width, dev->height, dev->field); 602 dev->width, dev->height, dev->field);
611 v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED); 603 v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, MEDIA_BUS_FMT_FIXED);
612 call_all(dev, video, s_mbus_fmt, &mbus_fmt); 604 call_all(dev, video, s_mbus_fmt, &mbus_fmt);
613 v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt); 605 v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt);
614 /* s_mbus_fmt overwrites f->fmt.pix.field, restore it */ 606 /* s_mbus_fmt overwrites f->fmt.pix.field, restore it */
diff --git a/drivers/media/pci/cx23885/cx23885.h b/drivers/media/pci/cx23885/cx23885.h
index 6c35e6115969..f55cd12da0fd 100644
--- a/drivers/media/pci/cx23885/cx23885.h
+++ b/drivers/media/pci/cx23885/cx23885.h
@@ -93,6 +93,12 @@
93#define CX23885_BOARD_HAUPPAUGE_IMPACTVCBE 43 93#define CX23885_BOARD_HAUPPAUGE_IMPACTVCBE 43
94#define CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2 44 94#define CX23885_BOARD_DVICO_FUSIONHDTV_DVB_T_DUAL_EXP2 44
95#define CX23885_BOARD_DVBSKY_T9580 45 95#define CX23885_BOARD_DVBSKY_T9580 45
96#define CX23885_BOARD_DVBSKY_T980C 46
97#define CX23885_BOARD_DVBSKY_S950C 47
98#define CX23885_BOARD_TT_CT2_4500_CI 48
99#define CX23885_BOARD_DVBSKY_S950 49
100#define CX23885_BOARD_DVBSKY_S952 50
101#define CX23885_BOARD_DVBSKY_T982 51
96 102
97#define GPIO_0 0x00000001 103#define GPIO_0 0x00000001
98#define GPIO_1 0x00000002 104#define GPIO_1 0x00000002
@@ -296,6 +302,7 @@ struct cx23885_tsport {
296 302
297 struct i2c_client *i2c_client_demod; 303 struct i2c_client *i2c_client_demod;
298 struct i2c_client *i2c_client_tuner; 304 struct i2c_client *i2c_client_tuner;
305 struct i2c_client *i2c_client_ci;
299 306
300 int (*set_frontend)(struct dvb_frontend *fe); 307 int (*set_frontend)(struct dvb_frontend *fe);
301 int (*fe_set_voltage)(struct dvb_frontend *fe, 308 int (*fe_set_voltage)(struct dvb_frontend *fe,
@@ -418,6 +425,7 @@ struct cx23885_dev {
418 struct vb2_queue vb2_vidq; 425 struct vb2_queue vb2_vidq;
419 struct cx23885_dmaqueue vbiq; 426 struct cx23885_dmaqueue vbiq;
420 struct vb2_queue vb2_vbiq; 427 struct vb2_queue vb2_vbiq;
428 void *alloc_ctx;
421 429
422 spinlock_t slock; 430 spinlock_t slock;
423 431