aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleksandr Andrushchenko <andr2000@gmail.com>2018-04-12 13:26:27 -0400
committerBoris Ostrovsky <boris.ostrovsky@oracle.com>2018-04-17 08:26:33 -0400
commitcd6e992b3aab072cc90839508aaf5573c8f7e066 (patch)
treeae8832ca9aadf7887b5885a5600be89942e8fad6
parentde3d01fd8549ec0444fc917aab711b3f884930c5 (diff)
xen/sndif: Sync up with the canonical definition in Xen
This is the sync up with the canonical definition of the sound protocol in Xen: 1. Protocol version was referenced in the protocol description, but missed its definition. Fixed by adding a constant for current protocol version. 2. Some of the request descriptions have "reserved" fields missed: fixed by adding corresponding entries. 3. Extend the size of the requests and responses to 64 octets. Bump protocol version to 2. 4. Add explicit back and front synchronization In order to provide explicit synchronization between backend and frontend the following changes are introduced in the protocol: - add new ring buffer for sending asynchronous events from backend to frontend to report number of bytes played by the frontend (XENSND_EVT_CUR_POS) - introduce trigger events for playback control: start/stop/pause/resume - add "req-" prefix to event-channel and ring-ref to unify naming of the Xen event channels for requests and events 5. Add explicit back and front parameter negotiation In order to provide explicit stream parameter negotiation between backend and frontend the following changes are introduced in the protocol: add XENSND_OP_HW_PARAM_QUERY request to read/update configuration space for the parameters given: request passes desired parameter's intervals/masks and the response to this request returns allowed min/max intervals/masks to be used. Signed-off-by: Oleksandr Andrushchenko <oleksandr_andrushchenko@epam.com> Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@epam.com> Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Reviewed-by: Boris Ostrovsky <boris.ostrovsky@oracle.com> Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com> Cc: Takashi Iwai <tiwai@suse.de> Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
-rw-r--r--include/xen/interface/io/sndif.h322
1 files changed, 306 insertions, 16 deletions
diff --git a/include/xen/interface/io/sndif.h b/include/xen/interface/io/sndif.h
index 5c918276835e..78bb5d9f8d83 100644
--- a/include/xen/interface/io/sndif.h
+++ b/include/xen/interface/io/sndif.h
@@ -38,6 +38,13 @@
38 38
39/* 39/*
40 ****************************************************************************** 40 ******************************************************************************
41 * Protocol version
42 ******************************************************************************
43 */
44#define XENSND_PROTOCOL_VERSION 2
45
46/*
47 ******************************************************************************
41 * Feature and Parameter Negotiation 48 * Feature and Parameter Negotiation
42 ****************************************************************************** 49 ******************************************************************************
43 * 50 *
@@ -106,6 +113,8 @@
106 * 113 *
107 * /local/domain/1/device/vsnd/0/0/0/ring-ref = "386" 114 * /local/domain/1/device/vsnd/0/0/0/ring-ref = "386"
108 * /local/domain/1/device/vsnd/0/0/0/event-channel = "15" 115 * /local/domain/1/device/vsnd/0/0/0/event-channel = "15"
116 * /local/domain/1/device/vsnd/0/0/0/evt-ring-ref = "1386"
117 * /local/domain/1/device/vsnd/0/0/0/evt-event-channel = "215"
109 * 118 *
110 *------------------------------ Stream 1, capture ---------------------------- 119 *------------------------------ Stream 1, capture ----------------------------
111 * 120 *
@@ -115,6 +124,8 @@
115 * 124 *
116 * /local/domain/1/device/vsnd/0/0/1/ring-ref = "384" 125 * /local/domain/1/device/vsnd/0/0/1/ring-ref = "384"
117 * /local/domain/1/device/vsnd/0/0/1/event-channel = "13" 126 * /local/domain/1/device/vsnd/0/0/1/event-channel = "13"
127 * /local/domain/1/device/vsnd/0/0/1/evt-ring-ref = "1384"
128 * /local/domain/1/device/vsnd/0/0/1/evt-event-channel = "213"
118 * 129 *
119 *------------------------------- PCM device 1 -------------------------------- 130 *------------------------------- PCM device 1 --------------------------------
120 * 131 *
@@ -128,6 +139,8 @@
128 * 139 *
129 * /local/domain/1/device/vsnd/0/1/0/ring-ref = "387" 140 * /local/domain/1/device/vsnd/0/1/0/ring-ref = "387"
130 * /local/domain/1/device/vsnd/0/1/0/event-channel = "151" 141 * /local/domain/1/device/vsnd/0/1/0/event-channel = "151"
142 * /local/domain/1/device/vsnd/0/1/0/evt-ring-ref = "1387"
143 * /local/domain/1/device/vsnd/0/1/0/evt-event-channel = "351"
131 * 144 *
132 *------------------------------- PCM device 2 -------------------------------- 145 *------------------------------- PCM device 2 --------------------------------
133 * 146 *
@@ -140,6 +153,8 @@
140 * 153 *
141 * /local/domain/1/device/vsnd/0/2/0/ring-ref = "389" 154 * /local/domain/1/device/vsnd/0/2/0/ring-ref = "389"
142 * /local/domain/1/device/vsnd/0/2/0/event-channel = "152" 155 * /local/domain/1/device/vsnd/0/2/0/event-channel = "152"
156 * /local/domain/1/device/vsnd/0/2/0/evt-ring-ref = "1389"
157 * /local/domain/1/device/vsnd/0/2/0/evt-event-channel = "452"
143 * 158 *
144 ****************************************************************************** 159 ******************************************************************************
145 * Backend XenBus Nodes 160 * Backend XenBus Nodes
@@ -285,6 +300,23 @@
285 * The Xen grant reference granting permission for the backend to map 300 * The Xen grant reference granting permission for the backend to map
286 * a sole page in a single page sized ring buffer. 301 * a sole page in a single page sized ring buffer.
287 * 302 *
303 *--------------------- Stream Event Transport Parameters ---------------------
304 *
305 * This communication path is used to deliver asynchronous events from backend
306 * to frontend, set up per stream.
307 *
308 * evt-event-channel
309 * Values: <uint32_t>
310 *
311 * The identifier of the Xen event channel used to signal activity
312 * in the ring buffer.
313 *
314 * evt-ring-ref
315 * Values: <uint32_t>
316 *
317 * The Xen grant reference granting permission for the backend to map
318 * a sole page in a single page sized ring buffer.
319 *
288 ****************************************************************************** 320 ******************************************************************************
289 * STATE DIAGRAMS 321 * STATE DIAGRAMS
290 ****************************************************************************** 322 ******************************************************************************
@@ -432,6 +464,20 @@
432#define XENSND_OP_GET_VOLUME 5 464#define XENSND_OP_GET_VOLUME 5
433#define XENSND_OP_MUTE 6 465#define XENSND_OP_MUTE 6
434#define XENSND_OP_UNMUTE 7 466#define XENSND_OP_UNMUTE 7
467#define XENSND_OP_TRIGGER 8
468#define XENSND_OP_HW_PARAM_QUERY 9
469
470#define XENSND_OP_TRIGGER_START 0
471#define XENSND_OP_TRIGGER_PAUSE 1
472#define XENSND_OP_TRIGGER_STOP 2
473#define XENSND_OP_TRIGGER_RESUME 3
474
475/*
476 ******************************************************************************
477 * EVENT CODES
478 ******************************************************************************
479 */
480#define XENSND_EVT_CUR_POS 0
435 481
436/* 482/*
437 ****************************************************************************** 483 ******************************************************************************
@@ -448,6 +494,8 @@
448#define XENSND_FIELD_VCARD_LONG_NAME "long-name" 494#define XENSND_FIELD_VCARD_LONG_NAME "long-name"
449#define XENSND_FIELD_RING_REF "ring-ref" 495#define XENSND_FIELD_RING_REF "ring-ref"
450#define XENSND_FIELD_EVT_CHNL "event-channel" 496#define XENSND_FIELD_EVT_CHNL "event-channel"
497#define XENSND_FIELD_EVT_RING_REF "evt-ring-ref"
498#define XENSND_FIELD_EVT_EVT_CHNL "evt-event-channel"
451#define XENSND_FIELD_DEVICE_NAME "name" 499#define XENSND_FIELD_DEVICE_NAME "name"
452#define XENSND_FIELD_TYPE "type" 500#define XENSND_FIELD_TYPE "type"
453#define XENSND_FIELD_STREAM_UNIQUE_ID "unique-id" 501#define XENSND_FIELD_STREAM_UNIQUE_ID "unique-id"
@@ -526,7 +574,7 @@
526 * 574 *
527 *---------------------------------- Requests --------------------------------- 575 *---------------------------------- Requests ---------------------------------
528 * 576 *
529 * All request packets have the same length (32 octets) 577 * All request packets have the same length (64 octets)
530 * All request packets have common header: 578 * All request packets have common header:
531 * 0 1 2 3 octet 579 * 0 1 2 3 octet
532 * +----------------+----------------+----------------+----------------+ 580 * +----------------+----------------+----------------+----------------+
@@ -559,11 +607,13 @@
559 * +----------------+----------------+----------------+----------------+ 607 * +----------------+----------------+----------------+----------------+
560 * | gref_directory | 24 608 * | gref_directory | 24
561 * +----------------+----------------+----------------+----------------+ 609 * +----------------+----------------+----------------+----------------+
562 * | reserved | 28 610 * | period_sz | 28
611 * +----------------+----------------+----------------+----------------+
612 * | reserved | 32
563 * +----------------+----------------+----------------+----------------+ 613 * +----------------+----------------+----------------+----------------+
564 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 614 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
565 * +----------------+----------------+----------------+----------------+ 615 * +----------------+----------------+----------------+----------------+
566 * | reserved | 32 616 * | reserved | 64
567 * +----------------+----------------+----------------+----------------+ 617 * +----------------+----------------+----------------+----------------+
568 * 618 *
569 * pcm_rate - uint32_t, stream data rate, Hz 619 * pcm_rate - uint32_t, stream data rate, Hz
@@ -571,6 +621,14 @@
571 * pcm_channels - uint8_t, number of channels of this stream, 621 * pcm_channels - uint8_t, number of channels of this stream,
572 * [channels-min; channels-max] 622 * [channels-min; channels-max]
573 * buffer_sz - uint32_t, buffer size to be allocated, octets 623 * buffer_sz - uint32_t, buffer size to be allocated, octets
624 * period_sz - uint32_t, event period size, octets
625 * This is the requested value of the period at which frontend would
626 * like to receive XENSND_EVT_CUR_POS notifications from the backend when
627 * stream position advances during playback/capture.
628 * It shows how many octets are expected to be played/captured before
629 * sending such an event.
630 * If set to 0 no XENSND_EVT_CUR_POS events are sent by the backend.
631 *
574 * gref_directory - grant_ref_t, a reference to the first shared page 632 * gref_directory - grant_ref_t, a reference to the first shared page
575 * describing shared buffer references. At least one page exists. If shared 633 * describing shared buffer references. At least one page exists. If shared
576 * buffer size (buffer_sz) exceeds what can be addressed by this single page, 634 * buffer size (buffer_sz) exceeds what can be addressed by this single page,
@@ -585,6 +643,7 @@ struct xensnd_open_req {
585 uint16_t reserved; 643 uint16_t reserved;
586 uint32_t buffer_sz; 644 uint32_t buffer_sz;
587 grant_ref_t gref_directory; 645 grant_ref_t gref_directory;
646 uint32_t period_sz;
588}; 647};
589 648
590/* 649/*
@@ -632,7 +691,7 @@ struct xensnd_page_directory {
632 * +----------------+----------------+----------------+----------------+ 691 * +----------------+----------------+----------------+----------------+
633 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 692 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
634 * +----------------+----------------+----------------+----------------+ 693 * +----------------+----------------+----------------+----------------+
635 * | reserved | 32 694 * | reserved | 64
636 * +----------------+----------------+----------------+----------------+ 695 * +----------------+----------------+----------------+----------------+
637 * 696 *
638 * Request read/write - used for read (for capture) or write (for playback): 697 * Request read/write - used for read (for capture) or write (for playback):
@@ -650,7 +709,7 @@ struct xensnd_page_directory {
650 * +----------------+----------------+----------------+----------------+ 709 * +----------------+----------------+----------------+----------------+
651 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 710 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
652 * +----------------+----------------+----------------+----------------+ 711 * +----------------+----------------+----------------+----------------+
653 * | reserved | 32 712 * | reserved | 64
654 * +----------------+----------------+----------------+----------------+ 713 * +----------------+----------------+----------------+----------------+
655 * 714 *
656 * operation - XENSND_OP_READ for read or XENSND_OP_WRITE for write 715 * operation - XENSND_OP_READ for read or XENSND_OP_WRITE for write
@@ -673,9 +732,11 @@ struct xensnd_rw_req {
673 * +----------------+----------------+----------------+----------------+ 732 * +----------------+----------------+----------------+----------------+
674 * | length | 16 733 * | length | 16
675 * +----------------+----------------+----------------+----------------+ 734 * +----------------+----------------+----------------+----------------+
735 * | reserved | 20
736 * +----------------+----------------+----------------+----------------+
676 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 737 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
677 * +----------------+----------------+----------------+----------------+ 738 * +----------------+----------------+----------------+----------------+
678 * | reserved | 32 739 * | reserved | 64
679 * +----------------+----------------+----------------+----------------+ 740 * +----------------+----------------+----------------+----------------+
680 * 741 *
681 * operation - XENSND_OP_SET_VOLUME for volume set 742 * operation - XENSND_OP_SET_VOLUME for volume set
@@ -713,9 +774,11 @@ struct xensnd_rw_req {
713 * +----------------+----------------+----------------+----------------+ 774 * +----------------+----------------+----------------+----------------+
714 * | length | 16 775 * | length | 16
715 * +----------------+----------------+----------------+----------------+ 776 * +----------------+----------------+----------------+----------------+
777 * | reserved | 20
778 * +----------------+----------------+----------------+----------------+
716 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 779 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
717 * +----------------+----------------+----------------+----------------+ 780 * +----------------+----------------+----------------+----------------+
718 * | reserved | 32 781 * | reserved | 64
719 * +----------------+----------------+----------------+----------------+ 782 * +----------------+----------------+----------------+----------------+
720 * 783 *
721 * operation - XENSND_OP_MUTE for mute or XENSND_OP_UNMUTE for unmute 784 * operation - XENSND_OP_MUTE for mute or XENSND_OP_UNMUTE for unmute
@@ -743,32 +806,213 @@ struct xensnd_rw_req {
743 * 806 *
744 * The 'struct xensnd_rw_req' is also used for XENSND_OP_SET_VOLUME, 807 * The 'struct xensnd_rw_req' is also used for XENSND_OP_SET_VOLUME,
745 * XENSND_OP_GET_VOLUME, XENSND_OP_MUTE, XENSND_OP_UNMUTE. 808 * XENSND_OP_GET_VOLUME, XENSND_OP_MUTE, XENSND_OP_UNMUTE.
809 *
810 * Request stream running state change - trigger PCM stream running state
811 * to start, stop, pause or resume:
812 *
813 * 0 1 2 3 octet
814 * +----------------+----------------+----------------+----------------+
815 * | id | _OP_TRIGGER | reserved | 4
816 * +----------------+----------------+----------------+----------------+
817 * | reserved | 8
818 * +----------------+----------------+----------------+----------------+
819 * | type | reserved | 12
820 * +----------------+----------------+----------------+----------------+
821 * | reserved | 16
822 * +----------------+----------------+----------------+----------------+
823 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
824 * +----------------+----------------+----------------+----------------+
825 * | reserved | 64
826 * +----------------+----------------+----------------+----------------+
827 *
828 * type - uint8_t, XENSND_OP_TRIGGER_XXX value
746 */ 829 */
747 830
831struct xensnd_trigger_req {
832 uint8_t type;
833};
834
748/* 835/*
749 *---------------------------------- Responses -------------------------------- 836 * Request stream parameter ranges: request intervals and
837 * masks of supported ranges for stream configuration values.
750 * 838 *
751 * All response packets have the same length (32 octets) 839 * Sound device configuration for a particular stream is a limited subset
840 * of the multidimensional configuration available on XenStore, e.g.
841 * once the frame rate has been selected there is a limited supported range
842 * for sample rates becomes available (which might be the same set configured
843 * on XenStore or less). For example, selecting 96kHz sample rate may limit
844 * number of channels available for such configuration from 4 to 2, etc.
845 * Thus, each call to XENSND_OP_HW_PARAM_QUERY may reduce configuration
846 * space making it possible to iteratively get the final stream configuration,
847 * used in XENSND_OP_OPEN request.
848 *
849 * See response format for this request.
752 * 850 *
753 * Response for all requests:
754 * 0 1 2 3 octet 851 * 0 1 2 3 octet
755 * +----------------+----------------+----------------+----------------+ 852 * +----------------+----------------+----------------+----------------+
756 * | id | operation | reserved | 4 853 * | id | _HW_PARAM_QUERY| reserved | 4
757 * +----------------+----------------+----------------+----------------+ 854 * +----------------+----------------+----------------+----------------+
758 * | status | 8 855 * | reserved | 8
856 * +----------------+----------------+----------------+----------------+
857 * | formats mask low 32-bit | 12
858 * +----------------+----------------+----------------+----------------+
859 * | formats mask high 32-bit | 16
759 * +----------------+----------------+----------------+----------------+ 860 * +----------------+----------------+----------------+----------------+
760 * | reserved | 12 861 * | min rate | 20
862 * +----------------+----------------+----------------+----------------+
863 * | max rate | 24
864 * +----------------+----------------+----------------+----------------+
865 * | min channels | 28
866 * +----------------+----------------+----------------+----------------+
867 * | max channels | 32
868 * +----------------+----------------+----------------+----------------+
869 * | min buffer frames | 36
870 * +----------------+----------------+----------------+----------------+
871 * | max buffer frames | 40
872 * +----------------+----------------+----------------+----------------+
873 * | min period frames | 44
874 * +----------------+----------------+----------------+----------------+
875 * | max period frames | 48
876 * +----------------+----------------+----------------+----------------+
877 * | reserved | 52
761 * +----------------+----------------+----------------+----------------+ 878 * +----------------+----------------+----------------+----------------+
762 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/| 879 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
763 * +----------------+----------------+----------------+----------------+ 880 * +----------------+----------------+----------------+----------------+
764 * | reserved | 32 881 * | reserved | 64
882 * +----------------+----------------+----------------+----------------+
883 *
884 * formats - uint64_t, bit mask representing values of the parameter
885 * made as bitwise OR of (1 << XENSND_PCM_FORMAT_XXX) values
886 *
887 * For interval parameters:
888 * min - uint32_t, minimum value of the parameter
889 * max - uint32_t, maximum value of the parameter
890 *
891 * Frame is defined as a product of the number of channels by the
892 * number of octets per one sample.
893 */
894
895struct xensnd_query_hw_param {
896 uint64_t formats;
897 struct {
898 uint32_t min;
899 uint32_t max;
900 } rates;
901 struct {
902 uint32_t min;
903 uint32_t max;
904 } channels;
905 struct {
906 uint32_t min;
907 uint32_t max;
908 } buffer;
909 struct {
910 uint32_t min;
911 uint32_t max;
912 } period;
913};
914
915/*
916 *---------------------------------- Responses --------------------------------
917 *
918 * All response packets have the same length (64 octets)
919 *
920 * All response packets have common header:
921 * 0 1 2 3 octet
922 * +----------------+----------------+----------------+----------------+
923 * | id | operation | reserved | 4
924 * +----------------+----------------+----------------+----------------+
925 * | status | 8
765 * +----------------+----------------+----------------+----------------+ 926 * +----------------+----------------+----------------+----------------+
766 * 927 *
767 * id - uint16_t, copied from the request 928 * id - uint16_t, copied from the request
768 * operation - uint8_t, XENSND_OP_* - copied from request 929 * operation - uint8_t, XENSND_OP_* - copied from request
769 * status - int32_t, response status, zero on success and -XEN_EXX on failure 930 * status - int32_t, response status, zero on success and -XEN_EXX on failure
931 *
932 *
933 * HW parameter query response - response for XENSND_OP_HW_PARAM_QUERY:
934 * 0 1 2 3 octet
935 * +----------------+----------------+----------------+----------------+
936 * | id | operation | reserved | 4
937 * +----------------+----------------+----------------+----------------+
938 * | status | 8
939 * +----------------+----------------+----------------+----------------+
940 * | formats mask low 32-bit | 12
941 * +----------------+----------------+----------------+----------------+
942 * | formats mask high 32-bit | 16
943 * +----------------+----------------+----------------+----------------+
944 * | min rate | 20
945 * +----------------+----------------+----------------+----------------+
946 * | max rate | 24
947 * +----------------+----------------+----------------+----------------+
948 * | min channels | 28
949 * +----------------+----------------+----------------+----------------+
950 * | max channels | 32
951 * +----------------+----------------+----------------+----------------+
952 * | min buffer frames | 36
953 * +----------------+----------------+----------------+----------------+
954 * | max buffer frames | 40
955 * +----------------+----------------+----------------+----------------+
956 * | min period frames | 44
957 * +----------------+----------------+----------------+----------------+
958 * | max period frames | 48
959 * +----------------+----------------+----------------+----------------+
960 * | reserved | 52
961 * +----------------+----------------+----------------+----------------+
962 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
963 * +----------------+----------------+----------------+----------------+
964 * | reserved | 64
965 * +----------------+----------------+----------------+----------------+
966 *
967 * Meaning of the values in this response is the same as for
968 * XENSND_OP_HW_PARAM_QUERY request.
969 */
970
971/*
972 *----------------------------------- Events ----------------------------------
973 *
974 * Events are sent via shared page allocated by the front and propagated by
975 * evt-event-channel/evt-ring-ref XenStore entries
976 * All event packets have the same length (64 octets)
977 * All event packets have common header:
978 * 0 1 2 3 octet
979 * +----------------+----------------+----------------+----------------+
980 * | id | type | reserved | 4
981 * +----------------+----------------+----------------+----------------+
982 * | reserved | 8
983 * +----------------+----------------+----------------+----------------+
984 *
985 * id - uint16_t, event id, may be used by front
986 * type - uint8_t, type of the event
987 *
988 *
989 * Current stream position - event from back to front when stream's
990 * playback/capture position has advanced:
991 * 0 1 2 3 octet
992 * +----------------+----------------+----------------+----------------+
993 * | id | _EVT_CUR_POS | reserved | 4
994 * +----------------+----------------+----------------+----------------+
995 * | reserved | 8
996 * +----------------+----------------+----------------+----------------+
997 * | position low 32-bit | 12
998 * +----------------+----------------+----------------+----------------+
999 * | position high 32-bit | 16
1000 * +----------------+----------------+----------------+----------------+
1001 * | reserved | 20
1002 * +----------------+----------------+----------------+----------------+
1003 * |/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/|
1004 * +----------------+----------------+----------------+----------------+
1005 * | reserved | 64
1006 * +----------------+----------------+----------------+----------------+
1007 *
1008 * position - current value of stream's playback/capture position, octets
1009 *
770 */ 1010 */
771 1011
1012struct xensnd_cur_pos_evt {
1013 uint64_t position;
1014};
1015
772struct xensnd_req { 1016struct xensnd_req {
773 uint16_t id; 1017 uint16_t id;
774 uint8_t operation; 1018 uint8_t operation;
@@ -776,7 +1020,9 @@ struct xensnd_req {
776 union { 1020 union {
777 struct xensnd_open_req open; 1021 struct xensnd_open_req open;
778 struct xensnd_rw_req rw; 1022 struct xensnd_rw_req rw;
779 uint8_t reserved[24]; 1023 struct xensnd_trigger_req trigger;
1024 struct xensnd_query_hw_param hw_param;
1025 uint8_t reserved[56];
780 } op; 1026 } op;
781}; 1027};
782 1028
@@ -785,9 +1031,53 @@ struct xensnd_resp {
785 uint8_t operation; 1031 uint8_t operation;
786 uint8_t reserved; 1032 uint8_t reserved;
787 int32_t status; 1033 int32_t status;
788 uint8_t reserved1[24]; 1034 union {
1035 struct xensnd_query_hw_param hw_param;
1036 uint8_t reserved1[56];
1037 } resp;
1038};
1039
1040struct xensnd_evt {
1041 uint16_t id;
1042 uint8_t type;
1043 uint8_t reserved[5];
1044 union {
1045 struct xensnd_cur_pos_evt cur_pos;
1046 uint8_t reserved[56];
1047 } op;
789}; 1048};
790 1049
791DEFINE_RING_TYPES(xen_sndif, struct xensnd_req, struct xensnd_resp); 1050DEFINE_RING_TYPES(xen_sndif, struct xensnd_req, struct xensnd_resp);
792 1051
1052/*
1053 ******************************************************************************
1054 * Back to front events delivery
1055 ******************************************************************************
1056 * In order to deliver asynchronous events from back to front a shared page is
1057 * allocated by front and its granted reference propagated to back via
1058 * XenStore entries (evt-ring-ref/evt-event-channel).
1059 * This page has a common header used by both front and back to synchronize
1060 * access and control event's ring buffer, while back being a producer of the
1061 * events and front being a consumer. The rest of the page after the header
1062 * is used for event packets.
1063 *
1064 * Upon reception of an event(s) front may confirm its reception
1065 * for either each event, group of events or none.
1066 */
1067
1068struct xensnd_event_page {
1069 uint32_t in_cons;
1070 uint32_t in_prod;
1071 uint8_t reserved[56];
1072};
1073
1074#define XENSND_EVENT_PAGE_SIZE XEN_PAGE_SIZE
1075#define XENSND_IN_RING_OFFS (sizeof(struct xensnd_event_page))
1076#define XENSND_IN_RING_SIZE (XENSND_EVENT_PAGE_SIZE - XENSND_IN_RING_OFFS)
1077#define XENSND_IN_RING_LEN (XENSND_IN_RING_SIZE / sizeof(struct xensnd_evt))
1078#define XENSND_IN_RING(page) \
1079 ((struct xensnd_evt *)((char *)(page) + XENSND_IN_RING_OFFS))
1080#define XENSND_IN_RING_REF(page, idx) \
1081 (XENSND_IN_RING((page))[(idx) % XENSND_IN_RING_LEN])
1082
793#endif /* __XEN_PUBLIC_IO_SNDIF_H__ */ 1083#endif /* __XEN_PUBLIC_IO_SNDIF_H__ */