Merge commit 'opendreambox/opendreambox-1.6' into vuplus-1.6
[vuplus_openembedded] / recipes / linux / linux-bm750 / linux_bm750_dvb-core_fe.patch
1 Index: drivers/media/dvb/dvb-core/dvb_frontend.h
2 ===================================================================
3 --- drivers/media/dvb/dvb-core/dvb_frontend.h   (revision 1)
4 +++ drivers/media/dvb/dvb-core/dvb_frontend.h   (working copy)
5 @@ -41,14 +41,40 @@
6  #include "dvbdev.h"
7  
8  struct dvb_frontend_tune_settings {
9 -       int min_delay_ms;
10 -       int step_size;
11 -       int max_drift;
12 -       struct dvb_frontend_parameters parameters;
13 +        int min_delay_ms;
14 +        int step_size;
15 +        int max_drift;
16 +        struct dvb_frontend_parameters parameters;
17  };
18  
19  struct dvb_frontend;
20  
21 +//NOTE : LINUX_2_6_31 related stuffs are added to make back-porting of  frontend driver easier.
22 +
23 +#define LINUX_2_6_31           1
24 +
25 +#ifdef LINUX_2_6_31    
26 +
27 +#define FE_TUNE_MODE_ONESHOT 0x01
28 +#define FE_SET_FRONTEND_TUNE_MODE  _IO('o', 81) /* unsigned int */
29 +
30 +struct delayed_work {
31 +       struct work_struct work;
32 +       struct timer_list timer;
33 +};
34 +
35 +#define DVB_MAX_ADAPTERS 8
36 +
37 +#define DVB_UNSET (-1)
38 +
39 +#define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \
40 +       static short adapter_nr[] = \
41 +               {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \
42 +       module_param_array(adapter_nr, short, NULL, 0444); \
43 +       MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers")
44 +
45 +
46 +
47  struct dvb_tuner_info {
48         char name[128];
49  
50 @@ -61,6 +87,132 @@
51         u32 bandwidth_step;
52  };
53  
54 +struct analog_parameters {
55 +       unsigned int frequency;
56 +       unsigned int mode;
57 +       unsigned int audmode;
58 +       u64 std;
59 +};
60 +
61 +enum dvbfe_modcod {
62 +       DVBFE_MODCOD_DUMMY_PLFRAME      = 0,
63 +       DVBFE_MODCOD_QPSK_1_4,
64 +       DVBFE_MODCOD_QPSK_1_3,
65 +       DVBFE_MODCOD_QPSK_2_5,
66 +       DVBFE_MODCOD_QPSK_1_2,
67 +       DVBFE_MODCOD_QPSK_3_5,
68 +       DVBFE_MODCOD_QPSK_2_3,
69 +       DVBFE_MODCOD_QPSK_3_4,
70 +       DVBFE_MODCOD_QPSK_4_5,
71 +       DVBFE_MODCOD_QPSK_5_6,
72 +       DVBFE_MODCOD_QPSK_8_9,
73 +       DVBFE_MODCOD_QPSK_9_10,
74 +       DVBFE_MODCOD_8PSK_3_5,
75 +       DVBFE_MODCOD_8PSK_2_3,
76 +       DVBFE_MODCOD_8PSK_3_4,
77 +       DVBFE_MODCOD_8PSK_5_6,
78 +       DVBFE_MODCOD_8PSK_8_9,
79 +       DVBFE_MODCOD_8PSK_9_10,
80 +       DVBFE_MODCOD_16APSK_2_3,
81 +       DVBFE_MODCOD_16APSK_3_4,
82 +       DVBFE_MODCOD_16APSK_4_5,
83 +       DVBFE_MODCOD_16APSK_5_6,
84 +       DVBFE_MODCOD_16APSK_8_9,
85 +       DVBFE_MODCOD_16APSK_9_10,
86 +       DVBFE_MODCOD_32APSK_3_4,
87 +       DVBFE_MODCOD_32APSK_4_5,
88 +       DVBFE_MODCOD_32APSK_5_6,
89 +       DVBFE_MODCOD_32APSK_8_9,
90 +       DVBFE_MODCOD_32APSK_9_10,
91 +       DVBFE_MODCOD_RESERVED_1,
92 +       DVBFE_MODCOD_BPSK_1_3,
93 +       DVBFE_MODCOD_BPSK_1_4,
94 +       DVBFE_MODCOD_RESERVED_2
95 +};
96 +
97 +enum tuner_param {
98 +       DVBFE_TUNER_FREQUENCY           = (1 <<  0),
99 +       DVBFE_TUNER_TUNERSTEP           = (1 <<  1),
100 +       DVBFE_TUNER_IFFREQ              = (1 <<  2),
101 +       DVBFE_TUNER_BANDWIDTH           = (1 <<  3),
102 +       DVBFE_TUNER_REFCLOCK            = (1 <<  4),
103 +       DVBFE_TUNER_IQSENSE             = (1 <<  5),
104 +       DVBFE_TUNER_DUMMY               = (1 << 31)
105 +};
106 +
107 +/*
108 + * ALGO_HW: (Hardware Algorithm)
109 + * ----------------------------------------------------------------
110 + * Devices that support this algorithm do everything in hardware
111 + * and no software support is needed to handle them.
112 + * Requesting these devices to LOCK is the only thing required,
113 + * device is supposed to do everything in the hardware.
114 + *
115 + * ALGO_SW: (Software Algorithm)
116 + * ----------------------------------------------------------------
117 + * These are dumb devices, that require software to do everything
118 + *
119 + * ALGO_CUSTOM: (Customizable Agorithm)
120 + * ----------------------------------------------------------------
121 + * Devices having this algorithm can be customized to have specific
122 + * algorithms in the frontend driver, rather than simply doing a
123 + * software zig-zag. In this case the zigzag maybe hardware assisted
124 + * or it maybe completely done in hardware. In all cases, usage of
125 + * this algorithm, in conjunction with the search and track
126 + * callbacks, utilizes the driver specific algorithm.
127 + *
128 + * ALGO_RECOVERY: (Recovery Algorithm)
129 + * ----------------------------------------------------------------
130 + * These devices have AUTO recovery capabilities from LOCK failure
131 + */
132 +enum dvbfe_algo {
133 +       DVBFE_ALGO_HW                   = (1 <<  0),
134 +       DVBFE_ALGO_SW                   = (1 <<  1),
135 +       DVBFE_ALGO_CUSTOM               = (1 <<  2),
136 +       DVBFE_ALGO_RECOVERY             = (1 << 31)
137 +};
138 +
139 +struct tuner_state {
140 +       u32 frequency;
141 +       u32 tunerstep;
142 +       u32 ifreq;
143 +       u32 bandwidth;
144 +       u32 iqsense;
145 +       u32 refclock;
146 +};
147 +
148 +/*
149 + * search callback possible return status
150 + *
151 + * DVBFE_ALGO_SEARCH_SUCCESS
152 + * The frontend search algorithm completed and returned succesfully
153 + *
154 + * DVBFE_ALGO_SEARCH_ASLEEP
155 + * The frontend search algorithm is sleeping
156 + *
157 + * DVBFE_ALGO_SEARCH_FAILED
158 + * The frontend search for a signal failed
159 + *
160 + * DVBFE_ALGO_SEARCH_INVALID
161 + * The frontend search algorith was probably supplied with invalid
162 + * parameters and the search is an invalid one
163 + *
164 + * DVBFE_ALGO_SEARCH_ERROR
165 + * The frontend search algorithm failed due to some error
166 + *
167 + * DVBFE_ALGO_SEARCH_AGAIN
168 + * The frontend search algorithm was requested to search again
169 + */
170 +enum dvbfe_search {
171 +       DVBFE_ALGO_SEARCH_SUCCESS       = (1 <<  0),
172 +       DVBFE_ALGO_SEARCH_ASLEEP        = (1 <<  1),
173 +       DVBFE_ALGO_SEARCH_FAILED        = (1 <<  2),
174 +       DVBFE_ALGO_SEARCH_INVALID       = (1 <<  3),
175 +       DVBFE_ALGO_SEARCH_AGAIN         = (1 <<  4),
176 +       DVBFE_ALGO_SEARCH_ERROR         = (1 << 31),
177 +};
178 +
179 +
180  struct dvb_tuner_ops {
181  
182         struct dvb_tuner_info info;
183 @@ -71,22 +223,73 @@
184  
185         /** This is for simple PLLs - set all parameters in one go. */
186         int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
187 +       int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
188  
189         /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
190         int (*calc_regs)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len);
191  
192 +       /** This is to allow setting tuner-specific configs */
193 +       int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
194 +
195         int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
196         int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
197  
198  #define TUNER_STATUS_LOCKED 1
199 +#define TUNER_STATUS_STEREO 2
200         int (*get_status)(struct dvb_frontend *fe, u32 *status);
201 +       int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
202  
203         /** These are provided seperately from set_params in order to facilitate silicon
204          * tuners which require sophisticated tuning loops, controlling each parameter seperately. */
205         int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
206         int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
207 +
208 +       /*
209 +        * These are provided seperately from set_params in order to facilitate silicon
210 +        * tuners which require sophisticated tuning loops, controlling each parameter seperately.
211 +        */
212 +       int (*set_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
213 +       int (*get_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
214  };
215 +struct analog_demod_info {
216 +       char *name;
217 +};
218  
219 +struct analog_demod_ops {
220 +
221 +       struct analog_demod_info info;
222 +
223 +       void (*set_params)(struct dvb_frontend *fe,
224 +                          struct analog_parameters *params);
225 +       int  (*has_signal)(struct dvb_frontend *fe);
226 +       int  (*is_stereo)(struct dvb_frontend *fe);
227 +       int  (*get_afc)(struct dvb_frontend *fe);
228 +       void (*tuner_status)(struct dvb_frontend *fe);
229 +       void (*standby)(struct dvb_frontend *fe);
230 +       void (*release)(struct dvb_frontend *fe);
231 +       int  (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
232 +
233 +       /** This is to allow setting tuner-specific configuration */
234 +       int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
235 +};
236 +struct dtv_property {
237 +        __u32 cmd;
238 +        __u32 reserved[3];
239 +        union {
240 +                __u32 data;
241 +                struct {
242 +                        __u8 data[32];
243 +                        __u32 len;
244 +                        __u32 reserved1[3];
245 +                        void *reserved2;
246 +                } buffer;
247 +        } u;
248 +        int result;
249 +} __attribute__ ((packed));
250 +
251 +
252 +#endif
253 +
254  struct dvb_frontend_ops {
255  
256         struct dvb_frontend_info info;
257 @@ -95,7 +298,7 @@
258  
259         int (*init)(struct dvb_frontend* fe);
260         int (*sleep)(struct dvb_frontend* fe);
261 -
262 +#ifdef LINUX_2_6_31    
263         /* if this is set, it overrides the default swzigzag */
264         int (*tune)(struct dvb_frontend* fe,
265                     struct dvb_frontend_parameters* params,
266 @@ -106,11 +309,11 @@
267         int (*get_frontend_algo)(struct dvb_frontend *fe);
268  
269         /* these two are only used for the swzigzag code */
270 +#endif
271         int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
272 +       int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
273         int (*get_tune_settings)(struct dvb_frontend* fe, struct dvb_frontend_tune_settings* settings);
274  
275 -       int (*get_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
276 -
277         int (*read_status)(struct dvb_frontend* fe, fe_status_t* status);
278         int (*read_ber)(struct dvb_frontend* fe, u32* ber);
279         int (*read_signal_strength)(struct dvb_frontend* fe, u16* strength);
280 @@ -123,11 +326,27 @@
281         int (*diseqc_send_burst)(struct dvb_frontend* fe, fe_sec_mini_cmd_t minicmd);
282         int (*set_tone)(struct dvb_frontend* fe, fe_sec_tone_mode_t tone);
283         int (*set_voltage)(struct dvb_frontend* fe, fe_sec_voltage_t voltage);
284 -       int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
285 -       int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
286 -       int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
287 +       int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, int arg);
288 +       int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned int cmd);
289  
290 -       struct dvb_tuner_ops tuner_ops;
291 +#ifdef LINUX_2_6_31    
292 +        int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
293 +        int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
294 +
295 +        /* These callbacks are for devices that implement their own
296 +         * tuning algorithms, rather than a simple swzigzag
297 +         */
298 +        enum dvbfe_search (*search)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
299 +        int (*track)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
300 +
301 +        struct dvb_tuner_ops tuner_ops;
302 +        struct analog_demod_ops analog_ops;
303 +
304 +        int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
305 +        int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
306 +#endif
307 +       
308 +       int (*set_sw_loopthrough)(struct dvb_frontend* fe, int* arg);
309  };
310  
311  #define MAX_EVENT 8
312 @@ -141,13 +360,102 @@
313         struct semaphore          sem;
314  };
315  
316 +
317 +#ifdef LINUX_2_6_31    
318 +// 2.6.31
319 +typedef enum fe_pilot {
320 +       PILOT_ON,
321 +       PILOT_OFF,
322 +       PILOT_AUTO,
323 +} fe_pilot_t;
324 +
325 +typedef enum fe_rolloff {
326 +       ROLLOFF_35, /* Implied value in DVB-S, default for DVB-S2 */
327 +       ROLLOFF_20,
328 +       ROLLOFF_25,
329 +       ROLLOFF_AUTO,
330 +} fe_rolloff_t;
331 +
332 +typedef enum fe_delivery_system {
333 +       SYS_UNDEFINED,
334 +       SYS_DVBC_ANNEX_AC,
335 +       SYS_DVBC_ANNEX_B,
336 +       SYS_DVBT,
337 +       SYS_DSS,
338 +       SYS_DVBS,
339 +       SYS_DVBS2,
340 +       SYS_DVBH,
341 +       SYS_ISDBT,
342 +       SYS_ISDBS,
343 +       SYS_ISDBC,
344 +       SYS_ATSC,
345 +       SYS_ATSCMH,
346 +       SYS_DMBTH,
347 +       SYS_CMMB,
348 +       SYS_DAB,
349 +} fe_delivery_system_t;
350 +
351 +struct dtv_frontend_properties {
352 +
353 +       /* Cache State */
354 +       u32                     state;
355 +
356 +       u32                     frequency;
357 +       fe_modulation_t         modulation;
358 +
359 +       fe_sec_voltage_t        voltage;
360 +       fe_sec_tone_mode_t      sectone;
361 +       fe_spectral_inversion_t inversion;
362 +       fe_code_rate_t          fec_inner;
363 +       fe_transmit_mode_t      transmission_mode;
364 +       u32                     bandwidth_hz;   /* 0 = AUTO */
365 +       fe_guard_interval_t     guard_interval;
366 +       fe_hierarchy_t          hierarchy;
367 +       u32                     symbol_rate;
368 +       fe_code_rate_t          code_rate_HP;
369 +       fe_code_rate_t          code_rate_LP;
370 +
371 +       fe_pilot_t              pilot;
372 +       fe_rolloff_t            rolloff;
373 +
374 +       fe_delivery_system_t    delivery_system;
375 +};
376 +
377 +
378 +
379 +#ifndef false
380 +#define false 0
381 +#endif
382 +
383 +#ifndef true
384 +#define true   1
385 +#endif
386 +
387 +#define        KERN_CONT       "<c>"
388 +
389 +#endif
390 +
391 +
392  struct dvb_frontend {
393 +#ifndef LINUX_2_6_31   
394 +       struct dvb_frontend_ops* ops;
395 +       struct dvb_adapter *dvb;
396 +       void* demodulator_priv;
397 +       void* frontend_priv;
398 +#else
399         struct dvb_frontend_ops ops;
400         struct dvb_adapter *dvb;
401         void* demodulator_priv;
402 -       void* tuner_priv;
403 -       void* frontend_priv;
404 -       void* misc_priv;
405 +       void *tuner_priv;
406 +       void *frontend_priv;
407 +       void *sec_priv;
408 +       void *analog_demod_priv;
409 +       struct dtv_frontend_properties dtv_property_cache;
410 +#define DVB_FRONTEND_COMPONENT_TUNER 0
411 +       int (*callback)(void *adapter_priv, int component, int cmd, int arg);
412 +       int id;
413 +
414 +#endif
415  };
416  
417  extern int dvb_register_frontend(struct dvb_adapter* dvb,
418 @@ -155,8 +463,6 @@
419  
420  extern int dvb_unregister_frontend(struct dvb_frontend* fe);
421  
422 -extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
423 -
424  extern void dvb_frontend_sleep_until(struct timeval *waketime, u32 add_usec);
425  extern s32 timeval_usec_diff(struct timeval lasttime, struct timeval curtime);
426