]> git.baikalelectronics.ru Git - kernel.git/commitdiff
drm: Wrap the check for atomic_commit implementation
authorDhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Thu, 22 Dec 2016 08:50:42 +0000 (00:50 -0800)
committerDaniel Vetter <daniel.vetter@ffwll.ch>
Tue, 27 Dec 2016 09:44:00 +0000 (10:44 +0100)
This check is useful for drivers that do not have DRIVER_ATOMIC set but
have atomic modesetting internally implemented. Wrap the check into a
function since this is used in many places and as a bonus, the function
name helps to document what the check is for.

v2:
Change return type to bool (Ville)
Move the function drm_atomic.h (Daniel)
Fixed comment marker for documentation

Suggested-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Cc: Ben Skeggs <bskeggs@redhat.com>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
[danvet: Move back to drmP.h because include hell.]
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/1482396643-32456-1-git-send-email-dhinakaran.pandiyan@intel.com
drivers/gpu/drm/drm_fb_helper.c
drivers/gpu/drm/nouveau/nouveau_connector.c
drivers/gpu/drm/nouveau/nouveau_display.c
drivers/gpu/drm/nouveau/nouveau_fbcon.c
include/drm/drmP.h
include/drm/drm_atomic.h

index 145d55fef69ebbef01011fbecad538da60637f52..730342cbe899b68f5e2533b5144f170afb83f0b2 100644 (file)
@@ -405,7 +405,7 @@ static int restore_fbdev_mode(struct drm_fb_helper *fb_helper)
 
        drm_warn_on_modeset_not_all_locked(dev);
 
-       if (dev->mode_config.funcs->atomic_commit)
+       if (drm_drv_uses_atomic_modeset(dev))
                return restore_fbdev_mode_atomic(fb_helper);
 
        drm_for_each_plane(plane, dev) {
@@ -1444,7 +1444,7 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var,
                return -EBUSY;
        }
 
-       if (dev->mode_config.funcs->atomic_commit) {
+       if (drm_drv_uses_atomic_modeset(dev)) {
                ret = pan_display_atomic(var, info);
                goto unlock;
        }
@@ -2060,7 +2060,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper,
         * NULL we fallback to the default drm_atomic_helper_best_encoder()
         * helper.
         */
-       if (fb_helper->dev->mode_config.funcs->atomic_commit &&
+       if (drm_drv_uses_atomic_modeset(fb_helper->dev) &&
            !connector_funcs->best_encoder)
                encoder = drm_atomic_helper_best_encoder(connector);
        else
index 947c200655b4d1da0c0ea77d6ceaf47cdb7d776d..966d20ab4de47e428ad2fb03fdfb1bb56563343a 100644 (file)
@@ -33,6 +33,7 @@
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_crtc_helper.h>
+#include <drm/drm_atomic.h>
 
 #include "nouveau_reg.h"
 #include "nouveau_drv.h"
@@ -769,7 +770,7 @@ nouveau_connector_set_property(struct drm_connector *connector,
        struct drm_encoder *encoder = to_drm_encoder(nv_encoder);
        int ret;
 
-       if (connector->dev->mode_config.funcs->atomic_commit)
+       if (drm_drv_uses_atomic_modeset(connector->dev))
                return drm_atomic_helper_connector_set_property(connector, property, value);
 
        ret = connector->funcs->atomic_set_property(&nv_connector->base,
@@ -1074,7 +1075,7 @@ nouveau_connector_helper_funcs = {
 static int
 nouveau_connector_dpms(struct drm_connector *connector, int mode)
 {
-       if (connector->dev->mode_config.funcs->atomic_commit)
+       if (drm_drv_uses_atomic_modeset(connector->dev))
                return drm_atomic_helper_connector_dpms(connector, mode);
        return drm_helper_connector_dpms(connector, mode);
 }
index c5cf88859b0b0f23e5b2eeb1c12128dd1a21d0ad..add353e230f48e5423817025d139839f455a34e9 100644 (file)
@@ -162,7 +162,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe,
        list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
                if (nouveau_crtc(crtc)->index == pipe) {
                        struct drm_display_mode *mode;
-                       if (dev->mode_config.funcs->atomic_commit)
+                       if (drm_drv_uses_atomic_modeset(dev))
                                mode = &crtc->state->adjusted_mode;
                        else
                                mode = &crtc->hwmode;
@@ -738,7 +738,7 @@ nouveau_display_suspend(struct drm_device *dev, bool runtime)
        struct nouveau_display *disp = nouveau_display(dev);
        struct drm_crtc *crtc;
 
-       if (dev->mode_config.funcs->atomic_commit) {
+       if (drm_drv_uses_atomic_modeset(dev)) {
                if (!runtime) {
                        disp->suspend = nouveau_atomic_suspend(dev);
                        if (IS_ERR(disp->suspend)) {
@@ -784,7 +784,7 @@ nouveau_display_resume(struct drm_device *dev, bool runtime)
        struct drm_crtc *crtc;
        int ret;
 
-       if (dev->mode_config.funcs->atomic_commit) {
+       if (drm_drv_uses_atomic_modeset(dev)) {
                nouveau_display_init(dev);
                if (disp->suspend) {
                        drm_atomic_helper_resume(dev, disp->suspend);
index 5600f6c64497d5bc073810c92eb41e5a38c21a74..9de6abb65781d454288c7a847565ac2662f80a60 100644 (file)
@@ -41,6 +41,7 @@
 #include <drm/drm_crtc.h>
 #include <drm/drm_crtc_helper.h>
 #include <drm/drm_fb_helper.h>
+#include <drm/drm_atomic.h>
 
 #include "nouveau_drv.h"
 #include "nouveau_gem.h"
@@ -524,7 +525,7 @@ nouveau_fbcon_init(struct drm_device *dev)
                preferred_bpp = 32;
 
        /* disable all the possible outputs/crtcs before entering KMS mode */
-       if (!dev->mode_config.funcs->atomic_commit)
+       if (!drm_drv_uses_atomic_modeset(dev))
                drm_helper_disable_unused_functions(dev);
 
        ret = drm_fb_helper_initial_config(&fbcon->helper, preferred_bpp);
index a9cfd33c7b1a4d912f3bcd242b8ecc32e167c127..8671ddd256fc5a1f276e5505ba35ae445364c238 100644 (file)
@@ -634,6 +634,19 @@ struct drm_device {
        int switch_power_state;
 };
 
+/**
+ * drm_drv_uses_atomic_modeset - check if the driver implements
+ * atomic_commit()
+ * @dev: DRM device
+ *
+ * This check is useful if drivers do not have DRIVER_ATOMIC set but
+ * have atomic modesetting internally implemented.
+ */
+static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev)
+{
+       return dev->mode_config.funcs->atomic_commit != NULL;
+}
+
 #include <drm/drm_irq.h>
 
 #define DRM_SWITCH_POWER_ON 0
index 8cc7ca2079fbe35702a32c972496604675949e8f..b0ebe0fafc413f9c0466e0638bd24e5f5c6be529 100644 (file)
@@ -419,5 +419,4 @@ drm_atomic_crtc_needs_modeset(const struct drm_crtc_state *state)
               state->connectors_changed;
 }
 
-
 #endif /* DRM_ATOMIC_H_ */