vchi_cfg.h revision 278277
1278277Sgonzo/** 2278277Sgonzo * Copyright (c) 2010-2012 Broadcom. All rights reserved. 3278277Sgonzo * 4278277Sgonzo * Redistribution and use in source and binary forms, with or without 5278277Sgonzo * modification, are permitted provided that the following conditions 6278277Sgonzo * are met: 7278277Sgonzo * 1. Redistributions of source code must retain the above copyright 8278277Sgonzo * notice, this list of conditions, and the following disclaimer, 9278277Sgonzo * without modification. 10278277Sgonzo * 2. Redistributions in binary form must reproduce the above copyright 11278277Sgonzo * notice, this list of conditions and the following disclaimer in the 12278277Sgonzo * documentation and/or other materials provided with the distribution. 13278277Sgonzo * 3. The names of the above-listed copyright holders may not be used 14278277Sgonzo * to endorse or promote products derived from this software without 15278277Sgonzo * specific prior written permission. 16278277Sgonzo * 17278277Sgonzo * ALTERNATIVELY, this software may be distributed under the terms of the 18278277Sgonzo * GNU General Public License ("GPL") version 2, as published by the Free 19278277Sgonzo * Software Foundation. 20278277Sgonzo * 21278277Sgonzo * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS 22278277Sgonzo * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, 23278277Sgonzo * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 24278277Sgonzo * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR 25278277Sgonzo * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26278277Sgonzo * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 27278277Sgonzo * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 28278277Sgonzo * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 29278277Sgonzo * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING 30278277Sgonzo * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31278277Sgonzo * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32278277Sgonzo */ 33278277Sgonzo 34278277Sgonzo#ifndef VCHI_CFG_H_ 35278277Sgonzo#define VCHI_CFG_H_ 36278277Sgonzo 37278277Sgonzo/**************************************************************************************** 38278277Sgonzo * Defines in this first section are part of the VCHI API and may be examined by VCHI 39278277Sgonzo * services. 40278277Sgonzo ***************************************************************************************/ 41278277Sgonzo 42278277Sgonzo/* Required alignment of base addresses for bulk transfer, if unaligned transfers are not enabled */ 43278277Sgonzo/* Really determined by the message driver, and should be available from a run-time call. */ 44278277Sgonzo#ifndef VCHI_BULK_ALIGN 45278277Sgonzo# if __VCCOREVER__ >= 0x04000000 46278277Sgonzo# define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans 47278277Sgonzo# else 48278277Sgonzo# define VCHI_BULK_ALIGN 16 49278277Sgonzo# endif 50278277Sgonzo#endif 51278277Sgonzo 52278277Sgonzo/* Required length multiple for bulk transfers, if unaligned transfers are not enabled */ 53278277Sgonzo/* May be less than or greater than VCHI_BULK_ALIGN */ 54278277Sgonzo/* Really determined by the message driver, and should be available from a run-time call. */ 55278277Sgonzo#ifndef VCHI_BULK_GRANULARITY 56278277Sgonzo# if __VCCOREVER__ >= 0x04000000 57278277Sgonzo# define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache cleans 58278277Sgonzo# else 59278277Sgonzo# define VCHI_BULK_GRANULARITY 16 60278277Sgonzo# endif 61278277Sgonzo#endif 62278277Sgonzo 63278277Sgonzo/* The largest possible message to be queued with vchi_msg_queue. */ 64278277Sgonzo#ifndef VCHI_MAX_MSG_SIZE 65278277Sgonzo# if defined VCHI_LOCAL_HOST_PORT 66278277Sgonzo# define VCHI_MAX_MSG_SIZE 16384 // makes file transfers fast, but should they be using bulk? 67278277Sgonzo# else 68278277Sgonzo# define VCHI_MAX_MSG_SIZE 4096 // NOTE: THIS MUST BE LARGER THAN OR EQUAL TO THE SIZE OF THE KHRONOS MERGE BUFFER!! 69278277Sgonzo# endif 70278277Sgonzo#endif 71278277Sgonzo 72278277Sgonzo/****************************************************************************************** 73278277Sgonzo * Defines below are system configuration options, and should not be used by VCHI services. 74278277Sgonzo *****************************************************************************************/ 75278277Sgonzo 76278277Sgonzo/* How many connections can we support? A localhost implementation uses 2 connections, 77278277Sgonzo * 1 for host-app, 1 for VMCS, and these are hooked together by a loopback MPHI VCFW 78278277Sgonzo * driver. */ 79278277Sgonzo#ifndef VCHI_MAX_NUM_CONNECTIONS 80278277Sgonzo# define VCHI_MAX_NUM_CONNECTIONS 3 81278277Sgonzo#endif 82278277Sgonzo 83278277Sgonzo/* How many services can we open per connection? Extending this doesn't cost processing time, just a small 84278277Sgonzo * amount of static memory. */ 85278277Sgonzo#ifndef VCHI_MAX_SERVICES_PER_CONNECTION 86278277Sgonzo# define VCHI_MAX_SERVICES_PER_CONNECTION 36 87278277Sgonzo#endif 88278277Sgonzo 89278277Sgonzo/* Adjust if using a message driver that supports more logical TX channels */ 90278277Sgonzo#ifndef VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION 91278277Sgonzo# define VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION 9 // 1 MPHI + 8 CCP2 logical channels 92278277Sgonzo#endif 93278277Sgonzo 94278277Sgonzo/* Adjust if using a message driver that supports more logical RX channels */ 95278277Sgonzo#ifndef VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 96278277Sgonzo# define VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 1 // 1 MPHI 97278277Sgonzo#endif 98278277Sgonzo 99278277Sgonzo/* How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the effective 100278277Sgonzo * receive queue space, less message headers. */ 101278277Sgonzo#ifndef VCHI_NUM_READ_SLOTS 102278277Sgonzo# if defined(VCHI_LOCAL_HOST_PORT) 103278277Sgonzo# define VCHI_NUM_READ_SLOTS 4 104278277Sgonzo# else 105278277Sgonzo# define VCHI_NUM_READ_SLOTS 48 106278277Sgonzo# endif 107278277Sgonzo#endif 108278277Sgonzo 109278277Sgonzo/* Do we utilise overrun facility for receive message slots? Can aid peer transmit 110278277Sgonzo * performance. Only define on VideoCore end, talking to host. 111278277Sgonzo */ 112278277Sgonzo//#define VCHI_MSG_RX_OVERRUN 113278277Sgonzo 114278277Sgonzo/* How many transmit slots do we use. Generally don't need many, as the hardware driver 115278277Sgonzo * underneath VCHI will usually have its own buffering. */ 116278277Sgonzo#ifndef VCHI_NUM_WRITE_SLOTS 117278277Sgonzo# define VCHI_NUM_WRITE_SLOTS 4 118278277Sgonzo#endif 119278277Sgonzo 120278277Sgonzo/* If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or more slots, 121278277Sgonzo * then it's taking up too much buffer space, and the peer service will be told to stop 122278277Sgonzo * transmitting with an XOFF message. For this to be effective, the VCHI_NUM_READ_SLOTS 123278277Sgonzo * needs to be considerably bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency 124278277Sgonzo * is too high. */ 125278277Sgonzo#ifndef VCHI_XOFF_THRESHOLD 126278277Sgonzo# define VCHI_XOFF_THRESHOLD (VCHI_NUM_READ_SLOTS / 2) 127278277Sgonzo#endif 128278277Sgonzo 129278277Sgonzo/* After we've sent an XOFF, the peer will be told to resume transmission once the local 130278277Sgonzo * service has dequeued/released enough messages that it's now occupying 131278277Sgonzo * VCHI_XON_THRESHOLD slots or fewer. */ 132278277Sgonzo#ifndef VCHI_XON_THRESHOLD 133278277Sgonzo# define VCHI_XON_THRESHOLD (VCHI_NUM_READ_SLOTS / 4) 134278277Sgonzo#endif 135278277Sgonzo 136278277Sgonzo/* A size below which a bulk transfer omits the handshake completely and always goes 137278277Sgonzo * via the message channel, if bulk auxiliary is being sent on that service. (The user 138278277Sgonzo * can guarantee this by enabling unaligned transmits). 139278277Sgonzo * Not API. */ 140278277Sgonzo#ifndef VCHI_MIN_BULK_SIZE 141278277Sgonzo# define VCHI_MIN_BULK_SIZE ( VCHI_MAX_MSG_SIZE / 2 < 4096 ? VCHI_MAX_MSG_SIZE / 2 : 4096 ) 142278277Sgonzo#endif 143278277Sgonzo 144278277Sgonzo/* Maximum size of bulk transmission chunks, for each interface type. A trade-off between 145278277Sgonzo * speed and latency; the smaller the chunk size the better change of messages and other 146278277Sgonzo * bulk transmissions getting in when big bulk transfers are happening. Set to 0 to not 147278277Sgonzo * break transmissions into chunks. 148278277Sgonzo */ 149278277Sgonzo#ifndef VCHI_MAX_BULK_CHUNK_SIZE_MPHI 150278277Sgonzo# define VCHI_MAX_BULK_CHUNK_SIZE_MPHI (16 * 1024) 151278277Sgonzo#endif 152278277Sgonzo 153278277Sgonzo/* NB Chunked CCP2 transmissions violate the letter of the CCP2 spec by using "JPEG8" mode 154278277Sgonzo * with multiple-line frames. Only use if the receiver can cope. */ 155278277Sgonzo#ifndef VCHI_MAX_BULK_CHUNK_SIZE_CCP2 156278277Sgonzo# define VCHI_MAX_BULK_CHUNK_SIZE_CCP2 0 157278277Sgonzo#endif 158278277Sgonzo 159278277Sgonzo/* How many TX messages can we have pending in our transmit slots. Once exhausted, 160278277Sgonzo * vchi_msg_queue will be blocked. */ 161278277Sgonzo#ifndef VCHI_TX_MSG_QUEUE_SIZE 162278277Sgonzo# define VCHI_TX_MSG_QUEUE_SIZE 256 163278277Sgonzo#endif 164278277Sgonzo 165278277Sgonzo/* How many RX messages can we have parsed in the receive slots. Once exhausted, parsing 166278277Sgonzo * will be suspended until older messages are dequeued/released. */ 167278277Sgonzo#ifndef VCHI_RX_MSG_QUEUE_SIZE 168278277Sgonzo# define VCHI_RX_MSG_QUEUE_SIZE 256 169278277Sgonzo#endif 170278277Sgonzo 171278277Sgonzo/* Really should be able to cope if we run out of received message descriptors, by 172278277Sgonzo * suspending parsing as the comment above says, but we don't. This sweeps the issue 173278277Sgonzo * under the carpet. */ 174278277Sgonzo#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS 175278277Sgonzo# undef VCHI_RX_MSG_QUEUE_SIZE 176278277Sgonzo# define VCHI_RX_MSG_QUEUE_SIZE (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS 177278277Sgonzo#endif 178278277Sgonzo 179278277Sgonzo/* How many bulk transmits can we have pending. Once exhausted, vchi_bulk_queue_transmit 180278277Sgonzo * will be blocked. */ 181278277Sgonzo#ifndef VCHI_TX_BULK_QUEUE_SIZE 182278277Sgonzo# define VCHI_TX_BULK_QUEUE_SIZE 64 183278277Sgonzo#endif 184278277Sgonzo 185278277Sgonzo/* How many bulk receives can we have pending. Once exhausted, vchi_bulk_queue_receive 186278277Sgonzo * will be blocked. */ 187278277Sgonzo#ifndef VCHI_RX_BULK_QUEUE_SIZE 188278277Sgonzo# define VCHI_RX_BULK_QUEUE_SIZE 64 189278277Sgonzo#endif 190278277Sgonzo 191278277Sgonzo/* A limit on how many outstanding bulk requests we expect the peer to give us. If 192278277Sgonzo * the peer asks for more than this, VCHI will fail and assert. The number is determined 193278277Sgonzo * by the peer's hardware - it's the number of outstanding requests that can be queued 194278277Sgonzo * on all bulk channels. VC3's MPHI peripheral allows 16. */ 195278277Sgonzo#ifndef VCHI_MAX_PEER_BULK_REQUESTS 196278277Sgonzo# define VCHI_MAX_PEER_BULK_REQUESTS 32 197278277Sgonzo#endif 198278277Sgonzo 199278277Sgonzo/* Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2 200278277Sgonzo * transmitter on and off. 201278277Sgonzo */ 202278277Sgonzo/*#define VCHI_CCP2TX_MANUAL_POWER*/ 203278277Sgonzo 204278277Sgonzo#ifndef VCHI_CCP2TX_MANUAL_POWER 205278277Sgonzo 206278277Sgonzo/* Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state. Set 207278277Sgonzo * negative for no IDLE. 208278277Sgonzo */ 209278277Sgonzo# ifndef VCHI_CCP2TX_IDLE_TIMEOUT 210278277Sgonzo# define VCHI_CCP2TX_IDLE_TIMEOUT 5 211278277Sgonzo# endif 212278277Sgonzo 213278277Sgonzo/* Timeout (in milliseconds) for putting the CCP2TX interface into OFF state. Set 214278277Sgonzo * negative for no OFF. 215278277Sgonzo */ 216278277Sgonzo# ifndef VCHI_CCP2TX_OFF_TIMEOUT 217278277Sgonzo# define VCHI_CCP2TX_OFF_TIMEOUT 1000 218278277Sgonzo# endif 219278277Sgonzo 220278277Sgonzo#endif /* VCHI_CCP2TX_MANUAL_POWER */ 221278277Sgonzo 222278277Sgonzo#endif /* VCHI_CFG_H_ */ 223278277Sgonzo 224278277Sgonzo/****************************** End of file **********************************/ 225