From patchwork Mon Mar 4 19:44:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 13581159 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B0E0C48BF6 for ; Mon, 4 Mar 2024 19:52:24 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 18239112522; Mon, 4 Mar 2024 19:52:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ITp8STN6"; dkim-atps=neutral Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2775311250F for ; Mon, 4 Mar 2024 19:52:19 +0000 (UTC) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6e622b46f45so1062529b3a.1 for ; Mon, 04 Mar 2024 11:52:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709581938; x=1710186738; darn=lists.freedesktop.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=HAdbgCmL1JUyU1z1fzxxTd742Zn0pWVogzMahWVRBAc=; b=ITp8STN65T6v5sSPuKn76nCCp8ZlekBwwXhWN6ABqmKu0rYGr7bGjtmg2UnYNfT28+ eiGeurA+zqvFmF01s8ghDcpDEIk/1Q91+ctX9+Tr8hRazdBpTd06pB+Yb9HA0Pcb/rGq 7zBL1lwYbYWnF3pw2elFwRRGREOQekNfTkR5A= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709581938; x=1710186738; 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=HAdbgCmL1JUyU1z1fzxxTd742Zn0pWVogzMahWVRBAc=; b=dwTFNa1N6JYzqY9Lw0WfW5F3N4w4chYR5IefU/CUPabDe8nogpkTSN8tr+PpnDvYkQ i+iGbuGghoWAQEn2HdqTTTXfqV4nCdjuHZs070EKo7gsgesFR+vHAZtaVO8r8wOp2Bpl atBKZkxVAZCl4SRUpTya14TSGzyxBBqjjYr53maalXwT80lG27nCcSqUTlE5agMsUFX+ yHkIw9OAlNDnXYZSVwVhf2SrWmJZOnHs3jEX6grsSbeXrJCSL9JlHa1GFWvY4pzkJZpq YxYRWZGhtdzRcliBDVU/zYXfwmAvfyxZELTvDuz1531ehzEXBmPf3YkUy9UAO+TDjmCv szxQ== X-Forwarded-Encrypted: i=1; AJvYcCU+8NJY+q/IoBSIB5cnAs5LEB49qHArW+D0cbrt6oUzdSWAsniBIvFeCv3y3RfrpoqEkt0DNDyWqS/eTQYZdUFZ/NvX+lWiHdJshGc7qb/D X-Gm-Message-State: AOJu0YxY6UPcaYijrocO5tYCffuuKyr17IVqCoWyRxgw3oECUMr84W3f V1JGtxQqJp1FS9nvAm21VcJh1KxNLxK7GrdpIllxeyqOHtFeAkgh3RzSFQ+yHg== X-Google-Smtp-Source: AGHT+IEOm+QcTl+86EEesCT2u/ZrmLwlc+r86Qai/ywJyBFgaBRFx4FVe6nrbf26Cfl3UKz5fVXo+Q== X-Received: by 2002:aa7:8714:0:b0:6e6:136b:cfc with SMTP id b20-20020aa78714000000b006e6136b0cfcmr3990091pfo.4.1709581938522; Mon, 04 Mar 2024 11:52:18 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:bcf3:25da:25cd:199]) by smtp.gmail.com with ESMTPSA id r27-20020aa7845b000000b006e04d2be954sm7600820pfn.187.2024.03.04.11.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 11:52:18 -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 Subject: [PATCH v3 1/4] drm_edid: Add a function to get EDID base block Date: Mon, 4 Mar 2024 11:44:56 -0800 Message-ID: <20240304195214.14563-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog In-Reply-To: <20240304195214.14563-1-hsinyi@chromium.org> References: <20240304195214.14563-1-hsinyi@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" It's found that some panels have variants that they share the same panel id although their EDID and names are different. Besides panel id, now we need more information from the EDID base block to distinguish these panel variants. Add drm_edid_get_base_block() to return the EDID base block, which is introduced as a new type edid_base_block with the same layout as edid. Caller can further use it to get panel id or check if the block contains certain strings, such as panel name. Signed-off-by: Hsin-Yi Wang --- v2->v3: change back to return only the first block. --- drivers/gpu/drm/drm_edid.c | 58 ++++++++++++++++++------------- drivers/gpu/drm/panel/panel-edp.c | 8 +++-- include/drm/drm_edid.h | 7 +++- 3 files changed, 45 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 923c4423151c..13454bc64ca2 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2770,58 +2770,66 @@ static u32 edid_extract_panel_id(const struct edid *edid) } /** - * drm_edid_get_panel_id - Get a panel's ID through DDC - * @adapter: I2C adapter to use for DDC + * drm_edid_get_panel_id - Get a panel's ID from EDID base block + * @base_block: EDID base block that contains panel ID. * - * This function reads the first block of the EDID of a panel and (assuming + * This function uses the first block of the EDID of a panel and (assuming * that the EDID is valid) extracts the ID out of it. The ID is a 32-bit value * (16 bits of manufacturer ID and 16 bits of per-manufacturer ID) that's * supposed to be different for each different modem of panel. * + * Return: A 32-bit ID that should be different for each make/model of panel. + * See the functions drm_edid_encode_panel_id() and + * drm_edid_decode_panel_id() for some details on the structure of this + * ID. + */ +u32 drm_edid_get_panel_id(struct edid_base_block *base_block) +{ + return edid_extract_panel_id(&base_block->edid); +} +EXPORT_SYMBOL(drm_edid_get_panel_id); + +/** + * drm_edid_get_base_block - Get a panel's EDID base block + * @adapter: I2C adapter to use for DDC + * + * This function returns the first block of the EDID of a panel. + * * This function is intended to be used during early probing on devices where * more than one panel might be present. Because of its intended use it must - * assume that the EDID of the panel is correct, at least as far as the ID - * is concerned (in other words, we don't process any overrides here). + * assume that the EDID of the panel is correct, at least as far as the base + * block is concerned (in other words, we don't process any overrides here). * * NOTE: it's expected that this function and drm_do_get_edid() will both * be read the EDID, but there is no caching between them. Since we're only * reading the first block, hopefully this extra overhead won't be too big. * - * Return: A 32-bit ID that should be different for each make/model of panel. - * See the functions drm_edid_encode_panel_id() and - * drm_edid_decode_panel_id() for some details on the structure of this - * ID. + * Caller should free the base block after use. + * + * Return: Pointer to allocated EDID base block, or NULL if failed. */ - -u32 drm_edid_get_panel_id(struct i2c_adapter *adapter) +struct edid_base_block *drm_edid_get_base_block(struct i2c_adapter *adapter) { enum edid_block_status status; void *base_block; - u32 panel_id = 0; - - /* - * There are no manufacturer IDs of 0, so if there is a problem reading - * the EDID then we'll just return 0. - */ base_block = kzalloc(EDID_LENGTH, GFP_KERNEL); if (!base_block) - return 0; + return NULL; status = edid_block_read(base_block, 0, drm_do_probe_ddc_edid, adapter); edid_block_status_print(status, base_block, 0); - if (edid_block_status_valid(status, edid_block_tag(base_block))) - panel_id = edid_extract_panel_id(base_block); - else + if (!edid_block_status_valid(status, edid_block_tag(base_block))) { edid_block_dump(KERN_NOTICE, base_block, 0); + kfree(base_block); + return NULL; + } - kfree(base_block); - - return panel_id; + return base_block; } -EXPORT_SYMBOL(drm_edid_get_panel_id); +EXPORT_SYMBOL(drm_edid_get_base_block); /** * drm_get_edid_switcheroo - get EDID data for a vga_switcheroo output diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index 745f3e48f02a..fc2d648fd3ab 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -766,6 +766,7 @@ static const struct edp_panel_entry *find_edp_panel(u32 panel_id); static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel) { struct panel_desc *desc; + struct edid_base_block *base_block; u32 panel_id; char vend[4]; u16 product_id; @@ -795,8 +796,11 @@ static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel) goto exit; } - panel_id = drm_edid_get_panel_id(panel->ddc); - if (!panel_id) { + base_block = drm_edid_get_base_block(panel->ddc); + if (base_block) { + panel_id = drm_edid_get_panel_id(base_block); + kfree(base_block); + } else { dev_err(dev, "Couldn't identify panel via EDID\n"); ret = -EIO; goto exit; diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 7923bc00dc7a..2455d6ab2221 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -312,6 +312,10 @@ struct edid { u8 checksum; } __packed; +struct edid_base_block { + struct edid edid; +} __packed; + #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8)) /* Short Audio Descriptor */ @@ -410,7 +414,8 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, void *data); struct edid *drm_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter); -u32 drm_edid_get_panel_id(struct i2c_adapter *adapter); +struct edid_base_block *drm_edid_get_base_block(struct i2c_adapter *adapter); +u32 drm_edid_get_panel_id(struct edid_base_block *base_block); struct edid *drm_get_edid_switcheroo(struct drm_connector *connector, struct i2c_adapter *adapter); struct edid *drm_edid_duplicate(const struct edid *edid); From patchwork Mon Mar 4 19:44:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 13581158 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 0EA3CC5478C for ; Mon, 4 Mar 2024 19:52:21 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D0F28112520; Mon, 4 Mar 2024 19:52:20 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="Yrlxn8cQ"; dkim-atps=neutral Received: from mail-pf1-f180.google.com (mail-pf1-f180.google.com [209.85.210.180]) by gabe.freedesktop.org (Postfix) with ESMTPS id 105C811251F for ; Mon, 4 Mar 2024 19:52:20 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6e6277f72d8so836319b3a.1 for ; Mon, 04 Mar 2024 11:52:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709581939; x=1710186739; darn=lists.freedesktop.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=Oeg1ks8Z5TiI329gqNMDbm7TYAS4q9yMPCP31gjx14E=; b=Yrlxn8cQa2nhWBiV2pyitXGh5xy7BwJx2PtGOp/Z2ApGLxl6vNc27pPSHLPXqYqD75 Lnawr2Cx+XJ4FVlSJKfGvVOQogUi+rTf44ldY7hNh0MplIKwoJMozO+08XQ36tL1uB1a pdhCnppjT1rScDfSD+kVv5tqweaLSPUkJasB8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709581939; x=1710186739; 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=Oeg1ks8Z5TiI329gqNMDbm7TYAS4q9yMPCP31gjx14E=; b=MYqIieKfjXVKUQFJ7AngdOEfRqCkuRNyFrQBvuokECqzsKuEU3LhbPEelPMKHr4RO5 jzwAAnXyTU9GHhP///NyiZFaiX6xYNBmE/JsyediMLVqI/hwaUq41f+Z1n0kHgxl4o9V kamVMCBfvKXt5wak948FJPPwluyBv2skBSlFnluhCnlDGpWGaHx9cGbT+mSKYEbSiFUv Gh7LN9bSkKa43tqcswNjDmfqpuruwG4ZAFZDsHUwIuUwKRpY9L2gxV/1wUFLL8bl+8fa ZG/xPraOyJto9oP9VHEcE6uI2j98lWvjq5oYGagsUZohKV1t4t8g08qwdh6lX3FMpTp8 kIEA== X-Forwarded-Encrypted: i=1; AJvYcCXEm+GK/rctrytdVRyIH1ubEkVw6mDJ6O73NmiRLLUHOoC4EhAtUMbTAfwbRPeAyNpKFoAxZxugDquD4xdDPArS2yPt8KNeuJiXUMdTrrDZ X-Gm-Message-State: AOJu0YxkgAoJxIBqGWKU4cJhFW9TmtKYpVf6EU1CVjchc7VjrJDQeyD9 4MZL/CxOzUS1khD9Nyl/TgMnvB0ulgnxXpi3pgw9IKUPDnfJM1lk43oo5HuDUw== X-Google-Smtp-Source: AGHT+IHLmXC5K65w/XvN1QDNXYVbf7LPTiLwzZQXv2LlpjmfZV2obLbzbD8eHFHeFT4rlwCqsjH5GQ== X-Received: by 2002:a05:6a20:3d01:b0:1a1:14f2:4b70 with SMTP id y1-20020a056a203d0100b001a114f24b70mr9419789pzi.22.1709581939567; Mon, 04 Mar 2024 11:52:19 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:bcf3:25da:25cd:199]) by smtp.gmail.com with ESMTPSA id r27-20020aa7845b000000b006e04d2be954sm7600820pfn.187.2024.03.04.11.52.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 11:52:19 -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 Subject: [PATCH v3 2/4] drm/edid: Add a function to check monitor string Date: Mon, 4 Mar 2024 11:44:57 -0800 Message-ID: <20240304195214.14563-3-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog In-Reply-To: <20240304195214.14563-1-hsinyi@chromium.org> References: <20240304195214.14563-1-hsinyi@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Add a function to check if the EDID base block contains a given string. One of the use cases is fetching panel from a list of panel names, since some panel vendors put the monitor name after EDID_DETAIL_MONITOR_STRING instead of EDID_DETAIL_MONITOR_NAME. Signed-off-by: Hsin-Yi Wang --- v2->v3: move string matching to drm_edid --- drivers/gpu/drm/drm_edid.c | 49 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 1 + 2 files changed, 50 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 13454bc64ca2..fcdc2bd143dd 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2789,6 +2789,55 @@ u32 drm_edid_get_panel_id(struct edid_base_block *base_block) } EXPORT_SYMBOL(drm_edid_get_panel_id); +/** + * drm_edid_has_monitor_string - Check if a EDID base block has certain string. + * @base_block: EDID base block to check. + * @str: pointer to a character array to hold the string to be checked. + * + * Check if the detailed timings section of a EDID base block has the given + * string. + * + * Return: True if the EDID base block contains the string, false otherwise. + */ +bool drm_edid_has_monitor_string(struct edid_base_block *base_block, const char *str) +{ + unsigned int i, j, k, buflen = strlen(str); + + for (i = 0; i < EDID_DETAILED_TIMINGS; i++) { + struct detailed_timing *timing = &base_block->edid.detailed_timings[i]; + unsigned int size = ARRAY_SIZE(timing->data.other_data.data.str.str); + + if (buflen > size || timing->pixel_clock != 0 || + timing->data.other_data.pad1 != 0 || + (timing->data.other_data.type != EDID_DETAIL_MONITOR_NAME && + timing->data.other_data.type != EDID_DETAIL_MONITOR_STRING)) + continue; + + for (j = 0; j < buflen; j++) { + char c = timing->data.other_data.data.str.str[j]; + + if (c != str[j] || c == '\n') + break; + } + + if (j == buflen) { + /* Allow trailing white spaces. */ + for (k = j; k < size; k++) { + char c = timing->data.other_data.data.str.str[k]; + + if (c == '\n') + return true; + else if (c != ' ') + break; + } + if (k == size) + return true; + } + } + + return false; +} + /** * drm_edid_get_base_block - Get a panel's EDID base block * @adapter: I2C adapter to use for DDC diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 2455d6ab2221..248ddb0a6b5d 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -416,6 +416,7 @@ struct edid *drm_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter); struct edid_base_block *drm_edid_get_base_block(struct i2c_adapter *adapter); u32 drm_edid_get_panel_id(struct edid_base_block *base_block); +bool drm_edid_has_monitor_string(struct edid_base_block *base_block, const char *str); struct edid *drm_get_edid_switcheroo(struct drm_connector *connector, struct i2c_adapter *adapter); struct edid *drm_edid_duplicate(const struct edid *edid); From patchwork Mon Mar 4 19:44:58 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 13581160 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8B05AC5478C for ; Mon, 4 Mar 2024 19:52:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B9F70112521; Mon, 4 Mar 2024 19:52:22 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DWrRk/62"; dkim-atps=neutral Received: from mail-pf1-f176.google.com (mail-pf1-f176.google.com [209.85.210.176]) by gabe.freedesktop.org (Postfix) with ESMTPS id 18DD5112521 for ; Mon, 4 Mar 2024 19:52:20 +0000 (UTC) Received: by mail-pf1-f176.google.com with SMTP id d2e1a72fcca58-6e635b772eeso422085b3a.2 for ; Mon, 04 Mar 2024 11:52:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709581940; x=1710186740; darn=lists.freedesktop.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=T3Jp14BDf8QPEEvMzAymcf9k4zD9ixOAGCQ7prLq3JA=; b=DWrRk/620e/vTJanaa5V0Xx5XeAlS98aVObFwPGV/clw5kYtG7CZUqYImwjt+FzZtO p80tjIv/aro5UTdm5mjFEi9z3ZahqmypMKaoIlYu1/PzslJye3SkS1EkMr2gVa3XRYe3 PLagIKcG3NRaWFJgIRVszK2RaufcMfh1aKVfs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709581940; x=1710186740; 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=T3Jp14BDf8QPEEvMzAymcf9k4zD9ixOAGCQ7prLq3JA=; b=kLmVEbD6CDLTkzFsfJwD2X8p4E5lGGWW/uNQQ+u11I4NuZcYvYXxOFQncBQyL6gxy6 BxJYqwmUzB2GJlo4OPrsTuNu7KI1IdmIfwBOClbDzbpyw3mRMj1a1Y/o3bpnrbFzDNJu fhAGoNdbrJ3F/ptT/pW5tE4NlycE/c7ewLMo6P0h1M5DQixXwNx22/ozHHbgzXCmevEz txCkXLUVU3LPKsOYOhsn6vW5VjRX2tun2Ir+RGx9D0YRjyYmgEGi24yLHztKvbV0Lo1E 26Nlq+/M/5gLEQLJQyt9VuyhWAYQI9DjUU6h6OTtHSNnGw2NHMVaLJ8lBtq0/rx2fQAP FqCQ== X-Forwarded-Encrypted: i=1; AJvYcCV8HDM27usGNZBteWmVoGh0ZAZg97YVEswsGxx1rPbEcW2GYDnChUgIu35SimTWXXRBokobHWdfs3tTSZlKwA7tbTEk5el+Pbl9IjlCKGqI X-Gm-Message-State: AOJu0Yz4sbOskWs/zrHSVsONt28TNJ+FOxZIrXHiJfMNTp2xhJQ/d7gQ GDNrLLslL+x+suuRcbfdR4QbUWpnSi2c6rx5fa2jJStlZ0T1t3tNEK9N1R2gIQ== X-Google-Smtp-Source: AGHT+IHK/PazsA/rAq12BUCaXQt6do7doHeEYNnPIuOEBjQwpxHmb2OW8AC1Tseh0xuGhFovu2zIEA== X-Received: by 2002:a05:6a00:18a8:b0:6e6:21b3:cf2 with SMTP id x40-20020a056a0018a800b006e621b30cf2mr4672758pfh.8.1709581940519; Mon, 04 Mar 2024 11:52:20 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:bcf3:25da:25cd:199]) by smtp.gmail.com with ESMTPSA id r27-20020aa7845b000000b006e04d2be954sm7600820pfn.187.2024.03.04.11.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 11:52:20 -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 Subject: [PATCH v3 3/4] drm/panel: panel-edp: Match edp_panels with panel name Date: Mon, 4 Mar 2024 11:44:58 -0800 Message-ID: <20240304195214.14563-4-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog In-Reply-To: <20240304195214.14563-1-hsinyi@chromium.org> References: <20240304195214.14563-1-hsinyi@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 id and panel name by checking if edid contains the name string. If not found, match with panel id only. Signed-off-by: Hsin-Yi Wang --- v2->v3: move string matching to drm_edid --- drivers/gpu/drm/panel/panel-edp.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index fc2d648fd3ab..e3044e34c5f8 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -761,7 +761,8 @@ 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, + struct edid_base_block *base_block); static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel) { @@ -799,7 +800,6 @@ static int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel) base_block = drm_edid_get_base_block(panel->ddc); if (base_block) { panel_id = drm_edid_get_panel_id(base_block); - kfree(base_block); } else { dev_err(dev, "Couldn't identify panel via EDID\n"); ret = -EIO; @@ -807,7 +807,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); + + kfree(base_block); /* * We're using non-optimized timings and want it really obvious that @@ -2087,13 +2089,18 @@ 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, + struct edid_base_block *base_block) { const struct edp_panel_entry *panel; - if (!panel_id) - return NULL; + /* Match with both panel_id and name */ + for (panel = edp_panels; panel->panel_id; panel++) + if (panel->panel_id == panel_id && + drm_edid_has_monitor_string(base_block, panel->name)) + return panel; + /* Match with only panel_id */ for (panel = edp_panels; panel->panel_id; panel++) if (panel->panel_id == panel_id) return panel; From patchwork Mon Mar 4 19:44:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hsin-Yi Wang X-Patchwork-Id: 13581161 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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 1B5BCC54E49 for ; Mon, 4 Mar 2024 19:52:28 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 29683112523; Mon, 4 Mar 2024 19:52:23 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="eX5QO3TJ"; dkim-atps=neutral Received: from mail-pf1-f170.google.com (mail-pf1-f170.google.com [209.85.210.170]) by gabe.freedesktop.org (Postfix) with ESMTPS id F324F112521 for ; Mon, 4 Mar 2024 19:52:21 +0000 (UTC) Received: by mail-pf1-f170.google.com with SMTP id d2e1a72fcca58-6e46dcd8feaso2752701b3a.2 for ; Mon, 04 Mar 2024 11:52:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709581941; x=1710186741; darn=lists.freedesktop.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=EMSlD4D61SNUMtl55lAIMxqBblJYN3jwwZ/l0KMGCh0=; b=eX5QO3TJdw6gpu1TdP6LP4ZHELkjCCR9TZ2zf4CNLZhTaiW2mknSXq1vKrZqb6B8Ik MOonxAmoqz/7t4b4RlfvYRBwAoU5dVxFVOXg1NtYozevhsrel7u8cFe/+RVjPleLDR3m 3wat+GzHRXvfAIuQCh58n7f7Za/CoG9yuWKYs= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709581941; x=1710186741; 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=EMSlD4D61SNUMtl55lAIMxqBblJYN3jwwZ/l0KMGCh0=; b=XA1CwadmooYO60ZqQD8wo5+5HwGD30p+2pO50StvygKHIJECIHIrXCu9aOyn/q3I8L rMxIs1NhJjVnnUezJ/g67lbX8p5405jxX5TfzkPnYntFdAar2aVdTjY7VVUvhGFipooz 7zuuI8b5AUicxhF3tEs+nPJLoSnGoGV6zrYjEjg3dvxwaeYhrIkXF5mxoByrm8OcVKo4 i0a+IWvKZK0qefxIi5Q4YDJYv5izs+B2hqqPB8/UoGQHGg74KkCFLsvkdoHOFQxbdlDd mRpdaBjy3Wqii8wiNaU7UV5mPvsuhAYmP7ZUVDN2l4SKckmt44oef69l4IjkcSBpPup6 Qx2w== X-Forwarded-Encrypted: i=1; AJvYcCUJ6fV53jIxFcH6KvftOMcm80mEVTeSPVBJ+j8GLGbYQMn/+ii/Umidnlvdqo7W47KkPmDyg/vpKo+d5/rFQa7HQ9cexCywJRFrVRlRdA+7 X-Gm-Message-State: AOJu0YwPS5TR1odJjG/Ovq4/06OpZRg45I1QKhJSRtxsaQoFAbto2YmM Y1Tk1dRp4nt93x2wFKuvuBRHDSjMukeaLlFG4qDUv0ZL8sijOk1+Mz5hrDN6ww== X-Google-Smtp-Source: AGHT+IHPtFpxTAyxqYpM+QvUFmcFVeN7dHU0wEyqkEdqd7zuA4ef1jTJ4eEAL4kK24nK/EHKqXAQdw== X-Received: by 2002:a05:6a20:e11a:b0:1a1:4d8b:8cf9 with SMTP id kr26-20020a056a20e11a00b001a14d8b8cf9mr1728648pzb.11.1709581941402; Mon, 04 Mar 2024 11:52:21 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:bcf3:25da:25cd:199]) by smtp.gmail.com with ESMTPSA id r27-20020aa7845b000000b006e04d2be954sm7600820pfn.187.2024.03.04.11.52.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 04 Mar 2024 11:52:21 -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 Subject: [PATCH v3 4/4] drm/panel: panel-edp: Fix AUO 0x405c panel naming and add a variant Date: Mon, 4 Mar 2024 11:44:59 -0800 Message-ID: <20240304195214.14563-5-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.rc1.240.g4c46232300-goog In-Reply-To: <20240304195214.14563-1-hsinyi@chromium.org> References: <20240304195214.14563-1-hsinyi@chromium.org> MIME-Version: 1.0 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" There are 2 different AUO panels using the same panel id. One of the variants requires using overridden modes to resolve glitching issue as described in commit 70e0d5550f5c ("drm/panel-edp: Add auo_b116xa3_mode"). Other variants should use the modes parsed from EDID. Signed-off-by: Hsin-Yi Wang --- v2->v3: no change. --- drivers/gpu/drm/panel/panel-edp.c | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index e3044e34c5f8..d2e181efff98 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -1011,6 +1011,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, @@ -1966,7 +1979,9 @@ 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_ENTRY('A', 'U', 'O', 0x405c, &auo_b116xak01.delay, "B116XAN04.0"), + EDP_PANEL_ENTRY2('A', 'U', 'O', 0x405c, &auo_b116xak01.delay, "B116XAK01.0 ", + &auo_b116xa3_mode), EDP_PANEL_ENTRY('A', 'U', 'O', 0x435c, &delay_200_500_e50, "Unknown"), 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"),