From patchwork Tue Feb 20 07:28:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 10229469 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 AB74C602A7 for ; Tue, 20 Feb 2018 07:31:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8AC4B28492 for ; Tue, 20 Feb 2018 07:31:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7EE68284FC; Tue, 20 Feb 2018 07:31:18 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 80BB228492 for ; Tue, 20 Feb 2018 07:31:17 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8F4A06E345; Tue, 20 Feb 2018 07:31:15 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-lf0-x241.google.com (mail-lf0-x241.google.com [IPv6:2a00:1450:4010:c07::241]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2AE7B6E345 for ; Tue, 20 Feb 2018 07:31:12 +0000 (UTC) Received: by mail-lf0-x241.google.com with SMTP id x196so2752235lfd.12 for ; Mon, 19 Feb 2018 23:31:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=FVIcPl/1kFRzBc0kgk5rQZT6Qv5cbgvSuEkYhnMVnP8=; b=LpZJhdximhRwbh+3tKUVbJVobDQbZfTCyjLmoFo1ePfxF9hERnLZlHtmpfCT21EI5j iOt8J6vs+WhbTek5dQDM/7gjdI5+Yyznwxi8htBcGt7rVB8Su25/t6qPSKN8QKSadH+b sZIzzlJOgGwhqQcITRFUoL0dyjhAMbCl3a9iw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=FVIcPl/1kFRzBc0kgk5rQZT6Qv5cbgvSuEkYhnMVnP8=; b=jotvANlMh5obB6E7ThR26pQ5C4xKsU5PvJpSs6a4cr68jh+HOVSrFCImcRuDv5BihO I63mlagJkR8VEal0gncF4I7Kli7D33AaaOYuOXvTlnTVOjOV3TZEev4MBfrdIy7KjoKw n5N10INdmk6ZwWc2DEfbb3oC+CLY+ng7dX5Wl5DVrI1Wp+x7Zu9rXecmdiUMGIXdtLlA eTFK9Y+iioTmhXIQX0Dx+ZSqjpdqhI0NphhphxEw2ki69up15c0V3C2HQ8tNKjhel6qE d3HGwuBHHiQsebXpl/jzaSQDTqPBNwcZU8kR/EzONBRvirtx+j3klNIYkI25fXB2R1e+ e3jQ== X-Gm-Message-State: APf1xPARmNcpafmIMDyZ1IgS73LjGJLDzINVSpO17VuwLeZkmu09BMoM uOeVEE00dr5KoQGYqz6VELWHJw== X-Google-Smtp-Source: AH8x227TBUVhnVrMWPqXPPc4C4c0uD42NqTBh6Utanf97RGM1BxzQ8dYL+z6GimGPLLj09qtJmJCNA== X-Received: by 10.46.99.11 with SMTP id x11mr12079587ljb.136.1519111871318; Mon, 19 Feb 2018 23:31:11 -0800 (PST) Received: from localhost.localdomain (c-cb7471d5.014-348-6c756e10.cust.bredbandsbolaget.se. [213.113.116.203]) by smtp.gmail.com with ESMTPSA id t69sm3131658ljb.36.2018.02.19.23.31.09 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 19 Feb 2018 23:31:10 -0800 (PST) From: Linus Walleij To: Daniel Vetter , Jani Nikula , Sean Paul , Eric Anholt Subject: [PATCH] drm: simple_kms_helper: Add mode_valid() callback support Date: Tue, 20 Feb 2018 08:28:59 +0100 Message-Id: <20180220072859.3386-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.14.3 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP The PL111 needs to filter valid modes based on memory bandwidth. I guess it is a pretty simple operation, so we can still claim the DRM KMS helper pipeline is simple after adding this (optional) vtable callback. Reviewed-by: Eric Anholt Reviewed-by: Daniel Vetter Signed-off-by: Linus Walleij Reviewed-by: Thierry Reding --- ChangeLog v1->v2: - Fix up the kerneldoc to just refer to the enum. - Collect Eric's and Daniel's review tags. --- drivers/gpu/drm/drm_simple_kms_helper.c | 15 +++++++++++++++ include/drm/drm_simple_kms_helper.h | 14 ++++++++++++++ 2 files changed, 29 insertions(+) diff --git a/drivers/gpu/drm/drm_simple_kms_helper.c b/drivers/gpu/drm/drm_simple_kms_helper.c index 9f3b1c94802b..652cde9a5a6b 100644 --- a/drivers/gpu/drm/drm_simple_kms_helper.c +++ b/drivers/gpu/drm/drm_simple_kms_helper.c @@ -34,6 +34,20 @@ static const struct drm_encoder_funcs drm_simple_kms_encoder_funcs = { .destroy = drm_encoder_cleanup, }; +static enum drm_mode_status +drm_simple_kms_crtc_mode_valid(struct drm_crtc *crtc, + const struct drm_display_mode *mode) +{ + struct drm_simple_display_pipe *pipe; + + pipe = container_of(crtc, struct drm_simple_display_pipe, crtc); + if (!pipe->funcs || !pipe->funcs->mode_valid) + /* Anything goes */ + return MODE_OK; + + return pipe->funcs->mode_valid(crtc, mode); +} + static int drm_simple_kms_crtc_check(struct drm_crtc *crtc, struct drm_crtc_state *state) { @@ -72,6 +86,7 @@ static void drm_simple_kms_crtc_disable(struct drm_crtc *crtc, } static const struct drm_crtc_helper_funcs drm_simple_kms_crtc_helper_funcs = { + .mode_valid = drm_simple_kms_crtc_mode_valid, .atomic_check = drm_simple_kms_crtc_check, .atomic_enable = drm_simple_kms_crtc_enable, .atomic_disable = drm_simple_kms_crtc_disable, diff --git a/include/drm/drm_simple_kms_helper.h b/include/drm/drm_simple_kms_helper.h index 6d9adbb46293..d9e4c3c3f009 100644 --- a/include/drm/drm_simple_kms_helper.h +++ b/include/drm/drm_simple_kms_helper.h @@ -21,6 +21,20 @@ struct drm_simple_display_pipe; * display pipeline */ struct drm_simple_display_pipe_funcs { + /** + * @mode_valid: + * + * This function is called to filter out valid modes from the + * suggestions suggested by the bridge or display. This optional + * hook is passed in when initializing the pipeline. + * + * RETURNS: + * + * drm_mode_status Enum + */ + enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc, + const struct drm_display_mode *mode); + /** * @enable: *