Commit e46c5b66 authored by Antti Palosaari's avatar Antti Palosaari Committed by Mauro Carvalho Chehab

[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: default avatarAntti Palosaari <crope@iki.fi>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent 3024985d
...@@ -114,17 +114,7 @@ struct usb_data_stream_properties { ...@@ -114,17 +114,7 @@ struct usb_data_stream_properties {
* @stream: configuration of the USB streaming * @stream: configuration of the USB streaming
*/ */
struct dvb_usb_adapter_fe_properties { 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 (*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 (*frontend_attach) (struct dvb_usb_adapter *);
int (*tuner_attach) (struct dvb_usb_adapter *); int (*tuner_attach) (struct dvb_usb_adapter *);
...@@ -134,8 +124,18 @@ struct dvb_usb_adapter_fe_properties { ...@@ -134,8 +124,18 @@ struct dvb_usb_adapter_fe_properties {
#define MAX_NO_OF_FE_PER_ADAP 3 #define MAX_NO_OF_FE_PER_ADAP 3
struct dvb_usb_adapter_properties { 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 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 (*frontend_ctrl) (struct dvb_frontend *, int);
int (*fe_ioctl_override) (struct dvb_frontend *, int (*fe_ioctl_override) (struct dvb_frontend *,
unsigned int, void *, unsigned int); unsigned int, void *, unsigned int);
...@@ -314,24 +314,21 @@ struct dvb_usb_fe_adapter { ...@@ -314,24 +314,21 @@ struct dvb_usb_fe_adapter {
int (*fe_init) (struct dvb_frontend *); int (*fe_init) (struct dvb_frontend *);
int (*fe_sleep) (struct dvb_frontend *); int (*fe_sleep) (struct dvb_frontend *);
int pid_filtering;
int max_feed_count;
void *priv; void *priv;
}; };
struct dvb_usb_adapter { 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_INIT 0x000
#define DVB_USB_ADAP_STATE_DVB 0x001 #define DVB_USB_ADAP_STATE_DVB 0x001
int state; int state;
struct dvb_usb_device *dev;
struct dvb_usb_adapter_properties props;
struct usb_data_stream stream;
u8 id; u8 id;
int pid_filtering;
int feedcount; int feedcount;
int max_feed_count;
/* dvb */ /* dvb */
struct dvb_adapter dvb_adap; struct dvb_adapter dvb_adap;
......
...@@ -97,14 +97,14 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ...@@ -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 */ /* activate the pid on the device specific pid_filter */
deb_ts("setting pid (%s): %5d %04x at index %d '%s'\n", 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, "yes" : "no", dvbdmxfeed->pid, dvbdmxfeed->pid,
dvbdmxfeed->index, onoff ? "on" : "off"); dvbdmxfeed->index, onoff ? "on" : "off");
if (adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_HAS_PID_FILTER && if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER &&
adap->fe_adap[adap->active_fe].pid_filtering && adap->pid_filtering &&
adap->props.fe[adap->active_fe].pid_filter != NULL) adap->props.pid_filter != NULL)
adap->props.fe[adap->active_fe].pid_filter(adap, adap->props.pid_filter(adap, dvbdmxfeed->index,
dvbdmxfeed->index, dvbdmxfeed->pid, onoff); dvbdmxfeed->pid, onoff);
/* start the feed if this was the first feed and there is still a feed /* start the feed if this was the first feed and there is still a feed
* for reception. * for reception.
...@@ -146,13 +146,13 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) ...@@ -146,13 +146,13 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff)
usb_urb_submit(&adap->stream, &stream_props); usb_urb_submit(&adap->stream, &stream_props);
deb_ts("controlling pid parser\n"); deb_ts("controlling pid parser\n");
if (adap->props.fe[adap->active_fe].caps & DVB_USB_ADAP_HAS_PID_FILTER && if (adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER &&
adap->props.fe[adap->active_fe].caps & adap->props.caps &
DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF && DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF &&
adap->props.fe[adap->active_fe].pid_filter_ctrl != NULL) { adap->props.pid_filter_ctrl != NULL) {
ret = adap->props.fe[adap->active_fe].pid_filter_ctrl( ret = adap->props.pid_filter_ctrl(
adap, adap,
adap->fe_adap[adap->active_fe].pid_filtering); adap->pid_filtering);
if (ret < 0) { if (ret < 0) {
err("could not handle pid_parser"); err("could not handle pid_parser");
return ret; return ret;
...@@ -214,8 +214,8 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap) ...@@ -214,8 +214,8 @@ int dvb_usb_adapter_dvb_init(struct dvb_usb_adapter *adap)
adap->demux.filternum = 0; adap->demux.filternum = 0;
for (i = 0; i < adap->props.num_frontends; i++) { for (i = 0; i < adap->props.num_frontends; i++) {
if (adap->demux.filternum < adap->fe_adap[i].max_feed_count) if (adap->demux.filternum < adap->max_feed_count)
adap->demux.filternum = adap->fe_adap[i].max_feed_count; adap->demux.filternum = adap->max_feed_count;
} }
adap->demux.feednum = adap->demux.filternum; adap->demux.feednum = adap->demux.filternum;
adap->demux.start_feed = dvb_usb_start_feed; adap->demux.start_feed = dvb_usb_start_feed;
......
...@@ -34,7 +34,7 @@ MODULE_PARM_DESC(force_pid_filter_usage, "force all dvb-usb-devices to use a" \ ...@@ -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) static int dvb_usb_adapter_init(struct dvb_usb_device *d)
{ {
struct dvb_usb_adapter *adap; struct dvb_usb_adapter *adap;
int ret, n, o, adapter_count; int ret, n, adapter_count;
/* resolve adapter count */ /* resolve adapter count */
adapter_count = d->props.num_adapters; adapter_count = d->props.num_adapters;
...@@ -54,57 +54,37 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d) ...@@ -54,57 +54,37 @@ static int dvb_usb_adapter_init(struct dvb_usb_device *d)
memcpy(&adap->props, &d->props.adapter[n], memcpy(&adap->props, &d->props.adapter[n],
sizeof(struct dvb_usb_adapter_properties)); sizeof(struct dvb_usb_adapter_properties));
for (o = 0; o < adap->props.num_frontends; o++) { /* speed - when running at FULL speed we need a HW PID filter */
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 && if (d->udev->speed == USB_SPEED_FULL &&
!(props->caps & DVB_USB_ADAP_HAS_PID_FILTER)) { !(adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER)) {
err("This USB2.0 device cannot be run on a" \ err("This USB2.0 device cannot be run on a" \
" USB1.1 port. (it lacks a" \ " USB1.1 port. (it lacks a" \
" hardware PID filter)"); " hardware PID filter)");
return -ENODEV; return -ENODEV;
} } else if ((d->udev->speed == USB_SPEED_FULL &&
adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) ||
if ((d->udev->speed == USB_SPEED_FULL && (adap->props.caps & DVB_USB_ADAP_NEED_PID_FILTERING)) {
props->caps & DVB_USB_ADAP_HAS_PID_FILTER) ||
(props->caps & DVB_USB_ADAP_NEED_PID_FILTERING)) {
info("will use the device's hardware PID" \ info("will use the device's hardware PID" \
" filter (table count: %d).", " filter (table count: %d).",
props->pid_filter_count); adap->props.pid_filter_count);
adap->fe_adap[o].pid_filtering = 1; adap->pid_filtering = 1;
adap->fe_adap[o].max_feed_count = adap->max_feed_count = adap->props.pid_filter_count;
props->pid_filter_count;
} else { } else {
info("will pass the complete MPEG2 transport" \ info("will pass the complete MPEG2 transport" \
" stream to the software demuxer."); " stream to the software demuxer.");
adap->fe_adap[o].pid_filtering = 0; adap->pid_filtering = 0;
adap->fe_adap[o].max_feed_count = 255; adap->max_feed_count = 255;
} }
if (!adap->fe_adap[o].pid_filtering && if (!adap->pid_filtering && dvb_usb_force_pid_filter_usage &&
dvb_usb_force_pid_filter_usage && adap->props.caps & DVB_USB_ADAP_HAS_PID_FILTER) {
props->caps & DVB_USB_ADAP_HAS_PID_FILTER) {
info("pid filter enabled by module option."); info("pid filter enabled by module option.");
adap->fe_adap[o].pid_filtering = 1; adap->pid_filtering = 1;
adap->fe_adap[o].max_feed_count = adap->max_feed_count = adap->props.pid_filter_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;
}
}
} }
if (adap->props.size_of_priv > 0) { if (adap->props.size_of_priv > 0) {
adap->priv = kzalloc(adap->props.size_of_priv, adap->priv = kzalloc(adap->props.size_of_priv, GFP_KERNEL);
GFP_KERNEL);
if (adap->priv == NULL) { if (adap->priv == NULL) {
err("no memory for priv for adapter %d.", n); err("no memory for priv for adapter %d.", n);
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment