drm: rcar-du: add rcar_du_get_{old,new}_group_state()
Add helpers to get the old and new group state for a given group object.
Signed-off-by: Kieran Bingham <kieran.bingham+renesas@ideasonboard.com>
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.c b/drivers/gpu/drm/rcar-du/rcar_du_group.c
index 6333931..b2c8990 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.c
@@ -398,6 +398,58 @@ rcar_du_get_group_state(struct drm_atomic_state *state,
return to_rcar_group_state(pstate);
}
+/**
+ * rcar_du_get_old_group_state - get old group state, if it exists
+ * @state: global atomic state object
+ * @rgrp: group to grab
+ *
+ * This function returns the old group state for the given group, or
+ * NULL if the group is not part of the global atomic state.
+ */
+struct rcar_du_group_state *
+rcar_du_get_old_group_state(struct drm_atomic_state *state,
+ struct rcar_du_group *rgrp)
+{
+ struct drm_private_obj *obj = &rgrp->private;
+ struct drm_private_state *pstate;
+ unsigned int i;
+
+ for (i = 0; i < state->num_private_objs; i++) {
+ if (obj == state->private_objs[i].ptr) {
+ pstate = state->private_objs[i].old_state;
+ return to_rcar_group_state(pstate);
+ }
+ }
+
+ return NULL;
+}
+
+/**
+ * rcar_du_get_new_group_state - get new group state, if it exists
+ * @state: global atomic state object
+ * @rgrp: group to grab
+ *
+ * This function returns the new group state for the given group, or
+ * NULL if the group is not part of the global atomic state.
+ */
+struct rcar_du_group_state *
+rcar_du_get_new_group_state(struct drm_atomic_state *state,
+ struct rcar_du_group *rgrp)
+{
+ struct drm_private_obj *obj = &rgrp->private;
+ struct drm_private_state *pstate;
+ unsigned int i;
+
+ for (i = 0; i < state->num_private_objs; i++) {
+ if (obj == state->private_objs[i].ptr) {
+ pstate = state->private_objs[i].new_state;
+ return to_rcar_group_state(pstate);
+ }
+ }
+
+ return NULL;
+}
+
int rcar_du_group_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state)
{
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_group.h b/drivers/gpu/drm/rcar-du/rcar_du_group.h
index 3c76c12..d67eea4 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_group.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_group.h
@@ -82,6 +82,12 @@ int rcar_du_set_dpad0_vsp1_routing(struct rcar_du_device *rcdu);
struct rcar_du_group_state *
rcar_du_get_group_state(struct drm_atomic_state *state,
struct rcar_du_group *rgrp);
+struct rcar_du_group_state *
+rcar_du_get_old_group_state(struct drm_atomic_state *state,
+ struct rcar_du_group *rgrp);
+struct rcar_du_group_state *
+rcar_du_get_new_group_state(struct drm_atomic_state *state,
+ struct rcar_du_group *rgrp);
int rcar_du_group_atomic_check(struct drm_device *dev,
struct drm_atomic_state *state);
int rcar_du_group_atomic_pre_commit(struct drm_device *dev,