From patchwork Tue Feb 14 19:25:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 9572573 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 C882C60573 for ; Tue, 14 Feb 2017 19:25:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B692527D8D for ; Tue, 14 Feb 2017 19:25:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB3F127F81; Tue, 14 Feb 2017 19:25: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.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 47B6427D8D for ; Tue, 14 Feb 2017 19:25:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 157866E7DB; Tue, 14 Feb 2017 19:25:13 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-ot0-x231.google.com (mail-ot0-x231.google.com [IPv6:2607:f8b0:4003:c0f::231]) by gabe.freedesktop.org (Postfix) with ESMTPS id 01BF16E7DB for ; Tue, 14 Feb 2017 19:25:10 +0000 (UTC) Received: by mail-ot0-x231.google.com with SMTP id 73so101919008otj.0 for ; Tue, 14 Feb 2017 11:25:09 -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:in-reply-to:references; bh=tuf6+xkPOe7GmYnkIsuUqr3et6vUx+eSvcYiFtvQYEM=; b=Meu9yxNX/KPn/bXn8QPqvRmNyRG8J3DxkGaRq1iRChINHVlZ0RIUUuMXRTPdELcK6Z tE4XwCHKyEbMO2iDKPhHqxrlguiyUTDr/w9257yJey4lHHt+dX4yevg7HOFl8ArhSiTZ 2ADgw7iLhoc4lom84JFbMyDLlXMaM0Hx+3LN0= 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:in-reply-to :references; bh=tuf6+xkPOe7GmYnkIsuUqr3et6vUx+eSvcYiFtvQYEM=; b=FbFzx/RG/b4a1PRqqZwnXaXU7THBKnkO6oBKqsYpPfCW+SRbmauyWOwHV5cq/kLKuP qI5TESndzCFxiTXY+8Zkm3Uyavw8FsPLrDyMQbVJzSkY5YSZ53RYyeZlXPWYLr67HHfN 8kY1jbquaPW7vs7mpqVmGgMvqL1F/hT6Zo3/xIrbweF2jiAdCe3w+YTKOpYQka7ObNan xD+TYxA4rFEjze8dYc3tf4Sn118Z4bxZisF30C15qNNBANh8t6mRntT0V2dzj8RSMK+V N137Vxvxb7Gckf1507hAWwCc2Qsfgf5RONGnDzUkiAgp91ATDcbvCsRq5zr7ZxhMwsSZ zfrQ== X-Gm-Message-State: AMke39nHWSBLkW18C+mLa1rZt68g+z2SSkF6PgRiLzhtlthtVcs8g+DdpqCZwNWTIkODn7cz X-Received: by 10.98.130.206 with SMTP id w197mr33058450pfd.5.1487100309225; Tue, 14 Feb 2017 11:25:09 -0800 (PST) Received: from localhost.localdomain ([2601:1c2:1002:83f0:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id t6sm2825378pgt.8.2017.02.14.11.25.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 14 Feb 2017 11:25:07 -0800 (PST) From: John Stultz To: lkml Subject: [RFC][PATCH 1/2] drm/probe-helper: Add mode_valid check to drm_crtc_helper_funcs Date: Tue, 14 Feb 2017 11:25:01 -0800 Message-Id: <1487100302-9445-2-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1487100302-9445-1-git-send-email-john.stultz@linaro.org> References: <1487100302-9445-1-git-send-email-john.stultz@linaro.org> Cc: Chen Feng , Xinwei Kong , Xinliang Liu , dri-devel@lists.freedesktop.org, Rongrong Zou , Daniel Vetter 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" X-Virus-Scanned: ClamAV using ClamSMTP Currently, on the hikey board, we have the adv7511 bridge wired up to the kirin ade drm driver. Unfortunately, the kirin ade core cannot generate accurate byteclocks for all pixel clock values. Thus if a mode clock is selected that we cannot calculate a matching byteclock, the device will boot with a blank screen. Unfortunately, currently the only place we can properly check potential modes for this issue in the connector mode_valid helper. Again, hikey uses the adv7511 bridge, which is shared between a number of different devices, so its improper to put restrictions caused by the kirin drm driver in the adv7511 logic. So this patch tries to correct for that, by adding some infrastructure so that the drm_crtc_helper_funcs can optionally implement a mode_valid check, so that the probe helpers can check to make sure there are not any restrictions at the crtc level as well. Cc: Daniel Vetter Cc: Jani Nikula Cc: Sean Paul Cc: David Airlie Cc: Rob Clark Cc: Xinliang Liu Cc: Xinliang Liu Cc: Rongrong Zou Cc: Xinwei Kong Cc: Chen Feng Cc: Archit Taneja Cc: dri-devel@lists.freedesktop.org Signed-off-by: John Stultz --- drivers/gpu/drm/drm_probe_helper.c | 24 ++++++++++++++++++++++++ include/drm/drm_modeset_helper_vtables.h | 26 ++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index cf8f012..a808348 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -170,6 +170,28 @@ drm_connector_detect(struct drm_connector *connector, bool force) connector_status_connected; } +static enum drm_mode_status +drm_connector_check_crtc_modes(struct drm_connector *connector, + struct drm_display_mode *mode) +{ + struct drm_device *dev = connector->dev; + const struct drm_crtc_helper_funcs *crtc_funcs; + struct drm_crtc *c; + + if (mode->status != MODE_OK) + return mode->status; + + /* Check all the crtcs on a connector to make sure the mode is valid */ + drm_for_each_crtc(c, dev) { + crtc_funcs = c->helper_private; + if (crtc_funcs && crtc_funcs->mode_valid) + mode->status = crtc_funcs->mode_valid(c, mode); + if (mode->status != MODE_OK) + break; + } + return mode->status; +} + /** * drm_helper_probe_single_connector_modes - get complete set of display modes * @connector: connector to probe @@ -338,6 +360,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector, if (mode->status == MODE_OK && connector_funcs->mode_valid) mode->status = connector_funcs->mode_valid(connector, mode); + + mode->status = drm_connector_check_crtc_modes(connector, mode); } prune: diff --git a/include/drm/drm_modeset_helper_vtables.h b/include/drm/drm_modeset_helper_vtables.h index 69c3974..53ca0e4 100644 --- a/include/drm/drm_modeset_helper_vtables.h +++ b/include/drm/drm_modeset_helper_vtables.h @@ -105,6 +105,32 @@ struct drm_crtc_helper_funcs { void (*commit)(struct drm_crtc *crtc); /** + * @mode_valid: + * + * Callback to validate a mode for a crtc, irrespective of the + * specific display configuration. + * + * This callback is used by the probe helpers to filter the mode list + * (which is usually derived from the EDID data block from the sink). + * See e.g. drm_helper_probe_single_connector_modes(). + * + * NOTE: + * + * This only filters the mode list supplied to userspace in the + * GETCONNECOTR IOCTL. Userspace is free to create modes of its own and + * ask the kernel to use them. It this case the atomic helpers or legacy + * CRTC helpers will not call this function. Drivers therefore must + * still fully validate any mode passed in in a modeset request. + * + * RETURNS: + * + * Either MODE_OK or one of the failure reasons in enum + * &drm_mode_status. + */ + enum drm_mode_status (*mode_valid)(struct drm_crtc *crtc, + struct drm_display_mode *mode); + + /** * @mode_fixup: * * This callback is used to validate a mode. The parameter mode is the