>-----Original Message----- >From: Zanoni, Paulo R >Sent: Monday, August 14, 2017 2:14 PM >To: Srivatsa, Anusha <anusha.srivatsa@xxxxxxxxx>; intel- >gfx@xxxxxxxxxxxxxxxxxxxxx >Cc: Vivi, Rodrigo <rodrigo.vivi@xxxxxxxxx> >Subject: Re: [PATCH] drm/i915: Split pin mapping into per platform >functions > >Em Qui, 2017-08-10 às 11:42 -0700, Anusha Srivatsa escreveu: >> Cleanup the code. Map the pins in accordance to individual platforms >> rather than according to ports. >> Create separate functions for platforms. >> >> v2: >> - Add missing condition for CoffeeLake. Make platform >> specific functions static. Add function >> i915_ddc_pin_mapping(). >> >> Sugested-by Ville Syrjala <ville.syrjala@xxxxxxxxxxxxxxx> >> Cc: Ville Syrjala <ville.syrjala@xxxxxxxxxxxxxxx> >> Cc: Rodrigo Vivi <rodrigo.vivi@xxxxxxxxx> >> Cc: Clinton Tayloe <clinton.a.taylor@xxxxxxxxx> >> Signed-off-by: Anusha Srivatsa <anusha.srivatsa@xxxxxxxxx> >> --- >> drivers/gpu/drm/i915/intel_hdmi.c | 115 >> ++++++++++++++++++++++++++++++-------- >> 1 file changed, 92 insertions(+), 23 deletions(-) >> >> diff --git a/drivers/gpu/drm/i915/intel_hdmi.c >> b/drivers/gpu/drm/i915/intel_hdmi.c >> index 2ef1ee85129d..41e6ba01ec1c 100644 >> --- a/drivers/gpu/drm/i915/intel_hdmi.c >> +++ b/drivers/gpu/drm/i915/intel_hdmi.c >> @@ -1843,49 +1843,118 @@ void >> intel_hdmi_handle_sink_scrambling(struct intel_encoder *encoder, >> DRM_DEBUG_KMS("sink scrambling handled\n"); >> } >> >> -static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv, >> - enum port port) >> +static u8 chv_ddc_pin_mapping(struct drm_i915_private *dev_priv, > >Bikeshedding: what these functions do is pretty much map ports to DDC pins, so >I'd have named them x_port_to_ddc_pin() since that's the most usual naming >when converting "units", but I'm not opposed to the current naming. Your choice. > > >> enum port port) >> { >> - const struct ddi_vbt_port_info *info = >> - &dev_priv->vbt.ddi_port_info[port]; >> u8 ddc_pin; >> >> - if (info->alternate_ddc_pin) { >> - DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c >> (VBT)\n", >> - info->alternate_ddc_pin, >> port_name(port)); >> - return info->alternate_ddc_pin; >> + switch (port) { >> + > >This is the only switch statement where you added a blank line at this point. Doing >this is not our usual coding style. Will change in the next version. > >> + case PORT_B: >> + ddc_pin = GMBUS_PIN_DPB; >> + break; >> + case PORT_C: >> + ddc_pin = GMBUS_PIN_DPC; >> + break; >> + case PORT_D: >> + ddc_pin = GMBUS_PIN_DPD_CHV; >> + break; >> + default: >> + MISSING_CASE(port); >> + ddc_pin = GMBUS_PIN_DPB; >> + break; >> } >> + return ddc_pin; > >Another bikeshedding which you don't need to implement: just returning the pins >inside the switch statements (return GMBUX_PIN_XYZ) without the ddc_pin >variable would have made the functions much shorter. > Hmm... yes. I agree. >> +} >> + >> +static u8 bxt_ddc_pin_mapping(struct drm_i915_private *dev_priv, >> enum port port) >> +{ >> + u8 ddc_pin; >> >> switch (port) { >> case PORT_B: >> - if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv)) >> - ddc_pin = GMBUS_PIN_1_BXT; >> - else >> - ddc_pin = GMBUS_PIN_DPB; >> + ddc_pin = GMBUS_PIN_1_BXT; >> break; >> case PORT_C: >> - if (IS_GEN9_LP(dev_priv) || HAS_PCH_CNP(dev_priv)) >> - ddc_pin = GMBUS_PIN_2_BXT; >> - else >> - ddc_pin = GMBUS_PIN_DPC; >> + ddc_pin = GMBUS_PIN_2_BXT; >> + break; >> + default: >> + MISSING_CASE(port); >> + ddc_pin = GMBUS_PIN_DPB; > >Now that you've reorganized the code it's very easy to notice that on bxt/cnp the >default value doesn't even match what we return from port B. I wouldn't >complain if you addressed this issue in a follow-up patch. > Yes. Will change. >> + break; >> + } >> + return ddc_pin; >> +} >> + >> +static u8 cnp_ddc_pin_mapping(struct drm_i915_private *dev_priv, >> + enum port port) >> +{ >> + u8 ddc_pin; >> + >> + switch (port) { >> + case PORT_B: >> + ddc_pin = GMBUS_PIN_1_BXT; >> + break; >> + case PORT_C: >> + ddc_pin = GMBUS_PIN_2_BXT; >> break; >> case PORT_D: >> - if (HAS_PCH_CNP(dev_priv)) >> - ddc_pin = GMBUS_PIN_4_CNP; >> - else if (IS_CHERRYVIEW(dev_priv)) >> - ddc_pin = GMBUS_PIN_DPD_CHV; >> - else >> - ddc_pin = GMBUS_PIN_DPD; >> + ddc_pin = GMBUS_PIN_4_CNP; >> + break; >> + default: >> + MISSING_CASE(port); >> + ddc_pin = GMBUS_PIN_DPB; >> + break; >> + } >> + return ddc_pin; >> +} >> + >> +static u8 i915_ddc_pin_mapping(struct drm_i915_private *dev_priv, >> + enum port port) > >The first platform to run this is g4x, so please make the function name start with >g4x_ I thought having i915_ will make it more readable. But will change to g4x_ in the next version. > >> +{ >> + u8 ddc_pin; >> + >> + switch (port) { >> + case PORT_B: >> + ddc_pin = GMBUS_PIN_DPB; >> + break; >> + case PORT_C: >> + ddc_pin = GMBUS_PIN_DPC; >> + break; >> + case PORT_D: >> + ddc_pin = GMBUS_PIN_DPD; >> break; >> default: >> MISSING_CASE(port); >> ddc_pin = GMBUS_PIN_DPB; >> break; >> } >> + return ddc_pin; >> + >> +} >> +static u8 intel_hdmi_ddc_pin(struct drm_i915_private *dev_priv, >> + enum port port) > >Missing blank line between functions. Will take care in the next version. > >> +{ >> + const struct ddi_vbt_port_info *info = >> + &dev_priv->vbt.ddi_port_info[port]; >> + u8 ddc_pin = 0; >In our coding style we usually don't zero-initialize things when they don't need to >be zero-initialized. The advantage of not zero- initializing when we don't need is >that if some rework happens and we suddenly start forgetting to set a sane value, >the compiler will tell us. Got it. Thanks a lot Paulo. > >> + >> + if (info->alternate_ddc_pin) { >> + DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c >> (VBT)\n", >> + info->alternate_ddc_pin, >> port_name(port)); >> + return info->alternate_ddc_pin; >> + } >> + >> + if (IS_CHERRYVIEW(dev_priv)) >> + ddc_pin = chv_ddc_pin_mapping(dev_priv, port); >> + else if (IS_GEN9_LP(dev_priv)) >> + ddc_pin = bxt_ddc_pin_mapping(dev_priv, port); >> + else if (HAS_PCH_CNP(dev_priv)) >> + ddc_pin = cnp_ddc_pin_mapping(dev_priv, port); >> + else >> + ddc_pin = i915_ddc_pin_mapping(dev_priv, port); > >> DRM_DEBUG_KMS("Using DDC pin 0x%x for port %c (platform >default)\n", >> ddc_pin, port_name(port)); >> - > >Please don't remove this line. Yes. Will send the next version with changes soon. Anusha > >> return ddc_pin; >> } >> _______________________________________________ Intel-gfx mailing list Intel-gfx@xxxxxxxxxxxxxxxxxxxxx https://lists.freedesktop.org/mailman/listinfo/intel-gfx