diff options
author | Steven Toth <stoth@hauppauge.com> | 2007-12-19 23:14:43 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:04:12 -0500 |
commit | e12671cf0c3c8460dfa3ab945023803612827fb7 (patch) | |
tree | d663d35b7552fb6405be4474a1581dca583641dc /drivers/media | |
parent | d1987d55a1eda774dfbab240a432607c17241d07 (diff) |
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>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/dvb/frontends/xc5000.c | 300 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/xc5000.h | 5 | ||||
-rw-r--r-- | drivers/media/dvb/frontends/xc5000_priv.h | 3 | ||||
-rw-r--r-- | drivers/media/video/cx23885/cx23885-dvb.c | 6 |
4 files changed, 163 insertions, 151 deletions
diff --git a/drivers/media/dvb/frontends/xc5000.c b/drivers/media/dvb/frontends/xc5000.c index 048f9a79b915..9edd07115395 100644 --- a/drivers/media/dvb/frontends/xc5000.c +++ b/drivers/media/dvb/frontends/xc5000.c | |||
@@ -117,8 +117,8 @@ MODULE_PARM_DESC(debug, "Turn on/off debugging (default:off)."); | |||
117 | */ | 117 | */ |
118 | typedef struct { | 118 | typedef struct { |
119 | char *Name; | 119 | char *Name; |
120 | unsigned short AudioMode; | 120 | u16 AudioMode; |
121 | unsigned short VideoMode; | 121 | u16 VideoMode; |
122 | } XC_TV_STANDARD; | 122 | } XC_TV_STANDARD; |
123 | 123 | ||
124 | /* Tuner standards */ | 124 | /* Tuner standards */ |
@@ -154,29 +154,27 @@ static int xc5000_writeregs(struct xc5000_priv *priv, u8 *buf, u8 len); | |||
154 | static int xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len); | 154 | static int xc5000_readregs(struct xc5000_priv *priv, u8 *buf, u8 len); |
155 | static void xc5000_TunerReset(struct dvb_frontend *fe); | 155 | static void xc5000_TunerReset(struct dvb_frontend *fe); |
156 | 156 | ||
157 | int xc_send_i2c_data(struct xc5000_priv *priv, | 157 | static int xc_send_i2c_data(struct xc5000_priv *priv, u8 *buf, int len) |
158 | unsigned char *bytes_to_send, int nb_bytes_to_send) | ||
159 | { | 158 | { |
160 | return xc5000_writeregs(priv, bytes_to_send, nb_bytes_to_send) | 159 | return xc5000_writeregs(priv, buf, len) |
161 | ? XC_RESULT_I2C_WRITE_FAILURE : XC_RESULT_SUCCESS; | 160 | ? XC_RESULT_I2C_WRITE_FAILURE : XC_RESULT_SUCCESS; |
162 | } | 161 | } |
163 | 162 | ||
164 | int xc_read_i2c_data(struct xc5000_priv *priv, unsigned char *bytes_received, | 163 | static int xc_read_i2c_data(struct xc5000_priv *priv, u8 *buf, int len) |
165 | int nb_bytes_to_receive) | ||
166 | { | 164 | { |
167 | return xc5000_readregs(priv, bytes_received, nb_bytes_to_receive) | 165 | return xc5000_readregs(priv, buf, len) |
168 | ? XC_RESULT_I2C_READ_FAILURE : XC_RESULT_SUCCESS; | 166 | ? XC_RESULT_I2C_READ_FAILURE : XC_RESULT_SUCCESS; |
169 | } | 167 | } |
170 | 168 | ||
171 | int xc_reset(struct dvb_frontend *fe) | 169 | static int xc_reset(struct dvb_frontend *fe) |
172 | { | 170 | { |
173 | xc5000_TunerReset(fe); | 171 | xc5000_TunerReset(fe); |
174 | return XC_RESULT_SUCCESS; | 172 | return XC_RESULT_SUCCESS; |
175 | } | 173 | } |
176 | 174 | ||
177 | void xc_wait(int wait_ms) | 175 | static void xc_wait(int wait_ms) |
178 | { | 176 | { |
179 | msleep( wait_ms ); | 177 | msleep(wait_ms); |
180 | } | 178 | } |
181 | 179 | ||
182 | static void xc5000_TunerReset(struct dvb_frontend *fe) | 180 | static void xc5000_TunerReset(struct dvb_frontend *fe) |
@@ -186,7 +184,7 @@ static void xc5000_TunerReset(struct dvb_frontend *fe) | |||
186 | 184 | ||
187 | dprintk(1, "%s()\n", __FUNCTION__); | 185 | dprintk(1, "%s()\n", __FUNCTION__); |
188 | 186 | ||
189 | if(priv->cfg->tuner_reset) { | 187 | if (priv->cfg->tuner_reset) { |
190 | ret = priv->cfg->tuner_reset(fe); | 188 | ret = priv->cfg->tuner_reset(fe); |
191 | if (ret) | 189 | if (ret) |
192 | printk(KERN_ERR "xc5000: reset failed\n"); | 190 | printk(KERN_ERR "xc5000: reset failed\n"); |
@@ -194,10 +192,9 @@ static void xc5000_TunerReset(struct dvb_frontend *fe) | |||
194 | printk(KERN_ERR "xc5000: no tuner reset function, fatal\n"); | 192 | printk(KERN_ERR "xc5000: no tuner reset function, fatal\n"); |
195 | } | 193 | } |
196 | 194 | ||
197 | int xc_write_reg(struct xc5000_priv *priv, unsigned short int regAddr, | 195 | static int xc_write_reg(struct xc5000_priv *priv, u16 regAddr, u16 i2cData) |
198 | unsigned short int i2cData) | ||
199 | { | 196 | { |
200 | unsigned char buf[4]; | 197 | u8 buf[4]; |
201 | int WatchDogTimer = 5; | 198 | int WatchDogTimer = 5; |
202 | int result; | 199 | int result; |
203 | 200 | ||
@@ -206,7 +203,7 @@ int xc_write_reg(struct xc5000_priv *priv, unsigned short int regAddr, | |||
206 | buf[2] = (i2cData >> 8) & 0xFF; | 203 | buf[2] = (i2cData >> 8) & 0xFF; |
207 | buf[3] = i2cData & 0xFF; | 204 | buf[3] = i2cData & 0xFF; |
208 | result = xc_send_i2c_data(priv, buf, 4); | 205 | result = xc_send_i2c_data(priv, buf, 4); |
209 | if ( result == XC_RESULT_SUCCESS) { | 206 | if (result == XC_RESULT_SUCCESS) { |
210 | /* wait for busy flag to clear */ | 207 | /* wait for busy flag to clear */ |
211 | while ((WatchDogTimer > 0) && (result == XC_RESULT_SUCCESS)) { | 208 | while ((WatchDogTimer > 0) && (result == XC_RESULT_SUCCESS)) { |
212 | buf[0] = 0; | 209 | buf[0] = 0; |
@@ -233,43 +230,42 @@ int xc_write_reg(struct xc5000_priv *priv, unsigned short int regAddr, | |||
233 | return result; | 230 | return result; |
234 | } | 231 | } |
235 | 232 | ||
236 | int xc_read_reg(struct xc5000_priv *priv, unsigned short int regAddr, | 233 | static int xc_read_reg(struct xc5000_priv *priv, u16 regAddr, u16 *i2cData) |
237 | unsigned short int *i2cData) | ||
238 | { | 234 | { |
239 | unsigned char buf[2]; | 235 | u8 buf[2]; |
240 | int result; | 236 | int result; |
241 | 237 | ||
242 | buf[0] = (regAddr >> 8) & 0xFF; | 238 | buf[0] = (regAddr >> 8) & 0xFF; |
243 | buf[1] = regAddr & 0xFF; | 239 | buf[1] = regAddr & 0xFF; |
244 | result = xc_send_i2c_data(priv, buf, 2); | 240 | result = xc_send_i2c_data(priv, buf, 2); |
245 | if (result!=XC_RESULT_SUCCESS) | 241 | if (result != XC_RESULT_SUCCESS) |
246 | return result; | 242 | return result; |
247 | 243 | ||
248 | result = xc_read_i2c_data(priv, buf, 2); | 244 | result = xc_read_i2c_data(priv, buf, 2); |
249 | if (result!=XC_RESULT_SUCCESS) | 245 | if (result != XC_RESULT_SUCCESS) |
250 | return result; | 246 | return result; |
251 | 247 | ||
252 | *i2cData = buf[0] * 256 + buf[1]; | 248 | *i2cData = buf[0] * 256 + buf[1]; |
253 | return result; | 249 | return result; |
254 | } | 250 | } |
255 | 251 | ||
256 | int xc_load_i2c_sequence(struct dvb_frontend *fe, unsigned char i2c_sequence[]) | 252 | static int xc_load_i2c_sequence(struct dvb_frontend *fe, u8 i2c_sequence[]) |
257 | { | 253 | { |
258 | struct xc5000_priv *priv = fe->tuner_priv; | 254 | struct xc5000_priv *priv = fe->tuner_priv; |
259 | 255 | ||
260 | int i, nbytes_to_send, result; | 256 | int i, nbytes_to_send, result; |
261 | unsigned int len, pos, index; | 257 | unsigned int len, pos, index; |
262 | unsigned char buf[XC_MAX_I2C_WRITE_LENGTH]; | 258 | u8 buf[XC_MAX_I2C_WRITE_LENGTH]; |
263 | 259 | ||
264 | index=0; | 260 | index=0; |
265 | while ((i2c_sequence[index]!=0xFF) || (i2c_sequence[index+1]!=0xFF)) { | 261 | while ((i2c_sequence[index]!=0xFF) || (i2c_sequence[index+1]!=0xFF)) { |
266 | 262 | ||
267 | len = i2c_sequence[index]* 256 + i2c_sequence[index+1]; | 263 | len = i2c_sequence[index]* 256 + i2c_sequence[index+1]; |
268 | if (len==0x0000) { | 264 | if (len == 0x0000) { |
269 | /* RESET command */ | 265 | /* RESET command */ |
270 | result = xc_reset(fe); | 266 | result = xc_reset(fe); |
271 | index += 2; | 267 | index += 2; |
272 | if (result!=XC_RESULT_SUCCESS) | 268 | if (result != XC_RESULT_SUCCESS) |
273 | return result; | 269 | return result; |
274 | } else if (len & 0x8000) { | 270 | } else if (len & 0x8000) { |
275 | /* WAIT command */ | 271 | /* WAIT command */ |
@@ -294,7 +290,7 @@ int xc_load_i2c_sequence(struct dvb_frontend *fe, unsigned char i2c_sequence[]) | |||
294 | } | 290 | } |
295 | result = xc_send_i2c_data(priv, buf, nbytes_to_send); | 291 | result = xc_send_i2c_data(priv, buf, nbytes_to_send); |
296 | 292 | ||
297 | if (result!=XC_RESULT_SUCCESS) | 293 | if (result != XC_RESULT_SUCCESS) |
298 | return result; | 294 | return result; |
299 | 295 | ||
300 | pos += nbytes_to_send - 2; | 296 | pos += nbytes_to_send - 2; |
@@ -305,14 +301,14 @@ int xc_load_i2c_sequence(struct dvb_frontend *fe, unsigned char i2c_sequence[]) | |||
305 | return XC_RESULT_SUCCESS; | 301 | return XC_RESULT_SUCCESS; |
306 | } | 302 | } |
307 | 303 | ||
308 | int xc_initialize(struct xc5000_priv *priv) | 304 | static int xc_initialize(struct xc5000_priv *priv) |
309 | { | 305 | { |
310 | dprintk(1, "%s()\n", __FUNCTION__); | 306 | dprintk(1, "%s()\n", __FUNCTION__); |
311 | return xc_write_reg(priv, XREG_INIT, 0); | 307 | return xc_write_reg(priv, XREG_INIT, 0); |
312 | } | 308 | } |
313 | 309 | ||
314 | int xc_SetTVStandard(struct xc5000_priv *priv, unsigned short int VideoMode, | 310 | static int xc_SetTVStandard(struct xc5000_priv *priv, |
315 | unsigned short int AudioMode) | 311 | u16 VideoMode, u16 AudioMode) |
316 | { | 312 | { |
317 | int ret; | 313 | int ret; |
318 | dprintk(1, "%s(%d,%d)\n", __FUNCTION__, VideoMode, AudioMode); | 314 | dprintk(1, "%s(%d,%d)\n", __FUNCTION__, VideoMode, AudioMode); |
@@ -327,17 +323,17 @@ int xc_SetTVStandard(struct xc5000_priv *priv, unsigned short int VideoMode, | |||
327 | return ret; | 323 | return ret; |
328 | } | 324 | } |
329 | 325 | ||
330 | int xc_shutdown(struct xc5000_priv *priv) | 326 | static int xc_shutdown(struct xc5000_priv *priv) |
331 | { | 327 | { |
332 | return xc_write_reg(priv, XREG_POWER_DOWN, 0); | 328 | return xc_write_reg(priv, XREG_POWER_DOWN, 0); |
333 | } | 329 | } |
334 | 330 | ||
335 | int xc_SetSignalSource(struct xc5000_priv *priv, unsigned short int rf_mode) | 331 | static int xc_SetSignalSource(struct xc5000_priv *priv, u16 rf_mode) |
336 | { | 332 | { |
337 | dprintk(1, "%s(%d) Source = %s\n", __FUNCTION__, rf_mode, | 333 | dprintk(1, "%s(%d) Source = %s\n", __FUNCTION__, rf_mode, |
338 | rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); | 334 | rf_mode == XC_RF_MODE_AIR ? "ANTENNA" : "CABLE"); |
339 | 335 | ||
340 | if( (rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE) ) | 336 | if ((rf_mode != XC_RF_MODE_AIR) && (rf_mode != XC_RF_MODE_CABLE)) |
341 | { | 337 | { |
342 | rf_mode = XC_RF_MODE_CABLE; | 338 | rf_mode = XC_RF_MODE_CABLE; |
343 | printk(KERN_ERR | 339 | printk(KERN_ERR |
@@ -347,52 +343,43 @@ int xc_SetSignalSource(struct xc5000_priv *priv, unsigned short int rf_mode) | |||
347 | return xc_write_reg(priv, XREG_SIGNALSOURCE, rf_mode); | 343 | return xc_write_reg(priv, XREG_SIGNALSOURCE, rf_mode); |
348 | } | 344 | } |
349 | 345 | ||
350 | int xc_set_RF_frequency(struct xc5000_priv *priv, long frequency_in_hz) | 346 | static const struct dvb_tuner_ops xc5000_tuner_ops; |
351 | { | ||
352 | unsigned int frequency_code = (unsigned int)(frequency_in_hz / 15625); | ||
353 | 347 | ||
354 | if ((frequency_in_hz>1023000000) || (frequency_in_hz<1000000)) | 348 | static int xc_set_RF_frequency(struct xc5000_priv *priv, u32 freq_hz) |
355 | return XC_RESULT_OUT_OF_RANGE; | 349 | { |
350 | u16 freq_code; | ||
356 | 351 | ||
357 | return xc_write_reg(priv, XREG_RF_FREQ ,frequency_code); | 352 | dprintk(1, "%s(%d)\n", __FUNCTION__, freq_hz); |
358 | } | ||
359 | 353 | ||
360 | int xc_FineTune_RF_frequency(struct xc5000_priv *priv, long frequency_in_hz) | 354 | if ((freq_hz > xc5000_tuner_ops.info.frequency_max) || |
361 | { | 355 | (freq_hz < xc5000_tuner_ops.info.frequency_min)) |
362 | unsigned int frequency_code = (unsigned int)(frequency_in_hz / 15625); | ||
363 | if ((frequency_in_hz>1023000000) || (frequency_in_hz<1000000)) | ||
364 | return XC_RESULT_OUT_OF_RANGE; | 356 | return XC_RESULT_OUT_OF_RANGE; |
365 | 357 | ||
366 | return xc_write_reg(priv, XREG_FINERFFREQ ,frequency_code); | 358 | freq_code = (u16)(freq_hz / 15625); |
359 | |||
360 | return xc_write_reg(priv, XREG_RF_FREQ, freq_code); | ||
367 | } | 361 | } |
368 | 362 | ||
369 | int xc_set_IF_frequency(struct xc5000_priv *priv, u32 freq_hz) | ||
370 | { | ||
371 | u32 freq_code = (freq_hz * 1024)/1000000; | ||
372 | dprintk(1, "%s(%d)\n", __FUNCTION__, freq_hz); | ||
373 | 363 | ||
374 | printk(KERN_ERR "FIXME - Hardcoded IF, FIXME\n"); | 364 | static int xc_set_IF_frequency(struct xc5000_priv *priv, u32 freq_khz) |
375 | freq_code = 0x1585; | 365 | { |
366 | u32 freq_code = (freq_khz * 1024)/1000; | ||
367 | dprintk(1, "%s(freq_khz = %d) freq_code = 0x%x\n", | ||
368 | __FUNCTION__, freq_khz, freq_code); | ||
376 | 369 | ||
377 | return xc_write_reg(priv, XREG_IF_OUT ,freq_code); | 370 | return xc_write_reg(priv, XREG_IF_OUT, freq_code); |
378 | } | 371 | } |
379 | 372 | ||
380 | int xc_set_Xtal_frequency(struct xc5000_priv *priv, long xtalFreqInKHz) | ||
381 | { | ||
382 | unsigned int xtalRatio = (32000 * 0x8000)/xtalFreqInKHz; | ||
383 | return xc_write_reg(priv, XREG_XTALFREQ ,xtalRatio); | ||
384 | } | ||
385 | 373 | ||
386 | int xc_get_ADC_Envelope(struct xc5000_priv *priv, | 374 | static int xc_get_ADC_Envelope(struct xc5000_priv *priv, u16 *adc_envelope) |
387 | unsigned short int *adc_envelope) | ||
388 | { | 375 | { |
389 | return xc_read_reg(priv, XREG_ADC_ENV, adc_envelope); | 376 | return xc_read_reg(priv, XREG_ADC_ENV, adc_envelope); |
390 | } | 377 | } |
391 | 378 | ||
392 | int xc_get_frequency_error(struct xc5000_priv *priv, u32 *frequency_error_hz) | 379 | static int xc_get_frequency_error(struct xc5000_priv *priv, u32 *freq_error_hz) |
393 | { | 380 | { |
394 | int result; | 381 | int result; |
395 | unsigned short int regData; | 382 | u16 regData; |
396 | u32 tmp; | 383 | u32 tmp; |
397 | 384 | ||
398 | result = xc_read_reg(priv, XREG_FREQ_ERROR, ®Data); | 385 | result = xc_read_reg(priv, XREG_FREQ_ERROR, ®Data); |
@@ -400,45 +387,37 @@ int xc_get_frequency_error(struct xc5000_priv *priv, u32 *frequency_error_hz) | |||
400 | return result; | 387 | return result; |
401 | 388 | ||
402 | tmp = (u32)regData; | 389 | tmp = (u32)regData; |
403 | (*frequency_error_hz) = (tmp * 15625) / 1000; | 390 | (*freq_error_hz) = (tmp * 15625) / 1000; |
404 | return result; | 391 | return result; |
405 | } | 392 | } |
406 | 393 | ||
407 | int xc_get_lock_status(struct xc5000_priv *priv, | 394 | static int xc_get_lock_status(struct xc5000_priv *priv, u16 *lock_status) |
408 | unsigned short int *lock_status) | ||
409 | { | 395 | { |
410 | return xc_read_reg(priv, XREG_LOCK, lock_status); | 396 | return xc_read_reg(priv, XREG_LOCK, lock_status); |
411 | } | 397 | } |
412 | 398 | ||
413 | int xc_get_version(struct xc5000_priv *priv, | 399 | static int xc_get_version(struct xc5000_priv *priv, |
414 | unsigned char* hw_majorversion, | 400 | u8 *hw_majorversion, u8 *hw_minorversion, |
415 | unsigned char* hw_minorversion, | 401 | u8 *fw_majorversion, u8 *fw_minorversion) |
416 | unsigned char* fw_majorversion, | ||
417 | unsigned char* fw_minorversion) | ||
418 | { | 402 | { |
419 | unsigned short int data; | 403 | u16 data; |
420 | int result; | 404 | int result; |
421 | 405 | ||
422 | result = xc_read_reg(priv, XREG_VERSION, &data); | 406 | result = xc_read_reg(priv, XREG_VERSION, &data); |
423 | if (result) | 407 | if (result) |
424 | return result; | 408 | return result; |
425 | 409 | ||
426 | (*hw_majorversion) = (data>>12) & 0x0F; | 410 | (*hw_majorversion) = (data >> 12) & 0x0F; |
427 | (*hw_minorversion) = (data>>8) & 0x0F; | 411 | (*hw_minorversion) = (data >> 8) & 0x0F; |
428 | (*fw_majorversion) = (data>>4) & 0x0F; | 412 | (*fw_majorversion) = (data >> 4) & 0x0F; |
429 | (*fw_minorversion) = (data) & 0x0F; | 413 | (*fw_minorversion) = data & 0x0F; |
430 | 414 | ||
431 | return 0; | 415 | return 0; |
432 | } | 416 | } |
433 | 417 | ||
434 | int xc_get_product_id(struct xc5000_priv *priv, unsigned short int *product_id) | 418 | static int xc_get_hsync_freq(struct xc5000_priv *priv, u32 *hsync_freq_hz) |
435 | { | ||
436 | return xc_read_reg(priv, XREG_PRODUCT_ID, product_id); | ||
437 | } | ||
438 | |||
439 | int xc_get_hsync_freq(struct xc5000_priv *priv, int *hsync_freq_hz) | ||
440 | { | 419 | { |
441 | unsigned short int regData; | 420 | u16 regData; |
442 | int result; | 421 | int result; |
443 | 422 | ||
444 | result = xc_read_reg(priv, XREG_HSYNC_FREQ, ®Data); | 423 | result = xc_read_reg(priv, XREG_HSYNC_FREQ, ®Data); |
@@ -449,26 +428,24 @@ int xc_get_hsync_freq(struct xc5000_priv *priv, int *hsync_freq_hz) | |||
449 | return result; | 428 | return result; |
450 | } | 429 | } |
451 | 430 | ||
452 | int xc_get_frame_lines(struct xc5000_priv *priv, | 431 | static int xc_get_frame_lines(struct xc5000_priv *priv, u16 *frame_lines) |
453 | unsigned short int *frame_lines) | ||
454 | { | 432 | { |
455 | return xc_read_reg(priv, XREG_FRAME_LINES, frame_lines); | 433 | return xc_read_reg(priv, XREG_FRAME_LINES, frame_lines); |
456 | } | 434 | } |
457 | 435 | ||
458 | int xc_get_quality(struct xc5000_priv *priv, unsigned short int *quality) | 436 | static int xc_get_quality(struct xc5000_priv *priv, u16 *quality) |
459 | { | 437 | { |
460 | return xc_read_reg(priv, XREG_QUALITY, quality); | 438 | return xc_read_reg(priv, XREG_QUALITY, quality); |
461 | } | 439 | } |
462 | 440 | ||
463 | unsigned short int WaitForLock(struct xc5000_priv *priv) | 441 | static u16 WaitForLock(struct xc5000_priv *priv) |
464 | { | 442 | { |
465 | unsigned short int lockState = 0; | 443 | u16 lockState = 0; |
466 | int watchDogCount = 40; | 444 | int watchDogCount = 40; |
467 | while ((lockState == 0) && (watchDogCount > 0)) | 445 | |
468 | { | 446 | while ((lockState == 0) && (watchDogCount > 0)) { |
469 | xc_get_lock_status(priv, &lockState); | 447 | xc_get_lock_status(priv, &lockState); |
470 | if (lockState != 1) | 448 | if (lockState != 1) { |
471 | { | ||
472 | xc_wait(5); | 449 | xc_wait(5); |
473 | watchDogCount--; | 450 | watchDogCount--; |
474 | } | 451 | } |
@@ -476,16 +453,16 @@ unsigned short int WaitForLock(struct xc5000_priv *priv) | |||
476 | return lockState; | 453 | return lockState; |
477 | } | 454 | } |
478 | 455 | ||
479 | int xc_tune_channel(struct xc5000_priv *priv, u32 freq) | 456 | static int xc_tune_channel(struct xc5000_priv *priv, u32 freq_hz) |
480 | { | 457 | { |
481 | int found = 0; | 458 | int found = 0; |
482 | 459 | ||
483 | dprintk(1, "%s(%d)\n", __FUNCTION__, freq); | 460 | dprintk(1, "%s(%d)\n", __FUNCTION__, freq_hz); |
484 | 461 | ||
485 | if (xc_set_RF_frequency(priv, freq) != XC_RESULT_SUCCESS) | 462 | if (xc_set_RF_frequency(priv, freq_hz) != XC_RESULT_SUCCESS) |
486 | return 0; | 463 | return 0; |
487 | 464 | ||
488 | if (WaitForLock(priv)== 1) | 465 | if (WaitForLock(priv) == 1) |
489 | found = 1; | 466 | found = 1; |
490 | 467 | ||
491 | return found; | 468 | return found; |
@@ -542,15 +519,15 @@ static int xc5000_fwupload(struct dvb_frontend* fe) | |||
542 | const struct firmware *fw; | 519 | const struct firmware *fw; |
543 | int ret; | 520 | int ret; |
544 | 521 | ||
545 | /* request the firmware, this will block until someone uploads it */ | 522 | if (!priv->cfg->request_firmware) { |
546 | printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", | ||
547 | XC5000_DEFAULT_FIRMWARE); | ||
548 | |||
549 | if(!priv->cfg->request_firmware) { | ||
550 | printk(KERN_ERR "xc5000: no firmware callback, fatal\n"); | 523 | printk(KERN_ERR "xc5000: no firmware callback, fatal\n"); |
551 | return -EIO; | 524 | return -EIO; |
552 | } | 525 | } |
553 | 526 | ||
527 | /* request the firmware, this will block and timeout */ | ||
528 | printk(KERN_INFO "xc5000: waiting for firmware upload (%s)...\n", | ||
529 | XC5000_DEFAULT_FIRMWARE); | ||
530 | |||
554 | ret = priv->cfg->request_firmware(fe, &fw, XC5000_DEFAULT_FIRMWARE); | 531 | ret = priv->cfg->request_firmware(fe, &fw, XC5000_DEFAULT_FIRMWARE); |
555 | if (ret) { | 532 | if (ret) { |
556 | printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); | 533 | printk(KERN_ERR "xc5000: Upload failed. (file not found?)\n"); |
@@ -560,7 +537,7 @@ static int xc5000_fwupload(struct dvb_frontend* fe) | |||
560 | ret = XC_RESULT_SUCCESS; | 537 | ret = XC_RESULT_SUCCESS; |
561 | } | 538 | } |
562 | 539 | ||
563 | if(fw->size != XC5000_DEFAULT_FIRMWARE_SIZE) { | 540 | if (fw->size != XC5000_DEFAULT_FIRMWARE_SIZE) { |
564 | printk(KERN_ERR "xc5000: firmware incorrect size\n"); | 541 | printk(KERN_ERR "xc5000: firmware incorrect size\n"); |
565 | ret = XC_RESULT_RESET_FAILURE; | 542 | ret = XC_RESULT_RESET_FAILURE; |
566 | } else { | 543 | } else { |
@@ -572,89 +549,110 @@ static int xc5000_fwupload(struct dvb_frontend* fe) | |||
572 | return ret; | 549 | return ret; |
573 | } | 550 | } |
574 | 551 | ||
575 | void xc_debug_dump(struct xc5000_priv *priv) | 552 | static void xc_debug_dump(struct xc5000_priv *priv) |
576 | { | 553 | { |
577 | unsigned short adc_envelope; | 554 | u16 adc_envelope; |
578 | u32 frequency_error_hz; | 555 | u32 freq_error_hz = 0; |
579 | unsigned short lock_status; | 556 | u16 lock_status; |
580 | unsigned char hw_majorversion, hw_minorversion = 0; | 557 | u32 hsync_freq_hz = 0; |
581 | unsigned char fw_majorversion, fw_minorversion = 0; | 558 | u16 frame_lines; |
582 | int hsync_freq_hz; | 559 | u16 quality; |
583 | unsigned short frame_lines; | 560 | u8 hw_majorversion = 0, hw_minorversion = 0; |
584 | unsigned short quality; | 561 | u8 fw_majorversion = 0, fw_minorversion = 0; |
585 | 562 | ||
586 | /* Wait for stats to stabilize. | 563 | /* Wait for stats to stabilize. |
587 | * Frame Lines needs two frame times after initial lock | 564 | * Frame Lines needs two frame times after initial lock |
588 | * before it is valid. | 565 | * before it is valid. |
589 | */ | 566 | */ |
590 | xc_wait( 100 ); | 567 | xc_wait(100); |
591 | 568 | ||
592 | xc_get_ADC_Envelope(priv, &adc_envelope ); | 569 | xc_get_ADC_Envelope(priv, &adc_envelope); |
593 | dprintk(1, "*** ADC envelope (0-1023) = %u\n", adc_envelope); | 570 | dprintk(1, "*** ADC envelope (0-1023) = %d\n", adc_envelope); |
594 | 571 | ||
595 | xc_get_frequency_error(priv, &frequency_error_hz ); | 572 | xc_get_frequency_error(priv, &freq_error_hz); |
596 | dprintk(1, "*** Frequency error = %d Hz\n", frequency_error_hz); | 573 | dprintk(1, "*** Frequency error = %d Hz\n", freq_error_hz); |
597 | 574 | ||
598 | xc_get_lock_status(priv, &lock_status ); | 575 | xc_get_lock_status(priv, &lock_status); |
599 | dprintk(1, "*** Lock status (0-Wait, 1-Locked, 2-No-signal) = %u\n", | 576 | dprintk(1, "*** Lock status (0-Wait, 1-Locked, 2-No-signal) = %d\n", |
600 | lock_status); | 577 | lock_status); |
601 | 578 | ||
602 | xc_get_version(priv, &hw_majorversion, &hw_minorversion, | 579 | xc_get_version(priv, &hw_majorversion, &hw_minorversion, |
603 | &fw_majorversion, &fw_minorversion ); | 580 | &fw_majorversion, &fw_minorversion); |
604 | dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x\n", | 581 | dprintk(1, "*** HW: V%02x.%02x, FW: V%02x.%02x\n", |
605 | hw_majorversion, hw_minorversion, | 582 | hw_majorversion, hw_minorversion, |
606 | fw_majorversion, fw_minorversion); | 583 | fw_majorversion, fw_minorversion); |
607 | 584 | ||
608 | xc_get_hsync_freq(priv, &hsync_freq_hz ); | 585 | xc_get_hsync_freq(priv, &hsync_freq_hz); |
609 | dprintk(1, "*** Horizontal sync frequency = %u Hz\n", hsync_freq_hz); | 586 | dprintk(1, "*** Horizontal sync frequency = %d Hz\n", hsync_freq_hz); |
610 | 587 | ||
611 | xc_get_frame_lines(priv, &frame_lines ); | 588 | xc_get_frame_lines(priv, &frame_lines); |
612 | dprintk(1, "*** Frame lines = %u\n", frame_lines); | 589 | dprintk(1, "*** Frame lines = %d\n", frame_lines); |
613 | 590 | ||
614 | xc_get_quality(priv, &quality ); | 591 | xc_get_quality(priv, &quality); |
615 | dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %u\n", quality); | 592 | dprintk(1, "*** Quality (0:<8dB, 7:>56dB) = %d\n", quality); |
616 | } | 593 | } |
617 | 594 | ||
618 | static int xc5000_set_params(struct dvb_frontend *fe, | 595 | static int xc5000_set_params(struct dvb_frontend *fe, |
619 | struct dvb_frontend_parameters *params) | 596 | struct dvb_frontend_parameters *params) |
620 | { | 597 | { |
621 | struct xc5000_priv *priv = fe->tuner_priv; | 598 | struct xc5000_priv *priv = fe->tuner_priv; |
599 | int ret; | ||
622 | 600 | ||
623 | dprintk(1, "%s() frequency=%d\n", __FUNCTION__, params->frequency); | 601 | dprintk(1, "%s() frequency=%d (Hz)\n", __FUNCTION__, params->frequency); |
624 | 602 | ||
625 | priv->frequency = params->frequency - 1750000; | ||
626 | priv->bandwidth = 6; | ||
627 | priv->video_standard = DTV6; | ||
628 | 603 | ||
629 | switch(params->u.vsb.modulation) { | 604 | switch(params->u.vsb.modulation) { |
630 | case VSB_8: | 605 | case VSB_8: |
631 | case VSB_16: | 606 | case VSB_16: |
632 | dprintk(1, "%s() VSB modulation\n", __FUNCTION__); | 607 | dprintk(1, "%s() VSB modulation\n", __FUNCTION__); |
633 | priv->rf_mode = XC_RF_MODE_AIR; | 608 | priv->rf_mode = XC_RF_MODE_AIR; |
609 | priv->freq_hz = params->frequency - 1750000; | ||
610 | priv->bandwidth = BANDWIDTH_6_MHZ; | ||
611 | priv->video_standard = DTV6; | ||
634 | break; | 612 | break; |
635 | case QAM_64: | 613 | case QAM_64: |
636 | case QAM_256: | 614 | case QAM_256: |
637 | case QAM_AUTO: | 615 | case QAM_AUTO: |
638 | dprintk(1, "%s() QAM modulation\n", __FUNCTION__); | 616 | dprintk(1, "%s() QAM modulation\n", __FUNCTION__); |
639 | priv->rf_mode = XC_RF_MODE_CABLE; | 617 | priv->rf_mode = XC_RF_MODE_CABLE; |
618 | priv->freq_hz = params->frequency - 1750000; | ||
619 | priv->bandwidth = BANDWIDTH_6_MHZ; | ||
620 | priv->video_standard = DTV6; | ||
640 | break; | 621 | break; |
641 | default: | 622 | default: |
642 | return -EINVAL; | 623 | return -EINVAL; |
643 | } | 624 | } |
644 | 625 | ||
645 | dprintk(1, "%s() frequency=%d (compensated)\n", | 626 | dprintk(1, "%s() frequency=%d (compensated)\n", |
646 | __FUNCTION__, priv->frequency); | 627 | __FUNCTION__, priv->freq_hz); |
647 | 628 | ||
648 | /* FIXME: check result codes */ | 629 | ret = xc_SetSignalSource(priv, priv->rf_mode); |
649 | xc_SetSignalSource(priv, priv->rf_mode); | 630 | if (ret != XC_RESULT_SUCCESS) { |
631 | printk(KERN_ERR | ||
632 | "xc5000: xc_SetSignalSource(%d) failed\n", | ||
633 | priv->rf_mode); | ||
634 | return -EREMOTEIO; | ||
635 | } | ||
650 | 636 | ||
651 | xc_SetTVStandard(priv, | 637 | ret = xc_SetTVStandard(priv, |
652 | XC5000_Standard[priv->video_standard].VideoMode, | 638 | XC5000_Standard[priv->video_standard].VideoMode, |
653 | XC5000_Standard[priv->video_standard].AudioMode); | 639 | XC5000_Standard[priv->video_standard].AudioMode); |
640 | if (ret != XC_RESULT_SUCCESS) { | ||
641 | printk(KERN_ERR "xc5000: xc_SetTVStandard failed\n"); | ||
642 | return -EREMOTEIO; | ||
643 | } | ||
644 | |||
645 | ret = xc_set_IF_frequency(priv, priv->cfg->if_khz); | ||
646 | if (ret != XC_RESULT_SUCCESS) { | ||
647 | printk(KERN_ERR "xc5000: xc_Set_IF_frequency(%d) failed\n", | ||
648 | priv->cfg->if_khz); | ||
649 | return -EIO; | ||
650 | } | ||
651 | |||
652 | xc_tune_channel(priv, priv->freq_hz); | ||
654 | 653 | ||
655 | xc_set_IF_frequency(priv, priv->cfg->if_frequency); | 654 | if (debug) |
656 | xc_tune_channel(priv, priv->frequency); | 655 | xc_debug_dump(priv); |
657 | xc_debug_dump(priv); | ||
658 | 656 | ||
659 | return 0; | 657 | return 0; |
660 | } | 658 | } |
@@ -663,7 +661,7 @@ static int xc5000_get_frequency(struct dvb_frontend *fe, u32 *freq) | |||
663 | { | 661 | { |
664 | struct xc5000_priv *priv = fe->tuner_priv; | 662 | struct xc5000_priv *priv = fe->tuner_priv; |
665 | dprintk(1, "%s()\n", __FUNCTION__); | 663 | dprintk(1, "%s()\n", __FUNCTION__); |
666 | *freq = priv->frequency; | 664 | *freq = priv->freq_hz; |
667 | return 0; | 665 | return 0; |
668 | } | 666 | } |
669 | 667 | ||
@@ -678,7 +676,7 @@ static int xc5000_get_bandwidth(struct dvb_frontend *fe, u32 *bw) | |||
678 | static int xc5000_get_status(struct dvb_frontend *fe, u32 *status) | 676 | static int xc5000_get_status(struct dvb_frontend *fe, u32 *status) |
679 | { | 677 | { |
680 | struct xc5000_priv *priv = fe->tuner_priv; | 678 | struct xc5000_priv *priv = fe->tuner_priv; |
681 | unsigned short int lock_status = 0; | 679 | u16 lock_status = 0; |
682 | 680 | ||
683 | xc_get_lock_status(priv, &lock_status); | 681 | xc_get_lock_status(priv, &lock_status); |
684 | 682 | ||
@@ -689,15 +687,15 @@ static int xc5000_get_status(struct dvb_frontend *fe, u32 *status) | |||
689 | return 0; | 687 | return 0; |
690 | } | 688 | } |
691 | 689 | ||
692 | int xc_load_fw_and_init_tuner(struct dvb_frontend *fe) | 690 | static int xc_load_fw_and_init_tuner(struct dvb_frontend *fe) |
693 | { | 691 | { |
694 | struct xc5000_priv *priv = fe->tuner_priv; | 692 | struct xc5000_priv *priv = fe->tuner_priv; |
695 | int ret; | 693 | int ret; |
696 | 694 | ||
697 | if(priv->fwloaded == 0) { | 695 | if (priv->fwloaded == 0) { |
698 | ret = xc5000_fwupload(fe); | 696 | ret = xc5000_fwupload(fe); |
699 | if( ret != XC_RESULT_SUCCESS ) | 697 | if (ret != XC_RESULT_SUCCESS) |
700 | return -EREMOTEIO; | 698 | return ret; |
701 | 699 | ||
702 | priv->fwloaded = 1; | 700 | priv->fwloaded = 1; |
703 | } | 701 | } |
@@ -718,13 +716,26 @@ int xc_load_fw_and_init_tuner(struct dvb_frontend *fe) | |||
718 | return ret; | 716 | return ret; |
719 | } | 717 | } |
720 | 718 | ||
719 | static int xc5000_sleep(struct dvb_frontend *fe) | ||
720 | { | ||
721 | struct xc5000_priv *priv = fe->tuner_priv; | ||
722 | dprintk(1, "%s()\n", __FUNCTION__); | ||
723 | |||
724 | return xc_shutdown(priv); | ||
725 | } | ||
726 | |||
721 | static int xc5000_init(struct dvb_frontend *fe) | 727 | static int xc5000_init(struct dvb_frontend *fe) |
722 | { | 728 | { |
723 | struct xc5000_priv *priv = fe->tuner_priv; | 729 | struct xc5000_priv *priv = fe->tuner_priv; |
724 | dprintk(1, "%s()\n", __FUNCTION__); | 730 | dprintk(1, "%s()\n", __FUNCTION__); |
725 | 731 | ||
726 | xc_load_fw_and_init_tuner(fe); | 732 | if (xc_load_fw_and_init_tuner(fe) != XC_RESULT_SUCCESS) { |
727 | xc_debug_dump(priv); | 733 | printk(KERN_ERR "xc5000: Unable to initialise tuner\n"); |
734 | return -EREMOTEIO; | ||
735 | } | ||
736 | |||
737 | if (debug) | ||
738 | xc_debug_dump(priv); | ||
728 | 739 | ||
729 | return 0; | 740 | return 0; |
730 | } | 741 | } |
@@ -747,6 +758,7 @@ static const struct dvb_tuner_ops xc5000_tuner_ops = { | |||
747 | 758 | ||
748 | .release = xc5000_release, | 759 | .release = xc5000_release, |
749 | .init = xc5000_init, | 760 | .init = xc5000_init, |
761 | .sleep = xc5000_sleep, | ||
750 | 762 | ||
751 | .set_params = xc5000_set_params, | 763 | .set_params = xc5000_set_params, |
752 | .get_frequency = xc5000_get_frequency, | 764 | .get_frequency = xc5000_get_frequency, |
@@ -768,7 +780,7 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, | |||
768 | return NULL; | 780 | return NULL; |
769 | 781 | ||
770 | priv->cfg = cfg; | 782 | priv->cfg = cfg; |
771 | priv->bandwidth = 6000000; /* 6MHz */ | 783 | priv->bandwidth = BANDWIDTH_6_MHZ; |
772 | priv->i2c = i2c; | 784 | priv->i2c = i2c; |
773 | priv->fwloaded = 0; | 785 | priv->fwloaded = 0; |
774 | 786 | ||
@@ -777,7 +789,7 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, | |||
777 | return NULL; | 789 | return NULL; |
778 | } | 790 | } |
779 | 791 | ||
780 | if ( (id != 0x2000) && (id != 0x1388) ) { | 792 | if ((id != 0x2000) && (id != 0x1388)) { |
781 | printk(KERN_ERR | 793 | printk(KERN_ERR |
782 | "xc5000: Device not found at addr 0x%02x (0x%x)\n", | 794 | "xc5000: Device not found at addr 0x%02x (0x%x)\n", |
783 | cfg->i2c_address, id); | 795 | cfg->i2c_address, id); |
@@ -798,5 +810,5 @@ struct dvb_frontend * xc5000_attach(struct dvb_frontend *fe, | |||
798 | EXPORT_SYMBOL(xc5000_attach); | 810 | EXPORT_SYMBOL(xc5000_attach); |
799 | 811 | ||
800 | MODULE_AUTHOR("Steven Toth"); | 812 | MODULE_AUTHOR("Steven Toth"); |
801 | MODULE_DESCRIPTION("Xceive XC5000 silicon tuner driver"); | 813 | MODULE_DESCRIPTION("Xceive xc5000 silicon tuner driver"); |
802 | MODULE_LICENSE("GPL"); | 814 | MODULE_LICENSE("GPL"); |
diff --git a/drivers/media/dvb/frontends/xc5000.h b/drivers/media/dvb/frontends/xc5000.h index ce5a3212f8f4..9286a03822c1 100644 --- a/drivers/media/dvb/frontends/xc5000.h +++ b/drivers/media/dvb/frontends/xc5000.h | |||
@@ -29,8 +29,9 @@ struct i2c_adapter; | |||
29 | 29 | ||
30 | struct xc5000_config { | 30 | struct xc5000_config { |
31 | u8 i2c_address; | 31 | u8 i2c_address; |
32 | u32 if_frequency; | 32 | u32 if_khz; |
33 | int (*request_firmware)(struct dvb_frontend* fe, const struct firmware **fw, char* name); | 33 | int (*request_firmware)(struct dvb_frontend *fe, |
34 | const struct firmware **fw, char *name); | ||
34 | int (*tuner_reset)(struct dvb_frontend* fe); | 35 | int (*tuner_reset)(struct dvb_frontend* fe); |
35 | }; | 36 | }; |
36 | 37 | ||
diff --git a/drivers/media/dvb/frontends/xc5000_priv.h b/drivers/media/dvb/frontends/xc5000_priv.h index a2b54535db0f..13b2d19341da 100644 --- a/drivers/media/dvb/frontends/xc5000_priv.h +++ b/drivers/media/dvb/frontends/xc5000_priv.h | |||
@@ -26,11 +26,10 @@ struct xc5000_priv { | |||
26 | struct xc5000_config *cfg; | 26 | struct xc5000_config *cfg; |
27 | struct i2c_adapter *i2c; | 27 | struct i2c_adapter *i2c; |
28 | 28 | ||
29 | u32 frequency; | 29 | u32 freq_hz; |
30 | u32 bandwidth; | 30 | u32 bandwidth; |
31 | u8 video_standard; | 31 | u8 video_standard; |
32 | u8 rf_mode; | 32 | u8 rf_mode; |
33 | |||
34 | u8 fwloaded; | 33 | u8 fwloaded; |
35 | }; | 34 | }; |
36 | 35 | ||
diff --git a/drivers/media/video/cx23885/cx23885-dvb.c b/drivers/media/video/cx23885/cx23885-dvb.c index 5fa65ef08bfd..f0882dd30d3f 100644 --- a/drivers/media/video/cx23885/cx23885-dvb.c +++ b/drivers/media/video/cx23885/cx23885-dvb.c | |||
@@ -146,10 +146,10 @@ static struct s5h1409_config hauppauge_hvr1500q_config = { | |||
146 | }; | 146 | }; |
147 | 147 | ||
148 | static struct xc5000_config hauppauge_hvr1500q_tunerconfig = { | 148 | static struct xc5000_config hauppauge_hvr1500q_tunerconfig = { |
149 | .i2c_address = 0x61, | 149 | .i2c_address = 0x61, |
150 | .if_frequency = 4570000, | 150 | .if_khz = 5380, |
151 | .request_firmware = cx23885_request_firmware, | 151 | .request_firmware = cx23885_request_firmware, |
152 | .tuner_reset = hauppauge_hvr1500q_tuner_reset | 152 | .tuner_reset = hauppauge_hvr1500q_tuner_reset |
153 | }; | 153 | }; |
154 | 154 | ||
155 | static int dvb_register(struct cx23885_tsport *port) | 155 | static int dvb_register(struct cx23885_tsport *port) |