From: Antti Palosaari Date: Tue, 29 May 2012 21:05:40 +0000 (-0300) Subject: [media] dvb_usb_v2: move PID filters from frontend to adapter X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=e46c5b66da84d8eccf4566216f0582964a28b73e;p=openwrt%2Fstaging%2Fblogic.git [media] dvb_usb_v2: move PID filters from frontend to adapter 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 Signed-off-by: Mauro Carvalho Chehab --- diff --git a/drivers/media/dvb/dvb-usb/dvb_usb.h b/drivers/media/dvb/dvb-usb/dvb_usb.h index 6ce97975bd03..ee6df793ce1b 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb.h +++ b/drivers/media/dvb/dvb-usb/dvb_usb.h @@ -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; diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c b/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c index 7fcbcc3e5b7f..980a1d30a2cb 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c @@ -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; diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_init.c b/drivers/media/dvb/dvb-usb/dvb_usb_init.c index 1441324a9115..0e26299c19ca 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_init.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_init.c @@ -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;