mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-09-06 02:50:43 +00:00
media: ov5640: Set JPEG output timings when outputting JPEG data
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> Signed-off-by: Sakari Ailus <sakari.ailus@linux.intel.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
This commit is contained in:
parent
bddc5cdfc8
commit
7cb013b104
1 changed files with 21 additions and 0 deletions
|
@ -83,6 +83,8 @@
|
||||||
#define OV5640_REG_SIGMADELTA_CTRL0C 0x3c0c
|
#define OV5640_REG_SIGMADELTA_CTRL0C 0x3c0c
|
||||||
#define OV5640_REG_FRAME_CTRL01 0x4202
|
#define OV5640_REG_FRAME_CTRL01 0x4202
|
||||||
#define OV5640_REG_FORMAT_CONTROL00 0x4300
|
#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_POLARITY_CTRL00 0x4740
|
||||||
#define OV5640_REG_MIPI_CTRL00 0x4800
|
#define OV5640_REG_MIPI_CTRL00 0x4800
|
||||||
#define OV5640_REG_DEBUG_MODE 0x4814
|
#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));
|
(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 */
|
/* download ov5640 settings to sensor through i2c */
|
||||||
static int ov5640_set_timings(struct ov5640_dev *sensor,
|
static int ov5640_set_timings(struct ov5640_dev *sensor,
|
||||||
const struct ov5640_mode_info *mode)
|
const struct ov5640_mode_info *mode)
|
||||||
{
|
{
|
||||||
int ret;
|
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);
|
ret = ov5640_write_reg16(sensor, OV5640_REG_TIMING_DVPHO, mode->hact);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
Loading…
Reference in a new issue