23 #include <linux/kernel.h>
24 #include <linux/module.h>
25 #include <linux/slab.h>
26 #include <linux/string.h>
40 #define dprintk(x, y, z, format, arg...) do { \
42 if ((x > FE_ERROR) && (x > y)) \
43 printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \
44 else if ((x > FE_NOTICE) && (x > y)) \
45 printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \
46 else if ((x > FE_INFO) && (x > y)) \
47 printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \
48 else if ((x > FE_DEBUG) && (x > y)) \
49 printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \
52 printk(format, ##arg); \
66 { 950000, 1000000, 0x0a },
67 { 1000000, 1075000, 0x0c },
68 { 1075000, 1200000, 0x00 },
69 { 1200000, 1300000, 0x01 },
70 { 1300000, 1370000, 0x02 },
71 { 1370000, 1470000, 0x04 },
72 { 1470000, 1530000, 0x05 },
73 { 1530000, 1650000, 0x06 },
74 { 1650000, 1800000, 0x08 },
75 { 1800000, 1950000, 0x0a },
76 { 1950000, 2150000, 0x0c },
77 { 2150000, 9999999, 0x0c },
82 static const char *stb6100_regnames[] = {
123 static inline void stb6100_normalise_regs(
u8 regs[])
128 regs[i] = (regs[i] & stb6100_template[i].
mask) | stb6100_template[
i].
set;
135 .addr = state->
config->tuner_address,
138 .len = STB6100_NUMREGS
144 state->
config->tuner_address, rc);
171 if (
unlikely(reg >= STB6100_NUMREGS)) {
180 return (
unsigned int)regs[0];
194 if (
unlikely(start < 1 || start + len > STB6100_NUMREGS)) {
199 memcpy(&cmdbuf[1], buf, len);
206 for (i = 0; i <
len; i++)
212 (
unsigned int)state->
config->tuner_address, start, len, rc);
220 if (
unlikely(reg >= STB6100_NUMREGS)) {
224 data = (data & stb6100_template[
reg].
mask) | stb6100_template[reg].
set;
225 return stb6100_write_reg_range(state, &data, reg, 1);
253 state->
status.bandwidth = (f + 5) * 2000;
260 static int stb6100_set_bandwidth(
struct dvb_frontend *fe,
u32 bandwidth)
270 if (bandwidth >= 36000000)
272 else if (bandwidth <= 5000000)
275 tmp = (bandwidth + 500000) / 1000000 - 5;
283 rc = stb6100_write_reg(state,
STB6100_F, 0xc0 | tmp);
301 u32 nint, nfrac, fvco;
306 rc = stb6100_read_regs(state, regs);
315 *frequency = state->
frequency = fvco >> (odiv + 1);
318 "frequency = %u kHz, odiv = %u, psd2 = %u, fxtal = %u kHz, fvco = %u kHz, N(I) = %u, N(F) = %u",
324 static int stb6100_set_frequency(
struct dvb_frontend *fe,
u32 frequency)
331 u32 srate = 0, fvco, nint, nfrac;
337 if (fe->
ops.get_frontend) {
339 fe->
ops.get_frontend(fe);
357 if (frequency <= 1075000)
371 printk(
KERN_ERR "%s: frequency out of range: %u kHz\n", __func__, frequency);
379 if ((frequency > 1075000) && (frequency <= 1325000))
384 fvco = frequency << (1 + odiv);
386 nint = fvco / (state->
reference << psd2);
411 if (srate >= 15000000)
413 else if (srate >= 5000000)
434 "frequency = %u, srate = %u, g = %u, odiv = %u, psd2 = %u, fxtal = %u, osm = %u, fvco = %u, N(I) = %u, N(F) = %u",
435 frequency, srate, (
unsigned int)g, (
unsigned int)odiv,
437 ptr->
reg, fvco, nint, nfrac);
459 rc = stb6100_write_reg(state, STB6100_VCO, regs[STB6100_VCO]);
467 rc = stb6100_write_reg(state, STB6100_VCO, regs[STB6100_VCO]);
509 stb6100_get_frequency(fe, &state->
frequency);
516 stb6100_get_bandwidth(fe, &state->
bandwidth);
535 stb6100_set_frequency(fe, state->
frequency);
543 stb6100_set_bandwidth(fe, state->
bandwidth);
557 .name =
"STB6100 Silicon Tuner",
558 .frequency_min = 950000,
559 .frequency_max = 2150000,
563 .init = stb6100_init,
564 .sleep = stb6100_sleep,
565 .get_status = stb6100_get_status,
566 .get_state = stb6100_get_state,
567 .set_state = stb6100_set_state,
568 .release = stb6100_release
586 fe->
ops.tuner_ops = stb6100_ops;
588 printk(
"%s: Attaching STB6100 \n", __func__);