diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-01-23 16:58:26 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-03-13 07:48:48 -0400 |
commit | 3fcc42e07c60cd1c459fa2f7e8b2b84e61116ac9 (patch) | |
tree | 6abfde0b7a99a3056acd5873a3a64ea8be0d2074 | |
parent | 00d762cbd1fb5df63bf005ffa1c8d0275f79890e (diff) |
drm: kerneldoc polish for drm_crtc_helper.c
Most of this is newly added kerneldoc for the hotplug and output
polling code. But I've also thrown in a bit lesser polish, most of it
is tuning down the shouting RETURN: headers.
Overview documentation for the output probing and mode setting support
code will be added in later patches.
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/drm_crtc_helper.c | 125 |
1 files changed, 111 insertions, 14 deletions
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index 0f60150adfc3..a85517854073 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c | |||
@@ -114,8 +114,8 @@ static void drm_mode_validate_flag(struct drm_connector *connector, | |||
114 | * @connector vfunc for drivers that use the crtc helpers for output mode | 114 | * @connector vfunc for drivers that use the crtc helpers for output mode |
115 | * filtering and detection. | 115 | * filtering and detection. |
116 | * | 116 | * |
117 | * RETURNS: | 117 | * Returns: |
118 | * Number of modes found on @connector. | 118 | * The number of modes found on @connector. |
119 | */ | 119 | */ |
120 | int drm_helper_probe_single_connector_modes(struct drm_connector *connector, | 120 | int drm_helper_probe_single_connector_modes(struct drm_connector *connector, |
121 | uint32_t maxX, uint32_t maxY) | 121 | uint32_t maxX, uint32_t maxY) |
@@ -217,10 +217,12 @@ EXPORT_SYMBOL(drm_helper_probe_single_connector_modes); | |||
217 | * drm_helper_encoder_in_use - check if a given encoder is in use | 217 | * drm_helper_encoder_in_use - check if a given encoder is in use |
218 | * @encoder: encoder to check | 218 | * @encoder: encoder to check |
219 | * | 219 | * |
220 | * Walk @encoders's DRM device's mode_config and see if it's in use. | 220 | * Checks whether @encoder is with the current mode setting output configuration |
221 | * in use by any connector. This doesn't mean that it is actually enabled since | ||
222 | * the DPMS state is tracked separately. | ||
221 | * | 223 | * |
222 | * RETURNS: | 224 | * Returns: |
223 | * True if @encoder is part of the mode_config, false otherwise. | 225 | * True if @encoder is used, false otherwise. |
224 | */ | 226 | */ |
225 | bool drm_helper_encoder_in_use(struct drm_encoder *encoder) | 227 | bool drm_helper_encoder_in_use(struct drm_encoder *encoder) |
226 | { | 228 | { |
@@ -239,10 +241,12 @@ EXPORT_SYMBOL(drm_helper_encoder_in_use); | |||
239 | * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config | 241 | * drm_helper_crtc_in_use - check if a given CRTC is in a mode_config |
240 | * @crtc: CRTC to check | 242 | * @crtc: CRTC to check |
241 | * | 243 | * |
242 | * Walk @crtc's DRM device's mode_config and see if it's in use. | 244 | * Checks whether @crtc is with the current mode setting output configuration |
245 | * in use by any connector. This doesn't mean that it is actually enabled since | ||
246 | * the DPMS state is tracked separately. | ||
243 | * | 247 | * |
244 | * RETURNS: | 248 | * Returns: |
245 | * True if @crtc is part of the mode_config, false otherwise. | 249 | * True if @crtc is used, false otherwise. |
246 | */ | 250 | */ |
247 | bool drm_helper_crtc_in_use(struct drm_crtc *crtc) | 251 | bool drm_helper_crtc_in_use(struct drm_crtc *crtc) |
248 | { | 252 | { |
@@ -278,8 +282,11 @@ drm_encoder_disable(struct drm_encoder *encoder) | |||
278 | * drm_helper_disable_unused_functions - disable unused objects | 282 | * drm_helper_disable_unused_functions - disable unused objects |
279 | * @dev: DRM device | 283 | * @dev: DRM device |
280 | * | 284 | * |
281 | * If an connector or CRTC isn't part of @dev's mode_config, it can be disabled | 285 | * This function walks through the entire mode setting configuration of @dev. It |
282 | * by calling its dpms function, which should power it off. | 286 | * will remove any crtc links of unused encoders and encoder links of |
287 | * disconnected connectors. Then it will disable all unused encoders and crtcs | ||
288 | * either by calling their disable callback if available or by calling their | ||
289 | * dpms callback with DRM_MODE_DPMS_OFF. | ||
283 | */ | 290 | */ |
284 | void drm_helper_disable_unused_functions(struct drm_device *dev) | 291 | void drm_helper_disable_unused_functions(struct drm_device *dev) |
285 | { | 292 | { |
@@ -358,8 +365,8 @@ drm_crtc_prepare_encoders(struct drm_device *dev) | |||
358 | * drm_crtc_helper_set_config() helper function to drive the mode setting | 365 | * drm_crtc_helper_set_config() helper function to drive the mode setting |
359 | * sequence. | 366 | * sequence. |
360 | * | 367 | * |
361 | * RETURNS: | 368 | * Returns: |
362 | * True if the mode was set successfully, or false otherwise. | 369 | * True if the mode was set successfully, false otherwise. |
363 | */ | 370 | */ |
364 | bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, | 371 | bool drm_crtc_helper_set_mode(struct drm_crtc *crtc, |
365 | struct drm_display_mode *mode, | 372 | struct drm_display_mode *mode, |
@@ -559,8 +566,8 @@ drm_crtc_helper_disable(struct drm_crtc *crtc) | |||
559 | * kernel mode setting with the crtc helper functions and the assorted | 566 | * kernel mode setting with the crtc helper functions and the assorted |
560 | * ->prepare(), ->modeset() and ->commit() helper callbacks. | 567 | * ->prepare(), ->modeset() and ->commit() helper callbacks. |
561 | * | 568 | * |
562 | * RETURNS: | 569 | * Returns: |
563 | * Returns 0 on success, -ERRNO on failure. | 570 | * Returns 0 on success, negative errno numbers on failure. |
564 | */ | 571 | */ |
565 | int drm_crtc_helper_set_config(struct drm_mode_set *set) | 572 | int drm_crtc_helper_set_config(struct drm_mode_set *set) |
566 | { | 573 | { |
@@ -916,6 +923,14 @@ void drm_helper_connector_dpms(struct drm_connector *connector, int mode) | |||
916 | } | 923 | } |
917 | EXPORT_SYMBOL(drm_helper_connector_dpms); | 924 | EXPORT_SYMBOL(drm_helper_connector_dpms); |
918 | 925 | ||
926 | /** | ||
927 | * drm_helper_mode_fill_fb_struct - fill out framebuffer metadata | ||
928 | * @fb: drm_framebuffer object to fill out | ||
929 | * @mode_cmd: metadata from the userspace fb creation request | ||
930 | * | ||
931 | * This helper can be used in a drivers fb_create callback to pre-fill the fb's | ||
932 | * metadata fields. | ||
933 | */ | ||
919 | void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, | 934 | void drm_helper_mode_fill_fb_struct(struct drm_framebuffer *fb, |
920 | struct drm_mode_fb_cmd2 *mode_cmd) | 935 | struct drm_mode_fb_cmd2 *mode_cmd) |
921 | { | 936 | { |
@@ -998,6 +1013,22 @@ void drm_helper_resume_force_mode(struct drm_device *dev) | |||
998 | } | 1013 | } |
999 | EXPORT_SYMBOL(drm_helper_resume_force_mode); | 1014 | EXPORT_SYMBOL(drm_helper_resume_force_mode); |
1000 | 1015 | ||
1016 | /** | ||
1017 | * drm_kms_helper_hotplug_event - fire off KMS hotplug events | ||
1018 | * @dev: drm_device whose connector state changed | ||
1019 | * | ||
1020 | * This function fires off the uevent for userspace and also calls the | ||
1021 | * output_poll_changed function, which is most commonly used to inform the fbdev | ||
1022 | * emulation code and allow it to update the fbcon output configuration. | ||
1023 | * | ||
1024 | * Drivers should call this from their hotplug handling code when a change is | ||
1025 | * detected. Note that this function does not do any output detection of its | ||
1026 | * own, like drm_helper_hpd_irq_event() does - this is assumed to be done by the | ||
1027 | * driver already. | ||
1028 | * | ||
1029 | * This function must be called from process context with no mode | ||
1030 | * setting locks held. | ||
1031 | */ | ||
1001 | void drm_kms_helper_hotplug_event(struct drm_device *dev) | 1032 | void drm_kms_helper_hotplug_event(struct drm_device *dev) |
1002 | { | 1033 | { |
1003 | /* send a uevent + call fbdev */ | 1034 | /* send a uevent + call fbdev */ |
@@ -1066,6 +1097,16 @@ static void output_poll_execute(struct work_struct *work) | |||
1066 | schedule_delayed_work(delayed_work, DRM_OUTPUT_POLL_PERIOD); | 1097 | schedule_delayed_work(delayed_work, DRM_OUTPUT_POLL_PERIOD); |
1067 | } | 1098 | } |
1068 | 1099 | ||
1100 | /** | ||
1101 | * drm_kms_helper_poll_disable - disable output polling | ||
1102 | * @dev: drm_device | ||
1103 | * | ||
1104 | * This function disables the output polling work. | ||
1105 | * | ||
1106 | * Drivers can call this helper from their device suspend implementation. It is | ||
1107 | * not an error to call this even when output polling isn't enabled or arlready | ||
1108 | * disabled. | ||
1109 | */ | ||
1069 | void drm_kms_helper_poll_disable(struct drm_device *dev) | 1110 | void drm_kms_helper_poll_disable(struct drm_device *dev) |
1070 | { | 1111 | { |
1071 | if (!dev->mode_config.poll_enabled) | 1112 | if (!dev->mode_config.poll_enabled) |
@@ -1074,6 +1115,16 @@ void drm_kms_helper_poll_disable(struct drm_device *dev) | |||
1074 | } | 1115 | } |
1075 | EXPORT_SYMBOL(drm_kms_helper_poll_disable); | 1116 | EXPORT_SYMBOL(drm_kms_helper_poll_disable); |
1076 | 1117 | ||
1118 | /** | ||
1119 | * drm_kms_helper_poll_enable - re-enable output polling. | ||
1120 | * @dev: drm_device | ||
1121 | * | ||
1122 | * This function re-enables the output polling work. | ||
1123 | * | ||
1124 | * Drivers can call this helper from their device resume implementation. It is | ||
1125 | * an error to call this when the output polling support has not yet been set | ||
1126 | * up. | ||
1127 | */ | ||
1077 | void drm_kms_helper_poll_enable(struct drm_device *dev) | 1128 | void drm_kms_helper_poll_enable(struct drm_device *dev) |
1078 | { | 1129 | { |
1079 | bool poll = false; | 1130 | bool poll = false; |
@@ -1093,6 +1144,25 @@ void drm_kms_helper_poll_enable(struct drm_device *dev) | |||
1093 | } | 1144 | } |
1094 | EXPORT_SYMBOL(drm_kms_helper_poll_enable); | 1145 | EXPORT_SYMBOL(drm_kms_helper_poll_enable); |
1095 | 1146 | ||
1147 | /** | ||
1148 | * drm_kms_helper_poll_init - initialize and enable output polling | ||
1149 | * @dev: drm_device | ||
1150 | * | ||
1151 | * This function intializes and then also enables output polling support for | ||
1152 | * @dev. Drivers which do not have reliable hotplug support in hardware can use | ||
1153 | * this helper infrastructure to regularly poll such connectors for changes in | ||
1154 | * their connection state. | ||
1155 | * | ||
1156 | * Drivers can control which connectors are polled by setting the | ||
1157 | * DRM_CONNECTOR_POLL_CONNECT and DRM_CONNECTOR_POLL_DISCONNECT flags. On | ||
1158 | * connectors where probing live outputs can result in visual distortion drivers | ||
1159 | * should not set the DRM_CONNECTOR_POLL_DISCONNECT flag to avoid this. | ||
1160 | * Connectors which have no flag or only DRM_CONNECTOR_POLL_HPD set are | ||
1161 | * completely ignored by the polling logic. | ||
1162 | * | ||
1163 | * Note that a connector can be both polled and probed from the hotplug handler, | ||
1164 | * in case the hotplug interrupt is known to be unreliable. | ||
1165 | */ | ||
1096 | void drm_kms_helper_poll_init(struct drm_device *dev) | 1166 | void drm_kms_helper_poll_init(struct drm_device *dev) |
1097 | { | 1167 | { |
1098 | INIT_DELAYED_WORK(&dev->mode_config.output_poll_work, output_poll_execute); | 1168 | INIT_DELAYED_WORK(&dev->mode_config.output_poll_work, output_poll_execute); |
@@ -1102,12 +1172,39 @@ void drm_kms_helper_poll_init(struct drm_device *dev) | |||
1102 | } | 1172 | } |
1103 | EXPORT_SYMBOL(drm_kms_helper_poll_init); | 1173 | EXPORT_SYMBOL(drm_kms_helper_poll_init); |
1104 | 1174 | ||
1175 | /** | ||
1176 | * drm_kms_helper_poll_fini - disable output polling and clean it up | ||
1177 | * @dev: drm_device | ||
1178 | */ | ||
1105 | void drm_kms_helper_poll_fini(struct drm_device *dev) | 1179 | void drm_kms_helper_poll_fini(struct drm_device *dev) |
1106 | { | 1180 | { |
1107 | drm_kms_helper_poll_disable(dev); | 1181 | drm_kms_helper_poll_disable(dev); |
1108 | } | 1182 | } |
1109 | EXPORT_SYMBOL(drm_kms_helper_poll_fini); | 1183 | EXPORT_SYMBOL(drm_kms_helper_poll_fini); |
1110 | 1184 | ||
1185 | /** | ||
1186 | * drm_helper_hpd_irq_event - hotplug processing | ||
1187 | * @dev: drm_device | ||
1188 | * | ||
1189 | * Drivers can use this helper function to run a detect cycle on all connectors | ||
1190 | * which have the DRM_CONNECTOR_POLL_HPD flag set in their &polled member. All | ||
1191 | * other connectors are ignored, which is useful to avoid reprobing fixed | ||
1192 | * panels. | ||
1193 | * | ||
1194 | * This helper function is useful for drivers which can't or don't track hotplug | ||
1195 | * interrupts for each connector. | ||
1196 | * | ||
1197 | * Drivers which support hotplug interrupts for each connector individually and | ||
1198 | * which have a more fine-grained detect logic should bypass this code and | ||
1199 | * directly call drm_kms_helper_hotplug_event() in case the connector state | ||
1200 | * changed. | ||
1201 | * | ||
1202 | * This function must be called from process context with no mode | ||
1203 | * setting locks held. | ||
1204 | * | ||
1205 | * Note that a connector can be both polled and probed from the hotplug handler, | ||
1206 | * in case the hotplug interrupt is known to be unreliable. | ||
1207 | */ | ||
1111 | bool drm_helper_hpd_irq_event(struct drm_device *dev) | 1208 | bool drm_helper_hpd_irq_event(struct drm_device *dev) |
1112 | { | 1209 | { |
1113 | struct drm_connector *connector; | 1210 | struct drm_connector *connector; |