Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
raspberrypi-kernel
提交
fdf77a4f
R
raspberrypi-kernel
项目概览
openeuler
/
raspberrypi-kernel
通知
13
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
raspberrypi-kernel
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
提交
fdf77a4f
编写于
7月 20, 2011
作者:
M
Mauro Carvalho Chehab
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
[media] mt2063: Use Unix standard error handling
Signed-off-by:
N
Mauro Carvalho Chehab
<
mchehab@redhat.com
>
上级
065719a7
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
1139 addition
and
1220 deletion
+1139
-1220
drivers/media/common/tuners/mt2063.c
drivers/media/common/tuners/mt2063.c
+1139
-1220
未找到文件。
drivers/media/common/tuners/mt2063.c
浏览文件 @
fdf77a4f
...
@@ -16,64 +16,18 @@ module_param(verbose, int, 0644);
...
@@ -16,64 +16,18 @@ module_param(verbose, int, 0644);
#define DVBFE_TUNER_SOFTWARE_SHUTDOWN 100
#define DVBFE_TUNER_SOFTWARE_SHUTDOWN 100
#define DVBFE_TUNER_CLEAR_POWER_MASKBITS 101
#define DVBFE_TUNER_CLEAR_POWER_MASKBITS 101
#define MT2063_ERROR (1 << 31)
/* FIXME: Those error codes need conversion*/
#define MT2063_USER_ERROR (1 << 30)
/* Macro to be used to check for errors */
#define MT2063_IS_ERROR(s) (((s) >> 30) != 0)
#define MT2063_NO_ERROR(s) (((s) >> 30) == 0)
#define MT2063_OK (0x00000000)
/* Unknown error */
#define MT2063_UNKNOWN (0x80000001)
/* Error: Upconverter PLL is not locked */
/* Error: Upconverter PLL is not locked */
#define MT2063_UPC_UNLOCK (0x80000002)
#define MT2063_UPC_UNLOCK (0x80000002)
/* Error: Downconverter PLL is not locked */
/* Error: Downconverter PLL is not locked */
#define MT2063_DNC_UNLOCK (0x80000004)
#define MT2063_DNC_UNLOCK (0x80000004)
/* Info: Unavoidable LO-related spur may be present in the output */
/* Error: Two-wire serial bus communications error */
#define MT2063_SPUR_PRESENT_ERR (0x00800000)
#define MT2063_COMM_ERR (0x80000008)
/* Error: Tuner handle passed to function was invalid */
#define MT2063_INV_HANDLE (0x80000010)
/* Error: Function argument is invalid (out of range) */
#define MT2063_ARG_RANGE (0x80000020)
/* Error: Function argument (ptr to return value) was NULL */
#define MT2063_ARG_NULL (0x80000040)
/* Error: Attempt to open more than MT_TUNER_CNT tuners */
#define MT2063_TUNER_CNT_ERR (0x80000080)
/* Error: Tuner Part Code / Rev Code mismatches expected value */
#define MT2063_TUNER_ID_ERR (0x80000100)
/* Error: Tuner Initialization failure */
#define MT2063_TUNER_INIT_ERR (0x80000200)
#define MT2063_TUNER_OPEN_ERR (0x80000400)
/* User-definable fields (see mt_userdef.h) */
#define MT2063_USER_DEFINED1 (0x00001000)
#define MT2063_USER_DEFINED2 (0x00002000)
#define MT2063_USER_DEFINED3 (0x00004000)
#define MT2063_USER_DEFINED4 (0x00008000)
#define MT2063_USER_MASK (0x4000f000)
#define MT2063_USER_SHIFT (12)
/* Info: Mask of bits used for # of LO-related spurs that were avoided during tuning */
/* Info: Mask of bits used for # of LO-related spurs that were avoided during tuning */
#define MT2063_SPUR_CNT_MASK (0x001f0000)
#define MT2063_SPUR_CNT_MASK (0x001f0000)
#define MT2063_SPUR_SHIFT (16)
#define MT2063_SPUR_SHIFT (16)
/* Info: Tuner timeout waiting for condition */
#define MT2063_TUNER_TIMEOUT (0x00400000)
/* Info: Unavoidable LO-related spur may be present in the output */
#define MT2063_SPUR_PRESENT_ERR (0x00800000)
/* Info: Tuner input frequency is out of range */
/* Info: Tuner input frequency is out of range */
#define MT2063_FIN_RANGE (0x01000000)
#define MT2063_FIN_RANGE (0x01000000)
...
@@ -539,12 +493,12 @@ struct mt2063_state {
...
@@ -539,12 +493,12 @@ struct mt2063_state {
/* Prototypes */
/* Prototypes */
static
void
MT2063_AddExclZone
(
struct
MT2063_AvoidSpursData_t
*
pAS_Info
,
static
void
MT2063_AddExclZone
(
struct
MT2063_AvoidSpursData_t
*
pAS_Info
,
u32
f_min
,
u32
f_max
);
u32
f_min
,
u32
f_max
);
static
u32
MT2063_ReInit
(
void
*
h
);
static
u32
MT2063_ReInit
(
struct
MT2063_Info_t
*
pInfo
);
static
u32
MT2063_Close
(
void
*
hMT2063
);
static
u32
MT2063_Close
(
struct
MT2063_Info_t
*
pInfo
);
static
u32
MT2063_GetReg
(
void
*
h
,
u8
reg
,
u8
*
val
);
static
u32
MT2063_GetReg
(
struct
MT2063_Info_t
*
pInfo
,
u8
reg
,
u8
*
val
);
static
u32
MT2063_GetParam
(
void
*
h
,
enum
MT2063_Param
param
,
u32
*
pValue
);
static
u32
MT2063_GetParam
(
struct
MT2063_Info_t
*
pInfo
,
enum
MT2063_Param
param
,
u32
*
pValue
);
static
u32
MT2063_SetReg
(
void
*
h
,
u8
reg
,
u8
val
);
static
u32
MT2063_SetReg
(
struct
MT2063_Info_t
*
pInfo
,
u8
reg
,
u8
val
);
static
u32
MT2063_SetParam
(
void
*
h
,
enum
MT2063_Param
param
,
u32
nValue
);
static
u32
MT2063_SetParam
(
struct
MT2063_Info_t
*
pInfo
,
enum
MT2063_Param
param
,
u32
nValue
);
/*****************/
/*****************/
/* From drivers/media/common/tuners/mt2063_cfg.h */
/* From drivers/media/common/tuners/mt2063_cfg.h */
...
@@ -769,7 +723,7 @@ static u32 MT2063_WriteSub(void *hUserData,
...
@@ -769,7 +723,7 @@ static u32 MT2063_WriteSub(void *hUserData,
u32
addr
,
u32
addr
,
u8
subAddress
,
u8
*
pData
,
u32
cnt
)
u8
subAddress
,
u8
*
pData
,
u32
cnt
)
{
{
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
struct
dvb_frontend
*
fe
=
hUserData
;
struct
dvb_frontend
*
fe
=
hUserData
;
struct
mt2063_state
*
state
=
fe
->
tuner_priv
;
struct
mt2063_state
*
state
=
fe
->
tuner_priv
;
/*
/*
...
@@ -782,7 +736,7 @@ static u32 MT2063_WriteSub(void *hUserData,
...
@@ -782,7 +736,7 @@ static u32 MT2063_WriteSub(void *hUserData,
fe
->
ops
.
i2c_gate_ctrl
(
fe
,
1
);
//I2C bypass drxk3926 close i2c bridge
fe
->
ops
.
i2c_gate_ctrl
(
fe
,
1
);
//I2C bypass drxk3926 close i2c bridge
if
(
mt2063_writeregs
(
state
,
subAddress
,
pData
,
cnt
)
<
0
)
{
if
(
mt2063_writeregs
(
state
,
subAddress
,
pData
,
cnt
)
<
0
)
{
status
=
MT2063_ERROR
;
status
=
-
EINVAL
;
}
}
fe
->
ops
.
i2c_gate_ctrl
(
fe
,
0
);
//I2C bypass drxk3926 close i2c bridge
fe
->
ops
.
i2c_gate_ctrl
(
fe
,
0
);
//I2C bypass drxk3926 close i2c bridge
...
@@ -838,7 +792,7 @@ static u32 MT2063_ReadSub(void *hUserData,
...
@@ -838,7 +792,7 @@ static u32 MT2063_ReadSub(void *hUserData,
** return MT_OK.
** return MT_OK.
*/
*/
/* return status; */
/* return status; */
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
struct
dvb_frontend
*
fe
=
hUserData
;
struct
dvb_frontend
*
fe
=
hUserData
;
struct
mt2063_state
*
state
=
fe
->
tuner_priv
;
struct
mt2063_state
*
state
=
fe
->
tuner_priv
;
u32
i
=
0
;
u32
i
=
0
;
...
@@ -846,7 +800,7 @@ static u32 MT2063_ReadSub(void *hUserData,
...
@@ -846,7 +800,7 @@ static u32 MT2063_ReadSub(void *hUserData,
for
(
i
=
0
;
i
<
cnt
;
i
++
)
{
for
(
i
=
0
;
i
<
cnt
;
i
++
)
{
if
(
mt2063_read_regs
(
state
,
subAddress
+
i
,
pData
+
i
,
1
)
<
0
)
{
if
(
mt2063_read_regs
(
state
,
subAddress
+
i
,
pData
+
i
,
1
)
<
0
)
{
status
=
MT2063_ERROR
;
status
=
-
EINVAL
;
break
;
break
;
}
}
}
}
...
@@ -962,7 +916,7 @@ static u32 MT2063_RegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info)
...
@@ -962,7 +916,7 @@ static u32 MT2063_RegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info)
{
{
#if MT2063_TUNER_CNT == 1
#if MT2063_TUNER_CNT == 1
pAS_Info
->
nAS_Algorithm
=
1
;
pAS_Info
->
nAS_Algorithm
=
1
;
return
MT2063_OK
;
return
0
;
#else
#else
u32
index
;
u32
index
;
...
@@ -973,7 +927,7 @@ static u32 MT2063_RegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info)
...
@@ -973,7 +927,7 @@ static u32 MT2063_RegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info)
*/
*/
for
(
index
=
0
;
index
<
TunerCount
;
index
++
)
{
for
(
index
=
0
;
index
<
TunerCount
;
index
++
)
{
if
(
TunerList
[
index
]
==
pAS_Info
)
{
if
(
TunerList
[
index
]
==
pAS_Info
)
{
return
MT2063_OK
;
/* Already here - no problem */
return
0
;
/* Already here - no problem */
}
}
}
}
...
@@ -983,9 +937,9 @@ static u32 MT2063_RegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info)
...
@@ -983,9 +937,9 @@ static u32 MT2063_RegisterTuner(struct MT2063_AvoidSpursData_t *pAS_Info)
if
(
TunerCount
<
MT2063_TUNER_CNT
)
{
if
(
TunerCount
<
MT2063_TUNER_CNT
)
{
TunerList
[
TunerCount
]
=
pAS_Info
;
TunerList
[
TunerCount
]
=
pAS_Info
;
TunerCount
++
;
TunerCount
++
;
return
MT2063_OK
;
return
0
;
}
else
}
else
return
MT2063_TUNER_CNT_ERR
;
return
-
ENODEV
;
#endif
#endif
}
}
...
@@ -1810,13 +1764,13 @@ static u32 IsSpurInBand(struct MT2063_AvoidSpursData_t *pAS_Info,
...
@@ -1810,13 +1764,13 @@ static u32 IsSpurInBand(struct MT2063_AvoidSpursData_t *pAS_Info,
*****************************************************************************/
*****************************************************************************/
static
u32
MT2063_AvoidSpurs
(
void
*
h
,
struct
MT2063_AvoidSpursData_t
*
pAS_Info
)
static
u32
MT2063_AvoidSpurs
(
void
*
h
,
struct
MT2063_AvoidSpursData_t
*
pAS_Info
)
{
{
u32
status
=
MT2063_OK
;
u32
status
=
0
;
u32
fm
,
fp
;
/* restricted range on LO's */
u32
fm
,
fp
;
/* restricted range on LO's */
pAS_Info
->
bSpurAvoided
=
0
;
pAS_Info
->
bSpurAvoided
=
0
;
pAS_Info
->
nSpursFound
=
0
;
pAS_Info
->
nSpursFound
=
0
;
if
(
pAS_Info
->
maxH1
==
0
)
if
(
pAS_Info
->
maxH1
==
0
)
return
MT2063_OK
;
return
0
;
/*
/*
** Avoid LO Generated Spurs
** Avoid LO Generated Spurs
...
@@ -2030,14 +1984,14 @@ static u32 MT2063_fLO_FractionalTerm(u32 f_ref, u32 num,
...
@@ -2030,14 +1984,14 @@ static u32 MT2063_fLO_FractionalTerm(u32 f_ref, u32 num,
******************************************************************************/
******************************************************************************/
static
u32
MT2063_Open
(
u32
MT2063_Addr
,
struct
MT2063_Info_t
**
hMT2063
,
void
*
hUserData
)
static
u32
MT2063_Open
(
u32
MT2063_Addr
,
struct
MT2063_Info_t
**
hMT2063
,
void
*
hUserData
)
{
{
u32
status
=
MT2063_OK
;
/* Status to be returned. */
u32
status
=
0
;
/* Status to be returned. */
struct
MT2063_Info_t
*
pInfo
=
NULL
;
struct
MT2063_Info_t
*
pInfo
=
NULL
;
struct
dvb_frontend
*
fe
=
(
struct
dvb_frontend
*
)
hUserData
;
struct
dvb_frontend
*
fe
=
(
struct
dvb_frontend
*
)
hUserData
;
struct
mt2063_state
*
state
=
fe
->
tuner_priv
;
struct
mt2063_state
*
state
=
fe
->
tuner_priv
;
/* Check the argument before using */
/* Check the argument before using */
if
(
hMT2063
==
NULL
)
{
if
(
hMT2063
==
NULL
)
{
return
MT2063_ARG_NULL
;
return
-
ENODEV
;
}
}
/* Default tuner handle to NULL. If successful, it will be reassigned */
/* Default tuner handle to NULL. If successful, it will be reassigned */
...
@@ -2045,7 +1999,7 @@ static u32 MT2063_Open(u32 MT2063_Addr, struct MT2063_Info_t **hMT2063, void *hU
...
@@ -2045,7 +1999,7 @@ static u32 MT2063_Open(u32 MT2063_Addr, struct MT2063_Info_t **hMT2063, void *hU
if
(
state
->
MT2063_init
==
false
)
{
if
(
state
->
MT2063_init
==
false
)
{
pInfo
=
kzalloc
(
sizeof
(
struct
MT2063_Info_t
),
GFP_KERNEL
);
pInfo
=
kzalloc
(
sizeof
(
struct
MT2063_Info_t
),
GFP_KERNEL
);
if
(
pInfo
==
NULL
)
{
if
(
pInfo
==
NULL
)
{
return
MT2063_TUNER_OPEN_ERR
;
return
-
ENOMEM
;
}
}
pInfo
->
handle
=
NULL
;
pInfo
->
handle
=
NULL
;
pInfo
->
address
=
MAX_UDATA
;
pInfo
->
address
=
MAX_UDATA
;
...
@@ -2055,11 +2009,11 @@ static u32 MT2063_Open(u32 MT2063_Addr, struct MT2063_Info_t **hMT2063, void *hU
...
@@ -2055,11 +2009,11 @@ static u32 MT2063_Open(u32 MT2063_Addr, struct MT2063_Info_t **hMT2063, void *hU
pInfo
=
*
hMT2063
;
pInfo
=
*
hMT2063
;
}
}
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
MT2063_RegisterTuner
(
&
pInfo
->
AS_Data
);
status
|=
MT2063_RegisterTuner
(
&
pInfo
->
AS_Data
);
}
}
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
pInfo
->
handle
=
(
void
*
)
pInfo
;
pInfo
->
handle
=
(
void
*
)
pInfo
;
pInfo
->
hUserData
=
hUserData
;
pInfo
->
hUserData
=
hUserData
;
...
@@ -2068,7 +2022,7 @@ static u32 MT2063_Open(u32 MT2063_Addr, struct MT2063_Info_t **hMT2063, void *hU
...
@@ -2068,7 +2022,7 @@ static u32 MT2063_Open(u32 MT2063_Addr, struct MT2063_Info_t **hMT2063, void *hU
status
|=
MT2063_ReInit
((
void
*
)
pInfo
);
status
|=
MT2063_ReInit
((
void
*
)
pInfo
);
}
}
if
(
MT2063_IS_ERROR
(
status
)
)
if
(
status
<
0
)
/* MT2063_Close handles the un-registration of the tuner */
/* MT2063_Close handles the un-registration of the tuner */
MT2063_Close
((
void
*
)
pInfo
);
MT2063_Close
((
void
*
)
pInfo
);
else
{
else
{
...
@@ -2106,12 +2060,10 @@ static u32 MT2063_IsValidHandle(struct MT2063_Info_t *handle)
...
@@ -2106,12 +2060,10 @@ static u32 MT2063_IsValidHandle(struct MT2063_Info_t *handle)
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
**
**
******************************************************************************/
******************************************************************************/
static
u32
MT2063_Close
(
void
*
hMT2063
)
static
u32
MT2063_Close
(
struct
MT2063_Info_t
*
pInfo
)
{
{
struct
MT2063_Info_t
*
pInfo
=
(
struct
MT2063_Info_t
*
)
hMT2063
;
if
(
!
MT2063_IsValidHandle
(
pInfo
))
if
(
!
MT2063_IsValidHandle
(
pInfo
))
return
MT2063_INV_HANDLE
;
return
-
ENODEV
;
/* Unregister tuner with SpurAvoidance routines (if needed) */
/* Unregister tuner with SpurAvoidance routines (if needed) */
MT2063_UnRegisterTuner
(
&
pInfo
->
AS_Data
);
MT2063_UnRegisterTuner
(
&
pInfo
->
AS_Data
);
...
@@ -2122,7 +2074,7 @@ static u32 MT2063_Close(void *hMT2063)
...
@@ -2122,7 +2074,7 @@ static u32 MT2063_Close(void *hMT2063)
//kfree(pInfo);
//kfree(pInfo);
//pInfo = NULL;
//pInfo = NULL;
return
MT2063_OK
;
return
0
;
}
}
/****************************************************************************
/****************************************************************************
...
@@ -2150,19 +2102,18 @@ static u32 MT2063_Close(void *hMT2063)
...
@@ -2150,19 +2102,18 @@ static u32 MT2063_Close(void *hMT2063)
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
**
**
****************************************************************************/
****************************************************************************/
static
u32
MT2063_GetLocked
(
void
*
h
)
static
u32
MT2063_GetLocked
(
struct
MT2063_Info_t
*
pInfo
)
{
{
const
u32
nMaxWait
=
100
;
/* wait a maximum of 100 msec */
const
u32
nMaxWait
=
100
;
/* wait a maximum of 100 msec */
const
u32
nPollRate
=
2
;
/* poll status bits every 2 ms */
const
u32
nPollRate
=
2
;
/* poll status bits every 2 ms */
const
u32
nMaxLoops
=
nMaxWait
/
nPollRate
;
const
u32
nMaxLoops
=
nMaxWait
/
nPollRate
;
const
u8
LO1LK
=
0x80
;
const
u8
LO1LK
=
0x80
;
u8
LO2LK
=
0x08
;
u8
LO2LK
=
0x08
;
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
u32
nDelays
=
0
;
u32
nDelays
=
0
;
struct
MT2063_Info_t
*
pInfo
=
(
struct
MT2063_Info_t
*
)
h
;
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
return
MT2063_INV_HANDLE
;
return
-
ENODEV
;
/* LO2 Lock bit was in a different place for B0 version */
/* LO2 Lock bit was in a different place for B0 version */
if
(
pInfo
->
tuner_id
==
MT2063_B0
)
if
(
pInfo
->
tuner_id
==
MT2063_B0
)
...
@@ -2174,7 +2125,7 @@ static u32 MT2063_GetLocked(void *h)
...
@@ -2174,7 +2125,7 @@ static u32 MT2063_GetLocked(void *h)
MT2063_REG_LO_STATUS
,
MT2063_REG_LO_STATUS
,
&
pInfo
->
reg
[
MT2063_REG_LO_STATUS
],
1
);
&
pInfo
->
reg
[
MT2063_REG_LO_STATUS
],
1
);
if
(
MT2063_IS_ERROR
(
status
)
)
if
(
status
<
0
)
return
(
status
);
return
(
status
);
if
((
pInfo
->
reg
[
MT2063_REG_LO_STATUS
]
&
(
LO1LK
|
LO2LK
))
==
if
((
pInfo
->
reg
[
MT2063_REG_LO_STATUS
]
&
(
LO1LK
|
LO2LK
))
==
...
@@ -2285,21 +2236,19 @@ static u32 MT2063_GetLocked(void *h)
...
@@ -2285,21 +2236,19 @@ static u32 MT2063_GetLocked(void *h)
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
**
**
****************************************************************************/
****************************************************************************/
static
u32
MT2063_GetParam
(
void
*
h
,
enum
MT2063_Param
param
,
u32
*
pValue
)
static
u32
MT2063_GetParam
(
struct
MT2063_Info_t
*
pInfo
,
enum
MT2063_Param
param
,
u32
*
pValue
)
{
{
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
struct
MT2063_Info_t
*
pInfo
=
(
struct
MT2063_Info_t
*
)
h
;
u32
Div
;
u32
Div
;
u32
Num
;
u32
Num
;
if
(
pValue
==
NULL
)
if
(
pValue
==
NULL
)
status
|=
MT2063_ARG_NUL
L
;
return
-
EINVA
L
;
/* Verify that the handle passed points to a valid tuner */
/* Verify that the handle passed points to a valid tuner */
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
status
|=
MT2063_INV_HANDLE
;
return
-
ENODEV
;
if
(
MT2063_NO_ERROR
(
status
))
{
switch
(
param
)
{
switch
(
param
)
{
/* Serial Bus address of this tuner */
/* Serial Bus address of this tuner */
case
MT2063_IC_ADDR
:
case
MT2063_IC_ADDR
:
...
@@ -2497,7 +2446,7 @@ static u32 MT2063_GetParam(void *h, enum MT2063_Param param, u32 * pValue)
...
@@ -2497,7 +2446,7 @@ static u32 MT2063_GetParam(void *h, enum MT2063_Param param, u32 * pValue)
MT2063_REG_BYP_CTRL
,
MT2063_REG_BYP_CTRL
,
&
reg
,
1
);
&
reg
,
1
);
if
(
MT2063_IS_ERROR
(
status
)
)
if
(
status
<
0
)
return
(
status
);
return
(
status
);
for
(
i
=
0
;
i
<
8
;
i
++
)
{
for
(
i
=
0
;
i
<
8
;
i
++
)
{
...
@@ -2510,7 +2459,7 @@ static u32 MT2063_GetParam(void *h, enum MT2063_Param param, u32 * pValue)
...
@@ -2510,7 +2459,7 @@ static u32 MT2063_GetParam(void *h, enum MT2063_Param param, u32 * pValue)
[
MT2063_REG_ADC_OUT
],
[
MT2063_REG_ADC_OUT
],
1
);
1
);
if
(
MT2063_NO_ERROR
(
status
)
)
if
(
status
>=
0
)
*
pValue
+=
*
pValue
+=
pInfo
->
pInfo
->
reg
[
MT2063_REG_ADC_OUT
];
reg
[
MT2063_REG_ADC_OUT
];
...
@@ -2654,8 +2603,7 @@ static u32 MT2063_GetParam(void *h, enum MT2063_Param param, u32 * pValue)
...
@@ -2654,8 +2603,7 @@ static u32 MT2063_GetParam(void *h, enum MT2063_Param param, u32 * pValue)
case
MT2063_EOP
:
case
MT2063_EOP
:
default:
default:
status
|=
MT2063_ARG_RANGE
;
status
|=
-
ERANGE
;
}
}
}
return
(
status
);
return
(
status
);
}
}
...
@@ -2689,28 +2637,22 @@ static u32 MT2063_GetParam(void *h, enum MT2063_Param param, u32 * pValue)
...
@@ -2689,28 +2637,22 @@ static u32 MT2063_GetParam(void *h, enum MT2063_Param param, u32 * pValue)
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
**
**
****************************************************************************/
****************************************************************************/
static
u32
MT2063_GetReg
(
void
*
h
,
u8
reg
,
u8
*
val
)
static
u32
MT2063_GetReg
(
struct
MT2063_Info_t
*
pInfo
,
u8
reg
,
u8
*
val
)
{
{
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
struct
MT2063_Info_t
*
pInfo
=
(
struct
MT2063_Info_t
*
)
h
;
/* Verify that the handle passed points to a valid tuner */
/* Verify that the handle passed points to a valid tuner */
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
status
|=
MT2063_INV_HANDLE
;
return
-
ENODEV
;
if
(
val
==
NULL
)
if
(
val
==
NULL
)
status
|=
MT2063_ARG_NUL
L
;
return
-
EINVA
L
;
if
(
reg
>=
MT2063_REG_END_REGS
)
if
(
reg
>=
MT2063_REG_END_REGS
)
status
|=
MT2063_ARG_
RANGE
;
return
-
E
RANGE
;
if
(
MT2063_NO_ERROR
(
status
))
{
status
=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
reg
,
status
|=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
reg
,
&
pInfo
->
reg
[
reg
],
1
);
&
pInfo
->
reg
[
reg
],
1
);
if
(
MT2063_NO_ERROR
(
status
))
*
val
=
pInfo
->
reg
[
reg
];
}
return
(
status
);
return
(
status
);
}
}
...
@@ -2801,15 +2743,15 @@ static u32 MT2063_GetReg(void *h, u8 reg, u8 * val)
...
@@ -2801,15 +2743,15 @@ static u32 MT2063_GetReg(void *h, u8 reg, u8 * val)
static
u32
MT2063_SetReceiverMode
(
struct
MT2063_Info_t
*
pInfo
,
static
u32
MT2063_SetReceiverMode
(
struct
MT2063_Info_t
*
pInfo
,
enum
MT2063_RCVR_MODES
Mode
)
enum
MT2063_RCVR_MODES
Mode
)
{
{
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
u8
val
;
u8
val
;
u32
longval
;
u32
longval
;
if
(
Mode
>=
MT2063_NUM_RCVR_MODES
)
if
(
Mode
>=
MT2063_NUM_RCVR_MODES
)
status
=
MT2063_ARG_
RANGE
;
status
=
-
E
RANGE
;
/* RFAGCen */
/* RFAGCen */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
val
=
val
=
(
pInfo
->
(
pInfo
->
reg
[
MT2063_REG_PD1_TGT
]
&
(
u8
)
~
0x40
)
|
(
RFAGCEN
[
Mode
]
reg
[
MT2063_REG_PD1_TGT
]
&
(
u8
)
~
0x40
)
|
(
RFAGCEN
[
Mode
]
...
@@ -2821,12 +2763,12 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
...
@@ -2821,12 +2763,12 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
}
}
/* LNARin */
/* LNARin */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_LNA_RIN
,
LNARIN
[
Mode
]);
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_LNA_RIN
,
LNARIN
[
Mode
]);
}
}
/* FIFFQEN and FIFFQ */
/* FIFFQEN and FIFFQ */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
val
=
val
=
(
pInfo
->
(
pInfo
->
reg
[
MT2063_REG_FIFF_CTRL2
]
&
(
u8
)
~
0xF0
)
|
reg
[
MT2063_REG_FIFF_CTRL2
]
&
(
u8
)
~
0xF0
)
|
...
@@ -2852,40 +2794,40 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
...
@@ -2852,40 +2794,40 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_DNC_OUTPUT_ENABLE
,
longval
);
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_DNC_OUTPUT_ENABLE
,
longval
);
/* acLNAmax */
/* acLNAmax */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_ACLNA_MAX
,
ACLNAMAX
[
Mode
]);
MT2063_SetParam
(
pInfo
,
MT2063_ACLNA_MAX
,
ACLNAMAX
[
Mode
]);
}
}
/* LNATGT */
/* LNATGT */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_LNA_TGT
,
LNATGT
[
Mode
]);
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_LNA_TGT
,
LNATGT
[
Mode
]);
}
}
/* ACRF */
/* ACRF */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_ACRF_MAX
,
ACRFMAX
[
Mode
]);
MT2063_SetParam
(
pInfo
,
MT2063_ACRF_MAX
,
ACRFMAX
[
Mode
]);
}
}
/* PD1TGT */
/* PD1TGT */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_PD1_TGT
,
PD1TGT
[
Mode
]);
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_PD1_TGT
,
PD1TGT
[
Mode
]);
}
}
/* FIFATN */
/* FIFATN */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_ACFIF_MAX
,
ACFIFMAX
[
Mode
]);
MT2063_SetParam
(
pInfo
,
MT2063_ACFIF_MAX
,
ACFIFMAX
[
Mode
]);
}
}
/* PD2TGT */
/* PD2TGT */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_PD2_TGT
,
PD2TGT
[
Mode
]);
status
|=
MT2063_SetParam
(
pInfo
,
MT2063_PD2_TGT
,
PD2TGT
[
Mode
]);
}
}
/* Ignore ATN Overload */
/* Ignore ATN Overload */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
val
=
val
=
(
pInfo
->
(
pInfo
->
reg
[
MT2063_REG_LNA_TGT
]
&
(
u8
)
~
0x80
)
|
(
RFOVDIS
[
Mode
]
reg
[
MT2063_REG_LNA_TGT
]
&
(
u8
)
~
0x80
)
|
(
RFOVDIS
[
Mode
]
...
@@ -2897,7 +2839,7 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
...
@@ -2897,7 +2839,7 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
}
}
/* Ignore FIF Overload */
/* Ignore FIF Overload */
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
val
=
val
=
(
pInfo
->
(
pInfo
->
reg
[
MT2063_REG_PD1_TGT
]
&
(
u8
)
~
0x80
)
|
reg
[
MT2063_REG_PD1_TGT
]
&
(
u8
)
~
0x80
)
|
...
@@ -2907,7 +2849,7 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
...
@@ -2907,7 +2849,7 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
}
}
}
}
if
(
MT2063_NO_ERROR
(
status
)
)
if
(
status
>=
0
)
pInfo
->
rcvr_mode
=
Mode
;
pInfo
->
rcvr_mode
=
Mode
;
return
(
status
);
return
(
status
);
...
@@ -2947,13 +2889,15 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
...
@@ -2947,13 +2889,15 @@ static u32 MT2063_SetReceiverMode(struct MT2063_Info_t *pInfo,
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
**
**
******************************************************************************/
******************************************************************************/
static
u32
MT2063_ReInit
(
void
*
h
)
static
u32
MT2063_ReInit
(
struct
MT2063_Info_t
*
pInfo
)
{
{
u8
all_resets
=
0xF0
;
/* reset/load bits */
u8
all_resets
=
0xF0
;
/* reset/load bits */
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
struct
MT2063_Info_t
*
pInfo
=
(
struct
MT2063_Info_t
*
)
h
;
u8
*
def
=
NULL
;
u8
*
def
=
NULL
;
u32
FCRUN
;
s32
maxReads
;
u32
fcu_osc
;
u32
i
;
u8
MT2063B0_defaults
[]
=
{
/* Reg, Value */
u8
MT2063B0_defaults
[]
=
{
/* Reg, Value */
0x19
,
0x05
,
0x19
,
0x05
,
0x1B
,
0x1D
,
0x1B
,
0x1D
,
...
@@ -2976,7 +2920,6 @@ static u32 MT2063_ReInit(void *h)
...
@@ -2976,7 +2920,6 @@ static u32 MT2063_ReInit(void *h)
0x28
,
0xE0
,
/* Clear the FIFCrst bit here */
0x28
,
0xE0
,
/* Clear the FIFCrst bit here */
0x00
0x00
};
};
/* writing 0x05 0xf0 sw-resets all registers, so we write only needed changes */
/* writing 0x05 0xf0 sw-resets all registers, so we write only needed changes */
u8
MT2063B1_defaults
[]
=
{
/* Reg, Value */
u8
MT2063B1_defaults
[]
=
{
/* Reg, Value */
0x05
,
0xF0
,
0x05
,
0xF0
,
...
@@ -3002,7 +2945,6 @@ static u32 MT2063_ReInit(void *h)
...
@@ -3002,7 +2945,6 @@ static u32 MT2063_ReInit(void *h)
0x28
,
0xE0
,
/* Clear the FIFCrst bit here */
0x28
,
0xE0
,
/* Clear the FIFCrst bit here */
0x00
0x00
};
};
/* writing 0x05 0xf0 sw-resets all registers, so we write only needed changes */
/* writing 0x05 0xf0 sw-resets all registers, so we write only needed changes */
u8
MT2063B3_defaults
[]
=
{
/* Reg, Value */
u8
MT2063B3_defaults
[]
=
{
/* Reg, Value */
0x05
,
0xF0
,
0x05
,
0xF0
,
...
@@ -3016,37 +2958,35 @@ static u32 MT2063_ReInit(void *h)
...
@@ -3016,37 +2958,35 @@ static u32 MT2063_ReInit(void *h)
/* Verify that the handle passed points to a valid tuner */
/* Verify that the handle passed points to a valid tuner */
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
status
|=
MT2063_INV_HANDLE
;
return
-
ENODEV
;
/* Read the Part/Rev code from the tuner */
/* Read the Part/Rev code from the tuner */
if
(
MT2063_NO_ERROR
(
status
))
{
status
=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
status
|=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_REG_PART_REV
,
pInfo
->
reg
,
1
);
MT2063_REG_PART_REV
,
pInfo
->
reg
,
1
);
}
if
(
status
<
0
)
return
status
;
if
(
MT2063_NO_ERROR
(
status
)
/* Check the part/rev code */
/* Check the part/rev code */
&&
((
pInfo
->
reg
[
MT2063_REG_PART_REV
]
!=
MT2063_B0
)
/* MT2063 B0 */
if
(
((
pInfo
->
reg
[
MT2063_REG_PART_REV
]
!=
MT2063_B0
)
/* MT2063 B0 */
&&
(
pInfo
->
reg
[
MT2063_REG_PART_REV
]
!=
MT2063_B1
)
/* MT2063 B1 */
&&
(
pInfo
->
reg
[
MT2063_REG_PART_REV
]
!=
MT2063_B1
)
/* MT2063 B1 */
&&
(
pInfo
->
reg
[
MT2063_REG_PART_REV
]
!=
MT2063_B3
)))
/* MT2063 B3 */
&&
(
pInfo
->
reg
[
MT2063_REG_PART_REV
]
!=
MT2063_B3
)))
/* MT2063 B3 */
status
|=
MT2063_TUNER_ID_ERR
;
/* Wrong tuner Part/Rev code */
return
-
ENODEV
;
/* Wrong tuner Part/Rev code */
/* Read the Part/Rev code (2nd byte) from the tuner */
/* Check the 2nd byte of the Part/Rev code from the tuner */
if
(
MT2063_NO_ERROR
(
status
))
status
=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
status
|=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_REG_RSVD_3B
,
MT2063_REG_RSVD_3B
,
&
pInfo
->
reg
[
MT2063_REG_RSVD_3B
],
1
);
&
pInfo
->
reg
[
MT2063_REG_RSVD_3B
],
1
);
if
(
MT2063_NO_ERROR
(
status
)
/* Check the 2nd part/rev code */
if
(
status
>=
0
&&
((
pInfo
->
reg
[
MT2063_REG_RSVD_3B
]
&
0x80
)
!=
0x00
))
/* b7 != 0 ==> NOT MT2063 */
&&
((
pInfo
->
reg
[
MT2063_REG_RSVD_3B
]
&
0x80
)
!=
0x00
))
/* b7 != 0 ==> NOT MT2063 */
status
|=
MT2063_TUNER_ID_ERR
;
/* Wrong tuner Part/Rev code */
return
-
ENODEV
;
/* Wrong tuner Part/Rev code */
/* Reset the tuner */
/* Reset the tuner */
if
(
MT2063_NO_ERROR
(
status
))
status
=
MT2063_WriteSub
(
pInfo
->
hUserData
,
status
|=
MT2063_WriteSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
pInfo
->
address
,
MT2063_REG_LO2CQ_3
,
&
all_resets
,
1
);
MT2063_REG_LO2CQ_3
,
&
all_resets
,
1
);
if
(
status
<
0
)
return
status
;
/* change all of the default values that vary from the HW reset values */
/* change all of the default values that vary from the HW reset values */
/* def = (pInfo->reg[PART_REV] == MT2063_B0) ? MT2063B0_defaults : MT2063B1_defaults; */
/* def = (pInfo->reg[PART_REV] == MT2063_B0) ? MT2063B0_defaults : MT2063B1_defaults; */
...
@@ -3064,26 +3004,25 @@ static u32 MT2063_ReInit(void *h)
...
@@ -3064,26 +3004,25 @@ static u32 MT2063_ReInit(void *h)
break
;
break
;
default:
default:
status
|=
MT2063_TUNER_ID_ERR
;
return
-
ENODEV
;
break
;
break
;
}
}
while
(
MT2063_NO_ERROR
(
status
)
&&
*
def
)
{
while
(
status
>=
0
&&
*
def
)
{
u8
reg
=
*
def
++
;
u8
reg
=
*
def
++
;
u8
val
=
*
def
++
;
u8
val
=
*
def
++
;
status
|=
status
=
MT2063_WriteSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
reg
,
MT2063_WriteSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
reg
,
&
val
,
&
val
,
1
);
1
);
}
}
if
(
status
<
0
)
return
status
;
/* Wait for FIFF location to complete. */
/* Wait for FIFF location to complete. */
if
(
MT2063_NO_ERROR
(
status
))
{
FCRUN
=
1
;
u32
FCRUN
=
1
;
maxReads
=
10
;
s32
maxReads
=
10
;
while
(
status
>=
0
&&
(
FCRUN
!=
0
)
&&
(
maxReads
--
>
0
))
{
while
(
MT2063_NO_ERROR
(
status
)
&&
(
FCRUN
!=
0
)
&&
(
maxReads
--
>
0
))
{
msleep
(
2
);
msleep
(
2
);
status
|
=
MT2063_ReadSub
(
pInfo
->
hUserData
,
status
=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
pInfo
->
address
,
MT2063_REG_XO_STATUS
,
MT2063_REG_XO_STATUS
,
&
pInfo
->
&
pInfo
->
...
@@ -3092,28 +3031,26 @@ static u32 MT2063_ReInit(void *h)
...
@@ -3092,28 +3031,26 @@ static u32 MT2063_ReInit(void *h)
}
}
if
(
FCRUN
!=
0
)
if
(
FCRUN
!=
0
)
status
|=
MT2063_TUNER_INIT_ERR
|
MT2063_TUNER_TIMEOUT
;
return
-
ENODEV
;
if
(
MT2063_NO_ERROR
(
status
))
/* Re-read FIFFC value */
status
=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
status
|=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_REG_FIFFC
,
MT2063_REG_FIFFC
,
&
pInfo
->
reg
[
MT2063_REG_FIFFC
],
1
);
&
pInfo
->
reg
[
MT2063_REG_FIFFC
],
1
);
}
if
(
status
<
0
)
return
status
;
/* Read back all the registers from the tuner */
/* Read back all the registers from the tuner */
if
(
MT2063_NO_ERROR
(
status
))
status
=
MT2063_ReadSub
(
pInfo
->
hUserData
,
status
|=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
pInfo
->
address
,
MT2063_REG_PART_REV
,
MT2063_REG_PART_REV
,
pInfo
->
reg
,
MT2063_REG_END_REGS
);
pInfo
->
reg
,
MT2063_REG_END_REGS
);
if
(
status
<
0
)
return
status
;
if
(
MT2063_NO_ERROR
(
status
))
{
/* Initialize the tuner state. */
/* Initialize the tuner state. */
pInfo
->
tuner_id
=
pInfo
->
reg
[
MT2063_REG_PART_REV
];
pInfo
->
tuner_id
=
pInfo
->
reg
[
MT2063_REG_PART_REV
];
pInfo
->
AS_Data
.
f_ref
=
MT2063_REF_FREQ
;
pInfo
->
AS_Data
.
f_ref
=
MT2063_REF_FREQ
;
pInfo
->
AS_Data
.
f_if1_Center
=
pInfo
->
AS_Data
.
f_if1_Center
=
(
pInfo
->
AS_Data
.
f_ref
/
8
)
*
(
pInfo
->
AS_Data
.
f_ref
/
8
)
*
((
u32
)
pInfo
->
reg
[
MT2063_REG_FIFFC
]
+
640
);
((
u32
)
pInfo
->
reg
[
MT2063_REG_FIFFC
]
+
640
);
pInfo
->
AS_Data
.
f_if1_bw
=
MT2063_IF1_BW
;
pInfo
->
AS_Data
.
f_if1_bw
=
MT2063_IF1_BW
;
pInfo
->
AS_Data
.
f_out
=
43750000UL
;
pInfo
->
AS_Data
.
f_out
=
43750000UL
;
...
@@ -3128,16 +3065,13 @@ static u32 MT2063_ReInit(void *h)
...
@@ -3128,16 +3065,13 @@ static u32 MT2063_ReInit(void *h)
pInfo
->
AS_Data
.
f_LO1
=
2181000000UL
;
pInfo
->
AS_Data
.
f_LO1
=
2181000000UL
;
pInfo
->
AS_Data
.
f_LO2
=
1486249786UL
;
pInfo
->
AS_Data
.
f_LO2
=
1486249786UL
;
pInfo
->
f_IF1_actual
=
pInfo
->
AS_Data
.
f_if1_Center
;
pInfo
->
f_IF1_actual
=
pInfo
->
AS_Data
.
f_if1_Center
;
pInfo
->
AS_Data
.
f_in
=
pInfo
->
AS_Data
.
f_in
=
pInfo
->
AS_Data
.
f_LO1
-
pInfo
->
f_IF1_actual
;
pInfo
->
AS_Data
.
f_LO1
-
pInfo
->
f_IF1_actual
;
pInfo
->
AS_Data
.
f_LO1_FracN_Avoid
=
MT2063_LO1_FRACN_AVOID
;
pInfo
->
AS_Data
.
f_LO1_FracN_Avoid
=
MT2063_LO1_FRACN_AVOID
;
pInfo
->
AS_Data
.
f_LO2_FracN_Avoid
=
MT2063_LO2_FRACN_AVOID
;
pInfo
->
AS_Data
.
f_LO2_FracN_Avoid
=
MT2063_LO2_FRACN_AVOID
;
pInfo
->
num_regs
=
MT2063_REG_END_REGS
;
pInfo
->
num_regs
=
MT2063_REG_END_REGS
;
pInfo
->
AS_Data
.
avoidDECT
=
MT2063_AVOID_BOTH
;
pInfo
->
AS_Data
.
avoidDECT
=
MT2063_AVOID_BOTH
;
pInfo
->
ctfilt_sw
=
0
;
pInfo
->
ctfilt_sw
=
0
;
}
if
(
MT2063_NO_ERROR
(
status
))
{
pInfo
->
CTFiltMax
[
0
]
=
69230000
;
pInfo
->
CTFiltMax
[
0
]
=
69230000
;
pInfo
->
CTFiltMax
[
1
]
=
105770000
;
pInfo
->
CTFiltMax
[
1
]
=
105770000
;
pInfo
->
CTFiltMax
[
2
]
=
140350000
;
pInfo
->
CTFiltMax
[
2
]
=
140350000
;
...
@@ -3169,40 +3103,37 @@ static u32 MT2063_ReInit(void *h)
...
@@ -3169,40 +3103,37 @@ static u32 MT2063_ReInit(void *h)
pInfo
->
CTFiltMax
[
28
]
=
1061870000
;
pInfo
->
CTFiltMax
[
28
]
=
1061870000
;
pInfo
->
CTFiltMax
[
29
]
=
1098330000
;
pInfo
->
CTFiltMax
[
29
]
=
1098330000
;
pInfo
->
CTFiltMax
[
30
]
=
1138990000
;
pInfo
->
CTFiltMax
[
30
]
=
1138990000
;
}
/*
/*
** Fetch the FCU osc value and use it and the fRef value to
** Fetch the FCU osc value and use it and the fRef value to
** scale all of the Band Max values
** scale all of the Band Max values
*/
*/
if
(
MT2063_NO_ERROR
(
status
))
{
u32
fcu_osc
;
u32
i
;
pInfo
->
reg
[
MT2063_REG_CTUNE_CTRL
]
=
0x0A
;
pInfo
->
reg
[
MT2063_REG_CTUNE_CTRL
]
=
0x0A
;
status
|=
status
=
MT2063_WriteSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_WriteSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_REG_CTUNE_CTRL
,
MT2063_REG_CTUNE_CTRL
,
&
pInfo
->
reg
[
MT2063_REG_CTUNE_CTRL
],
1
);
&
pInfo
->
reg
[
MT2063_REG_CTUNE_CTRL
],
1
);
if
(
status
<
0
)
return
status
;
/* Read the ClearTune filter calibration value */
/* Read the ClearTune filter calibration value */
status
|=
status
=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_REG_FIFFC
,
MT2063_REG_FIFFC
,
&
pInfo
->
reg
[
MT2063_REG_FIFFC
],
1
);
&
pInfo
->
reg
[
MT2063_REG_FIFFC
],
1
);
if
(
status
<
0
)
return
status
;
fcu_osc
=
pInfo
->
reg
[
MT2063_REG_FIFFC
];
fcu_osc
=
pInfo
->
reg
[
MT2063_REG_FIFFC
];
pInfo
->
reg
[
MT2063_REG_CTUNE_CTRL
]
=
0x00
;
pInfo
->
reg
[
MT2063_REG_CTUNE_CTRL
]
=
0x00
;
status
|=
status
=
MT2063_WriteSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_WriteSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_REG_CTUNE_CTRL
,
MT2063_REG_CTUNE_CTRL
,
&
pInfo
->
reg
[
MT2063_REG_CTUNE_CTRL
],
1
);
&
pInfo
->
reg
[
MT2063_REG_CTUNE_CTRL
],
1
);
if
(
status
<
0
)
return
status
;
/* Adjust each of the values in the ClearTune filter cross-over table */
/* Adjust each of the values in the ClearTune filter cross-over table */
for
(
i
=
0
;
i
<
31
;
i
++
)
{
for
(
i
=
0
;
i
<
31
;
i
++
)
pInfo
->
CTFiltMax
[
i
]
=
pInfo
->
CTFiltMax
[
i
]
=
(
pInfo
->
CTFiltMax
[
i
]
/
768
)
*
(
fcu_osc
+
640
);
(
pInfo
->
CTFiltMax
[
i
]
/
768
)
*
(
fcu_osc
+
640
);
}
}
return
(
status
);
return
(
status
);
}
}
...
@@ -3290,17 +3221,15 @@ static u32 MT2063_ReInit(void *h)
...
@@ -3290,17 +3221,15 @@ static u32 MT2063_ReInit(void *h)
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
**
**
****************************************************************************/
****************************************************************************/
static
u32
MT2063_SetParam
(
void
*
h
,
enum
MT2063_Param
param
,
u32
nValue
)
static
u32
MT2063_SetParam
(
struct
MT2063_Info_t
*
pInfo
,
enum
MT2063_Param
param
,
u32
nValue
)
{
{
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
u8
val
=
0
;
u8
val
=
0
;
struct
MT2063_Info_t
*
pInfo
=
(
struct
MT2063_Info_t
*
)
h
;
/* Verify that the handle passed points to a valid tuner */
/* Verify that the handle passed points to a valid tuner */
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
status
|=
MT2063_INV_HANDLE
;
return
-
ENODEV
;
if
(
MT2063_NO_ERROR
(
status
))
{
switch
(
param
)
{
switch
(
param
)
{
/* crystal frequency */
/* crystal frequency */
case
MT2063_SRO_FREQ
:
case
MT2063_SRO_FREQ
:
...
@@ -3356,7 +3285,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3356,7 +3285,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
MT2063_REG_LO2CQ_1
,
MT2063_REG_LO2CQ_1
,
&
(
tempLO2C
[
0
]),
3
);
&
(
tempLO2C
[
0
]),
3
);
if
(
status
==
MT2063_OK
)
{
if
(
status
==
0
)
{
/* cache the bytes just written. */
/* cache the bytes just written. */
pInfo
->
reg
[
MT2063_REG_LO2CQ_1
]
=
pInfo
->
reg
[
MT2063_REG_LO2CQ_1
]
=
tempLO2C
[
0
];
tempLO2C
[
0
];
...
@@ -3677,7 +3606,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3677,7 +3606,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_DNC_GAIN
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_DNC_GAIN
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_DNC_GAIN
,
MT2063_REG_DNC_GAIN
,
val
);
val
);
...
@@ -3685,7 +3614,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3685,7 +3614,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_VGA_GAIN
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_VGA_GAIN
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_VGA_GAIN
,
MT2063_REG_VGA_GAIN
,
val
);
val
);
...
@@ -3693,7 +3622,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3693,7 +3622,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_RSVD_20
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_RSVD_20
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_RSVD_20
,
MT2063_REG_RSVD_20
,
val
);
val
);
...
@@ -3705,7 +3634,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3705,7 +3634,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_DNC_GAIN
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_DNC_GAIN
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_DNC_GAIN
,
MT2063_REG_DNC_GAIN
,
val
);
val
);
...
@@ -3713,7 +3642,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3713,7 +3642,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_VGA_GAIN
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_VGA_GAIN
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_VGA_GAIN
,
MT2063_REG_VGA_GAIN
,
val
);
val
);
...
@@ -3721,7 +3650,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3721,7 +3650,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_RSVD_20
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_RSVD_20
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_RSVD_20
,
MT2063_REG_RSVD_20
,
val
);
val
);
...
@@ -3733,7 +3662,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3733,7 +3662,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_DNC_GAIN
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_DNC_GAIN
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_DNC_GAIN
,
MT2063_REG_DNC_GAIN
,
val
);
val
);
...
@@ -3741,7 +3670,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3741,7 +3670,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_VGA_GAIN
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_VGA_GAIN
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_VGA_GAIN
,
MT2063_REG_VGA_GAIN
,
val
);
val
);
...
@@ -3749,7 +3678,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3749,7 +3678,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_RSVD_20
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_RSVD_20
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_RSVD_20
,
MT2063_REG_RSVD_20
,
val
);
val
);
...
@@ -3761,7 +3690,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3761,7 +3690,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_DNC_GAIN
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_DNC_GAIN
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_DNC_GAIN
,
MT2063_REG_DNC_GAIN
,
val
);
val
);
...
@@ -3769,7 +3698,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3769,7 +3698,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_VGA_GAIN
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_VGA_GAIN
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_VGA_GAIN
,
MT2063_REG_VGA_GAIN
,
val
);
val
);
...
@@ -3777,7 +3706,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3777,7 +3706,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
if
(
pInfo
->
reg
[
MT2063_REG_RSVD_20
]
!=
if
(
pInfo
->
reg
[
MT2063_REG_RSVD_20
]
!=
val
)
val
)
status
|=
status
|=
MT2063_SetReg
(
h
,
MT2063_SetReg
(
pInfo
,
MT2063_REG_RSVD_20
,
MT2063_REG_RSVD_20
,
val
);
val
);
...
@@ -3877,8 +3806,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3877,8 +3806,7 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
case
MT2063_ACFIF
:
case
MT2063_ACFIF
:
case
MT2063_EOP
:
case
MT2063_EOP
:
default:
default:
status
|=
MT2063_ARG_RANGE
;
status
|=
-
ERANGE
;
}
}
}
return
(
status
);
return
(
status
);
}
}
...
@@ -3912,12 +3840,11 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
...
@@ -3912,12 +3840,11 @@ static u32 MT2063_SetParam(void *h, enum MT2063_Param param, u32 nValue)
****************************************************************************/
****************************************************************************/
static
u32
MT2063_ClearPowerMaskBits
(
struct
MT2063_Info_t
*
pInfo
,
enum
MT2063_Mask_Bits
Bits
)
static
u32
MT2063_ClearPowerMaskBits
(
struct
MT2063_Info_t
*
pInfo
,
enum
MT2063_Mask_Bits
Bits
)
{
{
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
/* Verify that the handle passed points to a valid tuner */
/* Verify that the handle passed points to a valid tuner */
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
status
=
MT2063_INV_HANDLE
;
return
-
ENODEV
;
else
{
Bits
=
(
enum
MT2063_Mask_Bits
)(
Bits
&
MT2063_ALL_SD
);
/* Only valid bits for this tuner */
Bits
=
(
enum
MT2063_Mask_Bits
)(
Bits
&
MT2063_ALL_SD
);
/* Only valid bits for this tuner */
if
((
Bits
&
0xFF00
)
!=
0
)
{
if
((
Bits
&
0xFF00
)
!=
0
)
{
pInfo
->
reg
[
MT2063_REG_PWR_2
]
&=
~
(
u8
)
(
Bits
>>
8
);
pInfo
->
reg
[
MT2063_REG_PWR_2
]
&=
~
(
u8
)
(
Bits
>>
8
);
...
@@ -3933,7 +3860,6 @@ static u32 MT2063_ClearPowerMaskBits(struct MT2063_Info_t *pInfo, enum MT2063_Ma
...
@@ -3933,7 +3860,6 @@ static u32 MT2063_ClearPowerMaskBits(struct MT2063_Info_t *pInfo, enum MT2063_Ma
MT2063_REG_PWR_1
,
MT2063_REG_PWR_1
,
&
pInfo
->
reg
[
MT2063_REG_PWR_1
],
1
);
&
pInfo
->
reg
[
MT2063_REG_PWR_1
],
1
);
}
}
}
return
(
status
);
return
(
status
);
}
}
...
@@ -3968,12 +3894,11 @@ static u32 MT2063_ClearPowerMaskBits(struct MT2063_Info_t *pInfo, enum MT2063_Ma
...
@@ -3968,12 +3894,11 @@ static u32 MT2063_ClearPowerMaskBits(struct MT2063_Info_t *pInfo, enum MT2063_Ma
****************************************************************************/
****************************************************************************/
static
u32
MT2063_SoftwareShutdown
(
struct
MT2063_Info_t
*
pInfo
,
u8
Shutdown
)
static
u32
MT2063_SoftwareShutdown
(
struct
MT2063_Info_t
*
pInfo
,
u8
Shutdown
)
{
{
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
/* Verify that the handle passed points to a valid tuner */
/* Verify that the handle passed points to a valid tuner */
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
{
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
status
=
MT2063_INV_HANDLE
;
return
-
ENODEV
;
}
else
{
if
(
Shutdown
==
1
)
if
(
Shutdown
==
1
)
pInfo
->
reg
[
MT2063_REG_PWR_1
]
|=
0x04
;
/* Turn the bit on */
pInfo
->
reg
[
MT2063_REG_PWR_1
]
|=
0x04
;
/* Turn the bit on */
else
else
...
@@ -4000,7 +3925,6 @@ static u32 MT2063_SoftwareShutdown(struct MT2063_Info_t *pInfo, u8 Shutdown)
...
@@ -4000,7 +3925,6 @@ static u32 MT2063_SoftwareShutdown(struct MT2063_Info_t *pInfo, u8 Shutdown)
&
pInfo
->
reg
[
MT2063_REG_BYP_CTRL
],
&
pInfo
->
reg
[
MT2063_REG_BYP_CTRL
],
1
);
1
);
}
}
}
return
(
status
);
return
(
status
);
}
}
...
@@ -4033,25 +3957,21 @@ static u32 MT2063_SoftwareShutdown(struct MT2063_Info_t *pInfo, u8 Shutdown)
...
@@ -4033,25 +3957,21 @@ static u32 MT2063_SoftwareShutdown(struct MT2063_Info_t *pInfo, u8 Shutdown)
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
** 138 06-19-2007 DAD Ver 1.00: Initial, derived from mt2067_b.
**
**
****************************************************************************/
****************************************************************************/
static
u32
MT2063_SetReg
(
void
*
h
,
u8
reg
,
u8
val
)
static
u32
MT2063_SetReg
(
struct
MT2063_Info_t
*
pInfo
,
u8
reg
,
u8
val
)
{
{
u32
status
=
MT2063_OK
;
/* Status to be returned */
u32
status
=
0
;
/* Status to be returned */
struct
MT2063_Info_t
*
pInfo
=
(
struct
MT2063_Info_t
*
)
h
;
/* Verify that the handle passed points to a valid tuner */
/* Verify that the handle passed points to a valid tuner */
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
status
|=
MT2063_INV_HANDLE
;
return
-
ENODEV
;
if
(
reg
>=
MT2063_REG_END_REGS
)
if
(
reg
>=
MT2063_REG_END_REGS
)
status
|=
MT2063_ARG_
RANGE
;
status
|=
-
E
RANGE
;
if
(
MT2063_NO_ERROR
(
status
))
{
status
=
MT2063_WriteSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
reg
,
&
val
,
status
|=
MT2063_WriteSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
reg
,
&
val
,
1
);
1
);
if
(
MT2063_NO_ERROR
(
status
)
)
if
(
status
>=
0
)
pInfo
->
reg
[
reg
]
=
val
;
pInfo
->
reg
[
reg
]
=
val
;
}
return
(
status
);
return
(
status
);
}
}
...
@@ -4271,11 +4191,10 @@ static u32 FindClearTuneFilter(struct MT2063_Info_t *pInfo, u32 f_in)
...
@@ -4271,11 +4191,10 @@ static u32 FindClearTuneFilter(struct MT2063_Info_t *pInfo, u32 f_in)
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
** 06-24-2008 PINZ Ver 1.18: Add Get/SetParam CTFILT_SW
**
**
****************************************************************************/
****************************************************************************/
static
u32
MT2063_Tune
(
void
*
h
,
u32
f_in
)
static
u32
MT2063_Tune
(
struct
MT2063_Info_t
*
pInfo
,
u32
f_in
)
{
/* RF input center frequency */
{
/* RF input center frequency */
struct
MT2063_Info_t
*
pInfo
=
(
struct
MT2063_Info_t
*
)
h
;
u32
status
=
MT2063_OK
;
/* status of operation */
u32
status
=
0
;
/* status of operation */
u32
LO1
;
/* 1st LO register value */
u32
LO1
;
/* 1st LO register value */
u32
Num1
;
/* Numerator for LO1 reg. value */
u32
Num1
;
/* Numerator for LO1 reg. value */
u32
f_IF1
;
/* 1st IF requested */
u32
f_IF1
;
/* 1st IF requested */
...
@@ -4292,15 +4211,15 @@ static u32 MT2063_Tune(void *h, u32 f_in)
...
@@ -4292,15 +4211,15 @@ static u32 MT2063_Tune(void *h, u32 f_in)
/* Verify that the handle passed points to a valid tuner */
/* Verify that the handle passed points to a valid tuner */
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
if
(
MT2063_IsValidHandle
(
pInfo
)
==
0
)
return
MT2063_INV_HANDLE
;
return
-
ENODEV
;
/* Check the input and output frequency ranges */
/* Check the input and output frequency ranges */
if
((
f_in
<
MT2063_MIN_FIN_FREQ
)
||
(
f_in
>
MT2063_MAX_FIN_FREQ
))
if
((
f_in
<
MT2063_MIN_FIN_FREQ
)
||
(
f_in
>
MT2063_MAX_FIN_FREQ
))
status
|=
MT2063_FIN_RANGE
;
return
-
EINVAL
;
if
((
pInfo
->
AS_Data
.
f_out
<
MT2063_MIN_FOUT_FREQ
)
if
((
pInfo
->
AS_Data
.
f_out
<
MT2063_MIN_FOUT_FREQ
)
||
(
pInfo
->
AS_Data
.
f_out
>
MT2063_MAX_FOUT_FREQ
))
||
(
pInfo
->
AS_Data
.
f_out
>
MT2063_MAX_FOUT_FREQ
))
status
|=
MT2063_FOUT_RANGE
;
return
-
EINVAL
;
/*
/*
** Save original LO1 and LO2 register values
** Save original LO1 and LO2 register values
...
@@ -4333,7 +4252,7 @@ static u32 MT2063_Tune(void *h, u32 f_in)
...
@@ -4333,7 +4252,7 @@ static u32 MT2063_Tune(void *h, u32 f_in)
/*
/*
** Read the FIFF Center Frequency from the tuner
** Read the FIFF Center Frequency from the tuner
*/
*/
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
status
|=
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_ReadSub
(
pInfo
->
hUserData
,
pInfo
->
address
,
MT2063_REG_FIFFC
,
MT2063_REG_FIFFC
,
...
@@ -4370,7 +4289,7 @@ static u32 MT2063_Tune(void *h, u32 f_in)
...
@@ -4370,7 +4289,7 @@ static u32 MT2063_Tune(void *h, u32 f_in)
** Check for any LO spurs in the output bandwidth and adjust
** Check for any LO spurs in the output bandwidth and adjust
** the LO settings to avoid them if needed
** the LO settings to avoid them if needed
*/
*/
status
|=
MT2063_AvoidSpurs
(
h
,
&
pInfo
->
AS_Data
);
status
|=
MT2063_AvoidSpurs
(
pInfo
,
&
pInfo
->
AS_Data
);
/*
/*
** MT_AvoidSpurs spurs may have changed the LO1 & LO2 values.
** MT_AvoidSpurs spurs may have changed the LO1 & LO2 values.
** Recalculate the LO frequencies and the values to be placed
** Recalculate the LO frequencies and the values to be placed
...
@@ -4425,7 +4344,7 @@ static u32 MT2063_Tune(void *h, u32 f_in)
...
@@ -4425,7 +4344,7 @@ static u32 MT2063_Tune(void *h, u32 f_in)
** Place all of the calculated values into the local tuner
** Place all of the calculated values into the local tuner
** register fields.
** register fields.
*/
*/
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
pInfo
->
reg
[
MT2063_REG_LO1CQ_1
]
=
(
u8
)
(
LO1
&
0xFF
);
/* DIV1q */
pInfo
->
reg
[
MT2063_REG_LO1CQ_1
]
=
(
u8
)
(
LO1
&
0xFF
);
/* DIV1q */
pInfo
->
reg
[
MT2063_REG_LO1CQ_2
]
=
(
u8
)
(
Num1
&
0x3F
);
/* NUM1q */
pInfo
->
reg
[
MT2063_REG_LO1CQ_2
]
=
(
u8
)
(
Num1
&
0x3F
);
/* NUM1q */
pInfo
->
reg
[
MT2063_REG_LO2CQ_1
]
=
(
u8
)
(((
LO2
&
0x7F
)
<<
1
)
/* DIV2q */
pInfo
->
reg
[
MT2063_REG_LO2CQ_1
]
=
(
u8
)
(((
LO2
&
0x7F
)
<<
1
)
/* DIV2q */
...
@@ -4462,13 +4381,13 @@ static u32 MT2063_Tune(void *h, u32 f_in)
...
@@ -4462,13 +4381,13 @@ static u32 MT2063_Tune(void *h, u32 f_in)
** Check for LO's locking
** Check for LO's locking
*/
*/
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
status
|=
MT2063_GetLocked
(
h
);
status
|=
MT2063_GetLocked
(
pInfo
);
}
}
/*
/*
** If we locked OK, assign calculated data to MT2063_Info_t structure
** If we locked OK, assign calculated data to MT2063_Info_t structure
*/
*/
if
(
MT2063_NO_ERROR
(
status
)
)
{
if
(
status
>=
0
)
{
pInfo
->
f_IF1_actual
=
pInfo
->
AS_Data
.
f_LO1
-
f_in
;
pInfo
->
f_IF1_actual
=
pInfo
->
AS_Data
.
f_LO1
-
f_in
;
}
}
}
}
...
@@ -4480,7 +4399,7 @@ static u32 MT_Tune_atv(void *h, u32 f_in, u32 bw_in,
...
@@ -4480,7 +4399,7 @@ static u32 MT_Tune_atv(void *h, u32 f_in, u32 bw_in,
enum
MTTune_atv_standard
tv_type
)
enum
MTTune_atv_standard
tv_type
)
{
{
u32
status
=
MT2063_OK
;
u32
status
=
0
;
s32
pict_car
=
0
;
s32
pict_car
=
0
;
s32
pict2chanb_vsb
=
0
;
s32
pict2chanb_vsb
=
0
;
...
@@ -4608,14 +4527,14 @@ static u32 MT_Tune_atv(void *h, u32 f_in, u32 bw_in,
...
@@ -4608,14 +4527,14 @@ static u32 MT_Tune_atv(void *h, u32 f_in, u32 bw_in,
static
int
mt2063_init
(
struct
dvb_frontend
*
fe
)
static
int
mt2063_init
(
struct
dvb_frontend
*
fe
)
{
{
u32
status
=
MT2063_ERROR
;
u32
status
=
-
EINVAL
;
struct
mt2063_state
*
state
=
fe
->
tuner_priv
;
struct
mt2063_state
*
state
=
fe
->
tuner_priv
;
status
=
MT2063_Open
(
0xC0
,
&
(
state
->
MT2063_ht
),
fe
);
status
=
MT2063_Open
(
0xC0
,
&
(
state
->
MT2063_ht
),
fe
);
status
|=
MT2063_SoftwareShutdown
(
state
->
MT2063_ht
,
1
);
status
|=
MT2063_SoftwareShutdown
(
state
->
MT2063_ht
,
1
);
status
|=
MT2063_ClearPowerMaskBits
(
state
->
MT2063_ht
,
MT2063_ALL_SD
);
status
|=
MT2063_ClearPowerMaskBits
(
state
->
MT2063_ht
,
MT2063_ALL_SD
);
if
(
MT2063_OK
!=
status
)
{
if
(
0
!=
status
)
{
printk
(
"%s %d error status = 0x%x!!
\n
"
,
__func__
,
__LINE__
,
printk
(
"%s %d error status = 0x%x!!
\n
"
,
__func__
,
__LINE__
,
status
);
status
);
return
-
1
;
return
-
1
;
...
@@ -4665,7 +4584,7 @@ static int mt2063_set_state(struct dvb_frontend *fe,
...
@@ -4665,7 +4584,7 @@ static int mt2063_set_state(struct dvb_frontend *fe,
enum
tuner_param
param
,
struct
tuner_state
*
state
)
enum
tuner_param
param
,
struct
tuner_state
*
state
)
{
{
struct
mt2063_state
*
mt2063State
=
fe
->
tuner_priv
;
struct
mt2063_state
*
mt2063State
=
fe
->
tuner_priv
;
u32
status
=
MT2063_OK
;
u32
status
=
0
;
switch
(
param
)
{
switch
(
param
)
{
case
DVBFE_TUNER_FREQUENCY
:
case
DVBFE_TUNER_FREQUENCY
:
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录