summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaurabh Bipin Chandra2013-04-22 11:42:19 -0500
committerSaurabh Bipin Chandra2013-04-26 09:14:28 -0500
commit6647d1f16d70b9d867ce5b7aef92705939aa5975 (patch)
tree73b154f99e7ceff809c8a98be6489e4ee11d0877 /memplugin_qnx.c
downloadhardware-ti-libdce-6647d1f16d70b9d867ce5b7aef92705939aa5975.tar.gz
hardware-ti-libdce-6647d1f16d70b9d867ce5b7aef92705939aa5975.tar.xz
hardware-ti-libdce-6647d1f16d70b9d867ce5b7aef92705939aa5975.zip
[libDCE] Add IPC 3.x Adapted code to Repository
This patch adds libdce code to the repository. LibDCE has been adapted to use the MmRpc layer of IPC 3.x. This version of LibDCE is expected to work on QNX. Patchset 2 adds/modifies: 1. Removes Tiler 2D allocation/free for now. 2. Corrects memplugin_free() for Tiler 1D. 3. Modifies dce_test app to dump output till 30 frames. 4. Renamed dce.h to libdce.h. 5. Corrected header files across all files. 6. Build configuration for QNX 7. Removes build warnings. 8. Add README for Build instructions 9. Takes care of comments of Buddy and Pradeep. Patchset 3 adds/modifies: 1. Reduced Stack usage of each function. 2. Add ptr check in memplugin and remove from libdce. 3. Add DCE_Assert macros. 4. Add DCE_error_status enum. 5. Comments Cleanup 6. Make some functions static. 7. process() cleanup including removing reply_buf. 8. Add else if (for codec_type == Encoder type) 9. Converted Macros to Inline functions. 10.Converted init and deinit to dce_init and dce_deinit functions. 11. Removed dce_init() and dce_deinit() declarations Patchset 4 adds/modifies: 1. Assert Input function arguments. 2. Correct copyright year. 3. Correct memplugin_free for Shared memory. 4. Create dce_priv.h and move trace and assert macros to the header. 5. Redeclare mem_type enum and add mem_error_status enum in memplugin.h and make corresponding changes. 6. Add asserts in memplugin. Intention of some of the changes above is to move towards delinking Libdce and Memplugin. Patchset 5: 1. Missed to add dce_priv.h file. Patchset 6: 1. Take care Pradeep's comment. Change-Id: I6e5e37b7088362e7bad66200fc3454bb828e0eff Signed-off-by: Saurabh Bipin Chandra <a0131926@ti.com>
Diffstat (limited to 'memplugin_qnx.c')
-rw-r--r--memplugin_qnx.c158
1 files changed, 158 insertions, 0 deletions
diff --git a/memplugin_qnx.c b/memplugin_qnx.c
new file mode 100644
index 0000000..5555037
--- /dev/null
+++ b/memplugin_qnx.c
@@ -0,0 +1,158 @@
1/*
2 * Copyright (c) 2013, Texas Instruments Incorporated
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
7 * are met:
8 *
9 * * Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 *
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 *
16 * * Neither the name of Texas Instruments Incorporated nor the names of
17 * its contributors may be used to endorse or promote products derived
18 * from this software without specific prior written permission.
19 *
20 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
21 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
22 * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
27 * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
28 * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
29 * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
30 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 */
32
33#include "memplugin.h"
34#include "dce_priv.h"
35
36
37/* Would it be good to have MemHeaders for Tiler 2D buffers?? */
38/* Since the decision is to not support allocation of IO buffers, no */
39/* need to worry about Tiler 2D Buffers. Hence below Memheader */
40/* can be used. */
41/*
42typedef struct {
43 dce_memory_type memory_type;
44 union {
45 struct {
46 Uint32 size;
47 Uint32 ducati_addr;
48 } tilerHeader;
49 shm_buf shm_bufHeader;
50 }
51} MemHeader;
52else for Tiler 1D buffers */
53
54/* MemHeader is important because it is necessary to know the */
55/* size of the parameter buffers on IPU for Cache operations */
56/* The size can't be assumed as codec supports different inputs */
57/* For ex: static params can be VIDDEC3_Params, IVIDDEC3_Params */
58/* or IH264DEC_Params */
59typedef struct MemHeader {
60 int size;
61 void *ptr;
62} MemHeader;
63
64
65/* For TILER 2D Buffers : sz = width */
66/* : height = nonzero */
67/* For other memory_types : height = 0 */
68void *memplugin_alloc(int sz, int height, mem_type memory_type)
69{
70 MemHeader *h;
71 shm_buf *handle;
72 MemAllocBlock block;
73 int num_block;
74 mem_error_status eError = MEM_EOK;
75
76 _ASSERT(sz != 0, MEM_EINVALID_INPUT);
77 _ASSERT((memory_type < MEM_MAX) && (memory_type >= TILER_1D_BUFFER), MEM_EINVALID_INPUT);
78
79 /* Tiler buffer Allocations : Only Tiler 1D used for Parameter Buffers and RPC Message buffers */
80 if( memory_type == TILER_1D_BUFFER || memory_type == TILER8_2D_BUFFER || memory_type == TILER16_2D_BUFFER ) {
81 num_block = 1;
82
83 if( memory_type == TILER_1D_BUFFER ) {
84 /* Allocate in tiler paged mode (1d) container */
85 block.pixelFormat = PIXEL_FMT_PAGE;
86 block.dim.len = sz + sizeof(MemHeader);
87#if 0 /* Data Tiler Buffers not to be allocated by DCE */
88 } else if( memory_type == TILER8_2D_BUFFER ) {
89 /* Allocate in tiler 8 bit mode (2d) container */
90 _ASSERT(height != 0, MEM_EINVALID_INPUT);
91 block.pixelFormat = PIXEL_FMT_8BIT;
92 block.dim.area.width = sz;
93 block.dim.area.height = height;
94 } else {
95 /* Allocate in tiler 16 bit mode (2d) container */
96 _ASSERT(height != 0, MEM_EINVALID_INPUT);
97 block.pixelFormat = PIXEL_FMT_16BIT;
98 block.dim.area.width = sz;
99 block.dim.area.height = height;
100#endif
101 }
102 block.stride = 0;
103
104 h = MemMgr_Alloc(&block, num_block);
105
106 _ASSERT(h != NULL, MEM_EOUT_OF_TILER_MEMORY);
107
108 h->size = sz;
109 memset(H2P(h), 0, sz);
110 return (H2P(h));
111 } else {
112
113 handle = malloc(sizeof(shm_buf));
114 _ASSERT(handle != NULL, MEM_EOUT_OF_SYSTEM_MEMORY);
115
116 /* Parameter Buffers : Allocate from Shared Memory considering MemHeader*/
117 SHM_alloc(sz + sizeof(MemHeader), handle);
118
119 h = (MemHeader *)handle->vir_addr;
120 _ASSERT_AND_EXECUTE(h != NULL, MEM_EOUT_OF_SHMEMORY, free(handle));
121
122 h->size = sz;
123 h->ptr = handle;
124 memset(H2P(h), 0, sz);
125 return (H2P(h));
126 }
127EXIT:
128 return (NULL);
129}
130
131/* memory_type is not added if MemHeader is used for Tiler Buffers */
132void memplugin_free(void *ptr, mem_type memory_type)
133{
134 shm_buf *handle;
135 mem_error_status eError = MEM_EOK;
136
137 _ASSERT(ptr != NULL, MEM_EINVALID_INPUT);
138 _ASSERT((memory_type < MEM_MAX) && (memory_type >= TILER_1D_BUFFER), MEM_EINVALID_INPUT);
139
140 if( memory_type == TILER_1D_BUFFER ) {
141 MemMgr_Free(P2H(ptr));
142 } else if( memory_type == SHARED_MEMORY_BUFFER ) {
143 handle = (P2H(ptr))->ptr;
144 SHM_release(handle);
145 free(handle);
146 } else {
147 ERROR("Tiler 2D Allocation/Free not implemented");
148 }
149EXIT:;
150}
151
152void *memplugin_share(void *ptr, mem_type memory_type)
153{
154 /* No Userspace Virtual pointers to DMA BUF Handles conversion required*/
155 /* Do nothing */
156 return (ptr);
157}
158