Commit 341747be authored by istvan_v@mailbox.hu's avatar istvan_v@mailbox.hu Committed by Mauro Carvalho Chehab

[media] xc4000: code cleanup

Various coding style changes:
  - removed unused / commented out code
  - changed C++ style comments to C format
  - renamed functions and variables that included upper case letters in the name
  - removed tabs from module parameter descriptions
  - replaced the use of XC_RESULT_* with standard error codes
Signed-off-by: default avatarIstvan Varga <istvan_v@mailbox.hu>
Cc: Patrick Boettcher <pboettcher@kernellabs.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 7db98fe6
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
* Copyright (c) 2007 Steven Toth <stoth@linuxtv.org> * Copyright (c) 2007 Steven Toth <stoth@linuxtv.org>
* Copyright (c) 2009 Devin Heitmueller <dheitmueller@kernellabs.com> * Copyright (c) 2009 Devin Heitmueller <dheitmueller@kernellabs.com>
* Copyright (c) 2009 Davide Ferri <d.ferri@zero11.it> * Copyright (c) 2009 Davide Ferri <d.ferri@zero11.it>
* Copyright (c) 2010 Istvan Varga <istvan_v@mailbox.hu>
* *
* This program is free software; you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
...@@ -14,7 +15,6 @@ ...@@ -14,7 +15,6 @@
* This program is distributed in the hope that it will be useful, * This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
*
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
...@@ -39,44 +39,29 @@ ...@@ -39,44 +39,29 @@
static int debug; static int debug;
module_param(debug, int, 0644); module_param(debug, int, 0644);
MODULE_PARM_DESC(debug, "\n\t\tDebugging level (0 to 2, default: 0 (off))."); MODULE_PARM_DESC(debug, "Debugging level (0 to 2, default: 0 (off)).");
static int no_poweroff; static int no_poweroff;
module_param(no_poweroff, int, 0644); module_param(no_poweroff, int, 0644);
MODULE_PARM_DESC(no_poweroff, "\n\t\t1: keep device energized and with tuner " MODULE_PARM_DESC(no_poweroff, "Power management (1: disabled, 2: enabled, "
"ready all the times.\n" "0 (default): use device-specific default mode).");
"\t\tFaster, but consumes more power and keeps the device hotter.\n"
"\t\t2: powers device off when not used.\n"
"\t\t0 (default): use device-specific default mode.");
#define XC4000_AUDIO_STD_B 1
#define XC4000_AUDIO_STD_A2 2
#define XC4000_AUDIO_STD_K3 4
#define XC4000_AUDIO_STD_L 8
#define XC4000_AUDIO_STD_INPUT1 16
#define XC4000_AUDIO_STD_MONO 32
static int audio_std; static int audio_std;
module_param(audio_std, int, 0644); module_param(audio_std, int, 0644);
MODULE_PARM_DESC(audio_std, "\n\t\tAudio standard. XC4000 audio decoder " MODULE_PARM_DESC(audio_std, "Audio standard. XC4000 audio decoder explicitly "
"explicitly needs to know\n" "needs to know what audio standard is needed for some video standards "
"\t\twhat audio standard is needed for some video standards with\n" "with audio A2 or NICAM. The valid settings are a sum of:\n"
"\t\taudio A2 or NICAM.\n" " 1: use NICAM/B or A2/B instead of NICAM/A or A2/A\n"
"\t\tThe valid settings are a sum of:\n" " 2: use A2 instead of NICAM or BTSC\n"
"\t\t 1: use NICAM/B or A2/B instead of NICAM/A or A2/A\n" " 4: use SECAM/K3 instead of K1\n"
"\t\t 2: use A2 instead of NICAM or BTSC\n" " 8: use PAL-D/K audio for SECAM-D/K\n"
"\t\t 4: use SECAM/K3 instead of K1\n" "16: use FM radio input 1 instead of input 2\n"
"\t\t 8: use PAL-D/K audio for SECAM-D/K\n" "32: use mono audio (the lower three bits are ignored)");
"\t\t16: use FM radio input 1 instead of input 2\n"
"\t\t32: use mono audio (the lower three bits are ignored)");
#define XC4000_DEFAULT_FIRMWARE "xc4000.fw"
static char firmware_name[30]; static char firmware_name[30];
module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0); module_param_string(firmware_name, firmware_name, sizeof(firmware_name), 0);
MODULE_PARM_DESC(firmware_name, "\n\t\tFirmware file name. Allows overriding " MODULE_PARM_DESC(firmware_name, "Firmware file name. Allows overriding the "
"the default firmware\n" "default firmware name.");
"\t\tname.");
static DEFINE_MUTEX(xc4000_list_mutex); static DEFINE_MUTEX(xc4000_list_mutex);
static LIST_HEAD(hybrid_tuner_instance_list); static LIST_HEAD(hybrid_tuner_instance_list);
...@@ -115,13 +100,21 @@ struct xc4000_priv { ...@@ -115,13 +100,21 @@ struct xc4000_priv {
u8 rf_mode; u8 rf_mode;
u8 card_type; u8 card_type;
u8 ignore_i2c_write_errors; u8 ignore_i2c_write_errors;
/* struct xc2028_ctrl ctrl; */
struct firmware_properties cur_fw; struct firmware_properties cur_fw;
__u16 hwmodel; __u16 hwmodel;
__u16 hwvers; __u16 hwvers;
struct mutex lock; struct mutex lock;
}; };
#define XC4000_AUDIO_STD_B 1
#define XC4000_AUDIO_STD_A2 2
#define XC4000_AUDIO_STD_K3 4
#define XC4000_AUDIO_STD_L 8
#define XC4000_AUDIO_STD_INPUT1 16
#define XC4000_AUDIO_STD_MONO 32
#define XC4000_DEFAULT_FIRMWARE "dvb-fe-xc4000-1.4.fw"
/* Misc Defines */ /* Misc Defines */
#define MAX_TV_STANDARD 24 #define MAX_TV_STANDARD 24
#define XC_MAX_I2C_WRITE_LENGTH 64 #define XC_MAX_I2C_WRITE_LENGTH 64
...@@ -131,13 +124,6 @@ struct xc4000_priv { ...@@ -131,13 +124,6 @@ struct xc4000_priv {
#define XC_RF_MODE_AIR 0 #define XC_RF_MODE_AIR 0
#define XC_RF_MODE_CABLE 1 #define XC_RF_MODE_CABLE 1
/* Result codes */
#define XC_RESULT_SUCCESS 0
#define XC_RESULT_RESET_FAILURE 1
#define XC_RESULT_I2C_WRITE_FAILURE 2
#define XC_RESULT_I2C_READ_FAILURE 3
#define XC_RESULT_OUT_OF_RANGE 5
/* Product id */ /* Product id */
#define XC_PRODUCT_ID_FW_NOT_LOADED 0x2000 #define XC_PRODUCT_ID_FW_NOT_LOADED 0x2000
#define XC_PRODUCT_ID_XC4000 0x0FA0 #define XC_PRODUCT_ID_XC4000 0x0FA0
...@@ -202,8 +188,8 @@ struct xc4000_priv { ...@@ -202,8 +188,8 @@ struct xc4000_priv {
struct XC_TV_STANDARD { struct XC_TV_STANDARD {
const char *Name; const char *Name;
u16 AudioMode; u16 audio_mode;
u16 VideoMode; u16 video_mode;
u16 int_freq; u16 int_freq;
}; };
...@@ -233,7 +219,7 @@ struct XC_TV_STANDARD { ...@@ -233,7 +219,7 @@ struct XC_TV_STANDARD {
#define XC4000_FM_Radio_INPUT2 22 #define XC4000_FM_Radio_INPUT2 22
#define XC4000_FM_Radio_INPUT1 23 #define XC4000_FM_Radio_INPUT1 23
static struct XC_TV_STANDARD XC4000_Standard[MAX_TV_STANDARD] = { static struct XC_TV_STANDARD xc4000_standard[MAX_TV_STANDARD] = {
{"M/N-NTSC/PAL-BTSC", 0x0000, 0x80A0, 4500}, {"M/N-NTSC/PAL-BTSC", 0x0000, 0x80A0, 4500},
{"M/N-NTSC/PAL-A2", 0x0000, 0x80A0, 4600}, {"M/N-NTSC/PAL-A2", 0x0000, 0x80A0, 4600},
{"M/N-NTSC/PAL-EIAJ", 0x0040, 0x80A0, 4500}, {"M/N-NTSC/PAL-EIAJ", 0x0040, 0x80A0, 4500},
...@@ -261,7 +247,7 @@ static struct XC_TV_STANDARD XC4000_Standard[MAX_TV_STANDARD] = { ...@@ -261,7 +247,7 @@ static struct XC_TV_STANDARD XC4000_Standard[MAX_TV_STANDARD] = {
}; };
static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val); static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val);
static int xc4000_TunerReset(struct dvb_frontend *fe); static int xc4000_tuner_reset(struct dvb_frontend *fe);
static void xc_debug_dump(struct xc4000_priv *priv); static void xc_debug_dump(struct xc4000_priv *priv);
static int xc_send_i2c_data(struct xc4000_priv *priv, u8 *buf, int len) static int xc_send_i2c_data(struct xc4000_priv *priv, u8 *buf, int len)
...@@ -276,18 +262,13 @@ static int xc_send_i2c_data(struct xc4000_priv *priv, u8 *buf, int len) ...@@ -276,18 +262,13 @@ static int xc_send_i2c_data(struct xc4000_priv *priv, u8 *buf, int len)
printk("bytes %02x %02x %02x %02x\n", buf[0], printk("bytes %02x %02x %02x %02x\n", buf[0],
buf[1], buf[2], buf[3]); buf[1], buf[2], buf[3]);
} }
return XC_RESULT_I2C_WRITE_FAILURE; return -EREMOTEIO;
} }
} }
return XC_RESULT_SUCCESS; return 0;
}
static void xc_wait(int wait_ms)
{
msleep(wait_ms);
} }
static int xc4000_TunerReset(struct dvb_frontend *fe) static int xc4000_tuner_reset(struct dvb_frontend *fe)
{ {
struct xc4000_priv *priv = fe->tuner_priv; struct xc4000_priv *priv = fe->tuner_priv;
int ret; int ret;
...@@ -302,13 +283,14 @@ static int xc4000_TunerReset(struct dvb_frontend *fe) ...@@ -302,13 +283,14 @@ static int xc4000_TunerReset(struct dvb_frontend *fe)
XC4000_TUNER_RESET, 0); XC4000_TUNER_RESET, 0);
if (ret) { if (ret) {
printk(KERN_ERR "xc4000: reset failed\n"); printk(KERN_ERR "xc4000: reset failed\n");
return XC_RESULT_RESET_FAILURE; return -EREMOTEIO;
} }
} else { } else {
printk(KERN_ERR "xc4000: no tuner reset callback function, fatal\n"); printk(KERN_ERR "xc4000: no tuner reset callback function, "
return XC_RESULT_RESET_FAILURE; "fatal\n");
return -EINVAL;
} }
return XC_RESULT_SUCCESS; return 0;
} }
static int xc_write_reg(struct xc4000_priv *priv, u16 regAddr, u16 i2cData) static int xc_write_reg(struct xc4000_priv *priv, u16 regAddr, u16 i2cData)
...@@ -339,15 +321,12 @@ static int xc_load_i2c_sequence(struct dvb_frontend *fe, const u8 *i2c_sequence) ...@@ -339,15 +321,12 @@ static int xc_load_i2c_sequence(struct dvb_frontend *fe, const u8 *i2c_sequence)
len = i2c_sequence[index] * 256 + i2c_sequence[index+1]; len = i2c_sequence[index] * 256 + i2c_sequence[index+1];
if (len == 0x0000) { if (len == 0x0000) {
/* RESET command */ /* RESET command */
/* NOTE: this is ignored, as the reset callback was */
/* already called by check_firmware() */
index += 2; index += 2;
#if 0 /* not needed, as already called by check_firmware() */
result = xc4000_TunerReset(fe);
if (result != XC_RESULT_SUCCESS)
return result;
#endif
} else if (len & 0x8000) { } else if (len & 0x8000) {
/* WAIT command */ /* WAIT command */
xc_wait(len & 0x7FFF); msleep(len & 0x7FFF);
index += 2; index += 2;
} else { } else {
/* Send i2c data whilst ensuring individual transactions /* Send i2c data whilst ensuring individual transactions
...@@ -370,7 +349,7 @@ static int xc_load_i2c_sequence(struct dvb_frontend *fe, const u8 *i2c_sequence) ...@@ -370,7 +349,7 @@ static int xc_load_i2c_sequence(struct dvb_frontend *fe, const u8 *i2c_sequence)
result = xc_send_i2c_data(priv, buf, result = xc_send_i2c_data(priv, buf,
nbytes_to_send); nbytes_to_send);
if (result != XC_RESULT_SUCCESS) if (result != 0)
return result; return result;
pos += nbytes_to_send - 2; pos += nbytes_to_send - 2;
...@@ -378,31 +357,31 @@ static int xc_load_i2c_sequence(struct dvb_frontend *fe, const u8 *i2c_sequence) ...@@ -378,31 +357,31 @@ static int xc_load_i2c_sequence(struct dvb_frontend *fe, const u8 *i2c_sequence)
index += len; index += len;
} }
} }
return XC_RESULT_SUCCESS; return 0;
} }
static int xc_SetTVStandard(struct xc4000_priv *priv, static int xc_set_tv_standard(struct xc4000_priv *priv,
u16 VideoMode, u16 AudioMode) u16 video_mode, u16 audio_mode)
{ {
int ret; int ret;
dprintk(1, "%s(0x%04x,0x%04x)\n", __func__, VideoMode, AudioMode); dprintk(1, "%s(0x%04x,0x%04x)\n", __func__, video_mode, audio_mode);
dprintk(1, "%s() Standard = %s\n", dprintk(1, "%s() Standard = %s\n",
__func__, __func__,
XC4000_Standard[priv->video_standard].Name); xc4000_standard[priv->video_standard].Name);
/* Don't complain when the request fails because of i2c stretching */ /* Don't complain when the request fails because of i2c stretching */
priv->ignore_i2c_write_errors = 1; priv->ignore_i2c_write_errors = 1;
ret = xc_write_reg(priv, XREG_VIDEO_MODE, VideoMode); ret = xc_write_reg(priv, XREG_VIDEO_MODE, video_mode);
if (ret == XC_RESULT_SUCCESS) if (ret == 0)
ret = xc_write_reg(priv, XREG_AUDIO_MODE, AudioMode); ret = xc_write_reg(priv, XREG_AUDIO_MODE, audio_mode);
priv->ignore_i2c_write_errors = 0; priv->ignore_i2c_write_errors = 0;
return ret; return ret;
} }
static int xc_SetSignalSource(struct xc4000_priv *priv, u16 rf_mode) static int xc_set_signal_source(struct xc4000_priv *priv, u16 rf_mode)
{ {
dprintk(1, "%s(%d) Source = %s\n", __func__, rf_mode, dprintk(1, "%s(%d) Source = %s\n", __func__, rf_mode,
rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE");
...@@ -418,25 +397,26 @@ static int xc_SetSignalSource(struct xc4000_priv *priv, u16 rf_mode) ...@@ -418,25 +397,26 @@ static int xc_SetSignalSource(struct xc4000_priv *priv, u16 rf_mode)
static const struct dvb_tuner_ops xc4000_tuner_ops; static const struct dvb_tuner_ops xc4000_tuner_ops;
static int xc_set_RF_frequency(struct xc4000_priv *priv, u32 freq_hz) static int xc_set_rf_frequency(struct xc4000_priv *priv, u32 freq_hz)
{ {
u16 freq_code; u16 freq_code;
dprintk(1, "%s(%u)\n", __func__, freq_hz); dprintk(1, "%s(%u)\n", __func__, freq_hz);
if ((freq_hz > xc4000_tuner_ops.info.frequency_max) || if ((freq_hz > xc4000_tuner_ops.info.frequency_max) ||
(freq_hz < xc4000_tuner_ops.info.frequency_min)) (freq_hz < xc4000_tuner_ops.info.frequency_min))
return XC_RESULT_OUT_OF_RANGE; return -EINVAL;
freq_code = (u16)(freq_hz / 15625); freq_code = (u16)(freq_hz / 15625);
/* WAS: Starting in firmware version 1.1.44, Xceive recommends using the /* WAS: Starting in firmware version 1.1.44, Xceive recommends using the
FINERFREQ for all normal tuning (the doc indicates reg 0x03 should FINERFREQ for all normal tuning (the doc indicates reg 0x03 should
only be used for fast scanning for channel lock) */ only be used for fast scanning for channel lock) */
return xc_write_reg(priv, XREG_RF_FREQ, freq_code); /* WAS: XREG_FINERFREQ */ /* WAS: XREG_FINERFREQ */
return xc_write_reg(priv, XREG_RF_FREQ, freq_code);
} }
static int xc_get_ADC_Envelope(struct xc4000_priv *priv, u16 *adc_envelope) static int xc_get_adc_envelope(struct xc4000_priv *priv, u16 *adc_envelope)
{ {
return xc4000_readreg(priv, XREG_ADC_ENV, adc_envelope); return xc4000_readreg(priv, XREG_ADC_ENV, adc_envelope);
} }
...@@ -448,7 +428,7 @@ static int xc_get_frequency_error(struct xc4000_priv *priv, u32 *freq_error_hz) ...@@ -448,7 +428,7 @@ static int xc_get_frequency_error(struct xc4000_priv *priv, u32 *freq_error_hz)
u32 tmp; u32 tmp;
result = xc4000_readreg(priv, XREG_FREQ_ERROR, &regData); result = xc4000_readreg(priv, XREG_FREQ_ERROR, &regData);
if (result != XC_RESULT_SUCCESS) if (result != 0)
return result; return result;
tmp = (u32)regData & 0xFFFFU; tmp = (u32)regData & 0xFFFFU;
...@@ -470,7 +450,7 @@ static int xc_get_version(struct xc4000_priv *priv, ...@@ -470,7 +450,7 @@ static int xc_get_version(struct xc4000_priv *priv,
int result; int result;
result = xc4000_readreg(priv, XREG_VERSION, &data); result = xc4000_readreg(priv, XREG_VERSION, &data);
if (result != XC_RESULT_SUCCESS) if (result != 0)
return result; return result;
(*hw_majorversion) = (data >> 12) & 0x0F; (*hw_majorversion) = (data >> 12) & 0x0F;
...@@ -487,7 +467,7 @@ static int xc_get_hsync_freq(struct xc4000_priv *priv, u32 *hsync_freq_hz) ...@@ -487,7 +467,7 @@ static int xc_get_hsync_freq(struct xc4000_priv *priv, u32 *hsync_freq_hz)
int result; int result;
result = xc4000_readreg(priv, XREG_HSYNC_FREQ, &regData); result = xc4000_readreg(priv, XREG_HSYNC_FREQ, &regData);
if (result != XC_RESULT_SUCCESS) if (result != 0)
return result; return result;
(*hsync_freq_hz) = ((regData & 0x0fff) * 763)/100; (*hsync_freq_hz) = ((regData & 0x0fff) * 763)/100;
...@@ -504,19 +484,19 @@ static int xc_get_quality(struct xc4000_priv *priv, u16 *quality) ...@@ -504,19 +484,19 @@ static int xc_get_quality(struct xc4000_priv *priv, u16 *quality)
return xc4000_readreg(priv, XREG_QUALITY, quality); return xc4000_readreg(priv, XREG_QUALITY, quality);
} }
static u16 WaitForLock(struct xc4000_priv *priv) static u16 xc_wait_for_lock(struct xc4000_priv *priv)
{ {
u16 lockState = 0; u16 lock_state = 0;
int watchDogCount = 40; int watchdog_count = 40;
while ((lockState == 0) && (watchDogCount > 0)) { while ((lock_state == 0) && (watchdog_count > 0)) {
xc_get_lock_status(priv, &lockState); xc_get_lock_status(priv, &lock_state);
if (lockState != 1) { if (lock_state != 1) {
xc_wait(5); msleep(5);
watchDogCount--; watchdog_count--;
} }
} }
return lockState; return lock_state;
} }
static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz) static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz)
...@@ -528,15 +508,15 @@ static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz) ...@@ -528,15 +508,15 @@ static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz)
/* Don't complain when the request fails because of i2c stretching */ /* Don't complain when the request fails because of i2c stretching */
priv->ignore_i2c_write_errors = 1; priv->ignore_i2c_write_errors = 1;
result = xc_set_RF_frequency(priv, freq_hz); result = xc_set_rf_frequency(priv, freq_hz);
priv->ignore_i2c_write_errors = 0; priv->ignore_i2c_write_errors = 0;
if (result != XC_RESULT_SUCCESS) if (result != 0)
return 0; return 0;
/* wait for lock only in analog TV mode */ /* wait for lock only in analog TV mode */
if ((priv->cur_fw.type & (FM | DTV6 | DTV7 | DTV78 | DTV8)) == 0) { if ((priv->cur_fw.type & (FM | DTV6 | DTV7 | DTV78 | DTV8)) == 0) {
if (WaitForLock(priv) != 1) if (xc_wait_for_lock(priv) != 1)
found = 0; found = 0;
} }
...@@ -544,7 +524,7 @@ static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz) ...@@ -544,7 +524,7 @@ static int xc_tune_channel(struct xc4000_priv *priv, u32 freq_hz)
* Frame Lines needs two frame times after initial lock * Frame Lines needs two frame times after initial lock
* before it is valid. * before it is valid.
*/ */
xc_wait(debug ? 100 : 10); msleep(debug ? 100 : 10);
if (debug) if (debug)
xc_debug_dump(priv); xc_debug_dump(priv);
...@@ -569,7 +549,7 @@ static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val) ...@@ -569,7 +549,7 @@ static int xc4000_readreg(struct xc4000_priv *priv, u16 reg, u16 *val)
} }
*val = (bval[0] << 8) | bval[1]; *val = (bval[0] << 8) | bval[1];
return XC_RESULT_SUCCESS; return 0;
} }
#define dump_firm_type(t) dump_firm_type_and_int_freq(t, 0) #define dump_firm_type(t) dump_firm_type_and_int_freq(t, 0)
...@@ -647,7 +627,7 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type, ...@@ -647,7 +627,7 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
unsigned int best_nr_diffs = 255U; unsigned int best_nr_diffs = 255U;
if (!priv->firm) { if (!priv->firm) {
printk("Error! firmware not loaded\n"); printk(KERN_ERR "Error! firmware not loaded\n");
return -EINVAL; return -EINVAL;
} }
...@@ -685,8 +665,8 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type, ...@@ -685,8 +665,8 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
if (best_nr_diffs > 0U) { if (best_nr_diffs > 0U) {
printk("Selecting best matching firmware (%u bits differ) for " printk("Selecting best matching firmware (%u bits differ) for "
"type=", best_nr_diffs); "type=(%x), id %016llx:\n",
printk("(%x), id %016llx:\n", type, (unsigned long long)*id); best_nr_diffs, type, (unsigned long long)*id);
i = best_i; i = best_i;
} }
...@@ -695,8 +675,8 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type, ...@@ -695,8 +675,8 @@ static int seek_firmware(struct dvb_frontend *fe, unsigned int type,
ret: ret:
if (debug) { if (debug) {
printk("%s firmware for type=", (i < 0) ? "Can't find" : printk("%s firmware for type=",
"Found"); (i < 0) ? "Can't find" : "Found");
dump_firm_type(type); dump_firm_type(type);
printk("(%x), id %016llx.\n", type, (unsigned long long)*id); printk("(%x), id %016llx.\n", type, (unsigned long long)*id);
} }
...@@ -745,11 +725,10 @@ static int xc4000_fwupload(struct dvb_frontend *fe) ...@@ -745,11 +725,10 @@ static int xc4000_fwupload(struct dvb_frontend *fe)
rc = request_firmware(&fw, fname, priv->i2c_props.adap->dev.parent); rc = request_firmware(&fw, fname, priv->i2c_props.adap->dev.parent);
if (rc < 0) { if (rc < 0) {
if (rc == -ENOENT) if (rc == -ENOENT)
printk("Error: firmware %s not found.\n", printk("Error: firmware %s not found.\n", fname);
fname);
else else
printk("Error %d while requesting firmware %s \n", printk("Error %d while requesting firmware %s \n",
rc, fname); rc, fname);
return rc; return rc;
} }
...@@ -757,13 +736,12 @@ static int xc4000_fwupload(struct dvb_frontend *fe) ...@@ -757,13 +736,12 @@ static int xc4000_fwupload(struct dvb_frontend *fe)
endp = p + fw->size; endp = p + fw->size;
if (fw->size < sizeof(name) - 1 + 2 + 2) { if (fw->size < sizeof(name) - 1 + 2 + 2) {
printk("Error: firmware file %s has invalid size!\n", printk("Error: firmware file %s has invalid size!\n", fname);
fname);
goto corrupt; goto corrupt;
} }
memcpy(name, p, sizeof(name) - 1); memcpy(name, p, sizeof(name) - 1);
name[sizeof(name) - 1] = 0; name[sizeof(name) - 1] = '\0';
p += sizeof(name) - 1; p += sizeof(name) - 1;
priv->firm_version = get_unaligned_le16(p); priv->firm_version = get_unaligned_le16(p);
...@@ -920,7 +898,7 @@ static int load_scode(struct dvb_frontend *fe, unsigned int type, ...@@ -920,7 +898,7 @@ static int load_scode(struct dvb_frontend *fe, unsigned int type,
} }
rc = xc_send_i2c_data(priv, scode_buf, 13); rc = xc_send_i2c_data(priv, scode_buf, 13);
if (rc != XC_RESULT_SUCCESS) { if (rc != 0) {
/* Even if the send failed, make sure we set back to indirect /* Even if the send failed, make sure we set back to indirect
mode */ mode */
printk("Failed to set scode %d\n", rc); printk("Failed to set scode %d\n", rc);
...@@ -953,16 +931,11 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type, ...@@ -953,16 +931,11 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type,
return rc; return rc;
} }
#ifdef DJH_DEBUG
if (priv->ctrl.mts && !(type & FM))
type |= MTS;
#endif
retry: retry:
new_fw.type = type; new_fw.type = type;
new_fw.id = std; new_fw.id = std;
new_fw.std_req = std; new_fw.std_req = std;
new_fw.scode_table = SCODE /* | priv->ctrl.scode_table */; new_fw.scode_table = SCODE;
new_fw.scode_nr = 0; new_fw.scode_nr = 0;
new_fw.int_freq = int_freq; new_fw.int_freq = int_freq;
...@@ -971,15 +944,11 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type, ...@@ -971,15 +944,11 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type,
dump_firm_type(new_fw.type); dump_firm_type(new_fw.type);
printk("(%x), id %016llx, ", new_fw.type, printk("(%x), id %016llx, ", new_fw.type,
(unsigned long long)new_fw.std_req); (unsigned long long)new_fw.std_req);
if (!int_freq) { if (!int_freq)
printk("scode_tbl "); printk(KERN_CONT "scode_tbl ");
#ifdef DJH_DEBUG else
dump_firm_type(priv->ctrl.scode_table); printk(KERN_CONT "int_freq %d, ", new_fw.int_freq);
printk("(%x), ", priv->ctrl.scode_table); printk(KERN_CONT "scode_nr %d\n", new_fw.scode_nr);
#endif
} else
printk("int_freq %d, ", new_fw.int_freq);
printk("scode_nr %d\n", new_fw.scode_nr);
} }
/* No need to reload base firmware if it matches */ /* No need to reload base firmware if it matches */
...@@ -992,7 +961,7 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type, ...@@ -992,7 +961,7 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type,
memset(&priv->cur_fw, 0, sizeof(priv->cur_fw)); memset(&priv->cur_fw, 0, sizeof(priv->cur_fw));
/* Reset is needed before loading firmware */ /* Reset is needed before loading firmware */
rc = xc4000_TunerReset(fe); rc = xc4000_tuner_reset(fe);
if (rc < 0) if (rc < 0)
goto fail; goto fail;
...@@ -1046,14 +1015,14 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type, ...@@ -1046,14 +1015,14 @@ static int check_firmware(struct dvb_frontend *fe, unsigned int type,
/* Load SCODE firmware, if exists */ /* Load SCODE firmware, if exists */
rc = load_scode(fe, new_fw.type | new_fw.scode_table, &new_fw.id, rc = load_scode(fe, new_fw.type | new_fw.scode_table, &new_fw.id,
new_fw.int_freq, new_fw.scode_nr); new_fw.int_freq, new_fw.scode_nr);
if (rc != XC_RESULT_SUCCESS) if (rc != 0)
dprintk(1, "load scode failed %d\n", rc); dprintk(1, "load scode failed %d\n", rc);
check_device: check_device:
rc = xc4000_readreg(priv, XREG_PRODUCT_ID, &hwmodel); rc = xc4000_readreg(priv, XREG_PRODUCT_ID, &hwmodel);
if (xc_get_version(priv, &hw_major, &hw_minor, &fw_major, if (xc_get_version(priv, &hw_major, &hw_minor, &fw_major,
&fw_minor) != XC_RESULT_SUCCESS) { &fw_minor) != 0) {
printk("Unable to read tuner registers.\n"); printk("Unable to read tuner registers.\n");
goto fail; goto fail;
} }
...@@ -1121,7 +1090,7 @@ static void xc_debug_dump(struct xc4000_priv *priv) ...@@ -1121,7 +1090,7 @@ static void xc_debug_dump(struct xc4000_priv *priv)
u8 hw_majorversion = 0, hw_minorversion = 0; u8 hw_majorversion = 0, hw_minorversion = 0;
u8 fw_majorversion = 0, fw_minorversion = 0; u8 fw_majorversion = 0, fw_minorversion = 0;
xc_get_ADC_Envelope(priv, &adc_envelope); xc_get_adc_envelope(priv, &adc_envelope);
dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope); dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope);
xc_get_frequency_error(priv, &freq_error_hz); xc_get_frequency_error(priv, &freq_error_hz);
...@@ -1235,24 +1204,23 @@ static int xc4000_set_params(struct dvb_frontend *fe, ...@@ -1235,24 +1204,23 @@ static int xc4000_set_params(struct dvb_frontend *fe,
__func__, priv->freq_hz); __func__, priv->freq_hz);
/* Make sure the correct firmware type is loaded */ /* Make sure the correct firmware type is loaded */
if (check_firmware(fe, type, 0, priv->if_khz) != XC_RESULT_SUCCESS) if (check_firmware(fe, type, 0, priv->if_khz) != 0)
goto fail; goto fail;
ret = xc_SetSignalSource(priv, priv->rf_mode); ret = xc_set_signal_source(priv, priv->rf_mode);
if (ret != XC_RESULT_SUCCESS) { if (ret != 0) {
printk(KERN_ERR printk(KERN_ERR "xc4000: xc_set_signal_source(%d) failed\n",
"xc4000: xc_SetSignalSource(%d) failed\n",
priv->rf_mode); priv->rf_mode);
goto fail; goto fail;
} else { } else {
u16 video_mode, audio_mode; u16 video_mode, audio_mode;
video_mode = XC4000_Standard[priv->video_standard].VideoMode; video_mode = xc4000_standard[priv->video_standard].video_mode;
audio_mode = XC4000_Standard[priv->video_standard].AudioMode; audio_mode = xc4000_standard[priv->video_standard].audio_mode;
if (type == DTV6 && priv->firm_version != 0x0102) if (type == DTV6 && priv->firm_version != 0x0102)
video_mode |= 0x0001; video_mode |= 0x0001;
ret = xc_SetTVStandard(priv, video_mode, audio_mode); ret = xc_set_tv_standard(priv, video_mode, audio_mode);
if (ret != XC_RESULT_SUCCESS) { if (ret != 0) {
printk(KERN_ERR "xc4000: xc_SetTVStandard failed\n"); printk(KERN_ERR "xc4000: xc_set_tv_standard failed\n");
/* DJH - do not return when it fails... */ /* DJH - do not return when it fails... */
/* goto fail; */ /* goto fail; */
} }
...@@ -1423,27 +1391,25 @@ static int xc4000_set_analog_params(struct dvb_frontend *fe, ...@@ -1423,27 +1391,25 @@ static int xc4000_set_analog_params(struct dvb_frontend *fe,
} }
tune_channel: tune_channel:
/* Fix me: it could be air. */ /* FIXME: it could be air. */
priv->rf_mode = XC_RF_MODE_CABLE; priv->rf_mode = XC_RF_MODE_CABLE;
if (check_firmware(fe, type, params->std, if (check_firmware(fe, type, params->std,
XC4000_Standard[priv->video_standard].int_freq) xc4000_standard[priv->video_standard].int_freq) != 0)
!= XC_RESULT_SUCCESS) {
goto fail; goto fail;
}
ret = xc_SetSignalSource(priv, priv->rf_mode); ret = xc_set_signal_source(priv, priv->rf_mode);
if (ret != XC_RESULT_SUCCESS) { if (ret != 0) {
printk(KERN_ERR printk(KERN_ERR
"xc4000: xc_SetSignalSource(%d) failed\n", "xc4000: xc_set_signal_source(%d) failed\n",
priv->rf_mode); priv->rf_mode);
goto fail; goto fail;
} else { } else {
u16 video_mode, audio_mode; u16 video_mode, audio_mode;
video_mode = XC4000_Standard[priv->video_standard].VideoMode; video_mode = xc4000_standard[priv->video_standard].video_mode;
audio_mode = XC4000_Standard[priv->video_standard].AudioMode; audio_mode = xc4000_standard[priv->video_standard].audio_mode;
if (priv->video_standard < XC4000_BG_PAL_A2) { if (priv->video_standard < XC4000_BG_PAL_A2) {
if (0 /*type & NOGD*/) if (type & NOGD)
video_mode &= 0xFF7F; video_mode &= 0xFF7F;
} else if (priv->video_standard < XC4000_I_PAL_NICAM) { } else if (priv->video_standard < XC4000_I_PAL_NICAM) {
if (priv->card_type == XC4000_CARD_WINFAST_CX88 && if (priv->card_type == XC4000_CARD_WINFAST_CX88 &&
...@@ -1452,9 +1418,9 @@ static int xc4000_set_analog_params(struct dvb_frontend *fe, ...@@ -1452,9 +1418,9 @@ static int xc4000_set_analog_params(struct dvb_frontend *fe,
if (audio_std & XC4000_AUDIO_STD_B) if (audio_std & XC4000_AUDIO_STD_B)
video_mode |= 0x0080; video_mode |= 0x0080;
} }
ret = xc_SetTVStandard(priv, video_mode, audio_mode); ret = xc_set_tv_standard(priv, video_mode, audio_mode);
if (ret != XC_RESULT_SUCCESS) { if (ret != 0) {
printk(KERN_ERR "xc4000: xc_SetTVStandard failed\n"); printk(KERN_ERR "xc4000: xc_set_tv_standard failed\n");
goto fail; goto fail;
} }
} }
...@@ -1542,7 +1508,7 @@ static int xc4000_get_status(struct dvb_frontend *fe, u32 *status) ...@@ -1542,7 +1508,7 @@ static int xc4000_get_status(struct dvb_frontend *fe, u32 *status)
static int xc4000_sleep(struct dvb_frontend *fe) static int xc4000_sleep(struct dvb_frontend *fe)
{ {
struct xc4000_priv *priv = fe->tuner_priv; struct xc4000_priv *priv = fe->tuner_priv;
int ret = XC_RESULT_SUCCESS; int ret = 0;
dprintk(1, "%s()\n", __func__); dprintk(1, "%s()\n", __func__);
...@@ -1556,14 +1522,13 @@ static int xc4000_sleep(struct dvb_frontend *fe) ...@@ -1556,14 +1522,13 @@ static int xc4000_sleep(struct dvb_frontend *fe)
/* force reset and firmware reload */ /* force reset and firmware reload */
priv->cur_fw.type = XC_POWERED_DOWN; priv->cur_fw.type = XC_POWERED_DOWN;
if (xc_write_reg(priv, XREG_POWER_DOWN, 0) if (xc_write_reg(priv, XREG_POWER_DOWN, 0) != 0) {
!= XC_RESULT_SUCCESS) {
printk(KERN_ERR printk(KERN_ERR
"xc4000: %s() unable to shutdown tuner\n", "xc4000: %s() unable to shutdown tuner\n",
__func__); __func__);
ret = -EREMOTEIO; ret = -EREMOTEIO;
} }
xc_wait(20); msleep(20);
} }
mutex_unlock(&priv->lock); mutex_unlock(&priv->lock);
...@@ -1672,8 +1637,7 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe, ...@@ -1672,8 +1637,7 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe,
*/ */
if (instance == 1) { if (instance == 1) {
if (xc4000_readreg(priv, XREG_PRODUCT_ID, &id) if (xc4000_readreg(priv, XREG_PRODUCT_ID, &id) != 0)
!= XC_RESULT_SUCCESS)
goto fail; goto fail;
} else { } else {
id = ((priv->cur_fw.type & BASE) != 0 ? id = ((priv->cur_fw.type & BASE) != 0 ?
...@@ -1713,7 +1677,7 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe, ...@@ -1713,7 +1677,7 @@ struct dvb_frontend *xc4000_attach(struct dvb_frontend *fe,
mutex_lock(&priv->lock); mutex_lock(&priv->lock);
ret = xc4000_fwupload(fe); ret = xc4000_fwupload(fe);
mutex_unlock(&priv->lock); mutex_unlock(&priv->lock);
if (ret != XC_RESULT_SUCCESS) if (ret != 0)
goto fail2; goto fail2;
} }
......
...@@ -2706,13 +2706,14 @@ static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = { ...@@ -2706,13 +2706,14 @@ static struct dibx000_agc_config stk7700p_7000p_xc4000_agc_config = {
}; };
static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = { static struct dibx000_bandwidth_config stk7700p_xc4000_pll_config = {
60000, 30000, // internal, sampling 60000, 30000, /* internal, sampling */
1, 8, 3, 1, 0, // pll_cfg: prediv, ratio, range, reset, bypass 1, 8, 3, 1, 0, /* pll_cfg: prediv, ratio, range, reset, bypass */
0, 0, 1, 1, 0, // misc: refdiv, bypclk_div, IO_CLK_en_core, ADClkSrc, modulo 0, 0, 1, 1, 0, /* misc: refdiv, bypclk_div, IO_CLK_en_core, */
(3 << 14) | (1 << 12) | (524 << 0), // sad_cfg: refsel, sel, freq_15k /* ADClkSrc, modulo */
39370534, // ifreq (3 << 14) | (1 << 12) | 524, /* sad_cfg: refsel, sel, freq_15k */
20452225, // timf 39370534, /* ifreq */
30000000, // xtal 20452225, /* timf */
30000000 /* xtal */
}; };
/* FIXME: none of these inputs are validated yet */ /* FIXME: none of these inputs are validated yet */
......
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