diff options
author | Liu Ying <Ying.Liu@freescale.com> | 2014-02-17 21:17:59 -0500 |
---|---|---|
committer | Nitin Garg <nitin.garg@freescale.com> | 2014-04-16 09:57:32 -0400 |
commit | b3f2911ae6a6bc0a510eae159a4febe277b27426 (patch) | |
tree | 8f4cede46cb74dce1865942951c56dc5af809af6 /drivers/video | |
parent | f68bec1f568316d595633e81d29bf4002727ca5f (diff) |
ENGR00298052-1 video: mxc: add Hannstar CABC driver
This patch adds Hannstar CABC driver support. The CABC
function turns the backlight density of a display panel
automatically according to the content shown on the panel.
It is controlled(enabled/disabled) by a GPIO.
Signed-off-by: Liu Ying <Ying.Liu@freescale.com>
Diffstat (limited to 'drivers/video')
-rw-r--r-- | drivers/video/mxc/Kconfig | 8 | ||||
-rw-r--r-- | drivers/video/mxc/Makefile | 1 | ||||
-rw-r--r-- | drivers/video/mxc/hannstar_cabc.c | 89 |
3 files changed, 98 insertions, 0 deletions
diff --git a/drivers/video/mxc/Kconfig b/drivers/video/mxc/Kconfig index 759ff096826c..2269de1e02cb 100644 --- a/drivers/video/mxc/Kconfig +++ b/drivers/video/mxc/Kconfig | |||
@@ -61,3 +61,11 @@ config FB_MXC_EINK_AUTO_UPDATE_MODE | |||
61 | config FB_MXS_SII902X | 61 | config FB_MXS_SII902X |
62 | tristate "Si Image SII9022 DVI/HDMI Interface Chip" | 62 | tristate "Si Image SII9022 DVI/HDMI Interface Chip" |
63 | depends on FB_MXS && I2C | 63 | depends on FB_MXS && I2C |
64 | |||
65 | config HANNSTAR_CABC | ||
66 | tristate "Hannstar CABC function" | ||
67 | help | ||
68 | Say yes here to support switching on/off Hannstar CABC | ||
69 | function. This function turns backlight density of a | ||
70 | display panel automatically according to the content | ||
71 | shown on the panel. | ||
diff --git a/drivers/video/mxc/Makefile b/drivers/video/mxc/Makefile index 6a5b855dbafa..c0fec9e79727 100644 --- a/drivers/video/mxc/Makefile +++ b/drivers/video/mxc/Makefile | |||
@@ -6,3 +6,4 @@ obj-$(CONFIG_FB_MXC_EDID) += mxc_edid.o | |||
6 | obj-$(CONFIG_FB_MXC_SYNC_PANEL) += mxc_dispdrv.o mxc_lcdif.o mxc_ipuv3_fb.o | 6 | obj-$(CONFIG_FB_MXC_SYNC_PANEL) += mxc_dispdrv.o mxc_lcdif.o mxc_ipuv3_fb.o |
7 | obj-$(CONFIG_FB_MXC_EINK_PANEL) += mxc_epdc_fb.o | 7 | obj-$(CONFIG_FB_MXC_EINK_PANEL) += mxc_epdc_fb.o |
8 | obj-$(CONFIG_FB_MXS_SII902X) += mxsfb_sii902x.o | 8 | obj-$(CONFIG_FB_MXS_SII902X) += mxsfb_sii902x.o |
9 | obj-$(CONFIG_HANNSTAR_CABC) += hannstar_cabc.o | ||
diff --git a/drivers/video/mxc/hannstar_cabc.c b/drivers/video/mxc/hannstar_cabc.c new file mode 100644 index 000000000000..c1d8442948be --- /dev/null +++ b/drivers/video/mxc/hannstar_cabc.c | |||
@@ -0,0 +1,89 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2014 Freescale Semiconductor, Inc. All Rights Reserved. | ||
3 | * | ||
4 | * This program is free software; you can redistribute it and/or modify | ||
5 | * it under the terms of the GNU General Public License as published by | ||
6 | * the Free Software Foundation; either version 2 of the License, or | ||
7 | * (at your option) any later version. | ||
8 | |||
9 | * This program is distributed in the hope that it will be useful, | ||
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
12 | * GNU General Public License for more details. | ||
13 | |||
14 | * You should have received a copy of the GNU General Public License along | ||
15 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
16 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | ||
17 | */ | ||
18 | |||
19 | #include <linux/device.h> | ||
20 | #include <linux/err.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/of.h> | ||
24 | #include <linux/of_gpio.h> | ||
25 | #include <linux/platform_device.h> | ||
26 | |||
27 | #define DRIVER_NAME "hannstar-cabc" | ||
28 | |||
29 | static const struct of_device_id cabc_dt_ids[] = { | ||
30 | { .compatible = "hannstar,cabc", }, | ||
31 | { /* sentinel */ } | ||
32 | }; | ||
33 | MODULE_DEVICE_TABLE(of, cabc_dt_ids); | ||
34 | |||
35 | static int cabc_probe(struct platform_device *pdev) | ||
36 | { | ||
37 | struct device_node *np = pdev->dev.of_node, *pp; | ||
38 | int cabc_gpio, ret = 0; | ||
39 | bool cabc_enable; | ||
40 | unsigned long gpio_flag; | ||
41 | enum of_gpio_flags flags; | ||
42 | |||
43 | for_each_child_of_node(np, pp) { | ||
44 | if (!of_find_property(pp, "gpios", NULL)) { | ||
45 | dev_warn(&pdev->dev, "Found interface without " | ||
46 | "gpios\n"); | ||
47 | continue; | ||
48 | } | ||
49 | |||
50 | cabc_gpio = of_get_gpio_flags(pp, 0, &flags); | ||
51 | if (!gpio_is_valid(cabc_gpio)) { | ||
52 | ret = cabc_gpio; | ||
53 | if (ret != -EPROBE_DEFER) | ||
54 | dev_err(&pdev->dev, | ||
55 | "Failed to get gpio flags, " | ||
56 | "error: %d\n", ret); | ||
57 | return ret; | ||
58 | } | ||
59 | |||
60 | cabc_enable = of_property_read_bool(pp, "cabc-enable"); | ||
61 | |||
62 | if (flags & OF_GPIO_ACTIVE_LOW) | ||
63 | gpio_flag = cabc_enable ? | ||
64 | GPIOF_OUT_INIT_LOW : GPIOF_OUT_INIT_HIGH; | ||
65 | else | ||
66 | gpio_flag = cabc_enable ? | ||
67 | GPIOF_OUT_INIT_HIGH : GPIOF_OUT_INIT_LOW; | ||
68 | |||
69 | devm_gpio_request_one(&pdev->dev, cabc_gpio, | ||
70 | gpio_flag, "hannstar-cabc"); | ||
71 | } | ||
72 | |||
73 | return ret; | ||
74 | } | ||
75 | |||
76 | static struct platform_driver cabc_driver = { | ||
77 | .probe = cabc_probe, | ||
78 | .driver = { | ||
79 | .of_match_table = cabc_dt_ids, | ||
80 | .name = DRIVER_NAME, | ||
81 | .owner = THIS_MODULE, | ||
82 | }, | ||
83 | }; | ||
84 | module_platform_driver(cabc_driver); | ||
85 | |||
86 | MODULE_AUTHOR("Freescale Semiconductor, Inc."); | ||
87 | MODULE_DESCRIPTION("Hannstar CABC driver"); | ||
88 | MODULE_LICENSE("GPL"); | ||
89 | MODULE_ALIAS("platform:" DRIVER_NAME); | ||