From patchwork Tue Aug 20 23:06:15 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: John Stultz X-Patchwork-Id: 171873 Delivered-To: patches@linaro.org Received: by 2002:a92:d204:0:0:0:0:0 with SMTP id y4csp180228ily; Tue, 20 Aug 2019 16:06:50 -0700 (PDT) X-Received: by 2002:a17:90a:bc4b:: with SMTP id t11mr2398292pjv.87.1566342410322; Tue, 20 Aug 2019 16:06:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566342410; cv=none; d=google.com; s=arc-20160816; b=p5RDq0wsziolRw3Rc02/kh4w6BcuSqyJyg6uC9SIcIa87ok+AJqNgYup1HcCfRuqs2 gvPPkgGFO2/I930Vg7r6tFNSDusZwKDzs2xDlCERSdch44fOKPEFK+radEDoTfGhE7+w gv3s2YKbOtlO5M/4SDQP3wyTq9B03FkVAGwrwKDAieYi+6xQwSIlK2EUu+h+HNyACj2k aP9WYBHc04Q9TxEIFZut49SZvRIhDE8rxLUT3HNtkp/xRoVas94LdE74m1CJ19dozZHf Fbz3ziK+aL954KqLV5nnte4FGSSOLIe70iIuV655+cfEhXBPOsOWyg35FcWZZW7DPSED qFTA== 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=YJTcSCEwUYf2TN3oxKMWFSLC+lpczIvjHDBU/TsB0vU=; b=S6NclTjAsI9ojZHtUwxCh+dc8hobq2rzWYfLLAUA4f5aqgBRT2DeUnGdOD/ifi0ieQ yyjK5qz0AZzX2dsY14izeuf42F9lvVweNV9V4anOZK2cEjRRIvFKNl8Ha6ADH5rMzvAR yqnXSGiSeiH3SvvpeCTNKVj/s0ldfYTTp8sceXVlMosrwo0CY8kZ/GHsm/7rVHPDo+58 zGr3gD0Om0q3MlGq7b/MQMN1nYD3pvn8P8Dk3u8lq5xbUitOndjEs/dB+fhaUXpZPffO 4RQiOMpEAVYhHf8lpud2AEsNNEwvtVxSclO90wU1b2pm/a7TzRl/EqiXGke8kRAHMtoU QTkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UrhNpyBE; 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 i3sor1816348pjt.5.2019.08.20.16.06.50 for (Google Transport Security); Tue, 20 Aug 2019 16:06:50 -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=UrhNpyBE; 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=YJTcSCEwUYf2TN3oxKMWFSLC+lpczIvjHDBU/TsB0vU=; b=UrhNpyBEvkRLJlD1lnBou+mHZTRhB/m1n9p81ZBPRjW2VIAdtZdw5G0LZ73UkYTk7i 8yb8acrI/FprbY7QYWmu7hrInIgXo6Q1U8sBIfwpWF6Jy+T4/aDjI79bJ85+QDN/sb/z ph8+8gU5w39ZCU6HCOMXwXJJrQLlN1jMDhQhLpbJI/SR0eJW+vRZUfrV6gHu2tQKgSut Hrrs0dG0CzItmrae/ljTZN8Up+KIoi65kBrgp/exBe0g7+nLaiN8C2hjX0TAHvVDTsOu LOyowmqfp9OsBg3NCxiOwij812jVpq+HVLhQ8CDdigZTZIBOwxSUySP4EobC2wg3MqFh p/vQ== 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=YJTcSCEwUYf2TN3oxKMWFSLC+lpczIvjHDBU/TsB0vU=; b=ADB5O4YssYszB+U7YTatYlccwikWABT2D6pyllXyZB1Z7oHUVnnV9NWDYz7C9qkVWm 3qRkrv/MQAAjXp6q0Ekr0q4NLpJ7ipUyvbNSt2LKoQuHKl/qtrL+XNJJDBT29sRVd2mW UEoImPIdVhraoWjv3uitNoZ2ln6WRKkZiidVXam8wxWDWJIANtusjlUKdRL1XfifU8GJ FPtLX3jfipL0DYkUhUbv+nlSrQ4psazyol/sdx/OQyMuJBl4+Y2XMEAhHwj7BCudol6Y q8+OyMlecQbVjCpibtcqlbCoP6T8WBAcJGvjecChCaSM5Ude2ag4/M0HKyo2odnQ+zoa JVbg== X-Gm-Message-State: APjAAAWZMCo1ZjaaOVuT7NRRpGRVmtto1DBUrFaaLTz/aeL9XCQXxZGX mUqDeK5WGwNLU8TaahY0Dydlux0/ X-Google-Smtp-Source: APXvYqzWSCAXbwKwbbCD16y0knYnO0K/isFTQTyNGy5wU9rDTJP8Lzw67+HLeQDhCU/xG3ibZb6+cw== X-Received: by 2002:a17:90a:b016:: with SMTP id x22mr2454039pjq.116.1566342409877; Tue, 20 Aug 2019 16:06:49 -0700 (PDT) Return-Path: Received: from localhost.localdomain ([2601:1c2:680:1319:692:26ff:feda:3a81]) by smtp.gmail.com with ESMTPSA id q4sm27564747pff.183.2019.08.20.16.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 20 Aug 2019 16:06:49 -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: [PATCH v5 14/25] drm: kirin: Move channel formats to driver data Date: Tue, 20 Aug 2019 23:06:15 +0000 Message-Id: <20190820230626.23253-15-john.stultz@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190820230626.23253-1-john.stultz@linaro.org> References: <20190820230626.23253-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 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(-) -- 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 a1a79f372bcd..0489b6378e01 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;