drm/i915/hdcp: Convert intel_hdcp_enable to a blanket function
authorSuraj Kandpal <suraj.kandpal@intel.com>
Thu, 26 Oct 2023 12:11:39 +0000 (17:41 +0530)
committerAnkit Nautiyal <ankit.k.nautiyal@intel.com>
Tue, 31 Oct 2023 09:42:24 +0000 (15:12 +0530)
Let's convert intel_hdcp_enable to a blanket function
which just has some conditions which needs to be checked
before connectors enable hdcp.
This cleans up code and avoids code duplication.

--v3
-Keep function name as intel_hdcp_enable() [Jani]

Signed-off-by: Suraj Kandpal <suraj.kandpal@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ankit Nautiyal <ankit.k.nautiyal@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20231026121139.987437-3-suraj.kandpal@intel.com
drivers/gpu/drm/i915/display/intel_ddi.c
drivers/gpu/drm/i915/display/intel_dp_mst.c
drivers/gpu/drm/i915/display/intel_hdcp.c
drivers/gpu/drm/i915/display/intel_hdcp.h

index c4dc1f71da4bc49de0c47e60dff8492f436731c4..2e37708fecdd06847490c558750a96536a2c0cea 100644 (file)
@@ -3259,10 +3259,7 @@ static void intel_enable_ddi(struct intel_atomic_state *state,
        else
                intel_enable_ddi_dp(state, encoder, crtc_state, conn_state);
 
-       /* Enable hdcp if it's desired */
-       if (conn_state->content_protection ==
-           DRM_MODE_CONTENT_PROTECTION_DESIRED)
-               intel_hdcp_enable(state, encoder, crtc_state, conn_state);
+       intel_hdcp_enable(state, encoder, crtc_state, conn_state);
 }
 
 static void intel_disable_ddi_dp(struct intel_atomic_state *state,
index 7b4628f4f124040eae309b7367d2f26c59933e53..4366da79fe817f31cfde1ffe8bc0802297970a53 100644 (file)
@@ -836,10 +836,7 @@ static void intel_mst_enable_dp(struct intel_atomic_state *state,
 
        intel_audio_codec_enable(encoder, pipe_config, conn_state);
 
-       /* Enable hdcp if it's desired */
-       if (conn_state->content_protection ==
-           DRM_MODE_CONTENT_PROTECTION_DESIRED)
-               intel_hdcp_enable(state, encoder, pipe_config, conn_state);
+       intel_hdcp_enable(state, encoder, pipe_config, conn_state);
 }
 
 static bool intel_dp_mst_enc_get_hw_state(struct intel_encoder *encoder,
index 7c0cfcb48521f0bf828b6e06d3a5d67aebe564be..44c0a93f3af824f0426560eed6f445ed37f06bf6 100644 (file)
@@ -2324,10 +2324,10 @@ intel_hdcp_set_streams(struct intel_digital_port *dig_port,
        return 0;
 }
 
-int intel_hdcp_enable(struct intel_atomic_state *state,
-                     struct intel_encoder *encoder,
-                     const struct intel_crtc_state *pipe_config,
-                     const struct drm_connector_state *conn_state)
+static int _intel_hdcp_enable(struct intel_atomic_state *state,
+                             struct intel_encoder *encoder,
+                             const struct intel_crtc_state *pipe_config,
+                             const struct drm_connector_state *conn_state)
 {
        struct drm_i915_private *i915 = to_i915(encoder->base.dev);
        struct intel_connector *connector =
@@ -2404,6 +2404,17 @@ int intel_hdcp_enable(struct intel_atomic_state *state,
        return ret;
 }
 
+void intel_hdcp_enable(struct intel_atomic_state *state,
+                      struct intel_encoder *encoder,
+                      const struct intel_crtc_state *crtc_state,
+                      const struct drm_connector_state *conn_state)
+{
+       /* Enable hdcp if it's desired */
+       if (conn_state->content_protection ==
+           DRM_MODE_CONTENT_PROTECTION_DESIRED)
+               _intel_hdcp_enable(state, encoder, crtc_state, conn_state);
+}
+
 int intel_hdcp_disable(struct intel_connector *connector)
 {
        struct intel_digital_port *dig_port = intel_attached_dig_port(connector);
@@ -2491,7 +2502,7 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
        }
 
        if (desired_and_not_enabled || content_protection_type_changed)
-               intel_hdcp_enable(state, encoder, crtc_state, conn_state);
+               _intel_hdcp_enable(state, encoder, crtc_state, conn_state);
 }
 
 void intel_hdcp_component_fini(struct drm_i915_private *i915)
index 5997c52a0958975931b5e851106f585e0b33ec6d..a9c784fd9ba507a57fee5bc42eab0fda07222590 100644 (file)
@@ -28,10 +28,10 @@ void intel_hdcp_atomic_check(struct drm_connector *connector,
 int intel_hdcp_init(struct intel_connector *connector,
                    struct intel_digital_port *dig_port,
                    const struct intel_hdcp_shim *hdcp_shim);
-int intel_hdcp_enable(struct intel_atomic_state *state,
-                     struct intel_encoder *encoder,
-                     const struct intel_crtc_state *pipe_config,
-                     const struct drm_connector_state *conn_state);
+void intel_hdcp_enable(struct intel_atomic_state *state,
+                      struct intel_encoder *encoder,
+                      const struct intel_crtc_state *pipe_config,
+                      const struct drm_connector_state *conn_state);
 int intel_hdcp_disable(struct intel_connector *connector);
 void intel_hdcp_update_pipe(struct intel_atomic_state *state,
                            struct intel_encoder *encoder,