i-g-t: Adding test case to test background color.
PATCH v2 1/1 i-g-t: Adding test case to test background color.
From: chandra konduru <[email protected]>
Adding i-g-t test case to test display crtc background color.
v2:
- Added IGT_TEST_DESCRIPTION() (Thomas Wood)
- Added to .gitignore (Thomas Wood)
- Added additional details to function header (Thomas Wood)
- Simplified igt_main (Thomas Wood)
--- lib/igt_kms.c | 61 ++++++++++++ lib/igt_kms.h | 4 + tests/.gitignore | 1 + tests/Android.mk | 1 + tests/Makefile.sources | 1 + tests/kms_crtc_background_color.c | 201 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 269 insertions(+) create mode 100644 tests/kms_crtc_background_color.c
lib/igt_kms.c +61 -0
@@ -926,6 +926,22 @@ igt_plane_set_property(igt_plane_t *plane, uint32_t prop_id, uint64_t value) DRM_MODE_OBJECT_PLANE, prop_id, value); } +static bool +get_crtc_property (int drm_fd,uint32_t crtc_id,const char *name, +uint32_t *prop_id/* out */ ,uint64_t *value/* out */ , +drmModePropertyPtr *prop/* out */ ) +{ +return kmstest_get_property (drm_fd, crtc_id,DRM_MODE_OBJECT_CRTC , + name, prop_id, value, prop); +} + +static void +igt_crtc_set_property (igt_output_t *output,uint32_t prop_id,uint64_t value) +{ +drmModeObjectSetProperty (output->display->drm_fd, + output->config.crtc->crtc_id,DRM_MODE_OBJECT_CRTC , prop_id, value); +} +/* * Walk a plane's property list to determine its type. If we don't * find a type property, then the kernel doesn't support universal
@@ -1083,6 +1099,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)igt_assert (display->outputs);for (i =0 ; i < display->n_outputs; i++) { +int j;igt_output_t *output = &display->outputs[i];/*
@@ -1094,6 +1111,19 @@ void igt_display_init(igt_display_t *display, int drm_fd) output->display = display;igt_output_refresh (output); + +for (j =0 ; j < display->n_pipes; j++) { +uint64_t prop_value; +igt_pipe_t *pipe = &display->pipes[j]; +if (output->config.crtc) { +get_crtc_property (display->drm_fd, output->config.crtc->crtc_id, +"background_color" , + &pipe->background_property, + &prop_value, +NULL ); + pipe->background = (uint32_t )prop_value; + } + } }drmModeFreePlaneResources (plane_resources);
@@ -1513,6 +1543,13 @@ static int igt_output_commit(igt_output_t *output, pipe =igt_output_get_driving_pipe (output); +if (pipe->background_changed) { +igt_crtc_set_property (output, pipe->background_property, + pipe->background); + + pipe->background_changed = false; + } +for (i =0 ; i < pipe->n_planes; i++) {igt_plane_t *plane = &pipe->planes[i];
@@ -1765,6 +1802,30 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation) plane->rotation_changed = true; } +/** +* igt_crtc_set_background: +* @pipe: pipe pointer to which background color to be set +* @background: background color value in BGR 16bpc +* +* Sets background color for requested pipe. Color value provided here +* will be actually submitted at output commit time via "background_color" +* property. +* For example to get red as background, set background = 0x00000000FFFF. +*/ +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background) +{ +igt_display_t *display = pipe->display; + +LOG (display,"%s.%d: crtc_set_background(%lu)\n" , +kmstest_pipe_name (pipe->pipe), + pipe->pipe, background); + + pipe->background = background; + + pipe->background_changed = true; +} + +void igt_wait_for_vblank (int drm_fd,enum pipe pipe) {drmVBlank wait_vbl;
lib/igt_kms.h +4 -0
@@ -206,6 +206,9 @@ struct igt_pipe {#define IGT_MAX_PLANES 4int n_planes;igt_plane_t planes[IGT_MAX_PLANES ]; +uint64_t background;/* Background color MSB BGR 16bpc LSB */ + uint32_t background_changed : 1; +uint32_t background_property; }; typedef struct {
@@ -251,6 +254,7 @@ void igt_plane_set_position(igt_plane_t *plane, int x, int y);void igt_plane_set_size (igt_plane_t *plane,int w,int h);void igt_plane_set_panning (igt_plane_t *plane,int x,int y);void igt_plane_set_rotation (igt_plane_t *plane,igt_rotation_t rotation); +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background);void igt_wait_for_vblank (int drm_fd,enum pipe pipe);
tests/.gitignore +1 -0
@@ -137,6 +137,7 @@ kms_rotation_crc kms_setmode kms_sink_crc_basic kms_universal_plane +kms_crtc_background_color multi-tests.txt pm_lpsp pm_psr
tests/Android.mk +1 -0
@@ -75,6 +75,7 @@ else kms_rotation_crc \ kms_force_connector \ kms_flip_event_leak \ + kms_crtc_background_color \ kms_pwrite_crc IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0 endif
tests/Makefile.sources +1 -0
@@ -77,6 +77,7 @@ TESTS_progs_M = \ kms_rotation_crc \ kms_setmode \ kms_universal_plane \ + kms_crtc_background_color \ pm_lpsp \ pm_rpm \ pm_rps \
tests/kms_crtc_background_color.c new file +201 -0
201 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 11 lines · Chandra Konduru
From: chandra konduru <[email protected]>
Adding i-g-t test case to test display crtc background color.
v2:
- AddedIGT_TEST_DESCRIPTION()(Thomas Wood)
- Added to .gitignore (Thomas Wood)
- Added additional details to function header (Thomas Wood)
- Simplifiedigt_main(Thomas Wood)Signed-off-by chandra konduru <[email protected]>
This test doesn't seem to actually use crc checksums anywhere ...
Quoted 333 lines
--- lib/igt_kms.c | 61 ++++++++++++ lib/igt_kms.h | 4 + tests/.gitignore | 1 + tests/Android.mk | 1 + tests/Makefile.sources | 1 + tests/kms_crtc_background_color.c | 201 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 269 insertions(+) create mode 100644 tests/kms_crtc_background_color.clib/igt_kms.c +61
-0@@ -926,6 +926,22 @@ igt_plane_set_property(igt_plane_t *plane, uint32_t prop_id, uint64_t value) DRM_MODE_OBJECT_PLANE, prop_id, value); } +static bool +get_crtc_property (int drm_fd,uint32_t crtc_id,const char *name, +uint32_t *prop_id/* out */ ,uint64_t *value/* out */ , +drmModePropertyPtr *prop/* out */ ) +{ +return kmstest_get_property (drm_fd, crtc_id,DRM_MODE_OBJECT_CRTC , + name, prop_id, value, prop); +} + +static void +igt_crtc_set_property (igt_output_t *output,uint32_t prop_id,uint64_t value) +{ +drmModeObjectSetProperty (output->display->drm_fd, + output->config.crtc->crtc_id,DRM_MODE_OBJECT_CRTC , prop_id, value); +} +/* * Walk a plane's property list to determine its type. If we don't * find a type property, then the kernel doesn't support universal @@ -1083,6 +1099,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)igt_assert (display->outputs);for (i =0 ; i < display->n_outputs; i++) { +int j;igt_output_t *output = &display->outputs[i];/* @@ -1094,6 +1111,19 @@ void igt_display_init(igt_display_t *display, int drm_fd) output->display = display;igt_output_refresh (output); + +for (j =0 ; j < display->n_pipes; j++) { +uint64_t prop_value; +igt_pipe_t *pipe = &display->pipes[j]; +if (output->config.crtc) { +get_crtc_property (display->drm_fd, output->config.crtc->crtc_id, +"background_color" , + &pipe->background_property, + &prop_value, +NULL ); + pipe->background = (uint32_t )prop_value; + } + } }drmModeFreePlaneResources (plane_resources);@@ -1513,6 +1543,13 @@ static int igt_output_commit(igt_output_t *output, pipe =igt_output_get_driving_pipe (output); +if (pipe->background_changed) { +igt_crtc_set_property (output, pipe->background_property, + pipe->background); + + pipe->background_changed = false; + } +for (i =0 ; i < pipe->n_planes; i++) {igt_plane_t *plane = &pipe->planes[i];@@ -1765,6 +1802,30 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation) plane->rotation_changed = true; } +/** +* igt_crtc_set_background: +* @pipe: pipe pointer to which background color to be set +* @background: background color value in BGR 16bpc +* +* Sets background color for requested pipe. Color value provided here +* will be actually submitted at output commit time via "background_color" +* property. +* For example to get red as background, set background = 0x00000000FFFF. +*/ +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background) +{ +igt_display_t *display = pipe->display; + +LOG (display,"%s.%d: crtc_set_background(%lu)\n" , +kmstest_pipe_name (pipe->pipe), + pipe->pipe, background); + + pipe->background = background; + + pipe->background_changed = true; +} + +void igt_wait_for_vblank (int drm_fd,enum pipe pipe) {drmVBlank wait_vbl;lib/igt_kms.h +4
-0@@ -206,6 +206,9 @@ struct igt_pipe {#define IGT_MAX_PLANES 4int n_planes;igt_plane_t planes[IGT_MAX_PLANES ]; +uint64_t background;/* Background color MSB BGR 16bpc LSB */ + uint32_t background_changed : 1; +uint32_t background_property; }; typedef struct {@@ -251,6 +254,7 @@ void igt_plane_set_position(igt_plane_t *plane, int x, int y);void igt_plane_set_size (igt_plane_t *plane,int w,int h);void igt_plane_set_panning (igt_plane_t *plane,int x,int y);void igt_plane_set_rotation (igt_plane_t *plane,igt_rotation_t rotation); +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background);void igt_wait_for_vblank (int drm_fd,enum pipe pipe);tests/.gitignore +1
-0@@ -137,6 +137,7 @@ kms_rotation_crc kms_setmode kms_sink_crc_basic kms_universal_plane +kms_crtc_background_color multi-tests.txt pm_lpsp pm_psrtests/Android.mk +1
-0@@ -75,6 +75,7 @@ else kms_rotation_crc \ kms_force_connector \ kms_flip_event_leak \ + kms_crtc_background_color \ kms_pwrite_crc IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0 endiftests/Makefile.sources +1
-0@@ -77,6 +77,7 @@ TESTS_progs_M = \ kms_rotation_crc \ kms_setmode \ kms_universal_plane \ + kms_crtc_background_color \ pm_lpsp \ pm_rpm \ pm_rps \tests/kms_crtc_background_color.c new file +159
-0@@ -0,0 +1,201 @@ +/* +* Copyright © 2013,2014 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#include <math.h> + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" +#include "igt_core.h" + +IGT_TEST_DESCRIPTION ("Test crtc background color feature" ); + +typedef struct { +int gfx_fd; +igt_display_t display; +struct igt_fb fb; +igt_crc_t ref_crc; +igt_pipe_crc_t *pipe_crc; +}data_t ; + +#define BLACK 0x000000/* BGR 8bpc */ +#define CYAN 0xFFFF00/* BGR 8bpc */ +#define PURPLE 0xFF00FF/* BGR 8bpc */ +#define WHITE 0xFFFFFF/* BGR 8bpc */ + +#define BLACK64 0x000000000000/* BGR 16bpc */ +#define CYAN64 0xFFFFFFFF0000/* BGR 16bpc */ +#define PURPLE64 0xFFFF0000FFFF/* BGR 16bpc */ +#define YELLOW64 0x0000FFFFFFFF/* BGR 16bpc */ +#define WHITE64 0xFFFFFFFFFFFF/* BGR 16bpc */ +#define RED64 0x00000000FFFF/* BGR 16bpc */ +#define GREEN64 0x0000FFFF0000/* BGR 16bpc */ +#define BLUE64 0xFFFF00000000/* BGR 16bpc */ + +static void +paint_background (data_t *data,struct igt_fb *fb,drmModeModeInfo *mode, +uint32_t background,double alpha) +{ +cairo_t *cr; +int w, h; +double r, g, b; + + w = mode->hdisplay; + h = mode->vdisplay; + + cr =igt_get_cairo_ctx (data->gfx_fd, &data->fb); + +/* Paint with background color */ + r = (double ) (background &0xFF ) /255.0 ; + g = (double ) ((background &0xFF00 ) >>8 ) /255.0 ; + b = (double ) ((background &0xFF0000 ) >>16 ) /255.0 ; +igt_paint_color_alpha (cr,0 ,0 , w, h, r, g, b, alpha); + +cairo_destroy (cr); +} + +static void prepare_crtc (data_t *data,igt_output_t *output,enum pipe pipe, +igt_plane_t *plane,int opaque_buffer,int plane_color, +uint64_t pipe_background_color) +{ +drmModeModeInfo *mode; +igt_display_t *display = &data->display; +int fb_id; +double alpha; + +igt_output_set_pipe (output, pipe); + +/* create the pipe_crc object for this pipe */ +igt_pipe_crc_free (data->pipe_crc); + data->pipe_crc =igt_pipe_crc_new (pipe,INTEL_PIPE_CRC_SOURCE_AUTO ); + + mode =igt_output_get_mode (output); + + fb_id =igt_create_fb (data->gfx_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , + false,/* tiled */ + &data->fb); +igt_assert (fb_id); + +/* To make FB pixel win with background color, set alpha as full opaque */ +igt_crtc_set_background (plane->pipe, pipe_background_color); +if (opaque_buffer) + alpha =1.0 ;/* alpha 1 is fully opque */ +else + alpha =0.0 ;/* alpha 0 is fully transparent */ +paint_background (data, &data->fb, mode, plane_color, alpha); + +igt_plane_set_fb (plane, &data->fb); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); +} + +static void cleanup_crtc (data_t *data,igt_output_t *output,igt_plane_t *plane) +{ +igt_display_t *display = &data->display; + +igt_pipe_crc_free (data->pipe_crc); + data->pipe_crc =NULL ; + +igt_remove_fb (data->gfx_fd, &data->fb); + +igt_crtc_set_background (plane->pipe,BLACK64 ); +igt_plane_set_fb (plane,NULL ); +igt_output_set_pipe (output,PIPE_ANY ); + +igt_display_commit2 (display,COMMIT_UNIVERSAL ); +} + +static void test_crtc_background (data_t *data) +{ +igt_display_t *display = &data->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; + +igt_require (data->display.has_universal_planes); + +for_each_connected_output (display, output) { +igt_plane_t *plane; + + pipe = output->config.pipe; +igt_output_set_pipe (output, pipe); + + plane =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +igt_require (plane->pipe->background_property); + +prepare_crtc (data, output, pipe, plane,1 ,PURPLE ,BLACK64 ); + +/* Now set background without using a plane, i.e., +* Disable the plane to let hw background color win blend. */ +igt_plane_set_fb (plane,NULL ); +igt_crtc_set_background (plane->pipe,PURPLE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* Try few other background colors */ +sleep (1 ); +igt_crtc_set_background (plane->pipe,CYAN64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL );
tests/kms_crtc_background_color.c line 169
Quoted 10 lines
tests/kms_crtc_background_color.c new file +10
-0+ +sleep (1 ); +igt_crtc_set_background (plane->pipe,YELLOW64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +sleep (1 ); +igt_crtc_set_background (plane->pipe,RED64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +sleep (1 );
Please use igt_interactive_debug if you want to make a testcase useful for visual inspection. But igts _really_ must run fully automated, and that's possible using crc checksums. I.e. you need to draw reference frames using software, grab crc checksums and then compare against the same composition using the hw feature.
Cheers, Daniel
Quoted 39 lines
tests/kms_crtc_background_color.c new file +32
-0+igt_crtc_set_background (plane->pipe,GREEN64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +sleep (1 ); +igt_crtc_set_background (plane->pipe,BLUE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +sleep (1 ); +igt_crtc_set_background (plane->pipe,WHITE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + + valid_tests++; +cleanup_crtc (data, output, plane); + } +igt_require_f (valid_tests,"no valid crtc/connector combinations found\n" ); +} + +igt_main +{ +data_t data = {}; + +igt_skip_on_simulation (); + + data.gfx_fd =drm_open_any (); +igt_require_pipe_crc (); +igt_display_init (&data.display, data.gfx_fd); + + igt_subtest("pipe-background") +test_crtc_background (&data); + +igt_display_fini (&data.display); +}Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation +41 (0) 79 365 57 48 - http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 389 lines
-----Original Message-----
From: Daniel Vetter [mailto:[email protected]] On Behalf Of Daniel Vetter
Sent: Monday, March 02, 2015 9:54 AM
To: Konduru, Chandra
Cc: [email protected]
Subject: Re: [Intel-gfx] [PATCH v2] i-g-t: Adding test case to test background color.Quoted 11 lines · Chandra Konduru
From: chandra konduru <[email protected]>
Adding i-g-t test case to test display crtc background color.
v2:
- AddedIGT_TEST_DESCRIPTION()(Thomas Wood)
- Added to .gitignore (Thomas Wood)
- Added additional details to function header (Thomas Wood)
- Simplifiedigt_main(Thomas Wood)Signed-off-by chandra konduru <[email protected]>This test doesn't seem to actually use crc checksums anywhere ...
lib/igt_kms.c igt_plane_set_property(igt_plane_t *plane, uint32_t
Quoted 16 lines
--- lib/igt_kms.c | 61 ++++++++++++ lib/igt_kms.h | 4 + tests/.gitignore | 1 + tests/Android.mk | 1 + tests/Makefile.sources | 1 + tests/kms_crtc_background_color.c | 201 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 269 insertions(+) create mode 100644 tests/kms_crtc_background_color.clib/igt_kms.c index d0c3690..72841ef renamed from lib/igt_kms.c +0
-0100644
lib/igt_kms.c +0
-0@@ -926,6 +926,22 @@ igt_plane_set_property(igt_plane_t *plane, uint32_t
prop_id,uint64_tvalue)lib/igt_kms.c igt_plane_set_property(igt_plane_t *plane, uint32_t prop_id, uint64_t value) · line 926
Quoted 1 line
lib/igt_kms.c +0
-0DRM_MODE_OBJECT_PLANE, prop_id, value);}
lib/igt_kms.c igt_plane_set_property(igt_plane_t *plane, uint32_t prop_id, uint64_t value)
Quoted 6 lines
lib/igt_kms.c +5
-0+static bool +get_crtc_property (int drm_fd,uint32_t crtc_id,const char *name, +uint32_t *prop_id/* out */ ,uint64_t *value/* out */ , +drmModePropertyPtr *prop/* out */ ) { + return kmstest_get_property(drm_fd, crtc_id,
DRM_MODE_OBJECT_CRTC,lib/igt_kms.c igt_plane_set_property(igt_plane_t *plane, uint32_t prop_id, uint64_t value)
Quoted 8 lines
lib/igt_kms.c +8
-0+ name, prop_id, value, prop); +} + +static void +igt_crtc_set_property (igt_output_t *output,uint32_t prop_id, +uint64_t value) { + drmModeObjectSetProperty(output->display->drm_fd, + output->config.crtc->crtc_id, DRM_MODE_OBJECT_CRTC,
prop_id,lib/igt_kms.c void igt_display_init(igt_display_t *display, int
Quoted 14 lines
lib/igt_kms.c +3
-1+value); } +/* * Walk a plane's property list to determine its type. If we don't * find a type property, then the kernel doesn't support universal @@ -1083,6 +1099,7 @@ void igt_display_init(igt_display_t *display, int drm_fd) igt_assert(display->outputs); for (i = 0; i < display->n_outputs; i++) { +int j; igt_output_t *output = &display->outputs[i]; /* @@ -1094,6 +1111,19 @@ void igt_display_init(igt_display_t *display, int
drm_fd)lib/igt_kms.c void igt_plane_set_rotation(igt_plane_t *plane,
Quoted 37 lines
lib/igt_kms.c +13
-0output->display = display;igt_output_refresh (output); + +for (j =0 ; j < display->n_pipes; j++) { +uint64_t prop_value; +igt_pipe_t *pipe = &display->pipes[j]; +if (output->config.crtc) { +get_crtc_property (display->drm_fd, output- config.crtc->crtc_id, +"background_color" , + &pipe- background_property, + &prop_value, +NULL ); + pipe->background = (uint32_t )prop_value; + } + } }lib/igt_kms.c +7
-0drmModeFreePlaneResources (plane_resources);@@ -1513,6 +1543,13 @@ static int igt_output_commit(igt_output_t *output, pipe =igt_output_get_driving_pipe (output); +if (pipe->background_changed) { +igt_crtc_set_property (output, pipe->background_property, + pipe->background); + + pipe->background_changed = false; + } +for (i =0 ; i < pipe->n_planes; i++) {igt_plane_t *plane = &pipe->planes[i];@@ -1765,6 +1802,30 @@ void igt_plane_set_rotation(igt_plane_t *plane,
igt_rotation_trotation)Quoted 110 lines
lib/igt_kms.c +24
-0plane->rotation_changed = true; } +/** +* igt_crtc_set_background: +* @pipe: pipe pointer to which background color to be set +* @background: background color value in BGR 16bpc +* +* Sets background color for requested pipe. Color value provided +here +* will be actually submitted at output commit time via "background_color" +* property. +* For example to get red as background, set background = 0x00000000FFFF. +*/ +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background) { +igt_display_t *display = pipe->display; + +LOG (display,"%s.%d: crtc_set_background(%lu)\n" , +kmstest_pipe_name (pipe->pipe), + pipe->pipe, background); + + pipe->background = background; + + pipe->background_changed = true; +} + +void igt_wait_for_vblank (int drm_fd,enum pipe pipe) {drmVBlank wait_vbl;lib/igt_kms.h index a1483a4..4fada1b renamed from lib/igt_kms.h +0
-0100644
lib/igt_kms.h +3
-0@@ -206,6 +206,9 @@ struct igt_pipe {#define IGT_MAX_PLANES 4int n_planes;igt_plane_t planes[IGT_MAX_PLANES ]; +uint64_t background;/* Background color MSB BGR 16bpc LSB */ + uint32_t background_changed : 1; +uint32_t background_property; }; typedef struct {@@ -251,6 +254,7 @@ void igt_plane_set_position(igt_plane_t *plane,int x, int y); void
igt_plane_set_size(igt_plane_t *plane, int w, int h); voidigt_plane_set_panning(igt_plane_t *plane, int x, int y); voidigt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);lib/igt_kms.h +1
-0+void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background);void igt_wait_for_vblank (int drm_fd,enum pipe pipe);tests/.gitignore index renamed from tests/.gitignore +0
-088a6405..69d2ba0 100644
tests/.gitignore +1
-0@@ -137,6 +137,7 @@ kms_rotation_crc kms_setmode kms_sink_crc_basic kms_universal_plane +kms_crtc_background_color multi-tests.txt pm_lpsp pm_psrtests/Android.mk index renamed from tests/Android.mk +0
-0814b846..96a32b9 100644
tests/Android.mk +1
-0@@ -75,6 +75,7 @@ else kms_rotation_crc \ kms_force_connector \ kms_flip_event_leak \ + kms_crtc_background_color \ kms_pwrite_crc IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0 endif diff --gita/tests/Makefile.sources b/tests/Makefile.sources index 74deec3..4f612e6 100644
tests/Makefile.sources +1
-0@@ -77,6 +77,7 @@ TESTS_progs_M = \ kms_rotation_crc \ kms_setmode \ kms_universal_plane \ + kms_crtc_background_color \ pm_lpsp \ pm_rpm \ pm_rps \tests/kms_crtc_background_color.c new file +16
-0@@ -0,0 +1,201 @@ +/* +* Copyright (c) 2013,2014 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, +sublicense, +* and/or sell copies of the Software, and to permit persons to whom +the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including tests/kms_crtc_background_color.c line 26
Quoted 10 lines
tests/kms_crtc_background_color.c new file +10
-0+the next + * paragraph) shall be included in all copies or substantial portions +of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NOEVENT
tests/kms_crtc_background_color.c line 28
Quoted 2 lines
tests/kms_crtc_background_color.c new file +2
-0+SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES
Quoted 32 lines
tests/kms_crtc_background_color.c new file +32
-0+OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#include <math.h> + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" +#include "igt_core.h" + +IGT_TEST_DESCRIPTION ("Test crtc background color feature" ); + +typedef struct { +int gfx_fd; +igt_display_t display; +struct igt_fb fb; +igt_crc_t ref_crc; +igt_pipe_crc_t *pipe_crc; +}data_t ; + +#define BLACK 0x000000/* BGR 8bpc */ +#define CYAN 0xFFFF00/* BGR 8bpc */ +#define PURPLE 0xFF00FF/* BGR 8bpc */ +#define WHITE 0xFFFFFF/* BGR 8bpc */ + +#define BLACK64 0x000000000000/* BGR 16bpc */ tests/kms_crtc_background_color.c
Quoted 10 lines
tests/kms_crtc_background_color.c new file +10
-0+#define CYAN64 0xFFFFFFFF0000/* BGR 16bpc */ +#define PURPLE64 0xFFFF0000FFFF/* BGR 16bpc */ +#define YELLOW64 0x0000FFFFFFFF/* BGR 16bpc */ +#define WHITE64 0xFFFFFFFFFFFF/* BGR 16bpc */ +#define RED64 0x00000000FFFF/* BGR 16bpc */ +#define GREEN64 0x0000FFFF0000/* BGR 16bpc */ +#define BLUE64 0xFFFF00000000/* BGR 16bpc */ + +static void +paint_background(data_t *data, struct igt_fb *fb, drmModeModeInfo*mode,
Quoted 24 lines
tests/kms_crtc_background_color.c new file +24
-0+ uint32_t background, double alpha) +{ +cairo_t *cr; +int w, h; +double r, g, b; + + w = mode->hdisplay; + h = mode->vdisplay; + + cr =igt_get_cairo_ctx (data->gfx_fd, &data->fb); + +/* Paint with background color */ + r = (double ) (background &0xFF ) /255.0 ; + g = (double ) ((background &0xFF00 ) >>8 ) /255.0 ; + b = (double ) ((background &0xFF0000 ) >>16 ) /255.0 ; +igt_paint_color_alpha (cr,0 ,0 , w, h, r, g, b, alpha); + +cairo_destroy (cr); +} + +static void prepare_crtc (data_t *data,igt_output_t *output,enum pipe pipe, +igt_plane_t *plane,int opaque_buffer,int plane_color, +uint64_t pipe_background_color) +{tests/kms_crtc_background_color.c
Quoted 10 lines
tests/kms_crtc_background_color.c new file +10
-0+drmModeModeInfo *mode; +igt_display_t *display = &data->display; +int fb_id; +double alpha; + +igt_output_set_pipe (output, pipe); + +/* create the pipe_crc object for this pipe */ +igt_pipe_crc_free (data->pipe_crc); + data->pipe_crc = igt_pipe_crc_new(pipe,
INTEL_PIPE_CRC_SOURCE_AUTO);tests/kms_crtc_background_color.c
Quoted 11 lines
tests/kms_crtc_background_color.c new file +11
-0+ + mode =igt_output_get_mode (output); + + fb_id =igt_create_fb (data->gfx_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , + false,/* tiled */ + &data->fb); +igt_assert (fb_id); + +/* To make FB pixel win with background color, set alpha as full opaque */
Quoted 62 lines
tests/kms_crtc_background_color.c new file +62
-0+igt_crtc_set_background (plane->pipe, pipe_background_color); +if (opaque_buffer) + alpha =1.0 ;/* alpha 1 is fully opque */ +else + alpha =0.0 ;/* alpha 0 is fully transparent */ +paint_background (data, &data->fb, mode, plane_color, alpha); + +igt_plane_set_fb (plane, &data->fb); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); } + +static void cleanup_crtc (data_t *data,igt_output_t *output, +igt_plane_t *plane) { +igt_display_t *display = &data->display; + +igt_pipe_crc_free (data->pipe_crc); + data->pipe_crc =NULL ; + +igt_remove_fb (data->gfx_fd, &data->fb); + +igt_crtc_set_background (plane->pipe,BLACK64 ); +igt_plane_set_fb (plane,NULL ); +igt_output_set_pipe (output,PIPE_ANY ); + +igt_display_commit2 (display,COMMIT_UNIVERSAL ); } + +static void test_crtc_background (data_t *data) { +igt_display_t *display = &data->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; + +igt_require (data->display.has_universal_planes); + +for_each_connected_output (display, output) { +igt_plane_t *plane; + + pipe = output->config.pipe; +igt_output_set_pipe (output, pipe); + + plane =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +igt_require (plane->pipe->background_property); + +prepare_crtc (data, output, pipe, plane,1 ,PURPLE ,BLACK64 ); + +/* Now set background without using a plane, i.e., +* Disable the plane to let hw background color win blend. */ +igt_plane_set_fb (plane,NULL ); +igt_crtc_set_background (plane->pipe,PURPLE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* Try few other background colors */ +sleep (1 ); +igt_crtc_set_background (plane->pipe,CYAN64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +sleep (1 ); +igt_crtc_set_background (plane->pipe,YELLOW64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +sleep (1 ); +igt_crtc_set_background (plane->pipe,RED64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL );
Quoted 8 lines
tests/kms_crtc_background_color.c line 179
Quoted 2 lines
tests/kms_crtc_background_color.c new file +2
-0+ +sleep (1 );Please use
igt_interactive_debugif you want to make a testcase useful for visual inspection. But igts _really_ must run fully automated, and that's possible using crc checksums. I.e. you need to draw reference frames using software, grab crc checksums and then compare against the same composition using the hw feature.
Initially I planned to use crcs, but issue is that when all planes are disabled, which is required for this test, crcs aren't reliable to depend for comparison. Will sendout updated patch with sleeps takenout.
By the way, also I tried using igt_interactive_debug() but execution doesn't wait for keypress in response to calling igt_debug_wait_for_keypress. I might be missing something here. Is there a sample sequence
to use igt_interactive_debug?
Quoted 38 lines
Cheers, Daniel
Quoted 35 lines
tests/kms_crtc_background_color.c new file +32
-1+igt_crtc_set_background (plane->pipe,GREEN64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +sleep (1 ); +igt_crtc_set_background (plane->pipe,BLUE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +sleep (1 ); +igt_crtc_set_background (plane->pipe,WHITE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + + valid_tests++; +cleanup_crtc (data, output, plane); + } +igt_require_f (valid_tests,"no valid crtc/connector combinations +found\n"); } + +igt_main +{ +data_t data = {}; + +igt_skip_on_simulation (); + + data.gfx_fd =drm_open_any (); +igt_require_pipe_crc (); +igt_display_init (&data.display, data.gfx_fd); + + igt_subtest("pipe-background") +test_crtc_background (&data); + +igt_display_fini (&data.display); +} --1.9.1
Quoted 9 lines
Quoted 4 lines
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 9 lines · Chandra
Quoted 5 lines
Please use
igt_interactive_debugif you want to make a testcase useful for visual inspection. But igts _really_ must run fully automated, and that's possible using crc checksums. I.e. you need to draw reference frames using software, grab crc checksums and then compare against the same composition using the hw feature.Initially I planned to use crcs, but issue is that when all planes are disabled, which is required for this test, crcs aren't reliable to depend for comparison. Will sendout updated patch with sleeps takenout.
Funny that crcs don't work when all planes are disabled, we should still be scanning out a proper black. And the crcs we use by default are all at the pipe leve. What exactly falls apart?
Quoted 4 lines
By the way, also I tried using
igt_interactive_debug()but execution doesn't wait for keypress in response to callingigt_debug_wait_for_keypress. I might be missing something here. Is there a sample sequence
to useigt_interactive_debug?
You need to enable it with --interactive-debug=all The help text for that functions even explains that ...
Cheers, Daniel
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v3 1/1 i-g-t: Adding test case to test background color.
In reply to Chandra KonduruFrom: chandra konduru <[email protected]>
Adding i-g-t test case to test display crtc background color.
v2:
- Added IGT_TEST_DESCRIPTION() (Thomas Wood)
- Added to .gitignore (Thomas Wood)
- Added additional details to function header (Thomas Wood)
- Simplified igt_main (Thomas Wood)
v3:
- rebased to latest master (me)
- took sleep calls out (Daniel)
- use new tiled types when calling igt_create_fb (me)
--- lib/igt_kms.c | 61 ++++++++++++ lib/igt_kms.h | 4 + tests/.gitignore | 1 + tests/Android.mk | 1 + tests/Makefile.sources | 1 + tests/kms_crtc_background_color.c | 195 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 263 insertions(+) create mode 100644 tests/kms_crtc_background_color.c
lib/igt_kms.c +61 -0
@@ -940,6 +940,22 @@ igt_plane_set_property(igt_plane_t *plane, uint32_t prop_id, uint64_t value) DRM_MODE_OBJECT_PLANE, prop_id, value); } +static bool +get_crtc_property (int drm_fd,uint32_t crtc_id,const char *name, +uint32_t *prop_id/* out */ ,uint64_t *value/* out */ , +drmModePropertyPtr *prop/* out */ ) +{ +return kmstest_get_property (drm_fd, crtc_id,DRM_MODE_OBJECT_CRTC , + name, prop_id, value, prop); +} + +static void +igt_crtc_set_property (igt_output_t *output,uint32_t prop_id,uint64_t value) +{ +drmModeObjectSetProperty (output->display->drm_fd, + output->config.crtc->crtc_id,DRM_MODE_OBJECT_CRTC , prop_id, value); +} +/* * Walk a plane's property list to determine its type. If we don't * find a type property, then the kernel doesn't support universal
@@ -1097,6 +1113,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)igt_assert (display->outputs);for (i =0 ; i < display->n_outputs; i++) { +int j;igt_output_t *output = &display->outputs[i];/*
@@ -1108,6 +1125,19 @@ void igt_display_init(igt_display_t *display, int drm_fd) output->display = display;igt_output_refresh (output); + +for (j =0 ; j < display->n_pipes; j++) { +uint64_t prop_value; +igt_pipe_t *pipe = &display->pipes[j]; +if (output->config.crtc) { +get_crtc_property (display->drm_fd, output->config.crtc->crtc_id, +"background_color" , + &pipe->background_property, + &prop_value, +NULL ); + pipe->background = (uint32_t )prop_value; + } + } }drmModeFreePlaneResources (plane_resources);
@@ -1527,6 +1557,13 @@ static int igt_output_commit(igt_output_t *output, pipe =igt_output_get_driving_pipe (output); +if (pipe->background_changed) { +igt_crtc_set_property (output, pipe->background_property, + pipe->background); + + pipe->background_changed = false; + } +for (i =0 ; i < pipe->n_planes; i++) {igt_plane_t *plane = &pipe->planes[i];
@@ -1779,6 +1816,30 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation) plane->rotation_changed = true; } +/** +* igt_crtc_set_background: +* @pipe: pipe pointer to which background color to be set +* @background: background color value in BGR 16bpc +* +* Sets background color for requested pipe. Color value provided here +* will be actually submitted at output commit time via "background_color" +* property. +* For example to get red as background, set background = 0x00000000FFFF. +*/ +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background) +{ +igt_display_t *display = pipe->display; + +LOG (display,"%s.%d: crtc_set_background(%lu)\n" , +kmstest_pipe_name (pipe->pipe), + pipe->pipe, background); + + pipe->background = background; + + pipe->background_changed = true; +} + +void igt_wait_for_vblank (int drm_fd,enum pipe pipe) {drmVBlank wait_vbl;
lib/igt_kms.h +4 -0
@@ -207,6 +207,9 @@ struct igt_pipe {#define IGT_MAX_PLANES 4int n_planes;igt_plane_t planes[IGT_MAX_PLANES ]; +uint64_t background;/* Background color MSB BGR 16bpc LSB */ + uint32_t background_changed : 1; +uint32_t background_property; }; typedef struct {
@@ -252,6 +255,7 @@ void igt_plane_set_position(igt_plane_t *plane, int x, int y);void igt_plane_set_size (igt_plane_t *plane,int w,int h);void igt_plane_set_panning (igt_plane_t *plane,int x,int y);void igt_plane_set_rotation (igt_plane_t *plane,igt_rotation_t rotation); +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background);void igt_wait_for_vblank (int drm_fd,enum pipe pipe);
tests/.gitignore +1 -0
@@ -141,6 +141,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_crtc_background_color multi-tests.txt pm_lpsp pm_rc6_residency
tests/Android.mk +1 -0
@@ -75,6 +75,7 @@ else kms_rotation_crc \ kms_force_connector \ kms_flip_event_leak \ + kms_crtc_background_color \ kms_pwrite_crc IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0 endif
tests/Makefile.sources +1 -0
@@ -82,6 +82,7 @@ TESTS_progs_M = \ kms_setmode \ kms_universal_plane \ kms_vblank \ + kms_crtc_background_color \ pm_lpsp \ pm_rpm \ pm_rps \
tests/kms_crtc_background_color.c new file +195 -0
195 lines not on this page · raw message
Signature · 6 lines
1.9.1 _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 10 lines · Chandra Konduru
From: chandra konduru <[email protected]>
Adding i-g-t test case to test display crtc background color.
v2:
- AddedIGT_TEST_DESCRIPTION()(Thomas Wood)
- Added to .gitignore (Thomas Wood)
- Added additional details to function header (Thomas Wood)
- Simplifiedigt_main(Thomas Wood)
Quoted 4 lines
v3:
- rebased to latest master (me)
- took sleep calls out (Daniel)
- use new tiled types when callingigt_create_fb(me)
I've pushed this patch and the panel fitting and plane scaling test cases, but I have switched them all to use igt_simple_main and remove the single subtest, which I think was your intention in v2 of this patch.
Quoted 372 lines
Signed-off-by chandra konduru <[email protected]>--- lib/igt_kms.c | 61 ++++++++++++ lib/igt_kms.h | 4 + tests/.gitignore | 1 + tests/Android.mk | 1 + tests/Makefile.sources | 1 + tests/kms_crtc_background_color.c | 195 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 263 insertions(+) create mode 100644 tests/kms_crtc_background_color.clib/igt_kms.c +61
-0@@ -940,6 +940,22 @@ igt_plane_set_property(igt_plane_t *plane, uint32_t prop_id, uint64_t value) DRM_MODE_OBJECT_PLANE, prop_id, value); } +static bool +get_crtc_property (int drm_fd,uint32_t crtc_id,const char *name, +uint32_t *prop_id/* out */ ,uint64_t *value/* out */ , +drmModePropertyPtr *prop/* out */ ) +{ +return kmstest_get_property (drm_fd, crtc_id,DRM_MODE_OBJECT_CRTC , + name, prop_id, value, prop); +} + +static void +igt_crtc_set_property (igt_output_t *output,uint32_t prop_id,uint64_t value) +{ +drmModeObjectSetProperty (output->display->drm_fd, + output->config.crtc->crtc_id,DRM_MODE_OBJECT_CRTC , prop_id, value); +} +/* * Walk a plane's property list to determine its type. If we don't * find a type property, then the kernel doesn't support universal @@ -1097,6 +1113,7 @@ void igt_display_init(igt_display_t *display, int drm_fd)igt_assert (display->outputs);for (i =0 ; i < display->n_outputs; i++) { +int j;igt_output_t *output = &display->outputs[i];/* @@ -1108,6 +1125,19 @@ void igt_display_init(igt_display_t *display, int drm_fd) output->display = display;igt_output_refresh (output); + +for (j =0 ; j < display->n_pipes; j++) { +uint64_t prop_value; +igt_pipe_t *pipe = &display->pipes[j]; +if (output->config.crtc) { +get_crtc_property (display->drm_fd, output->config.crtc->crtc_id, +"background_color" , + &pipe->background_property, + &prop_value, +NULL ); + pipe->background = (uint32_t )prop_value; + } + } }drmModeFreePlaneResources (plane_resources);@@ -1527,6 +1557,13 @@ static int igt_output_commit(igt_output_t *output, pipe =igt_output_get_driving_pipe (output); +if (pipe->background_changed) { +igt_crtc_set_property (output, pipe->background_property, + pipe->background); + + pipe->background_changed = false; + } +for (i =0 ; i < pipe->n_planes; i++) {igt_plane_t *plane = &pipe->planes[i];@@ -1779,6 +1816,30 @@ void igt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation) plane->rotation_changed = true; } +/** +* igt_crtc_set_background: +* @pipe: pipe pointer to which background color to be set +* @background: background color value in BGR 16bpc +* +* Sets background color for requested pipe. Color value provided here +* will be actually submitted at output commit time via "background_color" +* property. +* For example to get red as background, set background = 0x00000000FFFF. +*/ +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background) +{ +igt_display_t *display = pipe->display; + +LOG (display,"%s.%d: crtc_set_background(%lu)\n" , +kmstest_pipe_name (pipe->pipe), + pipe->pipe, background); + + pipe->background = background; + + pipe->background_changed = true; +} + +void igt_wait_for_vblank (int drm_fd,enum pipe pipe) {drmVBlank wait_vbl;lib/igt_kms.h +4
-0@@ -207,6 +207,9 @@ struct igt_pipe {#define IGT_MAX_PLANES 4int n_planes;igt_plane_t planes[IGT_MAX_PLANES ]; +uint64_t background;/* Background color MSB BGR 16bpc LSB */ + uint32_t background_changed : 1; +uint32_t background_property; }; typedef struct {@@ -252,6 +255,7 @@ void igt_plane_set_position(igt_plane_t *plane, int x, int y);void igt_plane_set_size (igt_plane_t *plane,int w,int h);void igt_plane_set_panning (igt_plane_t *plane,int x,int y);void igt_plane_set_rotation (igt_plane_t *plane,igt_rotation_t rotation); +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background);void igt_wait_for_vblank (int drm_fd,enum pipe pipe);tests/.gitignore +1
-0@@ -141,6 +141,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_crtc_background_color multi-tests.txt pm_lpsp pm_rc6_residencytests/Android.mk +1
-0@@ -75,6 +75,7 @@ else kms_rotation_crc \ kms_force_connector \ kms_flip_event_leak \ + kms_crtc_background_color \ kms_pwrite_crc IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0 endiftests/Makefile.sources +1
-0@@ -82,6 +82,7 @@ TESTS_progs_M = \ kms_setmode \ kms_universal_plane \ kms_vblank \ + kms_crtc_background_color \ pm_lpsp \ pm_rpm \ pm_rps \tests/kms_crtc_background_color.c new file +195
-1@@ -0,0 +1,195 @@ +/* +* Copyright © 2013,2014 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person obtaining a +* copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation +* the rights to use, copy, modify, merge, publish, distribute, sublicense, +* and/or sell copies of the Software, and to permit persons to whom the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including the next +* paragraph) shall be included in all copies or substantial portions of the +* Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL +* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#include <math.h> + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" +#include "igt_core.h" + +IGT_TEST_DESCRIPTION ("Test crtc background color feature" ); + +typedef struct { +int gfx_fd; +igt_display_t display; +struct igt_fb fb; +igt_crc_t ref_crc; +igt_pipe_crc_t *pipe_crc; +}data_t ; + +#define BLACK 0x000000/* BGR 8bpc */ +#define CYAN 0xFFFF00/* BGR 8bpc */ +#define PURPLE 0xFF00FF/* BGR 8bpc */ +#define WHITE 0xFFFFFF/* BGR 8bpc */ + +#define BLACK64 0x000000000000/* BGR 16bpc */ +#define CYAN64 0xFFFFFFFF0000/* BGR 16bpc */ +#define PURPLE64 0xFFFF0000FFFF/* BGR 16bpc */ +#define YELLOW64 0x0000FFFFFFFF/* BGR 16bpc */ +#define WHITE64 0xFFFFFFFFFFFF/* BGR 16bpc */ +#define RED64 0x00000000FFFF/* BGR 16bpc */ +#define GREEN64 0x0000FFFF0000/* BGR 16bpc */ +#define BLUE64 0xFFFF00000000/* BGR 16bpc */ + +static void +paint_background (data_t *data,struct igt_fb *fb,drmModeModeInfo *mode, +uint32_t background,double alpha) +{ +cairo_t *cr; +int w, h; +double r, g, b; + + w = mode->hdisplay; + h = mode->vdisplay; + + cr =igt_get_cairo_ctx (data->gfx_fd, &data->fb); + +/* Paint with background color */ + r = (double ) (background &0xFF ) /255.0 ; + g = (double ) ((background &0xFF00 ) >>8 ) /255.0 ; + b = (double ) ((background &0xFF0000 ) >>16 ) /255.0 ; +igt_paint_color_alpha (cr,0 ,0 , w, h, r, g, b, alpha); + +cairo_destroy (cr); +} + +static void prepare_crtc (data_t *data,igt_output_t *output,enum pipe pipe, +igt_plane_t *plane,int opaque_buffer,int plane_color, +uint64_t pipe_background_color) +{ +drmModeModeInfo *mode; +igt_display_t *display = &data->display; +int fb_id; +double alpha; + +igt_output_set_pipe (output, pipe); + +/* create the pipe_crc object for this pipe */ +igt_pipe_crc_free (data->pipe_crc); + data->pipe_crc =igt_pipe_crc_new (pipe,INTEL_PIPE_CRC_SOURCE_AUTO ); + + mode =igt_output_get_mode (output); + + fb_id =igt_create_fb (data->gfx_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , +LOCAL_DRM_FORMAT_MOD_NONE ,/* tiled */ + &data->fb); +igt_assert (fb_id); + +/* To make FB pixel win with background color, set alpha as full opaque */ +igt_crtc_set_background (plane->pipe, pipe_background_color); +if (opaque_buffer) + alpha =1.0 ;/* alpha 1 is fully opque */ +else + alpha =0.0 ;/* alpha 0 is fully transparent */ +paint_background (data, &data->fb, mode, plane_color, alpha); + +igt_plane_set_fb (plane, &data->fb); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); +} + +static void cleanup_crtc (data_t *data,igt_output_t *output,igt_plane_t *plane) +{ +igt_display_t *display = &data->display; + +igt_pipe_crc_free (data->pipe_crc); + data->pipe_crc =NULL ; + +igt_remove_fb (data->gfx_fd, &data->fb); + +igt_crtc_set_background (plane->pipe,BLACK64 ); +igt_plane_set_fb (plane,NULL ); +igt_output_set_pipe (output,PIPE_ANY ); + +igt_display_commit2 (display,COMMIT_UNIVERSAL ); +} + +static void test_crtc_background (data_t *data) +{ +igt_display_t *display = &data->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; + +igt_require (data->display.has_universal_planes); + +for_each_connected_output (display, output) { +igt_plane_t *plane; + + pipe = output->config.pipe; +igt_output_set_pipe (output, pipe); + + plane =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +igt_require (plane->pipe->background_property); + +prepare_crtc (data, output, pipe, plane,1 ,PURPLE ,BLACK64 ); + +/* Now set background without using a plane, i.e., +* Disable the plane to let hw background color win blend. */ +igt_plane_set_fb (plane,NULL ); +igt_crtc_set_background (plane->pipe,PURPLE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* Try few other background colors */ +igt_crtc_set_background (plane->pipe,CYAN64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,YELLOW64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,RED64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,GREEN64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,BLUE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,WHITE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + + valid_tests++; +cleanup_crtc (data, output, plane); + } +igt_require_f (valid_tests,"no valid crtc/connector combinations found\n" ); +} + +igt_main +{ +data_t data = {}; + +igt_skip_on_simulation (); + + data.gfx_fd =drm_open_any (); +igt_require_pipe_crc (); +igt_display_init (&data.display, data.gfx_fd); + + igt_subtest("pipe-background") +test_crtc_background (&data); + +igt_display_fini (&data.display); +} --
Quoted 1 line
1.9.1
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 22 lines
-----Original Message-----
From: Thomas Wood [mailto:[email protected]]
Sent: Tuesday, April 14, 2015 10:02 AM
To: Konduru, Chandra
Cc: Intel Graphics Development
Subject: Re: [Intel-gfx] [PATCH v3] i-g-t: Adding test case to test background color.Quoted 10 lines · Chandra Konduru
From: chandra konduru <[email protected]>
Adding i-g-t test case to test display crtc background color.
v2:
- AddedIGT_TEST_DESCRIPTION()(Thomas Wood)
- Added to .gitignore (Thomas Wood)
- Added additional details to function header (Thomas Wood)
- Simplifiedigt_main(Thomas Wood)
Quoted 8 lines
Quoted 4 lines
v3:
- rebased to latest master (me)
- took sleep calls out (Daniel)
- use new tiled types when callingigt_create_fb(me)I've pushed this patch and the panel fitting and plane scaling test cases, but I have switched them all to use
igt_simple_mainand remove the single subtest, which I think was your intention in v2 of this patch.
That should be ok.
Thanks for merging.
Quoted 383 lines
lib/igt_kms.c igt_plane_set_property(igt_plane_t *plane, uint32_t
Quoted 20 lines
Signed-off-by chandra konduru <[email protected]>--- lib/igt_kms.c | 61 ++++++++++++ lib/igt_kms.h | 4 + tests/.gitignore | 1 + tests/Android.mk | 1 + tests/Makefile.sources | 1 + tests/kms_crtc_background_color.c | 195 ++++++++++++++++++++++++++++++++++++++ 6 files changed, 263 insertions(+) create mode 100644 tests/kms_crtc_background_color.clib/igt_kms.c index 9c131f0..9c46e18 renamed from lib/igt_kms.c +0
-0100644
lib/igt_kms.c +0
-0@@ -940,6 +940,22 @@ igt_plane_set_property(igt_plane_t *plane, uint32_t
prop_id,uint64_tvalue)lib/igt_kms.c igt_plane_set_property(igt_plane_t *plane, uint32_t prop_id, uint64_t value)
Quoted 8 lines
lib/igt_kms.c +5
-0DRM_MODE_OBJECT_PLANE , prop_id, value); } +static bool +get_crtc_property (int drm_fd,uint32_t crtc_id,const char *name, +uint32_t *prop_id/* out */ ,uint64_t *value/* out */ , +drmModePropertyPtr *prop/* out */ ) { + return kmstest_get_property(drm_fd, crtc_id,
DRM_MODE_OBJECT_CRTC,lib/igt_kms.c void igt_display_init(igt_display_t *display, int
Quoted 21 lines
lib/igt_kms.c +10
-1+ name, prop_id, value, prop); } + +static void +igt_crtc_set_property (igt_output_t *output,uint32_t prop_id, +uint64_t value) { +drmModeObjectSetProperty (output->display->drm_fd, + output->config.crtc->crtc_id,DRM_MODE_OBJECT_CRTC , +prop_id, value); } +/* * Walk a plane's property list to determine its type. If we don't * find a type property, then the kernel doesn't support universal @@ -1097,6 +1113,7 @@ void igt_display_init(igt_display_t *display, int drm_fd) igt_assert(display->outputs); for (i = 0; i < display->n_outputs; i++) { +int j; igt_output_t *output = &display->outputs[i]; /* @@ -1108,6 +1125,19 @@ void igt_display_init(igt_display_t *display, int
drm_fd)lib/igt_kms.c void igt_plane_set_rotation(igt_plane_t *plane,
Quoted 36 lines
lib/igt_kms.c +13
-0output->display = display;igt_output_refresh (output); + +for (j =0 ; j < display->n_pipes; j++) { +uint64_t prop_value; +igt_pipe_t *pipe = &display->pipes[j]; +if (output->config.crtc) { +get_crtc_property (display->drm_fd, output->config.crtc- crtc_id, +"background_color" , + &pipe->background_property, + &prop_value, +NULL ); + pipe->background = (uint32_t )prop_value; + } + } }drmModeFreePlaneResources(plane_resources);lib/igt_kms.c +7
-0@@ -1527,6 +1557,13 @@ static int igt_output_commit(igt_output_t *output, pipe =igt_output_get_driving_pipe (output); +if (pipe->background_changed) { +igt_crtc_set_property (output, pipe->background_property, + pipe->background); + + pipe->background_changed = false; + } +for (i =0 ; i < pipe->n_planes; i++) {igt_plane_t *plane = &pipe->planes[i];@@ -1779,6 +1816,30 @@ void igt_plane_set_rotation(igt_plane_t *plane,
igt_rotation_trotation)Quoted 108 lines
lib/igt_kms.c +23
-0plane->rotation_changed = true; } +/** +* igt_crtc_set_background: +* @pipe: pipe pointer to which background color to be set +* @background: background color value in BGR 16bpc +* +* Sets background color for requested pipe. Color value provided +here +* will be actually submitted at output commit time via "background_color" +* property. +* For example to get red as background, set background = 0x00000000FFFF. +*/ +void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background) { +igt_display_t *display = pipe->display; + +LOG (display,"%s.%d: crtc_set_background(%lu)\n" , +kmstest_pipe_name (pipe->pipe), + pipe->pipe, background); + + pipe->background = background; + + pipe->background_changed = true; } + +void igt_wait_for_vblank (int drm_fd,enum pipe pipe) {drmVBlank wait_vbl;lib/igt_kms.h index 565df14..84e8456 renamed from lib/igt_kms.h +0
-0100644
lib/igt_kms.h +3
-0@@ -207,6 +207,9 @@ struct igt_pipe {#define IGT_MAX_PLANES 4int n_planes;igt_plane_t planes[IGT_MAX_PLANES ]; +uint64_t background;/* Background color MSB BGR 16bpc LSB */ + uint32_t background_changed : 1; +uint32_t background_property; }; typedef struct {@@ -252,6 +255,7 @@ void igt_plane_set_position(igt_plane_t *plane,int x, int y); void
igt_plane_set_size(igt_plane_t *plane, int w, int h); voidigt_plane_set_panning(igt_plane_t *plane, int x, int y); voidigt_plane_set_rotation(igt_plane_t *plane, igt_rotation_t rotation);lib/igt_kms.h +1
-0+void igt_crtc_set_background (igt_pipe_t *pipe,uint64_t background);void igt_wait_for_vblank (int drm_fd,enum pipe pipe);tests/.gitignore index renamed from tests/.gitignore +0
-0402e062..0f08ce0 100644
tests/.gitignore +1
-0@@ -141,6 +141,7 @@ kms_setmode kms_sink_crc_basic kms_universal_plane kms_vblank +kms_crtc_background_color multi-tests.txt pm_lpsp pm_rc6_residencytests/Android.mk index renamed from tests/Android.mk +0
-0814b846..96a32b9 100644
tests/Android.mk +1
-0@@ -75,6 +75,7 @@ else kms_rotation_crc \ kms_force_connector \ kms_flip_event_leak \ + kms_crtc_background_color \ kms_pwrite_crc IGT_LOCAL_CFLAGS += -DANDROID_HAS_CAIRO=0 endif diff --gita/tests/Makefile.sources b/tests/Makefile.sources index a165978..5235b5f 100644
tests/Makefile.sources +1
-0@@ -82,6 +82,7 @@ TESTS_progs_M = \ kms_setmode \ kms_universal_plane \ kms_vblank \ + kms_crtc_background_color \ pm_lpsp \ pm_rpm \ pm_rps \tests/kms_crtc_background_color.c new file +16
-0@@ -0,0 +1,195 @@ +/* +* Copyright © 2013,2014 Intel Corporation +* +* Permission is hereby granted, free of charge, to any person +obtaining a +* copy of this software and associated documentation files (the +"Software"), +* to deal in the Software without restriction, including without +limitation +* the rights to use, copy, modify, merge, publish, distribute, +sublicense, +* and/or sell copies of the Software, and to permit persons to whom +the +* Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice (including tests/kms_crtc_background_color.c line 26
Quoted 10 lines
tests/kms_crtc_background_color.c new file +10
-0+the next + * paragraph) shall be included in all copies or substantial portions +of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, +EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF +MERCHANTABILITY , + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NOEVENT
tests/kms_crtc_background_color.c line 28
Quoted 2 lines
tests/kms_crtc_background_color.c new file +2
-0+SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,DAMAGES
Quoted 32 lines
tests/kms_crtc_background_color.c new file +32
-0+OR OTHER +* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, +ARISING +* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR +OTHER DEALINGS +* IN THE SOFTWARE. +* +*/ + +#include <math.h> + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" +#include "igt_core.h" + +IGT_TEST_DESCRIPTION ("Test crtc background color feature" ); + +typedef struct { +int gfx_fd; +igt_display_t display; +struct igt_fb fb; +igt_crc_t ref_crc; +igt_pipe_crc_t *pipe_crc; +}data_t ; + +#define BLACK 0x000000/* BGR 8bpc */ +#define CYAN 0xFFFF00/* BGR 8bpc */ +#define PURPLE 0xFF00FF/* BGR 8bpc */ +#define WHITE 0xFFFFFF/* BGR 8bpc */ + +#define BLACK64 0x000000000000/* BGR 16bpc */ tests/kms_crtc_background_color.c
Quoted 10 lines
tests/kms_crtc_background_color.c new file +10
-0+#define CYAN64 0xFFFFFFFF0000/* BGR 16bpc */ +#define PURPLE64 0xFFFF0000FFFF/* BGR 16bpc */ +#define YELLOW64 0x0000FFFFFFFF/* BGR 16bpc */ +#define WHITE64 0xFFFFFFFFFFFF/* BGR 16bpc */ +#define RED64 0x00000000FFFF/* BGR 16bpc */ +#define GREEN64 0x0000FFFF0000/* BGR 16bpc */ +#define BLUE64 0xFFFF00000000/* BGR 16bpc */ + +static void +paint_background(data_t *data, struct igt_fb *fb, drmModeModeInfo*mode,
Quoted 34 lines
tests/kms_crtc_background_color.c new file +34
-0+ uint32_t background, double alpha) { +cairo_t *cr; +int w, h; +double r, g, b; + + w = mode->hdisplay; + h = mode->vdisplay; + + cr =igt_get_cairo_ctx (data->gfx_fd, &data->fb); + +/* Paint with background color */ + r = (double ) (background &0xFF ) /255.0 ; + g = (double ) ((background &0xFF00 ) >>8 ) /255.0 ; + b = (double ) ((background &0xFF0000 ) >>16 ) /255.0 ; +igt_paint_color_alpha (cr,0 ,0 , w, h, r, g, b, alpha); + +cairo_destroy (cr); +} + +static void prepare_crtc (data_t *data,igt_output_t *output,enum pipe pipe, +igt_plane_t *plane,int opaque_buffer,int plane_color, +uint64_t pipe_background_color) { +drmModeModeInfo *mode; +igt_display_t *display = &data->display; +int fb_id; +double alpha; + +igt_output_set_pipe (output, pipe); + +/* create the pipe_crc object for this pipe */ +igt_pipe_crc_free (data->pipe_crc); + data->pipe_crc =igt_pipe_crc_new (pipe, +INTEL_PIPE_CRC_SOURCE_AUTO ); +tests/kms_crtc_background_color.c
Quoted 10 lines
tests/kms_crtc_background_color.c new file +10
-0+ mode =igt_output_get_mode (output); + + fb_id =igt_create_fb (data->gfx_fd, + mode->hdisplay, mode->vdisplay, +DRM_FORMAT_XRGB8888 , +LOCAL_DRM_FORMAT_MOD_NONE ,/* tiled */ + &data->fb); +igt_assert (fb_id); + +/* To make FB pixel win with background color, set alpha as full opaque */
Quoted 84 lines
tests/kms_crtc_background_color.c new file +84
-0+igt_crtc_set_background (plane->pipe, pipe_background_color); +if (opaque_buffer) + alpha =1.0 ;/* alpha 1 is fully opque */ +else + alpha =0.0 ;/* alpha 0 is fully transparent */ +paint_background (data, &data->fb, mode, plane_color, alpha); + +igt_plane_set_fb (plane, &data->fb); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); } + +static void cleanup_crtc (data_t *data,igt_output_t *output, +igt_plane_t *plane) { +igt_display_t *display = &data->display; + +igt_pipe_crc_free (data->pipe_crc); + data->pipe_crc =NULL ; + +igt_remove_fb (data->gfx_fd, &data->fb); + +igt_crtc_set_background (plane->pipe,BLACK64 ); +igt_plane_set_fb (plane,NULL ); +igt_output_set_pipe (output,PIPE_ANY ); + +igt_display_commit2 (display,COMMIT_UNIVERSAL ); } + +static void test_crtc_background (data_t *data) { +igt_display_t *display = &data->display; +igt_output_t *output; +enum pipe pipe; +int valid_tests =0 ; + +igt_require (data->display.has_universal_planes); + +for_each_connected_output (display, output) { +igt_plane_t *plane; + + pipe = output->config.pipe; +igt_output_set_pipe (output, pipe); + + plane =igt_output_get_plane (output,IGT_PLANE_PRIMARY ); +igt_require (plane->pipe->background_property); + +prepare_crtc (data, output, pipe, plane,1 ,PURPLE , +BLACK64 ); + +/* Now set background without using a plane, i.e., +* Disable the plane to let hw background color win blend. */ +igt_plane_set_fb (plane,NULL ); +igt_crtc_set_background (plane->pipe,PURPLE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +/* Try few other background colors */ +igt_crtc_set_background (plane->pipe,CYAN64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,YELLOW64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,RED64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,GREEN64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,BLUE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + +igt_crtc_set_background (plane->pipe,WHITE64 ); +igt_display_commit2 (display,COMMIT_UNIVERSAL ); + + valid_tests++; +cleanup_crtc (data, output, plane); + } + igt_require_f(valid_tests, "no valid crtc/connector +combinations found\n"); } + +igt_main +{ + data_t data = {}; + + igt_skip_on_simulation(); + + data.gfx_fd =drm_open_any (); +igt_require_pipe_crc ();
Quoted 8 lines
Quoted 8 lines
tests/kms_crtc_background_color.c new file +6
-1+igt_display_init (&data.display, data.gfx_fd); + + igt_subtest("pipe-background") +test_crtc_background (&data); + +igt_display_fini (&data.display); } --1.9.1
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx