#include <linux/platform_device.h>
#include <linux/slab.h>
#include <linux/rockchip_ion.h>
+#include <linux/uaccess.h>
#include "../ion_priv.h"
#ifdef CONFIG_OF
const char *name;
};
+extern struct ion_handle *ion_handle_get_by_id(struct ion_client *client,
+ int id);
+
static struct ion_heap_desc ion_heap_meta[] = {
{
.id = ION_SYSTEM_HEAP_ID,
static struct ion_platform_data *rockchip_ion_parse_dt(
struct device *dev)
{
- struct device_node *dt_node = dev->of_node;
+ struct device_node *dt_node = dev->of_node;
struct ion_platform_data *pdata = 0;
struct device_node *node;
uint32_t val = 0;
static long rockchip_custom_ioctl (struct ion_client *client, unsigned int cmd,
unsigned long arg)
{
+ pr_info("[%s %d] cmd=%X\n", __func__, __LINE__, cmd);
+
+ switch (cmd) {
+ case ION_IOC_CLEAN_CACHES:
+ case ION_IOC_INV_CACHES:
+ case ION_IOC_CLEAN_INV_CACHES:
+ break;
+ case ION_IOC_GET_PHYS:
+ {
+ struct ion_phys_data data;
+ struct ion_handle *handle;
+ int ret;
+
+ if (copy_from_user(&data, (void __user *)arg,
+ sizeof(struct ion_phys_data)))
+ return -EFAULT;
+
+ handle = ion_handle_get_by_id(client, data.handle);
+ if (IS_ERR(handle))
+ return PTR_ERR(handle);
+
+ ret = ion_phys(client, handle, &data.phys, (size_t *)&data.size);
+ pr_info("ret=%d, phys=0x%X\n", ret, data.phys);
+ if(ret < 0)
+ return ret;
+ if (copy_to_user((void __user *)arg, &data, sizeof(struct ion_phys_data)))
+ return -EFAULT;
+ break;
+ }
+ default:
+ return -ENOTTY;
+ }
+
return 0;
}
#define ION_HEAP(bit) (1 << (bit))
-#define ION_VIDEO_HEAP_NAME "video"
-#define ION_AUDIO_HEAP_NAME "audio"
+#define ION_VIDEO_HEAP_NAME "video"
+#define ION_AUDIO_HEAP_NAME "audio"
#define ION_CAMERA_HEAP_NAME "camera_preview"
-#define ION_IOMMU_HEAP_NAME "iommu"
+#define ION_IOMMU_HEAP_NAME "iommu"
#define ION_VMALLOC_HEAP_NAME "vmalloc"
#define ION_SET_CACHED(__cache) (__cache | ION_FLAG_CACHED)
unsigned int length;
};
+struct ion_phys_data {
+ ion_user_handle_t handle;
+ unsigned long phys;
+ unsigned long size;
+};
+
#define ION_IOC_ROCKCHIP_MAGIC 'R'
/**
- * DOC: ION_IOC_CLEAN_CACHES - clean the caches
- *
* Clean the caches of the handle specified.
*/
#define ION_IOC_CLEAN_CACHES _IOWR(ION_IOC_ROCKCHIP_MAGIC, 0, \
struct ion_flush_data)
/**
- * DOC: ION_IOC_INV_CACHES - invalidate the caches
- *
* Invalidate the caches of the handle specified.
*/
#define ION_IOC_INV_CACHES _IOWR(ION_IOC_ROCKCHIP_MAGIC, 1, \
struct ion_flush_data)
/**
- * DOC: ION_IOC_CLEAN_INV_CACHES - clean and invalidate the caches
- *
* Clean and invalidate the caches of the handle specified.
*/
#define ION_IOC_CLEAN_INV_CACHES _IOWR(ION_IOC_ROCKCHIP_MAGIC, 2, \
struct ion_flush_data)
+/**
+ * Get phys addr of the handle specified.
+ */
+#define ION_IOC_GET_PHYS _IOWR(ION_IOC_ROCKCHIP_MAGIC, 3, \
+ struct ion_phys_data)
+
#endif