aboutsummaryrefslogtreecommitdiff
path: root/drivers/mfd/glamo
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-05-27 22:14:11 +0100
committerThomas White <taw@bitwiz.org.uk>2009-05-27 22:14:11 +0100
commit740d8196e83bd7eaccf2f3575019a7bd96444c1d (patch)
treee9acf45bdbc32a641c8730991dcfd6faad86f20c /drivers/mfd/glamo
parent799dc0363fc2c4c98f18dbd9abf39c20811618d9 (diff)
Initial KMS stuff
Diffstat (limited to 'drivers/mfd/glamo')
-rw-r--r--drivers/mfd/glamo/Makefile2
-rw-r--r--drivers/mfd/glamo/glamo-display.c144
-rw-r--r--drivers/mfd/glamo/glamo-display.h30
-rw-r--r--drivers/mfd/glamo/glamo-drm-drv.c41
-rw-r--r--drivers/mfd/glamo/glamo-drm-private.h11
5 files changed, 218 insertions, 10 deletions
diff --git a/drivers/mfd/glamo/Makefile b/drivers/mfd/glamo/Makefile
index 75476de5ad7..7d3f7d6bc69 100644
--- a/drivers/mfd/glamo/Makefile
+++ b/drivers/mfd/glamo/Makefile
@@ -12,4 +12,4 @@ obj-$(CONFIG_MFD_GLAMO_SPI_FB) += glamo-lcm-spi.o
obj-$(CONFIG_MFD_GLAMO_MCI) += glamo-mci.o
obj-$(CONFIG_MFD_GLAMO_DRM) += glamo-drm.o
-glamo-drm-objs := glamo-drm-drv.o glamo-cmdq.o glamo-buffer.o
+glamo-drm-objs := glamo-drm-drv.o glamo-cmdq.o glamo-buffer.o glamo-display.o
diff --git a/drivers/mfd/glamo/glamo-display.c b/drivers/mfd/glamo/glamo-display.c
new file mode 100644
index 00000000000..b129b8da455
--- /dev/null
+++ b/drivers/mfd/glamo/glamo-display.c
@@ -0,0 +1,144 @@
+/*
+ * SMedia Glamo 336x/337x display
+ *
+ * Copyright (C) 2008-2009 Thomas White <taw@bitwiz.org.uk>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ *
+ */
+
+
+#include <drm/drmP.h>
+#include <drm/glamo_drm.h>
+#include <drm/drm_crtc_helper.h>
+#include <drm/drm_crtc.h>
+
+#include "glamo-core.h"
+#include "glamo-drm-private.h"
+#include "glamo-regs.h"
+
+
+static void glamo_crtc_dpms(struct drm_crtc *crtc, int mode)
+{
+}
+
+
+static bool glamo_crtc_mode_fixup(struct drm_crtc *crtc,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode)
+{
+ return true;
+}
+
+
+static void glamo_crtc_mode_set(struct drm_crtc *crtc,
+ struct drm_display_mode *mode,
+ struct drm_display_mode *adjusted_mode,
+ int x, int y,
+ struct drm_framebuffer *old_fb)
+{
+}
+
+
+
+static void glamo_pipe_set_base(struct drm_crtc *crtc, int x, int y,
+ struct drm_framebuffer *old_fb)
+{
+}
+
+
+static void glamo_crtc_prepare(struct drm_crtc *crtc)
+{
+ struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+ crtc_funcs->dpms(crtc, DRM_MODE_DPMS_OFF);
+}
+
+
+static void glamo_crtc_commit(struct drm_crtc *crtc)
+{
+ struct drm_crtc_helper_funcs *crtc_funcs = crtc->helper_private;
+ crtc_funcs->dpms(crtc, DRM_MODE_DPMS_ON);
+}
+
+
+static int glamo_crtc_cursor_set(struct drm_crtc *crtc,
+ struct drm_file *file_priv,
+ uint32_t handle,
+ uint32_t width, uint32_t height)
+{
+ return 0;
+}
+
+
+static int glamo_crtc_cursor_move(struct drm_crtc *crtc, int x, int y)
+{
+ return 0;
+}
+
+
+static void glamo_crtc_gamma_set(struct drm_crtc *crtc, u16 *red, u16 *green,
+ u16 *blue, uint32_t size)
+{
+}
+
+
+static void glamo_crtc_destroy(struct drm_crtc *crtc)
+{
+ struct glamo_crtc *glamo_crtc = to_glamo_crtc(crtc);
+
+ drm_crtc_cleanup(crtc);
+ kfree(glamo_crtc);
+}
+
+
+static const struct drm_crtc_helper_funcs glamo_helper_funcs = {
+ .dpms = glamo_crtc_dpms,
+ .mode_fixup = glamo_crtc_mode_fixup,
+ .mode_set = glamo_crtc_mode_set,
+ .mode_set_base = glamo_pipe_set_base,
+ .prepare = glamo_crtc_prepare,
+ .commit = glamo_crtc_commit,
+};
+
+
+static const struct drm_crtc_funcs glamo_crtc_funcs = {
+ .cursor_set = glamo_crtc_cursor_set,
+ .cursor_move = glamo_crtc_cursor_move,
+ .gamma_set = glamo_crtc_gamma_set,
+ .set_config = drm_crtc_helper_set_config,
+ .destroy = glamo_crtc_destroy,
+};
+
+
+int glamo_display_init(struct drm_device *dev)
+{
+ struct glamodrm_handle *gdrm;
+ struct glamo_crtc *glamo_crtc;
+
+ glamo_crtc = kzalloc(sizeof(struct glamo_crtc)
+ + sizeof(struct drm_connector *), GFP_KERNEL);
+ if (glamo_crtc == NULL)
+ return 1;
+
+ gdrm = dev->dev_private;
+
+ drm_crtc_init(dev, &glamo_crtc->base, &glamo_crtc_funcs);
+ drm_crtc_helper_add(&glamo_crtc->base, &glamo_helper_funcs);
+
+ return 0;
+}
diff --git a/drivers/mfd/glamo/glamo-display.h b/drivers/mfd/glamo/glamo-display.h
new file mode 100644
index 00000000000..6d8d43cbcfb
--- /dev/null
+++ b/drivers/mfd/glamo/glamo-display.h
@@ -0,0 +1,30 @@
+/* Smedia Glamo 336x/337x display
+ *
+ * Copyright (c) 2008-2009 Thomas White <taw@bitwiz.org.uk>
+ *
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
+ * MA 02111-1307 USA
+ */
+
+#ifndef __GLAMO_DISPLAY_H
+#define __GLAMO_DISPLAY_H
+
+#include <drm/drmP.h>
+
+extern int glamo_display_init(struct drm_device *dev);
+
+#endif /* __GLAMO_DISPLAY_H */
diff --git a/drivers/mfd/glamo/glamo-drm-drv.c b/drivers/mfd/glamo/glamo-drm-drv.c
index 2208a8ef5f7..5136263375b 100644
--- a/drivers/mfd/glamo/glamo-drm-drv.c
+++ b/drivers/mfd/glamo/glamo-drm-drv.c
@@ -31,6 +31,7 @@
#include "glamo-cmdq.h"
#include "glamo-buffer.h"
#include "glamo-drm-private.h"
+#include "glamo-display.h"
#define DRIVER_AUTHOR "Openmoko, Inc."
#define DRIVER_NAME "glamo-drm"
@@ -126,13 +127,43 @@ static void glamodrm_master_destroy(struct drm_device *dev,
}
+static int glamodrm_load(struct drm_device *dev, unsigned long flags)
+{
+ struct glamodrm_handle *gdrm;
+
+ gdrm = dev->dev_private;
+
+ glamo_buffer_init(gdrm);
+ glamo_cmdq_init(gdrm);
+ glamo_display_init(dev);
+
+ return 0;
+}
+
+
+static int glamodrm_unload(struct drm_device *dev)
+{
+ struct glamodrm_handle *gdrm;
+
+ gdrm = dev->dev_private;
+
+ glamo_engine_disable(gdrm->glamo_core, GLAMO_ENGINE_2D);
+ glamo_engine_disable(gdrm->glamo_core, GLAMO_ENGINE_3D);
+ glamo_buffer_final(gdrm);
+
+ return 0;
+}
+
+
static struct vm_operations_struct glamodrm_gem_vm_ops = {
.fault = glamodrm_gem_fault,
};
static struct drm_driver glamodrm_drm_driver = {
- .driver_features = DRIVER_IS_PLATFORM | DRIVER_GEM,
+ .driver_features = DRIVER_IS_PLATFORM | DRIVER_GEM | DRIVER_MODESET,
.firstopen = glamodrm_firstopen,
+ .load = glamodrm_load,
+ .unload = glamodrm_unload,
.open = glamodrm_open,
.preclose = glamodrm_preclose,
.postclose = glamodrm_postclose,
@@ -247,9 +278,6 @@ static int glamodrm_probe(struct platform_device *pdev)
/* Initialise DRM */
drm_platform_init(&glamodrm_drm_driver, pdev, (void *)gdrm);
- glamo_buffer_init(gdrm);
- glamo_cmdq_init(gdrm);
-
return 0;
out_release_cmdq:
@@ -272,12 +300,7 @@ out_free:
static int glamodrm_remove(struct platform_device *pdev)
{
struct glamodrm_handle *gdrm = platform_get_drvdata(pdev);
- struct glamo_core *glamocore = pdev->dev.platform_data;
-
- glamo_engine_disable(glamocore, GLAMO_ENGINE_2D);
- glamo_engine_disable(glamocore, GLAMO_ENGINE_3D);
- glamo_buffer_final(gdrm);
drm_exit(&glamodrm_drm_driver);
platform_set_drvdata(pdev, NULL);
diff --git a/drivers/mfd/glamo/glamo-drm-private.h b/drivers/mfd/glamo/glamo-drm-private.h
index 59fbc2488c5..d1c76c23115 100644
--- a/drivers/mfd/glamo/glamo-drm-private.h
+++ b/drivers/mfd/glamo/glamo-drm-private.h
@@ -58,6 +58,7 @@ struct glamodrm_handle {
struct drm_mm *mmgr;
};
+
/* Private data. This is where we keep our memory management bits */
struct drm_glamo_gem_object {
struct drm_gem_object *obj; /* The GEM object this refers to */
@@ -65,5 +66,15 @@ struct drm_glamo_gem_object {
};
+struct glamo_crtc {
+ struct drm_crtc base;
+};
+
+
+#define to_glamo_crtc(x) container_of(x, struct glamo_crtc, base)
+#define to_glamo_output(x) container_of(x, struct glamo_output, base)
+#define enc_to_glamo_output(x) container_of(x, struct glamo_output, enc)
+#define to_glamo_framebuffer(x) container_of(x, struct glamo_framebuffer, base)
+
#endif /* __GLAMO_DRMPRIV_H */