media: mfc: support kernel 4.14
authorJeonghee Kim <jhhhh.kim@samsung.com>
Fri, 26 Jan 2018 05:28:34 +0000 (14:28 +0900)
committerCosmin Tanislav <demonsingur@gmail.com>
Mon, 22 Apr 2024 17:22:21 +0000 (20:22 +0300)
- add VIDEOBUF2_DMA_SG dependency
- remove videobuf2_ion
- remove unnecessary cache control
- change vb2_memops
- remove vb2_ion_buf_prepare/finish
- use __dma_map_area for clean/invalidate
- use vb2_dma_sg_plane_dma_addr to get daddr

Change-Id: I46e70140df56435060469ebbfab45e9a2226d1a1
Signed-off-by: Jeonghee Kim <jhhhh.kim@samsung.com>
drivers/media/platform/exynos/mfc/Kconfig
drivers/media/platform/exynos/mfc/s5p_mfc_buf.c
drivers/media/platform/exynos/mfc/s5p_mfc_common.h
drivers/media/platform/exynos/mfc/s5p_mfc_dec_vb2_ops.c
drivers/media/platform/exynos/mfc/s5p_mfc_enc_vb2_ops.c
drivers/media/platform/exynos/mfc/s5p_mfc_mem.c
drivers/media/platform/exynos/mfc/s5p_mfc_mem.h

index 4f962905455886778e9a7562a1d822e3537d7b47..9cf64772011324ee016daa76daeb89ad10eb7355 100644 (file)
@@ -3,6 +3,7 @@ config VIDEO_EXYNOS_MFC
        default n
        depends on VIDEO_EXYNOS
        select VIDEOBUF2_CORE
+       select VIDEOBUF2_DMA_SG
        select EXYNOS_MFC_V12
        ---help---
          MFC driver for V4L2.
index cc633c59811c171e1068f351c718c503e8b79331..e02581d0a5dc6ecd4a5ccce68e4eda5029e08df9 100644 (file)
@@ -528,7 +528,6 @@ static int mfc_alloc_enc_roi_buffer(struct s5p_mfc_ctx *ctx, struct s5p_mfc_spec
        }
 
        memset(roi_buf->vaddr, 0, buf_size->shared_buf);
-       s5p_mfc_mem_clean(dev, roi_buf, 0, roi_buf->size);
 
        return 0;
 }
@@ -586,7 +585,6 @@ int s5p_mfc_otf_alloc_stream_buf(struct s5p_mfc_ctx *ctx)
                        return -EINVAL;
                }
                memset(buf->vaddr, 0, raw->total_plane_size);
-               s5p_mfc_mem_clean(dev, buf, 0, buf->size);
        }
 
        mfc_debug_leave();
@@ -722,13 +720,9 @@ int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev)
        }
 
        memcpy(dev->fw_buf.vaddr, fw_blob->data, fw_blob->size);
-       s5p_mfc_mem_clean(dev, &dev->fw_buf, 0, fw_blob->size);
-       s5p_mfc_mem_invalidate(dev, &dev->fw_buf, 0, fw_blob->size);
        if (dev->drm_fw_buf.vaddr) {
                memcpy(dev->drm_fw_buf.vaddr, fw_blob->data, fw_blob->size);
                mfc_debug(2, "copy firmware to secure region\n");
-               s5p_mfc_mem_clean(dev, &dev->drm_fw_buf, 0, fw_blob->size);
-               s5p_mfc_mem_invalidate(dev, &dev->drm_fw_buf, 0, fw_blob->size);
        }
        release_firmware(fw_blob);
        trace_mfc_loadfw_end(dev->fw.size, firmware_size);
index 218fc9c6a8f6270f9f5f9dce7d5a2d9e701d9116..063e26f4f06004b3275db81068edc9e0d459f2ff 100644 (file)
@@ -17,6 +17,9 @@
 #include <linux/io.h>
 #include <linux/slab.h>
 #include <linux/sched/clock.h>
+#include <linux/exynos_ion.h>
+#include <media/videobuf2-dma-sg.h>
+#include <asm/cacheflush.h>
 
 #include "s5p_mfc_regs_v10.h"
 #include "s5p_mfc_macros.h"
index f3e77bb27529bed6af0d9c19ecc6f4391122afdd..b545fdeef2beff792f84e5f6da325b2424b3edbc 100644 (file)
@@ -279,8 +279,6 @@ static int s5p_mfc_dec_buf_prepare(struct vb2_buffer *vb)
                        mfc_err_ctx("failed in to_buf_ctrls\n");
        }
 
-       s5p_mfc_mem_buf_prepare(vb);
-
        return 0;
 }
 
@@ -302,8 +300,6 @@ static void s5p_mfc_dec_buf_finish(struct vb2_buffer *vb)
                if (call_cop(ctx, to_ctx_ctrls, ctx, &ctx->src_ctrls[index]) < 0)
                        mfc_err_ctx("failed in to_ctx_ctrls\n");
        }
-
-       s5p_mfc_mem_buf_finish(vb);
 }
 
 static void s5p_mfc_dec_buf_cleanup(struct vb2_buffer *vb)
@@ -586,10 +582,9 @@ static void s5p_mfc_dec_buf_queue(struct vb2_buffer *vb)
                                s5p_mfc_mem_get_daddr_vb(vb, 0),
                                buf->addr[0]);
                if (dec->dst_memtype == V4L2_MEMORY_DMABUF &&
-                               ctx->state < MFCINST_HEAD_PARSED && !ctx->is_drm) {
+                               ctx->state < MFCINST_HEAD_PARSED && !ctx->is_drm)
                        stream_vir = vb2_plane_vaddr(vb, 0);
-                       s5p_mfc_mem_inv_vb(vb, 1);
-               }
+
                buf->vir_addr = stream_vir;
 
                s5p_mfc_add_tail_buf(&ctx->buf_queue_lock, &ctx->src_buf_queue, buf);
index cb4d4c9a1ec364891654e84a45deb54c84fafe77..0a87654fd8c6449e6abceff309ceb38a74be0a16 100644 (file)
@@ -238,8 +238,6 @@ static int s5p_mfc_enc_buf_prepare(struct vb2_buffer *vb)
                return -EINVAL;
        }
 
-       s5p_mfc_mem_buf_prepare(vb);
-
        mfc_debug_leave();
 
        return 0;
@@ -259,8 +257,6 @@ static void s5p_mfc_enc_buf_finish(struct vb2_buffer *vb)
                if (call_cop(ctx, to_ctx_ctrls, ctx, &ctx->src_ctrls[index]) < 0)
                        mfc_err_ctx("failed in to_ctx_ctrls\n");
        }
-
-       s5p_mfc_mem_buf_finish(vb);
 }
 
 static void s5p_mfc_enc_buf_cleanup(struct vb2_buffer *vb)
index ace5b48f4e777f1c72f09909255d113573abaad4..4e36bd09d165bed1369be7c844a050b626926e13 100644 (file)
 
 struct vb2_mem_ops *s5p_mfc_mem_ops(void)
 {
-       return (struct vb2_mem_ops *)&vb2_ion_memops;
+       return (struct vb2_mem_ops *)&vb2_dma_sg_memops;
 }
 
 void s5p_mfc_mem_clean(struct s5p_mfc_dev *dev,
                        struct s5p_mfc_special_buf *special_buf,
                        off_t offset, size_t size)
 {
-       exynos_ion_sync_vaddr_for_device(dev->device, special_buf->dma_buf,
-                       special_buf->vaddr, size, offset, DMA_TO_DEVICE);
+       __dma_map_area(special_buf->vaddr + offset, size, DMA_TO_DEVICE);
        return;
 }
 
