aboutsummaryrefslogtreecommitdiff
path: root/drivers/media/common
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab@redhat.com>2011-07-21 16:40:03 -0300
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-01-04 22:21:43 -0200
commit54a4613fdb84786d71ef4b26ab59eed97cad0e7c (patch)
tree9031f297865a12f0d7f3bf13e9652ef395268681 /drivers/media/common
parent99ac54125490f16f7434f82fcb73bbb88290b38e (diff)
[media] mt2063: Fix comments
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/common')
-rw-r--r--drivers/media/common/tuners/mt2063.c959
1 files changed, 370 insertions, 589 deletions
diff --git a/drivers/media/common/tuners/mt2063.c b/drivers/media/common/tuners/mt2063.c
index 4f634ad24e1..181deac7200 100644
--- a/drivers/media/common/tuners/mt2063.c
+++ b/drivers/media/common/tuners/mt2063.c
@@ -1,3 +1,22 @@
+/*
+ * Driver for mt2063 Micronas tuner
+ *
+ * Copyright (c) 2011 Mauro Carvalho Chehab <mchehab@redhat.com>
+ *
+ * This driver came from a driver originally written by Henry, made available
+ * by Terratec, at:
+ * http://linux.terratec.de/files/TERRATEC_H7/20110323_TERRATEC_H7_Linux.tar.gz
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation under version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
#include <linux/init.h>
#include <linux/kernel.h>
#include <linux/module.h>
@@ -89,8 +108,8 @@ struct MT2063_AvoidSpursData_t {
};
/*
- * Parameter for function MT2063_SetPowerMask that specifies the power down
- * of various sections of the MT2063.
+ * Parameter for function MT2063_SetPowerMask that specifies the power down
+ * of various sections of the MT2063.
*/
enum MT2063_Mask_Bits {
MT2063_REG_SD = 0x0040, /* Shutdown regulator */
@@ -134,9 +153,9 @@ enum MT2063_DNC_Output_Enable {
};
/*
-** Two-wire serial bus subaddresses of the tuner registers.
-** Also known as the tuner's register addresses.
-*/
+ * Two-wire serial bus subaddresses of the tuner registers.
+ * Also known as the tuner's register addresses.
+ */
enum MT2063_Register_Offsets {
MT2063_REG_PART_REV = 0, /* 0x00: Part/Rev Code */
MT2063_REG_LO1CQ_1, /* 0x01: LO1C Queued Byte 1 */
@@ -320,8 +339,7 @@ static u32 mt2063_read(struct mt2063_state *state,
static int MT2063_Sleep(struct dvb_frontend *fe)
{
/*
- ** ToDo: Add code here to implement a OS blocking
- ** for a period of "nMinDelayTime" milliseconds.
+ * ToDo: Add code here to implement a OS blocking
*/
msleep(10);
@@ -391,23 +409,14 @@ static struct MT2063_ExclZone_t *RemoveNode(struct MT2063_AvoidSpursData_t
return pNext;
}
-/*****************************************************************************
-**
-** Name: MT_AddExclZone
-**
-** Description: Add (and merge) an exclusion zone into the list.
-** If the range (f_min, f_max) is totally outside the
-** 1st IF BW, ignore the entry.
-** If the range (f_min, f_max) is negative, ignore the entry.
-**
-** Revision History:
-**
-** SCR Date Author Description
-** -------------------------------------------------------------------------
-** 103 01-31-2005 DAD Ver 1.14: In MT_AddExclZone(), if the range
-** (f_min, f_max) < 0, ignore the entry.
-**
-*****************************************************************************/
+/*
+ * MT_AddExclZone()
+ *
+ * Add (and merge) an exclusion zone into the list.
+ * If the range (f_min, f_max) is totally outside the
+ * 1st IF BW, ignore the entry.
+ * If the range (f_min, f_max) is negative, ignore the entry.
+ */
static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info,
u32 f_min, u32 f_max)
{
@@ -420,11 +429,11 @@ static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info,
&& (f_min < (pAS_Info->f_if1_Center + (pAS_Info->f_if1_bw / 2)))
&& (f_min < f_max)) {
/*
- ** 1 2 3 4 5 6
- **
- ** New entry: |---| |--| |--| |-| |---| |--|
- ** or or or or or
- ** Existing: |--| |--| |--| |---| |-| |--|
+ * 1 2 3 4 5 6
+ *
+ * New entry: |---| |--| |--| |-| |---| |--|
+ * or or or or or
+ * Existing: |--| |--| |--| |---| |-| |--|
*/
/* Check for our place in the list */
@@ -450,18 +459,16 @@ static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info,
while ((pNext != NULL) && (pNext->min_ < pNode->max_)) {
if (pNext->max_ > pNode->max_)
pNode->max_ = pNext->max_;
- pNext = RemoveNode(pAS_Info, pNode, pNext); /* Remove pNext, return ptr to pNext->next */
+ /* Remove pNext, return ptr to pNext->next */
+ pNext = RemoveNode(pAS_Info, pNode, pNext);
}
}
}
/*
-** Reset all exclusion zones.
-** Add zones to protect the PLL FracN regions near zero
-**
-** N/A I 06-17-2008 RSK Ver 1.19: Refactoring avoidance of DECT
-** frequencies into MT_ResetExclZones().
-*/
+ * Reset all exclusion zones.
+ * Add zones to protect the PLL FracN regions near zero
+ */
static void MT2063_ResetExclZones(struct MT2063_AvoidSpursData_t *pAS_Info)
{
u32 center;
@@ -525,32 +532,21 @@ static void MT2063_ResetExclZones(struct MT2063_AvoidSpursData_t *pAS_Info)
}
}
-/*****************************************************************************
-**
-** Name: MT_ChooseFirstIF
-**
-** Description: Choose the best available 1st IF
-** If f_Desired is not excluded, choose that first.
-** Otherwise, return the value closest to f_Center that is
-** not excluded
-**
-** Revision History:
-**
-** SCR Date Author Description
-** -------------------------------------------------------------------------
-** 117 03-29-2007 RSK Ver 1.15: Re-wrote to match search order from
-** tuner DLL.
-** 147 07-27-2007 RSK Ver 1.17: Corrected calculation (-) to (+)
-** Added logic to force f_Center within 1/2 f_Step.
-**
-*****************************************************************************/
+/*
+ * MT_ChooseFirstIF - Choose the best available 1st IF
+ * If f_Desired is not excluded, choose that first.
+ * Otherwise, return the value closest to f_Center that is
+ * not excluded
+ */
static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info)
{
/*
- ** Update "f_Desired" to be the nearest "combinational-multiple" of "f_LO1_Step".
- ** The resulting number, F_LO1 must be a multiple of f_LO1_Step. And F_LO1 is the arithmetic sum
- ** of f_in + f_Center. Neither f_in, nor f_Center must be a multiple of f_LO1_Step.
- ** However, the sum must be.
+ * Update "f_Desired" to be the nearest "combinational-multiple" of
+ * "f_LO1_Step".
+ * The resulting number, F_LO1 must be a multiple of f_LO1_Step.
+ * And F_LO1 is the arithmetic sum of f_in + f_Center.
+ * Neither f_in, nor f_Center must be a multiple of f_LO1_Step.
+ * However, the sum must be.
*/
const u32 f_Desired =
pAS_Info->f_LO1_Step *
@@ -575,7 +571,10 @@ static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info)
if (pAS_Info->nZones == 0)
return f_Desired;
- /* f_Center needs to be an integer multiple of f_Step away from f_Desired */
+ /*
+ * f_Center needs to be an integer multiple of f_Step away
+ * from f_Desired
+ */
if (pAS_Info->f_if1_Center > f_Desired)
f_Center =
f_Desired +
@@ -589,7 +588,10 @@ static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info)
((f_Desired - pAS_Info->f_if1_Center +
f_Step / 2) / f_Step);
- /* Take MT_ExclZones, center around f_Center and change the resolution to f_Step */
+ /*
+ * Take MT_ExclZones, center around f_Center and change the
+ * resolution to f_Step
+ */
while (pNode != NULL) {
/* floor function */
tmpMin =
@@ -618,13 +620,13 @@ static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info)
}
/*
- ** If the desired is okay, return with it
+ * If the desired is okay, return with it
*/
if (bDesiredExcluded == 0)
return f_Desired;
/*
- ** If the desired is excluded and the center is okay, return with it
+ * If the desired is excluded and the center is okay, return with it
*/
if (bZeroExcluded == 0)
return f_Center;
@@ -644,30 +646,14 @@ static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info)
return f_Center + (bestDiff * f_Step);
}
-/****************************************************************************
-**
-** Name: gcd
-**
-** Description: Uses Euclid's algorithm
-**
-** Parameters: u, v - unsigned values whose GCD is desired.
-**
-** Global: None
-**
-** Returns: greatest common divisor of u and v, if either value
-** is 0, the other value is returned as the result.
-**
-** Dependencies: None.
-**
-** Revision History:
-**
-** SCR Date Author Description
-** -------------------------------------------------------------------------
-** N/A 06-01-2004 JWS Original
-** N/A 08-03-2004 DAD Changed to Euclid's since it can handle
-** unsigned numbers.
-**
-****************************************************************************/
+/**
+ * gcd() - Uses Euclid's algorithm
+ *
+ * @u, @v: Unsigned values whose GCD is desired.
+ *
+ * Returns THE greatest common divisor of u and v, if either value is 0,
+ * the other value is returned as the result.
+ */
static u32 MT2063_gcd(u32 u, u32 v)
{
u32 r;
@@ -681,39 +667,25 @@ static u32 MT2063_gcd(u32 u, u32 v)
return u;
}
-/****************************************************************************
-**
-** Name: IsSpurInBand
-**
-** Description: Checks to see if a spur will be present within the IF's
-** bandwidth. (fIFOut +/- fIFBW, -fIFOut +/- fIFBW)
-**
-** ma mb mc md
-** <--+-+-+-------------------+-------------------+-+-+-->
-** | ^ 0 ^ |
-** ^ b=-fIFOut+fIFBW/2 -b=+fIFOut-fIFBW/2 ^
-** a=-fIFOut-fIFBW/2 -a=+fIFOut+fIFBW/2
-**
-** Note that some equations are doubled to prevent round-off
-** problems when calculating fIFBW/2
-**
-** Parameters: pAS_Info - Avoid Spurs information block
-** fm - If spur, amount f_IF1 has to move negative
-** fp - If spur, amount f_IF1 has to move positive
-**
-** Global: None
-**
-** Returns: 1 if an LO spur would be present, otherwise 0.
-**
-** Dependencies: None.
-**
-** Revision History:
-**
-** SCR Date Author Description
-** -------------------------------------------------------------------------
-** N/A 11-28-2002 DAD Implemented algorithm from applied patent
-**
-****************************************************************************/
+/**
+ * IsSpurInBand() - Checks to see if a spur will be present within the IF's
+ * bandwidth. (fIFOut +/- fIFBW, -fIFOut +/- fIFBW)
+ *
+ * ma mb mc md
+ * <--+-+-+-------------------+-------------------+-+-+-->
+ * | ^ 0 ^ |
+ * ^ b=-fIFOut+fIFBW/2 -b=+fIFOut-fIFBW/2 ^
+ * a=-fIFOut-fIFBW/2 -a=+fIFOut+fIFBW/2
+ *
+ * Note that some equations are doubled to prevent round-off
+ * problems when calculating fIFBW/2
+ *
+ * @pAS_Info: Avoid Spurs information block
+ * @fm: If spur, amount f_IF1 has to move negative
+ * @fp: If spur, amount f_IF1 has to move positive
+ *
+ * Returns 1 if an LO spur would be present, otherwise 0.
+ */
static u32 IsSpurInBand(struct MT2063_AvoidSpursData_t *pAS_Info,
u32 *fm, u32 * fp)
{
@@ -814,22 +786,12 @@ static u32 IsSpurInBand(struct MT2063_AvoidSpursData_t *pAS_Info,
return 0;
}
-/*****************************************************************************
-**
-** Name: MT_AvoidSpurs
-**
-** Description: Main entry point to avoid spurs.
-** Checks for existing spurs in present LO1, LO2 freqs
-** and if present, chooses spur-free LO1, LO2 combination
-** that tunes the same input/output frequencies.
-**
-** Revision History:
-**
-** SCR Date Author Description
-** -------------------------------------------------------------------------
-** 096 04-06-2005 DAD Ver 1.11: Fix divide by 0 error if maxH==0.
-**
-*****************************************************************************/
+/*
+ * MT_AvoidSpurs() - Main entry point to avoid spurs.
+ * Checks for existing spurs in present LO1, LO2 freqs
+ * and if present, chooses spur-free LO1, LO2 combination
+ * that tunes the same input/output frequencies.
+ */
static u32 MT2063_AvoidSpurs(struct MT2063_AvoidSpursData_t *pAS_Info)
{
u32 status = 0;
@@ -841,15 +803,15 @@ static u32 MT2063_AvoidSpurs(struct MT2063_AvoidSpursData_t *pAS_Info)
return 0;
/*
- ** Avoid LO Generated Spurs
- **
- ** Make sure that have no LO-related spurs within the IF output
- ** bandwidth.
- **
- ** If there is an LO spur in this band, start at the current IF1 frequency
- ** and work out until we find a spur-free frequency or run up against the
- ** 1st IF SAW band edge. Use temporary copies of fLO1 and fLO2 so that they
- ** will be unchanged if a spur-free setting is not found.
+ * Avoid LO Generated Spurs
+ *
+ * Make sure that have no LO-related spurs within the IF output
+ * bandwidth.
+ *
+ * If there is an LO spur in this band, start at the current IF1 frequency
+ * and work out until we find a spur-free frequency or run up against the
+ * 1st IF SAW band edge. Use temporary copies of fLO1 and fLO2 so that they
+ * will be unchanged if a spur-free setting is not found.
*/
pAS_Info->bSpurPresent = IsSpurInBand(pAS_Info, &fm, &fp);
if (pAS_Info->bSpurPresent) {
@@ -887,15 +849,15 @@ static u32 MT2063_AvoidSpurs(struct MT2063_AvoidSpursData_t *pAS_Info)
pAS_Info->bSpurPresent = IsSpurInBand(pAS_Info, &fm, &fp);
/*
- ** Continue while the new 1st IF is still within the 1st IF bandwidth
- ** and there is a spur in the band (again)
+ * Continue while the new 1st IF is still within the 1st IF bandwidth
+ * and there is a spur in the band (again)
*/
} while ((2 * delta_IF1 + pAS_Info->f_out_bw <= pAS_Info->f_if1_bw) && pAS_Info->bSpurPresent);
/*
- ** Use the LO-spur free values found. If the search went all the way to
- ** the 1st IF band edge and always found spurs, just leave the original
- ** choice. It's as "good" as any other.
+ * Use the LO-spur free values found. If the search went all
+ * the way to the 1st IF band edge and always found spurs, just
+ * leave the original choice. It's as "good" as any other.
*/
if (pAS_Info->bSpurPresent == 1) {
status |= MT2063_SPUR_PRESENT_ERR;
@@ -912,7 +874,6 @@ static u32 MT2063_AvoidSpurs(struct MT2063_AvoidSpursData_t *pAS_Info)
return status;
}
-
/*
* Constants used by the tuning algorithm
*/
@@ -936,35 +897,29 @@ static u32 MT2063_AvoidSpurs(struct MT2063_AvoidSpursData_t *pAS_Info)
#define MT2063_MAX_UPC_FREQ (2750000000UL) /* Maximum LO1 frequency (in Hz) */
/*
-** Define the supported Part/Rev codes for the MT2063
-*/
+ * Define the supported Part/Rev codes for the MT2063
+ */
#define MT2063_B0 (0x9B)
#define MT2063_B1 (0x9C)
#define MT2063_B2 (0x9D)
#define MT2063_B3 (0x9E)
/*
-** Constants for setting receiver modes.
-** (6 modes defined at this time, enumerated by MT2063_RCVR_MODES)
-** (DNC1GC & DNC2GC are the values, which are used, when the specific
-** DNC Output is selected, the other is always off)
-**
-** If PAL-L or L' is received, set:
-** MT2063_SetParam(hMT2063,MT2063_TAGC,1);
-**
-** --------------+----------------------------------------------
-** Mode 0 : | MT2063_CABLE_QAM
-** Mode 1 : | MT2063_CABLE_ANALOG
-** Mode 2 : | MT2063_OFFAIR_COFDM
-** Mode 3 : | MT2063_OFFAIR_COFDM_SAWLESS
-** Mode 4 : | MT2063_OFFAIR_ANALOG
-** Mode 5 : | MT2063_OFFAIR_8VSB
-** --------------+----+----+----+----+-----+-----+--------------
-** Mode | 0 | 1 | 2 | 3 | 4 | 5 |
-** --------------+----+----+----+----+-----+-----+
-**
-**
-*/
+ * Constants for setting receiver modes.
+ * (6 modes defined at this time, enumerated by MT2063_RCVR_MODES)
+ * (DNC1GC & DNC2GC are the values, which are used, when the specific
+ * DNC Output is selected, the other is always off)
+ *
+ * enum MT2063_RCVR_MODES
+ * -------------+----------------------------------------------
+ * Mode 0 : | MT2063_CABLE_QAM
+ * Mode 1 : | MT2063_CABLE_ANALOG
+ * Mode 2 : | MT2063_OFFAIR_COFDM
+ * Mode 3 : | MT2063_OFFAIR_COFDM_SAWLESS
+ * Mode 4 : | MT2063_OFFAIR_ANALOG
+ * Mode 5 : | MT2063_OFFAIR_8VSB
+ * --------------+----------------------------------------------
+ */
static const u8 RFAGCEN[] = { 0, 0, 0, 0, 0, 0 };
static const u8 LNARIN[] = { 0, 0, 3, 3, 3, 3 };
static const u8 FIFFQEN[] = { 1, 1, 1, 1, 1, 1 };
@@ -1053,117 +1008,109 @@ static u32 mt2063_set_dnc_output_enable(struct mt2063_state *state,
/* selects, which DNC output is used */
switch (nValue) {
case MT2063_DNC_NONE:
- {
- val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 0x03; /* Set DNC1GC=3 */
- if (state->reg[MT2063_REG_DNC_GAIN] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_DNC_GAIN,
- val);
+ val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 0x03; /* Set DNC1GC=3 */
+ if (state->reg[MT2063_REG_DNC_GAIN] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_DNC_GAIN,
+ val);
- val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03; /* Set DNC2GC=3 */
- if (state->reg[MT2063_REG_VGA_GAIN] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_VGA_GAIN,
- val);
+ val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03; /* Set DNC2GC=3 */
+ if (state->reg[MT2063_REG_VGA_GAIN] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_VGA_GAIN,
+ val);
- val = (state->reg[MT2063_REG_RSVD_20] & ~0x40); /* Set PD2MUX=0 */
- if (state->reg[MT2063_REG_RSVD_20] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_RSVD_20,
- val);
+ val = (state->reg[MT2063_REG_RSVD_20] & ~0x40); /* Set PD2MUX=0 */
+ if (state->reg[MT2063_REG_RSVD_20] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_RSVD_20,
+ val);
- break;
- }
+ break;
case MT2063_DNC_1:
- {
- val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | (DNC1GC[state->rcvr_mode] & 0x03); /* Set DNC1GC=x */
- if (state->reg[MT2063_REG_DNC_GAIN] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_DNC_GAIN,
- val);
+ val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | (DNC1GC[state->rcvr_mode] & 0x03); /* Set DNC1GC=x */
+ if (state->reg[MT2063_REG_DNC_GAIN] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_DNC_GAIN,
+ val);
- val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03; /* Set DNC2GC=3 */
- if (state->reg[MT2063_REG_VGA_GAIN] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_VGA_GAIN,
- val);
+ val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | 0x03; /* Set DNC2GC=3 */
+ if (state->reg[MT2063_REG_VGA_GAIN] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_VGA_GAIN,
+ val);
- val = (state->reg[MT2063_REG_RSVD_20] & ~0x40); /* Set PD2MUX=0 */
- if (state->reg[MT2063_REG_RSVD_20] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_RSVD_20,
- val);
+ val = (state->reg[MT2063_REG_RSVD_20] & ~0x40); /* Set PD2MUX=0 */
+ if (state->reg[MT2063_REG_RSVD_20] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_RSVD_20,
+ val);
- break;
- }
+ break;
case MT2063_DNC_2:
- {
- val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 0x03; /* Set DNC1GC=3 */
- if (state->reg[MT2063_REG_DNC_GAIN] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_DNC_GAIN,
- val);
+ val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | 0x03; /* Set DNC1GC=3 */
+ if (state->reg[MT2063_REG_DNC_GAIN] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_DNC_GAIN,
+ val);
- val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | (DNC2GC[state->rcvr_mode] & 0x03); /* Set DNC2GC=x */
- if (state->reg[MT2063_REG_VGA_GAIN] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_VGA_GAIN,
- val);
+ val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | (DNC2GC[state->rcvr_mode] & 0x03); /* Set DNC2GC=x */
+ if (state->reg[MT2063_REG_VGA_GAIN] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_VGA_GAIN,
+ val);
- val = (state->reg[MT2063_REG_RSVD_20] | 0x40); /* Set PD2MUX=1 */
- if (state->reg[MT2063_REG_RSVD_20] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_RSVD_20,
- val);
+ val = (state->reg[MT2063_REG_RSVD_20] | 0x40); /* Set PD2MUX=1 */
+ if (state->reg[MT2063_REG_RSVD_20] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_RSVD_20,
+ val);
- break;
- }
+ break;
case MT2063_DNC_BOTH:
- {
- val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | (DNC1GC[state->rcvr_mode] & 0x03); /* Set DNC1GC=x */
- if (state->reg[MT2063_REG_DNC_GAIN] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_DNC_GAIN,
- val);
+ val = (state->reg[MT2063_REG_DNC_GAIN] & 0xFC) | (DNC1GC[state->rcvr_mode] & 0x03); /* Set DNC1GC=x */
+ if (state->reg[MT2063_REG_DNC_GAIN] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_DNC_GAIN,
+ val);
- val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | (DNC2GC[state->rcvr_mode] & 0x03); /* Set DNC2GC=x */
- if (state->reg[MT2063_REG_VGA_GAIN] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_VGA_GAIN,
- val);
+ val = (state->reg[MT2063_REG_VGA_GAIN] & 0xFC) | (DNC2GC[state->rcvr_mode] & 0x03); /* Set DNC2GC=x */
+ if (state->reg[MT2063_REG_VGA_GAIN] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_VGA_GAIN,
+ val);
- val = (state->reg[MT2063_REG_RSVD_20] | 0x40); /* Set PD2MUX=1 */
- if (state->reg[MT2063_REG_RSVD_20] !=
- val)
- status |=
- mt2063_setreg(state,
- MT2063_REG_RSVD_20,
- val);
+ val = (state->reg[MT2063_REG_RSVD_20] | 0x40); /* Set PD2MUX=1 */
+ if (state->reg[MT2063_REG_RSVD_20] !=
+ val)
+ status |=
+ mt2063_setreg(state,
+ MT2063_REG_RSVD_20,
+ val);
- break;
- }
+ break;
default:
break;
}
@@ -1171,89 +1118,47 @@ static u32 mt2063_set_dnc_output_enable(struct mt2063_state *state,
return status;
}
-/******************************************************************************
-**
-** Name: MT2063_SetReceiverMode
-**
-** Description: Set the MT2063 receiver mode
-**
-** --------------+----------------------------------------------
-** Mode 0 : | MT2063_CABLE_QAM
-** Mode 1 : | MT2063_CABLE_ANALOG
-** Mode 2 : | MT2063_OFFAIR_COFDM
-** Mode 3 : | MT2063_OFFAIR_COFDM_SAWLESS
-** Mode 4 : | MT2063_OFFAIR_ANALOG
-** Mode 5 : | MT2063_OFFAIR_8VSB
-** --------------+----+----+----+----+-----+--------------------
-** (DNC1GC & DNC2GC are the values, which are used, when the specific
-** DNC Output is selected, the other is always off)
-**
-** |<---------- Mode -------------->|
-** Reg Field | 0 | 1 | 2 | 3 | 4 | 5 |
-** ------------+-----+-----+-----+-----+-----+-----+
-** RFAGCen | OFF | OFF | OFF | OFF | OFF | OFF
-** LNARin | 0 | 0 | 3 | 3 | 3 | 3
-** FIFFQen | 1 | 1 | 1 | 1 | 1 | 1
-** FIFFq | 0 | 0 | 0 | 0 | 0 | 0
-** DNC1gc | 0 | 0 | 0 | 0 | 0 | 0
-** DNC2gc | 0 | 0 | 0 | 0 | 0 | 0
-** GCU Auto | 1 | 1 | 1 | 1 | 1 | 1
-** LNA max Atn | 31 | 31 | 31 | 31 | 31 | 31
-** LNA Target | 44 | 43 | 43 | 43 | 43 | 43
-** ign RF Ovl | 0 | 0 | 0 | 0 | 0 | 0
-** RF max Atn | 31 | 31 | 31 | 31 | 31 | 31
-** PD1 Target | 36 | 36 | 38 | 38 | 36 | 38
-** ign FIF Ovl | 0 | 0 | 0 | 0 | 0 | 0
-** FIF max Atn | 5 | 5 | 5 | 5 | 5 | 5
-** PD2 Target | 40 | 33 | 42 | 42 | 33 | 42
-**
-**
-** Parameters: state - ptr to mt2063_state structure
-** Mode - desired reciever mode
-**
-** Usage: status = MT2063_SetReceiverMode(hMT2063, Mode);
-**
-** Returns: status:
-** MT_OK - No errors
-** MT_COMM_ERR - Serial bus communications error
-**
-** Dependencies: mt2063_setreg - Write a byte of data to a HW register.
-** Assumes that the tuner cache is valid.
-**
-** Revision History:
-**
-** SCR Date Author Description
-** -------------------------------------------------------------------------
-** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
-** N/A 01-10-2007 PINZ Added additional GCU Settings, FIFF Calib will be triggered
-** 155 10-01-2007 DAD Ver 1.06: Add receiver mode for SECAM positive
-** modulation
-** (MT2063_ANALOG_TV_POS_NO_RFAGC_MODE)
-** N/A 10-22-2007 PINZ Ver 1.07: Changed some Registers at init to have
-** the same settings as with MT Launcher
-** N/A 10-30-2007 PINZ Add SetParam VGAGC & VGAOI
-** Add SetParam DNC_OUTPUT_ENABLE
-** Removed VGAGC from receiver mode,
-** default now 1
-** N/A 10-31-2007 PINZ Ver 1.08: Add SetParam TAGC, removed from rcvr-mode
-** Add SetParam AMPGC, removed from rcvr-mode
-** Corrected names of GCU values
-** reorganized receiver modes, removed,
-** (MT2063_ANALOG_TV_POS_NO_RFAGC_MODE)
-** Actualized Receiver-Mode values
-** N/A 11-12-2007 PINZ Ver 1.09: Actualized Receiver-Mode values
-** N/A 11-27-2007 PINZ Improved buffered writing
-** 01-03-2008 PINZ Ver 1.10: Added a trigger of BYPATNUP for
-** correct wakeup of the LNA after shutdown
-** Set AFCsd = 1 as default
-** Changed CAP1sel default
-** 01-14-2008 PINZ Ver 1.11: Updated gain settings
-** 04-18-2008 PINZ Ver 1.15: Add SetParam LNARIN & PDxTGT
-** Split SetParam up to ACLNA / ACLNA_MAX
-** removed ACLNA_INRC/DECR (+RF & FIF)
-** removed GCUAUTO / BYPATNDN/UP
-**
-******************************************************************************/
+/*
+ * MT2063_SetReceiverMode() - Set the MT2063 receiver mode
+**
+ * enum MT2063_RCVR_MODES
+ * --------------+----------------------------------------------
+ * Mode 0 : | MT2063_CABLE_QAM
+ * Mode 1 : | MT2063_CABLE_ANALOG
+ * Mode 2 : | MT2063_OFFAIR_COFDM
+ * Mode 3 : | MT2063_OFFAIR_COFDM_SAWLESS
+ * Mode 4 : | MT2063_OFFAIR_ANALOG
+ * Mode 5 : | MT2063_OFFAIR_8VSB
+ * --------------+----------------------------------------------
+ * (DNC1GC & DNC2GC are the values, which are used, when the specific
+ * DNC Output is selected, the other is always off)
+ *
+ * |<---------- Mode -------------->|
+ * Reg Field | 0 | 1 | 2 | 3 | 4 | 5 |
+ * ------------+-----+-----+-----+-----+-----+-----+
+ * RFAGCen | OFF | OFF | OFF | OFF | OFF | OFF
+ * LNARin | 0 | 0 | 3 | 3 | 3 | 3
+ * FIFFQen | 1 | 1 | 1 | 1 | 1 | 1
+ * FIFFq | 0 | 0 | 0 | 0 | 0 | 0
+ * DNC1gc | 0 | 0 | 0 | 0 | 0 | 0
+ * DNC2gc | 0 | 0 | 0 | 0 | 0 | 0
+ * GCU Auto | 1 | 1 | 1 | 1 | 1 | 1
+ * LNA max Atn | 31 | 31 | 31 | 31 | 31 | 31
+ * LNA Target | 44 | 43 | 43 | 43 | 43 | 43
+ * ign RF Ovl | 0 | 0 | 0 | 0 | 0 | 0
+ * RF max Atn | 31 | 31 | 31 | 31 | 31 | 31
+ * PD1 Target | 36 | 36 | 38 | 38 | 36 | 38
+ * ign FIF Ovl | 0 | 0 | 0 | 0 | 0 | 0
+ * FIF max Atn | 5 | 5 | 5 | 5 | 5 | 5
+ * PD2 Target | 40 | 33 | 42 | 42 | 33 | 42
+ *
+ *
+ * @state: ptr to mt2063_state structure
+ * @Mode: desired reciever mode
+ *
+ * Note: Register cache must be valid for it to work
+ */
+
static u32 MT2063_SetReceiverMode(struct mt2063_state *state,
enum MT2063_RCVR_MODES Mode)
{
@@ -1382,37 +1287,19 @@ static u32 MT2063_SetReceiverMode(struct mt2063_state *state,
return status;
}
-/****************************************************************************
-**
-** Name: MT2063_ClearPowerMaskBits
-**
-** Description: Clears the power-down mask bits for various sections of
-** the MT2063
-**
-** Parameters: h - Tuner handle (returned by MT2063_Open)
-** Bits - Mask bits to be cleared.
-**
-** See definition of MT2063_Mask_Bits type for description
-** of each of the power bits.
-**
-** Returns: status:
-** MT_OK - No errors
-** MT_INV_HANDLE - Invalid tuner handle
-** MT_COMM_ERR - Serial bus communications error
-**
-** Dependencies: USERS MUST CALL MT2063_Open() FIRST!
-**
-** Revision History:
-**
-** SCR Date Author Description
-** -------------------------------------------------------------------------
-** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
-**
-****************************************************************************/
+/*
+ * MT2063_ClearPowerMaskBits () - Clears the power-down mask bits for various
+ * sections of the MT2063
+ *
+ * @Bits: Mask bits to be cleared.
+ *
+ * See definition of MT2063_Mask_Bits type for description
+ * of each of the power bits.
+ */
static u32 MT2063_ClearPowerMaskBits(struct mt2063_state *state,
enum MT2063_Mask_Bits Bits)
{
- u32 status = 0; /* Status to be returned */
+ u32 status = 0;
Bits = (enum MT2063_Mask_Bits)(Bits & MT2063_ALL_SD); /* Only valid bits for this tuner */
if ((Bits & 0xFF00) != 0) {
@@ -1433,42 +1320,19 @@ static u32 MT2063_ClearPowerMaskBits(struct mt2063_state *state,
return status;
}
-/****************************************************************************
-**
-** Name: MT2063_SoftwareShutdown
-**
-** Description: Enables or disables software shutdown function. When
-** Shutdown==1, any section whose power mask is set will be
-** shutdown.
-**
-** Parameters: h - Tuner handle (returned by MT2063_Open)
-** Shutdown - 1 = shutdown the masked sections, otherwise
-** power all sections on
-**
-** Returns: status:
-** MT_OK - No errors
-** MT_INV_HANDLE - Invalid tuner handle
-** MT_COMM_ERR - Serial bus communications error
-**
-** Dependencies: USERS MUST CALL MT2063_Open() FIRST!
-**
-** Revision History:
-**
-** SCR Date Author Description
-** -------------------------------------------------------------------------
-** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
-** 01-03-2008 PINZ Ver 1.xx: Added a trigger of BYPATNUP for
-** correct wakeup of the LNA
-**
-****************************************************************************/
+/*
+ * MT2063_SoftwareShutdown() - Enables or disables software shutdown function.
+ * When Shutdown is 1, any section whose power
+ * mask is set will be shutdown.
+ */
static u32 MT2063_SoftwareShutdown(struct mt2063_state *state, u8 Shutdown)
{
- u32 status; /* Status to be returned */
+ u32 status;
if (Shutdown == 1)
- state->reg[MT2063_REG_PWR_1] |= 0x04; /* Turn the bit on */
+ state->reg[MT2063_REG_PWR_1] |= 0x04;
else
- state->reg[MT2063_REG_PWR_1] &= ~0x04; /* Turn off the bit */
+ state->reg[MT2063_REG_PWR_1] &= ~0x04;
status = mt2063_write(state,
MT2063_REG_PWR_1,
@@ -1500,36 +1364,24 @@ static u32 MT2063_Round_fLO(u32 f_LO, u32 f_LO_Step, u32 f_ref)
+ f_LO_Step * (((f_LO % f_ref) + (f_LO_Step / 2)) / f_LO_Step);
}
-/****************************************************************************
-**
-** Name: fLO_FractionalTerm
-**
-** Description: Calculates the portion contributed by FracN / denom.
-**
-** This function preserves maximum precision without
-** risk of overflow. It accurately calculates
-** f_ref * num / denom to within 1 HZ with fixed math.
-**
-** Parameters: num - Fractional portion of the multiplier
-** denom - denominator portion of the ratio
-** This routine successfully handles denom values
-** up to and including 2^18.
-** f_Ref - SRO frequency. This calculation handles
-** f_ref as two separate 14-bit fields.
-** Therefore, a maximum value of 2^28-1
-** may safely be used for f_ref. This is
-** the genesis of the magic number "14" and the
-** magic mask value of 0x03FFF.
-**
-** Returns: f_ref * num / denom
-**
-** Revision History:
-**
-** SCR Date Author Description
-** -------------------------------------------------------------------------
-** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
-**
-****************************************************************************/
+/**
+ * fLO_FractionalTerm() - Calculates the portion contributed by FracN / denom.
+ * This function preserves maximum precision without
+ * risk of overflow. It accurately calculates
+ * f_ref * num / denom to within 1 HZ with fixed math.
+ *
+ * @num : Fractional portion of the multiplier
+ * @denom: denominator portion of the ratio
+ * @f_Ref: SRO frequency.
+ *
+ * This calculation handles f_ref as two separate 14-bit fields.
+ * Therefore, a maximum value of 2^28-1 may safely be used for f_ref.
+ * This is the genesis of the magic number "14" and the magic mask value of
+ * 0x03FFF.
+ *
+ * This routine successfully handles denom values up to and including 2^18.
+ * Returns: f_ref * num / denom
+ */
static u32 MT2063_fLO_FractionalTerm(u32 f_ref, u32 num, u32 denom)
{
u32 t1 = (f_ref >> 14) * num;
@@ -1540,33 +1392,23 @@ static u32 MT2063_fLO_FractionalTerm(u32 f_ref, u32 num, u32 denom)
return (term1 << 14) + term2;
}
-/****************************************************************************
-**
-** Name: CalcLO1Mult
-**
-** Description: Calculates Integer divider value and the numerator
-** value for a FracN PLL.
-**
-** This function assumes that the f_LO and f_Ref are
-** evenly divisible by f_LO_Step.
-**
-** Parameters: Div - OUTPUT: Whole number portion of the multi