Commit 76aec2dc authored by Michael Hunold's avatar Michael Hunold Committed by Linus Torvalds

[PATCH] DVB: Misc. DVB frontend driver updates

 - [DVB] follow changes in dvb-core for frontend drivers (ves1x93,
   ves1820, nxt6000, sp887x, tda1004x, stv0299, mt312, alps_tdlb7,
   alps_tdmb7, at76c651, cx24110, dst, dvb_dummy_fe, grundig_29504-401,
   grundig_29504-491)
 - [DVB] tda1004x: updated timeout to 800ms, implemented FE_SLEEP
 - [DVB] cx24110: add FE_CAN_RECOVER to reduce kdvb-fe CPU load
 - [DVB] grundig_29504-401: added 200ms delay after first FE_INIT,
   Implemented FE_GET_FRONTEND
 - [DVB] alps_tdlb7, alps_tdmb7: upped tuning delays to fix tuning
parent a652d124
......@@ -29,11 +29,11 @@
*/
#define __KERNEL_SYSCALLS__
#include <linux/module.h>
#include <linux/init.h>
#include <linux/vmalloc.h>
#include <linux/fs.h>
#include <linux/syscalls.h>
#include <linux/unistd.h>
#include <linux/delay.h>
......@@ -56,6 +56,8 @@ static int debug = 0;
#define SP8870_FIRMWARE_OFFSET 0x0A
static int errno;
static struct dvb_frontend_info tdlb7_info = {
.name = "Alps TDLB7",
.type = FE_OFDM,
......@@ -74,12 +76,7 @@ static struct dvb_frontend_info tdlb7_info = {
static int sp8870_writereg (struct dvb_i2c_bus *i2c, u16 reg, u16 data)
{
u8 buf [] = { reg >> 8, reg & 0xff, data >> 8, data & 0xff };
struct i2c_msg msg = {
.addr = 0x71,
.flags = 0,
.buf = buf,
.len = 4
};
struct i2c_msg msg = { .addr = 0x71, .flags = 0, .buf = buf, .len = 4 };
int err;
if ((err = i2c->xfer (i2c, &msg, 1)) != 1) {
......@@ -96,20 +93,8 @@ static u16 sp8870_readreg (struct dvb_i2c_bus *i2c, u16 reg)
int ret;
u8 b0 [] = { reg >> 8 , reg & 0xff };
u8 b1 [] = { 0, 0 };
struct i2c_msg msg [] = {
{
.addr = 0x71,
.flags = 0,
.buf = b0,
.len = 2
},
{
.addr = 0x71,
.flags = I2C_M_RD,
.buf = b1,
.len = 2
}
};
struct i2c_msg msg [] = { { .addr = 0x71, .flags = 0, .buf = b0, .len = 2 },
{ .addr = 0x71, .flags = I2C_M_RD, .buf = b1, .len = 2 } };
ret = i2c->xfer (i2c, msg, 2);
......@@ -125,12 +110,7 @@ static u16 sp8870_readreg (struct dvb_i2c_bus *i2c, u16 reg)
static int sp5659_write (struct dvb_i2c_bus *i2c, u8 data [4])
{
int ret;
struct i2c_msg msg = {
.addr = 0x60,
.flags = 0,
.buf = data,
.len =4
};
struct i2c_msg msg = { .addr = 0x60, .flags = 0, .buf = data, .len = 4 };
ret = i2c->xfer (i2c, &msg, 1);
......@@ -170,13 +150,13 @@ static int sp8870_read_firmware_file (const char *fn, char **fp)
loff_t filesize;
char *dp;
fd = sys_open(fn, 0, 0);
fd = open(fn, 0, 0);
if (fd == -1) {
printk("%s: unable to open '%s'.\n", __FUNCTION__, fn);
return -EIO;
}
filesize = sys_lseek(fd, 0L, 2);
filesize = lseek(fd, 0L, 2);
if (filesize <= 0 || filesize < SP8870_FIRMWARE_OFFSET + SP8870_FIRMWARE_SIZE) {
printk("%s: firmware filesize to small '%s'\n", __FUNCTION__, fn);
sys_close(fd);
......@@ -190,8 +170,8 @@ static int sp8870_read_firmware_file (const char *fn, char **fp)
return -EIO;
}
sys_lseek(fd, SP8870_FIRMWARE_OFFSET, 0);
if (sys_read(fd, dp, SP8870_FIRMWARE_SIZE) != SP8870_FIRMWARE_SIZE) {
lseek(fd, SP8870_FIRMWARE_OFFSET, 0);
if (read(fd, dp, SP8870_FIRMWARE_SIZE) != SP8870_FIRMWARE_SIZE) {
printk("%s: failed to read '%s'.\n",__FUNCTION__, fn);
vfree(dp);
sys_close(fd);
......@@ -658,9 +638,6 @@ static int tdlb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_SET_FRONTEND:
return sp8870_set_frontend(i2c, (struct dvb_frontend_parameters*) arg);
case FE_RESET:
return -EOPNOTSUPP;
case FE_GET_FRONTEND: // FIXME: read known values back from Hardware...
return -EOPNOTSUPP;
......@@ -675,6 +652,15 @@ static int tdlb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
}
break;
case FE_GET_TUNE_SETTINGS:
{
struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
fesettings->min_delay_ms = 150;
fesettings->step_size = 166667;
fesettings->max_drift = 166667*2;
return 0;
}
default:
return -EOPNOTSUPP;
};
......@@ -687,21 +673,8 @@ static int tdlb7_attach (struct dvb_i2c_bus *i2c, void **data)
{
u8 b0 [] = { 0x02 , 0x00 };
u8 b1 [] = { 0, 0 };
struct i2c_msg msg [] =
{
{
.addr = 0x71,
.flags = 0,
.buf = b0,
.len = 2
},
{
.addr = 0x71,
.flags = I2C_M_RD,
.buf = b1,
.len = 2
}
};
struct i2c_msg msg [] = { { .addr = 0x71, .flags = 0, .buf = b0, .len = 2 },
{ .addr = 0x71, .flags = I2C_M_RD, .buf = b1, .len = 2 } };
dprintk ("%s\n", __FUNCTION__);
......
......@@ -50,7 +50,7 @@ static struct dvb_frontend_info tdmb7_info = {
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
FE_CAN_CLEAN_SETUP | FE_CAN_RECOVER
FE_CAN_RECOVER
};
......@@ -390,8 +390,14 @@ static int tdmb7_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_INIT:
return cx22700_init (i2c);
case FE_RESET:
break;
case FE_GET_TUNE_SETTINGS:
{
struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
fesettings->min_delay_ms = 150;
fesettings->step_size = 166667;
fesettings->max_drift = 166667*2;
return 0;
}
default:
return -EOPNOTSUPP;
......
......@@ -71,9 +71,7 @@ static struct dvb_frontend_info at76c651_info = {
FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 | FE_CAN_QAM_128 |
FE_CAN_QAM_256 /* | FE_CAN_QAM_512 | FE_CAN_QAM_1024 */ |
FE_CAN_RECOVER | FE_CAN_CLEAN_SETUP | FE_CAN_MUTE_TS
FE_CAN_MUTE_TS | FE_CAN_QAM_256 | FE_CAN_RECOVER
};
#if ! defined(__powerpc__)
......@@ -361,6 +359,7 @@ static int at76c651_set_parameters(struct dvb_i2c_bus *i2c,
at76c651_set_symbolrate(i2c, p->u.qam.symbol_rate);
at76c651_set_inversion(i2c, p->inversion);
at76c651_set_auto_config(i2c);
at76c651_reset(i2c);
return 0;
......@@ -462,8 +461,14 @@ static int at76c651_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_INIT:
return at76c651_set_defaults(fe->i2c);
case FE_RESET:
return at76c651_reset(fe->i2c);
case FE_GET_TUNE_SETTINGS:
{
struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
fesettings->min_delay_ms = 50;
fesettings->step_size = 0;
fesettings->max_drift = 0;
return 0;
}
default:
return -ENOIOCTLCMD;
......
......@@ -59,8 +59,7 @@ static struct dvb_frontend_info cx24110_info = {
.caps = FE_CAN_INVERSION_AUTO |
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK |
FE_CAN_CLEAN_SETUP
FE_CAN_QPSK | FE_CAN_RECOVER
};
/* fixme: are these values correct? especially ..._tolerance and caps */
......@@ -621,11 +620,6 @@ static int cx24110_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_INIT:
return cx24110_init (i2c);
case FE_RESET:
/* no idea what to do for this call */
/* fixme (medium): fill me in */
break;
case FE_SET_TONE:
return cx24110_writereg(i2c,0x76,(cx24110_readreg(i2c,0x76)&~0x10)|((((fe_sec_tone_mode_t) arg)==SEC_TONE_ON)?0x10:0));
case FE_SET_VOLTAGE:
......
......@@ -963,7 +963,6 @@ struct lkup {
{FE_GET_FRONTEND, "FE_GET_FRONTEND:" },
{FE_SLEEP, "FE_SLEEP:" },
{FE_INIT, "FE_INIT:" },
{FE_RESET, "FE_RESET:" },
{FE_SET_TONE, "FE_SET_TONE:" },
{FE_SET_VOLTAGE, "FE_SET_VOLTAGE:" },
};
......@@ -1091,9 +1090,6 @@ static int dst_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
dst_init(dst);
break;
case FE_RESET:
break;
case FE_DISEQC_SEND_MASTER_CMD:
{
struct dvb_diseqc_master_cmd *cmd = (struct dvb_diseqc_master_cmd *)arg;
......@@ -1149,8 +1145,8 @@ static int dst_attach (struct dvb_i2c_bus *i2c, void **data)
}
dst_init (dst);
dprintk("%s: register dst %p bt %p i2c %p\n", __FUNCTION__,
dst, dst->bt, dst->i2c);
dprintk("%s: register dst %8.8x bt %8.8x i2c %8.8x\n", __FUNCTION__,
(u32)dst, (u32)(dst->bt), (u32)(dst->i2c));
info = &dst_info_sat;
if (dst->dst_type == DST_TYPE_IS_TERR)
......@@ -1166,7 +1162,7 @@ static int dst_attach (struct dvb_i2c_bus *i2c, void **data)
static void dst_detach (struct dvb_i2c_bus *i2c, void *data)
{
dvb_unregister_frontend (dst_ioctl, i2c);
dprintk("%s: unregister dst %p\n", __FUNCTION__, data);
dprintk("%s: unregister dst %8.8x\n", __FUNCTION__, (u32)(data));
if (data)
kfree(data);
}
......
......@@ -62,8 +62,7 @@ static struct dvb_frontend_info dvb_c_dummyfe_info = {
#endif
.caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
FE_CAN_QAM_128 | FE_CAN_QAM_256 |
FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO |
FE_CAN_CLEAN_SETUP
FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO
};
static struct dvb_frontend_info dvb_t_dummyfe_info = {
......@@ -157,9 +156,6 @@ static int dvbdummyfe_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *ar
case FE_INIT:
return 0;
case FE_RESET:
return 0;
case FE_SET_TONE:
return -EOPNOTSUPP;
......
......@@ -35,6 +35,9 @@ static int debug = 0;
#define dprintk if (debug) printk
struct grundig_state {
int first:1;
};
struct dvb_frontend_info grundig_29504_401_info = {
.name = "Grundig 29504-401",
......@@ -48,7 +51,7 @@ struct dvb_frontend_info grundig_29504_401_info = {
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
FE_CAN_MUTE_TS /*| FE_CAN_CLEAN_SETUP*/
FE_CAN_MUTE_TS
};
......@@ -102,6 +105,7 @@ static int tsa5060_write (struct dvb_i2c_bus *i2c, u8 data [4])
*/
static int tsa5060_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
{
#if 1
u32 div;
u8 buf [4];
u8 cfg, cpump, band_select;
......@@ -118,6 +122,20 @@ static int tsa5060_set_tv_freq (struct dvb_i2c_bus *i2c, u32 freq)
buf [1] = div & 0xff;
buf [2] = ((div >> 10) & 0x60) | cfg;
buf [3] = (cpump << 6) | band_select;
#else
/* old code which seems to work better for at least one person */
u32 div;
u8 buf [4];
u8 cfg;
div = (36000000 + freq) / 166666;
cfg = 0x88;
buf [0] = (div >> 8) & 0x7f;
buf [1] = div & 0xff;
buf [2] = ((div >> 10) & 0x60) | cfg;
buf [3] = 0xc0;
#endif
return tsa5060_write (i2c, buf);
}
......@@ -276,6 +294,123 @@ static int reset_and_configure (struct dvb_i2c_bus *i2c)
}
static int get_frontend(struct dvb_i2c_bus* i2c, struct dvb_frontend_parameters* param)
{
int tmp;
tmp = l64781_readreg(i2c, 0x04);
switch(tmp & 3) {
case 0:
param->u.ofdm.guard_interval = GUARD_INTERVAL_1_32;
break;
case 1:
param->u.ofdm.guard_interval = GUARD_INTERVAL_1_16;
break;
case 2:
param->u.ofdm.guard_interval = GUARD_INTERVAL_1_8;
break;
case 3:
param->u.ofdm.guard_interval = GUARD_INTERVAL_1_4;
break;
}
switch((tmp >> 2) & 3) {
case 0:
param->u.ofdm.transmission_mode = TRANSMISSION_MODE_2K;
break;
case 1:
param->u.ofdm.transmission_mode = TRANSMISSION_MODE_8K;
break;
default:
printk("Unexpected value for transmission_mode\n");
}
tmp = l64781_readreg(i2c, 0x05);
switch(tmp & 7) {
case 0:
param->u.ofdm.code_rate_HP = FEC_1_2;
break;
case 1:
param->u.ofdm.code_rate_HP = FEC_2_3;
break;
case 2:
param->u.ofdm.code_rate_HP = FEC_3_4;
break;
case 3:
param->u.ofdm.code_rate_HP = FEC_5_6;
break;
case 4:
param->u.ofdm.code_rate_HP = FEC_7_8;
break;
default:
printk("Unexpected value for code_rate_HP\n");
}
switch((tmp >> 3) & 7) {
case 0:
param->u.ofdm.code_rate_LP = FEC_1_2;
break;
case 1:
param->u.ofdm.code_rate_LP = FEC_2_3;
break;
case 2:
param->u.ofdm.code_rate_LP = FEC_3_4;
break;
case 3:
param->u.ofdm.code_rate_LP = FEC_5_6;
break;
case 4:
param->u.ofdm.code_rate_LP = FEC_7_8;
break;
default:
printk("Unexpected value for code_rate_LP\n");
}
tmp = l64781_readreg(i2c, 0x06);
switch(tmp & 3) {
case 0:
param->u.ofdm.constellation = QPSK;
break;
case 1:
param->u.ofdm.constellation = QAM_16;
break;
case 2:
param->u.ofdm.constellation = QAM_64;
break;
default:
printk("Unexpected value for constellation\n");
}
switch((tmp >> 2) & 7) {
case 0:
param->u.ofdm.hierarchy_information = HIERARCHY_NONE;
break;
case 1:
param->u.ofdm.hierarchy_information = HIERARCHY_1;
break;
case 2:
param->u.ofdm.hierarchy_information = HIERARCHY_2;
break;
case 3:
param->u.ofdm.hierarchy_information = HIERARCHY_4;
break;
default:
printk("Unexpected value for hierarchy\n");
}
tmp = l64781_readreg (i2c, 0x1d);
param->inversion = (tmp & 0x80) ? INVERSION_ON : INVERSION_OFF;
tmp = (int) (l64781_readreg (i2c, 0x08) |
(l64781_readreg (i2c, 0x09) << 8) |
(l64781_readreg (i2c, 0x0a) << 16));
param->frequency += tmp;
return 0;
}
static int init (struct dvb_i2c_bus *i2c)
{
......@@ -318,6 +453,9 @@ int grundig_29504_401_ioctl (struct dvb_frontend *fe,
unsigned int cmd, void *arg)
{
struct dvb_i2c_bus *i2c = fe->i2c;
int res;
struct grundig_state* state = (struct grundig_state*) fe->data;
switch (cmd) {
case FE_GET_INFO:
memcpy (arg, &grundig_29504_401_info,
......@@ -393,18 +531,33 @@ int grundig_29504_401_ioctl (struct dvb_frontend *fe,
tsa5060_set_tv_freq (i2c, p->frequency);
return apply_frontend_param (i2c, p);
}
case FE_GET_FRONTEND:
/* we could correct the frequency here, but...
* (...do you want to implement this?;)
*/
return 0;
{
struct dvb_frontend_parameters *p = arg;
return get_frontend(i2c, p);
}
case FE_SLEEP:
/* Power down */
return l64781_writereg (i2c, 0x3e, 0x5a);
case FE_INIT:
return init (i2c);
res = init (i2c);
if ((res == 0) && (state->first)) {
state->first = 0;
dvb_delay(200);
}
return res;
case FE_GET_TUNE_SETTINGS:
{
struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
fesettings->min_delay_ms = 200;
fesettings->step_size = 166667;
fesettings->max_drift = 166667*2;
return 0;
}
default:
dprintk ("%s: unknown command !!!\n", __FUNCTION__);
......@@ -422,6 +575,7 @@ static int l64781_attach (struct dvb_i2c_bus *i2c, void **data)
u8 b1 [] = { 0x00 };
struct i2c_msg msg [] = { { .addr = 0x55, .flags = 0, .buf = b0, .len = 1 },
{ .addr = 0x55, .flags = I2C_M_RD, .buf = b1, .len = 1 } };
struct grundig_state* state;
/**
* the L64781 won't show up before we send the reset_and_configure()
......@@ -465,7 +619,12 @@ static int l64781_attach (struct dvb_i2c_bus *i2c, void **data)
goto bailout;
}
return dvb_register_frontend (grundig_29504_401_ioctl, i2c, NULL,
state = kmalloc(sizeof(struct grundig_state), GFP_KERNEL);
if (state == NULL) goto bailout;
*data = state;
state->first = 1;
return dvb_register_frontend (grundig_29504_401_ioctl, i2c, state,
&grundig_29504_401_info);
bailout:
......@@ -477,6 +636,7 @@ static int l64781_attach (struct dvb_i2c_bus *i2c, void **data)
static void l64781_detach (struct dvb_i2c_bus *i2c, void *data)
{
kfree(data);
dvb_unregister_frontend (grundig_29504_401_ioctl, i2c);
}
......
......@@ -52,8 +52,7 @@ static struct dvb_frontend_info grundig_29504_491_info = {
FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK |
FE_CAN_MUTE_TS | FE_CAN_CLEAN_SETUP
FE_CAN_QPSK | FE_CAN_MUTE_TS
};
......@@ -398,11 +397,6 @@ static int grundig_29504_491_ioctl (struct dvb_frontend *fe, unsigned int cmd,
tda8083_writereg (i2c, 0x00, 0x04);
break;
case FE_RESET:
tda8083_writereg (i2c, 0x00, 0x3c);
tda8083_writereg (i2c, 0x00, 0x04);
break;
case FE_DISEQC_SEND_MASTER_CMD:
return tda8083_send_diseqc_msg (i2c, arg);
......
......@@ -66,8 +66,8 @@ static struct dvb_frontend_info mt312_info = {
.caps =
FE_CAN_INVERSION_AUTO | FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 |
FE_CAN_FEC_3_4 | FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 |
FE_CAN_FEC_AUTO | FE_CAN_QPSK | FE_CAN_RECOVER |
FE_CAN_CLEAN_SETUP | FE_CAN_MUTE_TS
FE_CAN_FEC_AUTO | FE_CAN_QPSK | FE_CAN_MUTE_TS |
FE_CAN_RECOVER
};
static int mt312_read(struct dvb_i2c_bus *i2c,
......@@ -570,6 +570,8 @@ static int mt312_set_frontend(struct dvb_i2c_bus *i2c,
if ((ret = mt312_write(i2c, SYM_RATE_H, buf, sizeof(buf))) < 0)
return ret;
mt312_reset(i2c, 0);
return 0;
}
......@@ -756,8 +758,14 @@ static int mt312_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
else
return mt312_init(i2c, (long) fe->data, (u8) 60);
case FE_RESET:
return mt312_reset(i2c, 0);
case FE_GET_TUNE_SETTINGS:
{
struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
fesettings->min_delay_ms = 50;
fesettings->step_size = 0;
fesettings->max_drift = 0;
return 0;
}
default:
return -ENOIOCTLCMD;
......
......@@ -55,7 +55,12 @@ static struct dvb_frontend_info nxt6000_info = {
.symbol_rate_max = 9360000, /* FIXME */
.symbol_rate_tolerance = 4000,
.notifier_delay = 0,
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 | FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 | FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO | FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO | FE_CAN_HIERARCHY_AUTO,
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_4_5 | FE_CAN_FEC_5_6 | FE_CAN_FEC_6_7 |
FE_CAN_FEC_7_8 | FE_CAN_FEC_8_9 | FE_CAN_FEC_AUTO |
FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_QAM_AUTO |
FE_CAN_TRANSMISSION_MODE_AUTO | FE_CAN_GUARD_INTERVAL_AUTO |
FE_CAN_HIERARCHY_AUTO,
};
struct nxt6000_config {
......@@ -762,9 +767,6 @@ static int nxt6000_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
nxt6000_setup(fe);
break;
case FE_RESET:
break;
case FE_SET_FRONTEND:
{
struct nxt6000_config *nxt = FE2NXT(fe);
......
......@@ -12,13 +12,13 @@
next 0x4000 loaded. This may change in future versions.
*/
#define __KERNEL_SYSCALLS__
#include <linux/kernel.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/syscalls.h>
#include <linux/fs.h>
#include <linux/unistd.h>
#include <linux/fcntl.h>
......@@ -64,19 +64,17 @@ struct dvb_frontend_info sp887x_info = {
.frequency_stepsize = 166666,
.caps = FE_CAN_FEC_1_2 | FE_CAN_FEC_2_3 | FE_CAN_FEC_3_4 |
FE_CAN_FEC_5_6 | FE_CAN_FEC_7_8 | FE_CAN_FEC_AUTO |
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 | FE_CAN_RECOVER
FE_CAN_QPSK | FE_CAN_QAM_16 | FE_CAN_QAM_64 |
FE_CAN_RECOVER
};
static int errno;
static
int i2c_writebytes (struct dvb_frontend *fe, u8 addr, u8 *buf, u8 len)
{
struct dvb_i2c_bus *i2c = fe->i2c;
struct i2c_msg msg = {
.addr = addr,
.flags = 0,
.buf = buf,
.len = len
};
struct i2c_msg msg = { .addr = addr, .flags = 0, .buf = buf, .len = len };
int err;
LOG("i2c_writebytes", msg.addr, msg.buf, msg.len);
......@@ -213,13 +211,13 @@ int sp887x_initial_setup (struct dvb_frontend *fe)
// Load the firmware
set_fs(get_ds());
fd = sys_open(sp887x_firmware, 0, 0);
fd = open(sp887x_firmware, 0, 0);
if (fd < 0) {
printk(KERN_WARNING "%s: Unable to open firmware %s\n", __FUNCTION__,
sp887x_firmware);
return -EIO;
}
filesize = sys_lseek(fd, 0L, 2);
filesize = lseek(fd, 0L, 2);
if (filesize <= 0) {
printk(KERN_WARNING "%s: Firmware %s is empty\n", __FUNCTION__,
sp887x_firmware);
......@@ -241,8 +239,8 @@ int sp887x_initial_setup (struct dvb_frontend *fe)
// read it!
// read the first 16384 bytes from the file
// ignore the first 10 bytes
sys_lseek(fd, 10, 0);
if (sys_read(fd, firmware, fw_size) != fw_size) {
lseek(fd, 10, 0);
if (read(fd, firmware, fw_size) != fw_size) {
printk(KERN_WARNING "%s: Failed to read firmware\n", __FUNCTION__);
vfree(firmware);
sys_close(fd);
......@@ -635,6 +633,15 @@ int sp887x_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
sp887x_writereg(fe, 0xc18, 0x00d);
break;
case FE_GET_TUNE_SETTINGS:
{
struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
fesettings->min_delay_ms = 50;
fesettings->step_size = 0;
fesettings->max_drift = 0;
return 0;
}
default:
return -EOPNOTSUPP;
};
......@@ -647,12 +654,7 @@ int sp887x_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
static
int sp887x_attach (struct dvb_i2c_bus *i2c, void **data)
{
struct i2c_msg msg = {
.addr = 0x70,
.flags = 0,
.buf = NULL,
.len = 0
};
struct i2c_msg msg = {.addr = 0x70, .flags = 0, .buf = NULL, .len = 0 };
dprintk ("%s\n", __FUNCTION__);
......
This diff is collapsed.
......@@ -32,14 +32,15 @@
*/
#define __KERNEL_SYSCALLS__
#include <linux/kernel.h>
#include <linux/vmalloc.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <linux/syscalls.h>
#include <linux/fs.h>
#include <linux/unistd.h>
#include <linux/fcntl.h>
#include <linux/errno.h>
#include "dvb_frontend.h"
......@@ -167,7 +168,6 @@ static struct dvb_frontend_info tda10046h_info = {
};
#pragma pack(1)
struct tda1004x_state {
u8 tda1004x_address;
u8 tuner_address;
......@@ -175,7 +175,7 @@ struct tda1004x_state {
u8 tuner_type:2;
u8 fe_type:2;
};
#pragma pack()
struct fwinfo {
int file_size;
......@@ -397,13 +397,13 @@ static int tda1004x_fwupload(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda
// Load the firmware
set_fs(get_ds());
fd = sys_open(tda1004x_firmware, 0, 0);
fd = open(tda1004x_firmware, 0, 0);
if (fd < 0) {
printk("%s: Unable to open firmware %s\n", __FUNCTION__,
tda1004x_firmware);
return -EIO;
}
filesize = sys_lseek(fd, 0L, 2);
filesize = lseek(fd, 0L, 2);
if (filesize <= 0) {
printk("%s: Firmware %s is empty\n", __FUNCTION__,
tda1004x_firmware);
......@@ -434,8 +434,8 @@ static int tda1004x_fwupload(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda
}
// read it!
sys_lseek(fd, fw_offset, 0);
if (sys_read(fd, firmware, fw_size) != fw_size) {
lseek(fd, fw_offset, 0);
if (read(fd, firmware, fw_size) != fw_size) {
printk("%s: Failed to read firmware\n", __FUNCTION__);
vfree(firmware);
sys_close(fd);
......@@ -448,6 +448,7 @@ static int tda1004x_fwupload(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda
switch(tda_state->fe_type) {
case FE_TYPE_TDA10045H:
// reset chip
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 0x10, 0);
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 8, 8);
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 8, 0);
dvb_delay(10);
......@@ -458,6 +459,7 @@ static int tda1004x_fwupload(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda
case FE_TYPE_TDA10046H:
// reset chip
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 1, 0);
tda1004x_write_mask(i2c, tda_state, TDA10046H_CONF_TRISTATE1, 1, 0);
dvb_delay(10);
......@@ -539,6 +541,8 @@ static int tda10045h_init(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_st
dprintk("%s\n", __FUNCTION__);
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFADC1, 0x10, 0); // wake up the ADC
// Disable the MC44BC374C
tda1004x_enable_tuner_i2c(i2c, tda_state);
tuner_msg.addr = MC44BC374_ADDRESS;
......@@ -575,6 +579,8 @@ static int tda10046h_init(struct dvb_i2c_bus *i2c, struct tda1004x_state *tda_st
dprintk("%s\n", __FUNCTION__);
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 1, 0); // wake up the chip
// Disable the MC44BC374C
tda1004x_enable_tuner_i2c(i2c, tda_state);
tuner_msg.addr = MC44BC374_ADDRESS;
......@@ -1278,12 +1284,27 @@ static int tda1004x_read_ber(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda
return 0;
}
static int tda1004x_sleep(struct dvb_i2c_bus *i2c, struct tda1004x_state* tda_state)
{
switch(tda_state->fe_type) {
case FE_TYPE_TDA10045H:
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFADC1, 0x10, 0x10);
break;
case FE_TYPE_TDA10046H:
tda1004x_write_mask(i2c, tda_state, TDA1004X_CONFC4, 1, 1);
break;
}
return 0;
}
static int tda1004x_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
int status = 0;
struct dvb_i2c_bus *i2c = fe->i2c;
struct tda1004x_state *tda_state = (struct tda1004x_state *) &(fe->data);
struct tda1004x_state *tda_state = (struct tda1004x_state *) fe->data;
dprintk("%s: cmd=0x%x\n", __FUNCTION__, cmd);
......@@ -1321,7 +1342,12 @@ static int tda1004x_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_GET_FRONTEND:
return tda1004x_get_fe(i2c, tda_state, (struct dvb_frontend_parameters*) arg);
case FE_SLEEP:
tda_state->initialised = 0;
return tda1004x_sleep(i2c, tda_state);
case FE_INIT:
// don't bother reinitialising
if (tda_state->initialised)
return 0;
......@@ -1340,6 +1366,15 @@ static int tda1004x_ioctl(struct dvb_frontend *fe, unsigned int cmd, void *arg)
tda_state->initialised = 1;
return status;
case FE_GET_TUNE_SETTINGS:
{
struct dvb_frontend_tune_settings* fesettings = (struct dvb_frontend_tune_settings*) arg;
fesettings->min_delay_ms = 800;
fesettings->step_size = 166667;
fesettings->max_drift = 166667*2;
return 0;
}
default:
return -EOPNOTSUPP;
}
......@@ -1355,6 +1390,7 @@ static int tda1004x_attach(struct dvb_i2c_bus *i2c, void **data)
int fe_type = -1;
int tuner_type = -1;
struct tda1004x_state tda_state;
struct tda1004x_state* ptda_state;
struct i2c_msg tuner_msg = {.addr=0, .flags=0, .buf=0, .len=0 };
static u8 td1344_init[] = { 0x0b, 0xf5, 0x88, 0xab };
static u8 td1316_init[] = { 0x0b, 0xf5, 0x85, 0xab };
......@@ -1447,13 +1483,20 @@ static int tda1004x_attach(struct dvb_i2c_bus *i2c, void **data)
// upload firmware
if ((status = tda1004x_fwupload(i2c, &tda_state)) != 0) return status;
// create the real state we'll be passing about
if ((ptda_state = (struct tda1004x_state*) kmalloc(sizeof(struct tda1004x_state), GFP_KERNEL)) == NULL) {
return -ENOMEM;
}
memcpy(ptda_state, &tda_state, sizeof(struct tda1004x_state));
*data = ptda_state;
// register
switch(tda_state.fe_type) {
case FE_TYPE_TDA10045H:
return dvb_register_frontend(tda1004x_ioctl, i2c, (void *)(*((u32*) &tda_state)), &tda10045h_info);
return dvb_register_frontend(tda1004x_ioctl, i2c, ptda_state, &tda10045h_info);
case FE_TYPE_TDA10046H:
return dvb_register_frontend(tda1004x_ioctl, i2c, (void *)(*((u32*) &tda_state)), &tda10046h_info);
return dvb_register_frontend(tda1004x_ioctl, i2c, ptda_state, &tda10046h_info);
}
// should not get here
......@@ -1466,6 +1509,7 @@ void tda1004x_detach(struct dvb_i2c_bus *i2c, void *data)
{
dprintk("%s\n", __FUNCTION__);
kfree(data);
dvb_unregister_frontend(tda1004x_ioctl, i2c);
}
......
......@@ -111,8 +111,7 @@ static struct dvb_frontend_info ves1820_info = {
#endif
.caps = FE_CAN_QAM_16 | FE_CAN_QAM_32 | FE_CAN_QAM_64 |
FE_CAN_QAM_128 | FE_CAN_QAM_256 |
FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO |
FE_CAN_CLEAN_SETUP | FE_CAN_RECOVER
FE_CAN_FEC_AUTO | FE_CAN_INVERSION_AUTO,
};
......
......@@ -30,6 +30,7 @@
#include <linux/slab.h>
#include "dvb_frontend.h"
#include "dvb_functions.h"
static int debug = 0;
#define dprintk if (debug) printk
......@@ -67,10 +68,10 @@ static struct dvb_frontend_info ves1x93_info = {
*/
static u8 init_1893_tab [] = {
0x01, 0xa4, 0x35, 0x81, 0x2a, 0x0d, 0x55, 0xc4,
0x01, 0xa4, 0x35, 0x80, 0x2a, 0x0b, 0x55, 0xc4,
0x09, 0x69, 0x00, 0x86, 0x4c, 0x28, 0x7f, 0x00,
0x00, 0x81, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x80, 0x00, 0x31, 0xb0, 0x14, 0x00, 0xdc, 0x00,
0x80, 0x00, 0x21, 0xb0, 0x14, 0x00, 0xdc, 0x00,
0x81, 0x80, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x55, 0x00, 0x00, 0x7f, 0x00
......@@ -109,6 +110,11 @@ static u8 init_1993_wtab[] =
1,1,1,0,1,1,1,1, 1,1,1,1,1
};
struct ves1x93_state {
fe_spectral_inversion_t inversion;
};
static int ves1x93_writereg (struct dvb_i2c_bus *i2c, u8 reg, u8 data)
{
......@@ -247,8 +253,16 @@ static int ves1x93_clr_bit (struct dvb_i2c_bus *i2c)
{
ves1x93_writereg (i2c, 0, init_1x93_tab[0] & 0xfe);
ves1x93_writereg (i2c, 0, init_1x93_tab[0]);
dvb_delay(5);
return 0;
}
static int ves1x93_init_aquire (struct dvb_i2c_bus *i2c)
{
ves1x93_writereg (i2c, 3, 0x00);
return ves1x93_writereg (i2c, 3, init_1x93_tab[3]);
ves1x93_writereg (i2c, 3, init_1x93_tab[3]);
dvb_delay(5);
return 0;
}
......@@ -275,10 +289,7 @@ static int ves1x93_set_inversion (struct dvb_i2c_bus *i2c, fe_spectral_inversion
return -EINVAL;
}
/* needs to be saved for FE_GET_FRONTEND */
init_1x93_tab[0x0c] = (init_1x93_tab[0x0c] & 0x3f) | val;
return ves1x93_writereg (i2c, 0x0c, init_1x93_tab[0x0c]);
return ves1x93_writereg (i2c, 0x0c, (init_1x93_tab[0x0c] & 0x3f) | val);
}
......@@ -403,6 +414,25 @@ static int ves1x93_set_symbolrate (struct dvb_i2c_bus *i2c, u32 srate)
}
static int ves1x93_afc (struct dvb_i2c_bus *i2c, u32 freq, u32 srate)
{
int afc;
afc = ((int)((ves1x93_readreg (i2c, 0x0a) << 1) & 0xff))/2;
afc = (afc * (int)(srate/1000/8))/16;
if (afc) {
freq -= afc;
tuner_set_tv_freq (i2c, freq, 0);
ves1x93_init_aquire (i2c);
}
return 0;
}
static int ves1x93_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltage)
{
switch (voltage) {
......@@ -421,6 +451,7 @@ static int ves1x93_set_voltage (struct dvb_i2c_bus *i2c, fe_sec_voltage_t voltag
static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
{
struct dvb_i2c_bus *i2c = fe->i2c;
struct ves1x93_state *state = (struct ves1x93_state*) fe->data;
switch (cmd) {
case FE_GET_INFO:
......@@ -497,6 +528,8 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
ves1x93_set_inversion (i2c, p->inversion);
ves1x93_set_fec (i2c, p->u.qpsk.fec_inner);
ves1x93_set_symbolrate (i2c, p->u.qpsk.symbol_rate);
ves1x93_afc (i2c, p->frequency, p->u.qpsk.symbol_rate);
state->inversion = p->inversion;
break;
}
......@@ -514,7 +547,7 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
* inversion indicator is only valid
* if auto inversion was used
*/
if (!(init_1x93_tab[0x0c] & 0x80))
if (state->inversion == INVERSION_AUTO)
p->inversion = (ves1x93_readreg (i2c, 0x0f) & 2) ?
INVERSION_OFF : INVERSION_ON;
p->u.qpsk.fec_inner = ves1x93_get_fec (i2c);
......@@ -530,9 +563,6 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
case FE_INIT:
return ves1x93_init (i2c);
case FE_RESET:
return ves1x93_clr_bit (i2c);
case FE_SET_TONE:
return -EOPNOTSUPP; /* the ves1893 can generate the 22k */
/* let's implement this when we have */
......@@ -552,14 +582,21 @@ static int ves1x93_ioctl (struct dvb_frontend *fe, unsigned int cmd, void *arg)
static int ves1x93_attach (struct dvb_i2c_bus *i2c, void **data)
{
u8 identity = ves1x93_readreg(i2c, 0x1e);
struct ves1x93_state* state;
switch (identity) {
case 0xdc: /* VES1893A rev1 */
printk("ves1x93: Detected ves1893a rev1\n");
demod_type = DEMOD_VES1893;
ves1x93_info.name[4] = '8';
break;
case 0xdd: /* VES1893A rev2 */
printk("ves1x93: Detected ves1893a rev2\n");
demod_type = DEMOD_VES1893;
ves1x93_info.name[4] = '8';
break;
case 0xde: /* VES1993 */
printk("ves1x93: Detected ves1993\n");
demod_type = DEMOD_VES1993;
ves1x93_info.name[4] = '9';
break;
......@@ -568,12 +605,19 @@ static int ves1x93_attach (struct dvb_i2c_bus *i2c, void **data)
return -ENODEV;
}
return dvb_register_frontend (ves1x93_ioctl, i2c, NULL, &ves1x93_info);
if ((state = kmalloc(sizeof(struct ves1x93_state), GFP_KERNEL)) == NULL) {
return -ENOMEM;
}
state->inversion = INVERSION_OFF;
*data = state;
return dvb_register_frontend (ves1x93_ioctl, i2c, (void*) state, &ves1x93_info);
}
static void ves1x93_detach (struct dvb_i2c_bus *i2c, void *data)
{
kfree(data);
dvb_unregister_frontend (ves1x93_ioctl, i2c);
}
......
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