c048f2624199fd2ddf41f62aaaf0a979c4c8dc17
[openwrt/staging/luka.git] /
1 From 4f2277b18d6bbb6fac50b751c4e513619849b23c Mon Sep 17 00:00:00 2001
2 From: Boris Brezillon <boris.brezillon@bootlin.com>
3 Date: Thu, 6 Dec 2018 15:24:37 +0100
4 Subject: [PATCH 715/806] drm/connector: Allow creation of margin props alone
5
6 Commit 6c4f52dca36f5e3e2354c30591d38e92f4657ed9 upstream.
7
8 TV margins properties can only be added as part of the SDTV TV
9 connector properties creation, but we might need those props for HDMI
10 TVs too, so let's move the margins props creation in a separate
11 function and expose it to drivers.
12
13 We also add an helper to attach margins props to a connector.
14
15 Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com>
16 Reviewed-by: Eric Anholt <eric@anholt.net>
17 Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
18 Link: https://patchwork.freedesktop.org/patch/msgid/20181206142439.10441-4-boris.brezillon@bootlin.com
19 ---
20 drivers/gpu/drm/drm_connector.c | 83 ++++++++++++++++++++++++++-------
21 include/drm/drm_connector.h | 2 +
22 2 files changed, 67 insertions(+), 18 deletions(-)
23
24 --- a/drivers/gpu/drm/drm_connector.c
25 +++ b/drivers/gpu/drm/drm_connector.c
26 @@ -1110,6 +1110,70 @@ void drm_hdmi_avi_infoframe_content_type
27 EXPORT_SYMBOL(drm_hdmi_avi_infoframe_content_type);
28
29 /**
30 + * drm_mode_attach_tv_margin_properties - attach TV connector margin properties
31 + * @connector: DRM connector
32 + *
33 + * Called by a driver when it needs to attach TV margin props to a connector.
34 + * Typically used on SDTV and HDMI connectors.
35 + */
36 +void drm_connector_attach_tv_margin_properties(struct drm_connector *connector)
37 +{
38 + struct drm_device *dev = connector->dev;
39 +
40 + drm_object_attach_property(&connector->base,
41 + dev->mode_config.tv_left_margin_property,
42 + 0);
43 + drm_object_attach_property(&connector->base,
44 + dev->mode_config.tv_right_margin_property,
45 + 0);
46 + drm_object_attach_property(&connector->base,
47 + dev->mode_config.tv_top_margin_property,
48 + 0);
49 + drm_object_attach_property(&connector->base,
50 + dev->mode_config.tv_bottom_margin_property,
51 + 0);
52 +}
53 +EXPORT_SYMBOL(drm_connector_attach_tv_margin_properties);
54 +
55 +/**
56 + * drm_mode_create_tv_margin_properties - create TV connector margin properties
57 + * @dev: DRM device
58 + *
59 + * Called by a driver's HDMI connector initialization routine, this function
60 + * creates the TV margin properties for a given device. No need to call this
61 + * function for an SDTV connector, it's already called from
62 + * drm_mode_create_tv_properties().
63 + */
64 +int drm_mode_create_tv_margin_properties(struct drm_device *dev)
65 +{
66 + if (dev->mode_config.tv_left_margin_property)
67 + return 0;
68 +
69 + dev->mode_config.tv_left_margin_property =
70 + drm_property_create_range(dev, 0, "left margin", 0, 100);
71 + if (!dev->mode_config.tv_left_margin_property)
72 + return -ENOMEM;
73 +
74 + dev->mode_config.tv_right_margin_property =
75 + drm_property_create_range(dev, 0, "right margin", 0, 100);
76 + if (!dev->mode_config.tv_right_margin_property)
77 + return -ENOMEM;
78 +
79 + dev->mode_config.tv_top_margin_property =
80 + drm_property_create_range(dev, 0, "top margin", 0, 100);
81 + if (!dev->mode_config.tv_top_margin_property)
82 + return -ENOMEM;
83 +
84 + dev->mode_config.tv_bottom_margin_property =
85 + drm_property_create_range(dev, 0, "bottom margin", 0, 100);
86 + if (!dev->mode_config.tv_bottom_margin_property)
87 + return -ENOMEM;
88 +
89 + return 0;
90 +}
91 +EXPORT_SYMBOL(drm_mode_create_tv_margin_properties);
92 +
93 +/**
94 * drm_mode_create_tv_properties - create TV specific connector properties
95 * @dev: DRM device
96 * @num_modes: number of different TV formats (modes) supported
97 @@ -1155,24 +1219,7 @@ int drm_mode_create_tv_properties(struct
98 /*
99 * Other, TV specific properties: margins & TV modes.
100 */
101 - dev->mode_config.tv_left_margin_property =
102 - drm_property_create_range(dev, 0, "left margin", 0, 100);
103 - if (!dev->mode_config.tv_left_margin_property)
104 - goto nomem;
105 -
106 - dev->mode_config.tv_right_margin_property =
107 - drm_property_create_range(dev, 0, "right margin", 0, 100);
108 - if (!dev->mode_config.tv_right_margin_property)
109 - goto nomem;
110 -
111 - dev->mode_config.tv_top_margin_property =
112 - drm_property_create_range(dev, 0, "top margin", 0, 100);
113 - if (!dev->mode_config.tv_top_margin_property)
114 - goto nomem;
115 -
116 - dev->mode_config.tv_bottom_margin_property =
117 - drm_property_create_range(dev, 0, "bottom margin", 0, 100);
118 - if (!dev->mode_config.tv_bottom_margin_property)
119 + if (drm_mode_create_tv_margin_properties(dev))
120 goto nomem;
121
122 dev->mode_config.tv_mode_property =
123 --- a/include/drm/drm_connector.h
124 +++ b/include/drm/drm_connector.h
125 @@ -1175,9 +1175,11 @@ const char *drm_get_tv_select_name(int v
126 const char *drm_get_content_protection_name(int val);
127
128 int drm_mode_create_dvi_i_properties(struct drm_device *dev);
129 +int drm_mode_create_tv_margin_properties(struct drm_device *dev);
130 int drm_mode_create_tv_properties(struct drm_device *dev,
131 unsigned int num_modes,
132 const char * const modes[]);
133 +void drm_connector_attach_tv_margin_properties(struct drm_connector *conn);
134 int drm_mode_create_scaling_mode_property(struct drm_device *dev);
135 int drm_connector_attach_content_type_property(struct drm_connector *dev);
136 int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,