#define OR51132_VSB_FIRMWARE …
#define OR51132_QAM_FIRMWARE …
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/init.h>
#include <linux/delay.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <asm/byteorder.h>
#include <linux/int_log.h>
#include <media/dvb_frontend.h>
#include "or51132.h"
static int debug;
#define dprintk(args...) …
struct or51132_state
{ … };
static int or51132_writebuf(struct or51132_state *state, const u8 *buf, int len)
{ … }
#define or51132_writebytes(state, data...) …
static int or51132_readbuf(struct or51132_state *state, u8 *buf, int len)
{ … }
static int or51132_readreg(struct or51132_state *state, u8 reg)
{ … }
static int or51132_load_firmware (struct dvb_frontend* fe, const struct firmware *fw)
{
struct or51132_state* state = fe->demodulator_priv;
static const u8 run_buf[] = {0x7F,0x01};
u8 rec_buf[8];
u32 firmwareAsize, firmwareBsize;
int i,ret;
dprintk("Firmware is %zd bytes\n",fw->size);
firmwareAsize = le32_to_cpu(*((__le32*)fw->data));
dprintk("FirmwareA is %i bytes\n",firmwareAsize);
firmwareBsize = le32_to_cpu(*((__le32*)(fw->data+4)));
dprintk("FirmwareB is %i bytes\n",firmwareBsize);
if ((ret = or51132_writebuf(state, &fw->data[8], firmwareAsize))) {
printk(KERN_WARNING "or51132: load_firmware error 1\n");
return ret;
}
if ((ret = or51132_writebuf(state, &fw->data[8+firmwareAsize],
firmwareBsize))) {
printk(KERN_WARNING "or51132: load_firmware error 2\n");
return ret;
}
if ((ret = or51132_writebuf(state, run_buf, 2))) {
printk(KERN_WARNING "or51132: load_firmware error 3\n");
return ret;
}
if ((ret = or51132_writebuf(state, run_buf, 2))) {
printk(KERN_WARNING "or51132: load_firmware error 4\n");
return ret;
}
msleep(50);
if ((ret = or51132_writebytes(state, 0x10, 0x10, 0x00))) {
printk(KERN_WARNING "or51132: load_firmware error a\n");
return ret;
}
if ((ret = or51132_writebytes(state, 0x04, 0x17))) {
printk(KERN_WARNING "or51132: load_firmware error b\n");
return ret;
}
if ((ret = or51132_writebytes(state, 0x00, 0x00))) {
printk(KERN_WARNING "or51132: load_firmware error c\n");
return ret;
}
for (i=0;i<4;i++) {
if ((ret = or51132_readbuf(state, &rec_buf[i*2], 2))) {
printk(KERN_WARNING
"or51132: load_firmware error d - %d\n",i);
return ret;
}
}
printk(KERN_WARNING
"or51132: Version: %02X%02X%02X%02X-%02X%02X%02X%02X (%02X%01X-%01X-%02X%01X-%01X)\n",
rec_buf[1],rec_buf[0],rec_buf[3],rec_buf[2],
rec_buf[5],rec_buf[4],rec_buf[7],rec_buf[6],
rec_buf[3],rec_buf[2]>>4,rec_buf[2]&0x0f,
rec_buf[5],rec_buf[4]>>4,rec_buf[4]&0x0f);
if ((ret = or51132_writebytes(state, 0x10, 0x00, 0x00))) {
printk(KERN_WARNING "or51132: load_firmware error e\n");
return ret;
}
return 0;
};
static int or51132_init(struct dvb_frontend* fe)
{ … }
static int or51132_read_ber(struct dvb_frontend* fe, u32* ber)
{ … }
static int or51132_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks)
{ … }
static int or51132_sleep(struct dvb_frontend* fe)
{ … }
static int or51132_setmode(struct dvb_frontend* fe)
{ … }
#define MOD_FWCLASS_UNKNOWN …
#define MOD_FWCLASS_VSB …
#define MOD_FWCLASS_QAM …
static int modulation_fw_class(enum fe_modulation modulation)
{ … }
static int or51132_set_parameters(struct dvb_frontend *fe)
{ … }
static int or51132_get_parameters(struct dvb_frontend* fe,
struct dtv_frontend_properties *p)
{ … }
static int or51132_read_status(struct dvb_frontend *fe, enum fe_status *status)
{ … }
static u32 calculate_snr(u32 mse, u32 c)
{ … }
static int or51132_read_snr(struct dvb_frontend* fe, u16* snr)
{ … }
static int or51132_read_signal_strength(struct dvb_frontend* fe, u16* strength)
{ … }
static int or51132_get_tune_settings(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* fe_tune_settings)
{ … }
static void or51132_release(struct dvb_frontend* fe)
{ … }
static const struct dvb_frontend_ops or51132_ops;
struct dvb_frontend* or51132_attach(const struct or51132_config* config,
struct i2c_adapter* i2c)
{ … }
static const struct dvb_frontend_ops or51132_ops = …;
module_param(debug, int, 0644);
MODULE_PARM_DESC(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;
EXPORT_SYMBOL_GPL(…);