brcm2708: add linux 4.19 support
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.19 / 950-0201-media-adv7180-Nasty-hack-to-allow-input-selection.patch
1 From b14afe8c3c5c85e3114617eba49751e21b9cbe47 Mon Sep 17 00:00:00 2001
2 From: Dave Stevenson <dave.stevenson@raspberrypi.org>
3 Date: Wed, 31 Oct 2018 15:00:04 +0000
4 Subject: [PATCH 201/703] media: adv7180: Nasty hack to allow input selection.
5
6 Whilst the adv7180 driver support s_routing, nothing else
7 does, and there is a missing lump of framework code to
8 define the mapping from connectors on a board to the inputs
9 they represent on the ADV7180.
10
11 Add a nasty hack to take a module parameter that is passed in
12 to s_routing on any call to G_STD, or S_STD (or subdev
13 g_input_status call).
14
15 Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.org>
16 ---
17 drivers/media/i2c/adv7180.c | 30 ++++++++++++++++++++++++++++--
18 1 file changed, 28 insertions(+), 2 deletions(-)
19
20 --- a/drivers/media/i2c/adv7180.c
21 +++ b/drivers/media/i2c/adv7180.c
22 @@ -189,6 +189,10 @@
23
24 #define V4L2_CID_ADV_FAST_SWITCH (V4L2_CID_USER_ADV7180_BASE + 0x00)
25
26 +static int dbg_input;
27 +module_param(dbg_input, int, 0644);
28 +MODULE_PARM_DESC(dbg_input, "Input number (0-31)");
29 +
30 struct adv7180_state;
31
32 #define ADV7180_FLAG_RESET_POWERED BIT(0)
33 @@ -405,10 +409,24 @@ out:
34 return ret;
35 }
36
37 +static void adv7180_check_input(struct v4l2_subdev *sd)
38 +{
39 + struct adv7180_state *state = to_state(sd);
40 +
41 + if (state->input != dbg_input)
42 + if (adv7180_s_routing(sd, dbg_input, 0, 0))
43 + /* Failed - reset dbg_input */
44 + dbg_input = state->input;
45 +}
46 +
47 static int adv7180_g_input_status(struct v4l2_subdev *sd, u32 *status)
48 {
49 struct adv7180_state *state = to_state(sd);
50 - int ret = mutex_lock_interruptible(&state->mutex);
51 + int ret;
52 +
53 + adv7180_check_input(sd);
54 +
55 + ret = mutex_lock_interruptible(&state->mutex);
56 if (ret)
57 return ret;
58
59 @@ -434,7 +452,11 @@ static int adv7180_program_std(struct ad
60 static int adv7180_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
61 {
62 struct adv7180_state *state = to_state(sd);
63 - int ret = mutex_lock_interruptible(&state->mutex);
64 + int ret;
65 +
66 + adv7180_check_input(sd);
67 +
68 + ret = mutex_lock_interruptible(&state->mutex);
69
70 if (ret)
71 return ret;
72 @@ -456,6 +478,8 @@ static int adv7180_g_std(struct v4l2_sub
73 {
74 struct adv7180_state *state = to_state(sd);
75
76 + adv7180_check_input(sd);
77 +
78 *norm = state->curr_norm;
79
80 return 0;
81 @@ -810,6 +834,8 @@ static int adv7180_s_stream(struct v4l2_
82 return 0;
83 }
84
85 + adv7180_check_input(sd);
86 +
87 /* Must wait until querystd released the lock */
88 ret = mutex_lock_interruptible(&state->mutex);
89 if (ret)