diff options
author | Mauro Carvalho Chehab <mchehab@redhat.com> | 2011-07-21 02:02:16 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-01-04 19:19:44 -0500 |
commit | e930b3a03e28b3ac8d936eee431e58052e6cf26c (patch) | |
tree | a531228fcaa37ef18d250bd87212d028fcf366cd /drivers/media/common | |
parent | e1de3d18d4838db333f8278e812c053cb039740a (diff) |
[media] mt2063: Simplify some functions
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/common')
-rw-r--r-- | drivers/media/common/tuners/mt2063.c | 150 |
1 files changed, 12 insertions, 138 deletions
diff --git a/drivers/media/common/tuners/mt2063.c b/drivers/media/common/tuners/mt2063.c index 0ae6c1544771..10116356f304 100644 --- a/drivers/media/common/tuners/mt2063.c +++ b/drivers/media/common/tuners/mt2063.c | |||
@@ -75,7 +75,6 @@ struct MT2063_ExclZone_t { | |||
75 | * Structure of data needed for Spur Avoidance | 75 | * Structure of data needed for Spur Avoidance |
76 | */ | 76 | */ |
77 | struct MT2063_AvoidSpursData_t { | 77 | struct MT2063_AvoidSpursData_t { |
78 | u32 nAS_Algorithm; | ||
79 | u32 f_ref; | 78 | u32 f_ref; |
80 | u32 f_in; | 79 | u32 f_in; |
81 | u32 f_LO1; | 80 | u32 f_LO1; |
@@ -410,7 +409,6 @@ struct mt2063_state { | |||
410 | static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info, | 409 | static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info, |
411 | u32 f_min, u32 f_max); | 410 | u32 f_min, u32 f_max); |
412 | static u32 MT2063_ReInit(struct mt2063_state *state); | 411 | static u32 MT2063_ReInit(struct mt2063_state *state); |
413 | static u32 MT2063_Close(struct mt2063_state *state); | ||
414 | static u32 MT2063_GetReg(struct mt2063_state *state, u8 reg, u8 * val); | 412 | static u32 MT2063_GetReg(struct mt2063_state *state, u8 reg, u8 * val); |
415 | static u32 MT2063_GetParam(struct mt2063_state *state, enum MT2063_Param param, u32 * pValue); | 413 | static u32 MT2063_GetParam(struct mt2063_state *state, enum MT2063_Param param, u32 * pValue); |
416 | static u32 MT2063_SetReg(struct mt2063_state *state, u8 reg, u8 val); | 414 | static u32 MT2063_SetReg(struct mt2063_state *state, u8 reg, u8 val); |
@@ -606,29 +604,9 @@ static u32 mt2063_read(struct mt2063_state *state, | |||
606 | return (status); | 604 | return (status); |
607 | } | 605 | } |
608 | 606 | ||
609 | /***************************************************************************** | 607 | /* |
610 | ** | 608 | * FIXME: Is this really needed? |
611 | ** Name: MT_Sleep | 609 | */ |
612 | ** | ||
613 | ** Description: Delay execution for "nMinDelayTime" milliseconds | ||
614 | ** | ||
615 | ** Parameters: hUserData - User-specific I/O parameter that was | ||
616 | ** passed to tuner's Open function. | ||
617 | ** nMinDelayTime - Delay time in milliseconds | ||
618 | ** | ||
619 | ** Returns: None. | ||
620 | ** | ||
621 | ** Notes: This is a callback function that is called from the | ||
622 | ** the tuning algorithm. You MUST provide code that | ||
623 | ** blocks execution for the specified period of time. | ||
624 | ** | ||
625 | ** Revision History: | ||
626 | ** | ||
627 | ** SCR Date Author Description | ||
628 | ** ------------------------------------------------------------------------- | ||
629 | ** N/A 03-25-2004 DAD Original | ||
630 | ** | ||
631 | *****************************************************************************/ | ||
632 | static int MT2063_Sleep(struct dvb_frontend *fe) | 610 | static int MT2063_Sleep(struct dvb_frontend *fe) |
633 | { | 611 | { |
634 | /* | 612 | /* |
@@ -640,78 +618,19 @@ static int MT2063_Sleep(struct dvb_frontend *fe) | |||
640 | return 0; | 618 | return 0; |
641 | } | 619 | } |
642 | 620 | ||
643 | //end of mt2063_userdef.c | 621 | /* |
644 | //================================================================= | 622 | * Microtune spur avoidance |
645 | //################################################################# | 623 | */ |
646 | //================================================================= | ||
647 | |||
648 | //context of mt2063_spuravoid.c <Henry> ====================================== | ||
649 | //################################################################# | ||
650 | //================================================================= | ||
651 | |||
652 | /***************************************************************************** | ||
653 | ** | ||
654 | ** Name: mt_spuravoid.c | ||
655 | ** | ||
656 | ** Description: Microtune spur avoidance software module. | ||
657 | ** Supports Microtune tuner drivers. | ||
658 | ** | ||
659 | ** CVS ID: $Id: mt_spuravoid.c,v 1.3 2008/06/26 15:39:52 software Exp $ | ||
660 | ** CVS Source: $Source: /export/home/cvsroot/software/tuners/MT2063/mt_spuravoid.c,v $ | ||
661 | ** | ||
662 | ** Revision History: | ||
663 | ** | ||
664 | ** SCR Date Author Description | ||
665 | ** ------------------------------------------------------------------------- | ||
666 | ** 082 03-25-2005 JWS Original multi-tuner support - requires | ||
667 | ** MTxxxx_CNT declarations | ||
668 | ** 096 04-06-2005 DAD Ver 1.11: Fix divide by 0 error if maxH==0. | ||
669 | ** 094 04-06-2005 JWS Ver 1.11 Added uceil and ufloor to get rid | ||
670 | ** of compiler warnings | ||
671 | ** N/A 04-07-2005 DAD Ver 1.13: Merged single- and multi-tuner spur | ||
672 | ** avoidance into a single module. | ||
673 | ** 103 01-31-2005 DAD Ver 1.14: In MT_AddExclZone(), if the range | ||
674 | ** (f_min, f_max) < 0, ignore the entry. | ||
675 | ** 115 03-23-2007 DAD Fix declaration of spur due to truncation | ||
676 | ** errors. | ||
677 | ** 117 03-29-2007 RSK Ver 1.15: Re-wrote to match search order from | ||
678 | ** tuner DLL. | ||
679 | ** 137 06-18-2007 DAD Ver 1.16: Fix possible divide-by-0 error for | ||
680 | ** multi-tuners that have | ||
681 | ** (delta IF1) > (f_out-f_outbw/2). | ||
682 | ** 147 07-27-2007 RSK Ver 1.17: Corrected calculation (-) to (+) | ||
683 | ** Added logic to force f_Center within 1/2 f_Step. | ||
684 | ** 177 S 02-26-2008 RSK Ver 1.18: Corrected calculation using LO1 > MAX/2 | ||
685 | ** Type casts added to preserve correct sign. | ||
686 | ** N/A I 06-17-2008 RSK Ver 1.19: Refactoring avoidance of DECT | ||
687 | ** frequencies into MT_ResetExclZones(). | ||
688 | ** N/A I 06-20-2008 RSK Ver 1.21: New VERSION number for ver checking. | ||
689 | ** | ||
690 | *****************************************************************************/ | ||
691 | |||
692 | 624 | ||
693 | /* Implement ceiling, floor functions. */ | 625 | /* Implement ceiling, floor functions. */ |
694 | #define ceil(n, d) (((n) < 0) ? (-((-(n))/(d))) : (n)/(d) + ((n)%(d) != 0)) | 626 | #define ceil(n, d) (((n) < 0) ? (-((-(n))/(d))) : (n)/(d) + ((n)%(d) != 0)) |
695 | #define uceil(n, d) ((n)/(d) + ((n)%(d) != 0)) | ||
696 | #define floor(n, d) (((n) < 0) ? (-((-(n))/(d))) - ((n)%(d) != 0) : (n)/(d)) | 627 | #define floor(n, d) (((n) < 0) ? (-((-(n))/(d))) - ((n)%(d) != 0) : (n)/(d)) |
697 | #define ufloor(n, d) ((n)/(d)) | ||
698 | 628 | ||
699 | struct MT2063_FIFZone_t { | 629 | struct MT2063_FIFZone_t { |
700 | s32 min_; | 630 | s32 min_; |
701 | s32 max_; | 631 | s32 max_; |
702 | }; | 632 | }; |
703 | 633 | ||
704 | |||
705 | static u32 MT2063_RegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info) | ||
706 | { | ||
707 | pAS_Info->nAS_Algorithm = 1; | ||
708 | return 0; | ||
709 | } | ||
710 | |||
711 | static void MT2063_UnRegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info) | ||
712 | { | ||
713 | } | ||
714 | |||
715 | /* | 634 | /* |
716 | ** Reset all exclusion zones. | 635 | ** Reset all exclusion zones. |
717 | ** Add zones to protect the PLL FracN regions near zero | 636 | ** Add zones to protect the PLL FracN regions near zero |
@@ -1153,7 +1072,7 @@ static u32 IsSpurInBand(struct MT2063_AvoidSpursData_t *pAS_Info, | |||
1153 | gf_Scale = MT2063_umax((u32) MT2063_gcd(lo_gcd, f), f_Scale); | 1072 | gf_Scale = MT2063_umax((u32) MT2063_gcd(lo_gcd, f), f_Scale); |
1154 | hgfs = gf_Scale / 2; | 1073 | hgfs = gf_Scale / 2; |
1155 | 1074 | ||
1156 | n0 = uceil(f_LO2 - d, f_LO1 - f_LO2); | 1075 | n0 = DIV_ROUND_UP(f_LO2 - d, f_LO1 - f_LO2); |
1157 | 1076 | ||
1158 | /* Check out all multiples of LO1 from n0 to m_maxLOSpurHarmonic */ | 1077 | /* Check out all multiples of LO1 from n0 to m_maxLOSpurHarmonic */ |
1159 | for (n = n0; n <= pAS_Info->maxH1; ++n) { | 1078 | for (n = n0; n <= pAS_Info->maxH1; ++n) { |
@@ -1462,54 +1381,14 @@ static u32 MT2063_Open(struct dvb_frontend *fe) | |||
1462 | u32 status; /* Status to be returned. */ | 1381 | u32 status; /* Status to be returned. */ |
1463 | struct mt2063_state *state = fe->tuner_priv; | 1382 | struct mt2063_state *state = fe->tuner_priv; |
1464 | 1383 | ||
1465 | /* Default tuner handle to NULL. If successful, it will be reassigned */ | 1384 | state->rcvr_mode = MT2063_CABLE_QAM; |
1466 | 1385 | if (state->MT2063_init != false) { | |
1467 | if (state->MT2063_init == false) | ||
1468 | state->rcvr_mode = MT2063_CABLE_QAM; | ||
1469 | |||
1470 | status = MT2063_RegisterTuner(&state->AS_Data); | ||
1471 | if (status >= 0) { | ||
1472 | state->rcvr_mode = MT2063_CABLE_QAM; | ||
1473 | status = MT2063_ReInit(state); | 1386 | status = MT2063_ReInit(state); |
1387 | if (status < 0) | ||
1388 | return status; | ||
1474 | } | 1389 | } |
1475 | 1390 | ||
1476 | if (status < 0) | 1391 | state->MT2063_init = true; |
1477 | /* MT2063_Close handles the un-registration of the tuner */ | ||
1478 | MT2063_Close(state); | ||
1479 | else { | ||
1480 | state->MT2063_init = true; | ||
1481 | } | ||
1482 | |||
1483 | return (status); | ||
1484 | } | ||
1485 | |||
1486 | /****************************************************************************** | ||
1487 | ** | ||
1488 | ** Name: MT2063_Close | ||
1489 | ** | ||
1490 | ** Description: Release the handle to the tuner. | ||
1491 | ** | ||
1492 | ** Parameters: hMT2063 - Handle to the MT2063 tuner | ||
1493 | ** | ||
1494 | ** Returns: status: | ||
1495 | ** MT_OK - No errors | ||
1496 | ** MT_INV_HANDLE - Invalid tuner handle | ||
1497 | ** | ||
1498 | ** Dependencies: mt_errordef.h - definition of error codes | ||
1499 | ** | ||
1500 | ** Revision History: | ||
1501 | ** | ||
1502 | ** SCR Date Author Description | ||
1503 | ** ------------------------------------------------------------------------- | ||
1504 | ** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b. | ||
1505 | ** | ||
1506 | ******************************************************************************/ | ||
1507 | static u32 MT2063_Close(struct mt2063_state *state) | ||
1508 | { | ||
1509 | /* Unregister tuner with SpurAvoidance routines (if needed) */ | ||
1510 | MT2063_UnRegisterTuner(&state->AS_Data); | ||
1511 | /* Now remove the tuner from our own list of tuners */ | ||
1512 | |||
1513 | return 0; | 1392 | return 0; |
1514 | } | 1393 | } |
1515 | 1394 | ||
@@ -1815,11 +1694,6 @@ static u32 MT2063_GetParam(struct mt2063_state *state, enum MT2063_Param param, | |||
1815 | *pValue = state->AS_Data.f_min_LO_Separation; | 1694 | *pValue = state->AS_Data.f_min_LO_Separation; |
1816 | break; | 1695 | break; |
1817 | 1696 | ||
1818 | /* ID of avoid-spurs algorithm in use */ | ||
1819 | case MT2063_AS_ALG: | ||
1820 | *pValue = state->AS_Data.nAS_Algorithm; | ||
1821 | break; | ||
1822 | |||
1823 | /* max # of intra-tuner harmonics */ | 1697 | /* max # of intra-tuner harmonics */ |
1824 | case MT2063_MAX_HARM1: | 1698 | case MT2063_MAX_HARM1: |
1825 | *pValue = state->AS_Data.maxH1; | 1699 | *pValue = state->AS_Data.maxH1; |