All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] R-Car DU DRM fixes for v3.11
@ 2013-07-04 18:05 Laurent Pinchart
  2013-07-04 18:05 ` [PATCH 1/2] drm/rcar-du: Don't ignore rcar_du_crtc_create() return value Laurent Pinchart
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Laurent Pinchart @ 2013-07-04 18:05 UTC (permalink / raw)
  To: dri-devel

Hello,

Here are two small fixes to the R-Car DU DRM driver. They have previously been
posted as part of the larger "R-Car DU DRM support for R8A7790" series, and
Daniel Vetter rightfully noticed that they should be applied to v3.11.

Laurent Pinchart (2):
  drm/rcar-du: Don't ignore rcar_du_crtc_create() return value
  drm/rcar-du: Fix buffer pitch alignment

 drivers/gpu/drm/rcar-du/rcar_du_drv.c |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 26 +++++++++++++++++++++++---
 drivers/gpu/drm/rcar-du/rcar_du_kms.h |  3 +++
 3 files changed, 27 insertions(+), 4 deletions(-)

-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] drm/rcar-du: Don't ignore rcar_du_crtc_create() return value
  2013-07-04 18:05 [PATCH 0/2] R-Car DU DRM fixes for v3.11 Laurent Pinchart
@ 2013-07-04 18:05 ` Laurent Pinchart
  2013-07-04 18:05 ` [PATCH 2/2] drm/rcar-du: Fix buffer pitch alignment Laurent Pinchart
  2013-07-05 13:01 ` [PATCH 0/2] R-Car DU DRM fixes for v3.11 Laurent Pinchart
  2 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2013-07-04 18:05 UTC (permalink / raw)
  To: dri-devel

Handle error cases correctly.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 9c63f39..06cacf6 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -191,8 +191,11 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu)
 	if (ret < 0)
 		return ret;
 
