From patchwork Thu Feb 22 20:06:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Noralf_Tr=C3=B8nnes?= X-Patchwork-Id: 10236313 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 92F3660349 for ; Thu, 22 Feb 2018 20:15:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 855D2289FD for ; Thu, 22 Feb 2018 20:15:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7888228C06; Thu, 22 Feb 2018 20:15:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=unavailable version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 3E346289FD for ; Thu, 22 Feb 2018 20:15:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 176756ED7C; Thu, 22 Feb 2018 20:15:50 +0000 (UTC) X-Original-To: intel-gfx@lists.freedesktop.org Delivered-To: intel-gfx@lists.freedesktop.org Received: from smtp.domeneshop.no (smtp.domeneshop.no [IPv6:2a01:5b40:0:3005::1]) by gabe.freedesktop.org (Postfix) with ESMTPS id AD09F6ED7C for ; Thu, 22 Feb 2018 20:15:48 +0000 (UTC) Received: from 211.81-166-168.customer.lyse.net ([81.166.168.211]:34576 helo=localhost.localdomain) by smtp.domeneshop.no with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_CBC_SHA256:128) (Exim 4.84_2) (envelope-from ) id 1eox93-0004nQ-NA; Thu, 22 Feb 2018 21:07:09 +0100 From: =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= To: dri-devel@lists.freedesktop.org Date: Thu, 22 Feb 2018 21:06:51 +0100 Message-Id: <20180222200653.19453-11-noralf@tronnes.org> X-Mailer: git-send-email 2.15.1 In-Reply-To: <20180222200653.19453-1-noralf@tronnes.org> References: <20180222200653.19453-1-noralf@tronnes.org> MIME-Version: 1.0 Subject: [Intel-gfx] [RFC v3 10/12] drm/client: Add fbdev emulation client X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: daniel.vetter@ffwll.ch, intel-gfx@lists.freedesktop.org, =?UTF-8?q?Noralf=20Tr=C3=B8nnes?= , laurent.pinchart@ideasonboard.com, dh.herrmann@gmail.com Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" X-Virus-Scanned: ClamAV using ClamSMTP This adds generic fbdev emulation for drivers that support the dumb buffer API. No fbdev code is necessary in the driver. Differences from drm_fb_helper: - The backing buffer is created when the first fd is opened. - Supports changing the mode from userspace. - Doesn't restore on lastclose if there is no fd/fbcon open. - Supports changing the buffer size (yres_virtual) from userspace before the fd is opened (double/trippel/... buffering). - Panning is only supported as page flipping, so no partial offset. - Supports real page flipping with FBIO_WAITFORVSYNC waiting on the actual flip. - Supports framebuffer flushing for fbcon on buffers that doesn't support fbdev deferred I/O (shmem). mmap doesn't work but fbcon does. TODO: - suspend/resume - sysrq - Look more into plane format selection/support. - Need a way for the driver to say that it wants generic fbdev emulation. The client .new hook is run in drm_dev_register() which is before drivers set up fbdev themselves. So the client can't look at drm_device->fb_helper to find out. - Do we need to support FB_VISUAL_PSEUDOCOLOR? TROUBLE: - fbcon can't handle fb_open returning an error, it just heads on. This results in a NULL deref in fbcon_init(). fbcon/vt is awful when it comes to error handling. It doesn't look to be easily fixed, so I guess a buffer has to be pre-allocated to ensure health and safety. Signed-off-by: Noralf Trønnes --- drivers/gpu/drm/client/Kconfig | 16 + drivers/gpu/drm/client/Makefile | 2 + drivers/gpu/drm/client/drm_fbdev.c | 997 +++++++++++++++++++++++++++++++++++++ 3 files changed, 1015 insertions(+) create mode 100644 drivers/gpu/drm/client/drm_fbdev.c diff --git a/drivers/gpu/drm/client/Kconfig b/drivers/gpu/drm/client/Kconfig index 4bb8e4655ff7..73902ab44c75 100644 --- a/drivers/gpu/drm/client/Kconfig +++ b/drivers/gpu/drm/client/Kconfig @@ -1,4 +1,20 @@ menu "DRM Clients" depends on DRM +config DRM_CLIENT_FBDEV + tristate "Generic fbdev emulation" + depends on DRM + select FB + select FRAMEBUFFER_CONSOLE if !EXPERT + select FRAMEBUFFER_CONSOLE_DETECT_PRIMARY if FRAMEBUFFER_CONSOLE + select FB_SYS_FOPS + select FB_SYS_FILLRECT + select FB_SYS_COPYAREA + select FB_SYS_IMAGEBLIT + select FB_DEFERRED_IO + select FB_MODE_HELPERS + select VIDEOMODE_HELPERS + help + Generic fbdev emulation + endmenu diff --git a/drivers/gpu/drm/client/Makefile b/drivers/gpu/drm/client/Makefile index f66554cd5c45..3ff694429dec 100644 --- a/drivers/gpu/drm/client/Makefile +++ b/drivers/gpu/drm/client/Makefile @@ -1 +1,3 @@ # SPDX-License-Identifier: GPL-2.0 + +obj-$(CONFIG_DRM_CLIENT_FBDEV) += drm_fbdev.o diff --git a/drivers/gpu/drm/client/drm_fbdev.c b/drivers/gpu/drm/client/drm_fbdev.c new file mode 100644 index 000000000000..e28416d72de1 --- /dev/null +++ b/drivers/gpu/drm/client/drm_fbdev.c @@ -0,0 +1,997 @@ +// SPDX-License-Identifier: GPL-2.0 +// Copyright 2018 Noralf Trønnes + +#include +#include +#include +#include +#include +#include +#include +#include