From patchwork Thu Aug 1 03:44:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 170293 Delivered-To: patches@linaro.org Received: by 2002:a92:512:0:0:0:0:0 with SMTP id q18csp4836308ile; Wed, 31 Jul 2019 20:45:09 -0700 (PDT) X-Received: by 2002:a17:902:6b07:: with SMTP id o7mr120440754plk.180.1564631109418; Wed, 31 Jul 2019 20:45:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564631109; cv=none; d=google.com; s=arc-20160816; b=qlmIlTcfltP1qssCyp4u7i22vxiwsIxHQ7/8UuRxoHao7oH+nfhgy2sp/nl/IPBOrN MoT8hU0Nvz7IrryaN7nLJOHNH/rQnPrKf3nYIgwd3dIUyuwM/mobSk/Zr+CYpGXtUfpc iT5g1SbZRvnjmCNPCzzXiNa1H++s4VtMXDHIPpraWon/dHs1xWG3R6EEQpwZqLUFZ0p0 lBlhT73Kctply6vtss31axVsYo+0a1kpN9Eddjq2drbrZNFMt7fjP1AjD+tCmDgSqFaL 5gSJo5E7FNtwqSS3/Bb7uQv3iD/Jmh4DyAfHA4YBmMqC+IREom0ymvJ94ItXXxit4jTt e6kA== 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=HDJvJkGt16A9xh+oJ/V6cF1p90cprtRCL0cPwhoe3KU=; b=Q6ehKizjPl1hcDv3NesIpRqMhdQSL2Csfxd0F77FGE/qE4skn2+pHFvEDh7pHId28R x/Ih1ZwL2GYixqGze7r/Mtfs8i7tG1pAOmq9Xqmhcyce8HH6aNUYN8r9X34fS5bP00lp zm28Inbyes+L6Nl9llFmBDA7jyeTpq9WeAgcFunE6yAcgTacmSpk9AzlCJV91V3ZoePe b+qKqO6McvYZGnnkCD+vQbPXBLEj2a1Be3Bup48lDgcqGGqI8FgifphxQR2RXoHjV9K3 eX2fHUOjohfusevMCVoCJOZO9ti9msV6Ues8p5ko42UWvzGciMHseDMN5y9OjOFY4b8A baXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Wym2MUS5; 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 r4sor83878318plo.57.2019.07.31.20.45.09 for (Google Transport Security); Wed, 31 Jul 2019 20:45:09 -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=Wym2MUS5; 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=HDJvJkGt16A9xh+oJ/V6cF1p90cprtRCL0cPwhoe3KU=; b=Wym2MUS5YK2BPc9KkQ7bWTa8b+pG1A+eWp2ZaWaawXbnATIPYTCjougDcNO1ggC5C1 ePXAj6Pvjjtt40YpLKEKKb23byuUWI3VKusNx1KjeSgBi2Weq68ttAOWhrgnyAJN62CJ AVpUXrLXNBERAeKf6d5/fOpR1drsQta+SUPrNUzRoBwnc/SNuEA4ZWbdl6ZFdLpIPd2v IKRGJX6wh6cYpRIx6D5KRCTVLD2DGezV2k9z7Yq57cSzad1wthBhLmZ3X/xnVQ6J/xbh /vouDxjP4jImvR/uBuQQA8qL36pa0TUN3HL95BYb4QUnWG/QcATvsUOvoMvm9Vrgfblb FTqQ== 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=HDJvJkGt16A9xh+oJ/V6cF1p90cprtRCL0cPwhoe3KU=; b=ocYiakZS5pvVNidbNE+P2s+3wZIOPI8x0NBdioCQyx4yKNXBdRbtvSEbx2KFa05ltB 10LD9InMWvQwJvJgFZJcEm8usexju1EaYvKBxW5EReDtyfya6nrSplEBWfWZn+iaocjv Gq77P2m+Y0WzSeBaWFgFqv59JhMG2n3y7pWQ/p6ym9AqQJNXwDErw/6KexwdPX3Zrp8V k9osQRCTNrxafaRXqf4VGJFHMoo66tzoOSUdD5L+CVIzpAzoTR+1K+SWOAAWP63HKC+k Hc1bEdVP6A3e/tWHrdB7Dz7/SMWs3qQALrIlxAeAvZaCkMsENWHudiNiSpy9azxP7Q4q EWhg== X-Gm-Message-State: APjAAAUgjRkHDs33GZ8pJ7bFqpc7Rh/TNbpgEUC5CWtsBBj/IKF5pitX ckTXRIr3r4gyrTC2fUI6YRJ2nKIR X-Google-Smtp-Source: APXvYqwyN9aTnd/ybC4ZOD7D2YlGwTywueZyug//Dj/lnSuPvgbMF+ELyqVChUrqIadiHW1xHsdSDA== X-Received: by 2002:a17:902:306:: with SMTP id 6mr125220747pld.148.1564631108989; Wed, 31 Jul 2019 20:45:08 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id h70sm64775674pgc.36.2019.07.31.20.45.07 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 31 Jul 2019 20:45:08 -0700 (PDT) From: John Stultz To: lkml Cc: Xu YiPing , Rongrong Zou , David Airlie , Daniel Vetter , dri-devel , Sam Ravnborg , John Stultz Subject: [PATCH v3 15/26] drm: kirin: Move channel formats to driver data Date: Thu, 1 Aug 2019 03:44:28 +0000 Message-Id: <20190801034439.98227-16-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190801034439.98227-1-john.stultz@linaro.org> References: <20190801034439.98227-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: 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;