Skip to content

Commit 9370f81

Browse files
GuEe-GUIRbb666
authored andcommitted
[dm][include] fixup loss' header
Signed-off-by: GuEe-GUI <[email protected]>
1 parent dd3cee9 commit 9370f81

File tree

4 files changed

+300
-0
lines changed

4 files changed

+300
-0
lines changed
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
/*
2+
* Copyright (c) 2006-2023, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2023-02-25 GuEe-GUI the first version
9+
*/
10+
11+
#ifndef __BACKLIGHT_H__
12+
#define __BACKLIGHT_H__
13+
14+
#include <rthw.h>
15+
#include <rtdef.h>
16+
17+
struct rt_backlight_ops;
18+
19+
enum rt_backlight_power
20+
{
21+
RT_BACKLIGHT_POWER_UNBLANK,
22+
RT_BACKLIGHT_POWER_NORMAL,
23+
RT_BACKLIGHT_POWER_SUSPEND,
24+
RT_BACKLIGHT_POWER_POWERDOWN,
25+
26+
RT_BACKLIGHT_POWER_NR,
27+
};
28+
29+
struct rt_backlight_properties
30+
{
31+
rt_uint32_t brightness;
32+
rt_uint32_t max_brightness;
33+
34+
enum rt_backlight_power power;
35+
};
36+
37+
struct rt_backlight_device
38+
{
39+
struct rt_device parent;
40+
41+
struct rt_backlight_properties props;
42+
43+
const struct rt_backlight_ops *ops;
44+
45+
struct rt_mutex lock;
46+
void *priv;
47+
};
48+
49+
struct rt_backlight_ops
50+
{
51+
rt_err_t (*update_status)(struct rt_backlight_device *);
52+
rt_err_t (*get_brightness)(struct rt_backlight_device *, rt_uint32_t *out_brightness);
53+
};
54+
55+
rt_err_t rt_backlight_register(struct rt_backlight_device *bl);
56+
rt_err_t rt_backlight_unregister(struct rt_backlight_device *bl);
57+
58+
rt_err_t rt_backlight_set_power(struct rt_backlight_device *bl, enum rt_backlight_power power);
59+
rt_err_t rt_backlight_get_power(struct rt_backlight_device *bl, enum rt_backlight_power *out_power);
60+
rt_err_t rt_backlight_set_brightness(struct rt_backlight_device *bl, rt_uint32_t brightness);
61+
rt_err_t rt_backlight_get_brightness(struct rt_backlight_device *bl, rt_uint32_t *out_brightness);
62+
63+
rt_inline rt_uint32_t rt_backlight_power_brightness(struct rt_backlight_device *bl)
64+
{
65+
if (bl->props.power != RT_BACKLIGHT_POWER_UNBLANK)
66+
{
67+
return 0;
68+
}
69+
70+
return bl->props.brightness;
71+
}
72+
73+
#endif /* __BACKLIGHT_H__ */
Lines changed: 153 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,153 @@
1+
/*
2+
* Copyright (c) 2006-2022, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2022-3-08 GuEe-GUI the first version
9+
*/
10+
11+
#ifndef __INPUT_H__
12+
#define __INPUT_H__
13+
14+
#include <rtthread.h>
15+
16+
#include <bitmap.h>
17+
#include <drivers/dev_touch.h>
18+
#include <dt-bindings/input/event-codes.h>
19+
20+
struct rt_input_poller;
21+
struct rt_input_absinfo;
22+
23+
struct rt_input_event
24+
{
25+
rt_tick_t tick;
26+
27+
rt_uint16_t type;
28+
rt_uint16_t code;
29+
rt_int32_t value;
30+
};
31+
32+
struct rt_input_device
33+
{
34+
struct rt_device parent;
35+
36+
RT_BITMAP_DECLARE(cap, EV_CNT);
37+
RT_BITMAP_DECLARE(key_map, KEY_CNT);
38+
RT_BITMAP_DECLARE(rel_map, REL_CNT);
39+
RT_BITMAP_DECLARE(abs_map, ABS_CNT);
40+
41+
rt_list_t list;
42+
rt_list_t handler_nodes;
43+
struct rt_spinlock lock;
44+
45+
rt_err_t (*trigger)(struct rt_input_device *idev,
46+
rt_uint16_t type, rt_uint16_t code, rt_int32_t value);
47+
48+
struct rt_input_poller *poller;
49+
struct rt_input_absinfo *absinfo;
50+
#ifdef RT_INPUT_TOUCHSCREEN
51+
void *touch;
52+
#endif
53+
#ifdef RT_INPUT_UAPI
54+
void *uapi;
55+
#endif
56+
};
57+
58+
struct rt_input_handler
59+
{
60+
rt_list_t list;
61+
struct rt_input_device *idev;
62+
63+
rt_bool_t (*identify)(struct rt_input_handler *handler, struct rt_input_device *idev);
64+
rt_bool_t (*callback)(struct rt_input_handler *handler, struct rt_input_event *ev);
65+
66+
void *priv;
67+
};
68+
69+
struct rt_input_poller
70+
{
71+
#define RT_INPUT_POLL_INTERVAL_DEFAULT 17 /* 60fps */
72+
rt_uint32_t interval;
73+
struct rt_timer timer;
74+
75+
void (*poll)(struct rt_input_device *idev);
76+
};
77+
78+
struct rt_input_absinfo
79+
{
80+
rt_int32_t value;
81+
rt_int32_t minimum;
82+
rt_int32_t maximum;
83+
rt_int32_t fuzz;
84+
rt_int32_t flat;
85+
rt_int32_t resolution;
86+
};
87+
88+
rt_err_t rt_input_device_register(struct rt_input_device *idev);
89+
rt_err_t rt_input_device_unregister(struct rt_input_device *idev);
90+
91+
rt_err_t rt_input_set_capability(struct rt_input_device *idev,
92+
rt_uint16_t type, rt_uint16_t code);
93+
94+
rt_err_t rt_input_set_absinfo(struct rt_input_device *idev, rt_uint32_t axis,
95+
rt_int32_t min, rt_int32_t max, rt_int32_t fuzz, rt_int32_t flat);
96+
97+
rt_err_t rt_input_setup_touch(struct rt_input_device *idev,
98+
rt_uint32_t num_slots, struct rt_touch_info *info);
99+
rt_err_t rt_input_parse_touch_position(struct rt_input_device *idev,
100+
rt_uint32_t *out_x, rt_uint32_t *out_y);
101+
102+
rt_err_t rt_input_setup_polling(struct rt_input_device *idev,
103+
void (*work)(struct rt_input_device *idev));
104+
rt_err_t rt_input_set_poll_interval(struct rt_input_device *idev,
105+
rt_uint32_t interval_ms);
106+
107+
void rt_input_remove_config(struct rt_input_device *idev);
108+
109+
rt_err_t rt_input_trigger(struct rt_input_device *idev,
110+
rt_uint16_t type, rt_uint16_t code, rt_int32_t value);
111+
112+
void rt_input_event(struct rt_input_device *idev,
113+
rt_uint16_t type, rt_uint16_t code, rt_int32_t value);
114+
115+
rt_inline void rt_input_report_key(struct rt_input_device *idev,
116+
rt_uint16_t code, rt_int32_t value)
117+
{
118+
rt_input_event(idev, EV_KEY, code, !!value);
119+
}
120+
121+
rt_inline void rt_input_report_rel(struct rt_input_device *idev,
122+
rt_uint16_t code, rt_int32_t value)
123+
{
124+
rt_input_event(idev, EV_REL, code, value);
125+
}
126+
127+
rt_inline void rt_input_report_abs(struct rt_input_device *idev,
128+
rt_uint16_t code, rt_int32_t value)
129+
{
130+
rt_input_event(idev, EV_ABS, code, value);
131+
}
132+
133+
rt_inline void rt_input_report_touch_slot(struct rt_input_device *idev,
134+
rt_uint32_t slot)
135+
{
136+
rt_input_event(idev, EV_ABS, ABS_MT_SLOT, slot);
137+
}
138+
139+
rt_bool_t rt_input_report_touch_inactive(struct rt_input_device *idev,
140+
rt_bool_t active);
141+
142+
void rt_input_report_touch_position(struct rt_input_device *idev,
143+
rt_uint32_t x, rt_uint32_t y, rt_bool_t multitouch);
144+
145+
rt_inline void rt_input_sync(struct rt_input_device *idev)
146+
{
147+
rt_input_event(idev, EV_SYN, SYN_REPORT, 0);
148+
}
149+
150+
rt_err_t rt_input_add_handler(struct rt_input_handler *handler);
151+
rt_err_t rt_input_del_handler(struct rt_input_handler *handler);
152+
153+
#endif /* __INPUT_H__ */
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/*
2+
* Copyright (c) 2006-2022, RT-Thread Development Team
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Change Logs:
7+
* Date Author Notes
8+
* 2022-3-08 GuEe-GUI the first version
9+
*/
10+
11+
#ifndef __INPUT_UAPI_H__
12+
#define __INPUT_UAPI_H__
13+
14+
#include <stdint.h>
15+
#include <sys/time.h>
16+
#include <sys/ioctl.h>
17+
18+
#include <dt-bindings/input/event-codes.h>
19+
20+
struct input_event
21+
{
22+
struct timeval time;
23+
uint16_t type;
24+
uint16_t code;
25+
int32_t value;
26+
};
27+
28+
#define EV_VERSION 0x010001
29+
30+
struct input_id
31+
{
32+
uint16_t bustype;
33+
uint16_t vendor;
34+
uint16_t product;
35+
uint16_t version;
36+
};
37+
38+
struct input_absinfo
39+
{
40+
int32_t value;
41+
int32_t minimum;
42+
int32_t maximum;
43+
int32_t fuzz;
44+
int32_t flat;
45+
int32_t resolution;
46+
};
47+
48+
/* Get driver version */
49+
#define EVIOCGVERSION _IOR('E', 0x01, int)
50+
/* Get device ID */
51+
#define EVIOCGID _IOR('E', 0x02, struct input_id)
52+
53+
/* Get device name */
54+
#define EVIOCGNAME(len) _IOC(_IOC_READ, 'E', 0x06, len)
55+
/* Get device properties */
56+
#define EVIOCGPROP(len) _IOC(_IOC_READ, 'E', 0x09, len)
57+
58+
/* Get event bits */
59+
#define EVIOCGBIT(ev, len) _IOC(_IOC_READ, 'E', 0x20 + (ev), len)
60+
61+
/* Get abs value/limits */
62+
#define EVIOCGABS(abs) _IOR('E', 0x40 + (abs), struct input_absinfo)
63+
64+
/* Grab/Release device */
65+
#define EVIOCGRAB _IOW('E', 0x90, int)
66+
67+
#endif /* __INPUT_UAPI_H__ */

components/drivers/include/rtdevice.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,13 @@ extern "C" {
4646
#include "drivers/core/power_domain.h"
4747
#include "drivers/platform.h"
4848

49+
#ifdef RT_USING_GRAPHIC
50+
#include "drivers/graphic.h"
51+
#ifdef RT_GRAPHIC_BACKLIGHT
52+
#include "drivers/backlight.h"
53+
#endif /* RT_GRAPHIC_BACKLIGHT */
54+
#endif /* RT_USING_GRAPHIC */
55+
4956
#ifdef RT_USING_ATA
5057
#ifdef RT_ATA_AHCI
5158
#include "drivers/ahci.h"

0 commit comments

Comments
 (0)