mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-04 01:49:36 +00:00
[media] via-camera: implement the control framework
And added a missing kfree to clean up the via_camera struct. Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Javier Martin <javier.martin@vista-silicon.com> Cc: Jonathan Corbet <corbet@lwn.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
593403c59b
commit
dbf8f4e583
1 changed files with 14 additions and 46 deletions
|
@ -18,6 +18,7 @@
|
|||
#include <media/v4l2-device.h>
|
||||
#include <media/v4l2-ioctl.h>
|
||||
#include <media/v4l2-chip-ident.h>
|
||||
#include <media/v4l2-ctrls.h>
|
||||
#include <media/ov7670.h>
|
||||
#include <media/videobuf-dma-sg.h>
|
||||
#include <linux/delay.h>
|
||||
|
@ -63,6 +64,7 @@ enum viacam_opstate { S_IDLE = 0, S_RUNNING = 1 };
|
|||
|
||||
struct via_camera {
|
||||
struct v4l2_device v4l2_dev;
|
||||
struct v4l2_ctrl_handler ctrl_handler;
|
||||
struct video_device vdev;
|
||||
struct v4l2_subdev *sensor;
|
||||
struct platform_device *platdev;
|
||||
|
@ -817,47 +819,6 @@ static int viacam_g_chip_ident(struct file *file, void *priv,
|
|||
return sensor_call(cam, core, g_chip_ident, ident);
|
||||
}
|
||||
|
||||
/*
|
||||
* Control ops are passed through to the sensor.
|
||||
*/
|
||||
static int viacam_queryctrl(struct file *filp, void *priv,
|
||||
struct v4l2_queryctrl *qc)
|
||||
{
|
||||
struct via_camera *cam = priv;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&cam->lock);
|
||||
ret = sensor_call(cam, core, queryctrl, qc);
|
||||
mutex_unlock(&cam->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int viacam_g_ctrl(struct file *filp, void *priv,
|
||||
struct v4l2_control *ctrl)
|
||||
{
|
||||
struct via_camera *cam = priv;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&cam->lock);
|
||||
ret = sensor_call(cam, core, g_ctrl, ctrl);
|
||||
mutex_unlock(&cam->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int viacam_s_ctrl(struct file *filp, void *priv,
|
||||
struct v4l2_control *ctrl)
|
||||
{
|
||||
struct via_camera *cam = priv;
|
||||
int ret;
|
||||
|
||||
mutex_lock(&cam->lock);
|
||||
ret = sensor_call(cam, core, s_ctrl, ctrl);
|
||||
mutex_unlock(&cam->lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* Only one input.
|
||||
*/
|
||||
|
@ -1214,9 +1175,6 @@ static int viacam_enum_frameintervals(struct file *filp, void *priv,
|
|||
|
||||
static const struct v4l2_ioctl_ops viacam_ioctl_ops = {
|
||||
.vidioc_g_chip_ident = viacam_g_chip_ident,
|
||||
.vidioc_queryctrl = viacam_queryctrl,
|
||||
.vidioc_g_ctrl = viacam_g_ctrl,
|
||||
.vidioc_s_ctrl = viacam_s_ctrl,
|
||||
.vidioc_enum_input = viacam_enum_input,
|
||||
.vidioc_g_input = viacam_g_input,
|
||||
.vidioc_s_input = viacam_s_input,
|
||||
|
@ -1418,8 +1376,12 @@ static int viacam_probe(struct platform_device *pdev)
|
|||
ret = v4l2_device_register(&pdev->dev, &cam->v4l2_dev);
|
||||
if (ret) {
|
||||
dev_err(&pdev->dev, "Unable to register v4l2 device\n");
|
||||
return ret;
|
||||
goto out_free;
|
||||
}
|
||||
ret = v4l2_ctrl_handler_init(&cam->ctrl_handler, 10);
|
||||
if (ret)
|
||||
goto out_unregister;
|
||||
cam->v4l2_dev.ctrl_handler = &cam->ctrl_handler;
|
||||
/*
|
||||
* Convince the system that we can do DMA.
|
||||
*/
|
||||
|
@ -1436,7 +1398,7 @@ static int viacam_probe(struct platform_device *pdev)
|
|||
*/
|
||||
ret = via_sensor_power_setup(cam);
|
||||
if (ret)
|
||||
goto out_unregister;
|
||||
goto out_ctrl_hdl_free;
|
||||
via_sensor_power_up(cam);
|
||||
|
||||
/*
|
||||
|
@ -1485,8 +1447,12 @@ static int viacam_probe(struct platform_device *pdev)
|
|||
free_irq(viadev->pdev->irq, cam);
|
||||
out_power_down:
|
||||
via_sensor_power_release(cam);
|
||||
out_ctrl_hdl_free:
|
||||
v4l2_ctrl_handler_free(&cam->ctrl_handler);
|
||||
out_unregister:
|
||||
v4l2_device_unregister(&cam->v4l2_dev);
|
||||
out_free:
|
||||
kfree(cam);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -1499,6 +1465,8 @@ static int viacam_remove(struct platform_device *pdev)
|
|||
v4l2_device_unregister(&cam->v4l2_dev);
|
||||
free_irq(viadev->pdev->irq, cam);
|
||||
via_sensor_power_release(cam);
|
||||
v4l2_ctrl_handler_free(&cam->ctrl_handler);
|
||||
kfree(cam);
|
||||
via_cam_info = NULL;
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue