From patchwork Tue Apr 30 07:37:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mario Kleiner X-Patchwork-Id: 10922955 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 155FB1395 for ; Tue, 30 Apr 2019 07:38:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 03079288C5 for ; Tue, 30 Apr 2019 07:38:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EA78C2896D; Tue, 30 Apr 2019 07:38:01 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, FREEMAIL_FROM,MAILING_LIST_MULTI,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 83626288C5 for ; Tue, 30 Apr 2019 07:38:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 11B4289487; Tue, 30 Apr 2019 07:37:59 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by gabe.freedesktop.org (Postfix) with ESMTPS id 612498946E; Tue, 30 Apr 2019 07:37:57 +0000 (UTC) Received: by mail-wm1-x341.google.com with SMTP id b10so2593185wmj.4; Tue, 30 Apr 2019 00:37:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=71xjCKqRmogdCAt+oF2fQeqyU5eEzyLG70Lr+3xnTC4=; b=R7uR1yx2V8Rfj6uciQ9zQzlT1+obuWBt1e6Wnlv5CG6oKOQNGG4gMfCrHb3dAPHTtg 4Y0VMp6rk81fUWmhlM1X9izq4lO23F8+dcfpyyK95BKe1DLbr50eBA5y3/6J97YdSqZ5 5jZ3dMMaNAMsBj3m8bEuw6ZCjwQOzmwGRlYFEvJ9UqBKHl0rGv0K49RfDVvo5vI+wLmu dixAfZchFNmPoosWLBl8YDIUfCSQde4gz5sYavR03vPp+AI1UgdEqHJlAdROUZ3LBg6i s3MtVoDW7Lu0pB1hbvlh3RZwwd8SN5RxTM0Sz4yVKKu0137oA340hG516UwUKiNPFGTo t9qQ== X-Gm-Message-State: APjAAAU6Z8fBAq9X3PaG0wLXjbrLQrm56s6KkLQIs/kK4Eb627FJF7tk ez+FtaUsBo16nVB4V1fPbV417GwX X-Google-Smtp-Source: APXvYqypk/OE6iyWgLBHy9v/2BPJv1ffUMfd9kRVyfTYaIH0QAI1eQnVPL80xKwDKl498zJ6ealwRQ== X-Received: by 2002:a1c:c004:: with SMTP id q4mr1895094wmf.131.1556609875705; Tue, 30 Apr 2019 00:37:55 -0700 (PDT) Received: from twisty.localdomain ([2a01:c22:d41f:e300:55b4:804e:196c:cde9]) by smtp.gmail.com with ESMTPSA id h123sm1908445wme.6.2019.04.30.00.37.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 30 Apr 2019 00:37:55 -0700 (PDT) From: Mario Kleiner To: amd-gfx@lists.freedesktop.org Subject: [PATCH] drm/amd/display: Allow faking displays as VRR capable. Date: Tue, 30 Apr 2019 09:37:24 +0200 Message-Id: <20190430073724.505-1-mario.kleiner.de@gmail.com> X-Mailer: git-send-email 2.17.1 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=71xjCKqRmogdCAt+oF2fQeqyU5eEzyLG70Lr+3xnTC4=; b=djbZDuCjegoxPVKOPtk7fmdTGKOeU+0ObyayOKCpnGXUPKY5O6j8FXM/EvlI8OHYfb TktVIAn6O/6Sr6MqK5Z+7XannIDosxA+U/Q1IbuCibXEzIET/ngtqdCMjoa6uk0u6MkG 4WUs7NfjtK0RgW9lpksSiyeorBSln3WpyIQQYJfLmXODrdAwVFrpUIHawqHVEzXV7VX+ iLPe3hNdhSQfenduaMtTQf/CEsVGlhTKj34OTAjaoiUx7xdgmh+5Lp/dyled/NwcyYpF 3aOhn+0Ctv10YJdtQG3g7y4Wzms4Iouxb5adlkgRTRGowx4kF7mKQ/X50PPx1QQgcz1Z 3H/A== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: nicholas.kazlauskas@amd.com, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Allow to detect any connected display to be marked as VRR capable. This is useful for testing the basics of VRR mode, e.g., scheduling and timestamping, BTR, and transition logic, on non-VRR capable displays, e.g., to perform IGT test-suit kms_vrr test runs. This fake VRR display mode is enabled by setting the optional module parameter amdgpu.fakevrrdisplay=1. It will try to use VRR range info parsed from EDID on DisplayPort displays which have a compatible EDID, but not compatible DPCD caps for Adaptive Sync. E.g., NVidia G-Sync compatible displays expose a proper EDID, but not proper DPCD caps. It will use a hard-coded VRR range of 30 Hz - 144 Hz on other displays without suitable EDID, e.g., standard DisplayPort, HDMI, DVI monitors. Signed-off-by: Mario Kleiner --- drivers/gpu/drm/amd/amdgpu/amdgpu.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 11 +++++++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 30 +++++++++++++++++++ 3 files changed, 42 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu.h b/drivers/gpu/drm/amd/amdgpu/amdgpu.h index 23c3375623d7..351af38e7fd3 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu.h +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu.h @@ -159,6 +159,7 @@ extern uint amdgpu_dc_feature_mask; extern struct amdgpu_mgpu_info mgpu_info; extern int amdgpu_ras_enable; extern uint amdgpu_ras_mask; +extern int amdgpu_fake_vrr_display; #ifdef CONFIG_DRM_AMDGPU_SI extern int amdgpu_si_support; diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 1e2cc9d68a05..3a9fc0fbc76e 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -134,6 +134,7 @@ int amdgpu_emu_mode = 0; uint amdgpu_smu_memory_pool_size = 0; /* FBC (bit 0) disabled by default*/ uint amdgpu_dc_feature_mask = 0; +int amdgpu_fake_vrr_display = 0; struct amdgpu_mgpu_info mgpu_info = { .mutex = __MUTEX_INITIALIZER(mgpu_info.mutex), @@ -665,6 +666,16 @@ MODULE_PARM_DESC(halt_if_hws_hang, "Halt if HWS hang is detected (0 = off (defau MODULE_PARM_DESC(dcfeaturemask, "all stable DC features enabled (default))"); module_param_named(dcfeaturemask, amdgpu_dc_feature_mask, uint, 0444); +/** + * DOC: fakevrrdisplay (int) + * Override detection of VRR displays to mark any display as VRR capable, even + * if it is not. Useful for basic testing of VRR without need to attach such a + * display, e.g., for igt tests. + * Setting 1 enables faking VRR. Default value, 0, does normal detection. + */ +module_param_named(fakevrrdisplay, amdgpu_fake_vrr_display, int, 0644); +MODULE_PARM_DESC(fakevrrdisplay, "Detect any display as VRR capable (0 = off (default), 1 = on)"); + static const struct pci_device_id pciidlist[] = { #ifdef CONFIG_DRM_AMDGPU_SI {0x1002, 0x6780, PCI_ANY_ID, PCI_ANY_ID, 0, 0, CHIP_TAHITI}, diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c index 1854506e3e8f..148ec5bb9fa8 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c @@ -6921,6 +6921,15 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, edid_check_required = is_dp_capable_without_timing_msa( adev->dm.dc, amdgpu_dm_connector); + + /* Force detection of not-quite adaptive sync capable + * displays as vrr capable if requested by moduleparam. + * Works, e.g., with G-Sync displays. + */ + if (!edid_check_required && amdgpu_fake_vrr_display) { + edid_check_required = true; + DRM_INFO("amdgpu.fakevrrdisplay=1 -> Force vrr.\n"); + } } } if (edid_check_required == true && (edid->version > 1 || @@ -6948,6 +6957,12 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, amdgpu_dm_connector->max_vfreq = range->max_vfreq; amdgpu_dm_connector->pixel_clock_mhz = range->pixel_clock_mhz * 10; + + DRM_DEBUG("edid vrr %d: %d - %d Hz, clock %d Mhz\n", + i, amdgpu_dm_connector->min_vfreq, + amdgpu_dm_connector->max_vfreq, + amdgpu_dm_connector->pixel_clock_mhz); + break; } @@ -6958,6 +6973,21 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector, } } + /* Fake a vrr display with hard-coded properties if none was + * detected and faking one is requested by module parameter. + */ + if (!freesync_capable && amdgpu_fake_vrr_display) { + freesync_capable = true; + amdgpu_dm_connector->min_vfreq = 30; + amdgpu_dm_connector->max_vfreq = 144; + amdgpu_dm_connector->pixel_clock_mhz = 590; + + DRM_INFO("fake vrr: %d - %d Hz, clock %d Mhz\n", + amdgpu_dm_connector->min_vfreq, + amdgpu_dm_connector->max_vfreq, + amdgpu_dm_connector->pixel_clock_mhz); + } + update: if (dm_con_state) dm_con_state->freesync_capable = freesync_capable;