[RFC 2/2] drm: Add SoC skeleton driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a skeleton driver for the DRM/SoC framework.

Signed-off-by: Thierry Reding <thierry.reding@xxxxxxxxxxxxxxxxx>
---
 drivers/gpu/drm/Kconfig       |   2 +
 drivers/gpu/drm/Makefile      |   1 +
 drivers/gpu/drm/soc/Kconfig   |  13 ++++
 drivers/gpu/drm/soc/Makefile  |   6 ++
 drivers/gpu/drm/soc/soc-drv.c | 166 ++++++++++++++++++++++++++++++++++++++++++
 5 files changed, 188 insertions(+)
 create mode 100644 drivers/gpu/drm/soc/Kconfig
 create mode 100644 drivers/gpu/drm/soc/Makefile
 create mode 100644 drivers/gpu/drm/soc/soc-drv.c

diff --git a/drivers/gpu/drm/Kconfig b/drivers/gpu/drm/Kconfig
index 529dede..a23b436 100644
--- a/drivers/gpu/drm/Kconfig
+++ b/drivers/gpu/drm/Kconfig
@@ -196,3 +196,5 @@ source "drivers/gpu/drm/ast/Kconfig"
 source "drivers/gpu/drm/mgag200/Kconfig"
 
 source "drivers/gpu/drm/cirrus/Kconfig"
+
+source "drivers/gpu/drm/soc/Kconfig"
diff --git a/drivers/gpu/drm/Makefile b/drivers/gpu/drm/Makefile
index 4731cbc..b7dde4e 100644
--- a/drivers/gpu/drm/Makefile
+++ b/drivers/gpu/drm/Makefile
@@ -47,4 +47,5 @@ obj-$(CONFIG_DRM_EXYNOS) +=exynos/
 obj-$(CONFIG_DRM_GMA500) += gma500/
 obj-$(CONFIG_DRM_UDL) += udl/
 obj-$(CONFIG_DRM_AST) += ast/
+obj-$(CONFIG_DRM_SOC_TEST) += soc/
 obj-y			+= i2c/
