Skip to content

Commit 3515387

Browse files
agd5fairlied
authored andcommitted
drm/radeon/kms: fix panel scaling adjusted mode setup
This should duplicate exactly what the ddx does for both legacy and avivo. Signed-off-by: Alex Deucher <alexdeucher@gmail.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
1 parent a1c4560 commit 3515387

File tree

3 files changed

+53
-22
lines changed

3 files changed

+53
-22
lines changed

drivers/gpu/drm/radeon/radeon_encoders.c

Lines changed: 49 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,53 @@ radeon_get_atom_connector_priv_from_encoder(struct drm_encoder *encoder)
254254
return dig_connector;
255255
}
256256

257+
void radeon_panel_mode_fixup(struct drm_encoder *encoder,
258+
struct drm_display_mode *adjusted_mode)
259+
{
260+
struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
261+
struct drm_device *dev = encoder->dev;
262+
struct radeon_device *rdev = dev->dev_private;
263+
struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
264+
unsigned hblank = native_mode->htotal - native_mode->hdisplay;
265+
unsigned vblank = native_mode->vtotal - native_mode->vdisplay;
266+
unsigned hover = native_mode->hsync_start - native_mode->hdisplay;
267+
unsigned vover = native_mode->vsync_start - native_mode->vdisplay;
268+
unsigned hsync_width = native_mode->hsync_end - native_mode->hsync_start;
269+
unsigned vsync_width = native_mode->vsync_end - native_mode->vsync_start;
270+
271+
adjusted_mode->clock = native_mode->clock;
272+
adjusted_mode->flags = native_mode->flags;
273+
274+
if (ASIC_IS_AVIVO(rdev)) {
275+
adjusted_mode->hdisplay = native_mode->hdisplay;
276+
adjusted_mode->vdisplay = native_mode->vdisplay;
277+
}
278+
279+
adjusted_mode->htotal = native_mode->hdisplay + hblank;
280+
adjusted_mode->hsync_start = native_mode->hdisplay + hover;
281+
adjusted_mode->hsync_end = adjusted_mode->hsync_start + hsync_width;
282+
283+
adjusted_mode->vtotal = native_mode->vdisplay + vblank;
284+
adjusted_mode->vsync_start = native_mode->vdisplay + vover;
285+
adjusted_mode->vsync_end = adjusted_mode->vsync_start + vsync_width;
286+
287+
drm_mode_set_crtcinfo(adjusted_mode, CRTC_INTERLACE_HALVE_V);
288+
289+
if (ASIC_IS_AVIVO(rdev)) {
290+
adjusted_mode->crtc_hdisplay = native_mode->hdisplay;
291+
adjusted_mode->crtc_vdisplay = native_mode->vdisplay;
292+
}
293+
294+
adjusted_mode->crtc_htotal = adjusted_mode->crtc_hdisplay + hblank;
295+
adjusted_mode->crtc_hsync_start = adjusted_mode->crtc_hdisplay + hover;
296+
adjusted_mode->crtc_hsync_end = adjusted_mode->crtc_hsync_start + hsync_width;
297+
298+
adjusted_mode->crtc_vtotal = adjusted_mode->crtc_vdisplay + vblank;
299+
adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + vover;
300+
adjusted_mode->crtc_vsync_end = adjusted_mode->crtc_vsync_start + vsync_width;
301+
302+
}
303+
257304
static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
258305
struct drm_display_mode *mode,
259306
struct drm_display_mode *adjusted_mode)
@@ -275,18 +322,8 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
275322
adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2;
276323

277324
/* get the native mode for LVDS */
278-
if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) {
279-
struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
280-
int mode_id = adjusted_mode->base.id;
281-
*adjusted_mode = *native_mode;
282-
if (!ASIC_IS_AVIVO(rdev)) {
283-
adjusted_mode->hdisplay = mode->hdisplay;
284-
adjusted_mode->vdisplay = mode->vdisplay;
285-
adjusted_mode->crtc_hdisplay = mode->hdisplay;
286-
adjusted_mode->crtc_vdisplay = mode->vdisplay;
287-
}
288-
adjusted_mode->base.id = mode_id;
289-
}
325+
if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT))
326+
radeon_panel_mode_fixup(encoder, adjusted_mode);
290327

291328
/* get the native mode for TV */
292329
if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) {

drivers/gpu/drm/radeon/radeon_legacy_encoders.c

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -228,16 +228,8 @@ static bool radeon_legacy_mode_fixup(struct drm_encoder *encoder,
228228
drm_mode_set_crtcinfo(adjusted_mode, 0);
229229

230230
/* get the native mode for LVDS */
231-
if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) {
232-
struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
233-
int mode_id = adjusted_mode->base.id;
234-
*adjusted_mode = *native_mode;
235-
adjusted_mode->hdisplay = mode->hdisplay;
236-
adjusted_mode->vdisplay = mode->vdisplay;
237-
adjusted_mode->crtc_hdisplay = mode->hdisplay;
238-
adjusted_mode->crtc_vdisplay = mode->vdisplay;
239-
adjusted_mode->base.id = mode_id;
240-
}
231+
if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT))
232+
radeon_panel_mode_fixup(encoder, adjusted_mode);
241233

242234
return true;
243235
}

drivers/gpu/drm/radeon/radeon_mode.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -558,6 +558,8 @@ extern int radeon_static_clocks_init(struct drm_device *dev);
558558
bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
559559
struct drm_display_mode *mode,
560560
struct drm_display_mode *adjusted_mode);
561+
void radeon_panel_mode_fixup(struct drm_encoder *encoder,
562+
struct drm_display_mode *adjusted_mode);
561563
void atom_rv515_force_tv_scaler(struct radeon_device *rdev, struct radeon_crtc *radeon_crtc);
562564

563565
/* legacy tv */

0 commit comments

Comments
 (0)