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