The default input is still TVP5150_COMPOSITE1, but if the platform
supports DT the default will be changed to the first valid connector.
First in this context means the connector at the lowest port number.

Signed-off-by: Marco Felsch <m.fel...@pengutronix.de>
---
 drivers/media/i2c/tvp5150.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/tvp5150.c b/drivers/media/i2c/tvp5150.c
index 3645d1166118..8b40cf721853 100644
--- a/drivers/media/i2c/tvp5150.c
+++ b/drivers/media/i2c/tvp5150.c
@@ -1835,7 +1835,7 @@ static int tvp5150_probe(struct i2c_client *c,
        struct v4l2_subdev *sd;
        struct device_node *np = c->dev.of_node;
        struct regmap *map;
-       int res;
+       int res, i;
 
        /* Check if the adapter supports the needed features */
        if (!i2c_check_functionality(c->adapter,
@@ -1881,7 +1881,16 @@ static int tvp5150_probe(struct i2c_client *c,
 
        core->norm = V4L2_STD_ALL;      /* Default is autodetect */
        core->detected_norm = V4L2_STD_UNKNOWN;
+       /*
+        * Default is TVP5150_COMPOSITE1.
+        * In case of OF support, default is first valid port
+        */
        core->input = TVP5150_COMPOSITE1;
+       for (i = 0; i < TVP5150_PORT_NUM - 1; i++)
+               if (core->endpoints[i]) {
+                       core->input = i;
+                       break;
+               }
        core->enable = true;
 
        v4l2_ctrl_handler_init(&core->hdl, 5);
-- 
2.17.1

Reply via email to