]> git.karo-electronics.de Git - karo-tx-linux.git/blobdiff - drivers/gpu/drm/rcar-du/rcar_du_kms.c
Merge branch 'fixes' of git://git.linaro.org/people/rmk/linux-arm
[karo-tx-linux.git] / drivers / gpu / drm / rcar-du / rcar_du_kms.c
index 06cacf6532c05f39314b3afabf5b8a0b26e050fd..d30c2e29bee2f122d8cff43681449fbe9e8ae46b 100644 (file)
@@ -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);