Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2846849pxk; Sun, 20 Sep 2020 20:29:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyMoJHk2d5UYNacRNTInTNTR6ofT6QQt3UX/pBxqHHSSM6/z13cA+NQikYZYI9gACQB0mlZ X-Received: by 2002:a50:eb0a:: with SMTP id y10mr36244993edp.89.1600658967809; Sun, 20 Sep 2020 20:29:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600658967; cv=none; d=google.com; s=arc-20160816; b=NKLYgb4VpJQ+lurdVbkzWt8exwjWmNDridcRJK7nMAlMX9U19biE+iAD+7ImkWuRR+ k63mvPi1ukNf+KqbAgZTPOV0TJcrzPYa0EBNSFasnobsLO7bk4kiuioaCvda/Eq4OWl7 QLE6nJ03v+iwRHbK9LbnH8h8XMqFcjMmbhxAiTL7IHyOxwWsIvgO6vc/4b7PFgCYwe2x qe5rpdutfMzVlLiB9AJzykXNoMqNkr2bPT8ZG2AOBCYQ1oDA8yU+jG7atOpNdppeYi/d gqFTlySu8jJT8Kjcft5qy4BExPYJBKEpY13Dc9ftb/KAqmcTskDk5bw+7GeA0Zradm3e z/gw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :date:subject:cc:to:from; bh=DiyVg380cf7EZrWyZpXOr4ToS+EAuysKyJcG4qKYdKs=; b=XaXos31lJmilGKk6qhBBqFVlidJRwOTjiFrTswbR0tZoFGpFqSxZYWZHYN4gCR4u9z pDoYK32mzcD6P7isZceNKhLsCTfePGNUxQM+NBaj7JyepIaPv1qNMR4CsqwVZNoArecP cSKlW8xNLoJH2FXJJbmLP92Fi+5jwX518N3zHF5NHPvTiQK3Qnb3Ir55wcvAg8XOW+l4 Ch7BlVzfldN2N2xx50lM4H4XagAvgBxGyh432Qy2adeBtSdz2KQ3ANXKk48zr4zE31x7 YZH1G3Pb9jNTABMO7/d8/23j9bUbyI84KK1tX+mcZe0H0uhdvrvGRKKpd5h/tFnWapJH cxCA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e1si7506183edy.163.2020.09.20.20.29.00; Sun, 20 Sep 2020 20:29:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726355AbgIUD2C (ORCPT + 99 others); Sun, 20 Sep 2020 23:28:02 -0400 Received: from szxga04-in.huawei.com ([45.249.212.190]:13778 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726196AbgIUD2B (ORCPT ); Sun, 20 Sep 2020 23:28:01 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id 3C5CD2830584C37A486F; Mon, 21 Sep 2020 11:27:56 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Mon, 21 Sep 2020 11:27:48 +0800 From: Tian Tao To: , , , , , , , , CC: Subject: [PATCH drm/hisilicon 2/3] drm/hisilicon: Features to support reading resolutions from EDID Date: Mon, 21 Sep 2020 11:25:21 +0800 Message-ID: <1600658722-35945-3-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600658722-35945-1-git-send-email-tiantao6@hisilicon.com> References: <1600658722-35945-1-git-send-email-tiantao6@hisilicon.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Use drm_get_edid to get the resolution, if that fails, set it to a fixed resolution. Signed-off-by: Tian Tao --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 35 ++++++++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c index 376a05d..e84d381 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c @@ -20,13 +20,24 @@ static int hibmc_connector_get_modes(struct drm_connector *connector) { - int count; + int count = 0; + void *edid; + struct hibmc_connector *hibmc_connector = to_hibmc_connector(connector); + + edid = drm_get_edid(connector, &hibmc_connector->adapter); + if (edid) { + drm_connector_update_edid_property(connector, edid); + count = drm_add_edid_modes(connector, edid); + } - count = drm_add_modes_noedid(connector, + if (!edid || count == 0) { + count = drm_add_modes_noedid(connector, connector->dev->mode_config.max_width, connector->dev->mode_config.max_height); - drm_set_preferred_mode(connector, 1024, 768); + drm_set_preferred_mode(connector, 1024, 768); + } + kfree(edid); return count; } @@ -77,10 +88,19 @@ static const struct drm_encoder_funcs hibmc_encoder_funcs = { int hibmc_vdac_init(struct hibmc_drm_private *priv) { struct drm_device *dev = priv->dev; + struct hibmc_connector *hibmc_connector = &priv->connector; struct drm_encoder *encoder = &priv->encoder; - struct drm_connector *connector = &priv->connector; + struct drm_connector *connector = &hibmc_connector->base; int ret; + hibmc_connector->dev = dev; + + ret = hibmc_ddc_create(hibmc_connector); + if (ret) { + drm_err(dev, "failed to create connector: %d\n", ret); + return ret; + } + encoder->possible_crtcs = 0x1; ret = drm_encoder_init(dev, encoder, &hibmc_encoder_funcs, DRM_MODE_ENCODER_DAC, NULL); @@ -91,12 +111,15 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv) drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs); - ret = drm_connector_init(dev, connector, &hibmc_connector_funcs, - DRM_MODE_CONNECTOR_VGA); + ret = drm_connector_init_with_ddc(dev, connector, + &hibmc_connector_funcs, + DRM_MODE_CONNECTOR_VGA, + &hibmc_connector->adapter); if (ret) { drm_err(dev, "failed to init connector: %d\n", ret); return ret; } + drm_connector_helper_add(connector, &hibmc_connector_helper_funcs); drm_connector_attach_encoder(connector, encoder); -- 2.7.4