Commit 68453b02 authored by Guoniu.zhou's avatar Guoniu.zhou Committed by Mauro Carvalho Chehab

media: ov5640: set correct default format for CSI-2 mode

In commit a89f14bb ("media: ov5640: Split DVP and CSI-2 formats"),
it splits format list for DVP and CSI-2 mode, but the default format
defined in commit 90b0f355 ("media: ov5640: Implement init_cfg")
is only supported by DVP mode, so define a new default format for
CSI-2 mode.
Signed-off-by: default avatarGuoniu.zhou <guoniu.zhou@nxp.com>
Reviewed-by: default avatarJai Luthra <j-luthra@ti.com>
Reviewed-by: default avatarJacopo Mondi <jacopo.mondi@ideasonboard.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@kernel.org>
parent ceddfd44
...@@ -520,7 +520,18 @@ static u32 ov5640_code_to_bpp(struct ov5640_dev *sensor, u32 code) ...@@ -520,7 +520,18 @@ static u32 ov5640_code_to_bpp(struct ov5640_dev *sensor, u32 code)
*/ */
/* YUV422 UYVY VGA@30fps */ /* YUV422 UYVY VGA@30fps */
static const struct v4l2_mbus_framefmt ov5640_default_fmt = { static const struct v4l2_mbus_framefmt ov5640_csi2_default_fmt = {
.code = MEDIA_BUS_FMT_UYVY8_1X16,
.width = 640,
.height = 480,
.colorspace = V4L2_COLORSPACE_SRGB,
.ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(V4L2_COLORSPACE_SRGB),
.quantization = V4L2_QUANTIZATION_FULL_RANGE,
.xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(V4L2_COLORSPACE_SRGB),
.field = V4L2_FIELD_NONE,
};
static const struct v4l2_mbus_framefmt ov5640_dvp_default_fmt = {
.code = MEDIA_BUS_FMT_UYVY8_2X8, .code = MEDIA_BUS_FMT_UYVY8_2X8,
.width = 640, .width = 640,
.height = 480, .height = 480,
...@@ -3719,11 +3730,13 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable) ...@@ -3719,11 +3730,13 @@ static int ov5640_s_stream(struct v4l2_subdev *sd, int enable)
static int ov5640_init_cfg(struct v4l2_subdev *sd, static int ov5640_init_cfg(struct v4l2_subdev *sd,
struct v4l2_subdev_state *state) struct v4l2_subdev_state *state)
{ {
struct ov5640_dev *sensor = to_ov5640_dev(sd);
struct v4l2_mbus_framefmt *fmt = struct v4l2_mbus_framefmt *fmt =
v4l2_subdev_get_try_format(sd, state, 0); v4l2_subdev_get_try_format(sd, state, 0);
struct v4l2_rect *crop = v4l2_subdev_get_try_crop(sd, state, 0); struct v4l2_rect *crop = v4l2_subdev_get_try_crop(sd, state, 0);
*fmt = ov5640_default_fmt; *fmt = ov5640_is_csi2(sensor) ? ov5640_csi2_default_fmt :
ov5640_dvp_default_fmt;
crop->left = OV5640_PIXEL_ARRAY_LEFT; crop->left = OV5640_PIXEL_ARRAY_LEFT;
crop->top = OV5640_PIXEL_ARRAY_TOP; crop->top = OV5640_PIXEL_ARRAY_TOP;
...@@ -3812,7 +3825,6 @@ static int ov5640_probe(struct i2c_client *client) ...@@ -3812,7 +3825,6 @@ static int ov5640_probe(struct i2c_client *client)
* default init sequence initialize sensor to * default init sequence initialize sensor to
* YUV422 UYVY VGA@30fps * YUV422 UYVY VGA@30fps
*/ */
sensor->fmt = ov5640_default_fmt;
sensor->frame_interval.numerator = 1; sensor->frame_interval.numerator = 1;
sensor->frame_interval.denominator = ov5640_framerates[OV5640_30_FPS]; sensor->frame_interval.denominator = ov5640_framerates[OV5640_30_FPS];
sensor->current_fr = OV5640_30_FPS; sensor->current_fr = OV5640_30_FPS;
...@@ -3845,6 +3857,9 @@ static int ov5640_probe(struct i2c_client *client) ...@@ -3845,6 +3857,9 @@ static int ov5640_probe(struct i2c_client *client)
return -EINVAL; return -EINVAL;
} }
sensor->fmt = ov5640_is_csi2(sensor) ? ov5640_csi2_default_fmt :
ov5640_dvp_default_fmt;
/* get system clock (xclk) */ /* get system clock (xclk) */
sensor->xclk = devm_clk_get(dev, "xclk"); sensor->xclk = devm_clk_get(dev, "xclk");
if (IS_ERR(sensor->xclk)) { if (IS_ERR(sensor->xclk)) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment