From patchwork Mon Jun 21 06:44:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Esaki Tomohito X-Patchwork-Id: 12333879 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 934ADC49EA4 for ; Mon, 21 Jun 2021 06:44:41 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E6296102A for ; Mon, 21 Jun 2021 06:44:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230061AbhFUGqx (ORCPT ); Mon, 21 Jun 2021 02:46:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230013AbhFUGqv (ORCPT ); Mon, 21 Jun 2021 02:46:51 -0400 Received: from mail-pj1-x1029.google.com (mail-pj1-x1029.google.com [IPv6:2607:f8b0:4864:20::1029]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C3A4C06175F for ; Sun, 20 Jun 2021 23:44:37 -0700 (PDT) Received: by mail-pj1-x1029.google.com with SMTP id x21-20020a17090aa395b029016e25313bfcso9661365pjp.2 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=J4qVsGkrv59qzlmjDq3dkbgpP72LV4n7f2IFgmDKgQwNoaKYgrqXSKxISFcU4BwcKo a6W2SjuFhahPxRzlLrEpjPqfTrOWTIEXrRXCYKuoOdN9L+CEwQ8t1mSwaFwDjA/zbmJ8 vcv0IMoeNv3g6LKRjfnz0a4mxwxQKhV1xqg/wrPbGgYtreVcUtkg3u4IwdJnA6wUpVze Yl44Bq9NUfPFjQXpFTfyv8LP/1lf4L8qwkWR2qoFAeYaQU7KcTToFFBVCBjQtHnodAhs KarvTlsLS8RRwIkMZ7RQtvjSdwc/AxyWGdPss4cmb4BTt7EWPXQJY3B7AxhRxyWlPSUX v73A== X-Gm-Message-State: AOAM530gVARohaUssbuqS6pp71Gs1/cRBx7RYzHuhD6yJkDWwjTnfW1S FfYxRm+w1P9WgcVOmrrNh0UK+AiL+s2UHWol X-Google-Smtp-Source: ABdhPJwm1skS90SDwh3TbqAPeTzqhXuupSqO9K5oGPbWTUr7Mbl8i2VR1myQ/mwpDI66W+po2iGtRw== 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 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 Reported-by: kernel test robot --- 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