aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/media/tuners/fc2580.c61
1 files changed, 35 insertions, 26 deletions
diff --git a/drivers/media/tuners/fc2580.c b/drivers/media/tuners/fc2580.c
index aff39ae457a0..81f38aae9c66 100644
--- a/drivers/media/tuners/fc2580.c
+++ b/drivers/media/tuners/fc2580.c
@@ -35,8 +35,6 @@
35 * Currently it blind writes bunch of static registers from the 35 * Currently it blind writes bunch of static registers from the
36 * fc2580_freq_regs_lut[] when fc2580_set_params() is called. Add some 36 * fc2580_freq_regs_lut[] when fc2580_set_params() is called. Add some
37 * logic to reduce unneeded register writes. 37 * logic to reduce unneeded register writes.
38 * There is also don't-care registers, initialized with value 0xff, and those
39 * are also written to the chip currently (yes, not wise).
40 */ 38 */
41 39
42/* write multiple registers */ 40/* write multiple registers */
@@ -111,6 +109,17 @@ static int fc2580_rd_reg(struct fc2580_priv *priv, u8 reg, u8 *val)
111 return fc2580_rd_regs(priv, reg, val, 1); 109 return fc2580_rd_regs(priv, reg, val, 1);
112} 110}
113 111
112/* write single register conditionally only when value differs from 0xff
113 * XXX: This is special routine meant only for writing fc2580_freq_regs_lut[]
114 * values. Do not use for the other purposes. */
115static int fc2580_wr_reg_ff(struct fc2580_priv *priv, u8 reg, u8 val)
116{
117 if (val == 0xff)
118 return 0;
119 else
120 return fc2580_wr_regs(priv, reg, &val, 1);
121}
122
114static int fc2580_set_params(struct dvb_frontend *fe) 123static int fc2580_set_params(struct dvb_frontend *fe)
115{ 124{
116 struct fc2580_priv *priv = fe->tuner_priv; 125 struct fc2580_priv *priv = fe->tuner_priv;
@@ -213,99 +222,99 @@ static int fc2580_set_params(struct dvb_frontend *fe)
213 if (i == ARRAY_SIZE(fc2580_freq_regs_lut)) 222 if (i == ARRAY_SIZE(fc2580_freq_regs_lut))
214 goto err; 223 goto err;
215 224
216 ret = fc2580_wr_reg(priv, 0x25, fc2580_freq_regs_lut[i].r25_val); 225 ret = fc2580_wr_reg_ff(priv, 0x25, fc2580_freq_regs_lut[i].r25_val);
217 if (ret < 0) 226 if (ret < 0)
218 goto err; 227 goto err;
219 228
220 ret = fc2580_wr_reg(priv, 0x27, fc2580_freq_regs_lut[i].r27_val); 229 ret = fc2580_wr_reg_ff(priv, 0x27, fc2580_freq_regs_lut[i].r27_val);
221 if (ret < 0) 230 if (ret < 0)
222 goto err; 231 goto err;
223 232
224 ret = fc2580_wr_reg(priv, 0x28, fc2580_freq_regs_lut[i].r28_val); 233 ret = fc2580_wr_reg_ff(priv, 0x28, fc2580_freq_regs_lut[i].r28_val);
225 if (ret < 0) 234 if (ret < 0)
226 goto err; 235 goto err;
227 236
228 ret = fc2580_wr_reg(priv, 0x29, fc2580_freq_regs_lut[i].r29_val); 237 ret = fc2580_wr_reg_ff(priv, 0x29, fc2580_freq_regs_lut[i].r29_val);
229 if (ret < 0) 238 if (ret < 0)
230 goto err; 239 goto err;
231 240
232 ret = fc2580_wr_reg(priv, 0x2b, fc2580_freq_regs_lut[i].r2b_val); 241 ret = fc2580_wr_reg_ff(priv, 0x2b, fc2580_freq_regs_lut[i].r2b_val);
233 if (ret < 0) 242 if (ret < 0)
234 goto err; 243 goto err;
235 244
236 ret = fc2580_wr_reg(priv, 0x2c, fc2580_freq_regs_lut[i].r2c_val); 245 ret = fc2580_wr_reg_ff(priv, 0x2c, fc2580_freq_regs_lut[i].r2c_val);
237 if (ret < 0) 246 if (ret < 0)
238 goto err; 247 goto err;
239 248
240 ret = fc2580_wr_reg(priv, 0x2d, fc2580_freq_regs_lut[i].r2d_val); 249 ret = fc2580_wr_reg_ff(priv, 0x2d, fc2580_freq_regs_lut[i].r2d_val);
241 if (ret < 0) 250 if (ret < 0)
242 goto err; 251 goto err;
243 252
244 ret = fc2580_wr_reg(priv, 0x30, fc2580_freq_regs_lut[i].r30_val); 253 ret = fc2580_wr_reg_ff(priv, 0x30, fc2580_freq_regs_lut[i].r30_val);
245 if (ret < 0) 254 if (ret < 0)
246 goto err; 255 goto err;
247 256
248 ret = fc2580_wr_reg(priv, 0x44, fc2580_freq_regs_lut[i].r44_val); 257 ret = fc2580_wr_reg_ff(priv, 0x44, fc2580_freq_regs_lut[i].r44_val);
249 if (ret < 0) 258 if (ret < 0)
250 goto err; 259 goto err;
251 260
252 ret = fc2580_wr_reg(priv, 0x50, fc2580_freq_regs_lut[i].r50_val); 261 ret = fc2580_wr_reg_ff(priv, 0x50, fc2580_freq_regs_lut[i].r50_val);
253 if (ret < 0) 262 if (ret < 0)
254 goto err; 263 goto err;
255 264
256 ret = fc2580_wr_reg(priv, 0x53, fc2580_freq_regs_lut[i].r53_val); 265 ret = fc2580_wr_reg_ff(priv, 0x53, fc2580_freq_regs_lut[i].r53_val);
257 if (ret < 0) 266 if (ret < 0)
258 goto err; 267 goto err;
259 268
260 ret = fc2580_wr_reg(priv, 0x5f, fc2580_freq_regs_lut[i].r5f_val); 269 ret = fc2580_wr_reg_ff(priv, 0x5f, fc2580_freq_regs_lut[i].r5f_val);
261 if (ret < 0) 270 if (ret < 0)
262 goto err; 271 goto err;
263 272
264 ret = fc2580_wr_reg(priv, 0x61, fc2580_freq_regs_lut[i].r61_val); 273 ret = fc2580_wr_reg_ff(priv, 0x61, fc2580_freq_regs_lut[i].r61_val);
265 if (ret < 0) 274 if (ret < 0)
266 goto err; 275 goto err;
267 276
268 ret = fc2580_wr_reg(priv, 0x62, fc2580_freq_regs_lut[i].r62_val); 277 ret = fc2580_wr_reg_ff(priv, 0x62, fc2580_freq_regs_lut[i].r62_val);
269 if (ret < 0) 278 if (ret < 0)
270 goto err; 279 goto err;
271 280
272 ret = fc2580_wr_reg(priv, 0x63, fc2580_freq_regs_lut[i].r63_val); 281 ret = fc2580_wr_reg_ff(priv, 0x63, fc2580_freq_regs_lut[i].r63_val);
273 if (ret < 0) 282 if (ret < 0)
274 goto err; 283 goto err;
275 284
276 ret = fc2580_wr_reg(priv, 0x67, fc2580_freq_regs_lut[i].r67_val); 285 ret = fc2580_wr_reg_ff(priv, 0x67, fc2580_freq_regs_lut[i].r67_val);
277 if (ret < 0) 286 if (ret < 0)
278 goto err; 287 goto err;
279 288
280 ret = fc2580_wr_reg(priv, 0x68, fc2580_freq_regs_lut[i].r68_val); 289 ret = fc2580_wr_reg_ff(priv, 0x68, fc2580_freq_regs_lut[i].r68_val);
281 if (ret < 0) 290 if (ret < 0)
282 goto err; 291 goto err;
283 292
284 ret = fc2580_wr_reg(priv, 0x69, fc2580_freq_regs_lut[i].r69_val); 293 ret = fc2580_wr_reg_ff(priv, 0x69, fc2580_freq_regs_lut[i].r69_val);
285 if (ret < 0) 294 if (ret < 0)
286 goto err; 295 goto err;
287 296
288 ret = fc2580_wr_reg(priv, 0x6a, fc2580_freq_regs_lut[i].r6a_val); 297 ret = fc2580_wr_reg_ff(priv, 0x6a, fc2580_freq_regs_lut[i].r6a_val);
289 if (ret < 0) 298 if (ret < 0)
290 goto err; 299 goto err;
291 300
292 ret = fc2580_wr_reg(priv, 0x6b, fc2580_freq_regs_lut[i].r6b_val); 301 ret = fc2580_wr_reg_ff(priv, 0x6b, fc2580_freq_regs_lut[i].r6b_val);
293 if (ret < 0) 302 if (ret < 0)
294 goto err; 303 goto err;
295 304
296 ret = fc2580_wr_reg(priv, 0x6c, fc2580_freq_regs_lut[i].r6c_val); 305 ret = fc2580_wr_reg_ff(priv, 0x6c, fc2580_freq_regs_lut[i].r6c_val);
297 if (ret < 0) 306 if (ret < 0)
298 goto err; 307 goto err;
299 308
300 ret = fc2580_wr_reg(priv, 0x6d, fc2580_freq_regs_lut[i].r6d_val); 309 ret = fc2580_wr_reg_ff(priv, 0x6d, fc2580_freq_regs_lut[i].r6d_val);
301 if (ret < 0) 310 if (ret < 0)
302 goto err; 311 goto err;
303 312
304 ret = fc2580_wr_reg(priv, 0x6e, fc2580_freq_regs_lut[i].r6e_val); 313 ret = fc2580_wr_reg_ff(priv, 0x6e, fc2580_freq_regs_lut[i].r6e_val);
305 if (ret < 0) 314 if (ret < 0)
306 goto err; 315 goto err;
307 316
308 ret = fc2580_wr_reg(priv, 0x6f, fc2580_freq_regs_lut[i].r6f_val); 317 ret = fc2580_wr_reg_ff(priv, 0x6f, fc2580_freq_regs_lut[i].r6f_val);
309 if (ret < 0) 318 if (ret < 0)
310 goto err; 319 goto err;
311 320