drm/i915: Use _PICK() for CHICKEN_TRANS()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 24 Oct 2019 12:21:36 +0000 (15:21 +0300)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Mon, 28 Oct 2019 10:47:55 +0000 (12:47 +0200)
Make CHICKEN_TRANS() a bit less special looking by using _PICK().

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20191024122138.25065-1-ville.syrjala@linux.intel.com
Reviewed-by: José Roberto de Souza <jose.souza@intel.com>
drivers/gpu/drm/i915/display/intel_ddi.c
drivers/gpu/drm/i915/display/intel_psr.c
drivers/gpu/drm/i915/i915_reg.h

index c596b1f74fee4721b7b6bfdbdaabb951f99086df..281594bcbfae107cddd0637b39421d58a92bbfec 100644 (file)
@@ -3872,12 +3872,12 @@ static i915_reg_t
 gen9_chicken_trans_reg_by_port(struct drm_i915_private *dev_priv,
                               enum port port)
 {
-       static const i915_reg_t regs[] = {
-               [PORT_A] = CHICKEN_TRANS_EDP,
-               [PORT_B] = CHICKEN_TRANS_A,
-               [PORT_C] = CHICKEN_TRANS_B,
-               [PORT_D] = CHICKEN_TRANS_C,
-               [PORT_E] = CHICKEN_TRANS_A,
+       static const enum transcoder trans[] = {
+               [PORT_A] = TRANSCODER_EDP,
+               [PORT_B] = TRANSCODER_A,
+               [PORT_C] = TRANSCODER_B,
+               [PORT_D] = TRANSCODER_C,
+               [PORT_E] = TRANSCODER_A,
        };
 
        WARN_ON(INTEL_GEN(dev_priv) < 9);
@@ -3885,7 +3885,7 @@ gen9_chicken_trans_reg_by_port(struct drm_i915_private *dev_priv,
        if (WARN_ON(port < PORT_A || port > PORT_E))
                port = PORT_A;
 
-       return regs[port];
+       return CHICKEN_TRANS(trans[port]);
 }
 
 static void intel_enable_ddi_hdmi(struct intel_encoder *encoder,
index 5d3cdd7d4a8d7d778b23c6373cf2f801805c8798..6a9f322d3fca46ef28cc4fe2a1bfefdeaf5984c4 100644 (file)
@@ -740,25 +740,6 @@ static void intel_psr_activate(struct intel_dp *intel_dp)
        dev_priv->psr.active = true;
 }
 
-static i915_reg_t gen9_chicken_trans_reg(struct drm_i915_private *dev_priv,
-                                        enum transcoder cpu_transcoder)
-{
-       static const i915_reg_t regs[] = {
-               [TRANSCODER_A] = CHICKEN_TRANS_A,
-               [TRANSCODER_B] = CHICKEN_TRANS_B,
-               [TRANSCODER_C] = CHICKEN_TRANS_C,
-               [TRANSCODER_EDP] = CHICKEN_TRANS_EDP,
-       };
-
-       WARN_ON(INTEL_GEN(dev_priv) < 9);
-
-       if (WARN_ON(cpu_transcoder >= ARRAY_SIZE(regs) ||
-                   !regs[cpu_transcoder].reg))
-               cpu_transcoder = TRANSCODER_A;
-
-       return regs[cpu_transcoder];
-}
-
 static void intel_psr_enable_source(struct intel_dp *intel_dp,
                                    const struct intel_crtc_state *crtc_state)
 {
@@ -774,8 +755,7 @@ static void intel_psr_enable_source(struct intel_dp *intel_dp,
 
        if (dev_priv->psr.psr2_enabled && (IS_GEN(dev_priv, 9) &&
                                           !IS_GEMINILAKE(dev_priv))) {
-               i915_reg_t reg = gen9_chicken_trans_reg(dev_priv,
-                                                       cpu_transcoder);
+               i915_reg_t reg = CHICKEN_TRANS(cpu_transcoder);
                u32 chicken = I915_READ(reg);
 
                chicken |= PSR2_VSC_ENABLE_PROG_HEADER |
index 7f04b6689ee009d5feed583a2a3fbfc5bcd994e7..446bebf3236c5b82131fe376e280ab8c0f32a983 100644 (file)
@@ -7627,10 +7627,15 @@ enum {
 #define  BDW_DPRS_MASK_VBLANK_SRD      (1 << 0)
 #define CHICKEN_PIPESL_1(pipe) _MMIO_PIPE(pipe, _CHICKEN_PIPESL_1_A, _CHICKEN_PIPESL_1_B)
 
-#define CHICKEN_TRANS_A                _MMIO(0x420c0)
-#define CHICKEN_TRANS_B                _MMIO(0x420c4)
-#define CHICKEN_TRANS_C                _MMIO(0x420c8)
-#define CHICKEN_TRANS_EDP      _MMIO(0x420cc)
+#define _CHICKEN_TRANS_A       0x420c0
+#define _CHICKEN_TRANS_B       0x420c4
+#define _CHICKEN_TRANS_C       0x420c8
+#define _CHICKEN_TRANS_EDP     0x420cc
+#define CHICKEN_TRANS(trans)   _MMIO(_PICK((trans), \
+                                           [TRANSCODER_EDP] = _CHICKEN_TRANS_EDP, \
+                                           [TRANSCODER_A] = _CHICKEN_TRANS_A, \
+                                           [TRANSCODER_B] = _CHICKEN_TRANS_B, \
+                                           [TRANSCODER_C] = _CHICKEN_TRANS_C))
 #define  VSC_DATA_SEL_SOFTWARE_CONTROL (1 << 25) /* GLK and CNL+ */
 #define  DDI_TRAINING_OVERRIDE_ENABLE  (1 << 19)
 #define  DDI_TRAINING_OVERRIDE_VALUE   (1 << 18)