blob: dbd91f3e63dd6c1a9be03915480e0af9bfe00f30 [file] [log] [blame]
Jiho Chang20c51682012-03-24 05:37:21 +09001/*
2 * Copyright@ Samsung Electronics Co. LTD
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15*/
16
17/*!
18 * \file ExynosBuffer.h
19 * \brief header file for ExynosBuffer
20 * \author Sangwoo, Park(sw5771.park@samsung.com)
21 * \date 2011/06/02
22 *
23 * <b>Revision History: </b>
24 * - 2010/06/03 : Sangwoo, Park(sw5771.park@samsung.com) \n
25 * Initial version
26 *
27 * - 2012/03/14 : sangwoo.park(sw5771.park@samsung.com) \n
28 * Change file, struct name to ExynosXXX.
29 *
30 */
31
32#ifndef EXYNOS_BUFFER_H_
33#define EXYNOS_BUFFER_H_
34
35#include <sys/types.h>
36
37//! Buffer information
38/*!
39 * \ingroup Exynos
40 */
41struct ExynosBuffer
42{
43public:
44 //! Buffer type
45 enum BUFFER_TYPE
46 {
47 BUFFER_TYPE_BASE = 0,
48 BUFFER_TYPE_VIRT = 1, //!< virtual address
49 BUFFER_TYPE_PHYS = 1 << 1, //!< physical address
50 BUFFER_TYPE_RESERVED = 1 << 2, //!< reserved type
51 BUFFER_TYPE_MAX,
52 };
53
54 //! Buffer virtual address
55 union {
56 char *p; //! single address.
57 char *extP[3]; //! Y Cb Cr.
58 } virt;
59
60 //! Buffer physical address
61 union {
62 unsigned int p; //! single address.
63 unsigned int extP[3]; //! Y Cb Cr.
64 } phys;
65
66 //! Buffer reserved id
67 union {
68 unsigned int p; //! \n
69 unsigned int extP[3]; //! \n
70 } reserved;
71
72 //! Buffer size
73 union {
74 unsigned int s;
75 unsigned int extS[3];
76 } size;
77
78#ifdef __cplusplus
79 //! Constructor
80 ExynosBuffer()
81 {
82 for (int i = 0; i < 3; i++) {
83 virt. extP[i] = NULL;
84 phys. extP[i] = 0;
85 reserved.extP[i] = 0;
86 size. extS[i] = 0;
87 }
88 }
89
90 //! Constructor
91 ExynosBuffer(const ExynosBuffer *other)
92 {
93 for (int i = 0; i < 3; i++) {
94 virt. extP[i] = other->virt.extP[i];
95 phys. extP[i] = other->phys.extP[i];
96 reserved.extP[i] = other->reserved.extP[i];
97 size. extS[i] = other->size.extS[i];
98 }
99 }
100
101 //! Operator(=) override
102 ExynosBuffer& operator =(const ExynosBuffer &other)
103 {
104 for (int i = 0; i < 3; i++) {
105 virt. extP[i] = other.virt.extP[i];
106 phys. extP[i] = other.phys.extP[i];
107 reserved.extP[i] = other.reserved.extP[i];
108 size. extS[i] = other.size.extS[i];
109 }
110 return *this;
111 }
112
113 //! Operator(==) override
114 bool operator ==(const ExynosBuffer &other) const
115 {
116 return ( virt. extP[0] == other.virt.extP[0]
117 && virt. extP[1] == other.virt.extP[1]
118 && virt. extP[2] == other.virt.extP[2]
119 && phys. extP[0] == other.phys.extP[0]
120 && phys. extP[1] == other.phys.extP[1]
121 && phys. extP[2] == other.phys.extP[2]
122 && reserved.extP[0] == other.reserved.extP[0]
123 && reserved.extP[1] == other.reserved.extP[1]
124 && reserved.extP[2] == other.reserved.extP[2]
125 && size. extS[0] == other.size.extS[0]
126 && size. extS[1] == other.size.extS[1]
127 && size. extS[2] == other.size.extS[2]);
128 }
129
130 //! Operator(!=) override
131 bool operator !=(const ExynosBuffer &other) const
132 {
133 // use operator(==)
134 return !(*this == other);
135 }
136
137 //! Get Buffer type
138 static int BUFFER_TYPE(ExynosBuffer *buf)
139 {
140 int type = BUFFER_TYPE_BASE;
141 if (buf->virt.p)
142 type |= BUFFER_TYPE_VIRT;
143 if (buf->phys.p)
144 type |= BUFFER_TYPE_PHYS;
145 if (buf->reserved.p)
146 type |= BUFFER_TYPE_RESERVED;
147
148 return type;
149 }
150#endif
151};
152
153#endif //EXYNOS_BUFFER_H_