upload tizen1.0 source
[kernel/linux-2.6.36.git] / drivers / media / video / s5p-mfc / s5p_mfc_mem.h
1 /*
2  * linux/drivers/media/video/s5p-mfc/s5p_mfc_mem.h
3  *
4  * Copyright (c) 2010 Samsung Electronics Co., Ltd.
5  *              http://www.samsung.com/
6  *
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.
11  */
12
13 #ifndef __S5P_MFC_MEM_H_
14 #define __S5P_MFC_MEM_H_ __FILE__
15
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>
23 #endif
24
25 /* Offset base used to differentiate between CAPTURE and OUTPUT
26 *  while mmaping */
27 #define DST_QUEUE_OFF_BASE      (TASK_SIZE / 2)
28
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 */
35
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
39
40 #define MFC_CMA_BANK1           "a"
41 #define MFC_CMA_BANK2           "b"
42 #define MFC_CMA_FW              "f"
43
44 #define MFC_CMA_BANK1_ALLOC_CTX 1
45 #define MFC_CMA_BANK2_ALLOC_CTX 0
46 #define MFC_CMA_FW_ALLOC_CTX    2
47
48 #define MFC_CMA_BANK1_ALIGN     0x2000  /* 8KB */
49 #define MFC_CMA_BANK2_ALIGN     0x2000  /* 8KB */
50 #define MFC_CMA_FW_ALIGN        0x20000 /* 128KB */
51
52 #define mfc_plane_cookie(v, n)  vb2_cma_plane_paddr(v, n)
53
54 static inline void *s5p_mfc_mem_alloc(void *a, unsigned int s)
55 {
56         return vb2_cma_memops.alloc(a, s);
57 }
58
59 static inline size_t s5p_mfc_mem_cookie(void *a, void *b)
60 {
61         return (size_t)vb2_cma_memops.cookie(b);
62 }
63
64 static inline void s5p_mfc_mem_put(void *a, void *b)
65 {
66         vb2_cma_memops.put(b);
67 }
68
69 static inline void *s5p_mfc_mem_vaddr(void *a, void *b)
70 {
71         return vb2_cma_memops.vaddr(b);
72 }
73 #elif defined(CONFIG_S5P_MFC_VB2_DMA_POOL)
74 #define MFC_ALLOC_CTX_NUM       2
75
76 #define MFC_BANK_A_ALLOC_CTX    0
77 #define MFC_BANK_B_ALLOC_CTX    1
78
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
82
83 #define mfc_plane_cookie(v, n)  vb2_dma_pool_plane_paddr(v, n)
84
85 static inline void *s5p_mfc_mem_alloc(void *a, unsigned int s)
86 {
87         return vb2_dma_pool_memops.alloc(a, s);
88 }
89
90 static inline size_t s5p_mfc_mem_cookie(void *a, void *b)
91 {
92         return (size_t)vb2_dma_pool_memops.cookie(b);
93 }
94
95 static inline void s5p_mfc_mem_put(void *a, void *b)
96 {
97         vb2_dma_pool_memops.put(b);
98 }
99
100 static inline void *s5p_mfc_mem_vaddr(void *a, void *b)
101 {
102         return vb2_dma_pool_memops.vaddr(b);
103 }
104 #elif defined(CONFIG_S5P_MFC_VB2_SDVMM)
105 #define MFC_ALLOC_CTX_NUM       2
106
107 #define MFC_BANK_A_ALLOC_CTX    0
108 #define MFC_BANK_B_ALLOC_CTX    1
109
110 #define MFC_BANK_A_ALIGN_ORDER  11
111 #define MFC_BANK_B_ALIGN_ORDER  11
112
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
116
117
118 #define mfc_plane_cookie(v, n)  vb2_sdvmm_plane_dvaddr(v, n)
119
120 static inline void *s5p_mfc_mem_alloc(void *a, unsigned int s)
121 {
122         return vb2_sdvmm_memops.alloc(a, s);
123 }
124
125 static inline size_t s5p_mfc_mem_cookie(void *a, void *b)
126 {
127         return (size_t)vb2_sdvmm_memops.cookie(b);
128 }
129
130 static inline void s5p_mfc_mem_put(void *a, void *b)
131 {
132         vb2_sdvmm_memops.put(b);
133 }
134
135 static inline void *s5p_mfc_mem_vaddr(void *a, void *b)
136 {
137         return vb2_sdvmm_memops.vaddr(b);
138 }
139 #endif
140
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);
144
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);
147
148 void s5p_mfc_mem_suspend(void *alloc_ctx);
149 void s5p_mfc_mem_resume(void *alloc_ctx);
150
151 #endif /* __S5P_MFC_MEM_H_ */