/******************************************************************************1* cameraif.h2*3* Unified camera 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) 2018-2019 EPAM Systems Inc.24*25* Author: Oleksandr Andrushchenko <[email protected]>26*/2728#ifndef __XEN_PUBLIC_IO_CAMERAIF_H__29#define __XEN_PUBLIC_IO_CAMERAIF_H__3031#include "ring.h"32#include "../grant_table.h"3334/*35******************************************************************************36* Protocol version37******************************************************************************38*/39#define XENCAMERA_PROTOCOL_VERSION "1"4041/*42******************************************************************************43* Feature and Parameter Negotiation44******************************************************************************45*46* Front->back notifications: when enqueuing a new request, sending a47* notification can be made conditional on xencamera_req (i.e., the generic48* hold-off mechanism provided by the ring macros). Backends must set49* xencamera_req appropriately (e.g., using RING_FINAL_CHECK_FOR_REQUESTS()).50*51* Back->front notifications: when enqueuing a new response, sending a52* notification can be made conditional on xencamera_resp (i.e., the generic53* hold-off mechanism provided by the ring macros). Frontends must set54* xencamera_resp appropriately (e.g., using RING_FINAL_CHECK_FOR_RESPONSES()).55*56* The two halves of a para-virtual camera driver utilize nodes within57* XenStore to communicate capabilities and to negotiate operating parameters.58* This section enumerates these nodes which reside in the respective front and59* backend portions of XenStore, following the XenBus convention.60*61* All data in XenStore is stored as strings. Nodes specifying numeric62* values are encoded in decimal. Integer value ranges listed below are63* expressed as fixed sized integer types capable of storing the conversion64* of a properly formatted node string, without loss of information.65*66******************************************************************************67* Example configuration68******************************************************************************69*70* This is an example of backend and frontend configuration:71*72*--------------------------------- Backend -----------------------------------73*74* /local/domain/0/backend/vcamera/1/0/frontend-id = "1"75* /local/domain/0/backend/vcamera/1/0/frontend = "/local/domain/1/device/vcamera/0"76* /local/domain/0/backend/vcamera/1/0/state = "4"77* /local/domain/0/backend/vcamera/1/0/versions = "1,2"78*79*--------------------------------- Frontend ----------------------------------80*81* /local/domain/1/device/vcamera/0/backend-id = "0"82* /local/domain/1/device/vcamera/0/backend = "/local/domain/0/backend/vcamera/1"83* /local/domain/1/device/vcamera/0/state = "4"84* /local/domain/1/device/vcamera/0/version = "1"85* /local/domain/1/device/vcamera/0/be-alloc = "1"86*87*---------------------------- Device 0 configuration -------------------------88*89* /local/domain/1/device/vcamera/0/max-buffers = "3"90* /local/domain/1/device/vcamera/0/controls = "contrast,hue"91* /local/domain/1/device/vcamera/0/formats/YUYV/640x480/frame-rates = "30/1,15/1"92* /local/domain/1/device/vcamera/0/formats/YUYV/1920x1080/frame-rates = "15/2"93* /local/domain/1/device/vcamera/0/formats/BGRA/640x480/frame-rates = "15/1,15/2"94* /local/domain/1/device/vcamera/0/formats/BGRA/1200x720/frame-rates = "15/2"95* /local/domain/1/device/vcamera/0/unique-id = "0"96* /local/domain/1/device/vcamera/0/req-ring-ref = "2832"97* /local/domain/1/device/vcamera/0/req-event-channel = "15"98* /local/domain/1/device/vcamera/0/evt-ring-ref = "387"99* /local/domain/1/device/vcamera/0/evt-event-channel = "16"100*101*---------------------------- Device 1 configuration -------------------------102*103* /local/domain/1/device/vcamera/1/max-buffers = "8"104* /local/domain/1/device/vcamera/1/controls = "brightness,saturation,hue"105* /local/domain/1/device/vcamera/1/formats/YUYV/640x480/frame-rates = "30/1,15/2"106* /local/domain/1/device/vcamera/1/formats/YUYV/1920x1080/frame-rates = "15/2"107* /local/domain/1/device/vcamera/1/unique-id = "1"108* /local/domain/1/device/vcamera/1/req-ring-ref = "2833"109* /local/domain/1/device/vcamera/1/req-event-channel = "17"110* /local/domain/1/device/vcamera/1/evt-ring-ref = "388"111* /local/domain/1/device/vcamera/1/evt-event-channel = "18"112*113******************************************************************************114* Backend XenBus Nodes115******************************************************************************116*117*----------------------------- Protocol version ------------------------------118*119* versions120* Values: <string>121*122* List of XENCAMERA_LIST_SEPARATOR separated protocol versions supported123* by the backend. For example "1,2,3".124*125******************************************************************************126* Frontend XenBus Nodes127******************************************************************************128*129*-------------------------------- Addressing ---------------------------------130*131* dom-id132* Values: <uint16_t>133*134* Domain identifier.135*136* dev-id137* Values: <uint16_t>138*139* Device identifier.140*141* /local/domain/<dom-id>/device/vcamera/<dev-id>/...142*143*----------------------------- Protocol version ------------------------------144*145* version146* Values: <string>147*148* Protocol version, chosen among the ones supported by the backend.149*150*------------------------- Backend buffer allocation -------------------------151*152* be-alloc153* Values: "0", "1"154*155* If value is set to "1", then backend will be the buffer156* provider/allocator for this domain during XENCAMERA_OP_BUF_CREATE157* operation.158* If value is not "1" or omitted frontend must allocate buffers itself.159*160*------------------------------- Camera settings -----------------------------161*162* unique-id163* Values: <string>164*165* After device instance initialization each camera is assigned a166* unique ID, so it can be identified by the backend by this ID.167* This can be UUID or such.168*169* max-buffers170* Values: <uint8_t>171*172* Maximum number of camera buffers this frontend may use.173*174* controls175* Values: <list of string>176*177* List of supported camera controls separated by XENCAMERA_LIST_SEPARATOR.178* Camera controls are expressed as a list of string values w/o any179* ordering requirement.180*181* formats182* Values: <format, char[7]>183*184* Formats are organized as a set of directories one per each185* supported pixel format. The name of the directory is the186* corresponding FOURCC string label. The next level of187* the directory under <formats> represents supported resolutions.188* If the format represents a big-endian variant of a little189* endian format, then the "-BE" suffix must be added. E.g. 'AR15' vs190* 'AR15-BE'.191* If FOURCC string label has spaces then those are only allowed to192* be at the end of the label and must be trimmed, for example193* 'Y16' and 'Y16-BE' will be trimmed.194*195* resolution196* Values: <width, uint32_t>x<height, uint32_t>197*198* Resolutions are organized as a set of directories one per each199* supported resolution under corresponding <formats> directory.200* The name of the directory is the supported width and height201* of the camera resolution in pixels.202*203* frame-rates204* Values: <numerator, uint32_t>/<denominator, uint32_t>205*206* List of XENCAMERA_FRAME_RATE_SEPARATOR separated supported frame rates207* of the camera expressed as numerator and denominator of the208* corresponding frame rate.209*210*------------------- Camera Request Transport Parameters ---------------------211*212* This communication path is used to deliver requests from frontend to backend213* and get the corresponding responses from backend to frontend,214* set up per virtual camera device.215*216* req-event-channel217* Values: <uint32_t>218*219* The identifier of the Xen camera's control event channel220* used to signal activity in the ring buffer.221*222* req-ring-ref223* Values: <uint32_t>224*225* The Xen grant reference granting permission for the backend to map226* a sole page of camera's control ring buffer.227*228*-------------------- Camera Event Transport Parameters ----------------------229*230* This communication path is used to deliver asynchronous events from backend231* to frontend, set up per virtual camera device.232*233* evt-event-channel234* Values: <uint32_t>235*236* The identifier of the Xen camera's event channel237* used to signal activity in the ring buffer.238*239* evt-ring-ref240* Values: <uint32_t>241*242* The Xen grant reference granting permission for the backend to map243* a sole page of camera's event ring buffer.244*/245246/*247******************************************************************************248* STATE DIAGRAMS249******************************************************************************250*251* Tool stack creates front and back state nodes with initial state252* XenbusStateInitialising.253* Tool stack creates and sets up frontend camera configuration254* nodes per domain.255*256*-------------------------------- Normal flow --------------------------------257*258* Front Back259* ================================= =====================================260* XenbusStateInitialising XenbusStateInitialising261* o Query backend device identification262* data.263* o Open and validate backend device.264* |265* |266* V267* XenbusStateInitWait268*269* o Query frontend configuration270* o Allocate and initialize271* event channels per configured272* camera.273* o Publish transport parameters274* that will be in effect during275* this connection.276* |277* |278* V279* XenbusStateInitialised280*281* o Query frontend transport parameters.282* o Connect to the event channels.283* |284* |285* V286* XenbusStateConnected287*288* o Create and initialize OS289* virtual camera as per290* configuration.291* |292* |293* V294* XenbusStateConnected295*296* XenbusStateUnknown297* XenbusStateClosed298* XenbusStateClosing299* o Remove virtual camera device300* o Remove event channels301* |302* |303* V304* XenbusStateClosed305*306*------------------------------- Recovery flow -------------------------------307*308* In case of frontend unrecoverable errors backend handles that as309* if frontend goes into the XenbusStateClosed state.310*311* In case of backend unrecoverable errors frontend tries removing312* the virtualized device. If this is possible at the moment of error,313* then frontend goes into the XenbusStateInitialising state and is ready for314* new connection with backend. If the virtualized device is still in use and315* cannot be removed, then frontend goes into the XenbusStateReconfiguring state316* until either the virtualized device is removed or backend initiates a new317* connection. On the virtualized device removal frontend goes into the318* XenbusStateInitialising state.319*320* Note on XenbusStateReconfiguring state of the frontend: if backend has321* unrecoverable errors then frontend cannot send requests to the backend322* and thus cannot provide functionality of the virtualized device anymore.323* After backend is back to normal the virtualized device may still hold some324* state: configuration in use, allocated buffers, client application state etc.325* In most cases, this will require frontend to implement complex recovery326* reconnect logic. Instead, by going into XenbusStateReconfiguring state,327* frontend will make sure no new clients of the virtualized device are328* accepted, allow existing client(s) to exit gracefully by signaling error329* state etc.330* Once all the clients are gone frontend can reinitialize the virtualized331* device and get into XenbusStateInitialising state again signaling the332* backend that a new connection can be made.333*334* There are multiple conditions possible under which frontend will go from335* XenbusStateReconfiguring into XenbusStateInitialising, some of them are OS336* specific. For example:337* 1. The underlying OS framework may provide callbacks to signal that the last338* client of the virtualized device has gone and the device can be removed339* 2. Frontend can schedule a deferred work (timer/tasklet/workqueue)340* to periodically check if this is the right time to re-try removal of341* the virtualized device.342* 3. By any other means.343*344******************************************************************************345* REQUEST CODES346******************************************************************************347*/348#define XENCAMERA_OP_CONFIG_SET 0x00349#define XENCAMERA_OP_CONFIG_GET 0x01350#define XENCAMERA_OP_CONFIG_VALIDATE 0x02351#define XENCAMERA_OP_FRAME_RATE_SET 0x03352#define XENCAMERA_OP_BUF_GET_LAYOUT 0x04353#define XENCAMERA_OP_BUF_REQUEST 0x05354#define XENCAMERA_OP_BUF_CREATE 0x06355#define XENCAMERA_OP_BUF_DESTROY 0x07356#define XENCAMERA_OP_BUF_QUEUE 0x08357#define XENCAMERA_OP_BUF_DEQUEUE 0x09358#define XENCAMERA_OP_CTRL_ENUM 0x0a359#define XENCAMERA_OP_CTRL_SET 0x0b360#define XENCAMERA_OP_CTRL_GET 0x0c361#define XENCAMERA_OP_STREAM_START 0x0d362#define XENCAMERA_OP_STREAM_STOP 0x0e363364#define XENCAMERA_CTRL_BRIGHTNESS 0365#define XENCAMERA_CTRL_CONTRAST 1366#define XENCAMERA_CTRL_SATURATION 2367#define XENCAMERA_CTRL_HUE 3368369/* Number of supported controls. */370#define XENCAMERA_MAX_CTRL 4371372/* Control is read-only. */373#define XENCAMERA_CTRL_FLG_RO (1 << 0)374/* Control is write-only. */375#define XENCAMERA_CTRL_FLG_WO (1 << 1)376/* Control's value is volatile. */377#define XENCAMERA_CTRL_FLG_VOLATILE (1 << 2)378379/* Supported color spaces. */380#define XENCAMERA_COLORSPACE_DEFAULT 0381#define XENCAMERA_COLORSPACE_SMPTE170M 1382#define XENCAMERA_COLORSPACE_REC709 2383#define XENCAMERA_COLORSPACE_SRGB 3384#define XENCAMERA_COLORSPACE_OPRGB 4385#define XENCAMERA_COLORSPACE_BT2020 5386#define XENCAMERA_COLORSPACE_DCI_P3 6387388/* Color space transfer function. */389#define XENCAMERA_XFER_FUNC_DEFAULT 0390#define XENCAMERA_XFER_FUNC_709 1391#define XENCAMERA_XFER_FUNC_SRGB 2392#define XENCAMERA_XFER_FUNC_OPRGB 3393#define XENCAMERA_XFER_FUNC_NONE 4394#define XENCAMERA_XFER_FUNC_DCI_P3 5395#define XENCAMERA_XFER_FUNC_SMPTE2084 6396397/* Color space Y’CbCr encoding. */398#define XENCAMERA_YCBCR_ENC_IGNORE 0399#define XENCAMERA_YCBCR_ENC_601 1400#define XENCAMERA_YCBCR_ENC_709 2401#define XENCAMERA_YCBCR_ENC_XV601 3402#define XENCAMERA_YCBCR_ENC_XV709 4403#define XENCAMERA_YCBCR_ENC_BT2020 5404#define XENCAMERA_YCBCR_ENC_BT2020_CONST_LUM 6405406/* Quantization range. */407#define XENCAMERA_QUANTIZATION_DEFAULT 0408#define XENCAMERA_QUANTIZATION_FULL_RANGE 1409#define XENCAMERA_QUANTIZATION_LIM_RANGE 2410411/*412******************************************************************************413* EVENT CODES414******************************************************************************415*/416#define XENCAMERA_EVT_FRAME_AVAIL 0x00417#define XENCAMERA_EVT_CTRL_CHANGE 0x01418419/*420******************************************************************************421* XENSTORE FIELD AND PATH NAME STRINGS, HELPERS422******************************************************************************423*/424#define XENCAMERA_DRIVER_NAME "vcamera"425426#define XENCAMERA_LIST_SEPARATOR ","427#define XENCAMERA_RESOLUTION_SEPARATOR "x"428#define XENCAMERA_FRACTION_SEPARATOR "/"429430#define XENCAMERA_FIELD_BE_VERSIONS "versions"431#define XENCAMERA_FIELD_FE_VERSION "version"432#define XENCAMERA_FIELD_REQ_RING_REF "req-ring-ref"433#define XENCAMERA_FIELD_REQ_CHANNEL "req-event-channel"434#define XENCAMERA_FIELD_EVT_RING_REF "evt-ring-ref"435#define XENCAMERA_FIELD_EVT_CHANNEL "evt-event-channel"436#define XENCAMERA_FIELD_MAX_BUFFERS "max-buffers"437#define XENCAMERA_FIELD_CONTROLS "controls"438#define XENCAMERA_FIELD_FORMATS "formats"439#define XENCAMERA_FIELD_FRAME_RATES "frame-rates"440#define XENCAMERA_FIELD_BE_ALLOC "be-alloc"441#define XENCAMERA_FIELD_UNIQUE_ID "unique-id"442443#define XENCAMERA_CTRL_BRIGHTNESS_STR "brightness"444#define XENCAMERA_CTRL_CONTRAST_STR "contrast"445#define XENCAMERA_CTRL_SATURATION_STR "saturation"446#define XENCAMERA_CTRL_HUE_STR "hue"447448#define XENCAMERA_FOURCC_BIGENDIAN_STR "-BE"449450/* Maximum number of buffer planes supported. */451#define XENCAMERA_MAX_PLANE 4452453/*454******************************************************************************455* STATUS RETURN CODES456******************************************************************************457*458* Status return code is zero on success and -XEN_EXX on failure.459*460******************************************************************************461* Assumptions462******************************************************************************463*464* - usage of grant reference 0 as invalid grant reference:465* grant reference 0 is valid, but never exposed to a PV driver,466* because of the fact it is already in use/reserved by the PV console.467* - all references in this document to page sizes must be treated468* as pages of size XEN_PAGE_SIZE unless otherwise noted.469* - all FOURCC mappings used for configuration and messaging are470* Linux V4L2 ones: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/uapi/linux/videodev2.h471* with the following exceptions:472* - characters are allowed in [0x20; 0x7f] range473* - when used for XenStore configuration entries the following474* are not allowed:475* - '/', '\', ' ' (space), '<', '>', ':', '"', '|', '?', '*'476* - if trailing spaces are part of the FOURCC code then those must be477* trimmed478*479*480******************************************************************************481* Description of the protocol between frontend and backend driver482******************************************************************************483*484* The two halves of a Para-virtual camera driver communicate with485* each other using shared pages and event channels.486* Shared page contains a ring with request/response packets.487*488* All reserved fields in the structures below must be 0.489*490* For all request/response/event packets:491* - frame rate parameter is represented as a pair of 4 octet long492* numerator and denominator:493* - frame_rate_numer - uint32_t, numerator of the frame rate494* - frame_rate_denom - uint32_t, denominator of the frame rate495* The corresponding frame rate (Hz) is calculated as:496* frame_rate = frame_rate_numer / frame_rate_denom497* - buffer index is a zero based index of the buffer. Must be less than498* the value of XENCAMERA_OP_CONFIG_SET.num_bufs response:499* - index - uint8_t, index of the buffer.500*501*502*---------------------------------- Requests ---------------------------------503*504* All request packets have the same length (64 octets).505* All request packets have common header:506* 0 1 2 3 octet507* +----------------+----------------+----------------+----------------+508* | id | operation | reserved | 4509* +----------------+----------------+----------------+----------------+510* | reserved | 8511* +----------------+----------------+----------------+----------------+512* id - uint16_t, private guest value, echoed in response.513* operation - uint8_t, operation code, XENCAMERA_OP_XXX.514*515*516* Request to set/validate the configuration - request to set the517* configuration/mode of the camera (XENCAMERA_OP_CONFIG_SET) or to518* check if the configuration is valid and can be used519* (XENCAMERA_OP_CONFIG_VALIDATE):520* 0 1 2 3 octet521* +----------------+----------------+----------------+----------------+522* | id | _OP_CONFIG_XXX | reserved | 4523* +----------------+----------------+----------------+----------------+524* | reserved | 8525* +----------------+----------------+----------------+----------------+526* | pixel format | 12527* +----------------+----------------+----------------+----------------+528* | width | 16529* +----------------+----------------+----------------+----------------+530* | height | 20531* +----------------+----------------+----------------+----------------+532* | reserved | 24533* +----------------+----------------+----------------+----------------+534* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|535* +----------------+----------------+----------------+----------------+536* | reserved | 64537* +----------------+----------------+----------------+----------------+538*539* pixel_format - uint32_t, pixel format to be used, FOURCC code.540* width - uint32_t, width in pixels.541* height - uint32_t, height in pixels.542*543* See response format for this request.544*545* Notes:546* - the only difference between XENCAMERA_OP_CONFIG_VALIDATE and547* XENCAMERA_OP_CONFIG_SET is that the former doesn't actually change548* camera configuration, but queries if the configuration is valid.549* This can be used while stream is active and/or buffers allocated.550* - frontend must check the corresponding response in order to see551* if the values reported back by the backend do match the desired ones552* and can be accepted.553* - frontend may send multiple XENCAMERA_OP_CONFIG_SET requests before554* sending XENCAMERA_OP_STREAM_START request to update or tune the555* final stream configuration.556* - configuration cannot be changed during active streaming, e.g.557* after XENCAMERA_OP_STREAM_START and before XENCAMERA_OP_STREAM_STOP558* requests.559*/560struct xencamera_config_req {561uint32_t pixel_format;562uint32_t width;563uint32_t height;564};565566/*567* Request current configuration of the camera:568* 0 1 2 3 octet569* +----------------+----------------+----------------+----------------+570* | id | _OP_CONFIG_GET | reserved | 4571* +----------------+----------------+----------------+----------------+572* | reserved | 8573* +----------------+----------------+----------------+----------------+574* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|575* +----------------+----------------+----------------+----------------+576* | reserved | 64577* +----------------+----------------+----------------+----------------+578*579* See response format for this request.580*581*582* Request to set the frame rate of the stream:583* 0 1 2 3 octet584* +----------------+----------------+----------------+----------------+585* | id | _FRAME_RATE_SET| reserved | 4586* +----------------+----------------+----------------+----------------+587* | reserved | 8588* +----------------+----------------+----------------+----------------+589* | frame_rate_numer | 12590* +----------------+----------------+----------------+----------------+591* | frame_rate_denom | 16592* +----------------+----------------+----------------+----------------+593* | reserved | 20594* +----------------+----------------+----------------+----------------+595* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|596* +----------------+----------------+----------------+----------------+597* | reserved | 64598* +----------------+----------------+----------------+----------------+599*600* frame_rate_numer - uint32_t, numerator of the frame rate.601* frame_rate_denom - uint32_t, denominator of the frame rate.602*603* Notes:604* - to query the current (actual) frame rate use XENCAMERA_OP_CONFIG_GET605* request.606* - this request can be used with camera buffers allocated, but stream607* stopped, e.g. frontend is allowed to stop the stream with608* XENCAMERA_OP_STREAM_STOP, hold the buffers allocated (e.g. keep the609* configuration set with XENCAMERA_OP_CONFIG_SET), change the610* frame rate of the stream and (re)start the stream again with611* XENCAMERA_OP_STREAM_START.612* - frame rate cannot be changed during active streaming, e.g.613* after XENCAMERA_OP_STREAM_START and before XENCAMERA_OP_STREAM_STOP614* commands.615*/616struct xencamera_frame_rate_req {617uint32_t frame_rate_numer;618uint32_t frame_rate_denom;619};620621/*622* Request camera buffer's layout:623* 0 1 2 3 octet624* +----------------+----------------+----------------+----------------+625* | id | _BUF_GET_LAYOUT| reserved | 4626* +----------------+----------------+----------------+----------------+627* | reserved | 8628* +----------------+----------------+----------------+----------------+629* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|630* +----------------+----------------+----------------+----------------+631* | reserved | 64632* +----------------+----------------+----------------+----------------+633*634* See response format for this request.635*636*637* Request number of buffers to be used:638* 0 1 2 3 octet639* +----------------+----------------+----------------+----------------+640* | id | _OP_BUF_REQUEST| reserved | 4641* +----------------+----------------+----------------+----------------+642* | reserved | 8643* +----------------+----------------+----------------+----------------+644* | num_bufs | reserved | 12645* +----------------+----------------+----------------+----------------+646* | reserved | 16647* +----------------+----------------+----------------+----------------+648* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|649* +----------------+----------------+----------------+----------------+650* | reserved | 64651* +----------------+----------------+----------------+----------------+652*653* num_bufs - uint8_t, desired number of buffers to be used.654*655* If num_bufs is not zero then the backend validates the requested number of656* buffers and responds with the number of buffers allowed for this frontend.657* Frontend is responsible for checking the corresponding response in order to658* see if the values reported back by the backend do match the desired ones659* and can be accepted.660* Frontend is allowed to send multiple XENCAMERA_OP_BUF_REQUEST requests661* before sending XENCAMERA_OP_STREAM_START request to update or tune the662* final configuration.663* Frontend is not allowed to change the camera configuration after this call664* with a non-zero value of num_bufs. If camera reconfiguration is required665* then this request must be sent with num_bufs set to zero and any created666* buffers must be destroyed first.667* Frontend is not allowed to change the number of buffers after the668* streaming has started.669*670* If num_bufs is 0 and streaming has not started yet, then the backend will671* free all previously allocated buffers (if any).672* Trying to call this if streaming is in progress will result in an error.673*674* If camera reconfiguration is required then the streaming must be stopped675* and this request must be sent with num_bufs set to zero and any676* created buffers must be destroyed.677*678* Please note, that the number of buffers in this request must not exceed679* the value configured in XenStore.max-buffers.680*681* See response format for this request.682*/683struct xencamera_buf_request {684uint8_t num_bufs;685};686687/*688* Request camera buffer creation:689* 0 1 2 3 octet690* +----------------+----------------+----------------+----------------+691* | id | _OP_BUF_CREATE | reserved | 4692* +----------------+----------------+----------------+----------------+693* | reserved | 8694* +----------------+----------------+----------------+----------------+695* | index | reserved | 12696* +----------------+----------------+----------------+----------------+697* | plane_offset[0] | 16698* +----------------+----------------+----------------+----------------+699* | plane_offset[1] | 20700* +----------------+----------------+----------------+----------------+701* | plane_offset[2] | 24702* +----------------+----------------+----------------+----------------+703* | plane_offset[3] | 28704* +----------------+----------------+----------------+----------------+705* | gref_directory | 32706* +----------------+----------------+----------------+----------------+707* | reserved | 36708* +----------------+----------------+----------------+----------------+709* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|710* +----------------+----------------+----------------+----------------+711* | reserved | 64712* +----------------+----------------+----------------+----------------+713*714* An attempt to create multiple buffers with the same index is an error.715* index can be re-used after destroying the corresponding camera buffer.716*717* index - uint8_t, index of the buffer to be created in the range718* from 0 to the num_bufs field returned in response for719* XENCAMERA_OP_BUF_REQUEST request720* plane_offset - array of uint32_t, offset of the corresponding plane721* in octets from the buffer start. Number of offsets returned is722* equal to the value returned in XENCAMERA_OP_BUF_GET_LAYOUT.num_planes.723* gref_directory - grant_ref_t, a reference to the first shared page724* describing shared buffer references. The size of the buffer is equal to725* XENCAMERA_OP_BUF_GET_LAYOUT.size response. At least one page exists. If726* shared buffer size exceeds what can be addressed by this single page,727* then reference to the next shared page must be supplied (see728* gref_dir_next_page below).729*730* If XENCAMERA_FIELD_BE_ALLOC configuration entry is set, then backend will731* allocate the buffer with the parameters provided in this request and page732* directory is handled as follows:733* Frontend on request:734* - allocates pages for the directory (gref_directory,735* gref_dir_next_page(s)736* - grants permissions for the pages of the directory to the backend737* - sets gref_dir_next_page fields738* Backend on response:739* - grants permissions for the pages of the buffer allocated to740* the frontend741* - fills in page directory with grant references742* (gref[] in struct xencamera_page_directory)743*/744struct xencamera_buf_create_req {745uint8_t index;746uint8_t reserved[3];747uint32_t plane_offset[XENCAMERA_MAX_PLANE];748grant_ref_t gref_directory;749};750751/*752* Shared page for XENCAMERA_OP_BUF_CREATE buffer descriptor (gref_directory in753* the request) employs a list of pages, describing all pages of the shared754* data buffer:755* 0 1 2 3 octet756* +----------------+----------------+----------------+----------------+757* | gref_dir_next_page | 4758* +----------------+----------------+----------------+----------------+759* | gref[0] | 8760* +----------------+----------------+----------------+----------------+761* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|762* +----------------+----------------+----------------+----------------+763* | gref[i] | i*4+8764* +----------------+----------------+----------------+----------------+765* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|766* +----------------+----------------+----------------+----------------+767* | gref[N - 1] | N*4+8768* +----------------+----------------+----------------+----------------+769*770* gref_dir_next_page - grant_ref_t, reference to the next page describing771* page directory. Must be 0 if there are no more pages in the list.772* gref[i] - grant_ref_t, reference to a shared page of the buffer773* allocated at XENCAMERA_OP_BUF_CREATE.774*775* Number of grant_ref_t entries in the whole page directory is not776* passed, but instead can be calculated as:777* num_grefs_total = (XENCAMERA_OP_BUF_REQUEST.size + XEN_PAGE_SIZE - 1) /778* XEN_PAGE_SIZE779*/780struct xencamera_page_directory {781grant_ref_t gref_dir_next_page;782grant_ref_t gref[1]; /* Variable length */783};784785/*786* Request buffer destruction - destroy a previously allocated camera buffer:787* 0 1 2 3 octet788* +----------------+----------------+----------------+----------------+789* | id | _OP_BUF_DESTROY| reserved | 4790* +----------------+----------------+----------------+----------------+791* | reserved | 8792* +----------------+----------------+----------------+----------------+793* | index | reserved | 12794* +----------------+----------------+----------------+----------------+795* | reserved | 16796* +----------------+----------------+----------------+----------------+797* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|798* +----------------+----------------+----------------+----------------+799* | reserved | 64800* +----------------+----------------+----------------+----------------+801*802* index - uint8_t, index of the buffer to be destroyed.803*804*805* Request queueing of the buffer for backend use:806* 0 1 2 3 octet807* +----------------+----------------+----------------+----------------+808* | id | _OP_BUF_QUEUE | reserved | 4809* +----------------+----------------+----------------+----------------+810* | reserved | 8811* +----------------+----------------+----------------+----------------+812* | index | reserved | 12813* +----------------+----------------+----------------+----------------+814* | reserved | 16815* +----------------+----------------+----------------+----------------+816* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|817* +----------------+----------------+----------------+----------------+818* | reserved | 64819* +----------------+----------------+----------------+----------------+820*821* Notes:822* - frontends must not access the buffer content after this request until823* response to XENCAMERA_OP_BUF_DEQUEUE has been received.824* - buffers must be queued to the backend before destroying them with825* XENCAMERA_OP_BUF_DESTROY.826*827* index - uint8_t, index of the buffer to be queued.828*829*830* Request dequeueing of the buffer for frontend use:831* 0 1 2 3 octet832* +----------------+----------------+----------------+----------------+833* | id |_OP_BUF_DEQUEUE | reserved | 4834* +----------------+----------------+----------------+----------------+835* | reserved | 8836* +----------------+----------------+----------------+----------------+837* | index | reserved | 12838* +----------------+----------------+----------------+----------------+839* | reserved | 16840* +----------------+----------------+----------------+----------------+841* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|842* +----------------+----------------+----------------+----------------+843* | reserved | 64844* +----------------+----------------+----------------+----------------+845*846* Notes:847* - frontend is allowed to access the buffer content after the corresponding848* response to this request.849*850* index - uint8_t, index of the buffer to be queued.851*852*853* Request camera control details:854* 0 1 2 3 octet855* +----------------+----------------+----------------+----------------+856* | id | _OP_CTRL_ENUM | reserved | 4857* +----------------+----------------+----------------+----------------+858* | index | reserved | 8859* +----------------+----------------+----------------+----------------+860* | reserved | 12861* +----------------+----------------+----------------+----------------+862* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|863* +----------------+----------------+----------------+----------------+864* | reserved | 64865* +----------------+----------------+----------------+----------------+866*867* See response format for this request.868*869* index - uint8_t, index of the control to be queried.870*/871struct xencamera_index {872uint8_t index;873};874875/*876* Request camera control change:877* 0 1 2 3 octet878* +----------------+----------------+----------------+----------------+879* | id | _OP_SET_CTRL | reserved | 4880* +----------------+----------------+----------------+----------------+881* | type | reserved | 8882* +----------------+----------------+----------------+----------------+883* | reserved | 12884* +----------------+----------------+----------------+----------------+885* | reserved | 16886* +----------------+----------------+----------------+----------------+887* | value low 32-bit | 20888* +----------------+----------------+----------------+----------------+889* | value high 32-bit | 24890* +----------------+----------------+----------------+----------------+891* | reserved | 28892* +----------------+----------------+----------------+----------------+893* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|894* +----------------+----------------+----------------+----------------+895* | reserved | 64896* +----------------+----------------+----------------+----------------+897*898* type - uint8_t, type of the control, one of the XENCAMERA_CTRL_XXX.899* value - int64_t, new value of the control.900*/901struct xencamera_ctrl_value {902uint8_t type;903uint8_t reserved[7];904int64_t value;905};906907/*908* Request camera control state:909* 0 1 2 3 octet910* +----------------+----------------+----------------+----------------+911* | id | _OP_GET_CTRL | reserved | 4912* +----------------+----------------+----------------+----------------+913* | type | reserved | 8914* +----------------+----------------+----------------+----------------+915* | reserved | 12916* +----------------+----------------+----------------+----------------+917* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|918* +----------------+----------------+----------------+----------------+919* | reserved | 64920* +----------------+----------------+----------------+----------------+921*922* See response format for this request.923*924* type - uint8_t, type of the control, one of the XENCAMERA_CTRL_XXX.925*/926struct xencamera_get_ctrl_req {927uint8_t type;928};929930/*931* Request camera capture stream start:932* 0 1 2 3 octet933* +----------------+----------------+----------------+----------------+934* | id |_OP_STREAM_START| reserved | 4935* +----------------+----------------+----------------+----------------+936* | reserved | 8937* +----------------+----------------+----------------+----------------+938* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|939* +----------------+----------------+----------------+----------------+940* | reserved | 64941* +----------------+----------------+----------------+----------------+942*943*944* Request camera capture stream stop:945* 0 1 2 3 octet946* +----------------+----------------+----------------+----------------+947* | id |_OP_STREAM_STOP | reserved | 4948* +----------------+----------------+----------------+----------------+949* | reserved | 8950* +----------------+----------------+----------------+----------------+951* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|952* +----------------+----------------+----------------+----------------+953* | reserved | 64954* +----------------+----------------+----------------+----------------+955*956*957*---------------------------------- Responses --------------------------------958*959* All response packets have the same length (64 octets).960*961* All response packets have common header:962* 0 1 2 3 octet963* +----------------+----------------+----------------+----------------+964* | id | operation | reserved | 4965* +----------------+----------------+----------------+----------------+966* | status | 8967* +----------------+----------------+----------------+----------------+968*969* id - uint16_t, copied from the request.970* operation - uint8_t, XENCAMERA_OP_* - copied from request.971* status - int32_t, response status, zero on success and -XEN_EXX on failure.972*973*974* Configuration response - response for XENCAMERA_OP_CONFIG_SET,975* XENCAMERA_OP_CONFIG_GET and XENCAMERA_OP_CONFIG_VALIDATE requests:976* 0 1 2 3 octet977* +----------------+----------------+----------------+----------------+978* | id | _OP_CONFIG_XXX | reserved | 4979* +----------------+----------------+----------------+----------------+980* | status | 8981* +----------------+----------------+----------------+----------------+982* | pixel format | 12983* +----------------+----------------+----------------+----------------+984* | width | 16985* +----------------+----------------+----------------+----------------+986* | height | 20987* +----------------+----------------+----------------+----------------+988* | colorspace | 24989* +----------------+----------------+----------------+----------------+990* | xfer_func | 28991* +----------------+----------------+----------------+----------------+992* | ycbcr_enc | 32993* +----------------+----------------+----------------+----------------+994* | quantization | 36995* +----------------+----------------+----------------+----------------+996* | displ_asp_ratio_numer | 40997* +----------------+----------------+----------------+----------------+998* | displ_asp_ratio_denom | 44999* +----------------+----------------+----------------+----------------+1000* | frame_rate_numer | 481001* +----------------+----------------+----------------+----------------+1002* | frame_rate_denom | 521003* +----------------+----------------+----------------+----------------+1004* | reserved | 561005* +----------------+----------------+----------------+----------------+1006* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|1007* +----------------+----------------+----------------+----------------+1008* | reserved | 641009* +----------------+----------------+----------------+----------------+1010*1011* Meaning of the corresponding values in this response is the same as for1012* XENCAMERA_OP_CONFIG_SET and XENCAMERA_OP_FRAME_RATE_SET requests.1013*1014* colorspace - uint32_t, this supplements pixel_format parameter,1015* one of the XENCAMERA_COLORSPACE_XXX.1016* xfer_func - uint32_t, this supplements colorspace parameter,1017* one of the XENCAMERA_XFER_FUNC_XXX.1018* ycbcr_enc - uint32_t, this supplements colorspace parameter,1019* one of the XENCAMERA_YCBCR_ENC_XXX. Please note, that ycbcr_enc is only1020* valid for YCbCr pixelformats and should be ignored otherwise.1021* quantization - uint32_t, this supplements colorspace parameter,1022* one of the XENCAMERA_QUANTIZATION_XXX.1023* displ_asp_ratio_numer - uint32_t, numerator of the display aspect ratio.1024* displ_asp_ratio_denom - uint32_t, denominator of the display aspect ratio.1025*/1026struct xencamera_config_resp {1027uint32_t pixel_format;1028uint32_t width;1029uint32_t height;1030uint32_t colorspace;1031uint32_t xfer_func;1032uint32_t ycbcr_enc;1033uint32_t quantization;1034uint32_t displ_asp_ratio_numer;1035uint32_t displ_asp_ratio_denom;1036uint32_t frame_rate_numer;1037uint32_t frame_rate_denom;1038};10391040/*1041* Request buffer response - response for XENCAMERA_OP_BUF_GET_LAYOUT1042* request:1043* 0 1 2 3 octet1044* +----------------+----------------+----------------+----------------+1045* | id |_BUF_GET_LAYOUT | reserved | 41046* +----------------+----------------+----------------+----------------+1047* | status | 81048* +----------------+----------------+----------------+----------------+1049* | num_planes | reserved | 121050* +----------------+----------------+----------------+----------------+1051* | size | 161052* +----------------+----------------+----------------+----------------+1053* | plane_size[0] | 201054* +----------------+----------------+----------------+----------------+1055* | plane_size[1] | 241056* +----------------+----------------+----------------+----------------+1057* | plane_size[2] | 281058* +----------------+----------------+----------------+----------------+1059* | plane_size[3] | 321060* +----------------+----------------+----------------+----------------+1061* | plane_stride[0] | 361062* +----------------+----------------+----------------+----------------+1063* | plane_stride[1] | 401064* +----------------+----------------+----------------+----------------+1065* | plane_stride[2] | 441066* +----------------+----------------+----------------+----------------+1067* | plane_stride[3] | 481068* +----------------+----------------+----------------+----------------+1069* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|1070* +----------------+----------------+----------------+----------------+1071* | reserved | 641072* +----------------+----------------+----------------+----------------+1073*1074* num_planes - uint8_t, number of planes of the buffer.1075* size - uint32_t, overall size of the buffer including sizes of the1076* individual planes and padding if applicable.1077* plane_size - array of uint32_t, size in octets of the corresponding plane1078* including padding.1079* plane_stride - array of uint32_t, size in octets occupied by the1080* corresponding single image line including padding if applicable.1081*1082* Note! The sizes and strides in this response apply to all buffers created1083* with XENCAMERA_OP_BUF_CREATE command, but individual buffers may have1084* different plane offsets, see XENCAMERA_OP_BUF_REQUEST.plane_offset.1085*/1086struct xencamera_buf_get_layout_resp {1087uint8_t num_planes;1088uint8_t reserved[3];1089uint32_t size;1090uint32_t plane_size[XENCAMERA_MAX_PLANE];1091uint32_t plane_stride[XENCAMERA_MAX_PLANE];1092};10931094/*1095* Request buffer response - response for XENCAMERA_OP_BUF_REQUEST1096* request:1097* 0 1 2 3 octet1098* +----------------+----------------+----------------+----------------+1099* | id |_OP_BUF_REQUEST | reserved | 41100* +----------------+----------------+----------------+----------------+1101* | status | 81102* +----------------+----------------+----------------+----------------+1103* | num_buffers | reserved | 121104* +----------------+----------------+----------------+----------------+1105* | reserved | 161106* +----------------+----------------+----------------+----------------+1107* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|1108* +----------------+----------------+----------------+----------------+1109* | reserved | 641110* +----------------+----------------+----------------+----------------+1111*1112* num_buffers - uint8_t, number of buffers to be used.1113*1114*1115* Control enumerate response - response for XENCAMERA_OP_CTRL_ENUM:1116* 0 1 2 3 octet1117* +----------------+----------------+----------------+----------------+1118* | id | _OP_CTRL_ENUM | reserved | 41119* +----------------+----------------+----------------+----------------+1120* | status | 81121* +----------------+----------------+----------------+----------------+1122* | index | type | reserved | 121123* +----------------+----------------+----------------+----------------+1124* | flags | 161125* +----------------+----------------+----------------+----------------+1126* | min low 32-bits | 201127* +----------------+----------------+----------------+----------------+1128* | min high 32-bits | 241129* +----------------+----------------+----------------+----------------+1130* | max low 32-bits | 281131* +----------------+----------------+----------------+----------------+1132* | max high 32-bits | 321133* +----------------+----------------+----------------+----------------+1134* | step low 32-bits | 361135* +----------------+----------------+----------------+----------------+1136* | step high 32-bits | 401137* +----------------+----------------+----------------+----------------+1138* | def_val low 32-bits | 441139* +----------------+----------------+----------------+----------------+1140* | def_val high 32-bits | 481141* +----------------+----------------+----------------+----------------+1142* | reserved | 521143* +----------------+----------------+----------------+----------------+1144* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|1145* +----------------+----------------+----------------+----------------+1146* | reserved | 641147* +----------------+----------------+----------------+----------------+1148*1149* index - uint8_t, index of the camera control in response.1150* type - uint8_t, type of the control, one of the XENCAMERA_CTRL_XXX.1151* flags - uint32_t, flags of the control, one of the XENCAMERA_CTRL_FLG_XXX.1152* min - int64_t, minimum value of the control.1153* max - int64_t, maximum value of the control.1154* step - int64_t, minimum size in which control value can be changed.1155* def_val - int64_t, default value of the control.1156*/1157struct xencamera_ctrl_enum_resp {1158uint8_t index;1159uint8_t type;1160uint8_t reserved[2];1161uint32_t flags;1162int64_t min;1163int64_t max;1164int64_t step;1165int64_t def_val;1166};11671168/*1169* Get control response - response for XENCAMERA_OP_CTRL_GET:1170* 0 1 2 3 octet1171* +----------------+----------------+----------------+----------------+1172* | id | _OP_CTRL_GET | reserved | 41173* +----------------+----------------+----------------+----------------+1174* | status | 81175* +----------------+----------------+----------------+----------------+1176* | type | reserved | 121177* +----------------+----------------+----------------+----------------+1178* | reserved | 161179* +----------------+----------------+----------------+----------------+1180* | reserved | 201181* +----------------+----------------+----------------+----------------+1182* | value low 32-bit | 241183* +----------------+----------------+----------------+----------------+1184* | value high 32-bit | 281185* +----------------+----------------+----------------+----------------+1186* | reserved | 321187* +----------------+----------------+----------------+----------------+1188* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|1189* +----------------+----------------+----------------+----------------+1190* | reserved | 641191* +----------------+----------------+----------------+----------------+1192*1193* type - uint8_t, type of the control, one of the XENCAMERA_CTRL_XXX.1194* value - int64_t, new value of the control.1195*/11961197/*1198*----------------------------------- Events ----------------------------------1199*1200* Events are sent via a shared page allocated by the front and propagated by1201* evt-event-channel/evt-ring-ref XenStore entries.1202*1203* All event packets have the same length (64 octets).1204* All event packets have common header:1205* 0 1 2 3 octet1206* +----------------+----------------+----------------+----------------+1207* | id | type | reserved | 41208* +----------------+----------------+----------------+----------------+1209* | reserved | 81210* +----------------+----------------+----------------+----------------+1211*1212* id - uint16_t, event id, may be used by front.1213* type - uint8_t, type of the event.1214*1215*1216* Frame captured event - event from back to front when a new captured1217* frame is available:1218* 0 1 2 3 octet1219* +----------------+----------------+----------------+----------------+1220* | id |_EVT_FRAME_AVAIL| reserved | 41221* +----------------+----------------+----------------+----------------+1222* | reserved | 81223* +----------------+----------------+----------------+----------------+1224* | index | reserved | 121225* +----------------+----------------+----------------+----------------+1226* | used_sz | 161227* +----------------+----------------+----------------+----------------+1228* | seq_num | 201229* +----------------+----------------+----------------+----------------+1230* | reserved | 241231* +----------------+----------------+----------------+----------------+1232* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|1233* +----------------+----------------+----------------+----------------+1234* | reserved | 641235* +----------------+----------------+----------------+----------------+1236*1237* index - uint8_t, index of the buffer that contains new captured frame,1238* see XENCAMERA_OP_BUF_CREATE description on the range1239* used_sz - uint32_t, number of octets this frame has. This can be less1240* than the XENCAMERA_OP_BUF_REQUEST.size (response) for compressed formats.1241* seq_num - uint32_t, sequential number of the frame. Must be1242* monotonically increasing. If skips are detected in seq_num then that1243* means that the frames in-between were dropped. Note however that not1244* all video capture hardware is capable of detecting dropped frames.1245* In that case there will be no skips in the sequence counter.1246*/1247struct xencamera_frame_avail_evt {1248uint8_t index;1249uint8_t reserved[3];1250uint32_t used_sz;1251uint32_t seq_num;1252};12531254/*1255* Control change event- event from back to front when camera control1256* has changed:1257* 0 1 2 3 octet1258* +----------------+----------------+----------------+----------------+1259* | id |_EVT_CTRL_CHANGE| reserved | 41260* +----------------+----------------+----------------+----------------+1261* | type | reserved | 81262* +----------------+----------------+----------------+----------------+1263* | reserved | 121264* +----------------+----------------+----------------+----------------+1265* | reserved | 161266* +----------------+----------------+----------------+----------------+1267* | value low 32-bit | 201268* +----------------+----------------+----------------+----------------+1269* | value high 32-bit | 241270* +----------------+----------------+----------------+----------------+1271* | reserved | 281272* +----------------+----------------+----------------+----------------+1273* |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|1274* +----------------+----------------+----------------+----------------+1275* | reserved | 641276* +----------------+----------------+----------------+----------------+1277*1278* type - uint8_t, type of the control, one of the XENCAMERA_CTRL_XXX.1279* value - int64_t, new value of the control.1280*1281* Notes:1282* - this event is not sent for write-only controls1283* - this event is not sent to the originator of the control change1284* - this event is not sent when frontend first connects, e.g. initial1285* control state must be explicitly queried1286*/12871288struct xencamera_req {1289uint16_t id;1290uint8_t operation;1291uint8_t reserved[5];1292union {1293struct xencamera_config_req config;1294struct xencamera_frame_rate_req frame_rate;1295struct xencamera_buf_request buf_request;1296struct xencamera_buf_create_req buf_create;1297struct xencamera_index index;1298struct xencamera_ctrl_value ctrl_value;1299struct xencamera_get_ctrl_req get_ctrl;1300uint8_t reserved[56];1301} req;1302};13031304struct xencamera_resp {1305uint16_t id;1306uint8_t operation;1307uint8_t reserved;1308int32_t status;1309union {1310struct xencamera_config_resp config;1311struct xencamera_buf_get_layout_resp buf_layout;1312struct xencamera_buf_request buf_request;1313struct xencamera_ctrl_enum_resp ctrl_enum;1314struct xencamera_ctrl_value ctrl_value;1315uint8_t reserved1[56];1316} resp;1317};13181319struct xencamera_evt {1320uint16_t id;1321uint8_t type;1322uint8_t reserved[5];1323union {1324struct xencamera_frame_avail_evt frame_avail;1325struct xencamera_ctrl_value ctrl_value;1326uint8_t reserved[56];1327} evt;1328};13291330DEFINE_RING_TYPES(xen_cameraif, struct xencamera_req, struct xencamera_resp);13311332/*1333******************************************************************************1334* Back to front events delivery1335******************************************************************************1336* In order to deliver asynchronous events from back to front a shared page is1337* allocated by front and its granted reference propagated to back via1338* XenStore entries (evt-ring-ref/evt-event-channel).1339* This page has a common header used by both front and back to synchronize1340* access and control event's ring buffer, while back being a producer of the1341* events and front being a consumer. The rest of the page after the header1342* is used for event packets.1343*1344* Upon reception of an event(s) front may confirm its reception1345* for either each event, group of events or none.1346*/13471348struct xencamera_event_page {1349uint32_t in_cons;1350uint32_t in_prod;1351uint8_t reserved[56];1352};13531354#define XENCAMERA_EVENT_PAGE_SIZE 40961355#define XENCAMERA_IN_RING_OFFS (sizeof(struct xencamera_event_page))1356#define XENCAMERA_IN_RING_SIZE (XENCAMERA_EVENT_PAGE_SIZE - XENCAMERA_IN_RING_OFFS)1357#define XENCAMERA_IN_RING_LEN (XENCAMERA_IN_RING_SIZE / sizeof(struct xencamera_evt))1358#define XENCAMERA_IN_RING(page) \1359((struct xencamera_evt *)((char *)(page) + XENCAMERA_IN_RING_OFFS))1360#define XENCAMERA_IN_RING_REF(page, idx) \1361(XENCAMERA_IN_RING((page))[(idx) % XENCAMERA_IN_RING_LEN])13621363#endif /* __XEN_PUBLIC_IO_CAMERAIF_H__ */13641365/*1366* Local variables:1367* mode: C1368* c-file-style: "BSD"1369* c-basic-offset: 41370* tab-width: 41371* indent-tabs-mode: nil1372* End:1373*/137413751376