2 * Copyright@ Samsung Electronics Co. LTD
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
8 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 * \file ExynosBuffer.h
19 * \brief header file for ExynosBuffer
20 * \author Sangwoo, Park(sw5771.park@samsung.com)
23 * <b>Revision History: </b>
24 * - 2010/06/03 : Sangwoo, Park(sw5771.park@samsung.com) \n
27 * - 2012/03/14 : sangwoo.park(sw5771.park@samsung.com) \n
28 * Change file, struct name to ExynosXXX.
30 * - 2012/10/08 : sangwoo.park(sw5771.park@samsung.com) \n
31 * Add BUFFER_PLANE_NUM_DEFAULT, and, Increase Buffer as 4.
35 #ifndef EXYNOS_BUFFER_H_
36 #define EXYNOS_BUFFER_H_
38 #include <sys/types.h>
40 //! Buffer information
51 BUFFER_TYPE_VIRT
= 1 << 0, //!< virtual address
52 BUFFER_TYPE_PHYS
= 1 << 1, //!< physical address
53 BUFFER_TYPE_FD
= 1 << 2, //!< fd address
54 BUFFER_TYPE_RESERVED
= 1 << 3, //!< reserved type
58 //! Buffer plane number
61 BUFFER_PLANE_NUM_DEFAULT
= 4,
64 //! Buffer virtual address
66 char *p
; //! single address.
67 char *extP
[BUFFER_PLANE_NUM_DEFAULT
]; //! Y Cb Cr.
70 //! Buffer physical address
72 unsigned int p
; //! single address.
73 unsigned int extP
[BUFFER_PLANE_NUM_DEFAULT
]; //! Y Cb Cr.
76 //! Buffer file descriptors
78 int fd
; //! single address.
79 int extFd
[BUFFER_PLANE_NUM_DEFAULT
]; //! Y Cb Cr.
82 //! Buffer reserved id
85 int extP
[BUFFER_PLANE_NUM_DEFAULT
]; //! \n
91 unsigned int extS
[BUFFER_PLANE_NUM_DEFAULT
];
98 for (int i
= 0; i
< BUFFER_PLANE_NUM_DEFAULT
; i
++) {
99 virt
. extP
[i
] = NULL
;
102 reserved
.extP
[i
] = 0;
108 ExynosBuffer(const ExynosBuffer
*other
)
110 for (int i
= 0; i
< BUFFER_PLANE_NUM_DEFAULT
; i
++) {
111 virt
. extP
[i
] = other
->virt
.extP
[i
];
112 phys
. extP
[i
] = other
->phys
.extP
[i
];
113 fd
. extFd
[i
] = other
->fd
.extFd
[i
];
114 reserved
.extP
[i
] = other
->reserved
.extP
[i
];
115 size
. extS
[i
] = other
->size
.extS
[i
];
119 //! Operator(=) override
120 ExynosBuffer
& operator =(const ExynosBuffer
&other
)
122 for (int i
= 0; i
< BUFFER_PLANE_NUM_DEFAULT
; i
++) {
123 virt
. extP
[i
] = other
.virt
.extP
[i
];
124 phys
. extP
[i
] = other
.phys
.extP
[i
];
125 fd
. extFd
[i
] = other
.fd
.extFd
[i
];
126 reserved
.extP
[i
] = other
.reserved
.extP
[i
];
127 size
. extS
[i
] = other
.size
.extS
[i
];
132 //! Operator(==) override
133 bool operator ==(const ExynosBuffer
&other
) const
137 for (int i
= 0; i
< BUFFER_PLANE_NUM_DEFAULT
; i
++) {
138 if ( virt
. extP
[i
] != other
.virt
. extP
[i
]
139 || phys
. extP
[i
] != other
.phys
. extP
[i
]
140 || fd
. extFd
[i
] != other
.fd
. extFd
[i
]
141 || reserved
.extP
[i
] != other
.reserved
.extP
[i
]
142 || size
. extS
[i
] != other
.size
. extS
[i
]) {
151 //! Operator(!=) override
152 bool operator !=(const ExynosBuffer
&other
) const
155 return !(*this == other
);
159 static int BUFFER_TYPE(ExynosBuffer
*buf
)
161 int type
= BUFFER_TYPE_BASE
;
163 type
|= BUFFER_TYPE_VIRT
;
165 type
|= BUFFER_TYPE_PHYS
;
167 type
|= BUFFER_TYPE_FD
;
169 type
|= BUFFER_TYPE_RESERVED
;
176 #endif //EXYNOS_BUFFER_H_