From patchwork Tue Apr 23 23:20:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 162751 Delivered-To: patches@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp4354791jan; Tue, 23 Apr 2019 16:21:21 -0700 (PDT) X-Received: by 2002:a63:131d:: with SMTP id i29mr8815327pgl.399.1556061680989; Tue, 23 Apr 2019 16:21:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1556061680; cv=none; d=google.com; s=arc-20160816; b=r8YJkfWEPkGGlRO6B03GtCAKeEWzmyd1vNFnllZyzY8HT7yFo4zBU29QX/SdlVzrKU XfZGWQJ/ygL7G81R1YYod/8lg+hfz5B2yzIGSN9qLnXhBSSUmCpdWfOrHJ/AQI86KxJj CP+Jsrh9uUK25zhuHFgLlO8IP59WXqxh4tIRyotKndpe6jI7lpFnVg9CagETe3ECGXxE exobqqu1I8PwJLiiAQ3XGglkeny5fBDxdC1Oer2wAm7xiBtFCdN0Q+o5JJ7zcK26vi9t 2aNcKIh1mwxWNsWa3OwILuODtIIxHHSc8GXNQr3NgpeIvpKHh/ncp0z4hDAFnFLyHjLV I4gw== 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=3w6o3fIq2iIb7WJJVP20Z4EfqmYB1pkBjh2u5OeFpHE=; b=vNZB2jWt7Xsg5SP0jEkQZv5a5/m1i1uGILfVsHpYdpHUWlyesBOgq3ZlLPiaeDm7Ym hPz0+e7Tw+C8a83CFjHVqwdMJ7RNlqzgrFwZrM0VONRWa/fSUddbNCMSuk+mFBZw+Ytm 2hLcYC4YvzEP0EgGT4QQXBdbo1MAypDD5KzYFVNzlHHZ0WRv13k8Mfa8kjT0n1CKrZsy 5zZEXpcrkUBWih8jGrlXGyf0YJFX4n7mnlPxXOzxoQt3KkraP5n/XRupmc9csUJtrWb+ JhbH8MRRF2Uzt/mU0T6urRXwoY9fdzx1a0+T7yXlAtYVnNl3dNigUG0UpDwupvs0Ddo3 eiDg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=nsh6amFf; 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 c193sor14839434pga.4.2019.04.23.16.21.20 for (Google Transport Security); Tue, 23 Apr 2019 16:21:20 -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=nsh6amFf; 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=3w6o3fIq2iIb7WJJVP20Z4EfqmYB1pkBjh2u5OeFpHE=; b=nsh6amFfhd4Ifw8Uob3BkzyqOpMWuM5rJhtKKK0K9SUaDGzpNqrP6Lnc++KtbbEF3h LIMAIvD+l3blZ+t0HETDRB0yQXT7NQnHsqLQw8dDMjbWsjm906Q/cB/TSShSRYBftQZO mZ3LbYAg4Cm+ma8lYjL98QaSTKq2IIJAS3weMwVpv69FnsZJ4o75c3NXktFKh1/FE0bF YR5Lkrlg0WpXi7dRsarHuft1+QdTWcJj6RXKCUfYuizv1dR4mhJWqoOu7wxTz1A3JdQq UabNV8mgRAODM/JiiZggCXDfQNl1oEUaK8LCz1dtOoMoQV8IiKCHyTXldR0RMTF95++N TscQ== 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=3w6o3fIq2iIb7WJJVP20Z4EfqmYB1pkBjh2u5OeFpHE=; b=AXyELfipXt/SGi9Vf9dhHxa86F0xJjquzm7XzvhF8iHSYKm/41yLbU44q927JqeyUB 3ZyEAuXoRhVZ8kqegqz3CKqIM9sVlSjvNpR+IifL4Du01uF7E1/GRAGmOhJjlTc7tH/f oXCv2xKk/ji/r0Nn8+8ZEcVQVSJPQN32lkEkKKBMIhqaDZ+w9IeVWW45x6/NaCxO60JJ uYZx8KgR2L/0H6zJ3G/oyMjotmb5RxNjv0Q5Jco7MAVukN07k4TjS/HZGIDhqYxPdRax ZywA0ajMOldaUZ0GcgHFMe3MEbpBK+V15M99u0DKYsVVg9fCq+dpYM/tmKwj/LHFo05A 9uJw== X-Gm-Message-State: APjAAAXhB6+ybaosCUy7pwauseK6P/dnzW0uf1eMy7Em0P0dG0tDmNeZ VKNHa20Po+GHOhkjWs9EO7LFycsE X-Google-Smtp-Source: APXvYqwUCGfe++hbxuKspqGxqH+ClR1wU0pXlx9MmWXqxBNFEBl3f+cwivJTEk5ptc68rsDcine/YA== X-Received: by 2002:a65:6414:: with SMTP id a20mr3518840pgv.217.1556061680604; Tue, 23 Apr 2019 16:21:20 -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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 23 Apr 2019 16:21:19 -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 14/25] drm: kirin: Move channel formats to driver data Date: Tue, 23 Apr 2019 16:20:45 -0700 Message-Id: <1556061656-1733-15-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 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: 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 commit message] Signed-off-by: John Stultz --- drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c | 30 ++++++------------------- drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h | 3 +++ 2 files changed, 10 insertions(+), 23 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 6aa529f..0ebe715 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 05161ff..f688612 100644 --- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h +++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_drv.h @@ -39,6 +39,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;