ath79: add support for TP-LINK Archer C7 v4
[openwrt/openwrt.git] / target / linux / brcm2708 / patches-4.9 / 950-0168-drm-Add-TV-connector-states-to-drm_connector_state.patch
1 From 01ff94b770786a793c08fc7fcbecdd5f859a8958 Mon Sep 17 00:00:00 2001
2 From: Boris Brezillon <boris.brezillon@free-electrons.com>
3 Date: Fri, 2 Dec 2016 14:48:09 +0100
4 Subject: [PATCH] drm: Add TV connector states to drm_connector_state
5
6 Some generic TV connector properties are exposed in drm_mode_config, but
7 they are currently handled independently in each DRM encoder driver.
8
9 Extend the drm_connector_state to store TV related states, and modify the
10 drm_atomic_connector_{set,get}_property() helpers to fill the connector
11 state accordingly.
12
13 Each driver is then responsible for checking and applying the new config
14 in its ->atomic_mode_{check,set}() operations.
15
16 Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
17 Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
18 Signed-off-by: Eric Anholt <eric@anholt.net>
19 (cherry picked from commit 299a16b163c95fbe1e3b1e142ba9c6ce9dab2c23)
20 ---
21 drivers/gpu/drm/drm_atomic.c | 50 ++++++++++++++++++++++++++++++++++++++++++++
22 include/drm/drm_connector.h | 32 ++++++++++++++++++++++++++++
23 2 files changed, 82 insertions(+)
24
25 --- a/drivers/gpu/drm/drm_atomic.c
26 +++ b/drivers/gpu/drm/drm_atomic.c
27 @@ -989,12 +989,38 @@ int drm_atomic_connector_set_property(st
28 * now?) atomic writes to DPMS property:
29 */
30 return -EINVAL;
31 + } else if (property == config->tv_select_subconnector_property) {
32 + state->tv.subconnector = val;
33 + } else if (property == config->tv_left_margin_property) {
34 + state->tv.margins.left = val;
35 + } else if (property == config->tv_right_margin_property) {
36 + state->tv.margins.right = val;
37 + } else if (property == config->tv_top_margin_property) {
38 + state->tv.margins.top = val;
39 + } else if (property == config->tv_bottom_margin_property) {
40 + state->tv.margins.bottom = val;
41 + } else if (property == config->tv_mode_property) {
42 + state->tv.mode = val;
43 + } else if (property == config->tv_brightness_property) {
44 + state->tv.brightness = val;
45 + } else if (property == config->tv_contrast_property) {
46 + state->tv.contrast = val;
47 + } else if (property == config->tv_flicker_reduction_property) {
48 + state->tv.flicker_reduction = val;
49 + } else if (property == config->tv_overscan_property) {
50 + state->tv.overscan = val;
51 + } else if (property == config->tv_saturation_property) {
52 + state->tv.saturation = val;
53 + } else if (property == config->tv_hue_property) {
54 + state->tv.hue = val;
55 } else if (connector->funcs->atomic_set_property) {
56 return connector->funcs->atomic_set_property(connector,
57 state, property, val);
58 } else {
59 return -EINVAL;
60 }
61 +
62 + return 0;
63 }
64 EXPORT_SYMBOL(drm_atomic_connector_set_property);
65
66 @@ -1025,6 +1051,30 @@ drm_atomic_connector_get_property(struct
67 *val = (state->crtc) ? state->crtc->base.id : 0;
68 } else if (property == config->dpms_property) {
69 *val = connector->dpms;
70 + } else if (property == config->tv_select_subconnector_property) {
71 + *val = state->tv.subconnector;
72 + } else if (property == config->tv_left_margin_property) {
73 + *val = state->tv.margins.left;
74 + } else if (property == config->tv_right_margin_property) {
75 + *val = state->tv.margins.right;
76 + } else if (property == config->tv_top_margin_property) {
77 + *val = state->tv.margins.top;
78 + } else if (property == config->tv_bottom_margin_property) {
79 + *val = state->tv.margins.bottom;
80 + } else if (property == config->tv_mode_property) {
81 + *val = state->tv.mode;
82 + } else if (property == config->tv_brightness_property) {
83 + *val = state->tv.brightness;
84 + } else if (property == config->tv_contrast_property) {
85 + *val = state->tv.contrast;
86 + } else if (property == config->tv_flicker_reduction_property) {
87 + *val = state->tv.flicker_reduction;
88 + } else if (property == config->tv_overscan_property) {
89 + *val = state->tv.overscan;
90 + } else if (property == config->tv_saturation_property) {
91 + *val = state->tv.saturation;
92 + } else if (property == config->tv_hue_property) {
93 + *val = state->tv.hue;
94 } else if (connector->funcs->atomic_get_property) {
95 return connector->funcs->atomic_get_property(connector,
96 state, property, val);
97 --- a/include/drm/drm_connector.h
98 +++ b/include/drm/drm_connector.h
99 @@ -194,10 +194,40 @@ int drm_display_info_set_bus_formats(str
100 unsigned int num_formats);
101
102 /**
103 + * struct drm_tv_connector_state - TV connector related states
104 + * @subconnector: selected subconnector
105 + * @margins: left/right/top/bottom margins
106 + * @mode: TV mode
107 + * @brightness: brightness in percent
108 + * @contrast: contrast in percent
109 + * @flicker_reduction: flicker reduction in percent
110 + * @overscan: overscan in percent
111 + * @saturation: saturation in percent
112 + * @hue: hue in percent
113 + */
114 +struct drm_tv_connector_state {
115 + enum drm_mode_subconnector subconnector;
116 + struct {
117 + unsigned int left;
118 + unsigned int right;
119 + unsigned int top;
120 + unsigned int bottom;
121 + } margins;
122 + unsigned int mode;
123 + unsigned int brightness;
124 + unsigned int contrast;
125 + unsigned int flicker_reduction;
126 + unsigned int overscan;
127 + unsigned int saturation;
128 + unsigned int hue;
129 +};
130 +
131 +/**
132 * struct drm_connector_state - mutable connector state
133 * @connector: backpointer to the connector
134 * @best_encoder: can be used by helpers and drivers to select the encoder
135 * @state: backpointer to global drm_atomic_state
136 + * @tv: TV connector state
137 */
138 struct drm_connector_state {
139 struct drm_connector *connector;
140 @@ -213,6 +243,8 @@ struct drm_connector_state {
141 struct drm_encoder *best_encoder;
142
143 struct drm_atomic_state *state;
144 +
145 + struct drm_tv_connector_state tv;
146 };
147
148 /**