Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp2936987pxk; Mon, 21 Sep 2020 00:26:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyIRupLDDwYN9GKCtBMqL41Xw7yNt+qbREGXaXm785YRRhdm7VazGuEXlrv27soHqbkSNU7 X-Received: by 2002:a17:906:3553:: with SMTP id s19mr46995491eja.178.1600673196288; Mon, 21 Sep 2020 00:26:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1600673196; cv=none; d=google.com; s=arc-20160816; b=xsDGDDPfj266KuRqFGe+klFyGT/uf8/cszCh7D7UpwCZeHN1FpXtrweFFwc54eqLGC 2XAxqbViUpxBKykQBN2Je6log/4Kt1JjhRKNjxQm4YlNj9k3NlHnrEclEQKgea8sObTN fh4r6mmrStzQvsyAVt0sw0v0cKL0n9aJiF1MFac91KmxGxJBo8e9F8W+HgnQPr+b6S87 3tjyu864MOQhaPteB01ozW2m+XG+QJkJMPQOqSrXPaUcQ4y30RR/tubewKvj0tqdlS9w XzbBnKcaydAEZpjqrqQw/GXuqawqvPY90lQxtNQoLbHleV3FzLZmNu7uR2UsgEbwSno3 h3aQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=JWlFIE1jxQ4oXiSBK1Vno/Mh4hcqMU0bDWMa4CSuous=; b=EutjsvsN+GEESe4SBUj8JVfY0+O+ngUQu4xQPao8F+KSQfnVFbtiYnT8377iKsiEOn 0SEdTHt0EA/ZzoziFNHBKffvcOZJq9+3xjt9P8eP6zZ7H2ynmIQeQhWDLoD9JxvQOV9a KJ66VQ+kVayri8iVkiBLGnqR2CfzPnOO/Ts3YYRsCfK5Hw0Oi357iCgi4ei108CH/uWm ljw42bVeJlTlQbm093h1wW9sxsmkONzi3sv71TegwjQdx4+1jC6ZCLf353ZK9UdDFyuY 7wFK7EogNK9luuHdBskrHVO/qLw1ITjH90+XU4gHA+rWeCgSo7X13+h/5bp/LIoKyg+1 Hklw== 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 rn4si9070797ejb.143.2020.09.21.00.26.13; Mon, 21 Sep 2020 00:26:36 -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 S1726471AbgIUHZV (ORCPT + 99 others); Mon, 21 Sep 2020 03:25:21 -0400 Received: from mx2.suse.de ([195.135.220.15]:52330 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726318AbgIUHZV (ORCPT ); Mon, 21 Sep 2020 03:25:21 -0400 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 19172AF31; Mon, 21 Sep 2020 07:25:56 +0000 (UTC) Subject: Re: [PATCH drm/hisilicon 2/3] drm/hisilicon: Features to support reading resolutions from EDID To: Tian Tao , airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de, dri-devel@lists.freedesktop.org, xinliang.liu@linaro.org, linux-kernel@vger.kernel.org Cc: linuxarm@huawei.com References: <1600658722-35945-1-git-send-email-tiantao6@hisilicon.com> <1600658722-35945-3-git-send-email-tiantao6@hisilicon.com> From: Thomas Zimmermann Message-ID: <839cdb82-9611-6279-8ee7-38c92ede4460@suse.de> Date: Mon, 21 Sep 2020 09:25:19 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.12.0 MIME-Version: 1.0 In-Reply-To: <1600658722-35945-3-git-send-email-tiantao6@hisilicon.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qlAWJtTmGWNRAd505BVABvokgquFgTe5i" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --qlAWJtTmGWNRAd505BVABvokgquFgTe5i Content-Type: multipart/mixed; boundary="FoNbeUpq5hsJHUaHPl5E84sWZ2QTKZ3ck"; protected-headers="v1" From: Thomas Zimmermann To: Tian Tao , airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de, dri-devel@lists.freedesktop.org, xinliang.liu@linaro.org, linux-kernel@vger.kernel.org Cc: linuxarm@huawei.com Message-ID: <839cdb82-9611-6279-8ee7-38c92ede4460@suse.de> Subject: Re: [PATCH drm/hisilicon 2/3] drm/hisilicon: Features to support reading resolutions from EDID References: <1600658722-35945-1-git-send-email-tiantao6@hisilicon.com> <1600658722-35945-3-git-send-email-tiantao6@hisilicon.com> In-Reply-To: <1600658722-35945-3-git-send-email-tiantao6@hisilicon.com> --FoNbeUpq5hsJHUaHPl5E84sWZ2QTKZ3ck Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi Am 21.09.20 um 05:25 schrieb Tian Tao: > Use drm_get_edid to get the resolution, if that fails, set it to > a fixed resolution. >=20 > Signed-off-by: Tian Tao > --- > drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 35 ++++++++++++++++= ++++---- > 1 file changed, 29 insertions(+), 6 deletions(-) >=20 > 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 @@ > =20 > static int hibmc_connector_get_modes(struct drm_connector *connector) > { > - int count; > + int count =3D 0; > + void *edid; > + struct hibmc_connector *hibmc_connector =3D to_hibmc_connector(connec= tor); > + > + edid =3D drm_get_edid(connector, &hibmc_connector->adapter); > + if (edid) { > + drm_connector_update_edid_property(connector, edid); > + count =3D drm_add_edid_modes(connector, edid); There's nothing wrong here, but i think it might be more readable if you = do if (count) goto out; within this branch. The out label would be just before the kfree. With this change, the code with drm_add_modes_noedid() would remain the same. > + } > =20 > - count =3D drm_add_modes_noedid(connector, > + if (!edid || count =3D=3D 0) { > + count =3D 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); > + } > =20 > + kfree(edid); > return count; > } > =20 > @@ -77,10 +88,19 @@ static const struct drm_encoder_funcs hibmc_encoder= _funcs =3D { > int hibmc_vdac_init(struct hibmc_drm_private *priv) > { > struct drm_device *dev =3D priv->dev; > + struct hibmc_connector *hibmc_connector =3D &priv->connector; > struct drm_encoder *encoder =3D &priv->encoder; > - struct drm_connector *connector =3D &priv->connector; > + struct drm_connector *connector =3D &hibmc_connector->base; > int ret; > =20 > + hibmc_connector->dev =3D dev; As mentioned, this dev field should be removed. > + > + ret =3D hibmc_ddc_create(hibmc_connector); > + if (ret) { > + drm_err(dev, "failed to create connector: %d\n", ret); The error message appears to be incorrect. (?) > + return ret; > + } > + > encoder->possible_crtcs =3D 0x1; > ret =3D 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= ) > =20 > drm_encoder_helper_add(encoder, &hibmc_encoder_helper_funcs); > =20 > - ret =3D drm_connector_init(dev, connector, &hibmc_connector_funcs, > - DRM_MODE_CONNECTOR_VGA); > + ret =3D 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); > =20 > drm_connector_attach_encoder(connector, encoder); >=20 --=20 Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany (HRB 36809, AG N=C3=BCrnberg) Gesch=C3=A4ftsf=C3=BChrer: Felix Imend=C3=B6rffer --FoNbeUpq5hsJHUaHPl5E84sWZ2QTKZ3ck-- --qlAWJtTmGWNRAd505BVABvokgquFgTe5i Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQFIBAEBCAAyFiEEchf7rIzpz2NEoWjlaA3BHVMLeiMFAl9oVV8UHHR6aW1tZXJt YW5uQHN1c2UuZGUACgkQaA3BHVMLeiPMlgf/dwVDeAkUdrGtWhm8+ObxemWp564+ RvY2pYz7MnwnmEubAUJceLyjHyoKM/hFpx4RDSu3MlRsPd3nC6Vcp/YHjuaPwhR2 GTYGT9PtKcxT83gn19rbQuvdj5/n2c8JUIybAo7ubsurt3Z6DAJimsCxbe+h7/4Y qg01oZOBZSkYITz66JbLO4Mt54mPai+2xQI0hTcGL2vRhxMKEM+ZDP/7/OwACyyZ BaidlRbcGZ7tdrEuoZY8oOh5AZUyYpSvmioxtSUgLXJYeldAvPYgLak9xurPwAiZ lSERgHY0nTVM5cWaHgZ8j0MK2GcYAREmZomsUiNQcTG7EB3eE2nkv/0c7A== =eXZi -----END PGP SIGNATURE----- --qlAWJtTmGWNRAd505BVABvokgquFgTe5i--