summaryrefslogtreecommitdiffstats
path: root/drivers/media/platform
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-06 20:36:13 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-07-19 09:29:51 +0200
commit4b71bfbc9787e359f63ef0d876e173b1c474ffc7 (patch)
tree680cba9fba24781b54b0d59c6e059de10f82f151 /drivers/media/platform
parentb1ca64f269300d8ef4e0912f787b8f3488a1e1d6 (diff)
downloadlinux-4b71bfbc9787e359f63ef0d876e173b1c474ffc7.tar.bz2
media: ti-vpe: cal: Decouple control handler from v4l2_device
To prepare for decoupling the v4l2_device from the cal_ctx, don't set the control handler in the v4l2_device and expect the video node to use it automatically, but set the video node control handler directly. This requires adding the sensor subdev controls to the control handler manually, as that operation was performed on the v4l2_device by v4l2_device_register_subdev(). Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Benoit Parrot <bparrot@ti.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Diffstat (limited to 'drivers/media/platform')
-rw-r--r--drivers/media/platform/ti-vpe/cal.c34
1 files changed, 19 insertions, 15 deletions
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 8de4d7b96a22..fe96edebd9c2 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1871,6 +1871,7 @@ static const struct video_device cal_videodev = {
static int cal_complete_ctx(struct cal_ctx *ctx)
{
+ struct v4l2_ctrl_handler *hdl = &ctx->ctrl_handler;
struct video_device *vfd;
struct vb2_queue *q;
int ret;
@@ -1904,6 +1905,17 @@ static int cal_complete_ctx(struct cal_ctx *ctx)
vfd->v4l2_dev = &ctx->v4l2_dev;
vfd->queue = q;
+ /* Initialize the control handler. */
+ v4l2_ctrl_handler_init(hdl, 11);
+ v4l2_ctrl_add_handler(hdl, ctx->phy->sensor->ctrl_handler, NULL, true);
+ if (hdl->error) {
+ ctx_err(ctx, "Failed to init ctrl handler\n");
+ ret = hdl->error;
+ goto error;
+ }
+
+ vfd->ctrl_handler = hdl;
+
/*
* Provide a mutex to v4l2 core. It will be used to protect
* all fops and v4l2 ioctls.
@@ -1913,12 +1925,16 @@ static int cal_complete_ctx(struct cal_ctx *ctx)
ret = video_register_device(vfd, VFL_TYPE_VIDEO, video_nr);
if (ret < 0)
- return ret;
+ goto error;
ctx_info(ctx, "V4L2 device registered as %s\n",
video_device_node_name(vfd));
return 0;
+
+error:
+ v4l2_ctrl_handler_free(hdl);
+ return ret;
}
static int cal_async_bound(struct v4l2_async_notifier *notifier,
@@ -2100,7 +2116,6 @@ cleanup_exit:
static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst)
{
struct cal_ctx *ctx;
- struct v4l2_ctrl_handler *hdl;
int ret;
ctx = devm_kzalloc(&cal->pdev->dev, sizeof(*ctx), GFP_KERNEL);
@@ -2114,15 +2129,7 @@ static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst)
"%s-%03d", CAL_MODULE_NAME, inst);
ret = v4l2_device_register(&cal->pdev->dev, &ctx->v4l2_dev);
if (ret)
- goto err_exit;
-
- hdl = &ctx->ctrl_handler;
- ret = v4l2_ctrl_handler_init(hdl, 11);
- if (ret) {
- ctx_err(ctx, "Failed to init ctrl handler\n");
- goto unreg_dev;
- }
- ctx->v4l2_dev.ctrl_handler = hdl;
+ return NULL;
/* Make sure Camera Core H/W register area is available */
ctx->phy = cal->phy[inst];
@@ -2134,15 +2141,12 @@ static struct cal_ctx *cal_ctx_create(struct cal_dev *cal, int inst)
ret = of_cal_create_instance(ctx, inst);
if (ret) {
ret = -EINVAL;
- goto free_hdl;
+ goto unreg_dev;
}
return ctx;
-free_hdl:
- v4l2_ctrl_handler_free(hdl);
unreg_dev:
v4l2_device_unregister(&ctx->v4l2_dev);
-err_exit:
return NULL;
}