Commit e6441fde authored by Hugues Fruchet's avatar Hugues Fruchet Committed by Mauro Carvalho Chehab

media: ov5640: fix get_/set_fmt colorspace related fields

Fix set of missing colorspace related fields in get_/set_fmt.
Detected by v4l2-compliance tool.

[Sakari Ailus: Rearrange fmt declaration in ov5640_probe()]
Signed-off-by: default avatarHugues Fruchet <hugues.fruchet@st.com>
Signed-off-by: default avatarSakari Ailus <sakari.ailus@linux.intel.com>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab@s-opensource.com>
parent 9f67a5e2
...@@ -1874,7 +1874,13 @@ static int ov5640_try_fmt_internal(struct v4l2_subdev *sd, ...@@ -1874,7 +1874,13 @@ static int ov5640_try_fmt_internal(struct v4l2_subdev *sd,
if (ov5640_formats[i].code == fmt->code) if (ov5640_formats[i].code == fmt->code)
break; break;
if (i >= ARRAY_SIZE(ov5640_formats)) if (i >= ARRAY_SIZE(ov5640_formats))
fmt->code = ov5640_formats[0].code; i = 0;
fmt->code = ov5640_formats[i].code;
fmt->colorspace = ov5640_formats[i].colorspace;
fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace);
fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE;
fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(fmt->colorspace);
return 0; return 0;
} }
...@@ -1885,6 +1891,7 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, ...@@ -1885,6 +1891,7 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd,
{ {
struct ov5640_dev *sensor = to_ov5640_dev(sd); struct ov5640_dev *sensor = to_ov5640_dev(sd);
const struct ov5640_mode_info *new_mode; const struct ov5640_mode_info *new_mode;
struct v4l2_mbus_framefmt *mbus_fmt = &format->format;
int ret; int ret;
if (format->pad != 0) if (format->pad != 0)
...@@ -1897,7 +1904,7 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, ...@@ -1897,7 +1904,7 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd,
goto out; goto out;
} }
ret = ov5640_try_fmt_internal(sd, &format->format, ret = ov5640_try_fmt_internal(sd, mbus_fmt,
sensor->current_fr, &new_mode); sensor->current_fr, &new_mode);
if (ret) if (ret)
goto out; goto out;
...@@ -1906,12 +1913,12 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd, ...@@ -1906,12 +1913,12 @@ static int ov5640_set_fmt(struct v4l2_subdev *sd,
struct v4l2_mbus_framefmt *fmt = struct v4l2_mbus_framefmt *fmt =
v4l2_subdev_get_try_format(sd, cfg, 0); v4l2_subdev_get_try_format(sd, cfg, 0);
*fmt = format->format; *fmt = *mbus_fmt;
goto out; goto out;
} }
sensor->current_mode = new_mode; sensor->current_mode = new_mode;
sensor->fmt = format->format; sensor->fmt = *mbus_fmt;
sensor->pending_mode_change = true; sensor->pending_mode_change = true;
out: out:
mutex_unlock(&sensor->lock); mutex_unlock(&sensor->lock);
...@@ -2496,6 +2503,7 @@ static int ov5640_probe(struct i2c_client *client, ...@@ -2496,6 +2503,7 @@ static int ov5640_probe(struct i2c_client *client,
struct device *dev = &client->dev; struct device *dev = &client->dev;
struct fwnode_handle *endpoint; struct fwnode_handle *endpoint;
struct ov5640_dev *sensor; struct ov5640_dev *sensor;
struct v4l2_mbus_framefmt *fmt;
int ret; int ret;
sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL); sensor = devm_kzalloc(dev, sizeof(*sensor), GFP_KERNEL);
...@@ -2503,10 +2511,15 @@ static int ov5640_probe(struct i2c_client *client, ...@@ -2503,10 +2511,15 @@ static int ov5640_probe(struct i2c_client *client,
return -ENOMEM; return -ENOMEM;
sensor->i2c_client = client; sensor->i2c_client = client;
sensor->fmt.code = MEDIA_BUS_FMT_UYVY8_2X8; fmt = &sensor->fmt;
sensor->fmt.width = 640; fmt->code = ov5640_formats[0].code;
sensor->fmt.height = 480; fmt->colorspace = ov5640_formats[0].colorspace;
sensor->fmt.field = V4L2_FIELD_NONE; fmt->ycbcr_enc = V4L2_MAP_YCBCR_ENC_DEFAULT(fmt->colorspace);
fmt->quantization = V4L2_QUANTIZATION_FULL_RANGE;
fmt->xfer_func = V4L2_MAP_XFER_FUNC_DEFAULT(fmt->colorspace);
fmt->width = 640;
fmt->height = 480;
fmt->field = V4L2_FIELD_NONE;
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;
......
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