#define pr_fmt(fmt) …
#define OR51211_DEFAULT_FIRMWARE …
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/firmware.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <asm/byteorder.h>
#include <linux/int_log.h>
#include <media/dvb_frontend.h>
#include "or51211.h"
static int debug;
#define dprintk(args...) …
static u8 run_buf[] = …;
static u8 cmd_buf[] = …;
struct or51211_state { … };
static int i2c_writebytes (struct or51211_state* state, u8 reg, const u8 *buf,
int len)
{ … }
static int i2c_readbytes(struct or51211_state *state, u8 reg, u8 *buf, int len)
{ … }
static int or51211_load_firmware (struct dvb_frontend* fe,
const struct firmware *fw)
{
struct or51211_state* state = fe->demodulator_priv;
u8 tudata[585];
int i;
dprintk("Firmware is %zu bytes\n", fw->size);
tudata[0] = 17;
if (i2c_writebytes(state,0x50,tudata,1)) {
pr_warn("error eprom addr\n");
return -1;
}
if (i2c_readbytes(state,0x50,&tudata[145],192)) {
pr_warn("error eprom\n");
return -1;
}
for (i = 0; i < 145; i++)
tudata[i] = fw->data[i];
for (i = 0; i < 248; i++)
tudata[i+337] = fw->data[145+i];
state->config->reset(fe);
if (i2c_writebytes(state,state->config->demod_address,tudata,585)) {
pr_warn("error 1\n");
return -1;
}
msleep(1);
if (i2c_writebytes(state,state->config->demod_address,
&fw->data[393],8125)) {
pr_warn("error 2\n");
return -1;
}
msleep(1);
if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
pr_warn("error 3\n");
return -1;
}
msleep(10);
if (i2c_writebytes(state,state->config->demod_address,run_buf,2)) {
pr_warn("error 4\n");
return -1;
}
msleep(10);
pr_info("Done.\n");
return 0;
};
static int or51211_setmode(struct dvb_frontend* fe, int mode)
{ … }
static int or51211_set_parameters(struct dvb_frontend *fe)
{ … }
static int or51211_read_status(struct dvb_frontend *fe, enum fe_status *status)
{ … }
static u32 calculate_snr(u32 mse, u32 c)
{ … }
static int or51211_read_snr(struct dvb_frontend* fe, u16* snr)
{ … }
static int or51211_read_signal_strength(struct dvb_frontend* fe, u16* strength)
{ … }
static int or51211_read_ber(struct dvb_frontend* fe, u32* ber)
{ … }
static int or51211_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
{ … }
static int or51211_sleep(struct dvb_frontend* fe)
{ … }
static int or51211_init(struct dvb_frontend* fe)
{ … }
static int or51211_get_tune_settings(struct dvb_frontend* fe,
struct dvb_frontend_tune_settings* fesettings)
{ … }
static void or51211_release(struct dvb_frontend* fe)
{ … }
static const struct dvb_frontend_ops or51211_ops;
struct dvb_frontend* or51211_attach(const struct or51211_config* config,
struct i2c_adapter* i2c)
{ … }
static const struct dvb_frontend_ops or51211_ops = …;
module_param(debug, int, 0644);
MODULE_PARM_DESC(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
EXPORT_SYMBOL_GPL(…);