/*=========================================================================== * FUNCTION : getBufDef * * DESCRIPTION: query detailed buffer information * * PARAMETERS : * @offset : [input] frame buffer offset * @bufDef : [output] reference to struct to store buffer definition * @index : [input] index of the buffer * * RETURN : int32_t type of status * NO_ERROR -- success * none-zero failure code *==========================================================================*/ int32_t QCamera3Memory::getBufDef(const cam_frame_len_offset_t &offset, mm_camera_buf_def_t &bufDef, uint32_t index) { Mutex::Autolock lock(mLock); if (!mBufferCount) { ALOGE("Memory not allocated"); return NO_INIT; } bufDef.fd = mMemInfo[index].fd; bufDef.frame_len = mMemInfo[index].size; bufDef.mem_info = (void *)this; bufDef.planes_buf.num_planes = (int8_t)offset.num_planes; bufDef.buffer = getPtrLocked(index); bufDef.buf_idx = (uint8_t)index; /* Plane 0 needs to be set separately. Set other planes in a loop */ bufDef.planes_buf.planes[0].length = offset.mp[0].len; bufDef.planes_buf.planes[0].m.userptr = (long unsigned int)mMemInfo[index].fd; bufDef.planes_buf.planes[0].data_offset = offset.mp[0].offset; bufDef.planes_buf.planes[0].reserved[0] = 0; for (int i = 1; i < bufDef.planes_buf.num_planes; i++) { bufDef.planes_buf.planes[i].length = offset.mp[i].len; bufDef.planes_buf.planes[i].m.userptr = (long unsigned int)mMemInfo[i].fd; bufDef.planes_buf.planes[i].data_offset = offset.mp[i].offset; bufDef.planes_buf.planes[i].reserved[0] = bufDef.planes_buf.planes[i-1].reserved[0] + bufDef.planes_buf.planes[i-1].length; } return NO_ERROR; }
/*=========================================================================== * FUNCTION : getPtr * * DESCRIPTION: Return buffer pointer * * PARAMETERS : * @index : index of the buffer * * RETURN : buffer ptr *==========================================================================*/ void *QCamera3HeapMemory::getPtr(int index) { return getPtrLocked(index); }
/*=========================================================================== * FUNCTION : getPtr * * DESCRIPTION: Return buffer pointer. * * PARAMETERS : * @index : index of the buffer * * RETURN : buffer ptr *==========================================================================*/ void *QCamera3GrallocMemory::getPtr(int index) { Mutex::Autolock lock(mLock); return getPtrLocked(index); }