Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3513034pxj; Sun, 20 Jun 2021 23:45:34 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzk6kUnMSH2Hz0MSNKzUolmvDwCVhHHF8wuoQrjR5SC/XoJ0tftxh4oPcqJImE2qi59FK73 X-Received: by 2002:a6b:f20c:: with SMTP id q12mr12389737ioh.72.1624257934682; Sun, 20 Jun 2021 23:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624257934; cv=none; d=google.com; s=arc-20160816; b=NOShjymQO7F+TPih2qiDl5MPco4CBLB8I7ATAcLgQvl6HAtE/XMhY0IrhPP7G7Nu4V bNsJAcFTqozhJBPLW32Ntj5q2HsS8mwNGtCk4/VuCoeMyAbbLtc/QOgIblzYNckXjUdy eAV30nhYqY8uo3PycXWJ5BQx9i5M3zGFXVL5muGhdMDmZGHW9gmcqTYZvubogN/UxRTr hU3P8hv7b7Hq1B8khMJT9U351eX/sWTOmHvtDso4yzi9/fx0uGM5kT/loAtLeaWdY/OE lW1Ej1qKgliRkVqHH+VdJX76/HZTx4EBDC9pMGwCMadcd7Oo/whi17Kqm/o7ShZizTOT ZB9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bgNlaTTHI6FGIUQBf975d3hWly9RgBTgrQeNsOVl2x8=; b=dAKUWZzEWWkOYa42tpvoABqbq6Lu/e4x15MOrCJsY1NB1hRqYmPefvNiM3dpj5eOxe L5MZmZri6fB6UpNwIn47FTgo9DL71YzjAZdeGurMkiHmUPaJPfTg9/Xux5Ha/6whjhFE 3xEX4TsEHgCWf2oo7l6Otibs/vdXrci/FVlYm2KlPs6vJsI6LEkFNQjVLUdH48eK3pdh udszlnjuWZsWuUYyY1QR8MqDz8sv92dD4yTKzu8rzGb/86aLwbbkCBosmfkS3ChpmV/K nHWorQpptJfsljMvD+/dYy2VSIkAx1mBT0UNQHiFaFqMlVWrtdhsQBn0rsMgoaEiPh/s 7Sxg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@igel-co-jp.20150623.gappssmtp.com header.s=20150623 header.b=zTaDLAlj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y12si13357436jap.126.2021.06.20.23.45.21; Sun, 20 Jun 2021 23:45:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@igel-co-jp.20150623.gappssmtp.com header.s=20150623 header.b=zTaDLAlj; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230013AbhFUGqx (ORCPT + 99 others); Mon, 21 Jun 2021 02:46:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37590 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230031AbhFUGqv (ORCPT ); Mon, 21 Jun 2021 02:46:51 -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 4830DC061574 for ; Sun, 20 Jun 2021 23:44:37 -0700 (PDT) Received: by mail-pj1-x1030.google.com with SMTP id m15-20020a17090a5a4fb029016f385ffad0so6832493pji.0 for ; Sun, 20 Jun 2021 23:44:37 -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=zTaDLAljWX74TmEJavxcih8E8wfIv4aOm8eJI5qOLLXO5Gsd3OXYAMmn/Op8ay1DLx KVVsTfHAIn7fjwAbSJ3OFpXLKDkYW6nWVTAUKQBzpBSKC4Kj+Qv7EZiW6EGDH422hMYm 6ScqemIFFIBlIyWRutCz2mWy2lJT4y3v1NBnSAqFvTLMAmgH5hfJw6x8SrBQBi+2Cqf4 TtT5YHIYCc69p1k00hBHEw/4fcJ/h3lPx4Ng94+jTRLdpd9Zbve0Ul1nVpfMophIfTz8 MskNMD6BEnDKBJqwJMLsXL59IRP7mjiQwAJrKM1lSxhM9HiwFeMVcbo/uDT7bIr3xXAT 9lag== 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=swKfUAAxZj1G43Dx9iLhRmUnMPQd3Ni0c3pKSTo3wOu8aeNtCnINPajqv9tatLT/WQ 5+bOoNFAiPQ4i+Z3/Dm75miorXocJTaX7CTIBZUj/3q5yTQHC5VQOsJjrf2cEpEPDK+Z ZurEoikIwbvIc5amzuvOCiK+0teHsFk/AjQP1DYiIGuosv4mG1rN2UTtFGxpI+E2trcp tXyM4Be6yUYzfrBZVaMZpyCBKyfQIoOzBIugj/s5W6jN5Zhw+CRghUoNLmN07R8AqL+S JDC4OPYzrm4lm8K6+814x7S/cs2WhMYVGm+DNgdIYtjEHuWFExRaYLaJXcBOBIovwumz cxrg== X-Gm-Message-State: AOAM532MR8dVP4osNObyGp4Oh554HZ5nZnW+NtXsL8OiqyB+Z5C8zPzG AutJ/gURH8vhNEtTBWZILa5C9A== X-Received: by 2002:a17:902:a5c9:b029:f7:9f7e:aa2f with SMTP id t9-20020a170902a5c9b02900f79f7eaa2fmr16613842plq.54.1624257876676; Sun, 20 Jun 2021 23:44:36 -0700 (PDT) Received: from localhost.localdomain ([240b:10:c9a0:ca00:61b8:26ec:dc30:8823]) by smtp.gmail.com with ESMTPSA id o34sm12744450pgm.6.2021.06.20.23.44.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 20 Jun 2021 23:44:36 -0700 (PDT) From: Tomohito Esaki To: Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Daniel Vetter , Laurent Pinchart , Kieran Bingham Cc: dri-devel@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:44:00 +0900 Message-Id: <20210621064403.26663-2-etom@igel.co.jp> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210621064403.26663-1-etom@igel.co.jp> References: <20210621064403.26663-1-etom@igel.co.jp> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@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