V4L/DVB (6886): xc5000: Cleanups of types, result codes etc

This translates much of the xceive coding style, adds
some result codes and generally cleans up whitespace
and function arguments.

Signed-off-by: Steven Toth <stoth@hauppauge.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
This commit is contained in:
Steven Toth 2007-12-20 01:14:43 -03:00 committed by Mauro Carvalho Chehab
parent d1987d55a1
commit e12671cf0c
4 changed files with 165 additions and 153 deletions

View File

@ -117,8 +117,8 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off).");
*/ */
typedef struct { typedef struct {
char *Name; char *Name;
unsigned short AudioMode; u16 AudioMode;
unsigned short VideoMode; u16 VideoMode;
} XC_TV_STANDARD; } XC_TV_STANDARD;
/* Tuner standards */ /* Tuner standards */
@ -154,29 +154,27 @@ static int xc5000_writeregs(struct xc5000_priv *priv, u8 *buf, u8 len);
static int xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len); static int xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len);
static void xc5000_TunerReset(struct dvb_frontend *fe); static void xc5000_TunerReset(struct dvb_frontend *fe);
int xc_send_i2c_data(struct xc5000_priv *priv, static int xc_send_i2c_data(struct xc5000_priv *priv, u8 *buf, int len)
unsigned char *bytes_to_send, int nb_bytes_to_send)
{ {
return xc5000_writeregs(priv, bytes_to_send, nb_bytes_to_send) return xc5000_writeregs(priv, buf, len)
? XC_RESULT_I2C_WRITE_FAILURE : XC_RESULT_SUCCESS; ? XC_RESULT_I2C_WRITE_FAILURE : XC_RESULT_SUCCESS;
} }
int xc_read_i2c_data(struct xc5000_priv *priv, unsigned char *bytes_received, static int xc_read_i2c_data(struct xc5000_priv *priv, u8 *buf, int len)
int nb_bytes_to_receive)
{ {
return xc5000_readregs(priv, bytes_received, nb_bytes_to_receive) return xc5000_readregs(priv, buf, len)
? XC_RESULT_I2C_READ_FAILURE : XC_RESULT_SUCCESS; ? XC_RESULT_I2C_READ_FAILURE : XC_RESULT_SUCCESS;
} }
int xc_reset(struct dvb_frontend *fe) static int xc_reset(struct dvb_frontend *fe)
{ {
xc5000_TunerReset(fe); xc5000_TunerReset(fe);
return XC_RESULT_SUCCESS; return XC_RESULT_SUCCESS;
} }
void xc_wait(int wait_ms) static void xc_wait(int wait_ms)
{ {
msleep( wait_ms ); msleep(wait_ms);
} }
static void xc5000_TunerReset(struct dvb_frontend *fe) static void xc5000_TunerReset(struct dvb_frontend *fe)
@ -186,7 +184,7 @@ static void xc5000_TunerReset(struct dvb_frontend *fe)
dprintk(1, "%s()\n", __FUNCTION__); dprintk(1, "%s()\n", __FUNCTION__);
if(priv->cfg->tuner_reset) { if (priv->cfg->tuner_reset) {
ret = priv->cfg->tuner_reset(fe); ret = priv->cfg->tuner_reset(fe);
if (ret) if (ret)
printk(KERN_ERR "xc5000: reset failed\n"); printk(KERN_ERR "xc5000: reset failed\n");
@ -194,10 +192,9 @@ static void xc5000_TunerReset(struct dvb_frontend *fe)
printk(KERN_ERR "xc5000: no tuner reset function, fatal\n"); printk(KERN_ERR "xc5000: no tuner reset function, fatal\n");
} }
int xc_write_reg(struct xc5000_priv *priv, unsigned short int regAddr, static int xc_write_reg(struct xc5000_priv *priv, u16 regAddr, u16 i2cData)
unsigned short int i2cData)
{ {
unsigned char buf[4]; u8 buf[4];
int WatchDogTimer = 5; int WatchDogTimer = 5;
int result; int result;
@ -206,7 +203,7 @@ int xc_write_reg(struct xc5000_priv *priv, unsigned short int regAddr,
buf[2] = (i2cData >> 8) & 0xFF; buf[2] = (i2cData >> 8) & 0xFF;
buf[3] = i2cData & 0xFF; buf[3] = i2cData & 0xFF;
result = xc_send_i2c_data(priv, buf, 4); result = xc_send_i2c_data(priv, buf, 4);
if ( result == XC_RESULT_SUCCESS) { if (result == XC_RESULT_SUCCESS) {
/* wait for busy flag to clear */ /* wait for busy flag to clear */
while ((WatchDogTimer > 0) && (result == XC_RESULT_SUCCESS)) { while ((WatchDogTimer > 0) && (result == XC_RESULT_SUCCESS)) {
buf[0] = 0; buf[0] = 0;
@ -233,43 +230,42 @@ int xc_write_reg(struct xc5000_priv *priv, unsigned short int regAddr,
return result; return result;
} }
int xc_read_reg(struct xc5000_priv *priv, unsigned short int regAddr, static int xc_read_reg(struct xc5000_priv *priv, u16 regAddr, u16 *i2cData)
unsigned short int *i2cData)
{ {
unsigned char buf[2]; u8 buf[2];
int result; int result;
buf[0] = (regAddr >> 8) & 0xFF; buf[0] = (regAddr >> 8) & 0xFF;
buf[1] = regAddr & 0xFF; buf[1] = regAddr & 0xFF;
result = xc_send_i2c_data(priv, buf, 2); result = xc_send_i2c_data(priv, buf, 2);
if (result!=XC_RESULT_SUCCESS) if (result != XC_RESULT_SUCCESS)
return result; return result;
result = xc_read_i2c_data(priv, buf, 2); result = xc_read_i2c_data(priv, buf, 2);
if (result!=XC_RESULT_SUCCESS) if (result != XC_RESULT_SUCCESS)
return result; return result;
*i2cData = buf[0] * 256 + buf[1]; *i2cData = buf[0] * 256 + buf[1];
return result; return result;
} }
int xc_load_i2c_sequence(struct dvb_frontend *fe, unsigned char i2c_sequence[]) static int xc_load_i2c_sequence(struct dvb_frontend *fe, u8 i2c_sequence[])
{ {
struct xc5000_priv *priv = fe->tuner_priv; struct xc5000_priv *priv = fe->tuner_priv;
int i, nbytes_to_send, result; int i, nbytes_to_send, result;
unsigned int len, pos, index; unsigned int len, pos, index;
unsigned char buf[XC_MAX_I2C_WRITE_LENGTH]; u8 buf[XC_MAX_I2C_WRITE_LENGTH];
index=0; index=0;
while ((i2c_sequence[index]!=0xFF) || (i2c_sequence[index+1]!=0xFF)) { while ((i2c_sequence[index]!=0xFF) || (i2c_sequence[index+1]!=0xFF)) {
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 */
result = xc_reset(fe); result = xc_reset(fe);
index += 2; index += 2;
if (result!=XC_RESULT_SUCCESS) if (result != XC_RESULT_SUCCESS)
return result; return result;
} else if (len & 0x8000) { } else if (len & 0x8000) {
/* WAIT command */ /* WAIT command */
@ -294,7 +290,7 @@ int xc_load_i2c_sequence(struct dvb_frontend *fe, unsigned char i2c_sequence[])
} }
result = xc_send_i2c_data(priv, buf, nbytes_to_send); result = xc_send_i2c_data(priv, buf, nbytes_to_send);
if (result!=XC_RESULT_SUCCESS) if (result != XC_RESULT_SUCCESS)
return result; return result;
pos += nbytes_to_send - 2; pos += nbytes_to_send - 2;
@ -305,14 +301,14 @@ int xc_load_i2c_sequence(struct dvb_frontend *fe, unsigned char i2c_sequence[])
return XC_RESULT_SUCCESS; return XC_RESULT_SUCCESS;
} }
int xc_initialize(struct xc5000_priv *priv) static int xc_initialize(struct xc5000_priv *priv)
{ {
dprintk(1, "%s()\n", __FUNCTION__); dprintk(1, "%s()\n", __FUNCTION__);
return xc_write_reg(priv, XREG_INIT, 0); return xc_write_reg(priv, XREG_INIT, 0);
} }
int xc_SetTVStandard(struct xc5000_priv *priv, unsigned short int VideoMode, static int xc_SetTVStandard(struct xc5000_priv *priv,
unsigned short int AudioMode) u16 VideoMode, u16 AudioMode)
{ {
int ret; int ret;
dprintk(1, "%s(%d,%d)\n", __FUNCTION__, VideoMode, AudioMode); dprintk(1, "%s(%d,%d)\n", __FUNCTION__, VideoMode, AudioMode);
@ -327,17 +323,17 @@ int xc_SetTVStandard(struct xc5000_priv *priv, unsigned short int VideoMode,
return ret; return ret;
} }
int xc_shutdown(struct xc5000_priv *priv) static int xc_shutdown(struct xc5000_priv *priv)
{ {
return xc_write_reg(priv, XREG_POWER_DOWN, 0); return xc_write_reg(priv, XREG_POWER_DOWN, 0);
} }
int xc_SetSignalSource(struct xc5000_priv *priv, unsigned short int rf_mode) static int xc_SetSignalSource(struct xc5000_priv *priv, u16 rf_mode)
{ {
dprintk(1, "%s(%d) Source = %s\n", __FUNCTION__, rf_mode, dprintk(1, "%s(%d) Source = %s\n", __FUNCTION__, rf_mode,
rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE");
if( (rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE) ) if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE))
{ {
rf_mode = XC_RF_MODE_CABLE; rf_mode = XC_RF_MODE_CABLE;
printk(KERN_ERR printk(KERN_ERR
@ -347,52 +343,43 @@ int xc_SetSignalSource(struct xc5000_priv *priv, unsigned short int rf_mode)
return xc_write_reg(priv, XREG_SIGNALSOURCE, rf_mode); return xc_write_reg(priv, XREG_SIGNALSOURCE, rf_mode);
} }
int xc_set_RF_frequency(struct xc5000_priv *priv, long frequency_in_hz) static const struct dvb_tuner_ops xc5000_tuner_ops;
static int xc_set_RF_frequency(struct xc5000_priv *priv, u32 freq_hz)
{ {
unsigned int frequency_code = (unsigned int)(frequency_in_hz / 15625); u16 freq_code;
if ((frequency_in_hz>1023000000) || (frequency_in_hz<1000000))
return XC_RESULT_OUT_OF_RANGE;
return xc_write_reg(priv, XREG_RF_FREQ ,frequency_code);
}
int xc_FineTune_RF_frequency(struct xc5000_priv *priv, long frequency_in_hz)
{
unsigned int frequency_code = (unsigned int)(frequency_in_hz / 15625);
if ((frequency_in_hz>1023000000) || (frequency_in_hz<1000000))
return XC_RESULT_OUT_OF_RANGE;
return xc_write_reg(priv, XREG_FINERFFREQ ,frequency_code);
}
int xc_set_IF_frequency(struct xc5000_priv *priv, u32 freq_hz)
{
u32 freq_code = (freq_hz * 1024)/1000000;
dprintk(1, "%s(%d)\n", __FUNCTION__, freq_hz); dprintk(1, "%s(%d)\n", __FUNCTION__, freq_hz);
printk(KERN_ERR "FIXME - Hardcoded IF, FIXME\n"); if ((freq_hz > xc5000_tuner_ops.info.frequency_max) ||
freq_code = 0x1585; (freq_hz < xc5000_tuner_ops.info.frequency_min))
return XC_RESULT_OUT_OF_RANGE;
return xc_write_reg(priv, XREG_IF_OUT ,freq_code); freq_code = (u16)(freq_hz / 15625);
return xc_write_reg(priv, XREG_RF_FREQ, freq_code);
} }
int xc_set_Xtal_frequency(struct xc5000_priv *priv, long xtalFreqInKHz)
static int xc_set_IF_frequency(struct xc5000_priv *priv, u32 freq_khz)
{ {
unsigned int xtalRatio = (32000 * 0x8000)/xtalFreqInKHz; u32 freq_code = (freq_khz * 1024)/1000;
return xc_write_reg(priv, XREG_XTALFREQ ,xtalRatio); dprintk(1, "%s(freq_khz = %d) freq_code = 0x%x\n",
__FUNCTION__, freq_khz, freq_code);
return xc_write_reg(priv, XREG_IF_OUT, freq_code);
} }
int xc_get_ADC_Envelope(struct xc5000_priv *priv,
unsigned short int *adc_envelope) static int xc_get_ADC_Envelope(struct xc5000_priv *priv, u16 *adc_envelope)
{ {
return xc_read_reg(priv, XREG_ADC_ENV, adc_envelope); return xc_read_reg(priv, XREG_ADC_ENV, adc_envelope);
} }
int xc_get_frequency_error(struct xc5000_priv *priv, u32 *frequency_error_hz) static int xc_get_frequency_error(struct xc5000_priv *priv, u32 *freq_error_hz)
{ {
int result; int result;
unsigned short int regData; u16 regData;
u32 tmp; u32 tmp;
result = xc_read_reg(priv, XREG_FREQ_ERROR, &regData); result = xc_read_reg(priv, XREG_FREQ_ERROR, &regData);
@ -400,45 +387,37 @@ int xc_get_frequency_error(struct xc5000_priv *priv, u32 *frequency_error_hz)
return result; return result;
tmp = (u32)regData; tmp = (u32)regData;
(*frequency_error_hz) = (tmp * 15625) / 1000; (*freq_error_hz) = (tmp * 15625) / 1000;
return result; return result;
} }
int xc_get_lock_status(struct xc5000_priv *priv, static int xc_get_lock_status(struct xc5000_priv *priv, u16 *lock_status)
unsigned short int *lock_status)
{ {
return xc_read_reg(priv, XREG_LOCK, lock_status); return xc_read_reg(priv, XREG_LOCK, lock_status);
} }
int xc_get_version(struct xc5000_priv *priv, static int xc_get_version(struct xc5000_priv *priv,
unsigned char* hw_majorversion, u8 *hw_majorversion, u8 *hw_minorversion,
unsigned char* hw_minorversion, u8 *fw_majorversion, u8 *fw_minorversion)
unsigned char* fw_majorversion,
unsigned char* fw_minorversion)
{ {
unsigned short int data; u16 data;
int result; int result;
result = xc_read_reg(priv, XREG_VERSION, &data); result = xc_read_reg(priv, XREG_VERSION, &data);
if (result) if (result)
return result; return result;
(*hw_majorversion) = (data>>12) & 0x0F; (*hw_majorversion) = (data >> 12) & 0x0F;
(*hw_minorversion) = (data>>8) & 0x0F; (*hw_minorversion) = (data >> 8) & 0x0F;
(*fw_majorversion) = (data>>4) & 0x0F; (*fw_majorversion) = (data >> 4) & 0x0F;
(*fw_minorversion) = (data) & 0x0F; (*fw_minorversion) = data & 0x0F;
return 0; return 0;
} }
int xc_get_product_id(struct xc5000_priv *priv, unsigned short int *product_id) static int xc_get_hsync_freq(struct xc5000_priv *priv, u32 *hsync_freq_hz)
{ {
return xc_read_reg(priv, XREG_PRODUCT_ID, product_id); u16 regData;
}
int xc_get_hsync_freq(struct xc5000_priv *priv, int *hsync_freq_hz)
{
unsigned short int regData;
int result; int result;
result = xc_read_reg(priv, XREG_HSYNC_FREQ, &regData); result = xc_read_reg(priv, XREG_HSYNC_FREQ, &regData);
@ -449,26 +428,24 @@ int xc_get_hsync_freq(struct xc5000_priv *priv, int *hsync_freq_hz)
return result; return result;
} }
int xc_get_frame_lines(struct xc5000_priv *priv, static int xc_get_frame_lines(struct xc5000_priv *priv, u16 *frame_lines)
unsigned short int *frame_lines)
{ {
return xc_read_reg(priv, XREG_FRAME_LINES, frame_lines); return xc_read_reg(priv, XREG_FRAME_LINES, frame_lines);
} }
int xc_get_quality(struct xc5000_priv *priv, unsigned short int *quality) static int xc_get_quality(struct xc5000_priv *priv, u16 *quality)
{ {
return xc_read_reg(priv, XREG_QUALITY, quality); return xc_read_reg(priv, XREG_QUALITY, quality);
} }
unsigned short int WaitForLock(struct xc5000_priv *priv) static u16 WaitForLock(struct xc5000_priv *priv)
{ {
unsigned short int lockState = 0; u16 lockState = 0;
int watchDogCount = 40; int watchDogCount = 40;
while ((lockState == 0) && (watchDogCount > 0))
{ while ((lockState == 0) && (watchDogCount > 0)) {
xc_get_lock_status(priv, &lockState); xc_get_lock_status(priv, &lockState);
if (lockState != 1) if (lockState != 1) {
{
xc_wait(5); xc_wait(5);
watchDogCount--; watchDogCount--;
} }
@ -476,16 +453,16 @@ unsigned short int WaitForLock(struct xc5000_priv *priv)
return lockState; return lockState;
} }
int xc_tune_channel(struct xc5000_priv *priv, u32 freq) static int xc_tune_channel(struct xc5000_priv *priv, u32 freq_hz)
{ {
int found = 0; int found = 0;
dprintk(1, "%s(%d)\n", __FUNCTION__, freq); dprintk(1, "%s(%d)\n", __FUNCTION__, freq_hz);
if (xc_set_RF_frequency(priv, freq) != XC_RESULT_SUCCESS) if (xc_set_RF_frequency(priv, freq_hz) != XC_RESULT_SUCCESS)
return 0; return 0;
if (WaitForLock(priv)== 1) if (WaitForLock(priv) == 1)
found = 1; found = 1;
return found; return found;
@ -542,15 +519,15 @@ static int xc5000_fwupload(struct dvb_frontend* fe)
const struct firmware *fw; const struct firmware *fw;
int ret; int ret;
/* request the firmware, this will block until someone uploads it */ if (!priv->cfg->request_firmware) {
printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n",
XC5000_DEFAULT_FIRMWARE);
if(!priv->cfg->request_firmware) {
printk(KERN_ERR "xc5000: no firmware callback, fatal\n"); printk(KERN_ERR "xc5000: no firmware callback, fatal\n");
return -EIO; return -EIO;
} }
/* request the firmware, this will block and timeout */
printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n",
XC5000_DEFAULT_FIRMWARE);
ret = priv->cfg->request_firmware(fe, &fw, XC5000_DEFAULT_FIRMWARE); ret = priv->cfg->request_firmware(fe, &fw, XC5000_DEFAULT_FIRMWARE);
if (ret) { if (ret) {
printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n");
@ -560,7 +537,7 @@ static int xc5000_fwupload(struct dvb_frontend* fe)
ret = XC_RESULT_SUCCESS; ret = XC_RESULT_SUCCESS;
} }
if(fw->size != XC5000_DEFAULT_FIRMWARE_SIZE) { if (fw->size != XC5000_DEFAULT_FIRMWARE_SIZE) {
printk(KERN_ERR "xc5000: firmware incorrect size\n"); printk(KERN_ERR "xc5000: firmware incorrect size\n");
ret = XC_RESULT_RESET_FAILURE; ret = XC_RESULT_RESET_FAILURE;
} else { } else {
@ -572,89 +549,110 @@ static int xc5000_fwupload(struct dvb_frontend* fe)
return ret; return ret;
} }
void xc_debug_dump(struct xc5000_priv *priv) static void xc_debug_dump(struct xc5000_priv *priv)
{ {
unsigned short adc_envelope; u16 adc_envelope;
u32 frequency_error_hz; u32 freq_error_hz = 0;
unsigned short lock_status; u16 lock_status;
unsigned char hw_majorversion, hw_minorversion = 0; u32 hsync_freq_hz = 0;
unsigned char fw_majorversion, fw_minorversion = 0; u16 frame_lines;
int hsync_freq_hz; u16 quality;
unsigned short frame_lines; u8 hw_majorversion = 0, hw_minorversion = 0;
unsigned short quality; u8 fw_majorversion = 0, fw_minorversion = 0;
/* Wait for stats to stabilize. /* Wait for stats to stabilize.
* 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( 100 ); xc_wait(100);
xc_get_ADC_Envelope(priv, &adc_envelope ); xc_get_ADC_Envelope(priv, &adc_envelope);
dprintk(1, "*** ADC envelope (0-1023) = %u\n", adc_envelope); dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope);
xc_get_frequency_error(priv, &frequency_error_hz ); xc_get_frequency_error(priv, &freq_error_hz);
dprintk(1, "*** Frequency error = %d Hz\n", frequency_error_hz); dprintk(1, "*** Frequency error = %d Hz\n", freq_error_hz);
xc_get_lock_status(priv, &lock_status ); xc_get_lock_status(priv, &lock_status);
dprintk(1, "*** Lock status (0-Wait, 1-Locked, 2-No-signal) = %u\n", dprintk(1, "*** Lock status (0-Wait, 1-Locked, 2-No-signal) = %d\n",
lock_status); lock_status);
xc_get_version(priv, &hw_majorversion, &hw_minorversion, xc_get_version(priv, &hw_majorversion, &hw_minorversion,
&fw_majorversion, &fw_minorversion ); &fw_majorversion, &fw_minorversion);
dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x\n", dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x\n",
hw_majorversion, hw_minorversion, hw_majorversion, hw_minorversion,
fw_majorversion, fw_minorversion); fw_majorversion, fw_minorversion);
xc_get_hsync_freq(priv, &hsync_freq_hz ); xc_get_hsync_freq(priv, &hsync_freq_hz);
dprintk(1, "*** Horizontal sync frequency = %u Hz\n", hsync_freq_hz); dprintk(1, "*** Horizontal sync frequency = %d Hz\n", hsync_freq_hz);
xc_get_frame_lines(priv, &frame_lines ); xc_get_frame_lines(priv, &frame_lines);
dprintk(1, "*** Frame lines = %u\n", frame_lines); dprintk(1, "*** Frame lines = %d\n", frame_lines);
xc_get_quality(priv, &quality ); xc_get_quality(priv, &quality);
dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %u\n", quality); dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality);
} }
static int xc5000_set_params(struct dvb_frontend *fe, static int xc5000_set_params(struct dvb_frontend *fe,
struct dvb_frontend_parameters *params) struct dvb_frontend_parameters *params)
{ {
struct xc5000_priv *priv = fe->tuner_priv; struct xc5000_priv *priv = fe->tuner_priv;
int ret;
dprintk(1, "%s() frequency=%d\n", __FUNCTION__, params->frequency); dprintk(1, "%s() frequency=%d (Hz)\n", __FUNCTION__, params->frequency);
priv->frequency = params->frequency - 1750000;
priv->bandwidth = 6;
priv->video_standard = DTV6;
switch(params->u.vsb.modulation) { switch(params->u.vsb.modulation) {
case VSB_8: case VSB_8:
case VSB_16: case VSB_16:
dprintk(1, "%s() VSB modulation\n", __FUNCTION__); dprintk(1, "%s() VSB modulation\n", __FUNCTION__);
priv->rf_mode = XC_RF_MODE_AIR; priv->rf_mode = XC_RF_MODE_AIR;
priv->freq_hz = params->frequency - 1750000;
priv->bandwidth = BANDWIDTH_6_MHZ;
priv->video_standard = DTV6;
break; break;
case QAM_64: case QAM_64:
case QAM_256: case QAM_256:
case QAM_AUTO: case QAM_AUTO:
dprintk(1, "%s() QAM modulation\n", __FUNCTION__); dprintk(1, "%s() QAM modulation\n", __FUNCTION__);
priv->rf_mode = XC_RF_MODE_CABLE; priv->rf_mode = XC_RF_MODE_CABLE;
priv->freq_hz = params->frequency - 1750000;
priv->bandwidth = BANDWIDTH_6_MHZ;
priv->video_standard = DTV6;
break; break;
default: default:
return -EINVAL; return -EINVAL;
} }
dprintk(1, "%s() frequency=%d (compensated)\n", dprintk(1, "%s() frequency=%d (compensated)\n",
__FUNCTION__, priv->frequency); __FUNCTION__, priv->freq_hz);
/* FIXME: check result codes */ ret = xc_SetSignalSource(priv, priv->rf_mode);
xc_SetSignalSource(priv, priv->rf_mode); if (ret != XC_RESULT_SUCCESS) {
printk(KERN_ERR
"xc5000: xc_SetSignalSource(%d) failed\n",
priv->rf_mode);
return -EREMOTEIO;
}
xc_SetTVStandard(priv, ret = xc_SetTVStandard(priv,
XC5000_Standard[priv->video_standard].VideoMode, XC5000_Standard[priv->video_standard].VideoMode,
XC5000_Standard[priv->video_standard].AudioMode); XC5000_Standard[priv->video_standard].AudioMode);
if (ret != XC_RESULT_SUCCESS) {
printk(KERN_ERR "xc5000: xc_SetTVStandard failed\n");
return -EREMOTEIO;
}
xc_set_IF_frequency(priv, priv->cfg->if_frequency); ret = xc_set_IF_frequency(priv, priv->cfg->if_khz);
xc_tune_channel(priv, priv->frequency); if (ret != XC_RESULT_SUCCESS) {
xc_debug_dump(priv); printk(KERN_ERR "xc5000: xc_Set_IF_frequency(%d) failed\n",
priv->cfg->if_khz);
return -EIO;
}
xc_tune_channel(priv, priv->freq_hz);
if (debug)
xc_debug_dump(priv);
return 0; return 0;
} }
@ -663,7 +661,7 @@ static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq)
{ {
struct xc5000_priv *priv = fe->tuner_priv; struct xc5000_priv *priv = fe->tuner_priv;
dprintk(1, "%s()\n", __FUNCTION__); dprintk(1, "%s()\n", __FUNCTION__);
*freq = priv->frequency; *freq = priv->freq_hz;
return 0; return 0;
} }
@ -678,7 +676,7 @@ static int xc5000_get_bandwidth(struct dvb_frontend *fe, u32 *bw)
static int xc5000_get_status(struct dvb_frontend *fe, u32 *status) static int xc5000_get_status(struct dvb_frontend *fe, u32 *status)
{ {
struct xc5000_priv *priv = fe->tuner_priv; struct xc5000_priv *priv = fe->tuner_priv;
unsigned short int lock_status = 0; u16 lock_status = 0;
xc_get_lock_status(priv, &lock_status); xc_get_lock_status(priv, &lock_status);
@ -689,15 +687,15 @@ static int xc5000_get_status(struct dvb_frontend *fe, u32 *status)
return 0; return 0;
} }
int xc_load_fw_and_init_tuner(struct dvb_frontend *fe) static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe)
{ {
struct xc5000_priv *priv = fe->tuner_priv; struct xc5000_priv *priv = fe->tuner_priv;
int ret; int ret;
if(priv->fwloaded == 0) { if (priv->fwloaded == 0) {
ret = xc5000_fwupload(fe); ret = xc5000_fwupload(fe);
if( ret != XC_RESULT_SUCCESS ) if (ret != XC_RESULT_SUCCESS)
return -EREMOTEIO; return ret;
priv->fwloaded = 1; priv->fwloaded = 1;
} }
@ -718,13 +716,26 @@ int xc_load_fw_and_init_tuner(struct dvb_frontend *fe)
return ret; return ret;
} }
static int xc5000_sleep(struct dvb_frontend *fe)
{
struct xc5000_priv *priv = fe->tuner_priv;
dprintk(1, "%s()\n", __FUNCTION__);
return xc_shutdown(priv);
}
static int xc5000_init(struct dvb_frontend *fe) static int xc5000_init(struct dvb_frontend *fe)
{ {
struct xc5000_priv *priv = fe->tuner_priv; struct xc5000_priv *priv = fe->tuner_priv;
dprintk(1, "%s()\n", __FUNCTION__); dprintk(1, "%s()\n", __FUNCTION__);
xc_load_fw_and_init_tuner(fe); if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) {
xc_debug_dump(priv); printk(KERN_ERR "xc5000: Unable to initialise tuner\n");
return -EREMOTEIO;
}
if (debug)
xc_debug_dump(priv);
return 0; return 0;
} }
@ -747,6 +758,7 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = {
.release = xc5000_release, .release = xc5000_release,
.init = xc5000_init, .init = xc5000_init,
.sleep = xc5000_sleep,
.set_params = xc5000_set_params, .set_params = xc5000_set_params,
.get_frequency = xc5000_get_frequency, .get_frequency = xc5000_get_frequency,
@ -768,7 +780,7 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe,
return NULL; return NULL;
priv->cfg = cfg; priv->cfg = cfg;
priv->bandwidth = 6000000; /* 6MHz */ priv->bandwidth = BANDWIDTH_6_MHZ;
priv->i2c = i2c; priv->i2c = i2c;
priv->fwloaded = 0; priv->fwloaded = 0;
@ -777,7 +789,7 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe,
return NULL; return NULL;
} }
if ( (id != 0x2000) && (id != 0x1388) ) { if ((id != 0x2000) && (id != 0x1388)) {
printk(KERN_ERR printk(KERN_ERR
"xc5000: Device not found at addr 0x%02x (0x%x)\n", "xc5000: Device not found at addr 0x%02x (0x%x)\n",
cfg->i2c_address, id); cfg->i2c_address, id);
@ -798,5 +810,5 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe,
EXPORT_SYMBOL(xc5000_attach); EXPORT_SYMBOL(xc5000_attach);
MODULE_AUTHOR("Steven Toth"); MODULE_AUTHOR("Steven Toth");
MODULE_DESCRIPTION("Xceive XC5000 silicon tuner driver"); MODULE_DESCRIPTION("Xceive xc5000 silicon tuner driver");
MODULE_LICENSE("GPL"); MODULE_LICENSE("GPL");

View File

@ -29,8 +29,9 @@ struct i2c_adapter;
struct xc5000_config { struct xc5000_config {
u8 i2c_address; u8 i2c_address;
u32 if_frequency; u32 if_khz;
int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); int (*request_firmware)(struct dvb_frontend *fe,
const struct firmware **fw, char *name);
int (*tuner_reset)(struct dvb_frontend* fe); int (*tuner_reset)(struct dvb_frontend* fe);
}; };

View File

@ -26,11 +26,10 @@ struct xc5000_priv {
struct xc5000_config *cfg; struct xc5000_config *cfg;
struct i2c_adapter *i2c; struct i2c_adapter *i2c;
u32 frequency; u32 freq_hz;
u32 bandwidth; u32 bandwidth;
u8 video_standard; u8 video_standard;
u8 rf_mode; u8 rf_mode;
u8 fwloaded; u8 fwloaded;
}; };

View File

@ -146,10 +146,10 @@ static struct s5h1409_config hauppauge_hvr1500q_config = {
}; };
static struct xc5000_config hauppauge_hvr1500q_tunerconfig = { static struct xc5000_config hauppauge_hvr1500q_tunerconfig = {
.i2c_address = 0x61, .i2c_address = 0x61,
.if_frequency = 4570000, .if_khz = 5380,
.request_firmware = cx23885_request_firmware, .request_firmware = cx23885_request_firmware,
.tuner_reset = hauppauge_hvr1500q_tuner_reset .tuner_reset = hauppauge_hvr1500q_tuner_reset
}; };
static int dvb_register(struct cx23885_tsport *port) static int dvb_register(struct cx23885_tsport *port)