From 8bd135bab91f4659d4c62466029aff468e56f235 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Tue, 3 Jul 2007 09:53:42 -0300 Subject: V4L/DVB (9375): Add STB0899 support Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/stb0899_priv.h | 272 +++++++++++++++++++++++++++++ 1 file changed, 272 insertions(+) create mode 100644 drivers/media/dvb/frontends/stb0899_priv.h (limited to 'drivers/media/dvb/frontends/stb0899_priv.h') diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h new file mode 100644 index 00000000000..47e533dd417 --- /dev/null +++ b/drivers/media/dvb/frontends/stb0899_priv.h @@ -0,0 +1,272 @@ +/* + STB0899 Multistandard Frontend driver + Copyright (C) Manu Abraham (abraham.manu@gmail.com) + + Copyright (C) ST Microelectronics + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +*/ + +#ifndef __STB0899_PRIV_H +#define __STB0899_PRIV_H + +#include "dvb_frontend.h" +#include "stb0899_drv.h" + +#define FE_ERROR 0 +#define FE_NOTICE 1 +#define FE_INFO 2 +#define FE_DEBUG 3 +#define FE_DEBUGREG 4 + +#define dprintk(x, y, z, format, arg...) do { \ + if (z) { \ + if ((x > FE_ERROR) && (x > y)) \ + printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \ + else if ((x > FE_NOTICE) && (x > y)) \ + printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \ + else if ((x > FE_INFO) && (x > y)) \ + printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \ + else if ((x > FE_DEBUG) && (x > y)) \ + printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \ + } else { \ + if (x > y) \ + printk(format, ##arg); \ + } \ +} while(0) + +#define INRANGE(val, x, y) (((x <= val) && (val <= y)) || \ + ((y <= val) && (val <= x)) ? 1 : 0) + +#define BYTE0 0 +#define BYTE1 8 +#define BYTE2 16 +#define BYTE3 24 + +#define GETBYTE(x, y) (((x) >> (y)) & 0xff) +#define MAKEWORD32(a, b, c, d) (((a) << 24) | ((b) << 16) | ((c) << 8) | (d)) +#define MAKEWORD16(a, b) (((a) << 8) | (b)) + +#define MIN(x, y) ((x) <= (y) ? (x) : (y)) +#define MAX(x, y) ((x) >= (y) ? (x) : (y)) +#define ABS(x) ((x) >= 0 ? (x) : -(x)) + +#define LSB(x) ((x & 0xff)) +#define MSB(y) ((y >> 8) & 0xff) + + +#define STB0899_GETFIELD(bitf, val) ((val >> STB0899_OFFST_##bitf) & ((1 << STB0899_WIDTH_##bitf) - 1)) + + +#define STB0899_SETFIELD(mask, val, width, offset) (mask & (~(((1 << width) - 1) << \ + offset))) | ((val & \ + ((1 << width) - 1)) << offset) + +#define STB0899_SETFIELD_VAL(bitf, mask, val) (mask = (mask & (~(((1 << STB0899_WIDTH_##bitf) - 1) <<\ + STB0899_OFFST_##bitf))) | \ + (val << STB0899_OFFST_##bitf)) + + +enum stb0899_status { + NOAGC1 = 0, + AGC1OK, + NOTIMING, + ANALOGCARRIER, + TIMINGOK, + NOAGC2, + AGC2OK, + NOCARRIER, + CARRIEROK, + NODATA, + FALSELOCK, + DATAOK, + OUTOFRANGE, + RANGEOK, + DVBS2_DEMOD_LOCK, + DVBS2_DEMOD_NOLOCK, + DVBS2_FEC_LOCK, + DVBS2_FEC_NOLOCK +}; + +enum stb0899_modcod { + STB0899_DUMMY_PLF, + STB0899_QPSK_14, + STB0899_QPSK_13, + STB0899_QPSK_25, + STB0899_QPSK_12, + STB0899_QPSK_35, + STB0899_QPSK_23, + STB0899_QPSK_34, + STB0899_QPSK_45, + STB0899_QPSK_56, + STB0899_QPSK_89, + STB0899_QPSK_910, + STB0899_8PSK_35, + STB0899_8PSK_23, + STB0899_8PSK_34, + STB0899_8PSK_56, + STB0899_8PSK_89, + STB0899_8PSK_910, + STB0899_16APSK_23, + STB0899_16APSK_34, + STB0899_16APSK_45, + STB0899_16APSK_56, + STB0899_16APSK_89, + STB0899_16APSK_910, + STB0899_32APSK_34, + STB0899_32APSK_45, + STB0899_32APSK_56, + STB0899_32APSK_89, + STB0899_32APSK_910 +}; + +enum stb0899_frame { + STB0899_LONG_FRAME, + STB0899_SHORT_FRAME +}; + +enum stb0899_inversion { + IQ_SWAP_OFF = 0, + IQ_SWAP_ON, + IQ_SWAP_AUTO +}; + +enum stb0899_alpha { + RRC_20, + RRC_25, + RRC_35 +}; + +struct stb0899_tab { + s32 real; + s32 read; +}; + +enum stb0899_fec { + STB0899_FEC_1_2 = 13, + STB0899_FEC_2_3 = 18, + STB0899_FEC_3_4 = 21, + STB0899_FEC_5_6 = 24, + STB0899_FEC_6_7 = 25, + STB0899_FEC_7_8 = 26 +}; + +struct stb0899_params { + u32 freq; /* Frequency */ + u32 srate; /* Symbol rate */ + enum dvbfe_fec fecrate; +}; + +struct stb0899_internal { + u32 master_clk; + u32 freq; /* Demod internal Frequency */ + u32 srate; /* Demod internal Symbol rate */ + enum stb0899_fec fecrate; /* Demod internal FEC rate */ + u32 srch_range; /* Demod internal Search Range */ + u32 sub_range; /* Demod current sub range (Hz) */ + u32 tuner_step; /* Tuner step (Hz) */ + u32 tuner_offst; /* Relative offset to carrier (Hz) */ + u32 tuner_bw; /* Current bandwidth of the tuner (Hz) */ + + s32 mclk; /* Masterclock Divider factor (binary) */ + s32 rolloff; /* Current RollOff of the filter (x100) */ + + s16 derot_freq; /* Current derotator frequency (Hz) */ + s16 derot_percent; + + s16 direction; /* Current derotator search direction */ + s16 derot_step; /* Derotator step (binary value) */ + s16 t_timing; /* Timing loop time constant (ms) */ + s16 t_derot; /* Derotator time constant (ms) */ + s16 t_data; /* Data recovery time constant (ms) */ + s16 sub_dir; /* Direction of the next sub range */ + + s16 t_agc1; /* Agc1 time constant (ms) */ + s16 t_agc2; /* Agc2 time constant (ms) */ + + u32 lock; /* Demod internal lock state */ + enum stb0899_status status; /* Demod internal status */ + + /* DVB-S2 */ + s32 agc_gain; /* RF AGC Gain */ + s32 center_freq; /* Nominal carrier frequency */ + s32 av_frame_coarse; /* Coarse carrier freq search frames */ + s32 av_frame_fine; /* Fine carrier freq search frames */ + + s16 step_size; /* Carrier frequency search step size */ + + enum stb0899_alpha rrc_alpha; + enum stb0899_inversion inversion; + enum stb0899_modcod modcod; + u8 pilots; /* Pilots found */ + + enum stb0899_frame frame_length; + u8 v_status; /* VSTATUS */ + u8 err_ctrl; /* ERRCTRLn */ +}; + +struct stb0899_state { + struct i2c_adapter *i2c; + struct stb0899_config *config; + struct dvb_frontend frontend; + + u32 verbose; /* Cached module verbosity level */ + + struct stb0899_internal internal; /* Device internal parameters */ + + /* cached params from API */ + enum dvbfe_delsys delsys; + struct stb0899_params params; + + u32 rx_freq; /* DiSEqC 2.0 receiver freq */ + struct mutex search_lock; +}; +/* stb0899.c */ +extern int stb0899_read_reg(struct stb0899_state *state, + unsigned int reg); + +extern u32 _stb0899_read_s2reg(struct stb0899_state *state, + u32 stb0899_i2cdev, + u32 stb0899_base_addr, + u16 stb0899_reg_offset); + +extern int stb0899_read_regs(struct stb0899_state *state, + unsigned int reg, u8 *buf, + size_t count); + +extern int stb0899_write_regs(struct stb0899_state *state, + unsigned int reg, u8 *data, + size_t count); + +extern int stb0899_write_reg(struct stb0899_state *state, + unsigned int reg, + u8 data); + +extern int stb0899_write_s2reg(struct stb0899_state *state, + u32 stb0899_i2cdev, + u32 stb0899_base_addr, + u16 stb0899_reg_offset, + u32 stb0899_data); + + +#define STB0899_READ_S2REG(DEVICE, REG) (_stb0899_read_s2reg(state, DEVICE, STB0899_BASE_##REG, STB0899_OFF0_##REG)) +//#define STB0899_WRITE_S2REG(DEVICE, REG, DATA) (_stb0899_write_s2reg(state, DEVICE, STB0899_BASE_##REG, STB0899_OFF0_##REG, DATA)) + +/* stb0899_algo.c */ +extern enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state); +extern enum stb0899_status stb0899_dvbs2_algo(struct stb0899_state *state); +extern long stb0899_carr_width(struct stb0899_state *state); + +#endif //__STB0899_PRIV_H -- cgit v1.2.3-70-g09d2 From ecdec311806220d6e88e3ac52936cc30e1580810 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Mon, 24 Sep 2007 19:38:11 -0300 Subject: V4L/DVB (9401): Code Simplification Use an enumeration for I/Q Swap rather than an int, easier to spot the nasty ones Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/stb0899_drv.h | 10 +++++++++- drivers/media/dvb/frontends/stb0899_priv.h | 6 ------ drivers/media/dvb/ttpci/budget-av.c | 2 +- drivers/media/dvb/ttpci/budget-ci.c | 2 +- 4 files changed, 11 insertions(+), 9 deletions(-) (limited to 'drivers/media/dvb/frontends/stb0899_priv.h') diff --git a/drivers/media/dvb/frontends/stb0899_drv.h b/drivers/media/dvb/frontends/stb0899_drv.h index 52c2ce17f85..8cb320643f8 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.h +++ b/drivers/media/dvb/frontends/stb0899_drv.h @@ -44,6 +44,12 @@ struct stb0899_s2_reg { u32 data; }; +enum stb0899_inversion { + IQ_SWAP_OFF = 0, + IQ_SWAP_ON, + IQ_SWAP_AUTO +}; + struct stb0899_config { const struct stb0899_s1_reg *init_dev; const struct stb0899_s2_reg *init_s2_demod; @@ -51,6 +57,8 @@ struct stb0899_config { const struct stb0899_s2_reg *init_s2_fec; const struct stb0899_s1_reg *init_tst; + enum stb0899_inversion inversion; + u32 xtal_freq; u8 demod_address; @@ -65,7 +73,7 @@ struct stb0899_config { u8 data_fifo_mode; u8 out_rate_comp; u8 i2c_repeater; - int inversion; +// int inversion; u32 esno_ave; u32 esno_quant; diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h index 47e533dd417..73790b4e345 100644 --- a/drivers/media/dvb/frontends/stb0899_priv.h +++ b/drivers/media/dvb/frontends/stb0899_priv.h @@ -137,12 +137,6 @@ enum stb0899_frame { STB0899_SHORT_FRAME }; -enum stb0899_inversion { - IQ_SWAP_OFF = 0, - IQ_SWAP_ON, - IQ_SWAP_AUTO -}; - enum stb0899_alpha { RRC_20, RRC_25, diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index 9e7fab0e31e..1b9bbdb36b8 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -1451,7 +1451,7 @@ static struct stb0899_config knc1_dvbs2_config = { // .ts_pfbit_toggle = STB0899_MPEG_NORMAL, /* DirecTV, MPEG toggling seq */ .xtal_freq = 27000000, - .inversion = 1, + .inversion = IQ_SWAP_ON, /* 1 */ .esno_ave = KNC1_DVBS2_ESNO_AVE, .esno_quant = KNC1_DVBS2_ESNO_QUANT, diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 005c4596343..fc4cc491ab5 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c @@ -1658,7 +1658,7 @@ static struct stb0899_config tt3200_config = { .demod_address = 0x68, .xtal_freq = 27000000, - .inversion = 1, + .inversion = IQ_SWAP_ON, /* 1 */ .esno_ave = TT3200_DVBS2_ESNO_AVE, .esno_quant = TT3200_DVBS2_ESNO_QUANT, -- cgit v1.2.3-70-g09d2 From 85eabac439ff6b60775e3d6458702dcb6c479e05 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 25 Jan 2008 20:28:46 -0300 Subject: V4L/DVB (9453): stb0899: fix compilation warnings Cleanup/Optimization: * Fix compile warnings * The compile warnings helped to identify 2 unnecessary I/O operations Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/stb0899_algo.c | 8 ++------ drivers/media/dvb/frontends/stb0899_drv.c | 2 +- drivers/media/dvb/frontends/stb0899_priv.h | 2 +- 3 files changed, 4 insertions(+), 8 deletions(-) (limited to 'drivers/media/dvb/frontends/stb0899_priv.h') diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c index f1432cb2926..65bc032964b 100644 --- a/drivers/media/dvb/frontends/stb0899_algo.c +++ b/drivers/media/dvb/frontends/stb0899_algo.c @@ -199,9 +199,7 @@ static enum stb0899_status stb0899_check_tmg(struct stb0899_state *state) msleep(internal->t_timing); - reg = stb0899_read_reg(state, STB0899_RTF); - STB0899_SETFIELD_VAL(RTF_TIMING_LOOP_FREQ, reg, 0xf2); - stb0899_write_reg(state, STB0899_RTF, reg); + stb0899_write_reg(state, STB0899_RTF, 0xf2); reg = stb0899_read_reg(state, STB0899_TLIR); lock = STB0899_GETFIELD(TLIR_TMG_LOCK_IND, reg); timing = stb0899_read_reg(state, STB0899_RTF); @@ -603,9 +601,7 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state) cfr[0] = cfr[1] = 0; stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* RESET derotator frequency */ - reg = stb0899_read_reg(state, STB0899_RTF); - STB0899_SETFIELD_VAL(RTF_TIMING_LOOP_FREQ, reg, 0); - stb0899_write_reg(state, STB0899_RTF, reg); + stb0899_write_reg(state, STB0899_RTF, 0); reg = stb0899_read_reg(state, STB0899_CFD); STB0899_SETFIELD_VAL(CFD_ON, reg, 1); stb0899_write_reg(state, STB0899_CFD, reg); diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c index 2caa192a8e7..6e7db991274 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.c +++ b/drivers/media/dvb/frontends/stb0899_drv.c @@ -495,7 +495,7 @@ err: return status < 0 ? status : -EREMOTEIO; } -int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, size_t count) +int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, u32 count) { int ret; u8 buf[2 + count]; diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h index 73790b4e345..da7fddb4e6b 100644 --- a/drivers/media/dvb/frontends/stb0899_priv.h +++ b/drivers/media/dvb/frontends/stb0899_priv.h @@ -242,7 +242,7 @@ extern int stb0899_read_regs(struct stb0899_state *state, extern int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, - size_t count); + u32 count); extern int stb0899_write_reg(struct stb0899_state *state, unsigned int reg, -- cgit v1.2.3-70-g09d2 From 3d6a3bebda2093cf563266bbfa0f1f1b1ae8fd41 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 25 Jan 2008 20:39:16 -0300 Subject: V4L/DVB (9454): Fix a compile warning Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/stb0899_drv.c | 2 +- drivers/media/dvb/frontends/stb0899_priv.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'drivers/media/dvb/frontends/stb0899_priv.h') diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c index 6e7db991274..196a837f11c 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.c +++ b/drivers/media/dvb/frontends/stb0899_drv.c @@ -444,7 +444,7 @@ err: return status < 0 ? status : -EREMOTEIO; } -int stb0899_read_regs(struct stb0899_state *state, unsigned int reg, u8 *buf, size_t count) +int stb0899_read_regs(struct stb0899_state *state, unsigned int reg, u8 *buf, u32 count) { int status; diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h index da7fddb4e6b..f9b8f51446a 100644 --- a/drivers/media/dvb/frontends/stb0899_priv.h +++ b/drivers/media/dvb/frontends/stb0899_priv.h @@ -238,7 +238,7 @@ extern u32 _stb0899_read_s2reg(struct stb0899_state *state, extern int stb0899_read_regs(struct stb0899_state *state, unsigned int reg, u8 *buf, - size_t count); + u32 count); extern int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, -- cgit v1.2.3-70-g09d2 From b359325d1e4a67942626421ea1f203b41adc9712 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Fri, 25 Jan 2008 20:56:21 -0300 Subject: V4L/DVB (9455): Cleanup: remove some superfluous stuff and dead commented out code Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/stb0899_algo.c | 36 +++++------------------------- drivers/media/dvb/frontends/stb0899_priv.h | 1 - 2 files changed, 5 insertions(+), 32 deletions(-) (limited to 'drivers/media/dvb/frontends/stb0899_priv.h') diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c index 65bc032964b..b7752473f7a 100644 --- a/drivers/media/dvb/frontends/stb0899_algo.c +++ b/drivers/media/dvb/frontends/stb0899_algo.c @@ -73,20 +73,16 @@ u32 stb0899_get_srate(struct stb0899_state *state) */ static u32 stb0899_set_srate(struct stb0899_state *state, u32 master_clk, u32 srate) { - u32 tmp, tmp_up, srate_up; - u8 sfr_up[3], sfr[3]; + u32 tmp; + u8 sfr[3]; -// srate_up = srate; dprintk(state->verbose, FE_DEBUG, 1, "-->"); /* * in order to have the maximum precision, the symbol rate entered into * the chip is computed as the closest value of the "true value". * In this purpose, the symbol rate value is rounded (1 is added on the bit * below the LSB ) - */ -// srate_up += (srate_up * 3) / 100; - - /* + * * srate = (SFR * master_clk) >> 20 * <=> * SFR = srate << 20 / master_clk @@ -97,40 +93,19 @@ static u32 stb0899_set_srate(struct stb0899_state *state, u32 master_clk, u32 sr * stored as 20 bit number with an offset of 4 bit: * sfr = SFR << 4; */ -// tmp_up = stb0899_do_div((((u64)srate_up) << 21) + master_clk, 2 * master_clk); -// tmp_up <<= 4; tmp = stb0899_do_div((((u64)srate) << 21) + master_clk, 2 * master_clk); tmp <<= 4; -// sfr_up[0] = tmp_up >> 16; -// sfr_up[1] = tmp_up >> 8; -// sfr_up[2] = tmp_up; - sfr[0] = tmp >> 16; sfr[1] = tmp >> 8; sfr[2] = tmp; -// stb0899_write_regs(state, STB0899_SFRUPH, sfr_up, 3); stb0899_write_regs(state, STB0899_SFRH, sfr, 3); return srate; } -/* - * stb0899_calc_loop_time - * Compute the amount of time needed by the timing loop to lock - * SymbolRate: Symbol rate - * return: timing loop time constant (ms) - */ -static long stb0899_calc_loop_time(long srate) -{ - if (srate > 0) - return (100000 / (srate / 1000)); - else - return 0; -} - /* * stb0899_calc_derot_time * Compute the amount of time needed by the derotator to lock @@ -197,7 +172,7 @@ static enum stb0899_status stb0899_check_tmg(struct stb0899_state *state) u8 reg; s8 timing; - msleep(internal->t_timing); + msleep(internal->t_derot); stb0899_write_reg(state, STB0899_RTF, 0xf2); reg = stb0899_read_reg(state, STB0899_TLIR); @@ -574,7 +549,6 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state) /* Initial calculations */ internal->derot_step = internal->derot_percent * (params->srate / 1000L) / internal->mclk; /* DerotStep/1000 * Fsymbol */ - internal->t_timing = stb0899_calc_loop_time(params->srate); internal->t_derot = stb0899_calc_derot_time(params->srate); internal->t_data = 500; @@ -617,7 +591,7 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state) if (state->config->tuner_get_frequency) state->config->tuner_get_frequency(&state->frontend, &internal->freq); - msleep(internal->t_agc1 + internal->t_agc2 + internal->t_timing); /* AGC1, AGC2 and timing loop */ + msleep(internal->t_agc1 + internal->t_agc2 + internal->t_derot); /* AGC1, AGC2 and timing loop */ dprintk(state->verbose, FE_DEBUG, 1, "current derot freq=%d", internal->derot_freq); internal->status = AGC1OK; diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h index f9b8f51446a..8a7c4ee087d 100644 --- a/drivers/media/dvb/frontends/stb0899_priv.h +++ b/drivers/media/dvb/frontends/stb0899_priv.h @@ -182,7 +182,6 @@ struct stb0899_internal { s16 direction; /* Current derotator search direction */ s16 derot_step; /* Derotator step (binary value) */ - s16 t_timing; /* Timing loop time constant (ms) */ s16 t_derot; /* Derotator time constant (ms) */ s16 t_data; /* Data recovery time constant (ms) */ s16 sub_dir; /* Direction of the next sub range */ -- cgit v1.2.3-70-g09d2 From 40e8ce3dba8e9437ed48c88c268615dc0a4bebb2 Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Sun, 3 Feb 2008 19:37:02 -0300 Subject: V4L/DVB (9457): Optimization, Fix a Bug * cut down some I/O operations by disabling "disable gate" * budget_av was left with the gate open, thereby more susceptible to RF interference due to I/O operations Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/stb0899_algo.c | 13 +++++++++++++ drivers/media/dvb/frontends/stb0899_drv.c | 22 ++++++++++++++++++++-- drivers/media/dvb/frontends/stb0899_priv.h | 2 ++ drivers/media/dvb/frontends/stb6100.c | 17 ----------------- drivers/media/dvb/frontends/tda8261.c | 8 -------- drivers/media/dvb/ttpci/budget-av.c | 2 +- drivers/media/dvb/ttpci/budget-ci.c | 2 +- 7 files changed, 37 insertions(+), 29 deletions(-) (limited to 'drivers/media/dvb/frontends/stb0899_priv.h') diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c index b7752473f7a..3cf9719204f 100644 --- a/drivers/media/dvb/frontends/stb0899_algo.c +++ b/drivers/media/dvb/frontends/stb0899_algo.c @@ -583,6 +583,9 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state) internal->derot_freq = 0; internal->status = NOAGC1; + /* enable tuner I/O */ + stb0899_i2c_gate_ctrl(&state->frontend, 1); + /* Move tuner to frequency */ dprintk(state->verbose, FE_DEBUG, 1, "Tuner set frequency"); if (state->config->tuner_set_frequency) @@ -598,6 +601,10 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state) /* There is signal in the band */ if (config->tuner_get_bandwidth) config->tuner_get_bandwidth(&state->frontend, &bandwidth); + + /* disable tuner I/O */ + stb0899_i2c_gate_ctrl(&state->frontend, 0); + if (params->srate <= bandwidth / 2) stb0899_search_tmg(state); /* For low rates (SCPC) */ else @@ -1325,12 +1332,18 @@ enum stb0899_status stb0899_dvbs2_algo(struct stb0899_state *state) STB0899_SETFIELD_VAL(FRESRS, reg, 1); stb0899_write_reg(state, STB0899_TSTRES, reg); + /* enable tuner I/O */ + stb0899_i2c_gate_ctrl(&state->frontend, 1); + /* Move tuner to frequency */ if (state->config->tuner_set_frequency) state->config->tuner_set_frequency(&state->frontend, internal->freq); if (state->config->tuner_get_frequency) state->config->tuner_get_frequency(&state->frontend, &internal->freq); + /* disable tuner I/O */ + stb0899_i2c_gate_ctrl(&state->frontend, 0); + /* Set IF AGC to acquisition */ reg = STB0899_READ_S2REG(STB0899_S2DEMOD, IF_AGC_CNTRL); STB0899_SETFIELD_VAL(IF_LOOP_GAIN, reg, 4); diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c index 196a837f11c..333b983b04a 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.c +++ b/drivers/media/dvb/frontends/stb0899_drv.c @@ -1241,7 +1241,7 @@ static int stb0899_set_tone(struct dvb_frontend *fe, fe_sec_tone_mode_t tone) return 0; } -static int stb0899_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) +int stb0899_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) { int i2c_stat; struct stb0899_state *state = fe->demodulator_priv; @@ -1255,10 +1255,15 @@ static int stb0899_i2c_gate_ctrl(struct dvb_frontend *fe, int enable) i2c_stat |= STB0899_I2CTON; if (stb0899_write_reg(state, STB0899_I2CRPT, i2c_stat) < 0) goto err; + } else { + dprintk(state->verbose, FE_DEBUG, 1, "Disabling I2C Repeater ..."); + i2c_stat &= ~STB0899_I2CTON; + if (stb0899_write_reg(state, STB0899_I2CRPT, i2c_stat) < 0) + goto err; } return 0; err: - dprintk(state->verbose, FE_ERROR, 1, "I2C Repeater enable failed"); + dprintk(state->verbose, FE_ERROR, 1, "I2C Repeater control failed"); return -EREMOTEIO; } @@ -1592,10 +1597,17 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa internal->derot_percent = 30; /* What to do for tuners having no bandwidth setup ? */ + /* enable tuner I/O */ + stb0899_i2c_gate_ctrl(&state->frontend, 1); + if (state->config->tuner_set_bandwidth) state->config->tuner_set_bandwidth(fe, (13 * (stb0899_carr_width(state) + SearchRange)) / 10); if (state->config->tuner_get_bandwidth) state->config->tuner_get_bandwidth(fe, &internal->tuner_bw); + + /* disable tuner I/O */ + stb0899_i2c_gate_ctrl(&state->frontend, 0); + /* Set DVB-S1 AGC */ stb0899_write_reg(state, STB0899_AGCRFCFG, 0x11); @@ -1624,11 +1636,17 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa internal->srate = i_params->srate; internal->srch_range = SearchRange; + /* enable tuner I/O */ + stb0899_i2c_gate_ctrl(&state->frontend, 1); + if (state->config->tuner_set_bandwidth) state->config->tuner_set_bandwidth(fe, (stb0899_carr_width(state) + SearchRange)); if (state->config->tuner_get_bandwidth) state->config->tuner_get_bandwidth(fe, &internal->tuner_bw); + /* disable tuner I/O */ + stb0899_i2c_gate_ctrl(&state->frontend, 0); + // pParams->SpectralInv = pSearch->IQ_Inversion; /* Set DVB-S2 AGC */ diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h index 8a7c4ee087d..755269979d1 100644 --- a/drivers/media/dvb/frontends/stb0899_priv.h +++ b/drivers/media/dvb/frontends/stb0899_priv.h @@ -253,6 +253,8 @@ extern int stb0899_write_s2reg(struct stb0899_state *state, u16 stb0899_reg_offset, u32 stb0899_data); +extern int stb0899_i2c_gate_ctrl(struct dvb_frontend *fe, int enable); + #define STB0899_READ_S2REG(DEVICE, REG) (_stb0899_read_s2reg(state, DEVICE, STB0899_BASE_##REG, STB0899_OFF0_##REG)) //#define STB0899_WRITE_S2REG(DEVICE, REG, DATA) (_stb0899_write_s2reg(state, DEVICE, STB0899_BASE_##REG, STB0899_OFF0_##REG, DATA)) diff --git a/drivers/media/dvb/frontends/stb6100.c b/drivers/media/dvb/frontends/stb6100.c index c8fdc1e99df..f404a4d0fb1 100644 --- a/drivers/media/dvb/frontends/stb6100.c +++ b/drivers/media/dvb/frontends/stb6100.c @@ -134,16 +134,7 @@ static int stb6100_read_regs(struct stb6100_state *state, u8 regs[]) .len = STB6100_NUMREGS }; - if (state->frontend->ops.i2c_gate_ctrl) - if ((rc = state->frontend->ops.i2c_gate_ctrl(state->frontend, 1)) < 0) - return rc; - rc = i2c_transfer(state->i2c, &msg, 1); - if (state->frontend->ops.i2c_gate_ctrl) { - int rc2; - if ((rc2 = state->frontend->ops.i2c_gate_ctrl(state->frontend, 0)) < 0) - return rc2; - } if (unlikely(rc != 1)) { dprintk(verbose, FE_ERROR, 1, "Read (0x%x) err, rc=[%d]", state->config->tuner_address, rc); @@ -200,15 +191,7 @@ static int stb6100_write_reg_range(struct stb6100_state *state, u8 buf[], int st for (i = 0; i < len; i++) dprintk(verbose, FE_DEBUG, 1, " %s: 0x%02x", stb6100_regnames[start + i], buf[i]); } - if (state->frontend->ops.i2c_gate_ctrl) - if ((rc = state->frontend->ops.i2c_gate_ctrl(state->frontend, 1)) < 0) - return rc; rc = i2c_transfer(state->i2c, &msg, 1); - if (state->frontend->ops.i2c_gate_ctrl) { - int rc2; - if ((rc2 = state->frontend->ops.i2c_gate_ctrl(state->frontend, 0)) < 0) - return rc2; - } if (unlikely(rc != 1)) { dprintk(verbose, FE_ERROR, 1, "(0x%x) write err [%d:%d], rc=[%d]", (unsigned int)state->config->tuner_address, start, len, rc); diff --git a/drivers/media/dvb/frontends/tda8261.c b/drivers/media/dvb/frontends/tda8261.c index 16e833fdc77..b6d17779910 100644 --- a/drivers/media/dvb/frontends/tda8261.c +++ b/drivers/media/dvb/frontends/tda8261.c @@ -37,14 +37,10 @@ struct tda8261_state { static int tda8261_read(struct tda8261_state *state, u8 *buf) { - struct dvb_frontend *fe = state->fe; const struct tda8261_config *config = state->config; int err = 0; struct i2c_msg msg = { .addr = config->addr, .flags = I2C_M_RD,.buf = buf, .len = 2 }; - if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 1); - if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) printk("%s: read error, err=%d\n", __func__, err); @@ -53,14 +49,10 @@ static int tda8261_read(struct tda8261_state *state, u8 *buf) static int tda8261_write(struct tda8261_state *state, u8 *buf) { - struct dvb_frontend *fe = state->fe; const struct tda8261_config *config = state->config; int err = 0; struct i2c_msg msg = { .addr = config->addr, .flags = 0, .buf = buf, .len = 4 }; - if (fe->ops.i2c_gate_ctrl) - fe->ops.i2c_gate_ctrl(fe, 1); - if ((err = i2c_transfer(state->i2c, &msg, 1)) != 1) printk("%s: write error, err=%d\n", __func__, err); diff --git a/drivers/media/dvb/ttpci/budget-av.c b/drivers/media/dvb/ttpci/budget-av.c index d2b5cad8e06..67a14c580a7 100644 --- a/drivers/media/dvb/ttpci/budget-av.c +++ b/drivers/media/dvb/ttpci/budget-av.c @@ -919,7 +919,7 @@ static const struct stb0899_s1_reg knc1_stb0899_s1_init_1[] = { { STB0899_IRQMSK_0 , 0xff }, { STB0899_IRQCFG , 0x00 }, { STB0899_I2CCFG , 0x88 }, - { STB0899_I2CRPT , 0x5c }, + { STB0899_I2CRPT , 0x58 }, /* Repeater=8, Stop=disabled */ { STB0899_IOPVALUE5 , 0x00 }, { STB0899_IOPVALUE4 , 0x20 }, { STB0899_IOPVALUE3 , 0xc9 }, diff --git a/drivers/media/dvb/ttpci/budget-ci.c b/drivers/media/dvb/ttpci/budget-ci.c index 5b6dbcc764c..9cb8ff59e61 100644 --- a/drivers/media/dvb/ttpci/budget-ci.c +++ b/drivers/media/dvb/ttpci/budget-ci.c @@ -1108,7 +1108,7 @@ static const struct stb0899_s1_reg tt3200_stb0899_s1_init_1[] = { { STB0899_IRQMSK_0 , 0xff }, { STB0899_IRQCFG , 0x00 }, { STB0899_I2CCFG , 0x88 }, - { STB0899_I2CRPT , 0x48 }, /* 12k Pullup */ + { STB0899_I2CRPT , 0x48 }, /* 12k Pullup, Repeater=16, Stop=disabled */ { STB0899_IOPVALUE5 , 0x00 }, { STB0899_IOPVALUE4 , 0x20 }, { STB0899_IOPVALUE3 , 0xc9 }, -- cgit v1.2.3-70-g09d2 From c615a27a533b6f6de6143d4d58cfa0abfdb6970d Mon Sep 17 00:00:00 2001 From: Reinhard Nissl Date: Wed, 9 Jul 2008 15:33:38 -0300 Subject: V4L/DVB (9467): Fix runtime verbosity Signed-off-by: Reinhard Nissl Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/stb0899_drv.c | 132 ++++++++++++++--------------- drivers/media/dvb/frontends/stb0899_priv.h | 12 +-- 2 files changed, 72 insertions(+), 72 deletions(-) (limited to 'drivers/media/dvb/frontends/stb0899_priv.h') diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c index bdbb60c9e4e..cf787f5fc00 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.c +++ b/drivers/media/dvb/frontends/stb0899_drv.c @@ -31,7 +31,7 @@ #include "stb0899_priv.h" #include "stb0899_reg.h" -static unsigned int verbose = 1; +static unsigned int verbose = 0;//1; module_param(verbose, int, 0644); /* C/N in dB/10, NIRM/NIRL */ @@ -241,14 +241,14 @@ int _stb0899_read_reg(struct stb0899_state *state, unsigned int reg) ret = i2c_transfer(state->i2c, msg, 2); if (ret != 2) { if (ret != -ERESTARTSYS) - dprintk(verbose, FE_ERROR, 1, + dprintk(state->verbose, FE_ERROR, 1, "Read error, Reg=[0x%02x], Status=%d", reg, ret); return ret < 0 ? ret : -EREMOTEIO; } - if (unlikely(verbose >= FE_DEBUGREG)) - dprintk(verbose, FE_ERROR, 1, "Reg=[0x%02x], data=%02x", + if (unlikely(*state->verbose >= FE_DEBUGREG)) + dprintk(state->verbose, FE_ERROR, 1, "Reg=[0x%02x], data=%02x", reg, buf); return (unsigned int)buf; @@ -361,7 +361,7 @@ u32 _stb0899_read_s2reg(struct stb0899_state *state, } data = MAKEWORD32(buf[3], buf[2], buf[1], buf[0]); - if (unlikely(state->verbose >= FE_DEBUGREG)) + if (unlikely(*state->verbose >= FE_DEBUGREG)) printk(KERN_DEBUG "%s Device=[0x%04x], Base address=[0x%08x], Offset=[0x%04x], Data=[0x%08x]\n", __func__, stb0899_i2cdev, stb0899_base_addr, stb0899_reg_offset, data); @@ -418,7 +418,7 @@ int stb0899_write_s2reg(struct stb0899_state *state, buf_1[4] = GETBYTE(stb0899_data, BYTE2); buf_1[5] = GETBYTE(stb0899_data, BYTE3); - if (unlikely(state->verbose >= FE_DEBUGREG)) + if (unlikely(*state->verbose >= FE_DEBUGREG)) printk(KERN_DEBUG "%s Device=[0x%04x], Base Address=[0x%08x], Offset=[0x%04x], Data=[0x%08x]\n", __func__, stb0899_i2cdev, stb0899_base_addr, stb0899_reg_offset, stb0899_data); @@ -480,7 +480,7 @@ int stb0899_read_regs(struct stb0899_state *state, unsigned int reg, u8 *buf, u3 (((reg & 0xff00) == 0xf200) || ((reg & 0xff00) == 0xf600))) _stb0899_read_reg(state, (reg | 0x00ff)); - if (unlikely(state->verbose >= FE_DEBUGREG)) { + if (unlikely(*state->verbose >= FE_DEBUGREG)) { int i; printk(KERN_DEBUG "%s [0x%04x]:", __func__, reg); @@ -510,7 +510,7 @@ int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, buf[1] = reg & 0xff; memcpy(&buf[2], data, count); - if (unlikely(state->verbose >= FE_DEBUGREG)) { + if (unlikely(*state->verbose >= FE_DEBUGREG)) { int i; printk(KERN_DEBUG "%s [0x%04x]:", __func__, reg); @@ -530,7 +530,7 @@ int stb0899_write_regs(struct stb0899_state *state, unsigned int reg, u8 *data, if (ret != 1) { if (ret != -ERESTARTSYS) - dprintk(verbose, FE_ERROR, 1, "Reg=[0x%04x], Data=[0x%02x ...], Count=%u, Status=%d", + dprintk(state->verbose, FE_ERROR, 1, "Reg=[0x%04x], Data=[0x%02x ...], Count=%u, Status=%d", reg, data[0], count, ret); return ret < 0 ? ret : -EREMOTEIO; } @@ -554,7 +554,7 @@ static u32 stb0899_get_mclk(struct stb0899_state *state) div = stb0899_read_reg(state, STB0899_NCOARSE); mclk = (div + 1) * state->config->xtal_freq / 6; - dprintk(verbose, FE_DEBUG, 1, "div=%d, mclk=%d", div, mclk); + dprintk(state->verbose, FE_DEBUG, 1, "div=%d, mclk=%d", div, mclk); return mclk; } @@ -570,14 +570,14 @@ static void stb0899_set_mclk(struct stb0899_state *state, u32 Mclk) struct stb0899_internal *internal = &state->internal; u8 mdiv = 0; - dprintk(verbose, FE_DEBUG, 1, "state->config=%p", state->config); + dprintk(state->verbose, FE_DEBUG, 1, "state->config=%p", state->config); mdiv = ((6 * Mclk) / state->config->xtal_freq) - 1; - dprintk(verbose, FE_DEBUG, 1, "mdiv=%d", mdiv); + dprintk(state->verbose, FE_DEBUG, 1, "mdiv=%d", mdiv); stb0899_write_reg(state, STB0899_NCOARSE, mdiv); internal->master_clk = stb0899_get_mclk(state); - dprintk(verbose, FE_DEBUG, 1, "MasterCLOCK=%d", internal->master_clk); + dprintk(state->verbose, FE_DEBUG, 1, "MasterCLOCK=%d", internal->master_clk); } static int stb0899_postproc(struct stb0899_state *state, u8 ctl, int enable) @@ -606,7 +606,7 @@ static void stb0899_release(struct dvb_frontend *fe) { struct stb0899_state *state = fe->demodulator_priv; - dprintk(verbose, FE_DEBUG, 1, "Release Frontend"); + dprintk(state->verbose, FE_DEBUG, 1, "Release Frontend"); /* post process event */ stb0899_postproc(state, STB0899_POSTPROC_GPIO_POWER, 0); kfree(state); @@ -683,7 +683,7 @@ static int stb0899_wait_diseqc_fifo_empty(struct stb0899_state *state, int timeo if (!STB0899_GETFIELD(FIFOFULL, reg)) break; if ((jiffies - start) > timeout) { - dprintk(verbose, FE_ERROR, 1, "timed out !!"); + dprintk(state->verbose, FE_ERROR, 1, "timed out !!"); return -ETIMEDOUT; } } @@ -725,7 +725,7 @@ static int stb0899_wait_diseqc_rxidle(struct stb0899_state *state, int timeout) while (!STB0899_GETFIELD(RXEND, reg)) { reg = stb0899_read_reg(state, STB0899_DISRX_ST0); if (jiffies - start > timeout) { - dprintk(verbose, FE_ERROR, 1, "timed out!!"); + dprintk(state->verbose, FE_ERROR, 1, "timed out!!"); return -ETIMEDOUT; } msleep(10); @@ -774,7 +774,7 @@ static int stb0899_wait_diseqc_txidle(struct stb0899_state *state, int timeout) while (!STB0899_GETFIELD(TXIDLE, reg)) { reg = stb0899_read_reg(state, STB0899_DISSTATUS); if (jiffies - start > timeout) { - dprintk(verbose, FE_ERROR, 1, "timed out!!"); + dprintk(state->verbose, FE_ERROR, 1, "timed out!!"); return -ETIMEDOUT; } msleep(10); @@ -862,7 +862,7 @@ static int stb0899_sleep(struct dvb_frontend *fe) struct stb0899_state *state = fe->demodulator_priv; u8 reg; - dprintk(verbose, FE_DEBUG, 1, "Going to Sleep .. (Really tired .. :-))"); + dprintk(state->verbose, FE_DEBUG, 1, "Going to Sleep .. (Really tired .. :-))"); /* post process event */ stb0899_postproc(state, STB0899_POSTPROC_GPIO_POWER, 0); @@ -894,15 +894,15 @@ static int stb0899_init(struct dvb_frontend *fe) struct stb0899_state *state = fe->demodulator_priv; struct stb0899_config *config = state->config; - dprintk(verbose, FE_DEBUG, 1, "Initializing STB0899 ... "); + dprintk(state->verbose, FE_DEBUG, 1, "Initializing STB0899 ... "); // mutex_init(&state->search_lock); /* init device */ - dprintk(verbose, FE_DEBUG, 1, "init device"); + dprintk(state->verbose, FE_DEBUG, 1, "init device"); for (i = 0; config->init_dev[i].address != 0xffff; i++) stb0899_write_reg(state, config->init_dev[i].address, config->init_dev[i].data); - dprintk(verbose, FE_DEBUG, 1, "init S2 demod"); + dprintk(state->verbose, FE_DEBUG, 1, "init S2 demod"); /* init S2 demod */ for (i = 0; config->init_s2_demod[i].offset != 0xffff; i++) stb0899_write_s2reg(state, STB0899_S2DEMOD, @@ -910,12 +910,12 @@ static int stb0899_init(struct dvb_frontend *fe) config->init_s2_demod[i].offset, config->init_s2_demod[i].data); - dprintk(verbose, FE_DEBUG, 1, "init S1 demod"); + dprintk(state->verbose, FE_DEBUG, 1, "init S1 demod"); /* init S1 demod */ for (i = 0; config->init_s1_demod[i].address != 0xffff; i++) stb0899_write_reg(state, config->init_s1_demod[i].address, config->init_s1_demod[i].data); - dprintk(verbose, FE_DEBUG, 1, "init S2 FEC"); + dprintk(state->verbose, FE_DEBUG, 1, "init S2 FEC"); /* init S2 fec */ for (i = 0; config->init_s2_fec[i].offset != 0xffff; i++) stb0899_write_s2reg(state, STB0899_S2FEC, @@ -923,7 +923,7 @@ static int stb0899_init(struct dvb_frontend *fe) config->init_s2_fec[i].offset, config->init_s2_fec[i].data); - dprintk(verbose, FE_DEBUG, 1, "init TST"); + dprintk(state->verbose, FE_DEBUG, 1, "init TST"); /* init test */ for (i = 0; config->init_tst[i].address != 0xffff; i++) stb0899_write_reg(state, config->init_tst[i].address, config->init_tst[i].data); @@ -979,7 +979,7 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength) *strength = stb0899_table_lookup(stb0899_dvbsrf_tab, ARRAY_SIZE(stb0899_dvbsrf_tab) - 1, val); *strength += 750; - dprintk(verbose, FE_DEBUG, 1, "AGCIQVALUE = 0x%02x, C = %d * 0.1 dBm", + dprintk(state->verbose, FE_DEBUG, 1, "AGCIQVALUE = 0x%02x, C = %d * 0.1 dBm", val & 0xff, *strength); } } @@ -991,12 +991,12 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength) *strength = stb0899_table_lookup(stb0899_dvbs2rf_tab, ARRAY_SIZE(stb0899_dvbs2rf_tab) - 1, val); *strength += 750; - dprintk(verbose, FE_DEBUG, 1, "IF_AGC_GAIN = 0x%04x, C = %d * 0.1 dBm", + dprintk(state->verbose, FE_DEBUG, 1, "IF_AGC_GAIN = 0x%04x, C = %d * 0.1 dBm", val & 0x3fff, *strength); } break; default: - dprintk(verbose, FE_DEBUG, 1, "Unsupported delivery system"); + dprintk(state->verbose, FE_DEBUG, 1, "Unsupported delivery system"); return -EINVAL; } @@ -1023,7 +1023,7 @@ static int stb0899_read_snr(struct dvb_frontend *fe, u16 *snr) val = MAKEWORD16(buf[0], buf[1]); *snr = stb0899_table_lookup(stb0899_cn_tab, ARRAY_SIZE(stb0899_cn_tab) - 1, val); - dprintk(verbose, FE_DEBUG, 1, "NIR = 0x%02x%02x = %u, C/N = %d * 0.1 dBm\n", + dprintk(state->verbose, FE_DEBUG, 1, "NIR = 0x%02x%02x = %u, C/N = %d * 0.1 dBm\n", buf[0], buf[1], val, *snr); } } @@ -1047,12 +1047,12 @@ static int stb0899_read_snr(struct dvb_frontend *fe, u16 *snr) val = (quantn - estn) / 10; } *snr = val; - dprintk(verbose, FE_DEBUG, 1, "Es/N0 quant = %d (%d) estimate = %u (%d), C/N = %d * 0.1 dBm", + dprintk(state->verbose, FE_DEBUG, 1, "Es/N0 quant = %d (%d) estimate = %u (%d), C/N = %d * 0.1 dBm", quant, quantn, est, estn, val); } break; default: - dprintk(verbose, FE_DEBUG, 1, "Unsupported delivery system"); + dprintk(state->verbose, FE_DEBUG, 1, "Unsupported delivery system"); return -EINVAL; } @@ -1118,7 +1118,7 @@ static int stb0899_read_status(struct dvb_frontend *fe, enum fe_status *status) } break; default: - dprintk(verbose, FE_DEBUG, 1, "Unsupported delivery system"); + dprintk(state->verbose, FE_DEBUG, 1, "Unsupported delivery system"); return -EINVAL; } return 0; @@ -1177,7 +1177,7 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber) } break; default: - dprintk(verbose, FE_DEBUG, 1, "Unsupported delivery system"); + dprintk(state->verbose, FE_DEBUG, 1, "Unsupported delivery system"); return -EINVAL; } @@ -1369,26 +1369,26 @@ static int stb0899_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info) { struct stb0899_state *state = fe->demodulator_priv; - dprintk(verbose, FE_DEBUG, 1, "Get Info"); + dprintk(state->verbose, FE_DEBUG, 1, "Get Info"); switch (state->delsys) { case DVBFE_DELSYS_DVBS: - dprintk(verbose, FE_ERROR, 1, "Querying DVB-S info"); + dprintk(state->verbose, FE_ERROR, 1, "Querying DVB-S info"); memcpy(fe_info, &dvbs_info, sizeof (struct dvbfe_info)); break; case DVBFE_DELSYS_DSS: - dprintk(verbose, FE_ERROR, 1, "Querying DSS info"); + dprintk(state->verbose, FE_ERROR, 1, "Querying DSS info"); memcpy(fe_info, &dss_info, sizeof (struct dvbfe_info)); break; case DVBFE_DELSYS_DVBS2: - dprintk(verbose, FE_ERROR, 1, "Querying DVB-S2 info"); + dprintk(state->verbose, FE_ERROR, 1, "Querying DVB-S2 info"); memcpy(fe_info, &dvbs2_info, sizeof (struct dvbfe_info)); break; default: - dprintk(verbose, FE_ERROR, 1, "Unsupported delivery system"); + dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system"); return -EINVAL; } - dprintk(verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys); + dprintk(state->verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys); return 0; } @@ -1410,7 +1410,7 @@ static void stb0899_set_delivery(struct stb0899_state *state) switch (state->delsys) { case DVBFE_DELSYS_DVBS: - dprintk(verbose, FE_DEBUG, 1, "Delivery System -- DVB-S"); + dprintk(state->verbose, FE_DEBUG, 1, "Delivery System -- DVB-S"); /* FECM/Viterbi ON */ reg = stb0899_read_reg(state, STB0899_FECM); STB0899_SETFIELD_VAL(FECM_RSVD0, reg, 0); @@ -1493,7 +1493,7 @@ static void stb0899_set_delivery(struct stb0899_state *state) STB0899_SETFIELD_VAL(STOP_CKS2DMD108, stop_clk[1], 1); break; default: - dprintk(verbose, FE_ERROR, 1, "Unsupported delivery system"); + dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system"); break; } STB0899_SETFIELD_VAL(STOP_CKADCI108, stop_clk[0], 0); @@ -1537,28 +1537,28 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa i_params->freq = params->frequency; switch (state->delsys) { case DVBFE_DELSYS_DVBS: - dprintk(verbose, FE_ERROR, 1, "set DVB-S params"); + dprintk(state->verbose, FE_ERROR, 1, "set DVB-S params"); i_params->srate = params->delsys.dvbs.symbol_rate; break; case DVBFE_DELSYS_DSS: - dprintk(verbose, FE_ERROR, 1, "set DSS params"); + dprintk(state->verbose, FE_ERROR, 1, "set DSS params"); i_params->srate = params->delsys.dss.symbol_rate; break; case DVBFE_DELSYS_DVBS2: - dprintk(verbose, FE_ERROR, 1, "set DVB-S2 params"); + dprintk(state->verbose, FE_ERROR, 1, "set DVB-S2 params"); i_params->srate = params->delsys.dvbs2.symbol_rate; break; default: - dprintk(verbose, FE_ERROR, 1, "Unsupported delivery system"); + dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system"); return -EINVAL; } - dprintk(verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys); + dprintk(state->verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys); SearchRange = 10000000; - dprintk(verbose, FE_DEBUG, 1, "Frequency=%d, Srate=%d", i_params->freq, i_params->srate); + dprintk(state->verbose, FE_DEBUG, 1, "Frequency=%d, Srate=%d", i_params->freq, i_params->srate); /* checking Search Range is meaningless for a fixed 3 Mhz */ if (INRANGE(i_params->srate, 1000000, 45000000)) { - dprintk(verbose, FE_DEBUG, 1, "Parameters IN RANGE"); + dprintk(state->verbose, FE_DEBUG, 1, "Parameters IN RANGE"); stb0899_set_delivery(state); if (state->config->tuner_set_rfsiggain) { @@ -1579,7 +1579,7 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa switch (state->delsys) { case DVBFE_DELSYS_DVBS: case DVBFE_DELSYS_DSS: - dprintk(verbose, FE_DEBUG, 1, "DVB-S delivery system"); + dprintk(state->verbose, FE_DEBUG, 1, "DVB-S delivery system"); internal->freq = i_params->freq; internal->srate = i_params->srate; /* @@ -1607,17 +1607,17 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa stb0899_write_reg(state, STB0899_AGCRFCFG, 0x11); /* Run the search algorithm */ - dprintk(verbose, FE_DEBUG, 1, "running DVB-S search algo .."); + dprintk(state->verbose, FE_DEBUG, 1, "running DVB-S search algo .."); if (stb0899_dvbs_algo(state) == RANGEOK) { internal->lock = 1; - dprintk(verbose, FE_DEBUG, 1, + dprintk(state->verbose, FE_DEBUG, 1, "-------------------------------------> DVB-S LOCK !"); // stb0899_write_reg(state, STB0899_ERRCTRL1, 0x3d); /* Viterbi Errors */ // internal->v_status = stb0899_read_reg(state, STB0899_VSTATUS); // internal->err_ctrl = stb0899_read_reg(state, STB0899_ERRCTRL1); -// dprintk(verbose, FE_DEBUG, 1, "VSTATUS=0x%02x", internal->v_status); -// dprintk(verbose, FE_DEBUG, 1, "ERR_CTRL=0x%02x", internal->err_ctrl); +// dprintk(state->verbose, FE_DEBUG, 1, "VSTATUS=0x%02x", internal->v_status); +// dprintk(state->verbose, FE_DEBUG, 1, "ERR_CTRL=0x%02x", internal->err_ctrl); return DVBFE_ALGO_SEARCH_SUCCESS; } else { @@ -1651,10 +1651,10 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa stb0899_set_iterations(state); /* Run the search algorithm */ - dprintk(verbose, FE_DEBUG, 1, "running DVB-S2 search algo .."); + dprintk(state->verbose, FE_DEBUG, 1, "running DVB-S2 search algo .."); if (stb0899_dvbs2_algo(state) == DVBS2_FEC_LOCK) { internal->lock = 1; - dprintk(verbose, FE_DEBUG, 1, + dprintk(state->verbose, FE_DEBUG, 1, "-------------------------------------> DVB-S2 LOCK !"); // stb0899_write_reg(state, STB0899_ERRCTRL1, 0xb6); /* Packet Errors */ @@ -1669,7 +1669,7 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa } break; default: - dprintk(verbose, FE_ERROR, 1, "Unsupported delivery system"); + dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system"); return DVBFE_ALGO_SEARCH_INVALID; } } @@ -1682,12 +1682,12 @@ static enum stb0899_status stb0899_track_carrier(struct stb0899_state *state) u8 reg; reg = stb0899_read_reg(state, STB0899_DSTATUS); - dprintk(verbose, FE_DEBUG, 1, "--------------------> STB0899_DSTATUS=[0x%02x]", reg); + dprintk(state->verbose, FE_DEBUG, 1, "--------------------> STB0899_DSTATUS=[0x%02x]", reg); if (STB0899_GETFIELD(CARRIER_FOUND, reg)) { - dprintk(verbose, FE_DEBUG, 1, "-------------> CARRIEROK !"); + dprintk(state->verbose, FE_DEBUG, 1, "-------------> CARRIEROK !"); return CARRIEROK; } else { - dprintk(verbose, FE_DEBUG, 1, "-------------> NOCARRIER !"); + dprintk(state->verbose, FE_DEBUG, 1, "-------------> NOCARRIER !"); return NOCARRIER; } @@ -1699,12 +1699,12 @@ static enum stb0899_status stb0899_get_ifagc(struct stb0899_state *state) u8 reg; reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STATUS); - dprintk(verbose, FE_DEBUG, 1, "DMD_STATUS=[0x%02x]", reg); + dprintk(state->verbose, FE_DEBUG, 1, "DMD_STATUS=[0x%02x]", reg); if (STB0899_GETFIELD(IF_AGC_LOCK, reg)) { - dprintk(verbose, FE_DEBUG, 1, "------------->IF AGC LOCKED !"); + dprintk(state->verbose, FE_DEBUG, 1, "------------->IF AGC LOCKED !"); return AGC1OK; } else { - dprintk(verbose, FE_DEBUG, 1, "------------->IF AGC LOCK LOST !"); + dprintk(state->verbose, FE_DEBUG, 1, "------------->IF AGC LOCK LOST !"); return NOAGC1; } @@ -1904,21 +1904,21 @@ static int stb0899_get_params(struct dvb_frontend *fe, struct dvbfe_params *para params->delivery = state->delsys; switch (state->delsys) { case DVBFE_DELSYS_DVBS: - dprintk(verbose, FE_DEBUG, 1, "Get DVB-S params"); + dprintk(state->verbose, FE_DEBUG, 1, "Get DVB-S params"); params->delsys.dvbs.symbol_rate = internal->srate; params->delsys.dvbs.modulation = DVBFE_MOD_QPSK; break; case DVBFE_DELSYS_DSS: - dprintk(verbose, FE_DEBUG, 1, "Get DSS params"); + dprintk(state->verbose, FE_DEBUG, 1, "Get DSS params"); params->delsys.dss.symbol_rate = internal->srate; params->delsys.dss.modulation = DVBFE_MOD_QPSK; break; case DVBFE_DELSYS_DVBS2: - dprintk(verbose, FE_DEBUG, 1, "Get DVB-S2 params"); + dprintk(state->verbose, FE_DEBUG, 1, "Get DVB-S2 params"); params->delsys.dvbs2.symbol_rate = internal->srate; break; default: - dprintk(verbose, FE_ERROR, 1, "Unsupported delivery system"); + dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system"); return -EINVAL; } @@ -1983,7 +1983,7 @@ struct dvb_frontend *stb0899_attach(struct stb0899_config *config, struct i2c_ad goto error; inversion = config->inversion; - state->verbose = verbose; + state->verbose = &verbose; state->config = config; state->i2c = i2c; state->frontend.ops = stb0899_ops; diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h index 755269979d1..2e845c93006 100644 --- a/drivers/media/dvb/frontends/stb0899_priv.h +++ b/drivers/media/dvb/frontends/stb0899_priv.h @@ -33,16 +33,16 @@ #define dprintk(x, y, z, format, arg...) do { \ if (z) { \ - if ((x > FE_ERROR) && (x > y)) \ + if ((*x > FE_ERROR) && (*x > y)) \ printk(KERN_ERR "%s: " format "\n", __func__ , ##arg); \ - else if ((x > FE_NOTICE) && (x > y)) \ + else if ((*x > FE_NOTICE) && (*x > y)) \ printk(KERN_NOTICE "%s: " format "\n", __func__ , ##arg); \ - else if ((x > FE_INFO) && (x > y)) \ + else if ((*x > FE_INFO) && (*x > y)) \ printk(KERN_INFO "%s: " format "\n", __func__ , ##arg); \ - else if ((x > FE_DEBUG) && (x > y)) \ + else if ((*x > FE_DEBUG) && (*x > y)) \ printk(KERN_DEBUG "%s: " format "\n", __func__ , ##arg); \ } else { \ - if (x > y) \ + if (*x > y) \ printk(format, ##arg); \ } \ } while(0) @@ -215,7 +215,7 @@ struct stb0899_state { struct stb0899_config *config; struct dvb_frontend frontend; - u32 verbose; /* Cached module verbosity level */ + u32 *verbose; /* Cached module verbosity level */ struct stb0899_internal internal; /* Device internal parameters */ -- cgit v1.2.3-70-g09d2 From 3f4009255bbcfcf55cf8ca40d70e4cf75e4dc68c Mon Sep 17 00:00:00 2001 From: Manu Abraham Date: Sun, 26 Oct 2008 18:28:52 -0300 Subject: V4L/DVB (9469): Port STB0899 and STB6100 Signed-off-by: Manu Abraham Signed-off-by: Mauro Carvalho Chehab --- drivers/media/dvb/frontends/stb0899_algo.c | 18 +- drivers/media/dvb/frontends/stb0899_drv.c | 423 ++++------------------------- drivers/media/dvb/frontends/stb0899_priv.h | 4 +- drivers/media/dvb/frontends/stb6100.c | 28 +- 4 files changed, 66 insertions(+), 407 deletions(-) (limited to 'drivers/media/dvb/frontends/stb0899_priv.h') diff --git a/drivers/media/dvb/frontends/stb0899_algo.c b/drivers/media/dvb/frontends/stb0899_algo.c index 750e88c2c8e..ced9b7ae7d5 100644 --- a/drivers/media/dvb/frontends/stb0899_algo.c +++ b/drivers/media/dvb/frontends/stb0899_algo.c @@ -293,7 +293,7 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state) if (stb0899_check_carrier(state) == NOCARRIER) { index++; last_derot_freq = derot_freq; - derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator position */ + derot_freq += index * internal->direction * internal->derot_step; /* next zig zag derotator position */ if(ABS(derot_freq) > derot_limit) next_loop--; @@ -309,11 +309,11 @@ static enum stb0899_status stb0899_search_carrier(struct stb0899_state *state) } } - internal->direction = -internal->direction; /* Change zigzag direction */ + internal->direction = -internal->direction; /* Change zigzag direction */ } while ((internal->status != CARRIEROK) && next_loop); if (internal->status == CARRIEROK) { - stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */ + stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */ internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]); dprintk(state->verbose, FE_DEBUG, 1, "----> CARRIER OK !, Derot Freq=%d", internal->derot_freq); } else { @@ -396,7 +396,7 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state) do { if ((internal->status != CARRIEROK) || (stb0899_check_data(state) != DATAOK)) { - derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */ + derot_freq += index * internal->direction * derot_step; /* next zig zag derotator position */ if (ABS(derot_freq) > derot_limit) next_loop--; @@ -414,11 +414,11 @@ static enum stb0899_status stb0899_search_data(struct stb0899_state *state) index++; } } - internal->direction = -internal->direction; /* change zig zag direction */ + internal->direction = -internal->direction; /* change zig zag direction */ } while ((internal->status != DATAOK) && next_loop); if (internal->status == DATAOK) { - stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */ + stb0899_read_regs(state, STB0899_CFRM, cfr, 2); /* get derotator frequency */ internal->derot_freq = state->config->inversion * MAKEWORD16(cfr[0], cfr[1]); dprintk(state->verbose, FE_DEBUG, 1, "------> DATAOK ! Derot Freq=%d", internal->derot_freq); } @@ -568,12 +568,12 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state) STB0899_SETFIELD_VAL(DEMAPVIT_KDIVIDER, reg, 60); stb0899_write_reg(state, STB0899_DEMAPVIT, reg); - stb0899_write_reg(state, STB0899_EQON, 0x01); /* Equalizer OFF while acquiring */ + stb0899_write_reg(state, STB0899_EQON, 0x01); /* Equalizer OFF while acquiring */ stb0899_write_reg(state, STB0899_VITSYNC, 0x19); stb0899_first_subrange(state); do { - /* Initialisations */ + /* Initialisations */ cfr[0] = cfr[1] = 0; stb0899_write_regs(state, STB0899_CFRM, cfr, 2); /* RESET derotator frequency */ @@ -588,7 +588,7 @@ enum stb0899_status stb0899_dvbs_algo(struct stb0899_state *state) /* enable tuner I/O */ stb0899_i2c_gate_ctrl(&state->frontend, 1); - /* Move tuner to frequency */ + /* Move tuner to frequency */ dprintk(state->verbose, FE_DEBUG, 1, "Tuner set frequency"); if (state->config->tuner_set_frequency) state->config->tuner_set_frequency(&state->frontend, internal->freq); diff --git a/drivers/media/dvb/frontends/stb0899_drv.c b/drivers/media/dvb/frontends/stb0899_drv.c index cf787f5fc00..8a329d6e6e8 100644 --- a/drivers/media/dvb/frontends/stb0899_drv.c +++ b/drivers/media/dvb/frontends/stb0899_drv.c @@ -823,16 +823,12 @@ static int stb0899_send_diseqc_burst(struct dvb_frontend *fe, fe_sec_mini_cmd_t static int stb0899_diseqc_init(struct stb0899_state *state) { struct dvb_diseqc_master_cmd tx_data; +/* struct dvb_diseqc_slave_reply rx_data; - +*/ u8 f22_tx, f22_rx, reg; - u32 mclk, tx_freq = 22000, count = 0, i; - - u32 trial = 0; /* try max = 2 (try 20khz and 17.5 khz) */ - u32 ret_1 = 0; /* 20 Khz status */ - u32 ret_2 = 0; /* 17.5 Khz status */ - + u32 mclk, tx_freq = 22000;/* count = 0, i; */ tx_data.msg[0] = 0xe2; tx_data.msg_len = 3; reg = stb0899_read_reg(state, STB0899_DISCNTRL2); @@ -860,8 +856,9 @@ static int stb0899_diseqc_init(struct stb0899_state *state) static int stb0899_sleep(struct dvb_frontend *fe) { struct stb0899_state *state = fe->demodulator_priv; +/* u8 reg; - +*/ dprintk(state->verbose, FE_DEBUG, 1, "Going to Sleep .. (Really tired .. :-))"); /* post process event */ stb0899_postproc(state, STB0899_POSTPROC_GPIO_POWER, 0); @@ -895,7 +892,6 @@ static int stb0899_init(struct dvb_frontend *fe) struct stb0899_config *config = state->config; dprintk(state->verbose, FE_DEBUG, 1, "Initializing STB0899 ... "); -// mutex_init(&state->search_lock); /* init device */ dprintk(state->verbose, FE_DEBUG, 1, "init device"); @@ -968,8 +964,8 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength) int val; u32 reg; switch (state->delsys) { - case DVBFE_DELSYS_DVBS: - case DVBFE_DELSYS_DSS: + case SYS_DVBS: + case SYS_DSS: if (internal->lock) { reg = stb0899_read_reg(state, STB0899_VSTATUS); if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) { @@ -984,7 +980,7 @@ static int stb0899_read_signal_strength(struct dvb_frontend *fe, u16 *strength) } } break; - case DVBFE_DELSYS_DVBS2: + case SYS_DVBS2: if (internal->lock) { reg = STB0899_READ_S2REG(STB0899_DEMOD, IF_AGC_GAIN); val = STB0899_GETFIELD(IF_AGC_GAIN, reg); @@ -1014,8 +1010,8 @@ static int stb0899_read_snr(struct dvb_frontend *fe, u16 *snr) reg = stb0899_read_reg(state, STB0899_VSTATUS); switch (state->delsys) { - case DVBFE_DELSYS_DVBS: - case DVBFE_DELSYS_DSS: + case SYS_DVBS: + case SYS_DSS: if (internal->lock) { if (STB0899_GETFIELD(VSTATUS_LOCKEDVIT, reg)) { @@ -1028,7 +1024,7 @@ static int stb0899_read_snr(struct dvb_frontend *fe, u16 *snr) } } break; - case DVBFE_DELSYS_DVBS2: + case SYS_DVBS2: if (internal->lock) { reg = STB0899_READ_S2REG(STB0899_S2DEMOD, UWP_CNTRL1); quant = STB0899_GETFIELD(UWP_ESN0_QUANT, reg); @@ -1067,8 +1063,8 @@ static int stb0899_read_status(struct dvb_frontend *fe, enum fe_status *status) *status = 0; switch (state->delsys) { - case DVBFE_DELSYS_DVBS: - case DVBFE_DELSYS_DSS: + case SYS_DVBS: + case SYS_DSS: dprintk(state->verbose, FE_DEBUG, 1, "Delivery system DVB-S/DSS"); if (internal->lock) { reg = stb0899_read_reg(state, STB0899_VSTATUS); @@ -1086,7 +1082,7 @@ static int stb0899_read_status(struct dvb_frontend *fe, enum fe_status *status) } } break; - case DVBFE_DELSYS_DVBS2: + case SYS_DVBS2: dprintk(state->verbose, FE_DEBUG, 1, "Delivery system DVB-S2"); if (internal->lock) { reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STAT2); @@ -1141,8 +1137,8 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber) *ber = 0; switch (state->delsys) { - case DVBFE_DELSYS_DVBS: - case DVBFE_DELSYS_DSS: + case SYS_DVBS: + case SYS_DSS: if (internal->lock) { /* average 5 BER values */ for (i = 0; i < 5; i++) { @@ -1162,7 +1158,7 @@ static int stb0899_read_ber(struct dvb_frontend *fe, u32 *ber) } } break; - case DVBFE_DELSYS_DVBS2: + case SYS_DVBS2: if (internal->lock) { /* Average 5 PER values */ for (i = 0; i < 5; i++) { @@ -1309,97 +1305,6 @@ int stb0899_get_dev_id(struct stb0899_state *state) return 0; } -static const struct dvbfe_info dvbs_info = { - .name = "STB0899 DVB-S", - .delsys = { - .dvbs.modulation = DVBFE_MOD_QPSK, - .dvbs.fec = DVBFE_FEC_1_2 | DVBFE_FEC_2_3 | - DVBFE_FEC_3_4 | DVBFE_FEC_5_6 | - DVBFE_FEC_6_7 - }, - - .frequency_min = 950000, - .frequency_max = 2150000, - .frequency_step = 0, - .symbol_rate_min = 1000000, - .symbol_rate_max = 45000000, - .symbol_rate_tolerance = 0 -}; - -static const struct dvbfe_info dss_info = { - .name = "STB0899 DSS", - .delsys = { - .dss.modulation = DVBFE_MOD_BPSK | DVBFE_MOD_QPSK, - .dss.fec = DVBFE_FEC_1_2 | DVBFE_FEC_2_3 | - DVBFE_FEC_3_4 | DVBFE_FEC_5_6 | - DVBFE_FEC_6_7 - }, - - .frequency_min = 950000, - .frequency_max = 2150000, - .frequency_step = 0, - .symbol_rate_min = 1000000, - .symbol_rate_max = 45000000, - .symbol_rate_tolerance = 0 -}; - -static const struct dvbfe_info dvbs2_info = { - .name = "STB0899 DVB-S2", - .delsys = { - .dvbs2.modulation = DVBFE_MOD_QPSK | DVBFE_MOD_8PSK | - DVBFE_MOD_16APSK | DVBFE_MOD_32APSK, - - .dvbs2.fec = DVBFE_FEC_1_4 | DVBFE_FEC_1_3 | - DVBFE_FEC_2_5 | DVBFE_FEC_1_2 | - DVBFE_FEC_3_5 | DVBFE_FEC_2_3 | - DVBFE_FEC_3_4 | DVBFE_FEC_4_5 | - DVBFE_FEC_5_6 | DVBFE_FEC_8_9 | - DVBFE_FEC_9_10, - }, - - .frequency_min = 950000, - .frequency_max = 2150000, - .frequency_step = 0, - .symbol_rate_min = 1000000, - .symbol_rate_max = 45000000, - .symbol_rate_tolerance = 0 -}; - -static int stb0899_get_info(struct dvb_frontend *fe, struct dvbfe_info *fe_info) -{ - struct stb0899_state *state = fe->demodulator_priv; - - dprintk(state->verbose, FE_DEBUG, 1, "Get Info"); - - switch (state->delsys) { - case DVBFE_DELSYS_DVBS: - dprintk(state->verbose, FE_ERROR, 1, "Querying DVB-S info"); - memcpy(fe_info, &dvbs_info, sizeof (struct dvbfe_info)); - break; - case DVBFE_DELSYS_DSS: - dprintk(state->verbose, FE_ERROR, 1, "Querying DSS info"); - memcpy(fe_info, &dss_info, sizeof (struct dvbfe_info)); - break; - case DVBFE_DELSYS_DVBS2: - dprintk(state->verbose, FE_ERROR, 1, "Querying DVB-S2 info"); - memcpy(fe_info, &dvbs2_info, sizeof (struct dvbfe_info)); - break; - default: - dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system"); - return -EINVAL; - } - dprintk(state->verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys); - - return 0; -} - -static int stb0899_get_delsys(struct dvb_frontend *fe, enum dvbfe_delsys *fe_delsys) -{ - *fe_delsys = DVBFE_DELSYS_DVBS | DVBFE_DELSYS_DSS | DVBFE_DELSYS_DVBS2; - - return 0; -} - static void stb0899_set_delivery(struct stb0899_state *state) { u8 reg; @@ -1409,7 +1314,7 @@ static void stb0899_set_delivery(struct stb0899_state *state) stop_clk[1] = stb0899_read_reg(state, STB0899_STOPCLK2); switch (state->delsys) { - case DVBFE_DELSYS_DVBS: + case SYS_DVBS: dprintk(state->verbose, FE_DEBUG, 1, "Delivery System -- DVB-S"); /* FECM/Viterbi ON */ reg = stb0899_read_reg(state, STB0899_FECM); @@ -1438,7 +1343,7 @@ static void stb0899_set_delivery(struct stb0899_state *state) STB0899_SETFIELD_VAL(STOP_CKS2DMD108, stop_clk[1], 1); break; - case DVBFE_DELSYS_DVBS2: + case SYS_DVBS2: /* FECM/Viterbi OFF */ reg = stb0899_read_reg(state, STB0899_FECM); STB0899_SETFIELD_VAL(FECM_RSVD0, reg, 0); @@ -1466,7 +1371,7 @@ static void stb0899_set_delivery(struct stb0899_state *state) STB0899_SETFIELD_VAL(STOP_CKS2DMD108, stop_clk[1], 0); break; - case DVBFE_DELSYS_DSS: + case SYS_DSS: /* FECM/Viterbi ON */ reg = stb0899_read_reg(state, STB0899_FECM); STB0899_SETFIELD_VAL(FECM_RSVD0, reg, 1); @@ -1525,33 +1430,19 @@ static void stb0899_set_iterations(struct stb0899_state *state) stb0899_write_s2reg(state, STB0899_S2DEMOD, STB0899_BASE_MAX_ITER, STB0899_OFF0_MAX_ITER, reg); } -static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_params *params) +static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { struct stb0899_state *state = fe->demodulator_priv; struct stb0899_params *i_params = &state->params; struct stb0899_internal *internal = &state->internal; struct stb0899_config *config = state->config; + struct dtv_frontend_properties *props = &fe->dtv_property_cache; u32 SearchRange, gain; - i_params->freq = params->frequency; - switch (state->delsys) { - case DVBFE_DELSYS_DVBS: - dprintk(state->verbose, FE_ERROR, 1, "set DVB-S params"); - i_params->srate = params->delsys.dvbs.symbol_rate; - break; - case DVBFE_DELSYS_DSS: - dprintk(state->verbose, FE_ERROR, 1, "set DSS params"); - i_params->srate = params->delsys.dss.symbol_rate; - break; - case DVBFE_DELSYS_DVBS2: - dprintk(state->verbose, FE_ERROR, 1, "set DVB-S2 params"); - i_params->srate = params->delsys.dvbs2.symbol_rate; - break; - default: - dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system"); - return -EINVAL; - } + i_params->freq = p->frequency; + i_params->srate = p->u.qpsk.symbol_rate; + state->delsys = props->delivery_system; dprintk(state->verbose, FE_DEBUG, 1, "delivery system=%d", state->delsys); SearchRange = 10000000; @@ -1563,11 +1454,11 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa if (state->config->tuner_set_rfsiggain) { if (internal->srate > 15000000) - gain = 8; /* 15Mb < srate < 45Mb, gain = 8dB */ + gain = 8; /* 15Mb < srate < 45Mb, gain = 8dB */ else if (internal->srate > 5000000) - gain = 12; /* 5Mb < srate < 15Mb, gain = 12dB */ + gain = 12; /* 5Mb < srate < 15Mb, gain = 12dB */ else - gain = 14; /* 1Mb < srate < 5Mb, gain = 14db */ + gain = 14; /* 1Mb < srate < 5Mb, gain = 14db */ state->config->tuner_set_rfsiggain(fe, gain); } @@ -1577,8 +1468,8 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa stb0899_set_mclk(state, config->hi_clk); switch (state->delsys) { - case DVBFE_DELSYS_DVBS: - case DVBFE_DELSYS_DSS: + case SYS_DVBS: + case SYS_DSS: dprintk(state->verbose, FE_DEBUG, 1, "DVB-S delivery system"); internal->freq = i_params->freq; internal->srate = i_params->srate; @@ -1626,7 +1517,7 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa return DVBFE_ALGO_SEARCH_FAILED; } break; - case DVBFE_DELSYS_DVBS2: + case SYS_DVBS2: internal->freq = i_params->freq; internal->srate = i_params->srate; internal->srch_range = SearchRange; @@ -1676,195 +1567,6 @@ static enum dvbfe_search stb0899_search(struct dvb_frontend *fe, struct dvbfe_pa return DVBFE_ALGO_SEARCH_ERROR; } - -static enum stb0899_status stb0899_track_carrier(struct stb0899_state *state) -{ - u8 reg; - - reg = stb0899_read_reg(state, STB0899_DSTATUS); - dprintk(state->verbose, FE_DEBUG, 1, "--------------------> STB0899_DSTATUS=[0x%02x]", reg); - if (STB0899_GETFIELD(CARRIER_FOUND, reg)) { - dprintk(state->verbose, FE_DEBUG, 1, "-------------> CARRIEROK !"); - return CARRIEROK; - } else { - dprintk(state->verbose, FE_DEBUG, 1, "-------------> NOCARRIER !"); - return NOCARRIER; - } - - return NOCARRIER; -} - -static enum stb0899_status stb0899_get_ifagc(struct stb0899_state *state) -{ - u8 reg; - - reg = STB0899_READ_S2REG(STB0899_S2DEMOD, DMD_STATUS); - dprintk(state->verbose, FE_DEBUG, 1, "DMD_STATUS=[0x%02x]", reg); - if (STB0899_GETFIELD(IF_AGC_LOCK, reg)) { - dprintk(state->verbose, FE_DEBUG, 1, "------------->IF AGC LOCKED !"); - return AGC1OK; - } else { - dprintk(state->verbose, FE_DEBUG, 1, "------------->IF AGC LOCK LOST !"); - return NOAGC1; - } - - return NOAGC1; -} - -static int stb0899_get_s1fec(struct stb0899_internal *internal, enum dvbfe_fec *fec) -{ - switch (internal->fecrate) { - case STB0899_FEC_1_2: - *fec = DVBFE_FEC_1_2; - break; - case STB0899_FEC_2_3: - *fec = DVBFE_FEC_2_3; - break; - case STB0899_FEC_3_4: - *fec = DVBFE_FEC_3_4; - break; - case STB0899_FEC_5_6: - *fec = DVBFE_FEC_5_6; - break; - case STB0899_FEC_6_7: - *fec = DVBFE_FEC_6_7; - break; - case STB0899_FEC_7_8: - *fec = DVBFE_FEC_7_8; - break; - default: - return -EINVAL; - } - - return 0; -} - -static int stb0899_get_modcod(struct stb0899_internal *internal, struct dvbs2_params *params) -{ - switch (internal->modcod) { - case STB0899_DUMMY_PLF: - params->modulation = DVBFE_MOD_NONE; - params->fec = DVBFE_FEC_NONE; - break; - case STB0899_QPSK_14: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_1_4; - break; - case STB0899_QPSK_13: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_1_3; - break; - case STB0899_QPSK_25: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_2_5; - break; - case STB0899_QPSK_12: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_1_2; - break; - case STB0899_QPSK_35: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_3_5; - break; - case STB0899_QPSK_23: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_2_3; - break; - case STB0899_QPSK_34: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_3_4; - break; - case STB0899_QPSK_45: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_4_5; - break; - case STB0899_QPSK_56: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_5_6; - break; - case STB0899_QPSK_89: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_8_9; - break; - case STB0899_QPSK_910: - params->modulation = DVBFE_MOD_QPSK; - params->fec = DVBFE_FEC_9_10; - break; - case STB0899_8PSK_35: - params->modulation = DVBFE_MOD_8PSK; - params->fec = DVBFE_FEC_3_5; - break; - case STB0899_8PSK_23: - params->modulation = DVBFE_MOD_8PSK; - params->fec = DVBFE_FEC_2_3; - break; - case STB0899_8PSK_34: - params->modulation = DVBFE_MOD_8PSK; - params->fec = DVBFE_FEC_3_4; - break; - case STB0899_8PSK_56: - params->modulation = DVBFE_MOD_8PSK; - params->fec = DVBFE_FEC_5_6; - break; - case STB0899_8PSK_89: - params->modulation = DVBFE_MOD_8PSK; - params->fec = DVBFE_FEC_8_9; - break; - case STB0899_8PSK_910: - params->modulation = DVBFE_MOD_8PSK; - params->fec = DVBFE_FEC_9_10; - break; - case STB0899_16APSK_23: - params->modulation = DVBFE_MOD_16APSK; - params->fec = DVBFE_FEC_2_3; - break; - case STB0899_16APSK_34: - params->modulation = DVBFE_MOD_16APSK; - params->fec = DVBFE_FEC_3_4; - break; - case STB0899_16APSK_45: - params->modulation = DVBFE_MOD_16APSK; - params->fec = DVBFE_FEC_4_5; - break; - case STB0899_16APSK_56: - params->modulation = DVBFE_MOD_16APSK; - params->fec = DVBFE_FEC_5_6; - break; - case STB0899_16APSK_89: - params->modulation = DVBFE_MOD_16APSK; - params->fec = DVBFE_FEC_8_9; - break; - case STB0899_16APSK_910: - params->modulation = DVBFE_MOD_16APSK; - params->fec = DVBFE_FEC_9_10; - break; - case STB0899_32APSK_34: - params->modulation = DVBFE_MOD_32APSK; - params->fec = DVBFE_FEC_3_4; - break; - case STB0899_32APSK_45: - params->modulation = DVBFE_MOD_32APSK; - params->fec = DVBFE_FEC_4_5; - break; - case STB0899_32APSK_56: - params->modulation = DVBFE_MOD_32APSK; - params->fec = DVBFE_FEC_5_6; - break; - case STB0899_32APSK_89: - params->modulation = DVBFE_MOD_32APSK; - params->fec = DVBFE_FEC_8_9; - break; - case STB0899_32APSK_910: - params->modulation = DVBFE_MOD_32APSK; - params->fec = DVBFE_FEC_9_10; - break; - default: - return -EINVAL; - } - - return 0; -} - /* * stb0899_track * periodically check the signal level against a specified @@ -1881,46 +1583,18 @@ static int stb0899_get_modcod(struct stb0899_internal *internal, struct dvbs2_pa * Once a new lock has established, the internal state * frequency (internal->freq) is updated */ -static int stb0899_track(struct dvb_frontend *fe, struct dvbfe_params *params, int *delay) +static int stb0899_track(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { - u32 lock_lost; - - struct stb0899_state *state = fe->demodulator_priv; - struct stb0899_internal *internal = &state->internal; - - - *delay = HZ/10; - return 0; } -static int stb0899_get_params(struct dvb_frontend *fe, struct dvbfe_params *params) +static int stb0899_get_frontend(struct dvb_frontend *fe, struct dvb_frontend_parameters *p) { struct stb0899_state *state = fe->demodulator_priv; struct stb0899_internal *internal = &state->internal; - params->frequency = internal->freq; - params->inversion = internal->inversion; - params->delivery = state->delsys; - switch (state->delsys) { - case DVBFE_DELSYS_DVBS: - dprintk(state->verbose, FE_DEBUG, 1, "Get DVB-S params"); - params->delsys.dvbs.symbol_rate = internal->srate; - params->delsys.dvbs.modulation = DVBFE_MOD_QPSK; - break; - case DVBFE_DELSYS_DSS: - dprintk(state->verbose, FE_DEBUG, 1, "Get DSS params"); - params->delsys.dss.symbol_rate = internal->srate; - params->delsys.dss.modulation = DVBFE_MOD_QPSK; - break; - case DVBFE_DELSYS_DVBS2: - dprintk(state->verbose, FE_DEBUG, 1, "Get DVB-S2 params"); - params->delsys.dvbs2.symbol_rate = internal->srate; - break; - default: - dprintk(state->verbose, FE_ERROR, 1, "Unsupported delivery system"); - return -EINVAL; - } + dprintk(state->verbose, FE_DEBUG, 1, "Get params"); + p->u.qpsk.symbol_rate = internal->srate; return 0; } @@ -1930,18 +1604,21 @@ static enum dvbfe_algo stb0899_frontend_algo(struct dvb_frontend *fe) return DVBFE_ALGO_CUSTOM; } -static int stb0899_set_delsys(struct dvb_frontend *fe, enum dvbfe_delsys delsys) -{ - struct stb0899_state *state = fe->demodulator_priv; - - state->delsys = delsys; - return 0; -} - static struct dvb_frontend_ops stb0899_ops = { .info = { - .name = "STB0899 Multistandard", + .name = "STB0899 Multistandard", + .type = FE_QPSK, + .frequency_min = 950000, + .frequency_max = 2150000, + .frequency_stepsize = 0, + .frequency_tolerance = 0, + .symbol_rate_min = 5000000, + .symbol_rate_max = 45000000, + + .caps = FE_CAN_INVERSION_AUTO | + FE_CAN_FEC_AUTO | + FE_CAN_QPSK }, .release = stb0899_release, @@ -1950,14 +1627,12 @@ static struct dvb_frontend_ops stb0899_ops = { // .wakeup = stb0899_wakeup, .i2c_gate_ctrl = stb0899_i2c_gate_ctrl, - .get_info = stb0899_get_info, - .get_delsys = stb0899_get_delsys, - .set_delsys = stb0899_set_delsys, .get_frontend_algo = stb0899_frontend_algo, .search = stb0899_search, .track = stb0899_track, - .get_params = stb0899_get_params, + .get_frontend = stb0899_get_frontend, + .read_status = stb0899_read_status, .read_snr = stb0899_read_snr, diff --git a/drivers/media/dvb/frontends/stb0899_priv.h b/drivers/media/dvb/frontends/stb0899_priv.h index 2e845c93006..24619e3689d 100644 --- a/drivers/media/dvb/frontends/stb0899_priv.h +++ b/drivers/media/dvb/frontends/stb0899_priv.h @@ -160,7 +160,7 @@ enum stb0899_fec { struct stb0899_params { u32 freq; /* Frequency */ u32 srate; /* Symbol rate */ - enum dvbfe_fec fecrate; + enum fe_code_rate fecrate; }; struct stb0899_internal { @@ -220,7 +220,7 @@ struct stb0899_state { struct stb0899_internal internal; /* Device internal parameters */ /* cached params from API */ - enum dvbfe_delsys delsys; + enum fe_delivery_system delsys; struct stb0899_params params; u32 rx_freq; /* DiSEqC 2.0 receiver freq */ diff --git a/drivers/media/dvb/frontends/stb6100.c b/drivers/media/dvb/frontends/stb6100.c index 083d6b62718..19a9e5fb970 100644 --- a/drivers/media/dvb/frontends/stb6100.c +++ b/drivers/media/dvb/frontends/stb6100.c @@ -305,7 +305,7 @@ static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency) int rc; const struct stb6100_lkup *ptr; struct stb6100_state *state = fe->tuner_priv; - struct dvbfe_params params; + struct dvb_frontend_parameters p; u32 srate = 0, fvco, nint, nfrac; u8 regs[STB6100_NUMREGS]; @@ -313,28 +313,12 @@ static int stb6100_set_frequency(struct dvb_frontend *fe, u32 frequency) if ((rc = stb6100_read_regs(state, regs)) < 0) return rc; - if (fe->ops.get_params) { - dprintk(verbose, FE_DEBUG, 1, "Get Frontend parameters"); - fe->ops.get_params(fe, ¶ms); - } - switch (params.delivery) { - case DVBFE_DELSYS_DVBS: - srate = params.delsys.dvbs.symbol_rate; - dprintk(verbose, FE_DEBUG, 1, "Delivery system = DVB-S, Symbol Rate=[%d]", srate); - break; - case DVBFE_DELSYS_DSS: - dprintk(verbose, FE_DEBUG, 1, "Delivery system = DSS, Symbol Rate=[%d]", srate); - srate = params.delsys.dss.symbol_rate; - break; - case DVBFE_DELSYS_DVBS2: - dprintk(verbose, FE_DEBUG, 1, "Delivery system = DVB-S2, Symbol Rate=[%d]", srate); - srate = params.delsys.dvbs2.symbol_rate; - break; - default: - dprintk(verbose, FE_NOTICE, 1, "symbol rate unknown!"); - srate = 22000000; /* just a typical default value */ - break; + + if (fe->ops.get_frontend) { + dprintk(verbose, FE_DEBUG, 1, "Get frontend parameters"); + fe->ops.get_frontend(fe, &p); } + srate = p.u.qpsk.symbol_rate; /* Baseband gain. */ if (srate >= 15000000) -- cgit v1.2.3-70-g09d2