#define DRXK_QAM_SL_SIG_POWER_QAM128 (20992)
#define DRXK_QAM_SL_SIG_POWER_QAM256 (43520)
+static unsigned int debug;
+module_param(debug, int, 0644);
+MODULE_PARM_DESC(debug, "enable debug messages");
+
+#define dprintk(level, fmt, arg...) do { \
+if (debug >= level) \
+ printk(KERN_DEBUG "drxk: %s" fmt, __func__, ## arg); \
+} while (0)
+
+
static inline u32 MulDiv32(u32 a, u32 b, u32 c)
{
u64 tmp64;
struct i2c_msg msg = {
.addr = adr, .flags = 0, .buf = data, .len = len };
+ dprintk(3, ":");
+ if (debug > 2) {
+ int i;
+ for (i = 0; i < len; i++)
+ printk(KERN_CONT " %02x", data[i]);
+ printk(KERN_CONT "\n");
+ }
if (i2c_transfer(adap, &msg, 1) != 1) {
printk(KERN_ERR "drxk: i2c write error at addr 0x%02x\n", adr);
return -1;
{.addr = adr, .flags = I2C_M_RD,
.buf = answ, .len = alen}
};
+ dprintk(3, ":");
+ if (debug > 2) {
+ int i;
+ for (i = 0; i < len; i++)
+ printk(KERN_CONT " %02x", msg[i]);
+ printk(KERN_CONT "\n");
+ }
if (i2c_transfer(adap, msgs, 2) != 2) {
+ if (debug > 2)
+ printk(KERN_CONT ": ERROR!\n");
+
printk(KERN_ERR "drxk: i2c read error at addr 0x%02x\n", adr);
return -1;
}
+ if (debug > 2) {
+ int i;
+ printk(KERN_CONT ": Read ");
+ for (i = 0; i < len; i++)
+ printk(KERN_CONT " %02x", msg[i]);
+ printk(KERN_CONT "\n");
+ }
return 0;
}
mm1[1] = (((reg >> 16) & 0x0F) | ((reg >> 18) & 0xF0));
len = 2;
}
+ dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags);
if (i2c_read(state->i2c, adr, mm1, len, mm2, 2) < 0)
return -1;
if (data)
*data = mm2[0] | (mm2[1] << 8);
+
return 0;
}
mm1[1] = (((reg >> 16) & 0x0F) | ((reg >> 18) & 0xF0));
len = 2;
}
+ dprintk(2, "(0x%08x, 0x%02x)\n", reg, flags);
if (i2c_read(state->i2c, adr, mm1, len, mm2, 4) < 0)
return -1;
if (data)
*data = mm2[0] | (mm2[1] << 8) |
(mm2[2] << 16) | (mm2[3] << 24);
+
return 0;
}
}
mm[len] = data & 0xff;
mm[len + 1] = (data >> 8) & 0xff;
+
+ dprintk(2, "(0x%08x, 0x%04x, 0x%02x)\n", reg, data, flags);
if (i2c_write(state->i2c, adr, mm, len + 2) < 0)
return -1;
return 0;
mm[len + 1] = (data >> 8) & 0xff;
mm[len + 2] = (data >> 16) & 0xff;
mm[len + 3] = (data >> 24) & 0xff;
+ dprintk(2, "(0x%08x, 0x%08x, 0x%02x)\n", reg, data, flags);
if (i2c_write(state->i2c, adr, mm, len + 4) < 0)
return -1;
return 0;
AdrLength = 2;
}
memcpy(&state->Chunk[AdrLength], pBlock, Chunk);
+ dprintk(2, "(0x%08x, 0x%02x)\n", Address, Flags);
+ if (debug > 1) {
+ int i;
+ if (pBlock)
+ for (i = 0; i < Chunk; i++)
+ printk(KERN_CONT " %02x", pBlock[i]);
+ printk(KERN_CONT "\n");
+ }
status = i2c_write(state->i2c, state->demod_address,
&state->Chunk[0], Chunk + AdrLength);
if (status < 0) {
u8 data = 0;
u16 retryCount = 0;
+ dprintk(1, "\n");
+
status = i2c_read1(state->i2c, state->demod_address, &data);
if (status < 0)
do {
u32 ulAntennaDVBC = 0;
u32 ulAntennaSwitchDVBTDVBC = 0;
+ dprintk(1, "\n");
+
state->m_hasLNA = false;
state->m_hasDVBT = false;
state->m_hasDVBC = false;
u16 bid = 0;
u16 key = 0;
+ dprintk(1, "\n");
do {
/* stop lock indicator process */
status = Write16_0(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE);
u32 sioTopJtagidLo = 0;
int status;
+ dprintk(1, "\n");
do {
/* driver 0.9.0 */
/* stop lock indicator process */
int status;
bool powerdown_cmd;
+ dprintk(1, "\n");
+
/* Write command */
status = Write16_0(state, SIO_HI_RA_RAM_CMD__A, cmd);
if (status < 0)
{
int status;
+ dprintk(1, "\n");
+
mutex_lock(&state->mutex);
do {
status = Write16_0(state, SIO_HI_RA_RAM_PAR_6__A, state->m_HICfgTimeout);
static int InitHI(struct drxk_state *state)
{
+ dprintk(1, "\n");
+
state->m_HICfgWakeUpKey = (state->demod_address << 1);
state->m_HICfgTimeout = 0x96FF;
/* port/bridge/power down ctrl */
u16 sioPdrMclkCfg = 0;
u16 sioPdrMdxCfg = 0;
+ dprintk(1, "\n");
do {
/* stop lock indicator process */
status = Write16_0(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE);
static int MPEGTSDisable(struct drxk_state *state)
{
+ dprintk(1, "\n");
+
return MPEGTSConfigurePins(state, false);
}
int status;
unsigned long end;
+ dprintk(1, "\n");
+
mutex_lock(&state->mutex);
do {
status = Write16_0(state, SIO_BL_MODE__A, SIO_BL_MODE_CHAIN);
u32 i;
int status = 0;
+ dprintk(1, "\n");
+
/* down the drain (we don care about MAGIC_WORD) */
Drain = (pSrc[0] << 8) | pSrc[1];
pSrc += sizeof(u16);
u16 desiredStatus = SIO_OFDM_SH_OFDM_RING_STATUS_ENABLED;
unsigned long end;
+ dprintk(1, "\n");
+
if (enable == false) {
desiredCtrl = SIO_OFDM_SH_OFDM_RING_ENABLE_OFF;
desiredStatus = SIO_OFDM_SH_OFDM_RING_STATUS_DOWN;
u16 fecOcSncMode = 0;
u16 fecOcIprMode = 0;
+ dprintk(1, "\n");
+
do {
/* Gracefull shutdown (byte boundaries) */
status = Read16_0(state, FEC_OC_SNC_MODE__A, &fecOcSncMode);
int status;
unsigned long end;
+ dprintk(1, "\n");
+
if ((cmd == 0) || ((parameterLen > 0) && (parameter == NULL)) ||
((resultLen > 0) && (result == NULL)))
return -1;
u16 data = 0;
int status;
+ dprintk(1, "\n");
+
do {
/* Configure IQM */
status = Read16_0(state, IQM_AF_STDBY__A, &data);
int status = 0;
u16 sioCcPwdMode = 0;
+ dprintk(1, "\n");
+
/* Check arguments */
if (mode == NULL)
return -1;
u16 data = 0;
int status;
+ dprintk(1, "\n");
+
do {
status = Read16_0(state, SCU_COMM_EXEC__A, &data);
if (status < 0)
{
int status = 0;
+ dprintk(1, "\n");
/*
Stop and power down previous standard
TODO investigate total power down instead of partial
{
int status = 0;
+ dprintk(1, "\n");
do {
u16 IFreqkHz;
s32 OffsetkHz = offsetFreq / 1000;
static int ShutDown(struct drxk_state *state)
{
+ dprintk(1, "\n");
+
MPEGTSStop(state);
return 0;
}
{
int status = 0;
+ dprintk(1, "\n");
+
if (pLockStatus == NULL)
return -1;
{
int status = -1;
+ dprintk(1, "\n");
+
do {
/* Rate integration settings */
status = Write16_0(state, FEC_OC_RCN_CTL_STEP_LO__A, 0x0000);
u32 maxBitRate = 0;
bool staticCLK = false;
+ dprintk(1, "\n");
+
do {
/* Check insertion of the Reed-Solomon parity bytes */
status = Read16_0(state, FEC_OC_MODE__A, &fecOcRegMode);
int status;
u16 fecOcRegIprInvert = 0;
+ dprintk(1, "\n");
+
/* Data mask for the output data byte */
u16 InvertDataMask =
FEC_OC_IPR_INVERT_MD7__M | FEC_OC_IPR_INVERT_MD6__M |
int status = 0;
struct SCfgAgc *pIfAgcSettings;
+ dprintk(1, "\n");
+
if (pAgcCfg == NULL)
return -1;
int status = 0;
struct SCfgAgc *pRfAgcSettings;
+ dprintk(1, "\n");
+
do {
switch (pAgcCfg->ctrlMode) {
case DRXK_AGC_CTRL_AUTO:
u16 agcDacLvl;
int status = Read16_0(state, IQM_AF_AGC_IF__A, &agcDacLvl);
+ dprintk(1, "\n");
+
*pValue = 0;
if (status == 0) {
{
int status = 0;
+ dprintk(1, "\n");
+
do {
/* MER calculation */
u16 qamSlErrPower = 0; /* accum. error between
u32 iMER = 0;
u16 transmissionParams = 0;
+ dprintk(1, "\n");
do {
status = Read16_0(state, OFDM_EQ_TOP_TD_TPS_PWR_OFS__A, &EqRegTdTpsPwrOfs);
if (status < 0)
static int GetSignalToNoise(struct drxk_state *state, s32 *pSignalToNoise)
{
+ dprintk(1, "\n");
+
*pSignalToNoise = 0;
switch (state->m_OperationMode) {
case OM_DVBT:
/* SNR Values for quasi errorfree reception rom Nordig 2.2 */
int status = 0;
+ dprintk(1, "\n");
+
static s32 QE_SN[] = {
51, /* QPSK 1/2 */
69, /* QPSK 2/3 */
int status = 0;
*pQuality = 0;
+ dprintk(1, "\n");
+
do {
u32 SignalToNoise = 0;
u32 BERQuality = 100;
static int GetQuality(struct drxk_state *state, s32 *pQuality)
{
+ dprintk(1, "\n");
+
switch (state->m_OperationMode) {
case OM_DVBT:
return GetDVBTQuality(state, pQuality);
{
int status;
+ dprintk(1, "\n");
+
if (state->m_DrxkState == DRXK_UNINITIALIZED)
return -1;
if (state->m_DrxkState == DRXK_POWERED_DOWN)
{
int status;
+ dprintk(1, "\n");
+
if ((pPreSawCfg == NULL)
|| (pPreSawCfg->reference > IQM_AF_PDREF__M))
return -1;
int status;
unsigned long end;
+ dprintk(1, "\n");
+
mutex_lock(&state->mutex);
do {
status = Write16_0(state, SIO_BL_MODE__A, SIO_BL_MODE_DIRECT);
u16 data = 0;
int status;
+ dprintk(1, "\n");
+
do {
/* Start measurement */
status = Write16_0(state, IQM_AF_COMM_EXEC__A, IQM_AF_COMM_EXEC_ACTIVE);
u16 count = 0;
int status;
+ dprintk(1, "\n");
+
do {
status = ADCSyncMeasurement(state, &count);
if (status < 0)
u32 frequencyShift;
bool imageToSelect;
+ dprintk(1, "\n");
+
/*
Program frequency shifter
No need to account for mirroring on RF
u16 clpCtrlMode = 0;
int status = 0;
+ dprintk(1, "\n");
+
do {
/* Common settings */
snsSumMax = 1023;
{
int status;
+ dprintk(1, "\n");
do {
if (packetErr == NULL) {
status = Write16_0(state, SCU_RAM_FEC_ACCUM_PKT_FAILURES__A, 0);
u16 scExec = 0;
int status;
+ dprintk(1, "\n");
status = Read16_0(state, OFDM_SC_COMM_EXEC__A, &scExec);
if (scExec != 1) {
/* SC is not running */
enum DRXPowerMode powerMode = DRX_POWER_UP;
int status;
+ dprintk(1, "\n");
do {
status = CtrlPowerMode(state, &powerMode);
if (status < 0)
{
int status;
+ dprintk(1, "\n");
if (*enabled == true)
status = Write16_0(state, IQM_CF_BYPASSDET__A, 0);
else
int status;
+ dprintk(1, "\n");
if (*enabled == true) {
/* write mask to 1 */
status = Write16_0(state, OFDM_SC_RA_RAM_FR_THRES_8K__A,
u16 data = 0;
int status;
+ dprintk(1, "\n");
do {
status = Read16_0(state, OFDM_SC_RA_RAM_ECHO_THRES__A, &data);
if (status < 0)
{
int status;
+ dprintk(1, "\n");
+
switch (*speed) {
case DRXK_DVBT_SQI_SPEED_FAST:
case DRXK_DVBT_SQI_SPEED_MEDIUM:
struct DRXKCfgDvbtEchoThres_t echoThres2k = { 0, DRX_FFTMODE_2K };
struct DRXKCfgDvbtEchoThres_t echoThres8k = { 0, DRX_FFTMODE_8K };
+ dprintk(1, "\n");
do {
bool setincenable = false;
bool setfrenable = true;
u16 data = 0;
int status;
- PowerUpDVBT(state);
+ dprintk(1, "\n");
+ PowerUpDVBT(state);
do {
/* added antenna switch */
SwitchAntennaToDVBT(state);
int status;
/* DRXKOfdmScCmd_t scCmd; */
+ dprintk(1, "\n");
/* Start correct processes to get in lock */
/* DRXK: OFDM_SC_RA_RAM_PROC_LOCKTRACK is no longer in mapfile! */
do {
u16 param1;
int status;
+ dprintk(1, "\n");
/* printk(KERN_DEBUG "drxk: %s IF =%d, TFO = %d\n", __func__, IntermediateFreqkHz, tunerFreqOffset); */
do {
status = scu_command(state, SCU_RAM_COMMAND_STANDARD_OFDM | SCU_RAM_COMMAND_CMD_DEMOD_STOP, 0, NULL, 1, &cmdResult);
u16 ScRaRamLock = 0;
u16 ScCommExec = 0;
+ dprintk(1, "\n");
+
/* driver 0.9.0 */
/* Check if SC is running */
status = Read16_0(state, OFDM_SC_COMM_EXEC__A, &ScCommExec);
enum DRXPowerMode powerMode = DRXK_POWER_DOWN_OFDM;
int status = 0;
+ dprintk(1, "\n");
do {
status = CtrlPowerMode(state, &powerMode);
if (status < 0)
u16 cmdResult;
int status = 0;
+ dprintk(1, "\n");
do {
status = Read16_0(state, SCU_COMM_EXEC__A, &data);
if (status < 0)
u16 fecRsPeriod = 0; /* Value for corresponding I2C register */
int status = 0;
- fecRsPrescale = 1;
+ dprintk(1, "\n");
+ fecRsPrescale = 1;
do {
/* fecBitsDesired = symbolRate [kHz] *
{
int status = 0;
+ dprintk(1, "\n");
do {
/* QAM Equalizer Setup */
/* Equalizer */
{
int status = 0;
+ dprintk(1, "\n");
do {
/* QAM Equalizer Setup */
/* Equalizer */
{
int status = 0;
+ dprintk(1, "\n");
do {
/* QAM Equalizer Setup */
/* Equalizer */
{
int status = 0;
+ dprintk(1, "\n");
do {
/* QAM Equalizer Setup */
/* Equalizer */
{
int status = 0;
+ dprintk(1, "\n");
do {
/* QAM Equalizer Setup */
/* Equalizer */
int status;
u16 cmdResult;
+ dprintk(1, "\n");
do {
/* Stop QAM comstate->m_exec */
status = Write16_0(state, QAM_COMM_EXEC__A, QAM_COMM_EXEC_STOP);
u32 lcSymbRate = 0;
int status;
+ dprintk(1, "\n");
do {
/* Select & calculate correct IQM rate */
adcFrequency = (state->m_sysClockFreq * 1000) / 3;
int status;
u16 Result[2] = { 0, 0 };
+ dprintk(1, "\n");
status =
scu_command(state,
SCU_RAM_COMMAND_STANDARD_QAM |
u16 setParamParameters[4] = { 0, 0, 0, 0 };
u16 cmdResult;
+ dprintk(1, "\n");
do {
/*
STEP 1: reset demodulator
int status;
#endif
+ dprintk(1, "\n");
do {
/* added antenna switch */
SwitchAntennaToQAM(state);
int status;
u16 value = 0;
+ dprintk(1, "\n");
do {
/* stop lock indicator process */
status = Write16_0(state, SCU_RAM_GPIO__A, SCU_RAM_GPIO_HW_LOCK_IND_DISABLE);
{
int status = -1;
+ dprintk(1, "\n");
if (state->m_AntennaSwitchDVBTDVBC != 0) {
if (state->m_GPIO != state->m_AntennaDVBC) {
state->m_GPIO = state->m_AntennaDVBC;
{
int status = -1;
+ dprintk(1, "\n");
if (state->m_AntennaSwitchDVBTDVBC != 0) {
if (state->m_GPIO != state->m_AntennaDVBT) {
state->m_GPIO = state->m_AntennaDVBT;
/* ADC power down */
/* Power down device */
int status;
+
+ dprintk(1, "\n");
do {
if (state->m_bPDownOpenBridge) {
/* Open I2C bridge before power down of DRXK */
const struct firmware *fw = NULL;
int err = 0;
+ dprintk(1, "\n");
+
err = request_firmware(&fw, mc_name, state->i2c->dev.parent);
if (err < 0) {
printk(KERN_ERR
enum DRXPowerMode powerMode = DRXK_POWER_DOWN_OFDM;
u16 driverVersion;
+ dprintk(1, "\n");
if ((state->m_DrxkState == DRXK_UNINITIALIZED)) {
do {
status = PowerUpDevice(state);
{
struct drxk_state *state = fe->demodulator_priv;
+ dprintk(1, "\n");
kfree(state);
}
{
struct drxk_state *state = fe->demodulator_priv;
+ dprintk(1, "\n");
if (mutex_trylock(&state->ctlock) == 0)
return -EBUSY;
SetOperationMode(state, OM_QAM_ITU_A);
{
struct drxk_state *state = fe->demodulator_priv;
+ dprintk(1, "\n");
ShutDown(state);
mutex_unlock(&state->ctlock);
return 0;
{
struct drxk_state *state = fe->demodulator_priv;
- /* printk(KERN_DEBUG "drxk: drxk_gate %d\n", enable); */
+ dprintk(1, "%s\n", enable ? "enable" : "disable");
return ConfigureI2CBridge(state, enable ? true : false);
}
struct drxk_state *state = fe->demodulator_priv;
u32 IF;
+ dprintk(1, "\n");
if (fe->ops.i2c_gate_ctrl)
fe->ops.i2c_gate_ctrl(fe, 1);
if (fe->ops.tuner_ops.set_params)
static int drxk_c_get_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *p)
{
+ dprintk(1, "\n");
return 0;
}
struct drxk_state *state = fe->demodulator_priv;
u32 stat;
+ dprintk(1, "\n");
*status = 0;
GetLockStatus(state, &stat, 0);
if (stat == MPEG_LOCK)
static int drxk_read_ber(struct dvb_frontend *fe, u32 *ber)
{
+ dprintk(1, "\n");
+
*ber = 0;
return 0;
}
struct drxk_state *state = fe->demodulator_priv;
u32 val;
+ dprintk(1, "\n");
ReadIFAgc(state, &val);
*strength = val & 0xffff;
return 0;
struct drxk_state *state = fe->demodulator_priv;
s32 snr2;
+ dprintk(1, "\n");
GetSignalToNoise(state, &snr2);
*snr = snr2 & 0xffff;
return 0;
struct drxk_state *state = fe->demodulator_priv;
u16 err;
+ dprintk(1, "\n");
DVBTQAMGetAccPktErr(state, &err);
*ucblocks = (u32) err;
return 0;
static int drxk_c_get_tune_settings(struct dvb_frontend *fe, struct dvb_frontend_tune_settings
*sets)
{
+ dprintk(1, "\n");
sets->min_delay_ms = 3000;
sets->max_drift = 0;
sets->step_size = 0;
#if 0
struct drxk_state *state = fe->demodulator_priv;
- printk(KERN_DEBUG "drxk: %s\n", __func__);
+ dprintk(1, "\n");
kfree(state);
#endif
}
static int drxk_t_init(struct dvb_frontend *fe)
{
struct drxk_state *state = fe->demodulator_priv;
+
+ dprintk(1, "\n");
if (mutex_trylock(&state->ctlock) == 0)
return -EBUSY;
SetOperationMode(state, OM_DVBT);
static int drxk_t_sleep(struct dvb_frontend *fe)
{
struct drxk_state *state = fe->demodulator_priv;
+
+ dprintk(1, "\n");
mutex_unlock(&state->ctlock);
return 0;
}
static int drxk_t_get_frontend(struct dvb_frontend *fe,
struct dvb_frontend_parameters *p)
{
+ dprintk(1, "\n");
+
return 0;
}
{
struct drxk_state *state = NULL;
+ dprintk(1, "\n");
state = kzalloc(sizeof(struct drxk_state), GFP_KERNEL);
if (!state)
return NULL;