/******************************************************************************1* displif.h2*3* Unified display device I/O interface for Xen guest OSes.4*5* Permission is hereby granted, free of charge, to any person obtaining a copy6* of this software and associated documentation files (the "Software"), to7* deal in the Software without restriction, including without limitation the8* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or9* sell copies of the Software, and to permit persons to whom the Software is10* furnished to do so, subject to the following conditions:11*12* The above copyright notice and this permission notice shall be included in13* all copies or substantial portions of the Software.14*15* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR16* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,17* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE18* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER19* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING20* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER21* DEALINGS IN THE SOFTWARE.22*23* Copyright (C) 2016-2017 EPAM Systems Inc.24*25* Authors: Oleksandr Andrushchenko <[email protected]>26* Oleksandr Grytsov <[email protected]>27*/2829#ifndef __XEN_PUBLIC_IO_DISPLIF_H__30#define __XEN_PUBLIC_IO_DISPLIF_H__3132#include "ring.h"33#include "../grant_table.h"3435/*36******************************************************************************37* Protocol version38******************************************************************************39*/40#define XENDISPL_PROTOCOL_VERSION "2"41#define XENDISPL_PROTOCOL_VERSION_INT 24243/*44******************************************************************************45* Main features provided by the protocol46******************************************************************************47* This protocol aims to provide a unified protocol which fits more48* sophisticated use-cases than a framebuffer device can handle. At the49* moment basic functionality is supported with the intention to be extended:50* o multiple dynamically allocated/destroyed framebuffers51* o buffers of arbitrary sizes52* o buffer allocation at either back or front end53* o better configuration options including multiple display support54*55* Note: existing fbif can be used together with displif running at the56* same time, e.g. on Linux one provides framebuffer and another DRM/KMS57*58* Note: display resolution (XenStore's "resolution" property) defines59* visible area of the virtual display. At the same time resolution of60* the display and frame buffers may differ: buffers can be smaller, equal61* or bigger than the visible area. This is to enable use-cases, where backend62* may do some post-processing of the display and frame buffers supplied,63* e.g. those buffers can be just a part of the final composition.64*65******************************************************************************66* Direction of improvements67******************************************************************************68* Future extensions to the existing protocol may include:69* o display/connector cloning70* o allocation of objects other than display buffers71* o plane/overlay support72* o scaling support73* o rotation support74*75******************************************************************************76* Feature and Parameter Negotiation77******************************************************************************78*79* Front->back notifications: when enqueuing a new request, sending a80* notification can be made conditional on xendispl_req (i.e., the generic81* hold-off mechanism provided by the ring macros). Backends must set82* xendispl_req appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).83*84* Back->front notifications: when enqueuing a new response, sending a85* notification can be made conditional on xendispl_resp (i.e., the generic86* hold-off mechanism provided by the ring macros). Frontends must set87* xendispl_resp appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).88*89* The two halves of a para-virtual display driver utilize nodes within90* XenStore to communicate capabilities and to negotiate operating parameters.91* This section enumerates these nodes which reside in the respective front and92* backend portions of XenStore, following the XenBus convention.93*94* All data in XenStore is stored as strings. Nodes specifying numeric95* values are encoded in decimal. Integer value ranges listed below are96* expressed as fixed sized integer types capable of storing the conversion97* of a properly formated node string, without loss of information.98*99******************************************************************************100* Example configuration101******************************************************************************102*103* Note: depending on the use-case backend can expose more display connectors104* than the underlying HW physically has by employing SW graphics compositors105*106* This is an example of backend and frontend configuration:107*108*--------------------------------- Backend -----------------------------------109*110* /local/domain/0/backend/vdispl/1/0/frontend-id = "1"111* /local/domain/0/backend/vdispl/1/0/frontend = "/local/domain/1/device/vdispl/0"112* /local/domain/0/backend/vdispl/1/0/state = "4"113* /local/domain/0/backend/vdispl/1/0/versions = "1,2"114*115*--------------------------------- Frontend ----------------------------------116*117* /local/domain/1/device/vdispl/0/backend-id = "0"118* /local/domain/1/device/vdispl/0/backend = "/local/domain/0/backend/vdispl/1/0"119* /local/domain/1/device/vdispl/0/state = "4"120* /local/domain/1/device/vdispl/0/version = "1"121* /local/domain/1/device/vdispl/0/be-alloc = "1"122*123*-------------------------- Connector 0 configuration ------------------------124*125* /local/domain/1/device/vdispl/0/0/resolution = "1920x1080"126* /local/domain/1/device/vdispl/0/0/req-ring-ref = "2832"127* /local/domain/1/device/vdispl/0/0/req-event-channel = "15"128* /local/domain/1/device/vdispl/0/0/evt-ring-ref = "387"129* /local/domain/1/device/vdispl/0/0/evt-event-channel = "16"130*131*-------------------------- Connector 1 configuration ------------------------132*133* /local/domain/1/device/vdispl/0/1/resolution = "800x600"134* /local/domain/1/device/vdispl/0/1/req-ring-ref = "2833"135* /local/domain/1/device/vdispl/0/1/req-event-channel = "17"136* /local/domain/1/device/vdispl/0/1/evt-ring-ref = "388"137* /local/domain/1/device/vdispl/0/1/evt-event-channel = "18"138*139******************************************************************************140* Backend XenBus Nodes141******************************************************************************142*143*----------------------------- Protocol version ------------------------------144*145* versions146* Values: <string>147*148* List of XENDISPL_LIST_SEPARATOR separated protocol versions supported149* by the backend. For example "1,2,3".150*151******************************************************************************152* Frontend XenBus Nodes153******************************************************************************154*155*-------------------------------- Addressing ---------------------------------156*157* dom-id158* Values: <uint16_t>159*160* Domain identifier.161*162* dev-id163* Values: <uint16_t>164*165* Device identifier.166*167* conn-idx168* Values: <uint8_t>169*170* Zero based contigous index of the connector.171* /local/domain/<dom-id>/device/vdispl/<dev-id>/<conn-idx>/...172*173*----------------------------- Protocol version ------------------------------174*175* version176* Values: <string>177*178* Protocol version, chosen among the ones supported by the backend.179*180*------------------------- Backend buffer allocation -------------------------181*182* be-alloc183* Values: "0", "1"184*185* If value is set to "1", then backend can be a buffer provider/allocator186* for this domain during XENDISPL_OP_DBUF_CREATE operation (see below187* for negotiation).188* If value is not "1" or omitted frontend must allocate buffers itself.189*190*----------------------------- Connector settings ----------------------------191*192* unique-id193* Values: <string>194*195* After device instance initialization each connector is assigned a196* unique ID, so it can be identified by the backend by this ID.197* This can be UUID or such.198*199* resolution200* Values: <width, uint32_t>x<height, uint32_t>201*202* Width and height of the connector in pixels separated by203* XENDISPL_RESOLUTION_SEPARATOR. This defines visible area of the204* display.205* If backend provides extended display identification data (EDID) with206* XENDISPL_OP_GET_EDID request then EDID values must take precedence207* over the resolutions defined here.208*209*------------------ Connector Request Transport Parameters -------------------210*211* This communication path is used to deliver requests from frontend to backend212* and get the corresponding responses from backend to frontend,213* set up per connector.214*215* req-event-channel216* Values: <uint32_t>217*218* The identifier of the Xen connector's control event channel219* used to signal activity in the ring buffer.220*221* req-ring-ref222* Values: <uint32_t>223*224* The Xen grant reference granting permission for the backend to map225* a sole page of connector's control ring buffer.226*227*------------------- Connector Event Transport Parameters --------------------228*229* This communication path is used to deliver asynchronous events from backend230* to frontend, set up per connector.231*232* evt-event-channel233* Values: <uint32_t>234*235* The identifier of the Xen connector's event channel236* used to signal activity in the ring buffer.237*238* evt-ring-ref239* Values: <uint32_t>240*241* The Xen grant reference granting permission for the backend to map242* a sole page of connector's event ring buffer.243*/244245/*246******************************************************************************247* STATE DIAGRAMS248******************************************************************************249*250* Tool stack creates front and back state nodes with initial state251* XenbusStateInitialising.252* Tool stack creates and sets up frontend display configuration253* nodes per domain.254*255*-------------------------------- Normal flow --------------------------------256*257* Front Back258* ================================= =====================================259* XenbusStateInitialising XenbusStateInitialising260* o Query backend device identification261* data.262* o Open and validate backend device.263* |264* |265* V266* XenbusStateInitWait267*268* o Query frontend configuration269* o Allocate and initialize270* event channels per configured271* connector.272* o Publish transport parameters273* that will be in effect during274* this connection.275* |276* |277* V278* XenbusStateInitialised279*280* o Query frontend transport parameters.281* o Connect to the event channels.282* |283* |284* V285* XenbusStateConnected286*287* o Create and initialize OS288* virtual display connectors289* as per configuration.290* |291* |292* V293* XenbusStateConnected294*295* XenbusStateUnknown296* XenbusStateClosed297* XenbusStateClosing298* o Remove virtual display device299* o Remove event channels300* |301* |302* V303* XenbusStateClosed304*305*------------------------------- Recovery flow -------------------------------306*307* In case of frontend unrecoverable errors backend handles that as308* if frontend goes into the XenbusStateClosed state.309*310* In case of backend unrecoverable errors frontend tries removing311* the virtualized device. If this is possible at the moment of error,312* then frontend goes into the XenbusStateInitialising state and is ready for313* new connection with backend. If the virtualized device is still in use and314* cannot be removed, then frontend goes into the XenbusStateReconfiguring state315* until either the virtualized device is removed or backend initiates a new316* connection. On the virtualized device removal frontend goes into the317* XenbusStateInitialising state.318*319* Note on XenbusStateReconfiguring state of the frontend: if backend has320* unrecoverable errors then frontend cannot send requests to the backend321* and thus cannot provide functionality of the virtualized device anymore.322* After backend is back to normal the virtualized device may still hold some323* state: configuration in use, allocated buffers, client application state etc.324* In most cases, this will require frontend to implement complex recovery325* reconnect logic. Instead, by going into XenbusStateReconfiguring state,326* frontend will make sure no new clients of the virtualized device are327* accepted, allow existing client(s) to exit gracefully by signaling error328* state etc.329* Once all the clients are gone frontend can reinitialize the virtualized330* device and get into XenbusStateInitialising state again signaling the331* backend that a new connection can be made.332*333* There are multiple conditions possible under which frontend will go from334* XenbusStateReconfiguring into XenbusStateInitialising, some of them are OS335* specific. For example:336* 1. The underlying OS framework may provide callbacks to signal that the last337* client of the virtualized device has gone and the device can be removed338* 2. Frontend can schedule a deferred work (timer/tasklet/workqueue)339* to periodically check if this is the right time to re-try removal of340* the virtualized device.341* 3. By any other means.342*343******************************************************************************344* REQUEST CODES345******************************************************************************346* Request codes [0; 15] are reserved and must not be used347*/348349#define XENDISPL_OP_DBUF_CREATE 0x10350#define XENDISPL_OP_DBUF_DESTROY 0x11351#define XENDISPL_OP_FB_ATTACH 0x12352#define XENDISPL_OP_FB_DETACH 0x13353#define XENDISPL_OP_SET_CONFIG 0x14354#define XENDISPL_OP_PG_FLIP 0x15355/* The below command is available in protocol version 2 and above. */356#define XENDISPL_OP_GET_EDID 0x16357358/*359******************************************************************************360* EVENT CODES361******************************************************************************362*/363#define XENDISPL_EVT_PG_FLIP 0x00364365/*366******************************************************************************367* XENSTORE FIELD AND PATH NAME STRINGS, HELPERS368******************************************************************************369*/370#define XENDISPL_DRIVER_NAME "vdispl"371372#define XENDISPL_LIST_SEPARATOR ","373#define XENDISPL_RESOLUTION_SEPARATOR "x"374375#define XENDISPL_FIELD_BE_VERSIONS "versions"376#define XENDISPL_FIELD_FE_VERSION "version"377#define XENDISPL_FIELD_REQ_RING_REF "req-ring-ref"378#define XENDISPL_FIELD_REQ_CHANNEL "req-event-channel"379#define XENDISPL_FIELD_EVT_RING_REF "evt-ring-ref"380#define XENDISPL_FIELD_EVT_CHANNEL "evt-event-channel"381#define XENDISPL_FIELD_RESOLUTION "resolution"382#define XENDISPL_FIELD_BE_ALLOC "be-alloc"383#define XENDISPL_FIELD_UNIQUE_ID "unique-id"384385#define XENDISPL_EDID_BLOCK_SIZE 128386#define XENDISPL_EDID_BLOCK_COUNT 256387#define XENDISPL_EDID_MAX_SIZE (XENDISPL_EDID_BLOCK_SIZE * XENDISPL_EDID_BLOCK_COUNT)388389/*390******************************************************************************391* STATUS RETURN CODES392******************************************************************************393*394* Status return code is zero on success and -XEN_EXX on failure.395*396******************************************************************************397* Assumptions398******************************************************************************399* o usage of grant reference 0 as invalid grant reference:400* grant reference 0 is valid, but never exposed to a PV driver,401* because of the fact it is already in use/reserved by the PV console.402* o all references in this document to page sizes must be treated403* as pages of size XEN_PAGE_SIZE unless otherwise noted.404*405******************************************************************************406* Description of the protocol between frontend and backend driver407******************************************************************************408*409* The two halves of a Para-virtual display driver communicate with410* each other using shared pages and event channels.411* Shared page contains a ring with request/response packets.412*413* All reserved fields in the structures below must be 0.414* Display buffers's cookie of value 0 is treated as invalid.415* Framebuffer's cookie of value 0 is treated as invalid.416*417* For all request/response/event packets that use cookies:418* dbuf_cookie - uint64_t, unique to guest domain value used by the backend419* to map remote display buffer to its local one420* fb_cookie - uint64_t, unique to guest domain value used by the backend421* to map remote framebuffer to its local one422*423*---------------------------------- Requests ---------------------------------424*425* All requests/responses, which are not connector specific, must be sent over426* control ring of the connector which has the index value of 0:427* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref428*429* All request packets have the same length (64 octets)430* All request packets have common header:431* 0 1 2 3 octet432* +----------------+----------------+----------------+----------------+433* | id | operation | reserved | 4434* +----------------+----------------+----------------+----------------+435* | reserved | 8436* +----------------+----------------+----------------+----------------+437* id - uint16_t, private guest value, echoed in response438* operation - uint8_t, operation code, XENDISPL_OP_???439*440* Request dbuf creation - request creation of a display buffer.441* 0 1 2 3 octet442* +----------------+----------------+----------------+----------------+443* | id |_OP_DBUF_CREATE | reserved | 4444* +----------------+----------------+----------------+----------------+445* | reserved | 8446* +----------------+----------------+----------------+----------------+447* | dbuf_cookie low 32-bit | 12448* +----------------+----------------+----------------+----------------+449* | dbuf_cookie high 32-bit | 16450* +----------------+----------------+----------------+----------------+451* | width | 20452* +----------------+----------------+----------------+----------------+453* | height | 24454* +----------------+----------------+----------------+----------------+455* | bpp | 28456* +----------------+----------------+----------------+----------------+457* | buffer_sz | 32458* +----------------+----------------+----------------+----------------+459* | flags | 36460* +----------------+----------------+----------------+----------------+461* | gref_directory | 40462* +----------------+----------------+----------------+----------------+463* | data_ofs | 44464* +----------------+----------------+----------------+----------------+465* | reserved | 48466* +----------------+----------------+----------------+----------------+467* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|468* +----------------+----------------+----------------+----------------+469* | reserved | 64470* +----------------+----------------+----------------+----------------+471*472* Must be sent over control ring of the connector which has the index473* value of 0:474* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref475* All unused bits in flags field must be set to 0.476*477* An attempt to create multiple display buffers with the same dbuf_cookie is478* an error. dbuf_cookie can be re-used after destroying the corresponding479* display buffer.480*481* Width and height of the display buffers can be smaller, equal or bigger482* than the connector's resolution. Depth/pixel format of the individual483* buffers can differ as well.484*485* width - uint32_t, width in pixels486* height - uint32_t, height in pixels487* bpp - uint32_t, bits per pixel488* buffer_sz - uint32_t, buffer size to be allocated, octets489* flags - uint32_t, flags of the operation490* o XENDISPL_DBUF_FLG_REQ_ALLOC - if set, then backend is requested491* to allocate the buffer with the parameters provided in this request.492* Page directory is handled as follows:493* Frontend on request:494* o allocates pages for the directory (gref_directory,495* gref_dir_next_page(s)496* o grants permissions for the pages of the directory to the backend497* o sets gref_dir_next_page fields498* Backend on response:499* o grants permissions for the pages of the buffer allocated to500* the frontend501* o fills in page directory with grant references502* (gref[] in struct xendispl_page_directory)503* gref_directory - grant_ref_t, a reference to the first shared page504* describing shared buffer references. At least one page exists. If shared505* buffer size (buffer_sz) exceeds what can be addressed by this single page,506* then reference to the next page must be supplied (see gref_dir_next_page507* below)508* data_ofs - uint32_t, offset of the data in the buffer, octets509*/510511#define XENDISPL_DBUF_FLG_REQ_ALLOC (1 << 0)512513struct xendispl_dbuf_create_req {514uint64_t dbuf_cookie;515uint32_t width;516uint32_t height;517uint32_t bpp;518uint32_t buffer_sz;519uint32_t flags;520grant_ref_t gref_directory;521uint32_t data_ofs;522};523524/*525* Shared page for XENDISPL_OP_DBUF_CREATE buffer descriptor (gref_directory in526* the request) employs a list of pages, describing all pages of the shared527* data buffer:528* 0 1 2 3 octet529* +----------------+----------------+----------------+----------------+530* | gref_dir_next_page | 4531* +----------------+----------------+----------------+----------------+532* | gref[0] | 8533* +----------------+----------------+----------------+----------------+534* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|535* +----------------+----------------+----------------+----------------+536* | gref[i] | i*4+8537* +----------------+----------------+----------------+----------------+538* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|539* +----------------+----------------+----------------+----------------+540* | gref[N - 1] | N*4+8541* +----------------+----------------+----------------+----------------+542*543* gref_dir_next_page - grant_ref_t, reference to the next page describing544* page directory. Must be 0 if there are no more pages in the list.545* gref[i] - grant_ref_t, reference to a shared page of the buffer546* allocated at XENDISPL_OP_DBUF_CREATE547*548* Number of grant_ref_t entries in the whole page directory is not549* passed, but instead can be calculated as:550* num_grefs_total = (XENDISPL_OP_DBUF_CREATE.buffer_sz + XEN_PAGE_SIZE - 1) /551* XEN_PAGE_SIZE552*/553554struct xendispl_page_directory {555grant_ref_t gref_dir_next_page;556grant_ref_t gref[1]; /* Variable length */557};558559/*560* Request dbuf destruction - destroy a previously allocated display buffer:561* 0 1 2 3 octet562* +----------------+----------------+----------------+----------------+563* | id |_OP_DBUF_DESTROY| reserved | 4564* +----------------+----------------+----------------+----------------+565* | reserved | 8566* +----------------+----------------+----------------+----------------+567* | dbuf_cookie low 32-bit | 12568* +----------------+----------------+----------------+----------------+569* | dbuf_cookie high 32-bit | 16570* +----------------+----------------+----------------+----------------+571* | reserved | 20572* +----------------+----------------+----------------+----------------+573* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|574* +----------------+----------------+----------------+----------------+575* | reserved | 64576* +----------------+----------------+----------------+----------------+577*578* Must be sent over control ring of the connector which has the index579* value of 0:580* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref581*/582583struct xendispl_dbuf_destroy_req {584uint64_t dbuf_cookie;585};586587/*588* Request framebuffer attachment - request attachment of a framebuffer to589* previously created display buffer.590* 0 1 2 3 octet591* +----------------+----------------+----------------+----------------+592* | id | _OP_FB_ATTACH | reserved | 4593* +----------------+----------------+----------------+----------------+594* | reserved | 8595* +----------------+----------------+----------------+----------------+596* | dbuf_cookie low 32-bit | 12597* +----------------+----------------+----------------+----------------+598* | dbuf_cookie high 32-bit | 16599* +----------------+----------------+----------------+----------------+600* | fb_cookie low 32-bit | 20601* +----------------+----------------+----------------+----------------+602* | fb_cookie high 32-bit | 24603* +----------------+----------------+----------------+----------------+604* | width | 28605* +----------------+----------------+----------------+----------------+606* | height | 32607* +----------------+----------------+----------------+----------------+608* | pixel_format | 36609* +----------------+----------------+----------------+----------------+610* | reserved | 40611* +----------------+----------------+----------------+----------------+612* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|613* +----------------+----------------+----------------+----------------+614* | reserved | 64615* +----------------+----------------+----------------+----------------+616*617* Must be sent over control ring of the connector which has the index618* value of 0:619* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref620* Width and height can be smaller, equal or bigger than the connector's621* resolution.622*623* An attempt to create multiple frame buffers with the same fb_cookie is624* an error. fb_cookie can be re-used after destroying the corresponding625* frame buffer.626*627* width - uint32_t, width in pixels628* height - uint32_t, height in pixels629* pixel_format - uint32_t, pixel format of the framebuffer, FOURCC code630*/631632struct xendispl_fb_attach_req {633uint64_t dbuf_cookie;634uint64_t fb_cookie;635uint32_t width;636uint32_t height;637uint32_t pixel_format;638};639640/*641* Request framebuffer detach - detach a previously642* attached framebuffer from the display buffer in request:643* 0 1 2 3 octet644* +----------------+----------------+----------------+----------------+645* | id | _OP_FB_DETACH | reserved | 4646* +----------------+----------------+----------------+----------------+647* | reserved | 8648* +----------------+----------------+----------------+----------------+649* | fb_cookie low 32-bit | 12650* +----------------+----------------+----------------+----------------+651* | fb_cookie high 32-bit | 16652* +----------------+----------------+----------------+----------------+653* | reserved | 20654* +----------------+----------------+----------------+----------------+655* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|656* +----------------+----------------+----------------+----------------+657* | reserved | 64658* +----------------+----------------+----------------+----------------+659*660* Must be sent over control ring of the connector which has the index661* value of 0:662* /local/domain/<dom-id>/device/vdispl/<dev-id>/0/req-ring-ref663*/664665struct xendispl_fb_detach_req {666uint64_t fb_cookie;667};668669/*670* Request configuration set/reset - request to set or reset671* the configuration/mode of the display:672* 0 1 2 3 octet673* +----------------+----------------+----------------+----------------+674* | id | _OP_SET_CONFIG | reserved | 4675* +----------------+----------------+----------------+----------------+676* | reserved | 8677* +----------------+----------------+----------------+----------------+678* | fb_cookie low 32-bit | 12679* +----------------+----------------+----------------+----------------+680* | fb_cookie high 32-bit | 16681* +----------------+----------------+----------------+----------------+682* | x | 20683* +----------------+----------------+----------------+----------------+684* | y | 24685* +----------------+----------------+----------------+----------------+686* | width | 28687* +----------------+----------------+----------------+----------------+688* | height | 32689* +----------------+----------------+----------------+----------------+690* | bpp | 40691* +----------------+----------------+----------------+----------------+692* | reserved | 44693* +----------------+----------------+----------------+----------------+694* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|695* +----------------+----------------+----------------+----------------+696* | reserved | 64697* +----------------+----------------+----------------+----------------+698*699* Pass all zeros to reset, otherwise command is treated as700* configuration set.701* Framebuffer's cookie defines which framebuffer/dbuf must be702* displayed while enabling display (applying configuration).703* x, y, width and height are bound by the connector's resolution and must not704* exceed it.705*706* x - uint32_t, starting position in pixels by X axis707* y - uint32_t, starting position in pixels by Y axis708* width - uint32_t, width in pixels709* height - uint32_t, height in pixels710* bpp - uint32_t, bits per pixel711*/712713struct xendispl_set_config_req {714uint64_t fb_cookie;715uint32_t x;716uint32_t y;717uint32_t width;718uint32_t height;719uint32_t bpp;720};721722/*723* Request page flip - request to flip a page identified by the framebuffer724* cookie:725* 0 1 2 3 octet726* +----------------+----------------+----------------+----------------+727* | id | _OP_PG_FLIP | reserved | 4728* +----------------+----------------+----------------+----------------+729* | reserved | 8730* +----------------+----------------+----------------+----------------+731* | fb_cookie low 32-bit | 12732* +----------------+----------------+----------------+----------------+733* | fb_cookie high 32-bit | 16734* +----------------+----------------+----------------+----------------+735* | reserved | 20736* +----------------+----------------+----------------+----------------+737* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|738* +----------------+----------------+----------------+----------------+739* | reserved | 64740* +----------------+----------------+----------------+----------------+741*/742743struct xendispl_page_flip_req {744uint64_t fb_cookie;745};746747/*748* Request EDID - request EDID describing current connector:749* 0 1 2 3 octet750* +----------------+----------------+----------------+----------------+751* | id | _OP_GET_EDID | reserved | 4752* +----------------+----------------+----------------+----------------+753* | buffer_sz | 8754* +----------------+----------------+----------------+----------------+755* | gref_directory | 12756* +----------------+----------------+----------------+----------------+757* | reserved | 16758* +----------------+----------------+----------------+----------------+759* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|760* +----------------+----------------+----------------+----------------+761* | reserved | 64762* +----------------+----------------+----------------+----------------+763*764* Notes:765* - This command is not available in protocol version 1 and should be766* ignored.767* - This request is optional and if not supported then visible area768* is defined by the relevant XenStore's "resolution" property.769* - Shared buffer, allocated for EDID storage, must not be less then770* XENDISPL_EDID_MAX_SIZE octets.771*772* buffer_sz - uint32_t, buffer size to be allocated, octets773* gref_directory - grant_ref_t, a reference to the first shared page774* describing EDID buffer references. See XENDISPL_OP_DBUF_CREATE for775* grant page directory structure (struct xendispl_page_directory).776*777* See response format for this request.778*/779780struct xendispl_get_edid_req {781uint32_t buffer_sz;782grant_ref_t gref_directory;783};784785/*786*---------------------------------- Responses --------------------------------787*788* All response packets have the same length (64 octets)789*790* All response packets have common header:791* 0 1 2 3 octet792* +----------------+----------------+----------------+----------------+793* | id | reserved | 4794* +----------------+----------------+----------------+----------------+795* | status | 8796* +----------------+----------------+----------------+----------------+797* | reserved | 12798* +----------------+----------------+----------------+----------------+799* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|800* +----------------+----------------+----------------+----------------+801* | reserved | 64802* +----------------+----------------+----------------+----------------+803*804* id - uint16_t, private guest value, echoed from request805* status - int32_t, response status, zero on success and -XEN_EXX on failure806*807*808* Get EDID response - response for XENDISPL_OP_GET_EDID:809* 0 1 2 3 octet810* +----------------+----------------+----------------+----------------+811* | id | operation | reserved | 4812* +----------------+----------------+----------------+----------------+813* | status | 8814* +----------------+----------------+----------------+----------------+815* | edid_sz | 12816* +----------------+----------------+----------------+----------------+817* | reserved | 16818* +----------------+----------------+----------------+----------------+819* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|820* +----------------+----------------+----------------+----------------+821* | reserved | 64822* +----------------+----------------+----------------+----------------+823*824* Notes:825* - This response is not available in protocol version 1 and should be826* ignored.827*828* edid_sz - uint32_t, size of the EDID, octets829*/830831struct xendispl_get_edid_resp {832uint32_t edid_sz;833};834835/*836*----------------------------------- Events ----------------------------------837*838* Events are sent via a shared page allocated by the front and propagated by839* evt-event-channel/evt-ring-ref XenStore entries840* All event packets have the same length (64 octets)841* All event packets have common header:842* 0 1 2 3 octet843* +----------------+----------------+----------------+----------------+844* | id | type | reserved | 4845* +----------------+----------------+----------------+----------------+846* | reserved | 8847* +----------------+----------------+----------------+----------------+848*849* id - uint16_t, event id, may be used by front850* type - uint8_t, type of the event851*852*853* Page flip complete event - event from back to front on page flip completed:854* 0 1 2 3 octet855* +----------------+----------------+----------------+----------------+856* | id | _EVT_PG_FLIP | reserved | 4857* +----------------+----------------+----------------+----------------+858* | reserved | 8859* +----------------+----------------+----------------+----------------+860* | fb_cookie low 32-bit | 12861* +----------------+----------------+----------------+----------------+862* | fb_cookie high 32-bit | 16863* +----------------+----------------+----------------+----------------+864* | reserved | 20865* +----------------+----------------+----------------+----------------+866* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|867* +----------------+----------------+----------------+----------------+868* | reserved | 64869* +----------------+----------------+----------------+----------------+870*/871872struct xendispl_pg_flip_evt {873uint64_t fb_cookie;874};875876struct xendispl_req {877uint16_t id;878uint8_t operation;879uint8_t reserved[5];880union {881struct xendispl_dbuf_create_req dbuf_create;882struct xendispl_dbuf_destroy_req dbuf_destroy;883struct xendispl_fb_attach_req fb_attach;884struct xendispl_fb_detach_req fb_detach;885struct xendispl_set_config_req set_config;886struct xendispl_page_flip_req pg_flip;887struct xendispl_get_edid_req get_edid;888uint8_t reserved[56];889} op;890};891892struct xendispl_resp {893uint16_t id;894uint8_t operation;895uint8_t reserved;896int32_t status;897union {898struct xendispl_get_edid_resp get_edid;899uint8_t reserved1[56];900} op;901};902903struct xendispl_evt {904uint16_t id;905uint8_t type;906uint8_t reserved[5];907union {908struct xendispl_pg_flip_evt pg_flip;909uint8_t reserved[56];910} op;911};912913DEFINE_RING_TYPES(xen_displif, struct xendispl_req, struct xendispl_resp);914915/*916******************************************************************************917* Back to front events delivery918******************************************************************************919* In order to deliver asynchronous events from back to front a shared page is920* allocated by front and its granted reference propagated to back via921* XenStore entries (evt-ring-ref/evt-event-channel).922* This page has a common header used by both front and back to synchronize923* access and control event's ring buffer, while back being a producer of the924* events and front being a consumer. The rest of the page after the header925* is used for event packets.926*927* Upon reception of an event(s) front may confirm its reception928* for either each event, group of events or none.929*/930931struct xendispl_event_page {932uint32_t in_cons;933uint32_t in_prod;934uint8_t reserved[56];935};936937#define XENDISPL_EVENT_PAGE_SIZE 4096938#define XENDISPL_IN_RING_OFFS (sizeof(struct xendispl_event_page))939#define XENDISPL_IN_RING_SIZE (XENDISPL_EVENT_PAGE_SIZE - XENDISPL_IN_RING_OFFS)940#define XENDISPL_IN_RING_LEN (XENDISPL_IN_RING_SIZE / sizeof(struct xendispl_evt))941#define XENDISPL_IN_RING(page) \942((struct xendispl_evt *)((char *)(page) + XENDISPL_IN_RING_OFFS))943#define XENDISPL_IN_RING_REF(page, idx) \944(XENDISPL_IN_RING((page))[(idx) % XENDISPL_IN_RING_LEN])945946#endif /* __XEN_PUBLIC_IO_DISPLIF_H__ */947948/*949* Local variables:950* mode: C951* c-file-style: "BSD"952* c-basic-offset: 4953* tab-width: 4954* indent-tabs-mode: nil955* End:956*/957958959