mirror of
https://github.com/tiagovignatti/intel-gpu-tools.git
synced 2025-06-20 06:16:13 +00:00
kms_rotation_crc: Consolidate plane and cursor code paths
There can only be one, either a plane or a cursor, in each subtest so there is no need for two framebuffer varilables and also some codepaths can be unified. Signed-off-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com> Cc: Sonika Jindal <sonika.jindal@intel.com> Reviewed-by: Sonika Jindal <sonika.jindal@intel.com> Signed-off-by: Thomas Wood <thomas.wood@intel.com>
This commit is contained in:
parent
e23a818c18
commit
b769a7c96b
@ -34,41 +34,24 @@ typedef struct {
|
|||||||
int gfx_fd;
|
int gfx_fd;
|
||||||
igt_display_t display;
|
igt_display_t display;
|
||||||
struct igt_fb fb;
|
struct igt_fb fb;
|
||||||
struct igt_fb fb_cursor;
|
|
||||||
struct igt_fb fb_modeset;
|
struct igt_fb fb_modeset;
|
||||||
igt_crc_t ref_crc;
|
igt_crc_t ref_crc;
|
||||||
igt_pipe_crc_t *pipe_crc;
|
igt_pipe_crc_t *pipe_crc;
|
||||||
igt_rotation_t rotation;
|
igt_rotation_t rotation;
|
||||||
int pos_x;
|
int pos_x;
|
||||||
int pos_y;
|
int pos_y;
|
||||||
|
unsigned int w, h;
|
||||||
} data_t;
|
} data_t;
|
||||||
|
|
||||||
static void
|
static void
|
||||||
paint_squares(data_t *data, struct igt_fb *fb, drmModeModeInfo *mode,
|
paint_squares(data_t *data, drmModeModeInfo *mode, igt_rotation_t rotation,
|
||||||
igt_rotation_t rotation, igt_plane_t *plane)
|
igt_plane_t *plane)
|
||||||
{
|
{
|
||||||
cairo_t *cr;
|
cairo_t *cr;
|
||||||
int w, h;
|
unsigned int w = data->w;
|
||||||
|
unsigned int h = data->h;
|
||||||
|
|
||||||
if (plane->is_cursor) {
|
cr = igt_get_cairo_ctx(data->gfx_fd, &data->fb);
|
||||||
w = 128;
|
|
||||||
h = 128;
|
|
||||||
cr = igt_get_cairo_ctx(data->gfx_fd, &data->fb_cursor);
|
|
||||||
|
|
||||||
if (rotation == IGT_ROTATION_180) {
|
|
||||||
cairo_translate(cr, w, h);
|
|
||||||
cairo_rotate(cr, M_PI);
|
|
||||||
}
|
|
||||||
|
|
||||||
igt_paint_color(cr, 0, 0, w / 2, h / 2, .75, 0.5, 0.5);
|
|
||||||
igt_paint_color(cr, w / 2, 0, w / 2, h / 2, 0.5, .75, 0.5);
|
|
||||||
igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.5, 0.5, .75);
|
|
||||||
igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, .75, .75, .75);
|
|
||||||
} else {
|
|
||||||
w = mode->hdisplay;
|
|
||||||
h = mode->vdisplay;
|
|
||||||
|
|
||||||
cr = igt_get_cairo_ctx(data->gfx_fd, fb);
|
|
||||||
|
|
||||||
if (rotation == IGT_ROTATION_180) {
|
if (rotation == IGT_ROTATION_180) {
|
||||||
cairo_translate(cr, w, h);
|
cairo_translate(cr, w, h);
|
||||||
@ -108,7 +91,7 @@ paint_squares(data_t *data, struct igt_fb *fb, drmModeModeInfo *mode,
|
|||||||
igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, 1.0);
|
igt_paint_color(cr, 0, h / 2, w / 2, h / 2, 0.0, 0.0, 1.0);
|
||||||
igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 1.0, 1.0, 1.0);
|
igt_paint_color(cr, w / 2, h / 2, w / 2, h / 2, 1.0, 1.0, 1.0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
cairo_destroy(cr);
|
cairo_destroy(cr);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -117,9 +100,10 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
|
|||||||
{
|
{
|
||||||
drmModeModeInfo *mode;
|
drmModeModeInfo *mode;
|
||||||
igt_display_t *display = &data->display;
|
igt_display_t *display = &data->display;
|
||||||
int fb_id, fb_cursor_id, fb_modeset_id;
|
int fb_id, fb_modeset_id;
|
||||||
int w, h;
|
unsigned int w, h;
|
||||||
uint64_t tiling = LOCAL_DRM_FORMAT_MOD_NONE;
|
uint64_t tiling = LOCAL_DRM_FORMAT_MOD_NONE;
|
||||||
|
uint32_t pixel_format = DRM_FORMAT_XRGB8888;
|
||||||
enum igt_commit_style commit = COMMIT_LEGACY;
|
enum igt_commit_style commit = COMMIT_LEGACY;
|
||||||
igt_plane_t *primary;
|
igt_plane_t *primary;
|
||||||
|
|
||||||
@ -136,7 +120,7 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
|
|||||||
|
|
||||||
fb_modeset_id = igt_create_fb(data->gfx_fd,
|
fb_modeset_id = igt_create_fb(data->gfx_fd,
|
||||||
w, h,
|
w, h,
|
||||||
DRM_FORMAT_XRGB8888,
|
pixel_format,
|
||||||
tiling,
|
tiling,
|
||||||
&data->fb_modeset);
|
&data->fb_modeset);
|
||||||
igt_assert(fb_modeset_id);
|
igt_assert(fb_modeset_id);
|
||||||
@ -160,32 +144,28 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
|
|||||||
data->rotation == IGT_ROTATION_270) {
|
data->rotation == IGT_ROTATION_270) {
|
||||||
tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
|
tiling = LOCAL_I915_FORMAT_MOD_Y_TILED;
|
||||||
w = h = mode->vdisplay;
|
w = h = mode->vdisplay;
|
||||||
|
} else if (plane->is_cursor) {
|
||||||
|
pixel_format = DRM_FORMAT_ARGB8888;
|
||||||
|
w = h = 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data->w = w;
|
||||||
|
data->h = h;
|
||||||
|
|
||||||
fb_id = igt_create_fb(data->gfx_fd,
|
fb_id = igt_create_fb(data->gfx_fd,
|
||||||
w, h,
|
w, h,
|
||||||
DRM_FORMAT_XRGB8888,
|
pixel_format,
|
||||||
tiling,
|
tiling,
|
||||||
&data->fb);
|
&data->fb);
|
||||||
igt_assert(fb_id);
|
igt_assert(fb_id);
|
||||||
|
|
||||||
fb_cursor_id = igt_create_fb(data->gfx_fd,
|
|
||||||
128, 128,
|
|
||||||
DRM_FORMAT_ARGB8888,
|
|
||||||
LOCAL_DRM_FORMAT_MOD_NONE,
|
|
||||||
&data->fb_cursor);
|
|
||||||
igt_assert(fb_cursor_id);
|
|
||||||
|
|
||||||
/* Step 1: create a reference CRC for a software-rotated fb */
|
/* Step 1: create a reference CRC for a software-rotated fb */
|
||||||
|
|
||||||
if (plane->is_cursor) {
|
paint_squares(data, mode, data->rotation, plane);
|
||||||
paint_squares(data, &data->fb_cursor, mode, data->rotation, plane);
|
|
||||||
igt_plane_set_fb(plane, &data->fb_cursor);
|
|
||||||
} else {
|
|
||||||
paint_squares(data, &data->fb, mode, data->rotation, plane);
|
|
||||||
igt_plane_set_fb(plane, &data->fb);
|
igt_plane_set_fb(plane, &data->fb);
|
||||||
|
if (!plane->is_cursor)
|
||||||
igt_plane_set_position(plane, data->pos_x, data->pos_y);
|
igt_plane_set_position(plane, data->pos_x, data->pos_y);
|
||||||
}
|
|
||||||
if (plane->is_primary || plane->is_cursor) {
|
if (plane->is_primary || plane->is_cursor) {
|
||||||
igt_require(data->display.has_universal_planes);
|
igt_require(data->display.has_universal_planes);
|
||||||
commit = COMMIT_UNIVERSAL;
|
commit = COMMIT_UNIVERSAL;
|
||||||
@ -198,13 +178,8 @@ static void prepare_crtc(data_t *data, igt_output_t *output, enum pipe pipe,
|
|||||||
* Step 2: prepare the plane with an non-rotated fb let the hw
|
* Step 2: prepare the plane with an non-rotated fb let the hw
|
||||||
* rotate it.
|
* rotate it.
|
||||||
*/
|
*/
|
||||||
if (plane->is_cursor) {
|
paint_squares(data, mode, IGT_ROTATION_0, plane);
|
||||||
paint_squares(data, &data->fb_cursor, mode, IGT_ROTATION_0, plane);
|
|
||||||
igt_plane_set_fb(plane, &data->fb_cursor);
|
|
||||||
} else {
|
|
||||||
paint_squares(data, &data->fb, mode, IGT_ROTATION_0, plane);
|
|
||||||
igt_plane_set_fb(plane, &data->fb);
|
igt_plane_set_fb(plane, &data->fb);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
|
static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
|
||||||
@ -215,7 +190,6 @@ static void cleanup_crtc(data_t *data, igt_output_t *output, igt_plane_t *plane)
|
|||||||
data->pipe_crc = NULL;
|
data->pipe_crc = NULL;
|
||||||
|
|
||||||
igt_remove_fb(data->gfx_fd, &data->fb);
|
igt_remove_fb(data->gfx_fd, &data->fb);
|
||||||
igt_remove_fb(data->gfx_fd, &data->fb_cursor);
|
|
||||||
igt_remove_fb(data->gfx_fd, &data->fb_modeset);
|
igt_remove_fb(data->gfx_fd, &data->fb_modeset);
|
||||||
|
|
||||||
/* XXX: see the note in prepare_crtc() */
|
/* XXX: see the note in prepare_crtc() */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user