From patchwork Wed Aug 14 18:46:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171346 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1203306ily; Wed, 14 Aug 2019 11:47:33 -0700 (PDT) X-Received: by 2002:aa7:9210:: with SMTP id 16mr1445260pfo.11.1565808453591; Wed, 14 Aug 2019 11:47:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565808453; cv=none; d=google.com; s=arc-20160816; b=oS71irheo2BjPpSbSGgBBIaI0fgbi+5hI8RV9KvlSjNRbAm71pjmzvyxNluAKiJd3d ULrxm02IyBgBW/18prT2z0mCfAw2GnhkLnwwfJcu2LChQ+1nSEvHuLnArw8oqAPpMUM4 7hXihGssbII0bHiyviAExuNvCryWyDZ4UAzr7Lk7bGQqlZkGyp/5anEJ3TSUHJEv+E9Q Hcr4v50VkyV4KWg9GXkOfxxFwvP8NcYnbQk+pIYYkjaEjFfXILMlqvsmpmaVXPVq/GM9 Xvy61HXKk0+px7y7oAX71uAzBghsXaFJlP6UIQCPOCZF3WmTwgmJPUyJ/Cj6bZN6Ea+A BxrQ== 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=86FCzQs5EG3Tlp7MWCnk0oCzxkL88DSF1TUkPvnf8Ag=; b=OsQa+5DLr71ypbPcrxlJld6jX9pXgOJvV7jxAUd1qLP5HazbvPpnohAqHx5ijM7krG lcLGLlBllnGDzHx1mR5cRyW8JZltZI8mVR4aOuBNF0UxBMfQjA2Hb8QbXOk/5CtDNZ6j ZtDhN6GnE+JkYexHZMldxVFUeHEfeSxLxY3xw9/Jxfi2CEGK5j+7cfJnN69VaB3RGP5b jOZlNV0buCX7lb4YtG74p8eCVWTdUujwY7IEPkKpbUBjaImgaq2ZGb/YI/z3IejlxQlI SqWo1OqNMqWv54jh8KZ1BqPR0aPxjA2US1y++fNfo9Ns9tCeP4pjuK1qHOEGcvzJy8Xm VvlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NYKzaRm1; 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 c76sor592959pfc.11.2019.08.14.11.47.33 for (Google Transport Security); Wed, 14 Aug 2019 11:47:33 -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=NYKzaRm1; 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=86FCzQs5EG3Tlp7MWCnk0oCzxkL88DSF1TUkPvnf8Ag=; b=NYKzaRm17tP5zbPEJdxJV8mwLPa4e5F6FFGpOt3yTQLiQAG/kxDCQxbTypob4j35rW z8ZNOEVzhSocgML3gJgfbSA5/Rx1caZmF+NoSoovjCWQhuD0rFiY82dpCoBH762FA6X7 MVyBpuXbahe5OCzxysaazjvgrx5Vnjco81ikU3d4hC5oEQ5KpRp3BcClPdaLlQYUe4Lx K4zv7eLn2yJEofJ2HLwi5DmAtnUJx1GGqSU8FBWvitObcf/3E/rk2Hn4dT66DhceO+/i hXjeAl3uGpnFt7KStap+luZW65gxRlqGYOjLG+Eq8bCw2LPtmLeJvt3Wh4pA+br0yPZV jWlQ== 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=86FCzQs5EG3Tlp7MWCnk0oCzxkL88DSF1TUkPvnf8Ag=; b=jLFJBhjD/P8nT98bUV4TaCygccBXaWQm1XBQJsMgYojb6myhlIVjUu5N/I0ulUn6Cx 9vqi1p/HF7AChPLlmqIDVYw9fIlI7fw2sV9Us5LOoM7IY1I1eSULne+mAY04L2sIq81d N8Z4zf18kE3ns81YlPBwoqT/Z04xhVcw30XT3WBKcRjLFcgXsgCZkWsgRYUejl4gb2jv TnhRQ+nghCJud/GD249T6fcmXXKvxBnfN3E2n50x0u0OKSABxHaDwC+zFncjZcXgEey2 J9H+SJqudQSmcjWLTZIpODbYMuxaKzzV5cR2PQcIPI45dvkiHpgGq3VsfG0kWVlBL8SL 0nXA== X-Gm-Message-State: APjAAAU5TGlQ2G9CEVUysmC6yOo1HPnFDZzGBClE+o6hESFoGn86CBtm 7hX/VzY4Sp8wwvur/HQD8LEGuhyG X-Google-Smtp-Source: APXvYqwe46/m/Z3WR/Ofq33p037b8zteD+0TSjAkh8AWNOXb2hCjKVmejw7gKNT110OmXr2pzAGK5g== X-Received: by 2002:aa7:8ad0:: with SMTP id b16mr1387941pfd.45.1565808453207; Wed, 14 Aug 2019 11:47:33 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id y16sm610855pfc.36.2019.08.14.11.47.31 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 14 Aug 2019 11:47:32 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , Xinliang Liu , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [RESEND][PATCH v3 17/26] drm: kirin: Move plane number and primay plane in driver data Date: Wed, 14 Aug 2019 18:46:53 +0000 Message-Id: <20190814184702.54275-18-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190814184702.54275-1-john.stultz@linaro.org> References: <20190814184702.54275-1-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: Rongrong Zou Cc: Xinliang Liu Cc: David Airlie Cc: Daniel Vetter Cc: dri-devel Cc: Sam Ravnborg Reviewed-by: Sam Ravnborg Signed-off-by: Xu YiPing Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 21 ++++++++++++------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 2 ++ 2 files changed, 15 insertions(+), 8 deletions(-) -- 2.17.1 diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index bca080e14009..fc0f4c04d1c9 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 ce9ddccc67a8..2b660df60293 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -37,6 +37,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;