Commit db6587bf authored by Mauro Carvalho Chehab's avatar Mauro Carvalho Chehab

[media] mt2063: Add some debug printk's

Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 669b67d9
...@@ -27,8 +27,15 @@ ...@@ -27,8 +27,15 @@
#include "mt2063.h" #include "mt2063.h"
static unsigned int verbose; static unsigned int debug;
module_param(verbose, int, 0644); module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "Set Verbosity level");
#define dprintk(level, fmt, arg...) do { \
if (debug >= level) \
printk(KERN_DEBUG "mt2063 %s: " fmt, __func__, ## arg); \
} while (0)
/* positive error codes used internally */ /* positive error codes used internally */
...@@ -248,6 +255,8 @@ static u32 mt2063_write(struct mt2063_state *state, u8 reg, u8 *data, u32 len) ...@@ -248,6 +255,8 @@ static u32 mt2063_write(struct mt2063_state *state, u8 reg, u8 *data, u32 len)
.len = len + 1 .len = len + 1
}; };
dprintk(2, "\n");
msg.buf[0] = reg; msg.buf[0] = reg;
memcpy(msg.buf + 1, data, len); memcpy(msg.buf + 1, data, len);
...@@ -270,6 +279,8 @@ static u32 mt2063_setreg(struct mt2063_state *state, u8 reg, u8 val) ...@@ -270,6 +279,8 @@ static u32 mt2063_setreg(struct mt2063_state *state, u8 reg, u8 val)
{ {
u32 status; u32 status;
dprintk(2, "\n");
if (reg >= MT2063_REG_END_REGS) if (reg >= MT2063_REG_END_REGS)
return -ERANGE; return -ERANGE;
...@@ -292,6 +303,8 @@ static u32 mt2063_read(struct mt2063_state *state, ...@@ -292,6 +303,8 @@ static u32 mt2063_read(struct mt2063_state *state,
struct dvb_frontend *fe = state->frontend; struct dvb_frontend *fe = state->frontend;
u32 i = 0; u32 i = 0;
dprintk(2, "\n");
if (fe->ops.i2c_gate_ctrl) if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1); fe->ops.i2c_gate_ctrl(fe, 1);
...@@ -353,6 +366,9 @@ static struct MT2063_ExclZone_t *InsertNode(struct MT2063_AvoidSpursData_t ...@@ -353,6 +366,9 @@ static struct MT2063_ExclZone_t *InsertNode(struct MT2063_AvoidSpursData_t
struct MT2063_ExclZone_t *pPrevNode) struct MT2063_ExclZone_t *pPrevNode)
{ {
struct MT2063_ExclZone_t *pNode; struct MT2063_ExclZone_t *pNode;
dprintk(2, "\n");
/* Check for a node in the free list */ /* Check for a node in the free list */
if (pAS_Info->freeZones != NULL) { if (pAS_Info->freeZones != NULL) {
/* Use one from the free list */ /* Use one from the free list */
...@@ -384,6 +400,8 @@ static struct MT2063_ExclZone_t *RemoveNode(struct MT2063_AvoidSpursData_t ...@@ -384,6 +400,8 @@ static struct MT2063_ExclZone_t *RemoveNode(struct MT2063_AvoidSpursData_t
{ {
struct MT2063_ExclZone_t *pNext = pNodeToRemove->next_; struct MT2063_ExclZone_t *pNext = pNodeToRemove->next_;
dprintk(2, "\n");
/* Make previous node point to the subsequent node */ /* Make previous node point to the subsequent node */
if (pPrevNode != NULL) if (pPrevNode != NULL)
pPrevNode->next_ = pNext; pPrevNode->next_ = pNext;
...@@ -413,6 +431,8 @@ static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info, ...@@ -413,6 +431,8 @@ static void MT2063_AddExclZone(struct MT2063_AvoidSpursData_t *pAS_Info,
struct MT2063_ExclZone_t *pPrev = NULL; struct MT2063_ExclZone_t *pPrev = NULL;
struct MT2063_ExclZone_t *pNext = NULL; struct MT2063_ExclZone_t *pNext = NULL;
dprintk(2, "\n");
/* Check to see if this overlaps the 1st IF filter */ /* Check to see if this overlaps the 1st IF filter */
if ((f_max > (pAS_Info->f_if1_Center - (pAS_Info->f_if1_bw / 2))) if ((f_max > (pAS_Info->f_if1_Center - (pAS_Info->f_if1_bw / 2)))
&& (f_min < (pAS_Info->f_if1_Center + (pAS_Info->f_if1_bw / 2))) && (f_min < (pAS_Info->f_if1_Center + (pAS_Info->f_if1_bw / 2)))
...@@ -462,6 +482,8 @@ static void MT2063_ResetExclZones(struct MT2063_AvoidSpursData_t *pAS_Info) ...@@ -462,6 +482,8 @@ static void MT2063_ResetExclZones(struct MT2063_AvoidSpursData_t *pAS_Info)
{ {
u32 center; u32 center;
dprintk(2, "\n");
pAS_Info->nZones = 0; /* this clears the used list */ pAS_Info->nZones = 0; /* this clears the used list */
pAS_Info->usedZones = NULL; /* reset ptr */ pAS_Info->usedZones = NULL; /* reset ptr */
pAS_Info->freeZones = NULL; /* reset ptr */ pAS_Info->freeZones = NULL; /* reset ptr */
...@@ -547,7 +569,6 @@ static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info) ...@@ -547,7 +569,6 @@ static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info)
pAS_Info->f_LO2_Step) ? pAS_Info->f_LO1_Step : pAS_Info-> pAS_Info->f_LO2_Step) ? pAS_Info->f_LO1_Step : pAS_Info->
f_LO2_Step; f_LO2_Step;
u32 f_Center; u32 f_Center;
s32 i; s32 i;
s32 j = 0; s32 j = 0;
u32 bDesiredExcluded = 0; u32 bDesiredExcluded = 0;
...@@ -557,6 +578,8 @@ static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info) ...@@ -557,6 +578,8 @@ static u32 MT2063_ChooseFirstIF(struct MT2063_AvoidSpursData_t *pAS_Info)
struct MT2063_ExclZone_t *pNode = pAS_Info->usedZones; struct MT2063_ExclZone_t *pNode = pAS_Info->usedZones;
struct MT2063_FIFZone_t zones[MT2063_MAX_ZONES]; struct MT2063_FIFZone_t zones[MT2063_MAX_ZONES];
dprintk(2, "\n");
if (pAS_Info->nZones == 0) if (pAS_Info->nZones == 0)
return f_Desired; return f_Desired;
...@@ -692,6 +715,9 @@ static u32 IsSpurInBand(struct MT2063_AvoidSpursData_t *pAS_Info, ...@@ -692,6 +715,9 @@ static u32 IsSpurInBand(struct MT2063_AvoidSpursData_t *pAS_Info,
s32 f_Spur; s32 f_Spur;
u32 ma, mb, mc, md, me, mf; u32 ma, mb, mc, md, me, mf;
u32 lo_gcd, gd_Scale, gc_Scale, gf_Scale, hgds, hgfs, hgcs; u32 lo_gcd, gd_Scale, gc_Scale, gf_Scale, hgds, hgfs, hgcs;
dprintk(2, "\n");
*fm = 0; *fm = 0;
/* /*
...@@ -788,6 +814,8 @@ static u32 MT2063_AvoidSpurs(struct MT2063_AvoidSpursData_t *pAS_Info) ...@@ -788,6 +814,8 @@ static u32 MT2063_AvoidSpurs(struct MT2063_AvoidSpursData_t *pAS_Info)
pAS_Info->bSpurAvoided = 0; pAS_Info->bSpurAvoided = 0;
pAS_Info->nSpursFound = 0; pAS_Info->nSpursFound = 0;
dprintk(2, "\n");
if (pAS_Info->maxH1 == 0) if (pAS_Info->maxH1 == 0)
return 0; return 0;
...@@ -910,6 +938,8 @@ static unsigned int mt2063_lockStatus(struct mt2063_state *state) ...@@ -910,6 +938,8 @@ static unsigned int mt2063_lockStatus(struct mt2063_state *state)
u32 status; u32 status;
u32 nDelays = 0; u32 nDelays = 0;
dprintk(2, "\n");
/* LO2 Lock bit was in a different place for B0 version */ /* LO2 Lock bit was in a different place for B0 version */
if (state->tuner_id == MT2063_B0) if (state->tuner_id == MT2063_B0)
LO2LK = 0x40; LO2LK = 0x40;
...@@ -1001,6 +1031,8 @@ static const u8 PD2TGT[] = { 40, 33, 38, 42, 30, 38 }; ...@@ -1001,6 +1031,8 @@ static const u8 PD2TGT[] = { 40, 33, 38, 42, 30, 38 };
static u32 mt2063_get_dnc_output_enable(struct mt2063_state *state, static u32 mt2063_get_dnc_output_enable(struct mt2063_state *state,
enum MT2063_DNC_Output_Enable *pValue) enum MT2063_DNC_Output_Enable *pValue)
{ {
dprintk(2, "\n");
if ((state->reg[MT2063_REG_DNC_GAIN] & 0x03) == 0x03) { /* if DNC1 is off */ if ((state->reg[MT2063_REG_DNC_GAIN] & 0x03) == 0x03) { /* if DNC1 is off */
if ((state->reg[MT2063_REG_VGA_GAIN] & 0x03) == 0x03) /* if DNC2 is off */ if ((state->reg[MT2063_REG_VGA_GAIN] & 0x03) == 0x03) /* if DNC2 is off */
*pValue = MT2063_DNC_NONE; *pValue = MT2063_DNC_NONE;
...@@ -1024,6 +1056,8 @@ static u32 mt2063_set_dnc_output_enable(struct mt2063_state *state, ...@@ -1024,6 +1056,8 @@ static u32 mt2063_set_dnc_output_enable(struct mt2063_state *state,
u32 status = 0; /* Status to be returned */ u32 status = 0; /* Status to be returned */
u8 val = 0; u8 val = 0;
dprintk(2, "\n");
/* selects, which DNC output is used */ /* selects, which DNC output is used */
switch (nValue) { switch (nValue) {
case MT2063_DNC_NONE: case MT2063_DNC_NONE:
...@@ -1157,6 +1191,8 @@ static u32 MT2063_SetReceiverMode(struct mt2063_state *state, ...@@ -1157,6 +1191,8 @@ static u32 MT2063_SetReceiverMode(struct mt2063_state *state,
u8 val; u8 val;
u32 longval; u32 longval;
dprintk(2, "\n");
if (Mode >= MT2063_NUM_RCVR_MODES) if (Mode >= MT2063_NUM_RCVR_MODES)
status = -ERANGE; status = -ERANGE;
...@@ -1292,6 +1328,7 @@ static u32 MT2063_ClearPowerMaskBits(struct mt2063_state *state, ...@@ -1292,6 +1328,7 @@ static u32 MT2063_ClearPowerMaskBits(struct mt2063_state *state,
{ {
u32 status = 0; u32 status = 0;
dprintk(2, "\n");
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) {
state->reg[MT2063_REG_PWR_2] &= ~(u8) (Bits >> 8); state->reg[MT2063_REG_PWR_2] &= ~(u8) (Bits >> 8);
...@@ -1320,6 +1357,7 @@ static u32 MT2063_SoftwareShutdown(struct mt2063_state *state, u8 Shutdown) ...@@ -1320,6 +1357,7 @@ static u32 MT2063_SoftwareShutdown(struct mt2063_state *state, u8 Shutdown)
{ {
u32 status; u32 status;
dprintk(2, "\n");
if (Shutdown == 1) if (Shutdown == 1)
state->reg[MT2063_REG_PWR_1] |= 0x04; state->reg[MT2063_REG_PWR_1] |= 0x04;
else else
...@@ -1498,6 +1536,7 @@ static u32 MT2063_Tune(struct mt2063_state *state, u32 f_in) ...@@ -1498,6 +1536,7 @@ static u32 MT2063_Tune(struct mt2063_state *state, u32 f_in)
u8 val; u8 val;
u32 RFBand; u32 RFBand;
dprintk(2, "\n");
/* 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))
return -EINVAL; return -EINVAL;
...@@ -1757,12 +1796,16 @@ static int mt2063_init(struct dvb_frontend *fe) ...@@ -1757,12 +1796,16 @@ static int mt2063_init(struct dvb_frontend *fe)
u32 fcu_osc; u32 fcu_osc;
u32 i; u32 i;
dprintk(2, "\n");
state->rcvr_mode = MT2063_CABLE_QAM; state->rcvr_mode = MT2063_CABLE_QAM;
/* Read the Part/Rev code from the tuner */ /* Read the Part/Rev code from the tuner */
status = mt2063_read(state, MT2063_REG_PART_REV, state->reg, 1); status = mt2063_read(state, MT2063_REG_PART_REV, state->reg, 1);
if (status < 0) if (status < 0) {
printk(KERN_ERR "Can't read mt2063 part ID\n");
return status; return status;
}
/* Check the part/rev code */ /* Check the part/rev code */
if (((state->reg[MT2063_REG_PART_REV] != MT2063_B0) /* MT2063 B0 */ if (((state->reg[MT2063_REG_PART_REV] != MT2063_B0) /* MT2063 B0 */
...@@ -1775,8 +1818,10 @@ static int mt2063_init(struct dvb_frontend *fe) ...@@ -1775,8 +1818,10 @@ static int mt2063_init(struct dvb_frontend *fe)
&state->reg[MT2063_REG_RSVD_3B], 1); &state->reg[MT2063_REG_RSVD_3B], 1);
/* b7 != 0 ==> NOT MT2063 */ /* b7 != 0 ==> NOT MT2063 */
if (status < 0 || ((state->reg[MT2063_REG_RSVD_3B] & 0x80) != 0x00)) if (status < 0 || ((state->reg[MT2063_REG_RSVD_3B] & 0x80) != 0x00)) {
printk(KERN_ERR "Can't read mt2063 2nd part ID\n");
return -ENODEV; /* Wrong tuner Part/Rev code */ return -ENODEV; /* Wrong tuner Part/Rev code */
}
/* Reset the tuner */ /* Reset the tuner */
status = mt2063_write(state, MT2063_REG_LO2CQ_3, &all_resets, 1); status = mt2063_write(state, MT2063_REG_LO2CQ_3, &all_resets, 1);
...@@ -1940,6 +1985,8 @@ static int mt2063_get_status(struct dvb_frontend *fe, u32 *tuner_status) ...@@ -1940,6 +1985,8 @@ static int mt2063_get_status(struct dvb_frontend *fe, u32 *tuner_status)
struct mt2063_state *state = fe->tuner_priv; struct mt2063_state *state = fe->tuner_priv;
int status; int status;
dprintk(2, "\n");
*tuner_status = 0; *tuner_status = 0;
status = mt2063_lockStatus(state); status = mt2063_lockStatus(state);
if (status < 0) if (status < 0)
...@@ -1954,6 +2001,8 @@ static int mt2063_release(struct dvb_frontend *fe) ...@@ -1954,6 +2001,8 @@ static int mt2063_release(struct dvb_frontend *fe)
{ {
struct mt2063_state *state = fe->tuner_priv; struct mt2063_state *state = fe->tuner_priv;
dprintk(2, "\n");
fe->tuner_priv = NULL; fe->tuner_priv = NULL;
kfree(state); kfree(state);
...@@ -1974,6 +2023,8 @@ static int mt2063_set_analog_params(struct dvb_frontend *fe, ...@@ -1974,6 +2023,8 @@ static int mt2063_set_analog_params(struct dvb_frontend *fe,
s32 rcvr_mode = 0; s32 rcvr_mode = 0;
int status; int status;
dprintk(2, "\n");
switch (params->mode) { switch (params->mode) {
case V4L2_TUNER_RADIO: case V4L2_TUNER_RADIO:
pict_car = 38900000; pict_car = 38900000;
...@@ -2065,6 +2116,8 @@ static int mt2063_set_params(struct dvb_frontend *fe) ...@@ -2065,6 +2116,8 @@ static int mt2063_set_params(struct dvb_frontend *fe)
s32 if_mid = 0; s32 if_mid = 0;
s32 rcvr_mode = 0; s32 rcvr_mode = 0;
dprintk(2, "\n");
if (c->bandwidth_hz == 0) if (c->bandwidth_hz == 0)
return -EINVAL; return -EINVAL;
if (c->bandwidth_hz <= 6000000) if (c->bandwidth_hz <= 6000000)
...@@ -2116,6 +2169,8 @@ static int mt2063_get_frequency(struct dvb_frontend *fe, u32 *freq) ...@@ -2116,6 +2169,8 @@ static int mt2063_get_frequency(struct dvb_frontend *fe, u32 *freq)
{ {
struct mt2063_state *state = fe->tuner_priv; struct mt2063_state *state = fe->tuner_priv;
dprintk(2, "\n");
*freq = state->frequency; *freq = state->frequency;
return 0; return 0;
} }
...@@ -2124,6 +2179,8 @@ static int mt2063_get_bandwidth(struct dvb_frontend *fe, u32 *bw) ...@@ -2124,6 +2179,8 @@ static int mt2063_get_bandwidth(struct dvb_frontend *fe, u32 *bw)
{ {
struct mt2063_state *state = fe->tuner_priv; struct mt2063_state *state = fe->tuner_priv;
dprintk(2, "\n");
*bw = state->AS_Data.f_out_bw - 750000; *bw = state->AS_Data.f_out_bw - 750000;
return 0; return 0;
} }
...@@ -2152,6 +2209,8 @@ struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe, ...@@ -2152,6 +2209,8 @@ struct dvb_frontend *mt2063_attach(struct dvb_frontend *fe,
{ {
struct mt2063_state *state = NULL; struct mt2063_state *state = NULL;
dprintk(2, "\n");
state = kzalloc(sizeof(struct mt2063_state), GFP_KERNEL); state = kzalloc(sizeof(struct mt2063_state), GFP_KERNEL);
if (state == NULL) if (state == NULL)
goto error; goto error;
...@@ -2181,6 +2240,8 @@ unsigned int tuner_MT2063_SoftwareShutdown(struct dvb_frontend *fe) ...@@ -2181,6 +2240,8 @@ unsigned int tuner_MT2063_SoftwareShutdown(struct dvb_frontend *fe)
struct mt2063_state *state = fe->tuner_priv; struct mt2063_state *state = fe->tuner_priv;
int err = 0; int err = 0;
dprintk(2, "\n");
err = MT2063_SoftwareShutdown(state, 1); err = MT2063_SoftwareShutdown(state, 1);
if (err < 0) if (err < 0)
printk(KERN_ERR "%s: Couldn't shutdown\n", __func__); printk(KERN_ERR "%s: Couldn't shutdown\n", __func__);
...@@ -2194,6 +2255,8 @@ unsigned int tuner_MT2063_ClearPowerMaskBits(struct dvb_frontend *fe) ...@@ -2194,6 +2255,8 @@ unsigned int tuner_MT2063_ClearPowerMaskBits(struct dvb_frontend *fe)
struct mt2063_state *state = fe->tuner_priv; struct mt2063_state *state = fe->tuner_priv;
int err = 0; int err = 0;
dprintk(2, "\n");
err = MT2063_ClearPowerMaskBits(state, MT2063_ALL_SD); err = MT2063_ClearPowerMaskBits(state, MT2063_ALL_SD);
if (err < 0) if (err < 0)
printk(KERN_ERR "%s: Invalid parameter\n", __func__); printk(KERN_ERR "%s: Invalid parameter\n", __func__);
...@@ -2202,9 +2265,6 @@ unsigned int tuner_MT2063_ClearPowerMaskBits(struct dvb_frontend *fe) ...@@ -2202,9 +2265,6 @@ unsigned int tuner_MT2063_ClearPowerMaskBits(struct dvb_frontend *fe)
} }
EXPORT_SYMBOL_GPL(tuner_MT2063_ClearPowerMaskBits); EXPORT_SYMBOL_GPL(tuner_MT2063_ClearPowerMaskBits);
MODULE_PARM_DESC(verbose, "Set Verbosity level");
MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>"); MODULE_AUTHOR("Mauro Carvalho Chehab <mchehab@redhat.com>");
MODULE_DESCRIPTION("MT2063 Silicon tuner"); MODULE_DESCRIPTION("MT2063 Silicon tuner");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment