#ifdef pr_fmt
#undef pr_fmt
#endif
#define pr_fmt(fmt) …
#define SP8870_DEFAULT_FIRMWARE …
#include <linux/init.h>
#include <linux/module.h>
#include <linux/device.h>
#include <linux/firmware.h>
#include <linux/delay.h>
#include <linux/string.h>
#include <linux/slab.h>
#include <media/dvb_frontend.h>
#include "sp8870.h"
struct sp8870_state { … };
static int debug;
#define dprintk(fmt, arg...) …
#define SP8870_FIRMWARE_SIZE …
#define SP8870_FIRMWARE_OFFSET …
static int sp8870_writereg(struct sp8870_state *state, u16 reg, u16 data)
{ … }
static int sp8870_readreg(struct sp8870_state *state, u16 reg)
{ … }
static int sp8870_firmware_upload(struct sp8870_state *state, const struct firmware *fw)
{
struct i2c_msg msg;
const char *fw_buf = fw->data;
int fw_pos;
u8 tx_buf[255];
int tx_len;
int err = 0;
dprintk("start firmware upload...\n");
if (fw->size < SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET)
return -EINVAL;
sp8870_writereg(state, 0x0F00, 0x0000);
sp8870_writereg(state, 0x8F08, ((SP8870_FIRMWARE_SIZE / 2) & 0xFFFF));
sp8870_writereg(state, 0x8F0A, ((SP8870_FIRMWARE_SIZE / 2) >> 16));
fw_pos = SP8870_FIRMWARE_OFFSET;
while (fw_pos < SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET) {
tx_len = (fw_pos <= SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET - 252) ? 252 :
SP8870_FIRMWARE_SIZE + SP8870_FIRMWARE_OFFSET - fw_pos;
tx_buf[0] = 0xCF;
tx_buf[1] = 0x0A;
memcpy(&tx_buf[2], fw_buf + fw_pos, tx_len);
msg.addr = state->config->demod_address;
msg.flags = 0;
msg.buf = tx_buf;
msg.len = tx_len + 2;
err = i2c_transfer(state->i2c, &msg, 1);
if (err != 1) {
pr_err("%s(): firmware upload failed!\n", __func__);
pr_err("%s(): i2c error (err == %i)\n", __func__, err);
return err;
}
fw_pos += tx_len;
}
dprintk("firmware upload successful!\n");
return 0;
};
static void sp8870_microcontroller_stop(struct sp8870_state *state)
{ … }
static void sp8870_microcontroller_start(struct sp8870_state *state)
{ … }
static int sp8870_read_data_valid_signal(struct sp8870_state *state)
{ … }
static int configure_reg0xc05(struct dtv_frontend_properties *p, u16 *reg0xc05)
{ … }
static int sp8870_wake_up(struct sp8870_state *state)
{ … }
static int sp8870_set_frontend_parameters(struct dvb_frontend *fe)
{ … }
static int sp8870_init(struct dvb_frontend *fe)
{ … }
static int sp8870_read_status(struct dvb_frontend *fe,
enum fe_status *fe_status)
{ … }
static int sp8870_read_ber(struct dvb_frontend *fe, u32 *ber)
{ … }
static int sp8870_read_signal_strength(struct dvb_frontend *fe, u16 *signal)
{ … }
static int sp8870_read_uncorrected_blocks(struct dvb_frontend *fe, u32 *ublocks)
{ … }
#define MAXTRIALS …
#define MAXCHECKS …
static int lockups;
static int switches;
static int sp8870_set_frontend(struct dvb_frontend *fe)
{ … }
static int sp8870_sleep(struct dvb_frontend *fe)
{ … }
static int sp8870_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings *fesettings)
{ … }
static int sp8870_i2c_gate_ctrl(struct dvb_frontend *fe, int enable)
{ … }
static void sp8870_release(struct dvb_frontend *fe)
{ … }
static const struct dvb_frontend_ops sp8870_ops;
struct dvb_frontend *sp8870_attach(const struct sp8870_config *config,
struct i2c_adapter *i2c)
{ … }
EXPORT_SYMBOL_GPL(…);
static const struct dvb_frontend_ops sp8870_ops = …;
module_param(debug, int, 0644);
MODULE_PARM_DESC(…) …;
MODULE_DESCRIPTION(…) …;
MODULE_AUTHOR(…) …;
MODULE_LICENSE(…) …;