diff options
author | Vaibhav Hiremath <hvaibhav@ti.com> | 2010-04-15 10:00:00 -0400 |
---|---|---|
committer | Tomi Valkeinen <tomi.valkeinen@nokia.com> | 2010-05-18 08:05:24 -0400 |
commit | 2b88c5bc310dc7a2bf9341b86e9f01cf05e8769e (patch) | |
tree | 80999fc64758348d63d824b8a1bd8dd2c4b5db0f /drivers | |
parent | 6df37271f879f14119a0605549f1a2574e83b4fe (diff) |
OMAP: LCD LS037V7DW01: Add Backlight driver support
Tested on OMAP3EVM for OMAP3530 and AM/DM 3730.
Signed-off-by: Vaibhav Hiremath <hvaibhav@ti.com>
[tomi.valkeinen@nokia.com: added slab.h include]
[tomi.valkeinen@nokia.com: added dependency to BACKLIGHT_CLASS_DEVICE]
Signed-off-by: Tomi Valkeinen <tomi.valkeinen@nokia.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/omap2/displays/Kconfig | 1 | ||||
-rw-r--r-- | drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c | 78 |
2 files changed, 79 insertions, 0 deletions
diff --git a/drivers/video/omap2/displays/Kconfig b/drivers/video/omap2/displays/Kconfig index dfb57ee50861..ea8ccd362c22 100644 --- a/drivers/video/omap2/displays/Kconfig +++ b/drivers/video/omap2/displays/Kconfig | |||
@@ -10,6 +10,7 @@ config PANEL_GENERIC | |||
10 | config PANEL_SHARP_LS037V7DW01 | 10 | config PANEL_SHARP_LS037V7DW01 |
11 | tristate "Sharp LS037V7DW01 LCD Panel" | 11 | tristate "Sharp LS037V7DW01 LCD Panel" |
12 | depends on OMAP2_DSS | 12 | depends on OMAP2_DSS |
13 | select BACKLIGHT_CLASS_DEVICE | ||
13 | help | 14 | help |
14 | LCD Panel used in TI's SDP3430 and EVM boards | 15 | LCD Panel used in TI's SDP3430 and EVM boards |
15 | 16 | ||
diff --git a/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c b/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c index 8d51a5e6341c..7d9eb2b1f5af 100644 --- a/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c +++ b/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c | |||
@@ -20,10 +20,17 @@ | |||
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/delay.h> | 21 | #include <linux/delay.h> |
22 | #include <linux/device.h> | 22 | #include <linux/device.h> |
23 | #include <linux/backlight.h> | ||
24 | #include <linux/fb.h> | ||
23 | #include <linux/err.h> | 25 | #include <linux/err.h> |
26 | #include <linux/slab.h> | ||
24 | 27 | ||
25 | #include <plat/display.h> | 28 | #include <plat/display.h> |
26 | 29 | ||
30 | struct sharp_data { | ||
31 | struct backlight_device *bl; | ||
32 | }; | ||
33 | |||
27 | static struct omap_video_timings sharp_ls_timings = { | 34 | static struct omap_video_timings sharp_ls_timings = { |
28 | .x_res = 480, | 35 | .x_res = 480, |
29 | .y_res = 640, | 36 | .y_res = 640, |
@@ -39,18 +46,89 @@ static struct omap_video_timings sharp_ls_timings = { | |||
39 | .vbp = 1, | 46 | .vbp = 1, |
40 | }; | 47 | }; |
41 | 48 | ||
49 | static int sharp_ls_bl_update_status(struct backlight_device *bl) | ||
50 | { | ||
51 | struct omap_dss_device *dssdev = dev_get_drvdata(&bl->dev); | ||
52 | int level; | ||
53 | |||
54 | if (!dssdev->set_backlight) | ||
55 | return -EINVAL; | ||
56 | |||
57 | if (bl->props.fb_blank == FB_BLANK_UNBLANK && | ||
58 | bl->props.power == FB_BLANK_UNBLANK) | ||
59 | level = bl->props.brightness; | ||
60 | else | ||
61 | level = 0; | ||
62 | |||
63 | return dssdev->set_backlight(dssdev, level); | ||
64 | } | ||
65 | |||
66 | static int sharp_ls_bl_get_brightness(struct backlight_device *bl) | ||
67 | { | ||
68 | if (bl->props.fb_blank == FB_BLANK_UNBLANK && | ||
69 | bl->props.power == FB_BLANK_UNBLANK) | ||
70 | return bl->props.brightness; | ||
71 | |||
72 | return 0; | ||
73 | } | ||
74 | |||
75 | static const struct backlight_ops sharp_ls_bl_ops = { | ||
76 | .get_brightness = sharp_ls_bl_get_brightness, | ||
77 | .update_status = sharp_ls_bl_update_status, | ||
78 | }; | ||
79 | |||
80 | |||
81 | |||
42 | static int sharp_ls_panel_probe(struct omap_dss_device *dssdev) | 82 | static int sharp_ls_panel_probe(struct omap_dss_device *dssdev) |
43 | { | 83 | { |
84 | struct backlight_properties props; | ||
85 | struct backlight_device *bl; | ||
86 | struct sharp_data *sd; | ||
87 | int r; | ||
88 | |||
44 | dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS | | 89 | dssdev->panel.config = OMAP_DSS_LCD_TFT | OMAP_DSS_LCD_IVS | |
45 | OMAP_DSS_LCD_IHS; | 90 | OMAP_DSS_LCD_IHS; |
46 | dssdev->panel.acb = 0x28; | 91 | dssdev->panel.acb = 0x28; |
47 | dssdev->panel.timings = sharp_ls_timings; | 92 | dssdev->panel.timings = sharp_ls_timings; |
48 | 93 | ||
94 | sd = kzalloc(sizeof(*sd), GFP_KERNEL); | ||
95 | if (!sd) | ||
96 | return -ENOMEM; | ||
97 | |||
98 | dev_set_drvdata(&dssdev->dev, sd); | ||
99 | |||
100 | memset(&props, 0, sizeof(struct backlight_properties)); | ||
101 | props.max_brightness = dssdev->max_backlight_level; | ||
102 | |||
103 | bl = backlight_device_register("sharp-ls", &dssdev->dev, dssdev, | ||
104 | &sharp_ls_bl_ops, &props); | ||
105 | if (IS_ERR(bl)) { | ||
106 | r = PTR_ERR(bl); | ||
107 | kfree(sd); | ||
108 | return r; | ||
109 | } | ||
110 | sd->bl = bl; | ||
111 | |||
112 | bl->props.fb_blank = FB_BLANK_UNBLANK; | ||
113 | bl->props.power = FB_BLANK_UNBLANK; | ||
114 | bl->props.brightness = dssdev->max_backlight_level; | ||
115 | r = sharp_ls_bl_update_status(bl); | ||
116 | if (r < 0) | ||
117 | dev_err(&dssdev->dev, "failed to set lcd brightness\n"); | ||
118 | |||
49 | return 0; | 119 | return 0; |
50 | } | 120 | } |
51 | 121 | ||
52 | static void sharp_ls_panel_remove(struct omap_dss_device *dssdev) | 122 | static void sharp_ls_panel_remove(struct omap_dss_device *dssdev) |
53 | { | 123 | { |
124 | struct sharp_data *sd = dev_get_drvdata(&dssdev->dev); | ||
125 | struct backlight_device *bl = sd->bl; | ||
126 | |||
127 | bl->props.power = FB_BLANK_POWERDOWN; | ||
128 | sharp_ls_bl_update_status(bl); | ||
129 | backlight_device_unregister(bl); | ||
130 | |||
131 | kfree(sd); | ||
54 | } | 132 | } |
55 | 133 | ||
56 | static int sharp_ls_power_on(struct omap_dss_device *dssdev) | 134 | static int sharp_ls_power_on(struct omap_dss_device *dssdev) |