From patchwork Wed Jan 24 12:51:00 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ankit Nautiyal X-Patchwork-Id: 10182471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 6EF16602B7 for ; Wed, 24 Jan 2018 12:55:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 62A4C288D1 for ; Wed, 24 Jan 2018 12:55:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 565E2288D4; Wed, 24 Jan 2018 12:55:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D7C5C288D1 for ; Wed, 24 Jan 2018 12:55:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 46DAB6E5DA; Wed, 24 Jan 2018 12:55:13 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by gabe.freedesktop.org (Postfix) with ESMTPS id CC9D189951; Wed, 24 Jan 2018 12:55:11 +0000 (UTC) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 24 Jan 2018 04:55:11 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,407,1511856000"; d="scan'208";a="198408659" Received: from ankit-desktop.iind.intel.com ([10.223.161.14]) by fmsmga006.fm.intel.com with ESMTP; 24 Jan 2018 04:55:09 -0800 From: "Nautiyal, Ankit K" To: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org Date: Wed, 24 Jan 2018 18:21:00 +0530 Message-Id: <1516798260-11685-3-git-send-email-ankit.k.nautiyal@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1516798260-11685-1-git-send-email-ankit.k.nautiyal@intel.com> References: <1516798260-11685-1-git-send-email-ankit.k.nautiyal@intel.com> Subject: [Intel-gfx] [igt-dev] [PATCH i-g-t 2/2] tests/testdisplay.c: add support to test modes with aspect ratio X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ankit Nautiyal MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Ankit Nautiyal This patch adds the support to test the modes with aspect ratios. If the kernel supports the aspect ratio capabilities, the modes with aspect ratios are set one by one. This test is a means to verify the drm patch series :Aspect ratio support in DRM : https://patchwork.freedesktop.org/series/33984/ Signed-off-by: Ankit Nautiyal --- tests/testdisplay.c | 104 ++++++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 100 insertions(+), 4 deletions(-) diff --git a/tests/testdisplay.c b/tests/testdisplay.c index b0156c5..910e395 100644 --- a/tests/testdisplay.c +++ b/tests/testdisplay.c @@ -73,13 +73,22 @@ #define Yb_OPT 3 #define Yf_OPT 4 +#ifndef DRM_CLIENT_CAP_ASPECT_RATIO +/** + * Taken from drm-uapi/drm.h + * DRM_CLIENT_CAP_ASPECT_RATIO + * + * If set to 1, the DRM core will expose aspect ratio to userspace + */ +#define DRM_CLIENT_CAP_ASPECT_RATIO 4 +#endif static int tio_fd; struct termios saved_tio; drmModeRes *resources; int drm_fd, modes; int test_all_modes = 0, test_preferred_mode = 0, force_mode = 0, test_plane, - test_stereo_modes; +test_stereo_modes, test_aspect_ratio_modes = 0; uint64_t tiling = LOCAL_DRM_FORMAT_MOD_NONE; int sleep_between_modes = 5; int do_dpms = 0; /* This aliases to DPMS_ON */ @@ -443,6 +452,62 @@ set_stereo_mode(struct connector *c) drmModeFreeConnector(c->connector); } +static void +set_aspect_ratio_mode(struct connector *c) +{ + int i, n; + uint32_t fb_id; + struct igt_fb fb_info = { }; + + + if (specified_mode_num != -1) + n = 1; + else + n = c->connector->count_modes; + + for (i = 0; i < n; i++) { + if (specified_mode_num == -1) + c->mode = c->connector->modes[i]; + + if (!c->mode_valid) + continue; + + if (!(c->mode.flags & DRM_MODE_FLAG_PIC_AR_MASK)) + continue; + + igt_info("CRTC(%u): [%d]", c->crtc, i); + kmstest_dump_mode(&c->mode); + width = c->mode.hdisplay; + height = c->mode.vdisplay; + + fb_id = igt_create_pattern_fb(drm_fd, width, height, + igt_bpp_depth_to_drm_format(bpp, depth), + tiling, &fb_info); + paint_output_info(c, &fb_info); + paint_color_key(&fb_info); + + kmstest_dump_mode(&c->mode); + igt_warn_on_f(drmModeSetCrtc(drm_fd, c->crtc, fb_id, 0, 0, &c->id, 1, &c->mode), + "failed to set mode (%dx%d@%dHz): %s\n", width, height, c->mode.vrefresh, strerror(errno)); + if (qr_code) { + set_single(); + pause(); + } else if (sleep_between_modes) + sleep(sleep_between_modes); + + if (do_dpms) { + kmstest_set_connector_dpms(drm_fd, c->connector, + DRM_MODE_DPMS_OFF); + sleep(sleep_between_modes); + kmstest_set_connector_dpms(drm_fd, c->connector, + DRM_MODE_DPMS_ON); + } + + igt_remove_fb(drm_fd, &fb_info); + } + drmModeFreeEncoder(c->encoder); + drmModeFreeConnector(c->connector); +} /* * Re-probe outputs and light up as many as possible. * @@ -517,18 +582,39 @@ int update_display(bool probe) } } + if (test_aspect_ratio_modes) { + for (c = 0; c < resources->count_connectors; c++) { + struct connector *connector = &connectors[c]; + + connector->id = resources->connectors[c]; + if (specified_disp_id != -1 && + connector->id != specified_disp_id) + continue; + + connector_find_preferred_mode(connector->id, + -1UL, + specified_mode_num, + connector, probe); + if (!connector->mode_valid) + continue; + + set_aspect_ratio_mode(connector); + } + } + free(connectors); drmModeFreeResources(resources); return 1; } -static char optstr[] = "3hiaf:s:d:p:mrto:j:y"; +static char optstr[] = "3hziaf:s:d:p:mrto:j:y"; static void __attribute__((noreturn)) usage(char *name, char opt) { igt_info("usage: %s [-hiasdpmtf]\n", name); igt_info("\t-i\tdump info\n"); igt_info("\t-a\ttest all modes\n"); + igt_info("\t-z\ttest aspect ratio modes\n"); igt_info("\t-s\t\tsleep between each mode test\n"); igt_info("\t-d\t\tbit depth of scanout buffer\n"); igt_info("\t-p\t,, test overlay plane\n"); @@ -637,6 +723,9 @@ int main(int argc, char **argv) case '3': test_stereo_modes = 1; break; + case 'z': + test_aspect_ratio_modes = 1; + break; case 'i': opt_dump_info = true; break; @@ -716,7 +805,8 @@ int main(int argc, char **argv) bpp = 32; if (!test_all_modes && !force_mode && !test_preferred_mode && - specified_mode_num == -1 && !test_stereo_modes) + specified_mode_num == -1 && !test_stereo_modes && + !test_aspect_ratio_modes) test_all_modes = 1; drm_fd = drm_open_driver(DRIVER_ANY); @@ -727,6 +817,12 @@ int main(int argc, char **argv) goto out_close; } + if (test_aspect_ratio_modes && + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_ASPECT_RATIO, 1) < 0) { + igt_warn("DRM_CLIENT_CAP_ASPECT_RATIO failed\n"); + goto out_close; + } + if (opt_dump_info) { dump_info(); goto out_close; @@ -766,7 +862,7 @@ int main(int argc, char **argv) goto out_stdio; } - if (test_all_modes) + if (test_all_modes || test_aspect_ratio_modes) goto out_stdio; g_main_loop_run(mainloop);