forked from luck/tmp_suning_uos_patched
V4L/DVB (12900): DiB8000: added support for DiBcom ISDB-T/ISDB-Tsb demodulator DiB8000
This commit adds support for the DiB8000 ISDB-T demodulator made by DiBcom. Signed-off-by: Olivier Grenie <Olivier.Grenie@dibcom.fr> Signed-off-by: Patrick Boettcher <pboettcher@dibcom.fr> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
2a6a30e05c
commit
77e2c0f5d4
@ -71,6 +71,7 @@ config DVB_USB_DIB0700
|
||||
depends on DVB_USB
|
||||
select DVB_DIB7000P if !DVB_FE_CUSTOMISE
|
||||
select DVB_DIB7000M if !DVB_FE_CUSTOMISE
|
||||
select DVB_DIB8000 if !DVB_FE_CUSTOMISE
|
||||
select DVB_DIB3000MC if !DVB_FE_CUSTOMISE
|
||||
select DVB_S5H1411 if !DVB_FE_CUSTOMISE
|
||||
select DVB_LGDT3305 if !DVB_FE_CUSTOMISE
|
||||
@ -87,7 +88,7 @@ config DVB_USB_DIB0700
|
||||
Avermedia and other big and small companies.
|
||||
|
||||
For an up-to-date list of devices supported by this driver, have a look
|
||||
on the Linux-DVB Wiki at www.linuxtv.org.
|
||||
on the LinuxTV Wiki at www.linuxtv.org.
|
||||
|
||||
Say Y if you own such a device and want to use it. You should build it as
|
||||
a module.
|
||||
|
@ -484,6 +484,14 @@ config DVB_S921
|
||||
AN ISDB-T DQPSK, QPSK, 16QAM and 64QAM 1seg tuner module.
|
||||
Say Y when you want to support this frontend.
|
||||
|
||||
config DVB_DIB8000
|
||||
tristate "DiBcom 8000MB/MC"
|
||||
depends on DVB_CORE && I2C
|
||||
default m if DVB_FE_CUSTOMISE
|
||||
help
|
||||
A driver for DiBcom's DiB8000 ISDB-T/ISDB-Tsb demodulator.
|
||||
Say Y when you want to support this frontend.
|
||||
|
||||
comment "Digital terrestrial only tuners/PLL"
|
||||
depends on DVB_CORE
|
||||
|
||||
|
@ -23,6 +23,7 @@ obj-$(CONFIG_DVB_DIB3000MB) += dib3000mb.o
|
||||
obj-$(CONFIG_DVB_DIB3000MC) += dib3000mc.o dibx000_common.o
|
||||
obj-$(CONFIG_DVB_DIB7000M) += dib7000m.o dibx000_common.o
|
||||
obj-$(CONFIG_DVB_DIB7000P) += dib7000p.o dibx000_common.o
|
||||
obj-$(CONFIG_DVB_DIB8000) += dib8000.o dibx000_common.o
|
||||
obj-$(CONFIG_DVB_MT312) += mt312.o
|
||||
obj-$(CONFIG_DVB_VES1820) += ves1820.o
|
||||
obj-$(CONFIG_DVB_VES1X93) += ves1x93.o
|
||||
|
2279
drivers/media/dvb/frontends/dib8000.c
Normal file
2279
drivers/media/dvb/frontends/dib8000.c
Normal file
File diff suppressed because it is too large
Load Diff
79
drivers/media/dvb/frontends/dib8000.h
Normal file
79
drivers/media/dvb/frontends/dib8000.h
Normal file
@ -0,0 +1,79 @@
|
||||
#ifndef DIB8000_H
|
||||
#define DIB8000_H
|
||||
|
||||
#include "dibx000_common.h"
|
||||
|
||||
struct dib8000_config {
|
||||
u8 output_mpeg2_in_188_bytes;
|
||||
u8 hostbus_diversity;
|
||||
u8 tuner_is_baseband;
|
||||
int (*update_lna) (struct dvb_frontend *, u16 agc_global);
|
||||
|
||||
u8 agc_config_count;
|
||||
struct dibx000_agc_config *agc;
|
||||
struct dibx000_bandwidth_config *pll;
|
||||
|
||||
#define DIB8000_GPIO_DEFAULT_DIRECTIONS 0xffff
|
||||
u16 gpio_dir;
|
||||
#define DIB8000_GPIO_DEFAULT_VALUES 0x0000
|
||||
u16 gpio_val;
|
||||
#define DIB8000_GPIO_PWM_POS0(v) ((v & 0xf) << 12)
|
||||
#define DIB8000_GPIO_PWM_POS1(v) ((v & 0xf) << 8 )
|
||||
#define DIB8000_GPIO_PWM_POS2(v) ((v & 0xf) << 4 )
|
||||
#define DIB8000_GPIO_PWM_POS3(v) (v & 0xf)
|
||||
#define DIB8000_GPIO_DEFAULT_PWM_POS 0xffff
|
||||
u16 gpio_pwm_pos;
|
||||
u16 pwm_freq_div;
|
||||
|
||||
void (*agc_control) (struct dvb_frontend *, u8 before);
|
||||
|
||||
u16 drives;
|
||||
u16 diversity_delay;
|
||||
u8 div_cfg;
|
||||
u8 output_mode;
|
||||
u8 refclksel;
|
||||
};
|
||||
|
||||
#define DEFAULT_DIB8000_I2C_ADDRESS 18
|
||||
|
||||
#if defined(CONFIG_DVB_DIB8000) || (defined(CONFIG_DVB_DIB8000_MODULE) && defined(MODULE))
|
||||
extern struct dvb_frontend *dib8000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg);
|
||||
extern struct i2c_adapter *dib8000_get_i2c_master(struct dvb_frontend *, enum dibx000_i2c_interface, int);
|
||||
|
||||
extern int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, u8 default_addr, u8 first_addr);
|
||||
|
||||
extern int dib8000_set_gpio(struct dvb_frontend *, u8 num, u8 dir, u8 val);
|
||||
extern int dib8000_set_wbd_ref(struct dvb_frontend *, u16 value);
|
||||
#else
|
||||
static inline struct dvb_frontend *dib8000_attach(struct i2c_adapter *i2c_adap, u8 i2c_addr, struct dib8000_config *cfg)
|
||||
{
|
||||
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct i2c_adapter *dib8000_get_i2c_master(struct dvb_frontend *fe, enum dibx000_i2c_interface i, int x)
|
||||
{
|
||||
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, u8 default_addr, u8 first_addr)
|
||||
{
|
||||
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int dib8000_set_gpio(struct dvb_frontend *fe, u8 num, u8 dir, u8 val)
|
||||
{
|
||||
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
int dib8000_set_wbd_ref(struct dvb_frontend *fe, u16 value)
|
||||
{
|
||||
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
|
||||
return -ENODEV;
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
@ -15,29 +15,31 @@ static int dibx000_write_word(struct dibx000_i2c_master *mst, u16 reg, u16 val)
|
||||
(val >> 8) & 0xff, val & 0xff,
|
||||
};
|
||||
struct i2c_msg msg = {
|
||||
.addr = mst->i2c_addr, .flags = 0, .buf = b, .len = 4
|
||||
.addr = mst->i2c_addr,.flags = 0,.buf = b,.len = 4
|
||||
};
|
||||
return i2c_transfer(mst->i2c_adap, &msg, 1) != 1 ? -EREMOTEIO : 0;
|
||||
}
|
||||
|
||||
|
||||
static int dibx000_i2c_select_interface(struct dibx000_i2c_master *mst, enum dibx000_i2c_interface intf)
|
||||
static int dibx000_i2c_select_interface(struct dibx000_i2c_master *mst,
|
||||
enum dibx000_i2c_interface intf)
|
||||
{
|
||||
if (mst->device_rev > DIB3000MC && mst->selected_interface != intf) {
|
||||
dprintk("selecting interface: %d\n",intf);
|
||||
dprintk("selecting interface: %d\n", intf);
|
||||
mst->selected_interface = intf;
|
||||
return dibx000_write_word(mst, mst->base_reg + 4, intf);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int dibx000_i2c_gate_ctrl(struct dibx000_i2c_master *mst, u8 tx[4], u8 addr, int onoff)
|
||||
static int dibx000_i2c_gate_ctrl(struct dibx000_i2c_master *mst, u8 tx[4],
|
||||
u8 addr, int onoff)
|
||||
{
|
||||
u16 val;
|
||||
|
||||
|
||||
if (onoff)
|
||||
val = addr << 8; // bit 7 = use master or not, if 0, the gate is open
|
||||
val = addr << 8; // bit 7 = use master or not, if 0, the gate is open
|
||||
else
|
||||
val = 1 << 7;
|
||||
|
||||
@ -45,7 +47,7 @@ static int dibx000_i2c_gate_ctrl(struct dibx000_i2c_master *mst, u8 tx[4], u8 ad
|
||||
val <<= 1;
|
||||
|
||||
tx[0] = (((mst->base_reg + 1) >> 8) & 0xff);
|
||||
tx[1] = ( (mst->base_reg + 1) & 0xff);
|
||||
tx[1] = ((mst->base_reg + 1) & 0xff);
|
||||
tx[2] = val >> 8;
|
||||
tx[3] = val & 0xff;
|
||||
|
||||
@ -57,59 +59,78 @@ static u32 dibx000_i2c_func(struct i2c_adapter *adapter)
|
||||
return I2C_FUNC_I2C;
|
||||
}
|
||||
|
||||
static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap, struct i2c_msg msg[], int num)
|
||||
static int dibx000_i2c_gated_tuner_xfer(struct i2c_adapter *i2c_adap,
|
||||
struct i2c_msg msg[], int num)
|
||||
{
|
||||
struct dibx000_i2c_master *mst = i2c_get_adapdata(i2c_adap);
|
||||
struct i2c_msg m[2 + num];
|
||||
u8 tx_open[4], tx_close[4];
|
||||
|
||||
memset(m,0, sizeof(struct i2c_msg) * (2 + num));
|
||||
memset(m, 0, sizeof(struct i2c_msg) * (2 + num));
|
||||
|
||||
dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_TUNER);
|
||||
|
||||
dibx000_i2c_gate_ctrl(mst, tx_open, msg[0].addr, 1);
|
||||
dibx000_i2c_gate_ctrl(mst, tx_open, msg[0].addr, 1);
|
||||
m[0].addr = mst->i2c_addr;
|
||||
m[0].buf = tx_open;
|
||||
m[0].len = 4;
|
||||
m[0].buf = tx_open;
|
||||
m[0].len = 4;
|
||||
|
||||
memcpy(&m[1], msg, sizeof(struct i2c_msg) * num);
|
||||
|
||||
dibx000_i2c_gate_ctrl(mst, tx_close, 0, 0);
|
||||
m[num+1].addr = mst->i2c_addr;
|
||||
m[num+1].buf = tx_close;
|
||||
m[num+1].len = 4;
|
||||
m[num + 1].addr = mst->i2c_addr;
|
||||
m[num + 1].buf = tx_close;
|
||||
m[num + 1].len = 4;
|
||||
|
||||
return i2c_transfer(mst->i2c_adap, m, 2+num) == 2 + num ? num : -EIO;
|
||||
return i2c_transfer(mst->i2c_adap, m, 2 + num) == 2 + num ? num : -EIO;
|
||||
}
|
||||
|
||||
static struct i2c_algorithm dibx000_i2c_gated_tuner_algo = {
|
||||
.master_xfer = dibx000_i2c_gated_tuner_xfer,
|
||||
.master_xfer = dibx000_i2c_gated_tuner_xfer,
|
||||
.functionality = dibx000_i2c_func,
|
||||
};
|
||||
|
||||
struct i2c_adapter * dibx000_get_i2c_adapter(struct dibx000_i2c_master *mst, enum dibx000_i2c_interface intf, int gating)
|
||||
struct i2c_adapter *dibx000_get_i2c_adapter(struct dibx000_i2c_master *mst,
|
||||
enum dibx000_i2c_interface intf,
|
||||
int gating)
|
||||
{
|
||||
struct i2c_adapter *i2c = NULL;
|
||||
|
||||
switch (intf) {
|
||||
case DIBX000_I2C_INTERFACE_TUNER:
|
||||
if (gating)
|
||||
i2c = &mst->gated_tuner_i2c_adap;
|
||||
break;
|
||||
default:
|
||||
printk(KERN_ERR "DiBX000: incorrect I2C interface selected\n");
|
||||
break;
|
||||
case DIBX000_I2C_INTERFACE_TUNER:
|
||||
if (gating)
|
||||
i2c = &mst->gated_tuner_i2c_adap;
|
||||
break;
|
||||
default:
|
||||
printk(KERN_ERR "DiBX000: incorrect I2C interface selected\n");
|
||||
break;
|
||||
}
|
||||
|
||||
return i2c;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(dibx000_get_i2c_adapter);
|
||||
|
||||
static int i2c_adapter_init(struct i2c_adapter *i2c_adap, struct i2c_algorithm *algo, const char *name, struct dibx000_i2c_master *mst)
|
||||
void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst)
|
||||
{
|
||||
/* initialize the i2c-master by closing the gate */
|
||||
u8 tx[4];
|
||||
struct i2c_msg m = {.addr = mst->i2c_addr,.buf = tx,.len = 4 };
|
||||
|
||||
dibx000_i2c_gate_ctrl(mst, tx, 0, 0);
|
||||
i2c_transfer(mst->i2c_adap, &m, 1);
|
||||
mst->selected_interface = 0xff; // the first time force a select of the I2C
|
||||
dibx000_i2c_select_interface(mst, DIBX000_I2C_INTERFACE_TUNER);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(dibx000_reset_i2c_master);
|
||||
|
||||
static int i2c_adapter_init(struct i2c_adapter *i2c_adap,
|
||||
struct i2c_algorithm *algo, const char *name,
|
||||
struct dibx000_i2c_master *mst)
|
||||
{
|
||||
strncpy(i2c_adap->name, name, sizeof(i2c_adap->name));
|
||||
i2c_adap->class = I2C_CLASS_TV_DIGITAL,
|
||||
i2c_adap->algo = algo;
|
||||
i2c_adap->class = I2C_CLASS_TV_DIGITAL, i2c_adap->algo = algo;
|
||||
i2c_adap->algo_data = NULL;
|
||||
i2c_set_adapdata(i2c_adap, mst);
|
||||
if (i2c_add_adapter(i2c_adap) < 0)
|
||||
@ -117,34 +138,40 @@ static int i2c_adapter_init(struct i2c_adapter *i2c_adap, struct i2c_algorithm *
|
||||
return 0;
|
||||
}
|
||||
|
||||
int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev, struct i2c_adapter *i2c_adap, u8 i2c_addr)
|
||||
int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev,
|
||||
struct i2c_adapter *i2c_adap, u8 i2c_addr)
|
||||
{
|
||||
u8 tx[4];
|
||||
struct i2c_msg m = { .addr = i2c_addr >> 1, .buf = tx, .len = 4 };
|
||||
struct i2c_msg m = {.addr = i2c_addr >> 1,.buf = tx,.len = 4 };
|
||||
|
||||
mst->device_rev = device_rev;
|
||||
mst->i2c_adap = i2c_adap;
|
||||
mst->i2c_addr = i2c_addr >> 1;
|
||||
mst->i2c_adap = i2c_adap;
|
||||
mst->i2c_addr = i2c_addr >> 1;
|
||||
|
||||
if (device_rev == DIB7000P)
|
||||
if (device_rev == DIB7000P || device_rev == DIB8000)
|
||||
mst->base_reg = 1024;
|
||||
else
|
||||
mst->base_reg = 768;
|
||||
|
||||
if (i2c_adapter_init(&mst->gated_tuner_i2c_adap, &dibx000_i2c_gated_tuner_algo, "DiBX000 tuner I2C bus", mst) != 0)
|
||||
printk(KERN_ERR "DiBX000: could not initialize the tuner i2c_adapter\n");
|
||||
if (i2c_adapter_init
|
||||
(&mst->gated_tuner_i2c_adap, &dibx000_i2c_gated_tuner_algo,
|
||||
"DiBX000 tuner I2C bus", mst) != 0)
|
||||
printk(KERN_ERR
|
||||
"DiBX000: could not initialize the tuner i2c_adapter\n");
|
||||
|
||||
/* initialize the i2c-master by closing the gate */
|
||||
dibx000_i2c_gate_ctrl(mst, tx, 0, 0);
|
||||
|
||||
return i2c_transfer(i2c_adap, &m, 1) == 1;
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(dibx000_init_i2c_master);
|
||||
|
||||
void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst)
|
||||
{
|
||||
i2c_del_adapter(&mst->gated_tuner_i2c_adap);
|
||||
}
|
||||
|
||||
EXPORT_SYMBOL(dibx000_exit_i2c_master);
|
||||
|
||||
MODULE_AUTHOR("Patrick Boettcher <pboettcher@dibcom.fr>");
|
||||
|
@ -2,7 +2,7 @@
|
||||
#define DIBX000_COMMON_H
|
||||
|
||||
enum dibx000_i2c_interface {
|
||||
DIBX000_I2C_INTERFACE_TUNER = 0,
|
||||
DIBX000_I2C_INTERFACE_TUNER = 0,
|
||||
DIBX000_I2C_INTERFACE_GPIO_1_2 = 1,
|
||||
DIBX000_I2C_INTERFACE_GPIO_3_4 = 2
|
||||
};
|
||||
@ -12,22 +12,29 @@ struct dibx000_i2c_master {
|
||||
#define DIB7000 2
|
||||
#define DIB7000P 11
|
||||
#define DIB7000MC 12
|
||||
#define DIB8000 13
|
||||
u16 device_rev;
|
||||
|
||||
enum dibx000_i2c_interface selected_interface;
|
||||
|
||||
// struct i2c_adapter tuner_i2c_adap;
|
||||
struct i2c_adapter gated_tuner_i2c_adap;
|
||||
// struct i2c_adapter tuner_i2c_adap;
|
||||
struct i2c_adapter gated_tuner_i2c_adap;
|
||||
|
||||
struct i2c_adapter *i2c_adap;
|
||||
u8 i2c_addr;
|
||||
u8 i2c_addr;
|
||||
|
||||
u16 base_reg;
|
||||
};
|
||||
|
||||
extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst, u16 device_rev, struct i2c_adapter *i2c_adap, u8 i2c_addr);
|
||||
extern struct i2c_adapter * dibx000_get_i2c_adapter(struct dibx000_i2c_master *mst, enum dibx000_i2c_interface intf, int gating);
|
||||
extern int dibx000_init_i2c_master(struct dibx000_i2c_master *mst,
|
||||
u16 device_rev, struct i2c_adapter *i2c_adap,
|
||||
u8 i2c_addr);
|
||||
extern struct i2c_adapter *dibx000_get_i2c_adapter(struct dibx000_i2c_master
|
||||
*mst,
|
||||
enum dibx000_i2c_interface
|
||||
intf, int gating);
|
||||
extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
|
||||
extern void dibx000_reset_i2c_master(struct dibx000_i2c_master *mst);
|
||||
|
||||
#define BAND_LBAND 0x01
|
||||
#define BAND_UHF 0x02
|
||||
@ -41,18 +48,18 @@ extern void dibx000_exit_i2c_master(struct dibx000_i2c_master *mst);
|
||||
(freq_kHz) <= 2000000 ? BAND_LBAND : BAND_SBAND )
|
||||
|
||||
struct dibx000_agc_config {
|
||||
/* defines the capabilities of this AGC-setting - using the BAND_-defines*/
|
||||
u8 band_caps;
|
||||
/* defines the capabilities of this AGC-setting - using the BAND_-defines */
|
||||
u8 band_caps;
|
||||
|
||||
u16 setup;
|
||||
|
||||
u16 inv_gain;
|
||||
u16 time_stabiliz;
|
||||
|
||||
u8 alpha_level;
|
||||
u8 alpha_level;
|
||||
u16 thlock;
|
||||
|
||||
u8 wbd_inv;
|
||||
u8 wbd_inv;
|
||||
u16 wbd_ref;
|
||||
u8 wbd_sel;
|
||||
u8 wbd_alpha;
|
||||
@ -92,8 +99,8 @@ struct dibx000_agc_config {
|
||||
};
|
||||
|
||||
struct dibx000_bandwidth_config {
|
||||
u32 internal;
|
||||
u32 sampling;
|
||||
u32 internal;
|
||||
u32 sampling;
|
||||
|
||||
u8 pll_prediv;
|
||||
u8 pll_ratio;
|
||||
|
Loading…
Reference in New Issue
Block a user