Commit f11ec7d4 authored by Steven Toth's avatar Steven Toth Committed by Mauro Carvalho Chehab

V4L/DVB (9254): cx24116: Checkpatch compliance #2

cx24116: Checkpatch compliance #2
Signed-off-by: default avatarSteven Toth <stoth@linuxtv.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent d93356a2
...@@ -41,10 +41,14 @@ ...@@ -41,10 +41,14 @@
#include "dvb_frontend.h" #include "dvb_frontend.h"
#include "cx24116.h" #include "cx24116.h"
static int debug = 0; static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
#define dprintk(args...) \ #define dprintk(args...) \
do { \ do { \
if (debug) printk ("cx24116: " args); \ if (debug) \
printk("cx24116: " args); \
} while (0) } while (0)
#define CX24116_DEFAULT_FIRMWARE "dvb-fe-cx24116.fw" #define CX24116_DEFAULT_FIRMWARE "dvb-fe-cx24116.fw"
...@@ -116,12 +120,15 @@ static int debug = 0; ...@@ -116,12 +120,15 @@ static int debug = 0;
/* DiSEqC tone burst */ /* DiSEqC tone burst */
static int toneburst = 1; static int toneburst = 1;
module_param(toneburst, int, 0644);
MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, 2=MESSAGE CACHE (default:1)");
/* SNR measurements */ /* SNR measurements */
static int esno_snr = 0; static int esno_snr;
module_param(esno_snr, int, 0644);
MODULE_PARM_DESC(debug, "SNR return units, 0=PERCENTAGE 0-100, 1=ESNO(db * 10) (default:0)");
enum cmds enum cmds {
{
CMD_SET_VCO = 0x10, CMD_SET_VCO = 0x10,
CMD_TUNEREQUEST = 0x11, CMD_TUNEREQUEST = 0x11,
CMD_MPEGCONFIG = 0x13, CMD_MPEGCONFIG = 0x13,
...@@ -138,8 +145,7 @@ enum cmds ...@@ -138,8 +145,7 @@ enum cmds
}; };
/* The Demod/Tuner can't easily provide these, we cache them */ /* The Demod/Tuner can't easily provide these, we cache them */
struct cx24116_tuning struct cx24116_tuning {
{
u32 frequency; u32 frequency;
u32 symbol_rate; u32 symbol_rate;
fe_spectral_inversion_t inversion; fe_spectral_inversion_t inversion;
...@@ -158,16 +164,14 @@ struct cx24116_tuning ...@@ -158,16 +164,14 @@ struct cx24116_tuning
}; };
/* Basic commands that are sent to the firmware */ /* Basic commands that are sent to the firmware */
struct cx24116_cmd struct cx24116_cmd {
{
u8 len; u8 len;
u8 args[CX24116_ARGLEN]; u8 args[CX24116_ARGLEN];
}; };
struct cx24116_state struct cx24116_state {
{ struct i2c_adapter *i2c;
struct i2c_adapter* i2c; const struct cx24116_config *config;
const struct cx24116_config* config;
struct dvb_frontend frontend; struct dvb_frontend frontend;
...@@ -179,18 +183,19 @@ struct cx24116_state ...@@ -179,18 +183,19 @@ struct cx24116_state
struct cx24116_cmd dsec_cmd; struct cx24116_cmd dsec_cmd;
}; };
static int cx24116_writereg(struct cx24116_state* state, int reg, int data) static int cx24116_writereg(struct cx24116_state *state, int reg, int data)
{ {
u8 buf[] = { reg, data }; u8 buf[] = { reg, data };
struct i2c_msg msg = { .addr = state->config->demod_address, struct i2c_msg msg = { .addr = state->config->demod_address,
.flags = 0, .buf = buf, .len = 2 }; .flags = 0, .buf = buf, .len = 2 };
int err; int err;
if (debug>1) if (debug > 1)
printk("cx24116: %s: write reg 0x%02x, value 0x%02x\n", printk("cx24116: %s: write reg 0x%02x, value 0x%02x\n",
__func__,reg, data); __func__, reg, data);
if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { err = i2c_transfer(state->i2c, &msg, 1);
if (err != 1) {
printk("%s: writereg error(err == %i, reg == 0x%02x," printk("%s: writereg error(err == %i, reg == 0x%02x,"
" value == 0x%02x)\n", __func__, err, reg, data); " value == 0x%02x)\n", __func__, err, reg, data);
return -EREMOTEIO; return -EREMOTEIO;
...@@ -200,7 +205,8 @@ static int cx24116_writereg(struct cx24116_state* state, int reg, int data) ...@@ -200,7 +205,8 @@ static int cx24116_writereg(struct cx24116_state* state, int reg, int data)
} }
/* Bulk byte writes to a single I2C address, for 32k firmware load */ /* Bulk byte writes to a single I2C address, for 32k firmware load */
static int cx24116_writeregN(struct cx24116_state* state, int reg, u8 *data, u16 len) static int cx24116_writeregN(struct cx24116_state *state, int reg,
u8 *data, u16 len)
{ {
int ret = -EREMOTEIO; int ret = -EREMOTEIO;
struct i2c_msg msg; struct i2c_msg msg;
...@@ -221,11 +227,12 @@ static int cx24116_writeregN(struct cx24116_state* state, int reg, u8 *data, u16 ...@@ -221,11 +227,12 @@ static int cx24116_writeregN(struct cx24116_state* state, int reg, u8 *data, u16
msg.buf = buf; msg.buf = buf;
msg.len = len + 1; msg.len = len + 1;
if (debug>1) if (debug > 1)
printk("cx24116: %s: write regN 0x%02x, len = %d\n", printk("cx24116: %s: write regN 0x%02x, len = %d\n",
__func__,reg, len); __func__, reg, len);
if ((ret = i2c_transfer(state->i2c, &msg, 1)) != 1) { ret = i2c_transfer(state->i2c, &msg, 1);
if (ret != 1) {
printk("%s: writereg error(err == %i, reg == 0x%02x\n", printk("%s: writereg error(err == %i, reg == 0x%02x\n",
__func__, ret, reg); __func__, ret, reg);
ret = -EREMOTEIO; ret = -EREMOTEIO;
...@@ -237,14 +244,16 @@ error: ...@@ -237,14 +244,16 @@ error:
return ret; return ret;
} }
static int cx24116_readreg(struct cx24116_state* state, u8 reg) static int cx24116_readreg(struct cx24116_state *state, u8 reg)
{ {
int ret; int ret;
u8 b0[] = { reg }; u8 b0[] = { reg };
u8 b1[] = { 0 }; u8 b1[] = { 0 };
struct i2c_msg msg[] = { struct i2c_msg msg[] = {
{ .addr = state->config->demod_address, .flags = 0, .buf = b0, .len = 1 }, { .addr = state->config->demod_address, .flags = 0,
{ .addr = state->config->demod_address, .flags = I2C_M_RD, .buf = b1, .len = 1 } .buf = b0, .len = 1 },
{ .addr = state->config->demod_address, .flags = I2C_M_RD,
.buf = b1, .len = 1 }
}; };
ret = i2c_transfer(state->i2c, msg, 2); ret = i2c_transfer(state->i2c, msg, 2);
...@@ -254,13 +263,14 @@ static int cx24116_readreg(struct cx24116_state* state, u8 reg) ...@@ -254,13 +263,14 @@ static int cx24116_readreg(struct cx24116_state* state, u8 reg)
return ret; return ret;
} }
if (debug>1) if (debug > 1)
printk("cx24116: read reg 0x%02x, value 0x%02x\n",reg, b1[0]); printk("cx24116: read reg 0x%02x, value 0x%02x\n",
reg, b1[0]);
return b1[0]; return b1[0];
} }
static int cx24116_set_inversion(struct cx24116_state* state, fe_spectral_inversion_t inversion) static int cx24116_set_inversion(struct cx24116_state *state, fe_spectral_inversion_t inversion)
{ {
dprintk("%s(%d)\n", __func__, inversion); dprintk("%s(%d)\n", __func__, inversion);
...@@ -389,18 +399,16 @@ struct cx24116_modfec { ...@@ -389,18 +399,16 @@ struct cx24116_modfec {
*/ */
}; };
static int cx24116_lookup_fecmod(struct cx24116_state* state, static int cx24116_lookup_fecmod(struct cx24116_state *state,
fe_modulation_t m, fe_code_rate_t f) fe_modulation_t m, fe_code_rate_t f)
{ {
int i, ret = -EOPNOTSUPP; int i, ret = -EOPNOTSUPP;
dprintk("%s(0x%02x,0x%02x)\n", __func__, m, f); dprintk("%s(0x%02x,0x%02x)\n", __func__, m, f);
for(i=0 ; i < sizeof(CX24116_MODFEC_MODES) / sizeof(struct cx24116_modfec) ; i++) for (i = 0; i < ARRAY_SIZE(CX24116_MODFEC_MODES); i++) {
{ if ((m == CX24116_MODFEC_MODES[i].modulation) &&
if( (m == CX24116_MODFEC_MODES[i].modulation) && (f == CX24116_MODFEC_MODES[i].fec)) {
(f == CX24116_MODFEC_MODES[i].fec) )
{
ret = i; ret = i;
break; break;
} }
...@@ -409,7 +417,7 @@ static int cx24116_lookup_fecmod(struct cx24116_state* state, ...@@ -409,7 +417,7 @@ static int cx24116_lookup_fecmod(struct cx24116_state* state,
return ret; return ret;
} }
static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_code_rate_t fec) static int cx24116_set_fec(struct cx24116_state *state, fe_modulation_t mod, fe_code_rate_t fec)
{ {
int ret = 0; int ret = 0;
...@@ -417,7 +425,7 @@ static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_ ...@@ -417,7 +425,7 @@ static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_
ret = cx24116_lookup_fecmod(state, mod, fec); ret = cx24116_lookup_fecmod(state, mod, fec);
if(ret < 0) if (ret < 0)
return ret; return ret;
state->dnxt.fec = fec; state->dnxt.fec = fec;
...@@ -429,7 +437,7 @@ static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_ ...@@ -429,7 +437,7 @@ static int cx24116_set_fec(struct cx24116_state* state, fe_modulation_t mod, fe_
return 0; return 0;
} }
static int cx24116_set_symbolrate(struct cx24116_state* state, u32 rate) static int cx24116_set_symbolrate(struct cx24116_state *state, u32 rate)
{ {
dprintk("%s(%d)\n", __func__, rate); dprintk("%s(%d)\n", __func__, rate);
...@@ -446,18 +454,18 @@ static int cx24116_set_symbolrate(struct cx24116_state* state, u32 rate) ...@@ -446,18 +454,18 @@ static int cx24116_set_symbolrate(struct cx24116_state* state, u32 rate)
return 0; return 0;
} }
static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware *fw); static int cx24116_load_firmware(struct dvb_frontend *fe,
const struct firmware *fw);
static int cx24116_firmware_ondemand(struct dvb_frontend* fe) static int cx24116_firmware_ondemand(struct dvb_frontend *fe)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
const struct firmware *fw; const struct firmware *fw;
int ret = 0; int ret = 0;
dprintk("%s()\n",__func__); dprintk("%s()\n", __func__);
if (cx24116_readreg(state, 0x20) > 0) if (cx24116_readreg(state, 0x20) > 0) {
{
if (state->skip_fw_load) if (state->skip_fw_load)
return 0; return 0;
...@@ -491,7 +499,7 @@ static int cx24116_firmware_ondemand(struct dvb_frontend* fe) ...@@ -491,7 +499,7 @@ static int cx24116_firmware_ondemand(struct dvb_frontend* fe)
} }
/* Take a basic firmware command structure, format it and forward it for processing */ /* Take a basic firmware command structure, format it and forward it for processing */
static int cx24116_cmd_execute(struct dvb_frontend* fe, struct cx24116_cmd *cmd) static int cx24116_cmd_execute(struct dvb_frontend *fe, struct cx24116_cmd *cmd)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
int i, ret; int i, ret;
...@@ -499,26 +507,23 @@ static int cx24116_cmd_execute(struct dvb_frontend* fe, struct cx24116_cmd *cmd) ...@@ -499,26 +507,23 @@ static int cx24116_cmd_execute(struct dvb_frontend* fe, struct cx24116_cmd *cmd)
dprintk("%s()\n", __func__); dprintk("%s()\n", __func__);
/* Load the firmware if required */ /* Load the firmware if required */
if ( (ret = cx24116_firmware_ondemand(fe)) != 0) ret = cx24116_firmware_ondemand(fe);
{ if (ret != 0) {
printk("%s(): Unable initialise the firmware\n", __func__); printk("%s(): Unable initialise the firmware\n", __func__);
return ret; return ret;
} }
/* Write the command */ /* Write the command */
for(i = 0; i < cmd->len ; i++) for (i = 0; i < cmd->len ; i++) {
{
dprintk("%s: 0x%02x == 0x%02x\n", __func__, i, cmd->args[i]); dprintk("%s: 0x%02x == 0x%02x\n", __func__, i, cmd->args[i]);
cx24116_writereg(state, i, cmd->args[i]); cx24116_writereg(state, i, cmd->args[i]);
} }
/* Start execution and wait for cmd to terminate */ /* Start execution and wait for cmd to terminate */
cx24116_writereg(state, CX24116_REG_EXECUTE, 0x01); cx24116_writereg(state, CX24116_REG_EXECUTE, 0x01);
while( cx24116_readreg(state, CX24116_REG_EXECUTE) ) while (cx24116_readreg(state, CX24116_REG_EXECUTE)) {
{
msleep(10); msleep(10);
if(i++ > 64) if (i++ > 64) {
{
/* Avoid looping forever if the firmware does no respond */ /* Avoid looping forever if the firmware does no respond */
printk("%s() Firmware not responding\n", __func__); printk("%s() Firmware not responding\n", __func__);
return -EREMOTEIO; return -EREMOTEIO;
...@@ -527,21 +532,21 @@ static int cx24116_cmd_execute(struct dvb_frontend* fe, struct cx24116_cmd *cmd) ...@@ -527,21 +532,21 @@ static int cx24116_cmd_execute(struct dvb_frontend* fe, struct cx24116_cmd *cmd)
return 0; return 0;
} }
static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware *fw) static int cx24116_load_firmware(struct dvb_frontend *fe,
const struct firmware *fw)
{ {
struct cx24116_state* state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
struct cx24116_cmd cmd; struct cx24116_cmd cmd;
int i, ret; int i, ret;
unsigned char vers[4]; unsigned char vers[4];
dprintk("%s\n", __func__); dprintk("%s\n", __func__);
dprintk("Firmware is %zu bytes (%02x %02x .. %02x %02x)\n" dprintk("Firmware is %zu bytes (%02x %02x .. %02x %02x)\n",
,fw->size fw->size,
,fw->data[0] fw->data[0],
,fw->data[1] fw->data[1],
,fw->data[ fw->size-2 ] fw->data[fw->size-2],
,fw->data[ fw->size-1 ] fw->data[fw->size-1]);
);
/* Toggle 88x SRST pin to reset demod */ /* Toggle 88x SRST pin to reset demod */
if (state->config->reset_device) if (state->config->reset_device)
...@@ -587,7 +592,7 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware ...@@ -587,7 +592,7 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware
cmd.args[0x07] = 0x9d; cmd.args[0x07] = 0x9d;
cmd.args[0x08] = 0xfc; cmd.args[0x08] = 0xfc;
cmd.args[0x09] = 0x06; cmd.args[0x09] = 0x06;
cmd.len= 0x0a; cmd.len = 0x0a;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -598,7 +603,7 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware ...@@ -598,7 +603,7 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware
cmd.args[0x00] = CMD_TUNERINIT; cmd.args[0x00] = CMD_TUNERINIT;
cmd.args[0x01] = 0x00; cmd.args[0x01] = 0x00;
cmd.args[0x02] = 0x00; cmd.args[0x02] = 0x00;
cmd.len= 0x03; cmd.len = 0x03;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -615,20 +620,20 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware ...@@ -615,20 +620,20 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware
else else
cmd.args[0x04] = 0x02; cmd.args[0x04] = 0x02;
cmd.args[0x05] = 0x00; cmd.args[0x05] = 0x00;
cmd.len= 0x06; cmd.len = 0x06;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if (ret != 0) if (ret != 0)
return ret; return ret;
/* Firmware CMD 35: Get firmware version */ /* Firmware CMD 35: Get firmware version */
cmd.args[0x00] = CMD_UPDFWVERS; cmd.args[0x00] = CMD_UPDFWVERS;
cmd.len= 0x02; cmd.len = 0x02;
for(i=0; i<4; i++) { for (i = 0; i < 4; i++) {
cmd.args[0x01] = i; cmd.args[0x01] = i;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if (ret != 0) if (ret != 0)
return ret; return ret;
vers[i]= cx24116_readreg(state, CX24116_REG_MAILBOX); vers[i] = cx24116_readreg(state, CX24116_REG_MAILBOX);
} }
printk("%s: FW version %i.%i.%i.%i\n", __func__, printk("%s: FW version %i.%i.%i.%i\n", __func__,
vers[0], vers[1], vers[2], vers[3]); vers[0], vers[1], vers[2], vers[3]);
...@@ -636,15 +641,17 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware ...@@ -636,15 +641,17 @@ static int cx24116_load_firmware (struct dvb_frontend* fe, const struct firmware
return 0; return 0;
} }
static int cx24116_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) static int cx24116_set_voltage(struct dvb_frontend *fe,
fe_sec_voltage_t voltage)
{ {
/* The isl6421 module will override this function in the fops. */ /* The isl6421 module will override this function in the fops. */
dprintk("%s() This should never appear if the isl6421 module is loaded correctly\n",__func__); dprintk("%s() This should never appear if the isl6421 module "
"is loaded correctly\n", __func__);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
static int cx24116_read_status(struct dvb_frontend* fe, fe_status_t* status) static int cx24116_read_status(struct dvb_frontend *fe, fe_status_t *status)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
...@@ -666,22 +673,23 @@ static int cx24116_read_status(struct dvb_frontend* fe, fe_status_t* status) ...@@ -666,22 +673,23 @@ static int cx24116_read_status(struct dvb_frontend* fe, fe_status_t* status)
return 0; return 0;
} }
static int cx24116_read_ber(struct dvb_frontend* fe, u32* ber) static int cx24116_read_ber(struct dvb_frontend *fe, u32 *ber)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
dprintk("%s()\n", __func__); dprintk("%s()\n", __func__);
*ber = ( cx24116_readreg(state, CX24116_REG_BER24) << 24 ) | *ber = (cx24116_readreg(state, CX24116_REG_BER24) << 24) |
( cx24116_readreg(state, CX24116_REG_BER16) << 16 ) | (cx24116_readreg(state, CX24116_REG_BER16) << 16) |
( cx24116_readreg(state, CX24116_REG_BER8 ) << 8 ) | (cx24116_readreg(state, CX24116_REG_BER8) << 8) |
cx24116_readreg(state, CX24116_REG_BER0 ); cx24116_readreg(state, CX24116_REG_BER0);
return 0; return 0;
} }
/* TODO Determine function and scale appropriately */ /* TODO Determine function and scale appropriately */
static int cx24116_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) static int cx24116_read_signal_strength(struct dvb_frontend *fe,
u16 *signal_strength)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
struct cx24116_cmd cmd; struct cx24116_cmd cmd;
...@@ -692,39 +700,43 @@ static int cx24116_read_signal_strength(struct dvb_frontend* fe, u16* signal_str ...@@ -692,39 +700,43 @@ static int cx24116_read_signal_strength(struct dvb_frontend* fe, u16* signal_str
/* Firmware CMD 19: Get AGC */ /* Firmware CMD 19: Get AGC */
cmd.args[0x00] = CMD_GETAGC; cmd.args[0x00] = CMD_GETAGC;
cmd.len= 0x01; cmd.len = 0x01;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if (ret != 0) if (ret != 0)
return ret; return ret;
sig_reading = ( cx24116_readreg(state, CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK ) | sig_reading =
( cx24116_readreg(state, CX24116_REG_SIGNAL) << 6 ); (cx24116_readreg(state,
*signal_strength= 0 - sig_reading; CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK) |
(cx24116_readreg(state, CX24116_REG_SIGNAL) << 6);
*signal_strength = 0 - sig_reading;
dprintk("%s: raw / cooked = 0x%04x / 0x%04x\n", __func__, sig_reading, *signal_strength); dprintk("%s: raw / cooked = 0x%04x / 0x%04x\n",
__func__, sig_reading, *signal_strength);
return 0; return 0;
} }
/* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */ /* SNR (0..100)% = (sig & 0xf0) * 10 + (sig & 0x0f) * 10 / 16 */
static int cx24116_read_snr_pct(struct dvb_frontend* fe, u16* snr) static int cx24116_read_snr_pct(struct dvb_frontend *fe, u16 *snr)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
u8 snr_reading; u8 snr_reading;
static const u32 snr_tab[] = { /* 10 x Table (rounded up) */ static const u32 snr_tab[] = { /* 10 x Table (rounded up) */
0x00000,0x0199A,0x03333,0x04ccD,0x06667, 0x00000, 0x0199A, 0x03333, 0x04ccD, 0x06667,
0x08000,0x0999A,0x0b333,0x0cccD,0x0e667, 0x08000, 0x0999A, 0x0b333, 0x0cccD, 0x0e667,
0x10000,0x1199A,0x13333,0x14ccD,0x16667,0x18000 }; 0x10000, 0x1199A, 0x13333, 0x14ccD, 0x16667,
0x18000 };
dprintk("%s()\n", __func__); dprintk("%s()\n", __func__);
snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0); snr_reading = cx24116_readreg(state, CX24116_REG_QUALITY0);
if(snr_reading >= 0xa0 /* 100% */) if (snr_reading >= 0xa0 /* 100% */)
*snr = 0xffff; *snr = 0xffff;
else else
*snr = snr_tab [ ( snr_reading & 0xf0 ) >> 4 ] + *snr = snr_tab[(snr_reading & 0xf0) >> 4] +
( snr_tab [ ( snr_reading & 0x0f ) ] >> 4 ); (snr_tab[(snr_reading & 0x0f)] >> 4);
dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__, dprintk("%s: raw / cooked = 0x%02x / 0x%04x\n", __func__,
snr_reading, *snr); snr_reading, *snr);
...@@ -736,7 +748,7 @@ static int cx24116_read_snr_pct(struct dvb_frontend* fe, u16* snr) ...@@ -736,7 +748,7 @@ static int cx24116_read_snr_pct(struct dvb_frontend* fe, u16* snr)
* ESNO, from 0->30db (values 0->300). We provide this value by * ESNO, from 0->30db (values 0->300). We provide this value by
* default. * default.
*/ */
static int cx24116_read_snr_esno(struct dvb_frontend* fe, u16* snr) static int cx24116_read_snr_esno(struct dvb_frontend *fe, u16 *snr)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
...@@ -750,7 +762,7 @@ static int cx24116_read_snr_esno(struct dvb_frontend* fe, u16* snr) ...@@ -750,7 +762,7 @@ static int cx24116_read_snr_esno(struct dvb_frontend* fe, u16* snr)
return 0; return 0;
} }
static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) static int cx24116_read_snr(struct dvb_frontend *fe, u16 *snr)
{ {
if (esno_snr == 1) if (esno_snr == 1)
return cx24116_read_snr_esno(fe, snr); return cx24116_read_snr_esno(fe, snr);
...@@ -758,27 +770,27 @@ static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr) ...@@ -758,27 +770,27 @@ static int cx24116_read_snr(struct dvb_frontend* fe, u16* snr)
return cx24116_read_snr_pct(fe, snr); return cx24116_read_snr_pct(fe, snr);
} }
static int cx24116_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) static int cx24116_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
dprintk("%s()\n", __func__); dprintk("%s()\n", __func__);
*ucblocks = ( cx24116_readreg(state, CX24116_REG_UCB8) << 8 ) | *ucblocks = (cx24116_readreg(state, CX24116_REG_UCB8) << 8) |
cx24116_readreg(state, CX24116_REG_UCB0); cx24116_readreg(state, CX24116_REG_UCB0);
return 0; return 0;
} }
/* Overwrite the current tuning params, we are about to tune */ /* Overwrite the current tuning params, we are about to tune */
static void cx24116_clone_params(struct dvb_frontend* fe) static void cx24116_clone_params(struct dvb_frontend *fe)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur)); memcpy(&state->dcur, &state->dnxt, sizeof(state->dcur));
} }
/* Wait for LNB */ /* Wait for LNB */
static int cx24116_wait_for_lnb(struct dvb_frontend* fe) static int cx24116_wait_for_lnb(struct dvb_frontend *fe)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
int i; int i;
...@@ -787,7 +799,7 @@ static int cx24116_wait_for_lnb(struct dvb_frontend* fe) ...@@ -787,7 +799,7 @@ static int cx24116_wait_for_lnb(struct dvb_frontend* fe)
cx24116_readreg(state, CX24116_REG_QSTATUS)); cx24116_readreg(state, CX24116_REG_QSTATUS));
/* Wait for up to 300 ms */ /* Wait for up to 300 ms */
for(i = 0; i < 30 ; i++) { for (i = 0; i < 30 ; i++) {
if (cx24116_readreg(state, CX24116_REG_QSTATUS) & 0x20) if (cx24116_readreg(state, CX24116_REG_QSTATUS) & 0x20)
return 0; return 0;
msleep(10); msleep(10);
...@@ -798,20 +810,21 @@ static int cx24116_wait_for_lnb(struct dvb_frontend* fe) ...@@ -798,20 +810,21 @@ static int cx24116_wait_for_lnb(struct dvb_frontend* fe)
return -ETIMEDOUT; /* -EBUSY ? */ return -ETIMEDOUT; /* -EBUSY ? */
} }
static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) static int cx24116_set_tone(struct dvb_frontend *fe,
fe_sec_tone_mode_t tone)
{ {
struct cx24116_cmd cmd; struct cx24116_cmd cmd;
int ret; int ret;
dprintk("%s(%d)\n", __func__, tone); dprintk("%s(%d)\n", __func__, tone);
if ( (tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF) ) { if ((tone != SEC_TONE_ON) && (tone != SEC_TONE_OFF)) {
printk("%s: Invalid, tone=%d\n", __func__, tone); printk("%s: Invalid, tone=%d\n", __func__, tone);
return -EINVAL; return -EINVAL;
} }
/* Wait for LNB ready */ /* Wait for LNB ready */
ret = cx24116_wait_for_lnb(fe); ret = cx24116_wait_for_lnb(fe);
if(ret != 0) if (ret != 0)
return ret; return ret;
/* Min delay time after DiSEqC send */ /* Min delay time after DiSEqC send */
...@@ -820,7 +833,7 @@ static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) ...@@ -820,7 +833,7 @@ static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
/* This is always done before the tone is set */ /* This is always done before the tone is set */
cmd.args[0x00] = CMD_SET_TONEPRE; cmd.args[0x00] = CMD_SET_TONEPRE;
cmd.args[0x01] = 0x00; cmd.args[0x01] = 0x00;
cmd.len= 0x02; cmd.len = 0x02;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -836,11 +849,11 @@ static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) ...@@ -836,11 +849,11 @@ static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
cmd.args[0x03] = 0x01; cmd.args[0x03] = 0x01;
break; break;
case SEC_TONE_OFF: case SEC_TONE_OFF:
dprintk("%s: setting tone off\n",__func__); dprintk("%s: setting tone off\n", __func__);
cmd.args[0x03] = 0x00; cmd.args[0x03] = 0x00;
break; break;
} }
cmd.len= 0x04; cmd.len = 0x04;
/* Min delay time before DiSEqC send */ /* Min delay time before DiSEqC send */
msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */ msleep(15); /* XXX determine is FW does this, see send_diseqc/burst */
...@@ -849,7 +862,7 @@ static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) ...@@ -849,7 +862,7 @@ static int cx24116_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
} }
/* Initialise DiSEqC */ /* Initialise DiSEqC */
static int cx24116_diseqc_init(struct dvb_frontend* fe) static int cx24116_diseqc_init(struct dvb_frontend *fe)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
struct cx24116_cmd cmd; struct cx24116_cmd cmd;
...@@ -864,7 +877,7 @@ static int cx24116_diseqc_init(struct dvb_frontend* fe) ...@@ -864,7 +877,7 @@ static int cx24116_diseqc_init(struct dvb_frontend* fe)
cmd.args[0x05] = 0x28; cmd.args[0x05] = 0x28;
cmd.args[0x06] = (toneburst == CX24116_DISEQC_TONEOFF) ? 0x00 : 0x01; cmd.args[0x06] = (toneburst == CX24116_DISEQC_TONEOFF) ? 0x00 : 0x01;
cmd.args[0x07] = 0x01; cmd.args[0x07] = 0x01;
cmd.len= 0x08; cmd.len = 0x08;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -884,13 +897,14 @@ static int cx24116_diseqc_init(struct dvb_frontend* fe) ...@@ -884,13 +897,14 @@ static int cx24116_diseqc_init(struct dvb_frontend* fe)
state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = 0x00; state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = 0x00;
/* Command length */ /* Command length */
state->dsec_cmd.len= CX24116_DISEQC_MSGOFS; state->dsec_cmd.len = CX24116_DISEQC_MSGOFS;
return 0; return 0;
} }
/* Send DiSEqC message with derived burst (hack) || previous burst */ /* Send DiSEqC message with derived burst (hack) || previous burst */
static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *d) static int cx24116_send_diseqc_msg(struct dvb_frontend *fe,
struct dvb_diseqc_master_cmd *d)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
int i, ret; int i, ret;
...@@ -898,16 +912,16 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma ...@@ -898,16 +912,16 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma
/* Dump DiSEqC message */ /* Dump DiSEqC message */
if (debug) { if (debug) {
printk("cx24116: %s(", __func__); printk("cx24116: %s(", __func__);
for(i = 0 ; i < d->msg_len ;) { for (i = 0 ; i < d->msg_len ;) {
printk("0x%02x", d->msg[i]); printk("0x%02x", d->msg[i]);
if(++i < d->msg_len) if (++i < d->msg_len)
printk(", "); printk(", ");
} }
printk(") toneburst=%d\n", toneburst); printk(") toneburst=%d\n", toneburst);
} }
/* Validate length */ /* Validate length */
if(d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS)) if (d->msg_len > (CX24116_ARGLEN - CX24116_DISEQC_MSGOFS))
return -EINVAL; return -EINVAL;
/* DiSEqC message */ /* DiSEqC message */
...@@ -918,18 +932,19 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma ...@@ -918,18 +932,19 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma
state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len; state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] = d->msg_len;
/* Command length */ /* Command length */
state->dsec_cmd.len= CX24116_DISEQC_MSGOFS + state->dsec_cmd.args[CX24116_DISEQC_MSGLEN]; state->dsec_cmd.len = CX24116_DISEQC_MSGOFS +
state->dsec_cmd.args[CX24116_DISEQC_MSGLEN];
/* DiSEqC toneburst */ /* DiSEqC toneburst */
if(toneburst == CX24116_DISEQC_MESGCACHE) if (toneburst == CX24116_DISEQC_MESGCACHE)
/* Message is cached */ /* Message is cached */
return 0; return 0;
else if(toneburst == CX24116_DISEQC_TONEOFF) else if (toneburst == CX24116_DISEQC_TONEOFF)
/* Message is sent without burst */ /* Message is sent without burst */
state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0; state->dsec_cmd.args[CX24116_DISEQC_BURST] = 0;
else if(toneburst == CX24116_DISEQC_TONECACHE) { else if (toneburst == CX24116_DISEQC_TONECACHE) {
/* /*
* Message is sent with derived else cached burst * Message is sent with derived else cached burst
* *
...@@ -948,15 +963,17 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma ...@@ -948,15 +963,17 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma
* Y = VOLTAGE (0=13V, 1=18V) * Y = VOLTAGE (0=13V, 1=18V)
* Z = BAND (0=LOW, 1=HIGH(22K)) * Z = BAND (0=LOW, 1=HIGH(22K))
*/ */
if(d->msg_len >= 4 && d->msg[2] == 0x38) if (d->msg_len >= 4 && d->msg[2] == 0x38)
state->dsec_cmd.args[CX24116_DISEQC_BURST] = ((d->msg[3] & 4) >> 2); state->dsec_cmd.args[CX24116_DISEQC_BURST] =
if(debug) ((d->msg[3] & 4) >> 2);
dprintk("%s burst=%d\n", __func__, state->dsec_cmd.args[CX24116_DISEQC_BURST]); if (debug)
dprintk("%s burst=%d\n", __func__,
state->dsec_cmd.args[CX24116_DISEQC_BURST]);
} }
/* Wait for LNB ready */ /* Wait for LNB ready */
ret = cx24116_wait_for_lnb(fe); ret = cx24116_wait_for_lnb(fe);
if(ret != 0) if (ret != 0)
return ret; return ret;
/* Wait for voltage/min repeat delay */ /* Wait for voltage/min repeat delay */
...@@ -964,7 +981,7 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma ...@@ -964,7 +981,7 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma
/* Command */ /* Command */
ret = cx24116_cmd_execute(fe, &state->dsec_cmd); ret = cx24116_cmd_execute(fe, &state->dsec_cmd);
if(ret != 0) if (ret != 0)
return ret; return ret;
/* /*
* Wait for send * Wait for send
...@@ -976,29 +993,33 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma ...@@ -976,29 +993,33 @@ static int cx24116_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma
* 12.5ms burst + * 12.5ms burst +
* >15ms delay (XXX determine if FW does this, see set_tone) * >15ms delay (XXX determine if FW does this, see set_tone)
*/ */
msleep( (state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + ((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60) ); msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) +
((toneburst == CX24116_DISEQC_TONEOFF) ? 30 : 60));
return 0; return 0;
} }
/* Send DiSEqC burst */ /* Send DiSEqC burst */
static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) static int cx24116_diseqc_send_burst(struct dvb_frontend *fe,
fe_sec_mini_cmd_t burst)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
int ret; int ret;
dprintk("%s(%d) toneburst=%d\n",__func__, burst, toneburst); dprintk("%s(%d) toneburst=%d\n", __func__, burst, toneburst);
/* DiSEqC burst */ /* DiSEqC burst */
if (burst == SEC_MINI_A) if (burst == SEC_MINI_A)
state->dsec_cmd.args[CX24116_DISEQC_BURST] = CX24116_DISEQC_MINI_A; state->dsec_cmd.args[CX24116_DISEQC_BURST] =
else if(burst == SEC_MINI_B) CX24116_DISEQC_MINI_A;
state->dsec_cmd.args[CX24116_DISEQC_BURST] = CX24116_DISEQC_MINI_B; else if (burst == SEC_MINI_B)
state->dsec_cmd.args[CX24116_DISEQC_BURST] =
CX24116_DISEQC_MINI_B;
else else
return -EINVAL; return -EINVAL;
/* DiSEqC toneburst */ /* DiSEqC toneburst */
if(toneburst != CX24116_DISEQC_MESGCACHE) if (toneburst != CX24116_DISEQC_MESGCACHE)
/* Burst is cached */ /* Burst is cached */
return 0; return 0;
...@@ -1006,7 +1027,7 @@ static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t ...@@ -1006,7 +1027,7 @@ static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t
/* Wait for LNB ready */ /* Wait for LNB ready */
ret = cx24116_wait_for_lnb(fe); ret = cx24116_wait_for_lnb(fe);
if(ret != 0) if (ret != 0)
return ret; return ret;
/* Wait for voltage/min repeat delay */ /* Wait for voltage/min repeat delay */
...@@ -1014,7 +1035,7 @@ static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t ...@@ -1014,7 +1035,7 @@ static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t
/* Command */ /* Command */
ret = cx24116_cmd_execute(fe, &state->dsec_cmd); ret = cx24116_cmd_execute(fe, &state->dsec_cmd);
if(ret != 0) if (ret != 0)
return ret; return ret;
/* /*
...@@ -1027,27 +1048,27 @@ static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t ...@@ -1027,27 +1048,27 @@ static int cx24116_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t
* 12.5ms burst + * 12.5ms burst +
* >15ms delay (XXX determine if FW does this, see set_tone) * >15ms delay (XXX determine if FW does this, see set_tone)
*/ */
msleep( (state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60 ); msleep((state->dsec_cmd.args[CX24116_DISEQC_MSGLEN] << 4) + 60);
return 0; return 0;
} }
static void cx24116_release(struct dvb_frontend* fe) static void cx24116_release(struct dvb_frontend *fe)
{ {
struct cx24116_state* state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
dprintk("%s\n",__func__); dprintk("%s\n", __func__);
kfree(state); kfree(state);
} }
static struct dvb_frontend_ops cx24116_ops; static struct dvb_frontend_ops cx24116_ops;
struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, struct dvb_frontend *cx24116_attach(const struct cx24116_config *config,
struct i2c_adapter* i2c) struct i2c_adapter *i2c)
{ {
struct cx24116_state* state = NULL; struct cx24116_state *state = NULL;
int ret; int ret;
dprintk("%s\n",__func__); dprintk("%s\n", __func__);
/* allocate memory for the internal state */ /* allocate memory for the internal state */
state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL); state = kmalloc(sizeof(struct cx24116_state), GFP_KERNEL);
...@@ -1077,18 +1098,20 @@ struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, ...@@ -1077,18 +1098,20 @@ struct dvb_frontend* cx24116_attach(const struct cx24116_config* config,
error2: kfree(state); error2: kfree(state);
error1: return NULL; error1: return NULL;
} }
EXPORT_SYMBOL(cx24116_attach);
/* /*
* Initialise or wake up device * Initialise or wake up device
* *
* Power config will reset and load initial firmware if required * Power config will reset and load initial firmware if required
*/ */
static int cx24116_initfe(struct dvb_frontend* fe) static int cx24116_initfe(struct dvb_frontend *fe)
{ {
struct cx24116_state* state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
struct cx24116_cmd cmd; struct cx24116_cmd cmd;
int ret; int ret;
dprintk("%s()\n",__func__); dprintk("%s()\n", __func__);
/* Power on */ /* Power on */
cx24116_writereg(state, 0xe0, 0); cx24116_writereg(state, 0xe0, 0);
...@@ -1098,9 +1121,9 @@ static int cx24116_initfe(struct dvb_frontend* fe) ...@@ -1098,9 +1121,9 @@ static int cx24116_initfe(struct dvb_frontend* fe)
/* Firmware CMD 36: Power config */ /* Firmware CMD 36: Power config */
cmd.args[0x00] = CMD_TUNERSLEEP; cmd.args[0x00] = CMD_TUNERSLEEP;
cmd.args[0x01] = 0; cmd.args[0x01] = 0;
cmd.len= 0x02; cmd.len = 0x02;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if(ret != 0) if (ret != 0)
return ret; return ret;
return cx24116_diseqc_init(fe); return cx24116_diseqc_init(fe);
...@@ -1109,20 +1132,20 @@ static int cx24116_initfe(struct dvb_frontend* fe) ...@@ -1109,20 +1132,20 @@ static int cx24116_initfe(struct dvb_frontend* fe)
/* /*
* Put device to sleep * Put device to sleep
*/ */
static int cx24116_sleep(struct dvb_frontend* fe) static int cx24116_sleep(struct dvb_frontend *fe)
{ {
struct cx24116_state* state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
struct cx24116_cmd cmd; struct cx24116_cmd cmd;
int ret; int ret;
dprintk("%s()\n",__func__); dprintk("%s()\n", __func__);
/* Firmware CMD 36: Power config */ /* Firmware CMD 36: Power config */
cmd.args[0x00] = CMD_TUNERSLEEP; cmd.args[0x00] = CMD_TUNERSLEEP;
cmd.args[0x01] = 1; cmd.args[0x01] = 1;
cmd.len= 0x02; cmd.len = 0x02;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if(ret != 0) if (ret != 0)
return ret; return ret;
/* Power off (Shutdown clocks) */ /* Power off (Shutdown clocks) */
...@@ -1133,13 +1156,15 @@ static int cx24116_sleep(struct dvb_frontend* fe) ...@@ -1133,13 +1156,15 @@ static int cx24116_sleep(struct dvb_frontend* fe)
return 0; return 0;
} }
static int cx24116_set_property(struct dvb_frontend *fe, struct dtv_property* tvp) static int cx24116_set_property(struct dvb_frontend *fe,
struct dtv_property *tvp)
{ {
dprintk("%s(..)\n", __func__); dprintk("%s(..)\n", __func__);
return 0; return 0;
} }
static int cx24116_get_property(struct dvb_frontend *fe, struct dtv_property* tvp) static int cx24116_get_property(struct dvb_frontend *fe,
struct dtv_property *tvp)
{ {
dprintk("%s(..)\n", __func__); dprintk("%s(..)\n", __func__);
return 0; return 0;
...@@ -1148,7 +1173,8 @@ static int cx24116_get_property(struct dvb_frontend *fe, struct dtv_property* tv ...@@ -1148,7 +1173,8 @@ static int cx24116_get_property(struct dvb_frontend *fe, struct dtv_property* tv
/* dvb-core told us to tune, the tv property cache will be complete, /* dvb-core told us to tune, the tv property cache will be complete,
* it's safe for is to pull values and use them for tuning purposes. * it's safe for is to pull values and use them for tuning purposes.
*/ */
static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) static int cx24116_set_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *p)
{ {
struct cx24116_state *state = fe->demodulator_priv; struct cx24116_state *state = fe->demodulator_priv;
struct dtv_frontend_properties *c = &fe->dtv_property_cache; struct dtv_frontend_properties *c = &fe->dtv_property_cache;
...@@ -1156,96 +1182,99 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par ...@@ -1156,96 +1182,99 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
fe_status_t tunerstat; fe_status_t tunerstat;
int i, status, ret, retune; int i, status, ret, retune;
dprintk("%s()\n",__func__); dprintk("%s()\n", __func__);
switch(c->delivery_system) { switch (c->delivery_system) {
case SYS_DVBS: case SYS_DVBS:
dprintk("%s: DVB-S delivery system selected\n",__func__); dprintk("%s: DVB-S delivery system selected\n", __func__);
/* Only QPSK is supported for DVB-S */ /* Only QPSK is supported for DVB-S */
if(c->modulation != QPSK) { if (c->modulation != QPSK) {
dprintk("%s: unsupported modulation selected (%d)\n", dprintk("%s: unsupported modulation selected (%d)\n",
__func__, c->modulation); __func__, c->modulation);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
/* Pilot doesn't exist in DVB-S, turn bit off */ /* Pilot doesn't exist in DVB-S, turn bit off */
state->dnxt.pilot_val = CX24116_PILOT_OFF; state->dnxt.pilot_val = CX24116_PILOT_OFF;
retune = 1; retune = 1;
/* DVB-S only supports 0.35 */ /* DVB-S only supports 0.35 */
if(c->rolloff != ROLLOFF_35) { if (c->rolloff != ROLLOFF_35) {
dprintk("%s: unsupported rolloff selected (%d)\n", dprintk("%s: unsupported rolloff selected (%d)\n",
__func__, c->rolloff); __func__, c->rolloff);
return -EOPNOTSUPP; return -EOPNOTSUPP;
} }
state->dnxt.rolloff_val = CX24116_ROLLOFF_035; state->dnxt.rolloff_val = CX24116_ROLLOFF_035;
break; break;
case SYS_DVBS2: case SYS_DVBS2:
dprintk("%s: DVB-S2 delivery system selected\n",__func__); dprintk("%s: DVB-S2 delivery system selected\n", __func__);
/*
* NBC 8PSK/QPSK with DVB-S is supported for DVB-S2,
* but not hardware auto detection
*/
if(c->modulation != PSK_8 && c->modulation != QPSK) {
dprintk("%s: unsupported modulation selected (%d)\n",
__func__, c->modulation);
return -EOPNOTSUPP;
}
switch(c->pilot) { /*
case PILOT_AUTO: /* Not supported but emulated */ * NBC 8PSK/QPSK with DVB-S is supported for DVB-S2,
retune = 2; /* Fall-through */ * but not hardware auto detection
case PILOT_OFF: */
state->dnxt.pilot_val = CX24116_PILOT_OFF; if (c->modulation != PSK_8 && c->modulation != QPSK) {
break; dprintk("%s: unsupported modulation selected (%d)\n",
case PILOT_ON: __func__, c->modulation);
state->dnxt.pilot_val = CX24116_PILOT_ON; return -EOPNOTSUPP;
break; }
default:
dprintk("%s: unsupported pilot mode selected (%d)\n",
__func__, c->pilot);
return -EOPNOTSUPP;
}
switch(c->rolloff) { switch (c->pilot) {
case ROLLOFF_20: case PILOT_AUTO: /* Not supported but emulated */
state->dnxt.rolloff_val= CX24116_ROLLOFF_020; retune = 2; /* Fall-through */
break; case PILOT_OFF:
case ROLLOFF_25: state->dnxt.pilot_val = CX24116_PILOT_OFF;
state->dnxt.rolloff_val= CX24116_ROLLOFF_025; break;
break; case PILOT_ON:
case ROLLOFF_35: state->dnxt.pilot_val = CX24116_PILOT_ON;
state->dnxt.rolloff_val= CX24116_ROLLOFF_035;
break;
case ROLLOFF_AUTO: /* Rolloff must be explicit */
default:
dprintk("%s: unsupported rolloff selected (%d)\n",
__func__, c->rolloff);
return -EOPNOTSUPP;
}
break; break;
default:
dprintk("%s: unsupported pilot mode selected (%d)\n",
__func__, c->pilot);
return -EOPNOTSUPP;
}
switch (c->rolloff) {
case ROLLOFF_20:
state->dnxt.rolloff_val = CX24116_ROLLOFF_020;
break;
case ROLLOFF_25:
state->dnxt.rolloff_val = CX24116_ROLLOFF_025;
break;
case ROLLOFF_35:
state->dnxt.rolloff_val = CX24116_ROLLOFF_035;
break;
case ROLLOFF_AUTO: /* Rolloff must be explicit */
default: default:
dprintk("%s: unsupported delivery system selected (%d)\n", dprintk("%s: unsupported rolloff selected (%d)\n",
__func__, c->delivery_system); __func__, c->rolloff);
return -EOPNOTSUPP; return -EOPNOTSUPP;
}
break;
default:
dprintk("%s: unsupported delivery system selected (%d)\n",
__func__, c->delivery_system);
return -EOPNOTSUPP;
} }
state->dnxt.modulation = c->modulation; state->dnxt.modulation = c->modulation;
state->dnxt.frequency = c->frequency; state->dnxt.frequency = c->frequency;
state->dnxt.pilot = c->pilot; state->dnxt.pilot = c->pilot;
state->dnxt.rolloff = c->rolloff; state->dnxt.rolloff = c->rolloff;
if ((ret = cx24116_set_inversion(state, c->inversion)) != 0) ret = cx24116_set_inversion(state, c->inversion);
if (ret != 0)
return ret; return ret;
/* FEC_NONE/AUTO for DVB-S2 is not supported and detected here */ /* FEC_NONE/AUTO for DVB-S2 is not supported and detected here */
if ((ret = cx24116_set_fec(state, c->modulation, c->fec_inner)) != 0) ret = cx24116_set_fec(state, c->modulation, c->fec_inner);
if (ret != 0)
return ret; return ret;
if ((ret = cx24116_set_symbolrate(state, c->symbol_rate)) != 0) ret = cx24116_set_symbolrate(state, c->symbol_rate);
if (ret != 0)
return ret; return ret;
/* discard the 'current' tuning parameters and prepare to tune */ /* discard the 'current' tuning parameters and prepare to tune */
...@@ -1271,7 +1300,7 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par ...@@ -1271,7 +1300,7 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
/* Set/Reset B/W */ /* Set/Reset B/W */
cmd.args[0x00] = CMD_BANDWIDTH; cmd.args[0x00] = CMD_BANDWIDTH;
cmd.args[0x01] = 0x01; cmd.args[0x01] = 0x01;
cmd.len= 0x02; cmd.len = 0x02;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -1319,7 +1348,7 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par ...@@ -1319,7 +1348,7 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
cx24116_writereg(state, CX24116_REG_RATEDIV, 0x00); cx24116_writereg(state, CX24116_REG_RATEDIV, 0x00);
} }
cmd.len= 0x13; cmd.len = 0x13;
/* We need to support pilot and non-pilot tuning in the /* We need to support pilot and non-pilot tuning in the
* driver automatically. This is a workaround for because * driver automatically. This is a workaround for because
...@@ -1327,12 +1356,13 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par ...@@ -1327,12 +1356,13 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
*/ */
do { do {
/* Reset status register */ /* Reset status register */
status = cx24116_readreg(state, CX24116_REG_SSTATUS) & CX24116_SIGNAL_MASK; status = cx24116_readreg(state, CX24116_REG_SSTATUS)
& CX24116_SIGNAL_MASK;
cx24116_writereg(state, CX24116_REG_SSTATUS, status); cx24116_writereg(state, CX24116_REG_SSTATUS, status);
/* Tune */ /* Tune */
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if( ret != 0 ) if (ret != 0)
break; break;
/* /*
...@@ -1341,28 +1371,27 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par ...@@ -1341,28 +1371,27 @@ static int cx24116_set_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
* If we are able to tune then generally it occurs within 100ms. * If we are able to tune then generally it occurs within 100ms.
* If it takes longer, try a different toneburst setting. * If it takes longer, try a different toneburst setting.
*/ */
for(i = 0; i < 50 ; i++) { for (i = 0; i < 50 ; i++) {
cx24116_read_status(fe, &tunerstat); cx24116_read_status(fe, &tunerstat);
status = tunerstat & (FE_HAS_SIGNAL | FE_HAS_SYNC); status = tunerstat & (FE_HAS_SIGNAL | FE_HAS_SYNC);
if(status == (FE_HAS_SIGNAL | FE_HAS_SYNC)) { if (status == (FE_HAS_SIGNAL | FE_HAS_SYNC)) {
dprintk("%s: Tuned\n",__func__); dprintk("%s: Tuned\n", __func__);
goto tuned; goto tuned;
} }
msleep(10); msleep(10);
} }
dprintk("%s: Not tuned\n",__func__); dprintk("%s: Not tuned\n", __func__);
/* Toggle pilot bit when in auto-pilot */ /* Toggle pilot bit when in auto-pilot */
if(state->dcur.pilot == PILOT_AUTO) if (state->dcur.pilot == PILOT_AUTO)
cmd.args[0x07] ^= CX24116_PILOT_ON; cmd.args[0x07] ^= CX24116_PILOT_ON;
} } while (--retune);
while(--retune);
tuned: /* Set/Reset B/W */ tuned: /* Set/Reset B/W */
cmd.args[0x00] = CMD_BANDWIDTH; cmd.args[0x00] = CMD_BANDWIDTH;
cmd.args[0x01] = 0x00; cmd.args[0x01] = 0x00;
cmd.len= 0x02; cmd.len = 0x02;
ret = cx24116_cmd_execute(fe, &cmd); ret = cx24116_cmd_execute(fe, &cmd);
if (ret != 0) if (ret != 0)
return ret; return ret;
...@@ -1407,17 +1436,7 @@ static struct dvb_frontend_ops cx24116_ops = { ...@@ -1407,17 +1436,7 @@ static struct dvb_frontend_ops cx24116_ops = {
.set_frontend = cx24116_set_frontend, .set_frontend = cx24116_set_frontend,
}; };
module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
module_param(toneburst, int, 0644);
MODULE_PARM_DESC(toneburst, "DiSEqC toneburst 0=OFF, 1=TONE CACHE, 2=MESSAGE CACHE (default:1)");
module_param(esno_snr, int, 0644);
MODULE_PARM_DESC(debug, "SNR return units, 0=PERCENTAGE 0-100, 1=ESNO(db * 10) (default:0)");
MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware"); MODULE_DESCRIPTION("DVB Frontend module for Conexant cx24116/cx24118 hardware");
MODULE_AUTHOR("Steven Toth"); MODULE_AUTHOR("Steven Toth");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
EXPORT_SYMBOL(cx24116_attach);
...@@ -23,31 +23,32 @@ ...@@ -23,31 +23,32 @@
#include <linux/dvb/frontend.h> #include <linux/dvb/frontend.h>
struct cx24116_config struct cx24116_config {
{
/* the demodulator's i2c address */ /* the demodulator's i2c address */
u8 demod_address; u8 demod_address;
/* Need to set device param for start_dma */ /* Need to set device param for start_dma */
int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured);
/* Need to reset device during firmware loading */ /* Need to reset device during firmware loading */
int (*reset_device)(struct dvb_frontend* fe); int (*reset_device)(struct dvb_frontend *fe);
/* Need to set MPEG parameters */ /* Need to set MPEG parameters */
u8 mpg_clk_pos_pol:0x02; u8 mpg_clk_pos_pol:0x02;
}; };
#if defined(CONFIG_DVB_CX24116) || defined(CONFIG_DVB_CX24116_MODULE) #if defined(CONFIG_DVB_CX24116) || defined(CONFIG_DVB_CX24116_MODULE)
extern struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, extern struct dvb_frontend *cx24116_attach(
struct i2c_adapter* i2c); const struct cx24116_config *config,
struct i2c_adapter *i2c);
#else #else
static inline struct dvb_frontend* cx24116_attach(const struct cx24116_config* config, static inline struct dvb_frontend *cx24116_attach(
struct i2c_adapter* i2c) const struct cx24116_config *config,
struct i2c_adapter *i2c)
{ {
printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
return NULL; return NULL;
} }
#endif // CONFIG_DVB_CX24116 #endif
#endif /* CX24116_H */ #endif /* CX24116_H */
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