From patchwork Wed Mar 6 19:55:51 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: 13584609 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 8D42DC54E49 for ; Wed, 6 Mar 2024 20:04:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7F21F113500; Wed, 6 Mar 2024 20:03:59 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CcWOofzl"; 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 B8E801134FD for ; Wed, 6 Mar 2024 20:03:57 +0000 (UTC) Received: by mail-pf1-f169.google.com with SMTP id d2e1a72fcca58-6e5b1c6daa3so105904b3a.1 for ; Wed, 06 Mar 2024 12:03:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709755437; x=1710360237; 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=TO8narEInEW2sevq0mocA7Cmq1HqvsvqWDqWB03ZgLw=; b=CcWOofzl5oJC9b8moow200/SS9qyAmLeYAYZvy2vJOrkc1BJARqXvyfFUvsOu+2nuz GjQCmp8umY1OOMCembiE2YD6kFkPdNVECj5JydIwWf1WOqx+ERV0KOPbfpm3dn2/Isvy SBWmV4L1bljIqQyBm6JXzAf80D+/alEPAOUqw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709755437; x=1710360237; 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=TO8narEInEW2sevq0mocA7Cmq1HqvsvqWDqWB03ZgLw=; b=Y43a+VTFDZvjFEuvgujl+7oi29IM+Yij9ihmn97utjKY8FlqEU+Bo9HiOQ8hPxCDcM heo/cCxlIymwN1JB1AKqOcS0N5G6Zn0mMMWz1MPgDeUOkBzj9gMmBiQ/LPbNTGG1AKzR nCmtktixcQ473XL5wBLBcTJp35/XNJi5h3jGxS4o+tnRxuu7PYchEfQNHpgp7YPtyrw1 QgvUBmPlCFZiM6WHhs22L/vkQh463+EZUWlkL3FX0Zxp4AOXslg76E274j01Lyx2Y7sA pOVut44OLP74afiW/jK9mprK9jvfHBI3poGGQlQg7Nn0YNVjtTZ0QBfoRLEc64n4rgRq ybdg== X-Forwarded-Encrypted: i=1; AJvYcCW8sHJbm6orcw9TZvZ0XnMN4GGesjTR3e59JCL0G/ci03t5oRMsKd1cBy5Xc3x/fXnn1t8CPTbRHLxou3E68UvnVNr6ZwTAaHzTyMErXoxD X-Gm-Message-State: AOJu0Yxax/BSpf7KPscUVtDDvS/32h1o+NrB91Wy/uQscuJ6uLgl3fLu O+65h0y+Sv7NFeRFtpap7W8ZNBJvRaIvsu8H4sQ7mGNmno6p1WhLV8GDP9IlZw== X-Google-Smtp-Source: AGHT+IFaWxLfmbk2letB3HSWHPl2i/aon3QJrVq0CuAm8X0TzZjoFsVZYJU8YOQj3s4ApQg/9FzYNQ== X-Received: by 2002:a05:6a20:7f99:b0:1a1:49be:c81d with SMTP id d25-20020a056a207f9900b001a149bec81dmr6833171pzj.33.1709755437070; Wed, 06 Mar 2024 12:03:57 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:a215:f6c0:3224:5460]) by smtp.gmail.com with ESMTPSA id e3-20020aa79803000000b006e5667793d4sm11124241pfl.66.2024.03.06.12.03.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:03:56 -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 v5 1/6] drm_edid: Add a function to get EDID base block Date: Wed, 6 Mar 2024 11:55:51 -0800 Message-ID: <20240306200353.1436198-2-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240306200353.1436198-1-hsinyi@chromium.org> References: <20240306200353.1436198-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_read_base_block() to return the EDID base block, which is wrapped in struct drm_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 Reviewed-by: Douglas Anderson Reviewed-by: Jani Nikula --- v4->v5: use _drm_edid_alloc --- drivers/gpu/drm/drm_edid.c | 63 +++++++++++++++++++------------ drivers/gpu/drm/panel/panel-edp.c | 8 +++- include/drm/drm_edid.h | 3 +- 3 files changed, 46 insertions(+), 28 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 1ad94473e400..8c7e871eff58 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2764,58 +2764,71 @@ 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 + * @drm_edid: EDID 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(const struct drm_edid *drm_edid) +{ + return edid_extract_panel_id(drm_edid->edid); +} +EXPORT_SYMBOL(drm_edid_get_panel_id); + +/** + * drm_edid_read_base_block - Get a panel's EDID base block + * @adapter: I2C adapter to use for DDC + * + * This function returns the drm_edid containing 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). + * + * Caller should call drm_edid_free() after use. * * 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. + * WARNING: Only use this function when the connector is unknown. For example, + * during the early probe of panel. The EDID read from the function is temporary + * and should be replaced by the full EDID returned from other drm_edid_read. + * + * Return: Pointer to allocated EDID base block, or NULL on any failure. */ - -u32 drm_edid_get_panel_id(struct i2c_adapter *adapter) +const struct drm_edid *drm_edid_read_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 _drm_edid_alloc(base_block, EDID_LENGTH); } -EXPORT_SYMBOL(drm_edid_get_panel_id); +EXPORT_SYMBOL(drm_edid_read_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 3fb5fcd326a4..fe51680feb61 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; + const struct drm_edid *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_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; goto exit; diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 70ae6c290bdc..8b233865b085 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -565,7 +565,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); +const struct drm_edid *drm_edid_read_base_block(struct i2c_adapter *adapter); +u32 drm_edid_get_panel_id(const struct drm_edid *drm_edid); 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 Wed Mar 6 19:55:52 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: 13584611 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 07A58C54E41 for ; Wed, 6 Mar 2024 20:04:03 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 46309113501; Wed, 6 Mar 2024 20:04:00 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="PG/UncUe"; dkim-atps=neutral Received: from mail-pf1-f181.google.com (mail-pf1-f181.google.com [209.85.210.181]) by gabe.freedesktop.org (Postfix) with ESMTPS id 772F01134FF for ; Wed, 6 Mar 2024 20:03:58 +0000 (UTC) Received: by mail-pf1-f181.google.com with SMTP id d2e1a72fcca58-6e6568e169aso145235b3a.0 for ; Wed, 06 Mar 2024 12:03:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709755438; x=1710360238; 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=4JCkj6GVRUNO967KT3bkL0DjQ/CoTjKrWRf8htMUslg=; b=PG/UncUeAM1ikSHjNZr8a92qRwwDa6pEMH3hzDJoVnr5t37OT2WSpWm1UXXOfTvrcj HSDFeXyb8ne9gXS5HzZ8qg9tfZCv1e57e4P8NEL2gkoVXrvr8w1CCMPsWpyNmqLPAoS6 58rVRSMMm0C8Qebaz1vLYntibNj60q7yW1j3o= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709755438; x=1710360238; 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=4JCkj6GVRUNO967KT3bkL0DjQ/CoTjKrWRf8htMUslg=; b=s0McooYF9o3qYmoyaa/nkiuShZITUIBaoKdn0QL+gofVI6ABjpvY2LrFl2FLD4ubTx zhAdM7oKUqc4yV4JCushLTLP14kaiOmR4q4H2qgYD45gp2cAwpU+oD/TEpd2mXVeDYWo 9Zh5YJGFQof4WBmBS0vUME0sA99r1UhU2gaFRdl1RsCZ85tJTeH36aqZGH7PNlScFUPD fc3cmOztRt24qa65aiYPz9ay0Oi6AlTjONRTj8x/kdyiFzIaBVVRqT7PokL2hgL3EFnM 2dYxadCeb8FgvTTr2dg9edTIMyaSBUAZMssQ11gUEoU+fJZU5AwiMbTh2/nKXAQswfKQ JxyQ== X-Forwarded-Encrypted: i=1; AJvYcCXLj9fZTA9GEISeFT2aa+4VhqmLL/VxrrC50XKbL1+L0wahg8QW/9NlnMzxthwyEB1E3C9KOS81g7XynjFCagASeV92FSpd+jhU2P3/DtYQ X-Gm-Message-State: AOJu0YxxYcejMUF/7FbTTvSQHMVBN59+s+pSYLgRoM5uEgQKPS4IUb+v njg+RLnE24qif2O++2SVSr8A0/7S/ercxau7OoCuNszLfhWEG8NX68WOAokErg== X-Google-Smtp-Source: AGHT+IHUlhDXpMflxQ7aiaCnsIh19pRSvBvh8iAGRXwrLu9WFPh0MIGQKicT8WXJgg+viWcZikJTdQ== X-Received: by 2002:a05:6a00:4f8d:b0:6e6:16b5:2eac with SMTP id ld13-20020a056a004f8d00b006e616b52eacmr13189150pfb.29.1709755437897; Wed, 06 Mar 2024 12:03:57 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:a215:f6c0:3224:5460]) by smtp.gmail.com with ESMTPSA id e3-20020aa79803000000b006e5667793d4sm11124241pfl.66.2024.03.06.12.03.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:03:57 -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 v5 2/6] drm/edid: Clean up drm_edid_get_panel_id() Date: Wed, 6 Mar 2024 11:55:52 -0800 Message-ID: <20240306200353.1436198-3-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240306200353.1436198-1-hsinyi@chromium.org> References: <20240306200353.1436198-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" drm_edid_get_panel_id() now just directly call edid_extract_panel_id(). Merge them into one function. Signed-off-by: Hsin-Yi Wang Reviewed-by: Douglas Anderson Reviewed-by: Jani Nikula --- v4->v5: new --- drivers/gpu/drm/drm_edid.c | 39 ++++++++++++++++++-------------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 8c7e871eff58..febe374fa969 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -2743,8 +2743,24 @@ const struct drm_edid *drm_edid_read(struct drm_connector *connector) } EXPORT_SYMBOL(drm_edid_read); -static u32 edid_extract_panel_id(const struct edid *edid) +/** + * drm_edid_get_panel_id - Get a panel's ID from EDID + * @drm_edid: EDID that contains panel ID. + * + * 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(const struct drm_edid *drm_edid) { + const struct edid *edid = drm_edid->edid; + /* * We represent the ID as a 32-bit number so it can easily be compared * with "==". @@ -2762,25 +2778,6 @@ static u32 edid_extract_panel_id(const struct edid *edid) (u32)edid->mfg_id[1] << 16 | (u32)EDID_PRODUCT_ID(edid); } - -/** - * drm_edid_get_panel_id - Get a panel's ID from EDID - * @drm_edid: EDID that contains panel ID. - * - * 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(const struct drm_edid *drm_edid) -{ - return edid_extract_panel_id(drm_edid->edid); -} EXPORT_SYMBOL(drm_edid_get_panel_id); /** @@ -2881,7 +2878,7 @@ EXPORT_SYMBOL(drm_edid_duplicate); */ static u32 edid_get_quirks(const struct drm_edid *drm_edid) { - u32 panel_id = edid_extract_panel_id(drm_edid->edid); + u32 panel_id = drm_edid_get_panel_id(drm_edid); const struct edid_quirk *quirk; int i; From patchwork Wed Mar 6 19:55:53 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: 13584612 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 19592C54E49 for ; Wed, 6 Mar 2024 20:04:05 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 4352F113503; Wed, 6 Mar 2024 20:04:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="RdniBarA"; dkim-atps=neutral Received: from mail-pf1-f179.google.com (mail-pf1-f179.google.com [209.85.210.179]) by gabe.freedesktop.org (Postfix) with ESMTPS id 6138D1134FF for ; Wed, 6 Mar 2024 20:03:59 +0000 (UTC) Received: by mail-pf1-f179.google.com with SMTP id d2e1a72fcca58-6e55731af5cso104247b3a.0 for ; Wed, 06 Mar 2024 12:03:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709755439; x=1710360239; 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=JRJUYRt2oq67C0/LdzkUEFZ3CsguCNeMnqbNn5e2Vjw=; b=RdniBarAqYT70LyI/66/2uPw59cOpKaJg7+qIlM0pTUP5ui4WOH6At9491wjXFZB21 2A2J+a+qYslHsAjRuDOp0Vwnv1cenAN9vFhigVlroggBLpQv/lnMcCFRrNW0/gn67wlX 2SsOSoVK8W+QVMYMAtvIsYCl9jeVG2qd7Xy+0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709755439; x=1710360239; 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=JRJUYRt2oq67C0/LdzkUEFZ3CsguCNeMnqbNn5e2Vjw=; b=N/pjx9uz2z3Bksggs4y46iNkLIiOeF+BUdc3Ytc1gn/euC7gVpGPyQK0FFxdL+wRiV MSSFlP9rbxIuiTvOthYcHvwtmBsXml2QcK64DI1osGPNOpsw8ywSywq7RvhjhFqz7Akt excBi9vdKjIimMgG1B7srXKVzCqyVLtTdZs8S0naTdE87jdMv7FZuC+/FBLAyW3Iahr7 cpjnsLzeFV55WHkfI5poGt1DS5BqWVy1Jom+8as2Xn17Eiu9qUzrNfn0fKJdL8BgcCp8 1V7AHBACKRsxmDYgaLoEA38KIa/rWKQCJdB/SBG/lPctLOZSnuVb5Wi9NGtvzRiApiNG L5jg== X-Forwarded-Encrypted: i=1; AJvYcCUBG/aDr5S0VfYFWO2wxtazDLVM2Y4Ik5HnFlAXZMLxNjWwd4m+84bckFsvbbdfejcjjlZ/gHuGdzByxJl68G35JcaXJszowIEavOXaz+cq X-Gm-Message-State: AOJu0YwwyOYHWdePlU0TLV4XjKzJUyhMGks/nFOym5UB+Hu0U40rGsg1 MeFUiLmwI6dgrNdZmX6eCjq7/cVzWvNVHbl13/8FH66nf9sS/da7P8dJyuzUiw== X-Google-Smtp-Source: AGHT+IEXmTS6PLw1/iaxz3ACFLOd7WH1/YNx8U/VqwNBQW526mexbfJ/D5D3qnZ8ATCE2qu9PJRPeg== X-Received: by 2002:a05:6a00:2da3:b0:6e6:451c:a519 with SMTP id fb35-20020a056a002da300b006e6451ca519mr6034543pfb.5.1709755438763; Wed, 06 Mar 2024 12:03:58 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:a215:f6c0:3224:5460]) by smtp.gmail.com with ESMTPSA id e3-20020aa79803000000b006e5667793d4sm11124241pfl.66.2024.03.06.12.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:03:58 -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 v5 3/6] drm/edid: Add a function to match EDID with identity Date: Wed, 6 Mar 2024 11:55:53 -0800 Message-ID: <20240306200353.1436198-4-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240306200353.1436198-1-hsinyi@chromium.org> References: <20240306200353.1436198-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" Create a type drm_edid_ident as the identity of an EDID. Currently it contains panel id and monitor name. Create a function that can match a given EDID and an identity: 1. Reject if the panel id doesn't match. 2. If name is not null in identity, try to match it in the detailed timing blocks. Note that some panel vendors put the monitor name after EDID_DETAIL_MONITOR_STRING. Signed-off-by: Hsin-Yi Wang --- v4->v5: use strncmp, change function/variable names. --- drivers/gpu/drm/drm_edid.c | 65 ++++++++++++++++++++++++++++++++++++++ include/drm/drm_edid.h | 8 +++++ 2 files changed, 73 insertions(+) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index febe374fa969..29ef35ebee32 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -100,6 +100,11 @@ struct detailed_mode_closure { int modes; }; +struct drm_edid_match_closure { + const struct drm_edid_ident *ident; + bool matched; +}; + #define LEVEL_DMT 0 #define LEVEL_GTF 1 #define LEVEL_GTF2 2 @@ -5405,6 +5410,66 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db) connector->audio_latency[0], connector->audio_latency[1]); } +static void +match_identity(const struct detailed_timing *timing, void *data) +{ + struct drm_edid_match_closure *closure = data; + unsigned int i; + const char *name = closure->ident->name; + unsigned int name_len = strlen(name); + const char *desc = timing->data.other_data.data.str.str; + unsigned int desc_len = ARRAY_SIZE(timing->data.other_data.data.str.str); + + if (name_len > desc_len || + !(is_display_descriptor(timing, EDID_DETAIL_MONITOR_NAME) || + is_display_descriptor(timing, EDID_DETAIL_MONITOR_STRING))) + return; + + if (strncmp(name, desc, name_len)) + return; + + /* Allow trailing white spaces and \0. */ + for (i = name_len; i < desc_len; i++) { + if (desc[i] == '\n') + break; + if (!isspace(desc[i]) && !desc[i]) + return; + } + + closure->matched = true; +} + +/** + * drm_edid_match - match drm_edid with given identity + * @drm_edid: EDID + * @ident: the EDID identity to match with + * + * Check if the EDID matches with the given identity. + * + * Return: True if the given identity matched with EDID, false otherwise. + */ +bool drm_edid_match(const struct drm_edid *drm_edid, + const struct drm_edid_ident *ident) +{ + if (!drm_edid || drm_edid_get_panel_id(drm_edid) != ident->panel_id) + return false; + + /* Match with name only if it's not NULL. */ + if (ident->name) { + struct drm_edid_match_closure closure = { + .ident = ident, + .matched = false, + }; + + drm_for_each_detailed_block(drm_edid, match_identity, &closure); + + return closure.matched; + } + + return true; +} +EXPORT_SYMBOL(drm_edid_match); + static void monitor_name(const struct detailed_timing *timing, void *data) { diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h index 8b233865b085..28f05a7b2f7b 100644 --- a/include/drm/drm_edid.h +++ b/include/drm/drm_edid.h @@ -367,6 +367,12 @@ struct edid { u8 checksum; } __attribute__((packed)); +/* EDID matching */ +struct drm_edid_ident { + u32 panel_id; + const char *name; +}; + #define EDID_PRODUCT_ID(e) ((e)->prod_code[0] | ((e)->prod_code[1] << 8)) /* Short Audio Descriptor */ @@ -567,6 +573,8 @@ struct edid *drm_get_edid(struct drm_connector *connector, struct i2c_adapter *adapter); const struct drm_edid *drm_edid_read_base_block(struct i2c_adapter *adapter); u32 drm_edid_get_panel_id(const struct drm_edid *drm_edid); +bool drm_edid_match(const struct drm_edid *drm_edid, + const struct drm_edid_ident *ident); 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 Wed Mar 6 19:55:54 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: 13584614 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 4F135C54E41 for ; Wed, 6 Mar 2024 20:04:07 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D27C1113504; Wed, 6 Mar 2024 20:04:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="CGI+ZszW"; 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 59649113502 for ; Wed, 6 Mar 2024 20:04:00 +0000 (UTC) Received: by mail-pf1-f180.google.com with SMTP id d2e1a72fcca58-6e61851dbaeso73126b3a.2 for ; Wed, 06 Mar 2024 12:04:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709755440; x=1710360240; 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=jcV5LiM2kdZ7H9iL9vZSs1WtOpfzFcM+Wcf+rllNpWo=; b=CGI+ZszWWHp+5uu8PJA4ZLMfEqBbdElQuiD4vRTAXsAk36IEqgxgtJit2tLKVk4xJ2 ZQnlVHJRpDXrJKIZ3gtt/BydVsgozC673EaSMJExDF542LL8ZagQrrnj4wXM1DjDfRIw WLYfj5xBHvrTEuEFbtSkklWMak19UWv2tN9OI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709755440; x=1710360240; 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=jcV5LiM2kdZ7H9iL9vZSs1WtOpfzFcM+Wcf+rllNpWo=; b=YhJAjbkvuY9es80Yh/M7dMywwdLw/A2+2IyAvu6EM1WVxZVd5ZkuOMQYg6EoJR2tE3 N1eTpkbZGUTxnWDE+BWmkDHK1t8eziIIPzLcggCYNZeuuRfAFWU0uNSM5mccDZHfRPbE LgmZnq5lCrfyLoGX9jHEKJFNeUCQNn6MgXAsG/wg+j6DcOrgF/T4AqAlCK/oFw3Mjn5f oMGrpNmNmAKi96fJFAgo5/yS180wgrlZzaIl5AcGIEj+6YUpCgGVkgLDMnivsIO8lcbw ffLB7XTQKJC1mnLi2C4xeLDITz0O49gkBn+hntdZeHbjgx0oyu2mOo77NbqHiTyX5cTg +N+Q== X-Forwarded-Encrypted: i=1; AJvYcCVzcraiLReZ3GgZ77Eb8pFXl01pt6aF90vFxpf6titxeF9UXcmWYzjI8rIC46b6G+k7YMoUkjKJG7viVTaLq41u0uX1NY2Tv2oMkULerncA X-Gm-Message-State: AOJu0Ywz/uAoOMCn41xx/CzVGT8AuSEcyqsPv0rYs7f23N39kh+Z8LKL gt6B5Yus+aTJEh/JlasXQS/ovCZ72Cnu9F/rfT2eZfJe0APwpL6/yXizzQd+Cw== X-Google-Smtp-Source: AGHT+IFCgN8qo4pn/qojFIdZBRNxtgY9xf1gMLK7jbuggLu5VWKkK+6qu1VlMtZ+ebGWkZKHlSr2Cw== X-Received: by 2002:a05:6a20:5489:b0:1a1:6d2c:45da with SMTP id i9-20020a056a20548900b001a16d2c45damr971620pzk.14.1709755439863; Wed, 06 Mar 2024 12:03:59 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:a215:f6c0:3224:5460]) by smtp.gmail.com with ESMTPSA id e3-20020aa79803000000b006e5667793d4sm11124241pfl.66.2024.03.06.12.03.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:03:59 -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 v5 4/6] drm/edid: Match edid quirks with identity Date: Wed, 6 Mar 2024 11:55:54 -0800 Message-ID: <20240306200353.1436198-5-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240306200353.1436198-1-hsinyi@chromium.org> References: <20240306200353.1436198-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" Currently edid quirks are matched by panel id only. Modify it to match with identity so it's easier to be extended for more complex matching if required. Suggested-by: Jani Nikula Signed-off-by: Hsin-Yi Wang Reviewed-by: Jani Nikula Reviewed-by: Douglas Anderson --- v5: no change --- drivers/gpu/drm/drm_edid.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 29ef35ebee32..f9e4dacd7255 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -112,13 +112,15 @@ struct drm_edid_match_closure { #define EDID_QUIRK(vend_chr_0, vend_chr_1, vend_chr_2, product_id, _quirks) \ { \ - .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, vend_chr_2, \ - product_id), \ + .ident = { \ + .panel_id = drm_edid_encode_panel_id(vend_chr_0, vend_chr_1, \ + vend_chr_2, product_id), \ + }, \ .quirks = _quirks \ } static const struct edid_quirk { - u32 panel_id; + const struct drm_edid_ident ident; u32 quirks; } edid_quirk_list[] = { /* Acer AL1706 */ @@ -2880,16 +2882,17 @@ EXPORT_SYMBOL(drm_edid_duplicate); * @drm_edid: EDID to process * * This tells subsequent routines what fixes they need to apply. + * + * Return: A u32 represents the quirks to apply. */ static u32 edid_get_quirks(const struct drm_edid *drm_edid) { - u32 panel_id = drm_edid_get_panel_id(drm_edid); const struct edid_quirk *quirk; int i; for (i = 0; i < ARRAY_SIZE(edid_quirk_list); i++) { quirk = &edid_quirk_list[i]; - if (quirk->panel_id == panel_id) + if (drm_edid_match(drm_edid, &quirk->ident)) return quirk->quirks; } From patchwork Wed Mar 6 19:55:55 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: 13584617 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 6C5C2C54E41 for ; Wed, 6 Mar 2024 20:04:14 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 75C8011350C; Wed, 6 Mar 2024 20:04:13 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="HD5gpnpO"; dkim-atps=neutral Received: from mail-pf1-f174.google.com (mail-pf1-f174.google.com [209.85.210.174]) by gabe.freedesktop.org (Postfix) with ESMTPS id 677EC113502 for ; Wed, 6 Mar 2024 20:04:01 +0000 (UTC) Received: by mail-pf1-f174.google.com with SMTP id d2e1a72fcca58-6e64cdf08e3so87548b3a.3 for ; Wed, 06 Mar 2024 12:04:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709755441; x=1710360241; 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=4CE2sNS/vxOPb5cf5bC+myjwShUIoD0EfwdnD7Qy1Os=; b=HD5gpnpOIvg/1k+o4+If+8poJhIjkoLyXnFMQWDob+EsWusADuE6wSOGdWkzx05Rpc EBPWrkxjsxs0gLt2/dcwmth0mTo8EW3kzr9Ot+h7j7QJqgG4o6s3DUmEfSVplz3Qv0Mt NwIuZX+axEA+7czwuWWpvF4ttTb8P8TuyNx+g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709755441; x=1710360241; 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=4CE2sNS/vxOPb5cf5bC+myjwShUIoD0EfwdnD7Qy1Os=; b=a1j6Ph6r0j43Qq6ZvVBGQz0Kb3g1I9aiiY5X6owGkVuU2W0GX7m5hQkd6Rah3DaP0Q W9AenwVeUKsk2WwI0E7yS29tpmKsTyx7qbF10e6YxGc7deeXUzWV9srosffxY6IKJ+cd v8bvO3WRJDUDEhbZxXL3nWdAc2yFearJPnsUPQHVzM6LqGOwBFPg9f3N/OnZkBU7EJMW QJFBOOzTug6sXA5mUeYwKp6WYYDN8FFjKHRi0c3Wa1QLLdS/FClPg8s5hVDoaOEk487t BNT+tkK6awq8Wpx6umTVR6IZV3HF96O8wtX5ed583x7a6OQmnYaAp3doDDyOnljiahNA k34Q== X-Forwarded-Encrypted: i=1; AJvYcCUQ1H0VgPW3FbYZunXJMre9IsngDlvBOeZdZ690yB+865SQj0nkN4WtKbsOJ+a+SB4PXPGVZ74LpKDKhshEdioa7WqawA2UT3OydV3vEump X-Gm-Message-State: AOJu0YxgSYcNrKQ9F7iK7apzfiwN+5wHvesDqaFPmp4y88T73pDyZVvG OkXKC3BWsfbK3KKKL0yXuJlR/cA99ayyvxzmLFNsBI3PR2S/oyL84aMi2H41jg== X-Google-Smtp-Source: AGHT+IETZdUaUGspqsCyXd6rJT/N5p6jaVTBU5cNKikpauZE+EH7NLX+lSXVUp6nj8dsq6Y/lQsAUw== X-Received: by 2002:a05:6a20:a104:b0:1a1:6f1b:a86a with SMTP id q4-20020a056a20a10400b001a16f1ba86amr126518pzk.28.1709755440790; Wed, 06 Mar 2024 12:04:00 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:a215:f6c0:3224:5460]) by smtp.gmail.com with ESMTPSA id e3-20020aa79803000000b006e5667793d4sm11124241pfl.66.2024.03.06.12.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:04: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 v5 5/6] drm/panel-edp: Match edp_panels with panel identity Date: Wed, 6 Mar 2024 11:55:55 -0800 Message-ID: <20240306200353.1436198-6-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240306200353.1436198-1-hsinyi@chromium.org> References: <20240306200353.1436198-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 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: no change --- drivers/gpu/drm/panel/panel-edp.c | 45 ++++++++++++++++--------------- 1 file changed, 24 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index fe51680feb61..772bf6011d79 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,16 @@ 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->ident.panel_id; panel++) + if (drm_edid_match(edid, &panel->ident)) + return panel; - for (panel = edp_panels; panel->panel_id; panel++) - if (panel->panel_id == panel_id) + for (panel = edp_panels; panel->ident.panel_id; panel++) + if (panel->ident.panel_id == panel_id) return panel; return NULL; From patchwork Wed Mar 6 19:55: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: 13584613 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 1428EC5475B for ; Wed, 6 Mar 2024 20:04:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id D06CD113502; Wed, 6 Mar 2024 20:04:04 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="ba9TPtTg"; dkim-atps=neutral Received: from mail-pf1-f173.google.com (mail-pf1-f173.google.com [209.85.210.173]) by gabe.freedesktop.org (Postfix) with ESMTPS id 32005113502 for ; Wed, 6 Mar 2024 20:04:02 +0000 (UTC) Received: by mail-pf1-f173.google.com with SMTP id d2e1a72fcca58-6e57a3bf411so95680b3a.0 for ; Wed, 06 Mar 2024 12:04:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1709755441; x=1710360241; 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=5q7RSLprSn1rt1j4rdHGaFDAMNSTGJDra0FF/HsNmOM=; b=ba9TPtTgLIP5WHC62n5Wf7yyK9mnWVjsEmHm6xMFgrNj8ytK6tbX9Qy0EPNqqNBdHZ zntMQGIdCoq7KjDxBng6i2XWAr/uKj8HnGELTibKoPgyzsfzQHZDOBT+n3itWgVkX1kJ OKgYv6ni2JMWv9pKLxc94whnyXUaHnVRehFAU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1709755441; x=1710360241; 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=5q7RSLprSn1rt1j4rdHGaFDAMNSTGJDra0FF/HsNmOM=; b=iUzaqlzyGpGyMfRyQYjxDKC9HskPZhjbfR5GNxJtkwkMIzJ60uB4WuEZB+Rl2MdoNR X/hh3Oz8w4hPzxj+VnKFmZQhqWHkWwkYwTTx0g+UvJR1W9l0mwcgKdua10jqOL3wr2+h TkvDGycAf9UMLSqyIVhjMqap7hDhlIvG1WrT5V7T4caRHvg6lJOW2ak+tQeG2QVYdUCM MxirSehZ+k2UENlipP9dgvWlWnH/MQgAsQgzeuUKrqjjfxfF1/yJ1zqUtEhjIZ22jMr6 r9XOuVA2ISS0xUNPvs0IzipHr4mrTzHwJuY3GQBJADv1w3Ph57Shzdag6gNHlYp2oyNh oFzg== X-Forwarded-Encrypted: i=1; AJvYcCVoTuwTtoUAuVX8GPzoEGST/DotLaT9MX9J9jKZ33+vvsgoEsMGMJYZIZw5udybl5dVGItSPDsBtmEwkbrK4jtbjJxxv75Mo7v4SOHIp306 X-Gm-Message-State: AOJu0YxM5PiQpULZKNO0wMSt9TtV85krLAPdVqFaIaktMXOnfmAQ1Bw6 qW1+jVZK+pVigP2ocifrn8pufKI85tSRReI3mirntmDLop8lN3yzkpgpuwd0Eg== X-Google-Smtp-Source: AGHT+IEvpr4QV5mPBpt2sxAyZS+vMLVhwGwjJwhB/E1OupG/ADEUdABJiDL7NbFUKKyTsEDER6dy8A== X-Received: by 2002:a05:6a20:8e09:b0:1a1:4e68:30db with SMTP id y9-20020a056a208e0900b001a14e6830dbmr7188437pzj.12.1709755441698; Wed, 06 Mar 2024 12:04:01 -0800 (PST) Received: from hsinyi.sjc.corp.google.com ([2620:15c:9d:2:a215:f6c0:3224:5460]) by smtp.gmail.com with ESMTPSA id e3-20020aa79803000000b006e5667793d4sm11124241pfl.66.2024.03.06.12.04.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Mar 2024 12:04:01 -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 v5 6/6] drm/panel-edp: Fix AUO 0x405c panel naming and add a variant Date: Wed, 6 Mar 2024 11:55:56 -0800 Message-ID: <20240306200353.1436198-7-hsinyi@chromium.org> X-Mailer: git-send-email 2.44.0.278.ge034bb2e1d-goog In-Reply-To: <20240306200353.1436198-1-hsinyi@chromium.org> References: <20240306200353.1436198-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 Reviewed-by: Douglas Anderson --- v5: 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 772bf6011d79..e3de55314bda 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -1009,6 +1009,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, @@ -1990,7 +2003,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"),