forked from EnJens/vendor-sony-oss-fingerprint
-
Notifications
You must be signed in to change notification settings - Fork 30
/
DmaBuffer.cpp
37 lines (29 loc) · 839 Bytes
/
DmaBuffer.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include "DmaBuffer.h"
#include <errno.h>
#include <fcntl.h>
#include <sys/mman.h>
#define LOG_TAG "FPC DmaBuffer"
#include <log/log.h>
DmaBuffer::DmaBuffer(BufferAllocator &allocator, size_t len) : len(len) {
allocFd = allocator.Alloc(DMABUF_QCOM_QSEECOM_HEAP_NAME, len);
LOG_ALWAYS_FATAL_IF(allocFd < 0, "Failed to allocate DMA heap buffer on qseecom heap");
map = mmap(NULL, len, PROT_READ | PROT_WRITE, MAP_SHARED, allocFd, 0);
ALOGD("Mapped %p", map);
LOG_ALWAYS_FATAL_IF(!map, "Failed to map DMA heap buffer");
}
DmaBuffer::~DmaBuffer() {
munmap(map, len);
close(allocFd);
}
size_t DmaBuffer::requestedSize() const {
return len;
}
int DmaBuffer::fd() const {
return allocFd;
}
void *DmaBuffer::operator()() {
return map;
}
const void *DmaBuffer::operator()() const {
return map;
}