Merge branch 'vuplus-1.6' of ssh://192.168.102.66/~ikseong/work/repo/openembedded...
[vuplus_openembedded] / recipes / linux / files / opendreambox / linux-2.6.18-dvb-core-headers-20100904.patch
1 diff -Naur linux-2.6.18/drivers/media/dvb.orig/dvb-core/compat.h linux-2.6.18/drivers/media/dvb/dvb-core/compat.h
2 --- linux-2.6.18/drivers/media/dvb.orig/dvb-core/compat.h       2010-09-10 02:00:59.000000000 +0000
3 +++ linux-2.6.18/drivers/media/dvb/dvb-core/compat.h    2010-09-15 00:00:00.000000000 +0000
4 @@ -1,19 +0,1 @@
5 -#ifndef _COMPAT_H
6 -#define _COMPAT_H
7 -
8 -#include <linux/i2c-id.h>
9 -#include <linux/version.h>
10 -#include <linux/utsname.h>
11 -
12 -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,13)
13 -# define class_device_create(a, b, c, d, e, f, g, h) class_simple_device_add(a, c, d, e, f, g, h)
14 -# define class_device_destroy(a, b...) class_simple_device_remove(b)
15 -# define class_create class_simple_create
16 -# define class_destroy class_simple_destroy
17 -# define class class_simple
18 -# define try_to_freeze() do { if (current->flags & PF_FREEZE) refrigerator(PF_FREEZE); } while(0)
19 -#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15)
20 -# define class_device_create(a, b, c, d, e, f, g, h) class_device_create(a, c, d, e, f, g, h)
21 -#endif
22 -
23 -#endif
24 +
25 diff -Naur linux-2.6.18/drivers/media/dvb.orig/dvb-core/demux.h linux-2.6.18/drivers/media/dvb/dvb-core/demux.h
26 --- linux-2.6.18/drivers/media/dvb.orig/dvb-core/demux.h        2006-09-20 03:42:06.000000000 +0000
27 +++ linux-2.6.18/drivers/media/dvb/dvb-core/demux.h     2010-09-09 12:38:50.000000000 +0000
28 @@ -80,6 +80,8 @@
29  #define        TS_PAYLOAD_ONLY 2   /* in case TS_PACKET is set, only send the TS
30                                payload (<=184 bytes per packet) to callback */
31  #define TS_DECODER      4   /* send stream to built-in decoder (if present) */
32 +#define TS_DEMUX        8   /* in case TS_PACKET is set, send the TS to
33 +                              the demux device, not to the dvr device */
34  
35  /* PES type for filters which write to built-in decoder */
36  /* these should be kept identical to the types in dmx.h */
37 @@ -245,7 +247,7 @@
38         void* priv;                  /* Pointer to private data of the API client */
39         int (*open) (struct dmx_demux* demux);
40         int (*close) (struct dmx_demux* demux);
41 -       int (*write) (struct dmx_demux* demux, const char* buf, size_t count);
42 +       int (*write) (struct dmx_demux* demux, const char __user *buf, size_t count);
43         int (*allocate_ts_feed) (struct dmx_demux* demux,
44                                  struct dmx_ts_feed** feed,
45                                  dmx_ts_cb callback);
46 diff -Naur linux-2.6.18/drivers/media/dvb.orig/dvb-core/dmxdev.h linux-2.6.18/drivers/media/dvb/dvb-core/dmxdev.h
47 --- linux-2.6.18/drivers/media/dvb.orig/dvb-core/dmxdev.h       2006-09-20 03:42:06.000000000 +0000
48 +++ linux-2.6.18/drivers/media/dvb/dvb-core/dmxdev.h    2010-09-09 12:38:50.000000000 +0000
49 @@ -30,7 +30,9 @@
50  #include <linux/wait.h>
51  #include <linux/fs.h>
52  #include <linux/string.h>
53 +#include "compat.h"
54  #include <linux/mutex.h>
55 +#include <linux/slab.h>
56  
57  #include <linux/dvb/dmx.h>
58  
59 @@ -53,13 +55,20 @@
60         DMXDEV_STATE_TIMEDOUT
61  };
62  
63 +struct dmxdev_feed {
64 +       u16 pid;
65 +       struct dmx_ts_feed *ts;
66 +       struct list_head next;
67 +};
68 +
69  struct dmxdev_filter {
70         union {
71                 struct dmx_section_filter *sec;
72         } filter;
73  
74         union {
75 -               struct dmx_ts_feed *ts;
76 +               /* list of TS and PES feeds (struct dmxdev_feed) */
77 +               struct list_head ts;
78                 struct dmx_section_feed *sec;
79         } feed;
80  
81 @@ -91,6 +100,8 @@
82  
83         int filternum;
84         int capabilities;
85 +
86 +       unsigned int exit:1;
87  #define DMXDEV_CAP_DUPLEX 1
88         struct dmx_frontend *dvr_orig_fe;
89  
90 diff -Naur linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_ca_en50221.h linux-2.6.18/drivers/media/dvb/dvb-core/dvb_ca_en50221.h
91 --- linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_ca_en50221.h       2006-09-20 03:42:06.000000000 +0000
92 +++ linux-2.6.18/drivers/media/dvb/dvb-core/dvb_ca_en50221.h    2010-09-09 12:38:50.000000000 +0000
93 @@ -45,8 +45,10 @@
94         /* the module owning this structure */
95         struct module* owner;
96  
97 -       /* NOTE: the read_*, write_* and poll_slot_status functions must use locks as
98 -        * they may be called from several threads at once */
99 +       /* NOTE: the read_*, write_* and poll_slot_status functions will be
100 +        * called for different slots concurrently and need to use locks where
101 +        * and if appropriate. There will be no concurrent access to one slot.
102 +        */
103  
104         /* functions for accessing attribute memory on the CAM */
105         int (*read_attribute_mem)(struct dvb_ca_en50221* ca, int slot, int address);
106 diff -Naur linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_demux.h linux-2.6.18/drivers/media/dvb/dvb-core/dvb_demux.h
107 --- linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_demux.h    2006-09-20 03:42:06.000000000 +0000
108 +++ linux-2.6.18/drivers/media/dvb/dvb-core/dvb_demux.h 2010-09-09 12:38:50.000000000 +0000
109 @@ -26,6 +26,7 @@
110  #include <linux/time.h>
111  #include <linux/timer.h>
112  #include <linux/spinlock.h>
113 +#include "compat.h"
114  #include <linux/mutex.h>
115  
116  #include "demux.h"
117 @@ -42,6 +43,10 @@
118  
119  #define DVB_DEMUX_MASK_MAX 18
120  
121 +#define MAX_PID 0x1fff
122 +
123 +#define SPEED_PKTS_INTERVAL 50000
124 +
125  struct dvb_demux_filter {
126         struct dmx_section_filter filter;
127         u8 maskandmode[DMX_MAX_FILTER_SIZE];
128 @@ -127,6 +132,11 @@
129  
130         struct mutex mutex;
131         spinlock_t lock;
132 +
133 +       uint8_t *cnt_storage; /* for TS continuity check */
134 +
135 +       struct timespec speed_last_time; /* for TS speed check */
136 +       uint32_t speed_pkts_cnt; /* for TS speed check */
137  };
138  
139  int dvb_dmx_init(struct dvb_demux *dvbdemux);
140 diff -Naur linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvbdev.h linux-2.6.18/drivers/media/dvb/dvb-core/dvbdev.h
141 --- linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvbdev.h       2006-09-20 03:42:06.000000000 +0000
142 +++ linux-2.6.18/drivers/media/dvb/dvb-core/dvbdev.h    2010-09-09 12:38:50.000000000 +0000
143 @@ -27,10 +27,17 @@
144  #include <linux/poll.h>
145  #include <linux/fs.h>
146  #include <linux/list.h>
147 -#include <linux/smp_lock.h>
148  
149  #define DVB_MAJOR 212
150  
151 +#if defined(CONFIG_DVB_MAX_ADAPTERS) && CONFIG_DVB_MAX_ADAPTERS > 0
152 +  #define DVB_MAX_ADAPTERS CONFIG_DVB_MAX_ADAPTERS
153 +#else
154 +  #define DVB_MAX_ADAPTERS 8
155 +#endif
156 +
157 +#define DVB_UNSET (-1)
158 +
159  #define DVB_DEVICE_VIDEO      0
160  #define DVB_DEVICE_AUDIO      1
161  #define DVB_DEVICE_SEC        2
162 @@ -41,6 +48,13 @@
163  #define DVB_DEVICE_NET        7
164  #define DVB_DEVICE_OSD        8
165  
166 +#define DVB_DEFINE_MOD_OPT_ADAPTER_NR(adapter_nr) \
167 +       static short adapter_nr[] = \
168 +               {[0 ... (DVB_MAX_ADAPTERS - 1)] = DVB_UNSET }; \
169 +       module_param_array(adapter_nr, short, NULL, 0444); \
170 +       MODULE_PARM_DESC(adapter_nr, "DVB adapter numbers")
171 +
172 +struct dvb_frontend;
173  
174  struct dvb_adapter {
175         int num;
176 @@ -53,14 +67,45 @@
177         struct device *device;
178  
179         struct module *module;
180 +
181 +       int mfe_shared;                 /* indicates mutually exclusive frontends */
182 +       struct dvb_device *mfe_dvbdev;  /* frontend device in use */
183 +       struct mutex mfe_lock;          /* access lock for thread creation */
184 +
185 +       /* Allow the adapter/bridge driver to perform an action before and/or
186 +        * after the core handles an ioctl:
187 +        *
188 +        * DVB_FE_IOCTL_PRE indicates that the ioctl has not yet been handled.
189 +        * DVB_FE_IOCTL_POST indicates that the ioctl has been handled.
190 +        *
191 +        * When DVB_FE_IOCTL_PRE is passed to the callback as the stage arg:
192 +        *
193 +        * return 0 to allow dvb-core to handle the ioctl.
194 +        * return a positive int to prevent dvb-core from handling the ioctl,
195 +        *      and exit without error.
196 +        * return a negative int to prevent dvb-core from handling the ioctl,
197 +        *      and return that value as an error.
198 +        *
199 +        * When DVB_FE_IOCTL_POST is passed to the callback as the stage arg:
200 +        *
201 +        * return 0 to allow the dvb_frontend ioctl handler to exit normally.
202 +        * return a negative int to cause the dvb_frontend ioctl handler to
203 +        *      return that value as an error.
204 +        */
205 +#define DVB_FE_IOCTL_PRE 0
206 +#define DVB_FE_IOCTL_POST 1
207 +       int (*fe_ioctl_override)(struct dvb_frontend *fe,
208 +                                unsigned int cmd, void *parg,
209 +                                unsigned int stage);
210  };
211  
212  
213  struct dvb_device {
214         struct list_head list_head;
215 -       struct file_operations *fops;
216 +       const struct file_operations *fops;
217         struct dvb_adapter *adapter;
218         int type;
219 +       int minor;
220         u32 id;
221  
222         /* in theory, 'users' can vanish now,
223 @@ -69,6 +114,7 @@
224         int writers;
225         int users;
226  
227 +       wait_queue_head_t         wait_queue;
228         /* don't really need those !? -- FIXME: use video_usercopy  */
229         int (*kernel_ioctl)(struct inode *inode, struct file *file,
230                             unsigned int cmd, void *arg);
231 @@ -77,7 +123,9 @@
232  };
233  
234  
235 -extern int dvb_register_adapter (struct dvb_adapter *adap, const char *name, struct module *module, struct device *device);
236 +extern int dvb_register_adapter(struct dvb_adapter *adap, const char *name,
237 +                               struct module *module, struct device *device,
238 +                               short *adapter_nums);
239  extern int dvb_unregister_adapter (struct dvb_adapter *adap);
240  
241  extern int dvb_register_device (struct dvb_adapter *adap,
242 @@ -102,4 +150,26 @@
243                             int (*func)(struct inode *inode, struct file *file,
244                             unsigned int cmd, void *arg));
245  
246 +/** generic DVB attach function. */
247 +#ifdef CONFIG_MEDIA_ATTACH
248 +#define dvb_attach(FUNCTION, ARGS...) ({ \
249 +       void *__r = NULL; \
250 +       typeof(&FUNCTION) __a = symbol_request(FUNCTION); \
251 +       if (__a) { \
252 +               __r = (void *) __a(ARGS); \
253 +               if (__r == NULL) \
254 +                       symbol_put(FUNCTION); \
255 +       } else { \
256 +               printk(KERN_ERR "DVB: Unable to find symbol "#FUNCTION"()\n"); \
257 +       } \
258 +       __r; \
259 +})
260 +
261 +#else
262 +#define dvb_attach(FUNCTION, ARGS...) ({ \
263 +       FUNCTION(ARGS); \
264 +})
265 +
266 +#endif
267 +
268  #endif /* #ifndef _DVBDEV_H_ */
269 diff -Naur linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_frontend.h linux-2.6.18/drivers/media/dvb/dvb-core/dvb_frontend.h
270 --- linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_frontend.h 2006-09-20 03:42:06.000000000 +0000
271 +++ linux-2.6.18/drivers/media/dvb/dvb-core/dvb_frontend.h      2010-09-09 12:38:50.000000000 +0000
272 @@ -35,6 +35,8 @@
273  #include <linux/module.h>
274  #include <linux/errno.h>
275  #include <linux/delay.h>
276 +#include <linux/mutex.h>
277 +#include <linux/slab.h>
278  
279  #include <linux/dvb/frontend.h>
280  
281 @@ -61,6 +63,132 @@
282         u32 bandwidth_step;
283  };
284  
285 +struct analog_parameters {
286 +       unsigned int frequency;
287 +       unsigned int mode;
288 +       unsigned int audmode;
289 +       u64 std;
290 +};
291 +
292 +enum dvbfe_modcod {
293 +       DVBFE_MODCOD_DUMMY_PLFRAME      = 0,
294 +       DVBFE_MODCOD_QPSK_1_4,
295 +       DVBFE_MODCOD_QPSK_1_3,
296 +       DVBFE_MODCOD_QPSK_2_5,
297 +       DVBFE_MODCOD_QPSK_1_2,
298 +       DVBFE_MODCOD_QPSK_3_5,
299 +       DVBFE_MODCOD_QPSK_2_3,
300 +       DVBFE_MODCOD_QPSK_3_4,
301 +       DVBFE_MODCOD_QPSK_4_5,
302 +       DVBFE_MODCOD_QPSK_5_6,
303 +       DVBFE_MODCOD_QPSK_8_9,
304 +       DVBFE_MODCOD_QPSK_9_10,
305 +       DVBFE_MODCOD_8PSK_3_5,
306 +       DVBFE_MODCOD_8PSK_2_3,
307 +       DVBFE_MODCOD_8PSK_3_4,
308 +       DVBFE_MODCOD_8PSK_5_6,
309 +       DVBFE_MODCOD_8PSK_8_9,
310 +       DVBFE_MODCOD_8PSK_9_10,
311 +       DVBFE_MODCOD_16APSK_2_3,
312 +       DVBFE_MODCOD_16APSK_3_4,
313 +       DVBFE_MODCOD_16APSK_4_5,
314 +       DVBFE_MODCOD_16APSK_5_6,
315 +       DVBFE_MODCOD_16APSK_8_9,
316 +       DVBFE_MODCOD_16APSK_9_10,
317 +       DVBFE_MODCOD_32APSK_3_4,
318 +       DVBFE_MODCOD_32APSK_4_5,
319 +       DVBFE_MODCOD_32APSK_5_6,
320 +       DVBFE_MODCOD_32APSK_8_9,
321 +       DVBFE_MODCOD_32APSK_9_10,
322 +       DVBFE_MODCOD_RESERVED_1,
323 +       DVBFE_MODCOD_BPSK_1_3,
324 +       DVBFE_MODCOD_BPSK_1_4,
325 +       DVBFE_MODCOD_RESERVED_2
326 +};
327 +
328 +enum tuner_param {
329 +       DVBFE_TUNER_FREQUENCY           = (1 <<  0),
330 +       DVBFE_TUNER_TUNERSTEP           = (1 <<  1),
331 +       DVBFE_TUNER_IFFREQ              = (1 <<  2),
332 +       DVBFE_TUNER_BANDWIDTH           = (1 <<  3),
333 +       DVBFE_TUNER_REFCLOCK            = (1 <<  4),
334 +       DVBFE_TUNER_IQSENSE             = (1 <<  5),
335 +       DVBFE_TUNER_DUMMY               = (1 << 31)
336 +};
337 +
338 +/*
339 + * ALGO_HW: (Hardware Algorithm)
340 + * ----------------------------------------------------------------
341 + * Devices that support this algorithm do everything in hardware
342 + * and no software support is needed to handle them.
343 + * Requesting these devices to LOCK is the only thing required,
344 + * device is supposed to do everything in the hardware.
345 + *
346 + * ALGO_SW: (Software Algorithm)
347 + * ----------------------------------------------------------------
348 + * These are dumb devices, that require software to do everything
349 + *
350 + * ALGO_CUSTOM: (Customizable Agorithm)
351 + * ----------------------------------------------------------------
352 + * Devices having this algorithm can be customized to have specific
353 + * algorithms in the frontend driver, rather than simply doing a
354 + * software zig-zag. In this case the zigzag maybe hardware assisted
355 + * or it maybe completely done in hardware. In all cases, usage of
356 + * this algorithm, in conjunction with the search and track
357 + * callbacks, utilizes the driver specific algorithm.
358 + *
359 + * ALGO_RECOVERY: (Recovery Algorithm)
360 + * ----------------------------------------------------------------
361 + * These devices have AUTO recovery capabilities from LOCK failure
362 + */
363 +enum dvbfe_algo {
364 +       DVBFE_ALGO_HW                   = (1 <<  0),
365 +       DVBFE_ALGO_SW                   = (1 <<  1),
366 +       DVBFE_ALGO_CUSTOM               = (1 <<  2),
367 +       DVBFE_ALGO_RECOVERY             = (1 << 31)
368 +};
369 +
370 +struct tuner_state {
371 +       u32 frequency;
372 +       u32 tunerstep;
373 +       u32 ifreq;
374 +       u32 bandwidth;
375 +       u32 iqsense;
376 +       u32 refclock;
377 +};
378 +
379 +/*
380 + * search callback possible return status
381 + *
382 + * DVBFE_ALGO_SEARCH_SUCCESS
383 + * The frontend search algorithm completed and returned successfully
384 + *
385 + * DVBFE_ALGO_SEARCH_ASLEEP
386 + * The frontend search algorithm is sleeping
387 + *
388 + * DVBFE_ALGO_SEARCH_FAILED
389 + * The frontend search for a signal failed
390 + *
391 + * DVBFE_ALGO_SEARCH_INVALID
392 + * The frontend search algorith was probably supplied with invalid
393 + * parameters and the search is an invalid one
394 + *
395 + * DVBFE_ALGO_SEARCH_ERROR
396 + * The frontend search algorithm failed due to some error
397 + *
398 + * DVBFE_ALGO_SEARCH_AGAIN
399 + * The frontend search algorithm was requested to search again
400 + */
401 +enum dvbfe_search {
402 +       DVBFE_ALGO_SEARCH_SUCCESS       = (1 <<  0),
403 +       DVBFE_ALGO_SEARCH_ASLEEP        = (1 <<  1),
404 +       DVBFE_ALGO_SEARCH_FAILED        = (1 <<  2),
405 +       DVBFE_ALGO_SEARCH_INVALID       = (1 <<  3),
406 +       DVBFE_ALGO_SEARCH_AGAIN         = (1 <<  4),
407 +       DVBFE_ALGO_SEARCH_ERROR         = (1 << 31),
408 +};
409 +
410 +
411  struct dvb_tuner_ops {
412  
413         struct dvb_tuner_info info;
414 @@ -71,20 +199,55 @@
415  
416         /** This is for simple PLLs - set all parameters in one go. */
417         int (*set_params)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
418 +       int (*set_analog_params)(struct dvb_frontend *fe, struct analog_parameters *p);
419  
420         /** This is support for demods like the mt352 - fills out the supplied buffer with what to write. */
421         int (*calc_regs)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p, u8 *buf, int buf_len);
422  
423 +       /** This is to allow setting tuner-specific configs */
424 +       int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
425 +
426         int (*get_frequency)(struct dvb_frontend *fe, u32 *frequency);
427         int (*get_bandwidth)(struct dvb_frontend *fe, u32 *bandwidth);
428  
429  #define TUNER_STATUS_LOCKED 1
430 +#define TUNER_STATUS_STEREO 2
431         int (*get_status)(struct dvb_frontend *fe, u32 *status);
432 +       int (*get_rf_strength)(struct dvb_frontend *fe, u16 *strength);
433  
434 -       /** These are provided seperately from set_params in order to facilitate silicon
435 -        * tuners which require sophisticated tuning loops, controlling each parameter seperately. */
436 +       /** These are provided separately from set_params in order to facilitate silicon
437 +        * tuners which require sophisticated tuning loops, controlling each parameter separately. */
438         int (*set_frequency)(struct dvb_frontend *fe, u32 frequency);
439         int (*set_bandwidth)(struct dvb_frontend *fe, u32 bandwidth);
440 +
441 +       /*
442 +        * These are provided separately from set_params in order to facilitate silicon
443 +        * tuners which require sophisticated tuning loops, controlling each parameter separately.
444 +        */
445 +       int (*set_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
446 +       int (*get_state)(struct dvb_frontend *fe, enum tuner_param param, struct tuner_state *state);
447 +};
448 +
449 +struct analog_demod_info {
450 +       char *name;
451 +};
452 +
453 +struct analog_demod_ops {
454 +
455 +       struct analog_demod_info info;
456 +
457 +       void (*set_params)(struct dvb_frontend *fe,
458 +                          struct analog_parameters *params);
459 +       int  (*has_signal)(struct dvb_frontend *fe);
460 +       int  (*is_stereo)(struct dvb_frontend *fe);
461 +       int  (*get_afc)(struct dvb_frontend *fe);
462 +       void (*tuner_status)(struct dvb_frontend *fe);
463 +       void (*standby)(struct dvb_frontend *fe);
464 +       void (*release)(struct dvb_frontend *fe);
465 +       int  (*i2c_gate_ctrl)(struct dvb_frontend *fe, int enable);
466 +
467 +       /** This is to allow setting tuner-specific configuration */
468 +       int (*set_config)(struct dvb_frontend *fe, void *priv_cfg);
469  };
470  
471  struct dvb_frontend_ops {
472 @@ -92,18 +255,21 @@
473         struct dvb_frontend_info info;
474  
475         void (*release)(struct dvb_frontend* fe);
476 +       void (*release_sec)(struct dvb_frontend* fe);
477  
478         int (*init)(struct dvb_frontend* fe);
479         int (*sleep)(struct dvb_frontend* fe);
480  
481 +       int (*write)(struct dvb_frontend* fe, u8* buf, int len);
482 +
483         /* if this is set, it overrides the default swzigzag */
484         int (*tune)(struct dvb_frontend* fe,
485                     struct dvb_frontend_parameters* params,
486                     unsigned int mode_flags,
487 -                   int *delay,
488 +                   unsigned int *delay,
489                     fe_status_t *status);
490         /* get frontend tuning algorithm from the module */
491 -       int (*get_frontend_algo)(struct dvb_frontend *fe);
492 +       enum dvbfe_algo (*get_frontend_algo)(struct dvb_frontend *fe);
493  
494         /* these two are only used for the swzigzag code */
495         int (*set_frontend)(struct dvb_frontend* fe, struct dvb_frontend_parameters* params);
496 @@ -126,8 +292,19 @@
497         int (*enable_high_lnb_voltage)(struct dvb_frontend* fe, long arg);
498         int (*dishnetwork_send_legacy_command)(struct dvb_frontend* fe, unsigned long cmd);
499         int (*i2c_gate_ctrl)(struct dvb_frontend* fe, int enable);
500 +       int (*ts_bus_ctrl)(struct dvb_frontend* fe, int acquire);
501 +
502 +       /* These callbacks are for devices that implement their own
503 +        * tuning algorithms, rather than a simple swzigzag
504 +        */
505 +       enum dvbfe_search (*search)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
506 +       int (*track)(struct dvb_frontend *fe, struct dvb_frontend_parameters *p);
507  
508         struct dvb_tuner_ops tuner_ops;
509 +       struct analog_demod_ops analog_ops;
510 +
511 +       int (*set_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
512 +       int (*get_property)(struct dvb_frontend* fe, struct dtv_property* tvp);
513  };
514  
515  #define MAX_EVENT 8
516 @@ -138,22 +315,72 @@
517         int                       eventr;
518         int                       overflow;
519         wait_queue_head_t         wait_queue;
520 -       struct semaphore          sem;
521 +       struct mutex              mtx;
522 +};
523 +
524 +struct dtv_frontend_properties {
525 +
526 +       /* Cache State */
527 +       u32                     state;
528 +
529 +       u32                     frequency;
530 +       fe_modulation_t         modulation;
531 +
532 +       fe_sec_voltage_t        voltage;
533 +       fe_sec_tone_mode_t      sectone;
534 +       fe_spectral_inversion_t inversion;
535 +       fe_code_rate_t          fec_inner;
536 +       fe_transmit_mode_t      transmission_mode;
537 +       u32                     bandwidth_hz;   /* 0 = AUTO */
538 +       fe_guard_interval_t     guard_interval;
539 +       fe_hierarchy_t          hierarchy;
540 +       u32                     symbol_rate;
541 +       fe_code_rate_t          code_rate_HP;
542 +       fe_code_rate_t          code_rate_LP;
543 +
544 +       fe_pilot_t              pilot;
545 +       fe_rolloff_t            rolloff;
546 +
547 +       fe_delivery_system_t    delivery_system;
548 +
549 +       /* ISDB-T specifics */
550 +       u8                      isdbt_partial_reception;
551 +       u8                      isdbt_sb_mode;
552 +       u8                      isdbt_sb_subchannel;
553 +       u32                     isdbt_sb_segment_idx;
554 +       u32                     isdbt_sb_segment_count;
555 +       u8                      isdbt_layer_enabled;
556 +       struct {
557 +           u8                  segment_count;
558 +           fe_code_rate_t      fec;
559 +           fe_modulation_t     modulation;
560 +           u8                  interleaving;
561 +       } layer[3];
562 +
563 +       /* ISDB-T specifics */
564 +       u32                     isdbs_ts_id;
565  };
566  
567  struct dvb_frontend {
568         struct dvb_frontend_ops ops;
569         struct dvb_adapter *dvb;
570 -       void* demodulator_priv;
571 -       void* tuner_priv;
572 -       void* frontend_priv;
573 -       void* misc_priv;
574 +       void *demodulator_priv;
575 +       void *tuner_priv;
576 +       void *frontend_priv;
577 +       void *sec_priv;
578 +       void *analog_demod_priv;
579 +       struct dtv_frontend_properties dtv_property_cache;
580 +#define DVB_FRONTEND_COMPONENT_TUNER 0
581 +       int (*callback)(void *adapter_priv, int component, int cmd, int arg);
582 +       int id;
583  };
584  
585 -extern int dvb_register_frontend(struct dvb_adapter* dvb,
586 -                                struct dvb_frontend* fe);
587 +extern int dvb_register_frontend(struct dvb_adapter *dvb,
588 +                                struct dvb_frontend *fe);
589 +
590 +extern int dvb_unregister_frontend(struct dvb_frontend *fe);
591  
592 -extern int dvb_unregister_frontend(struct dvb_frontend* fe);
593 +extern void dvb_frontend_detach(struct dvb_frontend *fe);
594  
595  extern void dvb_frontend_reinitialise(struct dvb_frontend *fe);
596  
597 diff -Naur linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_net.h linux-2.6.18/drivers/media/dvb/dvb-core/dvb_net.h
598 --- linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_net.h      2006-09-20 03:42:06.000000000 +0000
599 +++ linux-2.6.18/drivers/media/dvb/dvb-core/dvb_net.h   2010-09-09 12:38:50.000000000 +0000
600 @@ -36,6 +36,7 @@
601         struct dvb_device *dvbdev;
602         struct net_device *device[DVB_NET_DEVICES_MAX];
603         int state[DVB_NET_DEVICES_MAX];
604 +       unsigned int exit:1;
605         struct dmx_demux *demux;
606  };
607  
608 diff -Naur linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_ringbuffer.h linux-2.6.18/drivers/media/dvb/dvb-core/dvb_ringbuffer.h
609 --- linux-2.6.18/drivers/media/dvb.orig/dvb-core/dvb_ringbuffer.h       2006-09-20 03:42:06.000000000 +0000
610 +++ linux-2.6.18/drivers/media/dvb/dvb-core/dvb_ringbuffer.h    2010-09-10 11:57:24.000000000 +0000
611 @@ -38,6 +38,7 @@
612         int               error;
613  
614         wait_queue_head_t queue;
615 +       int               do_wait;
616         spinlock_t        lock;
617  };
618  
619 @@ -61,7 +62,7 @@
620  **     *** read min. 1000, max. <bufsize> bytes ***
621  **     avail = dvb_ringbuffer_avail(rbuf);
622  **     if (avail >= 1000)
623 -**         count = dvb_ringbuffer_read(rbuf, buffer, min(avail, bufsize), 0);
624 +**         count = dvb_ringbuffer_read(rbuf, buffer, min(avail, bufsize));
625  **     else
626  **         ...
627  **
628 @@ -69,6 +70,7 @@
629  **     to lock read or write operations.
630  **     Two or more readers must be locked against each other.
631  **     Flushing the buffer counts as a read operation.
632 +**     Resetting the buffer counts as a read and write operation.
633  **     Two or more writers must be locked against each other.
634  */
635  
636 @@ -85,6 +87,13 @@
637  extern ssize_t dvb_ringbuffer_avail(struct dvb_ringbuffer *rbuf);
638  
639  
640 +/*
641 +** Reset the read and write pointers to zero and flush the buffer
642 +** This counts as a read and write operation
643 +*/
644 +extern void dvb_ringbuffer_reset(struct dvb_ringbuffer *rbuf);
645 +
646 +
647  /* read routines & macros */
648  /* ---------------------- */
649  /* flush buffer */
650 @@ -106,8 +115,10 @@
651  ** <usermem> specifies whether <buf> resides in user space
652  ** returns number of bytes transferred or -EFAULT
653  */
654 -extern ssize_t dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf, u8 *buf,
655 -                                  size_t len, int usermem);
656 +extern ssize_t dvb_ringbuffer_read_user(struct dvb_ringbuffer *rbuf,
657 +                                  u8 __user *buf, size_t len);
658 +extern void dvb_ringbuffer_read(struct dvb_ringbuffer *rbuf,
659 +                                  u8 *buf, size_t len);
660  
661  
662  /* write routines & macros */
663 @@ -149,8 +160,10 @@
664   * <usermem> Set to 1 if <buf> is in userspace.
665   * returns Number of bytes read, or -EFAULT.
666   */
667 +extern ssize_t dvb_ringbuffer_pkt_read_user(struct dvb_ringbuffer *rbuf, size_t idx,
668 +                                      int offset, u8 __user *buf, size_t len);
669  extern ssize_t dvb_ringbuffer_pkt_read(struct dvb_ringbuffer *rbuf, size_t idx,
670 -                                      int offset, u8* buf, size_t len, int usermem);
671 +                                      int offset, u8 *buf, size_t len);
672  
673  /**
674   * Dispose of a packet in the ring buffer.