drm/radeon/kms: rework scaler handling
authorAlex Deucher <alexdeucher@gmail.com>
Thu, 12 Nov 2009 19:55:14 +0000 (14:55 -0500)
committerDave Airlie <airlied@redhat.com>
Wed, 2 Dec 2009 01:36:43 +0000 (11:36 +1000)
Keep requested scaler type in radeon_encoder
and the actual scaler type used in radeon_crtc.
This prevents us from enabling the scaler when it's
not required (i.e., the requested mode is the native
mode).  Also, always set the adjusted mode equal
to the native mode for lvds.

Should fix:
https://bugzilla.redhat.com/show_bug.cgi?id=522271

Signed-off-by: Alex Deucher <alexdeucher@gmail.com>
Acked-by: Jerome Glisse <jglisse@redhat.com>
Signed-off-by: Dave Airlie <airlied@redhat.com>
drivers/gpu/drm/radeon/radeon_display.c
drivers/gpu/drm/radeon/radeon_encoders.c
drivers/gpu/drm/radeon/radeon_legacy_encoders.c
drivers/gpu/drm/radeon/radeon_mode.h

index 8b117e82e5e9eaaaf5d35f4f098e9028a8a72ada..5859109f924ddf77697b5a2faf137bc2ab926057 100644 (file)
@@ -750,9 +750,17 @@ bool radeon_crtc_scaling_mode_fixup(struct drm_crtc *crtc,
                if (encoder->crtc != crtc)
                        continue;
                if (first) {
-                       radeon_crtc->rmx_type = radeon_encoder->rmx_type;
+                       /* set scaling */
+                       if (radeon_encoder->rmx_type == RMX_OFF)
+                               radeon_crtc->rmx_type = RMX_OFF;
+                       else if (mode->hdisplay < radeon_encoder->native_mode.hdisplay ||
+                                mode->vdisplay < radeon_encoder->native_mode.vdisplay)
+                               radeon_crtc->rmx_type = radeon_encoder->rmx_type;
+                       else
+                               radeon_crtc->rmx_type = RMX_OFF;
+                       /* copy native mode */
                        memcpy(&radeon_crtc->native_mode,
-                               &radeon_encoder->native_mode,
+                              &radeon_encoder->native_mode,
                                sizeof(struct drm_display_mode));
                        first = false;
                } else {
index d42bc512d75a8cd1c6a8ae3e91443a67d8121f74..57a29f36115eb3859774bcdfaea4cd3343859ed8 100644 (file)
@@ -163,29 +163,6 @@ radeon_get_connector_for_encoder(struct drm_encoder *encoder)
        return NULL;
 }
 
-/* used for both atom and legacy */
-void radeon_rmx_mode_fixup(struct drm_encoder *encoder,
-                          struct drm_display_mode *mode,
-                          struct drm_display_mode *adjusted_mode)
-{
-       struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
-       struct drm_device *dev = encoder->dev;
-       struct radeon_device *rdev = dev->dev_private;
-       struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
-
-       if (mode->hdisplay < native_mode->hdisplay ||
-           mode->vdisplay < native_mode->vdisplay) {
-               int mode_id = adjusted_mode->base.id;
-               *adjusted_mode = *native_mode;
-               if (!ASIC_IS_AVIVO(rdev)) {
-                       adjusted_mode->hdisplay = mode->hdisplay;
-                       adjusted_mode->vdisplay = mode->vdisplay;
-               }
-               adjusted_mode->base.id = mode_id;
-       }
-}
-
-
 static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
                                   struct drm_display_mode *mode,
                                   struct drm_display_mode *adjusted_mode)
