Commit 7e58132c authored by Lad Prabhakar's avatar Lad Prabhakar Committed by Hans Verkuil
Browse files

media: rzg2l-cru: Inline calculating bytesperline



Remove the `rzg2l_cru_format_bytesperline()` function and inline the
calculation of `bytesperline` directly in `rzg2l_cru_format_align()`.
This simplifies the code by removing an unnecessary function call and
directly multiplying the image width by the `bpp` (bytes per pixel)
from the format structure.

Signed-off-by: default avatarLad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Reviewed-by: default avatarLaurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
Link: https://lore.kernel.org/r/20241018133446.223516-15-prabhakar.mahadev-lad.rj@bp.renesas.com


Signed-off-by: default avatarLaurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: default avatarHans Verkuil <hverkuil@xs4all.nl>
parent 8853467c
Loading
Loading
Loading
Loading
+6 −10
Original line number Diff line number Diff line
@@ -812,20 +812,16 @@ int rzg2l_cru_dma_register(struct rzg2l_cru_dev *cru)
 * V4L2 stuff
 */

static u32 rzg2l_cru_format_bytesperline(struct v4l2_pix_format *pix)
static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
				   struct v4l2_pix_format *pix)
{
	const struct rzg2l_cru_ip_format *fmt;

	fmt = rzg2l_cru_ip_format_to_fmt(pix->pixelformat);

	return pix->width * fmt->bpp;
}

static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
				   struct v4l2_pix_format *pix)
{
	if (!rzg2l_cru_ip_format_to_fmt(pix->pixelformat))
	if (!fmt) {
		pix->pixelformat = RZG2L_CRU_DEFAULT_FORMAT;
		fmt = rzg2l_cru_ip_format_to_fmt(pix->pixelformat);
	}

	switch (pix->field) {
	case V4L2_FIELD_TOP:
@@ -844,7 +840,7 @@ static void rzg2l_cru_format_align(struct rzg2l_cru_dev *cru,
	v4l_bound_align_image(&pix->width, 320, RZG2L_CRU_MAX_INPUT_WIDTH, 1,
			      &pix->height, 240, RZG2L_CRU_MAX_INPUT_HEIGHT, 2, 0);

	pix->bytesperline = rzg2l_cru_format_bytesperline(pix);
	pix->bytesperline = pix->width * fmt->bpp;
	pix->sizeimage = pix->bytesperline * pix->height;

	dev_dbg(cru->dev, "Format %ux%u bpl: %u size: %u\n",