Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp3901776pxk; Tue, 22 Sep 2020 05:48:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw53TuO9NQx3pA/Y66cY4ys+oITqlkROrPCI4PZ4lHHsPxFrKU29Zgh5tfwPpOGezi9ozdn X-Received: by 2002:a17:907:4035:: with SMTP id nk5mr4638721ejb.418.1600778935635; Tue, 22 Sep 2020 05:48:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600778935; cv=none; d=google.com; s=arc-20160816; b=pXxb2mQNf6Hc4VSJvGfWlTaPGkdP650bJQuS2eSrY7KhEUC1fSLRFWmrFj5mokgp80 LFC7lnfHJSGf/wPtZSjJu9qQ+ffbQYXVFW6b+VXtC2YgIJilzgz3WPfMUdySW/uOuY/P YEATz3+pUC/c9sFFSYhq+IBaH6ZDND6SWcLrh13GKXZ9WboFC0GZk+YzjbC8JodZvV3q 2NWFu8/3t60V5UAZu4MmynubQPtmet2Lxu5OmX7zIIpBrxQE5yQTucd7AJAOzdcHh9Kb qIhLVvk2B/XDm6tE3ysPrxkPZ39lRYsYJ8EnuhNAeKmMLtvwj0m0zZvAPZeH1Zifdmp/ RshA== 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=krQ1UXUXZgo7JLyKMwsLFr6ZiLTyDtjvPFwWJvRi7+8=; b=WxBPjfbdW+5CgERsY6RVwpnCJ2j7wc1A3byNTeEkVutDMJHirrM9FYVg34t15xteLS Bz3+mx7kpWWgeDI89NYFtogzMU10qt8VwXHRLZk0mmHFMk1kDSlq+qO+OIZddZJs6iCp q4ol9FrBUYLIUOBab0vu9o9QjX9RB+15ADT+y+MpTINCIiDL64un/8GfzZw+fvjs38hb M1z0/steQ96xYk416ta22kG1gLDiz+rOWWVMlsaM+dqlB9eydMUp5sllctPpTh05fCP3 ZLwSp/M0Qt/PsBv0z05bVNia4kYbWA/aCIdqJT8BEkldyn0oBZuZ4RrtronZFK87rliL GPBg== 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 u59si10681549edc.226.2020.09.22.05.48.31; Tue, 22 Sep 2020 05:48:55 -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 S1726662AbgIVMrI (ORCPT + 99 others); Tue, 22 Sep 2020 08:47:08 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:14212 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726613AbgIVMrF (ORCPT ); Tue, 22 Sep 2020 08:47:05 -0400 Received: from DGGEMS403-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 75E55A48500049286DA0; Tue, 22 Sep 2020 20:47:03 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS403-HUB.china.huawei.com (10.3.19.203) with Microsoft SMTP Server id 14.3.487.0; Tue, 22 Sep 2020 20:46:57 +0800 From: Tian Tao To: , , , , , , , , CC: Subject: [PATCH drm/hisilicon v3 2/2] drm/hisilicon: Features to support reading resolutions from EDID Date: Tue, 22 Sep 2020 20:44:30 +0800 Message-ID: <1600778670-60370-3-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1600778670-60370-1-git-send-email-tiantao6@hisilicon.com> References: <1600778670-60370-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. Rewrite the desrtoy callback function to release resources. Signed-off-by: Tian Tao Reviewed-by: Thomas Zimmermann --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 38 +++++++++++++++++++++--- 1 file changed, 34 insertions(+), 4 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..c6999ed 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c @@ -21,12 +21,24 @@ static int hibmc_connector_get_modes(struct drm_connector *connector) { int count; + 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); + if (count) + goto out; + } 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); +out: + kfree(edid); return count; } @@ -36,6 +48,14 @@ static enum drm_mode_status hibmc_connector_mode_valid(struct drm_connector *con return MODE_OK; } +static void hibmc_connector_destroy(struct drm_connector *connector) +{ + struct hibmc_connector *hibmc_connector = to_hibmc_connector(connector); + + i2c_del_adapter(&hibmc_connector->adapter); + drm_connector_cleanup(connector); +} + static const struct drm_connector_helper_funcs hibmc_connector_helper_funcs = { .get_modes = hibmc_connector_get_modes, @@ -44,7 +64,7 @@ static const struct drm_connector_helper_funcs static const struct drm_connector_funcs hibmc_connector_funcs = { .fill_modes = drm_helper_probe_single_connector_modes, - .destroy = drm_connector_cleanup, + .destroy = hibmc_connector_destroy, .reset = drm_atomic_helper_connector_reset, .atomic_duplicate_state = drm_atomic_helper_connector_duplicate_state, .atomic_destroy_state = drm_atomic_helper_connector_destroy_state, @@ -77,10 +97,17 @@ 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; + ret = hibmc_ddc_create(dev, hibmc_connector); + if (ret) { + drm_err(dev, "failed to create ddc: %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 +118,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