Skip to content

Commit 9f43234

Browse files
pinchartlHans Verkuil
authored andcommitted
media: imx: imx7-media-csi: Init default format with __imx7_csi_video_try_fmt()
Use the __imx7_csi_video_try_fmt() helper function to initialize the default format at probe time. This improves consistency by using the same code path for both default initialization and validation at runtime, and allows dropping the now unused imx7_csi_find_pixel_format() function. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Alexander Stein <alexander.stein@ew.tq-group.com> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
1 parent bef1bb6 commit 9f43234

File tree

1 file changed

+6
-49
lines changed

1 file changed

+6
-49
lines changed

drivers/media/platform/nxp/imx7-media-csi.c

Lines changed: 6 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -1014,39 +1014,6 @@ static int imx7_csi_enum_mbus_formats(u32 *code, u32 index)
10141014
return -EINVAL;
10151015
}
10161016

1017-
static int imx7_csi_mbus_fmt_to_pix_fmt(struct v4l2_pix_format *pix,
1018-
const struct v4l2_mbus_framefmt *mbus,
1019-
const struct imx7_csi_pixfmt *cc)
1020-
{
1021-
u32 width;
1022-
u32 stride;
1023-
1024-
if (!cc) {
1025-
cc = imx7_csi_find_mbus_format(mbus->code);
1026-
if (!cc)
1027-
return -EINVAL;
1028-
}
1029-
1030-
/* Round up width for minimum burst size */
1031-
width = round_up(mbus->width, 8);
1032-
1033-
/* Round up stride for IDMAC line start address alignment */
1034-
stride = round_up((width * cc->bpp) >> 3, 8);
1035-
1036-
pix->width = width;
1037-
pix->height = mbus->height;
1038-
pix->pixelformat = cc->fourcc;
1039-
pix->colorspace = mbus->colorspace;
1040-
pix->xfer_func = mbus->xfer_func;
1041-
pix->ycbcr_enc = mbus->ycbcr_enc;
1042-
pix->quantization = mbus->quantization;
1043-
pix->field = mbus->field;
1044-
pix->bytesperline = stride;
1045-
pix->sizeimage = stride * pix->height;
1046-
1047-
return 0;
1048-
}
1049-
10501017
/* -----------------------------------------------------------------------------
10511018
* Video Capture Device - IOCTLs
10521019
*/
@@ -1603,22 +1570,14 @@ static struct imx7_csi_vb2_buffer *imx7_csi_video_next_buf(struct imx7_csi *csi)
16031570
return buf;
16041571
}
16051572

1606-
static int imx7_csi_video_init_format(struct imx7_csi *csi)
1573+
static void imx7_csi_video_init_format(struct imx7_csi *csi)
16071574
{
1608-
struct v4l2_mbus_framefmt format = { };
1609-
1610-
format.code = IMX7_CSI_DEF_MBUS_CODE;
1611-
format.width = IMX7_CSI_DEF_PIX_WIDTH;
1612-
format.height = IMX7_CSI_DEF_PIX_HEIGHT;
1613-
format.field = V4L2_FIELD_NONE;
1575+
struct v4l2_pix_format *pixfmt = &csi->vdev_fmt;
16141576

1615-
imx7_csi_mbus_fmt_to_pix_fmt(&csi->vdev_fmt, &format, NULL);
1616-
csi->vdev_compose.width = format.width;
1617-
csi->vdev_compose.height = format.height;
1577+
pixfmt->width = IMX7_CSI_DEF_PIX_WIDTH;
1578+
pixfmt->height = IMX7_CSI_DEF_PIX_HEIGHT;
16181579

1619-
csi->vdev_cc = imx7_csi_find_pixel_format(csi->vdev_fmt.pixelformat);
1620-
1621-
return 0;
1580+
csi->vdev_cc = __imx7_csi_video_try_fmt(pixfmt, &csi->vdev_compose);
16221581
}
16231582

16241583
static int imx7_csi_video_register(struct imx7_csi *csi)
@@ -1631,9 +1590,7 @@ static int imx7_csi_video_register(struct imx7_csi *csi)
16311590
vdev->v4l2_dev = v4l2_dev;
16321591

16331592
/* Initialize the default format and compose rectangle. */
1634-
ret = imx7_csi_video_init_format(csi);
1635-
if (ret < 0)
1636-
return ret;
1593+
imx7_csi_video_init_format(csi);
16371594

16381595
/* Register the video device. */
16391596
ret = video_register_device(vdev, VFL_TYPE_VIDEO, -1);

0 commit comments

Comments
 (0)