From patchwork Tue Sep 14 20:21:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 511008 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=-19.1 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, 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 76CF8C43219 for ; Tue, 14 Sep 2021 20:22:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5A3D06117A for ; Tue, 14 Sep 2021 20:22:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233904AbhINUXk (ORCPT ); Tue, 14 Sep 2021 16:23:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37622 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233398AbhINUXi (ORCPT ); Tue, 14 Sep 2021 16:23:38 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8DE95C061762 for ; Tue, 14 Sep 2021 13:22:20 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id w19-20020a17090aaf9300b00191e6d10a19so534162pjq.1 for ; Tue, 14 Sep 2021 13:22:20 -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=1eq1EhU+zYDo9mJHJDkG29Ky8UkHJSuUomIxtnQFNyU=; b=DbJEGg0xGwg+a49SFAxYOlo+UGjg3cC7kW+wHLhkk+opC8xZLjO4mXNmBmLN/sgtz4 3hCnSMgXi69PYfleT76+M+3GA9R2GRilBRHJLtDCgx3qOIWsMo+XJolkbO5j0Tp9AmyK AAfrHllQnojGW3KNEsEIKeY2DW5KA104z4sII= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=1eq1EhU+zYDo9mJHJDkG29Ky8UkHJSuUomIxtnQFNyU=; b=sZeyePJ3IX4idy1CIKttPsIhofht47sMq/o6ukVkikd77BZA5nEzXho+ppqOGbS/VW BXRYNnRmkwuc3nUPmQpGGV7ld5O1XXr1Ko54v9O9oej/JB/Vr32N3GowS0G9umY8DnKq uT35GIaXJXqlNSREh7lwXlCHG6n2B8bFDcfBUSMuxnN/1n4CBbv0tByBd+Axt3uqPa9T +1JkDPMWoTav2L7ktq5QqvN7ohQQEm14m/wq9QllnKFu6hJTUg9hXtexO6LdTOKqTcj6 r8MWsof0ADziv/OOe9r+Xr6XWWKLZjRGWY2NaoIaQnJIO5kaGINhyOM1Qq9+kebthIv1 ehMQ== X-Gm-Message-State: AOAM533HDLaTvtE4Yd2tUUlH0Cds8vLLwQwejVmN2y9soIzMFzvhPOha 1Q4xG2dTmHSBghhahWN3+HiMkw== X-Google-Smtp-Source: ABdhPJxZGuqeY7vVGYlZZdjz3TXxrq4Z8aVX1sSURyw7T47gpo2DGYj+w1EEfxevLORoECmy387ikA== X-Received: by 2002:a17:90b:3ec6:: with SMTP id rm6mr4119831pjb.68.1631650940174; Tue, 14 Sep 2021 13:22:20 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f38f:9d0f:3eba:f8c4]) by smtp.gmail.com with ESMTPSA id 141sm12185393pgg.16.2021.09.14.13.22.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 13:22:19 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring , Sam Ravnborg Cc: devicetree@vger.kernel.org, Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, David Airlie , Maarten Lankhorst , Thomas Zimmermann , Linus W , Bjorn Andersson , Daniel Vetter , Maxime Ripard , Douglas Anderson , Jani Nikula , linux-kernel@vger.kernel.org Subject: [PATCH v5 02/15] drm/edid: Break out reading block 0 of the EDID Date: Tue, 14 Sep 2021 13:21:49 -0700 Message-Id: <20210914132020.v5.2.I62e76a034ac78c994d40a23cd4ec5aeee56fa77c@changeid> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog In-Reply-To: <20210914202202.1702601-1-dianders@chromium.org> References: <20210914202202.1702601-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 Acked-by: Sam Ravnborg Reviewed-by: Jani Nikula --- (no changes since v4) Changes in v4: - "u8 *edid" => "void *edid" to avoid cast. - Don't put kmalloc() in the "if" test even if the old code did. - drm_do_get_edid_blk0() => drm_do_get_edid_base_block() drivers/gpu/drm/drm_edid.c | 63 +++++++++++++++++++++++++++----------- 1 file changed, 45 insertions(+), 18 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 6325877c5fd6..520fe1391769 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -1905,6 +1905,44 @@ int drm_add_override_edid_modes(struct drm_connector *connector) } EXPORT_SYMBOL(drm_add_override_edid_modes); +static struct edid *drm_do_get_edid_base_block( + 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; + void *edid; + + edid = kmalloc(EDID_LENGTH, GFP_KERNEL); + if (edid == 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 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 +1976,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_base_block(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 +2039,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 Tue Sep 14 20:21:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 511007 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=-19.1 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, UPPERCASE_50_75, 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 33F20C43217 for ; Tue, 14 Sep 2021 20:22:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1DE6B61183 for ; Tue, 14 Sep 2021 20:22:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233976AbhINUXq (ORCPT ); Tue, 14 Sep 2021 16:23:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234025AbhINUXn (ORCPT ); Tue, 14 Sep 2021 16:23:43 -0400 Received: from mail-pl1-x62f.google.com (mail-pl1-x62f.google.com [IPv6:2607:f8b0:4864:20::62f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C396C0613CF for ; Tue, 14 Sep 2021 13:22:24 -0700 (PDT) Received: by mail-pl1-x62f.google.com with SMTP id o8so183091pll.1 for ; Tue, 14 Sep 2021 13:22:24 -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=s2t3OBEBZv8gCynOpYw1ybZLTn4iofsMa7t+E6nlIw8=; b=kUWepDm3u3ET/VIch1RSsDhE5Hsd/ozwc9i2VCBWLQnb1V53VRLCj9NvuAM48YR4g5 NRjwJLsxwqXzt+RVqr6rUzPDr7oeNeTOYiON5by8i9SNRmCcrEMo58RK4uDBzmcKk+0S tMd/M2ySOlmCOT07PIIUlEBE5Y3ZYSemEviBY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=s2t3OBEBZv8gCynOpYw1ybZLTn4iofsMa7t+E6nlIw8=; b=RptDuQG8VPCNlfbb1M7tG07EnhALlnph9IlkNFMrnQ19PQ4q1GRszcBtjLMI/zTpru PJJ3IXIPs7CosUIwRgpuacOjKlqFqSIbEZuKIqKZwPDdtr8OGh7BOgrA2w4dugA1e/1f UeA/vOTy+nUIo5Fqt2m8ePZ5VZhn9KmqnzVQN7iYygMWdIZY3D3+trb56vV3l9JGIZ7N WeXGAqwYlRpV7sZ9/ovHEnXSVGF0JHgSG5npUFq2ZYYFnJkaan1Bm+OjhzBZdvcSnlUx iUQlX1sDevqFMIF07othweW0Jqs8F3+IWvDHnzMLZRGrTailTPTbJbdHRnyuxq2ad8/q z37A== X-Gm-Message-State: AOAM532xjgZ6m5HQmfCvfOt2XeoMO3m2ul4Z9M+320yLJrUj2AfX3CP6 keTxGTa1bXCCDTmfQ8aMg2hkCg== X-Google-Smtp-Source: ABdhPJz2sGn0Bqs0YP0tTx74GX1KX/TPZopgJxiZzR966FdQG3FtaTIpolYxJJbANoOa31KRVVpeEA== X-Received: by 2002:a17:90a:12:: with SMTP id 18mr4161394pja.104.1631650943914; Tue, 14 Sep 2021 13:22:23 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f38f:9d0f:3eba:f8c4]) by smtp.gmail.com with ESMTPSA id 141sm12185393pgg.16.2021.09.14.13.22.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 13:22:23 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring , Sam Ravnborg Cc: devicetree@vger.kernel.org, Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, David Airlie , Maarten Lankhorst , Thomas Zimmermann , Linus W , Bjorn Andersson , Daniel Vetter , Maxime Ripard , Douglas Anderson , Jani Nikula , linux-kernel@vger.kernel.org Subject: [PATCH v5 04/15] drm/edid: Use new encoded panel id style for quirks matching Date: Tue, 14 Sep 2021 13:21:51 -0700 Message-Id: <20210914132020.v5.4.I6103ce2b16e5e5a842b14c7022a034712b434609@changeid> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog In-Reply-To: <20210914202202.1702601-1-dianders@chromium.org> References: <20210914202202.1702601-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In the patch ("drm/edid: Allow the querying/working with the panel ID from the EDID") we introduced a different way of working with the panel ID stored in the EDID. Let's use this new way for the quirks code. Advantages of the new style: * Smaller data structure size. Saves 4 bytes per panel. * Iterate through quirks structure with just "==" instead of strncmp() * In-kernel storage is more similar to what's stored in the EDID itself making it easier to grok that they are referring to the same value. Signed-off-by: Douglas Anderson Reviewed-by: Jani Nikula --- This commit is only compile-tested. I don't have any DP panels that exercise this code. Transition from the old table to the new one was done with a regexp. Changes in v5: - Prettier encode panel ID function (thanks Andrzej!) Changes in v4: - ("Use new encoded panel id style for quirks matching") new for v4. drivers/gpu/drm/drm_edid.c | 156 +++++++++++++++++-------------------- 1 file changed, 70 insertions(+), 86 deletions(-) diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index f84e0dd264f4..53b342c058be 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c @@ -100,122 +100,127 @@ struct detailed_mode_closure { #define LEVEL_GTF2 2 #define LEVEL_CVT 3 +#define EDID_QUIRK(vend, product_id, _quirks) \ +{ \ + .panel_id = drm_edid_encode_panel_id(vend, product_id), \ + .quirks = _quirks \ +} + static const struct edid_quirk { - char vendor[4]; - int product_id; + u32 panel_id; u32 quirks; } edid_quirk_list[] = { /* Acer AL1706 */ - { "ACR", 44358, EDID_QUIRK_PREFER_LARGE_60 }, + EDID_QUIRK("ACR", 44358, EDID_QUIRK_PREFER_LARGE_60), /* Acer F51 */ - { "API", 0x7602, EDID_QUIRK_PREFER_LARGE_60 }, + EDID_QUIRK("API", 0x7602, EDID_QUIRK_PREFER_LARGE_60), /* AEO model 0 reports 8 bpc, but is a 6 bpc panel */ - { "AEO", 0, EDID_QUIRK_FORCE_6BPC }, + EDID_QUIRK("AEO", 0, EDID_QUIRK_FORCE_6BPC), /* BOE model on HP Pavilion 15-n233sl reports 8 bpc, but is a 6 bpc panel */ - { "BOE", 0x78b, EDID_QUIRK_FORCE_6BPC }, + EDID_QUIRK("BOE", 0x78b, EDID_QUIRK_FORCE_6BPC), /* CPT panel of Asus UX303LA reports 8 bpc, but is a 6 bpc panel */ - { "CPT", 0x17df, EDID_QUIRK_FORCE_6BPC }, + EDID_QUIRK("CPT", 0x17df, EDID_QUIRK_FORCE_6BPC), /* SDC panel of Lenovo B50-80 reports 8 bpc, but is a 6 bpc panel */ - { "SDC", 0x3652, EDID_QUIRK_FORCE_6BPC }, + EDID_QUIRK("SDC", 0x3652, EDID_QUIRK_FORCE_6BPC), /* BOE model 0x0771 reports 8 bpc, but is a 6 bpc panel */ - { "BOE", 0x0771, EDID_QUIRK_FORCE_6BPC }, + EDID_QUIRK("BOE", 0x0771, EDID_QUIRK_FORCE_6BPC), /* Belinea 10 15 55 */ - { "MAX", 1516, EDID_QUIRK_PREFER_LARGE_60 }, - { "MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60 }, + EDID_QUIRK("MAX", 1516, EDID_QUIRK_PREFER_LARGE_60), + EDID_QUIRK("MAX", 0x77e, EDID_QUIRK_PREFER_LARGE_60), /* Envision Peripherals, Inc. EN-7100e */ - { "EPI", 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH }, + EDID_QUIRK("EPI", 59264, EDID_QUIRK_135_CLOCK_TOO_HIGH), /* Envision EN2028 */ - { "EPI", 8232, EDID_QUIRK_PREFER_LARGE_60 }, + EDID_QUIRK("EPI", 8232, EDID_QUIRK_PREFER_LARGE_60), /* Funai Electronics PM36B */ - { "FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 | - EDID_QUIRK_DETAILED_IN_CM }, + EDID_QUIRK("FCM", 13600, EDID_QUIRK_PREFER_LARGE_75 | + EDID_QUIRK_DETAILED_IN_CM), /* LGD panel of HP zBook 17 G2, eDP 10 bpc, but reports unknown bpc */ - { "LGD", 764, EDID_QUIRK_FORCE_10BPC }, + EDID_QUIRK("LGD", 764, EDID_QUIRK_FORCE_10BPC), /* LG Philips LCD LP154W01-A5 */ - { "LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, - { "LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE }, + EDID_QUIRK("LPL", 0, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE), + EDID_QUIRK("LPL", 0x2a00, EDID_QUIRK_DETAILED_USE_MAXIMUM_SIZE), /* Samsung SyncMaster 205BW. Note: irony */ - { "SAM", 541, EDID_QUIRK_DETAILED_SYNC_PP }, + EDID_QUIRK("SAM", 541, EDID_QUIRK_DETAILED_SYNC_PP), /* Samsung SyncMaster 22[5-6]BW */ - { "SAM", 596, EDID_QUIRK_PREFER_LARGE_60 }, - { "SAM", 638, EDID_QUIRK_PREFER_LARGE_60 }, + EDID_QUIRK("SAM", 596, EDID_QUIRK_PREFER_LARGE_60), + EDID_QUIRK("SAM", 638, EDID_QUIRK_PREFER_LARGE_60), /* Sony PVM-2541A does up to 12 bpc, but only reports max 8 bpc */ - { "SNY", 0x2541, EDID_QUIRK_FORCE_12BPC }, + EDID_QUIRK("SNY", 0x2541, EDID_QUIRK_FORCE_12BPC), /* ViewSonic VA2026w */ - { "VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING }, + EDID_QUIRK("VSC", 5020, EDID_QUIRK_FORCE_REDUCED_BLANKING), /* Medion MD 30217 PG */ - { "MED", 0x7b8, EDID_QUIRK_PREFER_LARGE_75 }, + EDID_QUIRK("MED", 0x7b8, EDID_QUIRK_PREFER_LARGE_75), /* Lenovo G50 */ - { "SDC", 18514, EDID_QUIRK_FORCE_6BPC }, + EDID_QUIRK("SDC", 18514, EDID_QUIRK_FORCE_6BPC), /* Panel in Samsung NP700G7A-S01PL notebook reports 6bpc */ - { "SEC", 0xd033, EDID_QUIRK_FORCE_8BPC }, + EDID_QUIRK("SEC", 0xd033, EDID_QUIRK_FORCE_8BPC), /* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/ - { "ETR", 13896, EDID_QUIRK_FORCE_8BPC }, + EDID_QUIRK("ETR", 13896, EDID_QUIRK_FORCE_8BPC), /* Valve Index Headset */ - { "VLV", 0x91a8, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b0, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b1, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b2, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b3, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b4, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b5, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b6, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b7, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b8, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91b9, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91ba, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91bb, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91bc, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91bd, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91be, EDID_QUIRK_NON_DESKTOP }, - { "VLV", 0x91bf, EDID_QUIRK_NON_DESKTOP }, + EDID_QUIRK("VLV", 0x91a8, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b0, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b1, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b2, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b3, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b4, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b5, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b6, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b7, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b8, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91b9, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91ba, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91bb, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91bc, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91bd, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91be, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("VLV", 0x91bf, EDID_QUIRK_NON_DESKTOP), /* HTC Vive and Vive Pro VR Headsets */ - { "HVR", 0xaa01, EDID_QUIRK_NON_DESKTOP }, - { "HVR", 0xaa02, EDID_QUIRK_NON_DESKTOP }, + EDID_QUIRK("HVR", 0xaa01, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("HVR", 0xaa02, EDID_QUIRK_NON_DESKTOP), /* Oculus Rift DK1, DK2, CV1 and Rift S VR Headsets */ - { "OVR", 0x0001, EDID_QUIRK_NON_DESKTOP }, - { "OVR", 0x0003, EDID_QUIRK_NON_DESKTOP }, - { "OVR", 0x0004, EDID_QUIRK_NON_DESKTOP }, - { "OVR", 0x0012, EDID_QUIRK_NON_DESKTOP }, + EDID_QUIRK("OVR", 0x0001, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("OVR", 0x0003, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("OVR", 0x0004, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("OVR", 0x0012, EDID_QUIRK_NON_DESKTOP), /* Windows Mixed Reality Headsets */ - { "ACR", 0x7fce, EDID_QUIRK_NON_DESKTOP }, - { "HPN", 0x3515, EDID_QUIRK_NON_DESKTOP }, - { "LEN", 0x0408, EDID_QUIRK_NON_DESKTOP }, - { "LEN", 0xb800, EDID_QUIRK_NON_DESKTOP }, - { "FUJ", 0x1970, EDID_QUIRK_NON_DESKTOP }, - { "DEL", 0x7fce, EDID_QUIRK_NON_DESKTOP }, - { "SEC", 0x144a, EDID_QUIRK_NON_DESKTOP }, - { "AUS", 0xc102, EDID_QUIRK_NON_DESKTOP }, + EDID_QUIRK("ACR", 0x7fce, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("HPN", 0x3515, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("LEN", 0x0408, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("LEN", 0xb800, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("FUJ", 0x1970, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("DEL", 0x7fce, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("SEC", 0x144a, EDID_QUIRK_NON_DESKTOP), + EDID_QUIRK("AUS", 0xc102, EDID_QUIRK_NON_DESKTOP), /* Sony PlayStation VR Headset */ - { "SNY", 0x0704, EDID_QUIRK_NON_DESKTOP }, + EDID_QUIRK("SNY", 0x0704, EDID_QUIRK_NON_DESKTOP), /* Sensics VR Headsets */ - { "SEN", 0x1019, EDID_QUIRK_NON_DESKTOP }, + EDID_QUIRK("SEN", 0x1019, EDID_QUIRK_NON_DESKTOP), /* OSVR HDK and HDK2 VR Headsets */ - { "SVR", 0x1019, EDID_QUIRK_NON_DESKTOP }, + EDID_QUIRK("SVR", 0x1019, EDID_QUIRK_NON_DESKTOP), }; /* @@ -2090,9 +2095,8 @@ EXPORT_SYMBOL(drm_get_edid); static u32 edid_extract_panel_id(const struct edid *edid) { /* - * In theory we could try to de-obfuscate this like edid_get_quirks() - * does, but it's easier to just deal with a 32-bit number since then - * it can be compared with "==". + * We represent the ID as a 32-bit number so it can easily be compared + * with "==". * * NOTE that we deal with endianness differently for the top half * of this ID than for the bottom half. The bottom half (the product @@ -2197,25 +2201,6 @@ EXPORT_SYMBOL(drm_edid_duplicate); /*** EDID parsing ***/ -/** - * edid_vendor - match a string against EDID's obfuscated vendor field - * @edid: EDID to match - * @vendor: vendor string - * - * Returns true if @vendor is in @edid, false otherwise - */ -static bool edid_vendor(const struct edid *edid, const char *vendor) -{ - char edid_vendor[3]; - - edid_vendor[0] = ((edid->mfg_id[0] & 0x7c) >> 2) + '@'; - edid_vendor[1] = (((edid->mfg_id[0] & 0x3) << 3) | - ((edid->mfg_id[1] & 0xe0) >> 5)) + '@'; - edid_vendor[2] = (edid->mfg_id[1] & 0x1f) + '@'; - - return !strncmp(edid_vendor, vendor, 3); -} - /** * edid_get_quirks - return quirk flags for a given EDID * @edid: EDID to process @@ -2224,14 +2209,13 @@ static bool edid_vendor(const struct edid *edid, const char *vendor) */ static u32 edid_get_quirks(const struct edid *edid) { + u32 panel_id = edid_extract_panel_id(edid); const struct edid_quirk *quirk; int i; for (i = 0; i < ARRAY_SIZE(edid_quirk_list); i++) { quirk = &edid_quirk_list[i]; - - if (edid_vendor(edid, quirk->vendor) && - (EDID_PRODUCT_ID(edid) == quirk->product_id)) + if (quirk->panel_id == panel_id) return quirk->quirks; } From patchwork Tue Sep 14 20:21:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 511006 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=-19.1 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, 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 3EF57C433FE for ; Tue, 14 Sep 2021 20:22:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2CDE86117A for ; Tue, 14 Sep 2021 20:22:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234216AbhINUYB (ORCPT ); Tue, 14 Sep 2021 16:24:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233880AbhINUXs (ORCPT ); Tue, 14 Sep 2021 16:23:48 -0400 Received: from mail-pl1-x629.google.com (mail-pl1-x629.google.com [IPv6:2607:f8b0:4864:20::629]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 55B0BC0613EF for ; Tue, 14 Sep 2021 13:22:30 -0700 (PDT) Received: by mail-pl1-x629.google.com with SMTP id n4so148973plh.9 for ; Tue, 14 Sep 2021 13:22:30 -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=PBcYPyXmjQckFM/2vcPXaB6/oJE2xaU/uFm+3ktt/M4=; b=CckSXAwHc21xof5pws6PHHqcPQ6kRaqr7CDq3Ah80T9bXoLzSQyJLLwyDJdp/Z4NV+ KnBsoarxEdp5JCWnwQvDcUob4dp+ZffeJ4ikwepOBFvcQOv2QzXOoQAFLijV2lgZM65j akcP3i1aearFox7NMwtUtwptpOl1kFR5btp7c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PBcYPyXmjQckFM/2vcPXaB6/oJE2xaU/uFm+3ktt/M4=; b=UrW1Cxt56oG1i9b5XgOQ8Snzjm65E4kxhdlxQpeAcfNM6/MxKNJeFAihXO2VY8S5S1 zLOCjVEtwefLymdpfwEYa32p7hvNni69bxP7SNI3OkGsJxj7jhu9B+5A+doKzs0Im119 WndnARLpJ7YDw0FeA53U1PeHlEpUWkEYnCADojpexFCoZBc8J6sgOpzSDzVICy2VAfIW +TNzFPf6f+1osfa2fSuvN8kjxNDlfcCBbsGgGMOfTB49H5vQQi8EOIPvnRkqqOVyFw4i RHlD8uSMqJv9ooG11Xd1GmP0MGZt/b7+5ihGqHNGo2cLnIy41nYN/hBcxpnUoObSTYzi 5rdg== X-Gm-Message-State: AOAM533Wwe0AcOZc/s/4iUVhDfiyXnu/Ts00WMXj3G2DW2SmJNHb3KSv rgUqxzWtKYjSi+CHvlfguwvLwA== X-Google-Smtp-Source: ABdhPJwT8YboamT7k/5uDkHsbWCYQKBAEu3nQN/DiSI9zWeXYNzhx+6XvNbN4xBxoN6Mk4dIUp+88Q== X-Received: by 2002:a17:90b:4b47:: with SMTP id mi7mr4168709pjb.198.1631650949909; Tue, 14 Sep 2021 13:22:29 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f38f:9d0f:3eba:f8c4]) by smtp.gmail.com with ESMTPSA id 141sm12185393pgg.16.2021.09.14.13.22.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 13:22:29 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring , Sam Ravnborg Cc: devicetree@vger.kernel.org, Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, David Airlie , Maarten Lankhorst , Thomas Zimmermann , Linus W , Bjorn Andersson , Daniel Vetter , Maxime Ripard , Douglas Anderson , Adam Ford , Andrey Zhizhikin , Catalin Marinas , Dmitry Baryshkov , Enric Balletbo i Serra , =?utf-8?q?Guido_G=C3=BCnther?= , Jagan Teki , Krzysztof Kozlowski , Matthias Brugger , Michael Walle , Nishanth Menon , Shawn Guo , Will Deacon , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 06/15] arm64: defconfig: Everyone who had PANEL_SIMPLE now gets PANEL_EDP Date: Tue, 14 Sep 2021 13:21:53 -0700 Message-Id: <20210914132020.v5.6.Ied5c4da3ea36f8c49343176eda342027b6f19586@changeid> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog In-Reply-To: <20210914202202.1702601-1-dianders@chromium.org> References: <20210914202202.1702601-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org In the patch ("drm/panel-simple-edp: Split eDP panels out of panel-simple") we split the PANEL_SIMPLE driver in 2. Let's enable the new config. Signed-off-by: Douglas Anderson Acked-by: Sam Ravnborg --- (no changes since v4) Changes in v4: - PANEL_SIMPLE_EDP => PANEL_EDP - Reordered config patches to be before code patch arch/arm64/configs/defconfig | 1 + 1 file changed, 1 insertion(+) diff --git a/arch/arm64/configs/defconfig b/arch/arm64/configs/defconfig index f423d08b9a71..01b30f4a7e74 100644 --- a/arch/arm64/configs/defconfig +++ b/arch/arm64/configs/defconfig @@ -697,6 +697,7 @@ CONFIG_DRM_MSM=m CONFIG_DRM_TEGRA=m CONFIG_DRM_PANEL_LVDS=m CONFIG_DRM_PANEL_SIMPLE=m +CONFIG_DRM_PANEL_EDP=m CONFIG_DRM_PANEL_BOE_TV101WUM_NL6=m CONFIG_DRM_PANEL_MANTIX_MLAF057WE51=m CONFIG_DRM_PANEL_RAYDIUM_RM67191=m From patchwork Tue Sep 14 20:21:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 511005 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=-19.1 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, 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 B63C4C43217 for ; Tue, 14 Sep 2021 20:23:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9A33361178 for ; Tue, 14 Sep 2021 20:23:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234896AbhINUYd (ORCPT ); Tue, 14 Sep 2021 16:24:33 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234253AbhINUX7 (ORCPT ); Tue, 14 Sep 2021 16:23:59 -0400 Received: from mail-pl1-x634.google.com (mail-pl1-x634.google.com [IPv6:2607:f8b0:4864:20::634]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 30318C06178A for ; Tue, 14 Sep 2021 13:22:35 -0700 (PDT) Received: by mail-pl1-x634.google.com with SMTP id v1so139352plo.10 for ; Tue, 14 Sep 2021 13:22:35 -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=zFVooNpkXKL6QaH2NxgTwLnrt9lRR1lq61UFSNpROL4=; b=YiHuT2U32Cavd1ndhjDmW7DKt1dTQ9jdfsYNbuJK7wL0LwwJpqTsldmHl+sKQJMBC9 IbK6Vfi4j/jH205T7GDyfxD2h0ffjTgtxAXPiukh9299+XxKYh2RFkNJY7LJ0y1ffXb7 mFmNs8jHRzXJz7tVoOlDCYYFC9CsGr1pECE18= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=zFVooNpkXKL6QaH2NxgTwLnrt9lRR1lq61UFSNpROL4=; b=6b+dtxlggLesKtbRrMMnC5xTlB8XKD2I08ywyWbcu9QdFARW/CGxhtgcno7c+hLDUB oN5mrHp9MWb5zLD8vHdx3t3u+QQhagMAAu3j0+Srb5kEaVksBgpq1nQBeXjrihTPAG5Q 1kK0UhcVvOzEHG5eG2uGswPpdI0lDU2kf13gq1zuUvT/OWAXaX9GlNBnOvMq41WqQJkc ckNrrjMyL2RzTjUCSIUFLzUslhwT2v3Oms4OGCiuH9YbiBFBRG+8JvdseuKlUmz73uEp aF/D+wtV17Qn1ZGRBGOVwdzctbX8jgO0TfhvO7UpRto11tUAoSVSAFvCcGpl/VoR+Qsh ZCvA== X-Gm-Message-State: AOAM533eLN6xjpN+N/ZgKipqKcHnu7zWCq5pGHe+L7PkPcdMpPoRttgH R5EsBzsGSwLC9IFZaS1x2BkugQ== X-Google-Smtp-Source: ABdhPJxpb59hFktEUsGtipn4+6ObQpKxVDWnubnmEtjcV7gbXHLUZBLllQ3TmuYjqw1ZgK8f97Znjg== X-Received: by 2002:a17:90b:1646:: with SMTP id il6mr4148242pjb.210.1631650954684; Tue, 14 Sep 2021 13:22:34 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f38f:9d0f:3eba:f8c4]) by smtp.gmail.com with ESMTPSA id 141sm12185393pgg.16.2021.09.14.13.22.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 13:22:34 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring , Sam Ravnborg Cc: devicetree@vger.kernel.org, Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, David Airlie , Maarten Lankhorst , Thomas Zimmermann , Linus W , Bjorn Andersson , Daniel Vetter , Maxime Ripard , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v5 09/15] drm/panel-simple: Non-eDP panels don't need "HPD" handling Date: Tue, 14 Sep 2021 13:21:56 -0700 Message-Id: <20210914132020.v5.9.I77d7a48df0a6585ef2cc2ff140fbe8f236a9a9f7@changeid> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog In-Reply-To: <20210914202202.1702601-1-dianders@chromium.org> References: <20210914202202.1702601-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org All of the "HPD" handling added to panel-simple recently was for eDP panels. Remove it from panel-simple now that panel-edp handles eDP panels. The "prepare_to_enable" delay only makes sense in the context of HPD, so remove it too. No non-eDP panels used it anyway. Signed-off-by: Douglas Anderson Acked-by: Sam Ravnborg --- (no changes since v4) Changes in v4: - panel-simple-edp => panel-edp Changes in v3: - ("Non-eDP panels don't need "HPD" handling") new for v3. drivers/gpu/drm/panel/panel-simple.c | 134 +-------------------------- 1 file changed, 4 insertions(+), 130 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-simple.c b/drivers/gpu/drm/panel/panel-simple.c index 79cbad7e8c84..323d24427ec0 100644 --- a/drivers/gpu/drm/panel/panel-simple.c +++ b/drivers/gpu/drm/panel/panel-simple.c @@ -23,7 +23,6 @@ #include #include -#include #include #include #include @@ -92,44 +91,6 @@ struct panel_desc { */ 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.enable: Time for the panel to display a valid frame. * @@ -174,7 +135,6 @@ struct panel_desc { struct panel_simple { struct drm_panel base; bool enabled; - bool no_hpd; bool prepared; @@ -187,7 +147,6 @@ struct panel_simple { struct i2c_adapter *ddc; struct gpio_desc *enable_gpio; - struct gpio_desc *hpd_gpio; struct edid *edid; @@ -371,30 +330,10 @@ static int panel_simple_unprepare(struct drm_panel *panel) return 0; } -static int panel_simple_get_hpd_gpio(struct device *dev, struct panel_simple *p) -{ - int err; - - p->hpd_gpio = devm_gpiod_get_optional(dev, "hpd", GPIOD_IN); - if (IS_ERR(p->hpd_gpio)) { - err = PTR_ERR(p->hpd_gpio); - - if (err != -EPROBE_DEFER) - dev_err(dev, "failed to get 'hpd' GPIO: %d\n", err); - - return err; - } - - return 0; -} - -static int panel_simple_prepare_once(struct panel_simple *p) +static int panel_simple_resume(struct device *dev) { - struct device *dev = p->base.dev; - unsigned int delay; + struct panel_simple *p = dev_get_drvdata(dev); int err; - int hpd_asserted; - unsigned long hpd_wait_us; panel_simple_wait(p->unprepared_time, p->desc->delay.unprepare); @@ -406,68 +345,12 @@ static int panel_simple_prepare_once(struct panel_simple *p) gpiod_set_value_cansleep(p->enable_gpio, 1); - delay = p->desc->delay.prepare; - if (p->no_hpd) - 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; - else - hpd_wait_us = 2000000; - - err = readx_poll_timeout(gpiod_get_value_cansleep, p->hpd_gpio, - hpd_asserted, hpd_asserted, - 1000, hpd_wait_us); - if (hpd_asserted < 0) - err = hpd_asserted; - - if (err) { - if (err != -ETIMEDOUT) - dev_err(dev, - "error waiting for hpd GPIO: %d\n", err); - goto error; - } - } + if (p->desc->delay.prepare) + msleep(p->desc->delay.prepare); p->prepared_time = ktime_get(); return 0; - -error: - gpiod_set_value_cansleep(p->enable_gpio, 0); - regulator_disable(p->supply); - p->unprepared_time = ktime_get(); - - return err; -} - -/* - * Some panels simply don't always come up and need to be power cycled to - * work properly. We'll allow for a handful of retries. - */ -#define MAX_PANEL_PREPARE_TRIES 5 - -static int panel_simple_resume(struct device *dev) -{ - struct panel_simple *p = dev_get_drvdata(dev); - int ret; - int try; - - for (try = 0; try < MAX_PANEL_PREPARE_TRIES; try++) { - ret = panel_simple_prepare_once(p); - if (ret != -ETIMEDOUT) - break; - } - - if (ret == -ETIMEDOUT) - dev_err(dev, "Prepare timeout after %d tries\n", try); - else if (try) - dev_warn(dev, "Prepare needed %d retries\n", try); - - return ret; } static int panel_simple_prepare(struct drm_panel *panel) @@ -500,8 +383,6 @@ static int panel_simple_enable(struct drm_panel *panel) if (p->desc->delay.enable) msleep(p->desc->delay.enable); - panel_simple_wait(p->prepared_time, p->desc->delay.prepare_to_enable); - p->enabled = true; return 0; @@ -674,13 +555,6 @@ static int panel_simple_probe(struct device *dev, const struct panel_desc *desc) panel->prepared_time = 0; panel->desc = desc; - panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd"); - if (!panel->no_hpd) { - err = panel_simple_get_hpd_gpio(dev, panel); - if (err) - return err; - } - panel->supply = devm_regulator_get(dev, "power"); if (IS_ERR(panel->supply)) return PTR_ERR(panel->supply); From patchwork Tue Sep 14 20:21:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 511004 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=-19.1 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, 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 91FE2C433EF for ; Tue, 14 Sep 2021 20:23:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 75D1A6117A for ; Tue, 14 Sep 2021 20:23:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234253AbhINUYf (ORCPT ); Tue, 14 Sep 2021 16:24:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37660 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234059AbhINUYE (ORCPT ); Tue, 14 Sep 2021 16:24:04 -0400 Received: from mail-pg1-x52d.google.com (mail-pg1-x52d.google.com [IPv6:2607:f8b0:4864:20::52d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8B1BCC0617AA for ; Tue, 14 Sep 2021 13:22:36 -0700 (PDT) Received: by mail-pg1-x52d.google.com with SMTP id f129so382752pgc.1 for ; Tue, 14 Sep 2021 13:22:36 -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=SbkNd1f+XymmLQZxu6dv4yw2I0ZGx0PXZjCpH/YskzY=; b=C76eWOOWZdZu78MXStEfzsfhVb5cN/UDIHSrPo4LvCf0sZg9pQ4rlZxGyzLasXBDeX KRoierZw/+Iz9TQ/hLj4QdZJLinIa69QCPTUbWQSUx0/VMgxfdyw0NX4SdwCQNKh2IYl UiAyw4rtX9v8z6xT+71ljtdWrO9w6dqakgOqY= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SbkNd1f+XymmLQZxu6dv4yw2I0ZGx0PXZjCpH/YskzY=; b=El2zoHl7YRmMgH0Tea+ShixZFcd6xuI0WulJnGjgicyLsxgxR89A2ScWQZ8Q+WfwEr vxCXqfpIHtl/b0iR4E/fQ2eeTDi3IjhJRWS54t3QiE11yBr+4jKMWnUgZ2GDvAoDD//T 6/XWhokvw9Q8o65SzGBcO2Mi/cQxFE8E5hpjiuJTzw0sq0KtXePsI9fMkSkR6ezwbGPR eC1+DJArYlPbNj4RHOJ+3L0aJT7RY6itCDJeCql/uDB2xGZJ41CpYFmj5wMaVRYWw5SD lXvK07YXSdO1js56jWHFFFAqPRd1Pcl52mjkGATLw0romiwnulpvAgx/04mfEZzjXbgd FCKQ== X-Gm-Message-State: AOAM531XBTZcQj6sOrrPa2poevi+40Raq1BA/ofzBqio4nkpGDe3WHaG h8b6MDdp71hZ0jOvg4K4/AGpTQ== X-Google-Smtp-Source: ABdhPJzGfT9Hv5Is/g5kCUfIVMMc3F4nLifKxWjim9jX4524134jIL5QK9ZcTa+RC/oVu+v7cLddvA== X-Received: by 2002:a63:a80c:: with SMTP id o12mr17041076pgf.422.1631650956083; Tue, 14 Sep 2021 13:22:36 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f38f:9d0f:3eba:f8c4]) by smtp.gmail.com with ESMTPSA id 141sm12185393pgg.16.2021.09.14.13.22.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 13:22:35 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring , Sam Ravnborg Cc: devicetree@vger.kernel.org, Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, David Airlie , Maarten Lankhorst , Thomas Zimmermann , Linus W , Bjorn Andersson , Daniel Vetter , Maxime Ripard , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v5 10/15] drm/panel-edp: Split the delay structure out Date: Tue, 14 Sep 2021 13:21:57 -0700 Message-Id: <20210914132020.v5.10.I24f3646dd09954958645cc05c538909f169bf362@changeid> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog In-Reply-To: <20210914202202.1702601-1-dianders@chromium.org> References: <20210914202202.1702601-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 Acked-by: Sam Ravnborg --- (no changes since v4) Changes in v4: - panel-simple-edp => panel-edp Changes in v3: - Split the delay structure out patch just on eDP now. drivers/gpu/drm/panel/panel-edp.c | 159 +++++++++++++++--------------- 1 file changed, 82 insertions(+), 77 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index b698594ba43b..26f4ae7921e5 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -40,6 +40,87 @@ #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; + + /** + * @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. */ @@ -84,83 +165,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.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; }; struct panel_edp { From patchwork Tue Sep 14 20:22:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 511003 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=-19.1 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, 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 A508BC433F5 for ; Tue, 14 Sep 2021 20:23:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87A6061184 for ; Tue, 14 Sep 2021 20:23:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234701AbhINUYj (ORCPT ); Tue, 14 Sep 2021 16:24:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37688 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234833AbhINUY3 (ORCPT ); Tue, 14 Sep 2021 16:24:29 -0400 Received: from mail-pf1-x42b.google.com (mail-pf1-x42b.google.com [IPv6:2607:f8b0:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0DA7BC0613DE for ; Tue, 14 Sep 2021 13:22:42 -0700 (PDT) Received: by mail-pf1-x42b.google.com with SMTP id b7so435078pfo.11 for ; Tue, 14 Sep 2021 13:22:42 -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=dJXTwqS7PuPIT9CX0XVjRt+gK42F+FHMqbBg2Uj5BR4=; b=TqWvXeuyHuOSheemL0zyn3JHr5nZAS/bX+S2paShRs7l85FXpUjcDkt+1hQOqYJpwi Y5Pc8CsKF9F/Z3fUcl0iqJM4OIkeo1KmeN5dAWId8xYA37vSflKYmLAll37niHOfXqGS PN/VU9P8n26x9bxoXaxT8PyNNp5eteYT3LZqo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=dJXTwqS7PuPIT9CX0XVjRt+gK42F+FHMqbBg2Uj5BR4=; b=CN/RL9wwBgaSJfVjyBQmjnnjc02fVSy2SOmyezjRlZTiuzot/y2m+T6TJPWWtRV+8R bNFtL0L1Ki22ts21qWOuLwG8R8Ci3uEx9UL4q/VYsRfT25eCXWmSvdedM1FdN/jAy8MD bk5VQNXYHNdE78JU5tmBhSHCZlGolwI/YMQJsU8H3jO2Yr2e0LMNgeCE1dU3gOh3ltDw 0yEjW+fcHr6CHKw2o58Ln1D9kBN6dQiC0MhL00NfbpV0Joo6Meueejn3hCv1IwHFLGXe vvJS2vStvHw7RoNLIlzQnr/oojaGF8s74uEln97dtpHl+KGQPXsjK+sMoidM+M2/JpYA Gj2w== X-Gm-Message-State: AOAM5301GkgSNpMHiIhVAwqI3lVOKzJI5dKFQelSY3eKBUgABh0ra6aB q7MKF1qk2MEJPUM5SKcXWK916A== X-Google-Smtp-Source: ABdhPJyDGeNjSKE64qgG3//L1RREy4RmX89o+nEgvz2C87yHljnSuXQt+fd9GBedSnhIztUqyUoGfA== X-Received: by 2002:a63:6d89:: with SMTP id i131mr16955280pgc.235.1631650961596; Tue, 14 Sep 2021 13:22:41 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f38f:9d0f:3eba:f8c4]) by smtp.gmail.com with ESMTPSA id 141sm12185393pgg.16.2021.09.14.13.22.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 13:22:41 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring , Sam Ravnborg Cc: devicetree@vger.kernel.org, Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, David Airlie , Maarten Lankhorst , Thomas Zimmermann , Linus W , Bjorn Andersson , Daniel Vetter , Maxime Ripard , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v5 14/15] drm/panel-edp: Don't re-read the EDID every time we power off the panel Date: Tue, 14 Sep 2021 13:22:01 -0700 Message-Id: <20210914132020.v5.14.Ib810fb3bebd0bd6763e4609e1a6764d06064081e@changeid> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog In-Reply-To: <20210914202202.1702601-1-dianders@chromium.org> References: <20210914202202.1702601-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 Acked-by: Sam Ravnborg --- (no changes since v4) Changes in v4: - panel-simple-edp => panel-edp Changes in v3: - ("Don't re-read the EDID every time") moved to eDP only patch. drivers/gpu/drm/panel/panel-edp.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index a83ef9905ea7..817c60858ef8 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -362,9 +362,6 @@ static int panel_edp_suspend(struct device *dev) regulator_disable(p->supply); p->unprepared_time = ktime_get(); - kfree(p->edid); - p->edid = NULL; - return 0; } @@ -758,6 +755,9 @@ static int panel_edp_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 Tue Sep 14 20:22:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Doug Anderson X-Patchwork-Id: 511002 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=-19.1 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, 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 DBF06C4332F for ; Tue, 14 Sep 2021 20:23:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C83E061264 for ; Tue, 14 Sep 2021 20:23:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234457AbhINUYo (ORCPT ); Tue, 14 Sep 2021 16:24:44 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37694 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234879AbhINUYd (ORCPT ); Tue, 14 Sep 2021 16:24:33 -0400 Received: from mail-pj1-x102e.google.com (mail-pj1-x102e.google.com [IPv6:2607:f8b0:4864:20::102e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD556C0613E9 for ; Tue, 14 Sep 2021 13:22:43 -0700 (PDT) Received: by mail-pj1-x102e.google.com with SMTP id k23so563013pji.0 for ; Tue, 14 Sep 2021 13:22:43 -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=ImwOHouVQsDdwEGq/0DaGprseO0ycyPBvVBOnk+aelw=; b=PAfCWmrOn5L9sUwX2HlXlrOvqf83bUOkswByGUY/ZULC8jyCr4GVb9f7W3LyvTRrqW 4H4Xkf4c0qiNUJZLFDKnN74TVxOtHFYgZyGEtyd8iYE6SWJ6wqaK80g3i2DWLAMS2qH2 JsTcWKfiirvRtk0b5Y11KokrlU3pOIFt+Me8c= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ImwOHouVQsDdwEGq/0DaGprseO0ycyPBvVBOnk+aelw=; b=QbCBul5SlaRp7QqvAim3eoOdcxKfQT1QGPSNLuSIgS5CdwBB4OWsjCVhOxNjMZ8XPy vE5tNTSo5GQiXFMN3fWqyxVnJLSuG7rFfZI/OyEHMRoMN+/gPjiPzDiuPVkxxpo+Wxg3 XUJHMps27uwrjyixQRQkB4cce7mm2TrCeQgojH7otZ4llWt5Cf+UKtYRG8NTvyi5u+Tv GhwdzE8MXDX77H7chjFZvWmT6nxMtfsZTAZcoggry1s9Rah/GNjbiFYGn3/0kff/uBG5 qk95HsAKtu7WROGCXPXohzYl8zFS8qcD9BlbQ0jFBuLDI48+js6Xhjk8NC9OhqAHWSea cJAw== X-Gm-Message-State: AOAM531+DXvqYA6nBCoXFw7xk6ZK0Y9HUvw6HlyitmdHFiNdDu7QJ/AX SCZKNFuMtsOnZOAIPECnvt00lg== X-Google-Smtp-Source: ABdhPJz7cQthh0Ng8auEgRkki50tAgG3FA6dbiZVswIEHmA9qHwjiz+dU/pg613Hzwv2N29ch7rf6A== X-Received: by 2002:a17:902:7145:b0:137:2e25:5bf0 with SMTP id u5-20020a170902714500b001372e255bf0mr16665625plm.10.1631650963110; Tue, 14 Sep 2021 13:22:43 -0700 (PDT) Received: from tictac2.mtv.corp.google.com ([2620:15c:202:201:f38f:9d0f:3eba:f8c4]) by smtp.gmail.com with ESMTPSA id 141sm12185393pgg.16.2021.09.14.13.22.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 14 Sep 2021 13:22:42 -0700 (PDT) From: Douglas Anderson To: Thierry Reding , Rob Herring , Sam Ravnborg Cc: devicetree@vger.kernel.org, Steev Klimaszewski , dri-devel@lists.freedesktop.org, linux-arm-msm@vger.kernel.org, David Airlie , Maarten Lankhorst , Thomas Zimmermann , Linus W , Bjorn Andersson , Daniel Vetter , Maxime Ripard , Douglas Anderson , linux-kernel@vger.kernel.org Subject: [PATCH v5 15/15] drm/panel-edp: Implement generic "edp-panel"s probed by EDID Date: Tue, 14 Sep 2021 13:22:02 -0700 Message-Id: <20210914132020.v5.15.Id9c96cba4eba3e5ee519bfb09cd64b39f2490293@changeid> X-Mailer: git-send-email 2.33.0.309.g3052b89438-goog In-Reply-To: <20210914202202.1702601-1-dianders@chromium.org> References: <20210914202202.1702601-1-dianders@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org As discussed in the patch ("dt-bindings: drm/panel-simple: Introduce generic eDP panels") we can actually support probing eDP panels at runtime instead of hardcoding what panel is connected. Add support to the panel-edp driver for this. We'll implement a solution like this: * We'll read in two delays from the device tree that are used for powering up the panel the initial time (to read the EDID). * In the EDID we can find a 32-bit ID that identifies what panel we've found. From this ID we can look up the full set of delays. After this change we'll still need to add per-panel delays into the panel-simple driver but we will no longer need to specify exactly which panel is connected to which board in the device tree. Nicely, any panels that are only supported this way also don't need to hardcode mode data since it's guaranteed that we can get that through the EDID. This patch will seed the ID-to-delay table with a few panels that I have access to, many of which are on sc7180-trogdor devices. Signed-off-by: Douglas Anderson Acked-by: Sam Ravnborg --- Changes in v5: - Prettier encode panel ID function (thanks Andrzej!) Changes in v4: - decode_edid_id() => drm_edid_decode_panel_id() - drm_get_panel_id() => drm_edid_get_panel_id() - encode_edid_id() => drm_edid_encode_panel_id() - panel-simple-edp => panel-edp Changes in v3: - Add AUO B116XAN06.1 to table. - Add Sharp LQ116M1JW10 to table. - Adjust endianness of product ID. - Change init order to we power at the end. - Fallback to conservative delays if panel not recognized. - Generic "edp-panel" handled by the eDP panel driver now. - Rename delays more generically so they can be reused. Changes in v2: - Add "-ms" suffix to delays. - Don't support a "fallback" panel. Probed panels must be probed. - Not based on patch to copy "desc"--just allocate for probed panels. drivers/gpu/drm/panel/panel-edp.c | 215 ++++++++++++++++++++++++++++-- 1 file changed, 201 insertions(+), 14 deletions(-) diff --git a/drivers/gpu/drm/panel/panel-edp.c b/drivers/gpu/drm/panel/panel-edp.c index 817c60858ef8..8195155ac83e 100644 --- a/drivers/gpu/drm/panel/panel-edp.c +++ b/drivers/gpu/drm/panel/panel-edp.c @@ -189,6 +189,20 @@ struct panel_desc { struct panel_delay delay; }; +/** + * 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; + + /* @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; +}; + struct panel_edp { struct drm_panel base; bool enabled; @@ -559,8 +573,15 @@ static int panel_edp_get_modes(struct drm_panel *panel, pm_runtime_put_autosuspend(panel->dev); } - /* add hard-coded panel modes */ - num += panel_edp_get_non_edid_modes(p, connector); + /* + * Add hard-coded panel modes. Don't call this if there are no timings + * and no modes (the generic edp-panel case) because it will clobber + * the display_info that was already set by drm_add_edid_modes(). + */ + if (p->desc->num_timings || p->desc->num_modes) + num += panel_edp_get_non_edid_modes(p, connector); + else if (!num) + dev_warn(p->base.dev, "No display modes\n"); /* set up connector's "panel orientation" property */ drm_connector_set_panel_orientation(connector, p->orientation); @@ -641,6 +662,94 @@ 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 int generic_edp_panel_probe(struct device *dev, struct panel_edp *panel) +{ + const struct edp_panel_entry *edp_panel; + struct panel_desc *desc; + u32 panel_id; + char vend[4]; + u16 product_id; + u32 reliable_ms = 0; + u32 absent_ms = 0; + int ret; + + desc = devm_kzalloc(dev, sizeof(*desc), GFP_KERNEL); + if (!desc) + return -ENOMEM; + panel->desc = desc; + + /* + * Read the dts properties for the initial probe. These are used by + * the runtime resume code which will get called by the + * pm_runtime_get_sync() call below. + */ + of_property_read_u32(dev->of_node, "hpd-reliable-delay-ms", &reliable_ms); + desc->delay.hpd_reliable = reliable_ms; + of_property_read_u32(dev->of_node, "hpd-absent-delay-ms", &absent_ms); + desc->delay.hpd_reliable = absent_ms; + + /* Power the panel on so we can read the EDID */ + ret = pm_runtime_get_sync(dev); + if (ret < 0) { + dev_err(dev, "Couldn't power on panel to read EDID: %d\n", ret); + goto exit; + } + + panel_id = drm_edid_get_panel_id(panel->ddc); + if (!panel_id) { + dev_err(dev, "Couldn't identify panel via EDID\n"); + ret = -EIO; + goto exit; + } + drm_edid_decode_panel_id(panel_id, vend, &product_id); + + edp_panel = find_edp_panel(panel_id); + + /* + * We're using non-optimized timings and want it really obvious that + * someone needs to add an entry to the table, so we'll do a WARN_ON + * splat. + */ + if (WARN_ON(!edp_panel)) { + dev_warn(dev, + "Unknown panel %s %#06x, using conservative timings\n", + vend, product_id); + + /* + * It's highly likely that the panel will work if we use very + * conservative timings, so let's do that. We already know that + * the HPD-related delays must have worked since we got this + * far, so we really just need the "unprepare" / "enable" + * delays. We don't need "prepare_to_enable" since that + * overlaps the "enable" delay anyway. + * + * Nearly all panels have a "unprepare" delay of 500 ms though + * there are a few with 1000. Let's stick 2000 in just to be + * super conservative. + * + * An "enable" delay of 80 ms seems the most common, but we'll + * throw in 200 ms to be safe. + */ + desc->delay.unprepare = 2000; + desc->delay.enable = 200; + } else { + dev_info(dev, "Detected %s %s (%#06x)\n", + vend, edp_panel->name, product_id); + + /* Update the delay; everything else comes from EDID */ + desc->delay = *edp_panel->delay; + } + + ret = 0; +exit: + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + + return ret; +} + static int panel_edp_probe(struct device *dev, const struct panel_desc *desc, struct drm_dp_aux *aux) { @@ -698,12 +807,14 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc, if (!of_get_display_timing(dev->of_node, "panel-timing", &dt)) panel_edp_parse_panel_timing_node(dev, panel, &dt); - /* Catch common mistakes for panels. */ - if (desc->bpc != 6 && desc->bpc != 8 && desc->bpc != 10) - dev_warn(dev, "Expected bpc in {6,8,10} but got: %u\n", desc->bpc); - dev_set_drvdata(dev, panel); + drm_panel_init(&panel->base, dev, &panel_edp_funcs, DRM_MODE_CONNECTOR_eDP); + + err = drm_panel_of_backlight(&panel->base); + if (err) + goto err_finished_ddc_init; + /* * We use runtime PM for prepare / unprepare since those power the panel * on and off and those can be very slow operations. This is important @@ -714,11 +825,18 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc, pm_runtime_set_autosuspend_delay(dev, 1000); pm_runtime_use_autosuspend(dev); - drm_panel_init(&panel->base, dev, &panel_edp_funcs, DRM_MODE_CONNECTOR_eDP); - - err = drm_panel_of_backlight(&panel->base); - if (err) - goto disable_pm_runtime; + if (of_device_is_compatible(dev->of_node, "edp-panel")) { + err = generic_edp_panel_probe(dev, panel); + if (err) { + dev_err_probe(dev, err, + "Couldn't detect panel nor find a fallback\n"); + goto err_finished_pm_runtime; + } + /* generic_edp_panel_probe() replaces desc in the panel */ + desc = panel->desc; + } else if (desc->bpc != 6 && desc->bpc != 8 && desc->bpc != 10) { + dev_warn(dev, "Expected bpc in {6,8,10} but got: %u\n", desc->bpc); + } if (!panel->base.backlight && panel->aux) { pm_runtime_get_sync(dev); @@ -726,16 +844,17 @@ static int panel_edp_probe(struct device *dev, const struct panel_desc *desc, pm_runtime_mark_last_busy(dev); pm_runtime_put_autosuspend(dev); if (err) - goto disable_pm_runtime; + goto err_finished_pm_runtime; } drm_panel_add(&panel->base); return 0; -disable_pm_runtime: +err_finished_pm_runtime: pm_runtime_dont_use_autosuspend(dev); pm_runtime_disable(dev); +err_finished_ddc_init: if (panel->ddc && (!panel->aux || panel->ddc != &panel->aux->ddc)) put_device(&panel->ddc->dev); @@ -1516,6 +1635,9 @@ static const struct panel_desc starry_kr122ea0sra = { static const struct of_device_id platform_of_match[] = { { + /* Must be first */ + .compatible = "edp-panel", + }, { .compatible = "auo,b101ean01", .data = &auo_b101ean01, }, { @@ -1605,11 +1727,76 @@ static const struct of_device_id platform_of_match[] = { }; MODULE_DEVICE_TABLE(of, platform_of_match); +static const struct panel_delay delay_200_500_p2e80 = { + .hpd_absent = 200, + .unprepare = 500, + .prepare_to_enable = 80, +}; + +static const struct panel_delay delay_200_500_p2e100 = { + .hpd_absent = 200, + .unprepare = 500, + .prepare_to_enable = 100, +}; + +static const struct panel_delay delay_200_500_e50 = { + .hpd_absent = 200, + .unprepare = 500, + .enable = 50, +}; + +#define EDP_PANEL_ENTRY(vend, product_id, _delay, _name) \ +{ \ + .name = _name, \ + .panel_id = drm_edid_encode_panel_id(vend, product_id), \ + .delay = _delay \ +} + +/* + * This table is used to figure out power sequencing delays for panels that + * are detected by EDID. Entries here may point to entries in the + * platform_of_match table (if a panel is listed in both places). + * + * Sort first by vendor, then by product ID. + */ +static const struct edp_panel_entry edp_panels[] = { + EDP_PANEL_ENTRY("AUO", 0x405c, &auo_b116xak01.delay, "B116XAK01"), + EDP_PANEL_ENTRY("AUO", 0x615c, &delay_200_500_e50, "B116XAN06.1"), + + EDP_PANEL_ENTRY("BOE", 0x0786, &delay_200_500_p2e80, "NV116WHM-T01"), + EDP_PANEL_ENTRY("BOE", 0x07d1, &boe_nv133fhm_n61.delay, "NV133FHM-N61"), + EDP_PANEL_ENTRY("BOE", 0x082d, &boe_nv133fhm_n61.delay, "NV133FHM-N62"), + EDP_PANEL_ENTRY("BOE", 0x098d, &boe_nv110wtm_n61.delay, "NV110WTM-N61"), + + EDP_PANEL_ENTRY("CMN", 0x114c, &innolux_n116bca_ea1.delay, "N116BCA-EA1"), + + EDP_PANEL_ENTRY("KDB", 0x0624, &kingdisplay_kd116n21_30nv_a010.delay, "116N21-30NV-A010"), + + EDP_PANEL_ENTRY("SHP", 0x154c, &delay_200_500_p2e100, "LQ116M1JW10"), + + { /* sentinal */ } +}; + +static const struct edp_panel_entry *find_edp_panel(u32 panel_id) +{ + const struct edp_panel_entry *panel; + + if (!panel_id) + return NULL; + + for (panel = edp_panels; panel->panel_id; panel++) + if (panel->panel_id == panel_id) + return panel; + + return NULL; +} + static int panel_edp_platform_probe(struct platform_device *pdev) { const struct of_device_id *id; - id = of_match_node(platform_of_match, pdev->dev.of_node); + /* Skip one since "edp-panel" is only supported on DP AUX bus */ + id = of_match_node(platform_of_match + 1, pdev->dev.of_node); if (!id) return -ENODEV;