From patchwork Tue Apr 11 11:42:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 672475 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AA2ACC77B70 for ; Tue, 11 Apr 2023 11:43:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229916AbjDKLnE (ORCPT ); Tue, 11 Apr 2023 07:43:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51036 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229688AbjDKLm7 (ORCPT ); Tue, 11 Apr 2023 07:42:59 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 200533C25; Tue, 11 Apr 2023 04:42:53 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,336,1673881200"; d="scan'208";a="155597302" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Apr 2023 20:42:52 +0900 Received: from localhost.localdomain (unknown [10.226.93.123]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 6A0C7400195D; Tue, 11 Apr 2023 20:42:48 +0900 (JST) From: Biju Das To: David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v7 02/17] drm: rcar-du: Add kms lib support Date: Tue, 11 Apr 2023 12:42:20 +0100 Message-Id: <20230411114235.366042-3-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> References: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Add RCar DU kms lib support for sharing the common code between RCar and RZ/G2L DU KMS drivers by moving rcar_du_format_infos table and rcar_du_format_infos() to the lib file. Signed-off-by: Biju Das --- v6->v7: * Rebased to drm-tip. v1->v6: * Rebased on drm-misc-next and DU-next. v1: * Created the lib suggested by Laurent. Ref: https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220316131100.30685-6-biju.das.jz@bp.renesas.com/ --- drivers/gpu/drm/rcar-du/Makefile | 3 +- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 320 --------------------- drivers/gpu/drm/rcar-du/rcar_du_kms.h | 16 +- drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c | 335 ++++++++++++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h | 27 ++ 5 files changed, 366 insertions(+), 335 deletions(-) create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c create mode 100644 drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h diff --git a/drivers/gpu/drm/rcar-du/Makefile b/drivers/gpu/drm/rcar-du/Makefile index 479c8eebba5a..3ce410300334 100644 --- a/drivers/gpu/drm/rcar-du/Makefile +++ b/drivers/gpu/drm/rcar-du/Makefile @@ -6,7 +6,8 @@ rcar-du-drm-y := rcar_du_crtc.o \ rcar_du_kms.o \ rcar_du_plane.o \ -rcar-du-drm-$(CONFIG_DRM_RCAR_LIB) += rcar_du_encoder_lib.o +rcar-du-drm-$(CONFIG_DRM_RCAR_LIB) += rcar_du_encoder_lib.o \ + rcar_du_kms_lib.o rcar-du-drm-$(CONFIG_DRM_RCAR_VSP) += rcar_du_vsp.o rcar-du-drm-$(CONFIG_DRM_RCAR_WRITEBACK) += rcar_du_writeback.o diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index adfb36b0e815..3141d447e979 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -32,326 +32,6 @@ #include "rcar_du_vsp.h" #include "rcar_du_writeback.h" -/* ----------------------------------------------------------------------------- - * Format helpers - */ - -static const struct rcar_du_format_info rcar_du_format_infos[] = { - { - .fourcc = DRM_FORMAT_RGB565, - .v4l2 = V4L2_PIX_FMT_RGB565, - .bpp = 16, - .planes = 1, - .hsub = 1, - .pnmr = PnMR_SPIM_TP | PnMR_DDDF_16BPP, - .edf = PnDDCR4_EDF_NONE, - }, { - .fourcc = DRM_FORMAT_ARGB1555, - .v4l2 = V4L2_PIX_FMT_ARGB555, - .bpp = 16, - .planes = 1, - .hsub = 1, - .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_ARGB, - .edf = PnDDCR4_EDF_NONE, - }, { - .fourcc = DRM_FORMAT_XRGB1555, - .v4l2 = V4L2_PIX_FMT_XRGB555, - .bpp = 16, - .planes = 1, - .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_ARGB, - .edf = PnDDCR4_EDF_NONE, - }, { - .fourcc = DRM_FORMAT_XRGB8888, - .v4l2 = V4L2_PIX_FMT_XBGR32, - .bpp = 32, - .planes = 1, - .hsub = 1, - .pnmr = PnMR_SPIM_TP | PnMR_DDDF_16BPP, - .edf = PnDDCR4_EDF_RGB888, - }, { - .fourcc = DRM_FORMAT_ARGB8888, - .v4l2 = V4L2_PIX_FMT_ABGR32, - .bpp = 32, - .planes = 1, - .hsub = 1, - .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_16BPP, - .edf = PnDDCR4_EDF_ARGB8888, - }, { - .fourcc = DRM_FORMAT_UYVY, - .v4l2 = V4L2_PIX_FMT_UYVY, - .bpp = 16, - .planes = 1, - .hsub = 2, - .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, - .edf = PnDDCR4_EDF_NONE, - }, { - .fourcc = DRM_FORMAT_YUYV, - .v4l2 = V4L2_PIX_FMT_YUYV, - .bpp = 16, - .planes = 1, - .hsub = 2, - .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, - .edf = PnDDCR4_EDF_NONE, - }, { - .fourcc = DRM_FORMAT_NV12, - .v4l2 = V4L2_PIX_FMT_NV12M, - .bpp = 12, - .planes = 2, - .hsub = 2, - .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, - .edf = PnDDCR4_EDF_NONE, - }, { - .fourcc = DRM_FORMAT_NV21, - .v4l2 = V4L2_PIX_FMT_NV21M, - .bpp = 12, - .planes = 2, - .hsub = 2, - .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, - .edf = PnDDCR4_EDF_NONE, - }, { - .fourcc = DRM_FORMAT_NV16, - .v4l2 = V4L2_PIX_FMT_NV16M, - .bpp = 16, - .planes = 2, - .hsub = 2, - .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, - .edf = PnDDCR4_EDF_NONE, - }, - /* - * The following formats are not supported on Gen2 and thus have no - * associated .pnmr or .edf settings. - */ - { - .fourcc = DRM_FORMAT_RGB332, - .v4l2 = V4L2_PIX_FMT_RGB332, - .bpp = 8, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_ARGB4444, - .v4l2 = V4L2_PIX_FMT_ARGB444, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_XRGB4444, - .v4l2 = V4L2_PIX_FMT_XRGB444, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_RGBA4444, - .v4l2 = V4L2_PIX_FMT_RGBA444, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_RGBX4444, - .v4l2 = V4L2_PIX_FMT_RGBX444, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_ABGR4444, - .v4l2 = V4L2_PIX_FMT_ABGR444, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_XBGR4444, - .v4l2 = V4L2_PIX_FMT_XBGR444, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_BGRA4444, - .v4l2 = V4L2_PIX_FMT_BGRA444, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_BGRX4444, - .v4l2 = V4L2_PIX_FMT_BGRX444, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_RGBA5551, - .v4l2 = V4L2_PIX_FMT_RGBA555, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_RGBX5551, - .v4l2 = V4L2_PIX_FMT_RGBX555, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_ABGR1555, - .v4l2 = V4L2_PIX_FMT_ABGR555, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_XBGR1555, - .v4l2 = V4L2_PIX_FMT_XBGR555, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_BGRA5551, - .v4l2 = V4L2_PIX_FMT_BGRA555, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_BGRX5551, - .v4l2 = V4L2_PIX_FMT_BGRX555, - .bpp = 16, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_BGR888, - .v4l2 = V4L2_PIX_FMT_RGB24, - .bpp = 24, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_RGB888, - .v4l2 = V4L2_PIX_FMT_BGR24, - .bpp = 24, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_RGBA8888, - .v4l2 = V4L2_PIX_FMT_BGRA32, - .bpp = 32, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_RGBX8888, - .v4l2 = V4L2_PIX_FMT_BGRX32, - .bpp = 32, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_ABGR8888, - .v4l2 = V4L2_PIX_FMT_RGBA32, - .bpp = 32, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_XBGR8888, - .v4l2 = V4L2_PIX_FMT_RGBX32, - .bpp = 32, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_BGRA8888, - .v4l2 = V4L2_PIX_FMT_ARGB32, - .bpp = 32, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_BGRX8888, - .v4l2 = V4L2_PIX_FMT_XRGB32, - .bpp = 32, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_RGBX1010102, - .v4l2 = V4L2_PIX_FMT_RGBX1010102, - .bpp = 32, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_RGBA1010102, - .v4l2 = V4L2_PIX_FMT_RGBA1010102, - .bpp = 32, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_ARGB2101010, - .v4l2 = V4L2_PIX_FMT_ARGB2101010, - .bpp = 32, - .planes = 1, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_YVYU, - .v4l2 = V4L2_PIX_FMT_YVYU, - .bpp = 16, - .planes = 1, - .hsub = 2, - }, { - .fourcc = DRM_FORMAT_NV61, - .v4l2 = V4L2_PIX_FMT_NV61M, - .bpp = 16, - .planes = 2, - .hsub = 2, - }, { - .fourcc = DRM_FORMAT_YUV420, - .v4l2 = V4L2_PIX_FMT_YUV420M, - .bpp = 12, - .planes = 3, - .hsub = 2, - }, { - .fourcc = DRM_FORMAT_YVU420, - .v4l2 = V4L2_PIX_FMT_YVU420M, - .bpp = 12, - .planes = 3, - .hsub = 2, - }, { - .fourcc = DRM_FORMAT_YUV422, - .v4l2 = V4L2_PIX_FMT_YUV422M, - .bpp = 16, - .planes = 3, - .hsub = 2, - }, { - .fourcc = DRM_FORMAT_YVU422, - .v4l2 = V4L2_PIX_FMT_YVU422M, - .bpp = 16, - .planes = 3, - .hsub = 2, - }, { - .fourcc = DRM_FORMAT_YUV444, - .v4l2 = V4L2_PIX_FMT_YUV444M, - .bpp = 24, - .planes = 3, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_YVU444, - .v4l2 = V4L2_PIX_FMT_YVU444M, - .bpp = 24, - .planes = 3, - .hsub = 1, - }, { - .fourcc = DRM_FORMAT_Y210, - .v4l2 = V4L2_PIX_FMT_Y210, - .bpp = 32, - .planes = 1, - .hsub = 2, - }, { - .fourcc = DRM_FORMAT_Y212, - .v4l2 = V4L2_PIX_FMT_Y212, - .bpp = 32, - .planes = 1, - .hsub = 2, - }, -}; - -const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc) -{ - unsigned int i; - - for (i = 0; i < ARRAY_SIZE(rcar_du_format_infos); ++i) { - if (rcar_du_format_infos[i].fourcc == fourcc) - return &rcar_du_format_infos[i]; - } - - return NULL; -} - /* ----------------------------------------------------------------------------- * Frame buffer */ diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.h b/drivers/gpu/drm/rcar-du/rcar_du_kms.h index f31afeeee05a..d2d4f34fe557 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.h @@ -2,7 +2,7 @@ /* * R-Car Display Unit Mode Setting * - * Copyright (C) 2013-2014 Renesas Electronics Corporation + * Copyright (C) 2013-2023 Renesas Electronics Corporation * * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) */ @@ -10,7 +10,7 @@ #ifndef __RCAR_DU_KMS_H__ #define __RCAR_DU_KMS_H__ -#include +#include "rcar_du_kms_lib.h" struct dma_buf_attachment; struct drm_file; @@ -20,18 +20,6 @@ struct drm_mode_create_dumb; struct rcar_du_device; struct sg_table; -struct rcar_du_format_info { - u32 fourcc; - u32 v4l2; - unsigned int bpp; - unsigned int planes; - unsigned int hsub; - unsigned int pnmr; - unsigned int edf; -}; - -const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc); - int rcar_du_modeset_init(struct rcar_du_device *rcdu); int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c new file mode 100644 index 000000000000..5921040586fc --- /dev/null +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c @@ -0,0 +1,335 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * R-Car Display Unit Mode Setting Lib + * + * Copyright (C) 2013-2023 Renesas Electronics Corporation + * + * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) + */ + +#include + +#include + +#include "rcar_du_kms.h" +#include "rcar_du_regs.h" + +/* ----------------------------------------------------------------------------- + * Format helpers + */ + +static const struct rcar_du_format_info rcar_du_format_infos[] = { + { + .fourcc = DRM_FORMAT_RGB565, + .v4l2 = V4L2_PIX_FMT_RGB565, + .bpp = 16, + .planes = 1, + .hsub = 1, + .pnmr = PnMR_SPIM_TP | PnMR_DDDF_16BPP, + .edf = PnDDCR4_EDF_NONE, + }, { + .fourcc = DRM_FORMAT_ARGB1555, + .v4l2 = V4L2_PIX_FMT_ARGB555, + .bpp = 16, + .planes = 1, + .hsub = 1, + .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_ARGB, + .edf = PnDDCR4_EDF_NONE, + }, { + .fourcc = DRM_FORMAT_XRGB1555, + .v4l2 = V4L2_PIX_FMT_XRGB555, + .bpp = 16, + .planes = 1, + .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_ARGB, + .edf = PnDDCR4_EDF_NONE, + }, { + .fourcc = DRM_FORMAT_XRGB8888, + .v4l2 = V4L2_PIX_FMT_XBGR32, + .bpp = 32, + .planes = 1, + .hsub = 1, + .pnmr = PnMR_SPIM_TP | PnMR_DDDF_16BPP, + .edf = PnDDCR4_EDF_RGB888, + }, { + .fourcc = DRM_FORMAT_ARGB8888, + .v4l2 = V4L2_PIX_FMT_ABGR32, + .bpp = 32, + .planes = 1, + .hsub = 1, + .pnmr = PnMR_SPIM_ALP | PnMR_DDDF_16BPP, + .edf = PnDDCR4_EDF_ARGB8888, + }, { + .fourcc = DRM_FORMAT_UYVY, + .v4l2 = V4L2_PIX_FMT_UYVY, + .bpp = 16, + .planes = 1, + .hsub = 2, + .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, + .edf = PnDDCR4_EDF_NONE, + }, { + .fourcc = DRM_FORMAT_YUYV, + .v4l2 = V4L2_PIX_FMT_YUYV, + .bpp = 16, + .planes = 1, + .hsub = 2, + .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, + .edf = PnDDCR4_EDF_NONE, + }, { + .fourcc = DRM_FORMAT_NV12, + .v4l2 = V4L2_PIX_FMT_NV12M, + .bpp = 12, + .planes = 2, + .hsub = 2, + .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, + .edf = PnDDCR4_EDF_NONE, + }, { + .fourcc = DRM_FORMAT_NV21, + .v4l2 = V4L2_PIX_FMT_NV21M, + .bpp = 12, + .planes = 2, + .hsub = 2, + .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, + .edf = PnDDCR4_EDF_NONE, + }, { + .fourcc = DRM_FORMAT_NV16, + .v4l2 = V4L2_PIX_FMT_NV16M, + .bpp = 16, + .planes = 2, + .hsub = 2, + .pnmr = PnMR_SPIM_TP_OFF | PnMR_DDDF_YC, + .edf = PnDDCR4_EDF_NONE, + }, + /* + * The following formats are not supported on Gen2 and thus have no + * associated .pnmr or .edf settings. + */ + { + .fourcc = DRM_FORMAT_RGB332, + .v4l2 = V4L2_PIX_FMT_RGB332, + .bpp = 8, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_ARGB4444, + .v4l2 = V4L2_PIX_FMT_ARGB444, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_XRGB4444, + .v4l2 = V4L2_PIX_FMT_XRGB444, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_RGBA4444, + .v4l2 = V4L2_PIX_FMT_RGBA444, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_RGBX4444, + .v4l2 = V4L2_PIX_FMT_RGBX444, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_ABGR4444, + .v4l2 = V4L2_PIX_FMT_ABGR444, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_XBGR4444, + .v4l2 = V4L2_PIX_FMT_XBGR444, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_BGRA4444, + .v4l2 = V4L2_PIX_FMT_BGRA444, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_BGRX4444, + .v4l2 = V4L2_PIX_FMT_BGRX444, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_RGBA5551, + .v4l2 = V4L2_PIX_FMT_RGBA555, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_RGBX5551, + .v4l2 = V4L2_PIX_FMT_RGBX555, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_ABGR1555, + .v4l2 = V4L2_PIX_FMT_ABGR555, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_XBGR1555, + .v4l2 = V4L2_PIX_FMT_XBGR555, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_BGRA5551, + .v4l2 = V4L2_PIX_FMT_BGRA555, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_BGRX5551, + .v4l2 = V4L2_PIX_FMT_BGRX555, + .bpp = 16, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_BGR888, + .v4l2 = V4L2_PIX_FMT_RGB24, + .bpp = 24, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_RGB888, + .v4l2 = V4L2_PIX_FMT_BGR24, + .bpp = 24, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_RGBA8888, + .v4l2 = V4L2_PIX_FMT_BGRA32, + .bpp = 32, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_RGBX8888, + .v4l2 = V4L2_PIX_FMT_BGRX32, + .bpp = 32, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_ABGR8888, + .v4l2 = V4L2_PIX_FMT_RGBA32, + .bpp = 32, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_XBGR8888, + .v4l2 = V4L2_PIX_FMT_RGBX32, + .bpp = 32, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_BGRA8888, + .v4l2 = V4L2_PIX_FMT_ARGB32, + .bpp = 32, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_BGRX8888, + .v4l2 = V4L2_PIX_FMT_XRGB32, + .bpp = 32, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_RGBX1010102, + .v4l2 = V4L2_PIX_FMT_RGBX1010102, + .bpp = 32, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_RGBA1010102, + .v4l2 = V4L2_PIX_FMT_RGBA1010102, + .bpp = 32, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_ARGB2101010, + .v4l2 = V4L2_PIX_FMT_ARGB2101010, + .bpp = 32, + .planes = 1, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_YVYU, + .v4l2 = V4L2_PIX_FMT_YVYU, + .bpp = 16, + .planes = 1, + .hsub = 2, + }, { + .fourcc = DRM_FORMAT_NV61, + .v4l2 = V4L2_PIX_FMT_NV61M, + .bpp = 16, + .planes = 2, + .hsub = 2, + }, { + .fourcc = DRM_FORMAT_YUV420, + .v4l2 = V4L2_PIX_FMT_YUV420M, + .bpp = 12, + .planes = 3, + .hsub = 2, + }, { + .fourcc = DRM_FORMAT_YVU420, + .v4l2 = V4L2_PIX_FMT_YVU420M, + .bpp = 12, + .planes = 3, + .hsub = 2, + }, { + .fourcc = DRM_FORMAT_YUV422, + .v4l2 = V4L2_PIX_FMT_YUV422M, + .bpp = 16, + .planes = 3, + .hsub = 2, + }, { + .fourcc = DRM_FORMAT_YVU422, + .v4l2 = V4L2_PIX_FMT_YVU422M, + .bpp = 16, + .planes = 3, + .hsub = 2, + }, { + .fourcc = DRM_FORMAT_YUV444, + .v4l2 = V4L2_PIX_FMT_YUV444M, + .bpp = 24, + .planes = 3, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_YVU444, + .v4l2 = V4L2_PIX_FMT_YVU444M, + .bpp = 24, + .planes = 3, + .hsub = 1, + }, { + .fourcc = DRM_FORMAT_Y210, + .v4l2 = V4L2_PIX_FMT_Y210, + .bpp = 32, + .planes = 1, + .hsub = 2, + }, { + .fourcc = DRM_FORMAT_Y212, + .v4l2 = V4L2_PIX_FMT_Y212, + .bpp = 32, + .planes = 1, + .hsub = 2, + }, +}; + +const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc) +{ + unsigned int i; + + for (i = 0; i < ARRAY_SIZE(rcar_du_format_infos); ++i) { + if (rcar_du_format_infos[i].fourcc == fourcc) + return &rcar_du_format_infos[i]; + } + + return NULL; +} diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h new file mode 100644 index 000000000000..d72069436cac --- /dev/null +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h @@ -0,0 +1,27 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * R-Car Display Unit Mode Setting Lib + * + * Copyright (C) 2013-2023 Renesas Electronics Corporation + * + * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) + */ + +#ifndef __RCAR_DU_KMS_LIB_H__ +#define __RCAR_DU_KMS_LIB_H__ + +#include + +struct rcar_du_format_info { + u32 fourcc; + u32 v4l2; + unsigned int bpp; + unsigned int planes; + unsigned int hsub; + unsigned int pnmr; + unsigned int edf; +}; + +const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc); + +#endif /* __RCAR_DU_KMS_LIB_H__ */ From patchwork Tue Apr 11 11:42:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 672474 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8ED2CC77B73 for ; Tue, 11 Apr 2023 11:43:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230011AbjDKLn0 (ORCPT ); Tue, 11 Apr 2023 07:43:26 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52214 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbjDKLnN (ORCPT ); Tue, 11 Apr 2023 07:43:13 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id B7AD035B1; Tue, 11 Apr 2023 04:43:03 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,336,1673881200"; d="scan'208";a="155597319" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Apr 2023 20:43:02 +0900 Received: from localhost.localdomain (unknown [10.226.93.123]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 6D4014000A93; Tue, 11 Apr 2023 20:42:58 +0900 (JST) From: Biju Das To: David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v7 04/17] drm: rcar-du: Move rcar_du_vsp_atomic_begin() Date: Tue, 11 Apr 2023 12:42:22 +0100 Message-Id: <20230411114235.366042-5-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> References: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Move rcar_du_vsp_atomic_begin() to RCar DU VSP lib. Signed-off-by: Biju Das --- v6->v7: * Rebased to drm-tip. v1->v6: * Rebased on drm-misc-next and DU-next. v1: * Created the lib suggested by Laurent. Ref: https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220316131100.30685-6-biju.das.jz@bp.renesas.com/ --- drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 5 ----- drivers/gpu/drm/rcar-du/rcar_du_vsp.h | 2 -- drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c | 5 +++++ drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h | 2 ++ 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c index 3dab5fc822cf..66ada10fccd4 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c @@ -88,11 +88,6 @@ void rcar_du_vsp_enable(struct rcar_du_crtc *crtc) vsp1_du_setup_lif(crtc->vsp->vsp, crtc->vsp_pipe, &cfg); } -void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) -{ - vsp1_du_atomic_begin(crtc->vsp->vsp, crtc->vsp_pipe); -} - void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc) { struct vsp1_du_atomic_pipe_config cfg = { { 0, } }; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h index 8fbfa86c93e0..83a2f3e85860 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.h @@ -61,7 +61,6 @@ to_rcar_vsp_plane_state(struct drm_plane_state *state) int rcar_du_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, unsigned int crtcs); void rcar_du_vsp_enable(struct rcar_du_crtc *crtc); -void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc); void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc); int rcar_du_vsp_map_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb, struct sg_table sg_tables[3]); @@ -75,7 +74,6 @@ static inline int rcar_du_vsp_init(struct rcar_du_vsp *vsp, return -ENXIO; } static inline void rcar_du_vsp_enable(struct rcar_du_crtc *crtc) { }; -static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { }; static inline void rcar_du_vsp_atomic_flush(struct rcar_du_crtc *crtc) { }; static inline int rcar_du_vsp_map_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb, diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c index 374707b9cc12..a69e0842c98c 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c @@ -15,3 +15,8 @@ void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { vsp1_du_setup_lif(crtc->vsp->vsp, crtc->vsp_pipe, NULL); } + +void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) +{ + vsp1_du_atomic_begin(crtc->vsp->vsp, crtc->vsp_pipe); +} diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h index 55b026f20c46..e0077e832d01 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h @@ -12,8 +12,10 @@ #ifdef CONFIG_DRM_RCAR_VSP void rcar_du_vsp_disable(struct rcar_du_crtc *crtc); +void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc); #else static inline void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { }; +static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { }; #endif #endif /* __RCAR_DU_VSP_LIB_H__ */ From patchwork Tue Apr 11 11:42:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 672473 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 389CBC77B6F for ; Tue, 11 Apr 2023 11:43:52 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229822AbjDKLnv (ORCPT ); Tue, 11 Apr 2023 07:43:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53218 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229575AbjDKLnm (ORCPT ); Tue, 11 Apr 2023 07:43:42 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 3CEC749C5; Tue, 11 Apr 2023 04:43:18 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,336,1673881200"; d="scan'208";a="155597350" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Apr 2023 20:43:17 +0900 Received: from localhost.localdomain (unknown [10.226.93.123]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 78145400564A; Tue, 11 Apr 2023 20:43:13 +0900 (JST) From: Biju Das To: David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v7 07/17] drm: rcar-du: Move rcar_du_dumb_create() Date: Tue, 11 Apr 2023 12:42:25 +0100 Message-Id: <20230411114235.366042-8-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> References: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Move rcar_du_dumb_create() to RCar DU KMS lib. Signed-off-by: Biju Das --- v6->v7: * Rebased to drm-tip. v1->v6: * Rebased on drm-misc-next and DU-next. v1: * Created the lib suggested by Laurent. Ref: https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220316131100.30685-6-biju.das.jz@bp.renesas.com/ --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 21 ----------------- drivers/gpu/drm/rcar-du/rcar_du_kms.h | 5 ---- drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c | 28 +++++++++++++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h | 7 ++++++ 4 files changed, 35 insertions(+), 26 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 3141d447e979..4b5511a20313 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -81,27 +81,6 @@ struct drm_gem_object *rcar_du_gem_prime_import_sg_table(struct drm_device *dev, return gem_obj; } -int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, - struct drm_mode_create_dumb *args) -{ - struct rcar_du_device *rcdu = to_rcar_du_device(dev); - unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8); - unsigned int align; - - /* - * The R8A7779 DU requires a 16 pixels pitch alignment as documented, - * but the R8A7790 DU seems to require a 128 bytes pitch alignment. - */ - if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B)) - align = 128; - else - align = 16 * args->bpp / 8; - - args->pitch = roundup(min_pitch, align); - - return drm_gem_dma_dumb_create_internal(file, dev, args); -} - static struct drm_framebuffer * rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.h b/drivers/gpu/drm/rcar-du/rcar_du_kms.h index d2d4f34fe557..5490c99947fd 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.h @@ -13,18 +13,13 @@ #include "rcar_du_kms_lib.h" struct dma_buf_attachment; -struct drm_file; struct drm_device; struct drm_gem_object; -struct drm_mode_create_dumb; struct rcar_du_device; struct sg_table; int rcar_du_modeset_init(struct rcar_du_device *rcdu); -int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, - struct drm_mode_create_dumb *args); - struct drm_gem_object *rcar_du_gem_prime_import_sg_table(struct drm_device *dev, struct dma_buf_attachment *attach, struct sg_table *sgt); diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c index 5921040586fc..e88f753704cd 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c @@ -7,10 +7,13 @@ * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) */ +#include #include +#include #include +#include "rcar_du_drv.h" #include "rcar_du_kms.h" #include "rcar_du_regs.h" @@ -333,3 +336,28 @@ const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc) return NULL; } + +/* ----------------------------------------------------------------------------- + * Frame buffer + */ + +int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, + struct drm_mode_create_dumb *args) +{ + struct rcar_du_device *rcdu = to_rcar_du_device(dev); + unsigned int min_pitch = DIV_ROUND_UP(args->width * args->bpp, 8); + unsigned int align; + + /* + * The R8A7779 DU requires a 16 pixels pitch alignment as documented, + * but the R8A7790 DU seems to require a 128 bytes pitch alignment. + */ + if (rcar_du_needs(rcdu, RCAR_DU_QUIRK_ALIGN_128B)) + align = 128; + else + align = 16 * args->bpp / 8; + + args->pitch = roundup(min_pitch, align); + + return drm_gem_dma_dumb_create_internal(file, dev, args); +} diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h index d72069436cac..6e4cfe2ef867 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h @@ -12,6 +12,10 @@ #include +struct drm_device; +struct drm_file; +struct drm_mode_create_dumb; + struct rcar_du_format_info { u32 fourcc; u32 v4l2; @@ -24,4 +28,7 @@ struct rcar_du_format_info { const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc); +int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, + struct drm_mode_create_dumb *args); + #endif /* __RCAR_DU_KMS_LIB_H__ */ From patchwork Tue Apr 11 11:42:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 672472 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 31F77C76196 for ; Tue, 11 Apr 2023 11:43:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230037AbjDKLny (ORCPT ); Tue, 11 Apr 2023 07:43:54 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229973AbjDKLnq (ORCPT ); Tue, 11 Apr 2023 07:43:46 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 761A335B1; Tue, 11 Apr 2023 04:43:25 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,336,1673881200"; d="scan'208";a="155597359" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Apr 2023 20:43:23 +0900 Received: from localhost.localdomain (unknown [10.226.93.123]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 831FA4000A93; Tue, 11 Apr 2023 20:43:18 +0900 (JST) From: Biju Das To: David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v7 08/17] drm: rcar-du: Move rcar_du_gem_prime_import_sg_table() Date: Tue, 11 Apr 2023 12:42:26 +0100 Message-Id: <20230411114235.366042-9-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> References: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Move rcar_du_gem_prime_import_sg_table() to RCar DU KMS lib. Signed-off-by: Biju Das --- v6->v7: * Rebased to drm-tip. v1->v6: * Rebased on drm-misc-next and DU-next. v1: * Created the lib suggested by Laurent. Ref: https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220316131100.30685-6-biju.das.jz@bp.renesas.com/ --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 47 ----------------------- drivers/gpu/drm/rcar-du/rcar_du_kms.h | 8 ---- drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c | 46 ++++++++++++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h | 7 ++++ 4 files changed, 53 insertions(+), 55 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 4b5511a20313..ae969f640bb6 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -11,8 +11,6 @@ #include #include #include -#include -#include #include #include #include @@ -36,51 +34,6 @@ * Frame buffer */ -static const struct drm_gem_object_funcs rcar_du_gem_funcs = { - .free = drm_gem_dma_object_free, - .print_info = drm_gem_dma_object_print_info, - .get_sg_table = drm_gem_dma_object_get_sg_table, - .vmap = drm_gem_dma_object_vmap, - .mmap = drm_gem_dma_object_mmap, - .vm_ops = &drm_gem_dma_vm_ops, -}; - -struct drm_gem_object *rcar_du_gem_prime_import_sg_table(struct drm_device *dev, - struct dma_buf_attachment *attach, - struct sg_table *sgt) -{ - struct rcar_du_device *rcdu = to_rcar_du_device(dev); - struct drm_gem_dma_object *dma_obj; - struct drm_gem_object *gem_obj; - int ret; - - if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) - return drm_gem_dma_prime_import_sg_table(dev, attach, sgt); - - /* Create a DMA GEM buffer. */ - dma_obj = kzalloc(sizeof(*dma_obj), GFP_KERNEL); - if (!dma_obj) - return ERR_PTR(-ENOMEM); - - gem_obj = &dma_obj->base; - gem_obj->funcs = &rcar_du_gem_funcs; - - drm_gem_private_object_init(dev, gem_obj, attach->dmabuf->size); - dma_obj->map_noncoherent = false; - - ret = drm_gem_create_mmap_offset(gem_obj); - if (ret) { - drm_gem_object_release(gem_obj); - kfree(dma_obj); - return ERR_PTR(ret); - } - - dma_obj->dma_addr = 0; - dma_obj->sgt = sgt; - - return gem_obj; -} - static struct drm_framebuffer * rcar_du_fb_create(struct drm_device *dev, struct drm_file *file_priv, const struct drm_mode_fb_cmd2 *mode_cmd) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.h b/drivers/gpu/drm/rcar-du/rcar_du_kms.h index 5490c99947fd..02ba7c1c7a70 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.h @@ -12,16 +12,8 @@ #include "rcar_du_kms_lib.h" -struct dma_buf_attachment; -struct drm_device; -struct drm_gem_object; struct rcar_du_device; -struct sg_table; int rcar_du_modeset_init(struct rcar_du_device *rcdu); -struct drm_gem_object *rcar_du_gem_prime_import_sg_table(struct drm_device *dev, - struct dma_buf_attachment *attach, - struct sg_table *sgt); - #endif /* __RCAR_DU_KMS_H__ */ diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c index e88f753704cd..37809d06df89 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c @@ -10,6 +10,7 @@ #include #include #include +#include #include @@ -341,6 +342,51 @@ const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc) * Frame buffer */ +static const struct drm_gem_object_funcs rcar_du_gem_funcs = { + .free = drm_gem_dma_object_free, + .print_info = drm_gem_dma_object_print_info, + .get_sg_table = drm_gem_dma_object_get_sg_table, + .vmap = drm_gem_dma_object_vmap, + .mmap = drm_gem_dma_object_mmap, + .vm_ops = &drm_gem_dma_vm_ops, +}; + +struct drm_gem_object *rcar_du_gem_prime_import_sg_table(struct drm_device *dev, + struct dma_buf_attachment *attach, + struct sg_table *sgt) +{ + struct rcar_du_device *rcdu = to_rcar_du_device(dev); + struct drm_gem_dma_object *dma_obj; + struct drm_gem_object *gem_obj; + int ret; + + if (!rcar_du_has(rcdu, RCAR_DU_FEATURE_VSP1_SOURCE)) + return drm_gem_dma_prime_import_sg_table(dev, attach, sgt); + + /* Create a DMA GEM buffer. */ + dma_obj = kzalloc(sizeof(*dma_obj), GFP_KERNEL); + if (!dma_obj) + return ERR_PTR(-ENOMEM); + + gem_obj = &dma_obj->base; + gem_obj->funcs = &rcar_du_gem_funcs; + + drm_gem_private_object_init(dev, gem_obj, attach->dmabuf->size); + dma_obj->map_noncoherent = false; + + ret = drm_gem_create_mmap_offset(gem_obj); + if (ret) { + drm_gem_object_release(gem_obj); + kfree(dma_obj); + return ERR_PTR(ret); + } + + dma_obj->dma_addr = 0; + dma_obj->sgt = sgt; + + return gem_obj; +} + int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args) { diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h index 6e4cfe2ef867..2556966024f8 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h @@ -12,9 +12,12 @@ #include +struct dma_buf_attachment; struct drm_device; struct drm_file; +struct drm_gem_object; struct drm_mode_create_dumb; +struct sg_table; struct rcar_du_format_info { u32 fourcc; @@ -31,4 +34,8 @@ const struct rcar_du_format_info *rcar_du_format_info(u32 fourcc); int rcar_du_dumb_create(struct drm_file *file, struct drm_device *dev, struct drm_mode_create_dumb *args); +struct drm_gem_object *rcar_du_gem_prime_import_sg_table(struct drm_device *dev, + struct dma_buf_attachment *attach, + struct sg_table *sgt); + #endif /* __RCAR_DU_KMS_LIB_H__ */ From patchwork Tue Apr 11 11:42:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 672471 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42C44C77B76 for ; Tue, 11 Apr 2023 11:44:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229782AbjDKLoP (ORCPT ); Tue, 11 Apr 2023 07:44:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53296 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229716AbjDKLoN (ORCPT ); Tue, 11 Apr 2023 07:44:13 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 31D7A46B9; Tue, 11 Apr 2023 04:43:47 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,336,1673881200"; d="scan'208";a="159045224" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 Apr 2023 20:43:32 +0900 Received: from localhost.localdomain (unknown [10.226.93.123]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 8262A4000A93; Tue, 11 Apr 2023 20:43:28 +0900 (JST) From: Biju Das To: David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v7 10/17] drm: rcar-du: Move rcar_du_vsp_plane_prepare_fb() Date: Tue, 11 Apr 2023 12:42:28 +0100 Message-Id: <20230411114235.366042-11-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> References: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Move rcar_du_vsp_plane_prepare_fb() to RCar DU vsp lib so that both RCar and RZ/G2L DU vsp drivers can share this function. Signed-off-by: Biju Das --- v6->v7: * Rebased to drm-tip. v1->v6: * Rebased on drm-misc-next and DU-next. v1: * Created the lib suggested by Laurent. Ref: https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220316131100.30685-6-biju.das.jz@bp.renesas.com/ --- drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 21 --------------------- drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c | 21 +++++++++++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h | 8 ++++++++ 3 files changed, 29 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c index e54a605a1bdf..3abc5031112e 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c @@ -139,27 +139,6 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) plane->index, &cfg); } -static int rcar_du_vsp_plane_prepare_fb(struct drm_plane *plane, - struct drm_plane_state *state) -{ - struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state); - struct rcar_du_vsp *vsp = to_rcar_vsp_plane(plane)->vsp; - int ret; - - /* - * There's no need to prepare (and unprepare) the framebuffer when the - * plane is not visible, as it will not be displayed. - */ - if (!state->visible) - return 0; - - ret = rcar_du_vsp_map_fb(vsp, state->fb, rstate->sg_tables); - if (ret < 0) - return ret; - - return drm_gem_plane_helper_prepare_fb(plane, state); -} - static void rcar_du_vsp_plane_cleanup_fb(struct drm_plane *plane, struct drm_plane_state *state) { diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c index f2d55695f6c1..91259d44efe9 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c @@ -177,6 +177,27 @@ int rcar_du_vsp_map_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb, return ret; } +int rcar_du_vsp_plane_prepare_fb(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state); + struct rcar_du_vsp *vsp = to_rcar_vsp_plane(plane)->vsp; + int ret; + + /* + * There's no need to prepare (and unprepare) the framebuffer when the + * plane is not visible, as it will not be displayed. + */ + if (!state->visible) + return 0; + + ret = rcar_du_vsp_map_fb(vsp, state->fb, rstate->sg_tables); + if (ret < 0) + return ret; + + return drm_gem_plane_helper_prepare_fb(plane, state); +} + void rcar_du_vsp_unmap_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb, struct sg_table sg_tables[3]) { diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h index 2ced23132db2..3d3a7735facd 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h @@ -25,6 +25,8 @@ void rcar_du_vsp_unmap_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb, int rcar_du_lib_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, unsigned int crtcs, const struct drm_plane_helper_funcs *rcar_du_vsp_plane_helper_funcs); +int rcar_du_vsp_plane_prepare_fb(struct drm_plane *plane, + struct drm_plane_state *state); #else static inline void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { }; static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { }; @@ -49,6 +51,12 @@ rcar_du_lib_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, { return -ENXIO; } + +static inline int rcar_du_vsp_plane_prepare_fb(struct drm_plane *plane, + struct drm_plane_state *state) +{ + return -ENXIO; +} #endif #endif /* __RCAR_DU_VSP_LIB_H__ */ From patchwork Tue Apr 11 11:42:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 672470 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E19AC77B6F for ; Tue, 11 Apr 2023 11:44:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230008AbjDKLog (ORCPT ); Tue, 11 Apr 2023 07:44:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230087AbjDKLoc (ORCPT ); Tue, 11 Apr 2023 07:44:32 -0400 Received: from relmlie6.idc.renesas.com (relmlor2.renesas.com [210.160.252.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id EA35749FA; Tue, 11 Apr 2023 04:44:03 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,336,1673881200"; d="scan'208";a="159045229" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie6.idc.renesas.com with ESMTP; 11 Apr 2023 20:43:37 +0900 Received: from localhost.localdomain (unknown [10.226.93.123]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id 7D697400195D; Tue, 11 Apr 2023 20:43:33 +0900 (JST) From: Biju Das To: David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v7 11/17] drm: rcar-du: Move rcar_du_vsp_plane_cleanup_fb() Date: Tue, 11 Apr 2023 12:42:29 +0100 Message-Id: <20230411114235.366042-12-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> References: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Move rcar_du_vsp_plane_cleanup_fb() to RCar DU vsp lib so that it can be shared by both RCar and RZ/G2L DU vsp drivers. Signed-off-by: Biju Das --- v6->v7: * Rebased to drm-tip. v1->v6: * Rebased on drm-misc-next and DU-next. v1: * Created the lib suggested by Laurent. Ref: https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220316131100.30685-6-biju.das.jz@bp.renesas.com/ --- drivers/gpu/drm/rcar-du/rcar_du_vsp.c | 12 ------------ drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c | 12 ++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h | 7 +++++++ 3 files changed, 19 insertions(+), 12 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c index 3abc5031112e..d785654e4aa3 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp.c @@ -139,18 +139,6 @@ static void rcar_du_vsp_plane_setup(struct rcar_du_vsp_plane *plane) plane->index, &cfg); } -static void rcar_du_vsp_plane_cleanup_fb(struct drm_plane *plane, - struct drm_plane_state *state) -{ - struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state); - struct rcar_du_vsp *vsp = to_rcar_vsp_plane(plane)->vsp; - - if (!state->visible) - return; - - rcar_du_vsp_unmap_fb(vsp, state->fb, rstate->sg_tables); -} - static int rcar_du_vsp_plane_atomic_check(struct drm_plane *plane, struct drm_atomic_state *state) { diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c index 91259d44efe9..9240c56ec40f 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.c @@ -211,6 +211,18 @@ void rcar_du_vsp_unmap_fb(struct rcar_du_vsp *vsp, struct drm_framebuffer *fb, } } +void rcar_du_vsp_plane_cleanup_fb(struct drm_plane *plane, + struct drm_plane_state *state) +{ + struct rcar_du_vsp_plane_state *rstate = to_rcar_vsp_plane_state(state); + struct rcar_du_vsp *vsp = to_rcar_vsp_plane(plane)->vsp; + + if (!state->visible) + return; + + rcar_du_vsp_unmap_fb(vsp, state->fb, rstate->sg_tables); +} + static struct drm_plane_state * rcar_du_vsp_plane_atomic_duplicate_state(struct drm_plane *plane) { diff --git a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h index 3d3a7735facd..efd2bb36c88b 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_vsp_lib.h @@ -27,6 +27,8 @@ int rcar_du_lib_vsp_init(struct rcar_du_vsp *vsp, struct device_node *np, const struct drm_plane_helper_funcs *rcar_du_vsp_plane_helper_funcs); int rcar_du_vsp_plane_prepare_fb(struct drm_plane *plane, struct drm_plane_state *state); +void rcar_du_vsp_plane_cleanup_fb(struct drm_plane *plane, + struct drm_plane_state *state); #else static inline void rcar_du_vsp_disable(struct rcar_du_crtc *crtc) { }; static inline void rcar_du_vsp_atomic_begin(struct rcar_du_crtc *crtc) { }; @@ -57,6 +59,11 @@ static inline int rcar_du_vsp_plane_prepare_fb(struct drm_plane *plane, { return -ENXIO; } + +static inline void rcar_du_vsp_plane_cleanup_fb(struct drm_plane *plane, + struct drm_plane_state *state) +{ +} #endif #endif /* __RCAR_DU_VSP_LIB_H__ */ From patchwork Tue Apr 11 11:42:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 672469 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE38EC76196 for ; Tue, 11 Apr 2023 11:44:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229506AbjDKLon (ORCPT ); Tue, 11 Apr 2023 07:44:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54522 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229676AbjDKLoj (ORCPT ); Tue, 11 Apr 2023 07:44:39 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 46E9B421E; Tue, 11 Apr 2023 04:44:17 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,336,1673881200"; d="scan'208";a="155597402" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Apr 2023 20:43:58 +0900 Received: from localhost.localdomain (unknown [10.226.93.123]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id CDE394000A93; Tue, 11 Apr 2023 20:43:53 +0900 (JST) From: Biju Das To: David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v7 15/17] drm: rcar-du: Move rcar_du_encoders_init() Date: Tue, 11 Apr 2023 12:42:33 +0100 Message-Id: <20230411114235.366042-16-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> References: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org RZ/G2L supports only DSI and DPI. Add rcar_du_encoders_init() to handle the pointer to du_output_name(), so that we can share du_encoders_init() between RCar and RZ/G2L kms drivers. Signed-off-by: Biju Das --- v6->v7: * Rebased to drm-tip. v1->v6: * Rebased on drm-misc-next and DU-next. v1: * Created the lib suggested by Laurent. Ref: https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220316131100.30685-6-biju.das.jz@bp.renesas.com/ --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 92 +------------------ drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c | 102 ++++++++++++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h | 6 ++ 3 files changed, 110 insertions(+), 90 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index b0b40b1cc37d..94f1602ea707 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -69,95 +69,6 @@ static const struct drm_mode_config_funcs rcar_du_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; -static int rcar_du_encoders_init_one(struct rcar_du_device *rcdu, - enum rcar_du_output output, - struct of_endpoint *ep) -{ - struct device_node *entity; - int ret; - - /* Locate the connected entity and initialize the encoder. */ - entity = of_graph_get_remote_port_parent(ep->local_node); - if (!entity) { - dev_dbg(rcdu->dev, "unconnected endpoint %pOF, skipping\n", - ep->local_node); - return -ENODEV; - } - - if (!of_device_is_available(entity)) { - dev_dbg(rcdu->dev, - "connected entity %pOF is disabled, skipping\n", - entity); - of_node_put(entity); - return -ENODEV; - } - - ret = rcar_du_encoder_init(rcdu, output, entity); - if (ret && ret != -EPROBE_DEFER && ret != -ENOLINK) - dev_warn(rcdu->dev, - "failed to initialize encoder %pOF on output %s (%d), skipping\n", - entity, rcar_du_output_name(output), ret); - - of_node_put(entity); - - return ret; -} - -static int rcar_du_encoders_init(struct rcar_du_device *rcdu) -{ - struct device_node *np = rcdu->dev->of_node; - struct device_node *ep_node; - unsigned int num_encoders = 0; - - /* - * Iterate over the endpoints and create one encoder for each output - * pipeline. - */ - for_each_endpoint_of_node(np, ep_node) { - enum rcar_du_output output; - struct of_endpoint ep; - unsigned int i; - int ret; - - ret = of_graph_parse_endpoint(ep_node, &ep); - if (ret < 0) { - of_node_put(ep_node); - return ret; - } - - /* Find the output route corresponding to the port number. */ - for (i = 0; i < RCAR_DU_OUTPUT_MAX; ++i) { - if (rcdu->info->routes[i].possible_crtcs && - rcdu->info->routes[i].port == ep.port) { - output = i; - break; - } - } - - if (i == RCAR_DU_OUTPUT_MAX) { - dev_warn(rcdu->dev, - "port %u references unexisting output, skipping\n", - ep.port); - continue; - } - - /* Process the output pipeline. */ - ret = rcar_du_encoders_init_one(rcdu, output, &ep); - if (ret < 0) { - if (ret == -EPROBE_DEFER) { - of_node_put(ep_node); - return ret; - } - - continue; - } - - num_encoders++; - } - - return num_encoders; -} - static int rcar_du_properties_init(struct rcar_du_device *rcdu) { /* @@ -457,7 +368,8 @@ int rcar_du_modeset_init(struct rcar_du_device *rcdu) } /* Initialize the encoders. */ - ret = rcar_du_encoders_init(rcdu); + ret = rcar_du_encoders_init(rcdu, rcar_du_output_name, + rcar_du_encoder_init); if (ret < 0) return ret; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c index 13d033009c9f..781e666a45a8 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c @@ -15,6 +15,8 @@ #include #include +#include +#include #include #include "rcar_du_drv.h" @@ -535,3 +537,103 @@ rcar_du_lib_mode_cfg_helper_get(void) { return &rcar_du_mode_config_helper; } + +static int +rcar_du_encoders_init_one(struct rcar_du_device *rcdu, + enum rcar_du_output output, + struct of_endpoint *ep, + const char *output_name, + int (*rcar_du_encoder_init_fn)(struct rcar_du_device *r, + enum rcar_du_output op, + struct device_node *d)) +{ + struct device_node *entity; + int ret; + + /* Locate the connected entity and initialize the encoder. */ + entity = of_graph_get_remote_port_parent(ep->local_node); + if (!entity) { + dev_dbg(rcdu->dev, "unconnected endpoint %pOF, skipping\n", + ep->local_node); + return -ENODEV; + } + + if (!of_device_is_available(entity)) { + dev_dbg(rcdu->dev, + "connected entity %pOF is disabled, skipping\n", + entity); + of_node_put(entity); + return -ENODEV; + } + + ret = rcar_du_encoder_init_fn(rcdu, output, entity); + if (ret && ret != -EPROBE_DEFER && ret != -ENOLINK) + dev_warn(rcdu->dev, + "failed to initialize encoder %pOF on output %s (%d), skipping\n", + entity, output_name, ret); + + of_node_put(entity); + + return ret; +} + +int rcar_du_encoders_init(struct rcar_du_device *rcdu, + const char* (*out_name)(enum rcar_du_output output), + int (*encoder_init_fn)(struct rcar_du_device *rcdu, + enum rcar_du_output output, + struct device_node *enc_node)) +{ + struct device_node *np = rcdu->dev->of_node; + struct device_node *ep_node; + unsigned int num_encoders = 0; + + /* + * Iterate over the endpoints and create one encoder for each output + * pipeline. + */ + for_each_endpoint_of_node(np, ep_node) { + enum rcar_du_output output; + struct of_endpoint ep; + unsigned int i; + int ret; + + ret = of_graph_parse_endpoint(ep_node, &ep); + if (ret < 0) { + of_node_put(ep_node); + return ret; + } + + /* Find the output route corresponding to the port number. */ + for (i = 0; i < RCAR_DU_OUTPUT_MAX; ++i) { + if (rcdu->info->routes[i].possible_crtcs && + rcdu->info->routes[i].port == ep.port) { + output = i; + break; + } + } + + if (i == RCAR_DU_OUTPUT_MAX) { + dev_warn(rcdu->dev, + "port %u references unexisting output, skipping\n", + ep.port); + continue; + } + + /* Process the output pipeline. */ + ret = rcar_du_encoders_init_one(rcdu, output, &ep, + out_name(output), + encoder_init_fn); + if (ret < 0) { + if (ret == -EPROBE_DEFER) { + of_node_put(ep_node); + return ret; + } + + continue; + } + + num_encoders++; + } + + return num_encoders; +} diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h index be36b98b2d5d..ace973b80fe6 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h @@ -45,4 +45,10 @@ rcar_du_lib_fb_create(struct drm_device *dev, struct drm_file *file_priv, const struct drm_mode_config_helper_funcs * rcar_du_lib_mode_cfg_helper_get(void); +int rcar_du_encoders_init(struct rcar_du_device *rcdu, + const char* (*out_name)(enum rcar_du_output output), + int (*encoder_init_fn)(struct rcar_du_device *rcdu, + enum rcar_du_output output, + struct device_node *enc_node)); + #endif /* __RCAR_DU_KMS_LIB_H__ */ From patchwork Tue Apr 11 11:42:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Biju Das X-Patchwork-Id: 672468 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6411DC77B70 for ; Tue, 11 Apr 2023 11:45:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230102AbjDKLpC (ORCPT ); Tue, 11 Apr 2023 07:45:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230123AbjDKLpB (ORCPT ); Tue, 11 Apr 2023 07:45:01 -0400 Received: from relmlie5.idc.renesas.com (relmlor1.renesas.com [210.160.252.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 46E3146AB; Tue, 11 Apr 2023 04:44:39 -0700 (PDT) X-IronPort-AV: E=Sophos;i="5.98,336,1673881200"; d="scan'208";a="155597425" Received: from unknown (HELO relmlir5.idc.renesas.com) ([10.200.68.151]) by relmlie5.idc.renesas.com with ESMTP; 11 Apr 2023 20:44:03 +0900 Received: from localhost.localdomain (unknown [10.226.93.123]) by relmlir5.idc.renesas.com (Postfix) with ESMTP id D7C51400195D; Tue, 11 Apr 2023 20:43:58 +0900 (JST) From: Biju Das To: David Airlie , Daniel Vetter , Mauro Carvalho Chehab , Rob Herring , Krzysztof Kozlowski Cc: Biju Das , Laurent Pinchart , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-media@vger.kernel.org, Geert Uytterhoeven , Chris Paterson , Prabhakar Mahadev Lad , linux-renesas-soc@vger.kernel.org Subject: [PATCH v7 16/17] drm: rcar-du: Move rcar_du_properties_init() Date: Tue, 11 Apr 2023 12:42:34 +0100 Message-Id: <20230411114235.366042-17-biju.das.jz@bp.renesas.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> References: <20230411114235.366042-1-biju.das.jz@bp.renesas.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: devicetree@vger.kernel.org Move rcar_du_properties_init() to RCar DU kms lib, so that it can be shared by both RCar and RZ/G2L kms drivers. Signed-off-by: Biju Das --- v6->v7: * Rebased to drm-tip. v1->v6: * Rebased on drm-misc-next and DU-next. v1: * Created the lib suggested by Laurent. Ref: https://patchwork.kernel.org/project/linux-renesas-soc/patch/20220316131100.30685-6-biju.das.jz@bp.renesas.com/ --- drivers/gpu/drm/rcar-du/rcar_du_kms.c | 16 ---------------- drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c | 16 ++++++++++++++++ drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h | 2 ++ 3 files changed, 18 insertions(+), 16 deletions(-) diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms.c b/drivers/gpu/drm/rcar-du/rcar_du_kms.c index 94f1602ea707..01ffe36f9d44 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms.c @@ -69,22 +69,6 @@ static const struct drm_mode_config_funcs rcar_du_mode_config_funcs = { .atomic_commit = drm_atomic_helper_commit, }; -static int rcar_du_properties_init(struct rcar_du_device *rcdu) -{ - /* - * The color key is expressed as an RGB888 triplet stored in a 32-bit - * integer in XRGB8888 format. Bit 24 is used as a flag to disable (0) - * or enable source color keying (1). - */ - rcdu->props.colorkey = - drm_property_create_range(&rcdu->ddev, 0, "colorkey", - 0, 0x01ffffff); - if (rcdu->props.colorkey == NULL) - return -ENOMEM; - - return 0; -} - static int rcar_du_vsps_init(struct rcar_du_device *rcdu) { const struct device_node *np = rcdu->dev->of_node; diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c index 781e666a45a8..438a56c550f2 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.c @@ -637,3 +637,19 @@ int rcar_du_encoders_init(struct rcar_du_device *rcdu, return num_encoders; } + +int rcar_du_properties_init(struct rcar_du_device *rcdu) +{ + /* + * The color key is expressed as an RGB888 triplet stored in a 32-bit + * integer in XRGB8888 format. Bit 24 is used as a flag to disable (0) + * or enable source color keying (1). + */ + rcdu->props.colorkey = + drm_property_create_range(&rcdu->ddev, 0, "colorkey", + 0, 0x01ffffff); + if (rcdu->props.colorkey == NULL) + return -ENOMEM; + + return 0; +} diff --git a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h index ace973b80fe6..50e92a19d98c 100644 --- a/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h +++ b/drivers/gpu/drm/rcar-du/rcar_du_kms_lib.h @@ -51,4 +51,6 @@ int rcar_du_encoders_init(struct rcar_du_device *rcdu, enum rcar_du_output output, struct device_node *enc_node)); +int rcar_du_properties_init(struct rcar_du_device *rcdu); + #endif /* __RCAR_DU_KMS_LIB_H__ */