Re: [PATCH 44/66] drm/i915: Pass port explicitly to intel_ddi_get_hw_state

Daniel Vetter
2014-05-22T20:30:16Z

On Thu, May 22, 2014 at 04:38:07PM -0300, Paulo Zanoni wrote:
> 2014-04-24 18:55 GMT-03:00 Daniel Vetter <daniel.vetter@ffwll.ch>:
> > Well, the newly created intel_ddi_get_port_state.
> >
> > In general intel_ddi.c has way too intimate knowledge with everyone
> > else as exemplified with all the encoder/connector noodling and the
> > massive exported function list.
> >
> > As a first step explictly pass around the port, first in the encoder
> > callback.
>
> I don't really see the benefit of this patch, and the sentences above
> don't really help me. Can you please clarify?

intel_ddi.c gets called and calls functions all over the place, so this
tries to create a bit a better interface. Our modeset code is fairly
object-oriented overall and generally big scray switch statments which
decode from the object key indicate design problems.

So for that reasons there's a few patches in here to untangle things a bit
and raise clearer barriers between the different pieces.
-Daniel

>
> Anyway, the patch is correct, so: Reviewed-by: Paulo Zanoni
> <paulo.r.zanoni@intel.com>
>
> >
> > Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> > drivers/gpu/drm/i915/intel_crt.c | 8 +++++++-
> > drivers/gpu/drm/i915/intel_ddi.c | 13 ++++++++++---
> > drivers/gpu/drm/i915/intel_drv.h | 3 ++-
> > 3 files changed, 19 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/intel_crt.c b/drivers/gpu/drm/i915/intel_crt.c
> > index 22d8347f7838..f34d1df88918 100644
> > --- a/drivers/gpu/drm/i915/intel_crt.c
> > +++ b/drivers/gpu/drm/i915/intel_crt.c
> > @@ -137,6 +137,12 @@ static void hsw_crt_get_config(struct intel_encoder *encoder,
> > pipe_config->adjusted_mode.flags |= intel_crt_get_flags(encoder);
> > }
> >
> > +static bool hsw_crt_get_hw_state(struct intel_encoder *encoder,
> > + enum pipe *pipe)
> > +{
> > + return intel_ddi_get_port_state(encoder, pipe, PORT_E);
> > +}
> > +
> > /* Note: The caller is required to filter out dpms modes not supported by the
> > * platform. */
> > static void intel_crt_set_dpms(struct intel_encoder *encoder, int mode)
> > @@ -858,7 +864,7 @@ void intel_crt_init(struct drm_device *dev)
> > crt->base.hpd_pin = HPD_CRT;
> > if (HAS_DDI(dev)) {
> > crt->base.get_config = hsw_crt_get_config;
> > - crt->base.get_hw_state = intel_ddi_get_hw_state;
> > + crt->base.get_hw_state = hsw_crt_get_hw_state;
> > } else {
> > crt->base.get_config = intel_crt_get_config;
> > crt->base.get_hw_state = intel_crt_get_hw_state;
> > diff --git a/drivers/gpu/drm/i915/intel_ddi.c b/drivers/gpu/drm/i915/intel_ddi.c
> > index 09ae104d9c2b..ace43c6a6fa4 100644
> > --- a/drivers/gpu/drm/i915/intel_ddi.c
> > +++ b/drivers/gpu/drm/i915/intel_ddi.c
> > @@ -1082,12 +1082,11 @@ bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector)
> > }
> > }
> >
> > -bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
> > - enum pipe *pipe)
> > +bool intel_ddi_get_port_state(struct intel_encoder *encoder,
> > + enum pipe *pipe, enum port port)
> > {
> > struct drm_device *dev = encoder->base.dev;
> > struct drm_i915_private *dev_priv = dev->dev_private;
> > - enum port port = intel_ddi_get_encoder_port(encoder);
> > enum intel_display_power_domain power_domain;
> > u32 tmp;
> > int i;
> > @@ -1135,6 +1134,14 @@ bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
> > return false;
> > }
> >
> > +static bool intel_ddi_get_hw_state(struct intel_encoder *encoder,
> > + enum pipe *pipe)
> > +{
> > + enum port port = intel_ddi_get_encoder_port(encoder);
> > +
> > + return intel_ddi_get_port_state(encoder, pipe, port);
> > +}
> > +
> > static uint32_t intel_ddi_get_crtc_pll(struct drm_i915_private *dev_priv,
> > enum pipe pipe)
> > {
> > diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> > index 2be0b104fbec..ba727b11014a 100644
> > --- a/drivers/gpu/drm/i915/intel_drv.h
> > +++ b/drivers/gpu/drm/i915/intel_drv.h
> > @@ -671,7 +671,8 @@ void intel_prepare_ddi(struct drm_device *dev);
> > void hsw_fdi_link_train(struct drm_crtc *crtc);
> > void intel_ddi_init(struct drm_device *dev, enum port port);
> > enum port intel_ddi_get_encoder_port(struct intel_encoder *intel_encoder);
> > -bool intel_ddi_get_hw_state(struct intel_encoder *encoder, enum pipe *pipe);
> > +bool intel_ddi_get_port_state(struct intel_encoder *encoder, enum pipe *pipe,
> > + enum port port);
> > int intel_ddi_get_cdclk_freq(struct drm_i915_private *dev_priv);
> > void intel_ddi_pll_init(struct drm_device *dev);
> > void intel_ddi_enable_transcoder_func(struct drm_crtc *crtc);
> > --
> > 1.8.1.4
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > http://lists.freedesktop.org/mailman/listinfo/intel-gfx
>
>
>
> --
> Paulo Zanoni

--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch