From patchwork Tue Apr 23 23:20:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 162753 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4354852jan; Tue, 23 Apr 2019 16:21:24 -0700 (PDT) X-Received: by 2002:a17:902:2d04:: with SMTP id o4mr29282563plb.88.1556061683953; Tue, 23 Apr 2019 16:21:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556061683; cv=none; d=google.com; s=arc-20160816; b=ysTVWueSPZZKR+Ln63ebFbjMd/9jkG+V/soo9BkE6MT/9olE7VF3sFXEOkVRD0+qUp neegpVyha9i7Gj4E6sC4TZWUjhI0Gir4DXSypvABjv1+E1Je8hUoxX9WkAaJPlRm50Tb kBqnCjQVCE/wJ7wN0imd4pIkRrH00upi3e9PUFUjWh7oTzfydsaWmgduNqp2wJzbkXsQ zS1SYd9c67wQfVqV2lRWIM+4de82jrwgNMSn4W6xEKZPKIdDI/HzaCkHbDvD8nJ/NTlk cnAjjDQyy4OiarKo8qmTYs02bUM30SKCcuyQIozr4lezYTrZ16FfiyzZq2imJQvVHmut 71Uw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=yGwLHd/QsORrF/a1ijwtnZ+FE24YlLye7sgtz4UzsFE=; b=ntVtZ8ZOQjpypDqIihZUwcouRAeH0Np1w7qOyjzt0H16kFNoHRcjNpn6qQlo8PIxrY /jBIeljnPhAahELTcVpt1ZH+W2Ngh8vu72NudMUiKWboGdZ//Iuhnib/claS5CXKKSDM sEduLA2d1jgAyMwOhQMq3E+yXR5QfLXBtxRtGIidcBE6lPR/5Gf0C+/ArE/+XtUmI1/1 /PWLIA4g4bkag7ZFeegELuMAr1VAL1bI+iVuyLqkfBlE9zlL4WvSyolaJOgXpL3n2/dJ 6gVozhHxcQg8MbcgC/1rfGJEeBQjXauJymtimoKqvGn+WyYsAT1BBaainnnDrQOl9EbP PpmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AYPTBmaP; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id z64sor19761460pfz.2.2019.04.23.16.21.23 for (Google Transport Security); Tue, 23 Apr 2019 16:21:23 -0700 (PDT) Received-SPF: pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=AYPTBmaP; spf=pass (google.com: domain of john.stultz@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=john.stultz@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=yGwLHd/QsORrF/a1ijwtnZ+FE24YlLye7sgtz4UzsFE=; b=AYPTBmaPULPqQbE+sL+NfzdmJ/NSE/o6yP6F6cIWoYXmY0CqMRVYk/UqRfdeT4uWTu FQdwL60ib0zDfBNSOWNEuX694R0uH2Q9CsYZ6cr0WqglN6ZwWFkOV+H45t9HzzwIHfF6 TI6pgwM0e7lwezJzRWb8S/5jUO4lyyb+wNYhtZUOn36PlKzewKJIGzcfo2q+JVMNnxTJ wEiGjR5F0Vt9rkPbPUA6c5ldPVlCHSSYwiJlzTFoYBjKqKC8p1p3c4J1up/bV8J/s+Z8 AHvc9WgLr89MkVCoyF7TFjEgPCQ2l354ROa52gpn4GqMXWHhhrm6JSus+CzcxEkbheR+ 5IRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=yGwLHd/QsORrF/a1ijwtnZ+FE24YlLye7sgtz4UzsFE=; b=jmIQr+wetjyubW6wkRKchBAB1s6D6TPTidogCuMBRLVRi7pZfeGtQZ/kVP0yCwYetS MMzjNNQ7ScS7cKF0X0LIr/bXZjt8M/eH6N8YEiVPaXsuUQn7jBArJK9I7V40JBSi+cPz 9mYhLj62CEFW+v+rwjkukapwb9jhnddEMD+X2l4wYq4ul6ZncfFTVsyuien2ZPozUSCO aYaTS3O5iluu7eNyic693W4o3nhPx7Si/zksFG4ket4YrIiSNNxxdkUUEnvx7WlQhBzQ 7xTrTKytIhIFNUFSrvl43NalT3k3Oxf7850LF9DahW/1GlYzQwyzQKHdQyMzUy2izfKm 3Rlg== X-Gm-Message-State: APjAAAV0v776JVfLfbssCmAZoE7xBdB7PLqTkzSNd/hrqBh6HYc7dBYu ap1q9Ma8T9ZBVGhRdzRgLsmTkGIH X-Google-Smtp-Source: APXvYqx4xkcgjslUOx5dI/zefCl0o3ZiR4S9OssYEKtes1yNrH8CUQdAzRyAgv7ZkgB3p9XTSiFj6w== X-Received: by 2002:a62:5ec2:: with SMTP id s185mr30576470pfb.16.1556061683551; Tue, 23 Apr 2019 16:21:23 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:4e72:b9ff:fe99:466a]) by smtp.gmail.com with ESMTPSA id c28sm6984235pgm.42.2019.04.23.16.21.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Apr 2019 16:21:22 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Xinliang Liu , Rongrong Zou , Xinwei Kong , Chen Feng , David Airlie , Daniel Vetter , dri-devel , John Stultz Subject: [PATCH 16/25] drm: kirin: Move plane number and primay plane in driver data Date: Tue, 23 Apr 2019 16:20:47 -0700 Message-Id: <1556061656-1733-17-git-send-email-john.stultz@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1556061656-1733-1-git-send-email-john.stultz@linaro.org> References: <1556061656-1733-1-git-send-email-john.stultz@linaro.org> From: Xu YiPing As part of refactoring the kirin driver to better support different hardware revisions, this patch moves the number of planes and the primary plane value to the kirin_drm_data structure This will make it easier to add support for new devices via a new kirin_drm_data structure. Cc: Xinliang Liu Cc: Rongrong Zou Cc: Xinwei Kong Cc: Chen Feng Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Signed-off-by: Xu YiPing [jstultz: Reworded comit message] Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 21 +++++++++++++-------- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) -- 2.7.4 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 0e68257..b6b1da6 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -35,7 +35,6 @@ #include "kirin_drm_drv.h" #include "kirin_ade_reg.h" -#define PRIMARY_CH ADE_CH1 /* primary plane */ #define OUT_OVLY ADE_OVLY2 /* output overlay compositor */ #define ADE_DEBUG 1 @@ -991,7 +990,7 @@ static int ade_drm_init(struct platform_device *pdev) struct kirin_plane *kplane; enum drm_plane_type type; int ret; - int i; + u32 ch; ade = devm_kzalloc(dev->dev, sizeof(*ade), GFP_KERNEL); if (!ade) { @@ -1015,12 +1014,15 @@ static int ade_drm_init(struct platform_device *pdev) * TODO: Now only support primary plane, overlay planes * need to do. */ - for (i = 0; i < ADE_CH_NUM; i++) { - kplane = &ade->planes[i]; - kplane->ch = i; + for (ch = 0; ch < ade_driver_data.num_planes; ch++) { + kplane = &ade->planes[ch]; + kplane->ch = ch; kplane->hw_ctx = ctx; - type = i == PRIMARY_CH ? DRM_PLANE_TYPE_PRIMARY : - DRM_PLANE_TYPE_OVERLAY; + + if (ch == ade_driver_data.prim_plane) + type = DRM_PLANE_TYPE_PRIMARY; + else + type = DRM_PLANE_TYPE_OVERLAY; ret = ade_plane_init(dev, kplane, type); if (ret) @@ -1028,7 +1030,8 @@ static int ade_drm_init(struct platform_device *pdev) } /* crtc init */ - ret = ade_crtc_init(dev, &kcrtc->base, &ade->planes[PRIMARY_CH].base); + ret = ade_crtc_init(dev, &kcrtc->base, + &ade->planes[ade_driver_data.prim_plane].base); if (ret) return ret; @@ -1047,6 +1050,8 @@ static const struct drm_mode_config_funcs ade_mode_config_funcs = { }; struct kirin_drm_data ade_driver_data = { + .num_planes = ADE_CH_NUM, + .prim_plane = ADE_CH1, .channel_formats = channel_formats, .channel_formats_cnt = ARRAY_SIZE(channel_formats), .crtc_helper_funcs = &ade_crtc_helper_funcs, diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h index 700a203..59fc888 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -41,6 +41,8 @@ struct kirin_plane { struct kirin_drm_data { const u32 *channel_formats; u32 channel_formats_cnt; + u32 num_planes; + u32 prim_plane; const struct drm_crtc_helper_funcs *crtc_helper_funcs; const struct drm_crtc_funcs *crtc_funcs;