[v8,4/6] drm/hdcp: update content protection property with uevent

Submitted by Ramalingam C on July 5, 2019, 12:46 a.m.

Details

Message ID 20190705004642.15822-5-ramalingam.c@intel.com
State New
Headers show
Series "HDCP2.2 Phase II" ( rev: 10 ) in Intel GFX

Not browsing as part of any series.

Commit Message

Ramalingam C July 5, 2019, 12:46 a.m.
drm function is defined and exported to update a connector's
content protection property state and to generate a uevent along
with it.

Need ACK for the uevent from userspace consumer.

v2:
  Update only when state is different from old one.
v3:
  KDoc is added [Daniel]
v4:
  KDoc is extended bit more [pekka]

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/drm_hdcp.c | 34 ++++++++++++++++++++++++++++++++++
 include/drm/drm_hdcp.h     |  2 ++
 2 files changed, 36 insertions(+)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/drm_hdcp.c b/drivers/gpu/drm/drm_hdcp.c
index ce235fd1c844..77433ee3d652 100644
--- a/drivers/gpu/drm/drm_hdcp.c
+++ b/drivers/gpu/drm/drm_hdcp.c
@@ -374,6 +374,10 @@  DRM_ENUM_NAME_FN(drm_get_hdcp_content_type_name,
  *
  * The content protection will be set to &drm_connector_state.content_protection
  *
+ * When kernel triggered content protection state change like DESIRED->ENABLED
+ * and ENABLED->DESIRED, will use drm_hdcp_update_content_protection() to update
+ * the content protection state of a connector.
+ *
  * Returns:
  * Zero on success, negative errno on failure.
  */
@@ -414,3 +418,33 @@  int drm_connector_attach_content_protection_property(
 	return 0;
 }
 EXPORT_SYMBOL(drm_connector_attach_content_protection_property);
+
+/**
+ * drm_hdcp_update_content_protection - Updates the content protection state
+ * of a connector
+ *
+ * @connector: drm_connector on which content protection state needs an update
+ * @val: New state of the content protection property
+ *
+ * This function can be used by display drivers, to update the kernel triggered
+ * content protection state changes of a drm_connector such as DESIRED->ENABLED
+ * and ENABLED->DESIRED. No uevent for DESIRED->UNDESIRED or ENABLED->UNDESIRED,
+ * as userspace is triggering such state change and kernel performs it without
+ * fail.This function update the new state of the property into the connector's
+ * state and generate an uevent to notify the userspace.
+ */
+void drm_hdcp_update_content_protection(struct drm_connector *connector,
+					u64 val)
+{
+	struct drm_device *dev = connector->dev;
+	struct drm_connector_state *state = connector->state;
+
+	WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
+	if (state->content_protection == val)
+		return;
+
+	state->content_protection = val;
+	drm_sysfs_connector_status_event(connector,
+				 dev->mode_config.content_protection_property);
+}
+EXPORT_SYMBOL(drm_hdcp_update_content_protection);
diff --git a/include/drm/drm_hdcp.h b/include/drm/drm_hdcp.h
index 2970abdfaf12..dd864ac9ce85 100644
--- a/include/drm/drm_hdcp.h
+++ b/include/drm/drm_hdcp.h
@@ -292,4 +292,6 @@  bool drm_hdcp_check_ksvs_revoked(struct drm_device *dev,
 				 u8 *ksvs, u32 ksv_count);
 int drm_connector_attach_content_protection_property(
 		struct drm_connector *connector, bool hdcp_content_type);
+void drm_hdcp_update_content_protection(struct drm_connector *connector,
+					u64 val);
 #endif

Comments

On 2019-07-08 at 13:09:14 +0300, Pekka Paalanen wrote:
> On Fri,  5 Jul 2019 06:16:40 +0530
> Ramalingam C <ramalingam.c@intel.com> wrote:
> 
> > drm function is defined and exported to update a connector's
> > content protection property state and to generate a uevent along
> > with it.
> > 
> > Need ACK for the uevent from userspace consumer.
> > 
> > v2:
> >   Update only when state is different from old one.
> > v3:
> >   KDoc is added [Daniel]
> > v4:
> >   KDoc is extended bit more [pekka]
> > 
> > Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
> > Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> > ---
> >  drivers/gpu/drm/drm_hdcp.c | 34 ++++++++++++++++++++++++++++++++++
> >  include/drm/drm_hdcp.h     |  2 ++
> >  2 files changed, 36 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_hdcp.c b/drivers/gpu/drm/drm_hdcp.c
> > index ce235fd1c844..77433ee3d652 100644
> > --- a/drivers/gpu/drm/drm_hdcp.c
> > +++ b/drivers/gpu/drm/drm_hdcp.c
> > @@ -374,6 +374,10 @@ DRM_ENUM_NAME_FN(drm_get_hdcp_content_type_name,
> >   *
> >   * The content protection will be set to &drm_connector_state.content_protection
> >   *
> > + * When kernel triggered content protection state change like DESIRED->ENABLED
> > + * and ENABLED->DESIRED, will use drm_hdcp_update_content_protection() to update
> > + * the content protection state of a connector.
> > + *
> >   * Returns:
> >   * Zero on success, negative errno on failure.
> >   */
> > @@ -414,3 +418,33 @@ int drm_connector_attach_content_protection_property(
> >  	return 0;
> >  }
> >  EXPORT_SYMBOL(drm_connector_attach_content_protection_property);
> > +
> > +/**
> > + * drm_hdcp_update_content_protection - Updates the content protection state
> > + * of a connector
> > + *
> > + * @connector: drm_connector on which content protection state needs an update
> > + * @val: New state of the content protection property
> > + *
> > + * This function can be used by display drivers, to update the kernel triggered
> > + * content protection state changes of a drm_connector such as DESIRED->ENABLED
> > + * and ENABLED->DESIRED. No uevent for DESIRED->UNDESIRED or ENABLED->UNDESIRED,
> > + * as userspace is triggering such state change and kernel performs it without
> > + * fail.This function update the new state of the property into the connector's
> > + * state and generate an uevent to notify the userspace.

This para was rewritten to explain in which all are events uevents will be sent
and when events wont be sent.

> > + */
> 
> Hi,
> 
> this patch is not yet adding the documentation I asked for.
> 
> The uevent behaviour needs to be also documented with the Content
> Protection property description. No userspace developer will know to
> come to dig up these kernel-internal functions.

Sure this will help. I will do it. Thanks.

> 
> > +void drm_hdcp_update_content_protection(struct drm_connector *connector,
> > +					u64 val)
> > +{
> > +	struct drm_device *dev = connector->dev;
> > +	struct drm_connector_state *state = connector->state;
> > +
> > +	WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
> 
> Still missing WARN_ON(val == UNDESIRED) to prevent other drivers from
> making that mistake in the future.

IMHO This is not required. as kernel is not changing the "val" which is the
state requested by userspace tracked by "state->content_protection". So
this function will return as state->content_protection == val is true.

Thanks,
Ram.
> 
> 
> Thanks,
> pq
> 
> > +	if (state->content_protection == val)
> > +		return;
> > +
> > +	state->content_protection = val;
> > +	drm_sysfs_connector_status_event(connector,
> > +				 dev->mode_config.content_protection_property);
> > +}
> > +EXPORT_SYMBOL(drm_hdcp_update_content_protection);
> > diff --git a/include/drm/drm_hdcp.h b/include/drm/drm_hdcp.h
> > index 2970abdfaf12..dd864ac9ce85 100644
> > --- a/include/drm/drm_hdcp.h
> > +++ b/include/drm/drm_hdcp.h
> > @@ -292,4 +292,6 @@ bool drm_hdcp_check_ksvs_revoked(struct drm_device *dev,
> >  				 u8 *ksvs, u32 ksv_count);
> >  int drm_connector_attach_content_protection_property(
> >  		struct drm_connector *connector, bool hdcp_content_type);
> > +void drm_hdcp_update_content_protection(struct drm_connector *connector,
> > +					u64 val);
> >  #endif
>