Commit f0e91c65 authored by Lad, Prabhakar's avatar Lad, Prabhakar Committed by Mauro Carvalho Chehab

[media] media: blackfin: bfin_capture: use v4l2_fh_open and vb2_fop_release

this patch adds support to use v4l2_fh_open() and vb2_fop_release,
which allows to drop driver specific struct bcap_fh, as this is handled
by core.
Signed-off-by: default avatarLad, Prabhakar <prabhakar.csengg@gmail.com>
Tested-by: default avatarScott Jiang <scott.jiang.linux@gmail.com>
Signed-off-by: default avatarHans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@osg.samsung.com>
parent 8fd05b7e
...@@ -105,12 +105,6 @@ struct bcap_device { ...@@ -105,12 +105,6 @@ struct bcap_device {
bool stop; bool stop;
}; };
struct bcap_fh {
struct v4l2_fh fh;
/* indicates whether this file handle is doing IO */
bool io_allowed;
};
static const struct bcap_format bcap_formats[] = { static const struct bcap_format bcap_formats[] = {
{ {
.desc = "YCbCr 4:2:2 Interleaved UYVY", .desc = "YCbCr 4:2:2 Interleaved UYVY",
...@@ -200,50 +194,6 @@ static void bcap_free_sensor_formats(struct bcap_device *bcap_dev) ...@@ -200,50 +194,6 @@ static void bcap_free_sensor_formats(struct bcap_device *bcap_dev)
bcap_dev->sensor_formats = NULL; bcap_dev->sensor_formats = NULL;
} }
static int bcap_open(struct file *file)
{
struct bcap_device *bcap_dev = video_drvdata(file);
struct video_device *vfd = bcap_dev->video_dev;
struct bcap_fh *bcap_fh;
if (!bcap_dev->sd) {
v4l2_err(&bcap_dev->v4l2_dev, "No sub device registered\n");
return -ENODEV;
}
bcap_fh = kzalloc(sizeof(*bcap_fh), GFP_KERNEL);
if (!bcap_fh) {
v4l2_err(&bcap_dev->v4l2_dev,
"unable to allocate memory for file handle object\n");
return -ENOMEM;
}
v4l2_fh_init(&bcap_fh->fh, vfd);
/* store pointer to v4l2_fh in private_data member of file */
file->private_data = &bcap_fh->fh;
v4l2_fh_add(&bcap_fh->fh);
bcap_fh->io_allowed = false;
return 0;
}
static int bcap_release(struct file *file)
{
struct bcap_device *bcap_dev = video_drvdata(file);
struct v4l2_fh *fh = file->private_data;
struct bcap_fh *bcap_fh = container_of(fh, struct bcap_fh, fh);
/* if this instance is doing IO */
if (bcap_fh->io_allowed)
vb2_queue_release(&bcap_dev->buffer_queue);
file->private_data = NULL;
v4l2_fh_del(&bcap_fh->fh);
v4l2_fh_exit(&bcap_fh->fh);
kfree(bcap_fh);
return 0;
}
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
static unsigned long bcap_get_unmapped_area(struct file *file, static unsigned long bcap_get_unmapped_area(struct file *file,
unsigned long addr, unsigned long addr,
...@@ -436,13 +386,6 @@ static int bcap_reqbufs(struct file *file, void *priv, ...@@ -436,13 +386,6 @@ static int bcap_reqbufs(struct file *file, void *priv,
{ {
struct bcap_device *bcap_dev = video_drvdata(file); struct bcap_device *bcap_dev = video_drvdata(file);
struct vb2_queue *vq = &bcap_dev->buffer_queue; struct vb2_queue *vq = &bcap_dev->buffer_queue;
struct v4l2_fh *fh = file->private_data;
struct bcap_fh *bcap_fh = container_of(fh, struct bcap_fh, fh);
if (vb2_is_busy(vq))
return -EBUSY;
bcap_fh->io_allowed = true;
return vb2_reqbufs(vq, req_buf); return vb2_reqbufs(vq, req_buf);
} }
...@@ -459,11 +402,6 @@ static int bcap_qbuf(struct file *file, void *priv, ...@@ -459,11 +402,6 @@ static int bcap_qbuf(struct file *file, void *priv,
struct v4l2_buffer *buf) struct v4l2_buffer *buf)
{ {
struct bcap_device *bcap_dev = video_drvdata(file); struct bcap_device *bcap_dev = video_drvdata(file);
struct v4l2_fh *fh = file->private_data;
struct bcap_fh *bcap_fh = container_of(fh, struct bcap_fh, fh);
if (!bcap_fh->io_allowed)
return -EBUSY;
return vb2_qbuf(&bcap_dev->buffer_queue, buf); return vb2_qbuf(&bcap_dev->buffer_queue, buf);
} }
...@@ -472,11 +410,6 @@ static int bcap_dqbuf(struct file *file, void *priv, ...@@ -472,11 +410,6 @@ static int bcap_dqbuf(struct file *file, void *priv,
struct v4l2_buffer *buf) struct v4l2_buffer *buf)
{ {
struct bcap_device *bcap_dev = video_drvdata(file); struct bcap_device *bcap_dev = video_drvdata(file);
struct v4l2_fh *fh = file->private_data;
struct bcap_fh *bcap_fh = container_of(fh, struct bcap_fh, fh);
if (!bcap_fh->io_allowed)
return -EBUSY;
return vb2_dqbuf(&bcap_dev->buffer_queue, return vb2_dqbuf(&bcap_dev->buffer_queue,
buf, file->f_flags & O_NONBLOCK); buf, file->f_flags & O_NONBLOCK);
...@@ -527,14 +460,10 @@ static int bcap_streamon(struct file *file, void *priv, ...@@ -527,14 +460,10 @@ static int bcap_streamon(struct file *file, void *priv,
enum v4l2_buf_type buf_type) enum v4l2_buf_type buf_type)
{ {
struct bcap_device *bcap_dev = video_drvdata(file); struct bcap_device *bcap_dev = video_drvdata(file);
struct bcap_fh *fh = file->private_data;
struct ppi_if *ppi = bcap_dev->ppi; struct ppi_if *ppi = bcap_dev->ppi;
dma_addr_t addr; dma_addr_t addr;
int ret; int ret;
if (!fh->io_allowed)
return -EBUSY;
/* call streamon to start streaming in videobuf */ /* call streamon to start streaming in videobuf */
ret = vb2_streamon(&bcap_dev->buffer_queue, buf_type); ret = vb2_streamon(&bcap_dev->buffer_queue, buf_type);
if (ret) if (ret)
...@@ -568,10 +497,6 @@ static int bcap_streamoff(struct file *file, void *priv, ...@@ -568,10 +497,6 @@ static int bcap_streamoff(struct file *file, void *priv,
enum v4l2_buf_type buf_type) enum v4l2_buf_type buf_type)
{ {
struct bcap_device *bcap_dev = video_drvdata(file); struct bcap_device *bcap_dev = video_drvdata(file);
struct bcap_fh *fh = file->private_data;
if (!fh->io_allowed)
return -EBUSY;
return vb2_streamoff(&bcap_dev->buffer_queue, buf_type); return vb2_streamoff(&bcap_dev->buffer_queue, buf_type);
} }
...@@ -874,8 +799,8 @@ static const struct v4l2_ioctl_ops bcap_ioctl_ops = { ...@@ -874,8 +799,8 @@ static const struct v4l2_ioctl_ops bcap_ioctl_ops = {
static struct v4l2_file_operations bcap_fops = { static struct v4l2_file_operations bcap_fops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
.open = bcap_open, .open = v4l2_fh_open,
.release = bcap_release, .release = vb2_fop_release,
.unlocked_ioctl = video_ioctl2, .unlocked_ioctl = video_ioctl2,
.mmap = vb2_fop_mmap, .mmap = vb2_fop_mmap,
#ifndef CONFIG_MMU #ifndef CONFIG_MMU
......
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