1 /* SPDX-License-Identifier: LGPL-2.1-or-later */
2 #pragma once
3 
4 typedef enum DeviceType DeviceType;
5 typedef struct SessionDevice SessionDevice;
6 
7 #include "list.h"
8 #include "logind.h"
9 
10 enum DeviceType {
11         DEVICE_TYPE_UNKNOWN,
12         DEVICE_TYPE_DRM,
13         DEVICE_TYPE_EVDEV,
14 };
15 
16 struct SessionDevice {
17         Session *session;
18         Device *device;
19 
20         dev_t dev;
21         char *node;
22         int fd;
23         DeviceType type:3;
24         bool active:1;
25         bool pushed_fd:1;
26 
27         LIST_FIELDS(struct SessionDevice, sd_by_device);
28 };
29 
30 int session_device_new(Session *s, dev_t dev, bool open_device, SessionDevice **out);
31 void session_device_free(SessionDevice *sd);
32 void session_device_complete_pause(SessionDevice *sd);
33 
34 void session_device_resume_all(Session *s);
35 void session_device_pause_all(Session *s);
36 unsigned session_device_try_pause_all(Session *s);
37 
38 int session_device_save(SessionDevice *sd);
39 void session_device_attach_fd(SessionDevice *sd, int fd, bool active);
40