From patchwork Mon Aug 19 23:03:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 11102317 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61C5C1398 for ; Mon, 19 Aug 2019 23:03:58 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 4BB5922CEC for ; Mon, 19 Aug 2019 23:03:58 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 4BB5922CEC Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 9B7476E482; Mon, 19 Aug 2019 23:03:55 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by gabe.freedesktop.org (Postfix) with ESMTPS id 461946E47C for ; Mon, 19 Aug 2019 23:03:47 +0000 (UTC) Received: by mail-pf1-x444.google.com with SMTP id d85so2088564pfd.2 for ; Mon, 19 Aug 2019 16:03:47 -0700 (PDT) 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=HLpBk6XUcRfuXdq52l7Aj6EvNRXsKiox2i7zRtdxggg=; b=P1X8/e/aig3ySuI+ADw7l+DmS+UIxx9up2PKg4ntpap+lNL3TmU6h9PMs+pCz+Jm8W 9KmyZi2qzkxuAfOa2jwkQO1XPvPeFK0P4zRjr0Jzd+Hnf+ZpNlYE35lPlJbHIWOjWI1Z +/esExNXHob5MhJqKLaR9zT8O+91lDmwfMyBANFs4KSTci+4PyPzdBF4NxR3L8vj7d8F cT8WOERG/3xXhExPxc+kV74gu4Dy5gvSHns+4SZsR6iQqpnkpcTeUAcqcHrQzhSX2BOA k+zkOZ9zUze8xgf3k0JMK1+UafLI4/59QCTgliCsZ3qU1MkCXQN04yQE0kn7Ug++mt2c kzqQ== X-Gm-Message-State: APjAAAWiQZvzgt89NYHyY1pTUyfEgTG5KGMNHek24dkPNg3CQkTg8N4c rEixM1k1cVTo0trs42OG6uPOqQ== X-Google-Smtp-Source: APXvYqzNux6JkEwwJx7Pcle4eFyI1S63fNUUdGAfzJyqSQpDPqNectpDOgcDpdSBFDpjrMe7me7M9g== X-Received: by 2002:a17:90a:bb01:: with SMTP id u1mr22678933pjr.92.1566255826646; Mon, 19 Aug 2019 16:03:46 -0700 (PDT) Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id j15sm17256509pfr.146.2019.08.19.16.03.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Aug 2019 16:03:45 -0700 (PDT) From: John Stultz To: lkml Subject: [PATCH v4 14/25] drm: kirin: Move channel formats to driver data Date: Mon, 19 Aug 2019 23:03:10 +0000 Message-Id: <20190819230321.56480-15-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190819230321.56480-1-john.stultz@linaro.org> References: <20190819230321.56480-1-john.stultz@linaro.org> X-Mailman-Original-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=HLpBk6XUcRfuXdq52l7Aj6EvNRXsKiox2i7zRtdxggg=; b=VdEltd1nXZPR7DXTC3NOclmsoKQLEe6kXHPtTLjmLu2N/X61XZZY3vOgkdjnrBqUic 42+OUZZiChiJOxT0JN7pP7poX8DIkNMqbvOGrjMJN3zHQ2DBvicSZFdSQlnL2y9sNMyU WbizA8J8R1WTSjv4sLnqZRpRhunA7IidducUX67xTDkOJaQk9qRH0kJ1O08n4TZG5w/6 TXoc1VWk2NcoWGv0YroeT9MA0hepLh37DUMSAAR2KiS4JUs8ZNaCafwRhX0eqARtemwu 2ZRG2GjpflYIl2qLSzgbyiVeHn+WXP9ggrZmQSuz82p24q1htNqVqnoRJBOc5H6eChrk 8i5g== X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Xu YiPing , David Airlie , dri-devel , Xinliang Liu , Rongrong Zou , Sam Ravnborg MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 Acked-by: Xinliang Liu 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(-) diff --git a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c index 016a6057c5f6..cf542430a659 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;