summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Syrjälä <ville.syrjala@linux.intel.com>2018-07-18 21:17:05 +0300
committerVille Syrjälä <ville.syrjala@linux.intel.com>2018-09-25 16:04:45 +0300
commit94540e34bddfb728ac5acad96453dee666136945 (patch)
tree63218f3c7d5b3791c827cd188be7b32652602fce
parent19b0c74d20d9b53d4c82be14af0909a3b6846010 (diff)
lib/igt_fb: Respect the users choice of stride
We prented to allow the caller to specify the stride explicitly for the fb. But we don't actually use that user specified stride when we calculate the require bo size. Fix that oversight. v2: Rebased due to uint64_t size Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com> Reviewed-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
-rw-r--r--lib/igt_fb.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index 1ba1aa7c..21866e7d 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -215,11 +215,12 @@ static unsigned planar_height(struct format_desc_struct *format, unsigned height
static void calc_fb_size_planar(int fd, int width, int height,
struct format_desc_struct *format,
- uint64_t tiling, uint64_t *size_ret,
- unsigned *stride_ret, unsigned *offsets)
+ uint64_t tiling, unsigned stride,
+ uint64_t *size_ret, unsigned *stride_ret,
+ unsigned *offsets)
{
int plane;
- unsigned stride = 0, tile_width, tile_height;
+ unsigned max_stride = 0, tile_width, tile_height;
*size_ret = 0;
@@ -229,10 +230,13 @@ static void calc_fb_size_planar(int fd, int width, int height,
igt_get_fb_tile_size(fd, tiling, format->plane_bpp[plane], &tile_width, &tile_height);
plane_stride = ALIGN(planar_stride(format, width, plane), tile_width);
- if (stride < plane_stride)
- stride = plane_stride;
+ if (max_stride < plane_stride)
+ max_stride = plane_stride;
}
+ if (!stride)
+ stride = max_stride;
+
for (plane = 0; plane < format->num_planes; plane++) {
if (offsets)
offsets[plane] = *size_ret;
@@ -251,9 +255,9 @@ static void calc_fb_size_planar(int fd, int width, int height,
static void calc_fb_size_packed(int fd, int width, int height,
struct format_desc_struct *format, uint64_t tiling,
- uint64_t *size_ret, unsigned *stride_ret)
+ unsigned stride, uint64_t *size_ret, unsigned *stride_ret)
{
- unsigned int tile_width, tile_height, stride;
+ unsigned int tile_width, tile_height;
uint64_t size;
int byte_width = width * (format->plane_bpp[0] / 8);
@@ -269,13 +273,17 @@ static void calc_fb_size_packed(int fd, int width, int height,
* tiled. But then that failure is expected.
*/
- stride = max(byte_width, 512);
- stride = roundup_power_of_two(stride);
+ if (!stride) {
+ stride = max(byte_width, 512);
+ stride = roundup_power_of_two(stride);
+ }
size = max((uint64_t) stride * height, 1024*1024);
size = roundup_power_of_two(size);
} else {
- stride = ALIGN(byte_width, tile_width);
+ if (!stride)
+ stride = ALIGN(byte_width, tile_width);
+
size = (uint64_t) stride * ALIGN(height, tile_height);
}
@@ -303,9 +311,9 @@ void igt_calc_fb_size(int fd, int width, int height, uint32_t drm_format, uint64
igt_assert(format);
if (format->num_planes > 1)
- calc_fb_size_planar(fd, width, height, format, tiling, size_ret, stride_ret, NULL);
+ calc_fb_size_planar(fd, width, height, format, tiling, 0, size_ret, stride_ret, NULL);
else
- calc_fb_size_packed(fd, width, height, format, tiling, size_ret, stride_ret);
+ calc_fb_size_packed(fd, width, height, format, tiling, 0, size_ret, stride_ret);
}
/**
@@ -381,10 +389,10 @@ static int create_bo_for_fb(int fd, int width, int height,
unsigned int calculated_stride;
if (format->num_planes > 1)
- calc_fb_size_planar(fd, width, height, format, tiling,
+ calc_fb_size_planar(fd, width, height, format, tiling, stride,
&calculated_size, &calculated_stride, offsets);
else
- calc_fb_size_packed(fd, width, height, format, tiling,
+ calc_fb_size_packed(fd, width, height, format, tiling, stride,
&calculated_size, &calculated_stride);
if (stride == 0)