diff options
author | Laurent Pinchart <laurent.pinchart+renesas@ideasonboard.com> | 2013-07-04 14:05:51 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2013-07-05 01:35:13 -0400 |
commit | 59e32642d2e8fb170a1e777906dcb13359ea230f (patch) | |
tree | 9867f1bcc22b862e1aa23da61154619ef075e41a | |
parent | 3463ff67bc8d049098559adb850299c26b52350d (diff) |
drm/rcar-du: Fix buffer pitch alignment
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>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/rcar-du/rcar_du_drv.c | 2 | ||||
-rw-r--r-- | drivers/gpu/drm/rcar-du/rcar_du_kms.c | 19 | ||||
-rw-r--r-- | 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 003b34ee38e3..ff82877de876 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 = { | |||
251 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, | 251 | .prime_fd_to_handle = drm_gem_prime_fd_to_handle, |
252 | .gem_prime_import = drm_gem_cma_dmabuf_import, | 252 | .gem_prime_import = drm_gem_cma_dmabuf_import, |
253 | .gem_prime_export = drm_gem_cma_dmabuf_export, | 253 | .gem_prime_export = drm_gem_cma_dmabuf_export, |
254 | .dumb_create = drm_gem_cma_dumb_create, | 254 | .dumb_create = rcar_du_dumb_create, |
255 | .dumb_map_offset = drm_gem_cma_dumb_map_offset, | 255 | .dumb_map_offset = drm_gem_cma_dumb_map_offset, |
256 | .dumb_destroy = drm_gem_cma_dumb_destroy, | 256 | .dumb_destroy = drm_gem_cma_dumb_destroy, |
257 | .fops = &rcar_du_fops, | 257 | .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 06cacf6532c0..d30c2e29bee2 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) | |||
138 | * Frame buffer | 138 | * Frame buffer |
139 | */ | 139 | */ |
140 | 140 | ||
141 | int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, | ||
142 | struct drm_mode_create_dumb *args) | ||
143 | { | ||
144 | unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8); | ||
145 | unsigned int align; | ||
146 | |||
147 | /* The pitch must be aligned to a 16 pixels boundary. */ | ||
148 | align = 16 * args->bpp / 8; | ||
149 | args->pitch = roundup(max(args->pitch, min_pitch), align); | ||
150 | |||
151 | return drm_gem_cma_dumb_create(file, dev, args); | ||
152 | } | ||
153 | |||
141 | static struct drm_framebuffer * | 154 | static struct drm_framebuffer * |
142 | rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, | 155 | rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, |
143 | struct drm_mode_fb_cmd2 *mode_cmd) | 156 | struct drm_mode_fb_cmd2 *mode_cmd) |
144 | { | 157 | { |
145 | const struct rcar_du_format_info *format; | 158 | const struct rcar_du_format_info *format; |
159 | unsigned int align; | ||
146 | 160 | ||
147 | format = rcar_du_format_info(mode_cmd->pixel_format); | 161 | format = rcar_du_format_info(mode_cmd->pixel_format); |
148 | if (format == NULL) { | 162 | if (format == NULL) { |
@@ -151,7 +165,10 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, | |||
151 | return ERR_PTR(-EINVAL); | 165 | return ERR_PTR(-EINVAL); |
152 | } | 166 | } |
153 | 167 | ||
154 | if (mode_cmd->pitches[0] & 15 || mode_cmd->pitches[0] >= 8192) { | 168 | align = 16 * format->bpp / 8; |
169 | |||
170 | if (mode_cmd->pitches[0] & (align - 1) || | ||
171 | mode_cmd->pitches[0] >= 8192) { | ||
155 | dev_dbg(dev->dev, "invalid pitch value %u\n", | 172 | dev_dbg(dev->dev, "invalid pitch value %u\n", |
156 | mode_cmd->pitches[0]); | 173 | mode_cmd->pitches[0]); |
157 | return ERR_PTR(-EINVAL); | 174 | 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 e4d8db069a06..dba472263486 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); | |||
56 | 56 | ||
57 | int rcar_du_modeset_init(struct rcar_du_device *rcdu); | 57 | int rcar_du_modeset_init(struct rcar_du_device *rcdu); |
58 | 58 | ||
59 | int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, | ||
60 | struct drm_mode_create_dumb *args); | ||
61 | |||
59 | #endif /* __RCAR_DU_KMS_H__ */ | 62 | #endif /* __RCAR_DU_KMS_H__ */ |