This source file includes following definitions.
- jornada_bl_get_brightness
- jornada_bl_update_status
- jornada_bl_probe
1
2
3
4
5
6
7
8 #include <linux/backlight.h>
9 #include <linux/device.h>
10 #include <linux/fb.h>
11 #include <linux/kernel.h>
12 #include <linux/module.h>
13 #include <linux/platform_device.h>
14
15 #include <mach/jornada720.h>
16 #include <mach/hardware.h>
17
18 #include <video/s1d13xxxfb.h>
19
20 #define BL_MAX_BRIGHT 255
21 #define BL_DEF_BRIGHT 25
22
23 static int jornada_bl_get_brightness(struct backlight_device *bd)
24 {
25 int ret;
26
27
28 if (!(PPSR & PPC_LDD1))
29 return 0;
30
31 jornada_ssp_start();
32
33
34 ret = jornada_ssp_byte(GETBRIGHTNESS);
35
36 if (jornada_ssp_byte(GETBRIGHTNESS) != TXDUMMY) {
37 dev_err(&bd->dev, "get brightness timeout\n");
38 jornada_ssp_end();
39 return -ETIMEDOUT;
40 }
41
42
43 ret = jornada_ssp_byte(TXDUMMY);
44
45 jornada_ssp_end();
46
47 return BL_MAX_BRIGHT - ret;
48 }
49
50 static int jornada_bl_update_status(struct backlight_device *bd)
51 {
52 int ret = 0;
53
54 jornada_ssp_start();
55
56
57 if ((bd->props.power != FB_BLANK_UNBLANK) || (bd->props.fb_blank != FB_BLANK_UNBLANK)) {
58 ret = jornada_ssp_byte(BRIGHTNESSOFF);
59 if (ret != TXDUMMY) {
60 dev_info(&bd->dev, "brightness off timeout\n");
61
62 PPSR &= ~PPC_LDD1;
63 PPDR |= PPC_LDD1;
64 ret = -ETIMEDOUT;
65 }
66 } else
67 PPSR |= PPC_LDD1;
68
69
70 if (jornada_ssp_byte(SETBRIGHTNESS) != TXDUMMY) {
71 dev_info(&bd->dev, "failed to set brightness\n");
72 ret = -ETIMEDOUT;
73 goto out;
74 }
75
76
77
78
79
80
81
82
83 if (jornada_ssp_byte(BL_MAX_BRIGHT - bd->props.brightness)
84 != TXDUMMY) {
85 dev_err(&bd->dev, "set brightness failed\n");
86 ret = -ETIMEDOUT;
87 }
88
89
90
91
92
93 out:
94 jornada_ssp_end();
95
96 return ret;
97 }
98
99 static const struct backlight_ops jornada_bl_ops = {
100 .get_brightness = jornada_bl_get_brightness,
101 .update_status = jornada_bl_update_status,
102 .options = BL_CORE_SUSPENDRESUME,
103 };
104
105 static int jornada_bl_probe(struct platform_device *pdev)
106 {
107 struct backlight_properties props;
108 int ret;
109 struct backlight_device *bd;
110
111 memset(&props, 0, sizeof(struct backlight_properties));
112 props.type = BACKLIGHT_RAW;
113 props.max_brightness = BL_MAX_BRIGHT;
114
115 bd = devm_backlight_device_register(&pdev->dev, S1D_DEVICENAME,
116 &pdev->dev, NULL, &jornada_bl_ops,
117 &props);
118 if (IS_ERR(bd)) {
119 ret = PTR_ERR(bd);
120 dev_err(&pdev->dev, "failed to register device, err=%x\n", ret);
121 return ret;
122 }
123
124 bd->props.power = FB_BLANK_UNBLANK;
125 bd->props.brightness = BL_DEF_BRIGHT;
126
127
128
129
130
131 jornada_bl_update_status(bd);
132
133 platform_set_drvdata(pdev, bd);
134 dev_info(&pdev->dev, "HP Jornada 700 series backlight driver\n");
135
136 return 0;
137 }
138
139 static struct platform_driver jornada_bl_driver = {
140 .probe = jornada_bl_probe,
141 .driver = {
142 .name = "jornada_bl",
143 },
144 };
145
146 module_platform_driver(jornada_bl_driver);
147
148 MODULE_AUTHOR("Kristoffer Ericson <kristoffer.ericson>");
149 MODULE_DESCRIPTION("HP Jornada 710/720/728 Backlight driver");
150 MODULE_LICENSE("GPL");