Commit 8ace5084 authored by Laurent Pinchart's avatar Laurent Pinchart Committed by Mauro Carvalho Chehab

media: staging: media: imx: imx7-media-csi: Move format init to probe time

There's no need to wait until the subdev is registered to initialize the
active pad formats. Do so at probe time.
Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Acked-by: default avatarRui Miguel Silva <rmfrfs@gmail.com>
Tested-by: default avatarAlexander Stein <alexander.stein@ew.tq-group.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent 85f8673f
......@@ -763,16 +763,30 @@ static int imx7_csi_s_stream(struct v4l2_subdev *sd, int enable)
return ret;
}
static struct v4l2_mbus_framefmt *
imx7_csi_get_format(struct imx7_csi *csi,
struct v4l2_subdev_state *sd_state,
unsigned int pad,
enum v4l2_subdev_format_whence which)
{
if (which == V4L2_SUBDEV_FORMAT_TRY)
return v4l2_subdev_get_try_format(&csi->sd, sd_state, pad);
return &csi->format_mbus[pad];
}
static int imx7_csi_init_cfg(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state)
{
const enum v4l2_subdev_format_whence which =
sd_state ? V4L2_SUBDEV_FORMAT_TRY : V4L2_SUBDEV_FORMAT_ACTIVE;
struct imx7_csi *csi = v4l2_get_subdevdata(sd);
struct v4l2_mbus_framefmt *mf;
int ret;
int i;
for (i = 0; i < IMX7_CSI_PADS_NUM; i++) {
mf = v4l2_subdev_get_try_format(sd, sd_state, i);
struct v4l2_mbus_framefmt *mf =
imx7_csi_get_format(csi, sd_state, i, which);
ret = imx_media_init_mbus_fmt(mf, 800, 600, 0, V4L2_FIELD_NONE,
&csi->cc[i]);
......@@ -783,18 +797,6 @@ static int imx7_csi_init_cfg(struct v4l2_subdev *sd,
return 0;
}
static struct v4l2_mbus_framefmt *
imx7_csi_get_format(struct imx7_csi *csi,
struct v4l2_subdev_state *sd_state,
unsigned int pad,
enum v4l2_subdev_format_whence which)
{
if (which == V4L2_SUBDEV_FORMAT_TRY)
return v4l2_subdev_get_try_format(&csi->sd, sd_state, pad);
return &csi->format_mbus[pad];
}
static int imx7_csi_enum_mbus_code(struct v4l2_subdev *sd,
struct v4l2_subdev_state *sd_state,
struct v4l2_subdev_mbus_code_enum *code)
......@@ -1046,16 +1048,6 @@ static int imx7_csi_registered(struct v4l2_subdev *sd)
{
struct imx7_csi *csi = v4l2_get_subdevdata(sd);
int ret;
int i;
for (i = 0; i < IMX7_CSI_PADS_NUM; i++) {
/* set a default mbus format */
ret = imx_media_init_mbus_fmt(&csi->format_mbus[i],
800, 600, 0, V4L2_FIELD_NONE,
&csi->cc[i]);
if (ret < 0)
return ret;
}
csi->vdev = imx_media_capture_device_init(csi->sd.dev, &csi->sd,
IMX7_CSI_PAD_SRC, false);
......@@ -1298,7 +1290,8 @@ static int imx7_csi_probe(struct platform_device *pdev)
if (ret)
goto destroy_mutex;
ret = v4l2_device_register_subdev(&csi->imxmd->v4l2_dev, &csi->sd);
/* Set the default mbus formats. */
ret = imx7_csi_init_cfg(&csi->sd, NULL);
if (ret)
goto media_cleanup;
......
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