From: Wu Zhangjin <wuzhangjin@gmail.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org, Wu Zhangjin <wuzhangjin@gmail.com>
Subject: [PATCH 5/9] Loongson: YeeLoong: add video output driver
Date: Sun, 23 May 2010 21:58:00 +0800 [thread overview]
Message-ID: <214967c27f807b80a10d19a811d9bde6ace219fe.1274622624.git.wuzhangjin@gmail.com> (raw)
In-Reply-To: <cover.1274622624.git.wuzhangjin@gmail.com>
In-Reply-To: <cover.1274622624.git.wuzhangjin@gmail.com>
This patch adds Video Output Driver, it provides standard
interface(/sys/class/video_output) to turn on/off the video output of
LCD, CRT.
Acked-by: Pavel Machek <pavel@ucw.cz>
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
drivers/platform/mips/Kconfig | 1 +
drivers/platform/mips/yeeloong_laptop.c | 139 +++++++++++++++++++++++++++++++
2 files changed, 140 insertions(+), 0 deletions(-)
diff --git a/drivers/platform/mips/Kconfig b/drivers/platform/mips/Kconfig
index d4ce744..e1285f7 100644
--- a/drivers/platform/mips/Kconfig
+++ b/drivers/platform/mips/Kconfig
@@ -19,6 +19,7 @@ config LEMOTE_YEELOONG2F
depends on LEMOTE_MACH2F
select BACKLIGHT_CLASS_DEVICE
select HWMON
+ select VIDEO_OUTPUT_CONTROL
help
YeeLoong netbook is a mini laptop made by Lemote, which is basically
compatible to FuLoong2F mini PC, but it has an extra Embedded
diff --git a/drivers/platform/mips/yeeloong_laptop.c b/drivers/platform/mips/yeeloong_laptop.c
index a422acb..9fd70ae 100644
--- a/drivers/platform/mips/yeeloong_laptop.c
+++ b/drivers/platform/mips/yeeloong_laptop.c
@@ -14,6 +14,7 @@
#include <linux/fb.h>
#include <linux/hwmon.h> /* for hwmon subdriver */
#include <linux/hwmon-sysfs.h>
+#include <linux/video_output.h> /* for video output subdriver */
#include <ec_kb3310b.h>
@@ -323,6 +324,136 @@ static void yeeloong_hwmon_exit(void)
}
}
+/* video output subdriver */
+
+static int lcd_video_output_get(struct output_device *od)
+{
+ return ec_read(REG_DISPLAY_LCD);
+}
+
+#define LCD 0
+#define CRT 1
+
+static void display_vo_set(int display, int on)
+{
+ int addr;
+ unsigned long value;
+
+ addr = (display == LCD) ? 0x31 : 0x21;
+
+ outb(addr, 0x3c4);
+ value = inb(0x3c5);
+
+ if (display == LCD)
+ value |= (on ? 0x03 : 0x02);
+ else {
+ if (on)
+ clear_bit(7, &value);
+ else
+ set_bit(7, &value);
+ }
+
+ outb(addr, 0x3c4);
+ outb(value, 0x3c5);
+}
+
+static int lcd_video_output_set(struct output_device *od)
+{
+ unsigned long status;
+
+ status = !!od->request_state;
+
+ display_vo_set(LCD, status);
+ ec_write(REG_BACKLIGHT_CTRL, status);
+
+ return 0;
+}
+
+static struct output_properties lcd_output_properties = {
+ .set_state = lcd_video_output_set,
+ .get_status = lcd_video_output_get,
+};
+
+static int crt_video_output_get(struct output_device *od)
+{
+ return ec_read(REG_CRT_DETECT);
+}
+
+static int crt_video_output_set(struct output_device *od)
+{
+ unsigned long status;
+
+ status = !!od->request_state;
+
+ if (ec_read(REG_CRT_DETECT) == BIT_CRT_DETECT_PLUG)
+ display_vo_set(CRT, status);
+
+ return 0;
+}
+
+static struct output_properties crt_output_properties = {
+ .set_state = crt_video_output_set,
+ .get_status = crt_video_output_get,
+};
+
+static struct output_device *lcd_output_dev, *crt_output_dev;
+
+static void yeeloong_lcd_vo_set(int status)
+{
+ lcd_output_dev->request_state = status;
+ lcd_video_output_set(lcd_output_dev);
+}
+
+static void yeeloong_crt_vo_set(int status)
+{
+ crt_output_dev->request_state = status;
+ crt_video_output_set(crt_output_dev);
+}
+
+static int yeeloong_vo_init(void)
+{
+ int ret;
+
+ /* Register video output device: lcd, crt */
+ lcd_output_dev = video_output_register("LCD", NULL, NULL,
+ &lcd_output_properties);
+
+ if (IS_ERR(lcd_output_dev)) {
+ ret = PTR_ERR(lcd_output_dev);
+ lcd_output_dev = NULL;
+ return ret;
+ }
+ /* Ensure LCD is on by default */
+ yeeloong_lcd_vo_set(BIT_DISPLAY_LCD_ON);
+
+ crt_output_dev = video_output_register("CRT", NULL, NULL,
+ &crt_output_properties);
+
+ if (IS_ERR(crt_output_dev)) {
+ ret = PTR_ERR(crt_output_dev);
+ crt_output_dev = NULL;
+ return ret;
+ }
+
+ /* Turn off CRT by default, and will be enabled when the CRT
+ * connectting event reported by SCI */
+ yeeloong_crt_vo_set(BIT_CRT_DETECT_UNPLUG);
+
+ return 0;
+}
+
+static void yeeloong_vo_exit(void)
+{
+ if (lcd_output_dev) {
+ video_output_unregister(lcd_output_dev);
+ lcd_output_dev = NULL;
+ }
+ if (crt_output_dev) {
+ video_output_unregister(crt_output_dev);
+ crt_output_dev = NULL;
+ }
+}
+
static struct platform_device_id platform_device_ids[] = {
{
.name = "yeeloong_laptop",
@@ -367,11 +498,19 @@ static int __init yeeloong_init(void)
return ret;
}
+ ret = yeeloong_vo_init();
+ if (ret) {
+ pr_err("Fail to register yeeloong video output driver.\n");
+ yeeloong_vo_exit();
+ return ret;
+ }
+
return 0;
}
static void __exit yeeloong_exit(void)
{
+ yeeloong_vo_exit();
yeeloong_hwmon_exit();
yeeloong_backlight_exit();
platform_driver_unregister(&platform_driver);
--
1.7.0.4
next prev parent reply other threads:[~2010-05-23 14:00 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-05-23 13:57 [PATCH v12 0/9] Loongson: YeeLoong: add platform specific driver Wu Zhangjin
2010-05-23 13:57 ` [PATCH 1/9] MIPS: add subdirectory for platform extension drivers Wu Zhangjin
2010-05-23 13:57 ` [PATCH 3/9] Loongson: YeeLoong: add backlight driver Wu Zhangjin
2010-05-23 13:57 ` [PATCH 4/9] Loongson: YeeLoong: add hardware monitoring driver Wu Zhangjin
2010-05-23 13:58 ` Wu Zhangjin [this message]
2010-05-23 13:58 ` [PATCH 6/9] Loongson: YeeLoong: add suspend support Wu Zhangjin
2010-05-23 13:58 ` [PATCH 7/9] Loongson: YeeLoong: add input/hotkey driver Wu Zhangjin
2010-05-23 13:58 ` [PATCH 8/9] Loongson: YeeLoong: add power_supply based battery driver Wu Zhangjin
2010-05-23 13:58 ` [PATCH 9/9] Loongson: YeeLoong: Co-operate with the revisions of EC Wu Zhangjin
2010-05-23 13:59 ` [PATCH 2/9] Loongson: YeeLoong: add platform driver Wu Zhangjin
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=214967c27f807b80a10d19a811d9bde6ace219fe.1274622624.git.wuzhangjin@gmail.com \
--to=wuzhangjin@gmail.com \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).