Re: [PATCH v11 30/36] media: subdev: Fallback to pad config in v4l2_subdev_get_fmt()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 16/03/2022 13:03, Jacopo Mondi wrote:
On Tue, Mar 01, 2022 at 06:11:50PM +0200, Tomi Valkeinen wrote:
From: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>

If the subdev doesn't implement routing support, fallback to pad config
as the storage for pad formats. This allows using the V4L2 subdev active
state API and the v4l2_subdev_get_fmt() helper in subdev drivers that
don't implement routing support.

Signed-off-by: Laurent Pinchart <laurent.pinchart@xxxxxxxxxxxxxxxx>
---
  drivers/media/v4l2-core/v4l2-subdev.c | 10 ++++++++--
  1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/media/v4l2-core/v4l2-subdev.c b/drivers/media/v4l2-core/v4l2-subdev.c
index c1cc9b91dba7..7f50871054cd 100644
--- a/drivers/media/v4l2-core/v4l2-subdev.c
+++ b/drivers/media/v4l2-core/v4l2-subdev.c
@@ -1512,8 +1512,14 @@ int v4l2_subdev_get_fmt(struct v4l2_subdev *sd, struct v4l2_subdev_state *state,
  {
  	struct v4l2_mbus_framefmt *fmt;

-	fmt = v4l2_subdev_state_get_stream_format(state, format->pad,
-						  format->stream);
+	if (sd->flags & V4L2_SUBDEV_FL_MULTIPLEXED)
+		fmt = v4l2_subdev_state_get_stream_format(state, format->pad,
+							  format->stream);
+	else if (format->pad < sd->entity.num_pads && format->stream == 0)
+		fmt = v4l2_subdev_get_try_format(sd, state, format->pad);
+	else
+		fmt = NULL;

You could initialize fmt = NULL and skip the else

I do like it better this way, I think it's more understandable to have all the three cases listed there.

 Tomi



[Index of Archives]     [Linux Input]     [Video for Linux]     [Gstreamer Embedded]     [Mplayer Users]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux