summaryrefslogtreecommitdiffstats
path: root/drivers/media
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2020-07-06 20:36:35 +0200
committerMauro Carvalho Chehab <mchehab+huawei@kernel.org>2020-07-19 10:36:50 +0200
commit1b22b7a0ec9c505ac9b55adeb84a7c15cbd0bbb0 (patch)
tree3c31b9f8448ee1e89a82de296af762278a1e338b /drivers/media
parentb908235114d122ad59c8287f2dad0a1bd45b4e3a (diff)
media: ti-vpe: cal: Init formats in cal_ctx_v4l2_register()
To prepare for splitting the V4L2 API support to a separate file, call cal_ctx_v4l2_init_formats() from cal_ctx_v4l2_register(). 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')
-rw-r--r--drivers/media/platform/ti-vpe/cal.c83
1 files changed, 39 insertions, 44 deletions
diff --git a/drivers/media/platform/ti-vpe/cal.c b/drivers/media/platform/ti-vpe/cal.c
index 236fe826b635..26747e6da358 100644
--- a/drivers/media/platform/ti-vpe/cal.c
+++ b/drivers/media/platform/ti-vpe/cal.c
@@ -1948,39 +1948,6 @@ static const struct video_device cal_videodev = {
V4L2_CAP_READWRITE,
};
-static int cal_ctx_v4l2_register(struct cal_ctx *ctx)
-{
- struct v4l2_ctrl_handler *hdl = &ctx->ctrl_handler;
- struct video_device *vfd = &ctx->vdev;
- int ret;
-
- ret = v4l2_ctrl_add_handler(hdl, ctx->phy->sensor->ctrl_handler, NULL,
- true);
- if (ret < 0) {
- ctx_err(ctx, "Failed to add sensor ctrl handler\n");
- return ret;
- }
-
- ret = video_register_device(vfd, VFL_TYPE_VIDEO, video_nr);
- if (ret < 0) {
- ctx_err(ctx, "Failed to register video device\n");
- return ret;
- }
-
- ctx_info(ctx, "V4L2 device registered as %s\n",
- video_device_node_name(vfd));
-
- return 0;
-}
-
-static void cal_ctx_v4l2_unregister(struct cal_ctx *ctx)
-{
- ctx_dbg(1, ctx, "unregistering %s\n",
- video_device_node_name(&ctx->vdev));
-
- video_unregister_device(&ctx->vdev);
-}
-
static int cal_ctx_v4l2_init_formats(struct cal_ctx *ctx)
{
struct v4l2_subdev_mbus_code_enum mbus_code;
@@ -2047,6 +2014,43 @@ static int cal_ctx_v4l2_init_formats(struct cal_ctx *ctx)
return 0;
}
+static int cal_ctx_v4l2_register(struct cal_ctx *ctx)
+{
+ struct v4l2_ctrl_handler *hdl = &ctx->ctrl_handler;
+ struct video_device *vfd = &ctx->vdev;
+ int ret;
+
+ ret = cal_ctx_v4l2_init_formats(ctx);
+ if (ret)
+ return ret;
+
+ ret = v4l2_ctrl_add_handler(hdl, ctx->phy->sensor->ctrl_handler, NULL,
+ true);
+ if (ret < 0) {
+ ctx_err(ctx, "Failed to add sensor ctrl handler\n");
+ return ret;
+ }
+
+ ret = video_register_device(vfd, VFL_TYPE_VIDEO, video_nr);
+ if (ret < 0) {
+ ctx_err(ctx, "Failed to register video device\n");
+ return ret;
+ }
+
+ ctx_info(ctx, "V4L2 device registered as %s\n",
+ video_device_node_name(vfd));
+
+ return 0;
+}
+
+static void cal_ctx_v4l2_unregister(struct cal_ctx *ctx)
+{
+ ctx_dbg(1, ctx, "unregistering %s\n",
+ video_device_node_name(&ctx->vdev));
+
+ video_unregister_device(&ctx->vdev);
+}
+
static int cal_ctx_v4l2_init(struct cal_ctx *ctx)
{
struct v4l2_ctrl_handler *hdl = &ctx->ctrl_handler;
@@ -2147,19 +2151,10 @@ static int cal_async_notifier_complete(struct v4l2_async_notifier *notifier)
{
struct cal_dev *cal = container_of(notifier, struct cal_dev, notifier);
unsigned int i;
- int ret;
for (i = 0; i < ARRAY_SIZE(cal->ctx); ++i) {
- struct cal_ctx *ctx = cal->ctx[i];
-
- if (!ctx)
- continue;
-
- ret = cal_ctx_v4l2_init_formats(ctx);
- if (ret)
- continue;
-
- cal_ctx_v4l2_register(ctx);
+ if (cal->ctx[i])
+ cal_ctx_v4l2_register(cal->ctx[i]);
}
return 0;