From patchwork Fri Jul 14 15:18:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 9841325 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 8563460212 for ; Fri, 14 Jul 2017 15:19:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 744CF2874C for ; Fri, 14 Jul 2017 15:19:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 68FFC2878C; Fri, 14 Jul 2017 15:19: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 DBECD2874C for ; Fri, 14 Jul 2017 15:19:13 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 5C79A6E877; Fri, 14 Jul 2017 15:19:05 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from cam-smtp0.cambridge.arm.com (fw-tnat.cambridge.arm.com [217.140.96.140]) by gabe.freedesktop.org (Postfix) with ESMTPS id C39466E86F; Fri, 14 Jul 2017 15:19:01 +0000 (UTC) Received: from e110455-lin.cambridge.arm.com (e110455-lin.cambridge.arm.com [10.2.131.9]) by cam-smtp0.cambridge.arm.com (8.13.8/8.13.8) with ESMTP id v6EFIuFL000867; Fri, 14 Jul 2017 16:18:56 +0100 From: Liviu Dudau To: Intel GFX discussion Date: Fri, 14 Jul 2017 16:18:51 +0100 Message-Id: <20170714151856.32041-3-liviu.dudau@arm.com> X-Mailer: git-send-email 2.13.2 In-Reply-To: <20170714151856.32041-1-liviu.dudau@arm.com> References: <20170714151856.32041-1-liviu.dudau@arm.com> Cc: Boris Brezillon , DRI devel Subject: [Intel-gfx] [PATCH i-g-t v2 2/7] lib/igt_kms: Add writeback support in lib/ X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP From: Brian Starkey Add support in igt_kms for Writeback connectors, with the ability to attach framebuffers and retrieve fences. Signed-off-by: Brian Starkey --- lib/igt_aux.c | 1 + lib/igt_kms.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- lib/igt_kms.h | 16 +++++++++++++ 3 files changed, 92 insertions(+), 1 deletion(-) diff --git a/lib/igt_aux.c b/lib/igt_aux.c index 86a213c2..ad80452a 100644 --- a/lib/igt_aux.c +++ b/lib/igt_aux.c @@ -1106,6 +1106,7 @@ static const struct type_name connector_type_names[] = { { DRM_MODE_CONNECTOR_eDP, "eDP" }, { DRM_MODE_CONNECTOR_VIRTUAL, "Virtual" }, { DRM_MODE_CONNECTOR_DSI, "DSI" }, + { DRM_MODE_CONNECTOR_WRITEBACK, "Writeback" }, {} }; diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 6390229f..02e2b274 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -186,7 +186,10 @@ const char *igt_crtc_prop_names[IGT_NUM_CRTC_PROPS] = { const char *igt_connector_prop_names[IGT_NUM_CONNECTOR_PROPS] = { "scaling mode", - "CRTC_ID" + "CRTC_ID", + "WRITEBACK_PIXEL_FORMATS", + "WRITEBACK_FB_ID", + "WRITEBACK_OUT_FENCE_PTR" }; /* @@ -1832,6 +1835,7 @@ void igt_display_init(igt_display_t *display, int drm_fd) output->pending_crtc_idx_mask = 0; output->id = resources->connectors[i]; output->display = display; + output->writeback_out_fence_fd = -1; igt_output_refresh(output); @@ -1899,6 +1903,42 @@ igt_output_t *igt_output_from_connector(igt_display_t *display, return found; } +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb) +{ + igt_display_t *display = output->display; + struct kmstest_connector_config *config = &output->config; + + if (config->connector->connector_type != DRM_MODE_CONNECTOR_WRITEBACK) + return; + + LOG(display, "%s: output_set_writeback_fb(%d)\n", output->name, + fb ? fb->fb_id : 0); + + output->writeback_fb = fb; +} + +static void igt_output_reset_writeback_out_fence(igt_output_t *output) +{ + if (output->writeback_out_fence_fd >= 0) { + close(output->writeback_out_fence_fd); + output->writeback_out_fence_fd = -1; + } +} + +void igt_output_request_writeback_out_fence(igt_output_t *output) +{ + igt_output_reset_writeback_out_fence(output); + output->writeback_out_fence_requested = true; +} + +int igt_output_get_last_writeback_out_fence(igt_output_t *output) +{ + int fd = output->writeback_out_fence_fd; + output->writeback_out_fence_fd = -1; + + return fd; +} + static void igt_pipe_fini(igt_pipe_t *pipe) { int i; @@ -1922,6 +1962,8 @@ static void igt_pipe_fini(igt_pipe_t *pipe) static void igt_output_fini(igt_output_t *output) { kmstest_free_connector_config(&output->config); + if (output->writeback_out_fence_fd >= 0) + close(output->writeback_out_fence_fd); free(output->name); output->name = NULL; } @@ -2541,10 +2583,41 @@ static void igt_atomic_prepare_connector_commit(igt_output_t *output, drmModeAto igt_atomic_populate_connector_req(req, output, IGT_CONNECTOR_CRTC_ID, crtc_id); } + + if (output->writeback_fb) { + igt_atomic_populate_connector_req(req, output, IGT_CONNECTOR_WRITEBACK_FB_ID, output->writeback_fb->fb_id); + output->writeback_fb = NULL; + } + + igt_output_reset_writeback_out_fence(output); + if (output->writeback_out_fence_requested) { + igt_atomic_populate_connector_req(req, output, IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, + (uint64_t)(uintptr_t)&output->writeback_out_fence_fd); + } + /* * TODO: Add all other connector level properties here */ +} + +static void handle_writeback_out_fences(igt_display_t *display, uint32_t flags, int ret) +{ + int i; + for (i = 0; i < display->n_outputs; i++) { + igt_output_t *output = &display->outputs[i]; + + if (!output->config.connector) + continue; + + if (!output->writeback_out_fence_requested) + continue; + + output->writeback_out_fence_requested = false; + + if (ret || (flags & DRM_MODE_ATOMIC_TEST_ONLY)) + igt_assert(output->writeback_out_fence_fd == -1); + } } /* @@ -2593,6 +2666,7 @@ static int igt_atomic_commit(igt_display_t *display, uint32_t flags, void *user_ } ret = drmModeAtomicCommit(display->drm_fd, req, flags, user_data); + handle_writeback_out_fences(display, flags, ret); drmModeAtomicFree(req); return ret; diff --git a/lib/igt_kms.h b/lib/igt_kms.h index 35428f3e..ce9a35ef 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -37,6 +37,10 @@ #include "igt_fb.h" #include "ioctl_wrappers.h" +#ifndef DRM_MODE_CONNECTOR_WRITEBACK +#define DRM_MODE_CONNECTOR_WRITEBACK 18 +#endif + /* Low-level helpers with kmstest_ prefix */ /** @@ -113,6 +117,9 @@ extern const char *igt_crtc_prop_names[]; enum igt_atomic_connector_properties { IGT_CONNECTOR_SCALING_MODE = 0, IGT_CONNECTOR_CRTC_ID, + IGT_CONNECTOR_WRITEBACK_PIXEL_FORMATS, + IGT_CONNECTOR_WRITEBACK_FB_ID, + IGT_CONNECTOR_WRITEBACK_OUT_FENCE_PTR, IGT_NUM_CONNECTOR_PROPS }; @@ -363,6 +370,10 @@ typedef struct { unsigned long pending_crtc_idx_mask; bool use_override_mode; drmModeModeInfo override_mode; + + struct igt_fb *writeback_fb; + int32_t writeback_out_fence_fd; + bool writeback_out_fence_requested; } igt_output_t; struct igt_display { @@ -392,10 +403,15 @@ drmModeModeInfo *igt_output_get_mode(igt_output_t *output); void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode); void igt_output_set_pipe(igt_output_t *output, enum pipe pipe); void igt_output_set_scaling_mode(igt_output_t *output, uint64_t scaling_mode); + igt_plane_t *igt_output_get_plane(igt_output_t *output, int plane_idx); igt_plane_t *igt_output_get_plane_type(igt_output_t *output, int plane_type); igt_output_t *igt_output_from_connector(igt_display_t *display, drmModeConnector *connector); +void igt_output_set_writeback_fb(igt_output_t *output, struct igt_fb *fb); +void igt_output_request_writeback_out_fence(igt_output_t *output); +int igt_output_get_last_writeback_out_fence(igt_output_t *output); + igt_plane_t *igt_pipe_get_plane_type(igt_pipe_t *pipe, int plane_type); bool igt_pipe_get_property(igt_pipe_t *pipe, const char *name, uint32_t *prop_id, uint64_t *value,