drm/mediatek: Refactor plane init/check and support rotation
Subsystems (3)
v2 cover drm/mediatek: Refactor plane init/check and support rotation
From: Sean Paul <[email protected]>
Hello,
This is a follow-on to [1], which supports the original Y-flip. I've added X-flip and 180 degree rotate. Additionally, the rotation property is only exposed for ovl planes, not rdma planes since rdma doesn't support it. In order to differentiate between the two types, I had to do some plumbing in order to surface the supported rotations of a component as well as allowing a component to implement plane checks.
I've tested this on a 4.19 kernel on mt8183. The set was then forward ported to mainline and build tested. The forward port was relatively collision free, but there were a few.
Sean
[1]- https://lists.freedesktop.org/archives/dri-devel/2019-November/242312.html
Sean Paul (7):
drm/mediatek: Refactor plane init
drm/mediatek: Add helper to get component for a plane drm/mediatek: Add plumbing for layer_check hook drm/mediatek: Plumb supported rotation values from components to plane
init
drm/mediatek: Support reflect-y plane rotation drm/mediatek: Support reflect-x plane rotation drm/mediatek: Support 180 degree rotation
drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 50 +++++++ drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 145 ++++++++++++++------ drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 2 + drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 22 +++ drivers/gpu/drm/mediatek/mtk_drm_plane.c | 18 ++- drivers/gpu/drm/mediatek/mtk_drm_plane.h | 4 +- 6 files changed, 199 insertions(+), 42 deletions(-)
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/7 drm/mediatek: Refactor plane init
From: Sean Paul <[email protected]>
Add a couple of functions which enumerate the number of planes for a component and initialize the planes for a component.
No functional changes in this patch, but it will allow us to selectively support rotation if the component supports it.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 77 +++++++++++++++++++------ 1 file changed, 59 insertions(+), 18 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +59 -18
@@ -543,14 +543,63 @@ void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *comp)mtk_drm_finish_page_flip (mtk_crtc); } +static int mtk_drm_crtc_num_comp_planes (struct mtk_drm_crtc *mtk_crtc, +int comp_idx) +{ +struct mtk_ddp_comp *comp; + +if (comp_idx >1 ) +return 0 ; + + comp = mtk_crtc->ddp_comp[comp_idx]; +if (!comp->funcs) +return 0 ; + +if (comp_idx ==1 && !comp->funcs->bgclr_in_on) +return 0 ; + +return mtk_ddp_comp_layer_nr (comp); +} + +static inline +enum drm_plane_type mtk_drm_crtc_plane_type (unsigned int plane_idx) +{ +if (plane_idx ==0 ) +return DRM_PLANE_TYPE_PRIMARY ; +else if (plane_idx ==1 ) +return DRM_PLANE_TYPE_CURSOR ; +else +return DRM_PLANE_TYPE_OVERLAY ; + +} + +static int mtk_drm_crtc_init_comp_planes (struct drm_device *drm_dev, +struct mtk_drm_crtc *mtk_crtc, +int comp_idx,int pipe) +{ +int num_planes =mtk_drm_crtc_num_comp_planes (mtk_crtc, comp_idx); +int i, ret; + +for (i =0 ; i < num_planes; i++) { + ret =mtk_plane_init (drm_dev, + &mtk_crtc->planes[mtk_crtc->layer_nr], +BIT (pipe), +mtk_drm_crtc_plane_type (mtk_crtc->layer_nr)); +if (ret) +return ret; + + mtk_crtc->layer_nr++; + } +return 0 ; +} +int mtk_drm_crtc_create (struct drm_device *drm_dev,const enum mtk_ddp_comp_id *path,unsigned int path_len) {struct mtk_drm_private *priv = drm_dev->dev_private;struct device *dev = drm_dev->dev;struct mtk_drm_crtc *mtk_crtc; -enum drm_plane_type type; -unsigned int zpos; +unsigned int num_comp_planes =0 ;int pipe = priv->num_pipes;int ret;int i;
@@ -606,23 +655,15 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev, mtk_crtc->ddp_comp[i] = comp; } - mtk_crtc->layer_nr =mtk_ddp_comp_layer_nr (mtk_crtc->ddp_comp[0 ]); -if (mtk_crtc->ddp_comp_nr >1 ) { -struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[1 ]; +for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) + num_comp_planes +=mtk_drm_crtc_num_comp_planes (mtk_crtc, i); + + mtk_crtc->planes =devm_kcalloc (dev, num_comp_planes, +sizeof (struct drm_plane ),GFP_KERNEL ); -if (comp->funcs->bgclr_in_on) - mtk_crtc->layer_nr +=mtk_ddp_comp_layer_nr (comp); - } - mtk_crtc->planes =devm_kcalloc (dev, mtk_crtc->layer_nr, -sizeof (struct drm_plane ), -GFP_KERNEL ); - -for (zpos =0 ; zpos < mtk_crtc->layer_nr; zpos++) { - type = (zpos ==0 ) ?DRM_PLANE_TYPE_PRIMARY : - (zpos ==1 ) ?DRM_PLANE_TYPE_CURSOR : -DRM_PLANE_TYPE_OVERLAY ; - ret =mtk_plane_init (drm_dev, &mtk_crtc->planes[zpos], -BIT (pipe), type); +for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) { + ret =mtk_drm_crtc_init_comp_planes (drm_dev, mtk_crtc, i, + pipe);if (ret)return ret; }
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 2/7 drm/mediatek: Add helper to get component for a plane
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Instead of hard-coding which components have planes, add a helper function to walk the components and map a plane index to a component layer.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 56 +++++++++++++++---------- 1 file changed, 34 insertions(+), 22 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +34 -22
@@ -207,6 +207,28 @@ static void mtk_crtc_ddp_clk_disable(struct mtk_drm_crtc *mtk_crtc)clk_disable_unprepare (mtk_crtc->ddp_comp[i]->clk); } +static +struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane (struct drm_crtc *crtc, +struct drm_plane *plane, +unsigned int *local_layer) +{ +struct mtk_drm_crtc *mtk_crtc =to_mtk_crtc (crtc); +struct mtk_ddp_comp *comp; +int i, count =0 ; + +for (i =0 ; i < mtk_crtc->ddp_comp_nr; i++) { + comp = mtk_crtc->ddp_comp[i]; +if (plane->index < (count +mtk_ddp_comp_layer_nr (comp))) { + *local_layer = plane->index - count; +return comp; + } + count +=mtk_ddp_comp_layer_nr (comp); + } + +WARN (1 ,"Failed to find component for plane %d\n" , plane->index); +return NULL ; +} +static int mtk_crtc_ddp_hw_init (struct mtk_drm_crtc *mtk_crtc) {struct drm_crtc *crtc = &mtk_crtc->base;
@@ -283,19 +305,12 @@ static int mtk_crtc_ddp_hw_init(struct mtk_drm_crtc *mtk_crtc)for (i =0 ; i < mtk_crtc->layer_nr; i++) {struct drm_plane *plane = &mtk_crtc->planes[i];struct mtk_plane_state *plane_state; -struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0 ]; -unsigned int comp_layer_nr =mtk_ddp_comp_layer_nr (comp); +struct mtk_ddp_comp *comp;unsigned int local_layer; plane_state =to_mtk_plane_state (plane->state); - -if (i >= comp_layer_nr) { - comp = mtk_crtc->ddp_comp[1 ]; - local_layer = i - comp_layer_nr; - }else - local_layer = i; -mtk_ddp_comp_layer_config (comp, local_layer, - plane_state); + comp =mtk_drm_ddp_comp_for_plane (crtc, plane, &local_layer); +mtk_ddp_comp_layer_config (comp, local_layer, plane_state); }return 0 ;
@@ -343,7 +358,6 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc)struct mtk_crtc_state *state =to_mtk_crtc_state (mtk_crtc->base.state);struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[0 ];unsigned int i; -unsigned int comp_layer_nr =mtk_ddp_comp_layer_nr (comp);unsigned int local_layer;/*
@@ -366,17 +380,15 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc) plane_state =to_mtk_plane_state (plane->state); -if (plane_state->pending.config) { -if (i >= comp_layer_nr) { - comp = mtk_crtc->ddp_comp[1 ]; - local_layer = i - comp_layer_nr; - }else - local_layer = i; - -mtk_ddp_comp_layer_config (comp, local_layer, - plane_state); - plane_state->pending.config = false; - } +if (!plane_state->pending.config) +continue ; + + comp =mtk_drm_ddp_comp_for_plane (crtc, plane, + &local_layer); + +mtk_ddp_comp_layer_config (comp, local_layer, + plane_state); + plane_state->pending.config = false; } mtk_crtc->pending_planes = false; }
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 3/7 drm/mediatek: Add plumbing for layer_check hook
In reply to Sean PaulFrom: Sean Paul <[email protected]>
This allows components to implement a .layer_check callback for their layers which is called during atomic_check.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 10 ++++++++++ drivers/gpu/drm/mediatek/mtk_drm_crtc.h | 2 ++ drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 12 ++++++++++++ drivers/gpu/drm/mediatek/mtk_drm_plane.c | 6 ++++++ 4 files changed, 30 insertions(+)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +10 -0
@@ -394,6 +394,16 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc) } } +int mtk_drm_crtc_plane_check (struct drm_crtc *crtc,struct drm_plane *plane, +struct mtk_plane_state *state) +{ +unsigned int local_layer; +struct mtk_ddp_comp *comp; + + comp =mtk_drm_ddp_comp_for_plane (crtc, plane, &local_layer); +return mtk_ddp_comp_layer_check (comp, local_layer, state); +} +static void mtk_drm_crtc_atomic_enable (struct drm_crtc *crtc,struct drm_crtc_state *old_state) {
drivers/gpu/drm/mediatek/mtk_drm_crtc.h +2 -0
@@ -19,5 +19,7 @@ void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct mtk_ddp_comp *comp);int mtk_drm_crtc_create (struct drm_device *drm_dev,const enum mtk_ddp_comp_id *path,unsigned int path_len); +int mtk_drm_crtc_plane_check (struct drm_crtc *crtc,struct drm_plane *plane, +struct mtk_plane_state *state);#endif /* MTK_DRM_CRTC_H */
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +12 -0
@@ -80,6 +80,9 @@ struct mtk_ddp_comp_funcs {unsigned int (*layer_nr)(struct mtk_ddp_comp *comp);void (*layer_on)(struct mtk_ddp_comp *comp,unsigned int idx);void (*layer_off)(struct mtk_ddp_comp *comp,unsigned int idx); +int (*layer_check)(struct mtk_ddp_comp *comp, +unsigned int idx, +struct mtk_plane_state *state);void (*layer_config)(struct mtk_ddp_comp *comp,unsigned int idx,struct mtk_plane_state *state); void (*gamma_set)(struct mtk_ddp_comp *comp,
@@ -152,6 +155,15 @@ static inline void mtk_ddp_comp_layer_off(struct mtk_ddp_comp *comp, comp->funcs->layer_off (comp, idx); } +static inline int mtk_ddp_comp_layer_check (struct mtk_ddp_comp *comp, +unsigned int idx, +struct mtk_plane_state *state) +{ +if (comp->funcs && comp->funcs->layer_check) +return comp->funcs->layer_check (comp, idx, state); +return 0 ; +} +static inline void mtk_ddp_comp_layer_config (struct mtk_ddp_comp *comp,unsigned int idx,struct mtk_plane_state *state)
drivers/gpu/drm/mediatek/mtk_drm_plane.c +6 -0
@@ -84,6 +84,7 @@ static int mtk_plane_atomic_check(struct drm_plane *plane, {struct drm_framebuffer *fb = state->fb;struct drm_crtc_state *crtc_state; +int ret;if (!fb)return 0 ;
@@ -91,6 +92,11 @@ static int mtk_plane_atomic_check(struct drm_plane *plane,if (!state->crtc)return 0 ; + ret =mtk_drm_crtc_plane_check (state->crtc, plane, +to_mtk_plane_state (state)); +if (ret) +return ret; + crtc_state =drm_atomic_get_crtc_state (state->state, state->crtc);if (IS_ERR (crtc_state))return PTR_ERR (crtc_state);
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 4/7 drm/mediatek: Plumb supported rotation values from components to plane init
In reply to Sean PaulFrom: Sean Paul <[email protected]>
This patch adds the ability for components to expose supported rotations which will be exposed to userspace via a plane rotation property.
No functional changes in this patch.
--- drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 4 +++- drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h | 10 ++++++++++ drivers/gpu/drm/mediatek/mtk_drm_plane.c | 12 +++++++++++- drivers/gpu/drm/mediatek/mtk_drm_plane.h | 4 +++- 4 files changed, 27 insertions(+), 3 deletions(-)
drivers/gpu/drm/mediatek/mtk_drm_crtc.c +3 -1
@@ -600,13 +600,15 @@ static int mtk_drm_crtc_init_comp_planes(struct drm_device *drm_dev, int comp_idx, int pipe) { int num_planes = mtk_drm_crtc_num_comp_planes(mtk_crtc, comp_idx); +struct mtk_ddp_comp *comp = mtk_crtc->ddp_comp[comp_idx];int i, ret;for (i =0 ; i < num_planes; i++) { ret =mtk_plane_init (drm_dev, &mtk_crtc->planes[mtk_crtc->layer_nr],BIT (pipe), -mtk_drm_crtc_plane_type (mtk_crtc->layer_nr)); +mtk_drm_crtc_plane_type (mtk_crtc->layer_nr), +mtk_ddp_comp_supported_rotations (comp));if (ret)return ret;
drivers/gpu/drm/mediatek/mtk_drm_ddp_comp.h +10 -0
@@ -77,6 +77,7 @@ struct mtk_ddp_comp_funcs {void (*stop)(struct mtk_ddp_comp *comp);void (*enable_vblank)(struct mtk_ddp_comp *comp,struct drm_crtc *crtc);void (*disable_vblank)(struct mtk_ddp_comp *comp); +unsigned int (*supported_rotations)(struct mtk_ddp_comp *comp);unsigned int (*layer_nr)(struct mtk_ddp_comp *comp);void (*layer_on)(struct mtk_ddp_comp *comp,unsigned int idx);void (*layer_off)(struct mtk_ddp_comp *comp,unsigned int idx);
@@ -133,6 +134,15 @@ static inline void mtk_ddp_comp_disable_vblank(struct mtk_ddp_comp *comp) comp->funcs->disable_vblank (comp); } +static inline +unsigned int mtk_ddp_comp_supported_rotations (struct mtk_ddp_comp *comp) +{ +if (comp->funcs && comp->funcs->supported_rotations) +return comp->funcs->supported_rotations (comp); + +return 0 ; +} +static inline unsigned int mtk_ddp_comp_layer_nr (struct mtk_ddp_comp *comp) {if (comp->funcs && comp->funcs->layer_nr)
drivers/gpu/drm/mediatek/mtk_drm_plane.c +11 -1
@@ -138,6 +138,7 @@ static void mtk_plane_atomic_update(struct drm_plane *plane, state->pending.y = plane->state->dst.y1; state->pending.width =drm_rect_width (&plane->state->dst); state->pending.height =drm_rect_height (&plane->state->dst); + state->pending.rotation = plane->state->rotation;wmb ();/* Make sure the above parameters are set before update */ state->pending.dirty = true; }
@@ -160,7 +161,8 @@ static const struct drm_plane_helper_funcs mtk_plane_helper_funcs = { };int mtk_plane_init (struct drm_device *dev,struct drm_plane *plane, -unsigned long possible_crtcs,enum drm_plane_type type) +unsigned long possible_crtcs,enum drm_plane_type type, +unsigned int supported_rotations) {int err;
@@ -172,6 +174,14 @@ int mtk_plane_init(struct drm_device *dev, struct drm_plane *plane,return err; } +if (supported_rotations & ~DRM_MODE_ROTATE_0 ) { + err =drm_plane_create_rotation_property (plane, +DRM_MODE_ROTATE_0 , + supported_rotations); +if (err) +DRM_INFO ("Create rotation property failed\n" ); + } +drm_plane_helper_add (plane, &mtk_plane_helper_funcs);return 0 ;
drivers/gpu/drm/mediatek/mtk_drm_plane.h +3 -1
@@ -20,6 +20,7 @@ struct mtk_plane_pending_state {unsigned int y;unsigned int width;unsigned int height; +unsigned int rotation;bool dirty; };
@@ -35,6 +36,7 @@ to_mtk_plane_state(struct drm_plane_state *state) }int mtk_plane_init (struct drm_device *dev,struct drm_plane *plane, -unsigned long possible_crtcs,enum drm_plane_type type); +unsigned long possible_crtcs,enum drm_plane_type type, +unsigned int supported_rotations);#endif
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 5/7 drm/mediatek: Support reflect-y plane rotation
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Expose the rotation property and handle REFLECT_Y rotations.
Changes in v2:
- Move the check logic into mtk_disp_ovl.c since it doesn't apply to rdma
Link to v1: https://lists.freedesktop.org/archives/dri-devel/2019-November/242312.html
--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 42 +++++++++++++++++++++++++ 1 file changed, 42 insertions(+)
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +42 -0
@@ -3,6 +3,8 @@* Copyright (c) 2015 MediaTek Inc. */ +#include <drm/drm_fourcc.h> +#include <linux/clk.h> #include <linux/component.h> #include <linux/module.h>
@@ -50,6 +52,7 @@ OVL_CON_CLRFMT_RGB : 0)#define OVL_CON_AEN BIT(8)#define OVL_CON_ALPHA 0xff +#define OVL_CON_VIRT_FLIP BIT(9)struct mtk_disp_ovl_data {unsigned int addr;
@@ -137,6 +140,38 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp)return ovl->data->layer_nr; } +static unsigned int mtk_ovl_supported_rotations (struct mtk_ddp_comp *comp) +{ +return DRM_MODE_ROTATE_0 |DRM_MODE_REFLECT_Y ; +} + +static int mtk_ovl_layer_check (struct mtk_ddp_comp *comp,unsigned int idx, +struct mtk_plane_state *mtk_state) +{ +struct drm_plane_state *state = &mtk_state->base; +unsigned int rotation =0 ; + + rotation =drm_rotation_simplify (state->rotation, +DRM_MODE_ROTATE_0 | +DRM_MODE_REFLECT_Y ); + rotation &= ~DRM_MODE_ROTATE_0 ; + +/* We can only do reflection, not rotation */ +if ((rotation &DRM_MODE_ROTATE_MASK ) !=0 ) +return -EINVAL ; + +/* +* TODO: Rotating/reflecting YUV buffers is not supported at this time. +* Only RGB[AX] variants are supported. +*/ +if (state->fb->format->is_yuv && rotation !=0 ) +return -EINVAL ; + + state->rotation = rotation; + +return 0 ; +} +static void mtk_ovl_layer_on (struct mtk_ddp_comp *comp,unsigned int idx) {unsigned int reg;
@@ -229,6 +264,11 @@ static void mtk_ovl_layer_config(struct mtk_ddp_comp *comp, unsigned int idx,if (idx !=0 ) con |=OVL_CON_AEN |OVL_CON_ALPHA ; +if (pending->rotation &DRM_MODE_REFLECT_Y ) { + con |=OVL_CON_VIRT_FLIP ; + addr += (pending->height -1 ) * pending->pitch; + } +writel_relaxed (con, comp->regs +DISP_REG_OVL_CON (idx));writel_relaxed (pitch, comp->regs +DISP_REG_OVL_PITCH (idx));writel_relaxed (src_size, comp->regs +DISP_REG_OVL_SRC_SIZE (idx));
@@ -263,9 +303,11 @@ static const struct mtk_ddp_comp_funcs mtk_disp_ovl_funcs = { .stop = mtk_ovl_stop, .enable_vblank = mtk_ovl_enable_vblank, .disable_vblank = mtk_ovl_disable_vblank, + .supported_rotations = mtk_ovl_supported_rotations, .layer_nr = mtk_ovl_layer_nr, .layer_on = mtk_ovl_layer_on, .layer_off = mtk_ovl_layer_off, + .layer_check = mtk_ovl_layer_check, .layer_config = mtk_ovl_layer_config, .bgclr_in_on = mtk_ovl_bgclr_in_on, .bgclr_in_off = mtk_ovl_bgclr_in_off,
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 6/7 drm/mediatek: Support reflect-x plane rotation
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Add support for REFLECT_X rotations.
--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-)
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +9 -1
@@ -53,6 +53,7 @@#define OVL_CON_AEN BIT(8)#define OVL_CON_ALPHA 0xff#define OVL_CON_VIRT_FLIP BIT(9) +#define OVL_CON_HORZ_FLIP BIT(10)struct mtk_disp_ovl_data {unsigned int addr;
@@ -142,7 +143,8 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp)static unsigned int mtk_ovl_supported_rotations (struct mtk_ddp_comp *comp) { -return DRM_MODE_ROTATE_0 |DRM_MODE_REFLECT_Y ; +return DRM_MODE_ROTATE_0 |DRM_MODE_REFLECT_Y | +DRM_MODE_REFLECT_X ; } static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx,
@@ -153,6 +155,7 @@ static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx, rotation =drm_rotation_simplify (state->rotation,DRM_MODE_ROTATE_0 | +DRM_MODE_REFLECT_X |DRM_MODE_REFLECT_Y ); rotation &= ~DRM_MODE_ROTATE_0 ;
@@ -269,6 +272,11 @@ static void mtk_ovl_layer_config(struct mtk_ddp_comp *comp, unsigned int idx, addr += (pending->height -1 ) * pending->pitch; } +if (pending->rotation &DRM_MODE_REFLECT_X ) { + con |=OVL_CON_HORZ_FLIP ; + addr += pending->pitch -1 ; + } +writel_relaxed (con, comp->regs +DISP_REG_OVL_CON (idx));writel_relaxed (pitch, comp->regs +DISP_REG_OVL_PITCH (idx));writel_relaxed (src_size, comp->regs +DISP_REG_OVL_SRC_SIZE (idx));
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 7/7 drm/mediatek: Support 180 degree rotation
In reply to Sean PaulFrom: Sean Paul <[email protected]>
Now that we support both reflections, we can expose 180 degree rotation and rely on the simplify routine to convert that into REFLECT_X | REFLECT_Y
--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2 -2
@@ -143,8 +143,8 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp)static unsigned int mtk_ovl_supported_rotations (struct mtk_ddp_comp *comp) { -return DRM_MODE_ROTATE_0 |DRM_MODE_REFLECT_Y | -DRM_MODE_REFLECT_X ; +return DRM_MODE_ROTATE_0 |DRM_MODE_ROTATE_180 | +DRM_MODE_REFLECT_X |DRM_MODE_REFLECT_Y ; } static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx,
Signature · 6 lines
Sean Paul, Software Engineer, Google / Chromium OS _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 7/7] drm/mediatek: Support 180 degree rotation
Hi, Sean:
Quoted 6 lines · Sean Paul
From: Sean Paul <[email protected]>
Now that we support both reflections, we can expose 180 degree rotation and rely on the simplify routine to convert that into
REFLECT_X|REFLECT_Y
Patch 1 ~ 6 of this series looks good to me.
For this one, I think the rotation check in mtk_ovl_layer_check() should be modified.
Regards,
CK
Quoted 10 lines
Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0
-0
drivers/gpu/drm/mediatek/mtk_disp_ovl.c static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp) · line 150
Quoted 10 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2
-2@@ -143,8 +143,8 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp)static unsigned int mtk_ovl_supported_rotations (struct mtk_ddp_comp *comp) { -return DRM_MODE_ROTATE_0 |DRM_MODE_REFLECT_Y | -DRM_MODE_REFLECT_X ; +return DRM_MODE_ROTATE_0 |DRM_MODE_ROTATE_180 | +DRM_MODE_REFLECT_X |DRM_MODE_REFLECT_Y ; } static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 7/7] drm/mediatek: Support 180 degree rotation
Quoted 6 lines · CK Hu
Hi, Sean:
Quoted 2 lines · Sean Paul
From: Sean Paul <[email protected]>
Quoted 9 lines
Quoted 4 lines
Now that we support both reflections, we can expose 180 degree rotation and rely on the simplify routine to convert that into
REFLECT_X|REFLECT_YPatch 1 ~ 6 of this series looks good to me.
For this one, I think the rotation check inmtk_ovl_layer_check()should be modified.
Thanks for the quick reviews, CK!
In what way would you like the check to be modified? I'm guessing you're asking that I add it to the bitmask passed to the simplify_rotation function?
If that's the case, we don't actually want to modify the simplify_rotation bitmask since that bitmask is supposed to be only the rotations that the hardware can achieve. So if you pass ROTATE_180 into simplify_rotation, it will return REFLECT_X | REFLECT_Y, which is what we want. Does that make sense, or am I missing something?
Thanks,
Sean
Quoted 22 lines
Regards,
CKQuoted 19 lines
Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2
-2@@ -143,8 +143,8 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp)static unsigned int mtk_ovl_supported_rotations (struct mtk_ddp_comp *comp) { -return DRM_MODE_ROTATE_0 |DRM_MODE_REFLECT_Y | -DRM_MODE_REFLECT_X ; +return DRM_MODE_ROTATE_0 |DRM_MODE_ROTATE_180 | +DRM_MODE_REFLECT_X |DRM_MODE_REFLECT_Y ; }
Quoted 3 lines
drivers/gpu/drm/mediatek/mtk_disp_ovl.c static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp) · line 150
Quoted 1 line
drivers/gpu/drm/mediatek/mtk_disp_ovl.c +0
-0static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 7/7] drm/mediatek: Support 180 degree rotation
Hi, Sean:
Quoted 23 lines · Sean Paul
Quoted 6 lines · CK Hu
Hi, Sean:
Quoted 2 lines · Sean Paul
From: Sean Paul <[email protected]>
Quoted 9 lines
Quoted 4 lines
Now that we support both reflections, we can expose 180 degree rotation and rely on the simplify routine to convert that into
REFLECT_X|REFLECT_YPatch 1 ~ 6 of this series looks good to me.
For this one, I think the rotation check inmtk_ovl_layer_check()should be modified.Thanks for the quick reviews, CK!
In what way would you like the check to be modified? I'm guessing you're asking that I add it to the bitmask passed to the
simplify_rotationfunction?
Quoted 5 lines
If that's the case, we don't actually want to modify the
simplify_rotationbitmask since that bitmask is supposed to be only the rotations that the hardware can achieve. So if you passROTATE_180intosimplify_rotation, it will returnREFLECT_X|REFLECT_Y, which is what we want. Does that make sense, or am I missing something?
drm_rotation_simplify() is really hard to understand. You're right, so apply this series to mediatek-drm-next-5.5-2 [1], thanks.
[1]
https://github.com/ckhu-mediatek/linux.git-tags/commits/mediatek-drm-next-5.5-2
Regards,
CK
Quoted 30 lines
Thanks,
Sean
Quoted 25 lines
Regards,
CKQuoted 20 lines
Signed-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/mediatek/mtk_disp_ovl.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/mediatek/mtk_disp_ovl.c +2
-2@@ -143,8 +143,8 @@ static unsigned int mtk_ovl_layer_nr(struct mtk_ddp_comp *comp)static unsigned int mtk_ovl_supported_rotations (struct mtk_ddp_comp *comp) { -return DRM_MODE_ROTATE_0 |DRM_MODE_REFLECT_Y | -DRM_MODE_REFLECT_X ; +return DRM_MODE_ROTATE_0 |DRM_MODE_ROTATE_180 | +DRM_MODE_REFLECT_X |DRM_MODE_REFLECT_Y ; } static int mtk_ovl_layer_check(struct mtk_ddp_comp *comp, unsigned int idx,
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel