From patchwork Sun Feb 17 17:59:08 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: David Herrmann X-Patchwork-Id: 2153721 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by patchwork2.kernel.org (Postfix) with ESMTP id D354FDF283 for ; Sun, 17 Feb 2013 18:05:30 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id B11B6E62F3 for ; Sun, 17 Feb 2013 10:05:30 -0800 (PST) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-bk0-f50.google.com (mail-bk0-f50.google.com [209.85.214.50]) by gabe.freedesktop.org (Postfix) with ESMTP id 5D736E6220 for ; Sun, 17 Feb 2013 09:59:59 -0800 (PST) Received: by mail-bk0-f50.google.com with SMTP id jg9so2186502bkc.23 for ; Sun, 17 Feb 2013 09:59:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:from:to:cc:subject:date:message-id:x-mailer:in-reply-to :references; bh=bqYkUnKL6sC1VUhgd9Allt7PBLFPPzuYy1EUk8PijD8=; b=aI1U4KW0lZ5MyamXalcCsCB5WxXeqFLrlE5TDWqSP3SQVnydLsxgOQ6k1ZfYQWweNF qZN9hd3PKWmbWHIJh0l/lOtPqiiC5hlZaq0cyR4d53QRVoX49LCPBhU7EIu6BskDVe3E 0B+o2kYz/PVfq/Vi1tDjQSZstVWpxd0lWhzZtiMz1mn2tJZ5Yxt3GGWiFZSr3274ci72 lKBE5xZQYtzZaQXhZROTojgic7Qrb0/8klZJPNajxLdixvOpe/agzkdpagvtgrJA63Dc h5dvbpgEEOuH857j9Rb1kB8l7MEARXNq6Ly28jcOlZVFaZwRgrpg+F4EQWwPCpWizrYw qamQ== X-Received: by 10.204.156.83 with SMTP id v19mr1959261bkw.136.1361123998412; Sun, 17 Feb 2013 09:59:58 -0800 (PST) Received: from localhost.localdomain (stgt-5f71b832.pool.mediaWays.net. [95.113.184.50]) by mx.google.com with ESMTPS id ho6sm20038738bkc.0.2013.02.17.09.59.57 (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Sun, 17 Feb 2013 09:59:57 -0800 (PST) From: David Herrmann To: linux-kernel@vger.kernel.org Subject: [PATCH 6/9] drm: new sysfb DRM bus module Date: Sun, 17 Feb 2013 18:59:08 +0100 Message-Id: <1361123951-587-7-git-send-email-dh.herrmann@gmail.com> X-Mailer: git-send-email 1.8.1.3 In-Reply-To: <1361123951-587-1-git-send-email-dh.herrmann@gmail.com> References: <1361123951-587-1-git-send-email-dh.herrmann@gmail.com> Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org, Florian Tobias Schandinat X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org Errors-To: dri-devel-bounces+patchwork-dri-devel=patchwork.kernel.org@lists.freedesktop.org This provides a new DRM bus helper for the system framebuffer bus. It is very similar in its functionality to the DRM_USB helper. It allows to write DRM drivers that register as SYSFB drivers to the system. Signed-off-by: David Herrmann --- drivers/gpu/drm/Kconfig | 5 ++ drivers/gpu/drm/Makefile | 1 + drivers/gpu/drm/drm_sysfb.c | 145 ++++++++++++++++++++++++++++++++++++++++++++ include/drm/drmP.h | 4 ++ include/drm/drm_sysfb.h | 35 +++++++++++ 5 files changed, 190 insertions(+) create mode 100644 drivers/gpu/drm/drm_sysfb.c create mode 100644 include/drm/drm_sysfb.h diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig index 18321b68b..2df448e 100644 --- a/drivers/gpu/drm/Kconfig +++ b/drivers/gpu/drm/Kconfig @@ -25,6 +25,11 @@ config DRM_USB depends on USB_SUPPORT && USB_ARCH_HAS_HCD select USB +config DRM_SYSFB + tristate + depends on DRM + select SYSFB + config DRM_KMS_HELPER tristate depends on DRM diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile index 2ff5cef..9249b66 100644 --- a/drivers/gpu/drm/Makefile +++ b/drivers/gpu/drm/Makefile @@ -29,6 +29,7 @@ CFLAGS_drm_trace_points.o := -I$(src) obj-$(CONFIG_DRM) += drm.o obj-$(CONFIG_DRM_USB) += drm_usb.o +obj-$(CONFIG_DRM_SYSFB) += drm_sysfb.o obj-$(CONFIG_DRM_TTM) += ttm/ obj-$(CONFIG_DRM_TDFX) += tdfx/ obj-$(CONFIG_DRM_R128) += r128/ diff --git a/drivers/gpu/drm/drm_sysfb.c b/drivers/gpu/drm/drm_sysfb.c new file mode 100644 index 0000000..4e8a823 --- /dev/null +++ b/drivers/gpu/drm/drm_sysfb.c @@ -0,0 +1,145 @@ +/* + * DRM Bus for sysfb drivers + * + * Copyright 2013 David Herrmann + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include +#include + +int drm_get_sysfb_dev(struct sysfb_device *sdev, + struct drm_driver *driver) +{ + struct drm_device *dev; + int ret; + + DRM_DEBUG("\n"); + + dev = kzalloc(sizeof(*dev), GFP_KERNEL); + if (!dev) + return -ENOMEM; + + dev_set_drvdata(&sdev->dev, dev); + dev->sysfbdev = sdev; + dev->dev = &sdev->dev; + + mutex_lock(&drm_global_mutex); + + ret = drm_fill_in_dev(dev, NULL, driver); + if (ret) { + DRM_ERROR("drm_fill_in_dev failed\n"); + goto err_unlock; + } + + if (drm_core_check_feature(dev, DRIVER_MODESET)) { + ret = drm_get_minor(dev, &dev->control, DRM_MINOR_CONTROL); + if (ret) + goto err_unlock; + } + + ret = drm_get_minor(dev, &dev->primary, DRM_MINOR_LEGACY); + if (ret) + goto err_ctrl; + + if (dev->driver->load) { + ret = dev->driver->load(dev, 0); + if (ret) + goto err_primary; + } + + if (drm_core_check_feature(dev, DRIVER_MODESET)) { + ret = drm_mode_group_init_legacy_group(dev, + &dev->primary->mode_group); + if (ret) + goto err_primary; + } + + list_add_tail(&dev->driver_item, &driver->device_list); + + mutex_unlock(&drm_global_mutex); + + DRM_INFO("initialized %s %d.%d.%d %s on minor %d\n", + driver->name, driver->major, driver->minor, driver->patchlevel, + driver->date, dev->primary->index); + + return 0; + +err_primary: + drm_put_minor(&dev->primary); +err_ctrl: + if (drm_core_check_feature(dev, DRIVER_MODESET)) + drm_put_minor(&dev->control); +err_unlock: + mutex_unlock(&drm_global_mutex); + kfree(dev); + return ret; +} +EXPORT_SYMBOL(drm_get_sysfb_dev); + +static int drm_sysfb_get_irq(struct drm_device *dev) +{ + return 0; +} + +static const char *drm_sysfb_get_name(struct drm_device *dev) +{ + return dev_name(&dev->sysfbdev->dev); +} + +static int drm_sysfb_set_busid(struct drm_device *dev, + struct drm_master *master) +{ + return 0; +} + +static struct drm_bus drm_sysfb_bus = { + .bus_type = DRIVER_BUS_SYSFB, + .get_irq = drm_sysfb_get_irq, + .get_name = drm_sysfb_get_name, + .set_busid = drm_sysfb_set_busid, +}; + +int drm_sysfb_init(struct drm_driver *driver, struct sysfb_driver *sdrv) +{ + DRM_DEBUG("\n"); + + INIT_LIST_HEAD(&driver->device_list); + driver->kdriver.sysfb = sdrv; + driver->bus = &drm_sysfb_bus; + + return sysfb_register_driver(sdrv); +} +EXPORT_SYMBOL(drm_sysfb_init); + +void drm_sysfb_exit(struct drm_driver *driver, struct sysfb_driver *sdrv) +{ + DRM_DEBUG("\n"); + + sysfb_unregister_driver(sdrv); + DRM_INFO("module unloaded\n"); +} +EXPORT_SYMBOL(drm_sysfb_exit); + +MODULE_AUTHOR("David Herrmann "); +MODULE_DESCRIPTION("DRM sysfb support"); +MODULE_LICENSE("GPL and additional rights"); diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 3fd8280..e5d73fe 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -71,6 +71,7 @@ #endif #include #include +#include #include #include #include @@ -157,6 +158,7 @@ int drm_err(const char *func, const char *format, ...); #define DRIVER_BUS_PCI 0x1 #define DRIVER_BUS_PLATFORM 0x2 #define DRIVER_BUS_USB 0x3 +#define DRIVER_BUS_SYSFB 0x4 /***********************************************************************/ /** \name Begin the DRM... */ @@ -953,6 +955,7 @@ struct drm_driver { struct pci_driver *pci; struct platform_device *platform_device; struct usb_driver *usb; + struct sysfb_driver *sysfb; } kdriver; struct drm_bus *bus; @@ -1173,6 +1176,7 @@ struct drm_device { struct platform_device *platformdev; /**< Platform device struture */ struct usb_device *usbdev; + struct sysfb_device *sysfbdev; struct drm_sg_mem *sg; /**< Scatter gather memory */ unsigned int num_crtcs; /**< Number of CRTCs on this device */ diff --git a/include/drm/drm_sysfb.h b/include/drm/drm_sysfb.h new file mode 100644 index 0000000..ced54d7 --- /dev/null +++ b/include/drm/drm_sysfb.h @@ -0,0 +1,35 @@ +#ifndef __DRM_SYSFB_H +#define __DRM_SYSFB_H +/* + * DRM Bus for sysfb drivers + * + * Copyright 2013 David Herrmann + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#include +#include + +int drm_sysfb_init(struct drm_driver *driver, struct sysfb_driver *sdrv); +void drm_sysfb_exit(struct drm_driver *driver, struct sysfb_driver *sdrv); +int drm_get_sysfb_dev(struct sysfb_device *sdev, + struct drm_driver *driver); + +#endif /* __DRM_SYSFB_H */