/* SPDX-License-Identifier: MIT */1/******************************************************************************2* displif.h3*4* Unified display device I/O interface for Xen guest OSes.5*6* Copyright (C) 2016-2017 EPAM Systems Inc.7*8* Authors: Oleksandr Andrushchenko <[email protected]>9* Oleksandr Grytsov <[email protected]>10*/1112#ifndef __XEN_PUBLIC_IO_DISPLIF_H__13#define __XEN_PUBLIC_IO_DISPLIF_H__1415#include "ring.h"16#include "../grant_table.h"1718/*19******************************************************************************20* Protocol version21******************************************************************************22*/23#define XENDISPL_PROTOCOL_VERSION "2"24#define XENDISPL_PROTOCOL_VERSION_INT 22526/*27******************************************************************************28* Main features provided by the protocol29******************************************************************************30* This protocol aims to provide a unified protocol which fits more31* sophisticated use-cases than a framebuffer device can handle. At the32* moment basic functionality is supported with the intention to be extended:33* o multiple dynamically allocated/destroyed framebuffers34* o buffers of arbitrary sizes35* o buffer allocation at either back or front end36* o better configuration options including multiple display support37*38* Note: existing fbif can be used together with displif running at the39* same time, e.g. on Linux one provides framebuffer and another DRM/KMS40*41* Note: display resolution (XenStore's "resolution" property) defines42* visible area of the virtual display. At the same time resolution of43* the display and frame buffers may differ: buffers can be smaller, equal44* or bigger than the visible area. This is to enable use-cases, where backend45* may do some post-processing of the display and frame buffers supplied,46* e.g. those buffers can be just a part of the final composition.47*48******************************************************************************49* Direction of improvements50******************************************************************************51* Future extensions to the existing protocol may include:52* o display/connector cloning53* o allocation of objects other than display buffers54* o plane/overlay support55* o scaling support56* o rotation support57*58******************************************************************************59* Feature and Parameter Negotiation60******************************************************************************61*62* Front->back notifications: when enqueuing a new request, sending a63* notification can be made conditional on xendispl_req (i.e., the generic64* hold-off mechanism provided by the ring macros). Backends must set65* xendispl_req appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).66*67* Back->front notifications: when enqueuing a new response, sending a68* notification can be made conditional on xendispl_resp (i.e., the generic69* hold-off mechanism provided by the ring macros). Frontends must set70* xendispl_resp appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).71*72* The two halves of a para-virtual display driver utilize nodes within73* XenStore to communicate capabilities and to negotiate operating parameters.74* This section enumerates these nodes which reside in the respective front and75* backend portions of XenStore, following the XenBus convention.76*77* All data in XenStore is stored as strings. Nodes specifying numeric78* values are encoded in decimal. Integer value ranges listed below are79* expressed as fixed sized integer types capable of storing the conversion80* of a properly formated node string, without loss of information.81*82******************************************************************************83* Example configuration84******************************************************************************85*86* Note: depending on the use-case backend can expose more display connectors87* than the underlying HW physically has by employing SW graphics compositors88*89* This is an example of backend and frontend configuration:90*91*--------------------------------- Backend -----------------------------------92*93* /local/domain/0/backend/vdispl/1/0/frontend-id = "1"94* /local/domain/0/backend/vdispl/1/0/frontend = "/local/domain/1/device/vdispl/0"95* /local/domain/0/backend/vdispl/1/0/state = "4"96* /local/domain/0/backend/vdispl/1/0/versions = "1,2"97*98*--------------------------------- Frontend ----------------------------------99*100* /local/domain/1/device/vdispl/0/backend-id = "0"101* /local/domain/1/device/vdispl/0/backend = "/local/domain/0/backend/vdispl/1/0"102* /local/domain/1/device/vdispl/0/state = "4"103* /local/domain/1/device/vdispl/0/version = "1"104* /local/domain/1/device/vdispl/0/be-alloc = "1"105*106*-------------------------- Connector 0 configuration ------------------------107*108* /local/domain/1/device/vdispl/0/0/resolution = "1920x1080"109* /local/domain/1/device/vdispl/0/0/req-ring-ref = "2832"110* /local/domain/1/device/vdispl/0/0/req-event-channel = "15"111* /local/domain/1/device/vdispl/0/0/evt-ring-ref = "387"112* /local/domain/1/device/vdispl/0/0/evt-event-channel = "16"113*114*-------------------------- Connector 1 configuration ------------------------115*116* /local/domain/1/device/vdispl/0/1/resolution = "800x600"117* /local/domain/1/device/vdispl/0/1/req-ring-ref = "2833"118* /local/domain/1/device/vdispl/0/1/req-event-channel = "17"119* /local/domain/1/device/vdispl/0/1/evt-ring-ref = "388"120* /local/domain/1/device/vdispl/0/1/evt-event-channel = "18"121*122******************************************************************************123* Backend XenBus Nodes124******************************************************************************125*126*----------------------------- Protocol version ------------------------------127*128* versions129* Values: <string>130*131* List of XENDISPL_LIST_SEPARATOR separated protocol versions supported132* by the backend. For example "1,2,3".133*134******************************************************************************135* Frontend XenBus Nodes136******************************************************************************137*138*-------------------------------- Addressing ---------------------------------139*140* dom-id141* Values: <uint16_t>142*143* Domain identifier.144*145* dev-id146* Values: <uint16_t>147*148* Device identifier.149*150* conn-idx151* Values: <uint8_t>152*153* Zero based contigous index of the connector.154* /local/domain/<dom-id>/device/vdispl/<dev-id>/<conn-idx>/...155*156*----------------------------- Protocol version ------------------------------157*158* version159* Values: <string>160*161* Protocol version, chosen among the ones supported by the backend.162*163*------------------------- Backend buffer allocation -------------------------164*165* be-alloc166* Values: "0", "1"167*168* If value is set to "1", then backend can be a buffer provider/allocator169* for this domain during XENDISPL_OP_DBUF_CREATE operation (see below170* for negotiation).171* If value is not "1" or omitted frontend must allocate buffers itself.172*173*----------------------------- Connector settings ----------------------------174*175* unique-id176* Values: <string>177*178* After device instance initialization each connector is assigned a179* unique ID, so it can be identified by the backend by this ID.180* This can be UUID or such.181*182* resolution183* Values: <width, uint32_t>x<height, uint32_t>184*185* Width and height of the connector in pixels separated by186* XENDISPL_RESOLUTION_SEPARATOR. This defines visible area of the187* display.188* If backend provides extended display identification data (EDID) with189* XENDISPL_OP_GET_EDID request then EDID values must take precedence190* over the resolutions defined here.191*192*------------------ Connector Request Transport Parameters -------------------193*194* This communication path is used to deliver requests from frontend to backend195* and get the corresponding responses from backend to frontend,196* set up per connector.197*198* req-event-channel199* Values: <uint32_t>200*201* The identifier of the Xen connector's control event channel202* used to signal activity in the ring buffer.203*204* req-ring-ref205* Values: <uint32_t>206*207* The Xen grant reference granting permission for the backend to map208* a sole page of connector's control ring buffer.209*210*------------------- Connector Event Transport Parameters --------------------211*212* This communication path is used to deliver asynchronous events from backend213* to frontend, set up per connector.214*215* evt-event-channel216* Values: <uint32_t>217*218* The identifier of the Xen connector's event channel219* used to signal activity in the ring buffer.220*221* evt-ring-ref222* Values: <uint32_t>223*224* The Xen grant reference granting permission for the backend to map225* a sole page of connector's event ring buffer.226*/227228/*229******************************************************************************230* STATE DIAGRAMS231******************************************************************************232*233* Tool stack creates front and back state nodes with initial state234* XenbusStateInitialising.235* Tool stack creates and sets up frontend display configuration236* nodes per domain.237*238*-------------------------------- Normal flow --------------------------------239*240* Front Back241* ================================= =====================================242* XenbusStateInitialising XenbusStateInitialising243* o Query backend device identification244* data.245* o Open and validate backend device.246* |247* |248* V249* XenbusStateInitWait250*251* o Query frontend configuration252* o Allocate and initialize253* event channels per configured254* connector.255* o Publish transport parameters256* that will be in effect during257* this connection.258* |259* |260* V261* XenbusStateInitialised262*263* o Query frontend transport parameters.264* o Connect to the event channels.265* |266* |267* V268* XenbusStateConnected269*270* o Create and initialize OS271* virtual display connectors272* as per configuration.273* |274* |275* V276* XenbusStateConnected277*278* XenbusStateUnknown279* XenbusStateClosed280* XenbusStateClosing281* o Remove virtual display device282* o Remove event channels283* |284* |285* V286* XenbusStateClosed287*288*------------------------------- Recovery flow -------------------------------289*290* In case of frontend unrecoverable errors backend handles that as291* if frontend goes into the XenbusStateClosed state.292*293* In case of backend unrecoverable errors frontend tries removing294* the virtualized device. If this is possible at the moment of error,295* then frontend goes into the XenbusStateInitialising state and is ready for296* new connection with backend. If the virtualized device is still in use and297* cannot be removed, then frontend goes into the XenbusStateReconfiguring state298* until either the virtualized device is removed or backend initiates a new299* connection. On the virtualized device removal frontend goes into the300* XenbusStateInitialising state.301*302* Note on XenbusStateReconfiguring state of the frontend: if backend has303* unrecoverable errors then frontend cannot send requests to the backend304* and thus cannot provide functionality of the virtualized device anymore.305* After backend is back to normal the virtualized device may still hold some306* state: configuration in use, allocated buffers, client application state etc.307* In most cases, this will require frontend to implement complex recovery308* reconnect logic. Instead, by going into XenbusStateReconfiguring state,309* frontend will make sure no new clients of the virtualized device are310* accepted, allow existing client(s) to exit gracefully by signaling error311* state etc.312* Once all the clients are gone frontend can reinitialize the virtualized313* device and get into XenbusStateInitialising state again signaling the314* backend that a new connection can be made.315*316* There are multiple conditions possible under which frontend will go from317* XenbusStateReconfiguring into XenbusStateInitialising, some of them are OS318* specific. For example:319* 1. The underlying OS framework may provide callbacks to signal that the last320* client of the virtualized device has gone and the device can be removed321* 2. Frontend can schedule a deferred work (timer/tasklet/workqueue)322* to periodically check if this is the right time to re-try removal of323* the virtualized device.324* 3. By any other means.325*326******************************************************************************327* REQUEST CODES328******************************************************************************329* Request codes [0; 15] are reserved and must not be used330*/331332#define XENDISPL_OP_DBUF_CREATE 0x10333#define XENDISPL_OP_DBUF_DESTROY 0x11334#define XENDISPL_OP_FB_ATTACH 0x12335#define XENDISPL_OP_FB_DETACH 0x13336#define XENDISPL_OP_SET_CONFIG 0x14337#define XENDISPL_OP_PG_FLIP 0x15338/* The below command is available in protocol version 2 and above. */339#define XENDISPL_OP_GET_EDID 0x16340341/*342******************************************************************************343* EVENT CODES344******************************************************************************345*/346#define XENDISPL_EVT_PG_FLIP 0x00347348/*349******************************************************************************350* XENSTORE FIELD AND PATH NAME STRINGS, HELPERS351******************************************************************************352*/353#define XENDISPL_DRIVER_NAME "vdispl"354355#define XENDISPL_LIST_SEPARATOR ","356#define XENDISPL_RESOLUTION_SEPARATOR "x"357358#define XENDISPL_FIELD_BE_VERSIONS "versions"359#define XENDISPL_FIELD_FE_VERSION "version"360#define XENDISPL_FIELD_REQ_RING_REF "req-ring-ref"361#define XENDISPL_FIELD_REQ_CHANNEL "req-event-channel"362#define XENDISPL_FIELD_EVT_RING_REF "evt-ring-ref"363#define XENDISPL_FIELD_EVT_CHANNEL "evt-event-channel"364#define XENDISPL_FIELD_RESOLUTION "resolution"365#define XENDISPL_FIELD_BE_ALLOC "be-alloc"366#define XENDISPL_FIELD_UNIQUE_ID "unique-id"367368#define XENDISPL_EDID_BLOCK_SIZE 128369#define XENDISPL_EDID_BLOCK_COUNT 256370#define XENDISPL_EDID_MAX_SIZE (XENDISPL_EDID_BLOCK_SIZE * XENDISPL_EDID_BLOCK_COUNT)371372/*373******************************************************************************374* STATUS RETURN CODES375******************************************************************************376*377* Status return code is zero on success and -XEN_EXX on failure.378*379******************************************************************************380* Assumptions381******************************************************************************382* o usage of grant reference 0 as invalid grant reference:383* grant reference 0 is valid, but never exposed to a PV driver,384* because of the fact it is already in use/reserved by the PV console.385* o all references in this document to page sizes must be treated386* as pages of size XEN_PAGE_SIZE unless otherwise noted.387*388******************************************************************************389* Description of the protocol between frontend and backend driver390******************************************************************************391*392* The two halves of a Para-virtual display driver communicate with393* each other using shared pages and event channels.394* Shared page contains a ring with request/response packets.395*396* All reserved fields in the structures below must be 0.397* Display buffers's cookie of value 0 is treated as invalid.398* Framebuffer's cookie of value 0 is treated as invalid.399*400* For all request/response/event packets that use cookies:401* dbuf_cookie - uint64_t, unique to guest domain value used by the backend402* to map remote display buffer to its local one403* fb_cookie - uint64_t, unique to guest domain value used by the backend404* to map remote framebuffer to its local one405*406*---------------------------------- Requests ---------------------------------407*408* All requests/responses, which are not connector specific, must be sent over409* control ring of the connector which has the index value of 0:410* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref411*412* All request packets have the same length (64 octets)413* All request packets have common header:414* 0 1 2 3 octet415* +----------------+----------------+----------------+----------------+416* | id | operation | reserved | 4417* +----------------+----------------+----------------+----------------+418* | reserved | 8419* +----------------+----------------+----------------+----------------+420* id - uint16_t, private guest value, echoed in response421* operation - uint8_t, operation code, XENDISPL_OP_???422*423* Request dbuf creation - request creation of a display buffer.424* 0 1 2 3 octet425* +----------------+----------------+----------------+----------------+426* | id |_OP_DBUF_CREATE | reserved | 4427* +----------------+----------------+----------------+----------------+428* | reserved | 8429* +----------------+----------------+----------------+----------------+430* | dbuf_cookie low 32-bit | 12431* +----------------+----------------+----------------+----------------+432* | dbuf_cookie high 32-bit | 16433* +----------------+----------------+----------------+----------------+434* | width | 20435* +----------------+----------------+----------------+----------------+436* | height | 24437* +----------------+----------------+----------------+----------------+438* | bpp | 28439* +----------------+----------------+----------------+----------------+440* | buffer_sz | 32441* +----------------+----------------+----------------+----------------+442* | flags | 36443* +----------------+----------------+----------------+----------------+444* | gref_directory | 40445* +----------------+----------------+----------------+----------------+446* | data_ofs | 44447* +----------------+----------------+----------------+----------------+448* | reserved | 48449* +----------------+----------------+----------------+----------------+450* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|451* +----------------+----------------+----------------+----------------+452* | reserved | 64453* +----------------+----------------+----------------+----------------+454*455* Must be sent over control ring of the connector which has the index456* value of 0:457* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref458* All unused bits in flags field must be set to 0.459*460* An attempt to create multiple display buffers with the same dbuf_cookie is461* an error. dbuf_cookie can be re-used after destroying the corresponding462* display buffer.463*464* Width and height of the display buffers can be smaller, equal or bigger465* than the connector's resolution. Depth/pixel format of the individual466* buffers can differ as well.467*468* width - uint32_t, width in pixels469* height - uint32_t, height in pixels470* bpp - uint32_t, bits per pixel471* buffer_sz - uint32_t, buffer size to be allocated, octets472* flags - uint32_t, flags of the operation473* o XENDISPL_DBUF_FLG_REQ_ALLOC - if set, then backend is requested474* to allocate the buffer with the parameters provided in this request.475* Page directory is handled as follows:476* Frontend on request:477* o allocates pages for the directory (gref_directory,478* gref_dir_next_page(s)479* o grants permissions for the pages of the directory to the backend480* o sets gref_dir_next_page fields481* Backend on response:482* o grants permissions for the pages of the buffer allocated to483* the frontend484* o fills in page directory with grant references485* (gref[] in struct xendispl_page_directory)486* gref_directory - grant_ref_t, a reference to the first shared page487* describing shared buffer references. At least one page exists. If shared488* buffer size (buffer_sz) exceeds what can be addressed by this single page,489* then reference to the next page must be supplied (see gref_dir_next_page490* below)491* data_ofs - uint32_t, offset of the data in the buffer, octets492*/493494#define XENDISPL_DBUF_FLG_REQ_ALLOC (1 << 0)495496struct xendispl_dbuf_create_req {497uint64_t dbuf_cookie;498uint32_t width;499uint32_t height;500uint32_t bpp;501uint32_t buffer_sz;502uint32_t flags;503grant_ref_t gref_directory;504uint32_t data_ofs;505};506507/*508* Shared page for XENDISPL_OP_DBUF_CREATE buffer descriptor (gref_directory in509* the request) employs a list of pages, describing all pages of the shared510* data buffer:511* 0 1 2 3 octet512* +----------------+----------------+----------------+----------------+513* | gref_dir_next_page | 4514* +----------------+----------------+----------------+----------------+515* | gref[0] | 8516* +----------------+----------------+----------------+----------------+517* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|518* +----------------+----------------+----------------+----------------+519* | gref[i] | i*4+8520* +----------------+----------------+----------------+----------------+521* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|522* +----------------+----------------+----------------+----------------+523* | gref[N - 1] | N*4+8524* +----------------+----------------+----------------+----------------+525*526* gref_dir_next_page - grant_ref_t, reference to the next page describing527* page directory. Must be 0 if there are no more pages in the list.528* gref[i] - grant_ref_t, reference to a shared page of the buffer529* allocated at XENDISPL_OP_DBUF_CREATE530*531* Number of grant_ref_t entries in the whole page directory is not532* passed, but instead can be calculated as:533* num_grefs_total = (XENDISPL_OP_DBUF_CREATE.buffer_sz + XEN_PAGE_SIZE - 1) /534* XEN_PAGE_SIZE535*/536537struct xendispl_page_directory {538grant_ref_t gref_dir_next_page;539grant_ref_t gref[];540};541542/*543* Request dbuf destruction - destroy a previously allocated display buffer:544* 0 1 2 3 octet545* +----------------+----------------+----------------+----------------+546* | id |_OP_DBUF_DESTROY| reserved | 4547* +----------------+----------------+----------------+----------------+548* | reserved | 8549* +----------------+----------------+----------------+----------------+550* | dbuf_cookie low 32-bit | 12551* +----------------+----------------+----------------+----------------+552* | dbuf_cookie high 32-bit | 16553* +----------------+----------------+----------------+----------------+554* | reserved | 20555* +----------------+----------------+----------------+----------------+556* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|557* +----------------+----------------+----------------+----------------+558* | reserved | 64559* +----------------+----------------+----------------+----------------+560*561* Must be sent over control ring of the connector which has the index562* value of 0:563* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref564*/565566struct xendispl_dbuf_destroy_req {567uint64_t dbuf_cookie;568};569570/*571* Request framebuffer attachment - request attachment of a framebuffer to572* previously created display buffer.573* 0 1 2 3 octet574* +----------------+----------------+----------------+----------------+575* | id | _OP_FB_ATTACH | reserved | 4576* +----------------+----------------+----------------+----------------+577* | reserved | 8578* +----------------+----------------+----------------+----------------+579* | dbuf_cookie low 32-bit | 12580* +----------------+----------------+----------------+----------------+581* | dbuf_cookie high 32-bit | 16582* +----------------+----------------+----------------+----------------+583* | fb_cookie low 32-bit | 20584* +----------------+----------------+----------------+----------------+585* | fb_cookie high 32-bit | 24586* +----------------+----------------+----------------+----------------+587* | width | 28588* +----------------+----------------+----------------+----------------+589* | height | 32590* +----------------+----------------+----------------+----------------+591* | pixel_format | 36592* +----------------+----------------+----------------+----------------+593* | reserved | 40594* +----------------+----------------+----------------+----------------+595* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|596* +----------------+----------------+----------------+----------------+597* | reserved | 64598* +----------------+----------------+----------------+----------------+599*600* Must be sent over control ring of the connector which has the index601* value of 0:602* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref603* Width and height can be smaller, equal or bigger than the connector's604* resolution.605*606* An attempt to create multiple frame buffers with the same fb_cookie is607* an error. fb_cookie can be re-used after destroying the corresponding608* frame buffer.609*610* width - uint32_t, width in pixels611* height - uint32_t, height in pixels612* pixel_format - uint32_t, pixel format of the framebuffer, FOURCC code613*/614615struct xendispl_fb_attach_req {616uint64_t dbuf_cookie;617uint64_t fb_cookie;618uint32_t width;619uint32_t height;620uint32_t pixel_format;621};622623/*624* Request framebuffer detach - detach a previously625* attached framebuffer from the display buffer in request:626* 0 1 2 3 octet627* +----------------+----------------+----------------+----------------+628* | id | _OP_FB_DETACH | reserved | 4629* +----------------+----------------+----------------+----------------+630* | reserved | 8631* +----------------+----------------+----------------+----------------+632* | fb_cookie low 32-bit | 12633* +----------------+----------------+----------------+----------------+634* | fb_cookie high 32-bit | 16635* +----------------+----------------+----------------+----------------+636* | reserved | 20637* +----------------+----------------+----------------+----------------+638* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|639* +----------------+----------------+----------------+----------------+640* | reserved | 64641* +----------------+----------------+----------------+----------------+642*643* Must be sent over control ring of the connector which has the index644* value of 0:645* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref646*/647648struct xendispl_fb_detach_req {649uint64_t fb_cookie;650};651652/*653* Request configuration set/reset - request to set or reset654* the configuration/mode of the display:655* 0 1 2 3 octet656* +----------------+----------------+----------------+----------------+657* | id | _OP_SET_CONFIG | reserved | 4658* +----------------+----------------+----------------+----------------+659* | reserved | 8660* +----------------+----------------+----------------+----------------+661* | fb_cookie low 32-bit | 12662* +----------------+----------------+----------------+----------------+663* | fb_cookie high 32-bit | 16664* +----------------+----------------+----------------+----------------+665* | x | 20666* +----------------+----------------+----------------+----------------+667* | y | 24668* +----------------+----------------+----------------+----------------+669* | width | 28670* +----------------+----------------+----------------+----------------+671* | height | 32672* +----------------+----------------+----------------+----------------+673* | bpp | 40674* +----------------+----------------+----------------+----------------+675* | reserved | 44676* +----------------+----------------+----------------+----------------+677* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|678* +----------------+----------------+----------------+----------------+679* | reserved | 64680* +----------------+----------------+----------------+----------------+681*682* Pass all zeros to reset, otherwise command is treated as683* configuration set.684* Framebuffer's cookie defines which framebuffer/dbuf must be685* displayed while enabling display (applying configuration).686* x, y, width and height are bound by the connector's resolution and must not687* exceed it.688*689* x - uint32_t, starting position in pixels by X axis690* y - uint32_t, starting position in pixels by Y axis691* width - uint32_t, width in pixels692* height - uint32_t, height in pixels693* bpp - uint32_t, bits per pixel694*/695696struct xendispl_set_config_req {697uint64_t fb_cookie;698uint32_t x;699uint32_t y;700uint32_t width;701uint32_t height;702uint32_t bpp;703};704705/*706* Request page flip - request to flip a page identified by the framebuffer707* cookie:708* 0 1 2 3 octet709* +----------------+----------------+----------------+----------------+710* | id | _OP_PG_FLIP | reserved | 4711* +----------------+----------------+----------------+----------------+712* | reserved | 8713* +----------------+----------------+----------------+----------------+714* | fb_cookie low 32-bit | 12715* +----------------+----------------+----------------+----------------+716* | fb_cookie high 32-bit | 16717* +----------------+----------------+----------------+----------------+718* | reserved | 20719* +----------------+----------------+----------------+----------------+720* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|721* +----------------+----------------+----------------+----------------+722* | reserved | 64723* +----------------+----------------+----------------+----------------+724*/725726struct xendispl_page_flip_req {727uint64_t fb_cookie;728};729730/*731* Request EDID - request EDID describing current connector:732* 0 1 2 3 octet733* +----------------+----------------+----------------+----------------+734* | id | _OP_GET_EDID | reserved | 4735* +----------------+----------------+----------------+----------------+736* | buffer_sz | 8737* +----------------+----------------+----------------+----------------+738* | gref_directory | 12739* +----------------+----------------+----------------+----------------+740* | reserved | 16741* +----------------+----------------+----------------+----------------+742* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|743* +----------------+----------------+----------------+----------------+744* | reserved | 64745* +----------------+----------------+----------------+----------------+746*747* Notes:748* - This command is not available in protocol version 1 and should be749* ignored.750* - This request is optional and if not supported then visible area751* is defined by the relevant XenStore's "resolution" property.752* - Shared buffer, allocated for EDID storage, must not be less then753* XENDISPL_EDID_MAX_SIZE octets.754*755* buffer_sz - uint32_t, buffer size to be allocated, octets756* gref_directory - grant_ref_t, a reference to the first shared page757* describing EDID buffer references. See XENDISPL_OP_DBUF_CREATE for758* grant page directory structure (struct xendispl_page_directory).759*760* See response format for this request.761*/762763struct xendispl_get_edid_req {764uint32_t buffer_sz;765grant_ref_t gref_directory;766};767768/*769*---------------------------------- Responses --------------------------------770*771* All response packets have the same length (64 octets)772*773* All response packets have common header:774* 0 1 2 3 octet775* +----------------+----------------+----------------+----------------+776* | id | reserved | 4777* +----------------+----------------+----------------+----------------+778* | status | 8779* +----------------+----------------+----------------+----------------+780* | reserved | 12781* +----------------+----------------+----------------+----------------+782* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|783* +----------------+----------------+----------------+----------------+784* | reserved | 64785* +----------------+----------------+----------------+----------------+786*787* id - uint16_t, private guest value, echoed from request788* status - int32_t, response status, zero on success and -XEN_EXX on failure789*790*791* Get EDID response - response for XENDISPL_OP_GET_EDID:792* 0 1 2 3 octet793* +----------------+----------------+----------------+----------------+794* | id | operation | reserved | 4795* +----------------+----------------+----------------+----------------+796* | status | 8797* +----------------+----------------+----------------+----------------+798* | edid_sz | 12799* +----------------+----------------+----------------+----------------+800* | reserved | 16801* +----------------+----------------+----------------+----------------+802* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|803* +----------------+----------------+----------------+----------------+804* | reserved | 64805* +----------------+----------------+----------------+----------------+806*807* Notes:808* - This response is not available in protocol version 1 and should be809* ignored.810*811* edid_sz - uint32_t, size of the EDID, octets812*/813814struct xendispl_get_edid_resp {815uint32_t edid_sz;816};817818/*819*----------------------------------- Events ----------------------------------820*821* Events are sent via a shared page allocated by the front and propagated by822* evt-event-channel/evt-ring-ref XenStore entries823* All event packets have the same length (64 octets)824* All event packets have common header:825* 0 1 2 3 octet826* +----------------+----------------+----------------+----------------+827* | id | type | reserved | 4828* +----------------+----------------+----------------+----------------+829* | reserved | 8830* +----------------+----------------+----------------+----------------+831*832* id - uint16_t, event id, may be used by front833* type - uint8_t, type of the event834*835*836* Page flip complete event - event from back to front on page flip completed:837* 0 1 2 3 octet838* +----------------+----------------+----------------+----------------+839* | id | _EVT_PG_FLIP | reserved | 4840* +----------------+----------------+----------------+----------------+841* | reserved | 8842* +----------------+----------------+----------------+----------------+843* | fb_cookie low 32-bit | 12844* +----------------+----------------+----------------+----------------+845* | fb_cookie high 32-bit | 16846* +----------------+----------------+----------------+----------------+847* | reserved | 20848* +----------------+----------------+----------------+----------------+849* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|850* +----------------+----------------+----------------+----------------+851* | reserved | 64852* +----------------+----------------+----------------+----------------+853*/854855struct xendispl_pg_flip_evt {856uint64_t fb_cookie;857};858859struct xendispl_req {860uint16_t id;861uint8_t operation;862uint8_t reserved[5];863union {864struct xendispl_dbuf_create_req dbuf_create;865struct xendispl_dbuf_destroy_req dbuf_destroy;866struct xendispl_fb_attach_req fb_attach;867struct xendispl_fb_detach_req fb_detach;868struct xendispl_set_config_req set_config;869struct xendispl_page_flip_req pg_flip;870struct xendispl_get_edid_req get_edid;871uint8_t reserved[56];872} op;873};874875struct xendispl_resp {876uint16_t id;877uint8_t operation;878uint8_t reserved;879int32_t status;880union {881struct xendispl_get_edid_resp get_edid;882uint8_t reserved1[56];883} op;884};885886struct xendispl_evt {887uint16_t id;888uint8_t type;889uint8_t reserved[5];890union {891struct xendispl_pg_flip_evt pg_flip;892uint8_t reserved[56];893} op;894};895896DEFINE_RING_TYPES(xen_displif, struct xendispl_req, struct xendispl_resp);897898/*899******************************************************************************900* Back to front events delivery901******************************************************************************902* In order to deliver asynchronous events from back to front a shared page is903* allocated by front and its granted reference propagated to back via904* XenStore entries (evt-ring-ref/evt-event-channel).905* This page has a common header used by both front and back to synchronize906* access and control event's ring buffer, while back being a producer of the907* events and front being a consumer. The rest of the page after the header908* is used for event packets.909*910* Upon reception of an event(s) front may confirm its reception911* for either each event, group of events or none.912*/913914struct xendispl_event_page {915uint32_t in_cons;916uint32_t in_prod;917uint8_t reserved[56];918};919920#define XENDISPL_EVENT_PAGE_SIZE XEN_PAGE_SIZE921#define XENDISPL_IN_RING_OFFS (sizeof(struct xendispl_event_page))922#define XENDISPL_IN_RING_SIZE (XENDISPL_EVENT_PAGE_SIZE - XENDISPL_IN_RING_OFFS)923#define XENDISPL_IN_RING_LEN (XENDISPL_IN_RING_SIZE / sizeof(struct xendispl_evt))924#define XENDISPL_IN_RING(page) \925((struct xendispl_evt *)((char *)(page) + XENDISPL_IN_RING_OFFS))926#define XENDISPL_IN_RING_REF(page, idx) \927(XENDISPL_IN_RING((page))[(idx) % XENDISPL_IN_RING_LEN])928929#endif /* __XEN_PUBLIC_IO_DISPLIF_H__ */930931932