Commit ac1a4632 authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] DVB: frontend conversion #2

- [DVB] alps_tdlb7, alps_tdmb7, at76c651, cx24110, dst: convert from dvb-i2c
  to kernel-i2c, MODULE_PARM() to module_param(), dvb_delay() to mdelay()

- [DVB] alps_tdlb7: move from home-brewn firmware loading to firmware_class

- [DVB] dst: use sysfs attributes for type and flags for per-card parameters
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 7bea3b79
This diff is collapsed.
......@@ -23,15 +23,23 @@
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/moduleparam.h>
#include <linux/string.h>
#include <linux/slab.h>
#include "dvb_frontend.h"
#include "dvb_functions.h"
#define FRONTEND_NAME "dvbfe_alps_tdmb7"
static int debug = 0;
#define dprintk if (debug) printk
#define dprintk(args...) \
do { \
if (debug) printk(KERN_DEBUG FRONTEND_NAME ": " args); \
} while (0)
static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Turn on/off frontend debugging (default:off).");
static struct dvb_frontend_info tdmb7_info = {
......@@ -53,6 +61,10 @@ static struct dvb_frontend_info tdmb7_info = {
FE_CAN_RECOVER
};
struct tdmb7_state {
struct i2c_adapter *i2c;
struct dvb_adapter *dvb;
};
static u8 init_tab [] = {
0x04, 0x10,
......@@ -75,8 +87,7 @@ static u8 init_tab [] = {
0x47, 0x05,
};
static int cx22700_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
static int cx22700_writereg (struct i2c_adapter *i2c, u8 reg, u8 data)
{
int ret;
u8 buf [] = { reg, data };
......@@ -84,7 +95,7 @@ static int cx22700_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
dprintk ("%s\n", __FUNCTION__);
ret = i2c->xfer (i2c, &msg, 1);
ret = i2c_transfer (i2c, &msg, 1);
if (ret != 1)
printk("%s: writereg error (reg == 0x%02x, val == 0x%02x, ret == %i)\n",
......@@ -93,8 +104,7 @@ static int cx22700_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
return (ret != 1) ? -1 : 0;
}
static u8 cx22700_readreg (struct dvb_i2c_bus *i2c, u8 reg)
static u8 cx22700_readreg (struct i2c_adapter *i2c, u8 reg)
{
int ret;
u8 b0 [] = { reg };
......@@ -104,7 +114,7 @@ static u8 cx22700_readreg (struct dvb_i2c_bus *i2c, u8 reg)
dprintk ("%s\n", __FUNCTION__);
ret = i2c->xfer (i2c, msg, 2);
ret = i2c_transfer (i2c, msg, 2);
if (ret != 2)
printk("%s: readreg error (ret == %i)\n", __FUNCTION__, ret);
......@@ -112,14 +122,13 @@ static u8 cx22700_readreg (struct dvb_i2c_bus *i2c, u8 reg)
return b1[0];
}
static int pll_write (struct dvb_i2c_bus *i2c, u8 data [4])
static int pll_write (struct i2c_adapter *i2c, u8 data [4])
{
struct i2c_msg msg = { .addr = 0x61, .flags = 0, .buf = data, .len = 4 };
int ret;
cx22700_writereg (i2c, 0x0a, 0x00); /* open i2c bus switch */
ret = i2c->xfer (i2c, &msg, 1);
ret = i2c_transfer (i2c, &msg, 1);
cx22700_writereg (i2c, 0x0a, 0x01); /* close i2c bus switch */
if (ret != 1)
......@@ -133,7 +142,7 @@ static int pll_write (struct dvb_i2c_bus *i2c, u8 data [4])
* set up the downconverter frequency divisor for a
* reference clock comparision frequency of 125 kHz.
*/
static int pll_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
static int pll_set_tv_freq (struct i2c_adapter *i2c, u32 freq)
{
u32 div = (freq + 36166667) / 166667;
#if 1 //ALPS_SETTINGS
......@@ -149,8 +158,7 @@ static int pll_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
return pll_write (i2c, buf);
}
static int cx22700_init (struct dvb_i2c_bus *i2c)
static int cx22700_init (struct i2c_adapter *i2c)
{
int i;
......@@ -159,7 +167,7 @@ static int cx22700_init (struct dvb_i2c_bus *i2c)
cx22700_writereg (i2c, 0x00, 0x02); /* soft reset */
cx22700_writereg (i2c, 0x00, 0x00);
dvb_delay(10);
msleep(10);
for (i=0; i<sizeof(init_tab); i+=2)
cx22700_writereg (i2c, init_tab[i], init_tab[i+1]);
......@@ -169,8 +177,7 @@ static int cx22700_init (struct dvb_i2c_bus *i2c)
return 0;
}
static int cx22700_set_inversion (struct dvb_i2c_bus *i2c, int inversion)
static int cx22700_set_inversion (struct i2c_adapter *i2c, int inversion)
{
u8 val;
......@@ -190,8 +197,7 @@ static int cx22700_set_inversion (struct dvb_i2c_bus *i2c, int inversion)
}
}
static int cx22700_set_tps (struct dvb_i2c_bus *i2c, struct dvb_ofdm_parameters *p)
static int cx22700_set_tps (struct i2c_adapter *i2c, struct dvb_ofdm_parameters *p)
{
static const u8 qam_tab [4] = { 0, 1, 0, 2 };
static const u8 fec_tab [6] = { 0, 1, 2, 0, 3, 4 };
......@@ -253,8 +259,7 @@ static int cx22700_set_tps (struct dvb_i2c_bus *i2c, struct dvb_ofdm_parameters
return 0;
}
static int cx22700_get_tps (struct dvb_i2c_bus *i2c, struct dvb_ofdm_parameters *p)
static int cx22700_get_tps (struct i2c_adapter *i2c, struct dvb_ofdm_parameters *p)
{
static const fe_modulation_t qam_tab [3] = { QPSK, QAM_16, QAM_64 };
static const fe_code_rate_t fec_tab [5] = { FEC_1_2, FEC_2_3, FEC_3_4,
......@@ -300,10 +305,10 @@ static int cx22700_get_tps (struct dvb_i2c_bus *i2c, struct dvb_ofdm_parameters
return 0;
}
static int tdmb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
struct dvb_i2c_bus *i2c = fe->i2c;
struct tdmb7_state *state = fe->data;
struct i2c_adapter *i2c = state->i2c;
dprintk ("%s\n", __FUNCTION__);
......@@ -406,10 +411,14 @@ static int tdmb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
return 0;
}
static struct i2c_client client_template;
static int tdmb7_attach (struct dvb_i2c_bus *i2c, void **data)
static int attach_adapter (struct i2c_adapter *adapter)
{
struct tdmb7_state *state;
struct i2c_client *client;
int ret;
u8 b0 [] = { 0x7 };
u8 b1 [] = { 0 };
struct i2c_msg msg [] = { { .addr = 0x43, .flags = 0, .buf = b0, .len = 1 },
......@@ -417,41 +426,109 @@ static int tdmb7_attach (struct dvb_i2c_bus *i2c, void **data)
dprintk ("%s\n", __FUNCTION__);
if (i2c->xfer (i2c, msg, 2) != 2)
if (i2c_transfer(adapter, msg, 2) != 2)
return -ENODEV;
return dvb_register_frontend (tdmb7_ioctl, i2c, NULL, &tdmb7_info);
if (NULL == (state = kmalloc(sizeof(struct tdmb7_state), GFP_KERNEL)))
return -ENOMEM;
state->i2c = adapter;
if (NULL == (client = kmalloc(sizeof(struct i2c_client), GFP_KERNEL))) {
kfree(state);
return -ENOMEM;
}
memcpy(client, &client_template, sizeof(struct i2c_client));
client->adapter = adapter;
i2c_set_clientdata(client, state);
ret = i2c_attach_client(client);
if (ret) {
kfree(state);
kfree(client);
return ret;
}
BUG_ON(!state->dvb);
ret = dvb_register_frontend (tdmb7_ioctl, state->dvb, state,
&tdmb7_info, THIS_MODULE);
if (ret) {
i2c_detach_client(client);
kfree(state);
kfree(client);
return ret;
}
return 0;
}
static void tdmb7_detach (struct dvb_i2c_bus *i2c, void *data)
static int detach_client (struct i2c_client *client)
{
struct tdmb7_state *state = i2c_get_clientdata(client);
dprintk ("%s\n", __FUNCTION__);
dvb_unregister_frontend (tdmb7_ioctl, i2c);
dvb_unregister_frontend_new (tdmb7_ioctl, state->dvb);
i2c_detach_client(client);
BUG_ON(state->dvb);
kfree(client);
kfree(state);
return 0;
}
static int __init init_tdmb7 (void)
static int command (struct i2c_client *client,
unsigned int cmd, void *arg)
{
struct tdmb7_state *state = i2c_get_clientdata(client);
dprintk ("%s\n", __FUNCTION__);
return dvb_register_i2c_device (THIS_MODULE, tdmb7_attach, tdmb7_detach);
switch (cmd) {
case FE_REGISTER:
state->dvb = arg;
break;
case FE_UNREGISTER:
state->dvb = NULL;
break;
default:
return -EOPNOTSUPP;
}
return 0;
}
static struct i2c_driver driver = {
.owner = THIS_MODULE,
.name = FRONTEND_NAME,
.id = I2C_DRIVERID_DVBFE_ALPS_TDMB7,
.flags = I2C_DF_NOTIFY,
.attach_adapter = attach_adapter,
.detach_client = detach_client,
.command = command,
};
static struct i2c_client client_template = {
.name = FRONTEND_NAME,
.flags = I2C_CLIENT_ALLOW_USE,
.driver = &driver,
};
static void __exit exit_tdmb7 (void)
static int __init init_tdmb7 (void)
{
dprintk ("%s\n", __FUNCTION__);
return i2c_add_driver(&driver);
}
dvb_unregister_i2c_device (tdmb7_attach);
static void __exit exit_tdmb7 (void)
{
if (i2c_del_driver(&driver))
printk(KERN_ERR "alps_tdmb7: driver deregistration failed.\n");
}
module_init (init_tdmb7);
module_exit (exit_tdmb7);
MODULE_PARM(debug,"i");
MODULE_PARM_DESC(debug, "enable verbose debug messages");
MODULE_DESCRIPTION("TDMB7 DVB Frontend driver");
MODULE_AUTHOR("Holger Waechtler");
MODULE_LICENSE("GPL");
......
This diff is collapsed.
This diff is collapsed.
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