ar71xx/ath79: ag71xx: dont fetch the same var again
[openwrt/staging/wigyori.git] / target / linux / brcm2708 / patches-4.19 / 950-0720-drm-vc4-Attach-margin-props-to-the-HDMI-connector.patch
1 From c0f966a04d5ff984a33d7d7b9c3cdc32514ebc14 Mon Sep 17 00:00:00 2001
2 From: Boris Brezillon <boris.brezillon@bootlin.com>
3 Date: Thu, 6 Dec 2018 15:24:39 +0100
4 Subject: [PATCH 720/725] drm/vc4: Attach margin props to the HDMI connector
5
6 Commit db999538fdb0679629d90652f8a1437df1e85a7d upstream.
7
8 Now that the plane code takes the margins setup into account, we can
9 safely attach margin props to the HDMI connector.
10
11 We also take care of filling AVI infoframes correctly to expose the
12 top/botton/left/right bar.
13
14 Note that those margin props match pretty well the
15 overscan_{left,right,top,bottom} properties defined in config.txt and
16 parsed by the VC4 firmware.
17
18 Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
19 Reviewed-by: Eric Anholt <eric@anholt.net>
20 Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
21 Link: https://patchwork.freedesktop.org/patch/msgid/20181206142439.10441-6-boris.brezillon@bootlin.com
22 ---
23 drivers/gpu/drm/vc4/vc4_hdmi.c | 16 ++++++++++++++++
24 1 file changed, 16 insertions(+)
25
26 --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
27 +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
28 @@ -310,6 +310,7 @@ static struct drm_connector *vc4_hdmi_co
29 {
30 struct drm_connector *connector;
31 struct vc4_hdmi_connector *hdmi_connector;
32 + int ret;
33
34 hdmi_connector = devm_kzalloc(dev->dev, sizeof(*hdmi_connector),
35 GFP_KERNEL);
36 @@ -323,6 +324,13 @@ static struct drm_connector *vc4_hdmi_co
37 DRM_MODE_CONNECTOR_HDMIA);
38 drm_connector_helper_add(connector, &vc4_hdmi_connector_helper_funcs);
39
40 + /* Create and attach TV margin props to this connector. */
41 + ret = drm_mode_create_tv_margin_properties(dev);
42 + if (ret)
43 + return ERR_PTR(ret);
44 +
45 + drm_connector_attach_tv_margin_properties(connector);
46 +
47 connector->polled = (DRM_CONNECTOR_POLL_CONNECT |
48 DRM_CONNECTOR_POLL_DISCONNECT);
49
50 @@ -408,6 +416,9 @@ static void vc4_hdmi_write_infoframe(str
51 static void vc4_hdmi_set_avi_infoframe(struct drm_encoder *encoder)
52 {
53 struct vc4_hdmi_encoder *vc4_encoder = to_vc4_hdmi_encoder(encoder);
54 + struct vc4_dev *vc4 = encoder->dev->dev_private;
55 + struct vc4_hdmi *hdmi = vc4->hdmi;
56 + struct drm_connector_state *cstate = hdmi->connector->state;
57 struct drm_crtc *crtc = encoder->crtc;
58 const struct drm_display_mode *mode = &crtc->state->adjusted_mode;
59 union hdmi_infoframe frame;
60 @@ -426,6 +437,11 @@ static void vc4_hdmi_set_avi_infoframe(s
61 vc4_encoder->rgb_range_selectable,
62 false);
63
64 + frame.avi.right_bar = cstate->tv.margins.right;
65 + frame.avi.left_bar = cstate->tv.margins.left;
66 + frame.avi.top_bar = cstate->tv.margins.top;
67 + frame.avi.bottom_bar = cstate->tv.margins.bottom;
68 +
69 vc4_hdmi_write_infoframe(encoder, &frame);
70 }
71