From: <Eugen.Hristev@microchip.com> To: <linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <hverkuil@xs4all.nl> Cc: <Eugen.Hristev@microchip.com> Subject: [PATCH 5/5] media: atmel: atmel-isc-base: initialize the try_crop for the pads in try_fmt Date: Mon, 25 Nov 2019 08:32:54 +0000 [thread overview] Message-ID: <1574670712-31992-6-git-send-email-eugen.hristev@microchip.com> (raw) In-Reply-To: <1574670712-31992-1-git-send-email-eugen.hristev@microchip.com> From: Eugen Hristev <eugen.hristev@microchip.com> 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> --- drivers/media/platform/atmel/atmel-isc-base.c | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c index 1bb1dd5..511f0c5 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -1233,6 +1233,36 @@ 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 = {0}; + /* + * 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) { @@ -1336,6 +1366,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); -- 2.7.4
WARNING: multiple messages have this Message-ID (diff)
From: <Eugen.Hristev@microchip.com> To: <linux-media@vger.kernel.org>, <linux-kernel@vger.kernel.org>, <linux-arm-kernel@lists.infradead.org>, <hverkuil@xs4all.nl> Cc: Eugen.Hristev@microchip.com Subject: [PATCH 5/5] media: atmel: atmel-isc-base: initialize the try_crop for the pads in try_fmt Date: Mon, 25 Nov 2019 08:32:54 +0000 [thread overview] Message-ID: <1574670712-31992-6-git-send-email-eugen.hristev@microchip.com> (raw) In-Reply-To: <1574670712-31992-1-git-send-email-eugen.hristev@microchip.com> From: Eugen Hristev <eugen.hristev@microchip.com> 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> --- drivers/media/platform/atmel/atmel-isc-base.c | 33 +++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/drivers/media/platform/atmel/atmel-isc-base.c b/drivers/media/platform/atmel/atmel-isc-base.c index 1bb1dd5..511f0c5 100644 --- a/drivers/media/platform/atmel/atmel-isc-base.c +++ b/drivers/media/platform/atmel/atmel-isc-base.c @@ -1233,6 +1233,36 @@ 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 = {0}; + /* + * 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) { @@ -1336,6 +1366,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); -- 2.7.4 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2019-11-25 8:33 UTC|newest] Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top 2019-11-25 8:32 [PATCH 0/5] media: atmel: atmel-isc-base: fixes for GREY/mt9v022 support Eugen.Hristev 2019-11-25 8:32 ` Eugen.Hristev 2019-11-25 8:32 ` [PATCH 1/5] media: atmel: atmel-isc-base: allow 8 bit direct dump Eugen.Hristev 2019-11-25 8:32 ` Eugen.Hristev 2019-11-25 8:32 ` [PATCH 2/5] media: atmel: atmel-isc-base: add support for Y10 format Eugen.Hristev 2019-11-25 8:32 ` Eugen.Hristev 2019-11-25 8:32 ` [PATCH 3/5] media: atmel: atmel-isc-base: properly initialize pad_cfg Eugen.Hristev 2019-11-25 8:32 ` Eugen.Hristev 2019-11-25 8:32 ` [PATCH 4/5] media: atmel: atmel-isc-base: fix enum calls default format Eugen.Hristev 2019-11-25 8:32 ` Eugen.Hristev 2019-11-25 8:32 ` Eugen.Hristev [this message] 2019-11-25 8:32 ` [PATCH 5/5] media: atmel: atmel-isc-base: initialize the try_crop for the pads in try_fmt Eugen.Hristev
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=1574670712-31992-6-git-send-email-eugen.hristev@microchip.com \ --to=eugen.hristev@microchip.com \ --cc=hverkuil@xs4all.nl \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-media@vger.kernel.org \ /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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.