Thank you for your contribution! Sashiko AI review found 1 potential
issue to consider:
- [Medium] media: tegra-video: unpopulated pad index in
  __tegra_channel_try_format()
--

commit afb13afd32b21ef80b48671edacb48e14ada5d73
Author: Svyatoslav Ryhel <[email protected]>

media: tegra-video: vi: Adjust pad assignment logic

This commit populates the pad field in V4L2 subdevice format, selection, and
enumeration structures using media_get_pad_index() instead of assuming the
source pad is at index 0.

> diff --git a/drivers/media/platform/nvidia/tegra-video/vi.c 
> b/drivers/media/platform/nvidia/tegra-video/vi.c
> index 139e3ff0faaed..f028780f07bde 100644
> --- a/drivers/media/platform/nvidia/tegra-video/vi.c
> +++ b/drivers/media/platform/nvidia/tegra-video/vi.c

[ ... ]

> @@ -465,7 +471,9 @@ static int __tegra_channel_try_format(struct 
> tegra_vi_channel *chan,
>       }
>  
>       pix->field = V4L2_FIELD_NONE;
> -     fmt.pad = 0;
> +     fmt.pad = media_get_pad_index(&subdev->entity, MEDIA_PAD_FL_SOURCE,
> +                                   PAD_SIGNAL_DEFAULT);
> +
>       v4l2_fill_mbus_format(&fmt.format, pix, fmtinfo->code);
>  
>       /*

[Severity: Medium]
Should fse.pad, sdsel.pad, and the pad argument to
v4l2_subdev_state_get_crop() also be set to the source pad index in
__tegra_channel_try_format()?

Right after this hunk, __tegra_channel_try_format() still targets pad 0 for
those operations:

drivers/media/platform/nvidia/tegra-video/vi.c:__tegra_channel_try_format() {
    ...
        try_crop = v4l2_subdev_state_get_crop(sd_state, 0);
        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) ||
                    v4l2_subdev_call(subdev, pad, get_selection, NULL, NULL, 
&sdsel)) {
    ...
}

When the remote subdevice's source pad is not at index 0, enum_frame_size
and get_selection query pad 0 with a source-pad media bus code, and try_crop
updates pad 0's crop rectangle in sd_state instead of fmt.pad's before
set_fmt runs on fmt.pad.

-- 
Sashiko AI review ยท 
https://sashiko.dev/#/patchset/[email protected]?part=6

Reply via email to