From patchwork Fri Jul 23 00:21:40 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 484703 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9192C4320E for ; Fri, 23 Jul 2021 00:22:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9468B604AC for ; Fri, 23 Jul 2021 00:22:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232795AbhGVXlr (ORCPT ); Thu, 22 Jul 2021 19:41:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232860AbhGVXlk (ORCPT ); Thu, 22 Jul 2021 19:41:40 -0400 Received: from mail-pl1-x631.google.com (mail-pl1-x631.google.com [IPv6:2607:f8b0:4864:20::631]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 80DFBC061760 for ; Thu, 22 Jul 2021 17:22:11 -0700 (PDT) Received: by mail-pl1-x631.google.com with SMTP id e14so1250091plh.8 for ; Thu, 22 Jul 2021 17:22:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Dz0Mv44U7pSq0fpy5oNQADKe5lwuD2wgQVYhqR8kN5k=; b=WW1VbVA5TxR5D31JO8N5fA+f2CTE/dvdSS5sYzGDbCm67Euq7BGsFrmVbIgpcwAYtc WA0tvm24Q+Bn60dbdutps9sCZUgxe25PHpr7Yzil4d6UONN5Kg2aQta4fe5zagyXjQfx rNeIIiZzoQj1NjtFsGffBWZD6zoBLteoDtH3k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Dz0Mv44U7pSq0fpy5oNQADKe5lwuD2wgQVYhqR8kN5k=; b=kxgSANgrEkvSinJthFtQBdR57Rpz4qER7I9y4TMVsqsFSJETRWoTyW960rwnbBwd9t 48vNDd3GVHV8j64JvPAeEIlz0cbE+ihF6uB8ngGdQVKr8vT+x2vJu9sip6eyNmYp0bcY jbs6IGdvNzZ0Jvc9COE6Dcb9kLveDgNjTJYDD9K2NoVm8CtK7zUcNiSEgy4CAjuKthrW fVHXLTkbaYaxGG8oyzShOFhoeWupNBpRiepu9n01Do+uwjV14zkd/4YSpkPbYp4v0DdG iniAywbAzYaBrpWEq5gCayBNoHlzB4CP9Ep9l9cmteYYGu6pXx9k2RAWd2CweH/VvkC9 gCxw== X-Gm-Message-State: AOAM531HYE1hG+yWO3SYgPdZi3cQdMjNgzWcDD8WYP1pkQyuZD5XL9Mi IPpCeIKUUNrC+BEzIOjP/dwLVQ== X-Google-Smtp-Source: ABdhPJwurRVfcpuzGhIY95vFze3UNqdiJh89jbxbdWNNL1RY+jtbU8Qg/NcdAam6A9QzUH5W/zMz6w== X-Received: by 2002:a05:6a00:1692:b029:300:7193:f67 with SMTP id k18-20020a056a001692b029030071930f67mr2020764pfc.19.1626999731091; Thu, 22 Jul 2021 17:22:11 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:5e70:6a49:67b5:2b7e]) by smtp.gmail.com with ESMTPSA id iy13sm4072377pjb.28.2021.07.22.17.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jul 2021 17:22:10 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring Cc: Maarten Lankhorst , Steev Klimaszewski , dri-devel@lists.freedesktop.org, David Airlie , devicetree@vger.kernel.org, Daniel Vetter , Maxime Ripard , Sam Ravnborg , Thomas Zimmermann , linux-arm-msm@vger.kernel.org, Linus W , Bjorn Andersson , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/8] drm/edid: Break out reading block 0 of the EDID Date: Thu, 22 Jul 2021 17:21:40 -0700 Message-Id: <20210722172104.RFC.2.I62e76a034ac78c994d40a23cd4ec5aeee56fa77c@changeid> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog In-Reply-To: <20210723002146.1962910-1-dianders@chromium.org> References: <20210723002146.1962910-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org A future change wants to be able to read just block 0 of the EDID, so break it out of drm_do_get_edid() into a sub-function. This is intended to be a no-op change--just code movement. Signed-off-by: Douglas Anderson --- drivers/gpu/drm/drm_edid.c | 62 +++++++++++++++++++++++++++----------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 81d5f2524246..a623a80f7edb 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1905,6 +1905,43 @@ int drm_add_override_edid_modes(struct drm_connector *connector) } EXPORT_SYMBOL(drm_add_override_edid_modes); +static struct edid *drm_do_get_edid_blk0( + int (*get_edid_block)(void *data, u8 *buf, unsigned int block, + size_t len), + void *data, bool *edid_corrupt, int *null_edid_counter) +{ + int i; + u8 *edid; + + if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) + return NULL; + + /* base block fetch */ + for (i = 0; i < 4; i++) { + if (get_edid_block(data, edid, 0, EDID_LENGTH)) + goto out; + if (drm_edid_block_valid(edid, 0, false, edid_corrupt)) + break; + if (i == 0 && drm_edid_is_zero(edid, EDID_LENGTH)) { + if (null_edid_counter) + (*null_edid_counter)++; + goto carp; + } + } + if (i == 4) + goto carp; + + return (struct edid *)edid; + +carp: + kfree(edid); + return ERR_PTR(-EINVAL); + +out: + kfree(edid); + return NULL; +} + /** * drm_do_get_edid - get EDID data using a custom EDID block read function * @connector: connector we're probing @@ -1938,25 +1975,16 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, if (override) return override; - if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL) + edid = (u8 *)drm_do_get_edid_blk0(get_edid_block, data, + &connector->edid_corrupt, + &connector->null_edid_counter); + if (IS_ERR_OR_NULL(edid)) { + if (IS_ERR(edid)) + connector_bad_edid(connector, edid, 1); return NULL; - - /* base block fetch */ - for (i = 0; i < 4; i++) { - if (get_edid_block(data, edid, 0, EDID_LENGTH)) - goto out; - if (drm_edid_block_valid(edid, 0, false, - &connector->edid_corrupt)) - break; - if (i == 0 && drm_edid_is_zero(edid, EDID_LENGTH)) { - connector->null_edid_counter++; - goto carp; - } } - if (i == 4) - goto carp; - /* if there's no extensions, we're done */ + /* if there's no extensions or no connector, we're done */ valid_extensions = edid[0x7e]; if (valid_extensions == 0) return (struct edid *)edid; @@ -2010,8 +2038,6 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, return (struct edid *)edid; -carp: - connector_bad_edid(connector, edid, 1); out: kfree(edid); return NULL; From patchwork Fri Jul 23 00:21:42 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 484702 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCBEBC4320E for ; Fri, 23 Jul 2021 00:22:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A8DD960EB9 for ; Fri, 23 Jul 2021 00:22:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232911AbhGVXlt (ORCPT ); Thu, 22 Jul 2021 19:41:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232892AbhGVXlr (ORCPT ); Thu, 22 Jul 2021 19:41:47 -0400 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 87F91C06179B for ; Thu, 22 Jul 2021 17:22:14 -0700 (PDT) Received: by mail-pl1-x630.google.com with SMTP id c11so1167952plg.11 for ; Thu, 22 Jul 2021 17:22:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gWScQ3RoXdLdJS9t+RJN8kdgO9NRWYfVw++Ppk8gyUQ=; b=XqCcX4qSfe4fNA6xqHdCXE7WfptpmrsuVLTgFjOiMco81rVjYmUxtJip9IGSAumy3g PY/iX0k4asGRdW1+C7Odrq6m1900W/I8qEao9ifYHDajtZ6v8UJqceHNZnyoQApRRfJL AlchELWMfPx3fYJN1EkRqZPAOr9sTG5BTSjCk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gWScQ3RoXdLdJS9t+RJN8kdgO9NRWYfVw++Ppk8gyUQ=; b=d3ZulE6L/9bTMo+qh+6DgjGizduTjO+ZBM8CtE7UOtFajhKD73oNMmZ0wpe9RNBtUs c+1tsXjDw4c0ulKfiL+3n9Ak7nHYpR1U0YSNWlwPZ18/xiL9Srbo3y28GkE56Doy9oDr TtcdBzRGl11PtQ5gdx6jKgmhMA9EnkAJjCj9a0cvVlfO1GGG/bZRplRF8qy0ZIU4pxPw OrilIogRYNHJO508HzWtixHqqLoEfPctZh2v/h+segAUp87f5S4oE00zG1m/cjYL3g3/ QPTteGWUipvkONgzOYpTEVQEv9M/784H1ExBnLXTjmaMYGenn4thdC9j+iGsPth3AMQ6 curQ== X-Gm-Message-State: AOAM530YI6MyPVvmDYmpOCjhhytY+jg2mGmONLcx6jt3tIp+UxCm+s4a TO+moSMt6gNxL99KCPKjzjc3WA== X-Google-Smtp-Source: ABdhPJwHpj2aZr9pdn1A/6Wx4oICGJjmdyIfL+SVJ2uAcEvkUKah5a3ORUThg/UpxLy0oPpE5BTJDA== X-Received: by 2002:a17:90a:6c61:: with SMTP id x88mr11582187pjj.122.1626999734119; Thu, 22 Jul 2021 17:22:14 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:5e70:6a49:67b5:2b7e]) by smtp.gmail.com with ESMTPSA id iy13sm4072377pjb.28.2021.07.22.17.22.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jul 2021 17:22:13 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring Cc: Maarten Lankhorst , Steev Klimaszewski , dri-devel@lists.freedesktop.org, David Airlie , devicetree@vger.kernel.org, Daniel Vetter , Maxime Ripard , Sam Ravnborg , Thomas Zimmermann , linux-arm-msm@vger.kernel.org, Linus W , Bjorn Andersson , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [RFC PATCH 4/8] drm/panel-simple: Don't re-read the EDID every time we power off the panel Date: Thu, 22 Jul 2021 17:21:42 -0700 Message-Id: <20210722172104.RFC.4.Ib810fb3bebd0bd6763e4609e1a6764d06064081e@changeid> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog In-Reply-To: <20210723002146.1962910-1-dianders@chromium.org> References: <20210723002146.1962910-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org The simple-panel driver is for panels that are not hot-pluggable at runtime. Let's keep our cached EDID around until driver unload. Signed-off-by: Douglas Anderson --- drivers/gpu/drm/panel/panel-simple.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 9b286bd4444f..bcdc84b20827 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -370,9 +370,6 @@ static int panel_simple_suspend(struct device *dev) regulator_disable(p->supply); p->unprepared_time = ktime_get(); - kfree(p->edid); - p->edid = NULL; - return 0; } @@ -862,6 +859,9 @@ static int panel_simple_remove(struct device *dev) if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc)) put_device(&panel->ddc->dev); + kfree(panel->edid); + panel->edid = NULL; + return 0; } From patchwork Fri Jul 23 00:21:43 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 484700 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0656DC432BE for ; Fri, 23 Jul 2021 00:22:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E52A960EBC for ; Fri, 23 Jul 2021 00:22:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232948AbhGVXmA (ORCPT ); Thu, 22 Jul 2021 19:42:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40404 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232784AbhGVXlr (ORCPT ); Thu, 22 Jul 2021 19:41:47 -0400 Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 38642C0617A3 for ; Thu, 22 Jul 2021 17:22:16 -0700 (PDT) Received: by mail-pl1-x62a.google.com with SMTP id e14so1250288plh.8 for ; Thu, 22 Jul 2021 17:22:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tkFF98e5eFd70BOJkhQ3nRTVL7R4mLevP/eO/PN3oN4=; b=fLYg8viiIW0H7/q4zpJ6F8dzhqY5IjyMWaWn60YHhNODHTOAMdj9VUETy0KoQXyPFt 3GlVZI1M6KgtrD6gE8i8KmbREsQc36IkCQh7Pa/tWCNtU6CTIJdRRzKi6DXftrblKzAI uDE0y0fDM6yaGynW5ruJN/8T2tPE3TsO1Q7Ns= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tkFF98e5eFd70BOJkhQ3nRTVL7R4mLevP/eO/PN3oN4=; b=YuVUNdh1toxOAd7M5p68RuZRB9ytHSQ2u7akNpFYZSErUpZIqIkMZPiaKmxwHUJBB4 pndnTs4vaCVq/bvl4SlbrkkHJFicEj2sX6DbmVqciEUMb7lQERLLPECmUClTyxDXzsfp yuoGNkdJmclJ5bTeU3yPRrQxZnacDyt9wEZmdcUs5w9OnN1b0QuEO6MbyrmWn1Akm9Qk mP74I0wwhkyPEYzNuL6v7j5kSMbIAcn6faZLzgtiWhxPqJVLPvCrVK3cwlWDo1Ny6Exj 6xj/2CQtnx1Nxxqp1b5ouOxDITG1KiU58z0Ao/KIwLiDiZFZxB1E2ZWgjA5MjRSPSyVI 2l+A== X-Gm-Message-State: AOAM533vzqygi0tIj6flNpWmgDdz7XRQh8Eb7UEccOp4v0IyuiU5Fbis 7IwAZPfMBVtwuhf7Ui2FCnm2pg== X-Google-Smtp-Source: ABdhPJxlsb6y3A+e06iNRcOp7l33cEW/toaSNmDLWaT6y7DE2kQUGT81yYQTwLCF8XeIRzvauYImFw== X-Received: by 2002:a62:1c47:0:b029:328:c15c:7603 with SMTP id c68-20020a621c470000b0290328c15c7603mr2202363pfc.6.1626999735676; Thu, 22 Jul 2021 17:22:15 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:5e70:6a49:67b5:2b7e]) by smtp.gmail.com with ESMTPSA id iy13sm4072377pjb.28.2021.07.22.17.22.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jul 2021 17:22:15 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring Cc: Maarten Lankhorst , Steev Klimaszewski , dri-devel@lists.freedesktop.org, David Airlie , devicetree@vger.kernel.org, Daniel Vetter , Maxime Ripard , Sam Ravnborg , Thomas Zimmermann , linux-arm-msm@vger.kernel.org, Linus W , Bjorn Andersson , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [RFC PATCH 5/8] drm/panel-simple: Copy "desc" into driver data; don't store a pointer Date: Thu, 22 Jul 2021 17:21:43 -0700 Message-Id: <20210722172104.RFC.5.I89640bdefeafa3b4a856f16fb7f150dc2c4b14d5@changeid> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog In-Reply-To: <20210723002146.1962910-1-dianders@chromium.org> References: <20210723002146.1962910-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Up until now "desc" has usually pointed to one of the "static const" objects defined in the panel-simple driver. Just storing a pointer to one of these data elements made sense. In a future patch to support probable eDP panels, however, it's convenient to be able to modify the delays that the driver uses as it starts up. One nice way to handle this is to just copy the "desc" into our driver data instead of storing a pointer. This has a nice side effect of simplifying the "DPI" case since we no longer need an extra alloc there. Signed-off-by: Douglas Anderson --- drivers/gpu/drm/panel/panel-simple.c | 84 +++++++++++++--------------- 1 file changed, 38 insertions(+), 46 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index bcdc84b20827..c08bc70f7798 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -199,7 +199,7 @@ struct panel_simple { ktime_t prepared_time; ktime_t unprepared_time; - const struct panel_desc *desc; + struct panel_desc desc; struct regulator *supply; struct i2c_adapter *ddc; @@ -226,8 +226,8 @@ static unsigned int panel_simple_get_timings_modes(struct panel_simple *panel, struct drm_display_mode *mode; unsigned int i, num = 0; - for (i = 0; i < panel->desc->num_timings; i++) { - const struct display_timing *dt = &panel->desc->timings[i]; + for (i = 0; i < panel->desc.num_timings; i++) { + const struct display_timing *dt = &panel->desc.timings[i]; struct videomode vm; videomode_from_timing(dt, &vm); @@ -242,7 +242,7 @@ static unsigned int panel_simple_get_timings_modes(struct panel_simple *panel, mode->type |= DRM_MODE_TYPE_DRIVER; - if (panel->desc->num_timings == 1) + if (panel->desc.num_timings == 1) mode->type |= DRM_MODE_TYPE_PREFERRED; drm_mode_probed_add(connector, mode); @@ -258,8 +258,8 @@ static unsigned int panel_simple_get_display_modes(struct panel_simple *panel, struct drm_display_mode *mode; unsigned int i, num = 0; - for (i = 0; i < panel->desc->num_modes; i++) { - const struct drm_display_mode *m = &panel->desc->modes[i]; + for (i = 0; i < panel->desc.num_modes; i++) { + const struct drm_display_mode *m = &panel->desc.modes[i]; mode = drm_mode_duplicate(connector->dev, m); if (!mode) { @@ -271,7 +271,7 @@ static unsigned int panel_simple_get_display_modes(struct panel_simple *panel, mode->type |= DRM_MODE_TYPE_DRIVER; - if (panel->desc->num_modes == 1) + if (panel->desc.num_modes == 1) mode->type |= DRM_MODE_TYPE_PREFERRED; drm_mode_set_name(mode); @@ -290,9 +290,6 @@ static int panel_simple_get_non_edid_modes(struct panel_simple *panel, bool has_override = panel->override_mode.type; unsigned int num = 0; - if (!panel->desc) - return 0; - if (has_override) { mode = drm_mode_duplicate(connector->dev, &panel->override_mode); @@ -305,7 +302,7 @@ static int panel_simple_get_non_edid_modes(struct panel_simple *panel, } /* Only add timings if override was not there or failed to validate */ - if (num == 0 && panel->desc->num_timings) + if (num == 0 && panel->desc.num_timings) num = panel_simple_get_timings_modes(panel, connector); /* @@ -314,17 +311,17 @@ static int panel_simple_get_non_edid_modes(struct panel_simple *panel, * We should only ever have either the display timings specified * or a fixed mode. Anything else is rather bogus. */ - WARN_ON(panel->desc->num_timings && panel->desc->num_modes); + WARN_ON(panel->desc.num_timings && panel->desc.num_modes); if (num == 0) num = panel_simple_get_display_modes(panel, connector); - connector->display_info.bpc = panel->desc->bpc; - connector->display_info.width_mm = panel->desc->size.width; - connector->display_info.height_mm = panel->desc->size.height; - if (panel->desc->bus_format) + connector->display_info.bpc = panel->desc.bpc; + connector->display_info.width_mm = panel->desc.size.width; + connector->display_info.height_mm = panel->desc.size.height; + if (panel->desc.bus_format) drm_display_info_set_bus_formats(&connector->display_info, - &panel->desc->bus_format, 1); - connector->display_info.bus_flags = panel->desc->bus_flags; + &panel->desc.bus_format, 1); + connector->display_info.bus_flags = panel->desc.bus_flags; return num; } @@ -350,8 +347,8 @@ static int panel_simple_disable(struct drm_panel *panel) if (!p->enabled) return 0; - if (p->desc->delay.disable) - msleep(p->desc->delay.disable); + if (p->desc.delay.disable) + msleep(p->desc.delay.disable); p->enabled = false; @@ -364,8 +361,8 @@ static int panel_simple_suspend(struct device *dev) gpiod_set_value_cansleep(p->enable_gpio, 0); - if (p->desc->delay.disable_to_power_off) - msleep(p->desc->delay.disable_to_power_off); + if (p->desc.delay.disable_to_power_off) + msleep(p->desc.delay.disable_to_power_off); regulator_disable(p->supply); p->unprepared_time = ktime_get(); @@ -416,7 +413,7 @@ static int panel_simple_prepare_once(struct panel_simple *p) int hpd_asserted; unsigned long hpd_wait_us; - panel_simple_wait(p->unprepared_time, p->desc->delay.unprepare); + panel_simple_wait(p->unprepared_time, p->desc.delay.unprepare); err = regulator_enable(p->supply); if (err < 0) { @@ -424,20 +421,20 @@ static int panel_simple_prepare_once(struct panel_simple *p) return err; } - if (p->desc->delay.power_to_enable) - msleep(p->desc->delay.power_to_enable); + if (p->desc.delay.power_to_enable) + msleep(p->desc.delay.power_to_enable); gpiod_set_value_cansleep(p->enable_gpio, 1); - delay = p->desc->delay.prepare; + delay = p->desc.delay.prepare; if (p->no_hpd) - delay += p->desc->delay.hpd_absent_delay; + delay += p->desc.delay.hpd_absent_delay; if (delay) msleep(delay); if (p->hpd_gpio) { - if (p->desc->delay.hpd_absent_delay) - hpd_wait_us = p->desc->delay.hpd_absent_delay * 1000UL; + if (p->desc.delay.hpd_absent_delay) + hpd_wait_us = p->desc.delay.hpd_absent_delay * 1000UL; else hpd_wait_us = 2000000; @@ -520,10 +517,10 @@ static int panel_simple_enable(struct drm_panel *panel) if (p->enabled) return 0; - if (p->desc->delay.enable) - msleep(p->desc->delay.enable); + if (p->desc.delay.enable) + msleep(p->desc.delay.enable); - panel_simple_wait(p->prepared_time, p->desc->delay.prepare_to_enable); + panel_simple_wait(p->prepared_time, p->desc.delay.prepare_to_enable); p->enabled = true; @@ -566,14 +563,14 @@ static int panel_simple_get_timings(struct drm_panel *panel, struct panel_simple *p = to_panel_simple(panel); unsigned int i; - if (p->desc->num_timings < num_timings) - num_timings = p->desc->num_timings; + if (p->desc.num_timings < num_timings) + num_timings = p->desc.num_timings; if (timings) for (i = 0; i < num_timings; i++) - timings[i] = p->desc->timings[i]; + timings[i] = p->desc.timings[i]; - return p->desc->num_timings; + return p->desc.num_timings; } static const struct drm_panel_funcs panel_simple_funcs = { @@ -592,15 +589,12 @@ static int panel_dpi_probe(struct device *dev, { struct display_timing *timing; const struct device_node *np; - struct panel_desc *desc; + struct panel_desc *desc = &panel->desc; unsigned int bus_flags; struct videomode vm; int ret; np = dev->of_node; - desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); - if (!desc) - return -ENOMEM; timing = devm_kzalloc(dev, sizeof(*timing), GFP_KERNEL); if (!timing) @@ -628,8 +622,6 @@ static int panel_dpi_probe(struct device *dev, /* We do not know the connector for the DT node, so guess it */ desc->connector_type = DRM_MODE_CONNECTOR_DPI; - panel->desc = desc; - return 0; } @@ -640,7 +632,7 @@ static void panel_simple_parse_panel_timing_node(struct device *dev, struct panel_simple *panel, const struct display_timing *ot) { - const struct panel_desc *desc = panel->desc; + const struct panel_desc *desc = &panel->desc; struct videomode vm; unsigned int i; @@ -653,8 +645,8 @@ static void panel_simple_parse_panel_timing_node(struct device *dev, return; } - for (i = 0; i < panel->desc->num_timings; i++) { - const struct display_timing *dt = &panel->desc->timings[i]; + for (i = 0; i < desc->num_timings; i++) { + const struct display_timing *dt = &desc->timings[i]; if (!PANEL_SIMPLE_BOUNDS_CHECK(ot, dt, hactive) || !PANEL_SIMPLE_BOUNDS_CHECK(ot, dt, hfront_porch) || @@ -696,7 +688,7 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc, panel->enabled = false; panel->prepared_time = 0; - panel->desc = desc; + panel->desc = *desc; panel->aux = aux; panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd"); From patchwork Fri Jul 23 00:21:44 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 484701 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E65F2C00143 for ; Fri, 23 Jul 2021 00:22:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6ED1604AC for ; Fri, 23 Jul 2021 00:22:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232923AbhGVXlw (ORCPT ); Thu, 22 Jul 2021 19:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40412 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232907AbhGVXls (ORCPT ); Thu, 22 Jul 2021 19:41:48 -0400 Received: from mail-pl1-x635.google.com (mail-pl1-x635.google.com [IPv6:2607:f8b0:4864:20::635]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA843C0617B9 for ; Thu, 22 Jul 2021 17:22:17 -0700 (PDT) Received: by mail-pl1-x635.google.com with SMTP id u8so1394209plr.1 for ; Thu, 22 Jul 2021 17:22:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=QIfL2wi4rwyW3wFJc4TBxi5hgLk5jqj90hpJmrNmT08=; b=ffzYNOq+5NVIrjnzOEMQvzZiScPi84W+VikPLqJD6LV9d9YyiO2l7ClDARkhr/K97M pFa+YpWWemm8hWsjssa1u+22dNYXE7YcTvlFyc3sxbWbbJGCjPmb59fPeLMf1jgsrKDk sTbH07TxjFiFNzZRPa1ELyE0P0wB6UQE1NT+g= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QIfL2wi4rwyW3wFJc4TBxi5hgLk5jqj90hpJmrNmT08=; b=pQbbAjgtMgZmR7ha/aBqEFqL4IDL137FvpzvYFYAYwM6ML6/q8NzdfP6rU9hfSba0k 0L6M39ok+HF3ceOtlFcEC8SCITMQhO8+jFJEuDRXLmbqcH/71SY3q5ne8fbdAEMVeBGR RXFUr2cJkY/+NgyvvwHBAnYvJwKuS+tl2UUOShTyVL8jICD5jhuLoIM4rIvSSVgtiD6N wlK5PKHuQkY990Exaikqd/NgJwIfWxyL69lo1AHyJDJZjbCNfugEm6UTBwtxpmD1wIiW uHl5r+4t3HZ4wT446QQj+9Thi8ABl6bKg25BsgiOiO6LaTt29aZpz7GXg7jOGmk7ylOo tPEw== X-Gm-Message-State: AOAM5316zkIUjGJrWdvCgZaad/mYZYfshEZFB4j9yG4X9b7hlrf/HWbG +Nqm6Nxg/1l6fk9Bn+ppf5/Wvg== X-Google-Smtp-Source: ABdhPJxWVzz5mUT/xV8/8vfmjmFYzTrPcG2YkgBhXf9lv6EOfBA5NQ4+xu9T8hBisfib0fVtYQEr8w== X-Received: by 2002:a63:ee06:: with SMTP id e6mr2400550pgi.374.1626999737393; Thu, 22 Jul 2021 17:22:17 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:5e70:6a49:67b5:2b7e]) by smtp.gmail.com with ESMTPSA id iy13sm4072377pjb.28.2021.07.22.17.22.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 22 Jul 2021 17:22:16 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring Cc: Maarten Lankhorst , Steev Klimaszewski , dri-devel@lists.freedesktop.org, David Airlie , devicetree@vger.kernel.org, Daniel Vetter , Maxime Ripard , Sam Ravnborg , Thomas Zimmermann , linux-arm-msm@vger.kernel.org, Linus W , Bjorn Andersson , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [RFC PATCH 6/8] drm/panel-simple: Split the delay structure out of the panel description Date: Thu, 22 Jul 2021 17:21:44 -0700 Message-Id: <20210722172104.RFC.6.I11c226341f8e86d376a53d5ec11cb82f6fd2c38c@changeid> X-Mailer: git-send-email 2.32.0.432.gabb21c7263-goog In-Reply-To: <20210723002146.1962910-1-dianders@chromium.org> References: <20210723002146.1962910-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In the case where we can read an EDID for a panel the only part of the panel description that can't be found directly from the EDID is the description of the delays. Let's break the delay structure out so that we can specify just the delays for panels that are detected by EDID. This is simple code motion. No functional change is intended. Signed-off-by: Douglas Anderson --- drivers/gpu/drm/panel/panel-simple.c | 191 ++++++++++++++------------- 1 file changed, 98 insertions(+), 93 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index c08bc70f7798..80bc60648ecf 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -41,6 +41,103 @@ #include #include +/** + * struct panel_delay - Describes delays for a simple panel. + */ +struct panel_delay { + /** + * @prepare: Time for the panel to become ready. + * + * The time (in milliseconds) that it takes for the panel to + * become ready and start receiving video data + */ + unsigned int prepare; + + /** + * @hpd_absent_delay: Time to wait if HPD isn't hooked up. + * + * Add this to the prepare delay if we know Hot Plug Detect + * isn't used. + */ + unsigned int hpd_absent_delay; + + /** + * @prepare_to_enable: Time between prepare and enable. + * + * The minimum time, in milliseconds, that needs to have passed + * between when prepare finished and enable may begin. If at + * enable time less time has passed since prepare finished, + * the driver waits for the remaining time. + * + * If a fixed enable delay is also specified, we'll start + * counting before delaying for the fixed delay. + * + * If a fixed prepare delay is also specified, we won't start + * counting until after the fixed delay. We can't overlap this + * fixed delay with the min time because the fixed delay + * doesn't happen at the end of the function if a HPD GPIO was + * specified. + * + * In other words: + * prepare() + * ... + * // do fixed prepare delay + * // wait for HPD GPIO if applicable + * // start counting for prepare_to_enable + * + * enable() + * // do fixed enable delay + * // enforce prepare_to_enable min time + */ + unsigned int prepare_to_enable; + + /** + * @power_to_enable: Time for the power to enable the display on. + * + * The time (in milliseconds) to wait after powering up the display + * before asserting its enable pin. + */ + unsigned int power_to_enable; + + /** + * @disable_to_power_off: Time for the disable to power the display off. + * + * The time (in milliseconds) to wait before powering off the display + * after deasserting its enable pin. + */ + unsigned int disable_to_power_off; + + /** + * @enable: Time for the panel to display a valid frame. + * + * The time (in milliseconds) that it takes for the panel to + * display the first valid frame after starting to receive + * video data. + */ + unsigned int enable; + + /** + * @disable: Time for the panel to turn the display off. + * + * The time (in milliseconds) that it takes for the panel to + * turn the display off (no content is visible). + */ + unsigned int disable; + + /** + * @unprepare: Time to power down completely. + * + * The time (in milliseconds) that it takes for the panel + * to power itself down completely. + * + * This time is used to prevent a future "prepare" from + * starting until at least this many milliseconds has passed. + * If at prepare time less time has passed since unprepare + * finished, the driver waits for the remaining time. + */ + unsigned int unprepare; +}; + /** * struct panel_desc - Describes a simple panel. */ @@ -85,99 +182,7 @@ struct panel_desc { } size; /** @delay: Structure containing various delay values for this panel. */ - struct { - /** - * @delay.prepare: Time for the panel to become ready. - * - * The time (in milliseconds) that it takes for the panel to - * become ready and start receiving video data - */ - unsigned int prepare; - - /** - * @delay.hpd_absent_delay: Time to wait if HPD isn't hooked up. - * - * Add this to the prepare delay if we know Hot Plug Detect - * isn't used. - */ - unsigned int hpd_absent_delay; - - /** - * @delay.prepare_to_enable: Time between prepare and enable. - * - * The minimum time, in milliseconds, that needs to have passed - * between when prepare finished and enable may begin. If at - * enable time less time has passed since prepare finished, - * the driver waits for the remaining time. - * - * If a fixed enable delay is also specified, we'll start - * counting before delaying for the fixed delay. - * - * If a fixed prepare delay is also specified, we won't start - * counting until after the fixed delay. We can't overlap this - * fixed delay with the min time because the fixed delay - * doesn't happen at the end of the function if a HPD GPIO was - * specified. - * - * In other words: - * prepare() - * ... - * // do fixed prepare delay - * // wait for HPD GPIO if applicable - * // start counting for prepare_to_enable - * - * enable() - * // do fixed enable delay - * // enforce prepare_to_enable min time - */ - unsigned int prepare_to_enable; - - /** - * @delay.power_to_enable: Time for the power to enable the display on. - * - * The time (in milliseconds) to wait after powering up the display - * before asserting its enable pin. - */ - unsigned int power_to_enable; - - /** - * @delay.disable_to_power_off: Time for the disable to power the display off. - * - * The time (in milliseconds) to wait before powering off the display - * after deasserting its enable pin. - */ - unsigned int disable_to_power_off; - - /** - * @delay.enable: Time for the panel to display a valid frame. - * - * The time (in milliseconds) that it takes for the panel to - * display the first valid frame after starting to receive - * video data. - */ - unsigned int enable; - - /** - * @delay.disable: Time for the panel to turn the display off. - * - * The time (in milliseconds) that it takes for the panel to - * turn the display off (no content is visible). - */ - unsigned int disable; - - /** - * @delay.unprepare: Time to power down completely. - * - * The time (in milliseconds) that it takes for the panel - * to power itself down completely. - * - * This time is used to prevent a future "prepare" from - * starting until at least this many milliseconds has passed. - * If at prepare time less time has passed since unprepare - * finished, the driver waits for the remaining time. - */ - unsigned int unprepare; - } delay; + struct panel_delay delay; /** @bus_format: See MEDIA_BUS_FMT_... defines. */ u32 bus_format;