• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: GPL-2.0 OR MIT */
2 
3 /*
4  *  Xen para-virtual DRM device
5  *
6  * Copyright (C) 2016-2018 EPAM Systems Inc.
7  *
8  * Author: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com>
9  */
10 
11 #ifndef __XEN_DRM_FRONT_EVTCHNL_H_
12 #define __XEN_DRM_FRONT_EVTCHNL_H_
13 
14 #include <linux/completion.h>
15 #include <linux/types.h>
16 
17 #include <xen/interface/io/ring.h>
18 #include <xen/interface/io/displif.h>
19 
20 /*
21  * All operations which are not connector oriented use this ctrl event channel,
22  * e.g. fb_attach/destroy which belong to a DRM device, not to a CRTC.
23  */
24 #define GENERIC_OP_EVT_CHNL	0
25 
26 enum xen_drm_front_evtchnl_state {
27 	EVTCHNL_STATE_DISCONNECTED,
28 	EVTCHNL_STATE_CONNECTED,
29 };
30 
31 enum xen_drm_front_evtchnl_type {
32 	EVTCHNL_TYPE_REQ,
33 	EVTCHNL_TYPE_EVT,
34 };
35 
36 struct xen_drm_front_drm_info;
37 
38 struct xen_drm_front_evtchnl {
39 	struct xen_drm_front_info *front_info;
40 	int gref;
41 	int port;
42 	int irq;
43 	int index;
44 	enum xen_drm_front_evtchnl_state state;
45 	enum xen_drm_front_evtchnl_type type;
46 	/* either response id or incoming event id */
47 	u16 evt_id;
48 	/* next request id or next expected event id */
49 	u16 evt_next_id;
50 	union {
51 		struct {
52 			struct xen_displif_front_ring ring;
53 			struct completion completion;
54 			/* latest response status */
55 			int resp_status;
56 			/* serializer for backend IO: request/response */
57 			struct mutex req_io_lock;
58 		} req;
59 		struct {
60 			struct xendispl_event_page *page;
61 		} evt;
62 	} u;
63 };
64 
65 struct xen_drm_front_evtchnl_pair {
66 	struct xen_drm_front_evtchnl req;
67 	struct xen_drm_front_evtchnl evt;
68 };
69 
70 int xen_drm_front_evtchnl_create_all(struct xen_drm_front_info *front_info);
71 
72 int xen_drm_front_evtchnl_publish_all(struct xen_drm_front_info *front_info);
73 
74 void xen_drm_front_evtchnl_flush(struct xen_drm_front_evtchnl *evtchnl);
75 
76 void xen_drm_front_evtchnl_set_state(struct xen_drm_front_info *front_info,
77 				     enum xen_drm_front_evtchnl_state state);
78 
79 void xen_drm_front_evtchnl_free_all(struct xen_drm_front_info *front_info);
80 
81 #endif /* __XEN_DRM_FRONT_EVTCHNL_H_ */
82