Backlight & LCD : Composite two modules 91/17591/1
authorjinhyung.jo <jinhyung.jo@samsung.com>
Wed, 26 Feb 2014 07:16:45 +0000 (16:16 +0900)
committerjinhyung.jo <jinhyung.jo@samsung.com>
Fri, 7 Mar 2014 04:18:51 +0000 (13:18 +0900)
Now, the device can support to show the correct power status of the LCD.
The dummy LCD power module has been removed.
And the correct code has merged into maru_bl(maru_backlight, brightness device)

Change-Id: I4e3024a9260845373fc04b39a7118e2dd6c24c75
Signed-off-by: Jinhyung Jo <jinhyung.jo@samsung.com>
arch/x86/configs/i386_tizen_emul_defconfig
drivers/maru/Kconfig
drivers/maru/Makefile
drivers/maru/maru_bl.c
drivers/maru/maru_lcd.c [deleted file]

index e6bbbd4f603ccf2bffb60ed16345098916a32dd9..6fd043deda3cdf18a8dd0973bb9c365400f0e194 100644 (file)
@@ -2197,7 +2197,7 @@ CONFIG_FB_TILEBLITTING=y
 # CONFIG_FB_BROADSHEET is not set
 # CONFIG_EXYNOS_VIDEO is not set
 CONFIG_BACKLIGHT_LCD_SUPPORT=y
-# CONFIG_LCD_CLASS_DEVICE is not set
+CONFIG_LCD_CLASS_DEVICE=y
 CONFIG_BACKLIGHT_CLASS_DEVICE=y
 CONFIG_BACKLIGHT_GENERIC=y
 # CONFIG_BACKLIGHT_PROGEAR is not set
@@ -2774,7 +2774,6 @@ CONFIG_IOMMU_SUPPORT=y
 # CONFIG_VIRT_DRIVERS is not set
 # CONFIG_PM_DEVFREQ is not set
 CONFIG_MARU=y
-CONFIG_MARU_LCD=y
 CONFIG_MARU_CODEC=y
 CONFIG_MARU_TOUCHSCREEN=y
 CONFIG_MARU_VIRTIO_TOUCHSCREEN=y
index d9c1a18cb3eee7f8de9a918b187703feaada02fd..2ee1cf440a553b36fe4755a732dfed9e56ea0837 100644 (file)
@@ -2,10 +2,6 @@ menuconfig MARU
        tristate "MARU virtual device drivers for emulator"
        default n
 
-config MARU_LCD
-       tristate "MARU LCD driver"
-       depends on MARU != n
-
 config MARU_CODEC
        tristate "MARU codec driver"
        depends on MARU != n
index ddd9458203ab709e00a5a1492d61d08913328b67..52b847207f39aeedd9b3fc28abe581914cbba25c 100644 (file)
@@ -1,4 +1,3 @@
-obj-$(CONFIG_MARU_LCD) += maru_lcd.o
 obj-$(CONFIG_MARU_CODEC) += maru_codec.o
 obj-$(CONFIG_MARU_TOUCHSCREEN) += maru_usb_touchscreen.o
 obj-$(CONFIG_MARU_VIRTIO_TOUCHSCREEN) += maru_virtio_touchscreen.o
index c242dcd128e96f3dded4c1276b387d80a3566789..34f894158238dc219b0e3abc2822a8ee6712a997 100644 (file)
@@ -37,6 +37,7 @@
 #include <linux/err.h>
 #include <linux/fb.h>
 #include <linux/backlight.h>
+#include <linux/lcd.h>
 
 #include <linux/uaccess.h>
 
@@ -59,10 +60,12 @@ MODULE_DEVICE_TABLE(pci, marubl_pci_table);
 /* 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;
 };
 
 /* ========================================================================== */
@@ -98,6 +101,7 @@ static int marubl_send_intensity(struct backlight_device *bd)
        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;
 }
@@ -108,6 +112,22 @@ static const struct backlight_ops marubl_ops = {
        .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,
@@ -115,6 +135,7 @@ 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);
@@ -185,11 +206,24 @@ static int __devinit marubl_probe(struct pci_dev *pci_dev,
                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;
@@ -201,11 +235,13 @@ static void __devexit marubl_exit(struct pci_dev *pcidev)
         * 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);
 
        /*
diff --git a/drivers/maru/maru_lcd.c b/drivers/maru/maru_lcd.c
deleted file mode 100644 (file)
index 46996ac..0000000
+++ /dev/null
@@ -1,93 +0,0 @@
-/*
- * 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");