diff options
-rw-r--r-- | drivers/media/video/tuner-core.c | 92 |
1 files changed, 46 insertions, 46 deletions
diff --git a/drivers/media/video/tuner-core.c b/drivers/media/video/tuner-core.c index 529e00952a8d..2b72e10e6b9f 100644 --- a/drivers/media/video/tuner-core.c +++ b/drivers/media/video/tuner-core.c | |||
@@ -369,19 +369,13 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
369 | break; | 369 | break; |
370 | } | 370 | } |
371 | case TUNER_TEA5767: | 371 | case TUNER_TEA5767: |
372 | if (tea5767_attach(&t->fe, t->i2c->adapter, t->i2c->addr) == NULL) { | 372 | if (!tea5767_attach(&t->fe, t->i2c->adapter, t->i2c->addr)) |
373 | t->type = TUNER_ABSENT; | 373 | goto attach_failed; |
374 | t->mode_mask = T_UNINITIALIZED; | ||
375 | return; | ||
376 | } | ||
377 | t->mode_mask = T_RADIO; | 374 | t->mode_mask = T_RADIO; |
378 | break; | 375 | break; |
379 | case TUNER_TEA5761: | 376 | case TUNER_TEA5761: |
380 | if (tea5761_attach(&t->fe, t->i2c->adapter, t->i2c->addr) == NULL) { | 377 | if (!tea5761_attach(&t->fe, t->i2c->adapter, t->i2c->addr)) |
381 | t->type = TUNER_ABSENT; | 378 | goto attach_failed; |
382 | t->mode_mask = T_UNINITIALIZED; | ||
383 | return; | ||
384 | } | ||
385 | t->mode_mask = T_RADIO; | 379 | t->mode_mask = T_RADIO; |
386 | break; | 380 | break; |
387 | case TUNER_PHILIPS_FMD1216ME_MK3: | 381 | case TUNER_PHILIPS_FMD1216ME_MK3: |
@@ -394,12 +388,9 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
394 | buffer[2] = 0x86; | 388 | buffer[2] = 0x86; |
395 | buffer[3] = 0x54; | 389 | buffer[3] = 0x54; |
396 | i2c_master_send(c, buffer, 4); | 390 | i2c_master_send(c, buffer, 4); |
397 | if (simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, | 391 | if (!simple_tuner_attach(&t->fe, t->i2c->adapter, t->i2c->addr, |
398 | t->type) == NULL) { | 392 | t->type)) |
399 | t->type = TUNER_ABSENT; | 393 | goto attach_failed; |
400 | t->mode_mask = T_UNINITIALIZED; | ||
401 | return; | ||
402 | } | ||
403 | break; | 394 | break; |
404 | case TUNER_PHILIPS_TD1316: | 395 | case TUNER_PHILIPS_TD1316: |
405 | buffer[0] = 0x0b; | 396 | buffer[0] = 0x0b; |
@@ -407,12 +398,9 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
407 | buffer[2] = 0x86; | 398 | buffer[2] = 0x86; |
408 | buffer[3] = 0xa4; | 399 | buffer[3] = 0xa4; |
409 | i2c_master_send(c,buffer,4); | 400 | i2c_master_send(c,buffer,4); |
410 | if (simple_tuner_attach(&t->fe, t->i2c->adapter, | 401 | if (!simple_tuner_attach(&t->fe, t->i2c->adapter, |
411 | t->i2c->addr, t->type) == NULL) { | 402 | t->i2c->addr, t->type)) |
412 | t->type = TUNER_ABSENT; | 403 | goto attach_failed; |
413 | t->mode_mask = T_UNINITIALIZED; | ||
414 | return; | ||
415 | } | ||
416 | break; | 404 | break; |
417 | case TUNER_XC2028: | 405 | case TUNER_XC2028: |
418 | { | 406 | { |
@@ -421,40 +409,34 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
421 | .i2c_addr = t->i2c->addr, | 409 | .i2c_addr = t->i2c->addr, |
422 | .callback = t->tuner_callback, | 410 | .callback = t->tuner_callback, |
423 | }; | 411 | }; |
424 | if (!xc2028_attach(&t->fe, &cfg)) { | 412 | if (!xc2028_attach(&t->fe, &cfg)) |
425 | t->type = TUNER_ABSENT; | 413 | goto attach_failed; |
426 | t->mode_mask = T_UNINITIALIZED; | ||
427 | return; | ||
428 | } | ||
429 | break; | 414 | break; |
430 | } | 415 | } |
431 | case TUNER_TDA9887: | 416 | case TUNER_TDA9887: |
432 | tda9887_attach(&t->fe, t->i2c->adapter, t->i2c->addr); | 417 | tda9887_attach(&t->fe, t->i2c->adapter, t->i2c->addr); |
433 | break; | 418 | break; |
434 | case TUNER_XC5000: | 419 | case TUNER_XC5000: |
420 | { | ||
421 | struct dvb_tuner_ops *xc_tuner_ops; | ||
422 | |||
435 | xc5000_cfg.i2c_address = t->i2c->addr; | 423 | xc5000_cfg.i2c_address = t->i2c->addr; |
436 | xc5000_cfg.if_khz = 5380; | 424 | xc5000_cfg.if_khz = 5380; |
437 | xc5000_cfg.priv = c->adapter->algo_data; | 425 | xc5000_cfg.priv = c->adapter->algo_data; |
438 | xc5000_cfg.tuner_callback = t->tuner_callback; | 426 | xc5000_cfg.tuner_callback = t->tuner_callback; |
439 | if (!xc5000_attach(&t->fe, t->i2c->adapter, &xc5000_cfg)) { | 427 | if (!xc5000_attach(&t->fe, t->i2c->adapter, &xc5000_cfg)) |
440 | t->type = TUNER_ABSENT; | 428 | goto attach_failed; |
441 | t->mode_mask = T_UNINITIALIZED; | 429 | |
442 | return; | ||
443 | } | ||
444 | { | ||
445 | struct dvb_tuner_ops *xc_tuner_ops; | ||
446 | xc_tuner_ops = &t->fe.ops.tuner_ops; | 430 | xc_tuner_ops = &t->fe.ops.tuner_ops; |
447 | if(xc_tuner_ops->init != NULL) | 431 | if (xc_tuner_ops->init) |
448 | xc_tuner_ops->init(&t->fe); | 432 | xc_tuner_ops->init(&t->fe); |
449 | } | ||
450 | break; | 433 | break; |
434 | } | ||
451 | default: | 435 | default: |
452 | if (simple_tuner_attach(&t->fe, t->i2c->adapter, | 436 | if (!simple_tuner_attach(&t->fe, t->i2c->adapter, |
453 | t->i2c->addr, t->type) == NULL) { | 437 | t->i2c->addr, t->type)) |
454 | t->type = TUNER_ABSENT; | 438 | goto attach_failed; |
455 | t->mode_mask = T_UNINITIALIZED; | 439 | |
456 | return; | ||
457 | } | ||
458 | break; | 440 | break; |
459 | } | 441 | } |
460 | 442 | ||
@@ -476,11 +458,27 @@ static void set_type(struct i2c_client *c, unsigned int type, | |||
476 | if (t->mode_mask == T_UNINITIALIZED) | 458 | if (t->mode_mask == T_UNINITIALIZED) |
477 | t->mode_mask = new_mode_mask; | 459 | t->mode_mask = new_mode_mask; |
478 | 460 | ||
479 | set_freq(c, (V4L2_TUNER_RADIO == t->mode) ? t->radio_freq : t->tv_freq); | 461 | /* xc2028/3028 and xc5000 requires a firmware to be set-up later |
462 | trying to set a frequency here will just fail | ||
463 | FIXME: better to move set_freq to the tuner code. This is needed | ||
464 | on analog tuners for PLL to properly work | ||
465 | */ | ||
466 | if (t->type != TUNER_XC2028 && t->type != TUNER_XC5000) | ||
467 | set_freq(c, (V4L2_TUNER_RADIO == t->mode) ? | ||
468 | t->radio_freq : t->tv_freq); | ||
469 | |||
480 | tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n", | 470 | tuner_dbg("%s %s I2C addr 0x%02x with type %d used for 0x%02x\n", |
481 | c->adapter->name, c->driver->driver.name, c->addr << 1, type, | 471 | c->adapter->name, c->driver->driver.name, c->addr << 1, type, |
482 | t->mode_mask); | 472 | t->mode_mask); |
483 | tuner_i2c_address_check(t); | 473 | tuner_i2c_address_check(t); |
474 | return; | ||
475 | |||
476 | attach_failed: | ||
477 | tuner_dbg("Tuner attach for type = %d failed.\n", t->type); | ||
478 | t->type = TUNER_ABSENT; | ||
479 | t->mode_mask = T_UNINITIALIZED; | ||
480 | |||
481 | return; | ||
484 | } | 482 | } |
485 | 483 | ||
486 | /* | 484 | /* |
@@ -495,14 +493,16 @@ static void set_addr(struct i2c_client *c, struct tuner_setup *tun_setup) | |||
495 | { | 493 | { |
496 | struct tuner *t = i2c_get_clientdata(c); | 494 | struct tuner *t = i2c_get_clientdata(c); |
497 | 495 | ||
498 | tuner_dbg("set addr for type %i\n", t->type); | ||
499 | |||
500 | if ( (t->type == UNSET && ((tun_setup->addr == ADDR_UNSET) && | 496 | if ( (t->type == UNSET && ((tun_setup->addr == ADDR_UNSET) && |
501 | (t->mode_mask & tun_setup->mode_mask))) || | 497 | (t->mode_mask & tun_setup->mode_mask))) || |
502 | (tun_setup->addr == c->addr)) { | 498 | (tun_setup->addr == c->addr)) { |
503 | set_type(c, tun_setup->type, tun_setup->mode_mask, | 499 | set_type(c, tun_setup->type, tun_setup->mode_mask, |
504 | tun_setup->config, tun_setup->tuner_callback); | 500 | tun_setup->config, tun_setup->tuner_callback); |
505 | } | 501 | } else |
502 | tuner_dbg("set addr discarded for type %i, mask %x. " | ||
503 | "Asked to change tuner at addr 0x%02x, with mask %x\n", | ||
504 | t->type, t->mode_mask, | ||
505 | tun_setup->addr, tun_setup->mode_mask); | ||
506 | } | 506 | } |
507 | 507 | ||
508 | static inline int check_mode(struct tuner *t, char *cmd) | 508 | static inline int check_mode(struct tuner *t, char *cmd) |