diff options
author | Y.C. Chen <yc_chen@aspeedtech.com> | 2014-08-28 05:11:04 -0400 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2014-09-16 00:57:47 -0400 |
commit | 94d12b137c2dccdd9a8c6586c96404484e2ab1df (patch) | |
tree | 30ee7f142195aa815d44de4d0fb4458778afada3 | |
parent | b2efb3f0a1db62aff5e824125785ec6731143b6d (diff) |
drm/ast: Add reduced blanking modes for wide screen mode
Signed-off-by: Egbert Eich <eich@suse.com>
Tested-by: Steven You2 Liang <liangyou2@lenovo.com>
Signed-off-by: Y.C. Chen <yc_chen@aspeedtech.com>
v3: based on [PATCH 1/2] drm/ast: Add missing entry to dclk_table[].
Add reduced blanking modes, improve mode matching to
identify these modes by thier sync polarities.
[airlied: argh whitespace damage]
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/ast/ast_mode.c | 42 | ||||
-rw-r--r-- | drivers/gpu/drm/ast/ast_tables.h | 38 |
2 files changed, 56 insertions, 24 deletions
diff --git a/drivers/gpu/drm/ast/ast_mode.c b/drivers/gpu/drm/ast/ast_mode.c index 5389350244f2..19ada0bbe319 100644 --- a/drivers/gpu/drm/ast/ast_mode.c +++ b/drivers/gpu/drm/ast/ast_mode.c | |||
@@ -80,6 +80,8 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo | |||
80 | struct ast_private *ast = crtc->dev->dev_private; | 80 | struct ast_private *ast = crtc->dev->dev_private; |
81 | u32 refresh_rate_index = 0, mode_id, color_index, refresh_rate; | 81 | u32 refresh_rate_index = 0, mode_id, color_index, refresh_rate; |
82 | u32 hborder, vborder; | 82 | u32 hborder, vborder; |
83 | bool check_sync; | ||
84 | struct ast_vbios_enhtable *best = NULL; | ||
83 | 85 | ||
84 | switch (crtc->primary->fb->bits_per_pixel) { | 86 | switch (crtc->primary->fb->bits_per_pixel) { |
85 | case 8: | 87 | case 8: |
@@ -141,14 +143,34 @@ static bool ast_get_vbios_mode_info(struct drm_crtc *crtc, struct drm_display_mo | |||
141 | } | 143 | } |
142 | 144 | ||
143 | refresh_rate = drm_mode_vrefresh(mode); | 145 | refresh_rate = drm_mode_vrefresh(mode); |
144 | while (vbios_mode->enh_table->refresh_rate < refresh_rate) { | 146 | check_sync = vbios_mode->enh_table->flags & WideScreenMode; |
145 | vbios_mode->enh_table++; | 147 | do { |
146 | if ((vbios_mode->enh_table->refresh_rate > refresh_rate) || | 148 | struct ast_vbios_enhtable *loop = vbios_mode->enh_table; |
147 | (vbios_mode->enh_table->refresh_rate == 0xff)) { | 149 | |
148 | vbios_mode->enh_table--; | 150 | while (loop->refresh_rate != 0xff) { |
149 | break; | 151 | if ((check_sync) && |
152 | (((mode->flags & DRM_MODE_FLAG_NVSYNC) && | ||
153 | (loop->flags & PVSync)) || | ||
154 | ((mode->flags & DRM_MODE_FLAG_PVSYNC) && | ||
155 | (loop->flags & NVSync)) || | ||
156 | ((mode->flags & DRM_MODE_FLAG_NHSYNC) && | ||
157 | (loop->flags & PHSync)) || | ||
158 | ((mode->flags & DRM_MODE_FLAG_PHSYNC) && | ||
159 | (loop->flags & NHSync)))) { | ||
160 | loop++; | ||
161 | continue; | ||
162 | } | ||
163 | if (loop->refresh_rate <= refresh_rate | ||
164 | && (!best || loop->refresh_rate > best->refresh_rate)) | ||
165 | best = loop; | ||
166 | loop++; | ||
150 | } | 167 | } |
151 | } | 168 | if (best || !check_sync) |
169 | break; | ||
170 | check_sync = 0; | ||
171 | } while (1); | ||
172 | if (best) | ||
173 | vbios_mode->enh_table = best; | ||
152 | 174 | ||
153 | hborder = (vbios_mode->enh_table->flags & HBorder) ? 8 : 0; | 175 | hborder = (vbios_mode->enh_table->flags & HBorder) ? 8 : 0; |
154 | vborder = (vbios_mode->enh_table->flags & VBorder) ? 8 : 0; | 176 | vborder = (vbios_mode->enh_table->flags & VBorder) ? 8 : 0; |
@@ -419,8 +441,10 @@ static void ast_set_sync_reg(struct drm_device *dev, struct drm_display_mode *mo | |||
419 | struct ast_private *ast = dev->dev_private; | 441 | struct ast_private *ast = dev->dev_private; |
420 | u8 jreg; | 442 | u8 jreg; |
421 | 443 | ||
422 | jreg = ast_io_read8(ast, AST_IO_MISC_PORT_READ); | 444 | jreg = ast_io_read8(ast, AST_IO_MISC_PORT_READ); |
423 | jreg |= (vbios_mode->enh_table->flags & SyncNN); | 445 | jreg &= ~0xC0; |
446 | if (vbios_mode->enh_table->flags & NVSync) jreg |= 0x80; | ||
447 | if (vbios_mode->enh_table->flags & NHSync) jreg |= 0x40; | ||
424 | ast_io_write8(ast, AST_IO_MISC_PORT_WRITE, jreg); | 448 | ast_io_write8(ast, AST_IO_MISC_PORT_WRITE, jreg); |
425 | } | 449 | } |
426 | 450 | ||
diff --git a/drivers/gpu/drm/ast/ast_tables.h b/drivers/gpu/drm/ast/ast_tables.h index 05c01ea85294..3608d5aa7451 100644 --- a/drivers/gpu/drm/ast/ast_tables.h +++ b/drivers/gpu/drm/ast/ast_tables.h | |||
@@ -35,14 +35,18 @@ | |||
35 | #define HalfDCLK 0x00000002 | 35 | #define HalfDCLK 0x00000002 |
36 | #define DoubleScanMode 0x00000004 | 36 | #define DoubleScanMode 0x00000004 |
37 | #define LineCompareOff 0x00000008 | 37 | #define LineCompareOff 0x00000008 |
38 | #define SyncPP 0x00000000 | ||
39 | #define SyncPN 0x00000040 | ||
40 | #define SyncNP 0x00000080 | ||
41 | #define SyncNN 0x000000C0 | ||
42 | #define HBorder 0x00000020 | 38 | #define HBorder 0x00000020 |
43 | #define VBorder 0x00000010 | 39 | #define VBorder 0x00000010 |
44 | #define WideScreenMode 0x00000100 | 40 | #define WideScreenMode 0x00000100 |
45 | #define NewModeInfo 0x00000200 | 41 | #define NewModeInfo 0x00000200 |
42 | #define NHSync 0x00000400 | ||
43 | #define PHSync 0x00000800 | ||
44 | #define NVSync 0x00001000 | ||
45 | #define PVSync 0x00002000 | ||
46 | #define SyncPP (PVSync | PHSync) | ||
47 | #define SyncPN (PVSync | NHSync) | ||
48 | #define SyncNP (NVSync | PHSync) | ||
49 | #define SyncNN (NVSync | NHSync) | ||
46 | 50 | ||
47 | /* DCLK Index */ | 51 | /* DCLK Index */ |
48 | #define VCLK25_175 0x00 | 52 | #define VCLK25_175 0x00 |
@@ -72,6 +76,7 @@ | |||
72 | #define VCLK119 0x17 | 76 | #define VCLK119 0x17 |
73 | #define VCLK85_5 0x18 | 77 | #define VCLK85_5 0x18 |
74 | #define VCLK97_75 0x19 | 78 | #define VCLK97_75 0x19 |
79 | #define VCLK118_25 0x1A | ||
75 | 80 | ||
76 | static struct ast_vbios_dclk_info dclk_table[] = { | 81 | static struct ast_vbios_dclk_info dclk_table[] = { |
77 | {0x2C, 0xE7, 0x03}, /* 00: VCLK25_175 */ | 82 | {0x2C, 0xE7, 0x03}, /* 00: VCLK25_175 */ |
@@ -100,6 +105,7 @@ static struct ast_vbios_dclk_info dclk_table[] = { | |||
100 | {0x77, 0x58, 0x80}, /* 17: VCLK119 */ | 105 | {0x77, 0x58, 0x80}, /* 17: VCLK119 */ |
101 | {0x32, 0x67, 0x80}, /* 18: VCLK85_5 */ | 106 | {0x32, 0x67, 0x80}, /* 18: VCLK85_5 */ |
102 | {0x6a, 0x6d, 0x80}, /* 19: VCLK97_75 */ | 107 | {0x6a, 0x6d, 0x80}, /* 19: VCLK97_75 */ |
108 | {0x3b, 0x2c, 0x81}, /* 1A: VCLK118_25 */ | ||
103 | }; | 109 | }; |
104 | 110 | ||
105 | static struct ast_vbios_stdtable vbios_stdtable[] = { | 111 | static struct ast_vbios_stdtable vbios_stdtable[] = { |
@@ -246,8 +252,10 @@ static struct ast_vbios_enhtable res_1360x768[] = { | |||
246 | static struct ast_vbios_enhtable res_1600x900[] = { | 252 | static struct ast_vbios_enhtable res_1600x900[] = { |
247 | {1760, 1600, 48, 32, 926, 900, 3, 5, VCLK97_75, /* 60Hz CVT RB */ | 253 | {1760, 1600, 48, 32, 926, 900, 3, 5, VCLK97_75, /* 60Hz CVT RB */ |
248 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x3A }, | 254 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x3A }, |
249 | {1760, 1600, 48, 32, 926, 900, 3, 5, VCLK97_75, /* end */ | 255 | {2112, 1600, 88,168, 934, 900, 3, 5, VCLK118_25, /* 60Hz CVT */ |
250 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 1, 0x3A } | 256 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x3A }, |
257 | {2112, 1600, 88,168, 934, 900, 3, 5, VCLK118_25, /* 60Hz CVT */ | ||
258 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x3A }, | ||
251 | }; | 259 | }; |
252 | 260 | ||
253 | static struct ast_vbios_enhtable res_1920x1080[] = { | 261 | static struct ast_vbios_enhtable res_1920x1080[] = { |
@@ -261,11 +269,11 @@ static struct ast_vbios_enhtable res_1920x1080[] = { | |||
261 | /* 16:10 */ | 269 | /* 16:10 */ |
262 | static struct ast_vbios_enhtable res_1280x800[] = { | 270 | static struct ast_vbios_enhtable res_1280x800[] = { |
263 | {1440, 1280, 48, 32, 823, 800, 3, 6, VCLK71, /* 60Hz RB */ | 271 | {1440, 1280, 48, 32, 823, 800, 3, 6, VCLK71, /* 60Hz RB */ |
264 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 35 }, | 272 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x35 }, |
265 | {1680, 1280, 72,128, 831, 800, 3, 6, VCLK83_5, /* 60Hz */ | 273 | {1680, 1280, 72,128, 831, 800, 3, 6, VCLK83_5, /* 60Hz */ |
266 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x35 }, | 274 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x35 }, |
267 | {1680, 1280, 72,128, 831, 800, 3, 6, VCLK83_5, /* 60Hz */ | 275 | {1680, 1280, 72,128, 831, 800, 3, 6, VCLK83_5, /* 60Hz */ |
268 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 1, 0x35 }, | 276 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x35 }, |
269 | 277 | ||
270 | }; | 278 | }; |
271 | 279 | ||
@@ -273,24 +281,24 @@ static struct ast_vbios_enhtable res_1440x900[] = { | |||
273 | {1600, 1440, 48, 32, 926, 900, 3, 6, VCLK88_75, /* 60Hz RB */ | 281 | {1600, 1440, 48, 32, 926, 900, 3, 6, VCLK88_75, /* 60Hz RB */ |
274 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x36 }, | 282 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x36 }, |
275 | {1904, 1440, 80,152, 934, 900, 3, 6, VCLK106_5, /* 60Hz */ | 283 | {1904, 1440, 80,152, 934, 900, 3, 6, VCLK106_5, /* 60Hz */ |
276 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x36 }, | 284 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x36 }, |
277 | {1904, 1440, 80,152, 934, 900, 3, 6, VCLK106_5, /* 60Hz */ | 285 | {1904, 1440, 80,152, 934, 900, 3, 6, VCLK106_5, /* 60Hz */ |
278 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 1, 0x36 }, | 286 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x36 }, |
279 | }; | 287 | }; |
280 | 288 | ||
281 | static struct ast_vbios_enhtable res_1680x1050[] = { | 289 | static struct ast_vbios_enhtable res_1680x1050[] = { |
282 | {1840, 1680, 48, 32, 1080, 1050, 3, 6, VCLK119, /* 60Hz RB */ | 290 | {1840, 1680, 48, 32, 1080, 1050, 3, 6, VCLK119, /* 60Hz RB */ |
283 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x37 }, | 291 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x37 }, |
284 | {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */ | 292 | {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */ |
285 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x37 }, | 293 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 2, 0x37 }, |
286 | {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */ | 294 | {2240, 1680,104,176, 1089, 1050, 3, 6, VCLK146_25, /* 60Hz */ |
287 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 1, 0x37 }, | 295 | (SyncPN | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 2, 0x37 }, |
288 | }; | 296 | }; |
289 | 297 | ||
290 | static struct ast_vbios_enhtable res_1920x1200[] = { | 298 | static struct ast_vbios_enhtable res_1920x1200[] = { |
291 | {2080, 1920, 48, 32, 1235, 1200, 3, 6, VCLK154, /* 60Hz */ | 299 | {2080, 1920, 48, 32, 1235, 1200, 3, 6, VCLK154, /* 60Hz RB*/ |
292 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x34 }, | 300 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 60, 1, 0x34 }, |
293 | {2080, 1920, 48, 32, 1235, 1200, 3, 6, VCLK154, /* 60Hz */ | 301 | {2080, 1920, 48, 32, 1235, 1200, 3, 6, VCLK154, /* 60Hz RB */ |
294 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 1, 0x34 }, | 302 | (SyncNP | Charx8Dot | LineCompareOff | WideScreenMode | NewModeInfo), 0xFF, 1, 0x34 }, |
295 | }; | 303 | }; |
296 | 304 | ||