aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/ttpci/av7110.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/dvb/ttpci/av7110.c')
-rw-r--r--drivers/media/dvb/ttpci/av7110.c260
1 files changed, 39 insertions, 221 deletions
diff --git a/drivers/media/dvb/ttpci/av7110.c b/drivers/media/dvb/ttpci/av7110.c
index 7c6ccb96b157..840efec32cb6 100644
--- a/drivers/media/dvb/ttpci/av7110.c
+++ b/drivers/media/dvb/ttpci/av7110.c
@@ -54,7 +54,6 @@
54#include <linux/i2c.h> 54#include <linux/i2c.h>
55 55
56#include <asm/system.h> 56#include <asm/system.h>
57#include <asm/semaphore.h>
58 57
59#include <linux/dvb/frontend.h> 58#include <linux/dvb/frontend.h>
60 59
@@ -67,6 +66,10 @@
67#include "av7110_ca.h" 66#include "av7110_ca.h"
68#include "av7110_ipack.h" 67#include "av7110_ipack.h"
69 68
69#include "bsbe1.h"
70#include "lnbp21.h"
71#include "bsru6.h"
72
70#define TS_WIDTH 376 73#define TS_WIDTH 376
71#define TS_HEIGHT 512 74#define TS_HEIGHT 512
72#define TS_BUFLEN (TS_WIDTH*TS_HEIGHT) 75#define TS_BUFLEN (TS_WIDTH*TS_HEIGHT)
@@ -82,6 +85,8 @@ static int hw_sections;
82static int rgb_on; 85static int rgb_on;
83static int volume = 255; 86static int volume = 255;
84static int budgetpatch; 87static int budgetpatch;
88static int wss_cfg_4_3 = 0x4008;
89static int wss_cfg_16_9 = 0x0007;
85 90
86module_param_named(debug, av7110_debug, int, 0644); 91module_param_named(debug, av7110_debug, int, 0644);
87MODULE_PARM_DESC(debug, "debug level (bitmask, default 0)"); 92MODULE_PARM_DESC(debug, "debug level (bitmask, default 0)");
@@ -100,6 +105,10 @@ module_param(volume, int, 0444);
100MODULE_PARM_DESC(volume, "initial volume: default 255 (range 0-255)"); 105MODULE_PARM_DESC(volume, "initial volume: default 255 (range 0-255)");
101module_param(budgetpatch, int, 0444); 106module_param(budgetpatch, int, 0444);
102MODULE_PARM_DESC(budgetpatch, "use budget-patch hardware modification: default 0 (0 no, 1 autodetect, 2 always)"); 107MODULE_PARM_DESC(budgetpatch, "use budget-patch hardware modification: default 0 (0 no, 1 autodetect, 2 always)");
108module_param(wss_cfg_4_3, int, 0444);
109MODULE_PARM_DESC(wss_cfg_4_3, "WSS 4:3 - default 0x4008 - bit 15: disable, 14: burst mode, 13..0: wss data");
110module_param(wss_cfg_16_9, int, 0444);
111MODULE_PARM_DESC(wss_cfg_16_9, "WSS 16:9 - default 0x0007 - bit 15: disable, 14: burst mode, 13..0: wss data");
103 112
104static void restart_feeds(struct av7110 *av7110); 113static void restart_feeds(struct av7110 *av7110);
105 114
@@ -125,6 +134,13 @@ static void init_av7110_av(struct av7110 *av7110)
125 if (ret < 0) 134 if (ret < 0)
126 printk("dvb-ttpci:cannot set internal volume to maximum:%d\n",ret); 135 printk("dvb-ttpci:cannot set internal volume to maximum:%d\n",ret);
127 136
137 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 2, wss_cfg_4_3);
138 if (ret < 0)
139 printk("dvb-ttpci: unable to configure 4:3 wss\n");
140 ret = av7110_fw_cmd(av7110, COMTYPE_ENCODER, SetWSSConfig, 2, 3, wss_cfg_16_9);
141 if (ret < 0)
142 printk("dvb-ttpci: unable to configure 16:9 wss\n");
143
128 ret = av7710_set_video_mode(av7110, vidmode); 144 ret = av7710_set_video_mode(av7110, vidmode);
129 if (ret < 0) 145 if (ret < 0)
130 printk("dvb-ttpci:cannot set video mode:%d\n",ret); 146 printk("dvb-ttpci:cannot set video mode:%d\n",ret);
@@ -242,10 +258,10 @@ static int arm_thread(void *data)
242 if (!av7110->arm_ready) 258 if (!av7110->arm_ready)
243 continue; 259 continue;
244 260
245 if (down_interruptible(&av7110->dcomlock)) 261 if (mutex_lock_interruptible(&av7110->dcomlock))
246 break; 262 break;
247 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2); 263 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2);
248 up(&av7110->dcomlock); 264 mutex_unlock(&av7110->dcomlock);
249 265
250 if (newloops == av7110->arm_loops || av7110->arm_errors > 3) { 266 if (newloops == av7110->arm_loops || av7110->arm_errors > 3) {
251 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n", 267 printk(KERN_ERR "dvb-ttpci: ARM crashed @ card %d\n",
@@ -253,10 +269,10 @@ static int arm_thread(void *data)
253 269
254 recover_arm(av7110); 270 recover_arm(av7110);
255 271
256 if (down_interruptible(&av7110->dcomlock)) 272 if (mutex_lock_interruptible(&av7110->dcomlock))
257 break; 273 break;
258 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1; 274 newloops = rdebi(av7110, DEBINOSWAP, STATUS_LOOPS, 0, 2) - 1;
259 up(&av7110->dcomlock); 275 mutex_unlock(&av7110->dcomlock);
260 } 276 }
261 av7110->arm_loops = newloops; 277 av7110->arm_loops = newloops;
262 av7110->arm_errors = 0; 278 av7110->arm_errors = 0;
@@ -741,7 +757,7 @@ int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
741 int ret = 0; 757 int ret = 0;
742 dprintk(4, "%p\n", av7110); 758 dprintk(4, "%p\n", av7110);
743 759
744 if (down_interruptible(&av7110->pid_mutex)) 760 if (mutex_lock_interruptible(&av7110->pid_mutex))
745 return -ERESTARTSYS; 761 return -ERESTARTSYS;
746 762
747 if (!(vpid & 0x8000)) 763 if (!(vpid & 0x8000))
@@ -760,7 +776,7 @@ int ChangePIDs(struct av7110 *av7110, u16 vpid, u16 apid, u16 ttpid,
760 ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid); 776 ret = SetPIDs(av7110, vpid, apid, ttpid, subpid, pcrpid);
761 } 777 }
762 778
763 up(&av7110->pid_mutex); 779 mutex_unlock(&av7110->pid_mutex);
764 return ret; 780 return ret;
765} 781}
766 782
@@ -1088,11 +1104,9 @@ static int dvb_get_stc(struct dmx_demux *demux, unsigned int num,
1088 struct av7110 *av7110; 1104 struct av7110 *av7110;
1089 1105
1090 /* pointer casting paranoia... */ 1106 /* pointer casting paranoia... */
1091 if (!demux) 1107 BUG_ON(!demux);
1092 BUG();
1093 dvbdemux = (struct dvb_demux *) demux->priv; 1108 dvbdemux = (struct dvb_demux *) demux->priv;
1094 if (!dvbdemux) 1109 BUG_ON(!dvbdemux);
1095 BUG();
1096 av7110 = (struct av7110 *) dvbdemux->priv; 1110 av7110 = (struct av7110 *) dvbdemux->priv;
1097 1111
1098 dprintk(4, "%p\n", av7110); 1112 dprintk(4, "%p\n", av7110);
@@ -1570,208 +1584,6 @@ static struct ves1x93_config alps_bsrv2_config = {
1570 .pll_set = alps_bsrv2_pll_set, 1584 .pll_set = alps_bsrv2_pll_set,
1571}; 1585};
1572 1586
1573
1574static u8 alps_bsru6_inittab[] = {
1575 0x01, 0x15,
1576 0x02, 0x30,
1577 0x03, 0x00,
1578 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
1579 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
1580 0x06, 0x40, /* DAC not used, set to high impendance mode */
1581 0x07, 0x00, /* DAC LSB */
1582 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
1583 0x09, 0x00, /* FIFO */
1584 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
1585 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
1586 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
1587 0x10, 0x3f, // AGC2 0x3d
1588 0x11, 0x84,
1589 0x12, 0xb9,
1590 0x15, 0xc9, // lock detector threshold
1591 0x16, 0x00,
1592 0x17, 0x00,
1593 0x18, 0x00,
1594 0x19, 0x00,
1595 0x1a, 0x00,
1596 0x1f, 0x50,
1597 0x20, 0x00,
1598 0x21, 0x00,
1599 0x22, 0x00,
1600 0x23, 0x00,
1601 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
1602 0x29, 0x1e, // 1/2 threshold
1603 0x2a, 0x14, // 2/3 threshold
1604 0x2b, 0x0f, // 3/4 threshold
1605 0x2c, 0x09, // 5/6 threshold
1606 0x2d, 0x05, // 7/8 threshold
1607 0x2e, 0x01,
1608 0x31, 0x1f, // test all FECs
1609 0x32, 0x19, // viterbi and synchro search
1610 0x33, 0xfc, // rs control
1611 0x34, 0x93, // error control
1612 0x0f, 0x52,
1613 0xff, 0xff
1614};
1615
1616static int alps_bsru6_set_symbol_rate(struct dvb_frontend* fe, u32 srate, u32 ratio)
1617{
1618 u8 aclk = 0;
1619 u8 bclk = 0;
1620
1621 if (srate < 1500000) { aclk = 0xb7; bclk = 0x47; }
1622 else if (srate < 3000000) { aclk = 0xb7; bclk = 0x4b; }
1623 else if (srate < 7000000) { aclk = 0xb7; bclk = 0x4f; }
1624 else if (srate < 14000000) { aclk = 0xb7; bclk = 0x53; }
1625 else if (srate < 30000000) { aclk = 0xb6; bclk = 0x53; }
1626 else if (srate < 45000000) { aclk = 0xb4; bclk = 0x51; }
1627
1628 stv0299_writereg(fe, 0x13, aclk);
1629 stv0299_writereg(fe, 0x14, bclk);
1630 stv0299_writereg(fe, 0x1f, (ratio >> 16) & 0xff);
1631 stv0299_writereg(fe, 0x20, (ratio >> 8) & 0xff);
1632 stv0299_writereg(fe, 0x21, (ratio ) & 0xf0);
1633
1634 return 0;
1635}
1636
1637static int alps_bsru6_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
1638{
1639 int ret;
1640 u8 data[4];
1641 u32 div;
1642 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1643
1644 if ((params->frequency < 950000) || (params->frequency > 2150000))
1645 return -EINVAL;
1646
1647 div = (params->frequency + (125 - 1)) / 125; // round correctly
1648 data[0] = (div >> 8) & 0x7f;
1649 data[1] = div & 0xff;
1650 data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
1651 data[3] = 0xC4;
1652
1653 if (params->frequency > 1530000) data[3] = 0xc0;
1654
1655 ret = i2c_transfer(i2c, &msg, 1);
1656 if (ret != 1)
1657 return -EIO;
1658 return 0;
1659}
1660
1661static struct stv0299_config alps_bsru6_config = {
1662
1663 .demod_address = 0x68,
1664 .inittab = alps_bsru6_inittab,
1665 .mclk = 88000000UL,
1666 .invert = 1,
1667 .skip_reinit = 0,
1668 .lock_output = STV0229_LOCKOUTPUT_1,
1669 .volt13_op0_op1 = STV0299_VOLT13_OP1,
1670 .min_delay_ms = 100,
1671 .set_symbol_rate = alps_bsru6_set_symbol_rate,
1672 .pll_set = alps_bsru6_pll_set,
1673};
1674
1675
1676static u8 alps_bsbe1_inittab[] = {
1677 0x01, 0x15,
1678 0x02, 0x30,
1679 0x03, 0x00,
1680 0x04, 0x7d, /* F22FR = 0x7d, F22 = f_VCO / 128 / 0x7d = 22 kHz */
1681 0x05, 0x35, /* I2CT = 0, SCLT = 1, SDAT = 1 */
1682 0x06, 0x40, /* DAC not used, set to high impendance mode */
1683 0x07, 0x00, /* DAC LSB */
1684 0x08, 0x40, /* DiSEqC off, LNB power on OP2/LOCK pin on */
1685 0x09, 0x00, /* FIFO */
1686 0x0c, 0x51, /* OP1 ctl = Normal, OP1 val = 1 (LNB Power ON) */
1687 0x0d, 0x82, /* DC offset compensation = ON, beta_agc1 = 2 */
1688 0x0e, 0x23, /* alpha_tmg = 2, beta_tmg = 3 */
1689 0x10, 0x3f, // AGC2 0x3d
1690 0x11, 0x84,
1691 0x12, 0xb9,
1692 0x15, 0xc9, // lock detector threshold
1693 0x16, 0x00,
1694 0x17, 0x00,
1695 0x18, 0x00,
1696 0x19, 0x00,
1697 0x1a, 0x00,
1698 0x1f, 0x50,
1699 0x20, 0x00,
1700 0x21, 0x00,
1701 0x22, 0x00,
1702 0x23, 0x00,
1703 0x28, 0x00, // out imp: normal out type: parallel FEC mode:0
1704 0x29, 0x1e, // 1/2 threshold
1705 0x2a, 0x14, // 2/3 threshold
1706 0x2b, 0x0f, // 3/4 threshold
1707 0x2c, 0x09, // 5/6 threshold
1708 0x2d, 0x05, // 7/8 threshold
1709 0x2e, 0x01,
1710 0x31, 0x1f, // test all FECs
1711 0x32, 0x19, // viterbi and synchro search
1712 0x33, 0xfc, // rs control
1713 0x34, 0x93, // error control
1714 0x0f, 0x92,
1715 0xff, 0xff
1716};
1717
1718static int alps_bsbe1_pll_set(struct dvb_frontend* fe, struct i2c_adapter *i2c, struct dvb_frontend_parameters* params)
1719{
1720 int ret;
1721 u8 data[4];
1722 u32 div;
1723 struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = sizeof(data) };
1724
1725 if ((params->frequency < 950000) || (params->frequency > 2150000))
1726 return -EINVAL;
1727
1728 div = (params->frequency + (125 - 1)) / 125; // round correctly
1729 data[0] = (div >> 8) & 0x7f;
1730 data[1] = div & 0xff;
1731 data[2] = 0x80 | ((div & 0x18000) >> 10) | 4;
1732 data[3] = (params->frequency > 1530000) ? 0xE0 : 0xE4;
1733
1734 ret = i2c_transfer(i2c, &msg, 1);
1735 return (ret != 1) ? -EIO : 0;
1736}
1737
1738static struct stv0299_config alps_bsbe1_config = {
1739 .demod_address = 0x68,
1740 .inittab = alps_bsbe1_inittab,
1741 .mclk = 88000000UL,
1742 .invert = 1,
1743 .skip_reinit = 0,
1744 .min_delay_ms = 100,
1745 .set_symbol_rate = alps_bsru6_set_symbol_rate,
1746 .pll_set = alps_bsbe1_pll_set,
1747};
1748
1749static int lnbp21_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage)
1750{
1751 struct av7110* av7110 = (struct av7110*) fe->dvb->priv;
1752 int ret;
1753 u8 data[1];
1754 struct i2c_msg msg = { .addr = 0x08, .flags = 0, .buf = data, .len = sizeof(data) };
1755
1756 switch(voltage) {
1757 case SEC_VOLTAGE_OFF:
1758 data[0] = 0x00;
1759 break;
1760 case SEC_VOLTAGE_13:
1761 data[0] = 0x44;
1762 break;
1763 case SEC_VOLTAGE_18:
1764 data[0] = 0x4c;
1765 break;
1766 default:
1767 return -EINVAL;
1768 };
1769
1770 ret = i2c_transfer(&av7110->i2c_adap, &msg, 1);
1771 return (ret != 1) ? -EIO : 0;
1772}
1773
1774
1775static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params) 1587static int alps_tdbe2_pll_set(struct dvb_frontend* fe, struct dvb_frontend_parameters* params)
1776{ 1588{
1777 struct av7110* av7110 = fe->dvb->priv; 1589 struct av7110* av7110 = fe->dvb->priv;
@@ -2096,7 +1908,7 @@ static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
2096 if (av7110->playing) 1908 if (av7110->playing)
2097 return 0; 1909 return 0;
2098 1910
2099 if (down_interruptible(&av7110->pid_mutex)) 1911 if (mutex_lock_interruptible(&av7110->pid_mutex))
2100 return -ERESTARTSYS; 1912 return -ERESTARTSYS;
2101 1913
2102 if (synced) { 1914 if (synced) {
@@ -2118,7 +1930,7 @@ static int av7110_fe_lock_fix(struct av7110* av7110, fe_status_t status)
2118 if (!ret) 1930 if (!ret)
2119 av7110->fe_synced = synced; 1931 av7110->fe_synced = synced;
2120 1932
2121 up(&av7110->pid_mutex); 1933 mutex_unlock(&av7110->pid_mutex);
2122 return ret; 1934 return ret;
2123} 1935}
2124 1936
@@ -2374,9 +2186,15 @@ static int frontend_init(struct av7110 *av7110)
2374 /* ALPS BSBE1 */ 2186 /* ALPS BSBE1 */
2375 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap); 2187 av7110->fe = stv0299_attach(&alps_bsbe1_config, &av7110->i2c_adap);
2376 if (av7110->fe) { 2188 if (av7110->fe) {
2377 av7110->fe->ops->set_voltage = lnbp21_set_voltage; 2189 if (lnbp21_init(av7110->fe, &av7110->i2c_adap, 0, 0)) {
2378 av7110->fe->ops->dishnetwork_send_legacy_command = NULL; 2190 printk("dvb-ttpci: LNBP21 not found!\n");
2379 av7110->recover = dvb_s_recover; 2191 if (av7110->fe->ops->release)
2192 av7110->fe->ops->release(av7110->fe);
2193 av7110->fe = NULL;
2194 } else {
2195 av7110->fe->ops->dishnetwork_send_legacy_command = NULL;
2196 av7110->recover = dvb_s_recover;
2197 }
2380 } 2198 }
2381 break; 2199 break;
2382 } 2200 }
@@ -2714,16 +2532,16 @@ static int __devinit av7110_attach(struct saa7146_dev* dev,
2714 tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110); 2532 tasklet_init (&av7110->debi_tasklet, debiirq, (unsigned long) av7110);
2715 tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110); 2533 tasklet_init (&av7110->gpio_tasklet, gpioirq, (unsigned long) av7110);
2716 2534
2717 sema_init(&av7110->pid_mutex, 1); 2535 mutex_init(&av7110->pid_mutex);
2718 2536
2719 /* locks for data transfers from/to AV7110 */ 2537 /* locks for data transfers from/to AV7110 */
2720 spin_lock_init(&av7110->debilock); 2538 spin_lock_init(&av7110->debilock);
2721 sema_init(&av7110->dcomlock, 1); 2539 mutex_init(&av7110->dcomlock);
2722 av7110->debitype = -1; 2540 av7110->debitype = -1;
2723 2541
2724 /* default OSD window */ 2542 /* default OSD window */
2725 av7110->osdwin = 1; 2543 av7110->osdwin = 1;
2726 sema_init(&av7110->osd_sema, 1); 2544 mutex_init(&av7110->osd_mutex);
2727 2545
2728 /* ARM "watchdog" */ 2546 /* ARM "watchdog" */
2729 init_waitqueue_head(&av7110->arm_wait); 2547 init_waitqueue_head(&av7110->arm_wait);