From patchwork Mon Jun 21 06:27:39 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esaki Tomohito X-Patchwork-Id: 12333853 X-Patchwork-Delegate: kieran@bingham.xyz Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A9528C48BE5 for ; Mon, 21 Jun 2021 06:29:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9247661003 for ; Mon, 21 Jun 2021 06:29:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229897AbhFUGbu (ORCPT ); Mon, 21 Jun 2021 02:31:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34182 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230217AbhFUGbt (ORCPT ); Mon, 21 Jun 2021 02:31:49 -0400 Received: from mail-pj1-x1030.google.com (mail-pj1-x1030.google.com [IPv6:2607:f8b0:4864:20::1030]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 15F56C061756 for ; Sun, 20 Jun 2021 23:29:36 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id m15-20020a17090a5a4fb029016f385ffad0so6810732pji.0 for ; Sun, 20 Jun 2021 23:29:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=igel-co-jp.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=bgNlaTTHI6FGIUQBf975d3hWly9RgBTgrQeNsOVl2x8=; b=HcFdfJgagqNBu8WULVIxAIPFd4P21WEZaTueO9j/jcnj7XQxEjY/JnPSG5yiUk9E4x oXM+0htexTTxnS7YnTehEwjrX9G6K00SZUI4alD+R0KAcFS6VZhEg+sU5oVluIRdFSOF EvEcfQWJEyzDbej0EaoX4SZKU34XRLnWVxsxHzF12NYMgjm2tMTuWQrhoWZUURadPhdr vF8ArgTiPIXujwmV1TeE7iVVOq98sk+UVFHHY/6nQiiHjpDC12KtO7i+OeEtCSwrDFn2 PUY1VUCDkeJ1EuQzBj9mcgVWE+XTda51h1SuLLBcDhictjj8mlgZfwtrVEEEMuy1VRzA Iv9g== 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:mime-version:content-transfer-encoding; bh=bgNlaTTHI6FGIUQBf975d3hWly9RgBTgrQeNsOVl2x8=; b=cMRRsBHoWQLaQtMhlgFZn9oV5tqdlGZzXV6YPoCi2a2dhW6PSC8sX67TdqPX7Q9mM2 OP+1mfajMBqGcWvLDSOuZTeLPMRqjQ3j3Z1CR9ALKE1UwOtXS5ch+4SNEWx+ZuVF1w+t k/cq0+tYfXBZ4gN5QGxhi5K9lAxJQwKae/TngOtab4MnbISJo/Zl324980Fv4paV2N4D U2yvUJ+SA4OCGtBYciYdmI+4GaQlwj3g3Tfg8gUM5NnduQQYxaXMMeWxwmt8MfF3Z+NS pr+X8PyK0/gSESDMGOdwoYgvgREyM+HZ8+JCJZTrHe1EqozZFPcAXDohweUK2A/appUX LCpg== X-Gm-Message-State: AOAM530pERqNlpCmon4PTEM/Yk/Wb3d86PuNH1Cz8pYb4IwTw6qP8trt 7vilTC+wm/t6FaQUf5Z+YtQcWg== X-Google-Smtp-Source: ABdhPJylpJ0LtmqsKd6MekCnTAWpQ3GnGaf2kvxhje0NQWxgxO/i/PsTfkLnZz/wy1Vf+XbP1vQWVA== X-Received: by 2002:a17:90a:2f41:: with SMTP id s59mr25971374pjd.19.1624256975520; Sun, 20 Jun 2021 23:29:35 -0700 (PDT) Received: from localhost.localdomain ([240b:10:c9a0:ca00:61b8:26ec:dc30:8823]) by smtp.gmail.com with ESMTPSA id j19sm15266018pgm.44.2021.06.20.23.29.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jun 2021 23:29:34 -0700 (PDT) From: Tomohito Esaki To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Laurent Pinchart , Kieran Bingham Cc: dri-devlel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-doc@vger.kernel.org, Tomohito Esaki Subject: [PATH 1/4] drm: Add Virtual DRM device driver Date: Mon, 21 Jun 2021 15:27:39 +0900 Message-Id: <20210621062742.26073-2-etom@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621062742.26073-1-etom@igel.co.jp> References: <20210621062742.26073-1-etom@igel.co.jp> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-renesas-soc@vger.kernel.org Virtual DRM splits the resources of an overlay plane into multiple virtual devices to allow each plane to be accessed by each process. This makes it possible to overlay images output from multiple processes on a display. For example, one process displays the camera image without compositor while another process overlays the compositor's drawing of the UI. The virtual DRM creates standalone virtual device and make DRM planes from a master device (e.g. card0) accessible via one or more virtual devices. However, these plane are no longer accessible from the original device. Each virtual device (and plane) can be accessed via a separate device file. Signed-off-by: Tomohito Esaki --- drivers/gpu/drm/Kconfig | 7 + drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/vdrm/vdrm_api.h | 68 +++ drivers/gpu/drm/vdrm/vdrm_drv.c | 859 ++++++++++++++++++++++++++++++++ drivers/gpu/drm/vdrm/vdrm_drv.h | 80 +++ 5 files changed, 1015 insertions(+) create mode 100644 drivers/gpu/drm/vdrm/vdrm_api.h create mode 100644 drivers/gpu/drm/vdrm/vdrm_drv.c create mode 100644 drivers/gpu/drm/vdrm/vdrm_drv.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 3c16bd1afd87..ba7f4eeab385 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -294,6 +294,13 @@ config DRM_VKMS If M is selected the module will be called vkms. +config DRM_VDRM + tristate "Virtual DRM" + depends on DRM + help + Virtual DRM splits the resources of an overlay plane into multiple + virtual devices to allow each plane to be accessed by each process. + source "drivers/gpu/drm/exynos/Kconfig" source "drivers/gpu/drm/rockchip/Kconfig" diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 5279db4392df..55dbf85e2579 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -82,6 +82,7 @@ obj-$(CONFIG_DRM_VMWGFX)+= vmwgfx/ obj-$(CONFIG_DRM_VIA) +=via/ obj-$(CONFIG_DRM_VGEM) += vgem/ obj-$(CONFIG_DRM_VKMS) += vkms/ +obj-$(CONFIG_DRM_VDRM) += vdrm/ obj-$(CONFIG_DRM_NOUVEAU) +=nouveau/ obj-$(CONFIG_DRM_EXYNOS) +=exynos/ obj-$(CONFIG_DRM_ROCKCHIP) +=rockchip/ diff --git a/drivers/gpu/drm/vdrm/vdrm_api.h b/drivers/gpu/drm/vdrm/vdrm_api.h new file mode 100644 index 000000000000..dd4d7e774800 --- /dev/null +++ b/drivers/gpu/drm/vdrm/vdrm_api.h @@ -0,0 +1,68 @@ +/* SPDX-License-Identifier: GPL-2.0+ */ +/* + * vdrm_api.h -- Virtual DRM API + * + * Copyright (C) 2021 Renesas Electronics Corporation + */ + +#ifndef __VDRM_API__ +#define __VDRM_API__ + +#include +#include + +/** + * struct vdrm_property_info - Information about the properties passed from + * the DRM driver to vDRM + * @prop: Parent property to pass to vDRM + * @default_val: Default value for the property passed to vDRM + */ +struct vdrm_property_info { + struct drm_property *prop; + uint64_t default_val; +}; + +/** + * struct vdrm_funcs - Callbacks to parent DRM driver + */ +struct vdrm_funcs { + /** + * @dumb_create: + * + * Called by &drm_driver.dumb_create. Please read the documentation + * for the &drm_driver.dumb_create hook for more details. + */ + int (*dumb_create)(struct drm_file *file, struct drm_device *dev, + struct drm_mode_create_dumb *args); + + /** + * @crtc_flush: + * + * Called by &drm_crtc_helper_funcs.atomic_flush. Please read the + * documentation for the &drm_crtc_helper_funcs.atomic_flush hook for + * more details. + */ + void (*crtc_flush)(struct drm_crtc *crtc); +}; + +struct vdrm_device; +struct vdrm_display; + +void vdrm_drv_handle_vblank(struct vdrm_display *vdisplay); +void vdrm_drv_finish_page_flip(struct vdrm_display *vdisplay); +struct vdrm_device *vdrm_drv_init(struct drm_device *dev, + struct device_node *np, int num_props, + struct vdrm_property_info *props, + const struct vdrm_funcs *funcs); +int vdrm_drv_plane_init(struct vdrm_device *vdrm, struct drm_plane *plane, + const struct drm_plane_funcs *funcs, + const struct drm_plane_helper_funcs *helper_funcs, + const u32 *formats, unsigned int num_formats, + int max_zpos); +struct vdrm_display *vdrm_drv_display_init(struct vdrm_device *vdrm, + struct drm_crtc *crtc, + struct drm_plane *plane); +int vdrm_drv_register(struct vdrm_device *vdrm); +void vdrm_drv_fini(struct vdrm_device *vdrm); + +#endif /* __VDRM_API__ */ diff --git a/drivers/gpu/drm/vdrm/vdrm_drv.c b/drivers/gpu/drm/vdrm/vdrm_drv.c new file mode 100644 index 000000000000..835bdecfc8e6 --- /dev/null +++ b/drivers/gpu/drm/vdrm/vdrm_drv.c @@ -0,0 +1,859 @@ +// SPDX-License-Identifier: GPL-2.0+ +/* + * vdrm_drv.c -- Virtual DRM driver + * + * Copyright (C) 2021 Renesas Electronics Corporation + * + * This driver is based on drivers/gpu/drm/drm_simple_kms_helper.c. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include