Path: blob/main/sys/contrib/vchiq/interface/vchi/vchi_cfg.h
48383 views
/**1* Copyright (c) 2010-2012 Broadcom. All rights reserved.2*3* Redistribution and use in source and binary forms, with or without4* modification, are permitted provided that the following conditions5* are met:6* 1. Redistributions of source code must retain the above copyright7* notice, this list of conditions, and the following disclaimer,8* without modification.9* 2. Redistributions in binary form must reproduce the above copyright10* notice, this list of conditions and the following disclaimer in the11* documentation and/or other materials provided with the distribution.12* 3. The names of the above-listed copyright holders may not be used13* to endorse or promote products derived from this software without14* specific prior written permission.15*16* ALTERNATIVELY, this software may be distributed under the terms of the17* GNU General Public License ("GPL") version 2, as published by the Free18* Software Foundation.19*20* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS21* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,22* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR23* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR24* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,25* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,26* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR27* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF28* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING29* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS30* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.31*/3233#ifndef VCHI_CFG_H_34#define VCHI_CFG_H_3536/****************************************************************************************37* Defines in this first section are part of the VCHI API and may be examined by VCHI38* services.39***************************************************************************************/4041/* Required alignment of base addresses for bulk transfer, if unaligned transfers are not enabled */42/* Really determined by the message driver, and should be available from a run-time call. */43#ifndef VCHI_BULK_ALIGN44# if __VCCOREVER__ >= 0x0400000045# define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans46# else47# define VCHI_BULK_ALIGN 1648# endif49#endif5051/* Required length multiple for bulk transfers, if unaligned transfers are not enabled */52/* May be less than or greater than VCHI_BULK_ALIGN */53/* Really determined by the message driver, and should be available from a run-time call. */54#ifndef VCHI_BULK_GRANULARITY55# if __VCCOREVER__ >= 0x0400000056# define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache cleans57# else58# define VCHI_BULK_GRANULARITY 1659# endif60#endif6162/* The largest possible message to be queued with vchi_msg_queue. */63#ifndef VCHI_MAX_MSG_SIZE64# if defined VCHI_LOCAL_HOST_PORT65# define VCHI_MAX_MSG_SIZE 16384 // makes file transfers fast, but should they be using bulk?66# else67# define VCHI_MAX_MSG_SIZE 4096 // NOTE: THIS MUST BE LARGER THAN OR EQUAL TO THE SIZE OF THE KHRONOS MERGE BUFFER!!68# endif69#endif7071/******************************************************************************************72* Defines below are system configuration options, and should not be used by VCHI services.73*****************************************************************************************/7475/* How many connections can we support? A localhost implementation uses 2 connections,76* 1 for host-app, 1 for VMCS, and these are hooked together by a loopback MPHI VCFW77* driver. */78#ifndef VCHI_MAX_NUM_CONNECTIONS79# define VCHI_MAX_NUM_CONNECTIONS 380#endif8182/* How many services can we open per connection? Extending this doesn't cost processing time, just a small83* amount of static memory. */84#ifndef VCHI_MAX_SERVICES_PER_CONNECTION85# define VCHI_MAX_SERVICES_PER_CONNECTION 3686#endif8788/* Adjust if using a message driver that supports more logical TX channels */89#ifndef VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION90# define VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION 9 // 1 MPHI + 8 CCP2 logical channels91#endif9293/* Adjust if using a message driver that supports more logical RX channels */94#ifndef VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION95# define VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 1 // 1 MPHI96#endif9798/* How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the effective99* receive queue space, less message headers. */100#ifndef VCHI_NUM_READ_SLOTS101# if defined(VCHI_LOCAL_HOST_PORT)102# define VCHI_NUM_READ_SLOTS 4103# else104# define VCHI_NUM_READ_SLOTS 48105# endif106#endif107108/* Do we utilise overrun facility for receive message slots? Can aid peer transmit109* performance. Only define on VideoCore end, talking to host.110*/111//#define VCHI_MSG_RX_OVERRUN112113/* How many transmit slots do we use. Generally don't need many, as the hardware driver114* underneath VCHI will usually have its own buffering. */115#ifndef VCHI_NUM_WRITE_SLOTS116# define VCHI_NUM_WRITE_SLOTS 4117#endif118119/* If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or more slots,120* then it's taking up too much buffer space, and the peer service will be told to stop121* transmitting with an XOFF message. For this to be effective, the VCHI_NUM_READ_SLOTS122* needs to be considerably bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency123* is too high. */124#ifndef VCHI_XOFF_THRESHOLD125# define VCHI_XOFF_THRESHOLD (VCHI_NUM_READ_SLOTS / 2)126#endif127128/* After we've sent an XOFF, the peer will be told to resume transmission once the local129* service has dequeued/released enough messages that it's now occupying130* VCHI_XON_THRESHOLD slots or fewer. */131#ifndef VCHI_XON_THRESHOLD132# define VCHI_XON_THRESHOLD (VCHI_NUM_READ_SLOTS / 4)133#endif134135/* A size below which a bulk transfer omits the handshake completely and always goes136* via the message channel, if bulk auxiliary is being sent on that service. (The user137* can guarantee this by enabling unaligned transmits).138* Not API. */139#ifndef VCHI_MIN_BULK_SIZE140# define VCHI_MIN_BULK_SIZE ( VCHI_MAX_MSG_SIZE / 2 < 4096 ? VCHI_MAX_MSG_SIZE / 2 : 4096 )141#endif142143/* Maximum size of bulk transmission chunks, for each interface type. A trade-off between144* speed and latency; the smaller the chunk size the better change of messages and other145* bulk transmissions getting in when big bulk transfers are happening. Set to 0 to not146* break transmissions into chunks.147*/148#ifndef VCHI_MAX_BULK_CHUNK_SIZE_MPHI149# define VCHI_MAX_BULK_CHUNK_SIZE_MPHI (16 * 1024)150#endif151152/* NB Chunked CCP2 transmissions violate the letter of the CCP2 spec by using "JPEG8" mode153* with multiple-line frames. Only use if the receiver can cope. */154#ifndef VCHI_MAX_BULK_CHUNK_SIZE_CCP2155# define VCHI_MAX_BULK_CHUNK_SIZE_CCP2 0156#endif157158/* How many TX messages can we have pending in our transmit slots. Once exhausted,159* vchi_msg_queue will be blocked. */160#ifndef VCHI_TX_MSG_QUEUE_SIZE161# define VCHI_TX_MSG_QUEUE_SIZE 256162#endif163164/* How many RX messages can we have parsed in the receive slots. Once exhausted, parsing165* will be suspended until older messages are dequeued/released. */166#ifndef VCHI_RX_MSG_QUEUE_SIZE167# define VCHI_RX_MSG_QUEUE_SIZE 256168#endif169170/* Really should be able to cope if we run out of received message descriptors, by171* suspending parsing as the comment above says, but we don't. This sweeps the issue172* under the carpet. */173#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS174# undef VCHI_RX_MSG_QUEUE_SIZE175# define VCHI_RX_MSG_QUEUE_SIZE (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS176#endif177178/* How many bulk transmits can we have pending. Once exhausted, vchi_bulk_queue_transmit179* will be blocked. */180#ifndef VCHI_TX_BULK_QUEUE_SIZE181# define VCHI_TX_BULK_QUEUE_SIZE 64182#endif183184/* How many bulk receives can we have pending. Once exhausted, vchi_bulk_queue_receive185* will be blocked. */186#ifndef VCHI_RX_BULK_QUEUE_SIZE187# define VCHI_RX_BULK_QUEUE_SIZE 64188#endif189190/* A limit on how many outstanding bulk requests we expect the peer to give us. If191* the peer asks for more than this, VCHI will fail and assert. The number is determined192* by the peer's hardware - it's the number of outstanding requests that can be queued193* on all bulk channels. VC3's MPHI peripheral allows 16. */194#ifndef VCHI_MAX_PEER_BULK_REQUESTS195# define VCHI_MAX_PEER_BULK_REQUESTS 32196#endif197198/* Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2199* transmitter on and off.200*/201/*#define VCHI_CCP2TX_MANUAL_POWER*/202203#ifndef VCHI_CCP2TX_MANUAL_POWER204205/* Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state. Set206* negative for no IDLE.207*/208# ifndef VCHI_CCP2TX_IDLE_TIMEOUT209# define VCHI_CCP2TX_IDLE_TIMEOUT 5210# endif211212/* Timeout (in milliseconds) for putting the CCP2TX interface into OFF state. Set213* negative for no OFF.214*/215# ifndef VCHI_CCP2TX_OFF_TIMEOUT216# define VCHI_CCP2TX_OFF_TIMEOUT 1000217# endif218219#endif /* VCHI_CCP2TX_MANUAL_POWER */220221#endif /* VCHI_CFG_H_ */222223/****************************** End of file **********************************/224225226