1 /*************************************************************************/ /*!
3 @Title Services Transport Layer common types and definitions
4 @Copyright Copyright (c) Imagination Technologies Ltd. All Rights Reserved
5 @Description Transport layer common types and definitions included into
6 both user mode and kernel mode source.
7 @License Dual MIT/GPLv2
9 The contents of this file are subject to the MIT license as set out below.
11 Permission is hereby granted, free of charge, to any person obtaining a copy
12 of this software and associated documentation files (the "Software"), to deal
13 in the Software without restriction, including without limitation the rights
14 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 copies of the Software, and to permit persons to whom the Software is
16 furnished to do so, subject to the following conditions:
18 The above copyright notice and this permission notice shall be included in
19 all copies or substantial portions of the Software.
21 Alternatively, the contents of this file may be used under the terms of
22 the GNU General Public License Version 2 ("GPL") in which case the provisions
23 of GPL are applicable instead of those above.
25 If you wish to allow use of your version of this file only under the terms of
26 GPL, and not to allow others to use your version of this file under the terms
27 of the MIT license, indicate your decision by deleting the provisions above
28 and replace them with the notice and other provisions required by GPL as set
29 out in the file called "GPL-COPYING" included in this distribution. If you do
30 not delete the provisions above, a recipient may use your version of this file
31 under the terms of either the MIT license or GPL.
33 This License is also included in this distribution in the file called
36 EXCEPT AS OTHERWISE STATED IN A NEGOTIATED AGREEMENT: (A) THE SOFTWARE IS
37 PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING
38 BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
39 PURPOSE AND NONINFRINGEMENT; AND (B) IN NO EVENT SHALL THE AUTHORS OR
40 COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
41 IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
42 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
43 */ /**************************************************************************/
44 #ifndef __PVR_TLCOMMON_H__
45 #define __PVR_TLCOMMON_H__
47 #if defined (__cplusplus)
54 /*! Handle type for stream descriptor objects as created by this API */
55 typedef IMG_HANDLE PVRSRVTL_SD;
57 /*! Maximum stream name length including the null byte */
58 #define PRVSRVTL_MAX_STREAM_NAME_SIZE 40U
60 /*! Packet lengths are always rounded up to a multiple of 8 bytes */
61 #define PVRSRVTL_PACKET_ALIGNMENT 8U
62 #define PVRSRVTL_ALIGN(x) ((x+PVRSRVTL_PACKET_ALIGNMENT-1) & ~(PVRSRVTL_PACKET_ALIGNMENT-1))
65 /*! A packet is made up of a header structure followed by the data bytes.
66 * There are 3 types of packet: normal (has data), data lost and padding,
67 * see packet flags. Header kept small to reduce data overhead.
69 * if the ORDER of the structure members is changed, please UPDATE the
70 * PVRSRVTL_PACKET_FLAG_OFFSET macro.
72 typedef struct _PVRSRVTL_PACKETHDR_
74 IMG_UINT32 uiTypeSize; /*!< Type & number of bytes following header */
75 IMG_UINT32 uiReserved; /*!< Reserve, packets and data must be 8 byte aligned */
77 /* First bytes of TL packet data follow header ... */
78 } PVRSRVTL_PACKETHDR, *PVRSRVTL_PPACKETHDR;
80 /* Structure must always be a size multiple of 8 as stream buffer
81 * still an array of IMG_UINT32s.
83 static_assert((sizeof(PVRSRVTL_PACKETHDR) & (PVRSRVTL_PACKET_ALIGNMENT-1)) == 0,
84 "sizeof(PVRSRVTL_PACKETHDR) must be a multiple of 8");
86 /*! Packet header mask used to extract the size from the uiTypeSize member.
87 * Do not use directly, see GET macros.
89 #define PVRSRVTL_PACKETHDR_SIZE_MASK 0x0000FFFFU
90 #define PVRSRVTL_MAX_PACKET_SIZE (PVRSRVTL_PACKETHDR_SIZE_MASK & ~0xFU)
93 /*! Packet header mask used to extract the type from the uiTypeSize member.
94 * Do not use directly, see GET macros.
96 #define PVRSRVTL_PACKETHDR_TYPE_MASK 0xFF000000U
97 #define PVRSRVTL_PACKETHDR_TYPE_OFFSET 24U
99 /*! Packet type enumeration.
101 typedef enum _PVRSRVTL_PACKETTYPE_
103 /*! Undefined packet */
104 PVRSRVTL_PACKETTYPE_UNDEF = 0,
106 /*! Normal packet type. Indicates data follows the header.
108 PVRSRVTL_PACKETTYPE_DATA = 1,
110 /*! When seen this packet type indicates that at this moment in the stream
111 * packet(s) were not able to be accepted due to space constraints and that
112 * recent data may be lost - depends on how the producer handles the
113 * error. Such packets have no data, data length is 0.
115 PVRSRVTL_PACKETTYPE_MOST_RECENT_WRITE_FAILED = 2,
117 /*! Packets with this type set are padding packets that contain undefined
118 * data and must be ignored/skipped by the client. They are used when the
119 * circular stream buffer wraps around and there is not enough space for
120 * the data at the end of the buffer. Such packets have a length of 0 or
123 PVRSRVTL_PACKETTYPE_PADDING = 3,
125 /*! This packet type conveys to the stream consumer that the stream producer
126 * has reached the end of data for that data sequence. The TLDaemon
127 * has several options for processing these packets that can be selected
128 * on a per stream basis.
130 PVRSRVTL_PACKETTYPE_MARKER_EOS = 4,
132 PVRSRVTL_PACKETTYPE_LAST = PVRSRVTL_PACKETTYPE_MARKER_EOS
133 } PVRSRVTL_PACKETTYPE;
135 /* The SET_PACKET_* macros rely on the order the PVRSRVTL_PACKETHDR members are declared:
136 * uiFlags is the upper half of a structure consisting of 2 uint16 quantities.
138 #define PVRSRVTL_SET_PACKET_DATA(len) (len) | (PVRSRVTL_PACKETTYPE_DATA << PVRSRVTL_PACKETHDR_TYPE_OFFSET)
139 #define PVRSRVTL_SET_PACKET_PADDING(len) (len) | (PVRSRVTL_PACKETTYPE_PADDING << PVRSRVTL_PACKETHDR_TYPE_OFFSET)
140 #define PVRSRVTL_SET_PACKET_WRITE_FAILED (0) | (PVRSRVTL_PACKETTYPE_MOST_RECENT_WRITE_FAILED << PVRSRVTL_PACKETHDR_TYPE_OFFSET)
141 #define PVRSRVTL_SET_PACKET_HDR(len,type) (len) | ((type) << PVRSRVTL_PACKETHDR_TYPE_OFFSET)
143 /*! Returns the number of bytes of data in the packet. p may be any address type
145 #define GET_PACKET_DATA_LEN(p) \
146 ((IMG_UINT32) ((PVRSRVTL_PPACKETHDR)(p))->uiTypeSize & PVRSRVTL_PACKETHDR_SIZE_MASK)
149 /*! Returns a IMG_BYTE* pointer to the first byte of data in the packet */
150 #define GET_PACKET_DATA_PTR(p) \
151 ((IMG_PBYTE) ( ((size_t)p) + sizeof(PVRSRVTL_PACKETHDR)) )
153 /*! Given a PVRSRVTL_PPACKETHDR address, return the address of the next pack
154 * It is up to the caller to determine if the new address is within the packet
157 #define GET_NEXT_PACKET_ADDR(p) \
158 ((PVRSRVTL_PPACKETHDR) ( ((IMG_UINT8 *)p) + sizeof(PVRSRVTL_PACKETHDR) + \
159 (((((PVRSRVTL_PPACKETHDR)p)->uiTypeSize & PVRSRVTL_PACKETHDR_SIZE_MASK) + \
160 (PVRSRVTL_PACKET_ALIGNMENT-1)) & (~(PVRSRVTL_PACKET_ALIGNMENT-1)) ) ))
162 /*! Turns the packet address p into a PVRSRVTL_PPACKETHDR pointer type
164 #define GET_PACKET_HDR(p) ((PVRSRVTL_PPACKETHDR)(p))
166 /*! Get the type of the packet. p is of type PVRSRVTL_PPACKETHDR
168 #define GET_PACKET_TYPE(p) (((p)->uiTypeSize & PVRSRVTL_PACKETHDR_TYPE_MASK)>>PVRSRVTL_PACKETHDR_TYPE_OFFSET)
171 /*! Flags for use with PVRSRVTLOpenStream
172 * 0x01 - Do not block in PVRSRVTLAcquireData() when no bytes are available
173 * 0x02 - When the stream does not exist wait for a bit (2s) in
174 * PVRSRVTLOpenStream() and then exit with a timeout error if it still
176 * 0x04 - Open stream for write only operations.
177 * If flag is not used stream is opened as read-only. This flag is
178 * required if one wants to call reserve/commit/write function on the
179 * stream descriptor. Read from on the stream descriptor opened
180 * with this flag will fail.
182 #define PVRSRV_STREAM_FLAG_NONE (0U)
183 #define PVRSRV_STREAM_FLAG_ACQUIRE_NONBLOCKING (1U<<0)
184 #define PVRSRV_STREAM_FLAG_OPEN_WAIT (1U<<1)
185 #define PVRSRV_STREAM_FLAG_OPEN_WO (1U<<2)
187 #if defined (__cplusplus)
191 #endif /* __PVR_TLCOMMON_H__ */
192 /******************************************************************************
193 End of file (pvrsrv_tlcommon.h)
194 ******************************************************************************/