From patchwork Mon Nov 6 23:51:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 162233 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:8f47:0:b0:403:3b70:6f57 with SMTP id j7csp3001723vqu; Mon, 6 Nov 2023 16:01:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1f11zjivAYCSGanPIlRh/CRsbr/x3RAZkXEfafcTXw0I34fMitpfcBhKvgOmWElyaWsdD X-Received: by 2002:a17:903:2306:b0:1cc:3357:2ee8 with SMTP id d6-20020a170903230600b001cc33572ee8mr25392880plh.25.1699315304931; Mon, 06 Nov 2023 16:01:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1699315304; cv=none; d=google.com; s=arc-20160816; b=gNXDf8TDgpiaLuxLIcm1Fz0iJcxZ9KyT4aSraSaiBdL66crxrQ+vqPqB7swT4IVPrc +2kUxI9fy6wNrOscK78cAW2L0LQLHh1T7lbmutB/1dH3w7EuUC35JoRc1iW4E51c9Brv mYWR5LQHFKIuK04nl/NaX0bWVezeebWPrTjQbYqu+ucyVNCz48IlOhm2JRpGQT9RHR0m Xn8RNt6woI7n0oJaS+1QBC4bs0oIenQ3f3Blv1Okh7uQxAbnDx8uDt/mi5Pla7Hh3Bad aqRkC1j8id8nux2MpE8sTPJc9Dg7XXK70IqrPfNblut/Wm5yj08AMIJW1fiz8o12L1k7 agvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=nExiIqIE5poHUcHshO31rcWQ0P0GIrJm7ZyDGwrfXOM=; fh=QSF6wZwxRRIGJ9Ybx1nP+GUhkXoPhy52zPZ6csROsqc=; b=aLTmQVxU+hiTij1J4jzTKOsr1MkIUJYUzMFZ0kR4dmuhiBxLSC3vYC5sZyx6cVCTtv eznS9h8ZCq8HyImlfeyZhg0pzkkh/Xu7z9xV8lB2KBoZkW+78CfZL8AhOiZuExz0Euz3 X8AJJxnoCu6ac2CQTEPgD4rfd6lxhV1tWfIYREhwwWJtWaB6MMciWRPRNIwY3NKxrOyN xXeT9wync64YNDJLsqbnwkj9HA5ympuxv6nPrskfE8D83KEuuTv+DRE3AD/8SP4sG+TN MQId4mmxKxRaxfKouF2WWnKmacEIZ4cp/FIxKijfEVM4bVQ/W2sR5eu3rgQFBRsRUsAk aQsg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=di7VKaUx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from groat.vger.email (groat.vger.email. [23.128.96.35]) by mx.google.com with ESMTPS id u14-20020a17090341ce00b001c9ca0167e2si10221556ple.420.2023.11.06.16.01.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 16:01:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) client-ip=23.128.96.35; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=di7VKaUx; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.35 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 4E4D180984A5; Mon, 6 Nov 2023 16:01:40 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233453AbjKGAAn (ORCPT + 33 others); Mon, 6 Nov 2023 19:00:43 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56064 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233324AbjKGAAf (ORCPT ); Mon, 6 Nov 2023 19:00:35 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86D40125 for ; Mon, 6 Nov 2023 16:00:32 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id 41be03b00d2f7-5bd099e3d3cso3203088a12.1 for ; Mon, 06 Nov 2023 16:00:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1699315232; x=1699920032; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=nExiIqIE5poHUcHshO31rcWQ0P0GIrJm7ZyDGwrfXOM=; b=di7VKaUxngbg8IQhlM8x2RHuBEEsryoe0ZvybcK2NlieybH6aIAjnllIA6lHNZ386s KP1AvoOrPrDe/A2UuThOMDr5JBF3+nnmxiR0sOObW0IVYaliNPQ7Kncb2FTeHkIJ0pAU y4HsMW4qPYVMC/HnrkglFei1MI+fFSJXKx7Oo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699315232; x=1699920032; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nExiIqIE5poHUcHshO31rcWQ0P0GIrJm7ZyDGwrfXOM=; b=pB8sgpokWEmoOpEXmA4k3bonl8nRGpzpL/iScXvvEiPsR4a8jtEtBnayikvDdYzRAK qC0aCgzIvF+KA8P5mWzPQ0pdmHmMUxBRmUoNITnt4Sa1PhhIX+1F+RluAIbgHgbJT3+T 2by+XgP8EgFh6yShMFL7wwwmtX2BlTLHrbqAQhDvXDkqfaAsO1XGa6o/HOtaPbL4Su/U ShXm0LEWRn0ZCOW8+sgUlY5+ThHUqjIfM9gMe1vGXXBL5RzVRtuxPTSimINTeNW6KJoo uznx2kZOSXdWmTI2nahqbblNuq+7OkphbE3IcLInQAlOvxFjqCyXX+baSwfJu3kKRALw 3BAQ== X-Gm-Message-State: AOJu0YxxWfV3ZyvjNsPRY5hcxUAHTdIvcPcXH1HjlNRuY41ZvtDGj667 HQOloENw5H+6+xfxEu3UXxyOfQ== X-Received: by 2002:a17:90b:3746:b0:280:c85d:450 with SMTP id ne6-20020a17090b374600b00280c85d0450mr11795381pjb.44.1699315231923; Mon, 06 Nov 2023 16:00:31 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:586c:80a1:e007:beb9]) by smtp.gmail.com with ESMTPSA id fw11-20020a17090b128b00b00268b439a0cbsm5852866pjb.23.2023.11.06.16.00.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Nov 2023 16:00:31 -0800 (PST) From: Hsin-Yi Wang To: Douglas Anderson Cc: Neil Armstrong , Jessica Zhang , Sam Ravnborg , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCH v5 3/4] drm/panel-edp: Add override_edid_mode quirk for generic edp Date: Mon, 6 Nov 2023 15:51:34 -0800 Message-ID: <20231107000023.2928195-4-hsinyi@chromium.org> X-Mailer: git-send-email 2.42.0.869.gea05f2083d-goog In-Reply-To: <20231107000023.2928195-1-hsinyi@chromium.org> References: <20231107000023.2928195-1-hsinyi@chromium.org> MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Mon, 06 Nov 2023 16:01:40 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1781861245148174272 X-GMAIL-MSGID: 1781861245148174272 Generic edp gets mode from edid. However, some panels report incorrect mode in this way, resulting in glitches on panel. Introduce a new quirk additional_mode to the generic edid to pick a correct hardcoded mode. Signed-off-by: Hsin-Yi Wang Reviewed-by: Douglas Anderson --- v4->v5: fix coding style comments from v4. --- drivers/gpu/drm/panel/panel-edp.c | 67 ++++++++++++++++++++++++++++--- 1 file changed, 62 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index 599a949d74d1..c0c24d94c3a0 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -203,6 +203,9 @@ struct edp_panel_entry { /** @name: Name of this panel (for printing to logs). */ const char *name; + + /** @override_edid_mode: Override the mode obtained by edid. */ + const struct drm_display_mode *override_edid_mode; }; struct panel_edp { @@ -301,6 +304,24 @@ static unsigned int panel_edp_get_display_modes(struct panel_edp *panel, return num; } +static int panel_edp_override_edid_mode(struct panel_edp *panel, + struct drm_connector *connector, + const struct drm_display_mode *override_mode) +{ + struct drm_display_mode *mode; + + mode = drm_mode_duplicate(connector->dev, override_mode); + if (!mode) { + dev_err(panel->base.dev, "failed to add additional mode\n"); + return 0; + } + + mode->type |= DRM_MODE_TYPE_DRIVER | DRM_MODE_TYPE_PREFERRED; + drm_mode_set_name(mode); + drm_mode_probed_add(connector, mode); + return 1; +} + static int panel_edp_get_non_edid_modes(struct panel_edp *panel, struct drm_connector *connector) { @@ -568,6 +589,9 @@ static int panel_edp_get_modes(struct drm_panel *panel, { struct panel_edp *p = to_panel_edp(panel); int num = 0; + bool has_override_edid_mode = p->detected_panel && + p->detected_panel != ERR_PTR(-EINVAL) && + p->detected_panel->override_edid_mode; /* probe EDID if a DDC bus is available */ if (p->ddc) { @@ -575,9 +599,18 @@ static int panel_edp_get_modes(struct drm_panel *panel, if (!p->edid) p->edid = drm_get_edid(connector, p->ddc); - - if (p->edid) - num += drm_add_edid_modes(connector, p->edid); + if (p->edid) { + if (has_override_edid_mode) { + /* + * override_edid_mode is specified. Use + * override_edid_mode instead of from edid. + */ + num += panel_edp_override_edid_mode(p, connector, + p->detected_panel->override_edid_mode); + } else { + num += drm_add_edid_modes(connector, p->edid); + } + } pm_runtime_mark_last_busy(panel->dev); pm_runtime_put_autosuspend(panel->dev); @@ -950,6 +983,19 @@ static const struct panel_desc auo_b101ean01 = { }, }; +static const struct drm_display_mode auo_b116xa3_mode = { + .clock = 70589, + .hdisplay = 1366, + .hsync_start = 1366 + 40, + .hsync_end = 1366 + 40 + 40, + .htotal = 1366 + 40 + 40 + 32, + .vdisplay = 768, + .vsync_start = 768 + 10, + .vsync_end = 768 + 10 + 12, + .vtotal = 768 + 10 + 12 + 6, + .flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC, +}; + static const struct drm_display_mode auo_b116xak01_mode = { .clock = 69300, .hdisplay = 1366, @@ -1878,6 +1924,15 @@ static const struct panel_delay delay_200_150_e200 = { .delay = _delay \ } +#define EDP_PANEL_ENTRY2(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _delay, _name, _mode) \ +{ \ + .name = _name, \ + .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ + product_id), \ + .delay = _delay, \ + .override_edid_mode = _mode \ +} + /* * This table is used to figure out power sequencing delays for panels that * are detected by EDID. Entries here may point to entries in the @@ -1895,9 +1950,11 @@ static const struct edp_panel_entry edp_panels[] = { EDP_PANEL_ENTRY('A', 'U', 'O', 0x239b, &delay_200_500_e50, "B116XAN06.1"), EDP_PANEL_ENTRY('A', 'U', 'O', 0x255c, &delay_200_500_e50, "B116XTN02.5"), EDP_PANEL_ENTRY('A', 'U', 'O', 0x403d, &delay_200_500_e50, "B140HAN04.0"), - EDP_PANEL_ENTRY('A', 'U', 'O', 0x405c, &auo_b116xak01.delay, "B116XAK01.0"), + EDP_PANEL_ENTRY2('A', 'U', 'O', 0x405c, &auo_b116xak01.delay, "B116XAK01.0", + &auo_b116xa3_mode), EDP_PANEL_ENTRY('A', 'U', 'O', 0x582d, &delay_200_500_e50, "B133UAN01.0"), - EDP_PANEL_ENTRY('A', 'U', 'O', 0x615c, &delay_200_500_e50, "B116XAN06.1"), + EDP_PANEL_ENTRY2('A', 'U', 'O', 0x615c, &delay_200_500_e50, "B116XAN06.1", + &auo_b116xa3_mode), EDP_PANEL_ENTRY('A', 'U', 'O', 0x635c, &delay_200_500_e50, "B116XAN06.3"), EDP_PANEL_ENTRY('A', 'U', 'O', 0x639c, &delay_200_500_e50, "B140HAK02.7"), EDP_PANEL_ENTRY('A', 'U', 'O', 0x8594, &delay_200_500_e50, "B133UAN01.0"),