aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_rect.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2014-08-07 20:36:12 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2014-08-07 20:36:12 -0400
commita7d7a143d0b4cb1914705884ca5c25e322dba693 (patch)
tree0ee5e9e43f0863b38a29e8abc293e80eab177d74 /drivers/gpu/drm/drm_rect.c
parent43c40df2c7fedce640a6c39fcdf58764f6bbac5c (diff)
parent7963e9db1b1f842fdc53309baa8714d38e9f5681 (diff)
Merge branch 'drm-next' of git://people.freedesktop.org/~airlied/linux
Pull DRM updates from Dave Airlie: "Like all good pull reqs this ends with a revert, so it must mean we tested it, [ Ed. That's _one_ way of looking at it ] This pull is missing nouveau, Ben has been stuck trying to track down a very longstanding bug that revealed itself due to some other changes. I've asked him to send you a direct pull request for nouveau once he cleans things up. I'm away until Monday so don't want to delay things, you can make a decision on that when he sends it, I have my phone so I can ack things just not really merge much. It has one trivial conflict with your tree in armada_drv.c, and also the pull request contains some component changes that are already in your tree, the base tree from Russell went via Greg's tree already, but some stuff still shows up in here that doesn't when I merge my tree into yours. Otherwise all pretty standard graphics fare, one new driver and changes all over the place. New drivers: - sti kms driver for STMicroelectronics chipsets stih416 and stih407. core: - lots of cleanups to the drm core - DP MST helper code merged - universal cursor planes. - render nodes enabled by default panel: - better panel interfaces - new panel support - non-continuous cock advertising ability ttm: - shrinker fixes i915: - hopefully ditched UMS support - runtime pm fixes - psr tracking and locking - now enabled by default - userptr fixes - backlight brightness fixes - MST support merged - runtime PM for dpms - primary planes locking fixes - gen8 hw semaphore support - fbc fixes - runtime PM on SOix sleep state hw. - mmio base page flipping - lots of vlv/chv fixes. - universal cursor planes radeon: - Hawaii fixes - display scalar support for non-fixed mode displays - new firmware format support - dpm on more asics by default - GPUVM improvements - uncached and wc GTT buffers - BOs > visible VRAM exynos: - i80 interface support - module auto-loading - ipp driver consolidated. armada: - irq handling in crtc layer only - crtc renumbering - add component support - DT interaction changes. tegra: - load as module fixes - eDP bpp and sync polarity fixed - DSI non-continuous clock mode support - better support for importing buffers from nouveau msm: - mdp5/adq8084 v1.3 hw enablement - devicetree clk changse - ifc6410 board working tda998x: - component support - DT documentation update vmwgfx: - fix compat shader namespace" * 'drm-next' of git://people.freedesktop.org/~airlied/linux: (551 commits) Revert "drm: drop redundant drm_file->is_master" drm/panel: simple: Use devm_gpiod_get_optional() drm/dsi: Replace upcasting macro by function drm/panel: ld9040: Replace upcasting macro by function drm/exynos: dp: Modify driver to support drm_panel drm/exynos: Move DP setup into commit() drm/panel: simple: Add AUO B133HTN01 panel support drm/panel: simple: Support delays in panel functions drm/panel: simple: Add proper definition for prepare and unprepare drm/panel: s6e8aa0: Add proper definition for prepare and unprepare drm/panel: ld9040: Add proper definition for prepare and unprepare drm/tegra: Add support for panel prepare and unprepare routines drm/exynos: dsi: Add support for panel prepare and unprepare routines drm/exynos: dpi: Add support for panel prepare and unprepare routines drm/panel: simple: Add dummy prepare and unprepare routines drm/panel: s6e8aa0: Add dummy prepare and unprepare routines drm/panel: ld9040: Add dummy prepare and unprepare routines drm/panel: Provide convenience wrapper for .get_modes() drm/panel: add .prepare() and .unprepare() functions drm/panel: simple: Remove simple-panel compatible ...
Diffstat (limited to 'drivers/gpu/drm/drm_rect.c')
-rw-r--r--drivers/gpu/drm/drm_rect.c140
1 files changed, 140 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_rect.c b/drivers/gpu/drm/drm_rect.c
index 7047ca025787..631f5afd451c 100644
--- a/drivers/gpu/drm/drm_rect.c
+++ b/drivers/gpu/drm/drm_rect.c
@@ -293,3 +293,143 @@ void drm_rect_debug_print(const struct drm_rect *r, bool fixed_point)
293 DRM_DEBUG_KMS("%dx%d%+d%+d\n", w, h, r->x1, r->y1); 293 DRM_DEBUG_KMS("%dx%d%+d%+d\n", w, h, r->x1, r->y1);
294} 294}
295EXPORT_SYMBOL(drm_rect_debug_print); 295EXPORT_SYMBOL(drm_rect_debug_print);
296
297/**
298 * drm_rect_rotate - Rotate the rectangle
299 * @r: rectangle to be rotated
300 * @width: Width of the coordinate space
301 * @height: Height of the coordinate space
302 * @rotation: Transformation to be applied
303 *
304 * Apply @rotation to the coordinates of rectangle @r.
305 *
306 * @width and @height combined with @rotation define
307 * the location of the new origin.
308 *
309 * @width correcsponds to the horizontal and @height
310 * to the vertical axis of the untransformed coordinate
311 * space.
312 */
313void drm_rect_rotate(struct drm_rect *r,
314 int width, int height,
315 unsigned int rotation)
316{
317 struct drm_rect tmp;
318
319 if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) {
320 tmp = *r;
321
322 if (rotation & BIT(DRM_REFLECT_X)) {
323 r->x1 = width - tmp.x2;
324 r->x2 = width - tmp.x1;
325 }
326
327 if (rotation & BIT(DRM_REFLECT_Y)) {
328 r->y1 = height - tmp.y2;
329 r->y2 = height - tmp.y1;
330 }
331 }
332
333 switch (rotation & 0xf) {
334 case BIT(DRM_ROTATE_0):
335 break;
336 case BIT(DRM_ROTATE_90):
337 tmp = *r;
338 r->x1 = tmp.y1;
339 r->x2 = tmp.y2;
340 r->y1 = width - tmp.x2;
341 r->y2 = width - tmp.x1;
342 break;
343 case BIT(DRM_ROTATE_180):
344 tmp = *r;
345 r->x1 = width - tmp.x2;
346 r->x2 = width - tmp.x1;
347 r->y1 = height - tmp.y2;
348 r->y2 = height - tmp.y1;
349 break;
350 case BIT(DRM_ROTATE_270):
351 tmp = *r;
352 r->x1 = height - tmp.y2;
353 r->x2 = height - tmp.y1;
354 r->y1 = tmp.x1;
355 r->y2 = tmp.x2;
356 break;
357 default:
358 break;
359 }
360}
361EXPORT_SYMBOL(drm_rect_rotate);
362
363/**
364 * drm_rect_rotate_inv - Inverse rotate the rectangle
365 * @r: rectangle to be rotated
366 * @width: Width of the coordinate space
367 * @height: Height of the coordinate space
368 * @rotation: Transformation whose inverse is to be applied
369 *
370 * Apply the inverse of @rotation to the coordinates
371 * of rectangle @r.
372 *
373 * @width and @height combined with @rotation define
374 * the location of the new origin.
375 *
376 * @width correcsponds to the horizontal and @height
377 * to the vertical axis of the original untransformed
378 * coordinate space, so that you never have to flip
379 * them when doing a rotatation and its inverse.
380 * That is, if you do:
381 *
382 * drm_rotate(&r, width, height, rotation);
383 * drm_rotate_inv(&r, width, height, rotation);
384 *
385 * you will always get back the original rectangle.
386 */
387void drm_rect_rotate_inv(struct drm_rect *r,
388 int width, int height,
389 unsigned int rotation)
390{
391 struct drm_rect tmp;
392
393 switch (rotation & 0xf) {
394 case BIT(DRM_ROTATE_0):
395 break;
396 case BIT(DRM_ROTATE_90):
397 tmp = *r;
398 r->x1 = width - tmp.y2;
399 r->x2 = width - tmp.y1;
400 r->y1 = tmp.x1;
401 r->y2 = tmp.x2;
402 break;
403 case BIT(DRM_ROTATE_180):
404 tmp = *r;
405 r->x1 = width - tmp.x2;
406 r->x2 = width - tmp.x1;
407 r->y1 = height - tmp.y2;
408 r->y2 = height - tmp.y1;
409 break;
410 case BIT(DRM_ROTATE_270):
411 tmp = *r;
412 r->x1 = tmp.y1;
413 r->x2 = tmp.y2;
414 r->y1 = height - tmp.x2;
415 r->y2 = height - tmp.x1;
416 break;
417 default:
418 break;
419 }
420
421 if (rotation & (BIT(DRM_REFLECT_X) | BIT(DRM_REFLECT_Y))) {
422 tmp = *r;
423
424 if (rotation & BIT(DRM_REFLECT_X)) {
425 r->x1 = width - tmp.x2;
426 r->x2 = width - tmp.x1;
427 }
428
429 if (rotation & BIT(DRM_REFLECT_Y)) {
430 r->y1 = height - tmp.y2;
431 r->y2 = height - tmp.y1;
432 }
433 }
434}
435EXPORT_SYMBOL(drm_rect_rotate_inv);