From nobody Sat Nov 23 17:56:57 2024 Received: from szxga04-in.huawei.com (szxga04-in.huawei.com [45.249.212.190]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C5D8F1494CC for ; Tue, 12 Nov 2024 13:29:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=45.249.212.190 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418170; cv=none; b=FQauMfAW1XPNdZNqXlccX/7n/5fQCVTvSw236bcGzqM1wubvOMvB+WFPlRh2/EZNEb3oYlA9EKGclMaPAQt4yvLMUA/r+O/i2xFZzU5lRZAUnv64s4rDjBBctC9hr+eVi+AK+tlehqv+uWXhgyEYAMec99APW4340r8/vYq8fy8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1731418170; c=relaxed/simple; bh=pVN0c6LdzHB4MzKrC5poBvasIJ3wuJ1LsbATBIoBztM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=pmU7G5+sJ7NB8YPXezy3f9kmrnZxuEiJGF1SUEHcfHwWa4Wzt1W6VPoIEjPxkrjsEGZ+ZDBI3ylgAXEiloqw13+VGpdHIoira6Y4iHVDZ8TVe/55RN85NeLOzKHYXx0spYB+HbyAM1TVsZWjAnDle7PiKWMVcE+J88e+vskl92s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com; spf=pass smtp.mailfrom=huawei.com; arc=none smtp.client-ip=45.249.212.190 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=huawei.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=huawei.com Received: from mail.maildlp.com (unknown [172.19.88.234]) by szxga04-in.huawei.com (SkyGuard) with ESMTP id 4XnnKl58KSz20t6F; Tue, 12 Nov 2024 21:28:11 +0800 (CST) Received: from kwepemd500013.china.huawei.com (unknown [7.221.188.12]) by mail.maildlp.com (Postfix) with ESMTPS id 43F24140257; Tue, 12 Nov 2024 21:29:25 +0800 (CST) Received: from localhost.huawei.com (10.169.71.169) by kwepemd500013.china.huawei.com (7.221.188.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1258.34; Tue, 12 Nov 2024 21:29:23 +0800 From: Yongbang Shi To: , , , , , , , CC: , , , , , , , , Subject: [PATCH v4 drm-dp 4/5] drm/hisilicon/hibmc: separate struct of vdac Date: Tue, 12 Nov 2024 21:23:47 +0800 Message-ID: <20241112132348.2631150-5-shiyongbang@huawei.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20241112132348.2631150-1-shiyongbang@huawei.com> References: <20241112132348.2631150-1-shiyongbang@huawei.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemd500013.china.huawei.com (7.221.188.12) Content-Type: text/plain; charset="utf-8" From: baihan li Refactored struct hibmc_drm_private to separate VGA module from generic struct. Signed-off-by: Baihan Li Signed-off-by: Yongbang Shi --- ChangeLog: v3 -> v4: - separating hibmc_vdac and hibmc_dp changes into separate patche, sugges= ted by Dmitry Baryshkov. v2 -> v3: - fix build errors reported by kernel test robot Closes: https://lore.kernel.org/oe-kbuild-all/202410251136.1m7BlR68-lkp= @intel.com/ v1 -> v2: - deleting struct dp_mode and dp_mode_cfg function, suggested by Dmitry B= aryshkov. - modifying drm_simple_encoder_init function, suggested by Dmitry Baryshk= ov. - refactoring struct hibmc_connector, suggested by Dmitry Baryshkov. - withdrawing the modification in hibmc_kms_init, suggested by Dmitry Bar= yshkov. v1:https://lore.kernel.org/all/20240930100610.782363-1-shiyongbang@huawei= .com/ --- .../gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 16 ++++---- .../gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c | 41 +++++++++---------- .../gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c | 20 ++++----- 3 files changed, 38 insertions(+), 39 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h b/drivers/gpu/= drm/hisilicon/hibmc/hibmc_drm_drv.h index 6b566f3aeecb..42f0ab8f9b5a 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h @@ -20,9 +20,10 @@ =20 #include =20 -struct hibmc_connector { - struct drm_connector base; - +struct hibmc_vdac { + struct drm_device *dev; + struct drm_encoder encoder; + struct drm_connector connector; struct i2c_adapter adapter; struct i2c_algo_bit_data bit_data; }; @@ -35,13 +36,12 @@ struct hibmc_drm_private { struct drm_device dev; struct drm_plane primary_plane; struct drm_crtc crtc; - struct drm_encoder encoder; - struct hibmc_connector connector; + struct hibmc_vdac vdac; }; =20 -static inline struct hibmc_connector *to_hibmc_connector(struct drm_connec= tor *connector) +static inline struct hibmc_vdac *to_hibmc_vdac(struct drm_connector *conne= ctor) { - return container_of(connector, struct hibmc_connector, base); + return container_of(connector, struct hibmc_vdac, connector); } =20 static inline struct hibmc_drm_private *to_hibmc_drm_private(struct drm_de= vice *dev) @@ -57,6 +57,6 @@ void hibmc_set_current_gate(struct hibmc_drm_private *pri= v, int hibmc_de_init(struct hibmc_drm_private *priv); int hibmc_vdac_init(struct hibmc_drm_private *priv); =20 -int hibmc_ddc_create(struct drm_device *drm_dev, struct hibmc_connector *c= onnector); +int hibmc_ddc_create(struct drm_device *drm_dev, struct hibmc_vdac *connec= tor); =20 #endif diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c b/drivers/gpu/= drm/hisilicon/hibmc/hibmc_drm_i2c.c index e6e48651c15c..99b3b77b5445 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_i2c.c @@ -25,8 +25,8 @@ =20 static void hibmc_set_i2c_signal(void *data, u32 mask, int value) { - struct hibmc_connector *hibmc_connector =3D data; - struct hibmc_drm_private *priv =3D to_hibmc_drm_private(hibmc_connector->= base.dev); + struct hibmc_vdac *vdac =3D data; + struct hibmc_drm_private *priv =3D to_hibmc_drm_private(vdac->connector.d= ev); u32 tmp_dir =3D readl(priv->mmio + GPIO_DATA_DIRECTION); =20 if (value) { @@ -45,8 +45,8 @@ static void hibmc_set_i2c_signal(void *data, u32 mask, in= t value) =20 static int hibmc_get_i2c_signal(void *data, u32 mask) { - struct hibmc_connector *hibmc_connector =3D data; - struct hibmc_drm_private *priv =3D to_hibmc_drm_private(hibmc_connector->= base.dev); + struct hibmc_vdac *vdac =3D data; + struct hibmc_drm_private *priv =3D to_hibmc_drm_private(vdac->connector.d= ev); u32 tmp_dir =3D readl(priv->mmio + GPIO_DATA_DIRECTION); =20 if ((tmp_dir & mask) !=3D mask) { @@ -77,22 +77,21 @@ static int hibmc_ddc_getscl(void *data) return hibmc_get_i2c_signal(data, I2C_SCL_MASK); } =20 -int hibmc_ddc_create(struct drm_device *drm_dev, - struct hibmc_connector *connector) +int hibmc_ddc_create(struct drm_device *drm_dev, struct hibmc_vdac *vdac) { - connector->adapter.owner =3D THIS_MODULE; - snprintf(connector->adapter.name, I2C_NAME_SIZE, "HIS i2c bit bus"); - connector->adapter.dev.parent =3D drm_dev->dev; - i2c_set_adapdata(&connector->adapter, connector); - connector->adapter.algo_data =3D &connector->bit_data; - - connector->bit_data.udelay =3D 20; - connector->bit_data.timeout =3D usecs_to_jiffies(2000); - connector->bit_data.data =3D connector; - connector->bit_data.setsda =3D hibmc_ddc_setsda; - connector->bit_data.setscl =3D hibmc_ddc_setscl; - connector->bit_data.getsda =3D hibmc_ddc_getsda; - connector->bit_data.getscl =3D hibmc_ddc_getscl; - - return i2c_bit_add_bus(&connector->adapter); + vdac->adapter.owner =3D THIS_MODULE; + snprintf(vdac->adapter.name, I2C_NAME_SIZE, "HIS i2c bit bus"); + vdac->adapter.dev.parent =3D drm_dev->dev; + i2c_set_adapdata(&vdac->adapter, vdac); + vdac->adapter.algo_data =3D &vdac->bit_data; + + vdac->bit_data.udelay =3D 20; + vdac->bit_data.timeout =3D usecs_to_jiffies(2000); + vdac->bit_data.data =3D vdac; + vdac->bit_data.setsda =3D hibmc_ddc_setsda; + vdac->bit_data.setscl =3D hibmc_ddc_setscl; + vdac->bit_data.getsda =3D hibmc_ddc_getsda; + vdac->bit_data.getscl =3D hibmc_ddc_getscl; + + return i2c_bit_add_bus(&vdac->adapter); } diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c b/drivers/gpu= /drm/hisilicon/hibmc/hibmc_drm_vdac.c index 409c551c92af..05e19ea4c9f9 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_vdac.c @@ -24,11 +24,11 @@ =20 static int hibmc_connector_get_modes(struct drm_connector *connector) { - struct hibmc_connector *hibmc_connector =3D to_hibmc_connector(connector); + struct hibmc_vdac *vdac =3D to_hibmc_vdac(connector); const struct drm_edid *drm_edid; int count; =20 - drm_edid =3D drm_edid_read_ddc(connector, &hibmc_connector->adapter); + drm_edid =3D drm_edid_read_ddc(connector, &vdac->adapter); =20 drm_edid_connector_update(connector, drm_edid); =20 @@ -51,9 +51,9 @@ static int hibmc_connector_get_modes(struct drm_connector= *connector) =20 static void hibmc_connector_destroy(struct drm_connector *connector) { - struct hibmc_connector *hibmc_connector =3D to_hibmc_connector(connector); + struct hibmc_vdac *vdac =3D to_hibmc_vdac(connector); =20 - i2c_del_adapter(&hibmc_connector->adapter); + i2c_del_adapter(&vdac->adapter); drm_connector_cleanup(connector); } =20 @@ -93,20 +93,20 @@ static const struct drm_encoder_helper_funcs hibmc_enco= der_helper_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 hibmc_vdac *vdac =3D &priv->vdac; + struct drm_encoder *encoder =3D &vdac->encoder; struct drm_crtc *crtc =3D &priv->crtc; - struct drm_connector *connector =3D &hibmc_connector->base; + struct drm_connector *connector =3D &vdac->connector; int ret; =20 - ret =3D hibmc_ddc_create(dev, hibmc_connector); + ret =3D hibmc_ddc_create(dev, vdac); if (ret) { drm_err(dev, "failed to create ddc: %d\n", ret); return ret; } =20 encoder->possible_crtcs =3D drm_crtc_mask(crtc); - ret =3D drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_DAC); + ret =3D drmm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_DAC, NULL); if (ret) { drm_err(dev, "failed to init encoder: %d\n", ret); return ret; @@ -117,7 +117,7 @@ int hibmc_vdac_init(struct hibmc_drm_private *priv) ret =3D drm_connector_init_with_ddc(dev, connector, &hibmc_connector_funcs, DRM_MODE_CONNECTOR_VGA, - &hibmc_connector->adapter); + &vdac->adapter); if (ret) { drm_err(dev, "failed to init connector: %d\n", ret); return ret; --=20 2.33.0