From patchwork Thu Jun 13 02:16:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10991033 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 E5FAA14C0 for ; Thu, 13 Jun 2019 02:16:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CF36128A05 for ; Thu, 13 Jun 2019 02:16:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C3B5D28B1D; Thu, 13 Jun 2019 02:16:11 +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 26B9B28A05 for ; Thu, 13 Jun 2019 02:16:10 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 72FA9891AC; Thu, 13 Jun 2019 02:16:10 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-qk1-x744.google.com (mail-qk1-x744.google.com [IPv6:2607:f8b0:4864:20::744]) by gabe.freedesktop.org (Postfix) with ESMTPS id 82972891AC; Thu, 13 Jun 2019 02:16:09 +0000 (UTC) Received: by mail-qk1-x744.google.com with SMTP id t8so8059060qkt.1; Wed, 12 Jun 2019 19:16:09 -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:date:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=sM/dlpl65O3bWbkz29VE31eshzNZKqc67yXiUq+rpqo=; b=kYxpWK0TBX9w3+ZdgH23we+35C5bj6xUw1Sdnen8Iw+U3NSg5S9U5YOStx8Jgu19aS xxVmBm2VNUGSrpeq1cdFa1r2bhPqTQwfnIz5IMFfKDTWSxozTxN+cbMv0yf5J8Wh7VW7 iODxvxE3cQsy+xyrvgMX1bgLRaLlNGp+1Zb5aJgmPNzWqUTlwLj3LIDTaiSH24r+QBlq m7ew46aagBlHWRamFgt64lA0O9r3Ak+aRlPg59Ni2J+FmbBxOHn6rAVFtJ7ZdCM3jh2p xlNPiXNUI/jAZBz8jStl1hfC82PZ9cbgn+GHj02RDDtx3H59H4WKbXaMuyRIVQeu3yFs SR+Q== X-Gm-Message-State: APjAAAWGLV2SsbUZteMYJ19uQpiLA1Bk+6T64RI2sEf0WacTfZ+tufuo harCkij2Jw4IXprdSQwmkw4= X-Google-Smtp-Source: APXvYqzKyB2VA6ePeAvfu3o5BCDOY8bogihBYh6+8Skf5/930ntBRPifl9J0G5CDyofEYYB4FJvE2A== X-Received: by 2002:a05:620a:1097:: with SMTP id g23mr17145910qkk.185.1560392168556; Wed, 12 Jun 2019 19:16:08 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id k5sm705337qkc.75.2019.06.12.19.16.04 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 19:16:08 -0700 (PDT) From: Brian Starkey X-Google-Original-From: Brian Starkey Date: Wed, 12 Jun 2019 23:16:02 -0300 To: Brian Starkey , Liviu Dudau , Petri Latvala , Arkadiusz Hiler , Daniel Vetter Message-ID: <28eefeec574b63511909dace7df3b7e6f13c3ed1.1560374714.git.rodrigosiqueiramelo@gmail.com> References: MIME-Version: 1.0 In-Reply-To: User-Agent: NeoMutt/20180716 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:date:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=sM/dlpl65O3bWbkz29VE31eshzNZKqc67yXiUq+rpqo=; b=YGlULtv+wEHnhJpb+FUYQOtkckkOt+J6IFbyXFPTCcHE/4eYRbyPCybrn1rm99WZYn P1ZZh1DfMaH/JshN7b010QCsCUya8E5vTN+0Qkw/uulWKWoybnaFA4FgBnuY3lolHUGY NN9RtFRCmOVh+qAZ/YDc00yDu/P22kcx6s2+hxcsjsrbKDIjYl8XvSO9686OU/FzUjRq IjmjdRTrxBsC98oHdhmUoPdUZNpEqDfL7NOVhdGlfxuKKn90JxLN0SIEZ2sOitbhdmbR AvVtMEzjOMHyvCZYac5VMOfaab0aU3WxauVHgQZUc6K/Ir6/vCwbOS9SmGRlsll8vEOz sygA== Subject: [Intel-gfx] [PATCH V6 i-g-t 1/6] lib/igt_kms: Add writeback support 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: igt-dev@lists.freedesktop.org, intel-gfx@lists.freedesktop.org, nd Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP Add support in igt_kms for writeback connectors, with the ability to attach framebuffers. v5: Rebase and add DRM_CLIENT_CAP_WRITEBACK_CONNECTORS before drmModeGetResources() Signed-off-by: Brian Starkey [rebased and updated to the latest igt style] Signed-off-by: Liviu Dudau Reviewed-by: Liviu Dudau Reviewed-by: Simon Ser --- lib/igt_kms.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++ lib/igt_kms.h | 6 ++++++ 2 files changed, 63 insertions(+) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index da188a39..140db346 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -325,6 +325,9 @@ const char * const igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = { [IGT_CONNECTOR_BROADCAST_RGB] = "Broadcast RGB", [IGT_CONNECTOR_CONTENT_PROTECTION] = "Content Protection", [IGT_CONNECTOR_VRR_CAPABLE] = "vrr_capable", + [IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS] = "WRITEBACK_PIXEL_FORMATS", + [IGT_CONNECTOR_WRITEBACK_FB_ID] = "WRITEBACK_FB_ID", + [IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = "WRITEBACK_OUT_FENCE_PTR", }; /* @@ -557,6 +560,7 @@ static const struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, { DRM_MODE_CONNECTOR_DSI, "DSI" }, { DRM_MODE_CONNECTOR_DPI, "DPI" }, + { DRM_MODE_CONNECTOR_WRITEBACK, "Writeback" }, {} }; @@ -1889,6 +1893,12 @@ static void igt_output_reset(igt_output_t *output) if (igt_output_has_prop(output, IGT_CONNECTOR_BROADCAST_RGB)) igt_output_set_prop_value(output, IGT_CONNECTOR_BROADCAST_RGB, BROADCAST_RGB_FULL); + if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_FB_ID)) + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, 0); + if (igt_output_has_prop(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) { + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); + output->writeback_out_fence_fd = -1; + } } /** @@ -1901,6 +1911,8 @@ static void igt_output_reset(igt_output_t *output) * For outputs: * - %IGT_CONNECTOR_CRTC_ID * - %IGT_CONNECTOR_BROADCAST_RGB (if applicable) + * - %IGT_CONNECTOR_WRITEBACK_FB_ID + * - %IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR * - igt_output_override_mode() to default. * * For pipes: @@ -1970,6 +1982,8 @@ void igt_display_require(igt_display_t *display, int drm_fd) display->drm_fd = drm_fd; + drmSetClientCap(drm_fd, DRM_CLIENT_CAP_WRITEBACK_CONNECTORS, 1); + resources = drmModeGetResources(display->drm_fd); if (!resources) goto out; @@ -2263,6 +2277,11 @@ static void igt_output_fini(igt_output_t *output) kmstest_free_connector_config(&output->config); free(output->name); output->name = NULL; + + if (output->writeback_out_fence_fd != -1) { + close(output->writeback_out_fence_fd); + output->writeback_out_fence_fd = -1; + } } /** @@ -3325,6 +3344,11 @@ static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAto output->props[i], output->values[i])); } + + if (output->writeback_out_fence_fd != -1) { + close(output->writeback_out_fence_fd); + output->writeback_out_fence_fd = -1; + } } /* @@ -3447,6 +3471,16 @@ display_commit_changed(igt_display_t *display, enum igt_commit_style s) else /* no modeset in universal commit, no change to crtc. */ output->changed &= 1 << IGT_CONNECTOR_CRTC_ID; + + if (s == COMMIT_ATOMIC) { + if (igt_output_is_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR)) + igt_assert(output->writeback_out_fence_fd >= 0); + + output->values[IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR] = 0; + output->values[IGT_CONNECTOR_WRITEBACK_FB_ID] = 0; + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_FB_ID); + igt_output_clear_prop_changed(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR); + } } if (display->first_commit) { @@ -4119,6 +4153,29 @@ void igt_pipe_request_out_fence(igt_pipe_t *pipe) igt_pipe_obj_set_prop_value(pipe, IGT_CRTC_OUT_FENCE_PTR, (ptrdiff_t)&pipe->out_fence_fd); } +/** + * igt_output_set_writeback_fb: + * @output: Target output + * @fb: Target framebuffer + * + * This function sets the given @fb to be used as the target framebuffer for the + * writeback engine at the next atomic commit. It will also request a writeback + * out fence that will contain the fd number of the out fence created by KMS if + * the given @fb is valid. + */ +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb) +{ + igt_display_t *display = output->display; + + LOG(display, "%s: output_set_writeback_fb(%d)\n", output->name, fb ? fb->fb_id : 0); + + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_FB_ID, fb ? fb->fb_id : 0); + /* only request a writeback out fence if the framebuffer is valid */ + if (fb) + igt_output_set_prop_value(output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, + (ptrdiff_t)&output->writeback_out_fence_fd); +} + /** * igt_wait_for_vblank_count: * @drm_fd: A drm file descriptor diff --git a/lib/igt_kms.h b/lib/igt_kms.h index a448a003..cacc6b90 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -123,6 +123,9 @@ enum igt_atomic_connector_properties { IGT_CONNECTOR_BROADCAST_RGB, IGT_CONNECTOR_CONTENT_PROTECTION, IGT_CONNECTOR_VRR_CAPABLE, + IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS, + IGT_CONNECTOR_WRITEBACK_FB_ID, + IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, IGT_NUM_CONNECTOR_PROPS }; @@ -364,6 +367,8 @@ typedef struct { bool use_override_mode; drmModeModeInfo override_mode; + int32_t writeback_out_fence_fd; + /* bitmask of changed properties */ uint64_t changed; @@ -414,6 +419,7 @@ igt_plane_t *igt_output_get_plane_type_index(igt_output_t *output, igt_output_t *igt_output_from_connector(igt_display_t *display, drmModeConnector *connector); const drmModeModeInfo *igt_std_1024_mode_get(void); +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb); igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type); int igt_pipe_count_plane_type(igt_pipe_t *pipe, int plane_type);