aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorSteven Toth <stoth@linuxtv.org>2008-10-16 19:28:32 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2008-10-17 16:27:56 -0400
commit93504abfeb63397e2efe027f1c906e8e0ba8e57a (patch)
tree97a8eeb5879f0cf5f4c8d1fbfd145695e5b6d93b /drivers/media
parentb431c61642c086e93eec5198b974119f576481eb (diff)
V4L/DVB (9260): cx24123: Checkpatch compliance
cx24123: Checkpatch compliance Signed-off-by: Steven Toth <stoth@linuxtv.org> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media')
-rw-r--r--drivers/media/dvb/frontends/cx24123.c228
-rw-r--r--drivers/media/dvb/frontends/cx24123.h10
2 files changed, 133 insertions, 105 deletions
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
index 7156157cb34b..1a8c36f76061 100644
--- a/drivers/media/dvb/frontends/cx24123.c
+++ b/drivers/media/dvb/frontends/cx24123.c
@@ -33,7 +33,13 @@
33#define XTAL 10111000 33#define XTAL 10111000
34 34
35static int force_band; 35static int force_band;
36module_param(force_band, int, 0644);
37MODULE_PARM_DESC(force_band, "Force a specific band select "\
38 "(1-9, default:off).");
39
36static int debug; 40static int debug;
41module_param(debug, int, 0644);
42MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
37 43
38#define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0) 44#define info(args...) do { printk(KERN_INFO "CX24123: " args); } while (0)
39#define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0) 45#define err(args...) do { printk(KERN_ERR "CX24123: " args); } while (0)
@@ -46,10 +52,9 @@ static int debug;
46 } \ 52 } \
47 } while (0) 53 } while (0)
48 54
49struct cx24123_state 55struct cx24123_state {
50{ 56 struct i2c_adapter *i2c;
51 struct i2c_adapter* i2c; 57 const struct cx24123_config *config;
52 const struct cx24123_config* config;
53 58
54 struct dvb_frontend frontend; 59 struct dvb_frontend frontend;
55 60
@@ -70,8 +75,7 @@ struct cx24123_state
70}; 75};
71 76
72/* Various tuner defaults need to be established for a given symbol rate Sps */ 77/* Various tuner defaults need to be established for a given symbol rate Sps */
73static struct 78static struct cx24123_AGC_val {
74{
75 u32 symbolrate_low; 79 u32 symbolrate_low;
76 u32 symbolrate_high; 80 u32 symbolrate_high;
77 u32 VCAprogdata; 81 u32 VCAprogdata;
@@ -109,8 +113,7 @@ static struct
109 * fixme: The bounds on the bands do not match the doc in real life. 113 * fixme: The bounds on the bands do not match the doc in real life.
110 * fixme: Some of them have been moved, other might need adjustment. 114 * fixme: Some of them have been moved, other might need adjustment.
111 */ 115 */
112static struct 116static struct cx24123_bandselect_val {
113{
114 u32 freq_low; 117 u32 freq_low;
115 u32 freq_high; 118 u32 freq_high;
116 u32 VCOdivider; 119 u32 VCOdivider;
@@ -249,7 +252,8 @@ static int cx24123_i2c_writereg(struct cx24123_state *state,
249 252
250 /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */ 253 /* printk(KERN_DEBUG "wr(%02x): %02x %02x\n", i2c_addr, reg, data); */
251 254
252 if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) { 255 err = i2c_transfer(state->i2c, &msg, 1);
256 if (err != 1) {
253 printk("%s: writereg error(err == %i, reg == 0x%02x," 257 printk("%s: writereg error(err == %i, reg == 0x%02x,"
254 " data == 0x%02x)\n", __func__, err, reg, data); 258 " data == 0x%02x)\n", __func__, err, reg, data);
255 return err; 259 return err;
@@ -284,7 +288,8 @@ static int cx24123_i2c_readreg(struct cx24123_state *state, u8 i2c_addr, u8 reg)
284#define cx24123_writereg(state, reg, val) \ 288#define cx24123_writereg(state, reg, val) \
285 cx24123_i2c_writereg(state, state->config->demod_address, reg, val) 289 cx24123_i2c_writereg(state, state->config->demod_address, reg, val)
286 290
287static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_inversion_t inversion) 291static int cx24123_set_inversion(struct cx24123_state *state,
292 fe_spectral_inversion_t inversion)
288{ 293{
289 u8 nom_reg = cx24123_readreg(state, 0x0e); 294 u8 nom_reg = cx24123_readreg(state, 0x0e);
290 u8 auto_reg = cx24123_readreg(state, 0x10); 295 u8 auto_reg = cx24123_readreg(state, 0x10);
@@ -311,7 +316,8 @@ static int cx24123_set_inversion(struct cx24123_state* state, fe_spectral_invers
311 return 0; 316 return 0;
312} 317}
313 318
314static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_inversion_t *inversion) 319static int cx24123_get_inversion(struct cx24123_state *state,
320 fe_spectral_inversion_t *inversion)
315{ 321{
316 u8 val; 322 u8 val;
317 323
@@ -328,18 +334,20 @@ static int cx24123_get_inversion(struct cx24123_state* state, fe_spectral_invers
328 return 0; 334 return 0;
329} 335}
330 336
331static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec) 337static int cx24123_set_fec(struct cx24123_state *state, fe_code_rate_t fec)
332{ 338{
333 u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07; 339 u8 nom_reg = cx24123_readreg(state, 0x0e) & ~0x07;
334 340
335 if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) 341 if ((fec < FEC_NONE) || (fec > FEC_AUTO))
336 fec = FEC_AUTO; 342 fec = FEC_AUTO;
337 343
338 /* Set the soft decision threshold */ 344 /* Set the soft decision threshold */
339 if(fec == FEC_1_2) 345 if (fec == FEC_1_2)
340 cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01); 346 cx24123_writereg(state, 0x43,
347 cx24123_readreg(state, 0x43) | 0x01);
341 else 348 else
342 cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01); 349 cx24123_writereg(state, 0x43,
350 cx24123_readreg(state, 0x43) & ~0x01);
343 351
344 switch (fec) { 352 switch (fec) {
345 case FEC_1_2: 353 case FEC_1_2:
@@ -388,11 +396,11 @@ static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec)
388 return 0; 396 return 0;
389} 397}
390 398
391static int cx24123_get_fec(struct cx24123_state* state, fe_code_rate_t *fec) 399static int cx24123_get_fec(struct cx24123_state *state, fe_code_rate_t *fec)
392{ 400{
393 int ret; 401 int ret;
394 402
395 ret = cx24123_readreg (state, 0x1b); 403 ret = cx24123_readreg(state, 0x1b);
396 if (ret < 0) 404 if (ret < 0)
397 return ret; 405 return ret;
398 ret = ret & 0x07; 406 ret = ret & 0x07;
@@ -433,16 +441,16 @@ static u32 cx24123_int_log2(u32 a, u32 b)
433{ 441{
434 u32 exp, nearest = 0; 442 u32 exp, nearest = 0;
435 u32 div = a / b; 443 u32 div = a / b;
436 if(a % b >= b / 2) ++div; 444 if (a % b >= b / 2)
437 if(div < (1 << 31)) 445 ++div;
438 { 446 if (div < (1 << 31)) {
439 for(exp = 1; div > exp; nearest++) 447 for (exp = 1; div > exp; nearest++)
440 exp += exp; 448 exp += exp;
441 } 449 }
442 return nearest; 450 return nearest;
443} 451}
444 452
445static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate) 453static int cx24123_set_symbolrate(struct cx24123_state *state, u32 srate)
446{ 454{
447 u32 tmp, sample_rate, ratio, sample_gain; 455 u32 tmp, sample_rate, ratio, sample_gain;
448 u8 pll_mult; 456 u8 pll_mult;
@@ -498,9 +506,9 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate)
498 506
499 cx24123_writereg(state, 0x01, pll_mult * 6); 507 cx24123_writereg(state, 0x01, pll_mult * 6);
500 508
501 cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f ); 509 cx24123_writereg(state, 0x08, (ratio >> 16) & 0x3f);
502 cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff ); 510 cx24123_writereg(state, 0x09, (ratio >> 8) & 0xff);
503 cx24123_writereg(state, 0x0a, (ratio ) & 0xff ); 511 cx24123_writereg(state, 0x0a, ratio & 0xff);
504 512
505 /* also set the demodulator sample gain */ 513 /* also set the demodulator sample gain */
506 sample_gain = cx24123_int_log2(sample_rate, srate); 514 sample_gain = cx24123_int_log2(sample_rate, srate);
@@ -514,10 +522,12 @@ static int cx24123_set_symbolrate(struct cx24123_state* state, u32 srate)
514} 522}
515 523
516/* 524/*
517 * Based on the required frequency and symbolrate, the tuner AGC has to be configured 525 * Based on the required frequency and symbolrate, the tuner AGC has
518 * and the correct band selected. Calculate those values 526 * to be configured and the correct band selected.
527 * Calculate those values.
519 */ 528 */
520static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 529static int cx24123_pll_calculate(struct dvb_frontend *fe,
530 struct dvb_frontend_parameters *p)
521{ 531{
522 struct cx24123_state *state = fe->demodulator_priv; 532 struct cx24123_state *state = fe->demodulator_priv;
523 u32 ndiv = 0, adiv = 0, vco_div = 0; 533 u32 ndiv = 0, adiv = 0, vco_div = 0;
@@ -525,6 +535,8 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa
525 int pump = 2; 535 int pump = 2;
526 int band = 0; 536 int band = 0;
527 int num_bands = ARRAY_SIZE(cx24123_bandselect_vals); 537 int num_bands = ARRAY_SIZE(cx24123_bandselect_vals);
538 struct cx24123_bandselect_val *bsv = NULL;
539 struct cx24123_AGC_val *agcv = NULL;
528 540
529 /* Defaults for low freq, low rate */ 541 /* Defaults for low freq, low rate */
530 state->VCAarg = cx24123_AGC_vals[0].VCAprogdata; 542 state->VCAarg = cx24123_AGC_vals[0].VCAprogdata;
@@ -532,58 +544,65 @@ static int cx24123_pll_calculate(struct dvb_frontend* fe, struct dvb_frontend_pa
532 state->bandselectarg = cx24123_bandselect_vals[0].progdata; 544 state->bandselectarg = cx24123_bandselect_vals[0].progdata;
533 vco_div = cx24123_bandselect_vals[0].VCOdivider; 545 vco_div = cx24123_bandselect_vals[0].VCOdivider;
534 546
535 /* For the given symbol rate, determine the VCA, VGA and FILTUNE programming bits */ 547 /* For the given symbol rate, determine the VCA, VGA and
536 for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) 548 * FILTUNE programming bits */
537 { 549 for (i = 0; i < ARRAY_SIZE(cx24123_AGC_vals); i++) {
538 if ((cx24123_AGC_vals[i].symbolrate_low <= p->u.qpsk.symbol_rate) && 550 agcv = &cx24123_AGC_vals[i];
539 (cx24123_AGC_vals[i].symbolrate_high >= p->u.qpsk.symbol_rate) ) { 551 if ((agcv->symbolrate_low <= p->u.qpsk.symbol_rate) &&
540 state->VCAarg = cx24123_AGC_vals[i].VCAprogdata; 552 (agcv->symbolrate_high >= p->u.qpsk.symbol_rate)) {
541 state->VGAarg = cx24123_AGC_vals[i].VGAprogdata; 553 state->VCAarg = agcv->VCAprogdata;
542 state->FILTune = cx24123_AGC_vals[i].FILTune; 554 state->VGAarg = agcv->VGAprogdata;
555 state->FILTune = agcv->FILTune;
543 } 556 }
544 } 557 }
545 558
546 /* determine the band to use */ 559 /* determine the band to use */
547 if(force_band < 1 || force_band > num_bands) 560 if (force_band < 1 || force_band > num_bands) {
548 { 561 for (i = 0; i < num_bands; i++) {
549 for (i = 0; i < num_bands; i++) 562 bsv = &cx24123_bandselect_vals[i];
550 { 563 if ((bsv->freq_low <= p->frequency) &&
551 if ((cx24123_bandselect_vals[i].freq_low <= p->frequency) && 564 (bsv->freq_high >= p->frequency))
552 (cx24123_bandselect_vals[i].freq_high >= p->frequency) )
553 band = i; 565 band = i;
554 } 566 }
555 } 567 } else
556 else
557 band = force_band - 1; 568 band = force_band - 1;
558 569
559 state->bandselectarg = cx24123_bandselect_vals[band].progdata; 570 state->bandselectarg = cx24123_bandselect_vals[band].progdata;
560 vco_div = cx24123_bandselect_vals[band].VCOdivider; 571 vco_div = cx24123_bandselect_vals[band].VCOdivider;
561 572
562 /* determine the charge pump current */ 573 /* determine the charge pump current */
563 if ( p->frequency < (cx24123_bandselect_vals[band].freq_low + cx24123_bandselect_vals[band].freq_high)/2 ) 574 if (p->frequency < (cx24123_bandselect_vals[band].freq_low +
575 cx24123_bandselect_vals[band].freq_high) / 2)
564 pump = 0x01; 576 pump = 0x01;
565 else 577 else
566 pump = 0x02; 578 pump = 0x02;
567 579
568 /* Determine the N/A dividers for the requested lband freq (in kHz). */ 580 /* Determine the N/A dividers for the requested lband freq (in kHz). */
569 /* Note: the reference divider R=10, frequency is in KHz, XTAL is in Hz */ 581 /* Note: the reference divider R=10, frequency is in KHz,
570 ndiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) / 32) & 0x1ff; 582 * XTAL is in Hz */
571 adiv = ( ((p->frequency * vco_div * 10) / (2 * XTAL / 1000)) % 32) & 0x1f; 583 ndiv = (((p->frequency * vco_div * 10) /
584 (2 * XTAL / 1000)) / 32) & 0x1ff;
585 adiv = (((p->frequency * vco_div * 10) /
586 (2 * XTAL / 1000)) % 32) & 0x1f;
572 587
573 if (adiv == 0 && ndiv > 0) 588 if (adiv == 0 && ndiv > 0)
574 ndiv--; 589 ndiv--;
575 590
576 /* control bits 11, refdiv 11, charge pump polarity 1, charge pump current, ndiv, adiv */ 591 /* control bits 11, refdiv 11, charge pump polarity 1,
577 state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) | (pump << 14) | (ndiv << 5) | adiv; 592 * charge pump current, ndiv, adiv */
593 state->pllarg = (3 << 19) | (3 << 17) | (1 << 16) |
594 (pump << 14) | (ndiv << 5) | adiv;
578 595
579 return 0; 596 return 0;
580} 597}
581 598
582/* 599/*
583 * Tuner data is 21 bits long, must be left-aligned in data. 600 * Tuner data is 21 bits long, must be left-aligned in data.
584 * Tuner cx24109 is written through a dedicated 3wire interface on the demod chip. 601 * Tuner cx24109 is written through a dedicated 3wire interface
602 * on the demod chip.
585 */ 603 */
586static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_parameters *p, u32 data) 604static int cx24123_pll_writereg(struct dvb_frontend *fe,
605 struct dvb_frontend_parameters *p, u32 data)
587{ 606{
588 struct cx24123_state *state = fe->demodulator_priv; 607 struct cx24123_state *state = fe->demodulator_priv;
589 unsigned long timeout; 608 unsigned long timeout;
@@ -610,7 +629,7 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par
610 629
611 /* send another 8 bytes, wait for the send to be completed */ 630 /* send another 8 bytes, wait for the send to be completed */
612 timeout = jiffies + msecs_to_jiffies(40); 631 timeout = jiffies + msecs_to_jiffies(40);
613 cx24123_writereg(state, 0x22, (data>>8) & 0xff ); 632 cx24123_writereg(state, 0x22, (data >> 8) & 0xff);
614 while ((cx24123_readreg(state, 0x20) & 0x40) == 0) { 633 while ((cx24123_readreg(state, 0x20) & 0x40) == 0) {
615 if (time_after(jiffies, timeout)) { 634 if (time_after(jiffies, timeout)) {
616 err("%s: demodulator is not responding, "\ 635 err("%s: demodulator is not responding, "\
@@ -620,9 +639,10 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par
620 msleep(10); 639 msleep(10);
621 } 640 }
622 641
623 /* send the lower 5 bits of this byte, padded with 3 LBB, wait for the send to be completed */ 642 /* send the lower 5 bits of this byte, padded with 3 LBB,
643 * wait for the send to be completed */
624 timeout = jiffies + msecs_to_jiffies(40); 644 timeout = jiffies + msecs_to_jiffies(40);
625 cx24123_writereg(state, 0x22, (data) & 0xff ); 645 cx24123_writereg(state, 0x22, (data) & 0xff);
626 while ((cx24123_readreg(state, 0x20) & 0x80)) { 646 while ((cx24123_readreg(state, 0x20) & 0x80)) {
627 if (time_after(jiffies, timeout)) { 647 if (time_after(jiffies, timeout)) {
628 err("%s: demodulator is not responding," \ 648 err("%s: demodulator is not responding," \
@@ -639,7 +659,8 @@ static int cx24123_pll_writereg(struct dvb_frontend* fe, struct dvb_frontend_par
639 return 0; 659 return 0;
640} 660}
641 661
642static int cx24123_pll_tune(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 662static int cx24123_pll_tune(struct dvb_frontend *fe,
663 struct dvb_frontend_parameters *p)
643{ 664{
644 struct cx24123_state *state = fe->demodulator_priv; 665 struct cx24123_state *state = fe->demodulator_priv;
645 u8 val; 666 u8 val;
@@ -690,7 +711,7 @@ static int cx24123_repeater_mode(struct cx24123_state *state, u8 mode, u8 start)
690 return cx24123_writereg(state, 0x23, r); 711 return cx24123_writereg(state, 0x23, r);
691} 712}
692 713
693static int cx24123_initfe(struct dvb_frontend* fe) 714static int cx24123_initfe(struct dvb_frontend *fe)
694{ 715{
695 struct cx24123_state *state = fe->demodulator_priv; 716 struct cx24123_state *state = fe->demodulator_priv;
696 int i; 717 int i;
@@ -699,19 +720,22 @@ static int cx24123_initfe(struct dvb_frontend* fe)
699 720
700 /* Configure the demod to a good set of defaults */ 721 /* Configure the demod to a good set of defaults */
701 for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++) 722 for (i = 0; i < ARRAY_SIZE(cx24123_regdata); i++)
702 cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); 723 cx24123_writereg(state, cx24123_regdata[i].reg,
724 cx24123_regdata[i].data);
703 725
704 /* Set the LNB polarity */ 726 /* Set the LNB polarity */
705 if(state->config->lnb_polarity) 727 if (state->config->lnb_polarity)
706 cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02); 728 cx24123_writereg(state, 0x32,
729 cx24123_readreg(state, 0x32) | 0x02);
707 730
708 if (state->config->dont_use_pll) 731 if (state->config->dont_use_pll)
709 cx24123_repeater_mode(state, 1, 0); 732 cx24123_repeater_mode(state, 1, 0);
710 733
711 return 0; 734 return 0;
712} 735}
713 736
714static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage) 737static int cx24123_set_voltage(struct dvb_frontend *fe,
738 fe_sec_voltage_t voltage)
715{ 739{
716 struct cx24123_state *state = fe->demodulator_priv; 740 struct cx24123_state *state = fe->demodulator_priv;
717 u8 val; 741 u8 val;
@@ -740,7 +764,7 @@ static void cx24123_wait_for_diseqc(struct cx24123_state *state)
740{ 764{
741 unsigned long timeout = jiffies + msecs_to_jiffies(200); 765 unsigned long timeout = jiffies + msecs_to_jiffies(200);
742 while (!(cx24123_readreg(state, 0x29) & 0x40)) { 766 while (!(cx24123_readreg(state, 0x29) & 0x40)) {
743 if(time_after(jiffies, timeout)) { 767 if (time_after(jiffies, timeout)) {
744 err("%s: diseqc queue not ready, " \ 768 err("%s: diseqc queue not ready, " \
745 "command may be lost.\n", __func__); 769 "command may be lost.\n", __func__);
746 break; 770 break;
@@ -749,7 +773,8 @@ static void cx24123_wait_for_diseqc(struct cx24123_state *state)
749 } 773 }
750} 774}
751 775
752static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_master_cmd *cmd) 776static int cx24123_send_diseqc_msg(struct dvb_frontend *fe,
777 struct dvb_diseqc_master_cmd *cmd)
753{ 778{
754 struct cx24123_state *state = fe->demodulator_priv; 779 struct cx24123_state *state = fe->demodulator_priv;
755 int i, val, tone; 780 int i, val, tone;
@@ -771,20 +796,21 @@ static int cx24123_send_diseqc_msg(struct dvb_frontend* fe, struct dvb_diseqc_ma
771 cx24123_writereg(state, 0x2C + i, cmd->msg[i]); 796 cx24123_writereg(state, 0x2C + i, cmd->msg[i]);
772 797
773 val = cx24123_readreg(state, 0x29); 798 val = cx24123_readreg(state, 0x29);
774 cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) | ((cmd->msg_len-3) & 3)); 799 cx24123_writereg(state, 0x29, ((val & 0x90) | 0x40) |
800 ((cmd->msg_len-3) & 3));
775 801
776 /* wait for diseqc message to finish sending */ 802 /* wait for diseqc message to finish sending */
777 cx24123_wait_for_diseqc(state); 803 cx24123_wait_for_diseqc(state);
778 804
779 /* restart continuous tone if enabled */ 805 /* restart continuous tone if enabled */
780 if (tone & 0x10) { 806 if (tone & 0x10)
781 cx24123_writereg(state, 0x29, tone & ~0x40); 807 cx24123_writereg(state, 0x29, tone & ~0x40);
782 }
783 808
784 return 0; 809 return 0;
785} 810}
786 811
787static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t burst) 812static int cx24123_diseqc_send_burst(struct dvb_frontend *fe,
813 fe_sec_mini_cmd_t burst)
788{ 814{
789 struct cx24123_state *state = fe->demodulator_priv; 815 struct cx24123_state *state = fe->demodulator_priv;
790 int val, tone; 816 int val, tone;
@@ -814,13 +840,13 @@ static int cx24123_diseqc_send_burst(struct dvb_frontend* fe, fe_sec_mini_cmd_t
814 cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb); 840 cx24123_writereg(state, 0x2a, cx24123_readreg(state, 0x2a) & 0xfb);
815 841
816 /* restart continuous tone if enabled */ 842 /* restart continuous tone if enabled */
817 if (tone & 0x10) { 843 if (tone & 0x10)
818 cx24123_writereg(state, 0x29, tone & ~0x40); 844 cx24123_writereg(state, 0x29, tone & ~0x40);
819 } 845
820 return 0; 846 return 0;
821} 847}
822 848
823static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status) 849static int cx24123_read_status(struct dvb_frontend *fe, fe_status_t *status)
824{ 850{
825 struct cx24123_state *state = fe->demodulator_priv; 851 struct cx24123_state *state = fe->demodulator_priv;
826 int sync = cx24123_readreg(state, 0x14); 852 int sync = cx24123_readreg(state, 0x14);
@@ -853,8 +879,9 @@ static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status)
853} 879}
854 880
855/* 881/*
856 * Configured to return the measurement of errors in blocks, because no UCBLOCKS value 882 * Configured to return the measurement of errors in blocks,
857 * is available, so this value doubles up to satisfy both measurements 883 * because no UCBLOCKS value is available, so this value doubles up
884 * to satisfy both measurements.
858 */ 885 */
859static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber) 886static int cx24123_read_ber(struct dvb_frontend *fe, u32 *ber)
860{ 887{
@@ -876,7 +903,8 @@ static int cx24123_read_signal_strength(struct dvb_frontend *fe,
876{ 903{
877 struct cx24123_state *state = fe->demodulator_priv; 904 struct cx24123_state *state = fe->demodulator_priv;
878 905
879 *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ 906 /* larger = better */
907 *signal_strength = cx24123_readreg(state, 0x3b) << 8;
880 908
881 dprintk("Signal strength = %d\n", *signal_strength); 909 dprintk("Signal strength = %d\n", *signal_strength);
882 910
@@ -907,7 +935,7 @@ static int cx24123_set_frontend(struct dvb_frontend *fe,
907 if (state->config->set_ts_params) 935 if (state->config->set_ts_params)
908 state->config->set_ts_params(fe, 0); 936 state->config->set_ts_params(fe, 0);
909 937
910 state->currentfreq=p->frequency; 938 state->currentfreq = p->frequency;
911 state->currentsymbolrate = p->u.qpsk.symbol_rate; 939 state->currentsymbolrate = p->u.qpsk.symbol_rate;
912 940
913 cx24123_set_inversion(state, p->inversion); 941 cx24123_set_inversion(state, p->inversion);
@@ -932,7 +960,8 @@ static int cx24123_set_frontend(struct dvb_frontend *fe,
932 return 0; 960 return 0;
933} 961}
934 962
935static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_parameters *p) 963static int cx24123_get_frontend(struct dvb_frontend *fe,
964 struct dvb_frontend_parameters *p)
936{ 965{
937 struct cx24123_state *state = fe->demodulator_priv; 966 struct cx24123_state *state = fe->demodulator_priv;
938 967
@@ -952,7 +981,7 @@ static int cx24123_get_frontend(struct dvb_frontend* fe, struct dvb_frontend_par
952 return 0; 981 return 0;
953} 982}
954 983
955static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone) 984static int cx24123_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone)
956{ 985{
957 struct cx24123_state *state = fe->demodulator_priv; 986 struct cx24123_state *state = fe->demodulator_priv;
958 u8 val; 987 u8 val;
@@ -977,8 +1006,8 @@ static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
977 return 0; 1006 return 0;
978} 1007}
979 1008
980static int cx24123_tune(struct dvb_frontend* fe, 1009static int cx24123_tune(struct dvb_frontend *fe,
981 struct dvb_frontend_parameters* params, 1010 struct dvb_frontend_parameters *params,
982 unsigned int mode_flags, 1011 unsigned int mode_flags,
983 unsigned int *delay, 1012 unsigned int *delay,
984 fe_status_t *status) 1013 fe_status_t *status)
@@ -997,12 +1026,12 @@ static int cx24123_tune(struct dvb_frontend* fe,
997 1026
998static int cx24123_get_algo(struct dvb_frontend *fe) 1027static int cx24123_get_algo(struct dvb_frontend *fe)
999{ 1028{
1000 return 1; //FE_ALGO_HW 1029 return 1; /* FE_ALGO_HW */
1001} 1030}
1002 1031
1003static void cx24123_release(struct dvb_frontend* fe) 1032static void cx24123_release(struct dvb_frontend *fe)
1004{ 1033{
1005 struct cx24123_state* state = fe->demodulator_priv; 1034 struct cx24123_state *state = fe->demodulator_priv;
1006 dprintk("\n"); 1035 dprintk("\n");
1007 i2c_del_adapter(&state->tuner_i2c_adapter); 1036 i2c_del_adapter(&state->tuner_i2c_adapter);
1008 kfree(state); 1037 kfree(state);
@@ -1013,7 +1042,7 @@ static int cx24123_tuner_i2c_tuner_xfer(struct i2c_adapter *i2c_adap,
1013{ 1042{
1014 struct cx24123_state *state = i2c_get_adapdata(i2c_adap); 1043 struct cx24123_state *state = i2c_get_adapdata(i2c_adap);
1015 /* this repeater closes after the first stop */ 1044 /* this repeater closes after the first stop */
1016 cx24123_repeater_mode(state, 1, 1); 1045 cx24123_repeater_mode(state, 1, 1);
1017 return i2c_transfer(state->i2c, msg, num); 1046 return i2c_transfer(state->i2c, msg, num);
1018} 1047}
1019 1048
@@ -1037,8 +1066,8 @@ EXPORT_SYMBOL(cx24123_get_tuner_i2c_adapter);
1037 1066
1038static struct dvb_frontend_ops cx24123_ops; 1067static struct dvb_frontend_ops cx24123_ops;
1039 1068
1040struct dvb_frontend* cx24123_attach(const struct cx24123_config* config, 1069struct dvb_frontend *cx24123_attach(const struct cx24123_config *config,
1041 struct i2c_adapter* i2c) 1070 struct i2c_adapter *i2c)
1042{ 1071{
1043 struct cx24123_state *state = 1072 struct cx24123_state *state =
1044 kzalloc(sizeof(struct cx24123_state), GFP_KERNEL); 1073 kzalloc(sizeof(struct cx24123_state), GFP_KERNEL);
@@ -1057,20 +1086,25 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
1057 /* check if the demod is there */ 1086 /* check if the demod is there */
1058 state->demod_rev = cx24123_readreg(state, 0x00); 1087 state->demod_rev = cx24123_readreg(state, 0x00);
1059 switch (state->demod_rev) { 1088 switch (state->demod_rev) {
1060 case 0xe1: info("detected CX24123C\n"); break; 1089 case 0xe1:
1061 case 0xd1: info("detected CX24123\n"); break; 1090 info("detected CX24123C\n");
1091 break;
1092 case 0xd1:
1093 info("detected CX24123\n");
1094 break;
1062 default: 1095 default:
1063 err("wrong demod revision: %x\n", state->demod_rev); 1096 err("wrong demod revision: %x\n", state->demod_rev);
1064 goto error; 1097 goto error;
1065 } 1098 }
1066 1099
1067 /* create dvb_frontend */ 1100 /* create dvb_frontend */
1068 memcpy(&state->frontend.ops, &cx24123_ops, sizeof(struct dvb_frontend_ops)); 1101 memcpy(&state->frontend.ops, &cx24123_ops,
1102 sizeof(struct dvb_frontend_ops));
1069 state->frontend.demodulator_priv = state; 1103 state->frontend.demodulator_priv = state;
1070 1104
1071 /* create tuner i2c adapter */ 1105 /* create tuner i2c adapter */
1072 if (config->dont_use_pll) 1106 if (config->dont_use_pll)
1073 cx24123_repeater_mode(state, 1, 0); 1107 cx24123_repeater_mode(state, 1, 0);
1074 1108
1075 strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus", 1109 strlcpy(state->tuner_i2c_adapter.name, "CX24123 tuner I2C bus",
1076 sizeof(state->tuner_i2c_adapter.name)); 1110 sizeof(state->tuner_i2c_adapter.name));
@@ -1079,7 +1113,7 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
1079 state->tuner_i2c_adapter.algo_data = NULL; 1113 state->tuner_i2c_adapter.algo_data = NULL;
1080 i2c_set_adapdata(&state->tuner_i2c_adapter, state); 1114 i2c_set_adapdata(&state->tuner_i2c_adapter, state);
1081 if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) { 1115 if (i2c_add_adapter(&state->tuner_i2c_adapter) < 0) {
1082 err("tuner i2c bus could not be initialized\n"); 1116 err("tuner i2c bus could not be initialized\n");
1083 goto error; 1117 goto error;
1084 } 1118 }
1085 1119
@@ -1090,6 +1124,7 @@ error:
1090 1124
1091 return NULL; 1125 return NULL;
1092} 1126}
1127EXPORT_SYMBOL(cx24123_attach);
1093 1128
1094static struct dvb_frontend_ops cx24123_ops = { 1129static struct dvb_frontend_ops cx24123_ops = {
1095 1130
@@ -1126,15 +1161,8 @@ static struct dvb_frontend_ops cx24123_ops = {
1126 .get_frontend_algo = cx24123_get_algo, 1161 .get_frontend_algo = cx24123_get_algo,
1127}; 1162};
1128 1163
1129module_param(debug, int, 0644);
1130MODULE_PARM_DESC(debug, "Activates frontend debugging (default:0)");
1131
1132module_param(force_band, int, 0644);
1133MODULE_PARM_DESC(force_band, "Force a specific band select (1-9, default:off).");
1134
1135MODULE_DESCRIPTION("DVB Frontend module for Conexant " \ 1164MODULE_DESCRIPTION("DVB Frontend module for Conexant " \
1136 "CX24123/CX24109/CX24113 hardware"); 1165 "CX24123/CX24109/CX24113 hardware");
1137MODULE_AUTHOR("Steven Toth"); 1166MODULE_AUTHOR("Steven Toth");
1138MODULE_LICENSE("GPL"); 1167MODULE_LICENSE("GPL");
1139 1168
1140EXPORT_SYMBOL(cx24123_attach);
diff --git a/drivers/media/dvb/frontends/cx24123.h b/drivers/media/dvb/frontends/cx24123.h
index cc6b411d6d20..51ae866e9fed 100644
--- a/drivers/media/dvb/frontends/cx24123.h
+++ b/drivers/media/dvb/frontends/cx24123.h
@@ -23,13 +23,12 @@
23 23
24#include <linux/dvb/frontend.h> 24#include <linux/dvb/frontend.h>
25 25
26struct cx24123_config 26struct cx24123_config {
27{
28 /* the demodulator's i2c address */ 27 /* the demodulator's i2c address */
29 u8 demod_address; 28 u8 demod_address;
30 29
31 /* Need to set device param for start_dma */ 30 /* Need to set device param for start_dma */
32 int (*set_ts_params)(struct dvb_frontend* fe, int is_punctured); 31 int (*set_ts_params)(struct dvb_frontend *fe, int is_punctured);
33 32
34 /* 0 = LNB voltage normal, 1 = LNB voltage inverted */ 33 /* 0 = LNB voltage normal, 1 = LNB voltage inverted */
35 int lnb_polarity; 34 int lnb_polarity;
@@ -39,7 +38,8 @@ struct cx24123_config
39 void (*agc_callback) (struct dvb_frontend *); 38 void (*agc_callback) (struct dvb_frontend *);
40}; 39};
41 40
42#if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) && defined(MODULE)) 41#if defined(CONFIG_DVB_CX24123) || (defined(CONFIG_DVB_CX24123_MODULE) \
42 && defined(MODULE))
43extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config, 43extern struct dvb_frontend *cx24123_attach(const struct cx24123_config *config,
44 struct i2c_adapter *i2c); 44 struct i2c_adapter *i2c);
45extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *); 45extern struct i2c_adapter *cx24123_get_tuner_i2c_adapter(struct dvb_frontend *);
@@ -56,6 +56,6 @@ static struct i2c_adapter *
56 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__); 56 printk(KERN_WARNING "%s: driver disabled by Kconfig\n", __func__);
57 return NULL; 57 return NULL;
58} 58}
59#endif // CONFIG_DVB_CX24123 59#endif
60 60
61#endif /* CX24123_H */ 61#endif /* CX24123_H */