diff mbox

[2/2] drm/atomic: add plane iterator macros

Message ID 1416601712-25036-2-git-send-email-robdclark@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Rob Clark Nov. 21, 2014, 8:28 p.m. UTC
Add helper macros to iterate the current, or incoming set of planes
attached to a crtc.  These helpers are only available for drivers
converted to use atomic-helpers.

Signed-off-by: Rob Clark <robdclark@gmail.com>
---
 Documentation/DocBook/drm.tmpl  |  1 +
 include/drm/drm_atomic_helper.h | 26 ++++++++++++++++++++++++++
 2 files changed, 27 insertions(+)

Comments

Daniel Vetter Nov. 21, 2014, 8:38 p.m. UTC | #1
On Fri, Nov 21, 2014 at 03:28:32PM -0500, Rob Clark wrote:
> Add helper macros to iterate the current, or incoming set of planes
> attached to a crtc.  These helpers are only available for drivers
> converted to use atomic-helpers.
> 
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
>  Documentation/DocBook/drm.tmpl  |  1 +
>  include/drm/drm_atomic_helper.h | 26 ++++++++++++++++++++++++++
>  2 files changed, 27 insertions(+)
> 
> diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> index 8c54f9a..3789f2d 100644
> --- a/Documentation/DocBook/drm.tmpl
> +++ b/Documentation/DocBook/drm.tmpl
> @@ -2343,6 +2343,7 @@ void intel_crt_init(struct drm_device *dev)
>  	<title>Atomic State Reset and Initialization</title>
>  !Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
>        </sect3>
> +!Iinclude/drm/drm_atomic_helper.h
>  !Edrivers/gpu/drm/drm_atomic_helper.c
>      </sect2>
>      <sect2>
> diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
> index 64b4e91..42d56e6 100644
> --- a/include/drm/drm_atomic_helper.h
> +++ b/include/drm/drm_atomic_helper.h
> @@ -96,5 +96,31 @@ drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
>  void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
>  					  struct drm_connector_state *state);
>  
> +/**
> + * drm_crtc_for_each_plane - iterate over planes currently attached to crtc
> + * @plane: the loop cursor
> + * @crtc:  the crtc whose planes are iterated
> + *
> + * This iterates over the current state, useful (for example) when applying
> + * atomic state after it has been checked and swapped.  To iterate over the
> + * planes which *will* be attached (for ->atomic_check()) see
> + * drm_crtc_for_each_pending_plane()
> + */
> +#define drm_crtc_for_each_plane(plane, crtc) \
> +	list_for_each_entry((plane), &(crtc)->dev->mode_config.plane_list, head) \
> +		if ((crtc)->state->plane_mask & (1 << drm_plane_index(plane)))

Implement this as drm_crtc_for_each_pending_plane(plane, (crtc)->state)?
Which means _pending is a strange name ...
-Daniel

> +
> +/**
> + * drm_crtc_for_each_pending_plane - iterate over attached planes in new state
> + * @plane: the loop cursor
> + * @crtc_state: the incoming crtc-state
> + *
> + * Similar to drm_crtc_for_each_plane(), but iterates the planes that will be
> + * attached if the specified state is applied.  Useful during (for example)
> + * ->atomic_check() operations, to validate the incoming state
> + */
> +#define drm_crtc_for_each_pending_plane(plane, crtc_state) \
> +	list_for_each_entry((plane), &(crtc_state)->state->dev->mode_config.plane_list, head) \
> +		if ((crtc_state)->plane_mask & (1 << drm_plane_index(plane)))
>  
>  #endif /* DRM_ATOMIC_HELPER_H_ */
> -- 
> 1.9.3
>
Thierry Reding Nov. 21, 2014, 8:42 p.m. UTC | #2
On Fri, Nov 21, 2014 at 09:38:40PM +0100, Daniel Vetter wrote:
> On Fri, Nov 21, 2014 at 03:28:32PM -0500, Rob Clark wrote:
> > Add helper macros to iterate the current, or incoming set of planes
> > attached to a crtc.  These helpers are only available for drivers
> > converted to use atomic-helpers.
> > 
> > Signed-off-by: Rob Clark <robdclark@gmail.com>
> > ---
> >  Documentation/DocBook/drm.tmpl  |  1 +
> >  include/drm/drm_atomic_helper.h | 26 ++++++++++++++++++++++++++
> >  2 files changed, 27 insertions(+)
> > 
> > diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
> > index 8c54f9a..3789f2d 100644
> > --- a/Documentation/DocBook/drm.tmpl
> > +++ b/Documentation/DocBook/drm.tmpl
> > @@ -2343,6 +2343,7 @@ void intel_crt_init(struct drm_device *dev)
> >  	<title>Atomic State Reset and Initialization</title>
> >  !Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
> >        </sect3>
> > +!Iinclude/drm/drm_atomic_helper.h
> >  !Edrivers/gpu/drm/drm_atomic_helper.c
> >      </sect2>
> >      <sect2>
> > diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
> > index 64b4e91..42d56e6 100644
> > --- a/include/drm/drm_atomic_helper.h
> > +++ b/include/drm/drm_atomic_helper.h
> > @@ -96,5 +96,31 @@ drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
> >  void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
> >  					  struct drm_connector_state *state);
> >  
> > +/**
> > + * drm_crtc_for_each_plane - iterate over planes currently attached to crtc
> > + * @plane: the loop cursor
> > + * @crtc:  the crtc whose planes are iterated
> > + *
> > + * This iterates over the current state, useful (for example) when applying
> > + * atomic state after it has been checked and swapped.  To iterate over the
> > + * planes which *will* be attached (for ->atomic_check()) see
> > + * drm_crtc_for_each_pending_plane()
> > + */
> > +#define drm_crtc_for_each_plane(plane, crtc) \
> > +	list_for_each_entry((plane), &(crtc)->dev->mode_config.plane_list, head) \
> > +		if ((crtc)->state->plane_mask & (1 << drm_plane_index(plane)))
> 
> Implement this as drm_crtc_for_each_pending_plane(plane, (crtc)->state)?
> Which means _pending is a strange name ...

