aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/rcar-du/rcar_du_kms.c13
1 files changed, 11 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 a87edfac111f..76026104d000 100644
--- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c
+++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c
@@ -135,7 +135,9 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
135{ 135{
136 struct rcar_du_device *rcdu = dev->dev_private; 136 struct rcar_du_device *rcdu = dev->dev_private;
137 const struct rcar_du_format_info *format; 137 const struct rcar_du_format_info *format;
138 unsigned int max_pitch;
138 unsigned int align; 139 unsigned int align;
140 unsigned int bpp;
139 141
140 format = rcar_du_format_info(mode_cmd->pixel_format); 142 format = rcar_du_format_info(mode_cmd->pixel_format);
141 if (format == NULL) { 143 if (format == NULL) {
@@ -144,13 +146,20 @@ rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv,
144 return ERR_PTR(-EINVAL); 146 return ERR_PTR(-EINVAL);
145 } 147 }
146 148
149 /*
150 * The pitch and alignment constraints are expressed in pixels on the
151 * hardware side and in bytes in the DRM API.
152 */
153 bpp = format->planes == 2 ? 1 : format->bpp / 8;
154 max_pitch = 4096 * bpp;
155
147 if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B)) 156 if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B))
148 align = 128; 157 align = 128;
149 else 158 else
150 align = 16 * format->bpp / 8; 159 align = 16 * bpp;
151 160
152 if (mode_cmd->pitches[0] & (align - 1) || 161 if (mode_cmd->pitches[0] & (align - 1) ||
153 mode_cmd->pitches[0] >= 8192) { 162 mode_cmd->pitches[0] >= max_pitch) {
154 dev_dbg(dev->dev, "invalid pitch value %u\n", 163 dev_dbg(dev->dev, "invalid pitch value %u\n",
155 mode_cmd->pitches[0]); 164 mode_cmd->pitches[0]);
156 return ERR_PTR(-EINVAL); 165 return ERR_PTR(-EINVAL);