From patchwork Tue May 10 20:51:11 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 12845523 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFDB0C433EF for ; Tue, 10 May 2022 20:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231931AbiEJUxI (ORCPT ); Tue, 10 May 2022 16:53:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229685AbiEJUxH (ORCPT ); Tue, 10 May 2022 16:53:07 -0400 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 389C851E52 for ; Tue, 10 May 2022 13:53:06 -0700 (PDT) Received: by mail-pf1-x433.google.com with SMTP id c14so204699pfn.2 for ; Tue, 10 May 2022 13:53:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+HZZAVCUgB4PR5HOSv738zuWZd6viwdct4jZ4FZSIU0=; b=oWmYD10TXbpQiIJ/xzCl7IxKeJeRGHnNIYoe2NzGF8Z40b9A089yZu2d/GnlCuSqdo q6ZIKf55c1K3Q602V8ZhCPmbryBHAVSR29GFjetx8dPxfxwpeelua5Oe9dNh49PzFRnz msgXH2br9qxGT5GVAPoL2u6hWcb2Le2llWrms= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=+HZZAVCUgB4PR5HOSv738zuWZd6viwdct4jZ4FZSIU0=; b=8ApEEnaP89Jerq/TPGyVUsd4h1kxiOTg/I92rvuTtZlp4DZFPAf+/sJntn6GVStbwe PZqL7H50iW5zHkMEltlm6eIFZzSOzVBycZxUZcoC00fAL/3/9m8PT0mSYDUT5G554LLf TcFC/SOabij6dbXxytJZp08Mbfq8XtTRi46PMO7nLtlTrooziDBkTZN25GyQBYhePwi2 xzfhx50I9FF7jcndUwoFr+d4msP0QzU8EclA6PCvhg5rcLIvhdXv0upg/+iZHi4k/T5e ZK0wmwneuMXp3FlcuWQRmV/+K2MP9BNN4NoOed9ZJzNkdgr+QpH4Tf9y2mwY9nlMO60w sY9g== X-Gm-Message-State: AOAM530VVawcEIdVjv2Af8qC3xosZaBIZq4YpX2n6EXrR8b9cTDafIa3 NGiJtBiaW6CTvsw10a0Ju9reOg== X-Google-Smtp-Source: ABdhPJx51SH/5x8d1+7L4D8y1N7o70vXFdfzujmC9MaUWLZcKl14rafYh/2Xs1SSzWyvWcqe2COx9Q== X-Received: by 2002:a62:d0c5:0:b0:50d:a467:3cc8 with SMTP id p188-20020a62d0c5000000b0050da4673cc8mr22146677pfg.81.1652215985737; Tue, 10 May 2022 13:53:05 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:6f08:624c:c762:d238]) by smtp.gmail.com with ESMTPSA id lr10-20020a17090b4b8a00b001d2edf4b513sm92975pjb.56.2022.05.10.13.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 May 2022 13:53:05 -0700 (PDT) From: Douglas Anderson To: dri-devel@lists.freedesktop.org Cc: quic_abhinavk@quicinc.com, robdclark@gmail.com, swboyd@chromium.org, quic_aravindh@quicinc.com, ville.syrjala@linux.intel.com, tzimmermann@suse.de, linux-arm-msm@vger.kernel.org, jani.nikula@linux.intel.com, quic_sbillaka@quicinc.com, dmitry.baryshkov@linaro.org, freedreno@lists.freedesktop.org, quic_khsieh@quicinc.com, Douglas Anderson , Daniel Vetter , David Airlie , Maarten Lankhorst , Maxime Ripard , linux-kernel@vger.kernel.org Subject: [PATCH v2] drm/probe-helper: Default to 640x480 if no EDID Date: Tue, 10 May 2022 13:51:11 -0700 Message-Id: <20220510135101.v2.1.I31ec454f8d4ffce51a7708a8092f8a6f9c929092@changeid> X-Mailer: git-send-email 2.36.0.550.gb090851708-goog MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org If we're unable to read the EDID for a display because it's corrupt / bogus / invalid then we'll add a set of standard modes for the display. When userspace looks at these modes it doesn't really have a good concept for which mode to pick and it'll likely pick the highest resolution one by default. That's probably not ideal because the modes were purely guesses on the part of the Linux kernel. Let's instead set 640x480 as the "preferred" mode when we have no EDID. Signed-off-by: Douglas Anderson Reviewed-by: Abhinav Kumar --- Note that this is the second of two related and similar-sounding but different patches. See also ("drm/probe-helper: For DP, add 640x480 if all other modes are bad") [1]. I'm hoping to land _both_ of the patches since they address different issues. This patch addresses the case of a corrupt EDID and having 640x480 be the default in the "guessed" modes. The other patch handles the case where the EDID _isn't_ corrupt but all the modes listed can't be made with the existing situations. The two patches can land in either order. Also note that I didn't carry any Tested-by / Reviewed-by tags since the patch is now quite different. [1] https://lore.kernel.org/r/20220510131309.v2.2.I4ac7f55aa446699f8c200a23c10463256f6f439f@changeid Changes in v2: - Don't modify drm_add_modes_noedid() 'cause that'll break others - Set 640x480 as preferred in drm_helper_probe_single_connector_modes() drivers/gpu/drm/drm_probe_helper.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/drm_probe_helper.c b/drivers/gpu/drm/drm_probe_helper.c index 682359512996..1fbb9a8c315c 100644 --- a/drivers/gpu/drm/drm_probe_helper.c +++ b/drivers/gpu/drm/drm_probe_helper.c @@ -516,8 +516,17 @@ int drm_helper_probe_single_connector_modes(struct drm_connector *connector, count = drm_add_override_edid_modes(connector); if (count == 0 && (connector->status == connector_status_connected || - connector->status == connector_status_unknown)) + connector->status == connector_status_unknown)) { count = drm_add_modes_noedid(connector, 1024, 768); + + /* + * Give userspace a hint that we don't have a lot of confidence + * in these modes (we totally guessed) by marking 640x480 as + * preferred. This is low clock rate and incredibly common as + * a failsafe mode. + */ + drm_set_preferred_mode(connector, 640, 480); + } count += drm_helper_probe_add_cmdline_mode(connector); if (count == 0) goto prune;