drm: Add drm_{crtc/encoder/connector}_mode_valid()
authorJose Abreu <Jose.Abreu@synopsys.com>
Thu, 25 May 2017 14:19:13 +0000 (15:19 +0100)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 30 May 2017 06:37:24 +0000 (08:37 +0200)
Add a new helper to call crtc->mode_valid, connector->mode_valid
and encoder->mode_valid callbacks.

Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Jose Abreu <joabreu@synopsys.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>
Cc: Carlos Palminha <palminha@synopsys.com>
Cc: Dave Airlie <airlied@linux.ie>
Changes v2->v3:
- Move helpers to drm_probe_helper.c (Daniel)
- Squeeze patches that introduce helpers into a single
one (Daniel)

Signed-off-by: Jose Abreu <joabreu@synopsys.com>
[danvet: Make it compile when CONFIG_DRM_DP_AUX_CHARDEV is selected.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/b55c8bd029da219ff04e39086025c115731a49b1.1495720737.git.joabreu@synopsys.com
drivers/gpu/drm/drm_crtc_helper_internal.h
drivers/gpu/drm/drm_probe_helper.c

index 28295e5d0d9eaa0c5eddba195cc1c4b3d16fab0f..b5ac1581e6231dce42bd3c12756d4830fb6b5556 100644 (file)
  * implementation details and are not exported to drivers.
  */
 
  * implementation details and are not exported to drivers.
  */
 
+#include <drm/drm_connector.h>
+#include <drm/drm_crtc.h>
 #include <drm/drm_dp_helper.h>
 #include <drm/drm_dp_helper.h>
+#include <drm/drm_encoder.h>
+#include <drm/drm_modes.h>
 
 /* drm_fb_helper.c */
 #ifdef CONFIG_DRM_FBDEV_EMULATION
 
 /* drm_fb_helper.c */
 #ifdef CONFIG_DRM_FBDEV_EMULATION
@@ -63,3 +67,11 @@ static inline void drm_dp_aux_unregister_devnode(struct drm_dp_aux *aux)
 {
 }
 #endif
 {
 }
 #endif
+
+/* drm_probe_helper.c */
+enum drm_mode_status drm_crtc_mode_valid(struct drm_crtc *crtc,
+                                        const struct drm_display_mode *mode);
+enum drm_mode_status drm_encoder_mode_valid(struct drm_encoder *encoder,
+                                           const struct drm_display_mode *mode);
+enum drm_mode_status drm_connector_mode_valid(struct drm_connector *connector,
+                                             struct drm_display_mode *mode);
index 1b0c14ab3fffd1a6fa24b97b90ad16545e766d03..f01abdc124d289f258c63d004c64fb48031f9a7a 100644 (file)
@@ -38,6 +38,9 @@
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
 #include <drm/drm_edid.h>
+#include <drm/drm_modeset_helper_vtables.h>
+
+#include "drm_crtc_helper_internal.h"
 
 /**
  * DOC: output probing helper overview
 
 /**
  * DOC: output probing helper overview
@@ -113,6 +116,41 @@ static int drm_helper_probe_add_cmdline_mode(struct drm_connector *connector)
        return 1;
 }
 
        return 1;
 }
 
+enum drm_mode_status drm_crtc_mode_valid(struct drm_crtc *crtc,
+                                        const struct drm_display_mode *mode)
+{
+       const struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+
+       if (!crtc_funcs || !crtc_funcs->mode_valid)
+               return MODE_OK;
+
+       return crtc_funcs->mode_valid(crtc, mode);
+}
+
+enum drm_mode_status drm_encoder_mode_valid(struct drm_encoder *encoder,
+                                           const struct drm_display_mode *mode)
+{
+       const struct drm_encoder_helper_funcs *encoder_funcs =
+               encoder->helper_private;
+
+       if (!encoder_funcs || !encoder_funcs->mode_valid)
+               return MODE_OK;
+
+       return encoder_funcs->mode_valid(encoder, mode);
+}
+
+enum drm_mode_status drm_connector_mode_valid(struct drm_connector *connector,
+                                             struct drm_display_mode *mode)
+{
+       const struct drm_connector_helper_funcs *connector_funcs =
+               connector->helper_private;
+
+       if (!connector_funcs || !connector_funcs->mode_valid)
+               return MODE_OK;
+
+       return connector_funcs->mode_valid(connector, mode);
+}
+
 #define DRM_OUTPUT_POLL_PERIOD (10*HZ)
 /**
  * drm_kms_helper_poll_enable - re-enable output polling.
 #define DRM_OUTPUT_POLL_PERIOD (10*HZ)
 /**
  * drm_kms_helper_poll_enable - re-enable output polling.