2 * linux/drivers/media/video/s5p-mfc/s5p_mfc_mem.h
4 * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5 * http://www.samsung.com/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
13 #ifndef __S5P_MFC_MEM_H_
14 #define __S5P_MFC_MEM_H_ __FILE__
16 #include <linux/platform_device.h>
17 #if defined(CONFIG_S5P_MFC_VB2_CMA)
18 #include <media/videobuf2-cma.h>
19 #elif defined(CONFIG_S5P_MFC_VB2_DMA_POOL)
20 #include <media/videobuf2-dma-pool.h>
21 #elif defined(CONFIG_S5P_MFC_VB2_SDVMM)
22 #include <media/videobuf2-sdvmm.h>
25 /* Offset base used to differentiate between CAPTURE and OUTPUT
27 #define DST_QUEUE_OFF_BASE (TASK_SIZE / 2)
29 #define FIRMWARE_CODE_SIZE 0x60000 /* 384KB */
30 #define MFC_H264_CTX_BUF_SIZE 0x96000 /* 600KB per H264 instance */
31 #define MFC_CTX_BUF_SIZE 0x2800 /* 10KB per instance */
32 #define DESC_BUF_SIZE 0x20000 /* 128KB for DESC buffer */
33 #define SHARED_BUF_SIZE 0x01000 /* 4KB for shared buffer */
34 #define CPB_BUF_SIZE 0x400000 /* 4MB fr decoder */
36 #if defined(CONFIG_S5P_MFC_VB2_CMA)
37 /* Define names for CMA memory kinds used by MFC */
38 #define MFC_CMA_ALLOC_CTX_NUM 3
40 #define MFC_CMA_BANK1 "a"
41 #define MFC_CMA_BANK2 "b"
42 #define MFC_CMA_FW "f"
44 #define MFC_CMA_BANK1_ALLOC_CTX 1
45 #define MFC_CMA_BANK2_ALLOC_CTX 0
46 #define MFC_CMA_FW_ALLOC_CTX 2
48 #define MFC_CMA_BANK1_ALIGN 0x2000 /* 8KB */
49 #define MFC_CMA_BANK2_ALIGN 0x2000 /* 8KB */
50 #define MFC_CMA_FW_ALIGN 0x20000 /* 128KB */
52 #define mfc_plane_cookie(v, n) vb2_cma_plane_paddr(v, n)
54 static inline void *s5p_mfc_mem_alloc(void *a, unsigned int s)
56 return vb2_cma_memops.alloc(a, s);
59 static inline size_t s5p_mfc_mem_cookie(void *a, void *b)
61 return (size_t)vb2_cma_memops.cookie(b);
64 static inline void s5p_mfc_mem_put(void *a, void *b)
66 vb2_cma_memops.put(b);
69 static inline void *s5p_mfc_mem_vaddr(void *a, void *b)
71 return vb2_cma_memops.vaddr(b);
73 #elif defined(CONFIG_S5P_MFC_VB2_DMA_POOL)
74 #define MFC_ALLOC_CTX_NUM 2
76 #define MFC_BANK_A_ALLOC_CTX 0
77 #define MFC_BANK_B_ALLOC_CTX 1
79 #define MFC_CMA_BANK1_ALLOC_CTX MFC_BANK_A_ALLOC_CTX
80 #define MFC_CMA_BANK2_ALLOC_CTX MFC_BANK_B_ALLOC_CTX
81 #define MFC_CMA_FW_ALLOC_CTX MFC_BANK_A_ALLOC_CTX
83 #define mfc_plane_cookie(v, n) vb2_dma_pool_plane_paddr(v, n)
85 static inline void *s5p_mfc_mem_alloc(void *a, unsigned int s)
87 return vb2_dma_pool_memops.alloc(a, s);
90 static inline size_t s5p_mfc_mem_cookie(void *a, void *b)
92 return (size_t)vb2_dma_pool_memops.cookie(b);
95 static inline void s5p_mfc_mem_put(void *a, void *b)
97 vb2_dma_pool_memops.put(b);
100 static inline void *s5p_mfc_mem_vaddr(void *a, void *b)
102 return vb2_dma_pool_memops.vaddr(b);
104 #elif defined(CONFIG_S5P_MFC_VB2_SDVMM)
105 #define MFC_ALLOC_CTX_NUM 2
107 #define MFC_BANK_A_ALLOC_CTX 0
108 #define MFC_BANK_B_ALLOC_CTX 1
110 #define MFC_BANK_A_ALIGN_ORDER 11
111 #define MFC_BANK_B_ALIGN_ORDER 11
113 #define MFC_CMA_BANK1_ALLOC_CTX MFC_BANK_A_ALLOC_CTX
114 #define MFC_CMA_BANK2_ALLOC_CTX MFC_BANK_B_ALLOC_CTX
115 #define MFC_CMA_FW_ALLOC_CTX MFC_BANK_A_ALLOC_CTX
118 #define mfc_plane_cookie(v, n) vb2_sdvmm_plane_dvaddr(v, n)
120 static inline void *s5p_mfc_mem_alloc(void *a, unsigned int s)
122 return vb2_sdvmm_memops.alloc(a, s);
125 static inline size_t s5p_mfc_mem_cookie(void *a, void *b)
127 return (size_t)vb2_sdvmm_memops.cookie(b);
130 static inline void s5p_mfc_mem_put(void *a, void *b)
132 vb2_sdvmm_memops.put(b);
135 static inline void *s5p_mfc_mem_vaddr(void *a, void *b)
137 return vb2_sdvmm_memops.vaddr(b);
141 struct vb2_mem_ops *s5p_mfc_mem_ops(void);
142 void **s5p_mfc_mem_init_multi(struct device *dev);
143 void s5p_mfc_mem_cleanup_multi(void **alloc_ctxes);
145 void s5p_mfc_cache_clean(const void *start_addr, unsigned long size);
146 void s5p_mfc_cache_inv(const void *start_addr, unsigned long size);
148 void s5p_mfc_mem_suspend(void *alloc_ctx);
149 void s5p_mfc_mem_resume(void *alloc_ctx);
151 #endif /* __S5P_MFC_MEM_H_ */