2 * Copyright © 2006-2010 Intel Corporation
3 * Copyright (c) 2006 Dave Airlie <airlied@linux.ie>
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
25 * Eric Anholt <eric@anholt.net>
26 * Dave Airlie <airlied@linux.ie>
27 * Jesse Barnes <jesse.barnes@intel.com>
28 * Chris Wilson <chris@chris-wilson.co.uk>
31 #include "intel_drv.h"
34 intel_fixed_panel_mode(struct drm_display_mode
*fixed_mode
,
35 struct drm_display_mode
*adjusted_mode
)
37 adjusted_mode
->hdisplay
= fixed_mode
->hdisplay
;
38 adjusted_mode
->hsync_start
= fixed_mode
->hsync_start
;
39 adjusted_mode
->hsync_end
= fixed_mode
->hsync_end
;
40 adjusted_mode
->htotal
= fixed_mode
->htotal
;
42 adjusted_mode
->vdisplay
= fixed_mode
->vdisplay
;
43 adjusted_mode
->vsync_start
= fixed_mode
->vsync_start
;
44 adjusted_mode
->vsync_end
= fixed_mode
->vsync_end
;
45 adjusted_mode
->vtotal
= fixed_mode
->vtotal
;
47 adjusted_mode
->clock
= fixed_mode
->clock
;
49 drm_mode_set_crtcinfo(adjusted_mode
, CRTC_INTERLACE_HALVE_V
);
52 /* adjusted_mode has been preset to be the panel's fixed mode */
54 intel_pch_panel_fitting(struct drm_device
*dev
,
56 struct drm_display_mode
*mode
,
57 struct drm_display_mode
*adjusted_mode
)
59 struct drm_i915_private
*dev_priv
= dev
->dev_private
;
60 int x
, y
, width
, height
;
62 x
= y
= width
= height
= 0;
64 /* Native modes don't need fitting */
65 if (adjusted_mode
->hdisplay
== mode
->hdisplay
&&
66 adjusted_mode
->vdisplay
== mode
->vdisplay
)
69 switch (fitting_mode
) {
70 case DRM_MODE_SCALE_CENTER
:
71 width
= mode
->hdisplay
;
72 height
= mode
->vdisplay
;
73 x
= (adjusted_mode
->hdisplay
- width
+ 1)/2;
74 y
= (adjusted_mode
->vdisplay
- height
+ 1)/2;
77 case DRM_MODE_SCALE_ASPECT
:
78 /* Scale but preserve the aspect ratio */
80 u32 scaled_width
= adjusted_mode
->hdisplay
* mode
->vdisplay
;
81 u32 scaled_height
= mode
->hdisplay
* adjusted_mode
->vdisplay
;
82 if (scaled_width
> scaled_height
) { /* pillar */
83 width
= scaled_height
/ mode
->vdisplay
;
84 x
= (adjusted_mode
->hdisplay
- width
+ 1) / 2;
86 height
= adjusted_mode
->vdisplay
;
87 } else if (scaled_width
< scaled_height
) { /* letter */
88 height
= scaled_width
/ mode
->hdisplay
;
89 y
= (adjusted_mode
->vdisplay
- height
+ 1) / 2;
91 width
= adjusted_mode
->hdisplay
;
94 width
= adjusted_mode
->hdisplay
;
95 height
= adjusted_mode
->vdisplay
;
101 case DRM_MODE_SCALE_FULLSCREEN
:
103 width
= adjusted_mode
->hdisplay
;
104 height
= adjusted_mode
->vdisplay
;
109 dev_priv
->pch_pf_pos
= (x
<< 16) | y
;
110 dev_priv
->pch_pf_size
= (width
<< 16) | height
;