Implemented drm_hdcp_update_change() for updating the current
status to the hdcp_property value.

This will update the error status flag incase of encryption failure.
Whenever there is a HDCP state change KOBJ_UEVENT will be broadcasted
to notify the awaiting userspace consumers.

Signed-off-by: Ramalingam C <ramalinga...@intel.com>
---
 drivers/gpu/drm/drm_hdcp.c | 40 ++++++++++++++++++++++++++++++++++++++++
 include/drm/drm_hdcp.h     |  3 +++
 2 files changed, 43 insertions(+)

diff --git a/drivers/gpu/drm/drm_hdcp.c b/drivers/gpu/drm/drm_hdcp.c
index 9b3bf92..9785ab6 100644
--- a/drivers/gpu/drm/drm_hdcp.c
+++ b/drivers/gpu/drm/drm_hdcp.c
@@ -30,6 +30,46 @@
 #include <drm/drm_hdcp.h>
 #include <drm/drm_dp_helper.h>
 
+/*
+ * drm_hdcp_update_change:
+ *             Updating the HDCP property val along with uevent
+ *
+ * @hdcp:      ptr to hdcp instance
+ * @enabled:   status of HDCP encryption
+ * @status:    Error status bits, if auth failed.
+ * @mute:      uevent is mute or not
+ */
+static void drm_hdcp_update_change(struct drm_hdcp *hdcp, bool enabled,
+                                               uint64_t status, bool mute)
+{
+       struct drm_connector *connector = hdcp->connector;
+       char event_str[30];
+       uint64_t temp_state;
+
+       /* Mutex has to be acquired before entering this function */
+       WARN_ON(!mutex_is_locked(&hdcp->mutex));
+       temp_state = connector->hdcp_state;
+
+       if (enabled) {
+               temp_state &= ~(DRM_HDCP_ENABLE | DRM_HDCP_TYPE_MASK
+                                               | DRM_HDCP_STATUS_MASK);
+               temp_state |= hdcp->req_state;
+       } else {
+               temp_state &= DRM_HDCP_VER_SUPPORT_MASK;
+               temp_state |= (status & DRM_HDCP_STATUS_MASK);
+       }
+
+       connector->hdcp_state = temp_state;
+
+       if (!mute) {
+               sprintf(event_str, "HDCP=0x%llx", connector->hdcp_state);
+
+               /* Generating the uevent with custom string */
+               drm_sysfs_generate_uevent(hdcp->connector->dev, event_str);
+       }
+}
+
+
 int drm_hdcp_enable(struct drm_connector *connector, uint8_t stream_type)
 {
        struct drm_hdcp *hdcp = connector->hdcp;
diff --git a/include/drm/drm_hdcp.h b/include/drm/drm_hdcp.h
index eb7149b..d5adbf5 100644
--- a/include/drm/drm_hdcp.h
+++ b/include/drm/drm_hdcp.h
@@ -163,6 +163,9 @@ struct drm_hdcp {
 #define DRM_HDCP_TYPE_SHIFT                    4
 #define DRM_HDCP_TYPE_MASK                     (0xFFULL<<DRM_HDCP_TYPE_SHIFT)
 
+#define DRM_HDCP_STATUS_SHIFT                  20
+#define DRM_HDCP_STATUS_MASK                   (0xFULL<<DRM_HDCP_STATUS_SHIFT)
+
 /* Functions exported */
 extern int drm_hdcp_init(struct drm_connector *connector,
                                        struct drm_hdcp *hdcp,
-- 
2.7.4

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

Reply via email to