From: Wu Zhangin <wuzhangjin@gmail.com>
To: Ralf Baechle <ralf@linux-mips.org>
Cc: linux-mips@linux-mips.org, zhangfx@lemote.com,
luming.yu@intel.com, Wu Zhangjin <wuzhangjin@gmail.com>
Subject: [PATCH v6 6/8] Loongson: YeeLoong: add video output driver
Date: Tue, 1 Dec 2009 19:10:38 +0800 [thread overview]
Message-ID: <6447f36c749f513c3717c3bffdf21cbd8f416312.1259664573.git.wuzhangjin@gmail.com> (raw)
In-Reply-To: <cover.1259660040.git.wuzhangjin@gmail.com>
In-Reply-To: <cover.1259664573.git.wuzhangjin@gmail.com>
From: Wu Zhangjin <wuzhangjin@gmail.com>
This patch adds Video Output Driver, which provides standard interface
to turn on/off the video output of LCD, CRT.
Signed-off-by: Wu Zhangjin <wuzhangjin@gmail.com>
---
.../loongson/lemote-2f/yeeloong_laptop/Kconfig | 8 +
.../loongson/lemote-2f/yeeloong_laptop/Makefile | 1 +
.../lemote-2f/yeeloong_laptop/ec_kb3310b.h | 3 +
.../loongson/lemote-2f/yeeloong_laptop/yl_vo.c | 168 ++++++++++++++++++++
4 files changed, 180 insertions(+), 0 deletions(-)
create mode 100644 arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_vo.c
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
index d13e1ab..7cf6071 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Kconfig
@@ -37,4 +37,12 @@ config YEELOONG_HWMON
interface for lm-sensors to monitor the temperatures of CPU and
battery, the PWM of fan, the current, voltage of battery.
+config YEELOONG_VO
+ tristate "Video Output Driver"
+ select VIDEO_OUTPUT_CONTROL
+ default y
+ help
+ This option adds Video Output Driver, which provides standard
+ interface to turn on/off the video output of LCD, CRT.
+
endif
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
index b38fb2a..aa01140 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/Makefile
@@ -5,3 +5,4 @@ obj-y += ec_kb3310b.o
obj-$(CONFIG_YEELOONG_BACKLIGHT) += yl_backlight.o
obj-$(CONFIG_YEELOONG_BATTERY) += yl_battery.o
obj-$(CONFIG_YEELOONG_HWMON) += yl_hwmon.o
+obj-$(CONFIG_YEELOONG_VO) += yl_vo.o
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
index 0e3b5ad..9d06ad8 100644
--- a/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/ec_kb3310b.h
@@ -22,6 +22,9 @@ extern int ec_get_event_num(void);
typedef int (*sci_handler) (int status);
extern sci_handler yeeloong_report_lid_status;
+extern void yeeloong_lcd_vo_set(int status);
+extern void yeeloong_crt_vo_set(int status);
+
#define SCI_IRQ_NUM 0x0A
#define MAX_BRIGHTNESS 8
diff --git a/arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_vo.c b/arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_vo.c
new file mode 100644
index 0000000..db19a25
--- /dev/null
+++ b/arch/mips/loongson/lemote-2f/yeeloong_laptop/yl_vo.c
@@ -0,0 +1,168 @@
+/*
+ * YeeLoong Video Output Driver
+ *
+ * Copyright (C) 2009 Lemote Inc.
+ * Author: Wu Zhangjin <wuzj@lemote.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/err.h>
+#include <linux/video_output.h>
+
+#include <asm/bootinfo.h>
+
+#include "ec_kb3310b.h"
+
+MODULE_AUTHOR("Wu Zhangjin <wuzj@lemote.com>");
+MODULE_DESCRIPTION("YeeLoong laptop video output driver");
+MODULE_LICENSE("GPL");
+
+static int lcd_video_output_get(struct output_device *od)
+{
+ return ec_read(REG_DISPLAY_LCD);
+}
+
+static int lcd_video_output_set(struct output_device *od)
+{
+ int value;
+ unsigned long status;
+
+ status = !!od->request_state;
+
+ if (status == BIT_DISPLAY_LCD_ON) {
+ /* Turn on LCD */
+ outb(0x31, 0x3c4);
+ value = inb(0x3c5);
+ value = (value & 0xf8) | 0x03;
+ outb(0x31, 0x3c4);
+ outb(value, 0x3c5);
+ /* Turn on backlight */
+ ec_write(REG_BACKLIGHT_CTRL, BIT_BACKLIGHT_ON);
+ } else {
+ /* Turn off backlight */
+ ec_write(REG_BACKLIGHT_CTRL, BIT_BACKLIGHT_OFF);
+ /* Turn off LCD */
+ outb(0x31, 0x3c4);
+ value = inb(0x3c5);
+ value = (value & 0xf8) | 0x02;
+ outb(0x31, 0x3c4);
+ outb(value, 0x3c5);
+ }
+
+ 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)
+{
+ int value;
+ unsigned long status;
+
+ status = !!od->request_state;
+
+ if (status == BIT_CRT_DETECT_PLUG) {
+ if (ec_read(REG_CRT_DETECT) == BIT_CRT_DETECT_PLUG) {
+ /* Turn on CRT */
+ outb(0x21, 0x3c4);
+ value = inb(0x3c5);
+ value &= ~(1 << 7);
+ outb(0x21, 0x3c4);
+ outb(value, 0x3c5);
+ }
+ } else {
+ /* Turn off CRT */
+ outb(0x21, 0x3c4);
+ value = inb(0x3c5);
+ value |= (1 << 7);
+ outb(0x21, 0x3c4);
+ outb(value, 0x3c5);
+ }
+
+ 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;
+
+void yeeloong_lcd_vo_set(int status)
+{
+ lcd_output_dev->request_state = status;
+ lcd_video_output_set(lcd_output_dev);
+}
+EXPORT_SYMBOL(yeeloong_lcd_vo_set);
+
+void yeeloong_crt_vo_set(int status)
+{
+ crt_output_dev->request_state = status;
+ crt_video_output_set(crt_output_dev);
+}
+EXPORT_SYMBOL(yeeloong_crt_vo_set);
+
+static int __init yeeloong_vo_init(void)
+{
+ int ret;
+
+ if (mips_machtype != MACH_LEMOTE_YL2F89) {
+ pr_err("This Driver is only for YeeLoong laptop\n");
+ return -EFAULT;
+ }
+
+
+ /* 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 __exit 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;
+ }
+}
+
+module_init(yeeloong_vo_init);
+module_exit(yeeloong_vo_exit);
--
1.6.2.1
next prev parent reply other threads:[~2009-12-01 11:11 UTC|newest]
Thread overview: 30+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-12-01 11:06 [PATCH v6 0/8] Loongson: YeeLoong: add platform specific drivers Wu Zhangin
[not found] ` <cover.1259664573.git.wuzhangjin@gmail.com>
2009-12-01 11:07 ` [PATCH v6 1/8] Loongson: Lemote-2F: add platform specific submenu Wu Zhangin
2009-12-01 13:32 ` Ralf Baechle
2009-12-01 13:35 ` Wu Zhangjin
2009-12-01 11:07 ` [PATCH v6 2/8] Loongson: YeeLoong: add platform specific option Wu Zhangin
2009-12-01 13:34 ` Ralf Baechle
2009-12-01 13:39 ` Wu Zhangjin
2009-12-01 14:17 ` Ralf Baechle
2009-12-01 11:08 ` [PATCH v6 3/8] Loongson: YeeLoong: add backlight driver Wu Zhangin
2009-12-01 14:06 ` Ralf Baechle
2009-12-01 14:52 ` Wu Zhangjin
2009-12-01 14:57 ` Ralf Baechle
2009-12-01 15:01 ` Wu Zhangjin
2009-12-01 15:23 ` Ralf Baechle
[not found] ` <1259681303.13403.4.camel@falcon.domain.org>
2009-12-01 15:41 ` Ralf Baechle
2009-12-01 11:09 ` [PATCH v6 4/8] Loongson: YeeLoong: add battery driver Wu Zhangin
2009-12-01 14:20 ` Ralf Baechle
2009-12-01 11:09 ` [PATCH v6 5/8] Loongson: YeeLoong: add hwmon driver Wu Zhangin
2009-12-01 14:27 ` Ralf Baechle
2009-12-01 11:10 ` Wu Zhangin [this message]
2009-12-01 14:55 ` [PATCH v6 6/8] Loongson: YeeLoong: add video output driver Ralf Baechle
2009-12-01 11:11 ` [PATCH v6 7/8] Loongson: YeeLoong: add suspend driver Wu Zhangin
2009-12-01 12:24 ` Rafael J. Wysocki
2009-12-01 15:18 ` Ralf Baechle
2009-12-01 14:51 ` Ralf Baechle
2009-12-01 11:12 ` [PATCH v6 8/8] Loongson: YeeLoong: add hotkey driver Wu Zhangin
2009-12-01 15:40 ` Ralf Baechle
2009-12-01 18:03 ` Dmitry Torokhov
2009-12-02 9:43 ` Wu Zhangjin
2009-12-01 11:16 ` [PATCH v6 0/8] Loongson: YeeLoong: add platform specific drivers 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=6447f36c749f513c3717c3bffdf21cbd8f416312.1259664573.git.wuzhangjin@gmail.com \
--to=wuzhangjin@gmail.com \
--cc=linux-mips@linux-mips.org \
--cc=luming.yu@intel.com \
--cc=ralf@linux-mips.org \
--cc=zhangfx@lemote.com \
/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).