Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1800903rbb; Tue, 27 Feb 2024 01:15:23 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV8otaBQw2/8hvytPW6YJpPuQnhYpZ9ThYWlnU7WWLG1B8zM2R/5qCJthdp4d8jHBb6rqSUgguN8p6gm1ATojTyzyJNow7U6poI1J361A== X-Google-Smtp-Source: AGHT+IEHj0vOxDxaWfTbK9OYt4I3RXMs1BE9VSAIMc1pyyRNYc+OIhA893ms6JmRYHlni+Wc1erZ X-Received: by 2002:a17:903:2310:b0:1dc:418f:890b with SMTP id d16-20020a170903231000b001dc418f890bmr11183060plh.40.1709025323151; Tue, 27 Feb 2024 01:15:23 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709025322; cv=pass; d=google.com; s=arc-20160816; b=Ykc16OMfolKcNDj14yVyS7qZrRPkPUsI3obsBHHlpMtqMdyeNVfFTcuvWdddS9PJNj eQOYufdwNK5YqEO53a0R3Cz4DJXEb3zwbpu2iHG7UuW7kQYLM/+hjn3HaJyv75kdWwY4 Lm8FfybIvnUFEwOqCB2yr5O8mVgH2kwS+LFX+IuALMMo/V+EgOiXJojk0q+JFuMhM4tp p09xERbjNwGfs0A56LB8OG8JIL2qMZn9wFaBYJzs1gLY39YWa+niXbheEdo+eTsLWSmZ vb8aCIkqtWWcCTEHp6rcO0h2m7hNRiKsppvyAsZuzQ3u8adS9ehdWmfgrK6k0CkAGDWV 83Gw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=mime-version:list-unsubscribe:list-subscribe:list-id:precedence :message-id:date:references:organization:in-reply-to:subject:cc:to :from:dkim-signature; bh=C7OnqoTvP99MDLSqVvkiBz55mE/Vg//9/fbRcdFsXL8=; fh=Uj9FdYjjkxG8Dcj86bePjN+A3NGk/mXlul9otd0GhIY=; b=byw0JUwyfcjD/l+88usWE4cAFjRhOQqE9B4AMMa/3a4fb2kX76AQiaNvXTd0P56s2p K1p56OV+JouseYvRrJhk2vrJ1wvuQonLzAudWF7QlHH6Rd/jlmDwXvtggBUzTS51r0Q0 PxckDXg4QZGQ3hON6ory09vxw+UxsgiKsL2rYIJeNcPibImM4RmZsisD2o01UVyPjHP4 IsGWJYMeXhBzdB6TgKGFyyFv2DSmuD1H/0TP7nyL9HTrI0p0x1hZQdPyN/RhWL0fIk4q 1XAahXuRhy2RDN+Lt2YICO+ZBLS9MT5aS4nOBijBAPHj4AtyCUuyeWD/tGloGTwXV2Xf vMyg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="jc/xS+DE"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82915-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82915-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id im15-20020a170902bb0f00b001d92eb54a6asi1048918plb.387.2024.02.27.01.15.22 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 27 Feb 2024 01:15:22 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-82915-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b="jc/xS+DE"; arc=pass (i=1 spf=pass spfdomain=intel.com dkim=pass dkdomain=intel.com dmarc=pass fromdomain=linux.intel.com); spf=pass (google.com: domain of linux-kernel+bounces-82915-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-82915-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 3783728B862 for ; Tue, 27 Feb 2024 09:09:40 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 5AD59135A68; Tue, 27 Feb 2024 09:09:33 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b="jc/xS+DE" Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3EE30130E27 for ; Tue, 27 Feb 2024 09:09:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.175.65.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709024972; cv=none; b=cGDtdPeOnKXaTBTnX826vtba8S+obLD7NxCToc7xjGBD/8xSPUk+nWHQYuGJi/l9eNFTLQHk7jdQ2uZ7wdvqDstuJL/X3pJ+pef874EJOF8BB29e2L4Ej+xhbbtr/VuLPmvM8sH1gZETNT8/1cXAEyVS8tZaY+r9yneLs6gSLCA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709024972; c=relaxed/simple; bh=Gw1x/vbGsvJML+r/3pYD26OfBQDx+xJPDEc5xPwzsoY=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=vDX7skpMsvN4VT6zwdHX+iB26tT+SlHghDaYh4Ibb47nHw4xYVOlE+uFymnIZdQ/reTypd2FpswfOiCIzlmks79ARc/sjB5O5TPKjNZ3hbLJNWnzQgqL9ocNILd5NgpaVIFVHpDxpVtAuidq/R+xXIMZGjKPAqX/Lq4IFKiWJ00= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com; spf=pass smtp.mailfrom=intel.com; dkim=pass (2048-bit key) header.d=intel.com header.i=@intel.com header.b=jc/xS+DE; arc=none smtp.client-ip=198.175.65.18 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.intel.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=intel.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1709024970; x=1740560970; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version; bh=Gw1x/vbGsvJML+r/3pYD26OfBQDx+xJPDEc5xPwzsoY=; b=jc/xS+DEQcWnm2R+HuOh30XRTrh2PStGYfi8klBXEmPTbJbQDFwg5Ndt nH+TuyORZCHA8mPZFXyJ/whO8ILiIfseowMD6GchBBGlnSB2A4M1ujYV1 ULyj/GQ4DuEJhmQqVh2blBrlzGkL7rwMCf8/6Kswo/yHseIeUO1WMgiT/ OKjW84+juOcMcwGec3JHsoDi2aupKDzkI7Wz83GURrgThKeuepLCjkvA3 gZPqO548Qs5nycGl8mpEneHfpYob7BrmHBvFxxjQ4lZu9uTexuNpDnD9n VE4s5uZiS486IsUmytfu7vNTe+Bz0/MOKVeIBLjfYgDeaqgXjunShM4Jh w==; X-IronPort-AV: E=McAfee;i="6600,9927,10996"; a="3472678" X-IronPort-AV: E=Sophos;i="6.06,187,1705392000"; d="scan'208";a="3472678" Received: from orviesa001.jf.intel.com ([10.64.159.141]) by orvoesa110.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 01:09:30 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.06,187,1705392000"; d="scan'208";a="44464859" Received: from bdallmer-mobl1.ger.corp.intel.com (HELO localhost) ([10.252.49.187]) by smtpauth.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 27 Feb 2024 01:09:26 -0800 From: Jani Nikula To: Hsin-Yi Wang , 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: Re: [PATCH 1/2] drm_edid: Add a function to get EDID base block In-Reply-To: <20240223223958.3887423-2-hsinyi@chromium.org> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo References: <20240223223958.3887423-1-hsinyi@chromium.org> <20240223223958.3887423-2-hsinyi@chromium.org> Date: Tue, 27 Feb 2024 11:09:22 +0200 Message-ID: <87wmqqjmt9.fsf@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain On Fri, 23 Feb 2024, Hsin-Yi Wang wrote: > 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 > the hash of entire EDID base block to distinguish these panel variants. > > Add drm_edid_get_base_block to returns the EDID base block, so caller can > further use it to get panel id and/or the hash. Please reconsider the whole approach here. Please let's not add single-use special case functions to read an EDID base block. Please consider reading the whole EDID, using the regular EDID reading functions, and use that instead. Most likely you'll only have 1-2 blocks anyway. And you might consider caching the EDID in struct panel_edp if reading the entire EDID is too slow. (And if it is, this is probably sensible even if the EDID only consists of one block.) Anyway, please do *not* merge this as-is. BR, Jani. > > Signed-off-by: Hsin-Yi Wang > --- > drivers/gpu/drm/drm_edid.c | 55 +++++++++++++++++-------------- > drivers/gpu/drm/panel/panel-edp.c | 8 +++-- > include/drm/drm_edid.h | 3 +- > 3 files changed, 38 insertions(+), 28 deletions(-) > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c > index 923c4423151c..55598ca4a5d1 100644 > --- a/drivers/gpu/drm/drm_edid.c > +++ b/drivers/gpu/drm/drm_edid.c > @@ -2770,58 +2770,63 @@ 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_bock: 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(void *base_block) > +{ > + return edid_extract_panel_id(base_block); > +} > +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. > */ > - > -u32 drm_edid_get_panel_id(struct i2c_adapter *adapter) > +void *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); > + 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 bd71d239272a..f6ddbaa103b5 100644 > --- a/drivers/gpu/drm/panel/panel-edp.c > +++ b/drivers/gpu/drm/panel/panel-edp.c > @@ -763,6 +763,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; > + void *base_block; > u32 panel_id; > char vend[4]; > u16 product_id; > @@ -792,8 +793,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..56b60f9204d3 100644 > --- a/include/drm/drm_edid.h > +++ b/include/drm/drm_edid.h > @@ -410,7 +410,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); > +void *drm_edid_get_base_block(struct i2c_adapter *adapter); > +u32 drm_edid_get_panel_id(void *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); -- Jani Nikula, Intel