mirror of
https://github.com/Dasharo/linux.git
synced 2026-03-06 15:25:10 -08:00
staging: add bcm2708 vchiq driver
Signed-off-by: popcornmix <popcornmix@gmail.com> vchiq: create_pagelist copes with vmalloc memory Signed-off-by: Daniel Stone <daniels@collabora.com> vchiq: fix the shim message release Signed-off-by: Daniel Stone <daniels@collabora.com> vchiq: export additional symbols Signed-off-by: Daniel Stone <daniels@collabora.com> VCHIQ: Make service closure fully synchronous (drv) This is one half of a two-part patch, the other half of which is to the vchiq_lib user library. With these patches, calls to vchiq_close_service and vchiq_remove_service won't return until any associated callbacks have been delivered to the callback thread. VCHIQ: Add per-service tracing The new service option VCHIQ_SERVICE_OPTION_TRACE is a boolean that toggles tracing for the specified service. This commit also introduces vchi_service_set_option and the associated option VCHI_SERVICE_OPTION_TRACE. vchiq: Make the synchronous-CLOSE logic more tolerant vchiq: Move logging control into debugfs vchiq: Take care of a corner case tickled by VCSM Closing a connection that isn't fully open requires care, since one side does not know the other side's port number. Code was present to handle the case where a CLOSE is sent immediately after an OPEN, i.e. before the OPENACK has been received, but this was incorrectly being used when an OPEN from a client using port 0 was rejected. (In the observed failure, the host was attempting to use the VCSM service, which isn't present in the 'cutdown' firmware. The failure was intermittent because sometimes the keepalive service would grab port 0.) This case can be distinguished because the client's remoteport will still be VCHIQ_PORT_FREE, and the srvstate will be OPENING. Either condition is sufficient to differentiate it from the special case described above. vchiq: Avoid high load when blocked and unkillable vchiq: Include SIGSTOP and SIGCONT in list of signals not-masked by vchiq to allow gdb to work vchiq_arm: Complete support for SYNCHRONOUS mode vchiq: Remove inline from suspend/resume vchiq: Allocation does not need to be atomic vchiq: Fix wrong condition check The log level is checked from within the log call. Remove the check in the call. Signed-off-by: Pranith Kumar <bobby.prani@gmail.com> BCM270x: Add vchiq device to platform file and Device Tree Prepare to turn the vchiq module into a driver. Signed-off-by: Noralf Trønnes <noralf@tronnes.org> bcm2708: vchiq: Add Device Tree support Turn vchiq into a driver and stop hardcoding resources. Use devm_* functions in probe path to simplify cleanup. A global variable is used to hold the register address. This is done to keep this patch as small as possible. Also make available on ARCH_BCM2835. Based on work by Lubomir Rintel. Signed-off-by: Noralf Trønnes <noralf@tronnes.org> vchiq: Change logging level for inbound data vchiq_arm: Two cacheing fixes 1) Make fragment size vary with cache line size Without this patch, non-cache-line-aligned transfers may corrupt (or be corrupted by) adjacent data structures. Both ARM and VC need to be updated to enable this feature. This is ensured by having the loader apply a new DT parameter - cache-line-size. The existence of this parameter guarantees that the kernel is capable, and the parameter will only be modified from the safe default if the loader is capable. 2) Flush/invalidate vmalloc'd memory, and invalidate after reads vchiq: fix NULL pointer dereference when closing driver The following code run as root will cause a null pointer dereference oops: int fd = open("/dev/vc-cma", O_RDONLY); if (fd < 0) err(1, "open failed"); (void)close(fd); [ 1704.877721] Unable to handle kernel NULL pointer dereference at virtual address 00000000 [ 1704.877725] pgd = b899c000 [ 1704.877736] [00000000] *pgd=37fab831, *pte=00000000, *ppte=00000000 [ 1704.877748] Internal error: Oops: 817 [#1] PREEMPT SMP ARM [ 1704.877765] Modules linked in: evdev i2c_bcm2708 uio_pdrv_genirq uio [ 1704.877774] CPU: 2 PID: 3656 Comm: stress-ng-fstat Not tainted 3.19.1-12-generic-bcm2709 #12-Ubuntu [ 1704.877777] Hardware name: BCM2709 [ 1704.877783] task: b8ab9b00 ti: b7e68000 task.ti: b7e68000 [ 1704.877798] PC is at __down_interruptible+0x50/0xec [ 1704.877806] LR is at down_interruptible+0x5c/0x68 [ 1704.877813] pc : [<80630ee8>] lr : [<800704b0>] psr: 60080093 sp : b7e69e50 ip : b7e69e88 fp : b7e69e84 [ 1704.877817] r10: b88123c8 r9 : 00000010 r8 : 00000001 [ 1704.877822] r7 : b8ab9b00 r6 : 7fffffff r5 : 80a1cc34 r4 : 80a1cc34 [ 1704.877826] r3 : b7e69e50 r2 : 00000000 r1 : 00000000 r0 : 80a1cc34 [ 1704.877833] Flags: nZCv IRQs off FIQs on Mode SVC_32 ISA ARM Segment user [ 1704.877838] Control: 10c5387d Table: 3899c06a DAC: 00000015 [ 1704.877843] Process do-oops (pid: 3656, stack limit = 0xb7e68238) [ 1704.877848] Stack: (0xb7e69e50 to 0xb7e6a000) [ 1704.877856] 9e40: 80a1cc3c 00000000 00000010 b88123c8 [ 1704.877865] 9e60: b7e69e84 80a1cc34 fff9fee9 ffffffff b7e68000 00000009 b7e69ea4 b7e69e88 [ 1704.877874] 9e80: 800704b0 80630ea4 fff9fee9 60080013 80a1cc28 fff9fee9 b7e69edc b7e69ea8 [ 1704.877884] 9ea0: 8040f558 80070460 fff9fee9 ffffffff 00000000 00000000 00000009 80a1cb7c [ 1704.877893] 9ec0: 00000000 80a1cb7c 00000000 00000010 b7e69ef4 b7e69ee0 803e1ba4 8040f514 [ 1704.877902] 9ee0: 00000e48 80a1cb7c b7e69f14 b7e69ef8 803e1c9c 803e1b74 b88123c0 b92acb18 [ 1704.877911] 9f00: b8812790 b8d815d8 b7e69f24 b7e69f18 803e2250 803e1bc8 b7e69f5c b7e69f28 [ 1704.877921] 9f20: 80167bac 803e222c 00000000 00000000 b7e69f54 b8ab9ffc 00000000 8098c794 [ 1704.877930] 9f40: b8ab9b00 8000efc4 b7e68000 00000000 b7e69f6c b7e69f60 80167d6c 80167b28 [ 1704.877939] 9f60: b7e69f8c b7e69f70 80047d38 80167d60 b7e68000 b7e68010 8000efc4 b7e69fb0 [ 1704.877949] 9f80: b7e69fac b7e69f90 80012820 80047c84 01155490 011549a8 00000001 00000006 [ 1704.877957] 9fa0: 00000000 b7e69fb0 8000ee5c 80012790 00000000 353d8c0f 7efc4308 00000000 [ 1704.877966] 9fc0: 01155490 011549a8 00000001 00000006 00000000 00000000 76cf3ba0 00000003 [ 1704.877975] 9fe0: 00000000 7efc42e4 0002272f 76e2ed66 60080030 00000003 00000000 00000000 [ 1704.877998] [<80630ee8>] (__down_interruptible) from [<800704b0>] (down_interruptible+0x5c/0x68) [ 1704.878015] [<800704b0>] (down_interruptible) from [<8040f558>] (vchiu_queue_push+0x50/0xd8) [ 1704.878032] [<8040f558>] (vchiu_queue_push) from [<803e1ba4>] (send_worker_msg+0x3c/0x54) [ 1704.878045] [<803e1ba4>] (send_worker_msg) from [<803e1c9c>] (vc_cma_set_reserve+0xe0/0x1c4) [ 1704.878057] [<803e1c9c>] (vc_cma_set_reserve) from [<803e2250>] (vc_cma_release+0x30/0x38) [ 1704.878069] [<803e2250>] (vc_cma_release) from [<80167bac>] (__fput+0x90/0x1e0) [ 1704.878082] [<80167bac>] (__fput) from [<80167d6c>] (____fput+0x18/0x1c) [ 1704.878094] [<80167d6c>] (____fput) from [<80047d38>] (task_work_run+0xc0/0xf8) [ 1704.878109] [<80047d38>] (task_work_run) from [<80012820>] (do_work_pending+0x9c/0xc4) [ 1704.878123] [<80012820>] (do_work_pending) from [<8000ee5c>] (work_pending+0xc/0x20) [ 1704.878133] Code: e50b1034 e3a01000 e50b2030 e580300c (e5823000) ..the fix is to ensure that we have actually initialized the queue before we attempt to push any items onto it. This occurs if we do an open() followed by a close() without any activity in between. Signed-off-by: Colin Ian King <colin.king@canonical.com> vchiq_arm: Sort out the vmalloc case See: https://github.com/raspberrypi/linux/issues/1055 vchiq: hack: Add include depecated dma include file [gregkh] added dependancy on CONFIG_BROKEN to make things sane for now. Cc: Eric Anholt <eric@anholt.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
88638cf1a8
commit
71bad7f086
@@ -104,4 +104,6 @@ source "drivers/staging/ks7010/Kconfig"
|
||||
|
||||
source "drivers/staging/greybus/Kconfig"
|
||||
|
||||
source "drivers/staging/vc04_services/Kconfig"
|
||||
|
||||
endif # STAGING
|
||||
|
||||
@@ -41,3 +41,4 @@ obj-$(CONFIG_MOST) += most/
|
||||
obj-$(CONFIG_ISDN_I4L) += i4l/
|
||||
obj-$(CONFIG_KS7010) += ks7010/
|
||||
obj-$(CONFIG_GREYBUS) += greybus/
|
||||
obj-$(CONFIG_BCM2708_VCHIQ) += vc04_services/
|
||||
|
||||
9
drivers/staging/vc04_services/Kconfig
Normal file
9
drivers/staging/vc04_services/Kconfig
Normal file
@@ -0,0 +1,9 @@
|
||||
config BCM2708_VCHIQ
|
||||
tristate "Videocore VCHIQ"
|
||||
depends on RASPBERRYPI_FIRMWARE && BROKEN
|
||||
default y
|
||||
help
|
||||
Kernel to VideoCore communication interface for the
|
||||
BCM2708 family of products.
|
||||
Defaults to Y when the Broadcom Videocore services
|
||||
are included in the build, N otherwise.
|
||||
14
drivers/staging/vc04_services/Makefile
Normal file
14
drivers/staging/vc04_services/Makefile
Normal file
@@ -0,0 +1,14 @@
|
||||
obj-$(CONFIG_BCM2708_VCHIQ) += vchiq.o
|
||||
|
||||
vchiq-objs := \
|
||||
interface/vchiq_arm/vchiq_core.o \
|
||||
interface/vchiq_arm/vchiq_arm.o \
|
||||
interface/vchiq_arm/vchiq_kern_lib.o \
|
||||
interface/vchiq_arm/vchiq_2835_arm.o \
|
||||
interface/vchiq_arm/vchiq_debugfs.o \
|
||||
interface/vchiq_arm/vchiq_shim.o \
|
||||
interface/vchiq_arm/vchiq_util.o \
|
||||
interface/vchiq_arm/vchiq_connected.o \
|
||||
|
||||
ccflags-y += -DVCOS_VERIFY_BKPTS=1 -Idrivers/staging/vc04_services -DUSE_VCHIQ_ARM -D__VCCOREVER__=0x04000000
|
||||
|
||||
@@ -0,0 +1,328 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef CONNECTION_H_
|
||||
#define CONNECTION_H_
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/semaphore.h>
|
||||
|
||||
#include "interface/vchi/vchi_cfg_internal.h"
|
||||
#include "interface/vchi/vchi_common.h"
|
||||
#include "interface/vchi/message_drivers/message.h"
|
||||
|
||||
/******************************************************************************
|
||||
Global defs
|
||||
*****************************************************************************/
|
||||
|
||||
// Opaque handle for a connection / service pair
|
||||
typedef struct opaque_vchi_connection_connected_service_handle_t *VCHI_CONNECTION_SERVICE_HANDLE_T;
|
||||
|
||||
// opaque handle to the connection state information
|
||||
typedef struct opaque_vchi_connection_info_t VCHI_CONNECTION_STATE_T;
|
||||
|
||||
typedef struct vchi_connection_t VCHI_CONNECTION_T;
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
API
|
||||
*****************************************************************************/
|
||||
|
||||
// Routine to init a connection with a particular low level driver
|
||||
typedef VCHI_CONNECTION_STATE_T * (*VCHI_CONNECTION_INIT_T)( struct vchi_connection_t * connection,
|
||||
const VCHI_MESSAGE_DRIVER_T * driver );
|
||||
|
||||
// Routine to control CRC enabling at a connection level
|
||||
typedef int32_t (*VCHI_CONNECTION_CRC_CONTROL_T)( VCHI_CONNECTION_STATE_T *state_handle,
|
||||
VCHI_CRC_CONTROL_T control );
|
||||
|
||||
// Routine to create a service
|
||||
typedef int32_t (*VCHI_CONNECTION_SERVICE_CONNECT_T)( VCHI_CONNECTION_STATE_T *state_handle,
|
||||
int32_t service_id,
|
||||
uint32_t rx_fifo_size,
|
||||
uint32_t tx_fifo_size,
|
||||
int server,
|
||||
VCHI_CALLBACK_T callback,
|
||||
void *callback_param,
|
||||
int32_t want_crc,
|
||||
int32_t want_unaligned_bulk_rx,
|
||||
int32_t want_unaligned_bulk_tx,
|
||||
VCHI_CONNECTION_SERVICE_HANDLE_T *service_handle );
|
||||
|
||||
// Routine to close a service
|
||||
typedef int32_t (*VCHI_CONNECTION_SERVICE_DISCONNECT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle );
|
||||
|
||||
// Routine to queue a message
|
||||
typedef int32_t (*VCHI_CONNECTION_SERVICE_QUEUE_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
const void *data,
|
||||
uint32_t data_size,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *msg_handle );
|
||||
|
||||
// scatter-gather (vector) message queueing
|
||||
typedef int32_t (*VCHI_CONNECTION_SERVICE_QUEUE_MESSAGEV_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
VCHI_MSG_VECTOR_T *vector,
|
||||
uint32_t count,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *msg_handle );
|
||||
|
||||
// Routine to dequeue a message
|
||||
typedef int32_t (*VCHI_CONNECTION_SERVICE_DEQUEUE_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
void *data,
|
||||
uint32_t max_data_size_to_read,
|
||||
uint32_t *actual_msg_size,
|
||||
VCHI_FLAGS_T flags );
|
||||
|
||||
// Routine to peek at a message
|
||||
typedef int32_t (*VCHI_CONNECTION_SERVICE_PEEK_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
void **data,
|
||||
uint32_t *msg_size,
|
||||
VCHI_FLAGS_T flags );
|
||||
|
||||
// Routine to hold a message
|
||||
typedef int32_t (*VCHI_CONNECTION_SERVICE_HOLD_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
void **data,
|
||||
uint32_t *msg_size,
|
||||
VCHI_FLAGS_T flags,
|
||||
void **message_handle );
|
||||
|
||||
// Routine to initialise a received message iterator
|
||||
typedef int32_t (*VCHI_CONNECTION_SERVICE_LOOKAHEAD_MESSAGE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
VCHI_MSG_ITER_T *iter,
|
||||
VCHI_FLAGS_T flags );
|
||||
|
||||
// Routine to release a held message
|
||||
typedef int32_t (*VCHI_CONNECTION_HELD_MSG_RELEASE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
void *message_handle );
|
||||
|
||||
// Routine to get info on a held message
|
||||
typedef int32_t (*VCHI_CONNECTION_HELD_MSG_INFO_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
void *message_handle,
|
||||
void **data,
|
||||
int32_t *msg_size,
|
||||
uint32_t *tx_timestamp,
|
||||
uint32_t *rx_timestamp );
|
||||
|
||||
// Routine to check whether the iterator has a next message
|
||||
typedef int32_t (*VCHI_CONNECTION_MSG_ITER_HAS_NEXT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,
|
||||
const VCHI_MSG_ITER_T *iter );
|
||||
|
||||
// Routine to advance the iterator
|
||||
typedef int32_t (*VCHI_CONNECTION_MSG_ITER_NEXT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,
|
||||
VCHI_MSG_ITER_T *iter,
|
||||
void **data,
|
||||
uint32_t *msg_size );
|
||||
|
||||
// Routine to remove the last message returned by the iterator
|
||||
typedef int32_t (*VCHI_CONNECTION_MSG_ITER_REMOVE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,
|
||||
VCHI_MSG_ITER_T *iter );
|
||||
|
||||
// Routine to hold the last message returned by the iterator
|
||||
typedef int32_t (*VCHI_CONNECTION_MSG_ITER_HOLD_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service,
|
||||
VCHI_MSG_ITER_T *iter,
|
||||
void **msg_handle );
|
||||
|
||||
// Routine to transmit bulk data
|
||||
typedef int32_t (*VCHI_CONNECTION_BULK_QUEUE_TRANSMIT_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
const void *data_src,
|
||||
uint32_t data_size,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *bulk_handle );
|
||||
|
||||
// Routine to receive data
|
||||
typedef int32_t (*VCHI_CONNECTION_BULK_QUEUE_RECEIVE_T)( VCHI_CONNECTION_SERVICE_HANDLE_T service_handle,
|
||||
void *data_dst,
|
||||
uint32_t data_size,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *bulk_handle );
|
||||
|
||||
// Routine to report if a server is available
|
||||
typedef int32_t (*VCHI_CONNECTION_SERVER_PRESENT)( VCHI_CONNECTION_STATE_T *state, int32_t service_id, int32_t peer_flags );
|
||||
|
||||
// Routine to report the number of RX slots available
|
||||
typedef int (*VCHI_CONNECTION_RX_SLOTS_AVAILABLE)( const VCHI_CONNECTION_STATE_T *state );
|
||||
|
||||
// Routine to report the RX slot size
|
||||
typedef uint32_t (*VCHI_CONNECTION_RX_SLOT_SIZE)( const VCHI_CONNECTION_STATE_T *state );
|
||||
|
||||
// Callback to indicate that the other side has added a buffer to the rx bulk DMA FIFO
|
||||
typedef void (*VCHI_CONNECTION_RX_BULK_BUFFER_ADDED)(VCHI_CONNECTION_STATE_T *state,
|
||||
int32_t service,
|
||||
uint32_t length,
|
||||
MESSAGE_TX_CHANNEL_T channel,
|
||||
uint32_t channel_params,
|
||||
uint32_t data_length,
|
||||
uint32_t data_offset);
|
||||
|
||||
// Callback to inform a service that a Xon or Xoff message has been received
|
||||
typedef void (*VCHI_CONNECTION_FLOW_CONTROL)(VCHI_CONNECTION_STATE_T *state, int32_t service_id, int32_t xoff);
|
||||
|
||||
// Callback to inform a service that a server available reply message has been received
|
||||
typedef void (*VCHI_CONNECTION_SERVER_AVAILABLE_REPLY)(VCHI_CONNECTION_STATE_T *state, int32_t service_id, uint32_t flags);
|
||||
|
||||
// Callback to indicate that bulk auxiliary messages have arrived
|
||||
typedef void (*VCHI_CONNECTION_BULK_AUX_RECEIVED)(VCHI_CONNECTION_STATE_T *state);
|
||||
|
||||
// Callback to indicate that bulk auxiliary messages have arrived
|
||||
typedef void (*VCHI_CONNECTION_BULK_AUX_TRANSMITTED)(VCHI_CONNECTION_STATE_T *state, void *handle);
|
||||
|
||||
// Callback with all the connection info you require
|
||||
typedef void (*VCHI_CONNECTION_INFO)(VCHI_CONNECTION_STATE_T *state, uint32_t protocol_version, uint32_t slot_size, uint32_t num_slots, uint32_t min_bulk_size);
|
||||
|
||||
// Callback to inform of a disconnect
|
||||
typedef void (*VCHI_CONNECTION_DISCONNECT)(VCHI_CONNECTION_STATE_T *state, uint32_t flags);
|
||||
|
||||
// Callback to inform of a power control request
|
||||
typedef void (*VCHI_CONNECTION_POWER_CONTROL)(VCHI_CONNECTION_STATE_T *state, MESSAGE_TX_CHANNEL_T channel, int32_t enable);
|
||||
|
||||
// allocate memory suitably aligned for this connection
|
||||
typedef void * (*VCHI_BUFFER_ALLOCATE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_handle, uint32_t * length);
|
||||
|
||||
// free memory allocated by buffer_allocate
|
||||
typedef void (*VCHI_BUFFER_FREE)(VCHI_CONNECTION_SERVICE_HANDLE_T service_handle, void * address);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
System driver struct
|
||||
*****************************************************************************/
|
||||
|
||||
struct opaque_vchi_connection_api_t
|
||||
{
|
||||
// Routine to init the connection
|
||||
VCHI_CONNECTION_INIT_T init;
|
||||
|
||||
// Connection-level CRC control
|
||||
VCHI_CONNECTION_CRC_CONTROL_T crc_control;
|
||||
|
||||
// Routine to connect to or create service
|
||||
VCHI_CONNECTION_SERVICE_CONNECT_T service_connect;
|
||||
|
||||
// Routine to disconnect from a service
|
||||
VCHI_CONNECTION_SERVICE_DISCONNECT_T service_disconnect;
|
||||
|
||||
// Routine to queue a message
|
||||
VCHI_CONNECTION_SERVICE_QUEUE_MESSAGE_T service_queue_msg;
|
||||
|
||||
// scatter-gather (vector) message queue
|
||||
VCHI_CONNECTION_SERVICE_QUEUE_MESSAGEV_T service_queue_msgv;
|
||||
|
||||
// Routine to dequeue a message
|
||||
VCHI_CONNECTION_SERVICE_DEQUEUE_MESSAGE_T service_dequeue_msg;
|
||||
|
||||
// Routine to peek at a message
|
||||
VCHI_CONNECTION_SERVICE_PEEK_MESSAGE_T service_peek_msg;
|
||||
|
||||
// Routine to hold a message
|
||||
VCHI_CONNECTION_SERVICE_HOLD_MESSAGE_T service_hold_msg;
|
||||
|
||||
// Routine to initialise a received message iterator
|
||||
VCHI_CONNECTION_SERVICE_LOOKAHEAD_MESSAGE_T service_look_ahead_msg;
|
||||
|
||||
// Routine to release a message
|
||||
VCHI_CONNECTION_HELD_MSG_RELEASE_T held_msg_release;
|
||||
|
||||
// Routine to get information on a held message
|
||||
VCHI_CONNECTION_HELD_MSG_INFO_T held_msg_info;
|
||||
|
||||
// Routine to check for next message on iterator
|
||||
VCHI_CONNECTION_MSG_ITER_HAS_NEXT_T msg_iter_has_next;
|
||||
|
||||
// Routine to get next message on iterator
|
||||
VCHI_CONNECTION_MSG_ITER_NEXT_T msg_iter_next;
|
||||
|
||||
// Routine to remove the last message returned by iterator
|
||||
VCHI_CONNECTION_MSG_ITER_REMOVE_T msg_iter_remove;
|
||||
|
||||
// Routine to hold the last message returned by iterator
|
||||
VCHI_CONNECTION_MSG_ITER_HOLD_T msg_iter_hold;
|
||||
|
||||
// Routine to transmit bulk data
|
||||
VCHI_CONNECTION_BULK_QUEUE_TRANSMIT_T bulk_queue_transmit;
|
||||
|
||||
// Routine to receive data
|
||||
VCHI_CONNECTION_BULK_QUEUE_RECEIVE_T bulk_queue_receive;
|
||||
|
||||
// Routine to report the available servers
|
||||
VCHI_CONNECTION_SERVER_PRESENT server_present;
|
||||
|
||||
// Routine to report the number of RX slots available
|
||||
VCHI_CONNECTION_RX_SLOTS_AVAILABLE connection_rx_slots_available;
|
||||
|
||||
// Routine to report the RX slot size
|
||||
VCHI_CONNECTION_RX_SLOT_SIZE connection_rx_slot_size;
|
||||
|
||||
// Callback to indicate that the other side has added a buffer to the rx bulk DMA FIFO
|
||||
VCHI_CONNECTION_RX_BULK_BUFFER_ADDED rx_bulk_buffer_added;
|
||||
|
||||
// Callback to inform a service that a Xon or Xoff message has been received
|
||||
VCHI_CONNECTION_FLOW_CONTROL flow_control;
|
||||
|
||||
// Callback to inform a service that a server available reply message has been received
|
||||
VCHI_CONNECTION_SERVER_AVAILABLE_REPLY server_available_reply;
|
||||
|
||||
// Callback to indicate that bulk auxiliary messages have arrived
|
||||
VCHI_CONNECTION_BULK_AUX_RECEIVED bulk_aux_received;
|
||||
|
||||
// Callback to indicate that a bulk auxiliary message has been transmitted
|
||||
VCHI_CONNECTION_BULK_AUX_TRANSMITTED bulk_aux_transmitted;
|
||||
|
||||
// Callback to provide information about the connection
|
||||
VCHI_CONNECTION_INFO connection_info;
|
||||
|
||||
// Callback to notify that peer has requested disconnect
|
||||
VCHI_CONNECTION_DISCONNECT disconnect;
|
||||
|
||||
// Callback to notify that peer has requested power change
|
||||
VCHI_CONNECTION_POWER_CONTROL power_control;
|
||||
|
||||
// allocate memory suitably aligned for this connection
|
||||
VCHI_BUFFER_ALLOCATE buffer_allocate;
|
||||
|
||||
// free memory allocated by buffer_allocate
|
||||
VCHI_BUFFER_FREE buffer_free;
|
||||
|
||||
};
|
||||
|
||||
struct vchi_connection_t {
|
||||
const VCHI_CONNECTION_API_T *api;
|
||||
VCHI_CONNECTION_STATE_T *state;
|
||||
#ifdef VCHI_COARSE_LOCKING
|
||||
struct semaphore sem;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#endif /* CONNECTION_H_ */
|
||||
|
||||
/****************************** End of file **********************************/
|
||||
@@ -0,0 +1,204 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef _VCHI_MESSAGE_H_
|
||||
#define _VCHI_MESSAGE_H_
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/semaphore.h>
|
||||
|
||||
#include "interface/vchi/vchi_cfg_internal.h"
|
||||
#include "interface/vchi/vchi_common.h"
|
||||
|
||||
|
||||
typedef enum message_event_type {
|
||||
MESSAGE_EVENT_NONE,
|
||||
MESSAGE_EVENT_NOP,
|
||||
MESSAGE_EVENT_MESSAGE,
|
||||
MESSAGE_EVENT_SLOT_COMPLETE,
|
||||
MESSAGE_EVENT_RX_BULK_PAUSED,
|
||||
MESSAGE_EVENT_RX_BULK_COMPLETE,
|
||||
MESSAGE_EVENT_TX_COMPLETE,
|
||||
MESSAGE_EVENT_MSG_DISCARDED
|
||||
} MESSAGE_EVENT_TYPE_T;
|
||||
|
||||
typedef enum vchi_msg_flags
|
||||
{
|
||||
VCHI_MSG_FLAGS_NONE = 0x0,
|
||||
VCHI_MSG_FLAGS_TERMINATE_DMA = 0x1
|
||||
} VCHI_MSG_FLAGS_T;
|
||||
|
||||
typedef enum message_tx_channel
|
||||
{
|
||||
MESSAGE_TX_CHANNEL_MESSAGE = 0,
|
||||
MESSAGE_TX_CHANNEL_BULK = 1 // drivers may provide multiple bulk channels, from 1 upwards
|
||||
} MESSAGE_TX_CHANNEL_T;
|
||||
|
||||
// Macros used for cycling through bulk channels
|
||||
#define MESSAGE_TX_CHANNEL_BULK_PREV(c) (MESSAGE_TX_CHANNEL_BULK+((c)-MESSAGE_TX_CHANNEL_BULK+VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION-1)%VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION)
|
||||
#define MESSAGE_TX_CHANNEL_BULK_NEXT(c) (MESSAGE_TX_CHANNEL_BULK+((c)-MESSAGE_TX_CHANNEL_BULK+1)%VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION)
|
||||
|
||||
typedef enum message_rx_channel
|
||||
{
|
||||
MESSAGE_RX_CHANNEL_MESSAGE = 0,
|
||||
MESSAGE_RX_CHANNEL_BULK = 1 // drivers may provide multiple bulk channels, from 1 upwards
|
||||
} MESSAGE_RX_CHANNEL_T;
|
||||
|
||||
// Message receive slot information
|
||||
typedef struct rx_msg_slot_info {
|
||||
|
||||
struct rx_msg_slot_info *next;
|
||||
//struct slot_info *prev;
|
||||
#if !defined VCHI_COARSE_LOCKING
|
||||
struct semaphore sem;
|
||||
#endif
|
||||
|
||||
uint8_t *addr; // base address of slot
|
||||
uint32_t len; // length of slot in bytes
|
||||
|
||||
uint32_t write_ptr; // hardware causes this to advance
|
||||
uint32_t read_ptr; // this module does the reading
|
||||
int active; // is this slot in the hardware dma fifo?
|
||||
uint32_t msgs_parsed; // count how many messages are in this slot
|
||||
uint32_t msgs_released; // how many messages have been released
|
||||
void *state; // connection state information
|
||||
uint8_t ref_count[VCHI_MAX_SERVICES_PER_CONNECTION]; // reference count for slots held by services
|
||||
} RX_MSG_SLOTINFO_T;
|
||||
|
||||
// The message driver no longer needs to know about the fields of RX_BULK_SLOTINFO_T - sort this out.
|
||||
// In particular, it mustn't use addr and len - they're the client buffer, but the message
|
||||
// driver will be tasked with sending the aligned core section.
|
||||
typedef struct rx_bulk_slotinfo_t {
|
||||
struct rx_bulk_slotinfo_t *next;
|
||||
|
||||
struct semaphore *blocking;
|
||||
|
||||
// needed by DMA
|
||||
void *addr;
|
||||
uint32_t len;
|
||||
|
||||
// needed for the callback
|
||||
void *service;
|
||||
void *handle;
|
||||
VCHI_FLAGS_T flags;
|
||||
} RX_BULK_SLOTINFO_T;
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------
|
||||
* each connection driver will have a pool of the following struct.
|
||||
*
|
||||
* the pool will be managed by vchi_qman_*
|
||||
* this means there will be multiple queues (single linked lists)
|
||||
* a given struct message_info will be on exactly one of these queues
|
||||
* at any one time
|
||||
* -------------------------------------------------------------------- */
|
||||
typedef struct rx_message_info {
|
||||
|
||||
struct message_info *next;
|
||||
//struct message_info *prev;
|
||||
|
||||
uint8_t *addr;
|
||||
uint32_t len;
|
||||
RX_MSG_SLOTINFO_T *slot; // points to whichever slot contains this message
|
||||
uint32_t tx_timestamp;
|
||||
uint32_t rx_timestamp;
|
||||
|
||||
} RX_MESSAGE_INFO_T;
|
||||
|
||||
typedef struct {
|
||||
MESSAGE_EVENT_TYPE_T type;
|
||||
|
||||
struct {
|
||||
// for messages
|
||||
void *addr; // address of message
|
||||
uint16_t slot_delta; // whether this message indicated slot delta
|
||||
uint32_t len; // length of message
|
||||
RX_MSG_SLOTINFO_T *slot; // slot this message is in
|
||||
int32_t service; // service id this message is destined for
|
||||
uint32_t tx_timestamp; // timestamp from the header
|
||||
uint32_t rx_timestamp; // timestamp when we parsed it
|
||||
} message;
|
||||
|
||||
// FIXME: cleanup slot reporting...
|
||||
RX_MSG_SLOTINFO_T *rx_msg;
|
||||
RX_BULK_SLOTINFO_T *rx_bulk;
|
||||
void *tx_handle;
|
||||
MESSAGE_TX_CHANNEL_T tx_channel;
|
||||
|
||||
} MESSAGE_EVENT_T;
|
||||
|
||||
|
||||
// callbacks
|
||||
typedef void VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T( void *state );
|
||||
|
||||
typedef struct {
|
||||
VCHI_MESSAGE_DRIVER_EVENT_CALLBACK_T *event_callback;
|
||||
} VCHI_MESSAGE_DRIVER_OPEN_T;
|
||||
|
||||
|
||||
// handle to this instance of message driver (as returned by ->open)
|
||||
typedef struct opaque_mhandle_t *VCHI_MDRIVER_HANDLE_T;
|
||||
|
||||
struct opaque_vchi_message_driver_t {
|
||||
VCHI_MDRIVER_HANDLE_T *(*open)( VCHI_MESSAGE_DRIVER_OPEN_T *params, void *state );
|
||||
int32_t (*suspending)( VCHI_MDRIVER_HANDLE_T *handle );
|
||||
int32_t (*resumed)( VCHI_MDRIVER_HANDLE_T *handle );
|
||||
int32_t (*power_control)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T, int32_t enable );
|
||||
int32_t (*add_msg_rx_slot)( VCHI_MDRIVER_HANDLE_T *handle, RX_MSG_SLOTINFO_T *slot ); // rx message
|
||||
int32_t (*add_bulk_rx)( VCHI_MDRIVER_HANDLE_T *handle, void *data, uint32_t len, RX_BULK_SLOTINFO_T *slot ); // rx data (bulk)
|
||||
int32_t (*send)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel, const void *data, uint32_t len, VCHI_MSG_FLAGS_T flags, void *send_handle ); // tx (message & bulk)
|
||||
void (*next_event)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_EVENT_T *event ); // get the next event from message_driver
|
||||
int32_t (*enable)( VCHI_MDRIVER_HANDLE_T *handle );
|
||||
int32_t (*form_message)( VCHI_MDRIVER_HANDLE_T *handle, int32_t service_id, VCHI_MSG_VECTOR_T *vector, uint32_t count, void
|
||||
*address, uint32_t length_avail, uint32_t max_total_length, int32_t pad_to_fill, int32_t allow_partial );
|
||||
|
||||
int32_t (*update_message)( VCHI_MDRIVER_HANDLE_T *handle, void *dest, int16_t *slot_count );
|
||||
int32_t (*buffer_aligned)( VCHI_MDRIVER_HANDLE_T *handle, int tx, int uncached, const void *address, const uint32_t length );
|
||||
void * (*allocate_buffer)( VCHI_MDRIVER_HANDLE_T *handle, uint32_t *length );
|
||||
void (*free_buffer)( VCHI_MDRIVER_HANDLE_T *handle, void *address );
|
||||
int (*rx_slot_size)( VCHI_MDRIVER_HANDLE_T *handle, int msg_size );
|
||||
int (*tx_slot_size)( VCHI_MDRIVER_HANDLE_T *handle, int msg_size );
|
||||
|
||||
int32_t (*tx_supports_terminate)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel );
|
||||
uint32_t (*tx_bulk_chunk_size)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel );
|
||||
int (*tx_alignment)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel );
|
||||
int (*rx_alignment)( const VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_RX_CHANNEL_T channel );
|
||||
void (*form_bulk_aux)( VCHI_MDRIVER_HANDLE_T *handle, MESSAGE_TX_CHANNEL_T channel, const void *data, uint32_t len, uint32_t chunk_size, const void **aux_data, int32_t *aux_len );
|
||||
void (*debug)( VCHI_MDRIVER_HANDLE_T *handle );
|
||||
};
|
||||
|
||||
|
||||
#endif // _VCHI_MESSAGE_H_
|
||||
|
||||
/****************************** End of file ***********************************/
|
||||
378
drivers/staging/vc04_services/interface/vchi/vchi.h
Normal file
378
drivers/staging/vc04_services/interface/vchi/vchi.h
Normal file
@@ -0,0 +1,378 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHI_H_
|
||||
#define VCHI_H_
|
||||
|
||||
#include "interface/vchi/vchi_cfg.h"
|
||||
#include "interface/vchi/vchi_common.h"
|
||||
#include "interface/vchi/connections/connection.h"
|
||||
#include "vchi_mh.h"
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Global defs
|
||||
*****************************************************************************/
|
||||
|
||||
#define VCHI_BULK_ROUND_UP(x) ((((unsigned long)(x))+VCHI_BULK_ALIGN-1) & ~(VCHI_BULK_ALIGN-1))
|
||||
#define VCHI_BULK_ROUND_DOWN(x) (((unsigned long)(x)) & ~(VCHI_BULK_ALIGN-1))
|
||||
#define VCHI_BULK_ALIGN_NBYTES(x) (VCHI_BULK_ALIGNED(x) ? 0 : (VCHI_BULK_ALIGN - ((unsigned long)(x) & (VCHI_BULK_ALIGN-1))))
|
||||
|
||||
#ifdef USE_VCHIQ_ARM
|
||||
#define VCHI_BULK_ALIGNED(x) 1
|
||||
#else
|
||||
#define VCHI_BULK_ALIGNED(x) (((unsigned long)(x) & (VCHI_BULK_ALIGN-1)) == 0)
|
||||
#endif
|
||||
|
||||
struct vchi_version {
|
||||
uint32_t version;
|
||||
uint32_t version_min;
|
||||
};
|
||||
#define VCHI_VERSION(v_) { v_, v_ }
|
||||
#define VCHI_VERSION_EX(v_, m_) { v_, m_ }
|
||||
|
||||
typedef enum
|
||||
{
|
||||
VCHI_VEC_POINTER,
|
||||
VCHI_VEC_HANDLE,
|
||||
VCHI_VEC_LIST
|
||||
} VCHI_MSG_VECTOR_TYPE_T;
|
||||
|
||||
typedef struct vchi_msg_vector_ex {
|
||||
|
||||
VCHI_MSG_VECTOR_TYPE_T type;
|
||||
union
|
||||
{
|
||||
// a memory handle
|
||||
struct
|
||||
{
|
||||
VCHI_MEM_HANDLE_T handle;
|
||||
uint32_t offset;
|
||||
int32_t vec_len;
|
||||
} handle;
|
||||
|
||||
// an ordinary data pointer
|
||||
struct
|
||||
{
|
||||
const void *vec_base;
|
||||
int32_t vec_len;
|
||||
} ptr;
|
||||
|
||||
// a nested vector list
|
||||
struct
|
||||
{
|
||||
struct vchi_msg_vector_ex *vec;
|
||||
uint32_t vec_len;
|
||||
} list;
|
||||
} u;
|
||||
} VCHI_MSG_VECTOR_EX_T;
|
||||
|
||||
|
||||
// Construct an entry in a msg vector for a pointer (p) of length (l)
|
||||
#define VCHI_VEC_POINTER(p,l) VCHI_VEC_POINTER, { { (VCHI_MEM_HANDLE_T)(p), (l) } }
|
||||
|
||||
// Construct an entry in a msg vector for a message handle (h), starting at offset (o) of length (l)
|
||||
#define VCHI_VEC_HANDLE(h,o,l) VCHI_VEC_HANDLE, { { (h), (o), (l) } }
|
||||
|
||||
// Macros to manipulate 'FOURCC' values
|
||||
#define MAKE_FOURCC(x) ((int32_t)( (x[0] << 24) | (x[1] << 16) | (x[2] << 8) | x[3] ))
|
||||
#define FOURCC_TO_CHAR(x) (x >> 24) & 0xFF,(x >> 16) & 0xFF,(x >> 8) & 0xFF, x & 0xFF
|
||||
|
||||
|
||||
// Opaque service information
|
||||
struct opaque_vchi_service_t;
|
||||
|
||||
// Descriptor for a held message. Allocated by client, initialised by vchi_msg_hold,
|
||||
// vchi_msg_iter_hold or vchi_msg_iter_hold_next. Fields are for internal VCHI use only.
|
||||
typedef struct
|
||||
{
|
||||
struct opaque_vchi_service_t *service;
|
||||
void *message;
|
||||
} VCHI_HELD_MSG_T;
|
||||
|
||||
|
||||
|
||||
// structure used to provide the information needed to open a server or a client
|
||||
typedef struct {
|
||||
struct vchi_version version;
|
||||
int32_t service_id;
|
||||
VCHI_CONNECTION_T *connection;
|
||||
uint32_t rx_fifo_size;
|
||||
uint32_t tx_fifo_size;
|
||||
VCHI_CALLBACK_T callback;
|
||||
void *callback_param;
|
||||
/* client intends to receive bulk transfers of
|
||||
odd lengths or into unaligned buffers */
|
||||
int32_t want_unaligned_bulk_rx;
|
||||
/* client intends to transmit bulk transfers of
|
||||
odd lengths or out of unaligned buffers */
|
||||
int32_t want_unaligned_bulk_tx;
|
||||
/* client wants to check CRCs on (bulk) xfers.
|
||||
Only needs to be set at 1 end - will do both directions. */
|
||||
int32_t want_crc;
|
||||
} SERVICE_CREATION_T;
|
||||
|
||||
// Opaque handle for a VCHI instance
|
||||
typedef struct opaque_vchi_instance_handle_t *VCHI_INSTANCE_T;
|
||||
|
||||
// Opaque handle for a server or client
|
||||
typedef struct opaque_vchi_service_handle_t *VCHI_SERVICE_HANDLE_T;
|
||||
|
||||
// Service registration & startup
|
||||
typedef void (*VCHI_SERVICE_INIT)(VCHI_INSTANCE_T initialise_instance, VCHI_CONNECTION_T **connections, uint32_t num_connections);
|
||||
|
||||
typedef struct service_info_tag {
|
||||
const char * const vll_filename; /* VLL to load to start this service. This is an empty string if VLL is "static" */
|
||||
VCHI_SERVICE_INIT init; /* Service initialisation function */
|
||||
void *vll_handle; /* VLL handle; NULL when unloaded or a "static VLL" in build */
|
||||
} SERVICE_INFO_T;
|
||||
|
||||
/******************************************************************************
|
||||
Global funcs - implementation is specific to which side you are on (local / remote)
|
||||
*****************************************************************************/
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern /*@observer@*/ VCHI_CONNECTION_T * vchi_create_connection( const VCHI_CONNECTION_API_T * function_table,
|
||||
const VCHI_MESSAGE_DRIVER_T * low_level);
|
||||
|
||||
|
||||
// Routine used to initialise the vchi on both local + remote connections
|
||||
extern int32_t vchi_initialise( VCHI_INSTANCE_T *instance_handle );
|
||||
|
||||
extern int32_t vchi_exit( void );
|
||||
|
||||
extern int32_t vchi_connect( VCHI_CONNECTION_T **connections,
|
||||
const uint32_t num_connections,
|
||||
VCHI_INSTANCE_T instance_handle );
|
||||
|
||||
//When this is called, ensure that all services have no data pending.
|
||||
//Bulk transfers can remain 'queued'
|
||||
extern int32_t vchi_disconnect( VCHI_INSTANCE_T instance_handle );
|
||||
|
||||
// Global control over bulk CRC checking
|
||||
extern int32_t vchi_crc_control( VCHI_CONNECTION_T *connection,
|
||||
VCHI_CRC_CONTROL_T control );
|
||||
|
||||
// helper functions
|
||||
extern void * vchi_allocate_buffer(VCHI_SERVICE_HANDLE_T handle, uint32_t *length);
|
||||
extern void vchi_free_buffer(VCHI_SERVICE_HANDLE_T handle, void *address);
|
||||
extern uint32_t vchi_current_time(VCHI_INSTANCE_T instance_handle);
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Global service API
|
||||
*****************************************************************************/
|
||||
// Routine to create a named service
|
||||
extern int32_t vchi_service_create( VCHI_INSTANCE_T instance_handle,
|
||||
SERVICE_CREATION_T *setup,
|
||||
VCHI_SERVICE_HANDLE_T *handle );
|
||||
|
||||
// Routine to destory a service
|
||||
extern int32_t vchi_service_destroy( const VCHI_SERVICE_HANDLE_T handle );
|
||||
|
||||
// Routine to open a named service
|
||||
extern int32_t vchi_service_open( VCHI_INSTANCE_T instance_handle,
|
||||
SERVICE_CREATION_T *setup,
|
||||
VCHI_SERVICE_HANDLE_T *handle);
|
||||
|
||||
extern int32_t vchi_get_peer_version( const VCHI_SERVICE_HANDLE_T handle,
|
||||
short *peer_version );
|
||||
|
||||
// Routine to close a named service
|
||||
extern int32_t vchi_service_close( const VCHI_SERVICE_HANDLE_T handle );
|
||||
|
||||
// Routine to increment ref count on a named service
|
||||
extern int32_t vchi_service_use( const VCHI_SERVICE_HANDLE_T handle );
|
||||
|
||||
// Routine to decrement ref count on a named service
|
||||
extern int32_t vchi_service_release( const VCHI_SERVICE_HANDLE_T handle );
|
||||
|
||||
// Routine to set a control option for a named service
|
||||
extern int32_t vchi_service_set_option( const VCHI_SERVICE_HANDLE_T handle,
|
||||
VCHI_SERVICE_OPTION_T option,
|
||||
int value);
|
||||
|
||||
// Routine to send a message across a service
|
||||
extern int32_t vchi_msg_queue( VCHI_SERVICE_HANDLE_T handle,
|
||||
const void *data,
|
||||
uint32_t data_size,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *msg_handle );
|
||||
|
||||
// scatter-gather (vector) and send message
|
||||
int32_t vchi_msg_queuev_ex( VCHI_SERVICE_HANDLE_T handle,
|
||||
VCHI_MSG_VECTOR_EX_T *vector,
|
||||
uint32_t count,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *msg_handle );
|
||||
|
||||
// legacy scatter-gather (vector) and send message, only handles pointers
|
||||
int32_t vchi_msg_queuev( VCHI_SERVICE_HANDLE_T handle,
|
||||
VCHI_MSG_VECTOR_T *vector,
|
||||
uint32_t count,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *msg_handle );
|
||||
|
||||
// Routine to receive a msg from a service
|
||||
// Dequeue is equivalent to hold, copy into client buffer, release
|
||||
extern int32_t vchi_msg_dequeue( VCHI_SERVICE_HANDLE_T handle,
|
||||
void *data,
|
||||
uint32_t max_data_size_to_read,
|
||||
uint32_t *actual_msg_size,
|
||||
VCHI_FLAGS_T flags );
|
||||
|
||||
// Routine to look at a message in place.
|
||||
// The message is not dequeued, so a subsequent call to peek or dequeue
|
||||
// will return the same message.
|
||||
extern int32_t vchi_msg_peek( VCHI_SERVICE_HANDLE_T handle,
|
||||
void **data,
|
||||
uint32_t *msg_size,
|
||||
VCHI_FLAGS_T flags );
|
||||
|
||||
// Routine to remove a message after it has been read in place with peek
|
||||
// The first message on the queue is dequeued.
|
||||
extern int32_t vchi_msg_remove( VCHI_SERVICE_HANDLE_T handle );
|
||||
|
||||
// Routine to look at a message in place.
|
||||
// The message is dequeued, so the caller is left holding it; the descriptor is
|
||||
// filled in and must be released when the user has finished with the message.
|
||||
extern int32_t vchi_msg_hold( VCHI_SERVICE_HANDLE_T handle,
|
||||
void **data, // } may be NULL, as info can be
|
||||
uint32_t *msg_size, // } obtained from HELD_MSG_T
|
||||
VCHI_FLAGS_T flags,
|
||||
VCHI_HELD_MSG_T *message_descriptor );
|
||||
|
||||
// Initialise an iterator to look through messages in place
|
||||
extern int32_t vchi_msg_look_ahead( VCHI_SERVICE_HANDLE_T handle,
|
||||
VCHI_MSG_ITER_T *iter,
|
||||
VCHI_FLAGS_T flags );
|
||||
|
||||
/******************************************************************************
|
||||
Global service support API - operations on held messages and message iterators
|
||||
*****************************************************************************/
|
||||
|
||||
// Routine to get the address of a held message
|
||||
extern void *vchi_held_msg_ptr( const VCHI_HELD_MSG_T *message );
|
||||
|
||||
// Routine to get the size of a held message
|
||||
extern int32_t vchi_held_msg_size( const VCHI_HELD_MSG_T *message );
|
||||
|
||||
// Routine to get the transmit timestamp as written into the header by the peer
|
||||
extern uint32_t vchi_held_msg_tx_timestamp( const VCHI_HELD_MSG_T *message );
|
||||
|
||||
// Routine to get the reception timestamp, written as we parsed the header
|
||||
extern uint32_t vchi_held_msg_rx_timestamp( const VCHI_HELD_MSG_T *message );
|
||||
|
||||
// Routine to release a held message after it has been processed
|
||||
extern int32_t vchi_held_msg_release( VCHI_HELD_MSG_T *message );
|
||||
|
||||
// Indicates whether the iterator has a next message.
|
||||
extern int32_t vchi_msg_iter_has_next( const VCHI_MSG_ITER_T *iter );
|
||||
|
||||
// Return the pointer and length for the next message and advance the iterator.
|
||||
extern int32_t vchi_msg_iter_next( VCHI_MSG_ITER_T *iter,
|
||||
void **data,
|
||||
uint32_t *msg_size );
|
||||
|
||||
// Remove the last message returned by vchi_msg_iter_next.
|
||||
// Can only be called once after each call to vchi_msg_iter_next.
|
||||
extern int32_t vchi_msg_iter_remove( VCHI_MSG_ITER_T *iter );
|
||||
|
||||
// Hold the last message returned by vchi_msg_iter_next.
|
||||
// Can only be called once after each call to vchi_msg_iter_next.
|
||||
extern int32_t vchi_msg_iter_hold( VCHI_MSG_ITER_T *iter,
|
||||
VCHI_HELD_MSG_T *message );
|
||||
|
||||
// Return information for the next message, and hold it, advancing the iterator.
|
||||
extern int32_t vchi_msg_iter_hold_next( VCHI_MSG_ITER_T *iter,
|
||||
void **data, // } may be NULL
|
||||
uint32_t *msg_size, // }
|
||||
VCHI_HELD_MSG_T *message );
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Global bulk API
|
||||
*****************************************************************************/
|
||||
|
||||
// Routine to prepare interface for a transfer from the other side
|
||||
extern int32_t vchi_bulk_queue_receive( VCHI_SERVICE_HANDLE_T handle,
|
||||
void *data_dst,
|
||||
uint32_t data_size,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *transfer_handle );
|
||||
|
||||
|
||||
// Prepare interface for a transfer from the other side into relocatable memory.
|
||||
int32_t vchi_bulk_queue_receive_reloc( const VCHI_SERVICE_HANDLE_T handle,
|
||||
VCHI_MEM_HANDLE_T h_dst,
|
||||
uint32_t offset,
|
||||
uint32_t data_size,
|
||||
const VCHI_FLAGS_T flags,
|
||||
void * const bulk_handle );
|
||||
|
||||
// Routine to queue up data ready for transfer to the other (once they have signalled they are ready)
|
||||
extern int32_t vchi_bulk_queue_transmit( VCHI_SERVICE_HANDLE_T handle,
|
||||
const void *data_src,
|
||||
uint32_t data_size,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *transfer_handle );
|
||||
|
||||
|
||||
/******************************************************************************
|
||||
Configuration plumbing
|
||||
*****************************************************************************/
|
||||
|
||||
// function prototypes for the different mid layers (the state info gives the different physical connections)
|
||||
extern const VCHI_CONNECTION_API_T *single_get_func_table( void );
|
||||
//extern const VCHI_CONNECTION_API_T *local_server_get_func_table( void );
|
||||
//extern const VCHI_CONNECTION_API_T *local_client_get_func_table( void );
|
||||
|
||||
// declare all message drivers here
|
||||
const VCHI_MESSAGE_DRIVER_T *vchi_mphi_message_driver_func_table( void );
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
extern int32_t vchi_bulk_queue_transmit_reloc( VCHI_SERVICE_HANDLE_T handle,
|
||||
VCHI_MEM_HANDLE_T h_src,
|
||||
uint32_t offset,
|
||||
uint32_t data_size,
|
||||
VCHI_FLAGS_T flags,
|
||||
void *transfer_handle );
|
||||
#endif /* VCHI_H_ */
|
||||
|
||||
/****************************** End of file **********************************/
|
||||
224
drivers/staging/vc04_services/interface/vchi/vchi_cfg.h
Normal file
224
drivers/staging/vc04_services/interface/vchi/vchi_cfg.h
Normal file
@@ -0,0 +1,224 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHI_CFG_H_
|
||||
#define VCHI_CFG_H_
|
||||
|
||||
/****************************************************************************************
|
||||
* Defines in this first section are part of the VCHI API and may be examined by VCHI
|
||||
* services.
|
||||
***************************************************************************************/
|
||||
|
||||
/* Required alignment of base addresses for bulk transfer, if unaligned transfers are not enabled */
|
||||
/* Really determined by the message driver, and should be available from a run-time call. */
|
||||
#ifndef VCHI_BULK_ALIGN
|
||||
# if __VCCOREVER__ >= 0x04000000
|
||||
# define VCHI_BULK_ALIGN 32 // Allows for the need to do cache cleans
|
||||
# else
|
||||
# define VCHI_BULK_ALIGN 16
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Required length multiple for bulk transfers, if unaligned transfers are not enabled */
|
||||
/* May be less than or greater than VCHI_BULK_ALIGN */
|
||||
/* Really determined by the message driver, and should be available from a run-time call. */
|
||||
#ifndef VCHI_BULK_GRANULARITY
|
||||
# if __VCCOREVER__ >= 0x04000000
|
||||
# define VCHI_BULK_GRANULARITY 32 // Allows for the need to do cache cleans
|
||||
# else
|
||||
# define VCHI_BULK_GRANULARITY 16
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* The largest possible message to be queued with vchi_msg_queue. */
|
||||
#ifndef VCHI_MAX_MSG_SIZE
|
||||
# if defined VCHI_LOCAL_HOST_PORT
|
||||
# define VCHI_MAX_MSG_SIZE 16384 // makes file transfers fast, but should they be using bulk?
|
||||
# else
|
||||
# define VCHI_MAX_MSG_SIZE 4096 // NOTE: THIS MUST BE LARGER THAN OR EQUAL TO THE SIZE OF THE KHRONOS MERGE BUFFER!!
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/******************************************************************************************
|
||||
* Defines below are system configuration options, and should not be used by VCHI services.
|
||||
*****************************************************************************************/
|
||||
|
||||
/* How many connections can we support? A localhost implementation uses 2 connections,
|
||||
* 1 for host-app, 1 for VMCS, and these are hooked together by a loopback MPHI VCFW
|
||||
* driver. */
|
||||
#ifndef VCHI_MAX_NUM_CONNECTIONS
|
||||
# define VCHI_MAX_NUM_CONNECTIONS 3
|
||||
#endif
|
||||
|
||||
/* How many services can we open per connection? Extending this doesn't cost processing time, just a small
|
||||
* amount of static memory. */
|
||||
#ifndef VCHI_MAX_SERVICES_PER_CONNECTION
|
||||
# define VCHI_MAX_SERVICES_PER_CONNECTION 36
|
||||
#endif
|
||||
|
||||
/* Adjust if using a message driver that supports more logical TX channels */
|
||||
#ifndef VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION
|
||||
# define VCHI_MAX_BULK_TX_CHANNELS_PER_CONNECTION 9 // 1 MPHI + 8 CCP2 logical channels
|
||||
#endif
|
||||
|
||||
/* Adjust if using a message driver that supports more logical RX channels */
|
||||
#ifndef VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION
|
||||
# define VCHI_MAX_BULK_RX_CHANNELS_PER_CONNECTION 1 // 1 MPHI
|
||||
#endif
|
||||
|
||||
/* How many receive slots do we use. This times VCHI_MAX_MSG_SIZE gives the effective
|
||||
* receive queue space, less message headers. */
|
||||
#ifndef VCHI_NUM_READ_SLOTS
|
||||
# if defined(VCHI_LOCAL_HOST_PORT)
|
||||
# define VCHI_NUM_READ_SLOTS 4
|
||||
# else
|
||||
# define VCHI_NUM_READ_SLOTS 48
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* Do we utilise overrun facility for receive message slots? Can aid peer transmit
|
||||
* performance. Only define on VideoCore end, talking to host.
|
||||
*/
|
||||
//#define VCHI_MSG_RX_OVERRUN
|
||||
|
||||
/* How many transmit slots do we use. Generally don't need many, as the hardware driver
|
||||
* underneath VCHI will usually have its own buffering. */
|
||||
#ifndef VCHI_NUM_WRITE_SLOTS
|
||||
# define VCHI_NUM_WRITE_SLOTS 4
|
||||
#endif
|
||||
|
||||
/* If a service has held or queued received messages in VCHI_XOFF_THRESHOLD or more slots,
|
||||
* then it's taking up too much buffer space, and the peer service will be told to stop
|
||||
* transmitting with an XOFF message. For this to be effective, the VCHI_NUM_READ_SLOTS
|
||||
* needs to be considerably bigger than VCHI_NUM_WRITE_SLOTS, or the transmit latency
|
||||
* is too high. */
|
||||
#ifndef VCHI_XOFF_THRESHOLD
|
||||
# define VCHI_XOFF_THRESHOLD (VCHI_NUM_READ_SLOTS / 2)
|
||||
#endif
|
||||
|
||||
/* After we've sent an XOFF, the peer will be told to resume transmission once the local
|
||||
* service has dequeued/released enough messages that it's now occupying
|
||||
* VCHI_XON_THRESHOLD slots or fewer. */
|
||||
#ifndef VCHI_XON_THRESHOLD
|
||||
# define VCHI_XON_THRESHOLD (VCHI_NUM_READ_SLOTS / 4)
|
||||
#endif
|
||||
|
||||
/* A size below which a bulk transfer omits the handshake completely and always goes
|
||||
* via the message channel, if bulk auxiliary is being sent on that service. (The user
|
||||
* can guarantee this by enabling unaligned transmits).
|
||||
* Not API. */
|
||||
#ifndef VCHI_MIN_BULK_SIZE
|
||||
# define VCHI_MIN_BULK_SIZE ( VCHI_MAX_MSG_SIZE / 2 < 4096 ? VCHI_MAX_MSG_SIZE / 2 : 4096 )
|
||||
#endif
|
||||
|
||||
/* Maximum size of bulk transmission chunks, for each interface type. A trade-off between
|
||||
* speed and latency; the smaller the chunk size the better change of messages and other
|
||||
* bulk transmissions getting in when big bulk transfers are happening. Set to 0 to not
|
||||
* break transmissions into chunks.
|
||||
*/
|
||||
#ifndef VCHI_MAX_BULK_CHUNK_SIZE_MPHI
|
||||
# define VCHI_MAX_BULK_CHUNK_SIZE_MPHI (16 * 1024)
|
||||
#endif
|
||||
|
||||
/* NB Chunked CCP2 transmissions violate the letter of the CCP2 spec by using "JPEG8" mode
|
||||
* with multiple-line frames. Only use if the receiver can cope. */
|
||||
#ifndef VCHI_MAX_BULK_CHUNK_SIZE_CCP2
|
||||
# define VCHI_MAX_BULK_CHUNK_SIZE_CCP2 0
|
||||
#endif
|
||||
|
||||
/* How many TX messages can we have pending in our transmit slots. Once exhausted,
|
||||
* vchi_msg_queue will be blocked. */
|
||||
#ifndef VCHI_TX_MSG_QUEUE_SIZE
|
||||
# define VCHI_TX_MSG_QUEUE_SIZE 256
|
||||
#endif
|
||||
|
||||
/* How many RX messages can we have parsed in the receive slots. Once exhausted, parsing
|
||||
* will be suspended until older messages are dequeued/released. */
|
||||
#ifndef VCHI_RX_MSG_QUEUE_SIZE
|
||||
# define VCHI_RX_MSG_QUEUE_SIZE 256
|
||||
#endif
|
||||
|
||||
/* Really should be able to cope if we run out of received message descriptors, by
|
||||
* suspending parsing as the comment above says, but we don't. This sweeps the issue
|
||||
* under the carpet. */
|
||||
#if VCHI_RX_MSG_QUEUE_SIZE < (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS
|
||||
# undef VCHI_RX_MSG_QUEUE_SIZE
|
||||
# define VCHI_RX_MSG_QUEUE_SIZE (VCHI_MAX_MSG_SIZE/16 + 1) * VCHI_NUM_READ_SLOTS
|
||||
#endif
|
||||
|
||||
/* How many bulk transmits can we have pending. Once exhausted, vchi_bulk_queue_transmit
|
||||
* will be blocked. */
|
||||
#ifndef VCHI_TX_BULK_QUEUE_SIZE
|
||||
# define VCHI_TX_BULK_QUEUE_SIZE 64
|
||||
#endif
|
||||
|
||||
/* How many bulk receives can we have pending. Once exhausted, vchi_bulk_queue_receive
|
||||
* will be blocked. */
|
||||
#ifndef VCHI_RX_BULK_QUEUE_SIZE
|
||||
# define VCHI_RX_BULK_QUEUE_SIZE 64
|
||||
#endif
|
||||
|
||||
/* A limit on how many outstanding bulk requests we expect the peer to give us. If
|
||||
* the peer asks for more than this, VCHI will fail and assert. The number is determined
|
||||
* by the peer's hardware - it's the number of outstanding requests that can be queued
|
||||
* on all bulk channels. VC3's MPHI peripheral allows 16. */
|
||||
#ifndef VCHI_MAX_PEER_BULK_REQUESTS
|
||||
# define VCHI_MAX_PEER_BULK_REQUESTS 32
|
||||
#endif
|
||||
|
||||
/* Define VCHI_CCP2TX_MANUAL_POWER if the host tells us when to turn the CCP2
|
||||
* transmitter on and off.
|
||||
*/
|
||||
/*#define VCHI_CCP2TX_MANUAL_POWER*/
|
||||
|
||||
#ifndef VCHI_CCP2TX_MANUAL_POWER
|
||||
|
||||
/* Timeout (in milliseconds) for putting the CCP2TX interface into IDLE state. Set
|
||||
* negative for no IDLE.
|
||||
*/
|
||||
# ifndef VCHI_CCP2TX_IDLE_TIMEOUT
|
||||
# define VCHI_CCP2TX_IDLE_TIMEOUT 5
|
||||
# endif
|
||||
|
||||
/* Timeout (in milliseconds) for putting the CCP2TX interface into OFF state. Set
|
||||
* negative for no OFF.
|
||||
*/
|
||||
# ifndef VCHI_CCP2TX_OFF_TIMEOUT
|
||||
# define VCHI_CCP2TX_OFF_TIMEOUT 1000
|
||||
# endif
|
||||
|
||||
#endif /* VCHI_CCP2TX_MANUAL_POWER */
|
||||
|
||||
#endif /* VCHI_CFG_H_ */
|
||||
|
||||
/****************************** End of file **********************************/
|
||||
@@ -0,0 +1,71 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHI_CFG_INTERNAL_H_
|
||||
#define VCHI_CFG_INTERNAL_H_
|
||||
|
||||
/****************************************************************************************
|
||||
* Control optimisation attempts.
|
||||
***************************************************************************************/
|
||||
|
||||
// Don't use lots of short-term locks - use great long ones, reducing the overall locks-per-second
|
||||
#define VCHI_COARSE_LOCKING
|
||||
|
||||
// Avoid lock then unlock on exit from blocking queue operations (msg tx, bulk rx/tx)
|
||||
// (only relevant if VCHI_COARSE_LOCKING)
|
||||
#define VCHI_ELIDE_BLOCK_EXIT_LOCK
|
||||
|
||||
// Avoid lock on non-blocking peek
|
||||
// (only relevant if VCHI_COARSE_LOCKING)
|
||||
#define VCHI_AVOID_PEEK_LOCK
|
||||
|
||||
// Use one slot-handler thread per connection, rather than 1 thread dealing with all connections in rotation.
|
||||
#define VCHI_MULTIPLE_HANDLER_THREADS
|
||||
|
||||
// Put free descriptors onto the head of the free queue, rather than the tail, so that we don't thrash
|
||||
// our way through the pool of descriptors.
|
||||
#define VCHI_PUSH_FREE_DESCRIPTORS_ONTO_HEAD
|
||||
|
||||
// Don't issue a MSG_AVAILABLE callback for every single message. Possibly only safe if VCHI_COARSE_LOCKING.
|
||||
#define VCHI_FEWER_MSG_AVAILABLE_CALLBACKS
|
||||
|
||||
// Don't use message descriptors for TX messages that don't need them
|
||||
#define VCHI_MINIMISE_TX_MSG_DESCRIPTORS
|
||||
|
||||
// Nano-locks for multiqueue
|
||||
//#define VCHI_MQUEUE_NANOLOCKS
|
||||
|
||||
// Lock-free(er) dequeuing
|
||||
//#define VCHI_RX_NANOLOCKS
|
||||
|
||||
#endif /*VCHI_CFG_INTERNAL_H_*/
|
||||
175
drivers/staging/vc04_services/interface/vchi/vchi_common.h
Normal file
175
drivers/staging/vc04_services/interface/vchi/vchi_common.h
Normal file
@@ -0,0 +1,175 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHI_COMMON_H_
|
||||
#define VCHI_COMMON_H_
|
||||
|
||||
|
||||
//flags used when sending messages (must be bitmapped)
|
||||
typedef enum
|
||||
{
|
||||
VCHI_FLAGS_NONE = 0x0,
|
||||
VCHI_FLAGS_BLOCK_UNTIL_OP_COMPLETE = 0x1, // waits for message to be received, or sent (NB. not the same as being seen on other side)
|
||||
VCHI_FLAGS_CALLBACK_WHEN_OP_COMPLETE = 0x2, // run a callback when message sent
|
||||
VCHI_FLAGS_BLOCK_UNTIL_QUEUED = 0x4, // return once the transfer is in a queue ready to go
|
||||
VCHI_FLAGS_ALLOW_PARTIAL = 0x8,
|
||||
VCHI_FLAGS_BLOCK_UNTIL_DATA_READ = 0x10,
|
||||
VCHI_FLAGS_CALLBACK_WHEN_DATA_READ = 0x20,
|
||||
|
||||
VCHI_FLAGS_ALIGN_SLOT = 0x000080, // internal use only
|
||||
VCHI_FLAGS_BULK_AUX_QUEUED = 0x010000, // internal use only
|
||||
VCHI_FLAGS_BULK_AUX_COMPLETE = 0x020000, // internal use only
|
||||
VCHI_FLAGS_BULK_DATA_QUEUED = 0x040000, // internal use only
|
||||
VCHI_FLAGS_BULK_DATA_COMPLETE = 0x080000, // internal use only
|
||||
VCHI_FLAGS_INTERNAL = 0xFF0000
|
||||
} VCHI_FLAGS_T;
|
||||
|
||||
// constants for vchi_crc_control()
|
||||
typedef enum {
|
||||
VCHI_CRC_NOTHING = -1,
|
||||
VCHI_CRC_PER_SERVICE = 0,
|
||||
VCHI_CRC_EVERYTHING = 1,
|
||||
} VCHI_CRC_CONTROL_T;
|
||||
|
||||
//callback reasons when an event occurs on a service
|
||||
typedef enum
|
||||
{
|
||||
VCHI_CALLBACK_REASON_MIN,
|
||||
|
||||
//This indicates that there is data available
|
||||
//handle is the msg id that was transmitted with the data
|
||||
// When a message is received and there was no FULL message available previously, send callback
|
||||
// Tasks get kicked by the callback, reset their event and try and read from the fifo until it fails
|
||||
VCHI_CALLBACK_MSG_AVAILABLE,
|
||||
VCHI_CALLBACK_MSG_SENT,
|
||||
VCHI_CALLBACK_MSG_SPACE_AVAILABLE, // XXX not yet implemented
|
||||
|
||||
// This indicates that a transfer from the other side has completed
|
||||
VCHI_CALLBACK_BULK_RECEIVED,
|
||||
//This indicates that data queued up to be sent has now gone
|
||||
//handle is the msg id that was used when sending the data
|
||||
VCHI_CALLBACK_BULK_SENT,
|
||||
VCHI_CALLBACK_BULK_RX_SPACE_AVAILABLE, // XXX not yet implemented
|
||||
VCHI_CALLBACK_BULK_TX_SPACE_AVAILABLE, // XXX not yet implemented
|
||||
|
||||
VCHI_CALLBACK_SERVICE_CLOSED,
|
||||
|
||||
// this side has sent XOFF to peer due to lack of data consumption by service
|
||||
// (suggests the service may need to take some recovery action if it has
|
||||
// been deliberately holding off consuming data)
|
||||
VCHI_CALLBACK_SENT_XOFF,
|
||||
VCHI_CALLBACK_SENT_XON,
|
||||
|
||||
// indicates that a bulk transfer has finished reading the source buffer
|
||||
VCHI_CALLBACK_BULK_DATA_READ,
|
||||
|
||||
// power notification events (currently host side only)
|
||||
VCHI_CALLBACK_PEER_OFF,
|
||||
VCHI_CALLBACK_PEER_SUSPENDED,
|
||||
VCHI_CALLBACK_PEER_ON,
|
||||
VCHI_CALLBACK_PEER_RESUMED,
|
||||
VCHI_CALLBACK_FORCED_POWER_OFF,
|
||||
|
||||
#ifdef USE_VCHIQ_ARM
|
||||
// some extra notifications provided by vchiq_arm
|
||||
VCHI_CALLBACK_SERVICE_OPENED,
|
||||
VCHI_CALLBACK_BULK_RECEIVE_ABORTED,
|
||||
VCHI_CALLBACK_BULK_TRANSMIT_ABORTED,
|
||||
#endif
|
||||
|
||||
VCHI_CALLBACK_REASON_MAX
|
||||
} VCHI_CALLBACK_REASON_T;
|
||||
|
||||
// service control options
|
||||
typedef enum
|
||||
{
|
||||
VCHI_SERVICE_OPTION_MIN,
|
||||
|
||||
VCHI_SERVICE_OPTION_TRACE,
|
||||
VCHI_SERVICE_OPTION_SYNCHRONOUS,
|
||||
|
||||
VCHI_SERVICE_OPTION_MAX
|
||||
} VCHI_SERVICE_OPTION_T;
|
||||
|
||||
|
||||
//Callback used by all services / bulk transfers
|
||||
typedef void (*VCHI_CALLBACK_T)( void *callback_param, //my service local param
|
||||
VCHI_CALLBACK_REASON_T reason,
|
||||
void *handle ); //for transmitting msg's only
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* Define vector struct for scatter-gather (vector) operations
|
||||
* Vectors can be nested - if a vector element has negative length, then
|
||||
* the data pointer is treated as pointing to another vector array, with
|
||||
* '-vec_len' elements. Thus to append a header onto an existing vector,
|
||||
* you can do this:
|
||||
*
|
||||
* void foo(const VCHI_MSG_VECTOR_T *v, int n)
|
||||
* {
|
||||
* VCHI_MSG_VECTOR_T nv[2];
|
||||
* nv[0].vec_base = my_header;
|
||||
* nv[0].vec_len = sizeof my_header;
|
||||
* nv[1].vec_base = v;
|
||||
* nv[1].vec_len = -n;
|
||||
* ...
|
||||
*
|
||||
*/
|
||||
typedef struct vchi_msg_vector {
|
||||
const void *vec_base;
|
||||
int32_t vec_len;
|
||||
} VCHI_MSG_VECTOR_T;
|
||||
|
||||
// Opaque type for a connection API
|
||||
typedef struct opaque_vchi_connection_api_t VCHI_CONNECTION_API_T;
|
||||
|
||||
// Opaque type for a message driver
|
||||
typedef struct opaque_vchi_message_driver_t VCHI_MESSAGE_DRIVER_T;
|
||||
|
||||
|
||||
// Iterator structure for reading ahead through received message queue. Allocated by client,
|
||||
// initialised by vchi_msg_look_ahead. Fields are for internal VCHI use only.
|
||||
// Iterates over messages in queue at the instant of the call to vchi_msg_lookahead -
|
||||
// will not proceed to messages received since. Behaviour is undefined if an iterator
|
||||
// is used again after messages for that service are removed/dequeued by any
|
||||
// means other than vchi_msg_iter_... calls on the iterator itself.
|
||||
typedef struct {
|
||||
struct opaque_vchi_service_t *service;
|
||||
void *last;
|
||||
void *next;
|
||||
void *remove;
|
||||
} VCHI_MSG_ITER_T;
|
||||
|
||||
|
||||
#endif // VCHI_COMMON_H_
|
||||
42
drivers/staging/vc04_services/interface/vchi/vchi_mh.h
Normal file
42
drivers/staging/vc04_services/interface/vchi/vchi_mh.h
Normal file
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHI_MH_H_
|
||||
#define VCHI_MH_H_
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
typedef int32_t VCHI_MEM_HANDLE_T;
|
||||
#define VCHI_MEM_HANDLE_INVALID 0
|
||||
|
||||
#endif
|
||||
40
drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h
Normal file
40
drivers/staging/vc04_services/interface/vchiq_arm/vchiq.h
Normal file
@@ -0,0 +1,40 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHIQ_VCHIQ_H
|
||||
#define VCHIQ_VCHIQ_H
|
||||
|
||||
#include "vchiq_if.h"
|
||||
#include "vchiq_util.h"
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,42 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHIQ_2835_H
|
||||
#define VCHIQ_2835_H
|
||||
|
||||
#include "vchiq_pagelist.h"
|
||||
|
||||
#define VCHIQ_PLATFORM_FRAGMENTS_OFFSET_IDX 0
|
||||
#define VCHIQ_PLATFORM_FRAGMENTS_COUNT_IDX 1
|
||||
|
||||
#endif /* VCHIQ_2835_H */
|
||||
File diff suppressed because it is too large
Load Diff
2903
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
Normal file
2903
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.c
Normal file
File diff suppressed because it is too large
Load Diff
220
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h
Normal file
220
drivers/staging/vc04_services/interface/vchiq_arm/vchiq_arm.h
Normal file
@@ -0,0 +1,220 @@
|
||||
/**
|
||||
* Copyright (c) 2014 Raspberry Pi (Trading) Ltd. All rights reserved.
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHIQ_ARM_H
|
||||
#define VCHIQ_ARM_H
|
||||
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/semaphore.h>
|
||||
#include <linux/atomic.h>
|
||||
#include "vchiq_core.h"
|
||||
#include "vchiq_debugfs.h"
|
||||
|
||||
|
||||
enum vc_suspend_status {
|
||||
VC_SUSPEND_FORCE_CANCELED = -3, /* Force suspend canceled, too busy */
|
||||
VC_SUSPEND_REJECTED = -2, /* Videocore rejected suspend request */
|
||||
VC_SUSPEND_FAILED = -1, /* Videocore suspend failed */
|
||||
VC_SUSPEND_IDLE = 0, /* VC active, no suspend actions */
|
||||
VC_SUSPEND_REQUESTED, /* User has requested suspend */
|
||||
VC_SUSPEND_IN_PROGRESS, /* Slot handler has recvd suspend request */
|
||||
VC_SUSPEND_SUSPENDED /* Videocore suspend succeeded */
|
||||
};
|
||||
|
||||
enum vc_resume_status {
|
||||
VC_RESUME_FAILED = -1, /* Videocore resume failed */
|
||||
VC_RESUME_IDLE = 0, /* VC suspended, no resume actions */
|
||||
VC_RESUME_REQUESTED, /* User has requested resume */
|
||||
VC_RESUME_IN_PROGRESS, /* Slot handler has received resume request */
|
||||
VC_RESUME_RESUMED /* Videocore resumed successfully (active) */
|
||||
};
|
||||
|
||||
|
||||
enum USE_TYPE_E {
|
||||
USE_TYPE_SERVICE,
|
||||
USE_TYPE_SERVICE_NO_RESUME,
|
||||
USE_TYPE_VCHIQ
|
||||
};
|
||||
|
||||
|
||||
|
||||
typedef struct vchiq_arm_state_struct {
|
||||
/* Keepalive-related data */
|
||||
struct task_struct *ka_thread;
|
||||
struct completion ka_evt;
|
||||
atomic_t ka_use_count;
|
||||
atomic_t ka_use_ack_count;
|
||||
atomic_t ka_release_count;
|
||||
|
||||
struct completion vc_suspend_complete;
|
||||
struct completion vc_resume_complete;
|
||||
|
||||
rwlock_t susp_res_lock;
|
||||
enum vc_suspend_status vc_suspend_state;
|
||||
enum vc_resume_status vc_resume_state;
|
||||
|
||||
unsigned int wake_address;
|
||||
|
||||
struct timer_list suspend_timer;
|
||||
int suspend_timer_timeout;
|
||||
int suspend_timer_running;
|
||||
|
||||
/* Global use count for videocore.
|
||||
** This is equal to the sum of the use counts for all services. When
|
||||
** this hits zero the videocore suspend procedure will be initiated.
|
||||
*/
|
||||
int videocore_use_count;
|
||||
|
||||
/* Use count to track requests from videocore peer.
|
||||
** This use count is not associated with a service, so needs to be
|
||||
** tracked separately with the state.
|
||||
*/
|
||||
int peer_use_count;
|
||||
|
||||
/* Flag to indicate whether resume is blocked. This happens when the
|
||||
** ARM is suspending
|
||||
*/
|
||||
struct completion resume_blocker;
|
||||
int resume_blocked;
|
||||
struct completion blocked_blocker;
|
||||
int blocked_count;
|
||||
|
||||
int autosuspend_override;
|
||||
|
||||
/* Flag to indicate that the first vchiq connect has made it through.
|
||||
** This means that both sides should be fully ready, and we should
|
||||
** be able to suspend after this point.
|
||||
*/
|
||||
int first_connect;
|
||||
|
||||
unsigned long long suspend_start_time;
|
||||
unsigned long long sleep_start_time;
|
||||
unsigned long long resume_start_time;
|
||||
unsigned long long last_wake_time;
|
||||
|
||||
} VCHIQ_ARM_STATE_T;
|
||||
|
||||
extern int vchiq_arm_log_level;
|
||||
extern int vchiq_susp_log_level;
|
||||
|
||||
int vchiq_platform_init(struct platform_device *pdev, VCHIQ_STATE_T *state);
|
||||
|
||||
extern VCHIQ_STATE_T *
|
||||
vchiq_get_state(void);
|
||||
|
||||
extern VCHIQ_STATUS_T
|
||||
vchiq_arm_vcsuspend(VCHIQ_STATE_T *state);
|
||||
|
||||
extern VCHIQ_STATUS_T
|
||||
vchiq_arm_force_suspend(VCHIQ_STATE_T *state);
|
||||
|
||||
extern int
|
||||
vchiq_arm_allow_resume(VCHIQ_STATE_T *state);
|
||||
|
||||
extern VCHIQ_STATUS_T
|
||||
vchiq_arm_vcresume(VCHIQ_STATE_T *state);
|
||||
|
||||
extern VCHIQ_STATUS_T
|
||||
vchiq_arm_init_state(VCHIQ_STATE_T *state, VCHIQ_ARM_STATE_T *arm_state);
|
||||
|
||||
extern int
|
||||
vchiq_check_resume(VCHIQ_STATE_T *state);
|
||||
|
||||
extern void
|
||||
vchiq_check_suspend(VCHIQ_STATE_T *state);
|
||||
VCHIQ_STATUS_T
|
||||
vchiq_use_service(VCHIQ_SERVICE_HANDLE_T handle);
|
||||
|
||||
extern VCHIQ_STATUS_T
|
||||
vchiq_release_service(VCHIQ_SERVICE_HANDLE_T handle);
|
||||
|
||||
extern VCHIQ_STATUS_T
|
||||
vchiq_check_service(VCHIQ_SERVICE_T *service);
|
||||
|
||||
extern VCHIQ_STATUS_T
|
||||
vchiq_platform_suspend(VCHIQ_STATE_T *state);
|
||||
|
||||
extern int
|
||||
vchiq_platform_videocore_wanted(VCHIQ_STATE_T *state);
|
||||
|
||||
extern int
|
||||
vchiq_platform_use_suspend_timer(void);
|
||||
|
||||
extern void
|
||||
vchiq_dump_platform_use_state(VCHIQ_STATE_T *state);
|
||||
|
||||
extern void
|
||||
vchiq_dump_service_use_state(VCHIQ_STATE_T *state);
|
||||
|
||||
extern VCHIQ_ARM_STATE_T*
|
||||
vchiq_platform_get_arm_state(VCHIQ_STATE_T *state);
|
||||
|
||||
extern int
|
||||
vchiq_videocore_wanted(VCHIQ_STATE_T *state);
|
||||
|
||||
extern VCHIQ_STATUS_T
|
||||
vchiq_use_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service,
|
||||
enum USE_TYPE_E use_type);
|
||||
extern VCHIQ_STATUS_T
|
||||
vchiq_release_internal(VCHIQ_STATE_T *state, VCHIQ_SERVICE_T *service);
|
||||
|
||||
extern VCHIQ_DEBUGFS_NODE_T *
|
||||
vchiq_instance_get_debugfs_node(VCHIQ_INSTANCE_T instance);
|
||||
|
||||
extern int
|
||||
vchiq_instance_get_use_count(VCHIQ_INSTANCE_T instance);
|
||||
|
||||
extern int
|
||||
vchiq_instance_get_pid(VCHIQ_INSTANCE_T instance);
|
||||
|
||||
extern int
|
||||
vchiq_instance_get_trace(VCHIQ_INSTANCE_T instance);
|
||||
|
||||
extern void
|
||||
vchiq_instance_set_trace(VCHIQ_INSTANCE_T instance, int trace);
|
||||
|
||||
extern void
|
||||
set_suspend_state(VCHIQ_ARM_STATE_T *arm_state,
|
||||
enum vc_suspend_status new_state);
|
||||
|
||||
extern void
|
||||
set_resume_state(VCHIQ_ARM_STATE_T *arm_state,
|
||||
enum vc_resume_status new_state);
|
||||
|
||||
extern void
|
||||
start_suspend_timer(VCHIQ_ARM_STATE_T *arm_state);
|
||||
|
||||
|
||||
#endif /* VCHIQ_ARM_H */
|
||||
@@ -0,0 +1,37 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
const char *vchiq_get_build_hostname(void);
|
||||
const char *vchiq_get_build_version(void);
|
||||
const char *vchiq_get_build_time(void);
|
||||
const char *vchiq_get_build_date(void);
|
||||
@@ -0,0 +1,69 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2014 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHIQ_CFG_H
|
||||
#define VCHIQ_CFG_H
|
||||
|
||||
#define VCHIQ_MAGIC VCHIQ_MAKE_FOURCC('V', 'C', 'H', 'I')
|
||||
/* The version of VCHIQ - change with any non-trivial change */
|
||||
#define VCHIQ_VERSION 8
|
||||
/* The minimum compatible version - update to match VCHIQ_VERSION with any
|
||||
** incompatible change */
|
||||
#define VCHIQ_VERSION_MIN 3
|
||||
|
||||
/* The version that introduced the VCHIQ_IOC_LIB_VERSION ioctl */
|
||||
#define VCHIQ_VERSION_LIB_VERSION 7
|
||||
|
||||
/* The version that introduced the VCHIQ_IOC_CLOSE_DELIVERED ioctl */
|
||||
#define VCHIQ_VERSION_CLOSE_DELIVERED 7
|
||||
|
||||
/* The version that made it safe to use SYNCHRONOUS mode */
|
||||
#define VCHIQ_VERSION_SYNCHRONOUS_MODE 8
|
||||
|
||||
#define VCHIQ_MAX_STATES 1
|
||||
#define VCHIQ_MAX_SERVICES 4096
|
||||
#define VCHIQ_MAX_SLOTS 128
|
||||
#define VCHIQ_MAX_SLOTS_PER_SIDE 64
|
||||
|
||||
#define VCHIQ_NUM_CURRENT_BULKS 32
|
||||
#define VCHIQ_NUM_SERVICE_BULKS 4
|
||||
|
||||
#ifndef VCHIQ_ENABLE_DEBUG
|
||||
#define VCHIQ_ENABLE_DEBUG 1
|
||||
#endif
|
||||
|
||||
#ifndef VCHIQ_ENABLE_STATS
|
||||
#define VCHIQ_ENABLE_STATS 1
|
||||
#endif
|
||||
|
||||
#endif /* VCHIQ_CFG_H */
|
||||
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "vchiq_connected.h"
|
||||
#include "vchiq_core.h"
|
||||
#include "vchiq_killable.h"
|
||||
#include <linux/module.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
#define MAX_CALLBACKS 10
|
||||
|
||||
static int g_connected;
|
||||
static int g_num_deferred_callbacks;
|
||||
static VCHIQ_CONNECTED_CALLBACK_T g_deferred_callback[MAX_CALLBACKS];
|
||||
static int g_once_init;
|
||||
static struct mutex g_connected_mutex;
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* Function to initialize our lock.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
static void connected_init(void)
|
||||
{
|
||||
if (!g_once_init) {
|
||||
mutex_init(&g_connected_mutex);
|
||||
g_once_init = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* This function is used to defer initialization until the vchiq stack is
|
||||
* initialized. If the stack is already initialized, then the callback will
|
||||
* be made immediately, otherwise it will be deferred until
|
||||
* vchiq_call_connected_callbacks is called.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
void vchiq_add_connected_callback(VCHIQ_CONNECTED_CALLBACK_T callback)
|
||||
{
|
||||
connected_init();
|
||||
|
||||
if (mutex_lock_interruptible(&g_connected_mutex) != 0)
|
||||
return;
|
||||
|
||||
if (g_connected)
|
||||
/* We're already connected. Call the callback immediately. */
|
||||
|
||||
callback();
|
||||
else {
|
||||
if (g_num_deferred_callbacks >= MAX_CALLBACKS)
|
||||
vchiq_log_error(vchiq_core_log_level,
|
||||
"There already %d callback registered - "
|
||||
"please increase MAX_CALLBACKS",
|
||||
g_num_deferred_callbacks);
|
||||
else {
|
||||
g_deferred_callback[g_num_deferred_callbacks] =
|
||||
callback;
|
||||
g_num_deferred_callbacks++;
|
||||
}
|
||||
}
|
||||
mutex_unlock(&g_connected_mutex);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
*
|
||||
* This function is called by the vchiq stack once it has been connected to
|
||||
* the videocore and clients can start to use the stack.
|
||||
*
|
||||
***************************************************************************/
|
||||
|
||||
void vchiq_call_connected_callbacks(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
connected_init();
|
||||
|
||||
if (mutex_lock_interruptible(&g_connected_mutex) != 0)
|
||||
return;
|
||||
|
||||
for (i = 0; i < g_num_deferred_callbacks; i++)
|
||||
g_deferred_callback[i]();
|
||||
|
||||
g_num_deferred_callbacks = 0;
|
||||
g_connected = 1;
|
||||
mutex_unlock(&g_connected_mutex);
|
||||
}
|
||||
EXPORT_SYMBOL(vchiq_add_connected_callback);
|
||||
@@ -0,0 +1,50 @@
|
||||
/**
|
||||
* Copyright (c) 2010-2012 Broadcom. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions, and the following disclaimer,
|
||||
* without modification.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. The names of the above-listed copyright holders may not be used
|
||||
* to endorse or promote products derived from this software without
|
||||
* specific prior written permission.
|
||||
*
|
||||
* ALTERNATIVELY, this software may be distributed under the terms of the
|
||||
* GNU General Public License ("GPL") version 2, as published by the Free
|
||||
* Software Foundation.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#ifndef VCHIQ_CONNECTED_H
|
||||
#define VCHIQ_CONNECTED_H
|
||||
|
||||
/* ---- Include Files ----------------------------------------------------- */
|
||||
|
||||
/* ---- Constants and Types ---------------------------------------------- */
|
||||
|
||||
typedef void (*VCHIQ_CONNECTED_CALLBACK_T)(void);
|
||||
|
||||
/* ---- Variable Externs ------------------------------------------------- */
|
||||
|
||||
/* ---- Function Prototypes ---------------------------------------------- */
|
||||
|
||||
void vchiq_add_connected_callback(VCHIQ_CONNECTED_CALLBACK_T callback);
|
||||
void vchiq_call_connected_callbacks(void);
|
||||
|
||||
#endif /* VCHIQ_CONNECTED_H */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user