Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

V4L/DVB (12269): af9013: auto-detect parameters in case of garbage given by app

Request demodulator auto-detect transmission parameters in case of
garbage parameters provided by application for compatibility.
That's needed at least for MPlayer compatibility currently.

Thanks to Jelle de Jong for reporting issue and providing SSH access to
Devin for debugging.

Thanks to Devin Heitmueller for hard debug work he did to find that bug.

Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
Cc: Jelle de Jong <jelledejong@powercraft.nl>
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

authored by

Antti Palosaari and committed by
Mauro Carvalho Chehab
a2f5a811 27954930

+18 -7
+18 -7
drivers/media/dvb/frontends/af9013.c
··· 527 527 u8 i, buf[3] = {0, 0, 0}; 528 528 *auto_mode = 0; /* set if parameters are requested to auto set */ 529 529 530 + /* Try auto-detect transmission parameters in case of AUTO requested or 531 + garbage parameters given by application for compatibility. 532 + MPlayer seems to provide garbage parameters currently. */ 533 + 530 534 switch (params->transmission_mode) { 531 535 case TRANSMISSION_MODE_AUTO: 532 536 *auto_mode = 1; ··· 540 536 buf[0] |= (1 << 0); 541 537 break; 542 538 default: 543 - return -EINVAL; 539 + deb_info("%s: invalid transmission_mode\n", __func__); 540 + *auto_mode = 1; 544 541 } 545 542 546 543 switch (params->guard_interval) { ··· 559 554 buf[0] |= (3 << 2); 560 555 break; 561 556 default: 562 - return -EINVAL; 557 + deb_info("%s: invalid guard_interval\n", __func__); 558 + *auto_mode = 1; 563 559 } 564 560 565 561 switch (params->hierarchy_information) { ··· 578 572 buf[0] |= (3 << 4); 579 573 break; 580 574 default: 581 - return -EINVAL; 575 + deb_info("%s: invalid hierarchy_information\n", __func__); 576 + *auto_mode = 1; 582 577 }; 583 578 584 579 switch (params->constellation) { ··· 594 587 buf[1] |= (2 << 6); 595 588 break; 596 589 default: 597 - return -EINVAL; 590 + deb_info("%s: invalid constellation\n", __func__); 591 + *auto_mode = 1; 598 592 } 599 593 600 594 /* Use HP. How and which case we can switch to LP? */ ··· 619 611 buf[2] |= (4 << 0); 620 612 break; 621 613 default: 622 - return -EINVAL; 614 + deb_info("%s: invalid code_rate_HP\n", __func__); 615 + *auto_mode = 1; 623 616 } 624 617 625 618 switch (params->code_rate_LP) { ··· 647 638 if (params->hierarchy_information == HIERARCHY_AUTO) 648 639 break; 649 640 default: 650 - return -EINVAL; 641 + deb_info("%s: invalid code_rate_LP\n", __func__); 642 + *auto_mode = 1; 651 643 } 652 644 653 645 switch (params->bandwidth) { ··· 661 651 buf[1] |= (2 << 2); 662 652 break; 663 653 default: 664 - return -EINVAL; 654 + deb_info("%s: invalid bandwidth\n", __func__); 655 + buf[1] |= (2 << 2); /* cannot auto-detect BW, try 8 MHz */ 665 656 } 666 657 667 658 /* program */