Home | History | Annotate | Download | only in libgralloc1

Lines Matching defs:hnd

192   auto hnd = buf->handle;
193 ALOGD_IF(DEBUG, "FreeBuffer handle:%p", hnd);
195 if (private_handle_t::validate(hnd) != 0) {
196 ALOGE("FreeBuffer: Invalid handle: %p", hnd);
200 if (allocator_->FreeBuffer(reinterpret_cast<void *>(hnd->base), hnd->size, hnd->offset,
201 hnd->fd, buf->ion_handle_main) != 0) {
206 if (allocator_->FreeBuffer(reinterpret_cast<void *>(hnd->base_metadata), meta_size,
207 hnd->offset_metadata, hnd->fd_metadata, buf->ion_handle_meta) != 0) {
211 private_handle_t * handle = const_cast<private_handle_t *>(hnd);
220 void BufferManager::RegisterHandleLocked(const private_handle_t *hnd,
223 auto buffer = std::make_shared<Buffer>(hnd, ion_handle, ion_handle_meta);
224 handles_map_.emplace(std::make_pair(hnd, buffer));
227 gralloc1_error_t BufferManager::ImportHandleLocked(private_handle_t *hnd) {
228 ALOGD_IF(DEBUG, "Importing handle:%p id: %" PRIu64, hnd, hnd->id);
229 int ion_handle = allocator_->ImportBuffer(hnd->fd);
231 ALOGE("Failed to import ion buffer: hnd: %p, fd:%d, id:%" PRIu64, hnd, hnd->fd, hnd->id);
234 int ion_handle_meta = allocator_->ImportBuffer(hnd->fd_metadata);
236 ALOGE("Failed to import ion metadata buffer: hnd: %p, fd:%d, id:%" PRIu64, hnd,
237 hnd->fd, hnd->id);
241 hnd->base = 0;
242 hnd->base_metadata = 0;
243 RegisterHandleLocked(hnd, ion_handle, ion_handle_meta);
248 BufferManager::GetBufferFromHandleLocked(const private_handle_t *hnd) {
249 auto it = handles_map_.find(hnd);
258 private_handle_t *hnd = const_cast<private_handle_t *>(handle);
259 ALOGD_IF(DEBUG, "Map buffer handle:%p id: %" PRIu64, hnd, hnd->id);
261 hnd->base = 0;
262 if (allocator_->MapBuffer(reinterpret_cast<void **>(&hnd->base), hnd->size, hnd->offset,
263 hnd->fd) != 0) {
269 gralloc1_error_t BufferManager::RetainBuffer(private_handle_t const *hnd) {
270 ALOGD_IF(DEBUG, "Retain buffer handle:%p id: %" PRIu64, hnd, hnd->id);
273 auto buf = GetBufferFromHandleLocked(hnd);
277 private_handle_t *handle = const_cast<private_handle_t *>(hnd);
283 gralloc1_error_t BufferManager::ReleaseBuffer(private_handle_t const *hnd) {
284 ALOGD_IF(DEBUG, "Release buffer handle:%p", hnd);
286 auto buf = GetBufferFromHandleLocked(hnd);
288 ALOGE("Could not find handle: %p id: %" PRIu64, hnd, hnd->id);
292 handles_map_.erase(hnd);
300 gralloc1_error_t BufferManager::LockBuffer(const private_handle_t *hnd,
305 ALOGD_IF(DEBUG, "LockBuffer buffer handle:%p id: %" PRIu64, hnd, hnd->id);
312 if (hnd->base == 0) {
314 err = MapBuffer(hnd);
317 auto buf = GetBufferFromHandleLocked(hnd);
327 if (!err && (hnd->flags & private_handle_t::PRIV_FLAGS_USES_ION) &&
328 (hnd->flags & private_handle_t::PRIV_FLAGS_CACHED)) {
329 if (allocator_->CleanBuffer(reinterpret_cast<void *>(hnd->base), hnd->size, hnd->offset,
337 private_handle_t *handle = const_cast<private_handle_t *>(hnd);
348 private_handle_t *hnd = const_cast<private_handle_t *>(handle);
349 auto buf = GetBufferFromHandleLocked(hnd);
354 if (hnd->flags & private_handle_t::PRIV_FLAGS_NEEDS_FLUSH) {
355 if (allocator_->CleanBuffer(reinterpret_cast<void *>(hnd->base), hnd->size, hnd->offset,
359 hnd->flags &= ~private_handle_t::PRIV_FLAGS_NEEDS_FLUSH;
509 private_handle_t *hnd = new private_handle_t(data.fd,
522 hnd->id = ++next_id_;
523 hnd->base = 0;
524 hnd->base_metadata = 0;
525 hnd->layer_count = layer_count;
528 setMetaData(hnd, UPDATE_COLOR_SPACE, reinterpret_cast<void *>(&colorSpace));
529 *handle = hnd;
530 RegisterHandleLocked(hnd, data.ion_handle, e_data.ion_handle);
531 ALOGD_IF(DEBUG, "Allocated buffer handle: %p id: %" PRIu64, hnd, hnd->id);
533 private_handle_t::Dump(hnd);
550 private_handle_t *hnd = reinterpret_cast<private_handle_t *>(
552 if (hnd) {
554 hnd->magic = private_handle_t::kMagic;
555 hnd->fd = fd;
556 hnd->flags = private_handle_t::PRIV_FLAGS_USES_ION;
557 hnd->size = size;
558 hnd->offset = offset;
559 hnd->base = uint64_t(base) + offset;
560 hnd->gpuaddr = 0;
563 hnd->unaligned_width = width;
564 hnd->unaligned_height = height;
565 hnd->width = INT(alignedw);
566 hnd->height = INT(alignedh);
567 hnd->format = format;
568 *handle = reinterpret_cast<native_handle_t *>(hnd);
583 private_handle_t *hnd = va_arg(args, private_handle_t *);
585 if (private_handle_t::validate(hnd) != 0) {
590 if (getMetaData(hnd, GET_BUFFER_GEOMETRY, &buffer_dim) == 0) {
593 *stride = hnd->width;
599 private_handle_t *hnd = va_arg(args, private_handle_t *);
602 if (private_handle_t::validate(hnd) != 0) {
607 if (getMetaData(hnd, GET_BUFFER_GEOMETRY, &buffer_dim) == 0) {
611 *stride = hnd->width;
612 *height = hnd->height;
640 private_handle_t *hnd = va_arg(args, private_handle_t *);
642 if (private_handle_t::validate(hnd) != 0) {
648 if (getMetaData(hnd, GET_COLOR_METADATA, &color_metadata) == 0) {
666 if (getMetaData(hnd, GET_COLOR_SPACE, &color_metadata) != 0) {
672 private_handle_t *hnd = va_arg(args, private_handle_t *);
674 if (private_handle_t::validate(hnd) != 0) {
677 if (allocator_->GetYUVPlaneInfo(hnd, ycbcr)) {
683 private_handle_t *hnd = va_arg(args, private_handle_t *);
685 if (private_handle_t::validate(hnd) != 0) {
689 if (getMetaData(hnd, GET_MAP_SECURE_BUFFER, map_secure_buffer) == 0) {
695 private_handle_t *hnd = va_arg(args, private_handle_t *);
697 if (private_handle_t::validate(hnd) != 0) {
700 *flag = hnd->flags &private_handle_t::PRIV_FLAGS_UBWC_ALIGNED;
704 private_handle_t *hnd = va_arg(args, private_handle_t *);
706 if (private_handle_t::validate(hnd) != 0) {
709 if (allocator_->GetRgbDataAddress(hnd, rgb_data)) {
740 buffer_handle_t *hnd = va_arg(args, buffer_handle_t*);
747 AllocateBuffer(descriptor, hnd, size);
756 static bool IsYuvFormat(const private_handle_t *hnd) {
757 switch (hnd->format) {
777 gralloc1_error_t BufferManager::GetNumFlexPlanes(const private_handle_t *hnd,
779 if (!IsYuvFormat(hnd)) {
787 gralloc1_error_t BufferManager::GetFlexLayout(const private_handle_t *hnd,
789 if (!IsYuvFormat(hnd)) {
794 int err = allocator_->GetYUVPlaneInfo(hnd, &ycbcr);
831 auto hnd = buf->handle;
832 *os << "handle id: " << std::setw(4) << hnd->id;
833 *os << " fd: " << std::setw(3) << hnd->fd;
834 *os << " fd_meta: " << std::setw(3) << hnd->fd_metadata;
835 *os << " wxh: " << std::setw(4) << hnd->width <<" x " << std::setw(4) << hnd->height;
836 *os << " uwxuh: " << std::setw(4) << hnd->unaligned_width << " x ";
837 *os << std::setw(4) << hnd->unaligned_height;
838 *os << " size: " << std::setw(9) << hnd->size;
840 *os << " priv_flags: " << "0x" << std::setw(8) << hnd->flags;
841 *os << " prod_usage: " << "0x" << std::setw(8) << hnd->producer_usage;
842 *os << " cons_usage: " << "0x" << std::setw(8) << hnd->consumer_usage;
844 *os << " format: " << "0x" << std::setw(8) << hnd->format;