25 #include <linux/kernel.h>
26 #include <asm/div64.h>
35 #define rc(args...) do { \
36 printk(KERN_ERR "s921: " args); \
39 #define dprintk(args...) \
42 printk(KERN_DEBUG "s921: %s: ", __func__); \
62 static struct s921_bandselect_val {
65 } s921_bandselect[] = {
81 static struct regdata s921_init[] = {
189 static struct regdata s921_prefreq[] = {
197 static struct regdata s921_postfreq[] = {
211 .addr = i2c_addr, .flags = 0, .buf =
buf, .len = 2
217 printk(
"%s: writereg rcor(rc == %i, reg == 0x%02x,"
218 " data == 0x%02x)\n", __func__, rc, reg, data);
225 static int s921_i2c_writeregdata(
struct s921_state *state,
u8 i2c_addr,
230 for (i = 0; i <
size; i++) {
231 rc = s921_i2c_writereg(state, i2c_addr, rd[i].reg, rd[i].data);
238 static int s921_i2c_readreg(
struct s921_state *state,
u8 i2c_addr,
u8 reg)
243 { .
addr = i2c_addr, .flags = 0, .buf = &
reg, .len = 1 },
244 { .addr = i2c_addr, .flags =
I2C_M_RD, .buf = &
val, .len = 1 }
250 rc(
"%s: reg=0x%x (rcor=%d)\n", __func__, reg, rc);
257 #define s921_readreg(state, reg) \
258 s921_i2c_readreg(state, state->config->demod_address, reg)
259 #define s921_writereg(state, reg, val) \
260 s921_i2c_writereg(state, state->config->demod_address, reg, val)
261 #define s921_writeregdata(state, regdata) \
262 s921_i2c_writeregdata(state, state->config->demod_address, \
263 regdata, ARRAY_SIZE(regdata))
270 unsigned long f_offset;
276 for (band = 0; band <
ARRAY_SIZE(s921_bandselect); band++)
277 if (p->
frequency < s921_bandselect[band].freq_low)
282 rc(
"%s: frequency out of range\n", __func__);
286 f_switch = s921_bandselect[band].band_reg;
290 f_offset = ((
unsigned long)offset) + 2321;
312 for (i = 0 ; i < 6; i++) {
314 dprintk(
"status 0x80: %02x\n", rc);
321 dprintk(
"status 0x01: %02x\n", rc);
324 dprintk(
"status 0x80: %02x\n", rc);
327 dprintk(
"status 0x80: %02x\n", rc);
330 dprintk(
"status 0x32: %02x\n", rc);
332 dprintk(
"pll tune band=%d, pll=%d\n", f_switch, (
int)f_offset);
370 dprintk(
"status = %04x\n", regstatus);
373 if ((regstatus & 0xff) == 0x40) {
379 }
else if (regstatus & 0x40) {
390 static int s921_read_signal_strength(
struct dvb_frontend *fe,
u16 *strength)
397 rc = s921_read_status(fe, &status);
403 dprintk(
"strength = 0x%04x\n", *strength);
406 dprintk(
"status 0x01: %02x\n", rc);
409 dprintk(
"status 0x80: %02x\n", rc);
412 dprintk(
"status 0x32: %02x\n", rc);
427 rc = s921_pll_tune(fe);
450 unsigned int mode_flags,
459 rc = s921_set_frontend(fe);
462 s921_read_status(fe, status);
491 rc(
"Unable to kzalloc\n");
512 .name =
"Sharp S921",
513 .frequency_min = 470000000,
519 .frequency_max = 806000000,
520 .frequency_tolerance = 0,
530 .release = s921_release,
533 .set_frontend = s921_set_frontend,
534 .get_frontend = s921_get_frontend,
535 .read_status = s921_read_status,
536 .read_signal_strength = s921_read_signal_strength,
538 .get_frontend_algo = s921_get_algo,