1 From a39d399ecb26cad762a057cabceb965ffda71d81 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 716/773] drm/connector: Allow creation of margin props alone
6 Commit 6c4f52dca36f5e3e2354c30591d38e92f4657ed9 upstream.
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.
13 We also add an helper to attach margins props to a connector.
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
20 drivers/gpu/drm/drm_connector.c | 83 ++++++++++++++++++++++++++-------
21 include/drm/drm_connector.h | 2 +
22 2 files changed, 67 insertions(+), 18 deletions(-)
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);
30 + * drm_mode_attach_tv_margin_properties - attach TV connector margin properties
31 + * @connector: DRM connector
33 + * Called by a driver when it needs to attach TV margin props to a connector.
34 + * Typically used on SDTV and HDMI connectors.
36 +void drm_connector_attach_tv_margin_properties(struct drm_connector *connector)
38 + struct drm_device *dev = connector->dev;
40 + drm_object_attach_property(&connector->base,
41 + dev->mode_config.tv_left_margin_property,
43 + drm_object_attach_property(&connector->base,
44 + dev->mode_config.tv_right_margin_property,
46 + drm_object_attach_property(&connector->base,
47 + dev->mode_config.tv_top_margin_property,
49 + drm_object_attach_property(&connector->base,
50 + dev->mode_config.tv_bottom_margin_property,
53 +EXPORT_SYMBOL(drm_connector_attach_tv_margin_properties);
56 + * drm_mode_create_tv_margin_properties - create TV connector margin properties
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().
64 +int drm_mode_create_tv_margin_properties(struct drm_device *dev)
66 + if (dev->mode_config.tv_left_margin_property)
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)
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)
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)
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)
91 +EXPORT_SYMBOL(drm_mode_create_tv_margin_properties);
94 * drm_mode_create_tv_properties - create TV specific connector properties
96 * @num_modes: number of different TV formats (modes) supported
97 @@ -1155,24 +1219,7 @@ int drm_mode_create_tv_properties(struct
99 * Other, TV specific properties: margins & TV modes.
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)
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)
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)
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))
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);
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,