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