@@ -30,47 +29,10 @@ void s5p_mfc_mem_invalidate(struct s5p_mfc_dev *dev,
                        struct s5p_mfc_special_buf *special_buf,
                        off_t offset, size_t size)
 {
-       exynos_ion_sync_vaddr_for_device(dev->device, special_buf->dma_buf,
-                       special_buf->vaddr, size, offset, DMA_FROM_DEVICE);
+       __dma_map_area(special_buf->vaddr + offset, size, DMA_FROM_DEVICE);
        return;
 }
 
-int s5p_mfc_mem_clean_vb(struct vb2_buffer *vb, u32 num_planes)
-{
-       struct vb2_ion_cookie *cookie;
-       int i;
-       size_t size;
-
-       for (i = 0; i < num_planes; i++) {
-               cookie = vb2_plane_cookie(vb, i);
-               if (!cookie)
-                       continue;
-
-               size = vb->planes[i].length;
-               vb2_ion_sync_for_device(cookie, 0, size, DMA_TO_DEVICE);
-       }
-
-       return 0;
-}
-
-int s5p_mfc_mem_inv_vb(struct vb2_buffer *vb, u32 num_planes)
-{
-       struct vb2_ion_cookie *cookie;
-       int i;
-       size_t size;
-
-       for (i = 0; i < num_planes; i++) {
-               cookie = vb2_plane_cookie(vb, i);
-               if (!cookie)
-                       continue;
-
-               size = vb->planes[i].length;
-               vb2_ion_sync_for_device(cookie, 0, size, DMA_FROM_DEVICE);
-       }
-
-       return 0;
-}
-
 int s5p_mfc_mem_get_user_shared_handle(struct s5p_mfc_ctx *ctx,
        struct mfc_user_shared_handle *handle)
 {
index 18f0020482d8bed47cf0d5308bf0dcabfd32ace0..add0548296fbb10c44d13fde36432103fbd83da9 100644 (file)
@@ -13,8 +13,6 @@
 #ifndef __S5P_MFC_MEM_H
 #define __S5P_MFC_MEM_H __FILE__
 
-#include <media/videobuf2-ion.h>
-
 #include "s5p_mfc_common.h"
 
 /* Offset base used to differentiate between CAPTURE and OUTPUT
 #define DST_QUEUE_OFF_BASE      (TASK_SIZE / 2)
 
 static inline dma_addr_t s5p_mfc_mem_get_daddr_vb(
-       struct vb2_buffer *v, unsigned int n)
+       struct vb2_buffer *vb, unsigned int n)
 {
-       void *cookie = vb2_plane_cookie(v, n);
        dma_addr_t addr = 0;
 
-       WARN_ON(vb2_ion_dma_address(cookie, &addr) != 0);
+       addr = vb2_dma_sg_plane_dma_addr(vb, n);
+       WARN_ON((addr == 0) || IS_ERR_VALUE(addr));
 
        return addr;
 }
 
-static inline int s5p_mfc_mem_buf_prepare(struct vb2_buffer *vb)
-{
-       return vb2_ion_buf_prepare(vb);
-}
-
-static inline void s5p_mfc_mem_buf_finish(struct vb2_buffer *vb)
-{
-       vb2_ion_buf_finish(vb);
-}
-
 struct vb2_mem_ops *s5p_mfc_mem_ops(void);
 
 void s5p_mfc_mem_set_cacheable(bool cacheable);
@@ -51,8 +39,6 @@ void s5p_mfc_mem_clean(struct s5p_mfc_dev *dev,
 void s5p_mfc_mem_invalidate(struct s5p_mfc_dev *dev,
                        struct s5p_mfc_special_buf *specail_buf,
                        off_t offset, size_t size);
-int s5p_mfc_mem_clean_vb(struct vb2_buffer *vb, u32 num_planes);
-int s5p_mfc_mem_inv_vb(struct vb2_buffer *vb, u32 num_planes);
 
 int s5p_mfc_mem_get_user_shared_handle(struct s5p_mfc_ctx *ctx,
                struct mfc_user_shared_handle *handle);