1 | /* |
2 | Copyright (c) 2012, Broadcom Europe Ltd |
3 | All rights reserved. |
4 | |
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, 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 | |
16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND |
17 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED |
18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY |
20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES |
21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; |
22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND |
23 | ON 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 |
25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
26 | */ |
27 | |
28 | #include "interface/vmcs_host/khronos/IL/OMX_Component.h" |
29 | |
30 | #include "interface/vmcs_host/vcilcs.h" |
31 | #include "interface/vmcs_host/vcilcs_common.h" |
32 | |
33 | static IL_FN_T vcilcs_fns[] = {NULL, // response |
34 | NULL, // create component |
35 | |
36 | vcil_in_get_component_version, |
37 | NULL, // send command |
38 | vcil_in_get_parameter, |
39 | vcil_in_set_parameter, |
40 | vcil_in_get_config, |
41 | vcil_in_set_config, |
42 | vcil_in_get_extension_index, |
43 | vcil_in_get_state, |
44 | NULL, // tunnel request |
45 | vcil_in_use_buffer, |
46 | NULL, // use egl image |
47 | NULL, // allocate buffer |
48 | vcil_in_free_buffer, |
49 | vcil_in_empty_this_buffer, |
50 | vcil_in_fill_this_buffer, |
51 | NULL, // set callbacks |
52 | NULL, // component role enum |
53 | |
54 | NULL, // deinit |
55 | |
56 | vcil_out_event_handler, |
57 | vcil_out_empty_buffer_done, |
58 | vcil_out_fill_buffer_done, |
59 | |
60 | NULL, // component name enum |
61 | NULL, // get debug information |
62 | |
63 | NULL |
64 | }; |
65 | |
66 | static ILCS_COMMON_T *vcilcs_common_init(ILCS_SERVICE_T *ilcs) |
67 | { |
68 | ILCS_COMMON_T *st; |
69 | |
70 | st = vcos_malloc(sizeof(ILCS_COMMON_T), "ILCS_HOST_COMMON" ); |
71 | if(!st) |
72 | return NULL; |
73 | |
74 | if(vcos_semaphore_create(&st->component_lock, "ILCS" , 1) != VCOS_SUCCESS) |
75 | { |
76 | vcos_free(st); |
77 | return NULL; |
78 | } |
79 | |
80 | st->ilcs = ilcs; |
81 | st->component_list = NULL; |
82 | return st; |
83 | } |
84 | |
85 | static void vcilcs_common_deinit(ILCS_COMMON_T *st) |
86 | { |
87 | vcos_semaphore_delete(&st->component_lock); |
88 | |
89 | while(st->component_list) |
90 | { |
91 | VC_PRIVATE_COMPONENT_T *comp = st->component_list; |
92 | st->component_list = comp->next; |
93 | vcos_free(comp); |
94 | } |
95 | |
96 | vcos_free(st); |
97 | } |
98 | |
99 | static void vcilcs_thread_init(ILCS_COMMON_T *st) |
100 | { |
101 | } |
102 | |
103 | static unsigned char *vcilcs_mem_lock(OMX_BUFFERHEADERTYPE *buffer) |
104 | { |
105 | return buffer->pBuffer; |
106 | } |
107 | |
108 | static void vcilcs_mem_unlock(OMX_BUFFERHEADERTYPE *buffer) |
109 | { |
110 | } |
111 | |
112 | |
113 | void vcilcs_config(ILCS_CONFIG_T *config) |
114 | { |
115 | config->fns = vcilcs_fns; |
116 | config->ilcs_common_init = vcilcs_common_init; |
117 | config->ilcs_common_deinit = vcilcs_common_deinit; |
118 | config->ilcs_thread_init = vcilcs_thread_init; |
119 | config->ilcs_mem_lock = vcilcs_mem_lock; |
120 | config->ilcs_mem_unlock = vcilcs_mem_unlock; |
121 | } |
122 | |
123 | |