#ifdef CONFIG_USB_ANDROID
#include <linux/usb/android_composite.h>
#endif
+#include <linux/ion.h>
#include <mach/hardware.h>
#include <asm/setup.h>
};
#endif
+#ifdef CONFIG_ION
+static struct ion_platform_data rk29_ion_pdata = {
+ .nr = 1,
+ .heaps = {
+ {
+ .type = ION_HEAP_TYPE_CARVEOUT,
+ .id = 0,
+ .name = "ui",
+ .base = PMEM_UI_BASE,
+ .size = PMEM_UI_SIZE,
+ }
+ },
+};
+
+static struct platform_device rk29_ion_device = {
+ .name = "ion-rockchip",
+ .id = 0,
+ .dev = {
+ .platform_data = &rk29_ion_pdata,
+ },
+};
+#endif
+
#ifdef CONFIG_VIDEO_RK29XX_VOUT
static struct platform_device rk29_v4l2_output_devce = {
.name = "rk29_vout",
#endif
#if PMEM_SKYPE_SIZE > 0
&android_pmem_skype_device,
+#endif
+#ifdef CONFIG_ION
+ &rk29_ion_device,
#endif
&android_pmem_device,
&rk29_vpu_mem_device,
#include <linux/seq_file.h>
#include <linux/uaccess.h>
#include <linux/debugfs.h>
+#include <linux/android_pmem.h>
#include "ion_priv.h"
#define DEBUG
return ret;
}
+static long ion_share_ioctl(struct file *filp, unsigned int cmd, unsigned long arg)
+{
+ struct ion_buffer *buffer = filp->private_data;
+ struct pmem_region region;
+
+ region.offset = buffer->priv_phys;
+ region.len = buffer->size;
+
+ if (copy_to_user((void __user *)arg, ®ion,
+ sizeof(struct pmem_region)))
+ return -EFAULT;
+
+ return 0;
+}
+
static const struct file_operations ion_share_fops = {
.owner = THIS_MODULE,
.release = ion_share_release,
.mmap = ion_share_mmap,
+ .unlocked_ioctl = ion_share_ioctl,
};
static int ion_ioctl_share(struct file *parent, struct ion_client *client,
--- /dev/null
+/*
+ * drivers/gpu/rockchip/rockchip_ion.c
+ *
+ * Copyright (C) 2011 Google, Inc.
+ *
+ * This software is licensed under the terms of the GNU General Public
+ * License version 2, as published by the Free Software Foundation, and
+ * may be copied, distributed, and modified under those terms.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ */
+
+#include <linux/err.h>
+#include <linux/ion.h>
+#include <linux/platform_device.h>
+#include <linux/slab.h>
+#include "../ion_priv.h"
+
+static int num_heaps;
+static struct ion_heap **heaps;
+
+static int rockchip_ion_probe(struct platform_device *pdev)
+{
+ struct ion_device *idev;
+ struct ion_platform_data *pdata = pdev->dev.platform_data;
+ int err;
+ int i;
+
+ num_heaps = pdata->nr;
+ heaps = kzalloc(sizeof(struct ion_heap *) * pdata->nr, GFP_KERNEL);
+
+ idev = ion_device_create(NULL);
+ if (IS_ERR_OR_NULL(idev)) {
+ kfree(heaps);
+ return PTR_ERR(idev);
+ }
+
+ /* create the heaps as specified in the board file */
+ for (i = 0; i < num_heaps; i++) {
+ struct ion_platform_heap *heap_data = &pdata->heaps[i];
+
+ heaps[i] = ion_heap_create(heap_data);
+ if (IS_ERR_OR_NULL(heaps[i])) {
+ err = PTR_ERR(heaps[i]);
+ goto err;
+ }
+ ion_device_add_heap(idev, heaps[i]);
+ }
+ platform_set_drvdata(pdev, idev);
+ return 0;
+err:
+ for (i = 0; i < num_heaps; i++) {
+ if (heaps[i])
+ ion_heap_destroy(heaps[i]);
+ }
+ kfree(heaps);
+ return err;
+}
+
+static int rockchip_ion_remove(struct platform_device *pdev)
+{
+ struct ion_device *idev = platform_get_drvdata(pdev);
+ int i;
+
+ ion_device_destroy(idev);
+ for (i = 0; i < num_heaps; i++)
+ ion_heap_destroy(heaps[i]);
+ kfree(heaps);
+ return 0;
+}
+
+static struct platform_driver ion_driver = {
+ .probe = rockchip_ion_probe,
+ .remove = rockchip_ion_remove,
+ .driver = { .name = "ion-rockchip" }
+};
+
+static int __init ion_init(void)
+{
+ return platform_driver_register(&ion_driver);
+}
+
+static void __exit ion_exit(void)
+{
+ platform_driver_unregister(&ion_driver);
+}
+
+module_init(ion_init);
+module_exit(ion_exit);
+