summaryrefslogtreecommitdiff
path: root/drivers/media/video/mxc/opl/opl.h
blob: 0f6519d604b9ef25c14e5f58593e7be07290ae12 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
/*
 * Copyright 2004-2010 Freescale Semiconductor, Inc. All Rights Reserved.
 */

/*
 * The code contained herein is licensed under the GNU General Public
 * License. You may obtain a copy of the GNU General Public License
 * Version 2 or later at the following locations:
 *
 * http://www.opensource.org/licenses/gpl-license.html
 * http://www.gnu.org/copyleft/gpl.html
 */

/*!
 * @defgroup OPLIP OPL Image Processing
 */
/*!
 * @file opl.h
 *
 * @brief The OPL (Open Primitives Library) Image Processing library defines
 * efficient functions for rotation and mirroring.
 *
 * It includes ARM9-optimized rotation and mirroring functions. It is derived
 * from the original OPL project which is found at sourceforge.freescale.net.
 *
 * @ingroup OPLIP
 */
#ifndef __OPL_H__
#define __OPL_H__

#include <linux/types.h>

#define BYTES_PER_PIXEL			2
#define CACHE_LINE_WORDS		8
#define BYTES_PER_WORD			4

#define BYTES_PER_2PIXEL		(BYTES_PER_PIXEL * 2)
#define BYTES_PER_4PIXEL		(BYTES_PER_PIXEL * 4)
#define BYTES_PER_8PIXEL		(BYTES_PER_PIXEL * 8)

#define QCIF_Y_WIDTH			176
#define QCIF_Y_HEIGHT			144

/*! Enumerations of opl error code */
enum opl_error {
	OPLERR_SUCCESS = 0,
	OPLERR_NULL_PTR,
	OPLERR_BAD_ARG,
	OPLERR_DIV_BY_ZERO,
	OPLERR_OVER_FLOW,
	OPLERR_UNDER_FLOW,
	OPLERR_MISALIGNED,
};

/*!
 * @brief Rotate a 16bbp buffer 90 degrees clockwise.
 *
 * @param src             Pointer to the input buffer
 * @param src_line_stride Length in bytes of a raster line of the input buffer
 * @param width           Width in pixels of the region in the input buffer
 * @param height          Height in pixels of the region in the input buffer
 * @param dst             Pointer to the output buffer
 * @param dst_line_stride Length in bytes of a raster line of the output buffer
 *
 * @return Standard OPL error code. See enumeration for possible result codes.
 */
int opl_rotate90_u16(const u8 *src, int src_line_stride, int width, int height,
		     u8 *dst, int dst_line_stride);

/*!
 * @brief Rotate a 16bbp buffer 180 degrees clockwise.
 *
 * @param src             Pointer to the input buffer
 * @param src_line_stride Length in bytes of a raster line of the input buffer
 * @param width           Width in pixels of the region in the input buffer
 * @param height          Height in pixels of the region in the input buffer
 * @param dst             Pointer to the output buffer
 * @param dst_line_stride Length in bytes of a raster line of the output buffer
 *
 * @return Standard OPL error code. See enumeration for possible result codes.
 */
int opl_rotate180_u16(const u8 *src, int src_line_stride, int width,
		      int height, u8 *dst, int dst_line_stride);

/*!
 * @brief Rotate a 16bbp buffer 270 degrees clockwise
 *
 * @param src             Pointer to the input buffer
 * @param src_line_stride Length in bytes of a raster line of the input buffer
 * @param width           Width in pixels of the region in the input buffer
 * @param height          Height in pixels of the region in the input buffer
 * @param dst             Pointer to the output buffer
 * @param dst_line_stride Length in bytes of a raster line of the output buffer
 *
 * @return Standard OPL error code. See enumeration for possible result codes.
 */
int opl_rotate270_u16(const u8 *src, int src_line_stride, int width,
		      int height, u8 *dst, int dst_line_stride);

/*!
 * @brief Mirror a 16bpp buffer horizontally
 *
 * @param src             Pointer to the input buffer
 * @param src_line_stride Length in bytes of a raster line of the input buffer
 * @param width           Width in pixels of the region in the input buffer
 * @param height          Height in pixels of the region in the input buffer
 * @param dst             Pointer to the output buffer
 * @param dst_line_stride Length in bytes of a raster line of the output buffer
 *
 * @return Standard OPL error code. See enumeration for possible result codes.
 */
int opl_hmirror_u16(const u8 *src, int src_line_stride, int width, int height,
		    u8 *dst, int dst_line_stride);

/*!
 * @brief Mirror a 16bpp buffer vertically
 *
 * @param src             Pointer to the input buffer
 * @param src_line_stride Length in bytes of a raster line of the input buffer
 * @param width           Width in pixels of the region in the input buffer
 * @param height          Height in pixels of the region in the input buffer
 * @param dst             Pointer to the output buffer
 * @param dst_line_stride Length in bytes of a raster line of the output buffer
 *
 * @return Standard OPL error code. See enumeration for possible result codes.
 */
int opl_vmirror_u16(const u8 *src, int src_line_stride, int width, int height,
		    u8 *dst, int dst_line_stride);

/*!
 * @brief Rotate a 16bbp buffer 90 degrees clockwise and mirror vertically
 *	  It is equivalent to rotate 270 degree and mirror horizontally
 *
 * @param src             Pointer to the input buffer
 * @param src_line_stride Length in bytes of a raster line of the input buffer
 * @param width           Width in pixels of the region in the input buffer
 * @param height          Height in pixels of the region in the input buffer
 * @param dst             Pointer to the output buffer
 * @param dst_line_stride Length in bytes of a raster line of the output buffer
 *
 * @return Standard OPL error code. See enumeration for possible result codes.
 */
int opl_rotate90_vmirror_u16(const u8 *src, int src_line_stride, int width,
			     int height, u8 *dst, int dst_line_stride);

/*!
 * @brief Rotate a 16bbp buffer 270 degrees clockwise and mirror vertically
 *	  It is equivalent to rotate 90 degree and mirror horizontally
 *
 * @param src             Pointer to the input buffer
 * @param src_line_stride Length in bytes of a raster line of the input buffer
 * @param width           Width in pixels of the region in the input buffer
 * @param height          Height in pixels of the region in the input buffer
 * @param dst             Pointer to the output buffer
 * @param dst_line_stride Length in bytes of a raster line of the output buffer
 *
 * @return Standard OPL error code. See enumeration for possible result codes.
 */
int opl_rotate270_vmirror_u16(const u8 *src, int src_line_stride, int width,
			      int height, u8 *dst, int dst_line_stride);

#endif				/* __OPL_H__ */