1 /*
2 * dma_video_buffer.cpp - dma buffer
3 *
4 * Copyright (c) 2016 Intel Corporation
5 * Copyright (c) 2021 Rockchip Corporation
6 *
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
10 *
11 * http://www.apache.org/licenses/LICENSE-2.0
12 *
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 *
19 * Author: Wind Yuan <feng.yuan@intel.com>
20 * Author: Cody Xie <cody.xie@rock-chips.com>
21 */
22
23 #include "dma_video_buffer.h"
24
25 #include "xcam_log.h"
26
27 namespace XCam {
28
DmaVideoBuffer(const VideoBufferInfo & info,int dma_fd,bool need_close_fd)29 DmaVideoBuffer::DmaVideoBuffer(const VideoBufferInfo& info, int dma_fd, bool need_close_fd)
30 : DmaBuffer(dma_fd, info.size), VideoBuffer(info), _need_close_fd(need_close_fd) {
31 XCAM_ASSERT(dma_fd >= 0);
32 }
33
~DmaVideoBuffer()34 DmaVideoBuffer::~DmaVideoBuffer() {
35 if (!_need_close_fd) (void)(DmaBuffer::release());
36 }
37
map()38 uint8_t* DmaVideoBuffer::map() { return static_cast<uint8_t*>(DmaBuffer::map()); }
39
unmap()40 bool DmaVideoBuffer::unmap() {
41 DmaBuffer::unmap();
42 return true;
43 }
44
get_fd()45 int DmaVideoBuffer::get_fd() { return DmaBuffer::getFd(); }
46
47 } // namespace XCam
48