Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 366719
b: refs/heads/master
c: bdecbe4
h: refs/heads/master
i:
  366717: 74d5580
  366715: c8d3a3a
  366711: b359813
  366703: 6d8b53e
  366687: 96dfe1b
  366655: b218d38
  366591: 93d68ee
v: v3
  • Loading branch information
Antti Palosaari authored and Mauro Carvalho Chehab committed Mar 23, 2013
1 parent ea3a530 commit 4926f26
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 18 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 028c70ff42783509d3a7c7fa0faf900446a2657a
refs/heads/master: bdecbe43e345d1e5a0fa82625d7beb7c3371763e
5 changes: 4 additions & 1 deletion trunk/drivers/media/usb/dvb-usb-v2/dvb_usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,16 @@ struct dvb_usb_adapter {
u8 feed_count;
u8 max_feed_count;
s8 active_fe;
#define ADAP_INIT 0
#define ADAP_SLEEP 1
#define ADAP_STREAMING 2
unsigned long state_bits;

/* dvb */
struct dvb_adapter dvb_adap;
struct dmxdev dmxdev;
struct dvb_demux demux;
struct dvb_net dvb_net;
struct mutex sync_mutex;

struct dvb_frontend *fe[MAX_NO_OF_FE_PER_ADAP];
int (*fe_init[MAX_NO_OF_FE_PER_ADAP]) (struct dvb_frontend *);
Expand Down
53 changes: 37 additions & 16 deletions trunk/drivers/media/usb/dvb-usb-v2/dvb_usb_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,13 @@ static int dvb_usbv2_adapter_stream_exit(struct dvb_usb_adapter *adap)
return usb_urb_exitv2(&adap->stream);
}

static int wait_schedule(void *ptr)
{
schedule();

return 0;
}

static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
int count)
{
Expand All @@ -266,6 +273,9 @@ static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
dvbdmxfeed->pid, dvbdmxfeed->index,
(count == 1) ? "on" : "off");

wait_on_bit(&adap->state_bits, ADAP_INIT, wait_schedule,
TASK_UNINTERRUPTIBLE);

if (adap->active_fe == -1)
return -EINVAL;

Expand All @@ -283,11 +293,14 @@ static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
"failed=%d\n", KBUILD_MODNAME,
ret);
usb_urb_killv2(&adap->stream);
goto err_mutex_unlock;
goto err_clear_wait;
}
}
usb_urb_killv2(&adap->stream);
mutex_unlock(&adap->sync_mutex);

clear_bit(ADAP_STREAMING, &adap->state_bits);
smp_mb__after_clear_bit();
wake_up_bit(&adap->state_bits, ADAP_STREAMING);
}

/* activate the pid on the device pid filter */
Expand All @@ -303,7 +316,7 @@ static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
/* 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);
set_bit(ADAP_STREAMING, &adap->state_bits);
dev_dbg(&d->udev->dev, "%s: start feeding\n", __func__);

/* resolve input and output streaming paramters */
Expand All @@ -314,7 +327,7 @@ static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
adap->fe[adap->active_fe],
&adap->ts_type, &stream_props);
if (ret < 0)
goto err_mutex_unlock;
goto err_clear_wait;
} else {
stream_props = adap->props->stream;
}
Expand Down Expand Up @@ -344,7 +357,7 @@ static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
dev_err(&d->udev->dev, "%s: " \
"pid_filter_ctrl() failed=%d\n",
KBUILD_MODNAME, ret);
goto err_mutex_unlock;
goto err_clear_wait;
}
}

Expand All @@ -355,14 +368,16 @@ static inline int dvb_usb_ctrl_feed(struct dvb_demux_feed *dvbdmxfeed,
dev_err(&d->udev->dev, "%s: streaming_ctrl() " \
"failed=%d\n", KBUILD_MODNAME,
ret);
goto err_mutex_unlock;
goto err_clear_wait;
}
}
}

return 0;
err_mutex_unlock:
mutex_unlock(&adap->sync_mutex);
err_clear_wait:
clear_bit(ADAP_STREAMING, &adap->state_bits);
smp_mb__after_clear_bit();
wake_up_bit(&adap->state_bits, ADAP_STREAMING);
dev_dbg(&d->udev->dev, "%s: failed=%d\n", __func__, ret);
return ret;
}
Expand Down Expand Up @@ -435,8 +450,6 @@ static int dvb_usbv2_adapter_dvb_init(struct dvb_usb_adapter *adap)
goto err_dvb_net_init;
}

mutex_init(&adap->sync_mutex);

return 0;
err_dvb_net_init:
dvb_dmxdev_release(&adap->dmxdev);
Expand Down Expand Up @@ -500,7 +513,7 @@ static int dvb_usb_fe_init(struct dvb_frontend *fe)

if (!adap->suspend_resume_active) {
adap->active_fe = fe->id;
mutex_lock(&adap->sync_mutex);
set_bit(ADAP_INIT, &adap->state_bits);
}

ret = dvb_usbv2_device_power_ctrl(d, 1);
Expand All @@ -519,8 +532,11 @@ static int dvb_usb_fe_init(struct dvb_frontend *fe)
goto err;
}
err:
if (!adap->suspend_resume_active)
mutex_unlock(&adap->sync_mutex);
if (!adap->suspend_resume_active) {
clear_bit(ADAP_INIT, &adap->state_bits);
smp_mb__after_clear_bit();
wake_up_bit(&adap->state_bits, ADAP_INIT);
}

dev_dbg(&d->udev->dev, "%s: ret=%d\n", __func__, ret);
return ret;
Expand All @@ -534,8 +550,11 @@ static int dvb_usb_fe_sleep(struct dvb_frontend *fe)
dev_dbg(&d->udev->dev, "%s: adap=%d fe=%d\n", __func__, adap->id,
fe->id);

if (!adap->suspend_resume_active)
mutex_lock(&adap->sync_mutex);
if (!adap->suspend_resume_active) {
set_bit(ADAP_SLEEP, &adap->state_bits);
wait_on_bit(&adap->state_bits, ADAP_STREAMING, wait_schedule,
TASK_UNINTERRUPTIBLE);
}

if (adap->fe_sleep[fe->id]) {
ret = adap->fe_sleep[fe->id](fe);
Expand All @@ -555,7 +574,9 @@ static int dvb_usb_fe_sleep(struct dvb_frontend *fe)
err:
if (!adap->suspend_resume_active) {
adap->active_fe = -1;
mutex_unlock(&adap->sync_mutex);
clear_bit(ADAP_SLEEP, &adap->state_bits);
smp_mb__after_clear_bit();
wake_up_bit(&adap->state_bits, ADAP_SLEEP);
}

dev_dbg(&d->udev->dev, "%s: ret=%d\n", __func__, ret);
Expand Down

0 comments on commit 4926f26

Please sign in to comment.