From patchwork Thu Jun 13 02:18:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodrigo Siqueira X-Patchwork-Id: 10991041 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 6E9D313AF for ; Thu, 13 Jun 2019 02:18:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58695287FD for ; Thu, 13 Jun 2019 02:18:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4CE0B289F9; Thu, 13 Jun 2019 02:18:45 +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 D38E0287FD for ; Thu, 13 Jun 2019 02:18:43 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6EE838926E; Thu, 13 Jun 2019 02:18:43 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by gabe.freedesktop.org (Postfix) with ESMTPS id D080D891C7; Thu, 13 Jun 2019 02:18:41 +0000 (UTC) Received: by mail-ed1-x541.google.com with SMTP id k21so25426739edq.3; Wed, 12 Jun 2019 19:18:41 -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=/jj9TEcyZrSKuYTZPQQ59Ky24PAfbxRvOUX+EZhuCrg=; b=T6Tm5vk8EBFbHDtTjkKXPn0k8qsa54Od1ZR9ne3f7or+qcDyhH6/1wHCKWg/igk3eO XzCj0e0mcjR1GyXV1y6DOAQALerYNvrIDie6jV5qHPVIElb9uJmWmVIQZQINHvLH+Vyv mMaaECnYkytHZqfIvW95+OAO1u3nUfIJ1lUnXVVOZKmzpq9kL8Ch2DjcMKjULEj7X/Jo 1w48vW6Op5rctWozi1afci9VtVfi/b8vezY6lyu7nkPDKIc/kBNK+qzfRMK1gZOP5hpD dZSiPe8j4wM9VzGprCy07OUTb5eIvDE8SmrD755Z7guELqn8IteLL9qDQvgVMFdFxWmj VDDw== X-Gm-Message-State: APjAAAVPfxreKH7Ork0QfVAVzScKcFkkLQPF9QzSAanxtM7dEuthe0f6 1/pDv8lf6phym8/gMBBHd+g= X-Google-Smtp-Source: APXvYqykwkC9A0Z9DhgNyW5qiSfysoYtUOXOMnKqsATYHDSXQlWtBPyHZdOsTSS4q3gwVNa1OQf1VQ== X-Received: by 2002:a17:906:a950:: with SMTP id hh16mr73997307ejb.136.1560392320448; Wed, 12 Jun 2019 19:18:40 -0700 (PDT) Received: from smtp.gmail.com ([187.121.151.146]) by smtp.gmail.com with ESMTPSA id f36sm193549ede.47.2019.06.12.19.18.36 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 12 Jun 2019 19:18:39 -0700 (PDT) From: Brian Starkey X-Google-Original-From: Brian Starkey Date: Wed, 12 Jun 2019 23:18:34 -0300 To: Brian Starkey , Liviu Dudau , Petri Latvala , Arkadiusz Hiler , Daniel Vetter Message-ID: <9f4a3f1d1c9df084ec2bf8e9b7475bbeda5f0985.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=/jj9TEcyZrSKuYTZPQQ59Ky24PAfbxRvOUX+EZhuCrg=; b=FyzQaPTDGxlo5SOM4FvIbgPrUgr8AJy+LNYhKdAuNkW/5ZnXbQfZbRmWDziBboUfRV vtMJkChIgkQXUX5ejuIlqFiPRHKpFNa9p+2HZqvUWLwjZRf1kK0WyLhGeYczuKIobA2n yLDBmTTRwnTD3InCGaURMea6v6iqIsiNP8NOUuzXqW8EZRKzsUOjCSY6i+1H47tIlKX4 Ti3opJUjZv5CrW3X2HqXFVWCpqzkv48Dtk9rmko+NyU5ZDtlZ3EhMXe15s9zZAIzQjxA /Zv4OLeN0v6KL0CqdtXiuOFb3DO4pTuTyyd92bGsDzQdv+KHerNCCyWsPWxWKIRUGJDK cBjw== Subject: [Intel-gfx] [PATCH V6 i-g-t 5/6] lib/igt_kms: Add igt_output_clone_pipe for cloning 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 An output can be added as a clone of any other output(s) attached to a pipe using igt_output_clone_pipe() v5: Drop field out_fence_requested from struct igt_pipe (Brian Starkey) Signed-off-by: Brian Starkey --- lib/igt_kms.c | 100 +++++++++++++++++++++++++++++++------------------- lib/igt_kms.h | 4 ++ 2 files changed, 66 insertions(+), 38 deletions(-) diff --git a/lib/igt_kms.c b/lib/igt_kms.c index 140db346..b85a0404 100644 --- a/lib/igt_kms.c +++ b/lib/igt_kms.c @@ -1765,6 +1765,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; @@ -2317,42 +2328,6 @@ void igt_display_fini(igt_display_t *display) display->planes = 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 (output->pending_pipe != PIPE_NONE) { - if (pipes_in_use & (1 << output->pending_pipe)) - goto report_dup; - - pipes_in_use |= 1 << output->pending_pipe; - } - - 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_pipe != - b->pending_pipe, - "%s and %s are both trying to use pipe %s\n", - igt_output_name(output), igt_output_name(b), - kmstest_pipe_name(output->pending_pipe)); - } -} - static igt_pipe_t *igt_output_get_driving_pipe(igt_output_t *output) { igt_display_t *display = output->display; @@ -2376,6 +2351,40 @@ 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; + unsigned long pending_crtc_idx_mask; + + /* Check that outputs and pipes agree wrt. cloning */ + for (i = 0; i < display->n_outputs; i++) { + output = &display->outputs[i]; + pending_crtc_idx_mask = 1 << output->pending_pipe; + + 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 & pending_crtc_idx_mask) + LOG(display, "Output %s clones pipe %s\n", + igt_output_name(output), + kmstest_pipe_name(pipe->pipe)); + } + + pipes_in_use |= 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_require_f(plane_idx >= 0 && plane_idx < pipe->n_planes, @@ -3766,6 +3775,7 @@ void igt_output_override_mode(igt_output_t *output, const drmModeModeInfo *mode) output->use_override_mode = !!mode; if (pipe) { + igt_debug("overriding pipe mode in %s way\n", output->display->is_atomic ? "atomic" : "legacy"); if (output->display->is_atomic) igt_pipe_obj_replace_prop_blob(pipe, IGT_CRTC_MODE_ID, igt_output_get_mode(output), sizeof(*mode)); else @@ -3773,6 +3783,16 @@ void igt_output_override_mode(igt_output_t *output, const drmModeModeInfo *mode) } } +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; +} + /* * igt_output_set_pipe: * @output: Target output for which the pipe is being set to @@ -3789,11 +3809,15 @@ void igt_output_set_pipe(igt_output_t *output, enum pipe pipe) igt_assert(output->name); - if (output->pending_pipe != PIPE_NONE) + if (output->pending_pipe != PIPE_NONE) { old_pipe = igt_output_get_driving_pipe(output); + old_pipe->outputs &= ~(1 << igt_output_idx(output)); + } - if (pipe != PIPE_NONE) + if (pipe != PIPE_NONE) { pipe_obj = &display->pipes[pipe]; + pipe_obj->outputs = (1 << igt_output_idx(output)); + } LOG(display, "%s: set_pipe(%s)\n", igt_output_name(output), kmstest_pipe_name(pipe)); diff --git a/lib/igt_kms.h b/lib/igt_kms.h index cacc6b90..676839bb 100644 --- a/lib/igt_kms.h +++ b/lib/igt_kms.h @@ -354,6 +354,8 @@ struct igt_pipe { uint32_t crtc_id; int32_t out_fence_fd; + + uint32_t outputs; }; typedef struct { @@ -411,6 +413,8 @@ 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, const 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); + 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); int igt_output_count_plane_type(igt_output_t *output, int plane_type);