media: fimc-is2: fix use of ION API for 4.14 kernel
authorCho KyongHo <pullip.cho@samsung.com>
Mon, 12 Feb 2018 07:13:39 +0000 (16:13 +0900)
committerEunyoung Lee <ey470.lee@samsung.com>
Tue, 19 Jun 2018 08:43:37 +0000 (17:43 +0900)
ION is dramatically changed in 4.14 kernel including kernel API and
the header files. But the symantics of ION API is not changed.

Change-Id: I636ffdfa8a6e14937cc81dab93901f7c4740cf71
Signed-off-by: Cho KyongHo <pullip.cho@samsung.com>
drivers/media/platform/exynos/fimc-is2/fimc-is-device-csi_v4.c
drivers/media/platform/exynos/fimc-is2/fimc-is-mem.c
drivers/media/platform/exynos/fimc-is2/fimc-is-mem.h

index c619b5ac4247252c7e04fa49255ca79dfa0915bc..46b43c8c7b76eda4688f7b47e915ea0f8583609b 100644 (file)
@@ -1456,7 +1456,7 @@ static int csi_stream_on(struct v4l2_subdev *subdev,
                csi->sw_checker = EXPECT_FRAME_START;
                csi->overflow_cnt = 0;
                csi_s_config_dma(csi, sensor_cfg->output);
-               memset(csi->pre_dma_enable, -1, ARRAY_SIZE(csi->pre_dma_enable));
+               memset(csi->pre_dma_enable, -1, sizeof(csi->pre_dma_enable));
 
                /* for multi frame buffer setting for internal vc */
                csis_s_vc_dma_multibuf(csi);
index 1ed6ba437f4047bf1adc837bd5e4cdd4dd1dd297..822cf8cbefca363086fb9e438270faf4cdd6f4bf 100644 (file)
@@ -30,7 +30,7 @@
 #include <linux/interrupt.h>
 #include <linux/of.h>
 #include <linux/dma-buf.h>
-#include <linux/exynos_ion.h>
+#include <linux/ion_exynos.h>
 #include <asm/cacheflush.h>
 
 #include "fimc-is-core.h"
@@ -142,31 +142,24 @@ static void fimc_is_ion_free(struct fimc_is_priv_buf *pbuf)
                ion_iovmm_unmap(pbuf->attachment, pbuf->iova);
        mutex_unlock(&alloc_ctx->lock);
 
+       if (pbuf->kva)
+               dma_buf_vunmap(pbuf->dma_buf, pbuf->kva);
+
        dma_buf_unmap_attachment(pbuf->attachment, pbuf->sgt,
                                DMA_BIDIRECTIONAL);
        dma_buf_detach(pbuf->dma_buf, pbuf->attachment);
        dma_buf_put(pbuf->dma_buf);
 
-       if (pbuf->kva)
-               ion_unmap_kernel(alloc_ctx->client, pbuf->handle);
-       ion_free(alloc_ctx->client, pbuf->handle);
-
        vfree(pbuf);
 }
 
 static ulong fimc_is_ion_kvaddr(struct fimc_is_priv_buf *pbuf)
 {
-       struct fimc_is_ion_ctx *alloc_ctx;
-
        if (!pbuf)
                return 0;
 
-       alloc_ctx = pbuf->ctx;
-       if (!pbuf->kva) {
-               pbuf->kva = ion_map_kernel(alloc_ctx->client, pbuf->handle);
-               if (IS_ERR_OR_NULL(pbuf->kva))
-                       pbuf->kva = NULL;
-       }
+       if (!pbuf->kva)
+               pbuf->kva = dma_buf_vmap(pbuf->dma_buf);
 
        return (ulong)pbuf->kva;
 }
@@ -235,15 +228,8 @@ static void *fimc_is_ion_init(struct platform_device *pdev)
                return ERR_PTR(-ENOMEM);
 
        ctx->dev = &pdev->dev;
-       ctx->client = exynos_ion_client_create(dev_name(&pdev->dev));
-       if (IS_ERR(ctx->client)) {
-               void *retp = ctx->client;
-               kfree(ctx);
-               return retp;
-       }
-
        ctx->alignment = SZ_4K;
-       ctx->flags = ION_FLAG_CACHED | ION_FLAG_CACHED_NEEDS_SYNC;
+       ctx->flags = ION_FLAG_CACHED;
        mutex_init(&ctx->lock);
 
        return ctx;
@@ -255,7 +241,6 @@ static void fimc_is_ion_deinit(void *ctx)
        struct fimc_is_ion_ctx *alloc_ctx = ctx;
 
        mutex_destroy(&alloc_ctx->lock);
-       ion_client_destroy(alloc_ctx->client);
        vfree(alloc_ctx);
 }
 
@@ -264,7 +249,7 @@ static struct fimc_is_priv_buf *fimc_is_ion_alloc(void *ctx,
 {
        struct fimc_is_ion_ctx *alloc_ctx = ctx;
        struct fimc_is_priv_buf *buf;
-       int heapflags = EXYNOS_ION_HEAP_SYSTEM_MASK;
+       const char *heapname = "ion_system_heap";
        int ret = 0;
 
        buf = vzalloc(sizeof(*buf));
@@ -273,19 +258,12 @@ static struct fimc_is_priv_buf *fimc_is_ion_alloc(void *ctx,
 
        size = PAGE_ALIGN(size);
 
-       buf->handle = ion_alloc(alloc_ctx->client, size, alloc_ctx->alignment,
-                               heapflags, alloc_ctx->flags);
-       if (IS_ERR(buf->handle)) {
+       buf->dma_buf = ion_alloc_dmabuf(heapname, size, alloc_ctx->flags);
+       if (IS_ERR(buf->dma_buf)) {
                ret = -ENOMEM;
                goto err_alloc;
        }
 
-       buf->dma_buf = ion_share_dma_buf(alloc_ctx->client, buf->handle);
-       if (IS_ERR(buf->dma_buf)) {
-               ret = PTR_ERR(buf->dma_buf);
-               goto err_share;
-       }
-
        buf->attachment = dma_buf_attach(buf->dma_buf, alloc_ctx->dev);
        if (IS_ERR(buf->attachment)) {
                ret = PTR_ERR(buf->attachment);
@@ -317,16 +295,12 @@ static struct fimc_is_priv_buf *fimc_is_ion_alloc(void *ctx,
        return buf;
 
 err_ion_map_io:
-       if (buf->kva)
-               ion_unmap_kernel(alloc_ctx->client, buf->handle);
        dma_buf_unmap_attachment(buf->attachment, buf->sgt,
                                DMA_BIDIRECTIONAL);
 err_map_dmabuf:
        dma_buf_detach(buf->dma_buf, buf->attachment);
 err_attach:
        dma_buf_put(buf->dma_buf);
-err_share:
-       ion_free(alloc_ctx->client, buf->handle);
 err_alloc:
        vfree(buf);
 
index ccf4994f6267e27ae513ed4a5c3a59c20a7b54d8..531f402224df7cbde072b4483d17390873ea9b8f 100644 (file)
@@ -63,7 +63,6 @@ struct fimc_is_priv_buf {
 
        const struct fimc_is_priv_buf_ops       *ops;
        void                                    *priv;
-       struct ion_handle                       *handle;
        struct dma_buf                          *dma_buf;
        struct dma_buf_attachment               *attachment;
        enum dma_data_direction                 direction;
@@ -102,7 +101,6 @@ struct fimc_is_mem_ops {
 
 struct fimc_is_ion_ctx {
        struct device           *dev;
-       struct ion_client       *client;
        unsigned long           alignment;
        long                    flags;