public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: linux-kernel@vger.kernel.org, stable@vger.kernel.org
Cc: Hans de Goede <hdegoede@redhat.com>,
	Andy Shevchenko <andy.shevchenko@gmail.com>,
	Mauro Carvalho Chehab <mchehab@kernel.org>,
	Sasha Levin <sashal@kernel.org>,
	gregkh@linuxfoundation.org, andriy.shevchenko@linux.intel.com,
	kitakar@gmail.com, xiam0nd.tong@gmail.com,
	linux-media@vger.kernel.org, linux-staging@lists.linux.dev
Subject: [PATCH AUTOSEL 5.15 10/19] media: atomisp: Fix VIDIOC_TRY_FMT
Date: Tue,  1 Nov 2022 07:29:10 -0400	[thread overview]
Message-ID: <20221101112919.799868-10-sashal@kernel.org> (raw)
In-Reply-To: <20221101112919.799868-1-sashal@kernel.org>

From: Hans de Goede <hdegoede@redhat.com>

[ Upstream commit 4d3aafb9c9bba59c9b6f6df8ea6c89483bfed8d4 ]

atomisp_try_fmt() calls the sensor's try_fmt handler but it does
not copy the result back to the passed in v4l2_pix_format under
some circumstances.

Potentially returning an unsupported resolution to userspace,
which VIDIOC_TRY_FMT is not supposed to do.

atomisp_set_fmt() also uses atomisp_try_fmt() and relies
on this wrong behavior. The VIDIOC_TRY_FMT call passes NULL for
the res_overflow argument where as the atomisp_set_fmt() call
passes non NULL.

Use the res_overflow argument to differentiate between the 2 callers
and always propagate the sensors result in the VIDIOC_TRY_FMT case.

This fixes the resolution list in camorama showing resolutions like e.g.
1584x1184 instead of 1600x1200.

Reviewed-by: Andy Shevchenko <andy.shevchenko@gmail.com>
Signed-off-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
---
 drivers/staging/media/atomisp/pci/atomisp_cmd.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/atomisp/pci/atomisp_cmd.c b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
index 88db9818e083..1c36e0108b1d 100644
--- a/drivers/staging/media/atomisp/pci/atomisp_cmd.c
+++ b/drivers/staging/media/atomisp/pci/atomisp_cmd.c
@@ -4954,8 +4954,8 @@ int atomisp_try_fmt(struct video_device *vdev, struct v4l2_pix_format *f,
 		return 0;
 	}
 
-	if (snr_mbus_fmt->width < f->width
-	    && snr_mbus_fmt->height < f->height) {
+	if (!res_overflow || (snr_mbus_fmt->width < f->width &&
+			      snr_mbus_fmt->height < f->height)) {
 		f->width = snr_mbus_fmt->width;
 		f->height = snr_mbus_fmt->height;
 		/* Set the flag when resolution requested is
-- 
2.35.1


  parent reply	other threads:[~2022-11-01 11:32 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-01 11:29 [PATCH AUTOSEL 5.15 01/19] media: rkisp1: Don't pass the quantization to rkisp1_csm_config() Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 02/19] media: rkisp1: Initialize color space on resizer sink and source pads Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 03/19] media: rkisp1: Use correct macro for gradient registers Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 04/19] media: rkisp1: Zero v4l2_subdev_format fields in when validating links Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 05/19] media: s5p_cec: limit msg.len to CEC_MAX_MSG_SIZE Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 06/19] media: cros-ec-cec: " Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 07/19] media: dvb-frontends/drxk: initialize err to 0 Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 08/19] media: meson: vdec: fix possible refcount leak in vdec_probe() Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 09/19] media: v4l: subdev: Fail graciously when getting try data for NULL state Sasha Levin
2022-11-01 11:29 ` Sasha Levin [this message]
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 11/19] media: atomisp: Ensure that USERPTR pointers are page aligned Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 12/19] media: atomisp: Fix v4l2_fh resource leak on open errors Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 13/19] ACPI: APEI: Fix integer overflow in ghes_estatus_pool_init() Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 14/19] hwrng: bcm2835 - use hwrng_msleep() instead of cpu_relax() Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 15/19] scsi: core: Restrict legal sdev_state transitions via sysfs Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 16/19] HID: saitek: add madcatz variant of MMO7 mouse device ID Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 17/19] drm/amdgpu: set vm_update_mode=0 as default for Sienna Cichlid in SRIOV case Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 18/19] nvme-hwmon: consistently ignore errors from nvme_hwmon_init Sasha Levin
2022-11-01 11:29 ` [PATCH AUTOSEL 5.15 19/19] i2c: xiic: Add platform module alias Sasha Levin

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=20221101112919.799868-10-sashal@kernel.org \
    --to=sashal@kernel.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=hdegoede@redhat.com \
    --cc=kitakar@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=linux-staging@lists.linux.dev \
    --cc=mchehab@kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=xiam0nd.tong@gmail.com \
    /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: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox