From c864954870366553adf7c6afa29a0455effe7f09 Mon Sep 17 00:00:00 2001 From: Dave Stevenson Date: Wed, 31 Oct 2018 14:57:46 +0000 Subject: [PATCH] media: adv7180: Default to the first valid input The hardware default is differential CVBS on AIN1 & 2, which isn't very useful. Select the first input that is defined as valid for the chip variant (typically CVBS_AIN1). Signed-off-by: Dave Stevenson --- drivers/media/i2c/adv7180.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/drivers/media/i2c/adv7180.c b/drivers/media/i2c/adv7180.c index 378f4e6af12c..db92b003197c 100644 --- a/drivers/media/i2c/adv7180.c +++ b/drivers/media/i2c/adv7180.c @@ -852,6 +852,9 @@ static int init_device(struct adv7180_state *state) return ret; adv7180_set_field_mode(state); + ret = state->chip_info->select_input(state, state->input); + if (ret) + return ret; __v4l2_ctrl_handler_setup(&state->ctrl_hdl); @@ -1408,6 +1411,7 @@ static int adv7180_probe(struct i2c_client *client) struct device_node *np = client->dev.of_node; struct adv7180_state *state; struct v4l2_subdev *sd; + unsigned int i; int ret; /* Check if the adapter supports the needed features */ @@ -1463,6 +1467,14 @@ static int adv7180_probe(struct i2c_client *client) state->curr_norm = V4L2_STD_NTSC; state->input = 0; + /* Select first valid input */ + for (i = 0; i < 32; i++) { + if (BIT(i) & state->chip_info->valid_input_mask) { + state->input = i; + break; + } + } + sd = &state->sd; v4l2_i2c_subdev_init(sd, client, &adv7180_ops); sd->internal_ops = &adv7180_internal_ops;