[media] davinci: convert vpif_display to core-assisted locking
vpif_display now uses .unlocked_ioctl instead of .ioctl. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Manjunath Hadli <manjunath.hadli@ti.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
46656afa8a
commit
9bfaae24f9
@ -652,9 +652,6 @@ static int vpif_release(struct file *filep)
|
|||||||
struct channel_obj *ch = fh->channel;
|
struct channel_obj *ch = fh->channel;
|
||||||
struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
|
struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&common->lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
|
|
||||||
/* if this instance is doing IO */
|
/* if this instance is doing IO */
|
||||||
if (fh->io_allowed[VPIF_VIDEO_INDEX]) {
|
if (fh->io_allowed[VPIF_VIDEO_INDEX]) {
|
||||||
/* Reset io_usrs member of channel object */
|
/* Reset io_usrs member of channel object */
|
||||||
@ -677,8 +674,6 @@ static int vpif_release(struct file *filep)
|
|||||||
config_params.numbuffers[ch->channel_id];
|
config_params.numbuffers[ch->channel_id];
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&common->lock);
|
|
||||||
|
|
||||||
/* Decrement channel usrs counter */
|
/* Decrement channel usrs counter */
|
||||||
atomic_dec(&ch->usrs);
|
atomic_dec(&ch->usrs);
|
||||||
/* If this file handle has initialize encoder device, reset it */
|
/* If this file handle has initialize encoder device, reset it */
|
||||||
@ -737,24 +732,15 @@ static int vpif_g_fmt_vid_out(struct file *file, void *priv,
|
|||||||
struct vpif_fh *fh = priv;
|
struct vpif_fh *fh = priv;
|
||||||
struct channel_obj *ch = fh->channel;
|
struct channel_obj *ch = fh->channel;
|
||||||
struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
|
struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
/* Check the validity of the buffer type */
|
/* Check the validity of the buffer type */
|
||||||
if (common->fmt.type != fmt->type)
|
if (common->fmt.type != fmt->type)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
/* Fill in the information about format */
|
|
||||||
if (mutex_lock_interruptible(&common->lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
|
|
||||||
if (vpif_update_resolution(ch))
|
if (vpif_update_resolution(ch))
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
else
|
*fmt = common->fmt;
|
||||||
*fmt = common->fmt;
|
return 0;
|
||||||
|
|
||||||
mutex_unlock(&common->lock);
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vpif_s_fmt_vid_out(struct file *file, void *priv,
|
static int vpif_s_fmt_vid_out(struct file *file, void *priv,
|
||||||
@ -794,12 +780,7 @@ static int vpif_s_fmt_vid_out(struct file *file, void *priv,
|
|||||||
/* store the pix format in the channel object */
|
/* store the pix format in the channel object */
|
||||||
common->fmt.fmt.pix = *pixfmt;
|
common->fmt.fmt.pix = *pixfmt;
|
||||||
/* store the format in the channel object */
|
/* store the format in the channel object */
|
||||||
if (mutex_lock_interruptible(&common->lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
|
|
||||||
common->fmt = *fmt;
|
common->fmt = *fmt;
|
||||||
mutex_unlock(&common->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -829,7 +810,6 @@ static int vpif_reqbufs(struct file *file, void *priv,
|
|||||||
struct common_obj *common;
|
struct common_obj *common;
|
||||||
enum v4l2_field field;
|
enum v4l2_field field;
|
||||||
u8 index = 0;
|
u8 index = 0;
|
||||||
int ret = 0;
|
|
||||||
|
|
||||||
/* This file handle has not initialized the channel,
|
/* This file handle has not initialized the channel,
|
||||||
It is not allowed to do settings */
|
It is not allowed to do settings */
|
||||||
@ -847,18 +827,12 @@ static int vpif_reqbufs(struct file *file, void *priv,
|
|||||||
index = VPIF_VIDEO_INDEX;
|
index = VPIF_VIDEO_INDEX;
|
||||||
|
|
||||||
common = &ch->common[index];
|
common = &ch->common[index];
|
||||||
if (mutex_lock_interruptible(&common->lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
|
|
||||||
if (common->fmt.type != reqbuf->type) {
|
if (common->fmt.type != reqbuf->type)
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto reqbuf_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (0 != common->io_usrs) {
|
if (0 != common->io_usrs)
|
||||||
ret = -EBUSY;
|
return -EBUSY;
|
||||||
goto reqbuf_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (reqbuf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
|
if (reqbuf->type == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
|
||||||
if (common->fmt.fmt.pix.field == V4L2_FIELD_ANY)
|
if (common->fmt.fmt.pix.field == V4L2_FIELD_ANY)
|
||||||
@ -875,7 +849,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
|
|||||||
&common->irqlock,
|
&common->irqlock,
|
||||||
reqbuf->type, field,
|
reqbuf->type, field,
|
||||||
sizeof(struct videobuf_buffer), fh,
|
sizeof(struct videobuf_buffer), fh,
|
||||||
NULL);
|
&common->lock);
|
||||||
|
|
||||||
/* Set io allowed member of file handle to TRUE */
|
/* Set io allowed member of file handle to TRUE */
|
||||||
fh->io_allowed[index] = 1;
|
fh->io_allowed[index] = 1;
|
||||||
@ -886,11 +860,7 @@ static int vpif_reqbufs(struct file *file, void *priv,
|
|||||||
INIT_LIST_HEAD(&common->dma_queue);
|
INIT_LIST_HEAD(&common->dma_queue);
|
||||||
|
|
||||||
/* Allocate buffers */
|
/* Allocate buffers */
|
||||||
ret = videobuf_reqbufs(&common->buffer_queue, reqbuf);
|
return videobuf_reqbufs(&common->buffer_queue, reqbuf);
|
||||||
|
|
||||||
reqbuf_exit:
|
|
||||||
mutex_unlock(&common->lock);
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int vpif_querybuf(struct file *file, void *priv,
|
static int vpif_querybuf(struct file *file, void *priv,
|
||||||
@ -1011,25 +981,19 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Call encoder subdevice function to set the standard */
|
/* Call encoder subdevice function to set the standard */
|
||||||
if (mutex_lock_interruptible(&common->lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
|
|
||||||
ch->video.stdid = *std_id;
|
ch->video.stdid = *std_id;
|
||||||
ch->video.dv_preset = V4L2_DV_INVALID;
|
ch->video.dv_preset = V4L2_DV_INVALID;
|
||||||
memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings));
|
memset(&ch->video.bt_timings, 0, sizeof(ch->video.bt_timings));
|
||||||
|
|
||||||
/* Get the information about the standard */
|
/* Get the information about the standard */
|
||||||
if (vpif_update_resolution(ch)) {
|
if (vpif_update_resolution(ch))
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto s_std_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((ch->vpifparams.std_info.width *
|
if ((ch->vpifparams.std_info.width *
|
||||||
ch->vpifparams.std_info.height * 2) >
|
ch->vpifparams.std_info.height * 2) >
|
||||||
config_params.channel_bufsize[ch->channel_id]) {
|
config_params.channel_bufsize[ch->channel_id]) {
|
||||||
vpif_err("invalid std for this size\n");
|
vpif_err("invalid std for this size\n");
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto s_std_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
common->fmt.fmt.pix.bytesperline = common->fmt.fmt.pix.width;
|
common->fmt.fmt.pix.bytesperline = common->fmt.fmt.pix.width;
|
||||||
@ -1040,16 +1004,13 @@ static int vpif_s_std(struct file *file, void *priv, v4l2_std_id *std_id)
|
|||||||
s_std_output, *std_id);
|
s_std_output, *std_id);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
vpif_err("Failed to set output standard\n");
|
vpif_err("Failed to set output standard\n");
|
||||||
goto s_std_exit;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, core,
|
ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, core,
|
||||||
s_std, *std_id);
|
s_std, *std_id);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
vpif_err("Failed to set standard for sub devices\n");
|
vpif_err("Failed to set standard for sub devices\n");
|
||||||
|
|
||||||
s_std_exit:
|
|
||||||
mutex_unlock(&common->lock);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1121,14 +1082,10 @@ static int vpif_streamon(struct file *file, void *priv,
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&common->lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
|
|
||||||
/* If buffer queue is empty, return error */
|
/* If buffer queue is empty, return error */
|
||||||
if (list_empty(&common->dma_queue)) {
|
if (list_empty(&common->dma_queue)) {
|
||||||
vpif_err("buffer queue is empty\n");
|
vpif_err("buffer queue is empty\n");
|
||||||
ret = -EIO;
|
return -EIO;
|
||||||
goto streamon_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get the next frame from the buffer queue */
|
/* Get the next frame from the buffer queue */
|
||||||
@ -1154,8 +1111,7 @@ static int vpif_streamon(struct file *file, void *priv,
|
|||||||
|| (!ch->vpifparams.std_info.frm_fmt
|
|| (!ch->vpifparams.std_info.frm_fmt
|
||||||
&& (common->fmt.fmt.pix.field == V4L2_FIELD_NONE))) {
|
&& (common->fmt.fmt.pix.field == V4L2_FIELD_NONE))) {
|
||||||
vpif_err("conflict in field format and std format\n");
|
vpif_err("conflict in field format and std format\n");
|
||||||
ret = -EINVAL;
|
return -EINVAL;
|
||||||
goto streamon_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clock settings */
|
/* clock settings */
|
||||||
@ -1164,13 +1120,13 @@ static int vpif_streamon(struct file *file, void *priv,
|
|||||||
ch->vpifparams.std_info.hd_sd);
|
ch->vpifparams.std_info.hd_sd);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
vpif_err("can't set clock\n");
|
vpif_err("can't set clock\n");
|
||||||
goto streamon_exit;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* set the parameters and addresses */
|
/* set the parameters and addresses */
|
||||||
ret = vpif_set_video_params(vpif, ch->channel_id + 2);
|
ret = vpif_set_video_params(vpif, ch->channel_id + 2);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto streamon_exit;
|
return ret;
|
||||||
|
|
||||||
common->started = ret;
|
common->started = ret;
|
||||||
vpif_config_addr(ch, ret);
|
vpif_config_addr(ch, ret);
|
||||||
@ -1195,9 +1151,6 @@ static int vpif_streamon(struct file *file, void *priv,
|
|||||||
}
|
}
|
||||||
channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1;
|
channel_first_int[VPIF_VIDEO_INDEX][ch->channel_id] = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
streamon_exit:
|
|
||||||
mutex_unlock(&common->lock);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1223,9 +1176,6 @@ static int vpif_streamoff(struct file *file, void *priv,
|
|||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&common->lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
|
|
||||||
if (buftype == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
|
if (buftype == V4L2_BUF_TYPE_VIDEO_OUTPUT) {
|
||||||
/* disable channel */
|
/* disable channel */
|
||||||
if (VPIF_CHANNEL2_VIDEO == ch->channel_id) {
|
if (VPIF_CHANNEL2_VIDEO == ch->channel_id) {
|
||||||
@ -1240,8 +1190,6 @@ static int vpif_streamoff(struct file *file, void *priv,
|
|||||||
}
|
}
|
||||||
|
|
||||||
common->started = 0;
|
common->started = 0;
|
||||||
mutex_unlock(&common->lock);
|
|
||||||
|
|
||||||
return videobuf_streamoff(&common->buffer_queue);
|
return videobuf_streamoff(&common->buffer_queue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1288,13 +1236,9 @@ static int vpif_s_output(struct file *file, void *priv, unsigned int i)
|
|||||||
struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
|
struct common_obj *common = &ch->common[VPIF_VIDEO_INDEX];
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
|
||||||
if (mutex_lock_interruptible(&common->lock))
|
|
||||||
return -ERESTARTSYS;
|
|
||||||
|
|
||||||
if (common->started) {
|
if (common->started) {
|
||||||
vpif_err("Streaming in progress\n");
|
vpif_err("Streaming in progress\n");
|
||||||
ret = -EBUSY;
|
return -EBUSY;
|
||||||
goto s_output_exit;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, video,
|
ret = v4l2_device_call_until_err(&vpif_obj.v4l2_dev, 1, video,
|
||||||
@ -1304,9 +1248,6 @@ static int vpif_s_output(struct file *file, void *priv, unsigned int i)
|
|||||||
vpif_err("Failed to set output standard\n");
|
vpif_err("Failed to set output standard\n");
|
||||||
|
|
||||||
vid_ch->output_id = i;
|
vid_ch->output_id = i;
|
||||||
|
|
||||||
s_output_exit:
|
|
||||||
mutex_unlock(&common->lock);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1658,7 +1599,7 @@ static const struct v4l2_file_operations vpif_fops = {
|
|||||||
.owner = THIS_MODULE,
|
.owner = THIS_MODULE,
|
||||||
.open = vpif_open,
|
.open = vpif_open,
|
||||||
.release = vpif_release,
|
.release = vpif_release,
|
||||||
.ioctl = video_ioctl2,
|
.unlocked_ioctl = video_ioctl2,
|
||||||
.mmap = vpif_mmap,
|
.mmap = vpif_mmap,
|
||||||
.poll = vpif_poll
|
.poll = vpif_poll
|
||||||
};
|
};
|
||||||
@ -1842,6 +1783,7 @@ static __init int vpif_probe(struct platform_device *pdev)
|
|||||||
v4l2_prio_init(&ch->prio);
|
v4l2_prio_init(&ch->prio);
|
||||||
ch->common[VPIF_VIDEO_INDEX].fmt.type =
|
ch->common[VPIF_VIDEO_INDEX].fmt.type =
|
||||||
V4L2_BUF_TYPE_VIDEO_OUTPUT;
|
V4L2_BUF_TYPE_VIDEO_OUTPUT;
|
||||||
|
ch->video_dev->lock = &common->lock;
|
||||||
|
|
||||||
/* register video device */
|
/* register video device */
|
||||||
vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n",
|
vpif_dbg(1, debug, "channel=%x,channel->video_dev=%x\n",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user