Yeah, I think the drm_crtc_for_each_pending_plane() could be
drm_crtc_state_for_each_plane(), then your suggestion makes perfect
sense.

Thierry
Thierry Reding Nov. 21, 2014, 8:46 p.m. UTC | #3
On Fri, Nov 21, 2014 at 03:28:32PM -0500, Rob Clark wrote:
> Add helper macros to iterate the current, or incoming set of planes
> attached to a crtc.  These helpers are only available for drivers
> converted to use atomic-helpers.
> 
> Signed-off-by: Rob Clark <robdclark@gmail.com>
> ---
>  Documentation/DocBook/drm.tmpl  |  1 +
>  include/drm/drm_atomic_helper.h | 26 ++++++++++++++++++++++++++
>  2 files changed, 27 insertions(+)

I'd personally do s/crtc/CRTC/ in the commit message and kerneldoc
descriptions, but perhaps not everyone shares that same pedantry.

Thierry
Daniel Vetter Nov. 25, 2014, 12:31 p.m. UTC | #4
On Fri, Nov 21, 2014 at 09:42:25PM +0100, Thierry Reding wrote:
> On Fri, Nov 21, 2014 at 09:38:40PM +0100, Daniel Vetter wrote:
> > On Fri, Nov 21, 2014 at 03:28:32PM -0500, Rob Clark wrote:
> > > +#define drm_crtc_for_each_plane(plane, crtc) \
> > > +	list_for_each_entry((plane), &(crtc)->dev->mode_config.plane_list, head) \
> > > +		if ((crtc)->state->plane_mask & (1 << drm_plane_index(plane)))
> > 
> > Implement this as drm_crtc_for_each_pending_plane(plane, (crtc)->state)?
> > Which means _pending is a strange name ...
> 
> Yeah, I think the drm_crtc_for_each_pending_plane() could be
> drm_crtc_state_for_each_plane(), then your suggestion makes perfect
> sense.

I like Thierry's naming here. Rob can you apply that please?

Thanks, Daniel
diff mbox

Patch

diff --git a/Documentation/DocBook/drm.tmpl b/Documentation/DocBook/drm.tmpl
index 8c54f9a..3789f2d 100644
--- a/Documentation/DocBook/drm.tmpl
+++ b/Documentation/DocBook/drm.tmpl
@@ -2343,6 +2343,7 @@  void intel_crt_init(struct drm_device *dev)
 	<title>Atomic State Reset and Initialization</title>
 !Pdrivers/gpu/drm/drm_atomic_helper.c atomic state reset and initialization
       </sect3>
+!Iinclude/drm/drm_atomic_helper.h
 !Edrivers/gpu/drm/drm_atomic_helper.c
     </sect2>
     <sect2>
diff --git a/include/drm/drm_atomic_helper.h b/include/drm/drm_atomic_helper.h
index 64b4e91..42d56e6 100644
--- a/include/drm/drm_atomic_helper.h
+++ b/include/drm/drm_atomic_helper.h
@@ -96,5 +96,31 @@  drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector);
 void drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
 					  struct drm_connector_state *state);
 
+/**
+ * drm_crtc_for_each_plane - iterate over planes currently attached to crtc
+ * @plane: the loop cursor
+ * @crtc:  the crtc whose planes are iterated
+ *
+ * This iterates over the current state, useful (for example) when applying
+ * atomic state after it has been checked and swapped.  To iterate over the
+ * planes which *will* be attached (for ->atomic_check()) see
+ * drm_crtc_for_each_pending_plane()
+ */
+#define drm_crtc_for_each_plane(plane, crtc) \
+	list_for_each_entry((plane), &(crtc)->dev->mode_config.plane_list, head) \
+		if ((crtc)->state->plane_mask & (1 << drm_plane_index(plane)))
+
+/**
+ * drm_crtc_for_each_pending_plane - iterate over attached planes in new state
+ * @plane: the loop cursor
+ * @crtc_state: the incoming crtc-state
+ *
+ * Similar to drm_crtc_for_each_plane(), but iterates the planes that will be
+ * attached if the specified state is applied.  Useful during (for example)
+ * ->atomic_check() operations, to validate the incoming state
+ */
+#define drm_crtc_for_each_pending_plane(plane, crtc_state) \
+	list_for_each_entry((plane), &(crtc_state)->state->dev->mode_config.plane_list, head) \
+		if ((crtc_state)->plane_mask & (1 << drm_plane_index(plane)))
 
 #endif /* DRM_ATOMIC_HELPER_H_ */