#include <linux/err.h>
#include <linux/fb.h>
#include <linux/backlight.h>
+#include <linux/lcd.h>
#include <linux/uaccess.h>
/* MARU virtual brightness(backlight) device structure */
struct marubl {
struct backlight_device *bl_dev;
+ struct lcd_device *lcd_dev;
unsigned int brightness;
resource_size_t reg_start, reg_size;
/* memory mapped registers */
unsigned char __iomem *marubl_mmreg;
+ int power_off;
};
/* ========================================================================== */
writel(intensity, marubl_device->marubl_mmreg);
writel(off, marubl_device->marubl_mmreg + 0x04);
marubl_device->brightness = intensity;
+ marubl_device->power_off = off ? 1 : 0;
return 0;
}
.update_status = marubl_send_intensity,
};
+int maru_lcd_get_power(struct lcd_device *ld)
+{
+ int ret = 0;
+
+ if (marubl_device->power_off) {
+ ret = FB_BLANK_POWERDOWN;
+ } else {
+ ret = FB_BLANK_UNBLANK;
+ }
+ return ret;
+}
+
+static struct lcd_ops maru_lcd_ops = {
+ .get_power = maru_lcd_get_power,
+};
+
/* pci probe function
*/
static int __devinit marubl_probe(struct pci_dev *pci_dev,
{
int ret;
struct backlight_device *bd;
+ struct lcd_device *ld;
struct backlight_properties props;
marubl_device = kmalloc(sizeof(struct marubl), GFP_KERNEL);
return ret;
}
+ ld = lcd_device_register("emulator", &pci_dev->dev, NULL, &maru_lcd_ops);
+ if (IS_ERR(ld)) {
+ ret = PTR_ERR(ld);
+ iounmap(marubl_device->marubl_mmreg);
+ release_mem_region(marubl_device->reg_start,
+ marubl_device->reg_size);
+ pci_disable_device(pci_dev);
+ kfree(marubl_device);
+ marubl_device = NULL;
+ return ret;
+ }
+
bd->props.brightness = (unsigned int)readl(marubl_device->marubl_mmreg);
bd->props.power = FB_BLANK_UNBLANK;
backlight_update_status(bd);
marubl_device->bl_dev = bd;
+ marubl_device->lcd_dev = ld;
printk(KERN_INFO "marubl: MARU Virtual Backlight driver is loaded.\n");
return 0;
* Unregister backlight device
*/
struct backlight_device *bd = marubl_device->bl_dev;
+ struct lcd_device *ld = marubl_device->lcd_dev;
bd->props.power = 0;
bd->props.brightness = 0;
backlight_update_status(bd);
+ lcd_device_unregister(ld);
backlight_device_unregister(bd);
/*
+++ /dev/null
-/*
- * Virtual LCD sysfs node
- *
- * Copyright (c) 2011-2012 Samsung Electronics Co., Ltd. All rights reserved.
- *
- * Contact:
- * Hyunjun Son <hj79.son@samsung.com>
- * DongKyun Yun <dk77.yun@samsung.com>
- * YeongKyoon Lee <yeongkyoon.lee@samsung.com>
- *
- * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
- *
- * Contributors:
- * - S-Core Co., Ltd
- *
- */
-
-#include <linux/module.h>
-#include <linux/init.h>
-#include <linux/device.h>
-#include <linux/notifier.h>
-#include <linux/ctype.h>
-#include <linux/err.h>
-
-#include <asm/uaccess.h>
-
-static struct class *emul_lcd_class;
-static struct device *emul_lcd_dev;
-static int lcd_power = 0;
-
-static ssize_t lcd_power_show(struct device *dev,
- struct device_attribute *attr, char *buf)
-{
- printk(KERN_INFO "lcd_power = %d\n", lcd_power);
- return sprintf(buf, "%d\n", lcd_power);
-}
-
-static DEVICE_ATTR(lcd_power, 0664, lcd_power_show, NULL);
-static struct device_attribute *emul_lcd_device_attrib[] = {
- &dev_attr_lcd_power,
-};
-
-static int __init emul_lcd_class_init(void)
-{
- int i, ret;
-
- emul_lcd_class = class_create(THIS_MODULE, "lcd");
- if (IS_ERR(emul_lcd_class)) {
- printk(KERN_WARNING "Unable to create backlight class; errno = %ld\n",
- PTR_ERR(emul_lcd_class));
- return PTR_ERR(emul_lcd_class);
- }
-
- emul_lcd_dev = device_create(emul_lcd_class, NULL, 0, NULL, "emulator");
-
- for (i=0; i < ARRAY_SIZE(emul_lcd_device_attrib); i++) {
- ret = device_create_file(emul_lcd_dev, emul_lcd_device_attrib[i]);
- if (ret != 0) {
- printk(KERN_ERR "emul_lcd: Failed to create attr %d: %d\n", i, ret);
- return ret;
- }
- }
-
- return 0;
-}
-
-static void __exit emul_lcd_class_exit(void)
-{
- class_destroy(emul_lcd_class);
-}
-
-/*
- * if this is compiled into the kernel, we need to ensure that the
- * class is registered before users of the class try to register lcd's
- */
-module_init(emul_lcd_class_init);
-module_exit(emul_lcd_class_exit);
-
-MODULE_LICENSE("GPL");
-MODULE_AUTHOR("s-core");
-MODULE_DESCRIPTION("Emulator LCD driver for x86");