aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/dvb/frontends/cx24123.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@g5.osdl.org>2006-09-30 12:39:15 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-09-30 12:39:15 -0400
commit5ffd1a6aaacc25be8cd0770a51ec6d46add3a276 (patch)
tree5b076c44f8b7ff88dba9a554d7748c6f083c9071 /drivers/media/dvb/frontends/cx24123.c
parent0cd43f83d381c4246a08cd775834833d6fd64805 (diff)
parent8dd86eebc5315910ebfd9f30f1674254308be4b3 (diff)
Merge master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb
* master.kernel.org:/pub/scm/linux/kernel/git/mchehab/v4l-dvb: (180 commits) V4L/DVB (4641): Trivial: use lowercase letters in hex subsystem ids V4L/DVB (4639): Cx88: add autodetection for alternate revision of Leadtek PVR V4L/DVB (4638): Basic DVB-T and analog TV support for the HVR1300. V4L/DVB (4637): Add a default method for VIDIOC_G_PARM V4L/DVB (4635): Extend bttv and saa7134 to check for both AGP and PCI PCI failure case V4L/DVB (4634): Zr36120: implement pcipci checks V4L/DVB (4632): Zoran: Implement pcipci failure check V4L/DVB (4631): Av7110: remove V4L2_CAP_VBI_CAPTURE flag V4L/DVB (4630): Av7110: FW_LOADER depemdency fixed V4L/DVB (4629): Saa7134: add card support for Proteus Pro 2309 V4L/DVB (4628): Fix VIDIOC_ENUMSTD ioctl in videodev.c V4L/DVB (4627): Vivi crashes with mplayer V4L/DVB (4626): On saa7111/7113, LUMA_CTRL need a different value V4L/DVB (4624): Tvaudio: Replaced kernel_thread() with kthread_run() V4L/DVB (4622): Copy-paste bug in videodev.c V4L/DVB (4620): Fix AGC configuration for MOD3000P-based boards V4L/DVB (4619): Fixes some I2C dependencies on V4L devices V4L/DVB (4617): Problem with dibusb-mb.c USB IDs V4L/DVB (4616): [PATCH] Nebula DigiTV USB RC support V4L/DVB (4614): Export symbol saa7134_tvaudio_setmute from saa7134 for saa7134-alsa ...
Diffstat (limited to 'drivers/media/dvb/frontends/cx24123.c')
-rw-r--r--drivers/media/dvb/frontends/cx24123.c98
1 files changed, 56 insertions, 42 deletions
diff --git a/drivers/media/dvb/frontends/cx24123.c b/drivers/media/dvb/frontends/cx24123.c
index 274a87b7a5d5..62d69a6ea699 100644
--- a/drivers/media/dvb/frontends/cx24123.c
+++ b/drivers/media/dvb/frontends/cx24123.c
@@ -45,9 +45,6 @@ struct cx24123_state
45 45
46 struct dvb_frontend frontend; 46 struct dvb_frontend frontend;
47 47
48 u32 lastber;
49 u16 snr;
50
51 /* Some PLL specifics for tuning */ 48 /* Some PLL specifics for tuning */
52 u32 VCAarg; 49 u32 VCAarg;
53 u32 VGAarg; 50 u32 VGAarg;
@@ -194,7 +191,7 @@ static struct {
194 {0x06, 0x31}, /* MPEG (default) */ 191 {0x06, 0x31}, /* MPEG (default) */
195 {0x0b, 0x00}, /* Freq search start point (default) */ 192 {0x0b, 0x00}, /* Freq search start point (default) */
196 {0x0c, 0x00}, /* Demodulator sample gain (default) */ 193 {0x0c, 0x00}, /* Demodulator sample gain (default) */
197 {0x0d, 0x02}, /* Frequency search range = Fsymbol / 4 (default) */ 194 {0x0d, 0x7f}, /* Force driver to shift until the maximum (+-10 MHz) */
198 {0x0e, 0x03}, /* Default non-inverted, FEC 3/4 (default) */ 195 {0x0e, 0x03}, /* Default non-inverted, FEC 3/4 (default) */
199 {0x0f, 0xfe}, /* FEC search mask (all supported codes) */ 196 {0x0f, 0xfe}, /* FEC search mask (all supported codes) */
200 {0x10, 0x01}, /* Default search inversion, no repeat (default) */ 197 {0x10, 0x01}, /* Default search inversion, no repeat (default) */
@@ -223,8 +220,9 @@ static struct {
223 {0x44, 0x00}, /* Constellation (default) */ 220 {0x44, 0x00}, /* Constellation (default) */
224 {0x45, 0x00}, /* Symbol count (default) */ 221 {0x45, 0x00}, /* Symbol count (default) */
225 {0x46, 0x0d}, /* Symbol rate estimator on (default) */ 222 {0x46, 0x0d}, /* Symbol rate estimator on (default) */
226 {0x56, 0x41}, /* Various (default) */ 223 {0x56, 0xc1}, /* Error Counter = Viterbi BER */
227 {0x57, 0xff}, /* Error Counter Window (default) */ 224 {0x57, 0xff}, /* Error Counter Window (default) */
225 {0x5c, 0x20}, /* Acquisition AFC Expiration window (default is 0x10) */
228 {0x67, 0x83}, /* Non-DCII symbol clock */ 226 {0x67, 0x83}, /* Non-DCII symbol clock */
229}; 227};
230 228
@@ -321,6 +319,12 @@ static int cx24123_set_fec(struct cx24123_state* state, fe_code_rate_t fec)
321 if ( (fec < FEC_NONE) || (fec > FEC_AUTO) ) 319 if ( (fec < FEC_NONE) || (fec > FEC_AUTO) )
322 fec = FEC_AUTO; 320 fec = FEC_AUTO;
323 321
322 /* Set the soft decision threshold */
323 if(fec == FEC_1_2)
324 cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) | 0x01);
325 else
326 cx24123_writereg(state, 0x43, cx24123_readreg(state, 0x43) & ~0x01);
327
324 switch (fec) { 328 switch (fec) {
325 case FEC_1_2: 329 case FEC_1_2:
326 dprintk("%s: set FEC to 1/2\n",__FUNCTION__); 330 dprintk("%s: set FEC to 1/2\n",__FUNCTION__);
@@ -657,6 +661,10 @@ static int cx24123_initfe(struct dvb_frontend* fe)
657 for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++) 661 for (i = 0; i < sizeof(cx24123_regdata) / sizeof(cx24123_regdata[0]); i++)
658 cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data); 662 cx24123_writereg(state, cx24123_regdata[i].reg, cx24123_regdata[i].data);
659 663
664 /* Set the LNB polarity */
665 if(state->config->lnb_polarity)
666 cx24123_writereg(state, 0x32, cx24123_readreg(state, 0x32) | 0x02);
667
660 return 0; 668 return 0;
661} 669}
662 670
@@ -674,6 +682,9 @@ static int cx24123_set_voltage(struct dvb_frontend* fe, fe_sec_voltage_t voltage
674 case SEC_VOLTAGE_18: 682 case SEC_VOLTAGE_18:
675 dprintk("%s: setting voltage 18V\n", __FUNCTION__); 683 dprintk("%s: setting voltage 18V\n", __FUNCTION__);
676 return cx24123_writereg(state, 0x29, val | 0x80); 684 return cx24123_writereg(state, 0x29, val | 0x80);
685 case SEC_VOLTAGE_OFF:
686 /* already handled in cx88-dvb */
687 return 0;
677 default: 688 default:
678 return -EINVAL; 689 return -EINVAL;
679 }; 690 };
@@ -776,13 +787,15 @@ static int cx24123_read_status(struct dvb_frontend* fe, fe_status_t* status)
776 if (lock & 0x01) 787 if (lock & 0x01)
777 *status |= FE_HAS_SIGNAL; 788 *status |= FE_HAS_SIGNAL;
778 if (sync & 0x02) 789 if (sync & 0x02)
779 *status |= FE_HAS_CARRIER; 790 *status |= FE_HAS_CARRIER; /* Phase locked */
780 if (sync & 0x04) 791 if (sync & 0x04)
781 *status |= FE_HAS_VITERBI; 792 *status |= FE_HAS_VITERBI;
793
794 /* Reed-Solomon Status */
782 if (sync & 0x08) 795 if (sync & 0x08)
783 *status |= FE_HAS_SYNC; 796 *status |= FE_HAS_SYNC;
784 if (sync & 0x80) 797 if (sync & 0x80)
785 *status |= FE_HAS_LOCK; 798 *status |= FE_HAS_LOCK; /*Full Sync */
786 799
787 return 0; 800 return 0;
788} 801}
@@ -795,29 +808,13 @@ static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber)
795{ 808{
796 struct cx24123_state *state = fe->demodulator_priv; 809 struct cx24123_state *state = fe->demodulator_priv;
797 810
798 state->lastber = 811 /* The true bit error rate is this value divided by
799 ((cx24123_readreg(state, 0x1c) & 0x3f) << 16) | 812 the window size (set as 256 * 255) */
813 *ber = ((cx24123_readreg(state, 0x1c) & 0x3f) << 16) |
800 (cx24123_readreg(state, 0x1d) << 8 | 814 (cx24123_readreg(state, 0x1d) << 8 |
801 cx24123_readreg(state, 0x1e)); 815 cx24123_readreg(state, 0x1e));
802
803 /* Do the signal quality processing here, it's derived from the BER. */
804 /* Scale the BER from a 24bit to a SNR 16 bit where higher = better */
805 if (state->lastber < 5000)
806 state->snr = 655*100;
807 else if ( (state->lastber >= 5000) && (state->lastber < 55000) )
808 state->snr = 655*90;
809 else if ( (state->lastber >= 55000) && (state->lastber < 150000) )
810 state->snr = 655*80;
811 else if ( (state->lastber >= 150000) && (state->lastber < 250000) )
812 state->snr = 655*70;
813 else if ( (state->lastber >= 250000) && (state->lastber < 450000) )
814 state->snr = 655*65;
815 else
816 state->snr = 0;
817
818 dprintk("%s: BER = %d, S/N index = %d\n",__FUNCTION__,state->lastber, state->snr);
819 816
820 *ber = state->lastber; 817 dprintk("%s: BER = %d\n",__FUNCTION__,*ber);
821 818
822 return 0; 819 return 0;
823} 820}
@@ -825,6 +822,7 @@ static int cx24123_read_ber(struct dvb_frontend* fe, u32* ber)
825static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength) 822static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_strength)
826{ 823{
827 struct cx24123_state *state = fe->demodulator_priv; 824 struct cx24123_state *state = fe->demodulator_priv;
825
828 *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */ 826 *signal_strength = cx24123_readreg(state, 0x3b) << 8; /* larger = better */
829 827
830 dprintk("%s: Signal strength = %d\n",__FUNCTION__,*signal_strength); 828 dprintk("%s: Signal strength = %d\n",__FUNCTION__,*signal_strength);
@@ -835,19 +833,13 @@ static int cx24123_read_signal_strength(struct dvb_frontend* fe, u16* signal_str
835static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr) 833static int cx24123_read_snr(struct dvb_frontend* fe, u16* snr)
836{ 834{
837 struct cx24123_state *state = fe->demodulator_priv; 835 struct cx24123_state *state = fe->demodulator_priv;
838 *snr = state->snr;
839
840 dprintk("%s: read S/N index = %d\n",__FUNCTION__,*snr);
841 836
842 return 0; 837 /* Inverted raw Es/N0 count, totally bogus but better than the
843} 838 BER threshold. */
839 *snr = 65535 - (((u16)cx24123_readreg(state, 0x18) << 8) |
840 (u16)cx24123_readreg(state, 0x19));
844 841
845static int cx24123_read_ucblocks(struct dvb_frontend* fe, u32* ucblocks) 842 dprintk("%s: read S/N index = %d\n",__FUNCTION__,*snr);
846{
847 struct cx24123_state *state = fe->demodulator_priv;
848 *ucblocks = state->lastber;
849
850 dprintk("%s: ucblocks (ber) = %d\n",__FUNCTION__,*ucblocks);
851 843
852 return 0; 844 return 0;
853} 845}
@@ -922,6 +914,29 @@ static int cx24123_set_tone(struct dvb_frontend* fe, fe_sec_tone_mode_t tone)
922 return 0; 914 return 0;
923} 915}
924 916
917static int cx24123_tune(struct dvb_frontend* fe,
918 struct dvb_frontend_parameters* params,
919 unsigned int mode_flags,
920 int *delay,
921 fe_status_t *status)
922{
923 int retval = 0;
924
925 if (params != NULL)
926 retval = cx24123_set_frontend(fe, params);
927
928 if (!(mode_flags & FE_TUNE_MODE_ONESHOT))
929 cx24123_read_status(fe, status);
930 *delay = HZ/10;
931
932 return retval;
933}
934
935static int cx24123_get_algo(struct dvb_frontend *fe)
936{
937 return 1; //FE_ALGO_HW
938}
939
925static void cx24123_release(struct dvb_frontend* fe) 940static void cx24123_release(struct dvb_frontend* fe)
926{ 941{
927 struct cx24123_state* state = fe->demodulator_priv; 942 struct cx24123_state* state = fe->demodulator_priv;
@@ -949,8 +964,6 @@ struct dvb_frontend* cx24123_attach(const struct cx24123_config* config,
949 /* setup the state */ 964 /* setup the state */
950 state->config = config; 965 state->config = config;
951 state->i2c = i2c; 966 state->i2c = i2c;
952 state->lastber = 0;
953 state->snr = 0;
954 state->VCAarg = 0; 967 state->VCAarg = 0;
955 state->VGAarg = 0; 968 state->VGAarg = 0;
956 state->bandselectarg = 0; 969 state->bandselectarg = 0;
@@ -1003,11 +1016,12 @@ static struct dvb_frontend_ops cx24123_ops = {
1003 .read_ber = cx24123_read_ber, 1016 .read_ber = cx24123_read_ber,
1004 .read_signal_strength = cx24123_read_signal_strength, 1017 .read_signal_strength = cx24123_read_signal_strength,
1005 .read_snr = cx24123_read_snr, 1018 .read_snr = cx24123_read_snr,
1006 .read_ucblocks = cx24123_read_ucblocks,
1007 .diseqc_send_master_cmd = cx24123_send_diseqc_msg, 1019 .diseqc_send_master_cmd = cx24123_send_diseqc_msg,
1008 .diseqc_send_burst = cx24123_diseqc_send_burst, 1020 .diseqc_send_burst = cx24123_diseqc_send_burst,
1009 .set_tone = cx24123_set_tone, 1021 .set_tone = cx24123_set_tone,
1010 .set_voltage = cx24123_set_voltage, 1022 .set_voltage = cx24123_set_voltage,
1023 .tune = cx24123_tune,
1024 .get_frontend_algo = cx24123_get_algo,
1011}; 1025};
1012 1026
1013module_param(debug, int, 0644); 1027module_param(debug, int, 0644);