Browse Source

video: driver: check kernel version to differentiate api

dma_buf_vmap() api changed from kernel version 5.15 and hence
check kernel version to use the updated api.

Change-Id: I05b7c72199cedfe9c33a8888fffb5e38da875f7e
Signed-off-by: Maheshwar Ajja <[email protected]>
Maheshwar Ajja 3 years ago
parent
commit
814107162d
1 changed files with 11 additions and 0 deletions
  1. 11 0
      driver/vidc/src/msm_vidc_memory.c

+ 11 - 0
driver/vidc/src/msm_vidc_memory.c

@@ -3,6 +3,7 @@
  * Copyright (c) 2020-2021, The Linux Foundation. All rights reserved.
  */
 
+#include <linux/version.h>
 #include <linux/dma-buf.h>
 #include <linux/dma-heap.h>
 #include <linux/dma-mapping.h>
@@ -377,12 +378,22 @@ int msm_vidc_memory_alloc(struct msm_vidc_core *core, struct msm_vidc_alloc *mem
 
 	if (mem->map_kernel) {
 		dma_buf_begin_cpu_access(mem->dmabuf, DMA_BIDIRECTIONAL);
+
+#if (LINUX_VERSION_CODE < KERNEL_VERSION(5,15,0))
+		mem->kvaddr = dma_buf_vmap(mem->dmabuf);
+		if (!mem->kvaddr) {
+			d_vpr_e("%s: kernel map failed\n", __func__);
+			rc = -EIO;
+			goto error;
+		}
+#else
 		rc = dma_buf_vmap(mem->dmabuf, mem->kvaddr);
 		if (rc) {
 			d_vpr_e("%s: kernel map failed\n", __func__);
 			rc = -EIO;
 			goto error;
 		}
+#endif
 	}
 
 	d_vpr_h(