diff options
author | Eugen Hristev <eugen.hristev@microchip.com> | 2019-11-25 11:32:54 +0300 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab+huawei@kernel.org> | 2019-12-16 12:16:25 +0300 |
commit | 374d968ac7440d128f93128e7f13f2ab035b0dcc (patch) | |
tree | c3f6bb75de3baeb0ba9d6215e7305d458ee08307 | |
parent | da3a55b5a948e0226c2811d001df40c8ba6b4ac1 (diff) | |
download | linux-374d968ac7440d128f93128e7f13f2ab035b0dcc.tar.xz |
media: atmel: atmel-isc-base: initialize the try_crop for the pads in try_fmt
When requesting format from sensor, some sensors call the
subdev_get_try_crop which for ISC was not properly initialized, and this
causes errors in determining proper image resolutions.
To accommodate for this, when trying a format (in try_fmt), first attempt
to obtain the framesize for this format from sensor.
In case this fails, use the maximum ISC width/height as try_crop, otherwise
provide the first size height/width from the sensor.
Signed-off-by: Eugen Hristev <eugen.hristev@microchip.com>
[hverkuil-cisco@xs4all.nl: changed {0} to {}]
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
-rw-r--r-- | drivers/media/platform/atmel/atmel-isc-base.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c index 1843c1d56350..d7669a03e98e 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -1210,6 +1210,37 @@ static int isc_try_configure_pipeline(struct isc_device *isc) return 0; } +static void isc_try_fse(struct isc_device *isc, + struct v4l2_subdev_pad_config *pad_cfg) +{ + int ret; + struct v4l2_subdev_frame_size_enum fse = {}; + + /* + * If we do not know yet which format the subdev is using, we cannot + * do anything. + */ + if (!isc->try_config.sd_format) + return; + + fse.code = isc->try_config.sd_format->mbus_code; + fse.which = V4L2_SUBDEV_FORMAT_TRY; + + ret = v4l2_subdev_call(isc->current_subdev->sd, pad, enum_frame_size, + pad_cfg, &fse); + /* + * Attempt to obtain format size from subdev. If not available, + * just use the maximum ISC can receive. + */ + if (ret) { + pad_cfg->try_crop.width = ISC_MAX_SUPPORT_WIDTH; + pad_cfg->try_crop.height = ISC_MAX_SUPPORT_HEIGHT; + } else { + pad_cfg->try_crop.width = fse.max_width; + pad_cfg->try_crop.height = fse.max_height; + } +} + static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f, u32 *code) { @@ -1313,6 +1344,9 @@ static int isc_try_fmt(struct isc_device *isc, struct v4l2_format *f, if (ret) goto isc_try_fmt_err; + /* Obtain frame sizes if possible to have crop requirements ready */ + isc_try_fse(isc, &pad_cfg); + v4l2_fill_mbus_format(&format.format, pixfmt, mbus_code); ret = v4l2_subdev_call(isc->current_subdev->sd, pad, set_fmt, &pad_cfg, &format); |