From patchwork Tue Nov 30 12:07:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bryan Wu X-Patchwork-Id: 366741 X-Patchwork-Delegate: tomi.valkeinen@nokia.com Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oAUC7oM8032249 for ; Tue, 30 Nov 2010 12:07:51 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752001Ab0K3MHu (ORCPT ); Tue, 30 Nov 2010 07:07:50 -0500 Received: from adelie.canonical.com ([91.189.90.139]:50735 "EHLO adelie.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751662Ab0K3MHt (ORCPT ); Tue, 30 Nov 2010 07:07:49 -0500 Received: from hutte.canonical.com ([91.189.90.181]) by adelie.canonical.com with esmtp (Exim 4.69 #1 (Debian)) id 1PNOzs-0000qA-BG; Tue, 30 Nov 2010 12:07:48 +0000 Received: from [124.76.14.0] (helo=canonical.com) by hutte.canonical.com with esmtpsa (TLS-1.0:DHE_RSA_AES_128_CBC_SHA1:16) (Exim 4.69) (envelope-from ) id 1PNOzq-0006jt-Ag; Tue, 30 Nov 2010 12:07:48 +0000 From: Bryan Wu To: tomi.valkeinen@nokia.com, linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, gadiyar@ti.com, rpurdie@rpsys.net Subject: [PATCH 1/3] Backlight: driver for Sharp LS037V7DW01 panel on OMAP machine Date: Tue, 30 Nov 2010 20:07:38 +0800 Message-Id: <1291118860-10325-2-git-send-email-bryan.wu@canonical.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1291118860-10325-1-git-send-email-bryan.wu@canonical.com> References: <1291118860-10325-1-git-send-email-bryan.wu@canonical.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Tue, 30 Nov 2010 12:07:51 +0000 (UTC) diff --git a/drivers/video/backlight/Kconfig b/drivers/video/backlight/Kconfig index e54a337..46b2415 100644 --- a/drivers/video/backlight/Kconfig +++ b/drivers/video/backlight/Kconfig @@ -307,6 +307,16 @@ config BACKLIGHT_PCF50633 If you have a backlight driven by a NXP PCF50633 MFD, say Y here to enable its driver. +config BACKLIGHT_SHARP_LS037V7DW01 + tristate "Backlight driver for SHARP LS037V7DW01 Panel" + depends on PANEL_GENERIC_DPI + help + If you are using Sharp LS037V7DW01 LCD panel, say Y here to enable this driver. + + To compile this driver as a module, choose M here: the module will + be called sharp_ls037v7dw01. + + endif # BACKLIGHT_CLASS_DEVICE endif # BACKLIGHT_LCD_SUPPORT diff --git a/drivers/video/backlight/Makefile b/drivers/video/backlight/Makefile index 44c0f81..c756f49 100644 --- a/drivers/video/backlight/Makefile +++ b/drivers/video/backlight/Makefile @@ -35,4 +35,5 @@ obj-$(CONFIG_BACKLIGHT_ADP5520) += adp5520_bl.o obj-$(CONFIG_BACKLIGHT_ADP8860) += adp8860_bl.o obj-$(CONFIG_BACKLIGHT_88PM860X) += 88pm860x_bl.o obj-$(CONFIG_BACKLIGHT_PCF50633) += pcf50633-backlight.o +obj-$(CONFIG_BACKLIGHT_SHARP_LS037V7DW01) += sharp_ls037v7dw01.o diff --git a/drivers/video/backlight/sharp_ls037v7dw01.c b/drivers/video/backlight/sharp_ls037v7dw01.c new file mode 100644 index 0000000..e90595e --- /dev/null +++ b/drivers/video/backlight/sharp_ls037v7dw01.c @@ -0,0 +1,144 @@ +/* + * Backlight driver for Sharp LS037V7DW01 + * + * Copyright (C) 2010 Canonical Ltd. + * Author: Bryan Wu + * + * Copyright (C) 2008 Nokia Corporation + * Author: Tomi Valkeinen + * + * 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. + * + * 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, see . + */ + +#include +#include +#include +#include +#include + +/* This OMAP platform header file is required by this driver */ +#include + +static int sharp_ls_bl_update_status(struct backlight_device *bl) +{ + struct omap_dss_device *dssdev = bl_get_data(bl); + int level; + + if (!dssdev->set_backlight) + return -EINVAL; + + if (bl->props.fb_blank == FB_BLANK_UNBLANK && + bl->props.power == FB_BLANK_UNBLANK) + level = bl->props.brightness; + else + level = 0; + + return dssdev->set_backlight(dssdev, level); +} + +static int sharp_ls_bl_get_brightness(struct backlight_device *bl) +{ + if (bl->props.fb_blank == FB_BLANK_UNBLANK && + bl->props.power == FB_BLANK_UNBLANK) + return bl->props.brightness; + + return 0; +} + +static const struct backlight_ops sharp_ls_bl_ops = { + .get_brightness = sharp_ls_bl_get_brightness, + .update_status = sharp_ls_bl_update_status, +}; + +static int __devinit sharp_ls_bl_probe(struct platform_device *pdev) +{ + struct backlight_properties props; + struct backlight_device *bl; + struct omap_dss_device *dssdev = pdev->dev.platform_data; + + if (!dssdev) + return -EINVAL; + + memset(&props, 0, sizeof(struct backlight_properties)); + props.max_brightness = dssdev->max_backlight_level; + + bl = backlight_device_register("sharp-ls-bl", &dssdev->dev, dssdev, + &sharp_ls_bl_ops, &props); + if (IS_ERR(bl)) + return PTR_ERR(bl); + + bl->props.fb_blank = FB_BLANK_UNBLANK; + bl->props.power = FB_BLANK_UNBLANK; + bl->props.brightness = dssdev->max_backlight_level; + backlight_update_status(bl); + + platform_set_drvdata(pdev, bl); + return 0; +} + +static int __devexit sharp_ls_bl_remove(struct platform_device *pdev) +{ + struct backlight_device *bl = platform_get_drvdata(pdev); + + bl->props.power = FB_BLANK_POWERDOWN; + backlight_update_status(bl); + backlight_device_unregister(bl); + + return 0; +} + +#ifdef CONFIG_PM +static int sharp_ls_bl_suspend(struct platform_device *dev, pm_message_t state) +{ + return 0; +} + +static int sharp_ls_bl_resume(struct platform_device *dev) +{ + struct backlight_device *bl = platform_get_drvdata(dev); + + backlight_update_status(bl); + return 0; +} +#else +#define sharp_ls_bl_suspend NULL +#define sharp_ls_bl_resume NULL +#endif + +static struct platform_driver sharp_ls_bl_driver = { + .driver = { + .name = "sharp-ls-bl", + .owner = THIS_MODULE, + }, + .probe = sharp_ls_bl_probe, + .remove = __devexit_p(sharp_ls_bl_remove), + .suspend = sharp_ls_bl_suspend, + .resume = sharp_ls_bl_resume, +}; + +static int __init sharp_ls_bl_init(void) +{ + return platform_driver_register(&sharp_ls_bl_driver); +} +module_init(sharp_ls_bl_init); + +static void __exit sharp_ls_bl_exit(void) +{ + platform_driver_unregister(&sharp_ls_bl_driver); +} +module_exit(sharp_ls_bl_exit); + +MODULE_DESCRIPTION("Sharp LS037V7DW01 Backlight Driver"); +MODULE_AUTHOR("Bryan Wu "); +MODULE_LICENSE("GPL"); +MODULE_ALIAS("platform:sharp-ls-bl");