28 { .addr = priv->
cfg->i2c_address,
29 .flags = 0, .buf = &
reg, .len = 1 },
30 { .addr = priv->
cfg->i2c_address,
35 dev_warn(&priv->
i2c->dev,
"%s: i2c rd failed reg=%02x\n",
47 .flags = 0, .buf =
buf, .len = 2 };
50 dev_warn(&priv->
i2c->dev,
"%s: i2c wr failed reg=%02x\n",
115 #define FREQ1 32000000
116 #define FREQ2 4000000
126 if (fe->
ops.i2c_gate_ctrl)
127 fe->
ops.i2c_gate_ctrl(fe, 1);
130 if (freq < 290000000) reg05 = 0x14;
131 else if (freq < 610000000) reg05 = 0x34;
132 else if (freq < 802000000) reg05 = 0x54;
142 if (mod1 < 8000000) rd[6].
val = 0x1d;
143 else rd[6].
val = 0x1c;
146 if (mod1 < 1*FREQ2) rd[7].
val = 0x09;
147 else if (mod1 < 2*FREQ2) rd[7].
val = 0x08;
148 else if (mod1 < 3*FREQ2) rd[7].
val = 0x0f;
149 else if (mod1 < 4*FREQ2) rd[7].
val = 0x0e;
150 else if (mod1 < 5*FREQ2) rd[7].
val = 0x0d;
151 else if (mod1 < 6*FREQ2) rd[7].
val = 0x0c;
152 else if (mod1 < 7*FREQ2) rd[7].
val = 0x0b;
153 else rd[7].
val = 0x0a;
156 if (mod2 < 2000000) rd[8].
val = 0x45;
157 else rd[8].
val = 0x44;
170 if (freq < 450000000) rd[15].
val = 0xd0;
171 else if (freq < 482000000) rd[15].
val = 0xd1;
172 else if (freq < 514000000) rd[15].
val = 0xd4;
173 else if (freq < 546000000) rd[15].
val = 0xd7;
174 else if (freq < 610000000) rd[15].
val = 0xda;
175 else rd[15].
val = 0xd0;
178 rd[35].
val = (reg05 & 0xf0);
181 if (mod1 < 8000000) tmpval = 0x00;
182 else if (mod1 < 12000000) tmpval = 0x01;
183 else if (mod1 < 16000000) tmpval = 0x02;
184 else if (mod1 < 24000000) tmpval = 0x03;
185 else if (mod1 < 28000000) tmpval = 0x04;
190 if (mod1 < 8000000) tmpval = 0x00;
191 else if (mod1 < 12000000) tmpval = 0x01;
192 else if (mod1 < 20000000) tmpval = 0x02;
193 else if (mod1 < 24000000) tmpval = 0x03;
194 else if (mod1 < 28000000) tmpval = 0x04;
205 "%s: freq:%u 05:%02x 07:%02x 09:%02x 0a:%02x 0b:%02x " \
206 "1a:%02x 11:%02x 12:%02x 22:%02x 05:%02x 1f:%02x " \
207 "20:%02x 25:%02x 00:%02x\n", __func__, \
215 err = qt1010_writereg(priv, rd[i].reg, rd[i].val);
217 err = qt1010_readreg(priv, rd[i].reg, &tmpval);
222 if (fe->
ops.i2c_gate_ctrl)
223 fe->
ops.i2c_gate_ctrl(fe, 0);
228 static int qt1010_init_meas1(
struct qt1010_priv *priv,
243 err = qt1010_writereg(priv, i2c_data[i].reg,
246 err = qt1010_readreg(priv, i2c_data[i].reg, &val2);
253 err = qt1010_readreg(priv, reg, &val2);
255 dev_dbg(&priv->
i2c->dev,
"%s: compare reg:%02x %02x %02x\n",
256 __func__, reg, val1, val2);
257 }
while (val1 != val2);
260 return qt1010_writereg(priv, 0x1e, 0x00);
263 static int qt1010_init_meas2(
struct qt1010_priv *priv,
264 u8 reg_init_val,
u8 *retval)
279 err = qt1010_writereg(priv, i2c_data[i].reg,
282 err = qt1010_readreg(priv, i2c_data[i].reg, &val);
334 if (fe->
ops.i2c_gate_ctrl)
335 fe->
ops.i2c_gate_ctrl(fe, 1);
338 switch (i2c_data[i].oper) {
340 err = qt1010_writereg(priv, i2c_data[i].reg,
344 if (i2c_data[i].val == 0x20)
348 err = qt1010_readreg(priv, i2c_data[i].reg, valptr);
351 if (i2c_data[i].val == 0x25)
353 else if (i2c_data[i].val == 0x1f)
357 err = qt1010_init_meas1(priv, i2c_data[i+1].reg,
359 i2c_data[i].val, valptr);
366 for (i = 0x31; i < 0x3a; i++)
367 if ((err = qt1010_init_meas2(priv, i, &tmpval)))
373 return qt1010_set_params(fe);
392 *frequency = 36125000;
398 .name =
"Quantek QT1010",
404 .release = qt1010_release,
408 .set_params = qt1010_set_params,
409 .get_frequency = qt1010_get_frequency,
410 .get_if_frequency = qt1010_get_if_frequency,
427 if (fe->
ops.i2c_gate_ctrl)
428 fe->
ops.i2c_gate_ctrl(fe, 1);
432 if (qt1010_readreg(priv, 0x29, &
id) != 0 || (
id != 0x39)) {
437 if (fe->
ops.i2c_gate_ctrl)
438 fe->
ops.i2c_gate_ctrl(fe, 0);
441 "%s: Quantek QT1010 successfully identified\n",
444 memcpy(&fe->
ops.tuner_ops, &qt1010_tuner_ops,