From patchwork Wed Aug 14 18:46:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171344 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp1203262ily; Wed, 14 Aug 2019 11:47:30 -0700 (PDT) X-Received: by 2002:a17:902:441:: with SMTP id 59mr821652ple.62.1565808450720; Wed, 14 Aug 2019 11:47:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565808450; cv=none; d=google.com; s=arc-20160816; b=Qi0yuQLMbZviR6lilNrtP+Kis8pj53mNoWrRr8/JEVKpT8A1dBchyLw7mcqGWps+FR CZVntJ/B7pGTZ0AV0RKwmak87yn8rMOwUmxfjSTf4SsUtgjT9TCdJBB0fIoS96e8tNik Fm67eyyFS6YRsUq0gJby/LeXTERPK1152rENRJkhXQeb93RwtTWzrkGDv/RV7j0wZdgr W03A1qdwckEjG2W8jLdP2HSeGdM0XhqrjEXSVZ8kkumThGmNPiSmqk2mse+IBKqsuRHl yUw0zU7aQzC6utZUjBQoFZhEtPymY20PeeDVBHvfJL3m/c55JWQ8SSD1LgV+bAcaRcfC QGHg== 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=DPljuKj8Rrvaey+ZGnnQxT53Wa6yVLMni/ZPYwy7Ocs=; b=QoXVSX2EeitvJhSqsq86+923IP2FwF4HtwHq7LShxsYScNOw2cxDeFPq8s7OVM4fyM 9SqQz3wbNBJ7KrhQt3gN1C+J4MZ9PGPTWWslojbl1NTon00MmqhChRlyGZDCLmqJy0py 7yuPQf1cG13JHrDBr0BcPOFCuYaIbIIOGCrDrbIRyL2KAPG+1KFkgt3TUY0PHvWdvm82 ICV8JrdYFYZ0X/m+4ycwgL8/SND8zVcJ4e2iVyGfKo6ua0nobCxW66SYx2iTmRmUUEvU I+iWoSswDJXCdIsNK/010nKsZ+KQONDXUF/Xe/bulKJ0pO9XPHXPhoKnNzNxB74gK+VP kOuw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QRYla2J3; 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 m23sor385457pgv.70.2019.08.14.11.47.30 for (Google Transport Security); Wed, 14 Aug 2019 11:47:30 -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=QRYla2J3; 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=DPljuKj8Rrvaey+ZGnnQxT53Wa6yVLMni/ZPYwy7Ocs=; b=QRYla2J3YD94bct0XU/VHlhyLBX+vVhC+xrK/C+P82fiQdUTI0Nv6p2/JbYEJZOVP2 irXIWpYYUC4X2OFt0YIfI+Z+sogCMa5Yr344yI0VBA1ygrw398u2/Rkrvf9xUHpR7rUA 6zxlqnDtaevKn+NixPVJ3s3kLJqX5a4oA6MTSlZtGz43sUXt2Jpo5nDtOvINCQo8aFKH vnAIA8BYEpG9uji7lsh0fD2ywHOV6zNAvQIW2/Pmjd23ia5ctRBP/kcqlyyrjnPZQNyj pk2Y3KAIb6p1ap7SsTUjUnPTyWvpHnGKE75sq1g19cpd5bi3JAesWayUDirQ2c0VdZd9 9U7A== 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=DPljuKj8Rrvaey+ZGnnQxT53Wa6yVLMni/ZPYwy7Ocs=; b=I35VwzrcwA5VQYXzpLfx2Uc5sNcIgGW1AZYyIk1BW8fvQyLP2J8TwrqO2IAm6lEyrf XteGeqTIhOQcqAk+lRkNqmSNISxfdYAcQVYPQMrASAeDi9+VzYiR+Mf/e6OtHroofpoR VHPqOSpjh1MHgKQvv3ifEHlzpmnYmyB9XvGbQiCZbcbcc9ajzcvsx9XQGXhiWhquDQre Xf1Zpn43xRw4UEX4JO7orhhjp4ijruW4DlSrxohoDKGPSa1N+hk3Qawz2NucAv181W5i EOzp7Pc2KaPplaEC34kyJK5xo+dWF7FIDzikk1tpE2wg7fuk8zE5amuCHgGBGuIgsj6K XY+A== X-Gm-Message-State: APjAAAXlZhAWVKCyIIWSPm+KM9WA/3SXZr3dYJjArrysY3spxoGCiWW7 UBFzH/hjJkcaluGfOWOrye04YfUv X-Google-Smtp-Source: APXvYqxzYdQ++BF6VEmmM3gRhlHFCARtDdNB9cW6qpH5aGj4/2Nec/UVjqlAUe+ZhaEJDq6QZq0a8g== X-Received: by 2002:a63:60d1:: with SMTP id u200mr458559pgb.439.1565808450277; Wed, 14 Aug 2019 11:47:30 -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.28 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 14 Aug 2019 11:47:29 -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 15/26] drm: kirin: Move channel formats to driver data Date: Wed, 14 Aug 2019 18:46:51 +0000 Message-Id: <20190814184702.54275-16-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 channel format arrays into 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 [jstultz: reworded commit message] Signed-off-by: John Stultz --- .../gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 30 +++++-------------- .../gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 3 ++ 2 files changed, 10 insertions(+), 23 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 029733864aa8..99dfd15af771 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c @@ -76,7 +76,7 @@ static const struct kirin_format ade_formats[] = { { DRM_FORMAT_ABGR8888, ADE_ABGR_8888 }, }; -static const u32 channel_formats1[] = { +static const u32 channel_formats[] = { /* channel 1,2,3,4 */ DRM_FORMAT_RGB565, DRM_FORMAT_BGR565, DRM_FORMAT_RGB888, DRM_FORMAT_BGR888, DRM_FORMAT_XRGB8888, DRM_FORMAT_XBGR8888, @@ -84,19 +84,6 @@ static const u32 channel_formats1[] = { DRM_FORMAT_ABGR8888 }; -u32 ade_get_channel_formats(u8 ch, const u32 **formats) -{ - switch (ch) { - case ADE_CH1: - *formats = channel_formats1; - return ARRAY_SIZE(channel_formats1); - default: - DRM_ERROR("no this channel %d\n", ch); - *formats = NULL; - return 0; - } -} - /* convert from fourcc format to ade format */ static u32 ade_get_format(u32 pixel_format) { @@ -908,18 +895,13 @@ static struct drm_plane_funcs ade_plane_funcs = { static int ade_plane_init(struct drm_device *dev, struct kirin_plane *kplane, enum drm_plane_type type) { - const u32 *fmts; - u32 fmts_cnt; int ret = 0; - /* get properties */ - fmts_cnt = ade_get_channel_formats(kplane->ch, &fmts); - if (ret) - return ret; - ret = drm_universal_plane_init(dev, &kplane->base, 1, - ade_driver_data.plane_funcs, fmts, - fmts_cnt, NULL, type, NULL); + ade_driver_data.plane_funcs, + ade_driver_data.channel_formats, + ade_driver_data.channel_formats_cnt, + NULL, type, NULL); if (ret) { DRM_ERROR("fail to init plane, ch=%d\n", kplane->ch); return ret; @@ -1057,6 +1039,8 @@ static void ade_drm_cleanup(struct platform_device *pdev) } struct kirin_drm_data ade_driver_data = { + .channel_formats = channel_formats, + .channel_formats_cnt = ARRAY_SIZE(channel_formats), .crtc_helper_funcs = &ade_crtc_helper_funcs, .crtc_funcs = &ade_crtc_funcs, .plane_helper_funcs = &ade_plane_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 70b04e65789c..66916502a9e6 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -35,6 +35,9 @@ struct kirin_plane { /* display controller init/cleanup ops */ struct kirin_drm_data { + const u32 *channel_formats; + u32 channel_formats_cnt; + const struct drm_crtc_helper_funcs *crtc_helper_funcs; const struct drm_crtc_funcs *crtc_funcs; const struct drm_plane_helper_funcs *plane_helper_funcs;