rk: ion: change heap id
authorCMY <cmy@rock-chips.com>
Fri, 21 Feb 2014 01:23:35 +0000 (09:23 +0800)
committerCMY <cmy@rock-chips.com>
Fri, 21 Feb 2014 07:41:11 +0000 (15:41 +0800)
arch/arm/boot/dts/rk3188.dtsi
drivers/staging/android/ion/rockchip/rockchip_ion.c
drivers/video/rockchip/rk_fb.c
include/linux/rockchip_ion.h

index 76c10266e8f2baf24fa331ed0d682988228694ca..e2df5022e5b42ac18bff02d8779f9a8affc06f0f 100755 (executable)
                compatible = "rockchip,ion";
                #address-cells = <1>;
                #size-cells = <0>;
-               rockchip,ion-heap@1 { /* VIDEO HEAP */
+               rockchip,ion-heap@1 { /* CMA HEAP */
                        reg = <1>;
                };
        };
index 903562e67194572c5c72f68ffe7d7ed2e293fc0c..a91dfe6911cdfb2f4924707b0adc386f517d923c 100755 (executable)
@@ -42,29 +42,24 @@ extern struct ion_handle *ion_handle_get_by_id(struct ion_client *client,
 
 static struct ion_heap_desc ion_heap_meta[] = {
        {
-               .id     = ION_SYSTEM_HEAP_ID,
+               .id             = ION_SYSTEM_HEAP_ID,
                .type   = ION_HEAP_TYPE_SYSTEM,
-               .name   = ION_VMALLOC_HEAP_NAME,
+               .name   = ION_SYSTEM_HEAP_NAME,
        },
        {
-               .id     = ION_VIDEO_HEAP_ID,
+               .id             = ION_CMA_HEAP_ID,
                .type   = ION_HEAP_TYPE_DMA,
-               .name   = ION_VIDEO_HEAP_NAME,
+               .name   = ION_CMA_HEAP_NAME,
        },
        {
-               .id     = ION_AUDIO_HEAP_ID,
-               .type   = ION_HEAP_TYPE_DMA,
-               .name   = ION_AUDIO_HEAP_NAME,
-       },
-       {
-               .id     = ION_IOMMU_HEAP_ID,
+               .id             = ION_IOMMU_HEAP_ID,
                .type   = ION_HEAP_TYPE_DMA,//ION_HEAP_TYPE_IOMMU,
                .name   = ION_IOMMU_HEAP_NAME,
        },
        {
-               .id     = ION_CAMERA_HEAP_ID,
+               .id     = ION_DRM_HEAP_ID,
                .type   = ION_HEAP_TYPE_DMA,
-               .name   = ION_CAMERA_HEAP_NAME,
+               .name   = ION_DRM_HEAP_NAME,
        },
 };
 
@@ -116,7 +111,7 @@ static struct ion_platform_data *rockchip_ion_parse_dt(
        for_each_child_of_node(dt_node, node)
                num_heaps++;
 
-        pr_info("%s: num_heaps = %d\n", __func__, num_heaps);
+       pr_info("%s: num_heaps = %d\n", __func__, num_heaps);
         
        if (!num_heaps)
                return ERR_PTR(-EINVAL);
@@ -125,7 +120,7 @@ static struct ion_platform_data *rockchip_ion_parse_dt(
                        num_heaps*sizeof(struct ion_platform_heap), GFP_KERNEL);
        if (!pdata)
                return ERR_PTR(-ENOMEM);
-        pdata->heaps = (struct ion_platform_heap*)((void*)pdata+sizeof(struct ion_platform_data));
+       pdata->heaps = (struct ion_platform_heap*)((void*)pdata+sizeof(struct ion_platform_data));
        pdata->nr = num_heaps;
         
        for_each_child_of_node(dt_node, node) {
@@ -146,8 +141,8 @@ static struct ion_platform_data *rockchip_ion_parse_dt(
                        goto free_heaps;
 
 //             rockchip_ion_get_heap_adjacent(node, &pdata->heaps[idx]);
-                pdata->heaps[idx].priv = dev;
-                pr_info("%d:  %d  %d  %s  0x%08X\n", idx, pdata->heaps[idx].type, pdata->heaps[idx].id, pdata->heaps[idx].name, pdata->heaps[idx].size);
+               pdata->heaps[idx].priv = dev;
+               pr_info("%d:  %d  %d  %s  0x%08X\n", idx, pdata->heaps[idx].type, pdata->heaps[idx].id, pdata->heaps[idx].name, pdata->heaps[idx].size);
 
                ++idx;
        }
@@ -207,12 +202,10 @@ static long rockchip_custom_ioctl (struct ion_client *client, unsigned int cmd,
 static int rockchip_ion_probe(struct platform_device *pdev)
 {
        struct ion_platform_data *pdata;
-        unsigned int pdata_needs_to_be_freed;
+       unsigned int pdata_needs_to_be_freed;
        int err;
        int i;
 
-        printk("%s\n", __func__);
-
        if (pdev->dev.of_node) {
                pdata = rockchip_ion_parse_dt(&pdev->dev);
                if (IS_ERR(pdata)) {
@@ -247,12 +240,12 @@ static int rockchip_ion_probe(struct platform_device *pdev)
        if (pdata_needs_to_be_freed)
                kfree(pdata);
 
-        pr_info("Rockchip ion module is successfully loaded\n");
+       pr_info("Rockchip ion module is successfully loaded\n");
        return 0;
 err:
        for (i = 0; i < num_heaps; i++) {
-               if (heaps[i])
-                       ion_heap_destroy(heaps[i]);
+               if (heaps[i])
+               ion_heap_destroy(heaps[i]);
        }
        if (pdata_needs_to_be_freed)
                kfree(pdata);
@@ -262,39 +255,39 @@ 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;
+       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 const struct of_device_id rockchip_ion_dt_ids[] = {
-        { .compatible = "rockchip,ion", },
-        {}
+       { .compatible = "rockchip,ion", },
+       {}
 };
 
 static struct platform_driver ion_driver = {
-        .probe = rockchip_ion_probe,
-        .remove = rockchip_ion_remove,
-        .driver = {
-                .name = "ion-rockchip",
-                .owner = THIS_MODULE,
-                .of_match_table = of_match_ptr(rockchip_ion_dt_ids),
-        },
+       .probe = rockchip_ion_probe,
+       .remove = rockchip_ion_remove,
+       .driver = {
+               .name = "ion-rockchip",
+               .owner  = THIS_MODULE,
+               .of_match_table = of_match_ptr(rockchip_ion_dt_ids),
+       },
 };
 
 static int __init ion_init(void)
 {
-        return platform_driver_register(&ion_driver);
+       return platform_driver_register(&ion_driver);
 }
 
 static void __exit ion_exit(void)
 {
-        platform_driver_unregister(&ion_driver);
+       platform_driver_unregister(&ion_driver);
 }
 
 subsys_initcall(ion_init);
index 7d328ab9672143fc334cc05a2d5f4aa02b5cde2c..41185fa74597473feadb2f6d8513edbce4f01d76 100755 (executable)
@@ -1583,7 +1583,7 @@ static int rk_fb_alloc_buffer(struct fb_info *fbi, int fb_id)
                fb_mem_size = 3 * (fbi->var.xres * fbi->var.yres) << 2;
                fb_mem_size = ALIGN(fb_mem_size, SZ_1M);
 #if defined(CONFIG_ION_ROCKCHIP)
-               handle = ion_alloc(rk_fb->ion_client, (size_t)fb_mem_size, 0, ION_HEAP(ION_VIDEO_HEAP_ID), 0);
+               handle = ion_alloc(rk_fb->ion_client, (size_t)fb_mem_size, 0, ION_HEAP(ION_CMA_HEAP_ID), 0);
                if (IS_ERR(handle)) {
                        dev_err(fbi->device, "failed to ion_alloc:%ld\n",PTR_ERR(handle));
                        return -ENOMEM;
index def0f390ecbd9586622198970ad4e145fa9af26a..e9341a5a65d27e5d5c41d78e22c83d9eb4566dd7 100644 (file)
 #ifndef _LINUX_ROCKCHIP_ION_H
 #define _LINUX_ROCKCHIP_ION_H
 
+#ifdef __KERNEL__
 #include "../../drivers/staging/android/ion/ion.h"
+#else
+#include <linux/ion.h>
+#endif
 
 enum ion_heap_ids {
        INVALID_HEAP_ID = -1,
-       ION_VIDEO_HEAP_ID = 1,
-       ION_CAMERA_HEAP_ID,
+       ION_CMA_HEAP_ID = 1,
        ION_IOMMU_HEAP_ID,
-       ION_AUDIO_HEAP_ID,
        ION_SYSTEM_HEAP_ID,
+       ION_DRM_HEAP_ID,
 
        ION_HEAP_ID_RESERVED = 31
 };
 
 #define ION_HEAP(bit) (1 << (bit))
 
-#define ION_VIDEO_HEAP_NAME            "video"
-#define ION_AUDIO_HEAP_NAME            "audio"
-#define ION_CAMERA_HEAP_NAME   "camera_preview"
+#define ION_CMA_HEAP_NAME              "cma"
 #define ION_IOMMU_HEAP_NAME            "iommu"
-#define ION_VMALLOC_HEAP_NAME  "vmalloc"
+#define ION_SYSTEM_HEAP_NAME   "vmalloc"
+#define ION_DRM_HEAP_NAME              "drm"
 
 #define ION_SET_CACHED(__cache)                (__cache | ION_FLAG_CACHED)
 #define ION_SET_UNCACHED(__cache)      (__cache & ~ION_FLAG_CACHED)
@@ -55,7 +57,7 @@ enum ion_heap_ids {
  * the cache operations performed
  */
 struct ion_flush_data {
-       struct ion_handle *handle;
+       ion_user_handle_t handle;
        int fd;
        void *vaddr;
        unsigned int offset;