@@ -198,14 +175,24 @@ static bool radeon_atom_mode_fixup(struct drm_encoder *encoder,
        radeon_encoder_set_active_device(encoder);
        drm_mode_set_crtcinfo(adjusted_mode, 0);
 
-       if (radeon_encoder->rmx_type != RMX_OFF)
-               radeon_rmx_mode_fixup(encoder, mode, adjusted_mode);
-
        /* hw bug */
        if ((mode->flags & DRM_MODE_FLAG_INTERLACE)
            && (mode->crtc_vsync_start < (mode->crtc_vdisplay + 2)))
                adjusted_mode->crtc_vsync_start = adjusted_mode->crtc_vdisplay + 2;
 
+       /* get the native mode for LVDS */
+       if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) {
+               struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
+               int mode_id = adjusted_mode->base.id;
+               *adjusted_mode = *native_mode;
+               if (!ASIC_IS_AVIVO(rdev)) {
+                       adjusted_mode->hdisplay = mode->hdisplay;
+                       adjusted_mode->vdisplay = mode->vdisplay;
+               }
+               adjusted_mode->base.id = mode_id;
+       }
+
+       /* get the native mode for TV */
        if (radeon_encoder->active_device & (ATOM_DEVICE_TV_SUPPORT)) {
                struct radeon_encoder_atom_dac *tv_dac = radeon_encoder->enc_priv;
                if (tv_dac) {
index a1d9d29319b29b5c9c8657c6e3839e88cf790063..ae554bfa05488249ea9b03d6414b282dac6d5eb6 100644 (file)
@@ -184,9 +184,9 @@ static void radeon_legacy_lvds_mode_set(struct drm_encoder *encoder,
                radeon_combios_encoder_crtc_scratch_regs(encoder, radeon_crtc->crtc_id);
 }
 
-static bool radeon_legacy_lvds_mode_fixup(struct drm_encoder *encoder,
-                                         struct drm_display_mode *mode,
-                                         struct drm_display_mode *adjusted_mode)
+static bool radeon_legacy_mode_fixup(struct drm_encoder *encoder,
+                                    struct drm_display_mode *mode,
+                                    struct drm_display_mode *adjusted_mode)
 {
        struct radeon_encoder *radeon_encoder = to_radeon_encoder(encoder);
 
@@ -194,15 +194,22 @@ static bool radeon_legacy_lvds_mode_fixup(struct drm_encoder *encoder,
        radeon_encoder_set_active_device(encoder);
        drm_mode_set_crtcinfo(adjusted_mode, 0);
 
-       if (radeon_encoder->rmx_type != RMX_OFF)
-               radeon_rmx_mode_fixup(encoder, mode, adjusted_mode);
+       /* get the native mode for LVDS */
+       if (radeon_encoder->active_device & (ATOM_DEVICE_LCD_SUPPORT)) {
+               struct drm_display_mode *native_mode = &radeon_encoder->native_mode;
+               int mode_id = adjusted_mode->base.id;
+               *adjusted_mode = *native_mode;
+               adjusted_mode->hdisplay = mode->hdisplay;
+               adjusted_mode->vdisplay = mode->vdisplay;
+               adjusted_mode->base.id = mode_id;
+       }
 
        return true;
 }
 
 static const struct drm_encoder_helper_funcs radeon_legacy_lvds_helper_funcs = {
        .dpms = radeon_legacy_lvds_dpms,
-       .mode_fixup = radeon_legacy_lvds_mode_fixup,
+       .mode_fixup = radeon_legacy_mode_fixup,
        .prepare = radeon_legacy_lvds_prepare,
        .mode_set = radeon_legacy_lvds_mode_set,
        .commit = radeon_legacy_lvds_commit,
@@ -214,17 +221,6 @@ static const struct drm_encoder_funcs radeon_legacy_lvds_enc_funcs = {
        .destroy = radeon_enc_destroy,
 };
 
-static bool radeon_legacy_primary_dac_mode_fixup(struct drm_encoder *encoder,
-                                                struct drm_display_mode *mode,
-                                                struct drm_display_mode *adjusted_mode)
-{
-       /* set the active encoder to connector routing */
-       radeon_encoder_set_active_device(encoder);
-       drm_mode_set_crtcinfo(adjusted_mode, 0);
-
-       return true;
-}
-
 static void radeon_legacy_primary_dac_dpms(struct drm_encoder *encoder, int mode)
 {
        struct drm_device *dev = encoder->dev;
@@ -410,7 +406,7 @@ static enum drm_connector_status radeon_legacy_primary_dac_detect(struct drm_enc
 
 static const struct drm_encoder_helper_funcs radeon_legacy_primary_dac_helper_funcs = {
        .dpms = radeon_legacy_primary_dac_dpms,
-       .mode_fixup = radeon_legacy_primary_dac_mode_fixup,
+       .mode_fixup = radeon_legacy_mode_fixup,
        .prepare = radeon_legacy_primary_dac_prepare,
        .mode_set = radeon_legacy_primary_dac_mode_set,
        .commit = radeon_legacy_primary_dac_commit,
@@ -423,17 +419,6 @@ static const struct drm_encoder_funcs radeon_legacy_primary_dac_enc_funcs = {
        .destroy = radeon_enc_destroy,
 };
 
-static bool radeon_legacy_tmds_int_mode_fixup(struct drm_encoder *encoder,
-                                             struct drm_display_mode *mode,
-                                             struct drm_display_mode *adjusted_mode)
-{
-       /* set the active encoder to connector routing */
-       radeon_encoder_set_active_device(encoder);
-       drm_mode_set_crtcinfo(adjusted_mode, 0);
-
-       return true;
-}
-
 static void radeon_legacy_tmds_int_dpms(struct drm_encoder *encoder, int mode)
 {
        struct drm_device *dev = encoder->dev;
@@ -585,7 +570,7 @@ static void radeon_legacy_tmds_int_mode_set(struct drm_encoder *encoder,
 
 static const struct drm_encoder_helper_funcs radeon_legacy_tmds_int_helper_funcs = {
        .dpms = radeon_legacy_tmds_int_dpms,
-       .mode_fixup = radeon_legacy_tmds_int_mode_fixup,
+       .mode_fixup = radeon_legacy_mode_fixup,
        .prepare = radeon_legacy_tmds_int_prepare,
        .mode_set = radeon_legacy_tmds_int_mode_set,
        .commit = radeon_legacy_tmds_int_commit,
@@ -597,17 +582,6 @@ static const struct drm_encoder_funcs radeon_legacy_tmds_int_enc_funcs = {
        .destroy = radeon_enc_destroy,
 };
 
-static bool radeon_legacy_tmds_ext_mode_fixup(struct drm_encoder *encoder,
-                                             struct drm_display_mode *mode,
-                                             struct drm_display_mode *adjusted_mode)
-{
-       /* set the active encoder to connector routing */
-       radeon_encoder_set_active_device(encoder);
-       drm_mode_set_crtcinfo(adjusted_mode, 0);
-
-       return true;
-}
-
 static void radeon_legacy_tmds_ext_dpms(struct drm_encoder *encoder, int mode)
 {
        struct drm_device *dev = encoder->dev;
@@ -742,7 +716,7 @@ static void radeon_ext_tmds_enc_destroy(struct drm_encoder *encoder)
 
 static const struct drm_encoder_helper_funcs radeon_legacy_tmds_ext_helper_funcs = {
        .dpms = radeon_legacy_tmds_ext_dpms,
-       .mode_fixup = radeon_legacy_tmds_ext_mode_fixup,
+       .mode_fixup = radeon_legacy_mode_fixup,
        .prepare = radeon_legacy_tmds_ext_prepare,
        .mode_set = radeon_legacy_tmds_ext_mode_set,
        .commit = radeon_legacy_tmds_ext_commit,
@@ -754,17 +728,6 @@ static const struct drm_encoder_funcs radeon_legacy_tmds_ext_enc_funcs = {
        .destroy = radeon_ext_tmds_enc_destroy,
 };
 
-static bool radeon_legacy_tv_dac_mode_fixup(struct drm_encoder *encoder,
-                                           struct drm_display_mode *mode,
-                                           struct drm_display_mode *adjusted_mode)
-{
-       /* set the active encoder to connector routing */
-       radeon_encoder_set_active_device(encoder);
-       drm_mode_set_crtcinfo(adjusted_mode, 0);
-
-       return true;
-}
-
 static void radeon_legacy_tv_dac_dpms(struct drm_encoder *encoder, int mode)
 {
        struct drm_device *dev = encoder->dev;
@@ -1281,7 +1244,7 @@ static enum drm_connector_status radeon_legacy_tv_dac_detect(struct drm_encoder
 
 static const struct drm_encoder_helper_funcs radeon_legacy_tv_dac_helper_funcs = {
        .dpms = radeon_legacy_tv_dac_dpms,
-       .mode_fixup = radeon_legacy_tv_dac_mode_fixup,
+       .mode_fixup = radeon_legacy_mode_fixup,
        .prepare = radeon_legacy_tv_dac_prepare,
        .mode_set = radeon_legacy_tv_dac_mode_set,
        .commit = radeon_legacy_tv_dac_commit,
index 27ddc9b9a9edc52eba48f7a31d46a5553a5c47b3..d7a29ce19df894d87ce36a805d9985a0612fda3a 100644 (file)
@@ -473,9 +473,6 @@ void radeon_get_clock_info(struct drm_device *dev);
 extern bool radeon_get_atom_connector_info_from_object_table(struct drm_device *dev);
 extern bool radeon_get_atom_connector_info_from_supported_devices_table(struct drm_device *dev);
 
-void radeon_rmx_mode_fixup(struct drm_encoder *encoder,
-                          struct drm_display_mode *mode,
-                          struct drm_display_mode *adjusted_mode);
 void radeon_enc_destroy(struct drm_encoder *encoder);
 void radeon_copy_fb(struct drm_device *dev, struct drm_gem_object *dst_obj);
 void radeon_combios_asic_init(struct drm_device *dev);