]> git.karo-electronics.de Git - linux-beck.git/commitdiff
[media] dvb_usb_v2: move PID filters from frontend to adapter
authorAntti Palosaari <crope@iki.fi>
Tue, 29 May 2012 21:05:40 +0000 (18:05 -0300)
committerMauro Carvalho Chehab <mchehab@redhat.com>
Sat, 4 Aug 2012 10:56:24 +0000 (07:56 -0300)
Filtering given PIDs from the transport stream is done by the
DVB USB bridge. It is highly possible there is limitations what
kind of stream DVB USB bridge can PID filter, but it still does
not make sense to define filters for each frontend as frontend
could offer different stream types for different standards.

Likely new way is to enable / disable PID filters are needed to
make decision at runtime (callback). PID filters are quite legacy
stuff as those are aimed cut stream smaller to fit for the USB1.1...

Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
drivers/media/dvb/dvb-usb/dvb_usb.h
drivers/media/dvb/dvb-usb/dvb_usb_dvb.c
drivers/media/dvb/dvb-usb/dvb_usb_init.c

index 6ce97975bd03e7e2c68a97bbd74939506580054a..ee6df793ce1bfc6c870b754861ffc400269e2bde 100644 (file)
@@ -114,17 +114,7 @@ struct usb_data_stream_properties {
  * @stream: configuration of the USB streaming
  */
 struct dvb_usb_adapter_fe_properties {
-#define DVB_USB_ADAP_HAS_PID_FILTER               0x01
-#define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
-#define DVB_USB_ADAP_NEED_PID_FILTERING           0x04
-#define DVB_USB_ADAP_RECEIVES_204_BYTE_TS         0x08
-#define DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD         0x10
-       int caps;
-       int pid_filter_count;
-
        int (*streaming_ctrl)  (struct dvb_usb_adapter *, int);
-       int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
-       int (*pid_filter)      (struct dvb_usb_adapter *, int, u16, int);
 
        int (*frontend_attach) (struct dvb_usb_adapter *);
        int (*tuner_attach)    (struct dvb_usb_adapter *);
@@ -134,8 +124,18 @@ struct dvb_usb_adapter_fe_properties {
 
 #define MAX_NO_OF_FE_PER_ADAP 3
 struct dvb_usb_adapter_properties {
+#define DVB_USB_ADAP_HAS_PID_FILTER               0x01
+#define DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF 0x02
+#define DVB_USB_ADAP_NEED_PID_FILTERING           0x04
+#define DVB_USB_ADAP_RECEIVES_204_BYTE_TS         0x08
+#define DVB_USB_ADAP_RECEIVES_RAW_PAYLOAD         0x10
+       int caps;
        int size_of_priv;
 
+       int pid_filter_count;
+       int (*pid_filter_ctrl) (struct dvb_usb_adapter *, int);
+       int (*pid_filter) (struct dvb_usb_adapter *, int, u16, int);
+
        int (*frontend_ctrl)   (struct dvb_frontend *, int);
        int (*fe_ioctl_override) (struct dvb_frontend *,
                                  unsigned int, void *, unsigned int);
@@ -314,24 +314,21 @@ struct dvb_usb_fe_adapter {
        int (*fe_init)  (struct dvb_frontend *);
        int (*fe_sleep) (struct dvb_frontend *);
 
-       int pid_filtering;
-       int max_feed_count;
-
        void *priv;
 };
 
 struct dvb_usb_adapter {
-       struct dvb_usb_device *dev;
-       struct dvb_usb_adapter_properties props;
-       struct usb_data_stream stream;
-
 #define DVB_USB_ADAP_STATE_INIT 0x000
 #define DVB_USB_ADAP_STATE_DVB  0x001
        int state;
-
+       struct dvb_usb_device *dev;
+       struct dvb_usb_adapter_properties props;
+       struct usb_data_stream stream;
        u8  id;
 
+       int pid_filtering;
        int feedcount;
+       int max_feed_count;
 
        /* dvb */
        struct dvb_adapter   dvb_adap;
index 7fcbcc3e5b7fabcbe36973afdaaf87b0c53ff062..980a1d30a2cbc60805b5191f69f97bd5f317fffa 100644 (file)
@@ -97,14 +97,14 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
 
        /* activate the pid on the device specific pid_filter */
        deb_ts("setting pid (%s): %5d %04x at index %d '%s'\n",
-               adap->fe_adap[adap->active_fe].pid_filtering ?
+               adap->pid_filtering ?
                "yes" : "no", dvbdmxfeed->pid, dvbdmxfeed->pid,
                dvbdmxfeed->index, onoff ? "on" : "off");
-       if (adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_HAS_PID_FILTER &&
-               adap->fe_adap[adap->active_fe].pid_filtering &&
-               adap->props.fe[adap->active_fe].pid_filter != NULL)
-               adap->props.fe[adap->active_fe].pid_filter(adap,
-                       dvbdmxfeed->index, dvbdmxfeed->pid, onoff);
+       if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER &&
+                       adap->pid_filtering &&
+                       adap->props.pid_filter != NULL)
+               adap->props.pid_filter(adap, dvbdmxfeed->index,
+                               dvbdmxfeed->pid, onoff);
 
        /* start the feed if this was the first feed and there is still a feed
         * for reception.
@@ -146,13 +146,13 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
                usb_urb_submit(&adap->stream, &stream_props);
 
                deb_ts("controlling pid parser\n");
-               if (adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_HAS_PID_FILTER &&
-                       adap->props.fe[adap->active_fe].caps &
+               if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER &&
+                       adap->props.caps &
                        DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF &&
-                       adap->props.fe[adap->active_fe].pid_filter_ctrl != NULL) {
-                       ret = adap->props.fe[adap->active_fe].pid_filter_ctrl(
+                       adap->props.pid_filter_ctrl != NULL) {
+                       ret = adap->props.pid_filter_ctrl(
                                adap,
-                               adap->fe_adap[adap->active_fe].pid_filtering);
+                               adap->pid_filtering);
                        if (ret < 0) {
                                err("could not handle pid_parser");
                                return ret;
@@ -214,8 +214,8 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap)
 
        adap->demux.filternum        = 0;
        for (i = 0; i < adap->props.num_frontends; i++) {
-               if (adap->demux.filternum < adap->fe_adap[i].max_feed_count)
-                       adap->demux.filternum = adap->fe_adap[i].max_feed_count;
+               if (adap->demux.filternum < adap->max_feed_count)
+                       adap->demux.filternum = adap->max_feed_count;
        }
        adap->demux.feednum          = adap->demux.filternum;
        adap->demux.start_feed       = dvb_usb_start_feed;
index 1441324a911566451123ee2218e035b7dcc2521f..0e26299c19cac7ebc662582d179ad6a97102b5e6 100644 (file)
@@ -34,7 +34,7 @@ MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a" \
 static int dvb_usb_adapter_init(struct dvb_usb_device *d)
 {
        struct dvb_usb_adapter *adap;
-       int ret, n, o, adapter_count;
+       int ret, n, adapter_count;
 
        /* resolve adapter count */
        adapter_count = d->props.num_adapters;
@@ -54,57 +54,37 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d)
                memcpy(&adap->props, &d->props.adapter[n],
                                sizeof(struct dvb_usb_adapter_properties));
 
-               for (o = 0; o < adap->props.num_frontends; o++) {
-                       struct dvb_usb_adapter_fe_properties *props =
-                                       &adap->props.fe[o];
-                       /* speed - when running at FULL speed we need a HW
-                        * PID filter */
-                       if (d->udev->speed == USB_SPEED_FULL &&
-                                       !(props->caps & DVB_USB_ADAP_HAS_PID_FILTER)) {
-                               err("This USB2.0 device cannot be run on a" \
-                                       " USB1.1 port. (it lacks a" \
-                                       " hardware PID filter)");
-                               return -ENODEV;
-                       }
-
-                       if ((d->udev->speed == USB_SPEED_FULL &&
-                                       props->caps & DVB_USB_ADAP_HAS_PID_FILTER) ||
-                                       (props->caps & DVB_USB_ADAP_NEED_PID_FILTERING)) {
-                               info("will use the device's hardware PID" \
-                                       " filter (table count: %d).",
-                                       props->pid_filter_count);
-                               adap->fe_adap[o].pid_filtering  = 1;
-                               adap->fe_adap[o].max_feed_count =
-                                               props->pid_filter_count;
-                       } else {
-                               info("will pass the complete MPEG2 transport" \
-                                       " stream to the software demuxer.");
-                               adap->fe_adap[o].pid_filtering  = 0;
-                               adap->fe_adap[o].max_feed_count = 255;
-                       }
+               /* speed - when running at FULL speed we need a HW PID filter */
+               if (d->udev->speed == USB_SPEED_FULL &&
+                               !(adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER)) {
+                       err("This USB2.0 device cannot be run on a" \
+                               " USB1.1 port. (it lacks a" \
+                               " hardware PID filter)");
+                       return -ENODEV;
+               } else if ((d->udev->speed == USB_SPEED_FULL &&
+                               adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) ||
+                               (adap->props.caps & DVB_USB_ADAP_NEED_PID_FILTERING)) {
+                       info("will use the device's hardware PID" \
+                               " filter (table count: %d).",
+                               adap->props.pid_filter_count);
+                       adap->pid_filtering  = 1;
+                       adap->max_feed_count = adap->props.pid_filter_count;
+               } else {
+                       info("will pass the complete MPEG2 transport" \
+                               " stream to the software demuxer.");
+                       adap->pid_filtering  = 0;
+                       adap->max_feed_count = 255;
+               }
 
-                       if (!adap->fe_adap[o].pid_filtering &&
-                                       dvb_usb_force_pid_filter_usage &&
-                                       props->caps & DVB_USB_ADAP_HAS_PID_FILTER) {
+               if (!adap->pid_filtering && dvb_usb_force_pid_filter_usage &&
+                               adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) {
                                info("pid filter enabled by module option.");
-                               adap->fe_adap[o].pid_filtering  = 1;
-                               adap->fe_adap[o].max_feed_count =
-                                               props->pid_filter_count;
-                       }
-
-                       if (props->size_of_priv > 0) {
-                               adap->fe_adap[o].priv = kzalloc(props->size_of_priv, GFP_KERNEL);
-                               if (adap->fe_adap[o].priv == NULL) {
-                                       err("no memory for priv for adapter" \
-                                               " %d fe %d.", n, o);
-                                       return -ENOMEM;
-                               }
-                       }
+                       adap->pid_filtering  = 1;
+                       adap->max_feed_count = adap->props.pid_filter_count;
                }
 
                if (adap->props.size_of_priv > 0) {
-                       adap->priv = kzalloc(adap->props.size_of_priv,
-                                       GFP_KERNEL);
+                       adap->priv = kzalloc(adap->props.size_of_priv, GFP_KERNEL);
                        if (adap->priv == NULL) {
                                err("no memory for priv for adapter %d.", n);
                                return -ENOMEM;