Message ID | 20171125173341.14162-6-hdegoede@redhat.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
On Sat, Nov 25, 2017 at 06:33:39PM +0100, Hans de Goede wrote: > Ideally we could use the VBT for this, that would be simple, in > intel_dsi_init() check dev_priv->vbt.dsi.config->rotation, set > connector->display_info.panel_orientation accordingly and call > drm_connector_init_panel_orientation_property(), done. > > Unfortunately vbt.dsi.config->rotation is always 0 even on tablets > with an upside down LCD and where the GOP is properly rotating the > EFI fb in hardware. > > So instead we end up reading the rotation from the primary plane. > > This commit only implements the panel orientation property for DSI > panels on BYT / CHT hardware, as all known non normal oriented panels > sofar are only found on this hardware. > > Changes in v2: > -Read back the rotation applied by the GOP from the primary plane > instead of relying on dev_priv->vbt.dsi.config->rotation, because it > seems that the VBT rotation filed is always 0 even on devices where the > GOP does apply a rotation > > Changes in v3: > -Rewrite the code to read back the orientation from the primary > plane to contain all of this in intel_dsi.c instead of poking a bunch > of holes between all the different layers > > Changes in v6: > -Move hardware readout to intel_dsi_init() Yeah, this is what I had in mind. A small hack, but much more well contained. Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> > > Signed-off-by: Hans de Goede <hdegoede@redhat.com> > --- > drivers/gpu/drm/i915/intel_dsi.c | 28 ++++++++++++++++++++++++++++ > 1 file changed, 28 insertions(+) > > diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c > index f09474b0c4d3..f67d321376e4 100644 > --- a/drivers/gpu/drm/i915/intel_dsi.c > +++ b/drivers/gpu/drm/i915/intel_dsi.c > @@ -1666,6 +1666,27 @@ static const struct drm_connector_funcs intel_dsi_connector_funcs = { > .atomic_duplicate_state = intel_digital_connector_duplicate_state, > }; > > +static int intel_dsi_get_panel_orientation(struct intel_connector *connector) > +{ > + struct drm_i915_private *dev_priv = to_i915(connector->base.dev); > + int orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; > + enum i9xx_plane_id plane; > + u32 val; > + > + if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { > + if (connector->encoder->crtc_mask == BIT(PIPE_B)) > + plane = PLANE_B; > + else > + plane = PLANE_A; > + > + val = I915_READ(DSPCNTR(plane)); > + if (val & DISPPLANE_ROTATE_180) > + orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; > + } > + > + return orientation; > +} > + > static void intel_dsi_add_properties(struct intel_connector *connector) > { > struct drm_i915_private *dev_priv = to_i915(connector->base.dev); > @@ -1681,6 +1702,13 @@ static void intel_dsi_add_properties(struct intel_connector *connector) > allowed_scalers); > > connector->base.state->scaling_mode = DRM_MODE_SCALE_ASPECT; > + > + connector->base.display_info.panel_orientation = > + intel_dsi_get_panel_orientation(connector); > + drm_connector_init_panel_orientation_property( > + &connector->base, > + connector->panel.fixed_mode->hdisplay, > + connector->panel.fixed_mode->vdisplay); > } > } > > -- > 2.14.3 > > _______________________________________________ > Intel-gfx mailing list > Intel-gfx@lists.freedesktop.org > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Hans, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.15-rc1 next-20171128] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Hans-de-Goede/drm-fbdev-Panel-orientation-connector-property-support/20171128-225025 config: i386-randconfig-x074-201748 (attached as .config) compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025 reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): drivers/gpu/drm/i915/intel_dsi.c: In function 'intel_dsi_get_panel_orientation': >> drivers/gpu/drm/i915/intel_dsi.c:1672:21: error: storage size of 'plane' isn't known enum i9xx_plane_id plane; ^~~~~ drivers/gpu/drm/i915/intel_dsi.c:1672:21: warning: unused variable 'plane' [-Wunused-variable] vim +1672 drivers/gpu/drm/i915/intel_dsi.c 1667 1668 static int intel_dsi_get_panel_orientation(struct intel_connector *connector) 1669 { 1670 struct drm_i915_private *dev_priv = to_i915(connector->base.dev); 1671 int orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; > 1672 enum i9xx_plane_id plane; 1673 u32 val; 1674 1675 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { 1676 if (connector->encoder->crtc_mask == BIT(PIPE_B)) 1677 plane = PLANE_B; 1678 else 1679 plane = PLANE_A; 1680 1681 val = I915_READ(DSPCNTR(plane)); 1682 if (val & DISPPLANE_ROTATE_180) 1683 orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; 1684 } 1685 1686 return orientation; 1687 } 1688 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
Hi Hans, I love your patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.15-rc1 next-20171128] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Hans-de-Goede/drm-fbdev-Panel-orientation-connector-property-support/20171128-225025 config: x86_64-randconfig-x012-201748 (attached as .config) compiler: gcc-7 (Debian 7.2.0-12) 7.2.1 20171025 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/gpu/drm/i915/intel_dsi.c: In function 'intel_dsi_get_panel_orientation': drivers/gpu/drm/i915/intel_dsi.c:1672:21: error: storage size of 'plane' isn't known enum i9xx_plane_id plane; ^~~~~ >> drivers/gpu/drm/i915/intel_dsi.c:1672:21: error: unused variable 'plane' [-Werror=unused-variable] cc1: all warnings being treated as errors vim +/plane +1672 drivers/gpu/drm/i915/intel_dsi.c 1667 1668 static int intel_dsi_get_panel_orientation(struct intel_connector *connector) 1669 { 1670 struct drm_i915_private *dev_priv = to_i915(connector->base.dev); 1671 int orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; > 1672 enum i9xx_plane_id plane; 1673 u32 val; 1674 1675 if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { 1676 if (connector->encoder->crtc_mask == BIT(PIPE_B)) 1677 plane = PLANE_B; 1678 else 1679 plane = PLANE_A; 1680 1681 val = I915_READ(DSPCNTR(plane)); 1682 if (val & DISPPLANE_ROTATE_180) 1683 orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; 1684 } 1685 1686 return orientation; 1687 } 1688 --- 0-DAY kernel test infrastructure Open Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation
diff --git a/drivers/gpu/drm/i915/intel_dsi.c b/drivers/gpu/drm/i915/intel_dsi.c index f09474b0c4d3..f67d321376e4 100644 --- a/drivers/gpu/drm/i915/intel_dsi.c +++ b/drivers/gpu/drm/i915/intel_dsi.c @@ -1666,6 +1666,27 @@ static const struct drm_connector_funcs intel_dsi_connector_funcs = { .atomic_duplicate_state = intel_digital_connector_duplicate_state, }; +static int intel_dsi_get_panel_orientation(struct intel_connector *connector) +{ + struct drm_i915_private *dev_priv = to_i915(connector->base.dev); + int orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; + enum i9xx_plane_id plane; + u32 val; + + if (IS_VALLEYVIEW(dev_priv) || IS_CHERRYVIEW(dev_priv)) { + if (connector->encoder->crtc_mask == BIT(PIPE_B)) + plane = PLANE_B; + else + plane = PLANE_A; + + val = I915_READ(DSPCNTR(plane)); + if (val & DISPPLANE_ROTATE_180) + orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; + } + + return orientation; +} + static void intel_dsi_add_properties(struct intel_connector *connector) { struct drm_i915_private *dev_priv = to_i915(connector->base.dev); @@ -1681,6 +1702,13 @@ static void intel_dsi_add_properties(struct intel_connector *connector) allowed_scalers); connector->base.state->scaling_mode = DRM_MODE_SCALE_ASPECT; + + connector->base.display_info.panel_orientation = + intel_dsi_get_panel_orientation(connector); + drm_connector_init_panel_orientation_property( + &connector->base, + connector->panel.fixed_mode->hdisplay, + connector->panel.fixed_mode->vdisplay); } }
Ideally we could use the VBT for this, that would be simple, in intel_dsi_init() check dev_priv->vbt.dsi.config->rotation, set connector->display_info.panel_orientation accordingly and call drm_connector_init_panel_orientation_property(), done. Unfortunately vbt.dsi.config->rotation is always 0 even on tablets with an upside down LCD and where the GOP is properly rotating the EFI fb in hardware. So instead we end up reading the rotation from the primary plane. This commit only implements the panel orientation property for DSI panels on BYT / CHT hardware, as all known non normal oriented panels sofar are only found on this hardware. Changes in v2: -Read back the rotation applied by the GOP from the primary plane instead of relying on dev_priv->vbt.dsi.config->rotation, because it seems that the VBT rotation filed is always 0 even on devices where the GOP does apply a rotation Changes in v3: -Rewrite the code to read back the orientation from the primary plane to contain all of this in intel_dsi.c instead of poking a bunch of holes between all the different layers Changes in v6: -Move hardware readout to intel_dsi_init() Signed-off-by: Hans de Goede <hdegoede@redhat.com> --- drivers/gpu/drm/i915/intel_dsi.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)