From patchwork Fri Jul 14 15:18:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Liviu Dudau X-Patchwork-Id: 107805 Delivered-To: patch@linaro.org Received: by 10.140.101.44 with SMTP id t41csp1034101qge; Fri, 14 Jul 2017 08:19:06 -0700 (PDT) X-Received: by 10.99.101.132 with SMTP id z126mr15257680pgb.64.1500045546402; Fri, 14 Jul 2017 08:19:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1500045546; cv=none; d=google.com; s=arc-20160816; b=LxEr4t5SJmOSGugNUKsrVCTslQvoKVVqHDQ5OSRBJI9oNk1zUnLUpmlVAKH1PYm1oP 5dKU01WCIdlXLHGtrRixQvvQ/gtTHfOPdfz9xy7GnZJEAIIQ1dOmRzBGEZazNkOfq9zw DznZRub+XUl2/McjkSBYodKUi9zXI4b6VXjYDubLgzsg9mbH8NklBWx1JGIIhtm6bMjC mqDejISs+VLDv3roiNuz20bB/iYR9HdgqXOZdz02+Oo7BGkjlL2v6vlru3P39ZkHTk1f +kB7fLMSsuUqkUNPemE7x80EzTXWfspXDbtEZaFT1yY2vNBUCq4wnySyt0Pi+CUvL+X2 8uxQ== 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=HI/sGwRl5nQFSJN6lpVTpX7C05irz3v4ysysSwmmTSo=; b=jLhkFpOVEot+GwXeiXOsOM5HZobtx22W/FxfVc5QVK+6aZZJawbapjJb+u76IFMd/Q 8yVt2i5KWvxJhbt/qOhkclUvY/xX/jtGLgZqZAxkVLaO0YW1vyyX+A/OhVyyeXAbO8re qGfQn902YUnhootRDPL1wA+feXu7qSHTO3SmN1g91K1apWrlWrQh5c5c4XOG3NV98yuI X5SrF4vOaO8Gah7Hit6C5CRLcajJwhPj5vSaaHfxhVIDdpfwBF6auTbNmGmbln8pDFsj oaun/+2VSoIbNtD3V8sZBxYiHRHiAbZ4rlqvrNhEfHVVyshzUhrc1I2JRxJIgMP9aPyU S3Rg== 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 o21si369831pgj.262.2017.07.14.08.19.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 14 Jul 2017 08:19:06 -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 01CE66E869; Fri, 14 Jul 2017 15:19:03 +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 AD91E6E86D; 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 v6EFIuFP000867; Fri, 14 Jul 2017 16:18:57 +0100 From: Liviu Dudau To: Intel GFX discussion Subject: [PATCH i-g-t v2 6/7] lib/igt_kms: Add igt_output_clone_pipe for cloning Date: Fri, 14 Jul 2017 16:18:55 +0100 Message-Id: <20170714151856.32041-7-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 An output can be added as a clone of any other output(s) attached to a pipe using igt_output_clone_pipe() Signed-off-by: Brian Starkey --- lib/igt_kms.c | 90 +++++++++++++++++++++++++++++++++++++---------------------- lib/igt_kms.h | 3 ++ 2 files changed, 59 insertions(+), 34 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index aae32202..85dc0aa8 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1560,6 +1560,17 @@ static void igt_display_log_shift(igt_display_t *display, int shift) igt_assert(display->log_shift >= 0); } +static int igt_output_idx(igt_output_t *output) +{ + int i; + + for (i = 0; i < output->display->n_outputs; i++) + if (&output->display->outputs[i] == output) + return i; + + return -1; +} + static void igt_output_refresh(igt_output_t *output) { igt_display_t *display = output->display; @@ -1990,40 +2001,6 @@ void igt_display_fini(igt_display_t *display) display->pipes = NULL; } -static void igt_display_refresh(igt_display_t *display) -{ - igt_output_t *output; - int i; - - unsigned long pipes_in_use = 0; - - /* Check that two outputs aren't trying to use the same pipe */ - for (i = 0; i < display->n_outputs; i++) { - output = &display->outputs[i]; - - if (pipes_in_use & output->pending_crtc_idx_mask) - goto report_dup; - - pipes_in_use |= output->pending_crtc_idx_mask; - - if (output->force_reprobe) - igt_output_refresh(output); - } - - return; - -report_dup: - for (; i > 0; i--) { - igt_output_t *b = &display->outputs[i - 1]; - - igt_assert_f(output->pending_crtc_idx_mask != - b->pending_crtc_idx_mask, - "%s and %s are both trying to use pipe %s\n", - igt_output_name(output), igt_output_name(b), - kmstest_pipe_name(ffs(b->pending_crtc_idx_mask) - 1)); - } -} - static igt_pipe_t *igt_output_get_driving_pipe(igt_output_t *output) { igt_display_t *display = output->display; @@ -2047,6 +2024,38 @@ static igt_pipe_t *igt_output_get_driving_pipe(igt_output_t *output) return &display->pipes[pipe]; } +static void igt_display_refresh(igt_display_t *display) +{ + igt_output_t *output; + igt_pipe_t *pipe; + int i; + + unsigned long pipes_in_use = 0; + + /* Check that outputs and pipes agree wrt. cloning */ + for (i = 0; i < display->n_outputs; i++) { + output = &display->outputs[i]; + + pipe = igt_output_get_driving_pipe(output); + if (pipe) { + igt_assert_f(pipe->outputs & (1 << igt_output_idx(output)), + "Output %s not expected to be using pipe %s\n", + igt_output_name(output), + kmstest_pipe_name(pipe->pipe)); + + if (pipes_in_use & output->pending_crtc_idx_mask) + LOG(display, "Output %s clones pipe %s\n", + igt_output_name(output), + kmstest_pipe_name(pipe->pipe)); + } + + pipes_in_use |= output->pending_crtc_idx_mask; + + if (output->force_reprobe) + igt_output_refresh(output); + } +} + static igt_plane_t *igt_pipe_get_plane(igt_pipe_t *pipe, int plane_idx) { igt_assert_f(plane_idx >= 0 && plane_idx < pipe->n_planes, @@ -2941,6 +2950,16 @@ void igt_output_override_mode(igt_output_t *output, drmModeModeInfo *mode) pipe->mode_changed = true; } +void igt_output_clone_pipe(igt_output_t *output, enum pipe pipe) +{ + igt_display_t *display = output->display; + uint32_t current_clones = display->pipes[pipe].outputs; + + igt_output_set_pipe(output, pipe); + + display->pipes[pipe].outputs |= current_clones; +} + void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) { igt_display_t *display = output->display; @@ -2952,6 +2971,7 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) old_pipe = igt_output_get_driving_pipe(output); old_pipe->mode_changed = true; + old_pipe->outputs &= ~(1 << igt_output_idx(output)); } if (pipe == PIPE_NONE) { @@ -2963,6 +2983,8 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) output->pending_crtc_idx_mask = 1 << pipe; display->pipes[pipe].mode_changed = true; + + display->pipes[pipe].outputs = (1 << igt_output_idx(output)); } output->config.pipe_changed = true; diff --git a/lib/igt_kms.h b/lib/igt_kms.h index ab8ec764..9ddcfade 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -358,6 +358,8 @@ struct igt_pipe { int32_t out_fence_fd; bool out_fence_requested; + + uint32_t outputs; }; typedef struct { @@ -402,6 +404,7 @@ const char *igt_output_name(igt_output_t *output); 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_clone_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);