diff --git a/drivers/gpu/drm/soc/Kconfig b/drivers/gpu/drm/soc/Kconfig
new file mode 100644
index 0000000..c983bfe
--- /dev/null
+++ b/drivers/gpu/drm/soc/Kconfig
@@ -0,0 +1,13 @@
+config DRM_SOC_TEST
+	tristate "SoC DRM"
+	depends on DRM
+	select DRM_SOC
+
+if DRM_SOC_TEST
+
+config DRM_SOC_TEST_DEBUG
+	bool "SoC DRM debug support"
+	help
+	  Say Y here to enable debugging support.
+
+endif
diff --git a/drivers/gpu/drm/soc/Makefile b/drivers/gpu/drm/soc/Makefile
new file mode 100644
index 0000000..c42f540
--- /dev/null
+++ b/drivers/gpu/drm/soc/Makefile
@@ -0,0 +1,6 @@
+ccflags-y := -Iinclude/drm
+ccflags-$(CONFIG_DRM_SOC_TEST_DEBUG) += -DDEBUG
+
+soc-drm-y := soc-drv.o
+
+obj-$(CONFIG_DRM_SOC_TEST) += soc-drm.o
diff --git a/drivers/gpu/drm/soc/soc-drv.c b/drivers/gpu/drm/soc/soc-drv.c
new file mode 100644
index 0000000..90b1705
--- /dev/null
+++ b/drivers/gpu/drm/soc/soc-drv.c
@@ -0,0 +1,166 @@
+#include <linux/module.h>
+
+#include <drm/drmP.h>
+#include <drm/drm_sysfs.h>
+
+static int soc_drm_load(struct drm_device *dev, unsigned long flags)
+{
+	int ret = 0;
+
+	pr_debug("> %s(dev=%p, flags=%#lx)\n", __func__, dev, flags);
+
+	drm_mode_config_init(dev);
+
+	pr_debug("< %s() = %d\n", __func__, ret);
+	return ret;
+}
+
+static int soc_drm_unload(struct drm_device *dev)
+{
+	int ret = 0;
+
+	pr_debug("> %s(dev=%p)\n", __func__, dev);
+
+	drm_mode_config_cleanup(dev);
+
+	pr_debug("< %s() = %d\n", __func__, ret);
+	return ret;
+}
+
+static int soc_drm_open(struct drm_device *dev, struct drm_file *file)
+{
+	int ret = 0;
+	pr_debug("> %s(dev=%p, file=%p)\n", __func__, dev, file);
+	pr_debug("< %s() = %d\n", __func__, ret);
+	return ret;
+}
+
+static void soc_drm_preclose(struct drm_device *dev, struct drm_file *file)
+{
+	pr_debug("> %s(dev=%p, file=%p)\n", __func__, dev, file);
+	pr_debug("< %s()\n", __func__);
+}
+
+static void soc_drm_postclose(struct drm_device *dev, struct drm_file *file)
+{
+	pr_debug("> %s(dev=%p, file=%p)\n", __func__, dev, file);
+	pr_debug("< %s()\n", __func__);
+}
+
+static void soc_drm_lastclose(struct drm_device *dev)
+{
+	pr_debug("> %s(dev=%p)\n", __func__, dev);
+	pr_debug("< %s()\n", __func__);
+}
+
+static int drm_soc_open(struct inode *inode, struct file *filp)
+{
+	int ret = 0;
+	pr_debug("> %s(inode=%p, filp=%p)\n", __func__, inode, filp);
+	ret = drm_open(inode, filp);
+	pr_debug("< %s() = %d\n", __func__, ret);
+	return ret;
+}
+
+static int drm_soc_mmap(struct file *filp, struct vm_area_struct *vma)
+{
+	int ret = 0;
+	pr_debug("> %s(filp=%p, vma=%p)\n", __func__, filp, vma);
+	pr_debug("< %s() = %d\n", __func__, ret);
+	return ret;
+}
+
+static unsigned int drm_soc_poll(struct file *filp,
+				 struct poll_table_struct *wait)
+{
+	unsigned int ret = 0;
+	pr_debug("> %s(filp=%p, wait=%p)\n", __func__, filp, wait);
+	ret = drm_poll(filp, wait);
+	pr_debug("< %s() = %u\n", __func__, ret);
+	return ret;
+}
+
+static ssize_t drm_soc_read(struct file *filp, char __user *buffer,
+			    size_t count, loff_t *offset)
+{
+	ssize_t ret = 0;
+	pr_debug("> %s(filp=%p, buffer=%p, count=%zu, offset=%p)\n", __func__,
+		 filp, buffer, count, offset);
+	ret = drm_read(filp, buffer, count, offset);
+	pr_debug("< %s() = %zd\n", __func__, ret);
+	return ret;
+}
+
+static long drm_soc_ioctl(struct file *filp, unsigned int cmd,
+			  unsigned long arg)
+{
+	long ret = 0;
+	pr_debug("> %s(filp=%p, cmd=%#x, arg=%#lx)\n", __func__, filp, cmd,
+		 arg);
+	ret = drm_ioctl(filp, cmd, arg);
+	pr_debug("< %s() = %ld\n", __func__, ret);
+	return ret;
+}
+
+static int drm_soc_release(struct inode *inode, struct file *filp)
+{
+	int ret = 0;
+	pr_debug("> %s(inode=%p, file=%p)\n", __func__, inode, filp);
+	ret = drm_release(inode, filp);
+	pr_debug("< %s() = %d\n", __func__, ret);
+	return ret;
+}
+
+static const struct file_operations soc_drm_fops = {
+	.owner = THIS_MODULE,
+	.open = drm_soc_open,
+	.mmap = drm_soc_mmap,
+	.poll = drm_soc_poll,
+	.read = drm_soc_read,
+	.unlocked_ioctl = drm_soc_ioctl,
+	.release = drm_soc_release,
+};
+
+static struct drm_driver soc_drm = {
+	.driver_features = DRIVER_MODESET | DRIVER_GEM,
+	.load = soc_drm_load,
+	.unload = soc_drm_unload,
+	.open = soc_drm_open,
+	.preclose = soc_drm_preclose,
+	.lastclose = soc_drm_lastclose,
+	.postclose = soc_drm_postclose,
+	.fops = &soc_drm_fops,
+	.name = "soc-drm",
+	.desc = "SoC DRM driver",
+	.date = "20120706",
+	.major = 0,
+	.minor = 0,
+	.patchlevel = 0,
+};
+
+static int __init soc_drm_init(void)
+{
+	int ret = 0;
+
+	pr_debug("> %s()\n", __func__);
+
+	ret = drm_soc_init(&soc_drm, "soc");
+
+	pr_debug("< %s() = %d\n", __func__, ret);
+	return ret;
+}
+module_init(soc_drm_init);
+
+static void __exit soc_drm_exit(void)
+{
+	pr_debug("> %s()\n", __func__);
+
+	drm_soc_exit(&soc_drm);
+
+	pr_debug("< %s()\n", __func__);
+}
+module_exit(soc_drm_exit);
+
+MODULE_AUTHOR("Thierry Reding <thierry.reding@xxxxxxxxxxxxxxxxx>");
+MODULE_DESCRIPTION("SoC DRM driver");
+MODULE_LICENSE("GPL");
-- 
1.7.11.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel


[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux