Re: [PATCH 2/6] drm/modeset-helper: Add simple modeset suspend/resume helpers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Nov 02, 2017 at 09:09:05PM +0100, Noralf Trønnes wrote:
> Add drm_mode_config_helper_suspend/resume() which takes care of
> atomic modeset suspend/resume for simple use cases.
> The suspend state is stored in struct drm_mode_config.
> 
> Signed-off-by: Noralf Trønnes <noralf@xxxxxxxxxxx>

It'd be great if we could add a paragraph somewhere more prominent that
references these 2 helpers. As-is they'll be impossible to find.

But I didn't find a good spot, so

Reviewed-by: Daniel Vetter <daniel.vetter@xxxxxxxx>

on this one. If you have an idea, follow-up would be great.

> ---
>  drivers/gpu/drm/drm_modeset_helper.c | 76 ++++++++++++++++++++++++++++++++++++
>  include/drm/drm_mode_config.h        |  9 +++++
>  include/drm/drm_modeset_helper.h     |  3 ++
>  3 files changed, 88 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_modeset_helper.c b/drivers/gpu/drm/drm_modeset_helper.c
> index 9cb1eede0b4d..f1c24ab0ef09 100644
> --- a/drivers/gpu/drm/drm_modeset_helper.c
> +++ b/drivers/gpu/drm/drm_modeset_helper.c
> @@ -20,6 +20,9 @@
>   * OF THIS SOFTWARE.
>   */
>  
> +#include <drm/drm_atomic_helper.h>
> +#include <drm/drm_crtc_helper.h>
> +#include <drm/drm_fb_helper.h>
>  #include <drm/drm_modeset_helper.h>
>  #include <drm/drm_plane_helper.h>
>  
> @@ -156,3 +159,76 @@ int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
>  					 NULL);
>  }
>  EXPORT_SYMBOL(drm_crtc_init);
> +
> +/**
> + * drm_mode_config_helper_suspend - Modeset suspend helper
> + * @dev: DRM device
> + *
> + * This helper function takes care of suspending the modeset side. It disables
> + * output polling if initialized, suspends fbdev if used and finally calls
> + * drm_atomic_helper_suspend().

ocd nit: Either full new paragraph or merge the lines.
-Daniel

> + * If suspending fails, fbdev and polling is re-enabled.
> + *
> + * Returns:
> + * Zero on success, negative error code on error.
> + *
> + * See also:
> + * drm_kms_helper_poll_disable() and drm_fb_helper_set_suspend_unlocked().
> + */
> +int drm_mode_config_helper_suspend(struct drm_device *dev)
> +{
> +	struct drm_atomic_state *state;
> +
> +	if (!dev)
> +		return 0;
> +
> +	drm_kms_helper_poll_disable(dev);
> +	drm_fb_helper_set_suspend_unlocked(dev->fb_helper, 1);
> +	state = drm_atomic_helper_suspend(dev);
> +	if (IS_ERR(state)) {
> +		drm_fb_helper_set_suspend_unlocked(dev->fb_helper, 0);
> +		drm_kms_helper_poll_enable(dev);
> +		return PTR_ERR(state);
> +	}
> +
> +	dev->mode_config.suspend_state = state;
> +
> +	return 0;
> +}
> +EXPORT_SYMBOL(drm_mode_config_helper_suspend);
> +
> +/**
> + * drm_mode_config_helper_resume - Modeset resume helper
> + * @dev: DRM device
> + *
> + * This helper function takes care of resuming the modeset side. It calls
> + * drm_atomic_helper_resume(), resumes fbdev if used and enables output polling
> + * if initiaized.
> + *
> + * Returns:
> + * Zero on success, negative error code on error.
> + *
> + * See also:
> + * drm_fb_helper_set_suspend_unlocked() and drm_kms_helper_poll_enable().
> + */
> +int drm_mode_config_helper_resume(struct drm_device *dev)
> +{
> +	int ret;
> +
> +	if (!dev)
> +		return 0;
> +
> +	if (WARN_ON(!dev->mode_config.suspend_state))
> +		return -EINVAL;
> +
> +	ret = drm_atomic_helper_resume(dev, dev->mode_config.suspend_state);
> +	if (ret)
> +		DRM_ERROR("Failed to resume (%d)\n", ret);
> +	dev->mode_config.suspend_state = NULL;
> +
> +	drm_fb_helper_set_suspend_unlocked(dev->fb_helper, 0);
> +	drm_kms_helper_poll_enable(dev);
> +
> +	return ret;
> +}
> +EXPORT_SYMBOL(drm_mode_config_helper_resume);
> diff --git a/include/drm/drm_mode_config.h b/include/drm/drm_mode_config.h
> index 1b37368416c8..5a872496b409 100644
> --- a/include/drm/drm_mode_config.h
> +++ b/include/drm/drm_mode_config.h
> @@ -766,6 +766,15 @@ struct drm_mode_config {
>  	/* cursor size */
>  	uint32_t cursor_width, cursor_height;
>  
> +	/**
> +	 * @suspend_state:
> +	 *
> +	 * Atomic state when suspended.
> +	 * Set by drm_mode_config_helper_suspend() and cleared by
> +	 * drm_mode_config_helper_resume().
> +	 */
> +	struct drm_atomic_state *suspend_state;
> +
>  	const struct drm_mode_config_helper_funcs *helper_private;
>  };
>  
> diff --git a/include/drm/drm_modeset_helper.h b/include/drm/drm_modeset_helper.h
> index cb0ec92e11e6..efa337f03129 100644
> --- a/include/drm/drm_modeset_helper.h
> +++ b/include/drm/drm_modeset_helper.h
> @@ -34,4 +34,7 @@ void drm_helper_mode_fill_fb_struct(struct drm_device *dev,
>  int drm_crtc_init(struct drm_device *dev, struct drm_crtc *crtc,
>  		  const struct drm_crtc_funcs *funcs);
>  
> +int drm_mode_config_helper_suspend(struct drm_device *dev);
> +int drm_mode_config_helper_resume(struct drm_device *dev);
> +
>  #endif
> -- 
> 2.14.2
> 

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
https://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux