From: Anshuman Gupta <anshuman.gu...@intel.com>

Add support to enable/disable PLANE_SURF Decryption Request bit.
It requires only to enable plane decryption support when following
condition met.
1. PXP session is enabled.
2. Buffer object is protected.

v2:
- Used gen fb obj user_flags instead gem_object_metadata. [Krishna]

v3:
- intel_pxp_gem_object_status() API changes.

v4: use intel_pxp_is_active (Daniele)
v5: rebase and use the new protected object status checker (Daniele)

Cc: Bommu Krishnaiah <krishnaiah.bo...@intel.com>
Cc: Huang Sean Z <sean.z.hu...@intel.com>
Cc: Gaurav Kumar <kumar.gau...@intel.com>
Signed-off-by: Anshuman Gupta <anshuman.gu...@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospu...@intel.com>
---
 drivers/gpu/drm/i915/display/skl_universal_plane.c | 14 +++++++++++---
 drivers/gpu/drm/i915/i915_reg.h                    |  1 +
 2 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/skl_universal_plane.c 
b/drivers/gpu/drm/i915/display/skl_universal_plane.c
index 1f335cb09149..e42f682cbb46 100644
--- a/drivers/gpu/drm/i915/display/skl_universal_plane.c
+++ b/drivers/gpu/drm/i915/display/skl_universal_plane.c
@@ -16,6 +16,7 @@
 #include "intel_sprite.h"
 #include "skl_scaler.h"
 #include "skl_universal_plane.h"
+#include "pxp/intel_pxp.h"
 
 static const u32 skl_plane_formats[] = {
        DRM_FORMAT_C8,
@@ -971,7 +972,7 @@ skl_program_plane(struct intel_plane *plane,
        u8 alpha = plane_state->hw.alpha >> 8;
        u32 plane_color_ctl = 0, aux_dist = 0;
        unsigned long irqflags;
-       u32 keymsk, keymax;
+       u32 keymsk, keymax, plane_surf;
        u32 plane_ctl = plane_state->ctl;
 
        plane_ctl |= skl_plane_ctl_crtc(crtc_state);
@@ -1051,8 +1052,15 @@ skl_program_plane(struct intel_plane *plane,
         * the control register just before the surface register.
         */
        intel_de_write_fw(dev_priv, PLANE_CTL(pipe, plane_id), plane_ctl);
-       intel_de_write_fw(dev_priv, PLANE_SURF(pipe, plane_id),
-                         intel_plane_ggtt_offset(plane_state) + surf_addr);
+       plane_surf = intel_plane_ggtt_offset(plane_state) + surf_addr;
+
+       if (intel_pxp_is_active(&dev_priv->gt.pxp) &&
+           i915_gem_object_has_valid_protection(intel_fb_obj(fb)))
+               plane_surf |= PLANE_SURF_DECRYPTION_ENABLED;
+       else
+               plane_surf &= ~PLANE_SURF_DECRYPTION_ENABLED;
+
+       intel_de_write_fw(dev_priv, PLANE_SURF(pipe, plane_id), plane_surf);
 
        if (plane_state->scaler_id >= 0)
                skl_program_plane_scaler(plane, crtc_state, plane_state);
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 97a6d0c638ec..3fdbcfd59b0e 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -7223,6 +7223,7 @@ enum {
 #define _PLANE_SURF_3(pipe)    _PIPE(pipe, _PLANE_SURF_3_A, _PLANE_SURF_3_B)
 #define PLANE_SURF(pipe, plane)        \
        _MMIO_PLANE(plane, _PLANE_SURF_1(pipe), _PLANE_SURF_2(pipe))
+#define   PLANE_SURF_DECRYPTION_ENABLED                REG_BIT(2)
 
 #define _PLANE_OFFSET_1_B                      0x711a4
 #define _PLANE_OFFSET_2_B                      0x712a4
-- 
2.29.2

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

Reply via email to