aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/ipu-v3
diff options
context:
space:
mode:
authorSteve Longerbeam <slongerbeam@gmail.com>2014-06-25 21:05:37 -0400
committerPhilipp Zabel <p.zabel@pengutronix.de>2014-09-02 08:55:46 -0400
commitf835f386a119c3f78f5acb93e86a4f025211739a (patch)
tree25b664ab16429566cf5367a3c0de209157fabef9 /drivers/gpu/ipu-v3
parentae0e9708b30b3eebe5a58e4d055eb49a73d641dd (diff)
gpu: ipu-v3: Add rotation mode conversion utilities
Add two functions: - ipu_degrees_to_rot_mode(): converts a degrees, hflip, and vflip setting to an IPU rotation mode. - ipu_rot_mode_to_degrees(): converts an IPU rotation mode with given hflip and vflip settings to degrees. Signed-off-by: Steve Longerbeam <steve_longerbeam@mentor.com> Signed-off-by: Philipp Zabel <p.zabel@pengutronix.de>
Diffstat (limited to 'drivers/gpu/ipu-v3')
-rw-r--r--drivers/gpu/ipu-v3/ipu-common.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/drivers/gpu/ipu-v3/ipu-common.c b/drivers/gpu/ipu-v3/ipu-common.c
index 49ee990b4d1f..a1d42eed5d06 100644
--- a/drivers/gpu/ipu-v3/ipu-common.c
+++ b/drivers/gpu/ipu-v3/ipu-common.c
@@ -114,6 +114,70 @@ enum ipu_color_space ipu_mbus_code_to_colorspace(u32 mbus_code)
114} 114}
115EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace); 115EXPORT_SYMBOL_GPL(ipu_mbus_code_to_colorspace);
116 116
117int ipu_degrees_to_rot_mode(enum ipu_rotate_mode *mode, int degrees,
118 bool hflip, bool vflip)
119{
120 u32 r90, vf, hf;
121
122 switch (degrees) {
123 case 0:
124 vf = hf = r90 = 0;
125 break;
126 case 90:
127 vf = hf = 0;
128 r90 = 1;
129 break;
130 case 180:
131 vf = hf = 1;
132 r90 = 0;
133 break;
134 case 270:
135 vf = hf = r90 = 1;
136 break;
137 default:
138 return -EINVAL;
139 }
140
141 hf ^= (u32)hflip;
142 vf ^= (u32)vflip;
143
144 *mode = (enum ipu_rotate_mode)((r90 << 2) | (hf << 1) | vf);
145 return 0;
146}
147EXPORT_SYMBOL_GPL(ipu_degrees_to_rot_mode);
148
149int ipu_rot_mode_to_degrees(int *degrees, enum ipu_rotate_mode mode,
150 bool hflip, bool vflip)
151{
152 u32 r90, vf, hf;
153
154 r90 = ((u32)mode >> 2) & 0x1;
155 hf = ((u32)mode >> 1) & 0x1;
156 vf = ((u32)mode >> 0) & 0x1;
157 hf ^= (u32)hflip;
158 vf ^= (u32)vflip;
159
160 switch ((enum ipu_rotate_mode)((r90 << 2) | (hf << 1) | vf)) {
161 case IPU_ROTATE_NONE:
162 *degrees = 0;
163 break;
164 case IPU_ROTATE_90_RIGHT:
165 *degrees = 90;
166 break;
167 case IPU_ROTATE_180:
168 *degrees = 180;
169 break;
170 case IPU_ROTATE_90_LEFT:
171 *degrees = 270;
172 break;
173 default:
174 return -EINVAL;
175 }
176
177 return 0;
178}
179EXPORT_SYMBOL_GPL(ipu_rot_mode_to_degrees);
180
117struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned num) 181struct ipuv3_channel *ipu_idmac_get(struct ipu_soc *ipu, unsigned num)
118{ 182{
119 struct ipuv3_channel *channel; 183 struct ipuv3_channel *channel;