1/*
2Copyright (c) 2012, Broadcom Europe Ltd
3All rights reserved.
4
5Redistribution and use in source and binary forms, with or without
6modification, are permitted provided that the following conditions are met:
7 * Redistributions of source code must retain the above copyright
8 notice, this list of conditions and the following disclaimer.
9 * Redistributions in binary form must reproduce the above copyright
10 notice, this list of conditions and the following disclaimer in the
11 documentation and/or other materials provided with the distribution.
12 * Neither the name of the copyright holder nor the
13 names of its contributors may be used to endorse or promote products
14 derived from this software without specific prior written permission.
15
16THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY
20DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*/
27
28// OpenMAX IL Component Service definitions
29
30#ifndef ILCS_H
31#define ILCS_H
32
33#include "interface/vmcs_host/khronos/IL/OMX_Component.h"
34#include "interface/vmcs_host/vc_ilcs_defs.h"
35
36struct ILCS_SERVICE_T;
37typedef struct ILCS_SERVICE_T ILCS_SERVICE_T;
38
39struct ILCS_COMMON_T;
40typedef struct ILCS_COMMON_T ILCS_COMMON_T;
41
42typedef void (*IL_FN_T)(ILCS_COMMON_T *st, void *call, int clen, void *resp, int *rlen);
43
44typedef struct {
45 IL_FN_T *fns;
46 ILCS_COMMON_T *(*ilcs_common_init)(ILCS_SERVICE_T *);
47 void (*ilcs_common_deinit)(ILCS_COMMON_T *st);
48 void (*ilcs_thread_init)(ILCS_COMMON_T *st);
49 unsigned char *(*ilcs_mem_lock)(OMX_BUFFERHEADERTYPE *buffer);
50 void (*ilcs_mem_unlock)(OMX_BUFFERHEADERTYPE *buffer);
51} ILCS_CONFIG_T;
52
53// initialise the VideoCore IL Component service
54// returns pointer to state on success, NULL on failure
55#ifdef USE_VCHIQ_ARM
56VCHPRE_ ILCS_SERVICE_T VCHPOST_ *ilcs_init(VCHIQ_INSTANCE_T state, void **connection, ILCS_CONFIG_T *config, int use_memmgr);
57#else
58VCHPRE_ ILCS_SERVICE_T VCHPOST_ *ilcs_init(VCHIQ_STATE_T *state, void **connection, ILCS_CONFIG_T *config, int use_memmgr);
59#endif
60
61// deinitialises the IL Component service
62VCHPRE_ void VCHPOST_ ilcs_deinit(ILCS_SERVICE_T *ilcs);
63
64// returns 1 if the current thread is the ilcs thread, 0 otherwise
65VCHPRE_ int VCHPOST_ ilcs_thread_current(void *param);
66
67// returns pointer to shared state
68VCHPRE_ ILCS_COMMON_T *ilcs_get_common(ILCS_SERVICE_T *ilcs);
69
70VCHPRE_ int VCHPOST_ ilcs_execute_function(ILCS_SERVICE_T *ilcs, IL_FUNCTION_T func, void *data, int len, void *resp, int *rlen);
71VCHPRE_ OMX_ERRORTYPE VCHPOST_ ilcs_pass_buffer(ILCS_SERVICE_T *ilcs, IL_FUNCTION_T func, void *reference, OMX_BUFFERHEADERTYPE *pBuffer);
72VCHPRE_ OMX_BUFFERHEADERTYPE * VCHPOST_ ilcs_receive_buffer(ILCS_SERVICE_T *ilcs, void *call, int clen, OMX_COMPONENTTYPE **pComp);
73
74// bulks are 16 bytes aligned, implicit in use of vchiq
75#define ILCS_ALIGN 16
76
77#define ILCS_ROUND_UP(x) ((((unsigned long)(x))+ILCS_ALIGN-1) & ~(ILCS_ALIGN-1))
78#define ILCS_ROUND_DOWN(x) (((unsigned long)(x)) & ~(ILCS_ALIGN-1))
79#define ILCS_ALIGNED(x) (((unsigned long)(x) & (ILCS_ALIGN-1)) == 0)
80
81
82#ifdef _VIDEOCORE
83#include "vcfw/logging/logging.h"
84
85#ifdef ILCS_LOGGING
86
87#define LOG_MSG ILCS_LOGGING
88extern void ilcs_log_event_handler(OMX_HANDLETYPE hComponent, OMX_PTR pAppData, OMX_EVENTTYPE eEvent,
89 OMX_U32 nData1,OMX_U32 nData2,OMX_PTR pEventData);
90
91#else
92
93#define LOG_MSG LOGGING_GENERAL
94#define ilcs_log_event_handler(...)
95extern void dummy_logging_message(int level, const char *format, ...);
96#undef logging_message
97#define logging_message if (1) {} else dummy_logging_message
98
99#endif // ILCS_LOGGING
100#endif // _VIDEOCORE
101
102#endif // ILCS_H
103
104