long omap_ion_ioctl(struct ion_client *client, unsigned int cmd, unsigned long arg) { switch (cmd) { case OMAP_ION_TILER_ALLOC: { struct omap_ion_tiler_alloc_data data; int ret; if (!tiler_heap) { pr_err("%s: Tiler heap requested but no tiler " "heap exists on this platform\n", __func__); return -EINVAL; } if (copy_from_user(&data, (void __user *)arg, sizeof(data))) return -EFAULT; ret = omap_ion_tiler_alloc(client, &data); if (ret) return ret; if (copy_to_user((void __user *)arg, &data, sizeof(data))) return -EFAULT; break; } default: pr_err("%s: Unknown custom ioctl\n", __func__); return -ENOTTY; } return 0; }
static uint32_t tiler_alloc( int size ) { int res; struct omap_ion_tiler_alloc_data alloc_data = { .w = size, .h = 1, .fmt = TILER_PIXEL_FMT_PAGE, .flags = 0, }; struct alloc_t *alloc = get_alloc(); if( !alloc ) { return 0; } res = omap_ion_tiler_alloc(imt_ion_client, &alloc_data); if (res < 0) { ERR("imt: could not alloc %d\n", res); return 0; } else { ion_phys_addr_t phys; size_t len; ion_phys(imt_ion_client, alloc_data.handle, &phys, &len); DBG2("imt: ion: siz %8d %08X phys %08lX len %8d", size, (unsigned int)alloc_data.handle, phys, (int)len ); alloc->phys = phys; alloc->handle = alloc_data.handle; return phys; } } static void tiler_free( uint32_t data ) { struct ion_handle *handle = put_alloc( (ion_phys_addr_t)data ); if( handle ) { ion_free(imt_ion_client, handle); } } static void free_all( void ) { int i; for( i = 0; i < MAX_ALLOC; i++ ) { if( alloc_list[i].handle ) { DBG("imt: cleanup[%d] %08X phys %08lX", i, (unsigned int)alloc_list[i].handle, alloc_list[i].phys); ion_free(imt_ion_client, alloc_list[i].handle); alloc_list[i].handle = NULL; alloc_list[i].phys = 0; } } }