aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c')
-rw-r--r--drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c78
1 files changed, 78 insertions, 0 deletions
diff --git a/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c b/drivers/video/omap2/displays/panel-sharp-ls037v7dw01.c
index 8d51a5e6341..7d9eb2b1f5a 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
30struct sharp_data {
31 struct backlight_device *bl;
32};
33
27static struct omap_video_timings sharp_ls_timings = { 34static 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
49static 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
66static 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
75static 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
42static int sharp_ls_panel_probe(struct omap_dss_device *dssdev) 82static 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
52static void sharp_ls_panel_remove(struct omap_dss_device *dssdev) 122static 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
56static int sharp_ls_power_on(struct omap_dss_device *dssdev) 134static int sharp_ls_power_on(struct omap_dss_device *dssdev)