]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
staging: media: tegra-video: vi: adjust get_selection operation check
authorSvyatoslav Ryhel <clamor95@gmail.com>
Tue, 3 Mar 2026 08:42:25 +0000 (10:42 +0200)
committerHans Verkuil <hverkuil+cisco@kernel.org>
Thu, 19 Mar 2026 07:18:35 +0000 (08:18 +0100)
During __tegra_channel_try_format, the VI (Video Input) checks if the
camera sensor driver provides a get_selection operation. If this operation
is unavailable, the crop is set to 0. However, if the operation is
available but returns an error, the VI currently fails.

While this works for simple cameras with a single pad, it creates a corner
case for sensors like the mt9m114. This sensor provides the same operation
set for both IFP pads, but returns an error when get_selection is called
on an unsupported pad (such as the source pad), causing the aforementioned
behavior.

To resolve this, if get_selection is implemented but returns an error,
try_crop is now set to 0 — treating it as if the operation was not
implemented — instead of returning a failure.

Tested-by: Luca Ceresoli <luca.ceresoli@bootlin.com> # tegra20, parallel camera
Signed-off-by: Svyatoslav Ryhel <clamor95@gmail.com>
Signed-off-by: Hans Verkuil <hverkuil+cisco@kernel.org>
drivers/staging/media/tegra-video/vi.c

index a7892036f29e9283daa3a340aed41f9953948211..e0961bc0a0175887ce52fa4482e9c10e69b7b300 100644 (file)
@@ -476,17 +476,11 @@ static int __tegra_channel_try_format(struct tegra_vi_channel *chan,
        fse.code = fmtinfo->code;
        ret = v4l2_subdev_call(subdev, pad, enum_frame_size, sd_state, &fse);
        if (ret) {
-               if (!v4l2_subdev_has_op(subdev, pad, get_selection)) {
+               if (!v4l2_subdev_has_op(subdev, pad, get_selection) ||
+                   v4l2_subdev_call(subdev, pad, get_selection, NULL, &sdsel)) {
                        try_crop->width = 0;
                        try_crop->height = 0;
                } else {
-                       ret = v4l2_subdev_call(subdev, pad, get_selection,
-                                              NULL, &sdsel);
-                       if (ret) {
-                               ret = -EINVAL;
-                               goto out_free;
-                       }
-
                        try_crop->width = sdsel.r.width;
                        try_crop->height = sdsel.r.height;
                }