[igt-dev] [HAX 4/5] lib/igt_fb: s/tiling/modifier/ where appropriate

Dhinakaran Pandiyan
2019-02-21T09:43:42Z

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Rename the igt_fb.tiling to igt_fb.modifier to better reflect
what information it carries. Now it's clear whether we're talking
about a modifier or a i915 tiling thing.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Reviewed-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
Signed-off-by: Dhinakaran Pandiyan <dhinakaran.pandiyan@intel.com>
---
lib/igt_fb.c | 102 ++++++++++++++++++++++++------------------------
lib/igt_fb.h | 22 +++++------
tests/kms_ccs.c | 2 +-
3 files changed, 63 insertions(+), 63 deletions(-)

diff --git a/lib/igt_fb.c b/lib/igt_fb.c
index e0288282..6072f70e 100644
--- a/lib/igt_fb.c
+++ b/lib/igt_fb.c
@@ -259,7 +259,7 @@ static const struct format_desc_struct *lookup_drm_format(uint32_t drm_format)
/**
* igt_get_fb_tile_size:
* @fd: the DRM file descriptor
- * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
+ * @modifier: tiling layout of the framebuffer (as framebuffer modifier)
* @fb_bpp: bits per pixel of the framebuffer
* @width_ret: width of the tile in bytes
* @height_ret: height of the tile in lines
@@ -267,10 +267,10 @@ static const struct format_desc_struct *lookup_drm_format(uint32_t drm_format)
* This function returns width and height of a tile based on the given tiling
* format.
*/
-void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
+void igt_get_fb_tile_size(int fd, uint64_t modifier, int fb_bpp,
unsigned *width_ret, unsigned *height_ret)
{
- switch (tiling) {
+ switch (modifier) {
case LOCAL_DRM_FORMAT_MOD_NONE:
if (is_i915_device(fd))
*width_ret = 64;
@@ -340,7 +340,7 @@ static unsigned fb_plane_width(const struct igt_fb *fb, int plane)
{
const struct format_desc_struct *format = lookup_drm_format(fb->drm_format);

- if (is_ccs_modifier(fb->tiling) && plane == 1)
+ if (is_ccs_modifier(fb->modifier) && plane == 1)
return DIV_ROUND_UP(fb->width, 1024) * 128;
if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
return DIV_ROUND_UP(fb->width, 2);
@@ -355,7 +355,7 @@ static unsigned fb_plane_bpp(const struct igt_fb *fb, int plane)
{
const struct format_desc_struct *format = lookup_drm_format(fb->drm_format);

- if (is_ccs_modifier(fb->tiling) && plane == 1)
+ if (is_ccs_modifier(fb->modifier) && plane == 1)
return 8;
else
return format->plane_bpp[plane];
@@ -365,7 +365,7 @@ static unsigned fb_plane_height(const struct igt_fb *fb, int plane)
{
const struct format_desc_struct *format = lookup_drm_format(fb->drm_format);

- if (is_ccs_modifier(fb->tiling) && plane == 1)
+ if (is_ccs_modifier(fb->modifier) && plane == 1)
return DIV_ROUND_UP(fb->height, 512) * 32;
if (fb->drm_format == DRM_FORMAT_NV12 && plane == 1)
return DIV_ROUND_UP(fb->height, 2);
@@ -380,7 +380,7 @@ static int fb_num_planes(const struct igt_fb *fb)
{
const struct format_desc_struct *format = lookup_drm_format(fb->drm_format);

- if (is_ccs_modifier(fb->tiling))
+ if (is_ccs_modifier(fb->modifier))
return 2;
else
return format->num_planes;
@@ -401,7 +401,7 @@ static void fb_init(struct igt_fb *fb,

fb->width = width;
fb->height = height;
- fb->tiling = modifier;
+ fb->modifier = modifier;
fb->drm_format = drm_format;
fb->fd = fd;
fb->num_planes = fb_num_planes(fb);
@@ -420,7 +420,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
uint32_t min_stride = fb->plane_width[plane] *
(fb->plane_bpp[plane] / 8);

- if (fb->tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
+ if (fb->modifier != LOCAL_DRM_FORMAT_MOD_NONE &&
intel_gen(intel_get_drm_devid(fb->fd)) <= 3) {
uint32_t stride;

@@ -439,7 +439,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)
} else {
unsigned int tile_width, tile_height;

- igt_get_fb_tile_size(fb->fd, fb->tiling, fb->plane_bpp[plane],
+ igt_get_fb_tile_size(fb->fd, fb->modifier, fb->plane_bpp[plane],
&tile_width, &tile_height);

return ALIGN(min_stride, tile_width);
@@ -448,7 +448,7 @@ static uint32_t calc_plane_stride(struct igt_fb *fb, int plane)

static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
{
- if (fb->tiling != LOCAL_DRM_FORMAT_MOD_NONE &&
+ if (fb->modifier != LOCAL_DRM_FORMAT_MOD_NONE &&
intel_gen(intel_get_drm_devid(fb->fd)) <= 3) {
uint64_t min_size = (uint64_t) fb->strides[plane] *
fb->plane_height[plane];
@@ -469,7 +469,7 @@ static uint64_t calc_plane_size(struct igt_fb *fb, int plane)
} else {
unsigned int tile_width, tile_height;

- igt_get_fb_tile_size(fb->fd, fb->tiling, fb->plane_bpp[plane],
+ igt_get_fb_tile_size(fb->fd, fb->modifier, fb->plane_bpp[plane],
&tile_width, &tile_height);

return (uint64_t) fb->strides[plane] *
@@ -501,19 +501,19 @@ static uint64_t calc_fb_size(struct igt_fb *fb)
* @width: width of the framebuffer in pixels
* @height: height of the framebuffer in pixels
* @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
+ * @modifier: tiling layout of the framebuffer (as framebuffer modifier)
* @size_ret: returned size for the framebuffer
* @stride_ret: returned stride for the framebuffer
*
* This function returns valid stride and size values for a framebuffer with the
* specified parameters.
*/
-void igt_calc_fb_size(int fd, int width, int height, uint32_t drm_format, uint64_t tiling,
+void igt_calc_fb_size(int fd, int width, int height, uint32_t drm_format, uint64_t modifier,
uint64_t *size_ret, unsigned *stride_ret)
{
struct igt_fb fb;

- fb_init(&fb, fd, width, height, drm_format, tiling,
+ fb_init(&fb, fd, width, height, drm_format, modifier,
IGT_COLOR_YCBCR_BT709, IGT_COLOR_YCBCR_LIMITED_RANGE);

fb.size = calc_fb_size(&fb);
@@ -637,7 +637,7 @@ static int create_bo_for_fb(struct igt_fb *fb)
int fd = fb->fd;

if (is_i915_device(fd) &&
- (fb->tiling || fb->size || fb->strides[0] || igt_format_is_yuv(fb->drm_format))) {
+ (fb->modifier || fb->size || fb->strides[0] || igt_format_is_yuv(fb->drm_format))) {
uint64_t size;

size = calc_fb_size(fb);
@@ -649,7 +649,7 @@ static int create_bo_for_fb(struct igt_fb *fb)
fb->is_dumb = false;
fb->gem_handle = gem_create(fd, fb->size);
gem_set_tiling(fd, fb->gem_handle,
- igt_fb_mod_to_tiling(fb->tiling),
+ igt_fb_mod_to_tiling(fb->modifier),
fb->strides[0]);

goto out;
@@ -1053,7 +1053,7 @@ void igt_paint_image(cairo_t *cr, const char *filename,
* @width: width of the framebuffer in pixel
* @height: height of the framebuffer in pixel
* @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer (as framebuffer modifier)
+ * @modifier: tiling layout of the framebuffer (as framebuffer modifier)
* @fb: pointer to an #igt_fb structure
* @bo_size: size of the backing bo (0 for automatic size)
* @bo_stride: stride of the backing bo (0 for automatic stride)
@@ -1070,7 +1070,7 @@ void igt_paint_image(cairo_t *cr, const char *filename,
*/
unsigned int
igt_create_fb_with_bo_size(int fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
struct igt_fb *fb, uint64_t bo_size,
unsigned bo_stride)
{
@@ -1079,7 +1079,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
enum igt_color_range color_range = IGT_COLOR_YCBCR_LIMITED_RANGE;
uint32_t flags = 0;

- fb_init(fb, fd, width, height, format, tiling,
+ fb_init(fb, fd, width, height, format, modifier,
color_encoding, color_range);

for (int i = 0; i < fb->num_planes; i++)
@@ -1087,8 +1087,8 @@ igt_create_fb_with_bo_size(int fd, int width, int height,

fb->size = bo_size;

- igt_debug("%s(width=%d, height=%d, format=0x%x, tiling=0x%"PRIx64", size=%"PRIu64")\n",
- __func__, width, height, format, tiling, bo_size);
+ igt_debug("%s(width=%d, height=%d, format=0x%x, modifier=0x%"PRIx64", size=%"PRIu64")\n",
+ __func__, width, height, format, modifier, bo_size);

create_bo_for_fb(fb);
igt_assert(fb->gem_handle > 0);
@@ -1096,12 +1096,12 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
igt_debug("%s(handle=%d, pitch=%d)\n",
__func__, fb->gem_handle, fb->strides[0]);

- if (fb->tiling || igt_has_fb_modifiers(fd))
+ if (fb->modifier || igt_has_fb_modifiers(fd))
flags = LOCAL_DRM_MODE_FB_MODIFIERS;

do_or_die(__kms_addfb(fb->fd, fb->gem_handle,
fb->width, fb->height,
- fb->drm_format, fb->tiling,
+ fb->drm_format, fb->modifier,
fb->strides, fb->offsets, fb->num_planes, flags,
&fb->fb_id));

@@ -1114,7 +1114,7 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
* @width: width of the framebuffer in pixel
* @height: height of the framebuffer in pixel
* @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer
+ * @modifier: tiling layout of the framebuffer
* @fb: pointer to an #igt_fb structure
*
* This function allocates a gem buffer object suitable to back a framebuffer
@@ -1128,9 +1128,9 @@ igt_create_fb_with_bo_size(int fd, int width, int height,
* The kms id of the created framebuffer.
*/
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
- uint64_t tiling, struct igt_fb *fb)
+ uint64_t modifier, struct igt_fb *fb)
{
- return igt_create_fb_with_bo_size(fd, width, height, format, tiling, fb,
+ return igt_create_fb_with_bo_size(fd, width, height, format, modifier, fb,
0, 0);
}

@@ -1140,7 +1140,7 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
* @width: width of the framebuffer in pixel
* @height: height of the framebuffer in pixel
* @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer
+ * @modifier: tiling layout of the framebuffer
* @r: red value to use as fill color
* @g: green value to use as fill color
* @b: blue value to use as fill color
@@ -1158,14 +1158,14 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
* failure.
*/
unsigned int igt_create_color_fb(int fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
double r, double g, double b,
struct igt_fb *fb /* out */)
{
unsigned int fb_id;
cairo_t *cr;

- fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
+ fb_id = igt_create_fb(fd, width, height, format, modifier, fb);
igt_assert(fb_id);

cr = igt_get_cairo_ctx(fd, fb);
@@ -1181,7 +1181,7 @@ unsigned int igt_create_color_fb(int fd, int width, int height,
* @width: width of the framebuffer in pixel
* @height: height of the framebuffer in pixel
* @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer
+ * @modifier: tiling layout of the framebuffer
* @fb: pointer to an #igt_fb structure
*
* This function allocates a gem buffer object suitable to back a framebuffer
@@ -1196,13 +1196,13 @@ unsigned int igt_create_color_fb(int fd, int width, int height,
* failure.
*/
unsigned int igt_create_pattern_fb(int fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
struct igt_fb *fb /* out */)
{
unsigned int fb_id;
cairo_t *cr;

- fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
+ fb_id = igt_create_fb(fd, width, height, format, modifier, fb);
igt_assert(fb_id);

cr = igt_get_cairo_ctx(fd, fb);
@@ -1218,7 +1218,7 @@ unsigned int igt_create_pattern_fb(int fd, int width, int height,
* @width: width of the framebuffer in pixel
* @height: height of the framebuffer in pixel
* @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer
+ * @modifier: tiling layout of the framebuffer
* @r: red value to use as fill color
* @g: green value to use as fill color
* @b: blue value to use as fill color
@@ -1237,14 +1237,14 @@ unsigned int igt_create_pattern_fb(int fd, int width, int height,
* failure.
*/
unsigned int igt_create_color_pattern_fb(int fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
double r, double g, double b,
struct igt_fb *fb /* out */)
{
unsigned int fb_id;
cairo_t *cr;

- fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
+ fb_id = igt_create_fb(fd, width, height, format, modifier, fb);
igt_assert(fb_id);

cr = igt_get_cairo_ctx(fd, fb);
@@ -1261,7 +1261,7 @@ unsigned int igt_create_color_pattern_fb(int fd, int width, int height,
* @width: width of the framebuffer in pixel or 0
* @height: height of the framebuffer in pixel or 0
* @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer
+ * @modifier: tiling layout of the framebuffer
* @filename: filename of the png image to draw
* @fb: pointer to an #igt_fb structure
*
@@ -1273,7 +1273,7 @@ unsigned int igt_create_color_pattern_fb(int fd, int width, int height,
* failure.
*/
unsigned int igt_create_image_fb(int fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
const char *filename,
struct igt_fb *fb /* out */)
{
@@ -1289,7 +1289,7 @@ unsigned int igt_create_image_fb(int fd, int width, int height,
height = cairo_image_surface_get_height(image);
cairo_surface_destroy(image);

- fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
+ fb_id = igt_create_fb(fd, width, height, format, modifier, fb);

cr = igt_get_cairo_ctx(fd, fb);
igt_paint_image(cr, filename, 0, 0, width, height);
@@ -1365,7 +1365,7 @@ static void stereo_fb_layout_from_mode(struct stereo_fb_layout *layout,
* @drm_fd: open i915 drm file descriptor
* @mode: A stereo 3D mode.
* @format: drm fourcc pixel format code
- * @tiling: tiling layout of the framebuffer
+ * @modifier: tiling layout of the framebuffer
*
* Create a framebuffer for use with the stereo 3D mode specified by @mode.
*
@@ -1374,7 +1374,7 @@ static void stereo_fb_layout_from_mode(struct stereo_fb_layout *layout,
* failure.
*/
unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode,
- uint32_t format, uint64_t tiling)
+ uint32_t format, uint64_t modifier)
{
struct stereo_fb_layout layout;
cairo_t *cr;
@@ -1383,7 +1383,7 @@ unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode,

stereo_fb_layout_from_mode(&layout, mode);
fb_id = igt_create_fb(drm_fd, layout.fb_width, layout.fb_height, format,
- tiling, &fb);
+ modifier, &fb);
cr = igt_get_cairo_ctx(drm_fd, &fb);

igt_paint_image(cr, "1080p-left.png",
@@ -1444,12 +1444,12 @@ static void init_buf(struct fb_blit_upload *blit,

buf->bo = gem_handle_to_libdrm_bo(blit->bufmgr, blit->fd,
name, fb->gem_handle);
- buf->tiling = igt_fb_mod_to_tiling(fb->tiling);
+ buf->tiling = igt_fb_mod_to_tiling(fb->modifier);
buf->stride = fb->strides[0];
buf->bpp = fb->plane_bpp[0];
buf->size = fb->size;

- if (is_ccs_modifier(fb->tiling)) {
+ if (is_ccs_modifier(fb->modifier)) {
igt_assert_eq(fb->strides[0] & 127, 0);
igt_assert_eq(fb->strides[1] & 127, 0);

@@ -1494,14 +1494,14 @@ static void blitcopy(const struct igt_fb *dst_fb,
src_fb->gem_handle,
src_fb->offsets[i],
src_fb->strides[i],
- igt_fb_mod_to_tiling(src_fb->tiling),
+ igt_fb_mod_to_tiling(src_fb->modifier),
0, 0, /* src_x, src_y */
dst_fb->plane_width[i], dst_fb->plane_height[i],
dst_fb->plane_bpp[i],
dst_fb->gem_handle,
dst_fb->offsets[i],
dst_fb->strides[i],
- igt_fb_mod_to_tiling(dst_fb->tiling),
+ igt_fb_mod_to_tiling(dst_fb->modifier),
0, 0 /* dst_x, dst_y */);
}
}
@@ -2442,8 +2442,8 @@ static void create_cairo_surface__convert(int fd, struct igt_fb *fb)
&blit->shadow_fb);
igt_assert(blit->shadow_ptr);

- if (fb->tiling == LOCAL_I915_FORMAT_MOD_Y_TILED ||
- fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED) {
+ if (fb->modifier == LOCAL_I915_FORMAT_MOD_Y_TILED ||
+ fb->modifier == LOCAL_I915_FORMAT_MOD_Yf_TILED) {
setup_linear_mapping(&blit->base);
} else {
blit->base.linear.fb = *fb;
@@ -2523,10 +2523,10 @@ cairo_surface_t *igt_get_cairo_surface(int fd, struct igt_fb *fb)
((f->cairo_id == CAIRO_FORMAT_INVALID) &&
(f->pixman_id != PIXMAN_invalid)))
create_cairo_surface__convert(fd, fb);
- else if (is_ccs_modifier(fb->tiling))
+ else if (is_ccs_modifier(fb->modifier))
create_cairo_surface__rendercopy(fd, fb);
- else if (fb->tiling == LOCAL_I915_FORMAT_MOD_Y_TILED ||
- fb->tiling == LOCAL_I915_FORMAT_MOD_Yf_TILED)
+ else if (fb->modifier == LOCAL_I915_FORMAT_MOD_Y_TILED ||
+ fb->modifier == LOCAL_I915_FORMAT_MOD_Yf_TILED)
create_cairo_surface__blit(fd, fb);
else
create_cairo_surface__gtt(fd, fb);
diff --git a/lib/igt_fb.h b/lib/igt_fb.h
index 8c683db5..a5a1a2ba 100644
--- a/lib/igt_fb.h
+++ b/lib/igt_fb.h
@@ -53,7 +53,7 @@
* @drm_format: DRM FOURCC code
* @width: width in pixels
* @height: height in pixels
- * @tiling: tiling mode as a DRM framebuffer modifier
+ * @modifier: tiling mode as a DRM framebuffer modifier
* @size: size in bytes of the underlying backing storage
* @cairo_surface: optionally attached cairo drawing surface
* @domain: current domain for cache flushing tracking on i915.ko
@@ -76,7 +76,7 @@ typedef struct igt_fb {
int height;
enum igt_color_encoding color_encoding;
enum igt_color_range color_range;
- uint64_t tiling;
+ uint64_t modifier;
uint64_t size;
cairo_surface_t *cairo_surface;
unsigned int domain;
@@ -108,34 +108,34 @@ enum igt_text_align {
align_hcenter = 0x08,
};

-void igt_get_fb_tile_size(int fd, uint64_t tiling, int fb_bpp,
+void igt_get_fb_tile_size(int fd, uint64_t modifier, int fb_bpp,
unsigned *width_ret, unsigned *height_ret);
-void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t tiling,
+void igt_calc_fb_size(int fd, int width, int height, uint32_t format, uint64_t modifier,
uint64_t *size_ret, unsigned *stride_ret);
unsigned int
igt_create_fb_with_bo_size(int fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
struct igt_fb *fb, uint64_t bo_size,
unsigned bo_stride);
unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
- uint64_t tiling, struct igt_fb *fb);
+ uint64_t modifier, struct igt_fb *fb);
unsigned int igt_create_color_fb(int fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
double r, double g, double b,
struct igt_fb *fb /* out */);
unsigned int igt_create_pattern_fb(int fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
struct igt_fb *fb /* out */);
unsigned int igt_create_color_pattern_fb(int fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
double r, double g, double b,
struct igt_fb *fb /* out */);
unsigned int igt_create_image_fb(int drm_fd, int width, int height,
- uint32_t format, uint64_t tiling,
+ uint32_t format, uint64_t modifier,
const char *filename,
struct igt_fb *fb /* out */);
unsigned int igt_create_stereo_fb(int drm_fd, drmModeModeInfo *mode,
- uint32_t format, uint64_t tiling);
+ uint32_t format, uint64_t modifier);
unsigned int igt_fb_convert(struct igt_fb *dst, struct igt_fb *src,
uint32_t dst_fourcc);
void igt_remove_fb(int fd, struct igt_fb *fb);
diff --git a/tests/kms_ccs.c b/tests/kms_ccs.c
index 1ed2b4a0..42596a45 100644
--- a/tests/kms_ccs.c
+++ b/tests/kms_ccs.c
@@ -388,7 +388,7 @@ static void generate_fb(data_t *data, struct igt_fb *fb,
fb->width = f.width;
fb->height = f.height;
fb->strides[0] = f.pitches[0];
- fb->tiling = f.modifier[0];
+ fb->modifier = f.modifier[0];
fb->size = size[0];
fb->cairo_surface = NULL;
fb->domain = 0;
--
2.17.1