本文整理汇总了C++中ION_HEAP函数的典型用法代码示例。如果您正苦于以下问题:C++ ION_HEAP函数的具体用法?C++ ION_HEAP怎么用?C++ ION_HEAP使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了ION_HEAP函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: res_trk_close_secure_session
int res_trk_close_secure_session()
{
int rc;
if (res_trk_check_for_sec_session() == 1 &&
resource_context.sec_clk_heap) {
pr_err("Unsecuring....\n");
mutex_lock(&resource_context.secure_lock);
rc = res_trk_enable_iommu_clocks();
if (rc) {
pr_err("IOMMU clock enabled failed while close\n");
goto error_close;
}
msm_ion_unsecure_heap(ION_HEAP(resource_context.cmd_mem_type));
msm_ion_unsecure_heap(ION_HEAP(resource_context.memtype));
if (resource_context.vidc_platform_data->secure_wb_heap)
msm_ion_unsecure_heap(ION_HEAP(ION_CP_WB_HEAP_ID));
res_trk_disable_iommu_clocks();
resource_context.sec_clk_heap = 0;
mutex_unlock(&resource_context.secure_lock);
}
return 0;
error_close:
mutex_unlock(&resource_context.secure_lock);
return rc;
}
开发者ID:a937287837,项目名称:android_kernel_htc_m7wlj,代码行数:27,代码来源:vcd_res_tracker.c
示例2: res_trk_get_mem_type
int res_trk_get_mem_type(void)
{
int mem_type = -1;
switch (resource_context.res_mem_type) {
case DDL_FW_MEM:
mem_type = ION_HEAP(resource_context.fw_mem_type);
return mem_type;
case DDL_MM_MEM:
mem_type = resource_context.memtype;
break;
case DDL_CMD_MEM:
if (res_trk_check_for_sec_session())
mem_type = resource_context.cmd_mem_type;
else
mem_type = resource_context.memtype;
break;
default:
return mem_type;
}
if (resource_context.vidc_platform_data->enable_ion) {
if (res_trk_check_for_sec_session()) {
mem_type = ION_HEAP(mem_type);
if (resource_context.res_mem_type != DDL_FW_MEM)
mem_type |= ION_SECURE;
else if (res_trk_is_cp_enabled())
mem_type |= ION_SECURE;
} else
mem_type = (ION_HEAP(mem_type) |
ION_HEAP(ION_IOMMU_HEAP_ID));
}
return mem_type;
}
开发者ID:a937287837,项目名称:android_kernel_htc_m7wlj,代码行数:32,代码来源:vcd_res_tracker.c
示例3: alloc_ion_mem
int alloc_ion_mem(unsigned int size)
{
if (!overlay_supported)
return -EINVAL;
int result;
struct ion_fd_data fd_data;
struct ion_allocation_data ionAllocData;
mem_info.ion_fd = open("/dev/ion", O_RDWR|O_DSYNC);
if (mem_info.ion_fd < 0) {
perror("ERROR: Can't open ion ");
return -errno;
}
ionAllocData.flags = 0;
ionAllocData.len = size;
ionAllocData.align = sysconf(_SC_PAGESIZE);
#ifdef NEW_ION_HEAP
ionAllocData.heap_id_mask =
#else
ionAllocData.heap_mask =
#endif
ION_HEAP(ION_IOMMU_HEAP_ID) |
ION_HEAP(ION_SYSTEM_CONTIG_HEAP_ID);
result = ioctl(mem_info.ion_fd, ION_IOC_ALLOC, &ionAllocData);
if(result){
perror("ION_IOC_ALLOC Failed ");
close(mem_info.ion_fd);
return result;
}
fd_data.handle = ionAllocData.handle;
mem_info.handle_data.handle = ionAllocData.handle;
result = ioctl(mem_info.ion_fd, ION_IOC_MAP, &fd_data);
if (result) {
perror("ION_IOC_MAP Failed ");
free_ion_mem();
return result;
}
mem_info.mem_buf = (unsigned char *)mmap(NULL, size, PROT_READ |
PROT_WRITE, MAP_SHARED, fd_data.fd, 0);
mem_info.mem_fd = fd_data.fd;
if (!mem_info.mem_buf) {
perror("ERROR: mem_buf MAP_FAILED ");
free_ion_mem();
return -ENOMEM;
}
return 0;
}
开发者ID:Skin1980,项目名称:TWRP,代码行数:52,代码来源:graphics_overlay.c
示例4: alloc_ion_mem
static int alloc_ion_mem(struct fb_qcom_overlay_data *data, unsigned int size)
{
int result;
struct ion_fd_data fd_data;
struct ion_allocation_data ionAllocData;
data->ion_fd = open("/dev/ion", O_RDWR|O_DSYNC);
if (data->ion_fd < 0)
{
ERROR("ERROR: Can't open ion ");
return -errno;
}
ionAllocData.flags = 0;
ionAllocData.len = size;
ionAllocData.align = sysconf(_SC_PAGESIZE);
ionAllocData.heap_mask =
ION_HEAP(ION_IOMMU_HEAP_ID) |
ION_HEAP(21); // ION_SYSTEM_CONTIG_HEAP_ID
result = ioctl(data->ion_fd, ION_IOC_ALLOC, &ionAllocData);
if(result)
{
ERROR("ION_IOC_ALLOC Failed ");
close(data->ion_fd);
return result;
}
fd_data.handle = ionAllocData.handle;
data->handle_data.handle = ionAllocData.handle;
result = ioctl(data->ion_fd, ION_IOC_MAP, &fd_data);
if (result)
{
ERROR("ION_IOC_MAP Failed ");
free_ion_mem(data);
return result;
}
data->mem_buf = (uint8_t*)mmap(NULL, size, PROT_READ |
PROT_WRITE, MAP_SHARED, fd_data.fd, 0);
data->mem_fd = fd_data.fd;
if (!data->mem_buf)
{
ERROR("ERROR: mem_buf MAP_FAILED ");
free_ion_mem(data);
return -ENOMEM;
}
return 0;
}
开发者ID:Ever-Never,项目名称:multirom,代码行数:50,代码来源:framebuffer_qcom_overlay.c
示例5: ion_unsecure_heap
int ion_unsecure_heap(struct ion_device *dev, int heap_id, int version,
void *data)
{
struct rb_node *n;
int ret_val = 0;
/*
* traverse the list of heaps available in this system
* and find the heap that is specified.
*/
mutex_lock(&dev->lock);
for (n = rb_first(&dev->heaps); n != NULL; n = rb_next(n)) {
struct ion_heap *heap = rb_entry(n, struct ion_heap, node);
if (heap->type != ION_HEAP_TYPE_CP)
continue;
if (ION_HEAP(heap->id) != heap_id)
continue;
if (heap->ops->secure_heap)
ret_val = heap->ops->unsecure_heap(heap, version, data);
else
ret_val = -EINVAL;
break;
}
mutex_unlock(&dev->lock);
return ret_val;
}
开发者ID:Jarbu12,项目名称:Xperia-M-Kernel,代码行数:26,代码来源:ion.c
示例6: alloc_ion_mem
static int alloc_ion_mem(struct smem_client *client, size_t size,
u32 align, u32 flags, struct msm_smem *mem)
{
struct ion_handle *hndl;
size_t len;
int rc = 0;
flags = flags | ION_HEAP(ION_CP_MM_HEAP_ID);
hndl = ion_alloc(client->clnt, size, align, flags);
if (IS_ERR_OR_NULL(hndl)) {
pr_err("Failed to allocate shared memory = %p, %d, %d, 0x%x\n",
client, size, align, flags);
rc = -ENOMEM;
goto fail_shared_mem_alloc;
}
mem->mem_type = client->mem_type;
mem->smem_priv = hndl;
if (ion_phys(client->clnt, hndl, &mem->paddr, &len)) {
pr_err("Failed to get physical address\n");
rc = -EIO;
goto fail_map;
}
mem->device_addr = mem->paddr;
mem->size = size;
mem->kvaddr = ion_map_kernel(client->clnt, hndl, 0);
if (!mem->kvaddr) {
pr_err("Failed to map shared mem in kernel\n");
rc = -EIO;
goto fail_map;
}
return rc;
fail_map:
ion_free(client->clnt, hndl);
fail_shared_mem_alloc:
return rc;
}
开发者ID:thedancomplex,项目名称:BMW-OpenSource,代码行数:35,代码来源:msm_smem.c
示例7: ion_secure_heap
int ion_secure_heap(struct ion_device *dev, int heap_id, int version,
void *data)
{
struct rb_node *n;
int ret_val = 0;
/*
* traverse the list of heaps available in this system
* and find the heap that is specified.
*/
#if defined(CONFIG_MACH_LGE_L9II_OPEN_EU)
down_write(&dev->lock);
#else
mutex_lock(&dev->lock);
#endif
for (n = rb_first(&dev->heaps); n != NULL; n = rb_next(n)) {
struct ion_heap *heap = rb_entry(n, struct ion_heap, node);
if (heap->type != ION_HEAP_TYPE_CP)
continue;
if (ION_HEAP(heap->id) != heap_id)
continue;
if (heap->ops->secure_heap)
ret_val = heap->ops->secure_heap(heap, version, data);
else
ret_val = -EINVAL;
break;
}
#if defined(CONFIG_MACH_LGE_L9II_OPEN_EU)
up_write(&dev->lock);
#else
mutex_unlock(&dev->lock);
#endif
return ret_val;
}
开发者ID:Rondeau7,项目名称:android_kernel_lge_msm8960,代码行数:34,代码来源:ion.c
示例8: alloc_ion_mem
static int alloc_ion_mem(struct smem_client *client, size_t size,
u32 align, u32 flags, int domain, int partition,
struct msm_smem *mem)
{
struct ion_handle *hndl;
unsigned long iova = 0;
unsigned long buffer_size = 0;
unsigned long ionflags = 0;
unsigned long heap_mask = 0;
int rc = 0;
if (flags == SMEM_CACHED)
ionflags = ION_SET_CACHED(ionflags);
else
ionflags = ION_SET_UNCACHED(ionflags);
heap_mask = ION_HEAP(ION_CP_MM_HEAP_ID);
if (align < 4096)
align = 4096;
size = (size + 4095) & (~4095);
pr_debug("\n in %s domain: %d, Partition: %d\n",
__func__, domain, partition);
hndl = ion_alloc(client->clnt, size, align, heap_mask, ionflags);
if (IS_ERR_OR_NULL(hndl)) {
pr_err("Failed to allocate shared memory = %p, %d, %d, 0x%x\n",
client, size, align, ionflags);
rc = -ENOMEM;
goto fail_shared_mem_alloc;
}
mem->mem_type = client->mem_type;
mem->smem_priv = hndl;
mem->domain = domain;
mem->partition_num = partition;
mem->kvaddr = ion_map_kernel(client->clnt, hndl);
if (!mem->kvaddr) {
pr_err("Failed to map shared mem in kernel\n");
rc = -EIO;
goto fail_map;
}
rc = get_device_address(client->clnt, hndl, mem->domain,
mem->partition_num, align, &iova, &buffer_size);
if (rc) {
pr_err("Failed to get device address: %d\n", rc);
goto fail_device_address;
}
mem->device_addr = iova;
pr_debug("device_address = 0x%lx, kvaddr = 0x%p\n",
mem->device_addr, mem->kvaddr);
mem->size = size;
return rc;
fail_device_address:
ion_unmap_kernel(client->clnt, hndl);
fail_map:
ion_free(client->clnt, hndl);
fail_shared_mem_alloc:
return rc;
}
开发者ID:xIndirect,项目名称:HTC_Jewel_Device,代码行数:56,代码来源:msm_smem.c
示例9: res_trk_close_secure_session
int res_trk_close_secure_session()
{
int rc;
mutex_lock(&resource_context.secure_lock);
rc = res_trk_enable_iommu_clocks();
if (rc) {
pr_err("IOMMU clock enabled failed while close");
goto error_close;
}
msm_ion_unsecure_heap(ION_HEAP(resource_context.memtype));
msm_ion_unsecure_heap(ION_HEAP(resource_context.cmd_mem_type));
res_trk_disable_iommu_clocks();
resource_context.secure_session = 0;
mutex_unlock(&resource_context.secure_lock);
return 0;
error_close:
mutex_unlock(&resource_context.secure_lock);
return rc;
}
开发者ID:marc1706,项目名称:hd2_kernel,代码行数:19,代码来源:vcd_res_tracker.c
示例10: res_trk_open_secure_session
int res_trk_open_secure_session()
{
int rc;
mutex_lock(&resource_context.secure_lock);
if (resource_context.secure_session) {
pr_err("Secure session already open");
rc = -EBUSY;
goto error_open;
}
resource_context.secure_session = 1;
rc = res_trk_enable_iommu_clocks();
if (rc) {
pr_err("IOMMU clock enabled failed while open");
goto error_open;
}
msm_ion_secure_heap(ION_HEAP(resource_context.memtype));
msm_ion_secure_heap(ION_HEAP(resource_context.cmd_mem_type));
res_trk_disable_iommu_clocks();
mutex_unlock(&resource_context.secure_lock);
return 0;
error_open:
mutex_unlock(&resource_context.secure_lock);
return rc;
}
开发者ID:marc1706,项目名称:hd2_kernel,代码行数:24,代码来源:vcd_res_tracker.c
示例11: ION_HEAP
uint8_t *do_mmap_ion(int ion_fd, struct ion_allocation_data *alloc,
struct ion_fd_data *ion_info_fd, int *mapFd)
{
void *ret; /* returned virtual address */
int rc = 0;
struct ion_handle_data handle_data;
/* to make it page size aligned */
alloc->len = (alloc->len + 4095) & (~4095);
#ifdef TARGET_7x27A
alloc->flags = ION_HEAP(CAMERA_ION_HEAP_ID);
#endif
rc = ioctl(ion_fd, ION_IOC_ALLOC, alloc);
if (rc < 0) {
CDBG_ERROR("ION allocation failed\n");
goto ION_ALLOC_FAILED;
}
ion_info_fd->handle = alloc->handle;
rc = ioctl(ion_fd, ION_IOC_SHARE, ion_info_fd);
if (rc < 0) {
CDBG_ERROR("ION map failed %s\n", strerror(errno));
goto ION_MAP_FAILED;
}
*mapFd = ion_info_fd->fd;
ret = mmap(NULL,
alloc->len,
PROT_READ | PROT_WRITE,
MAP_SHARED,
*mapFd,
0);
if (ret == MAP_FAILED) {
CDBG_ERROR("ION_MMAP_FAILED: %s (%d)\n", strerror(errno), errno);
goto ION_MAP_FAILED;
}
return ret;
ION_MAP_FAILED:
handle_data.handle = ion_info_fd->handle;
ioctl(ion_fd, ION_IOC_FREE, &handle_data);
ION_ALLOC_FAILED:
return NULL;
}
开发者ID:tangxl0591,项目名称:camera,代码行数:45,代码来源:cam_mmap.c
示例12: mpq_dmx_channel_mem_alloc
/**
* Allocate memory for channel output of specific TSIF.
*
* @tsif: The TSIF id to which memory should be allocated.
*
* Return error status
*/
static int mpq_dmx_channel_mem_alloc(int tsif)
{
int result;
size_t len;
MPQ_DVB_DBG_PRINT("%s(%d)\n", __func__, tsif);
mpq_dmx_tspp_info.tsif[tsif].ch_mem_heap_handle =
ion_alloc(mpq_dmx_tspp_info.ion_client,
(mpq_dmx_tspp_info.tsif[tsif].buffer_count *
TSPP_DESCRIPTOR_SIZE),
SZ_4K,
ION_HEAP(tspp_out_ion_heap),
0); /* non-cached */
if (IS_ERR_OR_NULL(mpq_dmx_tspp_info.tsif[tsif].ch_mem_heap_handle)) {
MPQ_DVB_ERR_PRINT("%s: ion_alloc() failed\n", __func__);
mpq_dmx_channel_mem_free(tsif);
return -ENOMEM;
}
/* save virtual base address of heap */
mpq_dmx_tspp_info.tsif[tsif].ch_mem_heap_virt_base =
ion_map_kernel(mpq_dmx_tspp_info.ion_client,
mpq_dmx_tspp_info.tsif[tsif].ch_mem_heap_handle);
if (IS_ERR_OR_NULL(mpq_dmx_tspp_info.tsif[tsif].
ch_mem_heap_virt_base)) {
MPQ_DVB_ERR_PRINT("%s: ion_map_kernel() failed\n", __func__);
mpq_dmx_channel_mem_free(tsif);
return -ENOMEM;
}
/* save physical base address of heap */
result = ion_phys(mpq_dmx_tspp_info.ion_client,
mpq_dmx_tspp_info.tsif[tsif].ch_mem_heap_handle,
&(mpq_dmx_tspp_info.tsif[tsif].ch_mem_heap_phys_base), &len);
if (result < 0) {
MPQ_DVB_ERR_PRINT("%s: ion_phys() failed\n", __func__);
mpq_dmx_channel_mem_free(tsif);
return -ENOMEM;
}
return 0;
}
开发者ID:downthemachine,项目名称:arthur_msm-JB-3.4-vanilla,代码行数:51,代码来源:mpq_dmx_plugin_tspp_v1.c
示例13: ion_unsecure_heap
int ion_unsecure_heap(struct ion_device *dev, int heap_id, int version,
void *data)
{
struct rb_node *n;
int ret_val = 0;
mutex_lock(&dev->lock);
for (n = rb_first(&dev->heaps); n != NULL; n = rb_next(n)) {
struct ion_heap *heap = rb_entry(n, struct ion_heap, node);
if (heap->type != ION_HEAP_TYPE_CP)
continue;
if (ION_HEAP(heap->id) != heap_id)
continue;
if (heap->ops->secure_heap)
ret_val = heap->ops->unsecure_heap(heap, version, data);
else
ret_val = -EINVAL;
break;
}
mutex_unlock(&dev->lock);
return ret_val;
}
开发者ID:fulmix,项目名称:fulmix.Kernel,代码行数:22,代码来源:ion.c
示例14: qcom_km_ION_memalloc
static int32_t qcom_km_ION_memalloc(struct qcom_km_ion_info_t *handle,
uint32_t size)
{
int32_t ret = 0;
int32_t iret = 0;
int32_t fd = 0;
unsigned char *v_addr;
struct ion_allocation_data ion_alloc_data;
int32_t ion_fd;
int32_t rc;
struct ion_fd_data ifd_data;
struct ion_handle_data handle_data;
/* open ION device for memory management
* O_DSYNC -> uncached memory
*/
if(handle == NULL){
ALOGE("Error:: null handle received");
return -1;
}
ion_fd = open("/dev/ion", O_RDONLY | O_DSYNC);
if (ion_fd < 0) {
ALOGE("Error::Cannot open ION device");
return -1;
}
handle->ion_sbuffer = NULL;
handle->ifd_data_fd = 0;
/* Size of allocation */
ion_alloc_data.len = (size + 4095) & (~4095);
/* 4K aligned */
ion_alloc_data.align = 4096;
/* memory is allocated from EBI heap */
ion_alloc_data.heap_mask= ION_HEAP(ION_QSECOM_HEAP_ID);
/* Set the memory to be uncached */
ion_alloc_data.flags = 0;
/* IOCTL call to ION for memory request */
rc = ioctl(ion_fd, ION_IOC_ALLOC, &ion_alloc_data);
if (rc) {
ret = -1;
goto alloc_fail;
}
if (ion_alloc_data.handle != NULL) {
ifd_data.handle = ion_alloc_data.handle;
} else {
ret = -1;
goto alloc_fail;
}
/* Call MAP ioctl to retrieve the ifd_data.fd file descriptor */
rc = ioctl(ion_fd, ION_IOC_MAP, &ifd_data);
if (rc) {
ret = -1;
goto ioctl_fail;
}
/* Make the ion mmap call */
v_addr = (unsigned char *)mmap(NULL, ion_alloc_data.len,
PROT_READ | PROT_WRITE,
MAP_SHARED, ifd_data.fd, 0);
if (v_addr == MAP_FAILED) {
ALOGE("Error::ION MMAP failed");
ret = -1;
goto map_fail;
}
handle->ion_fd = ion_fd;
handle->ifd_data_fd = ifd_data.fd;
handle->ion_sbuffer = v_addr;
handle->ion_alloc_handle.handle = ion_alloc_data.handle;
handle->sbuf_len = size;
return ret;
map_fail:
if (handle->ion_sbuffer != NULL) {
iret = munmap(handle->ion_sbuffer, ion_alloc_data.len);
if (iret)
ALOGE("Error::Failed to unmap memory for load image. ret = %d", ret);
}
ioctl_fail:
handle_data.handle = ion_alloc_data.handle;
if (handle->ifd_data_fd)
close(handle->ifd_data_fd);
iret = ioctl(ion_fd, ION_IOC_FREE, &handle_data);
if (iret) {
ALOGE("Error::ION FREE ioctl returned error = %d",iret);
}
alloc_fail:
if (ion_fd > 0)
close(ion_fd);
return ret;
}
开发者ID:IllusionRom-deprecated,项目名称:android_platform_hardware_qcom_keymaster,代码行数:97,代码来源:keymaster_qcom.cpp
示例15: ion_memalloc
static int
ion_memalloc(struct ion_buf_handle *buf, uint32_t size, uint32_t heap)
{
struct ion_allocation_data alloc_data;
struct ion_fd_data fd_data;
unsigned char *va;
struct ion_handle_data handle_data;
int ion_fd;
int rc;
ion_fd = open("/dev/ion", O_RDONLY);
if (ion_fd < 0) {
fprintf(stderr, "Cannot open ION device (%s)\n", strerror(errno));
return -1;
}
alloc_data.len = (size + 4095) & ~4095;
alloc_data.align = 4096;
alloc_data.flags = 0;
alloc_data.heap_id_mask = ION_HEAP(heap);
/* Set the buffers to be uncached */
alloc_data.flags = 0;
rc = ioctl(ion_fd, ION_IOC_ALLOC, &alloc_data);
if (rc) {
fprintf(stderr, "ION buffer allocation failed (%s)\n",
strerror(errno));
goto alloc_fail;
}
if (alloc_data.handle) {
fd_data.handle = alloc_data.handle;
} else {
fprintf(stderr, "ION alloc data returned NULL\n");
rc = -1;
goto alloc_fail;
}
rc = ioctl(ion_fd, ION_IOC_MAP, &fd_data);
if (rc) {
fprintf(stderr, "ION map call failed(%s)\n", strerror(errno));
goto ioctl_fail;
}
va = mmap(NULL, alloc_data.len, PROT_READ | PROT_WRITE,
MAP_SHARED, fd_data.fd, 0);
if (va == MAP_FAILED) {
fprintf(stderr, "ION memory map failed (%s)\n", strerror(errno));
rc = -1;
goto map_fail;
}
buf->ion_fd = ion_fd;
buf->ifd_data_fd = fd_data.fd;
buf->buffer = va;
buf->ion_alloc_handle.handle = alloc_data.handle;
buf->buffer_len = alloc_data.len;
memset(buf->buffer, 0, buf->buffer_len);
return 0;
map_fail:
ioctl_fail:
handle_data.handle = alloc_data.handle;
if (buf->ifd_data_fd)
close(buf->ifd_data_fd);
rc = ioctl(ion_fd, ION_IOC_FREE, &handle_data);
if (rc)
fprintf(stderr, "ION free failed (%s)\n", strerror(errno));
alloc_fail:
if (ion_fd >= 0)
close(ion_fd);
buf->ion_fd = -1;
return rc;
}
开发者ID:cancro-dev,项目名称:device_qcom_common-caf,代码行数:77,代码来源:dec.c
示例16: LOGE
int IonDmaMemManager::createIonBuffer(struct bufferinfo_s* ionbuf)
{
int ret =0,i = 0;
int numBufs;
int frame_size;
camera_ionbuf_t* tmpalloc = NULL;
struct bufferinfo_s* tmp_buf = NULL;
#ifdef ROCKCHIP_ION_VERSION
ion_user_handle_t handle = 0;
#else
struct ion_handle* handle = NULL;
#endif
int map_fd;
long temp_handle = 0;
unsigned long vir_addr = 0;
if (!ionbuf) {
LOGE("ion_alloc malloc buffer failed");
return -1;
}
numBufs = ionbuf->mNumBffers;
frame_size = ionbuf->mPerBuffersize;
ionbuf->mBufferSizes = numBufs*PAGE_ALIGN(frame_size);
switch(ionbuf->mBufType)
{
case PREVIEWBUFFER:
tmpalloc = mPreviewData ;
if((tmp_buf = (struct bufferinfo_s*)malloc(numBufs*sizeof(struct bufferinfo_s))) != NULL){
mPreviewBufferInfo = tmp_buf;
}else{
LOGE("ion_alloc malloc buffer failed");
return -1;
}
break;
case RAWBUFFER:
tmpalloc = mRawData;
if((tmp_buf = (struct bufferinfo_s*)malloc(numBufs*sizeof(struct bufferinfo_s))) != NULL){
mRawBufferInfo = tmp_buf;
}else{
LOGE("ion_alloc malloc buffer failed");
return -1;
}
break;
case JPEGBUFFER:
tmpalloc = mJpegData;
if((tmp_buf = (struct bufferinfo_s*)malloc(numBufs*sizeof(struct bufferinfo_s))) != NULL ){
mJpegBufferInfo = tmp_buf;
}else{
LOGE("ion_alloc malloc buffer failed");
return -1;
}
break;
case VIDEOENCBUFFER:
tmpalloc = mVideoEncData ;
if((tmp_buf = (struct bufferinfo_s*)malloc(numBufs*sizeof(struct bufferinfo_s))) != NULL){
mVideoEncBufferInfo = tmp_buf;
}else{
LOGE("ion_alloc malloc buffer failed");
return -1;
}
break;
default:
return -1;
}
for(i = 0;i < numBufs;i++){
memset(tmpalloc,0,sizeof(struct camera_ionbuf_s));
if((!mIommuEnabled) || (!ionbuf->mIsForceIommuBuf))
ret = ion_alloc(client_fd, ionbuf->mPerBuffersize, PAGE_SIZE, ION_HEAP(ION_CMA_HEAP_ID), 0, &handle);
else
ret = ion_alloc(client_fd, ionbuf->mPerBuffersize, PAGE_SIZE, ION_HEAP(ION_VMALLOC_HEAP_ID), 0, &handle);
if (ret) {
LOGE("ion alloc failed\n");
break;
}
LOG1("handle %d\n", handle);
ret = ion_share(client_fd,handle,&map_fd);
if (ret) {
LOGE("ion map failed\n");
ion_free(client_fd,handle);
break;
}
vir_addr = (unsigned long )mmap(NULL, ionbuf->mPerBuffersize, PROT_READ | PROT_WRITE, MAP_SHARED, map_fd, 0);
if (vir_addr == 0) {
LOGE("ion mmap failed\n");
ret = -1;
ion_free(client_fd,handle);
break;
}
if((!mIommuEnabled) || (!ionbuf->mIsForceIommuBuf))
//.........这里部分代码省略.........
开发者ID:denisigo,项目名称:fireprime_hardware_rockchip,代码行数:101,代码来源:CameraHal_Mem.cpp
示例17: audpcm_in_open
static int audpcm_in_open(struct inode *inode, struct file *file)
{
struct audio_in *audio = &the_audio_in;
int rc;
int len = 0;
unsigned long ionflag = 0;
ion_phys_addr_t addr = 0;
struct ion_handle *handle = NULL;
struct ion_client *client = NULL;
int encid;
mutex_lock(&audio->lock);
if (audio->opened) {
rc = -EBUSY;
goto done;
}
/* Settings will be re-config at AUDIO_SET_CONFIG,
* but at least we need to have initial config
*/
audio->mode = MSM_AUD_ENC_MODE_TUNNEL;
audio->samp_rate = RPC_AUD_DEF_SAMPLE_RATE_11025;
audio->samp_rate_index = AUDREC_CMD_SAMP_RATE_INDX_11025;
audio->channel_mode = AUDREC_CMD_STEREO_MODE_MONO;
audio->buffer_size = MONO_DATA_SIZE;
audio->enc_type = AUDREC_CMD_TYPE_0_INDEX_WAV | audio->mode;
rc = audmgr_open(&audio->audmgr);
if (rc)
goto done;
encid = audpreproc_aenc_alloc(audio->enc_type, &audio->module_name,
&audio->queue_ids);
if (encid < 0) {
MM_ERR("No free encoder available\n");
rc = -ENODEV;
goto done;
}
audio->enc_id = encid;
rc = msm_adsp_get(audio->module_name, &audio->audrec,
&audrec_adsp_ops, audio);
if (rc) {
audpreproc_aenc_free(audio->enc_id);
goto done;
}
rc = msm_adsp_get("AUDPREPROCTASK", &audio->audpre,
&audpre_adsp_ops, audio);
if (rc) {
msm_adsp_put(audio->audrec);
audpreproc_aenc_free(audio->enc_id);
goto done;
}
audio->dsp_cnt = 0;
audio->stopped = 0;
audpcm_in_flush(audio);
client = msm_ion_client_create(UINT_MAX, "Audio_PCM_in_client");
if (IS_ERR_OR_NULL(client)) {
MM_ERR("Unable to create ION client\n");
rc = -ENOMEM;
goto client_create_error;
}
audio->client = client;
MM_DBG("allocating mem sz = %d\n", DMASZ);
handle = ion_alloc(client, DMASZ, SZ_4K,
ION_HEAP(ION_AUDIO_HEAP_ID), 0);
if (IS_ERR_OR_NULL(handle)) {
MM_ERR("Unable to create allocate O/P buffers\n");
rc = -ENOMEM;
goto output_buff_alloc_error;
}
audio->output_buff_handle = handle;
rc = ion_phys(client , handle, &addr, &len);
if (rc) {
MM_ERR("O/P buffers:Invalid phy: %x sz: %x\n",
(unsigned int) addr, (unsigned int) len);
rc = -ENOMEM;
goto output_buff_get_phys_error;
} else {
MM_INFO("O/P buffers:valid phy: %x sz: %x\n",
(unsigned int) addr, (unsigned int) len);
}
audio->phys = (int32_t)addr;
rc = ion_handle_get_flags(client, handle, &ionflag);
if (rc) {
MM_ERR("could not get flags for the handle\n");
rc = -ENOMEM;
goto output_buff_get_flags_error;
}
audio->data = ion_map_kernel(client, handle);
if (IS_ERR(audio->data)) {
MM_ERR("could not map read buffers,freeing instance 0x%08x\n",
//.........这里部分代码省略.........
开发者ID:Adrioid83,项目名称:GT-I9505,代码行数:101,代码来源:audio_pcm_in.c
示例18: ARRAY_SIZE
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
#include <sys/types.h>
#include <ctype.h>
#include <linux/input.h>
#include <linux/msm_ion.h>
#include <sys/mman.h>
#include "ion_test_plan.h"
#include "ion_test_utils.h"
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
static struct ion_test_data mm_heap_test = {
.align = 0x1000,
.size = 0x1000,
.heap_mask = ION_HEAP(ION_CP_MM_HEAP_ID),
};
static struct ion_test_data adv_mm_heap_test = {
.align = 0x1000,
.size = 0xC0000000,
.heap_mask = ION_HEAP(ION_CP_MM_HEAP_ID),
};
static struct ion_test_data adv_system_heap_test = {
.align = 0x1000,
.size = 0x1000,
.heap_mask = ION_HEAP(ION_SYSTEM_HEAP_ID),
};
static struct ion_test_data *mm_heap_data_settings[] = {
[NOMINAL_TEST] = &mm_heap_test,
[ADV_TEST] = &adv_mm_heap_test,
开发者ID:XperiaZProject,项目名称:Sony_Vendor,代码行数:31,代码来源:kernel_ion_tests.c
示例19: apr_pmem_alloc_ion_uncached
void apr_pmem_alloc_ion_uncached(struct mmap_info_ion *pmapion, uint32_t ionheapid) {
struct ion_handle_data handle_data;
struct ion_allocation_data alloc;
struct ion_client *ion_client;
struct ion_handle *ion_handle;
int32_t rc;
int32_t ion_fd;
uint32_t ret;
int32_t p_pmem_fd;
struct ion_fd_data ion_info_fd;
struct ion_fd_data test_fd;
struct ion_custom_data data;
ion_fd = open("/dev/ion", O_RDONLY);
if (ion_fd < 0) {
CDBG_ERROR("\n apr_pmem_alloc_ion : Open ion device failed");
pmapion->pVirtualAddr = NULL;
return;
}
alloc.len = pmapion->bufsize;
alloc.align = 4096;
alloc.heap_mask = ionheapid;
if (ionheapid == ION_HEAP(ION_CP_MM_HEAP_ID)) {
alloc.flags = ION_SECURE;
} else {
alloc.flags = 0;
}
rc = ioctl(ion_fd, ION_IOC_ALLOC, &alloc);
if (rc < 0) {
handle_data.handle = (pmapion->ion_info_fd).handle;
CDBG_ERROR("\n apr_pmem_alloc_ion : ION alloc length %d %d", rc,
alloc.len);
close(ion_fd);
pmapion->pVirtualAddr = NULL;
return;
} else {
pmapion->ion_info_fd.handle = alloc.handle;
rc = ioctl(ion_fd, ION_IOC_SHARE, &(pmapion->ion_info_fd));
if (rc < 0) {
CDBG_ERROR("\n apr_pmem_alloc_ion : ION map call failed %d", rc);
handle_data.handle = pmapion->ion_info_fd.handle;
ioctl(ion_fd, ION_IOC_FREE, &handle_data);
close(ion_fd);
pmapion->pVirtualAddr = NULL;
return;
} else {
p_pmem_fd = pmapion->ion_info_fd.fd;
ret = (uint32_t)mmap(NULL,
alloc.len,
PROT_READ | PROT_WRITE,
MAP_SHARED,
p_pmem_fd,
0);
if (ret == (uint32_t)MAP_FAILED) {
CDBG_ERROR("\n apr_pmem_alloc_ion : mmap call failed %d", rc);
handle_data.handle = (pmapion->ion_info_fd).handle;
ioctl(ion_fd, ION_IOC_FREE, &handle_data);
close(ion_fd);
pmapion->pVirtualAddr = NULL;
return;
} else {
CDBG_ERROR("\n Ion allocation success virtaddr : %u fd %u",
(uint32_t)ret,
(uint32_t)p_pmem_fd);
data.cmd = p_pmem_fd;
pmapion->pVirtualAddr = (void *)ret;
pmapion->ion_fd = ion_fd;
}
}
}
return;
}
开发者ID:xingrz,项目名称:android_tools_leeco_msm8996,代码行数:76,代码来源:apr_pmem.c
示例20: alloc_ion_mem
static int alloc_ion_mem(struct smem_client *client, size_t size, u32 align,
u32 flags, enum hal_buffer buffer_type, struct msm_smem *mem,
int map_kernel)
{
struct ion_handle *hndl;
unsigned long iova = 0;
unsigned long buffer_size = 0;
unsigned long heap_mask = 0;
int rc = 0;
align = ALIGN(align, SZ_4K);
size = ALIGN(size, SZ_4K);
if (flags & SMEM_SECURE) {
size = ALIGN(size, SZ_1M);
align = ALIGN(align, SZ_1M);
}
if (is_iommu_present(client->res)) {
heap_mask = ION_HEAP(ION_IOMMU_HEAP_ID);
} else {
dprintk(VIDC_DBG,
"allocate shared memory from adsp heap size %d align %d\n",
size, align);
heap_mask = ION_HEAP(ION_ADSP_HEAP_ID);
}
if (flags & SMEM_SECURE)
heap_mask = ION_HEAP(ION_CP_MM_HEAP_ID);
hndl = ion_alloc(client->clnt, size, align, heap_mask, flags);
if (IS_ERR_OR_NULL(hndl)) {
dprintk(VIDC_ERR,
"Failed to allocate shared memory = %p, %d, %d, 0x%x\n",
client, size, align, flags);
rc = -ENOMEM;
goto fail_shared_mem_alloc;
}
mem->mem_type = client->mem_type;
mem->smem_priv = hndl;
mem->flags = flags;
mem->buffer_type = buffer_type;
if (map_kernel) {
mem->kvaddr = ion_map_kernel(client->clnt, hndl);
if (!mem->kvaddr) {
dprintk(VIDC_ERR,
"Failed to map shared mem in kernel\n");
rc = -EIO;
goto fail_map;
}
} else
mem->kvaddr = NULL;
rc = get_device_address(client, hndl, align, &iova, &buffer_size,
flags, buffer_type);
if (rc) {
dprintk(VIDC_ERR, "Failed to get device address: %d\n",
rc);
goto fail_device_address;
}
mem->device_addr = iova;
dprintk(VIDC_DBG,
"device_address = 0x%lx, kvaddr = 0x%p, size = %d\n",
mem->device_addr, mem->kvaddr, size);
mem->size = size;
return rc;
fail_device_address:
ion_unmap_kernel(client->clnt, hndl);
fail_map:
ion_free(client->clnt, hndl);
fail_shared_mem_alloc:
return rc;
}
开发者ID:AbdulrahmanAmir,项目名称:Dorimanx-LG-G2-D802-Kernel,代码行数:73,代码来源:msm_smem.c
注:本文中的ION_HEAP函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论