drm/i915/audio: add register macros for audio config N value
authorJani Nikula <jani.nikula@intel.com>
Mon, 10 Oct 2016 15:04:06 +0000 (18:04 +0300)
committerJani Nikula <jani.nikula@intel.com>
Tue, 11 Oct 2016 14:22:17 +0000 (17:22 +0300)
Have generic macros in line with the rest of the register bit definition
macros instead of a dedicated function in intel_audio.c, and use them.
No functional changes.

Cc: Libin Yang <libin.yang@linux.intel.com>
Reviewed-by: Libin Yang <libin.yang@intel.com>
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/c8709b065ba5cb91b85c54f4e099219e4e68b192.1476111629.git.jani.nikula@intel.com
drivers/gpu/drm/i915/i915_reg.h
drivers/gpu/drm/i915/intel_audio.c

index acc767a52d8e8f3b6966ffbff78c032cfd1bfbe3..595d196f753fa42717b142b5a2ef6543744a7125 100644 (file)
@@ -7332,6 +7332,10 @@ enum {
 #define   AUD_CONFIG_UPPER_N_MASK              (0xff << 20)
 #define   AUD_CONFIG_LOWER_N_SHIFT             4
 #define   AUD_CONFIG_LOWER_N_MASK              (0xfff << 4)
+#define   AUD_CONFIG_N_MASK                    (AUD_CONFIG_UPPER_N_MASK | AUD_CONFIG_LOWER_N_MASK)
+#define   AUD_CONFIG_N(n) \
+       (((((n) >> 12) & 0xff) << AUD_CONFIG_UPPER_N_SHIFT) |   \
+        (((n) & 0xfff) << AUD_CONFIG_LOWER_N_SHIFT))
 #define   AUD_CONFIG_PIXEL_CLOCK_HDMI_SHIFT    16
 #define   AUD_CONFIG_PIXEL_CLOCK_HDMI_MASK     (0xf << 16)
 #define   AUD_CONFIG_PIXEL_CLOCK_HDMI_25175    (0 << 16)
index 34f55f2f44d7e3875b1d4d1af87dc0bea1cabc14..db46ead0c28c72940e1ce6ed69aecba8d93d9b29 100644 (file)
@@ -135,20 +135,6 @@ static int audio_config_get_n(const struct drm_display_mode *adjusted_mode,
        return 0;
 }
 
-static uint32_t audio_config_setup_n_reg(int n, uint32_t val)
-{
-       int n_low, n_up;
-       uint32_t tmp = val;
-
-       n_low = n & 0xfff;
-       n_up = (n >> 12) & 0xff;
-       tmp &= ~(AUD_CONFIG_UPPER_N_MASK | AUD_CONFIG_LOWER_N_MASK);
-       tmp |= ((n_up << AUD_CONFIG_UPPER_N_SHIFT) |
-                       (n_low << AUD_CONFIG_LOWER_N_SHIFT) |
-                       AUD_CONFIG_N_PROG_ENABLE);
-       return tmp;
-}
-
 static bool intel_eld_uptodate(struct drm_connector *connector,
                               i915_reg_t reg_eldv, uint32_t bits_eldv,
                               i915_reg_t reg_elda, uint32_t bits_elda,
@@ -271,10 +257,13 @@ hsw_hdmi_audio_config_update(struct intel_crtc *intel_crtc, enum port port,
        if (adjusted_mode->crtc_clock == TMDS_296M ||
            adjusted_mode->crtc_clock == TMDS_297M) {
                n = audio_config_get_n(adjusted_mode, rate);
-               if (n != 0)
-                       tmp = audio_config_setup_n_reg(n, tmp);
-               else
+               if (n != 0) {
+                       tmp &= ~AUD_CONFIG_N_MASK;
+                       tmp |= AUD_CONFIG_N(n);
+                       tmp |= AUD_CONFIG_N_PROG_ENABLE;
+               } else {
                        DRM_DEBUG_KMS("no suitable N value is found\n");
+               }
        }
 
        I915_WRITE(HSW_AUD_CFG(pipe), tmp);