[Freedreno] [PATCH 3/6] drm: add helpers to go from plane state to drm_rect
Sean Paul
seanpaul at chromium.org
Mon Oct 17 17:00:36 UTC 2016
On Fri, Oct 14, 2016 at 7:55 PM, Rob Clark <robdclark at gmail.com> wrote:
Reviewed-by: Sean Paul <seanpaul at chromium.org>
> Signed-off-by: Rob Clark <robdclark at gmail.com>
> ---
> drivers/gpu/drm/drm_simple_kms_helper.c | 14 ++------------
> drivers/gpu/drm/i915/intel_atomic_plane.c | 10 ++--------
> drivers/gpu/drm/mediatek/mtk_drm_plane.c | 15 ++-------------
> drivers/gpu/drm/rockchip/rockchip_drm_vop.c | 10 ++--------
> include/drm/drm_crtc.h | 24 ++++++++++++++++++++++++
> 5 files changed, 32 insertions(+), 41 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c
> index 0db36d2..9834fc5 100644
> --- a/drivers/gpu/drm/drm_simple_kms_helper.c
> +++ b/drivers/gpu/drm/drm_simple_kms_helper.c
> @@ -73,18 +73,8 @@ static const struct drm_crtc_funcs drm_simple_kms_crtc_funcs = {
> static int drm_simple_kms_plane_atomic_check(struct drm_plane *plane,
> struct drm_plane_state *plane_state)
> {
> - struct drm_rect src = {
> - .x1 = plane_state->src_x,
> - .y1 = plane_state->src_y,
> - .x2 = plane_state->src_x + plane_state->src_w,
> - .y2 = plane_state->src_y + plane_state->src_h,
> - };
> - struct drm_rect dest = {
> - .x1 = plane_state->crtc_x,
> - .y1 = plane_state->crtc_y,
> - .x2 = plane_state->crtc_x + plane_state->crtc_w,
> - .y2 = plane_state->crtc_y + plane_state->crtc_h,
> - };
> + struct drm_rect src = drm_plane_state_src(plane_state);
> + struct drm_rect dest = drm_plane_state_dest(plane_state);
> struct drm_rect clip = { 0 };
> struct drm_simple_display_pipe *pipe;
> struct drm_crtc_state *crtc_state;
> diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
> index 7de7721..6682e9b 100644
> --- a/drivers/gpu/drm/i915/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
> @@ -139,14 +139,8 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
> * we want to keep another copy internal to our driver that we can
> * clip/modify ourselves.
> */
> - intel_state->src.x1 = state->src_x;
> - intel_state->src.y1 = state->src_y;
> - intel_state->src.x2 = state->src_x + state->src_w;
> - intel_state->src.y2 = state->src_y + state->src_h;
> - intel_state->dst.x1 = state->crtc_x;
> - intel_state->dst.y1 = state->crtc_y;
> - intel_state->dst.x2 = state->crtc_x + state->crtc_w;
> - intel_state->dst.y2 = state->crtc_y + state->crtc_h;
> + intel_state->src = drm_plane_state_src(state);
> + intel_state->dst = drm_plane_state_dest(state);
>
> /* Clip all planes to CRTC size, or 0x0 if CRTC is disabled */
> intel_state->clip.x1 = 0;
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_plane.c b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> index 3995765..2749e74 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_plane.c
> @@ -135,19 +135,8 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,
> struct drm_framebuffer *fb = state->fb;
> struct drm_crtc_state *crtc_state;
> bool visible;
> - struct drm_rect dest = {
> - .x1 = state->crtc_x,
> - .y1 = state->crtc_y,
> - .x2 = state->crtc_x + state->crtc_w,
> - .y2 = state->crtc_y + state->crtc_h,
> - };
> - struct drm_rect src = {
> - /* 16.16 fixed point */
> - .x1 = state->src_x,
> - .y1 = state->src_y,
> - .x2 = state->src_x + state->src_w,
> - .y2 = state->src_y + state->src_h,
> - };
> + struct drm_rect dest = drm_plane_state_dest(state);
> + struct drm_rect src = drm_plane_state_src(state); /* 16.16 fixed point */
> struct drm_rect clip = { 0, };
>
> if (!fb)
> diff --git a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> index 6255e5b..31384ca 100644
> --- a/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> +++ b/drivers/gpu/drm/rockchip/rockchip_drm_vop.c
> @@ -610,14 +610,8 @@ static int vop_plane_atomic_check(struct drm_plane *plane,
> if (WARN_ON(!crtc_state))
> return -EINVAL;
>
> - src->x1 = state->src_x;
> - src->y1 = state->src_y;
> - src->x2 = state->src_x + state->src_w;
> - src->y2 = state->src_y + state->src_h;
> - dest->x1 = state->crtc_x;
> - dest->y1 = state->crtc_y;
> - dest->x2 = state->crtc_x + state->crtc_w;
> - dest->y2 = state->crtc_y + state->crtc_h;
> + *src = drm_plane_state_src(state);
> + *dest = drm_plane_state_dest(state);
>
> clip.x1 = 0;
> clip.y1 = 0;
> diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
> index b7d67cc..856fdf8 100644
> --- a/include/drm/drm_crtc.h
> +++ b/include/drm/drm_crtc.h
> @@ -36,6 +36,7 @@
> #include <uapi/drm/drm_mode.h>
> #include <uapi/drm/drm_fourcc.h>
> #include <drm/drm_modeset_lock.h>
> +#include <drm/drm_rect.h>
>
> struct drm_device;
> struct drm_mode_set;
> @@ -1395,6 +1396,29 @@ struct drm_plane_state {
> struct drm_atomic_state *state;
> };
>
> +static inline struct drm_rect
> +drm_plane_state_src(const struct drm_plane_state *state)
> +{
> + struct drm_rect src = {
> + .x1 = state->src_x,
> + .y1 = state->src_y,
> + .x2 = state->src_x + state->src_w,
> + .y2 = state->src_y + state->src_h,
> + };
> + return src;
> +}
> +
> +static inline struct drm_rect
> +drm_plane_state_dest(const struct drm_plane_state *state)
> +{
> + struct drm_rect dest = {
> + .x1 = state->crtc_x,
> + .y1 = state->crtc_y,
> + .x2 = state->crtc_x + state->crtc_w,
> + .y2 = state->crtc_y + state->crtc_h,
> + };
> + return dest;
> +}
>
> /**
> * struct drm_plane_funcs - driver plane control functions
> --
> 2.7.4
>
More information about the Freedreno
mailing list