Commit 67dfafeb authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] DVB: frontend conversion #3

- [DVB] dvb_dummy_fe, grundig_29504-401, grundig_29504-491, mt312: convert
  from dvb-i2c to kernel-i2c, MODULE_PARM() to module_param(), dvb_delay() to
  mdelay()

- [DVB] update frontend Kconfig
Signed-off-by: default avatarMichael Hunold <hunold@linuxtv.org>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent ac1a4632
comment "Supported Frontend Modules" comment "DVB-S (satellite) frontends"
depends on DVB depends on DVB_CORE
config DVB_TWINHAN_DST
tristate "TWINHAN DST based DVB-S frontend (QPSK)"
depends on DVB_CORE && DVB_BT8XX
help
Used in such cards as the VP-1020/1030, Twinhan DST,
VVmer TV@SAT. Say Y when you want to support frontends
using this asic.
This module requires the dvb-bt8xx driver and dvb bt878
module.
config DVB_STV0299 config DVB_STV0299
tristate "STV0299 based DVB-S frontend (QPSK)" tristate "ST STV0299 based"
depends on DVB_CORE depends on DVB_CORE
help help
The stv0299 by ST is used in many DVB-S tuner modules, A DVB-S tuner module. Say Y when you want to support this frontend.
say Y when you want to support frontends based on this
DVB-S demodulator.
Some examples are the Alps BSRU6, the Philips SU1278 and Some examples are the Alps BSRU6, the Philips SU1278 and
the LG TDQB-S00x. the LG TDQB-S00x.
...@@ -27,92 +14,83 @@ config DVB_STV0299 ...@@ -27,92 +14,83 @@ config DVB_STV0299
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_SP887X config DVB_CX24110
tristate "Frontends with sp887x demodulators, e.g. Microtune DTF7072" tristate "Connexant CX24110 based"
depends on DVB_CORE depends on DVB_CORE
help help
A DVB-T demodulator driver. Say Y when you want to support the sp887x. A DVB-S tuner module. Say Y when you want to support this frontend.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_GRUNDIG_29504_491
config DVB_SP887X_FIRMWARE_FILE tristate "Grundig 29504-491 based"
string "Full pathname of sp887x firmware file"
depends on DVB_SP887X
default "/usr/lib/hotplug/firmware/sc_main.mc"
help
This driver needs a copy of the Avermedia firmware. The version tested
is part of the Avermedia DVB-T 1.3.26.3 Application. This can be downloaded
from the Avermedia web site.
If the software is installed in Windows the file will be in the
/Program Files/AVerTV DVB-T/ directory and is called sc_main.mc.
Alternatively it can "extracted" from the install cab files but this will have
to be done in windows as I don't know of a linux version of extract.exe.
Copy this file to /usr/lib/hotplug/firmware/sc_main.mc.
With this version of the file the first 10 bytes are discarded and the next
0x4000 loaded. This may change in future versions.
config DVB_ALPS_TDLB7
tristate "Alps TDLB7 (OFDM)"
depends on DVB_CORE depends on DVB_CORE
help help
A DVB-T tuner module. Say Y when you want to support this frontend. A DVB-S tuner module. Say Y when you want to support this frontend.
This tuner module needs some microcode located in a file called
"Sc_main.mc" in the windows driver. Please pass the module parameter
mcfile="/PATH/FILENAME" when loading alps_tdlb7.o.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_MT312
config DVB_ALPS_TDMB7 tristate "Zarlink MT312 based"
tristate "Alps TDMB7 (OFDM)"
depends on DVB_CORE depends on DVB_CORE
help help
A DVB-T tuner module. Say Y when you want to support this frontend. A DVB-S tuner module. Say Y when you want to support this frontend.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_ATMEL_AT76C651 config DVB_VES1X93
tristate "Atmel AT76C651 (QAM)" tristate "VLSI VES1893 or VES1993 based"
depends on DVB_CORE depends on DVB_CORE
help help
The AT76C651 Demodulator is used in some DVB-C SetTopBoxes. Say Y A DVB-S tuner module. Say Y when you want to support this frontend.
when you see this demodulator chip near your tuner module.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_CX24110 comment "DVB-T (terrestrial) frontends"
tristate "Frontends with Connexant CX24110 demodulator (QPSK)" depends on DVB_CORE
config DVB_SP887X
tristate "Microtune sp887x based (i.e. Microtune DTF7072)"
depends on DVB_CORE depends on DVB_CORE
help help
The CX24110 Demodulator is used in some DVB-S frontends. A DVB-T tuner module. Say Y when you want to support this frontend.
Say Y if you want support for this chip in your kernel.
This driver needs a copy of the Avermedia firmware. The version tested
is part of the Avermedia DVB-T 1.3.26.3 Application. If the software is
installed in Windoze the file will be in the /Program Files/AVerTV DVB-T/
directory and is called sc_main.mc. Alternatively it can "extracted" from
the install cab files.
Copy this file to '/usr/lib/hotplug/firmware/dvb-fe-sp887x.fw'.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_GRUNDIG_29504_491 config DVB_ALPS_TDLB7
tristate "Grundig 29504-491 (QPSK)" tristate "Alps TDLB7 based"
depends on DVB_CORE depends on DVB_CORE
help help
A DVB-S tuner module. Say Y when you want to support this frontend. A DVB-T tuner module. Say Y when you want to support this frontend.
This driver needs a copy of the firmware file from the Haupauge
Windoze driver. Copy 'Sc_main.mc' to
'/usr/lib/hotplug/firmware/dvb-fe-tdlb7.fw'.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_GRUNDIG_29504_401 config DVB_ALPS_TDMB7
tristate "Grundig 29504-401 (OFDM)" tristate "Alps TDMB7 based"
depends on DVB_CORE depends on DVB_CORE
help help
A DVB-T tuner module. Say Y when you want to support this frontend. A DVB-T tuner module. Say Y when you want to support this frontend.
...@@ -121,40 +99,38 @@ config DVB_GRUNDIG_29504_401 ...@@ -121,40 +99,38 @@ config DVB_GRUNDIG_29504_401
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_MT312 config DVB_GRUNDIG_29504_401
tristate "Zarlink MT312 Satellite Channel Decoder (QPSK)" tristate "Grundig 29504-401 based"
depends on DVB_CORE depends on DVB_CORE
help help
A DVB-S tuner module. Say Y when you want to support this frontend. A DVB-T tuner module. Say Y when you want to support this frontend.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_VES1820 config DVB_TDA1004X
tristate "Frontends with external VES1820 demodulator (QAM)" tristate "Philips TDA10045H/TDA10046H based"
depends on DVB_CORE depends on DVB_CORE
help help
The VES1820 Demodulator is used on many DVB-C PCI cards and in some A DVB-T tuner module. Say Y when you want to support this frontend.
DVB-C SetTopBoxes. Say Y when you see this demodulator chip near your
tuner module.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_VES1X93 config DVB_NXT6000
tristate "Frontends with VES1893 or VES1993 demodulator (QPSK)" tristate "NxtWave Communications NXT6000 based"
depends on DVB_CORE depends on DVB_CORE
help help
A DVB-S tuner module. Say Y when you want to support this frontend. A DVB-T tuner module. Say Y when you want to support this frontend.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_TDA1004X config DVB_MT352
tristate "Frontends with external TDA10045H or TDA10046H demodulators (OFDM)" tristate "Zarlink MT352 based"
depends on DVB_CORE depends on DVB_CORE
help help
A DVB-T tuner module. Say Y when you want to support this frontend. A DVB-T tuner module. Say Y when you want to support this frontend.
...@@ -163,25 +139,36 @@ config DVB_TDA1004X ...@@ -163,25 +139,36 @@ config DVB_TDA1004X
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
config DVB_TDA1004X_FIRMWARE_FILE comment "DVB-C (cable) frontends"
string "Full pathname of tda1004x.bin firmware file" depends on DVB_CORE
depends on DVB_TDA1004X
default "/usr/lib/hotplug/firmware/tda1004x.bin" config DVB_ATMEL_AT76C651
tristate "Atmel AT76C651 based"
depends on DVB_CORE
help help
The TDA1004X requires additional firmware in order to function. A DVB-C tuner module. Say Y when you want to support this frontend.
The firmware file can obtained as follows:
wget http://www.technotrend.de/new/215/TTweb_215a_budget_20_05_2003.zip
unzip -j TTweb_215a_budget_20_05_2003.zip Software/Oem/PCI/App/ttlcdacc.dll
mv ttlcdacc.dll /usr/lib/hotplug/firmware/tda1004x.bin
Note: even if you're using a USB device, you MUST get the file from the
TechnoTrend PCI drivers.
config DVB_NXT6000 If you don't know what tuner module is soldered on your
tristate "Frontends with NxtWave Communications NXT6000 demodulator (OFDM)" DVB adapter simply enable all supported frontends, the
right one will get autodetected.
config DVB_VES1820
tristate "VLSI VES1820 based"
depends on DVB_CORE depends on DVB_CORE
help help
A DVB-T tuner module. Say Y when you want to support this frontend. A DVB-C tuner module. Say Y when you want to support this frontend.
If you don't know what tuner module is soldered on your If you don't know what tuner module is soldered on your
DVB adapter simply enable all supported frontends, the DVB adapter simply enable all supported frontends, the
right one will get autodetected. right one will get autodetected.
comment "Misc. Frontend Modules"
depends on DVB_CORE
config DVB_TWINHAN_DST
tristate "Twinhan DST based DVB-S/-T frontend"
depends on DVB_CORE && DVB_BT8XX
help
Used in such cards as the VP-1020/1030, Twinhan DST,
VVmer TV@SAT. Say Y when you want to support frontends
using this asic.
...@@ -20,12 +20,16 @@ ...@@ -20,12 +20,16 @@
*/ */
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/init.h> #include <linux/init.h>
#include "dvb_frontend.h" #include "dvb_frontend.h"
static int sct = 0; #define FRONTEND_NAME "dvbfe_dummy"
static int frontend_type;
module_param(frontend_type, int, 0444);
MODULE_PARM_DESC(frontend_type, "0 == DVB-S, 1 == DVB-C, 2 == DVB-T");
/* depending on module parameter sct deliver different infos /* depending on module parameter sct deliver different infos
*/ */
...@@ -87,8 +91,7 @@ static struct dvb_frontend_info dvb_t_dummyfe_info = { ...@@ -87,8 +91,7 @@ static struct dvb_frontend_info dvb_t_dummyfe_info = {
struct dvb_frontend_info *frontend_info(void) struct dvb_frontend_info *frontend_info(void)
{ {
switch(sct) switch(frontend_type) {
{
case 2: case 2:
return &dvb_t_dummyfe_info; return &dvb_t_dummyfe_info;
case 1: case 1:
...@@ -168,30 +171,89 @@ static int dvbdummyfe_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *ar ...@@ -168,30 +171,89 @@ static int dvbdummyfe_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *ar
return 0; return 0;
} }
static struct i2c_client client_template;
static int dvbdummyfe_attach (struct dvb_i2c_bus *i2c, void **data) static int dvbdummyfe_attach_adapter(struct i2c_adapter *adapter)
{ {
return dvb_register_frontend (dvbdummyfe_ioctl, i2c, NULL, frontend_info()); struct dvb_adapter *dvb;
struct i2c_client *client;
int ret;
if ((client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)) == NULL)
return -ENOMEM;
memcpy(client, &client_template, sizeof(struct i2c_client));
client->adapter = adapter;
if ((ret = i2c_attach_client(client))) {
kfree(client);
return ret;
}
dvb = i2c_get_clientdata(client);
BUG_ON(!dvb);
if ((ret = dvb_register_frontend(dvbdummyfe_ioctl, dvb, NULL,
frontend_info(), THIS_MODULE))) {
kfree(client);
return ret;
}
return 0;
} }
static void dvbdummyfe_detach (struct dvb_i2c_bus *i2c, void *data) static int dvbdummyfe_detach_client(struct i2c_client *client)
{
struct dvb_adapter *dvb = i2c_get_clientdata(client);
dvb_unregister_frontend_new(dvbdummyfe_ioctl, dvb);
i2c_detach_client(client);
kfree(client);
return 0;
}
static int dvbdummyfe_command(struct i2c_client *client,
unsigned int cmd, void *arg)
{ {
dvb_unregister_frontend (dvbdummyfe_ioctl, i2c); switch(cmd) {
case FE_REGISTER:
i2c_set_clientdata(client, arg);
break;
case FE_UNREGISTER:
break;
default:
return -EOPNOTSUPP;
}
return 0;
} }
static struct i2c_driver driver = {
.owner = THIS_MODULE,
.name = FRONTEND_NAME,
.id = I2C_DRIVERID_DVBFE_DUMMY,
.flags = I2C_DF_NOTIFY,
.attach_adapter = dvbdummyfe_attach_adapter,
.detach_client = dvbdummyfe_detach_client,
.command = dvbdummyfe_command,
};
static struct i2c_client client_template = {
.name = FRONTEND_NAME,
.flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver,
};
static int __init init_dvbdummyfe (void) static int __init init_dvbdummyfe (void)
{ {
return dvb_register_i2c_device (THIS_MODULE, return i2c_add_driver(&driver);
dvbdummyfe_attach,
dvbdummyfe_detach);
} }
static void __exit exit_dvbdummyfe (void) static void __exit exit_dvbdummyfe (void)
{ {
dvb_unregister_i2c_device (dvbdummyfe_attach); if (i2c_del_driver(&driver))
printk(KERN_ERR "dummyfe: driver deregistration failed.\n");
} }
...@@ -202,4 +264,4 @@ module_exit(exit_dvbdummyfe); ...@@ -202,4 +264,4 @@ module_exit(exit_dvbdummyfe);
MODULE_DESCRIPTION("DVB DUMMY Frontend"); MODULE_DESCRIPTION("DVB DUMMY Frontend");
MODULE_AUTHOR("Emard"); MODULE_AUTHOR("Emard");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
MODULE_PARM(sct, "i");
...@@ -27,17 +27,31 @@ ...@@ -27,17 +27,31 @@
#include <linux/init.h> #include <linux/init.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/string.h> #include <linux/string.h>
#include <linux/slab.h> #include <linux/slab.h>
#include "dvb_frontend.h" #include "dvb_frontend.h"
#include "dvb_functions.h"
static int debug = 0; #define FRONTEND_NAME "dvbfe_tda8083"
#define dprintk if (debug) printk
#define dprintk(args...) \
do { \
if (debug) printk(KERN_DEBUG FRONTEND_NAME ": " args); \
} while (0)
static struct dvb_frontend_info grundig_29504_491_info = { static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
struct tda8083_state {
struct i2c_adapter *i2c;
struct dvb_adapter *dvb;
};
static struct dvb_frontend_info tda8083_info = {
.name = "Grundig 29504-491, (TDA8083 based)", .name = "Grundig 29504-491, (TDA8083 based)",
.type = FE_QPSK, .type = FE_QPSK,
.frequency_min = 950000, /* FIXME: guessed! */ .frequency_min = 950000, /* FIXME: guessed! */
...@@ -67,14 +81,13 @@ static u8 tda8083_init_tab [] = { ...@@ -67,14 +81,13 @@ static u8 tda8083_init_tab [] = {
}; };
static int tda8083_writereg (struct i2c_adapter *i2c, u8 reg, u8 data)
static int tda8083_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
{ {
int ret; int ret;
u8 buf [] = { reg, data }; u8 buf [] = { reg, data };
struct i2c_msg msg = { .addr = 0x68, .flags = 0, .buf = buf, .len = 2 }; struct i2c_msg msg = { .addr = 0x68, .flags = 0, .buf = buf, .len = 2 };
ret = i2c->xfer (i2c, &msg, 1); ret = i2c_transfer(i2c, &msg, 1);
if (ret != 1) if (ret != 1)
dprintk ("%s: writereg error (reg %02x, ret == %i)\n", dprintk ("%s: writereg error (reg %02x, ret == %i)\n",
...@@ -84,13 +97,13 @@ static int tda8083_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data) ...@@ -84,13 +97,13 @@ static int tda8083_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
} }
static int tda8083_readregs (struct dvb_i2c_bus *i2c, u8 reg1, u8 *b, u8 len) static int tda8083_readregs (struct i2c_adapter *i2c, u8 reg1, u8 *b, u8 len)
{ {
int ret; int ret;
struct i2c_msg msg [] = { { .addr = 0x68, .flags = 0, .buf = &reg1, .len = 1 }, struct i2c_msg msg [] = { { .addr = 0x68, .flags = 0, .buf = &reg1, .len = 1 },
{ .addr = 0x68, .flags = I2C_M_RD, .buf = b, .len = len } }; { .addr = 0x68, .flags = I2C_M_RD, .buf = b, .len = len } };
ret = i2c->xfer (i2c, msg, 2); ret = i2c_transfer(i2c, msg, 2);
if (ret != 2) if (ret != 2)
dprintk ("%s: readreg error (reg %02x, ret == %i)\n", dprintk ("%s: readreg error (reg %02x, ret == %i)\n",
...@@ -100,7 +113,7 @@ static int tda8083_readregs (struct dvb_i2c_bus *i2c, u8 reg1, u8 *b, u8 len) ...@@ -100,7 +113,7 @@ static int tda8083_readregs (struct dvb_i2c_bus *i2c, u8 reg1, u8 *b, u8 len)
} }
static inline u8 tda8083_readreg (struct dvb_i2c_bus *i2c, u8 reg) static inline u8 tda8083_readreg (struct i2c_adapter *i2c, u8 reg)
{ {
u8 val; u8 val;
...@@ -110,12 +123,12 @@ static inline u8 tda8083_readreg (struct dvb_i2c_bus *i2c, u8 reg) ...@@ -110,12 +123,12 @@ static inline u8 tda8083_readreg (struct dvb_i2c_bus *i2c, u8 reg)
} }
static int tsa5522_write (struct dvb_i2c_bus *i2c, u8 data [4]) static int tsa5522_write (struct i2c_adapter *i2c, u8 data [4])
{ {
int ret; int ret;
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = 4 }; struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = 4 };
ret = i2c->xfer (i2c, &msg, 1); ret = i2c_transfer(i2c, &msg, 1);
if (ret != 1) if (ret != 1)
dprintk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret); dprintk("%s: i/o error (ret == %i)\n", __FUNCTION__, ret);
...@@ -128,7 +141,7 @@ static int tsa5522_write (struct dvb_i2c_bus *i2c, u8 data [4]) ...@@ -128,7 +141,7 @@ static int tsa5522_write (struct dvb_i2c_bus *i2c, u8 data [4])
* set up the downconverter frequency divisor for a * set up the downconverter frequency divisor for a
* reference clock comparision frequency of 125 kHz. * reference clock comparision frequency of 125 kHz.
*/ */
static int tsa5522_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq) static int tsa5522_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
{ {
u32 div = freq / 125; u32 div = freq / 125;
u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, 0x8e, 0x00 }; u8 buf [4] = { (div >> 8) & 0x7f, div & 0xff, 0x8e, 0x00 };
...@@ -137,7 +150,7 @@ static int tsa5522_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq) ...@@ -137,7 +150,7 @@ static int tsa5522_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
} }
static int tda8083_init (struct dvb_i2c_bus *i2c) static int tda8083_init (struct i2c_adapter *i2c)
{ {
int i; int i;
...@@ -150,7 +163,7 @@ static int tda8083_init (struct dvb_i2c_bus *i2c) ...@@ -150,7 +163,7 @@ static int tda8083_init (struct dvb_i2c_bus *i2c)
} }
static int tda8083_set_inversion (struct dvb_i2c_bus *i2c, fe_spectral_inversion_t inversion) static int tda8083_set_inversion (struct i2c_adapter *i2c, fe_spectral_inversion_t inversion)
{ {
/* XXX FIXME: implement other modes than FEC_AUTO */ /* XXX FIXME: implement other modes than FEC_AUTO */
if (inversion == INVERSION_AUTO) if (inversion == INVERSION_AUTO)
...@@ -160,7 +173,7 @@ static int tda8083_set_inversion (struct dvb_i2c_bus *i2c, fe_spectral_inversion ...@@ -160,7 +173,7 @@ static int tda8083_set_inversion (struct dvb_i2c_bus *i2c, fe_spectral_inversion
} }
static int tda8083_set_fec (struct dvb_i2c_bus *i2c, fe_code_rate_t fec) static int tda8083_set_fec (struct i2c_adapter *i2c, fe_code_rate_t fec)
{ {
if (fec == FEC_AUTO) if (fec == FEC_AUTO)
return tda8083_writereg (i2c, 0x07, 0xff); return tda8083_writereg (i2c, 0x07, 0xff);
...@@ -172,7 +185,7 @@ static int tda8083_set_fec (struct dvb_i2c_bus *i2c, fe_code_rate_t fec) ...@@ -172,7 +185,7 @@ static int tda8083_set_fec (struct dvb_i2c_bus *i2c, fe_code_rate_t fec)
} }
static fe_code_rate_t tda8083_get_fec (struct dvb_i2c_bus *i2c) static fe_code_rate_t tda8083_get_fec (struct i2c_adapter *i2c)
{ {
u8 index; u8 index;
static fe_code_rate_t fec_tab [] = { FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4, static fe_code_rate_t fec_tab [] = { FEC_8_9, FEC_1_2, FEC_2_3, FEC_3_4,
...@@ -184,7 +197,7 @@ static fe_code_rate_t tda8083_get_fec (struct dvb_i2c_bus *i2c) ...@@ -184,7 +197,7 @@ static fe_code_rate_t tda8083_get_fec (struct dvb_i2c_bus *i2c)
} }
static int tda8083_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate) static int tda8083_set_symbolrate (struct i2c_adapter *i2c, u32 srate)
{ {
u32 ratio; u32 ratio;
u32 tmp; u32 tmp;
...@@ -224,19 +237,19 @@ static int tda8083_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate) ...@@ -224,19 +237,19 @@ static int tda8083_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
} }
static void tda8083_wait_diseqc_fifo (struct dvb_i2c_bus *i2c, int timeout) static void tda8083_wait_diseqc_fifo (struct i2c_adapter *i2c, int timeout)
{ {
unsigned long start = jiffies; unsigned long start = jiffies;
while (jiffies - start < timeout && while (jiffies - start < timeout &&
!(tda8083_readreg(i2c, 0x02) & 0x80)) !(tda8083_readreg(i2c, 0x02) & 0x80))
{ {
dvb_delay(50); msleep(50);
}; };
} }
static int tda8083_send_diseqc_msg (struct dvb_i2c_bus *i2c, static int tda8083_send_diseqc_msg (struct i2c_adapter *i2c,
struct dvb_diseqc_master_cmd *m) struct dvb_diseqc_master_cmd *m)
{ {
int i; int i;
...@@ -254,7 +267,7 @@ static int tda8083_send_diseqc_msg (struct dvb_i2c_bus *i2c, ...@@ -254,7 +267,7 @@ static int tda8083_send_diseqc_msg (struct dvb_i2c_bus *i2c,
} }
static int tda8083_send_diseqc_burst (struct dvb_i2c_bus *i2c, fe_sec_mini_cmd_t burst) static int tda8083_send_diseqc_burst (struct i2c_adapter *i2c, fe_sec_mini_cmd_t burst)
{ {
switch (burst) { switch (burst) {
case SEC_MINI_A: case SEC_MINI_A:
...@@ -273,7 +286,7 @@ static int tda8083_send_diseqc_burst (struct dvb_i2c_bus *i2c, fe_sec_mini_cmd_t ...@@ -273,7 +286,7 @@ static int tda8083_send_diseqc_burst (struct dvb_i2c_bus *i2c, fe_sec_mini_cmd_t
} }
static int tda8083_set_tone (struct dvb_i2c_bus *i2c, fe_sec_tone_mode_t tone) static int tda8083_set_tone (struct i2c_adapter *i2c, fe_sec_tone_mode_t tone)
{ {
tda8083_writereg (i2c, 0x26, 0xf1); tda8083_writereg (i2c, 0x26, 0xf1);
...@@ -288,7 +301,7 @@ static int tda8083_set_tone (struct dvb_i2c_bus *i2c, fe_sec_tone_mode_t tone) ...@@ -288,7 +301,7 @@ static int tda8083_set_tone (struct dvb_i2c_bus *i2c, fe_sec_tone_mode_t tone)
} }
static int tda8083_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltage) static int tda8083_set_voltage (struct i2c_adapter *i2c, fe_sec_voltage_t voltage)
{ {
switch (voltage) { switch (voltage) {
case SEC_VOLTAGE_13: case SEC_VOLTAGE_13:
...@@ -301,15 +314,15 @@ static int tda8083_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltag ...@@ -301,15 +314,15 @@ static int tda8083_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltag
} }
static int grundig_29504_491_ioctl (struct dvb_frontend *fe, unsigned int cmd, static int tda8083_ioctl(struct dvb_frontend *fe, unsigned int cmd,
void *arg) void *arg)
{ {
struct dvb_i2c_bus *i2c = fe->i2c; struct tda8083_state *state = fe->data;
struct i2c_adapter *i2c = state->i2c;
switch (cmd) { switch (cmd) {
case FE_GET_INFO: case FE_GET_INFO:
memcpy (arg, &grundig_29504_491_info, memcpy (arg, &tda8083_info, sizeof(struct dvb_frontend_info));
sizeof(struct dvb_frontend_info));
break; break;
case FE_READ_STATUS: case FE_READ_STATUS:
...@@ -426,40 +439,119 @@ static int grundig_29504_491_ioctl (struct dvb_frontend *fe, unsigned int cmd, ...@@ -426,40 +439,119 @@ static int grundig_29504_491_ioctl (struct dvb_frontend *fe, unsigned int cmd,
return 0; return 0;
} }
static struct i2c_client client_template;
static int tda8083_attach (struct dvb_i2c_bus *i2c, void **data) static int tda8083_attach_adapter(struct i2c_adapter *adapter)
{ {
if ((tda8083_readreg (i2c, 0x00)) != 0x05) struct tda8083_state *state;
struct i2c_client *client;
int ret;
dprintk("Trying to attach to adapter 0x%x:%s.\n",
adapter->id, adapter->name);
if ((tda8083_readreg (adapter, 0x00)) != 0x05)
return -ENODEV; return -ENODEV;
return dvb_register_frontend (grundig_29504_491_ioctl, i2c, NULL, if ( !(state = kmalloc(sizeof(struct tda8083_state), GFP_KERNEL)) )
&grundig_29504_491_info); return -ENOMEM;
if ( !(client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL)) ) {
kfree(state);
return -ENOMEM;
}
memset(state, 0, sizeof(struct tda8083_state));
state->i2c = adapter;
memcpy(client, &client_template, sizeof(struct i2c_client));
client->adapter = adapter;
client->addr = 0; //XXX
i2c_set_clientdata(client, state);
if ((ret = i2c_attach_client(client))) {
kfree(state);
kfree(client);
return ret;
}
BUG_ON(!state->dvb);
if ((ret = dvb_register_frontend(tda8083_ioctl, state->dvb, state,
&tda8083_info, THIS_MODULE))) {
i2c_detach_client(client);
kfree(state);
kfree(client);
return ret;
}
return 0;
} }
static int tda8083_detach_client(struct i2c_client *client)
{
struct tda8083_state *state = i2c_get_clientdata(client);
dvb_unregister_frontend_new (tda8083_ioctl, state->dvb);
i2c_detach_client(client);
BUG_ON(state->dvb);
kfree(client);
kfree(state);
return 0;
}
static void tda8083_detach (struct dvb_i2c_bus *i2c, void *data) static int tda8083_command (struct i2c_client *client, unsigned int cmd, void *arg)
{ {
dvb_unregister_frontend (grundig_29504_491_ioctl, i2c); struct tda8083_state *data = i2c_get_clientdata(client);
dprintk ("%s\n", __FUNCTION__);
switch (cmd) {
case FE_REGISTER: {
data->dvb = arg;
break;
}
case FE_UNREGISTER: {
data->dvb = NULL;
break;
}
default:
return -EOPNOTSUPP;
}
return 0;
} }
static struct i2c_driver driver = {
.owner = THIS_MODULE,
.name = FRONTEND_NAME,
.id = I2C_DRIVERID_DVBFE_TDA8083,
.flags = I2C_DF_NOTIFY,
.attach_adapter = tda8083_attach_adapter,
.detach_client = tda8083_detach_client,
.command = tda8083_command,
};
static struct i2c_client client_template = {
.name = FRONTEND_NAME,
.flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver,
};
static int __init init_tda8083 (void) static int __init init_tda8083 (void)
{ {
return dvb_register_i2c_device (THIS_MODULE, return i2c_add_driver(&driver);
tda8083_attach, tda8083_detach);
} }
static void __exit exit_tda8083 (void) static void __exit exit_tda8083 (void)
{ {
dvb_unregister_i2c_device (tda8083_attach); if (i2c_del_driver(&driver))
printk("grundig_29504_401: driver deregistration failed\n");
} }
module_init(init_tda8083); module_init(init_tda8083);
module_exit(exit_tda8083); module_exit(exit_tda8083);
MODULE_PARM(debug,"i"); MODULE_DESCRIPTION("Grundig 29504-491 DVB frontend driver (TDA8083 Based)");
MODULE_DESCRIPTION("Grundig 29504-491 DVB frontend driver");
MODULE_AUTHOR("Ralph Metzler, Holger Waechtler"); MODULE_AUTHOR("Ralph Metzler, Holger Waechtler");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
This diff is collapsed.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment