Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 4a6b8df2 authored by Trent Piepho's avatar Trent Piepho Committed by Mauro Carvalho Chehab
Browse files

V4L/DVB (11902): pxa-camera: Use v4l bounding/alignment function



The v4l function has a better algorithm for aligning image size.

For instance the old code would change 159x243 into 156x240 to meet the
alignment requirements.  The new function will use 160x243, which is a lot
closer to what was asked for originally.

Cc: Robert Jarzmik <robert.jarzmik@free.fr>
Cc: Guennadi Liakhovetski <g.liakhovetski@gmx.de>
Signed-off-by: default avatarTrent Piepho <xyzzy@speakeasy.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@redhat.com>
parent b0d3159b
Loading
Loading
Loading
Loading
+7 −27
Original line number Original line Diff line number Diff line
@@ -162,13 +162,6 @@
			CICR0_PERRM | CICR0_QDM | CICR0_CDM | CICR0_SOFM | \
			CICR0_PERRM | CICR0_QDM | CICR0_CDM | CICR0_SOFM | \
			CICR0_EOFM | CICR0_FOM)
			CICR0_EOFM | CICR0_FOM)


/*
 * YUV422P picture size should be a multiple of 16, so the heuristic aligns
 * height, width on 4 byte boundaries to reach the 16 multiple for the size.
 */
#define YUV422P_X_Y_ALIGN 4
#define YUV422P_SIZE_ALIGN YUV422P_X_Y_ALIGN * YUV422P_X_Y_ALIGN

/*
/*
 * Structures
 * Structures
 */
 */
@@ -1398,28 +1391,15 @@ static int pxa_camera_try_fmt(struct soc_camera_device *icd,
		return -EINVAL;
		return -EINVAL;
	}
	}


	/* limit to pxa hardware capabilities */
	if (pix->height < 32)
		pix->height = 32;
	if (pix->height > 2048)
		pix->height = 2048;
	if (pix->width < 48)
		pix->width = 48;
	if (pix->width > 2048)
		pix->width = 2048;
	pix->width &= ~0x01;

	/*
	/*
	 * YUV422P planar format requires images size to be a 16 bytes
	 * Limit to pxa hardware capabilities.  YUV422P planar format requires
	 * multiple. If not, zeros will be inserted between Y and U planes, and
	 * images size to be a multiple of 16 bytes.  If not, zeros will be
	 * U and V planes, and YUV422P standard would be violated.
	 * inserted between Y and U planes, and U and V planes, which violates
	 * the YUV422P standard.
	 */
	 */
	if (xlate->host_fmt->fourcc == V4L2_PIX_FMT_YUV422P) {
	v4l_bound_align_image(&pix->width, 48, 2048, 1,
		if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN))
			      &pix->height, 32, 2048, 0,
			pix->height = ALIGN(pix->height, YUV422P_X_Y_ALIGN);
			      xlate->host_fmt->fourcc == V4L2_PIX_FMT_YUV422P ? 4 : 0);
		if (!IS_ALIGNED(pix->width * pix->height, YUV422P_SIZE_ALIGN))
			pix->width = ALIGN(pix->width, YUV422P_X_Y_ALIGN);
	}


	pix->bytesperline = pix->width *
	pix->bytesperline = pix->width *
		DIV_ROUND_UP(xlate->host_fmt->depth, 8);
		DIV_ROUND_UP(xlate->host_fmt->depth, 8);