diff mbox series

[1/3] drm/atomic-helper: Extract drm_atomic_helper_calc_timestamping_constants()

Message ID 20200907120026.6360-1-ville.syrjala@linux.intel.com (mailing list archive)
State New, archived
Headers show
Series [1/3] drm/atomic-helper: Extract drm_atomic_helper_calc_timestamping_constants() | expand

Commit Message

Ville Syrjälä Sept. 7, 2020, noon UTC
From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Put the vblank timestamping constants update loop into its own
function. It has no business living inside
drm_atomic_helper_update_legacy_modeset_state() so we'll be wanting
to move it out entirely. As a first step we'll still call it
from drm_atomic_helper_update_legacy_modeset_state().

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_atomic_helper.c | 22 +++++++++++++++++++++-
 include/drm/drm_atomic_helper.h     |  3 +++
 2 files changed, 24 insertions(+), 1 deletion(-)

Comments

Daniel Vetter Sept. 7, 2020, 6:08 p.m. UTC | #1
On Mon, Sep 07, 2020 at 03:00:24PM +0300, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Put the vblank timestamping constants update loop into its own
> function. It has no business living inside
> drm_atomic_helper_update_legacy_modeset_state() so we'll be wanting
> to move it out entirely. As a first step we'll still call it
> from drm_atomic_helper_update_legacy_modeset_state().
> 
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

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

> ---
>  drivers/gpu/drm/drm_atomic_helper.c | 22 +++++++++++++++++++++-
>  include/drm/drm_atomic_helper.h     |  3 +++
>  2 files changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index 9e1ad493e689..673e3fc282d9 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -1186,13 +1186,33 @@ drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
>  			crtc->x = new_plane_state->src_x >> 16;
>  			crtc->y = new_plane_state->src_y >> 16;
>  		}
> +	}
>  
> +	drm_atomic_helper_calc_timestamping_constants(old_state);
> +}
> +EXPORT_SYMBOL(drm_atomic_helper_update_legacy_modeset_state);
> +
> +/**
> + * drm_atomic_helper_calc_timestamping_constants - update vblank timestamping constants
> + * @state: atomic state object
> + *
> + * Updates the timestamping constants used for precise vblank timestamps
> + * by calling drm_calc_timestamping_constants() for all enabled crtcs in @state.
> + */
> +void drm_atomic_helper_calc_timestamping_constants(struct drm_atomic_state *state)
> +{
> +	struct drm_crtc_state *new_crtc_state;
> +	struct drm_crtc *crtc;
> +	int i;
> +
> +	/* set legacy state in the crtc structure */
> +	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
>  		if (new_crtc_state->enable)
>  			drm_calc_timestamping_constants(crtc,
>  							&new_crtc_state->adjusted_mode);
>  	}
>  }
> -EXPORT_SYMBOL(drm_atomic_helper_update_legacy_modeset_state);
> +EXPORT_SYMBOL(drm_atomic_helper_calc_timestamping_constants);
>  
>  static void
>  crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
> diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
> index b268180c97eb..85df04c8e62f 100644
> --- a/include/drm/drm_atomic_helper.h
> +++ b/include/drm/drm_atomic_helper.h
> @@ -74,6 +74,9 @@ void
>  drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
>  					      struct drm_atomic_state *old_state);
>  
> +void
> +drm_atomic_helper_calc_timestamping_constants(struct drm_atomic_state *state);
> +
>  void drm_atomic_helper_commit_modeset_disables(struct drm_device *dev,
>  					       struct drm_atomic_state *state);
>  void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,
> -- 
> 2.26.2
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox series

Patch

diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 9e1ad493e689..673e3fc282d9 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1186,13 +1186,33 @@  drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 			crtc->x = new_plane_state->src_x >> 16;
 			crtc->y = new_plane_state->src_y >> 16;
 		}
+	}
 
+	drm_atomic_helper_calc_timestamping_constants(old_state);
+}
+EXPORT_SYMBOL(drm_atomic_helper_update_legacy_modeset_state);
+
+/**
+ * drm_atomic_helper_calc_timestamping_constants - update vblank timestamping constants
+ * @state: atomic state object
+ *
+ * Updates the timestamping constants used for precise vblank timestamps
+ * by calling drm_calc_timestamping_constants() for all enabled crtcs in @state.
+ */
+void drm_atomic_helper_calc_timestamping_constants(struct drm_atomic_state *state)
+{
+	struct drm_crtc_state *new_crtc_state;
+	struct drm_crtc *crtc;
+	int i;
+
+	/* set legacy state in the crtc structure */
+	for_each_new_crtc_in_state(state, crtc, new_crtc_state, i) {
 		if (new_crtc_state->enable)
 			drm_calc_timestamping_constants(crtc,
 							&new_crtc_state->adjusted_mode);
 	}
 }
-EXPORT_SYMBOL(drm_atomic_helper_update_legacy_modeset_state);
+EXPORT_SYMBOL(drm_atomic_helper_calc_timestamping_constants);
 
 static void
 crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index b268180c97eb..85df04c8e62f 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -74,6 +74,9 @@  void
 drm_atomic_helper_update_legacy_modeset_state(struct drm_device *dev,
 					      struct drm_atomic_state *old_state);
 
+void
+drm_atomic_helper_calc_timestamping_constants(struct drm_atomic_state *state);
+
 void drm_atomic_helper_commit_modeset_disables(struct drm_device *dev,
 					       struct drm_atomic_state *state);
 void drm_atomic_helper_commit_modeset_enables(struct drm_device *dev,