aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomi Valkeinen <tomi.valkeinen@ti.com>2012-12-14 15:21:05 +0200
committerVikas Sajjan <vikas.sajjan@linaro.org>2013-02-18 18:07:37 +0530
commit84ad1b34555853ef47881678dd9b23ee5e46efc2 (patch)
tree5e76e125c7c50124066bd2d5b69b6bfafbe68b24
parent7b1fb99260bd1eca4fffe252bd06c7148bbbfd2d (diff)
video: add generic dvi monitor
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ti.com>
-rw-r--r--drivers/video/display/panel-dvi.c164
-rw-r--r--include/video/panel-dvi.h18
2 files changed, 182 insertions, 0 deletions
diff --git a/drivers/video/display/panel-dvi.c b/drivers/video/display/panel-dvi.c
new file mode 100644
index 00000000000..01cea099fc3
--- /dev/null
+++ b/drivers/video/display/panel-dvi.c
@@ -0,0 +1,164 @@
+/*
+ * Generic DVI monitor
+ *
+ * Copyright (C) 2012 Texas Instruments
+ *
+ * Contacts: Tomi Valkeinen <tomi.valkeinen@ti.com>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#include <linux/kernel.h>
+#include <linux/module.h>
+#include <linux/platform_device.h>
+
+#include <video/display.h>
+#include <video/panel-dvi.h>
+
+struct panel_data {
+ struct display_entity entity;
+ struct video_source *in;
+};
+
+#define to_panel(p) container_of(p, struct panel_data, entity)
+
+static int panel_dvi_set_state(struct display_entity *entity,
+ enum display_entity_state state)
+{
+ struct panel_data *data = to_panel(entity);
+ struct video_source *in = data->in;
+
+ switch (state) {
+ case DISPLAY_ENTITY_STATE_OFF:
+ case DISPLAY_ENTITY_STATE_STANDBY:
+ in->common_ops->set_stream(in, DISPLAY_ENTITY_STREAM_STOPPED);
+ break;
+
+ case DISPLAY_ENTITY_STATE_ON:
+ in->common_ops->set_stream(in, DISPLAY_ENTITY_STREAM_CONTINUOUS);
+ break;
+ }
+
+ return 0;
+}
+
+static const struct videomode vga_mode = {
+ .pixelclock = 23500,
+
+ .hactive = 640,
+ .hfront_porch = 48,
+ .hback_porch = 80,
+ .hsync_len = 32,
+
+ .vactive = 480,
+ .vfront_porch = 3,
+ .vback_porch = 7,
+ .vsync_len = 4,
+
+ .hah = true,
+ .vah = true,
+ .de = true,
+};
+
+static int panel_dvi_get_modes(struct display_entity *entity,
+ const struct videomode **modes)
+{
+ //struct panel_data *data = to_panel(entity);
+
+ *modes = &vga_mode;
+ return 1;
+}
+
+static int panel_dvi_get_size(struct display_entity *entity,
+ unsigned int *width, unsigned int *height)
+{
+ //struct panel_data *data = to_panel(entity);
+
+ *width = 10;
+ *height = 10;
+ return 0;
+}
+
+static const struct display_entity_control_ops panel_dvi_control_ops = {
+ .set_state = panel_dvi_set_state,
+ .get_modes = panel_dvi_get_modes,
+ .get_size = panel_dvi_get_size,
+};
+
+static void panel_dvi_release(struct display_entity *entity)
+{
+ printk("panel dvi release\n");
+}
+
+static int __devinit panel_dvi_probe(struct platform_device *pdev)
+{
+ const struct panel_dvi_platform_data *pdata = pdev->dev.platform_data;
+ struct panel_data *data;
+ int ret;
+
+ if (pdata == NULL)
+ return -ENODEV;
+
+ data = devm_kzalloc(&pdev->dev, sizeof(*data), GFP_KERNEL);
+ if (data == NULL)
+ return -ENOMEM;
+
+ /* setup input */
+ data->in = video_source_find(pdata->video_source);
+ if (data->in == NULL) {
+ printk("failed to get video source\n");
+ return -EINVAL;
+ }
+
+ /* setup default mode */
+ data->in->ops.dvi->set_videomode(data->in, &vga_mode);
+
+ /* setup panel entity */
+
+ data->entity.dev = &pdev->dev;
+ data->entity.release = panel_dvi_release;
+ data->entity.ops = &panel_dvi_control_ops;
+
+ ret = display_entity_register(&data->entity);
+ if (ret < 0) {
+ video_source_put(data->in);
+ return ret;
+ }
+
+ platform_set_drvdata(pdev, data);
+
+ return 0;
+}
+
+static int panel_dvi_remove(struct platform_device *pdev)
+{
+ struct panel_data *data = platform_get_drvdata(pdev);
+
+ display_entity_unregister(&data->entity);
+
+ video_source_put(data->in);
+
+ return 0;
+}
+
+
+static const struct dev_pm_ops panel_dvi_dev_pm_ops = {
+};
+
+static struct platform_driver panel_dvi_driver = {
+ .probe = panel_dvi_probe,
+ .remove = panel_dvi_remove,
+ .driver = {
+ .name = "panel_dvi",
+ .owner = THIS_MODULE,
+ .pm = &panel_dvi_dev_pm_ops,
+ },
+};
+
+module_platform_driver(panel_dvi_driver);
+
+MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
+MODULE_DESCRIPTION("DVI Monitor");
+MODULE_LICENSE("GPL");
diff --git a/include/video/panel-dvi.h b/include/video/panel-dvi.h
new file mode 100644
index 00000000000..ab883803297
--- /dev/null
+++ b/include/video/panel-dvi.h
@@ -0,0 +1,18 @@
+/*
+ * DVI Display Panel
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ */
+
+#ifndef __PANEL_DVI_H__
+#define __PANEL_DVI_H__
+
+#include <linux/videomode.h>
+
+struct panel_dvi_platform_data {
+ const char *video_source;
+};
+
+#endif /* __PANEL_DVI_H__ */