1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the following conditions are met: |
7 | * Redistributions of source code must retain the above copyright |
8 | notice, this list of conditions and the following disclaimer. |
9 | * Redistributions in binary form must reproduce the above copyright |
10 | notice, this list of conditions and the following disclaimer in the |
11 | documentation and/or other materials provided with the distribution. |
12 | * Neither the name of the copyright holder nor the |
13 | names of its contributors may be used to endorse or promote products |
14 | derived from this software without specific prior written permission. |
15 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | // Contains the #defines for the number of servers / clients etc, these can be |
29 | // over-ridden from the platform makefile if needed |
30 | |
31 | |
32 | #ifndef VCHI_CFG_H_ |
33 | #define VCHI_CFG_H_ |
34 | |
35 | /**************************************************************************************** |
36 | * Defines in this first section are part of the VCHI API and may be examined by VCHI |
37 | * services. |
38 | ***************************************************************************************/ |
39 | |
40 | /* Required alignment of base addresses for bulk transfer, if unaligned transfers are not enabled */ |
41 | /* Really determined by the message driver, and should be available from a run-time call. */ |
42 | #ifndef VCHI_BULK_ALIGN |
43 | # if __VCCOREVER__ >= 0x04000000 |
44 | # define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans |
45 | # else |
46 | # define VCHI_BULK_ALIGN 16 |
47 | # endif |
48 | #endif |
49 | |
50 | /* Required length multiple for bulk transfers, if unaligned transfers are not enabled */ |
51 | /* May be less than or greater than VCHI_BULK_ALIGN */ |
52 | /* Really determined by the message driver, and should be available from a run-time call. */ |
53 | #ifndef VCHI_BULK_GRANULARITY |
54 | # if __VCCOREVER__ >= 0x04000000 |
55 | # define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache cleans |
56 | # else |
57 | # define VCHI_BULK_GRANULARITY 16 |
58 | # endif |
59 | #endif |
60 | |
61 | /* The largest possible message to be queued with vchi_msg_queue. */ |
62 | #ifndef VCHI_MAX_MSG_SIZE |
63 | # if defined VCHI_LOCAL_HOST_PORT |
64 | # define VCHI_MAX_MSG_SIZE 16384 // makes file transfers fast, but should they be using bulk? |
65 | # else |
66 | # define VCHI_MAX_MSG_SIZE 4096 // NOTE: THIS MUST BE LARGER THAN OR EQUAL TO THE SIZE OF THE KHRONOS MERGE BUFFER!! |
67 | # endif |
68 | #endif |
69 | |
70 | /****************************************************************************************** |
71 | * Defines below are system configuration options, and should not be used by VCHI services. |
72 | *****************************************************************************************/ |
73 | |
74 | /* How many connections can we support? A localhost implementation uses 2 connections, |
75 | * 1 for host-app, 1 for VMCS, and these are hooked together by a loopback MPHI VCFW |
76 | * driver. */ |
77 | #ifndef VCHI_MAX_NUM_CONNECTIONS |
78 | # define VCHI_MAX_NUM_CONNECTIONS 3 |
79 | #endif |
80 | |
81 | /* How many services can we open per connection? Extending this doesn't cost processing time, just a small |
82 | * amount of static memory. */ |
83 | #ifndef VCHI_MAX_SERVICES_PER_CONNECTION |
84 | # define VCHI_MAX_SERVICES_PER_CONNECTION 36 |
85 | #endif |
86 | |
87 | /* Adjust if using a message driver that supports more logical TX channels */ |
88 | #ifndef VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION |
89 | # define VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION 9 // 1 MPHI + 8 CCP2 logical channels |
90 | #endif |
91 | |
92 | /* Adjust if using a message driver that supports more logical RX channels */ |
93 | #ifndef VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION |
94 | # define VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 1 // 1 MPHI |
95 | #endif |
96 | |
97 | /* How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the effective |
98 | * receive queue space, less message headers. */ |
99 | #ifndef VCHI_NUM_READ_SLOTS |
100 | # if defined(VCHI_LOCAL_HOST_PORT) |
101 | # define VCHI_NUM_READ_SLOTS 4 |
102 | # else |
103 | # define VCHI_NUM_READ_SLOTS 48 |
104 | # endif |
105 | #endif |
106 | |
107 | /* Do we utilise overrun facility for receive message slots? Can aid peer transmit |
108 | * performance. Only define on VideoCore end, talking to host. |
109 | */ |
110 | //#define VCHI_MSG_RX_OVERRUN |
111 | |
112 | /* How many transmit slots do we use. Generally don't need many, as the hardware driver |
113 | * underneath VCHI will usually have its own buffering. */ |
114 | #ifndef VCHI_NUM_WRITE_SLOTS |
115 | # define VCHI_NUM_WRITE_SLOTS 4 |
116 | #endif |
117 | |
118 | /* If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or more slots, |
119 | * then it's taking up too much buffer space, and the peer service will be told to stop |
120 | * transmitting with an XOFF message. For this to be effective, the VCHI_NUM_READ_SLOTS |
121 | * needs to be considerably bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency |
122 | * is too high. */ |
123 | #ifndef VCHI_XOFF_THRESHOLD |
124 | # define VCHI_XOFF_THRESHOLD (VCHI_NUM_READ_SLOTS / 2) |
125 | #endif |
126 | |
127 | /* After we've sent an XOFF, the peer will be told to resume transmission once the local |
128 | * service has dequeued/released enough messages that it's now occupying |
129 | * VCHI_XON_THRESHOLD slots or fewer. */ |
130 | #ifndef VCHI_XON_THRESHOLD |
131 | # define VCHI_XON_THRESHOLD (VCHI_NUM_READ_SLOTS / 4) |
132 | #endif |
133 | |
134 | /* A size below which a bulk transfer omits the handshake completely and always goes |
135 | * via the message channel, if bulk auxiliary is being sent on that service. (The user |
136 | * can guarantee this by enabling unaligned transmits). |
137 | * Not API. */ |
138 | #ifndef VCHI_MIN_BULK_SIZE |
139 | # define VCHI_MIN_BULK_SIZE ( VCHI_MAX_MSG_SIZE / 2 < 4096 ? VCHI_MAX_MSG_SIZE / 2 : 4096 ) |
140 | #endif |
141 | |
142 | /* Maximum size of bulk transmission chunks, for each interface type. A trade-off between |
143 | * speed and latency; the smaller the chunk size the better change of messages and other |
144 | * bulk transmissions getting in when big bulk transfers are happening. Set to 0 to not |
145 | * break transmissions into chunks. |
146 | */ |
147 | #ifndef VCHI_MAX_BULK_CHUNK_SIZE_MPHI |
148 | # define VCHI_MAX_BULK_CHUNK_SIZE_MPHI (16 * 1024) |
149 | #endif |
150 | |
151 | /* NB Chunked CCP2 transmissions violate the letter of the CCP2 spec by using "JPEG8" mode |
152 | * with multiple-line frames. Only use if the receiver can cope. */ |
153 | #ifndef VCHI_MAX_BULK_CHUNK_SIZE_CCP2 |
154 | # define VCHI_MAX_BULK_CHUNK_SIZE_CCP2 0 |
155 | #endif |
156 | |
157 | /* How many TX messages can we have pending in our transmit slots. Once exhausted, |
158 | * vchi_msg_queue will be blocked. */ |
159 | #ifndef VCHI_TX_MSG_QUEUE_SIZE |
160 | # define VCHI_TX_MSG_QUEUE_SIZE 256 |
161 | #endif |
162 | |
163 | /* How many RX messages can we have parsed in the receive slots. Once exhausted, parsing |
164 | * will be suspended until older messages are dequeued/released. */ |
165 | #ifndef VCHI_RX_MSG_QUEUE_SIZE |
166 | # define VCHI_RX_MSG_QUEUE_SIZE 256 |
167 | #endif |
168 | |
169 | /* Really should be able to cope if we run out of received message descriptors, by |
170 | * suspending parsing as the comment above says, but we don't. This sweeps the issue |
171 | * under the carpet. */ |
172 | #if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS |
173 | # undef VCHI_RX_MSG_QUEUE_SIZE |
174 | # define VCHI_RX_MSG_QUEUE_SIZE (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS |
175 | #endif |
176 | |
177 | /* How many bulk transmits can we have pending. Once exhausted, vchi_bulk_queue_transmit |
178 | * will be blocked. */ |
179 | #ifndef VCHI_TX_BULK_QUEUE_SIZE |
180 | # define VCHI_TX_BULK_QUEUE_SIZE 64 |
181 | #endif |
182 | |
183 | /* How many bulk receives can we have pending. Once exhausted, vchi_bulk_queue_receive |
184 | * will be blocked. */ |
185 | #ifndef VCHI_RX_BULK_QUEUE_SIZE |
186 | # define VCHI_RX_BULK_QUEUE_SIZE 64 |
187 | #endif |
188 | |
189 | /* A limit on how many outstanding bulk requests we expect the peer to give us. If |
190 | * the peer asks for more than this, VCHI will fail and assert. The number is determined |
191 | * by the peer's hardware - it's the number of outstanding requests that can be queued |
192 | * on all bulk channels. VC3's MPHI peripheral allows 16. */ |
193 | #ifndef VCHI_MAX_PEER_BULK_REQUESTS |
194 | # define VCHI_MAX_PEER_BULK_REQUESTS 32 |
195 | #endif |
196 | |
197 | /* Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2 |
198 | * transmitter on and off. |
199 | */ |
200 | /*#define VCHI_CCP2TX_MANUAL_POWER*/ |
201 | |
202 | #ifndef VCHI_CCP2TX_MANUAL_POWER |
203 | |
204 | /* Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state. Set |
205 | * negative for no IDLE. |
206 | */ |
207 | # ifndef VCHI_CCP2TX_IDLE_TIMEOUT |
208 | # define VCHI_CCP2TX_IDLE_TIMEOUT 5 |
209 | # endif |
210 | |
211 | /* Timeout (in milliseconds) for putting the CCP2TX interface into OFF state. Set |
212 | * negative for no OFF. |
213 | */ |
214 | # ifndef VCHI_CCP2TX_OFF_TIMEOUT |
215 | # define VCHI_CCP2TX_OFF_TIMEOUT 1000 |
216 | # endif |
217 | |
218 | #endif /* VCHI_CCP2TX_MANUAL_POWER */ |
219 | |
220 | #endif /* VCHI_CFG_H_ */ |
221 | |
222 | /****************************** End of file **********************************/ |
223 | |