aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorMichael Krufky <mkrufky@linuxtv.org>2008-04-22 13:41:44 -0400
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-04-24 12:42:14 -0400
commit9ba0a3c0e8147e5c8d04f2b284c44222af517307 (patch)
tree11f42c2537e1e2a23aea116637a7788f659992c6 /drivers
parent3dc5063786b273f1aee545844f6bd4e9651ebffe (diff)
V4L/DVB (7087): tuner-simple: whitespace / comments / codingstyle cleanups
Signed-off-by: Michael Krufky <mkrufky@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/media/video/tuner-simple.c138
1 files changed, 78 insertions, 60 deletions
diff --git a/drivers/media/video/tuner-simple.c b/drivers/media/video/tuner-simple.c
index c1db576696c6..770d6281c154 100644
--- a/drivers/media/video/tuner-simple.c
+++ b/drivers/media/video/tuner-simple.c
@@ -13,15 +13,15 @@
13#include "tuner-i2c.h" 13#include "tuner-i2c.h"
14#include "tuner-simple.h" 14#include "tuner-simple.h"
15 15
16static int debug = 0; 16static int debug;
17module_param(debug, int, 0644); 17module_param(debug, int, 0644);
18MODULE_PARM_DESC(debug, "enable verbose debug messages"); 18MODULE_PARM_DESC(debug, "enable verbose debug messages");
19 19
20#define PREFIX "tuner-simple" 20#define PREFIX "tuner-simple"
21 21
22static int offset = 0; 22static int offset;
23module_param(offset, int, 0664); 23module_param(offset, int, 0664);
24MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner"); 24MODULE_PARM_DESC(offset, "Allows to specify an offset for tuner");
25 25
26/* ---------------------------------------------------------------------- */ 26/* ---------------------------------------------------------------------- */
27 27
@@ -36,8 +36,8 @@ MODULE_PARM_DESC(offset,"Allows to specify an offset for tuner");
36 */ 36 */
37#define TEMIC_SET_PAL_I 0x05 37#define TEMIC_SET_PAL_I 0x05
38#define TEMIC_SET_PAL_DK 0x09 38#define TEMIC_SET_PAL_DK 0x09
39#define TEMIC_SET_PAL_L 0x0a // SECAM ? 39#define TEMIC_SET_PAL_L 0x0a /* SECAM ? */
40#define TEMIC_SET_PAL_L2 0x0b // change IF ! 40#define TEMIC_SET_PAL_L2 0x0b /* change IF ! */
41#define TEMIC_SET_PAL_BG 0x0c 41#define TEMIC_SET_PAL_BG 0x0c
42 42
43/* tv tuner system standard selection for Philips FQ1216ME 43/* tv tuner system standard selection for Philips FQ1216ME
@@ -107,7 +107,7 @@ static int tuner_read_status(struct dvb_frontend *fe)
107 struct tuner_simple_priv *priv = fe->tuner_priv; 107 struct tuner_simple_priv *priv = fe->tuner_priv;
108 unsigned char byte; 108 unsigned char byte;
109 109
110 if (1 != tuner_i2c_xfer_recv(&priv->i2c_props,&byte,1)) 110 if (1 != tuner_i2c_xfer_recv(&priv->i2c_props, &byte, 1))
111 return 0; 111 return 0;
112 112
113 return byte; 113 return byte;
@@ -121,13 +121,13 @@ static inline int tuner_signal(const int status)
121static inline int tuner_stereo(const int type, const int status) 121static inline int tuner_stereo(const int type, const int status)
122{ 122{
123 switch (type) { 123 switch (type) {
124 case TUNER_PHILIPS_FM1216ME_MK3: 124 case TUNER_PHILIPS_FM1216ME_MK3:
125 case TUNER_PHILIPS_FM1236_MK3: 125 case TUNER_PHILIPS_FM1236_MK3:
126 case TUNER_PHILIPS_FM1256_IH3: 126 case TUNER_PHILIPS_FM1256_IH3:
127 case TUNER_LG_NTSC_TAPE: 127 case TUNER_LG_NTSC_TAPE:
128 return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3); 128 return ((status & TUNER_SIGNAL) == TUNER_STEREO_MK3);
129 default: 129 default:
130 return status & TUNER_STEREO; 130 return status & TUNER_STEREO;
131 } 131 }
132} 132}
133 133
@@ -219,9 +219,9 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
219 continue; 219 continue;
220 break; 220 break;
221 } 221 }
222 /* use default tuner_t_params if desired_type not available */ 222 /* use default tuner params if desired_type not available */
223 if (desired_type != tun->params[j].type) { 223 if (desired_type != tun->params[j].type) {
224 tuner_dbg("IFPCoff = %d: tuner_t_params undefined for tuner %d\n", 224 tuner_dbg("IFPCoff = %d: params undefined for tuner %d\n",
225 IFPCoff, priv->type); 225 IFPCoff, priv->type);
226 j = 0; 226 j = 0;
227 } 227 }
@@ -234,7 +234,7 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
234 } 234 }
235 if (i == t_params->count) { 235 if (i == t_params->count) {
236 tuner_dbg("TV frequency out of range (%d > %d)", 236 tuner_dbg("TV frequency out of range (%d > %d)",
237 params->frequency, t_params->ranges[i - 1].limit); 237 params->frequency, t_params->ranges[i - 1].limit);
238 params->frequency = t_params->ranges[--i].limit; 238 params->frequency = t_params->ranges[--i].limit;
239 } 239 }
240 config = t_params->ranges[i].config; 240 config = t_params->ranges[i].config;
@@ -242,24 +242,25 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
242 /* i == 0 -> VHF_LO 242 /* i == 0 -> VHF_LO
243 * i == 1 -> VHF_HI 243 * i == 1 -> VHF_HI
244 * i == 2 -> UHF */ 244 * i == 2 -> UHF */
245 tuner_dbg("tv: param %d, range %d\n",j,i); 245 tuner_dbg("tv: param %d, range %d\n", j, i);
246 246
247 div=params->frequency + IFPCoff + offset; 247 div = params->frequency + IFPCoff + offset;
248 248
249 tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, Offset=%d.%02d MHz, div=%0d\n", 249 tuner_dbg("Freq= %d.%02d MHz, V_IF=%d.%02d MHz, "
250 params->frequency / 16, params->frequency % 16 * 100 / 16, 250 "Offset=%d.%02d MHz, div=%0d\n",
251 IFPCoff / 16, IFPCoff % 16 * 100 / 16, 251 params->frequency / 16, params->frequency % 16 * 100 / 16,
252 offset / 16, offset % 16 * 100 / 16, 252 IFPCoff / 16, IFPCoff % 16 * 100 / 16,
253 div); 253 offset / 16, offset % 16 * 100 / 16, div);
254 254
255 /* tv norm specific stuff for multi-norm tuners */ 255 /* tv norm specific stuff for multi-norm tuners */
256 switch (priv->type) { 256 switch (priv->type) {
257 case TUNER_PHILIPS_SECAM: // FI1216MF 257 case TUNER_PHILIPS_SECAM: /* FI1216MF */
258 /* 0x01 -> ??? no change ??? */ 258 /* 0x01 -> ??? no change ??? */
259 /* 0x02 -> PAL BDGHI / SECAM L */ 259 /* 0x02 -> PAL BDGHI / SECAM L */
260 /* 0x04 -> ??? PAL others / SECAM others ??? */ 260 /* 0x04 -> ??? PAL others / SECAM others ??? */
261 cb &= ~0x03; 261 cb &= ~0x03;
262 if (params->std & V4L2_STD_SECAM_L) //also valid for V4L2_STD_SECAM 262 if (params->std & V4L2_STD_SECAM_L)
263 /* also valid for V4L2_STD_SECAM */
263 cb |= PHILIPS_MF_SET_STD_L; 264 cb |= PHILIPS_MF_SET_STD_L;
264 else if (params->std & V4L2_STD_SECAM_LC) 265 else if (params->std & V4L2_STD_SECAM_LC)
265 cb |= PHILIPS_MF_SET_STD_LC; 266 cb |= PHILIPS_MF_SET_STD_LC;
@@ -333,10 +334,14 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
333 /* set to the correct mode (analog or digital) */ 334 /* set to the correct mode (analog or digital) */
334 tuneraddr = priv->i2c_props.addr; 335 tuneraddr = priv->i2c_props.addr;
335 priv->i2c_props.addr = 0x0a; 336 priv->i2c_props.addr = 0x0a;
336 if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[0],2))) 337 rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[0], 2);
337 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); 338 if (2 != rc)
338 if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,&buffer[2],2))) 339 tuner_warn("i2c i/o error: rc == %d "
339 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); 340 "(should be 2)\n", rc);
341 rc = tuner_i2c_xfer_send(&priv->i2c_props, &buffer[2], 2);
342 if (2 != rc)
343 tuner_warn("i2c i/o error: rc == %d "
344 "(should be 2)\n", rc);
340 priv->i2c_props.addr = tuneraddr; 345 priv->i2c_props.addr = tuneraddr;
341 /* FIXME: input */ 346 /* FIXME: input */
342 break; 347 break;
@@ -357,8 +362,10 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
357 if (t_params->has_tda9887) { 362 if (t_params->has_tda9887) {
358 struct v4l2_priv_tun_config tda9887_cfg; 363 struct v4l2_priv_tun_config tda9887_cfg;
359 int config = 0; 364 int config = 0;
360 int is_secam_l = (params->std & (V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)) && 365 int is_secam_l = (params->std & (V4L2_STD_SECAM_L |
361 !(params->std & ~(V4L2_STD_SECAM_L | V4L2_STD_SECAM_LC)); 366 V4L2_STD_SECAM_LC)) &&
367 !(params->std & ~(V4L2_STD_SECAM_L |
368 V4L2_STD_SECAM_LC));
362 369
363 tda9887_cfg.tuner = TUNER_TDA9887; 370 tda9887_cfg.tuner = TUNER_TDA9887;
364 tda9887_cfg.priv = &config; 371 tda9887_cfg.priv = &config;
@@ -368,8 +375,7 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
368 config |= TDA9887_PORT1_ACTIVE; 375 config |= TDA9887_PORT1_ACTIVE;
369 if (t_params->port2_active ^ t_params->port2_invert_for_secam_lc) 376 if (t_params->port2_active ^ t_params->port2_invert_for_secam_lc)
370 config |= TDA9887_PORT2_ACTIVE; 377 config |= TDA9887_PORT2_ACTIVE;
371 } 378 } else {
372 else {
373 if (t_params->port1_active) 379 if (t_params->port1_active)
374 config |= TDA9887_PORT1_ACTIVE; 380 config |= TDA9887_PORT1_ACTIVE;
375 if (t_params->port2_active) 381 if (t_params->port2_active)
@@ -384,8 +390,7 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
384 config |= TDA9887_TOP(t_params->default_top_secam_mid); 390 config |= TDA9887_TOP(t_params->default_top_secam_mid);
385 else if (t_params->default_top_secam_high) 391 else if (t_params->default_top_secam_high)
386 config |= TDA9887_TOP(t_params->default_top_secam_high); 392 config |= TDA9887_TOP(t_params->default_top_secam_high);
387 } 393 } else {
388 else {
389 if (i == 0 && t_params->default_top_low) 394 if (i == 0 && t_params->default_top_low)
390 config |= TDA9887_TOP(t_params->default_top_low); 395 config |= TDA9887_TOP(t_params->default_top_low);
391 else if (i == 1 && t_params->default_top_mid) 396 else if (i == 1 && t_params->default_top_mid)
@@ -399,10 +404,11 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
399 &tda9887_cfg); 404 &tda9887_cfg);
400 } 405 }
401 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", 406 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
402 buffer[0],buffer[1],buffer[2],buffer[3]); 407 buffer[0], buffer[1], buffer[2], buffer[3]);
403 408
404 if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4))) 409 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
405 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); 410 if (4 != rc)
411 tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc);
406 412
407 switch (priv->type) { 413 switch (priv->type) {
408 case TUNER_LG_TDVS_H06XF: 414 case TUNER_LG_TDVS_H06XF:
@@ -411,23 +417,28 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
411 buffer[0] &= ~0x20; 417 buffer[0] &= ~0x20;
412 buffer[0] |= 0x18; 418 buffer[0] |= 0x18;
413 buffer[1] = 0x20; 419 buffer[1] = 0x20;
414 tuner_dbg("tv 0x%02x 0x%02x\n",buffer[0],buffer[1]); 420 tuner_dbg("tv 0x%02x 0x%02x\n", buffer[0], buffer[1]);
415 421
416 if (2 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,2))) 422 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 2);
417 tuner_warn("i2c i/o error: rc == %d (should be 2)\n",rc); 423 if (2 != rc)
424 tuner_warn("i2c i/o error: rc == %d "
425 "(should be 2)\n", rc);
418 break; 426 break;
419 case TUNER_MICROTUNE_4042FI5: 427 case TUNER_MICROTUNE_4042FI5:
420 { 428 {
421 // FIXME - this may also work for other tuners 429 /* FIXME - this may also work for other tuners */
422 unsigned long timeout = jiffies + msecs_to_jiffies(1); 430 unsigned long timeout = jiffies + msecs_to_jiffies(1);
423 u8 status_byte = 0; 431 u8 status_byte = 0;
424 432
425 /* Wait until the PLL locks */ 433 /* Wait until the PLL locks */
426 for (;;) { 434 for (;;) {
427 if (time_after(jiffies,timeout)) 435 if (time_after(jiffies, timeout))
428 return 0; 436 return 0;
429 if (1 != (rc = tuner_i2c_xfer_recv(&priv->i2c_props,&status_byte,1))) { 437 rc = tuner_i2c_xfer_recv(&priv->i2c_props,
430 tuner_warn("i2c i/o read error: rc == %d (should be 1)\n",rc); 438 &status_byte, 1);
439 if (1 != rc) {
440 tuner_warn("i2c i/o read error: rc == %d "
441 "(should be 1)\n", rc);
431 break; 442 break;
432 } 443 }
433 if (status_byte & TUNER_PLL_LOCKED) 444 if (status_byte & TUNER_PLL_LOCKED)
@@ -442,10 +453,12 @@ static int simple_set_tv_freq(struct dvb_frontend *fe,
442 buffer[2] = config; 453 buffer[2] = config;
443 buffer[3] = cb; 454 buffer[3] = cb;
444 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n", 455 tuner_dbg("tv 0x%02x 0x%02x 0x%02x 0x%02x\n",
445 buffer[0],buffer[1],buffer[2],buffer[3]); 456 buffer[0], buffer[1], buffer[2], buffer[3]);
446 457
447 if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4))) 458 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
448 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); 459 if (4 != rc)
460 tuner_warn("i2c i/o error: rc == %d "
461 "(should be 4)\n", rc);
449 break; 462 break;
450 } 463 }
451 } 464 }
@@ -483,7 +496,8 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
483 freq += (unsigned int)(41.3*16000); 496 freq += (unsigned int)(41.3*16000);
484 break; 497 break;
485 default: 498 default:
486 tuner_warn("Unsupported radio_if value %d\n", t_params->radio_if); 499 tuner_warn("Unsupported radio_if value %d\n",
500 t_params->radio_if);
487 return 0; 501 return 0;
488 } 502 }
489 503
@@ -491,7 +505,8 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
491 switch (priv->type) { 505 switch (priv->type) {
492 case TUNER_TENA_9533_DI: 506 case TUNER_TENA_9533_DI:
493 case TUNER_YMEC_TVF_5533MF: 507 case TUNER_YMEC_TVF_5533MF:
494 tuner_dbg("This tuner doesn't have FM. Most cards have a TEA5767 for FM\n"); 508 tuner_dbg("This tuner doesn't have FM. "
509 "Most cards have a TEA5767 for FM\n");
495 return 0; 510 return 0;
496 case TUNER_PHILIPS_FM1216ME_MK3: 511 case TUNER_PHILIPS_FM1216ME_MK3:
497 case TUNER_PHILIPS_FM1236_MK3: 512 case TUNER_PHILIPS_FM1236_MK3:
@@ -534,7 +549,7 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
534 } 549 }
535 550
536 tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n", 551 tuner_dbg("radio 0x%02x 0x%02x 0x%02x 0x%02x\n",
537 buffer[0],buffer[1],buffer[2],buffer[3]); 552 buffer[0], buffer[1], buffer[2], buffer[3]);
538 priv->last_div = div; 553 priv->last_div = div;
539 554
540 if (t_params->has_tda9887) { 555 if (t_params->has_tda9887) {
@@ -544,9 +559,11 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
544 tda9887_cfg.tuner = TUNER_TDA9887; 559 tda9887_cfg.tuner = TUNER_TDA9887;
545 tda9887_cfg.priv = &config; 560 tda9887_cfg.priv = &config;
546 561
547 if (t_params->port1_active && !t_params->port1_fm_high_sensitivity) 562 if (t_params->port1_active &&
563 !t_params->port1_fm_high_sensitivity)
548 config |= TDA9887_PORT1_ACTIVE; 564 config |= TDA9887_PORT1_ACTIVE;
549 if (t_params->port2_active && !t_params->port2_fm_high_sensitivity) 565 if (t_params->port2_active &&
566 !t_params->port2_fm_high_sensitivity)
550 config |= TDA9887_PORT2_ACTIVE; 567 config |= TDA9887_PORT2_ACTIVE;
551 if (t_params->intercarrier_mode) 568 if (t_params->intercarrier_mode)
552 config |= TDA9887_INTERCARRIER; 569 config |= TDA9887_INTERCARRIER;
@@ -557,10 +574,11 @@ static int simple_set_radio_freq(struct dvb_frontend *fe,
557 if (t_params->radio_if == 2) 574 if (t_params->radio_if == 2)
558 config |= TDA9887_RIF_41_3; 575 config |= TDA9887_RIF_41_3;
559 i2c_clients_command(priv->i2c_props.adap, TUNER_SET_CONFIG, 576 i2c_clients_command(priv->i2c_props.adap, TUNER_SET_CONFIG,
560 &tda9887_cfg); 577 &tda9887_cfg);
561 } 578 }
562 if (4 != (rc = tuner_i2c_xfer_send(&priv->i2c_props,buffer,4))) 579 rc = tuner_i2c_xfer_send(&priv->i2c_props, buffer, 4);
563 tuner_warn("i2c i/o error: rc == %d (should be 4)\n",rc); 580 if (4 != rc)
581 tuner_warn("i2c i/o error: rc == %d (should be 4)\n", rc);
564 582
565 return 0; 583 return 0;
566} 584}
@@ -627,16 +645,16 @@ struct dvb_frontend *simple_tuner_attach(struct dvb_frontend *fe,
627 priv->type = cfg->type; 645 priv->type = cfg->type;
628 priv->tun = cfg->tun; 646 priv->tun = cfg->tun;
629 647
630 memcpy(&fe->ops.tuner_ops, &simple_tuner_ops, sizeof(struct dvb_tuner_ops)); 648 memcpy(&fe->ops.tuner_ops, &simple_tuner_ops,
649 sizeof(struct dvb_tuner_ops));
631 650
632 tuner_info("type set to %d (%s)\n", cfg->type, cfg->tun->name); 651 tuner_info("type set to %d (%s)\n", cfg->type, cfg->tun->name);
633 652
634 strlcpy(fe->ops.tuner_ops.info.name, cfg->tun->name, sizeof(fe->ops.tuner_ops.info.name)); 653 strlcpy(fe->ops.tuner_ops.info.name, cfg->tun->name,
654 sizeof(fe->ops.tuner_ops.info.name));
635 655
636 return fe; 656 return fe;
637} 657}
638
639
640EXPORT_SYMBOL_GPL(simple_tuner_attach); 658EXPORT_SYMBOL_GPL(simple_tuner_attach);
641 659
642MODULE_DESCRIPTION("Simple 4-control-bytes style tuner driver"); 660MODULE_DESCRIPTION("Simple 4-control-bytes style tuner driver");