[Intel-gfx] [PATCH 04/23] drm/i915: Add intel_atomic_get_crtc_state() helper function

Daniel Vetter daniel at ffwll.ch
Wed Mar 4 07:27:42 PST 2015


On Tue, Mar 03, 2015 at 03:21:58PM +0200, Ander Conselvan de Oliveira wrote:
> The pattern of getting the crtc state with drm_atomic_get_crtc_state()
> and then converting it to intel_crtc_state will repeat quite often in
> the following patches, so add a helper function to save some typing.
> 
> Signed-off-by: Ander Conselvan de Oliveira <ander.conselvan.de.oliveira at intel.com>
> ---
>  drivers/gpu/drm/i915/intel_drv.h | 10 ++++++++++
>  1 file changed, 10 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 632df1c..c1959e0 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -35,6 +35,7 @@
>  #include <drm/drm_fb_helper.h>
>  #include <drm/drm_dp_mst_helper.h>
>  #include <drm/drm_rect.h>
> +#include <drm/drm_atomic.h>
>  
>  #define DIV_ROUND_CLOSEST_ULL(ll, d)	\
>  ({ unsigned long long _tmp = (ll)+(d)/2; do_div(_tmp, d); _tmp; })
> @@ -564,6 +565,7 @@ struct cxsr_latency {
>  };
>  
>  #define to_intel_crtc(x) container_of(x, struct intel_crtc, base)
> +#define to_intel_crtc_state(x) container_of(x, struct intel_crtc_state, base)
>  #define to_intel_connector(x) container_of(x, struct intel_connector, base)
>  #define to_intel_encoder(x) container_of(x, struct intel_encoder, base)
>  #define to_intel_framebuffer(x) container_of(x, struct intel_framebuffer, base)
> @@ -1273,6 +1275,14 @@ int intel_connector_atomic_get_property(struct drm_connector *connector,
>  struct drm_crtc_state *intel_crtc_duplicate_state(struct drm_crtc *crtc);
>  void intel_crtc_destroy_state(struct drm_crtc *crtc,
>  			       struct drm_crtc_state *state);
> +static inline struct intel_crtc_state *
> +intel_atomic_get_crtc_state(struct drm_atomic_state *state,
> +			    struct intel_crtc *crtc)
> +{
> +	struct drm_crtc_state *crtc_state;
> +	crtc_state = drm_atomic_get_crtc_state(state, &crtc->base);
> +	return to_intel_crtc_state(crtc_state);

You need to check for error pointers before upcasting. Just to be robust
against someone putting the base structure not as the first thing.

I've merged all previous patches thus far, thanks.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch


More information about the Intel-gfx mailing list