diff options
| author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-04-10 04:51:11 -0400 |
|---|---|---|
| committer | Dave Airlie <airlied@redhat.com> | 2014-04-17 23:21:17 -0400 |
| commit | 8d754544202c0e4ef02e9c1abdf379bcf7ef9384 (patch) | |
| tree | 9642efef9e6e223ebd8d6754fdfa2f5d30ce7b4f | |
| parent | b6ccd7b9873dc46becd11838c885d5c783784156 (diff) | |
drm: Split out drm_probe_helper.c from drm_crtc_helper.c
This is leftover stuff from my previous doc round which I kinda wanted
to do but didn't yet due to rebase hell.
The modeset helpers and the probing helpers a independent and e.g.
i915 uses the probing stuff but has its own modeset infrastructure. It
hence makes to split this up. While at it add a DOC: comment for the
probing libraray.
It would be rather neat to pull some of the DocBook documenting these
two helpers into in-line DOC: comments. But unfortunately kerneldoc
doesn't support markdown or something similar to make nice-looking
documentation, so the current state is better.
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Dave Airlie <airlied@redhat.com>
| -rw-r--r-- | Documentation/DocBook/drm.tmpl | 5 | ||||
| -rw-r--r-- | drivers/gpu/drm/Makefile | 2 | ||||
| -rw-r--r-- | drivers/gpu/drm/drm_crtc_helper.c | 370 | ||||
| -rw-r--r-- | drivers/gpu/drm/drm_probe_helper.c | 426 | ||||
| -rw-r--r-- | include/drm/drm_crtc_helper.h | 6 |
5 files changed, 437 insertions, 372 deletions
diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl index 702c4474919c..677a02553ec0 100644 --- a/Documentation/DocBook/drm.tmpl +++ b/Documentation/DocBook/drm.tmpl | |||
| @@ -2287,6 +2287,11 @@ void intel_crt_init(struct drm_device *dev) | |||
| 2287 | !Edrivers/gpu/drm/drm_crtc_helper.c | 2287 | !Edrivers/gpu/drm/drm_crtc_helper.c |
| 2288 | </sect2> | 2288 | </sect2> |
| 2289 | <sect2> | 2289 | <sect2> |
| 2290 | <title>Output Probing Helper Functions Reference</title> | ||
| 2291 | !Pdrivers/gpu/drm/drm_probe_helper.c output probing helper overview | ||
| 2292 | !Edrivers/gpu/drm/drm_probe_helper.c | ||
| 2293 | </sect2> | ||
| 2294 | <sect2> | ||
| 2290 | <title>fbdev Helper Functions Reference</title> | 2295 | <title>fbdev Helper Functions Reference</title> |
| 2291 | !Pdrivers/gpu/drm/drm_fb_helper.c fbdev helpers | 2296 | !Pdrivers/gpu/drm/drm_fb_helper.c fbdev helpers |
| 2292 | !Edrivers/gpu/drm/drm_fb_helper.c | 2297 | !Edrivers/gpu/drm/drm_fb_helper.c |
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 9d25dbbe6771..48e38ba22783 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile | |||
| @@ -23,7 +23,7 @@ drm-$(CONFIG_DRM_PANEL) += drm_panel.o | |||
| 23 | 23 | ||
| 24 | drm-usb-y := drm_usb.o | 24 | drm-usb-y := drm_usb.o |
| 25 | 25 | ||
| 26 | drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o | 26 | drm_kms_helper-y := drm_crtc_helper.o drm_dp_helper.o drm_probe_helper.o |
| 27 | drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o | 27 | drm_kms_helper-$(CONFIG_DRM_LOAD_EDID_FIRMWARE) += drm_edid_load.o |
| 28 | drm_kms_helper-$(CONFIG_DRM_KMS_FB_HELPER) += drm_fb_helper.o | 28 | drm_kms_helper-$(CONFIG_DRM_KMS_FB_HELPER) += drm_fb_helper.o |
| 29 | drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o | 29 | drm_kms_helper-$(CONFIG_DRM_KMS_CMA_HELPER) += drm_fb_cma_helper.o |
diff --git a/drivers/gpu/drm/drm_crtc_helper.c b/drivers/gpu/drm/drm_crtc_helper.c index c43825e8f5c1..df281b54db01 100644 --- a/drivers/gpu/drm/drm_crtc_helper.c +++ b/drivers/gpu/drm/drm_crtc_helper.c | |||
| @@ -72,147 +72,6 @@ void drm_helper_move_panel_connectors_to_head(struct drm_device *dev) | |||
| 72 | } | 72 | } |
| 73 | EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head); | 73 | EXPORT_SYMBOL(drm_helper_move_panel_connectors_to_head); |
| 74 | 74 | ||
| 75 | static bool drm_kms_helper_poll = true; | ||
| 76 | module_param_named(poll, drm_kms_helper_poll, bool, 0600); | ||
| 77 | |||
| 78 | static void drm_mode_validate_flag(struct drm_connector *connector, | ||
| 79 | int flags) | ||
| 80 | { | ||
| 81 | struct drm_display_mode *mode; | ||
| 82 | |||
| 83 | if (flags == (DRM_MODE_FLAG_DBLSCAN | DRM_MODE_FLAG_INTERLACE | | ||
| 84 | DRM_MODE_FLAG_3D_MASK)) | ||
| 85 | return; | ||
| 86 | |||
| 87 | list_for_each_entry(mode, &connector->modes, head) { | ||
| 88 | if ((mode->flags & DRM_MODE_FLAG_INTERLACE) && | ||
| 89 | !(flags & DRM_MODE_FLAG_INTERLACE)) | ||
| 90 | mode->status = MODE_NO_INTERLACE; | ||
| 91 | if ((mode->flags & DRM_MODE_FLAG_DBLSCAN) && | ||
| 92 | !(flags & DRM_MODE_FLAG_DBLSCAN)) | ||
| 93 | mode->status = MODE_NO_DBLESCAN; | ||
| 94 | if ((mode->flags & DRM_MODE_FLAG_3D_MASK) && | ||
| 95 | !(flags & DRM_MODE_FLAG_3D_MASK)) | ||
| 96 | mode->status = MODE_NO_STEREO; | ||
| 97 | } | ||
| 98 | |||
| 99 | return; | ||
| 100 | } | ||
| 101 | |||
| 102 | /** | ||
| 103 | * drm_helper_probe_single_connector_modes - get complete set of display modes | ||
| 104 | * @connector: connector to probe | ||
| 105 | * @maxX: max width for modes | ||
| 106 | * @maxY: max height for modes | ||
| 107 | * | ||
| 108 | * Based on the helper callbacks implemented by @connector try to detect all | ||
| 109 | * valid modes. Modes will first be added to the connector's probed_modes list, | ||
| 110 | * then culled (based on validity and the @maxX, @maxY parameters) and put into | ||
| 111 | * the normal modes list. | ||
| 112 | * | ||
| 113 | * Intended to be use as a generic implementation of the ->fill_modes() | ||
| 114 | * @connector vfunc for drivers that use the crtc helpers for output mode | ||
| 115 | * filtering and detection. | ||
| 116 | * | ||
| 117 | * Returns: | ||
| 118 | * The number of modes found on @connector. | ||
| 119 | */ | ||
| 120 | int drm_helper_probe_single_connector_modes(struct drm_connector *connector, | ||
| 121 | uint32_t maxX, uint32_t maxY) | ||
| 122 | { | ||
| 123 | struct drm_device *dev = connector->dev; | ||
| 124 | struct drm_display_mode *mode; | ||
| 125 | struct drm_connector_helper_funcs *connector_funcs = | ||
| 126 | connector->helper_private; | ||
| 127 | int count = 0; | ||
| 128 | int mode_flags = 0; | ||
| 129 | bool verbose_prune = true; | ||
| 130 | |||
| 131 | WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); | ||
| 132 | |||
| 133 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s]\n", connector->base.id, | ||
| 134 | drm_get_connector_name(connector)); | ||
| 135 | /* set all modes to the unverified state */ | ||
| 136 | list_for_each_entry(mode, &connector->modes, head) | ||
| 137 | mode->status = MODE_UNVERIFIED; | ||
| 138 | |||
| 139 | if (connector->force) { | ||
| 140 | if (connector->force == DRM_FORCE_ON) | ||
| 141 | connector->status = connector_status_connected; | ||
| 142 | else | ||
| 143 | connector->status = connector_status_disconnected; | ||
| 144 | if (connector->funcs->force) | ||
| 145 | connector->funcs->force(connector); | ||
| 146 | } else { | ||
| 147 | connector->status = connector->funcs->detect(connector, true); | ||
| 148 | } | ||
| 149 | |||
| 150 | /* Re-enable polling in case the global poll config changed. */ | ||
| 151 | if (drm_kms_helper_poll != dev->mode_config.poll_running) | ||
| 152 | drm_kms_helper_poll_enable(dev); | ||
| 153 | |||
| 154 | dev->mode_config.poll_running = drm_kms_helper_poll; | ||
| 155 | |||
| 156 | if (connector->status == connector_status_disconnected) { | ||
| 157 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s] disconnected\n", | ||
| 158 | connector->base.id, drm_get_connector_name(connector)); | ||
| 159 | drm_mode_connector_update_edid_property(connector, NULL); | ||
| 160 | verbose_prune = false; | ||
| 161 | goto prune; | ||
| 162 | } | ||
| 163 | |||
| 164 | #ifdef CONFIG_DRM_LOAD_EDID_FIRMWARE | ||
| 165 | count = drm_load_edid_firmware(connector); | ||
| 166 | if (count == 0) | ||
| 167 | #endif | ||
| 168 | count = (*connector_funcs->get_modes)(connector); | ||
| 169 | |||
| 170 | if (count == 0 && connector->status == connector_status_connected) | ||
| 171 | count = drm_add_modes_noedid(connector, 1024, 768); | ||
| 172 | if (count == 0) | ||
| 173 | goto prune; | ||
| 174 | |||
| 175 | drm_mode_connector_list_update(connector); | ||
| 176 | |||
| 177 | if (maxX && maxY) | ||
| 178 | drm_mode_validate_size(dev, &connector->modes, maxX, maxY); | ||
| 179 | |||
| 180 | if (connector->interlace_allowed) | ||
| 181 | mode_flags |= DRM_MODE_FLAG_INTERLACE; | ||
| 182 | if (connector->doublescan_allowed) | ||
| 183 | mode_flags |= DRM_MODE_FLAG_DBLSCAN; | ||
| 184 | if (connector->stereo_allowed) | ||
| 185 | mode_flags |= DRM_MODE_FLAG_3D_MASK; | ||
| 186 | drm_mode_validate_flag(connector, mode_flags); | ||
| 187 | |||
| 188 | list_for_each_entry(mode, &connector->modes, head) { | ||
| 189 | if (mode->status == MODE_OK) | ||
| 190 | mode->status = connector_funcs->mode_valid(connector, | ||
| 191 | mode); | ||
| 192 | } | ||
| 193 | |||
| 194 | prune: | ||
| 195 | drm_mode_prune_invalid(dev, &connector->modes, verbose_prune); | ||
| 196 | |||
| 197 | if (list_empty(&connector->modes)) | ||
| 198 | return 0; | ||
| 199 | |||
| 200 | list_for_each_entry(mode, &connector->modes, head) | ||
| 201 | mode->vrefresh = drm_mode_vrefresh(mode); | ||
| 202 | |||
| 203 | drm_mode_sort(&connector->modes); | ||
| 204 | |||
| 205 | DRM_DEBUG_KMS("[CONNECTOR:%d:%s] probed modes :\n", connector->base.id, | ||
| 206 | drm_get_connector_name(connector)); | ||
| 207 | list_for_each_entry(mode, &connector->modes, head) { | ||
| 208 | drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V); | ||
| 209 | drm_mode_debug_printmodeline(mode); | ||
| 210 | } | ||
| 211 | |||
| 212 | return count; | ||
| 213 | } | ||
| 214 | EXPORT_SYMBOL(drm_helper_probe_single_connector_modes); | ||
| 215 | |||
| 216 | /** | 75 | /** |
| 217 | * drm_helper_encoder_in_use - check if a given encoder is in use | 76 | * drm_helper_encoder_in_use - check if a given encoder is in use |
| 218 | * @encoder: encoder to check | ||
