All of lore.kernel.org
 help / color / mirror / Atom feed
From: Anitha Chrisanthus <anitha.chrisanthus@intel.com>
To: dri-devel@lists.freedesktop.org, anitha.chrisanthus@intel.com,
	edmund.j.dea@intel.com
Subject: [PATCH 07/14] drm/kmb: Disable change of plane parameters
Date: Tue, 27 Jul 2021 17:31:19 -0700	[thread overview]
Message-ID: <20210728003126.1425028-7-anitha.chrisanthus@intel.com> (raw)
In-Reply-To: <20210728003126.1425028-1-anitha.chrisanthus@intel.com>

From: Edmund Dea <edmund.j.dea@intel.com>

Due to HW limitations, KMB cannot change height, width, or
pixel format after initial plane configuration.

Fixes: 7f7b96a8a0a1 ("drm/kmb: Add support for KeemBay Display")
Signed-off-by: Edmund Dea <edmund.j.dea@intel.com>
---
 drivers/gpu/drm/kmb/kmb_crtc.c  |  2 ++
 drivers/gpu/drm/kmb/kmb_drv.h   |  1 +
 drivers/gpu/drm/kmb/kmb_plane.c | 44 ++++++++++++++++++++++++++++++++-
 drivers/gpu/drm/kmb/kmb_plane.h |  6 +++++
 4 files changed, 52 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/kmb/kmb_crtc.c b/drivers/gpu/drm/kmb/kmb_crtc.c
index 44626044c85e..42c8010ef2f6 100644
--- a/drivers/gpu/drm/kmb/kmb_crtc.c
+++ b/drivers/gpu/drm/kmb/kmb_crtc.c
@@ -226,6 +226,8 @@ int kmb_setup_crtc(struct drm_device *drm)
 	struct kmb_plane *primary;
 	int ret;
 
+	memset(kmb->init_disp_cfg, 0, sizeof(kmb->init_disp_cfg));
+
 	primary = kmb_plane_init(drm);
 	if (IS_ERR(primary))
 		return PTR_ERR(primary);
