From: Chen-Yu Tsai <wens@csie.org>
To: Steve Longerbeam <slongerbeam@gmail.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Chen-Yu Tsai <wens@csie.org>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
Maxime Ripard <maxime.ripard@bootlin.com>
Subject: [PATCH 5/6] media: ov5640: Set JPEG output timings when outputting JPEG data
Date: Fri, 18 Jan 2019 16:52:05 +0800 [thread overview]
Message-ID: <20190118085206.2598-6-wens@csie.org> (raw)
In-Reply-To: <20190118085206.2598-1-wens@csie.org>
When compression is turned on, the on-bus data is framed according to
the compression mode, and the height and width set in VFIFO_VSIZE and
VFIFO_HSIZE. If these are not updated correctly, the sensor will send
data framed in a manner unexpected by the capture interface, such as
having more bytes per line than expected, and having the extra data
dropped. This ultimately results in corrupted data.
Set the two values when the media bus is configured for JPEG data,
meaning the sensor would be in JPEG mode.
Signed-off-by: Chen-Yu Tsai <wens@csie.org>
---
drivers/media/i2c/ov5640.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/media/i2c/ov5640.c b/drivers/media/i2c/ov5640.c
index 13311483792c..1c1dc401c678 100644
--- a/drivers/media/i2c/ov5640.c
+++ b/drivers/media/i2c/ov5640.c
@@ -83,6 +83,8 @@
#define OV5640_REG_SIGMADELTA_CTRL0C 0x3c0c
#define OV5640_REG_FRAME_CTRL01 0x4202
#define OV5640_REG_FORMAT_CONTROL00 0x4300
+#define OV5640_REG_VFIFO_HSIZE 0x4602
+#define OV5640_REG_VFIFO_VSIZE 0x4604
#define OV5640_REG_POLARITY_CTRL00 0x4740
#define OV5640_REG_MIPI_CTRL00 0x4800
#define OV5640_REG_DEBUG_MODE 0x4814
@@ -1043,12 +1045,31 @@ static int ov5640_set_dvp_pclk(struct ov5640_dev *sensor, unsigned long rate)
(ilog2(pclk_div) << 4));
}
+/* set JPEG framing sizes */
+static int ov5640_set_jpeg_timings(struct ov5640_dev *sensor,
+ const struct ov5640_mode_info *mode)
+{
+ int ret;
+
+ ret = ov5640_write_reg16(sensor, OV5640_REG_VFIFO_HSIZE, mode->hact);
+ if (ret < 0)
+ return ret;
+
+ return ov5640_write_reg16(sensor, OV5640_REG_VFIFO_VSIZE, mode->vact);
+}
+
/* download ov5640 settings to sensor through i2c */
static int ov5640_set_timings(struct ov5640_dev *sensor,
const struct ov5640_mode_info *mode)
{
int ret;
+ if (sensor->fmt.code == MEDIA_BUS_FMT_JPEG_1X8) {
+ ret = ov5640_set_jpeg_timings(sensor, mode);
+ if (ret < 0)
+ return ret;
+ }
+
ret = ov5640_write_reg16(sensor, OV5640_REG_TIMING_DVPHO, mode->hact);
if (ret < 0)
return ret;
--
2.20.1
next prev parent reply other threads:[~2019-01-18 8:52 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-01-18 8:52 [PATCH 0/6] media: ov5640: JPEG and test pattern improvements Chen-Yu Tsai
2019-01-18 8:52 ` [PATCH 1/6] media: ov5640: Move test_pattern_menu before ov5640_set_ctrl_test_pattern Chen-Yu Tsai
2019-01-18 8:52 ` [PATCH 2/6] media: ov5640: Add register definition for test pattern register Chen-Yu Tsai
2019-01-18 8:52 ` [PATCH 3/6] media: ov5640: Disable transparent feature for test pattern Chen-Yu Tsai
2019-01-18 8:52 ` [PATCH 4/6] media: ov5640: Add three more test patterns Chen-Yu Tsai
2019-01-18 8:52 ` Chen-Yu Tsai [this message]
2019-01-18 8:52 ` [PATCH 6/6] media: ov5640: Consolidate JPEG compression mode setting Chen-Yu Tsai
2019-02-05 8:55 ` Sakari Ailus
2019-02-05 13:50 ` Chen-Yu Tsai
2019-02-05 16:08 ` Sakari Ailus
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20190118085206.2598-6-wens@csie.org \
--to=wens@csie.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=maxime.ripard@bootlin.com \
--cc=mchehab@kernel.org \
--cc=sakari.ailus@linux.intel.com \
--cc=slongerbeam@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).