diff options
author | Antti Palosaari <crope@iki.fi> | 2012-06-20 04:47:42 +0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2012-08-04 14:56:37 +0400 |
commit | 62a5f449cab52a458120ba5b046675ee2f81000f (patch) | |
tree | 6314d869d1cd81f91a3f0f6c49a5206f0aa26be7 /drivers/media/dvb/dvb-usb | |
parent | 5cd983200ae8cba06d6ff5f515f741a654b62cf1 (diff) | |
download | linux-62a5f449cab52a458120ba5b046675ee2f81000f.tar.xz |
[media] dvb_usb_v2: refactor dvb_usb_ctrl_feed() logic
Signed-off-by: Antti Palosaari <crope@iki.fi>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/dvb/dvb-usb')
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb_usb.h | 2 | ||||
-rw-r--r-- | drivers/media/dvb/dvb-usb/dvb_usb_dvb.c | 82 |
2 files changed, 36 insertions, 48 deletions
diff --git a/drivers/media/dvb/dvb-usb/dvb_usb.h b/drivers/media/dvb/dvb-usb/dvb_usb.h index 2bef8f4ab71a..a87a9ff579c4 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb.h +++ b/drivers/media/dvb/dvb-usb/dvb_usb.h @@ -300,7 +300,7 @@ struct dvb_usb_adapter { u8 id; u8 ts_type; int pid_filtering; - int feedcount; + int feed_count; int max_feed_count; /* sync frontend and streaming as those are different tasks */ diff --git a/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c b/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c index f87319c788c0..384fe8eec21f 100644 --- a/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c +++ b/drivers/media/dvb/dvb-usb/dvb_usb_dvb.c @@ -49,58 +49,54 @@ int dvb_usbv2_adapter_stream_exit(struct dvb_usb_adapter *adap) } /* does the complete input transfer handling */ -static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) +static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int count) { struct dvb_usb_adapter *adap = dvbdmxfeed->demux->priv; struct dvb_usb_device *d = adap_to_d(adap); - int newfeedcount, ret; - - if (adap == NULL) { - ret = -ENODEV; - goto err; - } + int ret; + pr_debug("%s: adap=%d active_fe=%d feed_type=%d setting pid [%s]: " \ + "%04x (%04d) at index %d '%s'\n", __func__, adap->id, + adap->active_fe, dvbdmxfeed->type, + adap->pid_filtering ? "yes" : "no", dvbdmxfeed->pid, + dvbdmxfeed->pid, dvbdmxfeed->index, + (count == 1) ? "on" : "off"); - pr_debug("%s: adap=%d active_fe=%d\n", __func__, adap->id, - adap->active_fe); + if (adap->active_fe == -1) + return -EINVAL; - newfeedcount = adap->feedcount + (onoff ? 1 : -1); + adap->feed_count += count; - /* stop feed before setting a new pid if there will be no pid anymore */ - if (newfeedcount == 0) { + /* stop feeding if it is last pid */ + if (adap->feed_count == 0) { pr_debug("%s: stop feeding\n", __func__); usb_urb_killv2(&adap->stream); - if (d->props->streaming_ctrl != NULL) { + if (d->props->streaming_ctrl) { ret = d->props->streaming_ctrl(adap, 0); if (ret < 0) { - pr_err("%s: error while stopping stream\n", - KBUILD_MODNAME); + pr_err("%s: streaming_ctrl() failed=%d\n", + KBUILD_MODNAME, ret); goto err_mutex_unlock; } } mutex_unlock(&adap->sync_mutex); } - adap->feedcount = newfeedcount; - - /* activate the pid on the device specific pid_filter */ - pr_debug("%s: setting pid (%s): %5d %04x at index %d '%s'\n", __func__, - adap->pid_filtering ? "yes" : "no", dvbdmxfeed->pid, - dvbdmxfeed->pid, dvbdmxfeed->index, - onoff ? "on" : "off"); + /* activate the pid on the device pid filter */ 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. - */ - if (adap->feedcount == onoff && adap->feedcount > 0) { + adap->props->pid_filter) + ret = adap->props->pid_filter(adap, dvbdmxfeed->index, + dvbdmxfeed->pid, (count == 1) ? 1 : 0); + if (ret < 0) + pr_err("%s: pid_filter() failed=%d\n", + KBUILD_MODNAME, ret); + + /* start feeding if it is first pid */ + if (adap->feed_count == 1 && count == 1) { struct usb_data_stream_properties stream_props; mutex_lock(&adap->sync_mutex); + pr_debug("%s: start feeding\n", __func__); /* resolve input and output streaming paramters */ if (d->props->get_stream_config) { @@ -128,54 +124,46 @@ static int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed, int onoff) break; } - pr_debug("%s: submitting all URBs\n", __func__); usb_urb_submitv2(&adap->stream, &stream_props); - pr_debug("%s: controlling pid parser\n", __func__); if (adap->props->caps & DVB_USB_ADAP_HAS_PID_FILTER && adap->props->caps & DVB_USB_ADAP_PID_FILTER_CAN_BE_TURNED_OFF && - adap->props->pid_filter_ctrl != NULL) { + adap->props->pid_filter_ctrl) { ret = adap->props->pid_filter_ctrl(adap, adap->pid_filtering); if (ret < 0) { - pr_err("%s: could not handle pid_parser\n", - KBUILD_MODNAME); + pr_err("%s: pid_filter_ctrl() failed=%d\n", + KBUILD_MODNAME, ret); goto err_mutex_unlock; } } - pr_debug("%s: start feeding\n", __func__); - if (d->props->streaming_ctrl != NULL) { + + if (d->props->streaming_ctrl) { ret = d->props->streaming_ctrl(adap, 1); if (ret < 0) { - pr_err("%s: error while enabling fifo\n", - KBUILD_MODNAME); + pr_err("%s: streaming_ctrl() failed=%d\n", + KBUILD_MODNAME, ret); goto err_mutex_unlock; } } - } return 0; err_mutex_unlock: mutex_unlock(&adap->sync_mutex); -err: pr_debug("%s: failed=%d\n", __func__, ret); return ret; } static int dvb_usb_start_feed(struct dvb_demux_feed *dvbdmxfeed) { - pr_debug("%s: start pid=%04x feedtype=%d\n", __func__, dvbdmxfeed->pid, - dvbdmxfeed->type); return dvb_usb_ctrl_feed(dvbdmxfeed, 1); } static int dvb_usb_stop_feed(struct dvb_demux_feed *dvbdmxfeed) { - pr_debug("%s: stop pid=%04x feedtype=%d\n", __func__, dvbdmxfeed->pid, - dvbdmxfeed->type); - return dvb_usb_ctrl_feed(dvbdmxfeed, 0); + return dvb_usb_ctrl_feed(dvbdmxfeed, -1); } int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap) |