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: 107807 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1034416qge; Fri, 14 Jul 2017 08:19:22 -0700 (PDT) X-Received: by 10.98.217.145 with SMTP id b17mr5938587pfl.70.1500045562305; Fri, 14 Jul 2017 08:19:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500045562; cv=none; d=google.com; s=arc-20160816; b=FsFQoym1I52W4ovdyFHLkR3mjM+Z6zeUPE2n4tkJKv6qNCa46vDFrkUkoHQ8ohZzzf Cvp9MHALOz8Zl2movCCMsnLOWRuty2QqFIoF+CepGLoQJAQLdpBRSrkuAPzvHkrXKfOD waKGgHpDVVwx06TO/hMsHwA+F4qU3VHtxjlCSBcPY/hAeL9NQ0q7MEKK5rM+cIWqVjgV lvZjhd6/Y2xS9x0Xs9gBM/7PfG1+zn3AmxLfLC8gbPH8o7t4m4/n+5LQVOhO+PgOjWNQ UKcWmwczTHLBUrmWMrAMwhvfOafxIZVMPGeXJcxrkxRQwDcslajSHpzB9K229PcPdc2A UE8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:cc:references:in-reply-to:message-id:date :subject:to:from:delivered-to:arc-authentication-results; bh=NGQU+aWxeQVyNPN+dcOVPQTuQ/ak9NezeTJ0J4xqcJE=; b=ayZi+uEQsKuDw/mXeeOMk29nOvJ1acmJ9oVT2180kqYyVP3oWeKHfLIUWJyjSEBa44 xnASfyq+P3xjPJlIxCKWwK/9RVNnVpIdS+LkEToHqXqmZi+h09Vw2Fb2ffgUoOeSUGKe 7ubxlJAkIcWLkCjuwDUIzGsKpxhKJWQCVzlYyRrIhLqq+bC0YHDEOAWLr0v916hHc6jw pAyzOSaRGaAHPMPAPtDhOXbaZFTU3I3BIXrKrGXDUBcTTCLdvk71G9c3PTWXEOpmCJlO yOT+SownA1zXtI1VbmDK+r8KWmi8lsok42ufQ3ezUQObqNqsQ1pE0SM3bh8Ej9nYhMfE D8cA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [131.252.210.177]) by mx.google.com with ESMTPS id a25si6812175pgn.241.2017.07.14.08.19.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 08:19:22 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9436F6E87A; Fri, 14 Jul 2017 15:19:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@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 Subject: [PATCH i-g-t v2 2/7] lib/igt_kms: Add writeback support in lib/ 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 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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,