diff --git a/drivers/gpu/drm/kmb/kmb_drv.h b/drivers/gpu/drm/kmb/kmb_drv.h
index fefb1052058c..dc0679a70cc5 100644
--- a/drivers/gpu/drm/kmb/kmb_drv.h
+++ b/drivers/gpu/drm/kmb/kmb_drv.h
@@ -56,6 +56,7 @@ struct kmb_drm_private {
 	spinlock_t			irq_lock;
 	int				irq_lcd;
 	int				sys_clk_mhz;
+	struct disp_cfg			init_disp_cfg[KMB_MAX_PLANES];
 	struct layer_status		plane_status[KMB_MAX_PLANES];
 	int				kmb_under_flow;
 	int				kmb_flush_done;
diff --git a/drivers/gpu/drm/kmb/kmb_plane.c b/drivers/gpu/drm/kmb/kmb_plane.c
index e45419d6ed96..dacec5c4266f 100644
--- a/drivers/gpu/drm/kmb/kmb_plane.c
+++ b/drivers/gpu/drm/kmb/kmb_plane.c
@@ -71,12 +71,26 @@ static const u32 kmb_formats_v[] = {
 
 static unsigned int check_pixel_format(struct drm_plane *plane, u32 format)
 {
+	struct kmb_drm_private *kmb;
+	struct kmb_plane *kmb_plane = to_kmb_plane(plane);
 	int i;
+	int plane_id = kmb_plane->id;
+	struct disp_cfg init_disp_cfg;
 
+	kmb = to_kmb(plane->dev);
+	init_disp_cfg = kmb->init_disp_cfg[plane_id];
+	/* Due to HW limitations, changing pixel format after initial
+	 * plane configuration is not supported.
+	 */
+	if (init_disp_cfg.format && init_disp_cfg.format != format) {
+		drm_dbg(&kmb->drm, "Cannot change format after initial plane configuration");
+		return -EINVAL;
+	}
 	for (i = 0; i < plane->format_count; i++) {
 		if (plane->format_types[i] == format)
 			return 0;
 	}
+
 	return -EINVAL;
 }
 
@@ -85,11 +99,17 @@ static int kmb_plane_atomic_check(struct drm_plane *plane,
 {
 	struct drm_plane_state *new_plane_state = drm_atomic_get_new_plane_state(state,
 										 plane);
+	struct kmb_drm_private *kmb;
+	struct kmb_plane *kmb_plane = to_kmb_plane(plane);
+	int plane_id = kmb_plane->id;
+	struct disp_cfg init_disp_cfg;
 	struct drm_framebuffer *fb;
 	int ret;
 	struct drm_crtc_state *crtc_state;
 	bool can_position;
 
+	kmb = to_kmb(plane->dev);
+	init_disp_cfg = kmb->init_disp_cfg[plane_id];
 	fb = new_plane_state->fb;
 	if (!fb || !new_plane_state->crtc)
 		return 0;
@@ -102,6 +122,16 @@ static int kmb_plane_atomic_check(struct drm_plane *plane,
 		return -EINVAL;
 	if (new_plane_state->crtc_w < KMB_MIN_WIDTH || new_plane_state->crtc_h < KMB_MIN_HEIGHT)
 		return -EINVAL;
+
+	/* Due to HW limitations, changing plane height or width after
+	 * initial plane configuration is not supported.
+	 */
+	if ((init_disp_cfg.width && init_disp_cfg.height) &&
+	    (init_disp_cfg.width != fb->width ||
+	    init_disp_cfg.height != fb->height)) {
+		drm_dbg(&kmb->drm, "Cannot change plane height or width after initial configuration");
+		return -EINVAL;
+	}
 	can_position = (plane->type == DRM_PLANE_TYPE_OVERLAY);
 	crtc_state =
 		drm_atomic_get_existing_crtc_state(state,
@@ -300,6 +330,7 @@ static void kmb_plane_atomic_update(struct drm_plane *plane,
 	unsigned char plane_id;
 	int num_planes, i;
 	static dma_addr_t addr[MAX_SUB_PLANES];
+	struct disp_cfg *init_disp_cfg;
 	struct viv_vidmem_metadata *md = NULL;
 	struct drm_gem_object *gem_obj;
 
@@ -323,7 +354,8 @@ static void kmb_plane_atomic_update(struct drm_plane *plane,
 	}
 	spin_unlock_irq(&kmb->irq_lock);
 
-	src_w = (new_plane_state->src_w >> 16);
+	init_disp_cfg = &kmb->init_disp_cfg[plane_id];
+	src_w = new_plane_state->src_w >> 16;
 	src_h = new_plane_state->src_h >> 16;
 	crtc_x = new_plane_state->crtc_x;
 	crtc_y = new_plane_state->crtc_y;
@@ -478,6 +510,16 @@ static void kmb_plane_atomic_update(struct drm_plane *plane,
 
 	/* Enable DMA */
 	kmb_write_lcd(kmb, LCD_LAYERn_DMA_CFG(plane_id), dma_cfg);
+
+	/* Save initial display config */
+	if (!init_disp_cfg->width ||
+	    !init_disp_cfg->height ||
+	    !init_disp_cfg->format) {
+		init_disp_cfg->width = width;
+		init_disp_cfg->height = height;
+		init_disp_cfg->format = fb->format->format;
+	}
+
 	drm_dbg(&kmb->drm, "dma_cfg=0x%x LCD_DMA_CFG=0x%x\n", dma_cfg,
 		kmb_read_lcd(kmb, LCD_LAYERn_DMA_CFG(plane_id)));
 
diff --git a/drivers/gpu/drm/kmb/kmb_plane.h b/drivers/gpu/drm/kmb/kmb_plane.h
index 486490f7a3ec..99207b35365c 100644
--- a/drivers/gpu/drm/kmb/kmb_plane.h
+++ b/drivers/gpu/drm/kmb/kmb_plane.h
@@ -62,6 +62,12 @@ struct layer_status {
 	u32 ctrl;
 };
 
+struct disp_cfg {
+	unsigned int width;
+	unsigned int height;
+	unsigned int format;
+};
+
 struct kmb_plane *kmb_plane_init(struct drm_device *drm);
 void kmb_plane_destroy(struct drm_plane *plane);
 #endif /* __KMB_PLANE_H__ */
-- 
2.25.1


  parent reply	other threads:[~2021-07-28  0:32 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-28  0:31 [PATCH 01/14] drm/kmb: Enable LCD DMA for low TVDDCV Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 02/14] drm/kmb: Define driver date and major/minor version Anitha Chrisanthus
2021-07-28  7:06   ` Sam Ravnborg
2021-08-04 18:13   ` Thomas Zimmermann
2021-08-05 23:53     ` Chrisanthus, Anitha
2021-07-28  0:31 ` [PATCH 03/14] drm/kmb: Work around for higher system clock Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 04/14] drm/kmb : W/A for 256B cache alignment for video Anitha Chrisanthus
2021-07-28  7:16   ` Sam Ravnborg
2021-07-28 22:54     ` Chrisanthus, Anitha
2021-07-28  0:31 ` [PATCH 05/14] drm/kmb: Limit supported mode to 1080p Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 06/14] drm/kmb: Remove clearing DPHY regs Anitha Chrisanthus
2021-07-28  0:31 ` Anitha Chrisanthus [this message]
2021-07-28  0:31 ` [PATCH 08/14] drm/kmb: Corrected typo in handle_lcd_irq Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 09/14] drm/kmb : W/A for planar formats Anitha Chrisanthus
2021-07-28 22:48   ` Chrisanthus, Anitha
2021-07-28  0:31 ` [PATCH 10/14] drm/kmb: Enable ADV bridge after modeset Anitha Chrisanthus
2021-07-28  7:22   ` Sam Ravnborg
2021-07-28  0:31 ` [PATCH 11/14] drm/kmb: Prune display modes with CRTC vfp < 4 Anitha Chrisanthus
2021-07-28  0:31 ` [PATCH 12/14] drm/kmb: Fix possible oops in error handling Anitha Chrisanthus
2021-07-28  7:27   ` Sam Ravnborg
2021-07-28 23:23     ` Chrisanthus, Anitha
2021-07-28  7:46   ` Dan Carpenter
2021-07-28  0:31 ` [PATCH 13/14] drm/kmb: Enable alpha blended second plane Anitha Chrisanthus
2021-07-28  7:29   ` Sam Ravnborg
2021-08-02 20:44     ` Chrisanthus, Anitha
2021-08-03  5:10       ` Sam Ravnborg
2021-09-08 17:50         ` Thomas Zimmermann
2021-09-08 19:31           ` Sam Ravnborg
2021-09-09 17:46             ` Thomas Zimmermann
2021-07-28  0:31 ` [PATCH 14/14] drm/kmb: Enable support for fbcon (framebuffer console) Anitha Chrisanthus
2021-07-28  4:46   ` kernel test robot
2021-07-28  7:31   ` Sam Ravnborg
2021-07-28 23:03     ` Chrisanthus, Anitha
2021-07-31  5:27   ` kernel test robot
2021-07-28  7:04 ` [PATCH 01/14] drm/kmb: Enable LCD DMA for low TVDDCV Sam Ravnborg
2021-07-29 18:48   ` Chrisanthus, Anitha
2021-07-29 19:00     ` Sam Ravnborg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210728003126.1425028-7-anitha.chrisanthus@intel.com \
    --to=anitha.chrisanthus@intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=edmund.j.dea@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.