diff options
author | Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com> | 2016-12-22 03:50:42 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-12-27 04:44:00 -0500 |
commit | a743d7582db9aba0e7078d6386bdad2756309dba (patch) | |
tree | f142599c73b31d08257ee07294b4fbcf30df54e9 | |
parent | f79f26921ee12c6fc14d0df61b1eb27a5070b959 (diff) |
drm: Wrap the check for atomic_commit implementation
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
-rw-r--r-- | drivers/gpu/drm/drm_fb_helper.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_connector.c | 5 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_display.c | 6 | ||||
-rw-r--r-- | drivers/gpu/drm/nouveau/nouveau_fbcon.c | 3 | ||||
-rw-r--r-- | include/drm/drmP.h | 13 | ||||
-rw-r--r-- | include/drm/drm_atomic.h | 1 |
6 files changed, 24 insertions, 10 deletions
diff --git a/drivers/gpu/drm/drm_fb_helper.c b/drivers/gpu/drm/drm_fb_helper.c index 145d55fef69e..730342cbe899 100644 --- a/drivers/gpu/drm/drm_fb_helper.c +++ b/drivers/gpu/drm/drm_fb_helper.c | |||
@@ -405,7 +405,7 @@ static int restore_fbdev_mode(struct drm_fb_helper *fb_helper) | |||
405 | 405 | ||
406 | drm_warn_on_modeset_not_all_locked(dev); | 406 | drm_warn_on_modeset_not_all_locked(dev); |
407 | 407 | ||
408 | if (dev->mode_config.funcs->atomic_commit) | 408 | if (drm_drv_uses_atomic_modeset(dev)) |
409 | return restore_fbdev_mode_atomic(fb_helper); | 409 | return restore_fbdev_mode_atomic(fb_helper); |
410 | 410 | ||
411 | drm_for_each_plane(plane, dev) { | 411 | drm_for_each_plane(plane, dev) { |
@@ -1444,7 +1444,7 @@ int drm_fb_helper_pan_display(struct fb_var_screeninfo *var, | |||
1444 | return -EBUSY; | 1444 | return -EBUSY; |
1445 | } | 1445 | } |
1446 | 1446 | ||
1447 | if (dev->mode_config.funcs->atomic_commit) { | 1447 | if (drm_drv_uses_atomic_modeset(dev)) { |
1448 | ret = pan_display_atomic(var, info); | 1448 | ret = pan_display_atomic(var, info); |
1449 | goto unlock; | 1449 | goto unlock; |
1450 | } | 1450 | } |
@@ -2060,7 +2060,7 @@ static int drm_pick_crtcs(struct drm_fb_helper *fb_helper, | |||
2060 | * NULL we fallback to the default drm_atomic_helper_best_encoder() | 2060 | * NULL we fallback to the default drm_atomic_helper_best_encoder() |
2061 | * helper. | 2061 | * helper. |
2062 | */ | 2062 | */ |
2063 | if (fb_helper->dev->mode_config.funcs->atomic_commit && | 2063 | if (drm_drv_uses_atomic_modeset(fb_helper->dev) && |
2064 | !connector_funcs->best_encoder) | 2064 | !connector_funcs->best_encoder) |
2065 | encoder = drm_atomic_helper_best_encoder(connector); | 2065 | encoder = drm_atomic_helper_best_encoder(connector); |
2066 | else | 2066 | else |
diff --git a/drivers/gpu/drm/nouveau/nouveau_connector.c b/drivers/gpu/drm/nouveau/nouveau_connector.c index 947c200655b4..966d20ab4de4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_connector.c +++ b/drivers/gpu/drm/nouveau/nouveau_connector.c | |||
@@ -33,6 +33,7 @@ | |||
33 | #include <drm/drm_atomic_helper.h> | 33 | #include <drm/drm_atomic_helper.h> |
34 | #include <drm/drm_edid.h> | 34 | #include <drm/drm_edid.h> |
35 | #include <drm/drm_crtc_helper.h> | 35 | #include <drm/drm_crtc_helper.h> |
36 | #include <drm/drm_atomic.h> | ||
36 | 37 | ||
37 | #include "nouveau_reg.h" | 38 | #include "nouveau_reg.h" |
38 | #include "nouveau_drv.h" | 39 | #include "nouveau_drv.h" |
@@ -769,7 +770,7 @@ nouveau_connector_set_property(struct drm_connector *connector, | |||
769 | struct drm_encoder *encoder = to_drm_encoder(nv_encoder); | 770 | struct drm_encoder *encoder = to_drm_encoder(nv_encoder); |
770 | int ret; | 771 | int ret; |
771 | 772 | ||
772 | if (connector->dev->mode_config.funcs->atomic_commit) | 773 | if (drm_drv_uses_atomic_modeset(connector->dev)) |
773 | return drm_atomic_helper_connector_set_property(connector, property, value); | 774 | return drm_atomic_helper_connector_set_property(connector, property, value); |
774 | 775 | ||
775 | ret = connector->funcs->atomic_set_property(&nv_connector->base, | 776 | ret = connector->funcs->atomic_set_property(&nv_connector->base, |
@@ -1074,7 +1075,7 @@ nouveau_connector_helper_funcs = { | |||
1074 | static int | 1075 | static int |
1075 | nouveau_connector_dpms(struct drm_connector *connector, int mode) | 1076 | nouveau_connector_dpms(struct drm_connector *connector, int mode) |
1076 | { | 1077 | { |
1077 | if (connector->dev->mode_config.funcs->atomic_commit) | 1078 | if (drm_drv_uses_atomic_modeset(connector->dev)) |
1078 | return drm_atomic_helper_connector_dpms(connector, mode); | 1079 | return drm_atomic_helper_connector_dpms(connector, mode); |
1079 | return drm_helper_connector_dpms(connector, mode); | 1080 | return drm_helper_connector_dpms(connector, mode); |
1080 | } | 1081 | } |
diff --git a/drivers/gpu/drm/nouveau/nouveau_display.c b/drivers/gpu/drm/nouveau/nouveau_display.c index c5cf88859b0b..add353e230f4 100644 --- a/drivers/gpu/drm/nouveau/nouveau_display.c +++ b/drivers/gpu/drm/nouveau/nouveau_display.c | |||
@@ -162,7 +162,7 @@ nouveau_display_vblstamp(struct drm_device *dev, unsigned int pipe, | |||
162 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { | 162 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) { |
163 | if (nouveau_crtc(crtc)->index == pipe) { | 163 | if (nouveau_crtc(crtc)->index == pipe) { |
164 | struct drm_display_mode *mode; | 164 | struct drm_display_mode *mode; |
165 | if (dev->mode_config.funcs->atomic_commit) | 165 | if (drm_drv_uses_atomic_modeset(dev)) |
166 | mode = &crtc->state->adjusted_mode; | 166 | mode = &crtc->state->adjusted_mode; |
167 | else | 167 | else |
168 | mode = &crtc->hwmode; | 168 | mode = &crtc->hwmode; |
@@ -738,7 +738,7 @@ nouveau_display_suspend(struct drm_device *dev, bool runtime) | |||
738 | struct nouveau_display *disp = nouveau_display(dev); | 738 | struct nouveau_display *disp = nouveau_display(dev); |
739 | struct drm_crtc *crtc; | 739 | struct drm_crtc *crtc; |
740 | 740 | ||
741 | if (dev->mode_config.funcs->atomic_commit) { | 741 | if (drm_drv_uses_atomic_modeset(dev)) { |
742 | if (!runtime) { | 742 | if (!runtime) { |
743 | disp->suspend = nouveau_atomic_suspend(dev); | 743 | disp->suspend = nouveau_atomic_suspend(dev); |
744 | if (IS_ERR(disp->suspend)) { | 744 | if (IS_ERR(disp->suspend)) { |
@@ -784,7 +784,7 @@ nouveau_display_resume(struct drm_device *dev, bool runtime) | |||
784 | struct drm_crtc *crtc; | 784 | struct drm_crtc *crtc; |
785 | int ret; | 785 | int ret; |
786 | 786 | ||
787 | if (dev->mode_config.funcs->atomic_commit) { | 787 | if (drm_drv_uses_atomic_modeset(dev)) { |
788 | nouveau_display_init(dev); | 788 | nouveau_display_init(dev); |
789 | if (disp->suspend) { | 789 | if (disp->suspend) { |
790 | drm_atomic_helper_resume(dev, disp->suspend); | 790 | drm_atomic_helper_resume(dev, disp->suspend); |
diff --git a/drivers/gpu/drm/nouveau/nouveau_fbcon.c b/drivers/gpu/drm/nouveau/nouveau_fbcon.c index 5600f6c64497..9de6abb65781 100644 --- a/drivers/gpu/drm/nouveau/nouveau_fbcon.c +++ b/drivers/gpu/drm/nouveau/nouveau_fbcon.c | |||
@@ -41,6 +41,7 @@ | |||
41 | #include <drm/drm_crtc.h> | 41 | #include <drm/drm_crtc.h> |
42 | #include <drm/drm_crtc_helper.h> | 42 | #include <drm/drm_crtc_helper.h> |
43 | #include <drm/drm_fb_helper.h> | 43 | #include <drm/drm_fb_helper.h> |
44 | #include <drm/drm_atomic.h> | ||
44 | 45 | ||
45 | #include "nouveau_drv.h" | 46 | #include "nouveau_drv.h" |
46 | #include "nouveau_gem.h" | 47 | #include "nouveau_gem.h" |
@@ -524,7 +525,7 @@ nouveau_fbcon_init(struct drm_device *dev) | |||
524 | preferred_bpp = 32; | 525 | preferred_bpp = 32; |
525 | 526 | ||
526 | /* disable all the possible outputs/crtcs before entering KMS mode */ | 527 | /* disable all the possible outputs/crtcs before entering KMS mode */ |
527 | if (!dev->mode_config.funcs->atomic_commit) | 528 | if (!drm_drv_uses_atomic_modeset(dev)) |
528 | drm_helper_disable_unused_functions(dev); | 529 | drm_helper_disable_unused_functions(dev); |
529 | 530 | ||
530 | ret = drm_fb_helper_initial_config(&fbcon->helper, preferred_bpp); | 531 | ret = drm_fb_helper_initial_config(&fbcon->helper, preferred_bpp); |
diff --git a/include/drm/drmP.h b/include/drm/drmP.h index a9cfd33c7b1a..8671ddd256fc 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h | |||
@@ -634,6 +634,19 @@ struct drm_device { | |||
634 | int switch_power_state; | 634 | int switch_power_state; |
635 | }; | 635 | }; |
636 | 636 | ||
637 | /** | ||
638 | * drm_drv_uses_atomic_modeset - check if the driver implements | ||
639 | * atomic_commit() | ||
640 | * @dev: DRM device | ||
641 | * | ||
642 | * This check is useful if drivers do not have DRIVER_ATOMIC set but | ||
643 | * have atomic modesetting internally implemented. | ||
644 | */ | ||
645 | static inline bool drm_drv_uses_atomic_modeset(struct drm_device *dev) | ||
646 | { | ||
647 | return dev->mode_config.funcs->atomic_commit != NULL; | ||
648 | } | ||
649 | |||
637 | #include <drm/drm_irq.h> | 650 | #include <drm/drm_irq.h> |
638 | 651 | ||
639 | #define DRM_SWITCH_POWER_ON 0 | 652 | #define DRM_SWITCH_POWER_ON 0 |
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h index 8cc7ca2079fb..b0ebe0fafc41 100644 --- a/include/drm/drm_atomic.h +++ b/include/drm/drm_atomic.h | |||
@@ -419,5 +419,4 @@ drm_atomic_crtc_needs_modeset(const struct drm_crtc_state *state) | |||
419 | state->connectors_changed; | 419 | state->connectors_changed; |
420 | } | 420 | } |
421 | 421 | ||
422 | |||
423 | #endif /* DRM_ATOMIC_H_ */ | 422 | #endif /* DRM_ATOMIC_H_ */ |