build/patch/kernel/archive/sunxi-6.1/patches.megous/media-sun6i-csi-Make-the-video-device-respect-user-passed-bytes.patch

65 lines
2.5 KiB
Diff

From aee8e59fe57590bd912fcb2d21e7e33f50b3e656 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ond=C5=99ej=20Jirman?= <megi@xff.cz>
Date: Fri, 24 Jan 2020 18:24:22 +0100
Subject: [PATCH 032/389] media: sun6i-csi: Make the video device respect user
passed bytesperline
WIP!!!
It is useful to be able to set bytesperline for YUYV and friends formats,
so that CSI can output frames with line alignment that's directly
useable by the rotation engine.
Allow this.
Signed-off-by: Ondrej Jirman <megi@xff.cz>
---
drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c | 3 +--
drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c | 9 ++++++++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
index cbba8aa4d201..8bf5049dde91 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_csi.c
@@ -517,8 +517,7 @@ static void sun6i_csi_set_window(struct sun6i_csi_device *csi_dev)
dev_dbg(csi_dev->dev,
"Calculating pixelformat(0x%x)'s bytesperline as a packed format\n",
config->pixelformat);
- bytesperline_y = (sun6i_csi_get_bpp(config->pixelformat) *
- config->width) / 8;
+ bytesperline_y = csi_dev->video.format.fmt.pix.bytesperline;
bytesperline_c = 0;
planar_offset[1] = -1;
planar_offset[2] = -1;
diff --git a/drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c b/drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c
index f7f74fa5fbfc..82425fe1fb31 100644
--- a/drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c
+++ b/drivers/media/platform/sunxi/sun6i-csi/sun6i_video.c
@@ -379,6 +379,7 @@ static int sun6i_video_format_try(struct sun6i_video *video,
{
struct v4l2_pix_format *pix_format = &format->fmt.pix;
int bpp;
+ u32 bpl_packed;
if (!sun6i_video_format_check(pix_format->pixelformat))
pix_format->pixelformat = sun6i_video_formats[0];
@@ -387,7 +388,13 @@ static int sun6i_video_format_try(struct sun6i_video *video,
&pix_format->height, MIN_HEIGHT, MAX_WIDTH, 1, 1);
bpp = sun6i_csi_get_bpp(pix_format->pixelformat);
- pix_format->bytesperline = (pix_format->width * bpp) >> 3;
+ bpl_packed = (pix_format->width * bpp) / 8;
+
+ //XXX: only allow for YUYV and friends
+ if (pix_format->bytesperline < bpl_packed
+ || pix_format->bytesperline > bpl_packed + 256)
+ pix_format->bytesperline = bpl_packed;
+
pix_format->sizeimage = pix_format->bytesperline * pix_format->height;
if (pix_format->field == V4L2_FIELD_ANY)
--
2.35.3