aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorAlex Deucher <alexdeucher@gmail.com>2009-10-09 15:14:30 -0400
committerDave Airlie <airlied@redhat.com>2009-10-11 23:42:48 -0400
commitde2103e452ec7f2db5db7c44279735688608381d (patch)
tree10ccecbf806c916a774a486eb83c1b01520c607c /drivers/gpu
parent5a9bcacc0a56f0d9577494e834519480018a6cc3 (diff)
drm/radeon/kms: use drm_mode directly for panel modes
This reduces the number of mode format conversions needed and makes native panel mode support cleaner. Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/radeon/radeon_atombios.c32
-rw-r--r--drivers/gpu/drm/radeon/radeon_combios.c64
-rw-r--r--drivers/gpu/drm/radeon/radeon_connectors.c55
-rw-r--r--drivers/gpu/drm/radeon/radeon_display.c6
-rw-r--r--drivers/gpu/drm/radeon/radeon_encoders.c50
-rw-r--r--drivers/gpu/drm/radeon/radeon_legacy_crtc.c30
-rw-r--r--drivers/gpu/drm/radeon/radeon_mode.h19
7 files changed, 97 insertions, 159 deletions
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c
index 979ddfdf209c..79d4b771c770 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -798,27 +798,29 @@ struct radeon_encoder_atom_dig *radeon_atombios_get_lvds_info(struct
798 if (!lvds) 798 if (!lvds)
799 return NULL; 799 return NULL;
800 800
801 lvds->native_mode.dotclock = 801 lvds->native_mode.clock =
802 le16_to_cpu(lvds_info->info.sLCDTiming.usPixClk) * 10; 802 le16_to_cpu(lvds_info->info.sLCDTiming.usPixClk) * 10;
803 lvds->native_mode.panel_xres = 803 lvds->native_mode.hdisplay =
804 le16_to_cpu(lvds_info->info.sLCDTiming.usHActive); 804 le16_to_cpu(lvds_info->info.sLCDTiming.usHActive);
805 lvds->native_mode.panel_yres = 805 lvds->native_mode.vdisplay =
806 le16_to_cpu(lvds_info->info.sLCDTiming.usVActive); 806 le16_to_cpu(lvds_info->info.sLCDTiming.usVActive);
807 lvds->native_mode.hblank = 807 lvds->native_mode.htotal = lvds->native_mode.hdisplay +
808 le16_to_cpu(lvds_info->info.sLCDTiming.usHBlanking_Time); 808 le16_to_cpu(lvds_info->info.sLCDTiming.usHBlanking_Time);
809 lvds->native_mode.hoverplus = 809 lvds->native_mode.hsync_start = lvds->native_mode.hdisplay +
810 le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncOffset); 810 le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncOffset);
811 lvds->native_mode.hsync_width = 811 lvds->native_mode.hsync_end = lvds->native_mode.hsync_start +
812 le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncWidth); 812 le16_to_cpu(lvds_info->info.sLCDTiming.usHSyncWidth);
813 lvds->native_mode.vblank = 813 lvds->native_mode.vtotal = lvds->native_mode.vdisplay +
814 le16_to_cpu(lvds_info->info.sLCDTiming.usVBlanking_Time); 814 le16_to_cpu(lvds_info->info.sLCDTiming.usVBlanking_Time);
815 lvds->native_mode.voverplus = 815 lvds->native_mode.vsync_start = lvds->native_mode.vdisplay +
816 le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncOffset); 816 le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth);
817 lvds->native_mode.vsync_width = 817 lvds->native_mode.vsync_end = lvds->native_mode.vsync_start +
818 le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth); 818 le16_to_cpu(lvds_info->info.sLCDTiming.usVSyncWidth);
819 lvds->panel_pwr_delay = 819 lvds->panel_pwr_delay =
820 le16_to_cpu(lvds_info->info.usOffDelayInMs); 820 le16_to_cpu(lvds_info->info.usOffDelayInMs);
821 lvds->lvds_misc = lvds_info->info.ucLVDS_Misc; 821 lvds->lvds_misc = lvds_info->info.ucLVDS_Misc;
822 /* set crtc values */
823 drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
822 824
823 encoder->native_mode = lvds->native_mode; 825 encoder->native_mode = lvds->native_mode;
824 } 826 }
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c
index 748265a105b3..e91aba8530b6 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -808,25 +808,25 @@ static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct
808 lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf; 808 lvds->panel_blon_delay = (lvds_ss_gen_cntl >> RADEON_LVDS_PWRSEQ_DELAY2_SHIFT) & 0xf;
809 809
810 if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE) 810 if (fp_vert_stretch & RADEON_VERT_STRETCH_ENABLE)
811 lvds->native_mode.panel_yres = 811 lvds->native_mode.vdisplay =
812 ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >> 812 ((fp_vert_stretch & RADEON_VERT_PANEL_SIZE) >>
813 RADEON_VERT_PANEL_SHIFT) + 1; 813 RADEON_VERT_PANEL_SHIFT) + 1;
814 else 814 else
815 lvds->native_mode.panel_yres = 815 lvds->native_mode.vdisplay =
816 (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1; 816 (RREG32(RADEON_CRTC_V_TOTAL_DISP) >> 16) + 1;
817 817
818 if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE) 818 if (fp_horz_stretch & RADEON_HORZ_STRETCH_ENABLE)
819 lvds->native_mode.panel_xres = 819 lvds->native_mode.hdisplay =
820 (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >> 820 (((fp_horz_stretch & RADEON_HORZ_PANEL_SIZE) >>
821 RADEON_HORZ_PANEL_SHIFT) + 1) * 8; 821 RADEON_HORZ_PANEL_SHIFT) + 1) * 8;
822 else 822 else
823 lvds->native_mode.panel_xres = 823 lvds->native_mode.hdisplay =
824 ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8; 824 ((RREG32(RADEON_CRTC_H_TOTAL_DISP) >> 16) + 1) * 8;
825 825
826 if ((lvds->native_mode.panel_xres < 640) || 826 if ((lvds->native_mode.hdisplay < 640) ||
827 (lvds->native_mode.panel_yres < 480)) { 827 (lvds->native_mode.vdisplay < 480)) {
828 lvds->native_mode.panel_xres = 640; 828 lvds->native_mode.hdisplay = 640;
829 lvds->native_mode.panel_yres = 480; 829 lvds->native_mode.vdisplay = 480;
830 } 830 }
831 831
832 ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3; 832 ppll_div_sel = RREG8(RADEON_CLOCK_CNTL_INDEX + 1) & 0x3;
@@ -846,8 +846,8 @@ static struct radeon_encoder_lvds *radeon_legacy_get_lvds_info_from_regs(struct
846 lvds->panel_vcc_delay = 200; 846 lvds->panel_vcc_delay = 200;
847 847
848 DRM_INFO("Panel info derived from registers\n"); 848 DRM_INFO("Panel info derived from registers\n");
849 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.panel_xres, 849 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
850 lvds->native_mode.panel_yres); 850 lvds->native_mode.vdisplay);
851 851
852 return lvds; 852 return lvds;
853} 853}
@@ -882,11 +882,11 @@ struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
882 882
883 DRM_INFO("Panel ID String: %s\n", stmp); 883 DRM_INFO("Panel ID String: %s\n", stmp);
884 884
885 lvds->native_mode.panel_xres = RBIOS16(lcd_info + 0x19); 885 lvds->native_mode.hdisplay = RBIOS16(lcd_info + 0x19);
886 lvds->native_mode.panel_yres = RBIOS16(lcd_info + 0x1b); 886 lvds->native_mode.vdisplay = RBIOS16(lcd_info + 0x1b);
887 887
888 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.panel_xres, 888 DRM_INFO("Panel Size %dx%d\n", lvds->native_mode.hdisplay,
889 lvds->native_mode.panel_yres); 889 lvds->native_mode.vdisplay);
890 890
891 lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c); 891 lvds->panel_vcc_delay = RBIOS16(lcd_info + 0x2c);
892 if (lvds->panel_vcc_delay > 2000 || lvds->panel_vcc_delay < 0) 892 if (lvds->panel_vcc_delay > 2000 || lvds->panel_vcc_delay < 0)
@@ -944,27 +944,25 @@ struct radeon_encoder_lvds *radeon_combios_get_lvds_info(struct radeon_encoder
944 if (tmp == 0) 944 if (tmp == 0)
945 break; 945 break;
946 946
947 if ((RBIOS16(tmp) == lvds->native_mode.panel_xres) && 947 if ((RBIOS16(tmp) == lvds->native_mode.hdisplay) &&
948 (RBIOS16(tmp + 2) == 948 (RBIOS16(tmp + 2) ==
949 lvds->native_mode.panel_yres)) { 949 lvds->native_mode.vdisplay)) {
950 lvds->native_mode.hblank = 950 lvds->native_mode.htotal = RBIOS16(tmp + 17) * 8;
951 (RBIOS16(tmp + 17) - RBIOS16(tmp + 19)) * 8; 951 lvds->native_mode.hsync_start = RBIOS16(tmp + 21) * 8;
952 lvds->native_mode.hoverplus = 952 lvds->native_mode.hsync_end = (RBIOS8(tmp + 23) +
953 (RBIOS16(tmp + 21) - RBIOS16(tmp + 19) - 953 RBIOS16(tmp + 21)) * 8;
954 1) * 8; 954
955 lvds->native_mode.hsync_width = 955 lvds->native_mode.vtotal = RBIOS16(tmp + 24);
956 RBIOS8(tmp + 23) * 8; 956 lvds->native_mode.vsync_start = RBIOS16(tmp + 28) & 0x7ff;
957 957 lvds->native_mode.vsync_end =
958 lvds->native_mode.vblank = (RBIOS16(tmp + 24) - 958 ((RBIOS16(tmp + 28) & 0xf800) >> 11) +
959 RBIOS16(tmp + 26)); 959 (RBIOS16(tmp + 28) & 0x7ff);
960 lvds->native_mode.voverplus = 960
961 ((RBIOS16(tmp + 28) & 0x7ff) - 961 lvds->native_mode.clock = RBIOS16(tmp + 9) * 10;
962 RBIOS16(tmp + 26));
963 lvds->native_mode.vsync_width =
964 ((RBIOS16(tmp + 28) & 0xf800) >> 11);
965 lvds->native_mode.dotclock =
966 RBIOS16(tmp + 9) * 10;
967 lvds->native_mode.flags = 0; 962 lvds->native_mode.flags = 0;
963 /* set crtc values */
964 drm_mode_set_crtcinfo(&lvds->native_mode, CRTC_INTERLACE_HALVE_V);
965
968 } 966 }
969 } 967 }
970 } else { 968 } else {
diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c b/drivers/gpu/drm/radeon/radeon_connectors.c
index 466f6010a2e4..da3a049e3640 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -178,25 +178,13 @@ static struct drm_display_mode *radeon_fp_native_mode(struct drm_encoder *encode
178 struct drm_device *dev = encoder->dev; 178 struct drm_device *dev = encoder->dev;
179 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 179 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
180 struct drm_display_mode *mode = NULL; 180 struct drm_display_mode *mode = NULL;
181 struct radeon_native_mode *native_mode = &radeon_encoder->native_mode; 181 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
182 182
183 if (native_mode->panel_xres != 0 && 183 if (native_mode->hdisplay != 0 &&
184 native_mode->panel_yres != 0 && 184 native_mode->vdisplay != 0 &&
185 native_mode->dotclock != 0) { 185 native_mode->clock != 0) {
186 mode = drm_mode_create(dev); 186 mode = drm_mode_create(dev);
187 187 *mode = *native_mode;
188 mode->hdisplay = native_mode->panel_xres;
189 mode->vdisplay = native_mode->panel_yres;
190
191 mode->htotal = mode->hdisplay + native_mode->hblank;
192 mode->hsync_start = mode->hdisplay + native_mode->hoverplus;
193 mode->hsync_end = mode->hsync_start + native_mode->hsync_width;
194 mode->vtotal = mode->vdisplay + native_mode->vblank;
195 mode->vsync_start = mode->vdisplay + native_mode->voverplus;
196 mode->vsync_end = mode->vsync_start + native_mode->vsync_width;
197 mode->clock = native_mode->dotclock;
198 mode->flags = 0;
199
200 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER; 188 mode->type = DRM_MODE_TYPE_PREFERRED | DRM_MODE_TYPE_DRIVER;
201 drm_mode_set_name(mode); 189 drm_mode_set_name(mode);
202 190
@@ -210,7 +198,7 @@ static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_conn
210 struct drm_device *dev = encoder->dev; 198 struct drm_device *dev = encoder->dev;
211 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 199 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
212 struct drm_display_mode *mode = NULL; 200 struct drm_display_mode *mode = NULL;
213 struct radeon_native_mode *native_mode = &radeon_encoder->native_mode; 201 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
214 int i; 202 int i;
215 struct mode_size { 203 struct mode_size {
216 int w; 204 int w;
@@ -237,10 +225,10 @@ static void radeon_add_common_modes(struct drm_encoder *encoder, struct drm_conn
237 225
238 for (i = 0; i < 17; i++) { 226 for (i = 0; i < 17; i++) {
239 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) { 227 if (radeon_encoder->devices & (ATOM_DEVICE_LCD_SUPPORT)) {
240 if (common_modes[i].w > native_mode->panel_xres || 228 if (common_modes[i].w > native_mode->hdisplay ||
241 common_modes[i].h > native_mode->panel_yres || 229 common_modes[i].h > native_mode->vdisplay ||
242 (common_modes[i].w == native_mode->panel_xres && 230 (common_modes[i].w == native_mode->hdisplay &&
243 common_modes[i].h == native_mode->panel_yres)) 231 common_modes[i].h == native_mode->vdisplay))
244 continue; 232 continue;
245 } 233 }
246 if (common_modes[i].w < 320 || common_modes[i].h < 200) 234 if (common_modes[i].w < 320 || common_modes[i].h < 200)
@@ -344,28 +332,23 @@ static void radeon_fixup_lvds_native_mode(struct drm_encoder *encoder,
344 struct drm_connector *connector) 332 struct drm_connector *connector)
345{ 333{
346 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 334 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
347 struct radeon_native_mode *native_mode = &radeon_encoder->native_mode; 335 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
348 336
349 /* Try to get native mode details from EDID if necessary */ 337 /* Try to get native mode details from EDID if necessary */
350 if (!native_mode->dotclock) { 338 if (!native_mode->clock) {
351 struct drm_display_mode *t, *mode; 339 struct drm_display_mode *t, *mode;
352 340
353 list_for_each_entry_safe(mode, t, &connector->probed_modes, head) { 341 list_for_each_entry_safe(mode, t, &connector->probed_modes, head) {
354 if (mode->hdisplay == native_mode->panel_xres && 342 if (mode->hdisplay == native_mode->hdisplay &&
355 mode->vdisplay == native_mode->panel_yres) { 343 mode->vdisplay == native_mode->vdisplay) {
356 native_mode->hblank = mode->htotal - mode->hdisplay; 344 *native_mode = *mode;
357 native_mode->hoverplus = mode->hsync_start - mode->hdisplay; 345 drm_mode_set_crtcinfo(native_mode, CRTC_INTERLACE_HALVE_V);
358 native_mode->hsync_width = mode->hsync_end - mode->hsync_start;
359 native_mode->vblank = mode->vtotal - mode->vdisplay;
360 native_mode->voverplus = mode->vsync_start - mode->vdisplay;
361 native_mode->vsync_width = mode->vsync_end - mode->vsync_start;
362 native_mode->dotclock = mode->clock;
363 DRM_INFO("Determined LVDS native mode details from EDID\n"); 346 DRM_INFO("Determined LVDS native mode details from EDID\n");
364 break; 347 break;
365 } 348 }
366 } 349 }
367 } 350 }
368 if (!native_mode->dotclock) { 351 if (!native_mode->clock) {
369 DRM_INFO("No LVDS native mode details, disabling RMX\n"); 352 DRM_INFO("No LVDS native mode details, disabling RMX\n");
370 radeon_encoder->rmx_type = RMX_OFF; 353 radeon_encoder->rmx_type = RMX_OFF;
371 } 354 }
@@ -420,10 +403,10 @@ static enum drm_connector_status radeon_lvds_detect(struct drm_connector *connec
420 403
421 if (encoder) { 404 if (encoder) {
422 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 405 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
423 struct radeon_native_mode *native_mode = &radeon_encoder->native_mode; 406 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
424 407
425 /* check if panel is valid */ 408 /* check if panel is valid */
426 if (native_mode->panel_xres >= 320 && native_mode->panel_yres >= 240) 409 if (native_mode->hdisplay >= 320 && native_mode->vdisplay >= 240)
427 ret = connector_status_connected; 410 ret = connector_status_connected;
428 411
429 } 412 }
diff --git a/drivers/gpu/drm/radeon/radeon_display.c b/drivers/gpu/drm/radeon/radeon_display.c
index b8f234497aca..a20bf43389b3 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -761,7 +761,7 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
761 radeon_crtc->rmx_type = radeon_encoder->rmx_type; 761 radeon_crtc->rmx_type = radeon_encoder->rmx_type;
762 memcpy(&radeon_crtc->native_mode, 762 memcpy(&radeon_crtc->native_mode,
763 &radeon_encoder->native_mode, 763 &radeon_encoder->native_mode,
764 sizeof(struct radeon_native_mode)); 764 sizeof(struct drm_display_mode));
765 first = false; 765 first = false;
766 } else { 766 } else {
767 if (radeon_crtc->rmx_type != radeon_encoder->rmx_type) { 767 if (radeon_crtc->rmx_type != radeon_encoder->rmx_type) {
@@ -779,10 +779,10 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
779 if (radeon_crtc->rmx_type != RMX_OFF) { 779 if (radeon_crtc->rmx_type != RMX_OFF) {
780 fixed20_12 a, b; 780 fixed20_12 a, b;
781 a.full = rfixed_const(crtc->mode.vdisplay); 781 a.full = rfixed_const(crtc->mode.vdisplay);
782 b.full = rfixed_const(radeon_crtc->native_mode.panel_xres); 782 b.full = rfixed_const(radeon_crtc->native_mode.hdisplay);
783 radeon_crtc->vsc.full = rfixed_div(a, b); 783 radeon_crtc->vsc.full = rfixed_div(a, b);
784 a.full = rfixed_const(crtc->mode.hdisplay); 784 a.full = rfixed_const(crtc->mode.hdisplay);
785 b.full = rfixed_const(radeon_crtc->native_mode.panel_yres); 785 b.full = rfixed_const(radeon_crtc->native_mode.vdisplay);
786 radeon_crtc->hsc.full = rfixed_div(a, b); 786 radeon_crtc->hsc.full = rfixed_div(a, b);
787 } else { 787 } else {
788 radeon_crtc->vsc.full = rfixed_const(1); 788 radeon_crtc->vsc.full = rfixed_const(1);
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c b/drivers/gpu/drm/radeon/radeon_encoders.c
index 3e58c6eccea5..a9d4e0ab049a 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -171,49 +171,15 @@ void radeon_rmx_mode_fixup(struct drm_encoder *encoder,
171 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder); 171 struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
172 struct drm_device *dev = encoder->dev; 172 struct drm_device *dev = encoder->dev;
173 struct radeon_device *rdev = dev->dev_private; 173 struct radeon_device *rdev = dev->dev_private;
174 struct radeon_native_mode *native_mode = &radeon_encoder->native_mode; 174 struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
175 175
176 if (mode->hdisplay < native_mode->panel_xres || 176 if (mode->hdisplay < native_mode->hdisplay ||
177 mode->vdisplay < native_mode->panel_yres) { 177 mode->vdisplay < native_mode->vdisplay) {
178 if (ASIC_IS_AVIVO(rdev)) { 178 *adjusted_mode = *native_mode;
179 adjusted_mode->hdisplay = native_mode->panel_xres; 179 if (!ASIC_IS_AVIVO(rdev)) {
180 adjusted_mode->vdisplay = native_mode->panel_yres; 180 adjusted_mode->hdisplay = mode->hdisplay;
181 adjusted_mode->htotal = native_mode->panel_xres + native_mode->hblank; 181 adjusted_mode->vdisplay = mode->vdisplay;
182 adjusted_mode->hsync_start = native_mode->panel_xres + native_mode->hoverplus;
183 adjusted_mode->hsync_end = adjusted_mode->hsync_start + native_mode->hsync_width;
184 adjusted_mode->vtotal = native_mode->panel_yres + native_mode->vblank;
185 adjusted_mode->vsync_start = native_mode->panel_yres + native_mode->voverplus;
186 adjusted_mode->vsync_end = adjusted_mode->vsync_start + native_mode->vsync_width;
187 /* update crtc values */
188 drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V);
189 /* adjust crtc values */
190 adjusted_mode->crtc_hdisplay = native_mode->panel_xres;
191 adjusted_mode->crtc_vdisplay = native_mode->panel_yres;
192 adjusted_mode->crtc_htotal = adjusted_mode->crtc_hdisplay + native_mode->hblank;
193 adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hdisplay + native_mode->hoverplus;
194 adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + native_mode->hsync_width;
195 adjusted_mode->crtc_vtotal = adjusted_mode->crtc_vdisplay + native_mode->vblank;
196 adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + native_mode->voverplus;
197 adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + native_mode->vsync_width;
198 } else {
199 adjusted_mode->htotal = native_mode->panel_xres + native_mode->hblank;
200 adjusted_mode->hsync_start = native_mode->panel_xres + native_mode->hoverplus;
201 adjusted_mode->hsync_end = adjusted_mode->hsync_start + native_mode->hsync_width;
202 adjusted_mode->vtotal = native_mode->panel_yres + native_mode->vblank;
203 adjusted_mode->vsync_start = native_mode->panel_yres + native_mode->voverplus;
204 adjusted_mode->vsync_end = adjusted_mode->vsync_start + native_mode->vsync_width;
205 /* update crtc values */
206 drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V);
207 /* adjust crtc values */
208 adjusted_mode->crtc_htotal = adjusted_mode->crtc_hdisplay + native_mode->hblank;
209 adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hdisplay + native_mode->hoverplus;
210 adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + native_mode->hsync_width;
211 adjusted_mode->crtc_vtotal = adjusted_mode->crtc_vdisplay + native_mode->vblank;
212 adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + native_mode->voverplus;
213 adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + native_mode->vsync_width;
214 } 182 }
215 adjusted_mode->flags = native_mode->flags;
216 adjusted_mode->clock = native_mode->dotclock;
217 } 183 }
218} 184}
219 185
diff --git a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
index ec2df739c119..d22a195cf152 100644
--- a/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
+++ b/drivers/gpu/drm/radeon/radeon_legacy_crtc.c
@@ -48,7 +48,7 @@ static void radeon_legacy_rmx_mode_set(struct drm_crtc *crtc,
48 u32 fp_horz_stretch, fp_vert_stretch, fp_horz_vert_active; 48 u32 fp_horz_stretch, fp_vert_stretch, fp_horz_vert_active;
49 u32 fp_h_sync_strt_wid, fp_crtc_h_total_disp; 49 u32 fp_h_sync_strt_wid, fp_crtc_h_total_disp;
50 u32 fp_v_sync_strt_wid, fp_crtc_v_total_disp; 50 u32 fp_v_sync_strt_wid, fp_crtc_v_total_disp;
51 struct radeon_native_mode *native_mode = &radeon_crtc->native_mode; 51 struct drm_display_mode *native_mode = &radeon_crtc->native_mode;
52 52
53 fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH) & 53 fp_vert_stretch = RREG32(RADEON_FP_VERT_STRETCH) &
54 (RADEON_VERT_STRETCH_RESERVED | 54 (RADEON_VERT_STRETCH_RESERVED |
@@ -95,19 +95,19 @@ static void radeon_legacy_rmx_mode_set(struct drm_crtc *crtc,
95 95
96 fp_horz_vert_active = 0; 96 fp_horz_vert_active = 0;
97 97
98 if (native_mode->panel_xres == 0 || 98 if (native_mode->hdisplay == 0 ||
99 native_mode->panel_yres == 0) { 99 native_mode->vdisplay == 0) {
100 hscale = false; 100 hscale = false;
101 vscale = false; 101 vscale = false;
102 } else { 102 } else {
103 if (xres > native_mode->panel_xres) 103 if (xres > native_mode->hdisplay)
104 xres = native_mode->panel_xres; 104 xres = native_mode->hdisplay;
105 if (yres > native_mode->panel_yres) 105 if (yres > native_mode->vdisplay)
106 yres = native_mode->panel_yres; 106 yres = native_mode->vdisplay;
107 107
108 if (xres == native_mode->panel_xres) 108 if (xres == native_mode->hdisplay)
109 hscale = false; 109 hscale = false;
110 if (yres == native_mode->panel_yres) 110 if (yres == native_mode->vdisplay)
111 vscale = false; 111 vscale = false;
112 } 112 }
113 113
@@ -119,11 +119,11 @@ static void radeon_legacy_rmx_mode_set(struct drm_crtc *crtc,
119 else { 119 else {
120 inc = (fp_horz_stretch & RADEON_HORZ_AUTO_RATIO_INC) ? 1 : 0; 120 inc = (fp_horz_stretch & RADEON_HORZ_AUTO_RATIO_INC) ? 1 : 0;
121 scale = ((xres + inc) * RADEON_HORZ_STRETCH_RATIO_MAX) 121 scale = ((xres + inc) * RADEON_HORZ_STRETCH_RATIO_MAX)
122 / native_mode->panel_xres + 1; 122 / native_mode->hdisplay + 1;
123 fp_horz_stretch |= (((scale) & RADEON_HORZ_STRETCH_RATIO_MASK) | 123 fp_horz_stretch |= (((scale) & RADEON_HORZ_STRETCH_RATIO_MASK) |
124 RADEON_HORZ_STRETCH_BLEND | 124 RADEON_HORZ_STRETCH_BLEND |
125 RADEON_HORZ_STRETCH_ENABLE | 125 RADEON_HORZ_STRETCH_ENABLE |
126 ((native_mode->panel_xres/8-1) << 16)); 126 ((native_mode->hdisplay/8-1) << 16));
127 } 127 }
128 128
129 if (!vscale) 129 if (!vscale)
@@ -131,11 +131,11 @@ static void radeon_legacy_rmx_mode_set(struct drm_crtc *crtc,
131 else { 131 else {
132 inc = (fp_vert_stretch & RADEON_VERT_AUTO_RATIO_INC) ? 1 : 0; 132 inc = (fp_vert_stretch & RADEON_VERT_AUTO_RATIO_INC) ? 1 : 0;
133 scale = ((yres + inc) * RADEON_VERT_STRETCH_RATIO_MAX) 133 scale = ((yres + inc) * RADEON_VERT_STRETCH_RATIO_MAX)
134 / native_mode->panel_yres + 1; 134 / native_mode->vdisplay + 1;
135 fp_vert_stretch |= (((scale) & RADEON_VERT_STRETCH_RATIO_MASK) | 135 fp_vert_stretch |= (((scale) & RADEON_VERT_STRETCH_RATIO_MASK) |
136 RADEON_VERT_STRETCH_ENABLE | 136 RADEON_VERT_STRETCH_ENABLE |
137 RADEON_VERT_STRETCH_BLEND | 137 RADEON_VERT_STRETCH_BLEND |
138 ((native_mode->panel_yres-1) << 12)); 138 ((native_mode->vdisplay-1) << 12));
139 } 139 }
140 break; 140 break;
141 case RMX_CENTER: 141 case RMX_CENTER:
@@ -175,8 +175,8 @@ static void radeon_legacy_rmx_mode_set(struct drm_crtc *crtc,
175 ? RADEON_CRTC_V_SYNC_POL 175 ? RADEON_CRTC_V_SYNC_POL
176 : 0))); 176 : 0)));
177 177
178 fp_horz_vert_active = (((native_mode->panel_yres) & 0xfff) | 178 fp_horz_vert_active = (((native_mode->vdisplay) & 0xfff) |
179 (((native_mode->panel_xres / 8) & 0x1ff) << 16)); 179 (((native_mode->hdisplay / 8) & 0x1ff) << 16));
180 break; 180 break;
181 case RMX_OFF: 181 case RMX_OFF:
182 default: 182 default:
diff --git a/drivers/gpu/drm/radeon/radeon_mode.h b/drivers/gpu/drm/radeon/radeon_mode.h
index e61226817ccf..3d2631be073c 100644
--- a/drivers/gpu/drm/radeon/radeon_mode.h
+++ b/drivers/gpu/drm/radeon/radeon_mode.h
@@ -186,17 +186,6 @@ struct radeon_mode_info {
186 186
187}; 187};
188 188
189struct radeon_native_mode {
190 /* preferred mode */
191 uint32_t panel_xres, panel_yres;
192 uint32_t hoverplus, hsync_width;
193 uint32_t hblank;
194 uint32_t voverplus, vsync_width;
195 uint32_t vblank;
196 uint32_t dotclock;
197 uint32_t flags;
198};
199
200#define MAX_H_CODE_TIMING_LEN 32 189#define MAX_H_CODE_TIMING_LEN 32
201#define MAX_V_CODE_TIMING_LEN 32 190#define MAX_V_CODE_TIMING_LEN 32
202 191
@@ -228,7 +217,7 @@ struct radeon_crtc {
228 enum radeon_rmx_type rmx_type; 217 enum radeon_rmx_type rmx_type;
229 fixed20_12 vsc; 218 fixed20_12 vsc;
230 fixed20_12 hsc; 219 fixed20_12 hsc;
231 struct radeon_native_mode native_mode; 220 struct drm_display_mode native_mode;
232}; 221};
233 222
234struct radeon_encoder_primary_dac { 223struct radeon_encoder_primary_dac {
@@ -248,7 +237,7 @@ struct radeon_encoder_lvds {
248 bool use_bios_dividers; 237 bool use_bios_dividers;
249 uint32_t lvds_gen_cntl; 238 uint32_t lvds_gen_cntl;
250 /* panel mode */ 239 /* panel mode */
251 struct radeon_native_mode native_mode; 240 struct drm_display_mode native_mode;
252}; 241};
253 242
254struct radeon_encoder_tv_dac { 243struct radeon_encoder_tv_dac {
@@ -279,7 +268,7 @@ struct radeon_encoder_atom_dig {
279 uint32_t lvds_misc; 268 uint32_t lvds_misc;
280 uint16_t panel_pwr_delay; 269 uint16_t panel_pwr_delay;
281 /* panel mode */ 270 /* panel mode */
282 struct radeon_native_mode native_mode; 271 struct drm_display_mode native_mode;
283}; 272};
284 273
285struct radeon_encoder_atom_dac { 274struct radeon_encoder_atom_dac {
@@ -294,7 +283,7 @@ struct radeon_encoder {
294 uint32_t flags; 283 uint32_t flags;
295 uint32_t pixel_clock; 284 uint32_t pixel_clock;
296 enum radeon_rmx_type rmx_type; 285 enum radeon_rmx_type rmx_type;
297 struct radeon_native_mode native_mode; 286 struct drm_display_mode native_mode;
298 void *enc_priv; 287 void *enc_priv;
299}; 288};
300 289