Mailing List archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[linux-dvb] Re: Universal STV0299/TSA5059 frontend driver
Hi,
On Mon, Dec 09, 2002 at 12:00:28PM +0100, Holger Waechtler wrote:
> unfortunally this is a pretty bad solution if you have multiple cards
> with different stv0299 based tuner modules - you can't load the same
> module multiple times with different module parameters.
>
> We have to implement some autoprobing as you can see it in ves1820.c.
here is a patch against my modified BSRU6 driver (sent Dec 08 2002)
that adds autoprobing.
Peter
---------------------------------------------------------------------------
--- uni_stv0299.c.orig Sun Dec 22 22:16:04 2002
+++ uni_stv0299.c Sun Dec 22 22:46:27 2002
@@ -39,9 +39,9 @@
#define dprintk if (debug) printk
/* frontend types */
+#define UNKNOWN_FRONTEND -1
#define PHILIPS_SU1278SH 0
#define ALPS_BSRU6 1
-static int ftype = 0;
/* Master Clock = 88 MHz */
#define M_CLK (88000000UL)
@@ -231,7 +231,7 @@
static
-int tsa5059_write (struct dvb_i2c_bus *i2c, u8 data [4])
+int tsa5059_write (struct dvb_i2c_bus *i2c, u8 data [4], int ftype)
{
int ret;
u8 rpt1 [] = { 0x05, 0xb5 }; /* enable i2c repeater on stv0299 */
@@ -255,7 +255,7 @@
* reference clock comparision frequency of 125 kHz.
*/
static
-int tsa5059_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
+int tsa5059_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq, int ftype)
{
u32 div = freq / 125;
@@ -270,7 +270,7 @@
dprintk ("%s\n", __FUNCTION__);
- return tsa5059_write (i2c, buf);
+ return tsa5059_write (i2c, buf, ftype);
}
@@ -296,7 +296,7 @@
static
-int stv0299_init (struct dvb_i2c_bus *i2c)
+int stv0299_init (struct dvb_i2c_bus *i2c, int ftype)
{
int i;
@@ -591,6 +591,7 @@
static
int uni0299_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
+ int tuner_type = (int)fe->data;
struct dvb_i2c_bus *i2c = fe->i2c;
dprintk ("%s\n", __FUNCTION__);
@@ -663,7 +664,7 @@
{
struct dvb_frontend_parameters *p = arg;
- tsa5059_set_tv_freq (i2c, p->frequency);
+ tsa5059_set_tv_freq (i2c, p->frequency, tuner_type);
stv0299_set_FEC (i2c, p->u.qpsk.fec_inner);
stv0299_set_symbolrate (i2c, p->u.qpsk.symbol_rate);
stv0299_check_inversion (i2c);
@@ -703,7 +704,7 @@
break;
case FE_INIT:
- return stv0299_init (i2c);
+ return stv0299_init (i2c, tuner_type);
case FE_RESET:
stv0299_writereg (i2c, 0x22, 0x00);
@@ -731,11 +732,38 @@
return 0;
}
+static
+int probe_tuner (struct dvb_i2c_bus *i2c)
+{
+ int type;
+ /* read the status register of TSA5059 */
+ u8 rpt[] = { 0x05, 0xb5 };
+ u8 stat [] = { 0 };
+ struct i2c_msg msg1 [] = {{ addr: 0x68, flags: 0, buf: rpt, len: 2 },
+ { addr: 0x60, flags: I2C_M_RD, buf: stat, len: 1 }};
+ struct i2c_msg msg2 [] = {{ addr: 0x68, flags: 0, buf: rpt, len: 2 },
+ { addr: 0x61, flags: I2C_M_RD, buf: stat, len: 1 }};
+
+ if (i2c->xfer(i2c, msg1, 2) == 2) {
+ type = PHILIPS_SU1278SH;
+ printk ("%s: setup for tuner SU1278/SH\n", __FILE__);
+ } else if (i2c->xfer(i2c, msg2, 2) == 2) {
+ type = ALPS_BSRU6;
+ printk ("%s: setup for tuner BSRU6, TDQB-S00x, SU1278\n", __FILE__);
+ } else {
+ type = UNKNOWN_FRONTEND;
+ printk ("%s: unknown PLL synthesizer, "
+ "please report to <linuxdvb@linuxtv.org>!!\n",
+ __FILE__);
+ }
+ return type;
+}
static
int uni0299_attach (struct dvb_i2c_bus *i2c)
{
+ int tuner_type;
u8 id = stv0299_readreg (i2c, 0x00);
dprintk ("%s\n", __FUNCTION__);
@@ -744,7 +772,10 @@
if (id != 0xa1)
return -ENODEV;
- dvb_register_frontend (uni0299_ioctl, i2c, NULL, &uni0299_info);
+ if ((tuner_type = probe_tuner(i2c)) < 0)
+ return -ENODEV;
+
+ dvb_register_frontend (uni0299_ioctl, i2c, (void*)tuner_type, &uni0299_info);
return 0;
}
@@ -782,9 +813,7 @@
MODULE_PARM(debug,"i");
MODULE_PARM_DESC(debug, "enable verbose debug messages");
-MODULE_PARM(ftype,"i");
-MODULE_PARM_DESC(type, "frontend type");
-
MODULE_DESCRIPTION("Universal STV0299/TSA5059 DVB Frontend driver");
MODULE_AUTHOR("Ralph Metzler, Holger Waechtler, Peter Schildmann");
MODULE_LICENSE("GPL");
+
--
Info:
To unsubscribe send a mail to listar@linuxtv.org with "unsubscribe linux-dvb" as subject.
Home |
Main Index |
Thread Index