BACKPORT: drm/i915/dp: allow configuring eDP panel fitting scaling mode
authorYuly Novikov <ynovikov@chromium.org>
Mon, 26 Nov 2012 21:04:32 +0000 (16:04 -0500)
committerGerrit <chrome-bot@google.com>
Tue, 27 Nov 2012 20:03:42 +0000 (12:03 -0800)
LVDS allowed changing panel fitting scaling mode, while eDP didn't.
Copied relevant code from LVDS to eDP.
This also changed eDP default scaling mode to respect aspect ratio.

This patch was upstreamed as commits
53b41837935a4016852b30a6242a510e6927f9c7 and
8e740cd19fd3878453a3794e53c5252110697581,
which currently are on their way into linus' repo, and can be found in
git://people.freedesktop.org/~airlied/linux branch drm-next.

This version of the patch is a bit different from aforementioned commits,
but since backporting them would require cherry-picking 17 more commits,
it was decided to use this version instead.

BUG=chrome-os-partner:13682
TEST=Plug external monitor, switch to mirror mode,
check that aspect ratio is preserved (image is letterboxed/pillarboxed).

Signed-off-by: Yuly Novikov <ynovikov@chromium.org>
Change-Id: If1610945ccd1d69c3afa968916667fbb7de9ee40
Reviewed-on: https://gerrit.chromium.org/gerrit/33355
Reviewed-by: Stéphane Marchesin <marcheu@chromium.org>
drivers/gpu/drm/i915/intel_dp.c

index 6a7fe45..7c99261 100644 (file)
@@ -65,6 +65,7 @@ struct intel_dp {
        int backlight_on_delay;
        int backlight_off_delay;
        struct drm_display_mode *panel_fixed_mode;  /* for eDP */
+       int fitting_mode;  /* for eDP */
        struct delayed_work panel_vdd_work;
        bool want_panel_vdd;
 };
@@ -705,7 +706,7 @@ intel_dp_mode_fixup(struct drm_encoder *encoder, struct drm_display_mode *mode,
 
        if (is_edp(intel_dp) && intel_dp->panel_fixed_mode) {
                intel_fixed_panel_mode(intel_dp->panel_fixed_mode, adjusted_mode);
-               intel_pch_panel_fitting(dev, DRM_MODE_SCALE_FULLSCREEN,
+               intel_pch_panel_fitting(dev, intel_dp->fitting_mode,
                                        mode, adjusted_mode);
                /*
                 * the mode->clock is used to calculate the Data&Link M/N
@@ -2295,6 +2296,22 @@ intel_dp_set_property(struct drm_connector *connector,
                goto done_nomodeset;
        }
 
+       if (is_edp(intel_dp) &&
+               property == connector->dev->mode_config.scaling_mode_property) {
+               if (val == DRM_MODE_SCALE_NONE) {
+                       DRM_DEBUG_KMS("no scaling not supported\n");
+                       return -EINVAL;
+               }
+
+               if (intel_dp->fitting_mode == val) {
+                       /* the eDP scaling property is not changed */
+                       return 0;
+               }
+               intel_dp->fitting_mode = val;
+
+               goto done;
+       }
+
        return -EINVAL;
 
 done:
@@ -2419,6 +2436,15 @@ intel_dp_add_properties(struct drm_device *dev,
 {
        intel_attach_force_audio_property(connector);
        intel_attach_broadcast_rgb_property(connector);
+
+       if (is_edp(intel_dp)) {
+               drm_mode_create_scaling_mode_property(dev);
+               drm_connector_attach_property(
+                       connector,
+                       dev->mode_config.scaling_mode_property,
+                       DRM_MODE_SCALE_ASPECT);
+               intel_dp->fitting_mode = DRM_MODE_SCALE_ASPECT;
+       }
 }
 
 void