drm_rect.c revision 1.1.1.1.32.1 1 1.1.1.1.32.1 christos /* $NetBSD: drm_rect.c,v 1.1.1.1.32.1 2019/06/10 22:07:57 christos Exp $ */
2 1.1.1.1.32.1 christos
3 1.1 riastrad /*
4 1.1 riastrad * Copyright (C) 2011-2013 Intel Corporation
5 1.1 riastrad *
6 1.1 riastrad * Permission is hereby granted, free of charge, to any person obtaining a
7 1.1 riastrad * copy of this software and associated documentation files (the "Software"),
8 1.1 riastrad * to deal in the Software without restriction, including without limitation
9 1.1 riastrad * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 1.1 riastrad * and/or sell copies of the Software, and to permit persons to whom the
11 1.1 riastrad * Software is furnished to do so, subject to the following conditions:
12 1.1 riastrad *
13 1.1 riastrad * The above copyright notice and this permission notice (including the next
14 1.1 riastrad * paragraph) shall be included in all copies or substantial portions of the
15 1.1 riastrad * Software.
16 1.1 riastrad *
17 1.1 riastrad * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 1.1 riastrad * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 1.1 riastrad * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 1.1 riastrad * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21 1.1 riastrad * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 1.1 riastrad * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 1.1 riastrad * SOFTWARE.
24 1.1 riastrad */
25 1.1 riastrad
26 1.1.1.1.32.1 christos #include <sys/cdefs.h>
27 1.1.1.1.32.1 christos __KERNEL_RCSID(0, "$NetBSD: drm_rect.c,v 1.1.1.1.32.1 2019/06/10 22:07:57 christos Exp $");
28 1.1.1.1.32.1 christos
29 1.1 riastrad #include <linux/errno.h>
30 1.1 riastrad #include <linux/export.h>
31 1.1 riastrad #include <linux/kernel.h>
32 1.1 riastrad #include <drm/drmP.h>
33 1.1 riastrad #include <drm/drm_rect.h>
34 1.1 riastrad
35 1.1 riastrad /**
36 1.1 riastrad * drm_rect_intersect - intersect two rectangles
37 1.1 riastrad * @r1: first rectangle
38 1.1 riastrad * @r2: second rectangle
39 1.1 riastrad *
40 1.1 riastrad * Calculate the intersection of rectangles @r1 and @r2.
41 1.1 riastrad * @r1 will be overwritten with the intersection.
42 1.1 riastrad *
43 1.1 riastrad * RETURNS:
44 1.1 riastrad * %true if rectangle @r1 is still visible after the operation,
45 1.1 riastrad * %false otherwise.
46 1.1 riastrad */
47 1.1 riastrad bool drm_rect_intersect(struct drm_rect *r1, const struct drm_rect *r2)
48 1.1 riastrad {
49 1.1 riastrad r1->x1 = max(r1->x1, r2->x1);
50 1.1 riastrad r1->y1 = max(r1->y1, r2->y1);
51 1.1 riastrad r1->x2 = min(r1->x2, r2->x2);
52 1.1 riastrad r1->y2 = min(r1->y2, r2->y2);
53 1.1 riastrad
54 1.1 riastrad return drm_rect_visible(r1);
55 1.1 riastrad }
56 1.1 riastrad EXPORT_SYMBOL(drm_rect_intersect);
57 1.1 riastrad
58 1.1 riastrad /**
59 1.1 riastrad * drm_rect_clip_scaled - perform a scaled clip operation
60 1.1 riastrad * @src: source window rectangle
61 1.1 riastrad * @dst: destination window rectangle
62 1.1 riastrad * @clip: clip rectangle
63 1.1 riastrad * @hscale: horizontal scaling factor
64 1.1 riastrad * @vscale: vertical scaling factor
65 1.1 riastrad *
66 1.1 riastrad * Clip rectangle @dst by rectangle @clip. Clip rectangle @src by the
67 1.1 riastrad * same amounts multiplied by @hscale and @vscale.
68 1.1 riastrad *
69 1.1 riastrad * RETURNS:
70 1.1 riastrad * %true if rectangle @dst is still visible after being clipped,
71 1.1 riastrad * %false otherwise
72 1.1 riastrad */
73 1.1 riastrad bool drm_rect_clip_scaled(struct drm_rect *src, struct drm_rect *dst,
74 1.1 riastrad const struct drm_rect *clip,
75 1.1 riastrad int hscale, int vscale)
76 1.1 riastrad {
77 1.1 riastrad int diff;
78 1.1 riastrad
79 1.1 riastrad diff = clip->x1 - dst->x1;
80 1.1 riastrad if (diff > 0) {
81 1.1 riastrad int64_t tmp = src->x1 + (int64_t) diff * hscale;
82 1.1 riastrad src->x1 = clamp_t(int64_t, tmp, INT_MIN, INT_MAX);
83 1.1 riastrad }
84 1.1 riastrad diff = clip->y1 - dst->y1;
85 1.1 riastrad if (diff > 0) {
86 1.1 riastrad int64_t tmp = src->y1 + (int64_t) diff * vscale;
87 1.1 riastrad src->y1 = clamp_t(int64_t, tmp, INT_MIN, INT_MAX);
88 1.1 riastrad }
89 1.1 riastrad diff = dst->x2 - clip->x2;
90 1.1 riastrad if (diff > 0) {
91 1.1 riastrad int64_t tmp = src->x2 - (int64_t) diff * hscale;
92 1.1 riastrad src->x2 = clamp_t(int64_t, tmp, INT_MIN, INT_MAX);
93 1.1 riastrad }
94 1.1 riastrad diff = dst->y2 - clip->y2;
95 1.1 riastrad if (diff > 0) {
96 1.1 riastrad int64_t tmp = src->y2 - (int64_t) diff * vscale;
97 1.1 riastrad src->y2 = clamp_t(int64_t, tmp, INT_MIN, INT_MAX);
98 1.1 riastrad }
99 1.1 riastrad
100 1.1 riastrad return drm_rect_intersect(dst, clip);
101 1.1 riastrad }
102 1.1 riastrad EXPORT_SYMBOL(drm_rect_clip_scaled);
103 1.1 riastrad
104 1.1 riastrad static int drm_calc_scale(int src, int dst)
105 1.1 riastrad {
106 1.1 riastrad int scale = 0;
107 1.1 riastrad
108 1.1 riastrad if (src < 0 || dst < 0)
109 1.1 riastrad return -EINVAL;
110 1.1 riastrad
111 1.1 riastrad if (dst == 0)
112 1.1 riastrad return 0;
113 1.1 riastrad
114 1.1 riastrad scale = src / dst;
115 1.1 riastrad
116 1.1 riastrad return scale;
117 1.1 riastrad }
118 1.1 riastrad
119 1.1 riastrad /**
120 1.1 riastrad * drm_rect_calc_hscale - calculate the horizontal scaling factor
121 1.1 riastrad * @src: source window rectangle
122 1.1 riastrad * @dst: destination window rectangle
123 1.1 riastrad * @min_hscale: minimum allowed horizontal scaling factor
124 1.1 riastrad * @max_hscale: maximum allowed horizontal scaling factor
125 1.1 riastrad *
126 1.1 riastrad * Calculate the horizontal scaling factor as
127 1.1 riastrad * (@src width) / (@dst width).
128 1.1 riastrad *
129 1.1 riastrad * RETURNS:
130 1.1 riastrad * The horizontal scaling factor, or errno of out of limits.
131 1.1 riastrad */
132 1.1 riastrad int drm_rect_calc_hscale(const struct drm_rect *src,
133 1.1 riastrad const struct drm_rect *dst,
134 1.1 riastrad int min_hscale, int max_hscale)
135 1.1 riastrad {
136 1.1 riastrad int src_w = drm_rect_width(src);
137 1.1 riastrad int dst_w = drm_rect_width(dst);
138 1.1 riastrad int hscale = drm_calc_scale(src_w, dst_w);
139 1.1 riastrad
140 1.1 riastrad if (hscale < 0 || dst_w == 0)
141 1.1 riastrad return hscale;
142 1.1 riastrad
143 1.1 riastrad if (hscale < min_hscale || hscale > max_hscale)
144 1.1 riastrad return -ERANGE;
145 1.1 riastrad
146 1.1 riastrad return hscale;
147 1.1 riastrad }
148 1.1 riastrad EXPORT_SYMBOL(drm_rect_calc_hscale);
149 1.1 riastrad
150 1.1 riastrad /**
151 1.1 riastrad * drm_rect_calc_vscale - calculate the vertical scaling factor
152 1.1 riastrad * @src: source window rectangle
153 1.1 riastrad * @dst: destination window rectangle
154 1.1 riastrad * @min_vscale: minimum allowed vertical scaling factor
155 1.1 riastrad * @max_vscale: maximum allowed vertical scaling factor
156 1.1 riastrad *
157 1.1 riastrad * Calculate the vertical scaling factor as
158 1.1 riastrad * (@src height) / (@dst height).
159 1.1 riastrad *
160 1.1 riastrad * RETURNS:
161 1.1 riastrad * The vertical scaling factor, or errno of out of limits.
162 1.1 riastrad */
163 1.1 riastrad int drm_rect_calc_vscale(const struct drm_rect *src,
164 1.1 riastrad const struct drm_rect *dst,
165 1.1 riastrad int min_vscale, int max_vscale)
166 1.1 riastrad {
167 1.1 riastrad int src_h = drm_rect_height(src);
168 1.1 riastrad int dst_h = drm_rect_height(dst);
169 1.1 riastrad int vscale = drm_calc_scale(src_h, dst_h);
170 1.1 riastrad
171 1.1 riastrad if (vscale < 0 || dst_h == 0)
172 1.1 riastrad return vscale;
173 1.1 riastrad
174 1.1 riastrad if (vscale < min_vscale || vscale > max_vscale)
175 1.1 riastrad return -ERANGE;
176 1.1 riastrad
177 1.1 riastrad return vscale;
178 1.1 riastrad }
179 1.1 riastrad EXPORT_SYMBOL(drm_rect_calc_vscale);
180 1.1 riastrad
181 1.1 riastrad /**
182 1.1 riastrad * drm_calc_hscale_relaxed - calculate the horizontal scaling factor
183 1.1 riastrad * @src: source window rectangle
184 1.1 riastrad * @dst: destination window rectangle
185 1.1 riastrad * @min_hscale: minimum allowed horizontal scaling factor
186 1.1 riastrad * @max_hscale: maximum allowed horizontal scaling factor
187 1.1 riastrad *
188 1.1 riastrad * Calculate the horizontal scaling factor as
189 1.1 riastrad * (@src width) / (@dst width).
190 1.1 riastrad *
191 1.1 riastrad * If the calculated scaling factor is below @min_vscale,
192 1.1 riastrad * decrease the height of rectangle @dst to compensate.
193 1.1 riastrad *
194 1.1 riastrad * If the calculated scaling factor is above @max_vscale,
195 1.1 riastrad * decrease the height of rectangle @src to compensate.
196 1.1 riastrad *
197 1.1 riastrad * RETURNS:
198 1.1 riastrad * The horizontal scaling factor.
199 1.1 riastrad */
200 1.1 riastrad int drm_rect_calc_hscale_relaxed(struct drm_rect *src,
201 1.1 riastrad struct drm_rect *dst,
202 1.1 riastrad int min_hscale, int max_hscale)
203 1.1 riastrad {
204 1.1 riastrad int src_w = drm_rect_width(src);
205 1.1 riastrad int dst_w = drm_rect_width(dst);
206 1.1 riastrad int hscale = drm_calc_scale(src_w, dst_w);
207 1.1 riastrad
208 1.1 riastrad if (hscale < 0 || dst_w == 0)
209 1.1 riastrad return hscale;
210 1.1 riastrad
211 1.1 riastrad if (hscale < min_hscale) {
212 1.1 riastrad int max_dst_w = src_w / min_hscale;
213 1.1 riastrad
214 1.1 riastrad drm_rect_adjust_size(dst, max_dst_w - dst_w, 0);
215 1.1 riastrad
216 1.1 riastrad return min_hscale;
217 1.1 riastrad }
218 1.1 riastrad
219 1.1 riastrad if (hscale > max_hscale) {
220 1.1 riastrad int max_src_w = dst_w * max_hscale;
221 1.1 riastrad
222 1.1 riastrad drm_rect_adjust_size(src, max_src_w - src_w, 0);
223 1.1 riastrad
224 1.1 riastrad return max_hscale;
225 1.1 riastrad }
226 1.1 riastrad
227 1.1 riastrad return hscale;
228 1.1 riastrad }
229 1.1 riastrad EXPORT_SYMBOL(drm_rect_calc_hscale_relaxed);
230 1.1 riastrad
231 1.1 riastrad /**
232 1.1 riastrad * drm_rect_calc_vscale_relaxed - calculate the vertical scaling factor
233 1.1 riastrad * @src: source window rectangle
234 1.1 riastrad * @dst: destination window rectangle
235 1.1 riastrad * @min_vscale: minimum allowed vertical scaling factor
236 1.1 riastrad * @max_vscale: maximum allowed vertical scaling factor
237 1.1 riastrad *
238 1.1 riastrad * Calculate the vertical scaling factor as
239 1.1 riastrad * (@src height) / (@dst height).
240 1.1 riastrad *
241 1.1 riastrad * If the calculated scaling factor is below @min_vscale,
242 1.1 riastrad * decrease the height of rectangle @dst to compensate.
243 1.1 riastrad *
244 1.1 riastrad * If the calculated scaling factor is above @max_vscale,
245 1.1 riastrad * decrease the height of rectangle @src to compensate.
246 1.1 riastrad *
247 1.1 riastrad * RETURNS:
248 1.1 riastrad * The vertical scaling factor.
249 1.1 riastrad */
250 1.1 riastrad int drm_rect_calc_vscale_relaxed(struct drm_rect *src,
251 1.1 riastrad struct drm_rect *dst,
252 1.1 riastrad int min_vscale, int max_vscale)
253 1.1 riastrad {
254 1.1 riastrad int src_h = drm_rect_height(src);
255 1.1 riastrad int dst_h = drm_rect_height(dst);
256 1.1 riastrad int vscale = drm_calc_scale(src_h, dst_h);
257 1.1 riastrad
258 1.1 riastrad if (vscale < 0 || dst_h == 0)
259 1.1 riastrad return vscale;
260 1.1 riastrad
261 1.1 riastrad if (vscale < min_vscale) {
262 1.1 riastrad int max_dst_h = src_h / min_vscale;
263 1.1 riastrad
264 1.1 riastrad drm_rect_adjust_size(dst, 0, max_dst_h - dst_h);
265 1.1 riastrad
266 1.1 riastrad return min_vscale;
267 1.1 riastrad }
268 1.1 riastrad
269 1.1 riastrad if (vscale > max_vscale) {
270 1.1 riastrad int max_src_h = dst_h * max_vscale;
271 1.1 riastrad
272 1.1 riastrad drm_rect_adjust_size(src, 0, max_src_h - src_h);
273 1.1 riastrad
274 1.1 riastrad return max_vscale;
275 1.1 riastrad }
276 1.1 riastrad
277 1.1 riastrad return vscale;
278 1.1 riastrad }
279 1.1 riastrad EXPORT_SYMBOL(drm_rect_calc_vscale_relaxed);
280 1.1 riastrad
281 1.1 riastrad /**
282 1.1 riastrad * drm_rect_debug_print - print the rectangle information
283 1.1 riastrad * @r: rectangle to print
284 1.1 riastrad * @fixed_point: rectangle is in 16.16 fixed point format
285 1.1 riastrad */
286 1.1 riastrad void drm_rect_debug_print(const struct drm_rect *r, bool fixed_point)
287 1.1 riastrad {
288 1.1 riastrad int w = drm_rect_width(r);
289 1.1 riastrad int h = drm_rect_height(r);
290 1.1 riastrad
291 1.1 riastrad if (fixed_point)
292 1.1 riastrad DRM_DEBUG_KMS("%d.%06ux%d.%06u%+d.%06u%+d.%06u\n",
293 1.1 riastrad w >> 16, ((w & 0xffff) * 15625) >> 10,
294 1.1 riastrad h >> 16, ((h & 0xffff) * 15625) >> 10,
295 1.1 riastrad r->x1 >> 16, ((r->x1 & 0xffff) * 15625) >> 10,
296 1.1 riastrad r->y1 >> 16, ((r->y1 & 0xffff) * 15625) >> 10);
297 1.1 riastrad else
298 1.1 riastrad DRM_DEBUG_KMS("%dx%d%+d%+d\n", w, h, r->x1, r->y1);
299 1.1 riastrad }
300 1.1 riastrad EXPORT_SYMBOL(drm_rect_debug_print);
301 1.1.1.1.32.1 christos
302 1.1.1.1.32.1 christos /**
303 1.1.1.1.32.1 christos * drm_rect_rotate - Rotate the rectangle
304 1.1.1.1.32.1 christos * @r: rectangle to be rotated
305 1.1.1.1.32.1 christos * @width: Width of the coordinate space
306 1.1.1.1.32.1 christos * @height: Height of the coordinate space
307 1.1.1.1.32.1 christos * @rotation: Transformation to be applied
308 1.1.1.1.32.1 christos *
309 1.1.1.1.32.1 christos * Apply @rotation to the coordinates of rectangle @r.
310 1.1.1.1.32.1 christos *
311 1.1.1.1.32.1 christos * @width and @height combined with @rotation define
312 1.1.1.1.32.1 christos * the location of the new origin.
313 1.1.1.1.32.1 christos *
314 1.1.1.1.32.1 christos * @width correcsponds to the horizontal and @height
315 1.1.1.1.32.1 christos * to the vertical axis of the untransformed coordinate
316 1.1.1.1.32.1 christos * space.
317 1.1.1.1.32.1 christos */
318 1.1.1.1.32.1 christos void drm_rect_rotate(struct drm_rect *r,
319 1.1.1.1.32.1 christos int width, int height,
320 1.1.1.1.32.1 christos unsigned int rotation)
321 1.1.1.1.32.1 christos {
322 1.1.1.1.32.1 christos struct drm_rect tmp;
323 1.1.1.1.32.1 christos
324 1.1.1.1.32.1 christos if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) {
325 1.1.1.1.32.1 christos tmp = *r;
326 1.1.1.1.32.1 christos
327 1.1.1.1.32.1 christos if (rotation & BIT(DRM_REFLECT_X)) {
328 1.1.1.1.32.1 christos r->x1 = width - tmp.x2;
329 1.1.1.1.32.1 christos r->x2 = width - tmp.x1;
330 1.1.1.1.32.1 christos }
331 1.1.1.1.32.1 christos
332 1.1.1.1.32.1 christos if (rotation & BIT(DRM_REFLECT_Y)) {
333 1.1.1.1.32.1 christos r->y1 = height - tmp.y2;
334 1.1.1.1.32.1 christos r->y2 = height - tmp.y1;
335 1.1.1.1.32.1 christos }
336 1.1.1.1.32.1 christos }
337 1.1.1.1.32.1 christos
338 1.1.1.1.32.1 christos switch (rotation & DRM_ROTATE_MASK) {
339 1.1.1.1.32.1 christos case BIT(DRM_ROTATE_0):
340 1.1.1.1.32.1 christos break;
341 1.1.1.1.32.1 christos case BIT(DRM_ROTATE_90):
342 1.1.1.1.32.1 christos tmp = *r;
343 1.1.1.1.32.1 christos r->x1 = tmp.y1;
344 1.1.1.1.32.1 christos r->x2 = tmp.y2;
345 1.1.1.1.32.1 christos r->y1 = width - tmp.x2;
346 1.1.1.1.32.1 christos r->y2 = width - tmp.x1;
347 1.1.1.1.32.1 christos break;
348 1.1.1.1.32.1 christos case BIT(DRM_ROTATE_180):
349 1.1.1.1.32.1 christos tmp = *r;
350 1.1.1.1.32.1 christos r->x1 = width - tmp.x2;
351 1.1.1.1.32.1 christos r->x2 = width - tmp.x1;
352 1.1.1.1.32.1 christos r->y1 = height - tmp.y2;
353 1.1.1.1.32.1 christos r->y2 = height - tmp.y1;
354 1.1.1.1.32.1 christos break;
355 1.1.1.1.32.1 christos case BIT(DRM_ROTATE_270):
356 1.1.1.1.32.1 christos tmp = *r;
357 1.1.1.1.32.1 christos r->x1 = height - tmp.y2;
358 1.1.1.1.32.1 christos r->x2 = height - tmp.y1;
359 1.1.1.1.32.1 christos r->y1 = tmp.x1;
360 1.1.1.1.32.1 christos r->y2 = tmp.x2;
361 1.1.1.1.32.1 christos break;
362 1.1.1.1.32.1 christos default:
363 1.1.1.1.32.1 christos break;
364 1.1.1.1.32.1 christos }
365 1.1.1.1.32.1 christos }
366 1.1.1.1.32.1 christos EXPORT_SYMBOL(drm_rect_rotate);
367 1.1.1.1.32.1 christos
368 1.1.1.1.32.1 christos /**
369 1.1.1.1.32.1 christos * drm_rect_rotate_inv - Inverse rotate the rectangle
370 1.1.1.1.32.1 christos * @r: rectangle to be rotated
371 1.1.1.1.32.1 christos * @width: Width of the coordinate space
372 1.1.1.1.32.1 christos * @height: Height of the coordinate space
373 1.1.1.1.32.1 christos * @rotation: Transformation whose inverse is to be applied
374 1.1.1.1.32.1 christos *
375 1.1.1.1.32.1 christos * Apply the inverse of @rotation to the coordinates
376 1.1.1.1.32.1 christos * of rectangle @r.
377 1.1.1.1.32.1 christos *
378 1.1.1.1.32.1 christos * @width and @height combined with @rotation define
379 1.1.1.1.32.1 christos * the location of the new origin.
380 1.1.1.1.32.1 christos *
381 1.1.1.1.32.1 christos * @width correcsponds to the horizontal and @height
382 1.1.1.1.32.1 christos * to the vertical axis of the original untransformed
383 1.1.1.1.32.1 christos * coordinate space, so that you never have to flip
384 1.1.1.1.32.1 christos * them when doing a rotatation and its inverse.
385 1.1.1.1.32.1 christos * That is, if you do:
386 1.1.1.1.32.1 christos *
387 1.1.1.1.32.1 christos * drm_rotate(&r, width, height, rotation);
388 1.1.1.1.32.1 christos * drm_rotate_inv(&r, width, height, rotation);
389 1.1.1.1.32.1 christos *
390 1.1.1.1.32.1 christos * you will always get back the original rectangle.
391 1.1.1.1.32.1 christos */
392 1.1.1.1.32.1 christos void drm_rect_rotate_inv(struct drm_rect *r,
393 1.1.1.1.32.1 christos int width, int height,
394 1.1.1.1.32.1 christos unsigned int rotation)
395 1.1.1.1.32.1 christos {
396 1.1.1.1.32.1 christos struct drm_rect tmp;
397 1.1.1.1.32.1 christos
398 1.1.1.1.32.1 christos switch (rotation & DRM_ROTATE_MASK) {
399 1.1.1.1.32.1 christos case BIT(DRM_ROTATE_0):
400 1.1.1.1.32.1 christos break;
401 1.1.1.1.32.1 christos case BIT(DRM_ROTATE_90):
402 1.1.1.1.32.1 christos tmp = *r;
403 1.1.1.1.32.1 christos r->x1 = width - tmp.y2;
404 1.1.1.1.32.1 christos r->x2 = width - tmp.y1;
405 1.1.1.1.32.1 christos r->y1 = tmp.x1;
406 1.1.1.1.32.1 christos r->y2 = tmp.x2;
407 1.1.1.1.32.1 christos break;
408 1.1.1.1.32.1 christos case BIT(DRM_ROTATE_180):
409 1.1.1.1.32.1 christos tmp = *r;
410 1.1.1.1.32.1 christos r->x1 = width - tmp.x2;
411 1.1.1.1.32.1 christos r->x2 = width - tmp.x1;
412 1.1.1.1.32.1 christos r->y1 = height - tmp.y2;
413 1.1.1.1.32.1 christos r->y2 = height - tmp.y1;
414 1.1.1.1.32.1 christos break;
415 1.1.1.1.32.1 christos case BIT(DRM_ROTATE_270):
416 1.1.1.1.32.1 christos tmp = *r;
417 1.1.1.1.32.1 christos r->x1 = tmp.y1;
418 1.1.1.1.32.1 christos r->x2 = tmp.y2;
419 1.1.1.1.32.1 christos r->y1 = height - tmp.x2;
420 1.1.1.1.32.1 christos r->y2 = height - tmp.x1;
421 1.1.1.1.32.1 christos break;
422 1.1.1.1.32.1 christos default:
423 1.1.1.1.32.1 christos break;
424 1.1.1.1.32.1 christos }
425 1.1.1.1.32.1 christos
426 1.1.1.1.32.1 christos if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) {
427 1.1.1.1.32.1 christos tmp = *r;
428 1.1.1.1.32.1 christos
429 1.1.1.1.32.1 christos if (rotation & BIT(DRM_REFLECT_X)) {
430 1.1.1.1.32.1 christos r->x1 = width - tmp.x2;
431 1.1.1.1.32.1 christos r->x2 = width - tmp.x1;
432 1.1.1.1.32.1 christos }
433 1.1.1.1.32.1 christos
434 1.1.1.1.32.1 christos if (rotation & BIT(DRM_REFLECT_Y)) {
435 1.1.1.1.32.1 christos r->y1 = height - tmp.y2;
436 1.1.1.1.32.1 christos r->y2 = height - tmp.y1;
437 1.1.1.1.32.1 christos }
438 1.1.1.1.32.1 christos }
439 1.1.1.1.32.1 christos }
440 1.1.1.1.32.1 christos EXPORT_SYMBOL(drm_rect_rotate_inv);
441