-	for (i = 0; i < ARRAY_SIZE(rcdu->crtcs); ++i)
-		rcar_du_crtc_create(rcdu, i);
+	for (i = 0; i < ARRAY_SIZE(rcdu->crtcs); ++i) {
+		ret = rcar_du_crtc_create(rcdu, i);
+		if (ret < 0)
+			return ret;
+	}
 
 	rcdu->used_crtcs = 0;
 	rcdu->num_crtcs = i;
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH 2/2] drm/rcar-du: Fix buffer pitch alignment
  2013-07-04 18:05 [PATCH 0/2] R-Car DU DRM fixes for v3.11 Laurent Pinchart
  2013-07-04 18:05 ` [PATCH 1/2] drm/rcar-du: Don't ignore rcar_du_crtc_create() return value Laurent Pinchart
@ 2013-07-04 18:05 ` Laurent Pinchart
  2013-07-05 13:01 ` [PATCH 0/2] R-Car DU DRM fixes for v3.11 Laurent Pinchart
  2 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2013-07-04 18:05 UTC (permalink / raw)
  To: dri-devel

The DU requires a 16 pixels pitch alignement. Make sure dumb buffers are
allocated with the correct pitch, and validate the pitch when creating
frame buffers.

Signed-off-by: Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com>
---
 drivers/gpu/drm/rcar-du/rcar_du_drv.c |  2 +-
 drivers/gpu/drm/rcar-du/rcar_du_kms.c | 19 ++++++++++++++++++-
 drivers/gpu/drm/rcar-du/rcar_du_kms.h |  3 +++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/rcar-du/rcar_du_drv.c b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
index 003b34e..ff82877 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_drv.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_drv.c
@@ -251,7 +251,7 @@ static struct drm_driver rcar_du_driver = {
 	.prime_fd_to_handle	= drm_gem_prime_fd_to_handle,
 	.gem_prime_import	= drm_gem_cma_dmabuf_import,
 	.gem_prime_export	= drm_gem_cma_dmabuf_export,
-	.dumb_create		= drm_gem_cma_dumb_create,
+	.dumb_create		= rcar_du_dumb_create,
 	.dumb_map_offset	= drm_gem_cma_dumb_map_offset,
 	.dumb_destroy		= drm_gem_cma_dumb_destroy,
 	.fops			= &rcar_du_fops,
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
index 06cacf6..d30c2e2 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -138,11 +138,25 @@ void rcar_du_encoder_mode_commit(struct drm_encoder *encoder)
  * Frame buffer
  */
 
+int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev,
+			struct drm_mode_create_dumb *args)
+{
+	unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8);
+	unsigned int align;
+
+	/* The pitch must be aligned to a 16 pixels boundary. */
+	align = 16 * args->bpp / 8;
+	args->pitch = roundup(max(args->pitch, min_pitch), align);
+
+	return drm_gem_cma_dumb_create(file, dev, args);
+}
+
 static struct drm_framebuffer *
 rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 		  struct drm_mode_fb_cmd2 *mode_cmd)
 {
 	const struct rcar_du_format_info *format;
+	unsigned int align;
 
 	format = rcar_du_format_info(mode_cmd->pixel_format);
 	if (format == NULL) {
@@ -151,7 +165,10 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
 		return ERR_PTR(-EINVAL);
 	}
 
-	if (mode_cmd->pitches[0] & 15 || mode_cmd->pitches[0] >= 8192) {
+	align = 16 * format->bpp / 8;
+
+	if (mode_cmd->pitches[0] & (align - 1) ||
+	    mode_cmd->pitches[0] >= 8192) {
 		dev_dbg(dev->dev, "invalid pitch value %u\n",
 			mode_cmd->pitches[0]);
 		return ERR_PTR(-EINVAL);
diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.h b/drivers/gpu/drm/rcar-du/rcar_du_kms.h
index e4d8db0..dba4722 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.h
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.h
@@ -56,4 +56,7 @@ void rcar_du_encoder_mode_commit(struct drm_encoder *encoder);
 
 int rcar_du_modeset_init(struct rcar_du_device *rcdu);
 
+int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev,
+			struct drm_mode_create_dumb *args);
+
 #endif /* __RCAR_DU_KMS_H__ */
-- 
1.8.1.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH 0/2] R-Car DU DRM fixes for v3.11
  2013-07-04 18:05 [PATCH 0/2] R-Car DU DRM fixes for v3.11 Laurent Pinchart
  2013-07-04 18:05 ` [PATCH 1/2] drm/rcar-du: Don't ignore rcar_du_crtc_create() return value Laurent Pinchart
  2013-07-04 18:05 ` [PATCH 2/2] drm/rcar-du: Fix buffer pitch alignment Laurent Pinchart
@ 2013-07-05 13:01 ` Laurent Pinchart
  2 siblings, 0 replies; 4+ messages in thread
From: Laurent Pinchart @ 2013-07-05 13:01 UTC (permalink / raw)
  To: dri-devel; +Cc: Laurent Pinchart

Hi Dave,

On Thursday 04 July 2013 20:05:49 Laurent Pinchart wrote:
> Hello,
> 
> Here are two small fixes to the R-Car DU DRM driver. They have previously
> been posted as part of the larger "R-Car DU DRM support for R8A7790"
> series, and Daniel Vetter rightfully noticed that they should be applied to
> v3.11.

Given that your pull request for v3.11 hasn't been sent yet due to a 
dependency on fbdev, could you consider taking these two fixes in for v3.11 ?

> Laurent Pinchart (2):
>   drm/rcar-du: Don't ignore rcar_du_crtc_create() return value
>   drm/rcar-du: Fix buffer pitch alignment
> 
>  drivers/gpu/drm/rcar-du/rcar_du_drv.c |  2 +-
>  drivers/gpu/drm/rcar-du/rcar_du_kms.c | 26 +++++++++++++++++++++++---
>  drivers/gpu/drm/rcar-du/rcar_du_kms.h |  3 +++
>  3 files changed, 27 insertions(+), 4 deletions(-)
-- 
Regards,

Laurent Pinchart

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-07-05 13:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-07-04 18:05 [PATCH 0/2] R-Car DU DRM fixes for v3.11 Laurent Pinchart
2013-07-04 18:05 ` [PATCH 1/2] drm/rcar-du: Don't ignore rcar_du_crtc_create() return value Laurent Pinchart
2013-07-04 18:05 ` [PATCH 2/2] drm/rcar-du: Fix buffer pitch alignment Laurent Pinchart
2013-07-05 13:01 ` [PATCH 0/2] R-Car DU DRM fixes for v3.11 Laurent Pinchart

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.