mirror of
				https://github.com/tiagovignatti/intel-gpu-tools.git
				synced 2025-11-04 03:58:27 +00:00 
			
		
		
		
	lib: Extract some common fb create+fill methods into helpers
Several tests do one or more of the following: * igt_create_fb() + igt_paint_test_pattern() * igt_create_color_fb() + igt_paint_test_pattern() * igt_create_fb() + igt_paint_image() Extract them into new helpers: igt_create_pattern_fb(), igt_create_color_pattern_fb(), igt_create_image_fb(). v2: Fix typos, and improve API docs (Thomas) Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
This commit is contained in:
		
							parent
							
								
									7cb3510964
								
							
						
					
					
						commit
						5b113d323d
					
				
							
								
								
									
										128
									
								
								lib/igt_fb.c
									
									
									
									
									
								
							
							
						
						
									
										128
									
								
								lib/igt_fb.c
									
									
									
									
									
								
							@ -503,7 +503,7 @@ unsigned int igt_create_fb(int fd, int width, int height, uint32_t format,
 | 
			
		||||
 * @format: drm fourcc pixel format code
 | 
			
		||||
 * @tiling: tiling layout of the framebuffer
 | 
			
		||||
 * @r: red value to use as fill color
 | 
			
		||||
 * @g: gree value to use as fill color
 | 
			
		||||
 * @g: green value to use as fill color
 | 
			
		||||
 * @b: blue value to use as fill color
 | 
			
		||||
 * @fb: pointer to an #igt_fb structure
 | 
			
		||||
 *
 | 
			
		||||
@ -537,6 +537,132 @@ unsigned int igt_create_color_fb(int fd, int width, int height,
 | 
			
		||||
	return fb_id;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * igt_create_pattern_fb:
 | 
			
		||||
 * @fd: open i915 drm file descriptor
 | 
			
		||||
 * @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
 | 
			
		||||
 * @fb: pointer to an #igt_fb structure
 | 
			
		||||
 *
 | 
			
		||||
 * This function allocates a gem buffer object suitable to back a framebuffer
 | 
			
		||||
 * with the requested properties and then wraps it up in a drm framebuffer
 | 
			
		||||
 * object. All metadata is stored in @fb.
 | 
			
		||||
 *
 | 
			
		||||
 * Compared to igt_create_fb() this function also draws the standard test pattern
 | 
			
		||||
 * into the framebuffer.
 | 
			
		||||
 *
 | 
			
		||||
 * Returns:
 | 
			
		||||
 * The kms id of the created framebuffer on success or a negative error code on
 | 
			
		||||
 * failure.
 | 
			
		||||
 */
 | 
			
		||||
unsigned int igt_create_pattern_fb(int fd, int width, int height,
 | 
			
		||||
				   uint32_t format, uint64_t tiling,
 | 
			
		||||
				   struct igt_fb *fb /* out */)
 | 
			
		||||
{
 | 
			
		||||
	unsigned int fb_id;
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
 | 
			
		||||
	igt_assert(fb_id);
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(fd, fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, width, height);
 | 
			
		||||
	igt_assert(cairo_status(cr) == 0);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
 | 
			
		||||
	return fb_id;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * igt_create_color_pattern_fb:
 | 
			
		||||
 * @fd: open i915 drm file descriptor
 | 
			
		||||
 * @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
 | 
			
		||||
 * @r: red value to use as fill color
 | 
			
		||||
 * @g: green value to use as fill color
 | 
			
		||||
 * @b: blue value to use as fill color
 | 
			
		||||
 * @fb: pointer to an #igt_fb structure
 | 
			
		||||
 *
 | 
			
		||||
 * This function allocates a gem buffer object suitable to back a framebuffer
 | 
			
		||||
 * with the requested properties and then wraps it up in a drm framebuffer
 | 
			
		||||
 * object. All metadata is stored in @fb.
 | 
			
		||||
 *
 | 
			
		||||
 * Compared to igt_create_fb() this function also fills the entire framebuffer
 | 
			
		||||
 * with the given color, and then draws the standard test pattern into the
 | 
			
		||||
 * framebuffer.
 | 
			
		||||
 *
 | 
			
		||||
 * Returns:
 | 
			
		||||
 * The kms id of the created framebuffer on success or a negative error code on
 | 
			
		||||
 * failure.
 | 
			
		||||
 */
 | 
			
		||||
unsigned int igt_create_color_pattern_fb(int fd, int width, int height,
 | 
			
		||||
					 uint32_t format, uint64_t tiling,
 | 
			
		||||
					 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);
 | 
			
		||||
	igt_assert(fb_id);
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(fd, fb);
 | 
			
		||||
	igt_paint_color(cr, 0, 0, width, height, r, g, b);
 | 
			
		||||
	igt_paint_test_pattern(cr, width, height);
 | 
			
		||||
	igt_assert(cairo_status(cr) == 0);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
 | 
			
		||||
	return fb_id;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * igt_create_image_fb:
 | 
			
		||||
 * @drm_fd: open i915 drm file descriptor
 | 
			
		||||
 * @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
 | 
			
		||||
 * @filename: filename of the png image to draw
 | 
			
		||||
 * @fb: pointer to an #igt_fb structure
 | 
			
		||||
 *
 | 
			
		||||
 * Create a framebuffer with the specified image. If @width is zero the
 | 
			
		||||
 * image width will be used. If @height is zero the image height will be used.
 | 
			
		||||
 *
 | 
			
		||||
 * Returns:
 | 
			
		||||
 * The kms id of the created framebuffer on success or a negative error code on
 | 
			
		||||
 * failure.
 | 
			
		||||
 */
 | 
			
		||||
unsigned int igt_create_image_fb(int fd, int width, int height,
 | 
			
		||||
				 uint32_t format, uint64_t tiling,
 | 
			
		||||
				 const char *filename,
 | 
			
		||||
				 struct igt_fb *fb /* out */)
 | 
			
		||||
{
 | 
			
		||||
	cairo_surface_t *image;
 | 
			
		||||
	uint32_t fb_id;
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	image = cairo_image_surface_create_from_png(filename);
 | 
			
		||||
	igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
 | 
			
		||||
	if (width == 0)
 | 
			
		||||
		width = cairo_image_surface_get_width(image);
 | 
			
		||||
	if (height == 0)
 | 
			
		||||
		height = cairo_image_surface_get_height(image);
 | 
			
		||||
	cairo_surface_destroy(image);
 | 
			
		||||
 | 
			
		||||
	fb_id = igt_create_fb(fd, width, height, format, tiling, fb);
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(fd, fb);
 | 
			
		||||
	igt_paint_image(cr, filename, 0, 0, width, height);
 | 
			
		||||
	igt_assert(cairo_status(cr) == 0);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
 | 
			
		||||
	return fb_id;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
struct box {
 | 
			
		||||
	int x, y, width, height;
 | 
			
		||||
};
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										11
									
								
								lib/igt_fb.h
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								lib/igt_fb.h
									
									
									
									
									
								
							@ -80,6 +80,17 @@ unsigned int igt_create_color_fb(int fd, int width, int height,
 | 
			
		||||
				 uint32_t format, uint64_t tiling,
 | 
			
		||||
				 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,
 | 
			
		||||
				   struct igt_fb *fb /* out */);
 | 
			
		||||
unsigned int igt_create_color_pattern_fb(int fd, int width, int height,
 | 
			
		||||
					 uint32_t format, uint64_t tiling,
 | 
			
		||||
					 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,
 | 
			
		||||
				 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);
 | 
			
		||||
void igt_remove_fb(int fd, struct igt_fb *fb);
 | 
			
		||||
 | 
			
		||||
@ -867,7 +867,6 @@ static void plane_overlay(struct kms_atomic_crtc_state *crtc,
 | 
			
		||||
	uint32_t format = plane_get_igt_format(&plane);
 | 
			
		||||
	drmModeAtomicReq *req = drmModeAtomicAlloc();
 | 
			
		||||
	struct igt_fb fb;
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	igt_require(req);
 | 
			
		||||
	igt_require(format != 0);
 | 
			
		||||
@ -881,13 +880,10 @@ static void plane_overlay(struct kms_atomic_crtc_state *crtc,
 | 
			
		||||
	plane.crtc_w = mode->hdisplay / 2;
 | 
			
		||||
	plane.crtc_h = mode->vdisplay / 2;
 | 
			
		||||
	plane.crtc_id = crtc->obj;
 | 
			
		||||
	plane.fb_id = igt_create_fb(plane.state->desc->fd,
 | 
			
		||||
	plane.fb_id = igt_create_pattern_fb(plane.state->desc->fd,
 | 
			
		||||
					    plane.crtc_w, plane.crtc_h,
 | 
			
		||||
					    format, I915_TILING_NONE, &fb);
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(plane.state->desc->fd, &fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, plane.crtc_w, plane.crtc_h);
 | 
			
		||||
 | 
			
		||||
	/* Enable the overlay plane using the atomic API, and double-check
 | 
			
		||||
	 * state is what we think it should be. */
 | 
			
		||||
	plane_commit_atomic(&plane, req, ATOMIC_RELAX_NONE);
 | 
			
		||||
@ -916,7 +912,6 @@ static void plane_primary(struct kms_atomic_crtc_state *crtc,
 | 
			
		||||
	uint32_t *connectors;
 | 
			
		||||
	int num_connectors;
 | 
			
		||||
	struct igt_fb fb;
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	connectors = calloc(crtc->state->num_connectors, sizeof(*connectors));
 | 
			
		||||
@ -939,13 +934,10 @@ static void plane_primary(struct kms_atomic_crtc_state *crtc,
 | 
			
		||||
	plane.crtc_w = mode->hdisplay;
 | 
			
		||||
	plane.crtc_h = mode->vdisplay;
 | 
			
		||||
	plane.crtc_id = crtc->obj;
 | 
			
		||||
	plane.fb_id = igt_create_fb(plane.state->desc->fd,
 | 
			
		||||
	plane.fb_id = igt_create_pattern_fb(plane.state->desc->fd,
 | 
			
		||||
					    plane.crtc_w, plane.crtc_h,
 | 
			
		||||
					    format, I915_TILING_NONE, &fb);
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(plane.state->desc->fd, &fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, plane.crtc_w, plane.crtc_h);
 | 
			
		||||
 | 
			
		||||
	/* Flip the primary plane using the atomic API, and double-check
 | 
			
		||||
	 * state is what we think it should be. */
 | 
			
		||||
	crtc_commit_atomic(crtc, &plane, req, ATOMIC_RELAX_NONE);
 | 
			
		||||
@ -1044,7 +1036,6 @@ static void plane_invalid_params(struct kms_atomic_crtc_state *crtc,
 | 
			
		||||
	uint32_t format = plane_get_igt_format(&plane);
 | 
			
		||||
	drmModeAtomicReq *req = drmModeAtomicAlloc();
 | 
			
		||||
	struct igt_fb fb;
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	/* Pass a series of invalid object IDs for the FB ID. */
 | 
			
		||||
	plane.fb_id = plane.obj;
 | 
			
		||||
@ -1098,13 +1089,10 @@ static void plane_invalid_params(struct kms_atomic_crtc_state *crtc,
 | 
			
		||||
	plane.crtc_w = mode->hdisplay;
 | 
			
		||||
	plane.crtc_h = mode->vdisplay;
 | 
			
		||||
	plane.crtc_id = crtc->obj;
 | 
			
		||||
	plane.fb_id = igt_create_fb(plane.state->desc->fd,
 | 
			
		||||
	plane.fb_id = igt_create_pattern_fb(plane.state->desc->fd,
 | 
			
		||||
					    plane.crtc_w - 1, plane.crtc_h - 1,
 | 
			
		||||
					    format, I915_TILING_NONE, &fb);
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(plane.state->desc->fd, &fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, plane.crtc_w - 1, plane.crtc_h - 1);
 | 
			
		||||
 | 
			
		||||
	plane_commit_atomic_err(&plane, plane_old, req,
 | 
			
		||||
	                        ATOMIC_RELAX_NONE, ENOSPC);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -39,16 +39,6 @@ typedef struct {
 | 
			
		||||
	int gen;
 | 
			
		||||
} data_t;
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
fill_fb(struct igt_fb *fb, data_t *data, drmModeModeInfo *mode)
 | 
			
		||||
{
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(data->drm_fd, fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, mode->hdisplay, mode->vdisplay);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static igt_pipe_crc_t *_pipe_crc;
 | 
			
		||||
 | 
			
		||||
static igt_pipe_crc_t *pipe_crc_new(int pipe)
 | 
			
		||||
@ -121,20 +111,17 @@ test_flip_tiling(data_t *data, igt_output_t *output, uint64_t tiling[2])
 | 
			
		||||
			width *= 2;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	fb_id = igt_create_fb(data->drm_fd, width, mode->vdisplay,
 | 
			
		||||
	fb_id = igt_create_pattern_fb(data->drm_fd, width, mode->vdisplay,
 | 
			
		||||
				      DRM_FORMAT_XRGB8888, tiling[0],
 | 
			
		||||
				      &fb[0]);
 | 
			
		||||
	igt_assert(fb_id);
 | 
			
		||||
 | 
			
		||||
	/* Second fb has different background so CRC does not match. */
 | 
			
		||||
	fb_id = igt_create_color_fb(data->drm_fd, width, mode->vdisplay,
 | 
			
		||||
	fb_id = igt_create_color_pattern_fb(data->drm_fd, width, mode->vdisplay,
 | 
			
		||||
				      DRM_FORMAT_XRGB8888, tiling[1],
 | 
			
		||||
				      0.5, 0.5, 0.5, &fb[1]);
 | 
			
		||||
	igt_assert(fb_id);
 | 
			
		||||
 | 
			
		||||
	fill_fb(&fb[0], data, mode);
 | 
			
		||||
	fill_fb(&fb[1], data, mode);
 | 
			
		||||
 | 
			
		||||
	/* Set the crtc and generate a reference CRC. */
 | 
			
		||||
	igt_plane_set_fb(primary, &fb[1]);
 | 
			
		||||
	igt_display_commit(&data->display);
 | 
			
		||||
 | 
			
		||||
@ -53,26 +53,6 @@ typedef struct {
 | 
			
		||||
 | 
			
		||||
#define FILE_NAME   "1080p-left.png"
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
paint_color(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
 | 
			
		||||
{
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(d->drm_fd, fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, w, h);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
 | 
			
		||||
{
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(d->drm_fd, fb);
 | 
			
		||||
	igt_paint_image(cr, FILE_NAME, 0, 0, w, h);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 | 
			
		||||
			igt_plane_t *plane, drmModeModeInfo *mode, enum igt_commit_style s)
 | 
			
		||||
{
 | 
			
		||||
@ -91,15 +71,13 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* allocate fb for plane 1 */
 | 
			
		||||
	data->fb_id1 = igt_create_fb(data->drm_fd,
 | 
			
		||||
	data->fb_id1 = igt_create_pattern_fb(data->drm_fd,
 | 
			
		||||
					     mode->hdisplay, mode->vdisplay,
 | 
			
		||||
					     DRM_FORMAT_XRGB8888,
 | 
			
		||||
					     LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
 | 
			
		||||
					     &data->fb1);
 | 
			
		||||
	igt_assert(data->fb_id1);
 | 
			
		||||
 | 
			
		||||
	paint_color(data, &data->fb1, mode->hdisplay, mode->vdisplay);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * We always set the primary plane to actually enable the pipe as
 | 
			
		||||
	 * there's no way (that works) to light up a pipe with only a sprite
 | 
			
		||||
@ -188,13 +166,11 @@ static void test_panel_fitting(data_t *d)
 | 
			
		||||
		d->image_h = cairo_image_surface_get_height(image);
 | 
			
		||||
		cairo_surface_destroy(image);
 | 
			
		||||
 | 
			
		||||
		d->fb_id2 = igt_create_fb(d->drm_fd,
 | 
			
		||||
				d->image_w, d->image_h,
 | 
			
		||||
		d->fb_id2 = igt_create_image_fb(d->drm_fd, 0, 0,
 | 
			
		||||
						DRM_FORMAT_XRGB8888,
 | 
			
		||||
						LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
 | 
			
		||||
				&d->fb2);
 | 
			
		||||
						FILE_NAME, &d->fb2);
 | 
			
		||||
		igt_assert(d->fb_id2);
 | 
			
		||||
		paint_image(d, &d->fb2, d->fb2.width, d->fb2.height);
 | 
			
		||||
 | 
			
		||||
		/* Set up display to enable panel fitting */
 | 
			
		||||
		mode->hdisplay = 640;
 | 
			
		||||
 | 
			
		||||
@ -55,26 +55,6 @@ typedef struct {
 | 
			
		||||
 | 
			
		||||
#define FILE_NAME   "1080p-left.png"
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
paint_color(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
 | 
			
		||||
{
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(d->drm_fd, fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, w, h);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void
 | 
			
		||||
paint_image(data_t *d, struct igt_fb *fb, uint16_t w, uint16_t h)
 | 
			
		||||
{
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(d->drm_fd, fb);
 | 
			
		||||
	igt_paint_image(cr, FILE_NAME, 0, 0, w, h);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 | 
			
		||||
			igt_plane_t *plane, drmModeModeInfo *mode, enum igt_commit_style s)
 | 
			
		||||
{
 | 
			
		||||
@ -93,15 +73,13 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	/* allocate fb for plane 1 */
 | 
			
		||||
	data->fb_id1 = igt_create_fb(data->drm_fd,
 | 
			
		||||
	data->fb_id1 = igt_create_pattern_fb(data->drm_fd,
 | 
			
		||||
					     mode->hdisplay, mode->vdisplay,
 | 
			
		||||
					     DRM_FORMAT_XRGB8888,
 | 
			
		||||
					     LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
 | 
			
		||||
					     &data->fb1);
 | 
			
		||||
	igt_assert(data->fb_id1);
 | 
			
		||||
 | 
			
		||||
	paint_color(data, &data->fb1, mode->hdisplay, mode->vdisplay);
 | 
			
		||||
 | 
			
		||||
	/*
 | 
			
		||||
	 * We always set the primary plane to actually enable the pipe as
 | 
			
		||||
	 * there's no way (that works) to light up a pipe with only a sprite
 | 
			
		||||
@ -201,7 +179,6 @@ static void test_plane_scaling(data_t *d)
 | 
			
		||||
{
 | 
			
		||||
	igt_display_t *display = &d->display;
 | 
			
		||||
	igt_output_t *output;
 | 
			
		||||
	cairo_surface_t *image;
 | 
			
		||||
	enum pipe pipe;
 | 
			
		||||
	int valid_tests = 0;
 | 
			
		||||
	int primary_plane_scaling = 0; /* For now */
 | 
			
		||||
@ -218,27 +195,18 @@ static void test_plane_scaling(data_t *d)
 | 
			
		||||
		mode = igt_output_get_mode(output);
 | 
			
		||||
 | 
			
		||||
		/* allocate fb2 with image size */
 | 
			
		||||
		image = cairo_image_surface_create_from_png(FILE_NAME);
 | 
			
		||||
		igt_assert(cairo_surface_status(image) == CAIRO_STATUS_SUCCESS);
 | 
			
		||||
		d->image_w = cairo_image_surface_get_width(image);
 | 
			
		||||
		d->image_h = cairo_image_surface_get_height(image);
 | 
			
		||||
		cairo_surface_destroy(image);
 | 
			
		||||
 | 
			
		||||
		d->fb_id2 = igt_create_fb(d->drm_fd,
 | 
			
		||||
				d->image_w, d->image_h,
 | 
			
		||||
		d->fb_id2 = igt_create_image_fb(d->drm_fd, 0, 0,
 | 
			
		||||
						DRM_FORMAT_XRGB8888,
 | 
			
		||||
						LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
 | 
			
		||||
				&d->fb2);
 | 
			
		||||
						FILE_NAME, &d->fb2);
 | 
			
		||||
		igt_assert(d->fb_id2);
 | 
			
		||||
		paint_image(d, &d->fb2, d->fb2.width, d->fb2.height);
 | 
			
		||||
 | 
			
		||||
		d->fb_id3 = igt_create_fb(d->drm_fd,
 | 
			
		||||
		d->fb_id3 = igt_create_pattern_fb(d->drm_fd,
 | 
			
		||||
						  mode->hdisplay, mode->vdisplay,
 | 
			
		||||
						  DRM_FORMAT_XRGB8888,
 | 
			
		||||
						  LOCAL_I915_FORMAT_MOD_X_TILED, /* tiled */
 | 
			
		||||
						  &d->fb3);
 | 
			
		||||
		igt_assert(d->fb_id3);
 | 
			
		||||
		paint_color(d, &d->fb3, mode->hdisplay, mode->vdisplay);
 | 
			
		||||
 | 
			
		||||
		/* Set up display with plane 1 */
 | 
			
		||||
		d->plane1 = igt_output_get_plane(output, IGT_PLANE_PRIMARY);
 | 
			
		||||
 | 
			
		||||
@ -50,7 +50,6 @@ static void test(data_t *data)
 | 
			
		||||
	igt_output_t *output = data->output;
 | 
			
		||||
	struct igt_fb *fb = &data->fb[1];
 | 
			
		||||
	drmModeModeInfo *mode;
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
	uint32_t caching;
 | 
			
		||||
	void *buf;
 | 
			
		||||
	igt_crc_t crc;
 | 
			
		||||
@ -58,13 +57,9 @@ static void test(data_t *data)
 | 
			
		||||
	mode = igt_output_get_mode(output);
 | 
			
		||||
 | 
			
		||||
	/* create a non-white fb where we can pwrite later */
 | 
			
		||||
	igt_create_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
 | 
			
		||||
	igt_create_pattern_fb(data->drm_fd, mode->hdisplay, mode->vdisplay,
 | 
			
		||||
			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE, fb);
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(data->drm_fd, fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, fb->width, fb->height);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
 | 
			
		||||
	/* flip to it to make it UC/WC and fully flushed */
 | 
			
		||||
	drmModeSetPlane(data->drm_fd,
 | 
			
		||||
			data->primary->drm_plane->plane_id,
 | 
			
		||||
 | 
			
		||||
@ -146,8 +146,6 @@ static int paint_fb(struct igt_fb *fb, const char *test_name,
 | 
			
		||||
 | 
			
		||||
	cr = igt_get_cairo_ctx(drm_fd, fb);
 | 
			
		||||
 | 
			
		||||
	igt_paint_test_pattern(cr, fb->width, fb->height);
 | 
			
		||||
 | 
			
		||||
	cairo_move_to(cr, fb->width / 2, fb->height / 2);
 | 
			
		||||
	cairo_set_font_size(cr, 24);
 | 
			
		||||
	igt_cairo_printf_line(cr, align_hcenter, 40, "%s", test_name);
 | 
			
		||||
@ -180,10 +178,11 @@ static void create_fb_for_crtc(struct crtc_config *crtc,
 | 
			
		||||
 | 
			
		||||
	bpp = 32;
 | 
			
		||||
	depth = 24;
 | 
			
		||||
	fb_id = igt_create_fb(drm_fd, crtc->mode.hdisplay,
 | 
			
		||||
	fb_id = igt_create_pattern_fb(drm_fd, crtc->mode.hdisplay,
 | 
			
		||||
				      crtc->mode.vdisplay,
 | 
			
		||||
				      igt_bpp_depth_to_drm_format(bpp, depth),
 | 
			
		||||
				  LOCAL_DRM_FORMAT_MOD_NONE, fb_info);
 | 
			
		||||
				      LOCAL_DRM_FORMAT_MOD_NONE,
 | 
			
		||||
				      fb_info);
 | 
			
		||||
	igt_assert_lt(0, fb_id);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
@ -78,16 +78,9 @@ static void screens_disabled_subtest(int drm_fd, drmModeResPtr drm_res)
 | 
			
		||||
static uint32_t create_fb(int drm_fd, int width, int height)
 | 
			
		||||
{
 | 
			
		||||
	struct igt_fb fb;
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
	uint32_t buffer_id;
 | 
			
		||||
 | 
			
		||||
	buffer_id = igt_create_fb(drm_fd, width, height, DRM_FORMAT_XRGB8888,
 | 
			
		||||
	return igt_create_pattern_fb(drm_fd, width, height, DRM_FORMAT_XRGB8888,
 | 
			
		||||
				     LOCAL_DRM_FORMAT_MOD_NONE, &fb);
 | 
			
		||||
	cr = igt_get_cairo_ctx(drm_fd, &fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, width, height);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
 | 
			
		||||
	return buffer_id;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void edp_subtest(int drm_fd, drmModeResPtr drm_res,
 | 
			
		||||
 | 
			
		||||
@ -233,7 +233,6 @@ static bool init_modeset_params_for_type(struct mode_set_data *data,
 | 
			
		||||
	int i;
 | 
			
		||||
	uint32_t connector_id = 0;
 | 
			
		||||
	drmModeModeInfoPtr mode = NULL;
 | 
			
		||||
	cairo_t *cr;
 | 
			
		||||
 | 
			
		||||
	for (i = 0; i < data->res->count_connectors; i++) {
 | 
			
		||||
		drmModeConnectorPtr c = data->connectors[i];
 | 
			
		||||
@ -256,12 +255,9 @@ static bool init_modeset_params_for_type(struct mode_set_data *data,
 | 
			
		||||
	if (!connector_id)
 | 
			
		||||
		return false;
 | 
			
		||||
 | 
			
		||||
	igt_create_fb(drm_fd, mode->hdisplay, mode->vdisplay,
 | 
			
		||||
	igt_create_pattern_fb(drm_fd, mode->hdisplay, mode->vdisplay,
 | 
			
		||||
			      DRM_FORMAT_XRGB8888, LOCAL_DRM_FORMAT_MOD_NONE,
 | 
			
		||||
			      ¶ms->fb);
 | 
			
		||||
	cr = igt_get_cairo_ctx(drm_fd, ¶ms->fb);
 | 
			
		||||
	igt_paint_test_pattern(cr, mode->hdisplay, mode->vdisplay);
 | 
			
		||||
	cairo_destroy(cr);
 | 
			
		||||
 | 
			
		||||
	params->crtc_id = data->res->crtcs[0];
 | 
			
		||||
	params->connector_id = connector_id;
 | 
			
		||||
 | 
			
		||||
@ -259,8 +259,6 @@ static void paint_output_info(struct connector *c, struct igt_fb *fb)
 | 
			
		||||
	double max_width;
 | 
			
		||||
	int i;
 | 
			
		||||
 | 
			
		||||
	igt_paint_test_pattern(cr, l_width, l_height);
 | 
			
		||||
 | 
			
		||||
	cairo_move_to(cr, l_width / 2, l_height / 2);
 | 
			
		||||
 | 
			
		||||
	/* Print connector and mode name */
 | 
			
		||||
@ -353,7 +351,7 @@ set_mode(struct connector *c)
 | 
			
		||||
		width = c->mode.hdisplay;
 | 
			
		||||
		height = c->mode.vdisplay;
 | 
			
		||||
 | 
			
		||||
		fb_id = igt_create_fb(drm_fd, width, height,
 | 
			
		||||
		fb_id = igt_create_pattern_fb(drm_fd, width, height,
 | 
			
		||||
					      igt_bpp_depth_to_drm_format(bpp, depth),
 | 
			
		||||
					      tiling, &fb_info[current_fb]);
 | 
			
		||||
		paint_output_info(c, &fb_info[current_fb]);
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user