#include <linux/jiffies.h>
#include <linux/dvb/frontend.h>
#include "lg2160.h"
static int debug;
module_param(debug, int, 0644);
MODULE_PARM_DESC(…) …;
#define DBG_INFO …
#define DBG_REG …
#define lg_printk(kern, fmt, arg...) …
#define lg_info(fmt, arg...) …
#define lg_warn(fmt, arg...) …
#define lg_err(fmt, arg...) …
#define lg_dbg(fmt, arg...) …
#define lg_reg(fmt, arg...) …
#define lg_fail(ret) …
struct lg216x_state { … };
static int lg216x_write_reg(struct lg216x_state *state, u16 reg, u8 val)
{ … }
static int lg216x_read_reg(struct lg216x_state *state, u16 reg, u8 *val)
{ … }
struct lg216x_reg { … };
static int lg216x_write_regs(struct lg216x_state *state,
struct lg216x_reg *regs, int len)
{ … }
static int lg216x_set_reg_bit(struct lg216x_state *state,
u16 reg, int bit, int onoff)
{ … }
static int lg216x_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
{ … }
static int lg216x_soft_reset(struct lg216x_state *state)
{ … }
static int lg216x_initialize(struct lg216x_state *state)
{ … }
static int lg216x_set_if(struct lg216x_state *state)
{ … }
static int lg2160_agc_fix(struct lg216x_state *state,
int if_agc_fix, int rf_agc_fix)
{ … }
#if 0
static int lg2160_agc_freeze(struct lg216x_state *state,
int if_agc_freeze, int rf_agc_freeze)
{
u8 val;
int ret;
ret = lg216x_read_reg(state, 0x0100, &val);
if (lg_fail(ret))
goto fail;
val &= 0xcf;
val |= (if_agc_freeze) ? 0x20 : 0x00;
val |= (rf_agc_freeze) ? 0x10 : 0x00;
ret = lg216x_write_reg(state, 0x0100, val);
lg_fail(ret);
fail:
return ret;
}
#endif
static int lg2160_agc_polarity(struct lg216x_state *state,
int if_agc_polarity, int rf_agc_polarity)
{ … }
static int lg2160_tuner_pwr_save_polarity(struct lg216x_state *state,
int polarity)
{ … }
static int lg2160_spectrum_polarity(struct lg216x_state *state,
int inverted)
{ … }
static int lg2160_tuner_pwr_save(struct lg216x_state *state, int onoff)
{ … }
static int lg216x_set_parade(struct lg216x_state *state, int id)
{ … }
static int lg216x_set_ensemble(struct lg216x_state *state, int id)
{ … }
static int lg2160_set_spi_clock(struct lg216x_state *state)
{ … }
static int lg2161_set_output_interface(struct lg216x_state *state)
{ … }
static int lg216x_enable_fic(struct lg216x_state *state, int onoff)
{ … }
static int lg216x_get_fic_version(struct lg216x_state *state, u8 *ficver)
{ … }
#if 0
static int lg2160_get_parade_id(struct lg216x_state *state, u8 *id)
{
u8 val;
int ret;
*id = 0xff;
ret = lg216x_read_reg(state, 0x0123, &val);
if (lg_fail(ret))
goto fail;
*id = val & 0x7f;
fail:
return ret;
}
#endif
static int lg216x_get_nog(struct lg216x_state *state, u8 *nog)
{ … }
static int lg216x_get_tnog(struct lg216x_state *state, u8 *tnog)
{ … }
static int lg216x_get_sgn(struct lg216x_state *state, u8 *sgn)
{ … }
static int lg216x_get_prc(struct lg216x_state *state, u8 *prc)
{ … }
static int lg216x_get_rs_frame_mode(struct lg216x_state *state,
enum atscmh_rs_frame_mode *rs_framemode)
{ … }
static
int lg216x_get_rs_frame_ensemble(struct lg216x_state *state,
enum atscmh_rs_frame_ensemble *rs_frame_ens)
{ … }
static int lg216x_get_rs_code_mode(struct lg216x_state *state,
enum atscmh_rs_code_mode *rs_code_pri,
enum atscmh_rs_code_mode *rs_code_sec)
{ … }
static int lg216x_get_sccc_block_mode(struct lg216x_state *state,
enum atscmh_sccc_block_mode *sccc_block)
{ … }
static int lg216x_get_sccc_code_mode(struct lg216x_state *state,
enum atscmh_sccc_code_mode *mode_a,
enum atscmh_sccc_code_mode *mode_b,
enum atscmh_sccc_code_mode *mode_c,
enum atscmh_sccc_code_mode *mode_d)
{ … }
#if 0
static int lg216x_read_fic_err_count(struct lg216x_state *state, u8 *err)
{
u8 fic_err;
int ret;
*err = 0;
switch (state->cfg->lg_chip) {
case LG2160:
ret = lg216x_read_reg(state, 0x0012, &fic_err);
break;
case LG2161:
ret = lg216x_read_reg(state, 0x001e, &fic_err);
break;
}
if (lg_fail(ret))
goto fail;
*err = fic_err;
fail:
return ret;
}
static int lg2160_read_crc_err_count(struct lg216x_state *state, u16 *err)
{
u8 crc_err1, crc_err2;
int ret;
*err = 0;
ret = lg216x_read_reg(state, 0x0411, &crc_err1);
if (lg_fail(ret))
goto fail;
ret = lg216x_read_reg(state, 0x0412, &crc_err2);
if (lg_fail(ret))
goto fail;
*err = (u16)(((crc_err2 & 0x0f) << 8) | crc_err1);
fail:
return ret;
}
static int lg2161_read_crc_err_count(struct lg216x_state *state, u16 *err)
{
u8 crc_err;
int ret;
*err = 0;
ret = lg216x_read_reg(state, 0x0612, &crc_err);
if (lg_fail(ret))
goto fail;
*err = (u16)crc_err;
fail:
return ret;
}
static int lg216x_read_crc_err_count(struct lg216x_state *state, u16 *err)
{
int ret;
switch (state->cfg->lg_chip) {
case LG2160:
ret = lg2160_read_crc_err_count(state, err);
break;
case LG2161:
ret = lg2161_read_crc_err_count(state, err);
break;
default:
ret = -EINVAL;
break;
}
return ret;
}
static int lg2160_read_rs_err_count(struct lg216x_state *state, u16 *err)
{
u8 rs_err1, rs_err2;
int ret;
*err = 0;
ret = lg216x_read_reg(state, 0x0413, &rs_err1);
if (lg_fail(ret))
goto fail;
ret = lg216x_read_reg(state, 0x0414, &rs_err2);
if (lg_fail(ret))
goto fail;
*err = (u16)(((rs_err2 & 0x0f) << 8) | rs_err1);
fail:
return ret;
}
static int lg2161_read_rs_err_count(struct lg216x_state *state, u16 *err)
{
u8 rs_err1, rs_err2;
int ret;
*err = 0;
ret = lg216x_read_reg(state, 0x0613, &rs_err1);
if (lg_fail(ret))
goto fail;
ret = lg216x_read_reg(state, 0x0614, &rs_err2);
if (lg_fail(ret))
goto fail;
*err = (u16)((rs_err1 << 8) | rs_err2);
fail:
return ret;
}
static int lg216x_read_rs_err_count(struct lg216x_state *state, u16 *err)
{
int ret;
switch (state->cfg->lg_chip) {
case LG2160:
ret = lg2160_read_rs_err_count(state, err);
break;
case LG2161:
ret = lg2161_read_rs_err_count(state, err);
break;
default:
ret = -EINVAL;
break;
}
return ret;
}
#endif
static int lg216x_get_frontend(struct dvb_frontend *fe,
struct dtv_frontend_properties *c)
{ … }
static int lg2160_set_frontend(struct dvb_frontend *fe)
{ … }
static int lg2160_read_lock_status(struct lg216x_state *state,
int *acq_lock, int *sync_lock)
{ … }
#ifdef USE_LG2161_LOCK_BITS
static int lg2161_read_lock_status(struct lg216x_state *state,
int *acq_lock, int *sync_lock)
{
u8 val;
int ret;
*acq_lock = 0;
*sync_lock = 0;
ret = lg216x_read_reg(state, 0x0304, &val);
if (lg_fail(ret))
goto fail;
*sync_lock = (val & 0x80) ? 0 : 1;
ret = lg216x_read_reg(state, 0x011b, &val);
if (lg_fail(ret))
goto fail;
*acq_lock = (val & 0x40) ? 0 : 1;
fail:
return ret;
}
#endif
static int lg216x_read_lock_status(struct lg216x_state *state,
int *acq_lock, int *sync_lock)
{ … }
static int lg216x_read_status(struct dvb_frontend *fe, enum fe_status *status)
{ … }
static int lg2160_read_snr(struct dvb_frontend *fe, u16 *snr)
{ … }
static int lg2161_read_snr(struct dvb_frontend *fe, u16 *snr)
{ … }
static int lg216x_read_signal_strength(struct dvb_frontend *fe,
u16 *strength)
{ … }
static int lg216x_read_ucblocks(struct dvb_frontend *fe, u32 *ucblocks)
{ … }
static int lg216x_get_tune_settings(struct dvb_frontend *fe,
struct dvb_frontend_tune_settings
*fe_tune_settings)
{ … }
static void lg216x_release(struct dvb_frontend *fe)
{ … }
static const struct dvb_frontend_ops lg2160_ops = …;
static const struct dvb_frontend_ops lg2161_ops = …;
struct dvb_frontend *lg2160_attach(const struct lg2160_config *config,
struct i2c_adapter *i2c_adap)
{ … }
EXPORT_SYMBOL_GPL(…);
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
MODULE_VERSION(…) …;