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