Received: by 2002:ab2:3319:0:b0:1ef:7a0f:c32d with SMTP id i25csp206271lqc; Thu, 7 Mar 2024 15:07:42 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUJgylzlAkawmL9TV63gooun4uiKufG6QQB5dIuDGC7pjXqlQQEpZx9BTVOerW32xxS0I4yc/g6kSxgKrOhZgDBYJz/YRzdJfNflG0A2A== X-Google-Smtp-Source: AGHT+IHCGZOhtABWWkjxr4yG6rBtQBTlupKmp1jvPGlkvTJfyRJNqU1MKAxGOtkNJH+2/McxsrkV X-Received: by 2002:a05:6122:7c9:b0:4c8:979d:8137 with SMTP id l9-20020a05612207c900b004c8979d8137mr9490809vkr.3.1709852861895; Thu, 07 Mar 2024 15:07:41 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709852861; cv=pass; d=google.com; s=arc-20160816; b=WaD3/GvqQweT3/oEztD7AOUknfglWPcSZ3lnztCegRQzIE43EqIXumGVkRUt493npH rrsq+q7UuNRJw8I8Bvdrd2B1PNUtiqB60N4DUhDmm58UapEZ7RwTTHDHSP8GB5acrUJf wT4LvoH3NyX9XH0JcCSPm7ASVNFKIaG89dAWhfYkHCKhjoBvJI4T/hREvS1ZD2mDBS0R fmmZbOrXHKlazaGqfLOofukuhr1n+I+hsQ3RbJQkv2WqQgbvVsqKe6LwTMZtOe6MvjGa twRHEezIoV0hVvBlpFRPDbaBwYwD63RmukO8AUdRaXbmwi0Ce7Vk8qd+X8r/bJNGdU/y bomQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=kB/qX4HZuCvCcxbPmER5bpPaaStWtmbIuwHw3vs9CPk=; fh=YRLJlQLHIDmDxB0W4Bd8K7W7916fvK8ycB4qPv9r0EI=; b=tNs0V1XKpKco5cUHiX/nXTPdyFmIpHwR7B86dyHUTd6pQtiQ6nlrGzmEENzjoRMMzE xsD1qaVt8J0NiNm+rrwN4ogM6AesxqEJKBdukI7HPO51kxABPkeVPWOAKIoyZOU0w1lS VU08OOUxJOW/yQfX0nNaZfeOkQrEss+9QbZ3CbbKyG0IGhSAskjRy71F5nHJVLep23+3 PdDmMUF+BjF2HJMlFHTS8TxYc8lNKiR76XrAC00IsPqKljW73FtwixBzbfrAs7KL4M0R MWk3dLpfvL0iyW+Q8btVCqhvJczn5CryioQzhVC7r1gMSjeNPzCyKLFFaK18MBL8JB09 EGTQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=G41LXorD; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-96350-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96350-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id t14-20020a05622a180e00b0042efaed212bsi8601097qtc.154.2024.03.07.15.07.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 15:07:41 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-96350-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=G41LXorD; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-96350-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-96350-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 8F3C71C21041 for ; Thu, 7 Mar 2024 23:07:41 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 607BB4D106; Thu, 7 Mar 2024 23:07:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="G41LXorD" Received: from mail-pl1-f170.google.com (mail-pl1-f170.google.com [209.85.214.170]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A41A141C6A for ; Thu, 7 Mar 2024 23:07:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.170 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709852823; cv=none; b=c31Cykr1RTXHyFgaa1NK8yZsZ1T9CEz0R1wh9cBvlMjnw4FgE9y1wsP7EOGoYXMfrsj/BmNqvryIcVnIqTgcIlOiJgMnahpqY3ZOBAIFmn1bACyfn7glqvKK5uUmQIAFAFt9PxRapvNkRtkOxmnK2UK3WFliP+r32AUTeCyom3Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709852823; c=relaxed/simple; bh=kb9bxub8TItIW7WdLtYnLTeYMFRFguGXIAzWxunEwlo=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=KEsJECiErDj7l6O31er9iNaHPAyM2m7CynUtVf5zmGxwQNv1OImkGhDxIQqxxiDY2wkFYhXvLojYSv6WumCege8+e9Zn6XyZVr5HOeOEfGDI07y7eUVG1i7Q/EHy0vGmrOK1+GmtSfxRMBA06eoKPKR9HJ6+sIhJBvLwmWzRNeI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=G41LXorD; arc=none smtp.client-ip=209.85.214.170 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-pl1-f170.google.com with SMTP id d9443c01a7336-1dc1ff58fe4so11108405ad.1 for ; Thu, 07 Mar 2024 15:07:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709852821; x=1710457621; 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=kB/qX4HZuCvCcxbPmER5bpPaaStWtmbIuwHw3vs9CPk=; b=G41LXorDEmU+q7cDo8TDsHt8HSFh/FOt/MAaab98yokfEyzFCtjINPR6CWeoA3P99c ceGYSj0tsP0hLFS05GfFWjpduOZBOvrimuRpxRpVh+hum6t8TSwy5+/OLse5eaMegYvP OmGWtSrC16Mr7QuXODHx6r1NKKOLGQ8+uKKtA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709852821; x=1710457621; 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=kB/qX4HZuCvCcxbPmER5bpPaaStWtmbIuwHw3vs9CPk=; b=nDn1YdaOhYC6QxiTjXiCsfu9T73oKVznsnwQpEGEsdpDiLq3GGVpJCXuEOK9+dMryI kVUfo57EmQNEimdTHAcFLuqJI8hKCJ05ZBUPRzwB+USKWxMN5bBnSnLvzbb5E51A4DIF vWimcYWmNa3PTRRao/n5L5Fz+Q2MOvT+PYNuOdmn/HCd+pH5DtPz5bTru5iXGNBsPgeX GfZotl/tmFZZpL3KjWiARsdVk0YjHU/LJY8BMsKKcpq43G/Vnzn1hcyoYqIKmDO5phhK 8a/+fdkjylMhnSpf5//4Aug18zZ2pKcy8bw+Y69d6VNXL7ncGSDFk7/IbkrrtCAilO+6 7ZIg== X-Forwarded-Encrypted: i=1; AJvYcCWknYJN6pdFaS1xI9DgxLNLd1aTHUUqZ/BrdvKZSeG/wDLgHmyH/7ysN/z1LeTt3RA9SqQQwwGqLff3tIZGYKohryI0y58PobSv5Zd3 X-Gm-Message-State: AOJu0YxNGwNFwsvLRfANUM/txppqU8xetPy1sNf23xcq8XzgSrIMWPej kuFiaVPjE+VHgxay28vOGsuDC4ycr9udaJnOed1faHheCeZOuMKy4FDPVArYqA== X-Received: by 2002:a17:902:d58d:b0:1dc:bb8e:d28f with SMTP id k13-20020a170902d58d00b001dcbb8ed28fmr2842865plh.66.1709852821077; Thu, 07 Mar 2024 15:07:01 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:bf8f:10d4:f877:bee3]) by smtp.gmail.com with ESMTPSA id h19-20020a170902f2d300b001db63cfe07dsm15196654plc.283.2024.03.07.15.07.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 Mar 2024 15:07:00 -0800 (PST) From: Hsin-Yi Wang To: Jani Nikula , Dmitry Baryshkov , 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 Subject: [PATCH v6 4/5] drm/panel-edp: Match edp_panels with panel identity Date: Thu, 7 Mar 2024 14:57:44 -0800 Message-ID: <20240307230653.1807557-5-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240307230653.1807557-1-hsinyi@chromium.org> References: <20240307230653.1807557-1-hsinyi@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit It's found that some panels have variants that they share the same panel id although their EDID and names are different. When matching generic edp panels, we should first match with both panel identity, which contains both panel id and panel name. If not found, match with panel id only. Signed-off-by: Hsin-Yi Wang Reviewed-by: Douglas Anderson --- v5->v6: add some comments. --- drivers/gpu/drm/panel/panel-edp.c | 50 +++++++++++++++++++------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index fe51680feb61..7f749b17df85 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -210,15 +210,12 @@ struct panel_desc { * struct edp_panel_entry - Maps panel ID to delay / panel name. */ struct edp_panel_entry { - /** @panel_id: 32-bit ID for panel, encoded with drm_edid_encode_panel_id(). */ - u32 panel_id; + /** @ident: edid identity used for panel matching. */ + const struct drm_edid_ident ident; /** @delay: The power sequencing delays needed for this panel. */ const struct panel_delay *delay; - /** @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; }; @@ -691,7 +688,7 @@ static int detected_panel_show(struct seq_file *s, void *data) else if (!p->detected_panel) seq_puts(s, "HARDCODED\n"); else - seq_printf(s, "%s\n", p->detected_panel->name); + seq_printf(s, "%s\n", p->detected_panel->ident.name); return 0; } @@ -761,7 +758,7 @@ static void panel_edp_parse_panel_timing_node(struct device *dev, dev_err(dev, "Reject override mode: No display_timing found\n"); } -static const struct edp_panel_entry *find_edp_panel(u32 panel_id); +static const struct edp_panel_entry *find_edp_panel(u32 panel_id, const struct drm_edid *edid); static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel) { @@ -799,7 +796,6 @@ static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel) base_block = drm_edid_read_base_block(panel->ddc); if (base_block) { panel_id = drm_edid_get_panel_id(base_block); - drm_edid_free(base_block); } else { dev_err(dev, "Couldn't identify panel via EDID\n"); ret = -EIO; @@ -807,7 +803,9 @@ static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel) } drm_edid_decode_panel_id(panel_id, vend, &product_id); - panel->detected_panel = find_edp_panel(panel_id); + panel->detected_panel = find_edp_panel(panel_id, base_block); + + drm_edid_free(base_block); /* * We're using non-optimized timings and want it really obvious that @@ -840,7 +838,7 @@ static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel) panel->detected_panel = ERR_PTR(-EINVAL); } else { dev_info(dev, "Detected %s %s (%#06x)\n", - vend, panel->detected_panel->name, product_id); + vend, panel->detected_panel->ident.name, product_id); /* Update the delay; everything else comes from EDID */ desc->delay = *panel->detected_panel->delay; @@ -1954,17 +1952,21 @@ static const struct panel_delay delay_200_500_e50_po2e200 = { #define EDP_PANEL_ENTRY(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _delay, _name) \ { \ - .name = _name, \ - .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ - product_id), \ + .ident = { \ + .name = _name, \ + .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ + product_id), \ + }, \ .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), \ + .ident = { \ + .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 \ } @@ -2111,15 +2113,25 @@ static const struct edp_panel_entry edp_panels[] = { { /* sentinal */ } }; -static const struct edp_panel_entry *find_edp_panel(u32 panel_id) +static const struct edp_panel_entry *find_edp_panel(u32 panel_id, const struct drm_edid *edid) { const struct edp_panel_entry *panel; if (!panel_id) return NULL; - for (panel = edp_panels; panel->panel_id; panel++) - if (panel->panel_id == panel_id) + /* + * Match with identity first. This allows handling the case where + * vendors incorrectly reused the same panel ID for multiple panels that + * need different settings. If there's no match, try again with panel + * ID, which should be unique. + */ + for (panel = edp_panels; panel->ident.panel_id; panel++) + if (drm_edid_match(edid, &panel->ident)) + return panel; + + for (panel = edp_panels; panel->ident.panel_id; panel++) + if (panel->ident.panel_id == panel_id) return panel; return NULL; -- 2.44.0.278.ge034bb2e1d-goog