[PATCH 1/4] media: i2c: max9286: Initialize try formats

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

 



Initialize try formats at device node open time by querying the
format from the remote subdevices instead of hard-coding it.

Signed-off-by: Jacopo Mondi <jacopo+renesas@xxxxxxxxxx>
---
 drivers/media/i2c/max9286.c | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/drivers/media/i2c/max9286.c b/drivers/media/i2c/max9286.c
index 47f280518fdb..7c292f2e2704 100644
--- a/drivers/media/i2c/max9286.c
+++ b/drivers/media/i2c/max9286.c
@@ -794,12 +794,29 @@ static void max9286_init_format(struct v4l2_mbus_framefmt *fmt)

 static int max9286_open(struct v4l2_subdev *subdev, struct v4l2_subdev_fh *fh)
 {
+	struct max9286_priv *priv = sd_to_max9286(subdev);
+	struct device *dev = &priv->client->dev;
 	struct v4l2_mbus_framefmt *format;
-	unsigned int i;
+	struct max9286_source *source;
+
+	for_each_source(priv, source) {
+		struct v4l2_subdev_pad_config remote_config = {};
+		unsigned int i = to_index(priv, source);
+		struct v4l2_subdev_format remote_fmt = {
+			.which = V4L2_SUBDEV_FORMAT_TRY,
+			.pad = 0,
+		};
+		int ret;

-	for (i = 0; i < MAX9286_N_SINKS; i++) {
 		format = v4l2_subdev_get_try_format(subdev, fh->pad, i);
-		max9286_init_format(format);
+		ret = v4l2_subdev_call(source->sd, pad, get_fmt, &remote_config,
+				       &remote_fmt);
+		if (ret) {
+			dev_err(dev, "Unable get format on source %u\n", i);
+			return ret;
+		}
+
+		*format = remote_fmt.format;
 	}

 	return 0;
--
2.27.0




[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