aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c14
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c3
2 files changed, 9 insertions, 8 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
index 9fb8aa4d6bae..8d01aa24d68a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_fb.c
@@ -90,12 +90,12 @@ static struct fb_ops amdgpufb_ops = {
90}; 90};
91 91
92 92
93int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int bpp, bool tiled) 93int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int cpp, bool tiled)
94{ 94{
95 int aligned = width; 95 int aligned = width;
96 int pitch_mask = 0; 96 int pitch_mask = 0;
97 97
98 switch (bpp / 8) { 98 switch (cpp) {
99 case 1: 99 case 1:
100 pitch_mask = 255; 100 pitch_mask = 255;
101 break; 101 break;
@@ -110,7 +110,7 @@ int amdgpu_align_pitch(struct amdgpu_device *adev, int width, int bpp, bool tile
110 110
111 aligned += pitch_mask; 111 aligned += pitch_mask;
112 aligned &= ~pitch_mask; 112 aligned &= ~pitch_mask;
113 return aligned; 113 return aligned * cpp;
114} 114}
115 115
116static void amdgpufb_destroy_pinned_object(struct drm_gem_object *gobj) 116static void amdgpufb_destroy_pinned_object(struct drm_gem_object *gobj)
@@ -139,13 +139,13 @@ static int amdgpufb_create_pinned_object(struct amdgpu_fbdev *rfbdev,
139 int ret; 139 int ret;
140 int aligned_size, size; 140 int aligned_size, size;
141 int height = mode_cmd->height; 141 int height = mode_cmd->height;
142 u32 bpp, depth; 142 u32 cpp;
143 143
144 drm_fb_get_bpp_depth(mode_cmd->pixel_format, &depth, &bpp); 144 cpp = drm_format_plane_cpp(mode_cmd->pixel_format, 0);
145 145
146 /* need to align pitch with crtc limits */ 146 /* need to align pitch with crtc limits */
147 mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, bpp, 147 mode_cmd->pitches[0] = amdgpu_align_pitch(adev, mode_cmd->width, cpp,
148 fb_tiled) * ((bpp + 1) / 8); 148 fb_tiled);
149 149
150 height = ALIGN(mode_cmd->height, 8); 150 height = ALIGN(mode_cmd->height, 8);
151 size = mode_cmd->pitches[0] * height; 151 size = mode_cmd->pitches[0] * height;
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
index e0171c75b60c..3ad0bf6ce3e4 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c
@@ -702,7 +702,8 @@ int amdgpu_mode_dumb_create(struct drm_file *file_priv,
702 uint32_t handle; 702 uint32_t handle;
703 int r; 703 int r;
704 704
705 args->pitch = amdgpu_align_pitch(adev, args->width, args->bpp, 0) * ((args->bpp + 1) / 8); 705 args->pitch = amdgpu_align_pitch(adev, args->width,
706 DIV_ROUND_UP(args->bpp, 8), 0);
706 args->size = (u64)args->pitch * args->height; 707 args->size = (u64)args->pitch * args->height;
707 args->size = ALIGN(args->size, PAGE_SIZE); 708 args->size = ALIGN(args->size, PAGE_SIZE);
708 709