• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef __MEDIA_INFO_H__
2 #define __MEDIA_INFO_H__
3 
4 #ifndef MSM_MEDIA_ALIGN
5 #define MSM_MEDIA_ALIGN(__sz, __align) (((__sz) + (__align-1)) & (~(__align-1)))
6 #endif
7 
8 enum color_fmts {
9 	COLOR_FMT_NV12,
10 	COLOR_FMT_NV21,
11 };
12 
13 #define VENUS_Y_STRIDE(__color_fmt, __width) ({\
14 	unsigned int __alignment, __stride = 0; \
15 	if (__width) { \
16 		switch (__color_fmt) { \
17 		case COLOR_FMT_NV12: \
18 		__alignment = 128; \
19 		__stride = MSM_MEDIA_ALIGN(__width, __alignment);\
20 		break;\
21 		default:\
22 		break;\
23 		}\
24 	} \
25 	__stride;\
26 })
27 
28 #define VENUS_UV_STRIDE(__color_fmt, __width) ({\
29 	unsigned int __alignment, __stride = 0; \
30 	if (__width) {\
31 		switch (__color_fmt) { \
32 		case COLOR_FMT_NV12: \
33 		__alignment = 128; \
34 		__stride = MSM_MEDIA_ALIGN(__width, __alignment); \
35 		break; \
36 		default: \
37 		break; \
38 		} \
39 	} \
40 	__stride; \
41 })
42 
43 #define VENUS_Y_SCANLINES(__color_fmt, __height) ({ \
44 	unsigned int __alignment, __sclines = 0; \
45 	if (__height) {\
46 		switch (__color_fmt) { \
47 		case COLOR_FMT_NV12: \
48 		__alignment = 32; \
49 		__sclines = MSM_MEDIA_ALIGN(__height, __alignment); \
50 		break; \
51 		default: \
52 		break; \
53 		} \
54 	} \
55 	__sclines; \
56 })
57 
58 #define VENUS_UV_SCANLINES(__color_fmt, __height) ({\
59 	unsigned int __alignment, __sclines = 0; \
60 	if (__height) {\
61 		switch (__color_fmt) { \
62 		case COLOR_FMT_NV12: \
63 			__alignment = 16; \
64 			__sclines = MSM_MEDIA_ALIGN(((__height + 1) >> 1), __alignment); \
65 			break; \
66 		default: \
67 			break; \
68 		} \
69 	} \
70 	__sclines; \
71 })
72 
73 #define VENUS_BUFFER_SIZE( \
74 	__color_fmt, __width, __height) ({ \
75 	unsigned int __uv_alignment; \
76 	unsigned int __size = 0; \
77 	unsigned int __y_plane, __uv_plane, __y_stride, \
78 		__uv_stride, __y_sclines, __uv_sclines; \
79 	if (__width && __height) {\
80 		__y_stride = VENUS_Y_STRIDE(__color_fmt, __width); \
81 		__uv_stride = VENUS_UV_STRIDE(__color_fmt, __width); \
82 		__y_sclines = VENUS_Y_SCANLINES(__color_fmt, __height); \
83 		__uv_sclines = VENUS_UV_SCANLINES(__color_fmt, __height); \
84 		switch (__color_fmt) { \
85 		case COLOR_FMT_NV12: \
86 			__uv_alignment = 4096; \
87 			__y_plane = __y_stride * __y_sclines; \
88 			__uv_plane = __uv_stride * __uv_sclines + __uv_alignment; \
89 			__size = __y_plane + __uv_plane; \
90 			__size = MSM_MEDIA_ALIGN(__size, 4096); \
91 			break; \
92 		default: \
93 			break; \
94 		} \
95 	} \
96 	__size; \
97 })
98 
99 #endif
100