From: sagar.a.kamble@intel.com Subject: [PATCH v1 1/1] kms_plane_props: Test to verify drm properties for planes Date: Mon, 5 May 2014 23:44:56 +0530 Message-ID: <1399313696-31695-1-git-send-email-sagar.a.kamble@intel.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="===============1145445979==" Return-path: Received: from mga03.intel.com (mga03.intel.com [143.182.124.21]) by gabe.freedesktop.org (Postfix) with ESMTP id 25B796E987 for ; Mon, 5 May 2014 11:13:54 -0700 (PDT) List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" To: intel-gfx@lists.freedesktop.org Cc: "Sharma, Ankitprasad R" , daniel.vetter@ffwll.ch, shashidhar.hiremath@intel.com, vandita.kulkarni@intel.com, Sagar Kamble List-Id: intel-gfx@lists.freedesktop.org --===============1145445979== Content-Type: text/plain; charset=y Content-Transfer-Encoding: quoted-printable From: Sagar Kamble This test will set various values for drm properties exposed by planes and check for functional accuracy in some cases using CRC check. Currently this test is enabled for "const-alpha" drm property. Cc: daniel.vetter@ffwll.ch Cc: jani.nikula@linux.intel.com Cc: ville.syrjala@linux.intel.com Cc: indranil.mukherjee@intel.com Cc: shashidhar.hiremath@intel.com Cc: vandita.kulkarni@intel.com Cc: vijay.a.purushothaman@intel.com Signed-off-by: Sagar Kamble Signed-off-by: Sharma, Ankitprasad R --- tests/Makefile.sources | 1 + tests/kms_plane_props.c | 266 ++++++++++++++++++++++++++++++++++++++++++= ++++++ 2 files changed, 267 insertions(+) create mode 100644 tests/kms_plane_props.c diff --git a/tests/Makefile.sources b/tests/Makefile.sources index a8a091d..b0be0f4 100644 --- a/tests/Makefile.sources +++ b/tests/Makefile.sources @@ -63,6 +63,7 @@ TESTS_progs_M =3D \ kms_flip_tiling \ kms_pipe_crc_basic \ kms_plane \ + kms_plane_props \ kms_render \ kms_setmode \ pm_lpsp \ diff --git a/tests/kms_plane_props.c b/tests/kms_plane_props.c new file mode 100644 index 0000000..7cbc815 --- /dev/null +++ b/tests/kms_plane_props.c @@ -0,0 +1,266 @@ +/* + * Copyright =C2=A9 2014 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining= a + * copy of this software and associated documentation files (the "Softwa= re"), + * to deal in the Software without restriction, including without limita= tion + * the rights to use, copy, modify, merge, publish, distribute, sublicen= se, + * 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, EXPRE= SS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILI= TY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SH= ALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR = OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISI= NG + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER D= EALINGS + * IN THE SOFTWARE. + * + * Authors: + * Kamble, Sagar A + * Sharma, Ankitprasad R + */ + +#include +#include +#include +#include + +#include "drmtest.h" +#include "igt_debugfs.h" +#include "igt_kms.h" + +typedef struct { + int drm_fd; + igt_display_t display; +} data_t; + +/* + * Plane drm properties test + * Constant alpha test. + * - We start by grabbing a reference CRC of a full black fb being sca= nned + * out on the primary plane + * - Then we scannout sprite plane with full white fb and capture corr= esponding + * reference CRC. + * - Then we set constant alpha property of sprite plane with value fr= om + * 0 to 255 in increments of 5. + * - The resulting CRC when alpha is set to 0 should be identical to t= he reference CRC + * captured when only primary plane is set. + * - The resulting CRC when alpha is set to 255 should be identical to= the reference CRC + * captured when both primary and sprite plane are set. + */ + +typedef struct { + data_t *data; + igt_pipe_crc_t *pipe_crc; + igt_crc_t reference_crc[2]; +} test_plane_props_t; + +/* + * create a fb for primary plane + */ +static void +create_fb_for_primary(data_t *data, drmModeModeInfo *mode, + struct igt_fb *fb /* out */) +{ + unsigned int fb_id; + cairo_t *cr; + + fb_id =3D igt_create_fb(data->drm_fd, + mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + false /* tiling */, + fb); + igt_assert(fb_id); + + cr =3D igt_get_cairo_ctx(data->drm_fd, fb); + igt_paint_color(cr, 0, 0, mode->hdisplay, mode->vdisplay, + 0.0, 0.0, 0.0); + igt_assert(cairo_status(cr) =3D=3D 0); + cairo_destroy(cr); +} + +static void +test_plane_props_init(test_plane_props_t *test, igt_output_t *output, en= um pipe pipe) +{ + data_t *data =3D test->data; + struct igt_fb fb; + drmModeModeInfo *mode; + igt_plane_t *primary; + + test->pipe_crc =3D igt_pipe_crc_new(pipe, INTEL_PIPE_CRC_SOURCE_AUTO); + + igt_output_set_pipe(output, pipe); + primary =3D igt_output_get_plane(output, 0); + + mode =3D igt_output_get_mode(output); + igt_create_color_fb(data->drm_fd, mode->hdisplay, mode->vdisplay, + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 0.0, 0.0, 0.0, + &fb); + igt_plane_set_fb(primary, &fb); + + igt_display_commit(&data->display); + + sleep(2); + igt_pipe_crc_collect_crc(test->pipe_crc, &test->reference_crc[0]); + sleep(2); + + igt_plane_set_fb(primary, NULL); + igt_display_commit(&data->display); + + igt_remove_fb(data->drm_fd, &fb); +} + +static void +test_plane_props_fini(test_plane_props_t *test, igt_output_t *output) +{ + igt_pipe_crc_free(test->pipe_crc); + + igt_output_set_pipe(output, PIPE_ANY); + igt_display_commit(&test->data->display); +} + +static int set_plane_property(test_plane_props_t *test, igt_plane_t *spr= ite, char *prop_name, int val, igt_crc_t *crc_output) +{ + int i =3D 0, ret =3D 0, drm_fd =3D test->data->drm_fd, plane_id =3D spr= ite->drm_plane->plane_id; + uint64_t value; + drmModeObjectPropertiesPtr props =3D NULL; + + value =3D (uint64_t)val; + props =3D drmModeObjectGetProperties(drm_fd, plane_id, DRM_MODE_OBJECT_= PLANE); + + for (i =3D 0; i < props->count_props; i++) + { + drmModePropertyPtr prop =3D drmModeGetProperty(drm_fd, props->props[i]= ); + fprintf(stdout, "\nProp->name=3D%s ", prop->name); + + if (strcmp(prop->name, prop_name) =3D=3D 0) + { + ret =3D drmModeObjectSetProperty(drm_fd, plane_id, DRM_MODE_OBJECT_PL= ANE, + (uint32_t)prop->prop_id, value); + if (ret) + { + fprintf(stdout, "set_property \"%s\" to %d for plane %d is failed\n"= , prop_name, val, plane_id); + return ret; + } + else { + fprintf(stdout, "set_property \"%s\" to %d for plane %d is successfu= l\n", prop_name, val, plane_id); + sleep(2); + igt_pipe_crc_collect_crc(test->pipe_crc, crc_output); + sleep(2); + } + } + drmModeFreeProperty(prop); + } + drmModeFreeObjectProperties(props); + return 0; +} + +static void +test_plane_const_alpha_prop_with_output(data_t *data, + enum pipe pipe, + enum igt_plane plane, + igt_output_t *output) +{ + test_plane_props_t test =3D { .data =3D data }; + igt_plane_t *primary, *sprite; + struct igt_fb primary_fb, sprite_fb; + drmModeModeInfo *mode; + igt_crc_t crc_output; + int i =3D 0; + char prop_name[20] =3D "const-alpha"; + + fprintf(stdout, "Testing connector %s using pipe %c plane %d\n", + igt_output_name(output), pipe_name(pipe), plane); + + test_plane_props_init(&test, output, pipe); + + mode =3D igt_output_get_mode(output); + primary =3D igt_output_get_plane(output, 0); + sprite =3D igt_output_get_plane(output, plane); + + create_fb_for_primary(data, mode, &primary_fb); + igt_plane_set_fb(primary, &primary_fb); + + igt_create_color_fb(data->drm_fd, + mode->hdisplay / 2, mode->vdisplay / 2, /* width, height */ + DRM_FORMAT_XRGB8888, + false, /* tiled */ + 1.0, 1.0, 1.0, + &sprite_fb); + igt_plane_set_fb(sprite, &sprite_fb); + + igt_plane_set_position(sprite, mode->hdisplay / 4, mode->vdisplay / 4); + + igt_display_commit(&data->display); + + sleep(2); + igt_pipe_crc_collect_crc(test.pipe_crc, &test.reference_crc[1]); + sleep(2); + + for (i=3D0; i<256; i+=3D5) { + if (set_plane_property(&test, sprite, prop_name, i, &crc_output)) + return; + if (i =3D=3D 0) + igt_assert(igt_crc_equal(&test.reference_crc[0], &crc_output)); + else if (i =3D=3D 255) + igt_assert(igt_crc_equal(&test.reference_crc[1], &crc_output)); + } + + igt_plane_set_fb(primary, NULL); + igt_plane_set_fb(sprite, NULL); + + test_plane_props_fini(&test, output); +} + +static void +test_plane_props(data_t *data, enum pipe pipe, enum igt_plane plane) +{ + igt_output_t *output; + + igt_skip_on(pipe >=3D data->display.n_pipes); + igt_skip_on(plane >=3D data->display.pipes[pipe].n_planes); + + for_each_connected_output(&data->display, output) + test_plane_const_alpha_prop_with_output(data, pipe, plane, output); +} + +static void +run_tests_for_pipe(data_t *data, enum pipe pipe) +{ + int plane; + + for (plane =3D 1; plane < IGT_MAX_PLANES; plane++) + test_plane_props(data, pipe, plane); +} + +static data_t data; + +igt_main +{ + + igt_skip_on_simulation(); + + igt_fixture { + data.drm_fd =3D drm_open_any(); + + igt_set_vt_graphics_mode(); + + igt_require_pipe_crc(); + igt_display_init(&data.display, data.drm_fd); + } + + for (int pipe =3D 0; pipe < 3; pipe++) + run_tests_for_pipe(&data, pipe); + + igt_fixture { + igt_display_fini(&data.display); + } +} + --=20 1.8.5 --===============1145445979== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ Intel-gfx mailing list Intel-gfx@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/intel-gfx --===============1145445979==--