Received: by 2002:a25:ca44:0:0:0:0:0 with SMTP id a65csp2349988ybg; Thu, 30 Jul 2020 18:11:23 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwkqwWQ/EQ8ibdMrTglvQtMu/I83KEfOc+tDa1kl1b99QEALcKitHN3YBJAitck4s8NaTgW X-Received: by 2002:a17:906:5612:: with SMTP id f18mr1780039ejq.225.1596157883161; Thu, 30 Jul 2020 18:11:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596157883; cv=none; d=google.com; s=arc-20160816; b=Hzb6j7MRP2B/rxTo5ypgo3WyVOOB/cke97pino1UyVcfT06jfVxBs3lnzz4GFZecGT 2qScLcVJCGieuSaouHjrgpn6xj7MJCH4YPVLyv222c2wkDKn7xcEz3YySaYpdbu1jRhC T95clkXL5O6VimJj5V9WsWfRgtOu23GBPcx4xctSCDg7EuNE8flPx9YtVUfClga9AMlB 90r1wJyTW6y8f77CKUfe3IaUNzjKvErsFzfmefW5JhEiKu+C//Iu7Ch1uF02jC9EvN74 MlJf8fIcI/PsUGT0FAEhqJeUycWEEfdRHcwgR8dkK5ajl5iv+ezRydjiT8yl0O+/4wSm OkoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=xYkDleW+W3UKUWJYPwI7Z1hgGC2BkJq1PRpGbB45XOM=; b=IOlF6j6NNKNhnoyWsTFQUZI9booQ3gW0PsQuQjgywkS2wqh9wulWWK0rVVGuz4P4jy /hOlNJjsFWC1LBffZ5wHHTWLdl0pJ4LWcjB0sdHS50GeMGSy99p7Lqlnf23pOTX5k+C4 O9EIT5T6EX3qftixEL2CBMBZ7tx7yD3W6Mhd2cn+AD4l6yzhmglUdnFeviFXc/Icbzz4 22gQ3+M1B6jkQIi1+Qmv+hY45a5Ng08sJrv04EFC57284Z4rNAdZ5lBIOvtKSKvIPuo5 aYZ5sdonbi7pBDnuCAzqCJM4VuJP3Uye8Nh0m5CZ40t2rFnqTIZGEs6eAkVLBzmmrppL dTfw== 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 y19si4409442eje.56.2020.07.30.18.10.55; Thu, 30 Jul 2020 18:11:23 -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 S1731050AbgGaBHf (ORCPT + 99 others); Thu, 30 Jul 2020 21:07:35 -0400 Received: from szxga06-in.huawei.com ([45.249.212.32]:44674 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1731036AbgGaBHf (ORCPT ); Thu, 30 Jul 2020 21:07:35 -0400 Received: from DGGEMS406-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id C16B7AFCA5300A5F34C7; Fri, 31 Jul 2020 09:07:33 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS406-HUB.china.huawei.com (10.3.19.206) with Microsoft SMTP Server id 14.3.487.0; Fri, 31 Jul 2020 09:07:26 +0800 From: Tian Tao To: , , , , , , , , CC: Subject: [PATCH drm/hisilicon 2/2] drm/hisilicon: Code refactoring for hibmc_drv_de Date: Fri, 31 Jul 2020 09:05:32 +0800 Message-ID: <1596157532-50049-1-git-send-email-tiantao6@hisilicon.com> X-Mailer: git-send-email 2.7.4 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org code refactoring for hibmc_drv_de.c, no actual function changes. Signed-off-by: Tian Tao --- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c | 55 ++++++------------------- drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h | 2 + 2 files changed, 15 insertions(+), 42 deletions(-) diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c index 66132eb..af24c72 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_de.c @@ -157,37 +157,6 @@ static const struct drm_plane_helper_funcs hibmc_plane_helper_funcs = { .atomic_update = hibmc_plane_atomic_update, }; -static struct drm_plane *hibmc_plane_init(struct hibmc_drm_private *priv) -{ - struct drm_device *dev = priv->dev; - struct drm_plane *plane; - int ret = 0; - - plane = devm_kzalloc(dev->dev, sizeof(*plane), GFP_KERNEL); - if (!plane) { - DRM_ERROR("failed to alloc memory when init plane\n"); - return ERR_PTR(-ENOMEM); - } - /* - * plane init - * TODO: Now only support primary plane, overlay planes - * need to do. - */ - ret = drm_universal_plane_init(dev, plane, 1, &hibmc_plane_funcs, - channel_formats1, - ARRAY_SIZE(channel_formats1), - NULL, - DRM_PLANE_TYPE_PRIMARY, - NULL); - if (ret) { - DRM_ERROR("failed to init plane: %d\n", ret); - return ERR_PTR(ret); - } - - drm_plane_helper_add(plane, &hibmc_plane_helper_funcs); - return plane; -} - static void hibmc_crtc_dpms(struct drm_crtc *crtc, int dpms) { struct hibmc_drm_private *priv = crtc->dev->dev_private; @@ -534,22 +503,24 @@ static const struct drm_crtc_helper_funcs hibmc_crtc_helper_funcs = { int hibmc_de_init(struct hibmc_drm_private *priv) { struct drm_device *dev = priv->dev; - struct drm_crtc *crtc; - struct drm_plane *plane; + struct drm_crtc *crtc = &priv->crtc; + struct drm_plane *plane = &priv->plane; int ret; - plane = hibmc_plane_init(priv); - if (IS_ERR(plane)) { - DRM_ERROR("failed to create plane: %ld\n", PTR_ERR(plane)); - return PTR_ERR(plane); - } + ret = drm_universal_plane_init(dev, plane, 1, &hibmc_plane_funcs, + channel_formats1, + ARRAY_SIZE(channel_formats1), + NULL, + DRM_PLANE_TYPE_PRIMARY, + NULL); - crtc = devm_kzalloc(dev->dev, sizeof(*crtc), GFP_KERNEL); - if (!crtc) { - DRM_ERROR("failed to alloc memory when init crtc\n"); - return -ENOMEM; + if (ret) { + DRM_ERROR("failed to init plane: %d\n", ret); + return ret; } + drm_plane_helper_add(plane, &hibmc_plane_helper_funcs); + ret = drm_crtc_init_with_planes(dev, crtc, plane, NULL, &hibmc_crtc_funcs, NULL); if (ret) { diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h index a683763..91ef15c 100644 --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.h @@ -28,6 +28,8 @@ struct hibmc_drm_private { /* drm */ struct drm_device *dev; + struct drm_plane plane; + struct drm_crtc crtc; struct drm_encoder encoder; struct drm_connector connector; bool mode_config_initialized; -- 2.7.4