drm/i915: Implement HDCP
Subsystems (3)
v2 cover drm/i915: Implement HDCP
Ok, here's v2 of the HDCP patchset, no longer RFC since I've tackled the TODO list I set out in the first version (Annotated below for convenience).
The big changes to take note of in v2 is locking. To account for atomic async + the property's mutability, I'm using a dedicated mutex and moved property setting on the kernel side to the worker. I think this is actually a lot easier to read, and it opens the door to future improvements such as not doing the enable/disable via modeset.
TODO:
- DONE: Add kerneldoc for property
- DONE: Fix '//' comments
- DONE: Change to MIT license
- DONE: Improve documentation on drm_intel_hdcp_shim
- DONE: Fix async commit locking (ie: don't use connection_mutex)
- DONE: Don't change connector->state in enable, defer to worker
- Rebase on Ville's gmbus fixes (thanks Ville)
- Looks like these haven't landed, but I've rebased on drm-intel-next
- Add igt coverage for the feature.
- Working on this now
Thanks!
Sean
Sean Paul (8):
drm: Fix link-status kerneldoc line lengths drm/i915: Add more control to wait_for routines
drm: Add Content Protection property
drm: Add some HDCP related #defines drm/i915: Add HDCP framework + base implementation drm/i915: Add function to output Aksv over GMBUS drm/i915: Implement HDCP for HDMI drm/i915: Implement HDCP for DisplayPort
drivers/gpu/drm/drm_atomic.c | 8 + drivers/gpu/drm/drm_connector.c | 80 ++++- drivers/gpu/drm/drm_sysfs.c | 1 + drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_reg.h | 85 +++++ drivers/gpu/drm/i915/intel_atomic.c | 26 +- drivers/gpu/drm/i915/intel_ddi.c | 64 ++++ drivers/gpu/drm/i915/intel_dp.c | 245 ++++++++++++- drivers/gpu/drm/i915/intel_drv.h | 98 +++++- drivers/gpu/drm/i915/intel_hdcp.c | 684 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_hdmi.c | 254 +++++++++++++ drivers/gpu/drm/i915/intel_i2c.c | 54 ++- drivers/gpu/drm/i915/intel_uncore.c | 23 +- drivers/gpu/drm/i915/intel_uncore.h | 14 +- include/drm/drm_connector.h | 16 + include/drm/drm_dp_helper.h | 17 + include/drm/drm_hdcp.h | 56 +++ include/uapi/drm/drm_mode.h | 4 + 19 files changed, 1697 insertions(+), 34 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_hdcp.c create mode 100644 include/drm/drm_hdcp.h
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 1/8 drm: Fix link-status kerneldoc line lengths
I'm adding some stuff below it and it's killing my editor's vibe.
Changes in v2:
- Added to the series
--- drivers/gpu/drm/drm_connector.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-)
drivers/gpu/drm/drm_connector.c +5 -4
@@ -759,10 +759,11 @@ DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,* should update this value using drm_mode_connector_set_tile_property(). * Userspace cannot change this property. * link-status: -* Connector link-status property to indicate the status of link. The default -* value of link-status is "GOOD". If something fails during or after modeset, -* the kernel driver may set this to "BAD" and issue a hotplug uevent. Drivers -* should update this value using drm_mode_connector_set_link_status_property(). +* Connector link-status property to indicate the status of link. The +* default value of link-status is "GOOD". If something fails during or +* after modeset, the kernel driver may set this to "BAD" and issue a +* hotplug uevent. Drivers should update this value using +* drm_mode_connector_set_link_status_property(). * * Connectors also have one standardized atomic property: *
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
PATCH v2 2/8 drm/i915: Add more control to wait_for routines
In reply to Sean PaulThis patch adds a little more control to a couple wait_for routines such that we can avoid open-coding read/wait/timeout patterns which:
- need the value of the register after the wait_for
- run arbitrary operation for the read portion
This patch also chooses the correct sleep function (based on timers-howto.txt) for the polling interval the caller specifies.
Changes in v2:
- Added to the series
--- drivers/gpu/drm/i915/intel_drv.h | 17 ++++++++++++----- drivers/gpu/drm/i915/intel_uncore.c | 23 ++++++++++++++++------- drivers/gpu/drm/i915/intel_uncore.h | 14 +++++++++++++- 3 files changed, 41 insertions(+), 13 deletions(-)
drivers/gpu/drm/i915/intel_drv.h +12 -5
@@ -41,19 +41,21 @@#include <drm/drm_atomic.h> /** -* _wait_for - magic (register) wait macro +* __wait_for - magic wait macro * -* Does the right thing for modeset paths when run under kdgb or similar atomic -* contexts. Note that it's important that we check the condition again after +* Macro to help avoid open coding check/wait/timeout patterns, will do the +* right think wrt to choosing msleep vs usleep_range based on how long the wait +* interval is. Note that it's important that we check the condition again after * having timed out, since the timeout could be due to preemption or similar and * we've never had a chance to check the condition before the timeout. */ -#define _wait_for (COND ,US ,W ) ({ \ +#define __wait_for (OP ,COND ,US ,W ) ({ \ unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \ int ret__; \ might_sleep(); \ for (;;) { \ bool expired__ = time_after(jiffies, timeout__); \ + OP; \ if (COND) { \ ret__ = 0; \ break; \
@@ -62,11 +64,16 @@ ret__ = -ETIMEDOUT ; \break ; \ } \ -usleep_range ((W ), (W ) *2 ); \ +if (W > (20 *1000 )) \ +msleep (W /1000 ); \ +else \ +usleep_range ((W ), (W ) *2 ); \ } \ ret__; \ }) +#define _wait_for (COND ,US ,W ) __wait_for(;,(COND), US, W) +#define wait_for (COND ,MS ) _wait_for((COND), (MS) * 1000, 1000)/* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */
drivers/gpu/drm/i915/intel_uncore.c +16 -7
@@ -1770,12 +1770,14 @@ int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv, }/** -* intel_wait_for_register - wait until register matches expected state +* __intel_wait_for_register - wait until register matches expected state * @dev_priv: the i915 device * @reg: the register to read * @mask: mask to apply to register value * @value: expected value -* @timeout_ms: timeout in millisecond +* @fast_timeout_us: fast timeout in microsecond for atomic/tight wait +* @slow_timeout_ms: slow timeout in millisecond +* @out_value: optional placeholder to hold registry value * * This routine waits until the target register @reg contains the expected * @value after applying the @mask, i.e. it waits until ::
@@ -1786,15 +1788,18 @@ int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,* * Returns 0 if the register matches the desired condition, or -ETIMEOUT. */ -int intel_wait_for_register (struct drm_i915_private *dev_priv, +int __intel_wait_for_register (struct drm_i915_private *dev_priv,i915_reg_t reg,u32 mask,u32 value, -unsigned int timeout_ms) +unsigned int fast_timeout_us, +unsigned int slow_timeout_ms, +u32 *out_value) {unsigned fw =intel_uncore_forcewake_for_reg (dev_priv, reg,FW_REG_READ );int ret; +u32 reg_value;might_sleep ();
@@ -1803,14 +1808,18 @@ int intel_wait_for_register(struct drm_i915_private *dev_priv, ret =__intel_wait_for_register_fw (dev_priv, reg, mask, value, -2 ,0 ,NULL ); + fast_timeout_us,0 , ®_value);intel_uncore_forcewake_put__locked (dev_priv, fw);spin_unlock_irq (&dev_priv->uncore.lock);if (ret) - ret =wait_for ((I915_READ_NOTRACE (reg) & mask) == value, - timeout_ms); + ret =__wait_for (reg_value =I915_READ_NOTRACE (reg), + (reg_value & mask) == value, + slow_timeout_ms *1000 ,1000 ); + +if (out_value) + *out_value = reg_value;return ret; }
drivers/gpu/drm/i915/intel_uncore.h +13 -1
@@ -163,11 +163,23 @@ void intel_uncore_forcewake_put__locked(struct drm_i915_private *dev_priv,void intel_uncore_forcewake_user_get (struct drm_i915_private *dev_priv);void intel_uncore_forcewake_user_put (struct drm_i915_private *dev_priv); +int __intel_wait_for_register (struct drm_i915_private *dev_priv, +i915_reg_t reg, +u32 mask, +u32 value, +unsigned int fast_timeout_us, +unsigned int slow_timeout_ms, +u32 *out_value); +static inline int intel_wait_for_register (struct drm_i915_private *dev_priv,i915_reg_t reg,u32 mask,u32 value, -unsigned int timeout_ms); +unsigned int timeout_ms) +{ +return __intel_wait_for_register (dev_priv, reg, mask, value,2 , + timeout_ms,NULL ); +} int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv, i915_reg_t reg, u32 mask,
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Intel-gfx] [PATCH v2 2/8] drm/i915: Add more control to wait_for routines
Quoting Sean Paul (2017-12-01 17:20:24)
Quoted 24 lines
/**
- *_wait_for- magic (register) wait macro
+ *__wait_for- magic wait macro
*
- * Does the right thing for modeset paths when run under kdgb or similar atomic
- * contexts. Note that it's important that we check the condition again after
+ * Macro to help avoid open coding check/wait/timeout patterns, will do the
+ * right think wrt to choosing msleep vsusleep_rangebased on how long the wait
+ * interval is. Note that it's important that we check the condition again after
* having timed out, since the timeout could be due to preemption or similar and
* we've never had a chance to check the condition before the timeout. */drivers/gpu/drm/i915/intel_drv.h +2
-1-#define _wait_for (COND ,US ,W ) ({ \ +#define __wait_for (OP ,COND ,US ,W ) ({ \ unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \ int ret__; \ might_sleep(); \ for (;;) { \ bool expired__ = time_after(jiffies, timeout__); \ + OP; \ if (COND) { \ ret__ = 0; \ break; \
drivers/gpu/drm/i915/intel_drv.h line 70
Quoted 8 lines
drivers/gpu/drm/i915/intel_drv.h +4
-1@@ -62,11 +64,16 @@ ret__ = -ETIMEDOUT ; \break ; \ } \ -usleep_range ((W ), (W ) *2 ); \ +if (W > (20 *1000 )) \ +msleep (W /1000 ); \ +else \ +usleep_range ((W ), (W ) *2 ); \
The current wait_for() is a little more complicated nowadays (variable W).
Are ms intervals going to be that common? Using a state-machine springs to mind, but you could argue that msleep() is just a yield. Using msleep though is going to leave D processes visible and a bump in load :|
Quoted 60 lines
drivers/gpu/drm/i915/intel_drv.h +2
-0} \ ret__; \ }) +#define _wait_for (COND ,US ,W ) __wait_for(;,(COND), US, W) +#define wait_for (COND ,MS ) _wait_for((COND), (MS) * 1000, 1000)/* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */ drivers/gpu/drm/i915/intel_uncore.c +10
-5@@ -1770,12 +1770,14 @@ int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv, }/** -* intel_wait_for_register - wait until register matches expected state +* __intel_wait_for_register - wait until register matches expected state * @dev_priv: the i915 device * @reg: the register to read * @mask: mask to apply to register value * @value: expected value -* @timeout_ms: timeout in millisecond +* @fast_timeout_us: fast timeout in microsecond for atomic/tight wait +* @slow_timeout_ms: slow timeout in millisecond +* @out_value: optional placeholder to hold registry value * * This routine waits until the target register @reg contains the expected * @value after applying the @mask, i.e. it waits until :: @@ -1786,15 +1788,18 @@ int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,* * Returns 0 if the register matches the desired condition, or -ETIMEOUT. */ -int intel_wait_for_register (struct drm_i915_private *dev_priv, +int __intel_wait_for_register (struct drm_i915_private *dev_priv,i915_reg_t reg,u32 mask,u32 value, -unsigned int timeout_ms) +unsigned int fast_timeout_us, +unsigned int slow_timeout_ms, +u32 *out_value) {unsigned fw =intel_uncore_forcewake_for_reg (dev_priv, reg,FW_REG_READ );int ret; +u32 reg_value;might_sleep ();@@ -1803,14 +1808,18 @@ int intel_wait_for_register(struct drm_i915_private *dev_priv, ret =__intel_wait_for_register_fw (dev_priv, reg, mask, value, -2 ,0 ,NULL ); + fast_timeout_us,0 , ®_value);intel_uncore_forcewake_put__locked (dev_priv, fw);spin_unlock_irq (&dev_priv->uncore.lock);
drivers/gpu/drm/i915/intel_uncore.c int intel_wait_for_register(struct drm_i915_private *dev_priv, · line 1822
Quoted 10 lines
drivers/gpu/drm/i915/intel_uncore.c +6
-2if (ret) - ret =wait_for ((I915_READ_NOTRACE (reg) & mask) == value, - timeout_ms); + ret =__wait_for (reg_value =I915_READ_NOTRACE (reg), + (reg_value & mask) == value, + slow_timeout_ms *1000 ,1000 ); + +if (out_value) + *out_value = reg_value;
Looks good.
-Chris
Re: [Intel-gfx] [PATCH v2 2/8] drm/i915: Add more control to wait_for routines
Quoted 28 lines · Chris Wilson
Quoting Sean Paul (2017-12-01 17:20:24)
Quoted 27 lines
/**
- *_wait_for- magic (register) wait macro
+ *__wait_for- magic wait macro
*
- * Does the right thing for modeset paths when run under kdgb or similar atomic
- * contexts. Note that it's important that we check the condition again after
+ * Macro to help avoid open coding check/wait/timeout patterns, will do the
+ * right think wrt to choosing msleep vsusleep_rangebased on how long the wait
+ * interval is. Note that it's important that we check the condition again after
* having timed out, since the timeout could be due to preemption or similar and
* we've never had a chance to check the condition before the timeout. */drivers/gpu/drm/i915/intel_drv.h +2
-1-#define _wait_for (COND ,US ,W ) ({ \ +#define __wait_for (OP ,COND ,US ,W ) ({ \ unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \ int ret__; \ might_sleep(); \ for (;;) { \ bool expired__ = time_after(jiffies, timeout__); \ + OP; \ if (COND) { \ ret__ = 0; \ break; \@@ -62,11 +64,16 @@ ret__ = -ETIMEDOUT ; \break ; \ } \
Quoted 9 lines
drivers/gpu/drm/i915/intel_drv.h line 70
Quoted 5 lines
drivers/gpu/drm/i915/intel_drv.h +4
-1-usleep_range ((W ), (W ) *2 ); \ +if (W > (20 *1000 )) \ +msleep (W /1000 ); \ +else \ +usleep_range ((W ), (W ) *2 ); \The current
wait_for()is a little more complicated nowadays (variable W).
Hmm, am I based off the wrong tree? I'm using drm-intel-next.
Quoted 4 lines
Are ms intervals going to be that common? Using a state-machine springs to mind, but you could argue that
msleep()is just a yield. Using msleep though is going to leave D processes visible and a bump in load :|
Probably uncommon, but at the very least, I need one. I wouldn't feel comfortable handling such a large wait using usleep_range.
Sean
Quoted 61 lines
Quoted 61 lines
drivers/gpu/drm/i915/intel_drv.h +2
-0} \ ret__; \ }) +#define _wait_for (COND ,US ,W ) __wait_for(;,(COND), US, W) +#define wait_for (COND ,MS ) _wait_for((COND), (MS) * 1000, 1000)/* If CONFIG_PREEMPT_COUNT is disabled, in_atomic() always reports false. */ drivers/gpu/drm/i915/intel_uncore.c +10
-5@@ -1770,12 +1770,14 @@ int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv, }/** -* intel_wait_for_register - wait until register matches expected state +* __intel_wait_for_register - wait until register matches expected state * @dev_priv: the i915 device * @reg: the register to read * @mask: mask to apply to register value * @value: expected value -* @timeout_ms: timeout in millisecond +* @fast_timeout_us: fast timeout in microsecond for atomic/tight wait +* @slow_timeout_ms: slow timeout in millisecond +* @out_value: optional placeholder to hold registry value * * This routine waits until the target register @reg contains the expected * @value after applying the @mask, i.e. it waits until :: @@ -1786,15 +1788,18 @@ int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,* * Returns 0 if the register matches the desired condition, or -ETIMEOUT. */ -int intel_wait_for_register (struct drm_i915_private *dev_priv, +int __intel_wait_for_register (struct drm_i915_private *dev_priv,i915_reg_t reg,u32 mask,u32 value, -unsigned int timeout_ms) +unsigned int fast_timeout_us, +unsigned int slow_timeout_ms, +u32 *out_value) {unsigned fw =intel_uncore_forcewake_for_reg (dev_priv, reg,FW_REG_READ );int ret; +u32 reg_value;might_sleep ();@@ -1803,14 +1808,18 @@ int intel_wait_for_register(struct drm_i915_private *dev_priv, ret =__intel_wait_for_register_fw (dev_priv, reg, mask, value, -2 ,0 ,NULL ); + fast_timeout_us,0 , ®_value);intel_uncore_forcewake_put__locked (dev_priv, fw);spin_unlock_irq (&dev_priv->uncore.lock);
Quoted 12 lines
drivers/gpu/drm/i915/intel_uncore.c int intel_wait_for_register(struct drm_i915_private *dev_priv, · line 1822
Quoted 9 lines
drivers/gpu/drm/i915/intel_uncore.c +6
-2if (ret) - ret =wait_for ((I915_READ_NOTRACE (reg) & mask) == value, - timeout_ms); + ret =__wait_for (reg_value =I915_READ_NOTRACE (reg), + (reg_value & mask) == value, + slow_timeout_ms *1000 ,1000 ); + +if (out_value) + *out_value = reg_value;Looks good.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 2/8] drm/i915: Add more control to wait_for routines
Quoting Sean Paul (2017-12-01 17:48:17)
Quoted 39 lines · Chris Wilson
Quoted 28 lines
Quoting Sean Paul (2017-12-01 17:20:24)
Quoted 27 lines
/**
- *_wait_for- magic (register) wait macro
+ *__wait_for- magic wait macro
*
- * Does the right thing for modeset paths when run under kdgb or similar atomic
- * contexts. Note that it's important that we check the condition again after
+ * Macro to help avoid open coding check/wait/timeout patterns, will do the
+ * right think wrt to choosing msleep vsusleep_rangebased on how long the wait
+ * interval is. Note that it's important that we check the condition again after
* having timed out, since the timeout could be due to preemption or similar and
* we've never had a chance to check the condition before the timeout. */drivers/gpu/drm/i915/intel_drv.h +2
-1-#define _wait_for (COND ,US ,W ) ({ \ +#define __wait_for (OP ,COND ,US ,W ) ({ \ unsigned long timeout__ = jiffies + usecs_to_jiffies(US) + 1; \ int ret__; \ might_sleep(); \ for (;;) { \ bool expired__ = time_after(jiffies, timeout__); \ + OP; \ if (COND) { \ ret__ = 0; \ break; \@@ -62,11 +64,16 @@ ret__ = -ETIMEDOUT ; \break ; \ } \Quoted 9 lines
drivers/gpu/drm/i915/intel_drv.h line 70
Quoted 5 lines
drivers/gpu/drm/i915/intel_drv.h +4
-1-usleep_range ((W ), (W ) *2 ); \ +if (W > (20 *1000 )) \ +msleep (W /1000 ); \ +else \ +usleep_range ((W ), (W ) *2 ); \The current
wait_for()is a little more complicated nowadays (variable W).
Quoted 1 line
Hmm, am I based off the wrong tree? I'm using drm-intel-next.
drm-intel-next is what was sent as a PR; drm-intel-next-queued is always current. To be sure CI, doesn't complain about merge conflicts, base on drm-tip.
Quoted 7 lines
Quoted 4 lines
Are ms intervals going to be that common? Using a state-machine springs to mind, but you could argue that
msleep()is just a yield. Using msleep though is going to leave D processes visible and a bump in load :|Probably uncommon, but at the very least, I need one. I wouldn't feel comfortable handling such a large wait using
usleep_range.
We can use the constants to remove the predicate for when it never will be needed, so it's not an issue -- either wait will produce a long uninterruptible sleep. It's just if that we were to frequently hit that long sleep, there would be some push back against using wait_for() on that path as no one likes an "idle" system with load 1.
-Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 2/8] drm/i915: Add more control to wait_for routines
Quoting Chris Wilson (2017-12-01 17:55:15)
Quoted 11 lines
Quoting Sean Paul (2017-12-01 17:48:17)
Quoted 6 lines · Chris Wilson
Quoted 3 lines
The current
wait_for()is a little more complicated nowadays (variable W).Hmm, am I based off the wrong tree? I'm using drm-intel-next.
drm-intel-next is what was sent as a PR; drm-intel-next-queued is always current. To be sure CI, doesn't complain about merge conflicts, base on drm-tip.
Speaking of CI, do you have any instructions on how we might set up a test system? Just needs a compatible monitor and some test code? Could chamelium or something like that be used as a validator? -Chris
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [Intel-gfx] [PATCH v2 2/8] drm/i915: Add more control to wait_for routines
Quoted 13 lines · Chris Wilson
Quoting Chris Wilson (2017-12-01 17:55:15)
Quoted 11 lines
Quoting Sean Paul (2017-12-01 17:48:17)
Quoted 6 lines · Chris Wilson
Quoted 3 lines
The current
wait_for()is a little more complicated nowadays (variable W).Hmm, am I based off the wrong tree? I'm using drm-intel-next.
drm-intel-next is what was sent as a PR; drm-intel-next-queued is always current. To be sure CI, doesn't complain about merge conflicts, base on drm-tip.
Ahhhh, i forgot about -queued. ok, will rebase.
Quoted 2 lines
Speaking of CI, do you have any instructions on how we might set up a test system?
I'm working on an igt test for the property now.
Quoted 1 line
Just needs a compatible monitor and some test code?
Yep. For testing, I exposed the property via sysfs and fiddle with it that way.
Quoted 1 line
Could chamelium or something like that be used as a validator?
You would have to implement the receiver side of HDCP on chamelium in order for this to work. So, probably not.
Sean
Quoted 1 line
-Chris
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 3/8 drm: Add Content Protection property
In reply to Sean PaulThis patch adds a new optional connector property to allow userspace to enable protection over the content it is displaying. This will typically be implemented by the driver using HDCP.
The property is a tri-state with the following values:
- OFF: Self explanatory, no content protection
- DESIRED: Userspace requests that the driver enable protection
- ENABLED: Once the driver has authenticated the link, it sets this value
The driver is responsible for downgrading ENABLED to DESIRED if the link becomes unprotected. The driver should also maintain the desiredness of protection across hotplug/dpms/suspend.
If this looks familiar, I posted [1] this 3 years ago. We have been using this in ChromeOS across exynos, mediatek, and rockchip over that time.
Changes in v2:
- Pimp kerneldoc for content_protection_property (Daniel)
- Drop sysfs attribute
[1] https://lists.freedesktop.org/archives/dri-devel/2014-December/073336.html
--- drivers/gpu/drm/drm_atomic.c | 8 +++++ drivers/gpu/drm/drm_connector.c | 71 +++++++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/drm_sysfs.c | 1 + include/drm/drm_connector.h | 16 ++++++++++ include/uapi/drm/drm_mode.h | 4 +++ 5 files changed, 100 insertions(+)
drivers/gpu/drm/drm_atomic.c +8 -0
@@ -1196,6 +1196,12 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector, state->picture_aspect_ratio = val; }else if (property == connector->scaling_mode_property) { state->scaling_mode = val; + }else if (property == connector->content_protection_property) { +if (val ==DRM_MODE_CONTENT_PROTECTION_ENABLED ) { +DRM_DEBUG_KMS ("only drivers can set CP Enabled\n" ); +return -EINVAL ; + } + state->content_protection = val; }else if (connector->funcs->atomic_set_property) {return connector->funcs->atomic_set_property (connector, state, property, val);
@@ -1275,6 +1281,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector, *val = state->picture_aspect_ratio; }else if (property == connector->scaling_mode_property) { *val = state->scaling_mode; + }else if (property == connector->content_protection_property) { + *val = state->content_protection; }else if (connector->funcs->atomic_get_property) {return connector->funcs->atomic_get_property (connector, state, property, val);
drivers/gpu/drm/drm_connector.c +71 -0
89 lines not on this page · raw message
drivers/gpu/drm/drm_sysfs.c +1 -0
@@ -21,6 +21,7 @@#include <drm/drm_sysfs.h> #include <drm/drmP.h> #include "drm_internal.h" +#include "drm_crtc_internal.h" #define to_drm_minor (d) dev_get_drvdata(d)#define to_drm_connector (d) dev_get_drvdata(d)
include/drm/drm_connector.h +16 -0
@@ -370,6 +370,12 @@ struct drm_connector_state {* upscaling, mostly used for built-in panels. */ unsigned int scaling_mode; + +/** +* @content_protection: Connector property to request content +* protection. This is most commonly used for HDCP. +*/ +unsigned int content_protection; };/**
@@ -718,6 +724,7 @@ struct drm_cmdline_mode {* @tile_h_size: horizontal size of this tile. * @tile_v_size: vertical size of this tile. * @scaling_mode_property: Optional atomic property to control the upscaling. +* @content_protection_property: Optional property to control content protection * * Each connector may be connected to one or more CRTCs, or may be clonable by * another connector if they can share a CRTC. Each connector also has a specific
@@ -808,6 +815,12 @@ struct drm_connector {struct drm_property *scaling_mode_property; +/** +* @content_protection_property: DRM ENUM property for content +* protection +*/ +struct drm_property *content_protection_property; +/** * @path_blob_ptr: *
@@ -1002,6 +1015,7 @@ const char *drm_get_dvi_i_subconnector_name(int val);const char *drm_get_dvi_i_select_name (int val);const char *drm_get_tv_subconnector_name (int val);const char *drm_get_tv_select_name (int val); +const char *drm_get_content_protection_name (int val);int drm_mode_create_dvi_i_properties (struct drm_device *dev); int drm_mode_create_tv_properties(struct drm_device *dev,
@@ -1010,6 +1024,8 @@ int drm_mode_create_tv_properties(struct drm_device *dev,int drm_mode_create_scaling_mode_property (struct drm_device *dev);int drm_connector_attach_scaling_mode_property (struct drm_connector *connector,u32 scaling_mode_mask); +int drm_connector_attach_content_protection_property ( +struct drm_connector *connector);int drm_mode_create_aspect_ratio_property (struct drm_device *dev);int drm_mode_create_suggested_offset_properties (struct drm_device *dev);
include/uapi/drm/drm_mode.h +4 -0
@@ -173,6 +173,10 @@ extern "C" { DRM_MODE_REFLECT_X | \ DRM_MODE_REFLECT_Y) +/* Content Protection Flags */ +#define DRM_MODE_CONTENT_PROTECTION_OFF 0 +#define DRM_MODE_CONTENT_PROTECTION_DESIRED 1 +#define DRM_MODE_CONTENT_PROTECTION_ENABLED 2struct drm_mode_modeinfo {__u32 clock;
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 4/8 drm: Add some HDCP related #defines
In reply to Sean PaulIn preparation for implementing HDCP in i915, add some HDCP related register offsets and defines. The dpcd register offsets will go in drm_dp_helper.h whereas the ddc offsets along with generic HDCP stuff will get stuffed in drm_hdcp.h, which is new.
Changes in v2:
- drm_hdcp.h gets MIT license (Daniel)
--- include/drm/drm_dp_helper.h | 17 ++++++++++++++ include/drm/drm_hdcp.h | 56 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 73 insertions(+) create mode 100644 include/drm/drm_hdcp.h
include/drm/drm_dp_helper.h +17 -0
@@ -815,6 +815,23 @@#define DP_CEC_TX_MESSAGE_BUFFER 0x3020#define DP_CEC_MESSAGE_BUFFER_LENGTH 0x10 +#define DP_AUX_HDCP_BKSV 0x68000 +#define DP_AUX_HDCP_RI_PRIME 0x68005 +#define DP_AUX_HDCP_AKSV 0x68007 +#define DP_AUX_HDCP_AN 0x6800C +#define DP_AUX_HDCP_V_PRIME (h) (0x68014 + h * 4) +#define DP_AUX_HDCP_BCAPS 0x68028 +# define DP_BCAPS_REPEATER_PRESENT BIT(1) +# define DP_BCAPS_HDCP_CAPABLE BIT(0) +#define DP_AUX_HDCP_BSTATUS 0x68029 +# define DP_BSTATUS_REAUTH_REQ BIT(3) +# define DP_BSTATUS_LINK_FAILURE BIT(2) +# define DP_BSTATUS_R0_PRIME_READY BIT(1) +# define DP_BSTATUS_READY BIT(0) +#define DP_AUX_HDCP_BINFO 0x6802A +#define DP_AUX_HDCP_KSV_FIFO 0x6802C +#define DP_AUX_HDCP_AINFO 0x6803B +/* DP 1.2 Sideband message defines */ /* peer device type - DP 1.2a Table 2-92 */ #define DP_PEER_DEVICE_NONE 0x0
include/drm/drm_hdcp.h new file +56 -0
56 lines not on this page · raw message
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 5/8 drm/i915: Add HDCP framework + base implementation
In reply to Sean PaulThis patch adds the framework required to add HDCP support to intel connectors. It implements Aksv loading from fuse, and parts 1/2/3 of the HDCP authentication scheme.
Note that without shim implementations, this does not actually implement HDCP. That will come in subsequent patches.
Changes in v2:
- Don't open code wait_fors (Chris)
- drm_hdcp.c under MIT license (Daniel)
- Move intel_hdcp_disable() call above ddi_disable (Ram)
- Fix // comments (I wore a cone of shame for 12 hours to atone) (Daniel)
- Justify intel_hdcp_shim with comments (Daniel)
- Fixed async locking issues by adding hdcp_mutex (Daniel)
- Don't alter connector_state in enable/disable (Daniel)
--- drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_reg.h | 83 +++++ drivers/gpu/drm/i915/intel_atomic.c | 26 +- drivers/gpu/drm/i915/intel_ddi.c | 14 + drivers/gpu/drm/i915/intel_drv.h | 79 +++++ drivers/gpu/drm/i915/intel_hdcp.c | 684 ++++++++++++++++++++++++++++++++++++ 6 files changed, 885 insertions(+), 2 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_hdcp.c
drivers/gpu/drm/i915/Makefile +1 -0
@@ -106,6 +106,7 @@ i915-y += intel_audio.o \ intel_fbc.o \ intel_fifo_underrun.o \ intel_frontbuffer.o \ + intel_hdcp.o \ intel_hotplug.o \ intel_modes.o \ intel_overlay.o \
drivers/gpu/drm/i915/i915_reg.h +83 -0
95 lines not on this page · raw message
drivers/gpu/drm/i915/intel_atomic.c +24 -2
@@ -109,12 +109,34 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,struct intel_digital_connector_state *old_conn_state =to_intel_digital_connector_state (old_state);struct drm_crtc_state *crtc_state; - -if (!new_state->crtc) +uint64_t old_cp = old_conn_state->base.content_protection; +uint64_t new_cp = new_state->content_protection; + +if (!new_state->crtc) { +/* +* If the connector is being disabled with CP enabled, mark it +* desired so it's re-enabled when the connector is brought back +*/ +if (old_cp ==DRM_MODE_CONTENT_PROTECTION_ENABLED ) + new_state->content_protection = +DRM_MODE_CONTENT_PROTECTION_DESIRED ;return 0 ; + } crtc_state =drm_atomic_get_new_crtc_state (new_state->state, new_state->crtc); +if (new_cp != old_cp) { +/* Only drivers can set content protection enabled */ +if (new_cp ==DRM_MODE_CONTENT_PROTECTION_ENABLED ) + new_state->content_protection = +DRM_MODE_CONTENT_PROTECTION_DESIRED ; + +/* Involve the encoder/connector to enable/disable CP */ +if (new_cp ==DRM_MODE_CONTENT_PROTECTION_OFF || + old_cp ==DRM_MODE_CONTENT_PROTECTION_OFF ) + crtc_state->mode_changed = true; + } +/* * These properties are handled by fastset, and might not end * up in a modeset.
drivers/gpu/drm/i915/intel_ddi.c +14 -0
@@ -2414,10 +2414,17 @@ static void intel_enable_ddi(struct intel_encoder *encoder,const struct intel_crtc_state *crtc_state, const struct drm_connector_state *conn_state) { + struct drm_connector *connector = conn_state->connector; +struct intel_connector *intel_connector =to_intel_connector (connector); +if (intel_crtc_has_type (crtc_state,INTEL_OUTPUT_HDMI ))intel_enable_ddi_hdmi (encoder, crtc_state, conn_state);else intel_enable_ddi_dp (encoder, crtc_state, conn_state); + +if (conn_state->content_protection == +DRM_MODE_CONTENT_PROTECTION_DESIRED ) +intel_hdcp_enable (intel_connector); } static void intel_disable_ddi_dp(struct intel_encoder *encoder,
@@ -2452,6 +2459,13 @@ static void intel_disable_ddi(struct intel_encoder *encoder,const struct intel_crtc_state *old_crtc_state, const struct drm_connector_state *old_conn_state) { + struct drm_connector *connector = old_conn_state->connector; +struct intel_connector *intel_connector =to_intel_connector (connector); + +if (old_conn_state->content_protection != +DRM_MODE_CONTENT_PROTECTION_OFF ) +intel_hdcp_disable (intel_connector); +if (intel_crtc_has_type (old_crtc_state,INTEL_OUTPUT_HDMI ))intel_disable_ddi_hdmi (encoder, old_crtc_state, old_conn_state);else
drivers/gpu/drm/i915/intel_drv.h +79 -0
97 lines not on this page · raw message
drivers/gpu/drm/i915/intel_hdcp.c new file +684 -0
684 lines not on this page · raw message
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 6/8 drm/i915: Add function to output Aksv over GMBUS
In reply to Sean PaulOnce the Aksv is available in the PCH, we need to get it on the wire to the receiver via DDC. The hardware doesn't allow us to read the value directly, so we need to tell GMBUS to source the Aksv internally and send it to the right offset on the receiver.
The way we do this is to initiate an indexed write where the index is the Aksv register offset. We write dummy values to GMBUS3 as if we were sending the key, and the hardware slips in the "real" values when it goes out.
Changes in v2:
- None
--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_i2c.c | 54 ++++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 8 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
@@ -4043,6 +4043,7 @@ extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);extern void intel_teardown_gmbus (struct drm_i915_private *dev_priv);extern bool intel_gmbus_is_valid_pin (struct drm_i915_private *dev_priv,unsigned int pin); +extern int intel_gmbus_output_aksv (struct i2c_adapter *adapter);extern struct i2c_adapter *intel_gmbus_get_adapter (struct drm_i915_private *dev_priv,unsigned int pin);
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -3040,6 +3040,7 @@ enum i915_power_well_id {# define GPIO_DATA_PULLUP_DISABLE (1 << 13)#define GMBUS0 _MMIO(dev_priv->gpio_mmio_base + 0x5100)/* clock/port select */ +#define GMBUS_AKSV_SELECT (1<<11)#define GMBUS_RATE_100KHZ (0<<8)#define GMBUS_RATE_50KHZ (1<<8)#define GMBUS_RATE_400KHZ (2<<8)/* reserved on Pineview */
drivers/gpu/drm/i915/intel_i2c.c +46 -8
114 lines not on this page · raw message
Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 6/8] drm/i915: Add function to output Aksv over GMBUS
Quoted 152 lines · Sean Paul
Once the Aksv is available in the PCH, we need to get it on the wire to the receiver via DDC. The hardware doesn't allow us to read the value directly, so we need to tell GMBUS to source the Aksv internally and send it to the right offset on the receiver.
The way we do this is to initiate an indexed write where the index is the Aksv register offset. We write dummy values to GMBUS3 as if we were sending the key, and the hardware slips in the "real" values when it goes out.
Changes in v2:
- NoneSigned-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_i2c.c | 54 ++++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 8 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -4043,6 +4043,7 @@ extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);extern void intel_teardown_gmbus (struct drm_i915_private *dev_priv);extern bool intel_gmbus_is_valid_pin (struct drm_i915_private *dev_priv,unsigned int pin); +extern int intel_gmbus_output_aksv (struct i2c_adapter *adapter);extern struct i2c_adapter *intel_gmbus_get_adapter (struct drm_i915_private *dev_priv,unsigned int pin);drivers/gpu/drm/i915/i915_reg.h +1
-0@@ -3040,6 +3040,7 @@ enum i915_power_well_id {# define GPIO_DATA_PULLUP_DISABLE (1 << 13)#define GMBUS0 _MMIO(dev_priv->gpio_mmio_base + 0x5100)/* clock/port select */ +#define GMBUS_AKSV_SELECT (1<<11)#define GMBUS_RATE_100KHZ (0<<8)#define GMBUS_RATE_50KHZ (1<<8)#define GMBUS_RATE_400KHZ (2<<8)/* reserved on Pineview */ drivers/gpu/drm/i915/intel_i2c.c +29
-8@@ -30,6 +30,7 @@#include <linux/i2c-algo-bit.h> #include <linux/export.h> #include <drm/drmP.h> +#include <drm/drm_hdcp.h> #include "intel_drv.h" #include <drm/i915_drm.h> #include "i915_drv.h" @@ -373,7 +374,8 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,static int gmbus_xfer_write_chunk (struct drm_i915_private *dev_priv, -unsigned short addr,u8 *buf,unsigned int len) +unsigned short addr,u8 *buf,unsigned int len, +u32 gmbus1_index) {unsigned int chunk_size = len;u32 val, loop;@@ -386,7 +388,7 @@ gmbus_xfer_write_chunk(struct drm_i915_private *dev_priv,I915_WRITE_FW (GMBUS3 , val);I915_WRITE_FW (GMBUS1 , -GMBUS_CYCLE_WAIT | + gmbus1_index |GMBUS_CYCLE_WAIT | (chunk_size <<GMBUS_BYTE_COUNT_SHIFT ) | (addr <<GMBUS_SLAVE_ADDR_SHIFT ) |GMBUS_SLAVE_WRITE |GMBUS_SW_RDY );@@ -409,7 +411,8 @@ gmbus_xfer_write_chunk(struct drm_i915_private *dev_priv, }static int -gmbus_xfer_write (struct drm_i915_private *dev_priv,struct i2c_msg *msg) +gmbus_xfer_write (struct drm_i915_private *dev_priv,struct i2c_msg *msg, +u32 gmbus1_index) {u8 *buf = msg->buf;unsigned int tx_size = msg->len;@@ -419,7 +422,8 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg) do { len = min(tx_size, GMBUS_BYTE_COUNT_MAX); - ret = gmbus_xfer_write_chunk(dev_priv, msg->addr, buf, len); + ret = gmbus_xfer_write_chunk(dev_priv, msg->addr, buf, len, + gmbus1_index); if (ret) return ret;@@ -470,7 +474,8 @@ gmbus_xfer_index_read(struct drm_i915_private *dev_priv, struct i2c_msg *msgs) }static int -do_gmbus_xfer (struct i2c_adapter *adapter,struct i2c_msg *msgs,int num) +do_gmbus_xfer (struct i2c_adapter *adapter,struct i2c_msg *msgs,int num, +u32 gmbus0_source,u32 gmbus1_index) { struct intel_gmbus *bus = container_of(adapter, struct intel_gmbus,@@ -480,7 +485,7 @@ do_gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)int ret =0 ; retry: -I915_WRITE_FW (GMBUS0 , bus->reg0); +I915_WRITE_FW (GMBUS0 , gmbus0_source | bus->reg0);for (; i < num; i += inc) { inc =1 ;@@ -490,7 +495,8 @@ do_gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) }else if (msgs[i].flags &I2C_M_RD ) { ret =gmbus_xfer_read (dev_priv, &msgs[i],0 ); }else { - ret =gmbus_xfer_write (dev_priv, &msgs[i]); + ret =gmbus_xfer_write (dev_priv, &msgs[i], + gmbus1_index); }if (!ret)@@ -598,7 +604,7 @@ gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)if (ret <0 ) bus->force_bit &= ~GMBUS_FORCE_BIT_RETRY ; }else { - ret =do_gmbus_xfer (adapter, msgs, num); + ret =do_gmbus_xfer (adapter, msgs, num,0 ,0 );if (ret == -EAGAIN ) bus->force_bit |=GMBUS_FORCE_BIT_RETRY ; }@@ -608,6 +614,38 @@ gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)return ret; } +int intel_gmbus_output_aksv (struct i2c_adapter *adapter) +{ + struct intel_gmbus *bus = container_of(adapter, struct intel_gmbus, + adapter); +struct drm_i915_private *dev_priv = bus->dev_priv; +int ret; +u8 buf[DRM_HDCP_KSV_LEN ] = {0 }; +struct i2c_msg msg = { + .addr =DRM_HDCP_DDC_ADDR , + .flags =0 , + .len =sizeof (buf), + .buf = buf, + }; + +intel_display_power_get (dev_priv,POWER_DOMAIN_GMBUS );
drivers/gpu/drm/i915/intel_i2c.c gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) · line 641
Quoted 10 lines
drivers/gpu/drm/i915/intel_i2c.c +10
-0+mutex_lock (&dev_priv->gmbus_mutex); + +/* +* In order to output Aksv to the receiver, use an indexed write to +* pass the i2c command, and tell GMBUS to use the HW-provided value +* instead of sourcing GMBUS3 for the data. +*/ + ret =do_gmbus_xfer (adapter, &msg,1 ,GMBUS_AKSV_SELECT , +GMBUS_CYCLE_INDEX | + (DRM_HDCP_DDC_AKSV <<GMBUS_SLAVE_INDEX_SHIFT ));
It might be nicer to just use two msgs here and modify gmbus_xfer_index_read() to support indexed writes as well. Would avoid having to pass in the GMBUS1 value all the way.
Not sure what to do with GMBUS_AKSV_SELECT. I guess either pass it in explicitly like you're doing here, or maybe add a small helper ala gmbus_is_index_read() so that do_gmbus_xfer() could sniff out which source we should use based on the passed in msgs?
Quoted 17 lines
drivers/gpu/drm/i915/intel_i2c.c +7
-0+ +mutex_unlock (&dev_priv->gmbus_mutex); +intel_display_power_put (dev_priv,POWER_DOMAIN_GMBUS ); + +return ret; +} +static u32 gmbus_func (struct i2c_adapter *adapter) { return i2c_bit_algo.functionality(adapter) &Signature · 6 lines
2.15.0.531.g2ccb3012c9-goog _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ Intel-gfx mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Re: [PATCH v2 6/8] drm/i915: Add function to output Aksv over GMBUS
Quoted 158 lines · Ville Syrjälä
Quoted 157 lines · Sean Paul
Once the Aksv is available in the PCH, we need to get it on the wire to the receiver via DDC. The hardware doesn't allow us to read the value directly, so we need to tell GMBUS to source the Aksv internally and send it to the right offset on the receiver.
The way we do this is to initiate an indexed write where the index is the Aksv register offset. We write dummy values to GMBUS3 as if we were sending the key, and the hardware slips in the "real" values when it goes out.
Changes in v2:
- NoneSigned-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_i2c.c | 54 ++++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 8 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -4043,6 +4043,7 @@ extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);extern void intel_teardown_gmbus (struct drm_i915_private *dev_priv);extern bool intel_gmbus_is_valid_pin (struct drm_i915_private *dev_priv,unsigned int pin); +extern int intel_gmbus_output_aksv (struct i2c_adapter *adapter);extern struct i2c_adapter *intel_gmbus_get_adapter (struct drm_i915_private *dev_priv,unsigned int pin);drivers/gpu/drm/i915/i915_reg.h +1
-0@@ -3040,6 +3040,7 @@ enum i915_power_well_id {# define GPIO_DATA_PULLUP_DISABLE (1 << 13)#define GMBUS0 _MMIO(dev_priv->gpio_mmio_base + 0x5100)/* clock/port select */ +#define GMBUS_AKSV_SELECT (1<<11)#define GMBUS_RATE_100KHZ (0<<8)#define GMBUS_RATE_50KHZ (1<<8)#define GMBUS_RATE_400KHZ (2<<8)/* reserved on Pineview */ drivers/gpu/drm/i915/intel_i2c.c +34
-8@@ -30,6 +30,7 @@#include <linux/i2c-algo-bit.h> #include <linux/export.h> #include <drm/drmP.h> +#include <drm/drm_hdcp.h> #include "intel_drv.h" #include <drm/i915_drm.h> #include "i915_drv.h" @@ -373,7 +374,8 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,static int gmbus_xfer_write_chunk (struct drm_i915_private *dev_priv, -unsigned short addr,u8 *buf,unsigned int len) +unsigned short addr,u8 *buf,unsigned int len, +u32 gmbus1_index) {unsigned int chunk_size = len;u32 val, loop;@@ -386,7 +388,7 @@ gmbus_xfer_write_chunk(struct drm_i915_private *dev_priv,I915_WRITE_FW (GMBUS3 , val);I915_WRITE_FW (GMBUS1 , -GMBUS_CYCLE_WAIT | + gmbus1_index |GMBUS_CYCLE_WAIT | (chunk_size <<GMBUS_BYTE_COUNT_SHIFT ) | (addr <<GMBUS_SLAVE_ADDR_SHIFT ) |GMBUS_SLAVE_WRITE |GMBUS_SW_RDY );@@ -409,7 +411,8 @@ gmbus_xfer_write_chunk(struct drm_i915_private *dev_priv, }static int -gmbus_xfer_write (struct drm_i915_private *dev_priv,struct i2c_msg *msg) +gmbus_xfer_write (struct drm_i915_private *dev_priv,struct i2c_msg *msg, +u32 gmbus1_index) {u8 *buf = msg->buf;unsigned int tx_size = msg->len;@@ -419,7 +422,8 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg) do { len = min(tx_size, GMBUS_BYTE_COUNT_MAX); - ret = gmbus_xfer_write_chunk(dev_priv, msg->addr, buf, len); + ret = gmbus_xfer_write_chunk(dev_priv, msg->addr, buf, len, + gmbus1_index); if (ret) return ret;@@ -470,7 +474,8 @@ gmbus_xfer_index_read(struct drm_i915_private *dev_priv, struct i2c_msg *msgs) }static int -do_gmbus_xfer (struct i2c_adapter *adapter,struct i2c_msg *msgs,int num) +do_gmbus_xfer (struct i2c_adapter *adapter,struct i2c_msg *msgs,int num, +u32 gmbus0_source,u32 gmbus1_index) { struct intel_gmbus *bus = container_of(adapter, struct intel_gmbus,@@ -480,7 +485,7 @@ do_gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)int ret =0 ; retry: -I915_WRITE_FW (GMBUS0 , bus->reg0); +I915_WRITE_FW (GMBUS0 , gmbus0_source | bus->reg0);for (; i < num; i += inc) { inc =1 ;@@ -490,7 +495,8 @@ do_gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) }else if (msgs[i].flags &I2C_M_RD ) { ret =gmbus_xfer_read (dev_priv, &msgs[i],0 ); }else { - ret =gmbus_xfer_write (dev_priv, &msgs[i]); + ret =gmbus_xfer_write (dev_priv, &msgs[i], + gmbus1_index); }if (!ret)@@ -598,7 +604,7 @@ gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)if (ret <0 ) bus->force_bit &= ~GMBUS_FORCE_BIT_RETRY ; }else { - ret =do_gmbus_xfer (adapter, msgs, num); + ret =do_gmbus_xfer (adapter, msgs, num,0 ,0 );if (ret == -EAGAIN ) bus->force_bit |=GMBUS_FORCE_BIT_RETRY ; }@@ -608,6 +614,38 @@ gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)return ret; } +int intel_gmbus_output_aksv (struct i2c_adapter *adapter) +{ + struct intel_gmbus *bus = container_of(adapter, struct intel_gmbus, + adapter); +struct drm_i915_private *dev_priv = bus->dev_priv; +int ret; +u8 buf[DRM_HDCP_KSV_LEN ] = {0 }; +struct i2c_msg msg = { + .addr =DRM_HDCP_DDC_ADDR , + .flags =0 , + .len =sizeof (buf), + .buf = buf, + }; + +intel_display_power_get (dev_priv,POWER_DOMAIN_GMBUS ); +mutex_lock (&dev_priv->gmbus_mutex); + +/* +* In order to output Aksv to the receiver, use an indexed write to +* pass the i2c command, and tell GMBUS to use the HW-provided value
Quoted 8 lines
drivers/gpu/drm/i915/intel_i2c.c gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) · line 641
Quoted 5 lines
drivers/gpu/drm/i915/intel_i2c.c +5
-0+* instead of sourcing GMBUS3 for the data. +*/ + ret =do_gmbus_xfer (adapter, &msg,1 ,GMBUS_AKSV_SELECT , +GMBUS_CYCLE_INDEX | + (DRM_HDCP_DDC_AKSV <<GMBUS_SLAVE_INDEX_SHIFT ));It might be nicer to just use two msgs here and modify
gmbus_xfer_index_read()to support indexed writes as well.
I think two msgs implies a STOP bit in between. At least, that's how I interpret "normal" writes.
Quoted 1 line
Would avoid having to pass in the GMBUS1 value all the way.
We could infer an indexed write if num_msgs == 1 && flags == 0 && len
Quoted 1 line
1. However that would require us to assume that all single msg
writes have a command byte at the beginning of the transaction, which might not be true for all i2c slaves.
Sean
Quoted 19 lines
Not sure what to do with
GMBUS_AKSV_SELECT. I guess either pass it in explicitly like you're doing here, or maybe add a small helper alagmbus_is_index_read()so thatdo_gmbus_xfer()could sniff out which source we should use based on the passed in msgs?Quoted 13 lines
drivers/gpu/drm/i915/intel_i2c.c +7
-1+ +mutex_unlock (&dev_priv->gmbus_mutex); +intel_display_power_put (dev_priv,POWER_DOMAIN_GMBUS ); + +return ret; +} +static u32 gmbus_func (struct i2c_adapter *adapter) { return i2c_bit_algo.functionality(adapter) & --2.15.0.531.g2ccb3012c9-goog
Quoted 8 lines
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Ville Syrjälä
Intel OTC
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 6/8] drm/i915: Add function to output Aksv over GMBUS
Quoted 169 lines · Sean Paul
Quoted 158 lines · Ville Syrjälä
Quoted 157 lines · Sean Paul
Once the Aksv is available in the PCH, we need to get it on the wire to the receiver via DDC. The hardware doesn't allow us to read the value directly, so we need to tell GMBUS to source the Aksv internally and send it to the right offset on the receiver.
The way we do this is to initiate an indexed write where the index is the Aksv register offset. We write dummy values to GMBUS3 as if we were sending the key, and the hardware slips in the "real" values when it goes out.
Changes in v2:
- NoneSigned-off-by Sean Paul <[email protected]>--- drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_i2c.c | 54 ++++++++++++++++++++++++++++++++++------ 3 files changed, 48 insertions(+), 8 deletions(-)drivers/gpu/drm/i915/i915_drv.h +1
-0@@ -4043,6 +4043,7 @@ extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);extern void intel_teardown_gmbus (struct drm_i915_private *dev_priv);extern bool intel_gmbus_is_valid_pin (struct drm_i915_private *dev_priv,unsigned int pin); +extern int intel_gmbus_output_aksv (struct i2c_adapter *adapter);extern struct i2c_adapter *intel_gmbus_get_adapter (struct drm_i915_private *dev_priv,unsigned int pin);drivers/gpu/drm/i915/i915_reg.h +1
-0@@ -3040,6 +3040,7 @@ enum i915_power_well_id {# define GPIO_DATA_PULLUP_DISABLE (1 << 13)#define GMBUS0 _MMIO(dev_priv->gpio_mmio_base + 0x5100)/* clock/port select */ +#define GMBUS_AKSV_SELECT (1<<11)#define GMBUS_RATE_100KHZ (0<<8)#define GMBUS_RATE_50KHZ (1<<8)#define GMBUS_RATE_400KHZ (2<<8)/* reserved on Pineview */ drivers/gpu/drm/i915/intel_i2c.c +34
-8@@ -30,6 +30,7 @@#include <linux/i2c-algo-bit.h> #include <linux/export.h> #include <drm/drmP.h> +#include <drm/drm_hdcp.h> #include "intel_drv.h" #include <drm/i915_drm.h> #include "i915_drv.h" @@ -373,7 +374,8 @@ gmbus_xfer_read(struct drm_i915_private *dev_priv, struct i2c_msg *msg,static int gmbus_xfer_write_chunk (struct drm_i915_private *dev_priv, -unsigned short addr,u8 *buf,unsigned int len) +unsigned short addr,u8 *buf,unsigned int len, +u32 gmbus1_index) {unsigned int chunk_size = len;u32 val, loop;@@ -386,7 +388,7 @@ gmbus_xfer_write_chunk(struct drm_i915_private *dev_priv,I915_WRITE_FW (GMBUS3 , val);I915_WRITE_FW (GMBUS1 , -GMBUS_CYCLE_WAIT | + gmbus1_index |GMBUS_CYCLE_WAIT | (chunk_size <<GMBUS_BYTE_COUNT_SHIFT ) | (addr <<GMBUS_SLAVE_ADDR_SHIFT ) |GMBUS_SLAVE_WRITE |GMBUS_SW_RDY );@@ -409,7 +411,8 @@ gmbus_xfer_write_chunk(struct drm_i915_private *dev_priv, }static int -gmbus_xfer_write (struct drm_i915_private *dev_priv,struct i2c_msg *msg) +gmbus_xfer_write (struct drm_i915_private *dev_priv,struct i2c_msg *msg, +u32 gmbus1_index) {u8 *buf = msg->buf;unsigned int tx_size = msg->len;@@ -419,7 +422,8 @@ gmbus_xfer_write(struct drm_i915_private *dev_priv, struct i2c_msg *msg) do { len = min(tx_size, GMBUS_BYTE_COUNT_MAX); - ret = gmbus_xfer_write_chunk(dev_priv, msg->addr, buf, len); + ret = gmbus_xfer_write_chunk(dev_priv, msg->addr, buf, len, + gmbus1_index); if (ret) return ret;@@ -470,7 +474,8 @@ gmbus_xfer_index_read(struct drm_i915_private *dev_priv, struct i2c_msg *msgs) }static int -do_gmbus_xfer (struct i2c_adapter *adapter,struct i2c_msg *msgs,int num) +do_gmbus_xfer (struct i2c_adapter *adapter,struct i2c_msg *msgs,int num, +u32 gmbus0_source,u32 gmbus1_index) { struct intel_gmbus *bus = container_of(adapter, struct intel_gmbus,@@ -480,7 +485,7 @@ do_gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)int ret =0 ; retry: -I915_WRITE_FW (GMBUS0 , bus->reg0); +I915_WRITE_FW (GMBUS0 , gmbus0_source | bus->reg0);for (; i < num; i += inc) { inc =1 ;@@ -490,7 +495,8 @@ do_gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) }else if (msgs[i].flags &I2C_M_RD ) { ret =gmbus_xfer_read (dev_priv, &msgs[i],0 ); }else { - ret =gmbus_xfer_write (dev_priv, &msgs[i]); + ret =gmbus_xfer_write (dev_priv, &msgs[i], + gmbus1_index); }if (!ret)@@ -598,7 +604,7 @@ gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)if (ret <0 ) bus->force_bit &= ~GMBUS_FORCE_BIT_RETRY ; }else { - ret =do_gmbus_xfer (adapter, msgs, num); + ret =do_gmbus_xfer (adapter, msgs, num,0 ,0 );if (ret == -EAGAIN ) bus->force_bit |=GMBUS_FORCE_BIT_RETRY ; }@@ -608,6 +614,38 @@ gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num)return ret; } +int intel_gmbus_output_aksv (struct i2c_adapter *adapter) +{ + struct intel_gmbus *bus = container_of(adapter, struct intel_gmbus, + adapter); +struct drm_i915_private *dev_priv = bus->dev_priv; +int ret; +u8 buf[DRM_HDCP_KSV_LEN ] = {0 }; +struct i2c_msg msg = { + .addr =DRM_HDCP_DDC_ADDR , + .flags =0 , + .len =sizeof (buf), + .buf = buf, + }; + +intel_display_power_get (dev_priv,POWER_DOMAIN_GMBUS ); +mutex_lock (&dev_priv->gmbus_mutex); + +/* +* In order to output Aksv to the receiver, use an indexed write to +* pass the i2c command, and tell GMBUS to use the HW-provided value Quoted 8 lines
drivers/gpu/drm/i915/intel_i2c.c gmbus_xfer(struct i2c_adapter *adapter, struct i2c_msg *msgs, int num) · line 641
Quoted 5 lines
drivers/gpu/drm/i915/intel_i2c.c +5
-0+* instead of sourcing GMBUS3 for the data. +*/ + ret =do_gmbus_xfer (adapter, &msg,1 ,GMBUS_AKSV_SELECT , +GMBUS_CYCLE_INDEX | + (DRM_HDCP_DDC_AKSV <<GMBUS_SLAVE_INDEX_SHIFT ));It might be nicer to just use two msgs here and modify
gmbus_xfer_index_read()to support indexed writes as well.
Quoted 2 lines
I think two msgs implies a STOP bit in between. At least, that's how I interpret "normal" writes.
There is never a step between two msgs AIUI, unless you specify I2C_M_STOP. There might be a repeated start. If we want to be pedantic about the repeated start we could use the I2C_M_NOSTART flag. Although I don't think this stuff is really documented anywhere so I'm not sure if I2C_M_NOSTART is really supposed to apply to two messages with the same slave address and same direction, or if it's just meant to suppress the repeated start when changing the direction of the bus (which gmbus can't do, and we actually fail to check for that).
I suppose i2c-algo-bit is the defacto standard here. And that one seems to do the repeated start whenever I2C_M_NOSTART is not specified. Would be actually nice to know what gmbus does when you just do two back to back non-indexed writes to the same slave address. If it doesn't do a repeated start in between, then I guess we're also violating I2C_M_NOSTART currently.
Quoted 38 lines
Quoted 2 lines
Would avoid having to pass in the GMBUS1 value all the way.
We could infer an indexed write if
num_msgs== 1 && flags == 0 && lenQuoted 1 line
1. However that would require us to assume that all single msg
writes have a command byte at the beginning of the transaction, which might not be true for all i2c slaves.
Sean
Quoted 27 lines
Not sure what to do with
GMBUS_AKSV_SELECT. I guess either pass it in explicitly like you're doing here, or maybe add a small helper alagmbus_is_index_read()so thatdo_gmbus_xfer()could sniff out which source we should use based on the passed in msgs?Quoted 13 lines
drivers/gpu/drm/i915/intel_i2c.c +7
-1+ +mutex_unlock (&dev_priv->gmbus_mutex); +intel_display_power_put (dev_priv,POWER_DOMAIN_GMBUS ); + +return ret; +} +static u32 gmbus_func (struct i2c_adapter *adapter) { return i2c_bit_algo.functionality(adapter) & --2.15.0.531.g2ccb3012c9-goog
Quoted 4 lines
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel--
Ville Syrjälä
Intel OTC
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 7/8 drm/i915: Implement HDCP for HDMI
In reply to Sean PaulThis patch adds HDCP support for HDMI connectors by implementing the intel_hdcp_shim.
Nothing too special, just a bunch of DDC reads/writes.
Changes in v2:
- Rebased on drm-intel-next
--- drivers/gpu/drm/i915/i915_reg.h | 1 + drivers/gpu/drm/i915/intel_ddi.c | 50 ++++++++ drivers/gpu/drm/i915/intel_drv.h | 2 + drivers/gpu/drm/i915/intel_hdmi.c | 254 ++++++++++++++++++++++++++++++++++++++ 4 files changed, 307 insertions(+)
drivers/gpu/drm/i915/i915_reg.h +1 -0
@@ -8447,6 +8447,7 @@ enum skl_power_gate {#define TRANS_DDI_EDP_INPUT_A_ONOFF (4<<12)#define TRANS_DDI_EDP_INPUT_B_ONOFF (5<<12)#define TRANS_DDI_EDP_INPUT_C_ONOFF (6<<12) +#define TRANS_DDI_HDCP_SIGNALLING (1<<9)#define TRANS_DDI_DP_VC_PAYLOAD_ALLOC (1<<8)#define TRANS_DDI_HDMI_SCRAMBLER_CTS_ENABLE (1<<7)#define TRANS_DDI_HDMI_SCRAMBLER_RESET_FREQ (1<<6)
drivers/gpu/drm/i915/intel_ddi.c +50 -0
56 lines not on this page · raw message
drivers/gpu/drm/i915/intel_drv.h +2 -0
@@ -1378,6 +1378,8 @@ void intel_ddi_compute_min_voltage_level(struct drm_i915_private *dev_priv,u32 bxt_signal_levels (struct intel_dp *intel_dp);uint32_t ddi_signal_levels (struct intel_dp *intel_dp);u8 intel_ddi_dp_voltage_max (struct intel_encoder *encoder); +int intel_ddi_enable_hdcp_signalling (struct intel_encoder *intel_encoder); +int intel_ddi_disable_hdcp_signalling (struct intel_encoder *intel_encoder);unsigned int intel_fb_align_height (const struct drm_framebuffer *fb,int plane,unsigned int height);
drivers/gpu/drm/i915/intel_hdmi.c +254 -0
272 lines not on this page · raw message
Signature · 1 line
2.15.0.531.g2ccb3012c9-goog
PATCH v2 8/8 drm/i915: Implement HDCP for DisplayPort
In reply to Sean PaulThis patch adds HDCP support for DisplayPort connectors by implementing the intel_hdcp_shim.
Most of this is straightforward read/write from/to DPCD registers. One thing worth pointing out is the Aksv output bit. It wasn't easily separable like it's HDMI counterpart, so it's crammed in with the rest of it.
Changes in v2:
- Moved intel_hdcp_check_link out of intel_dp_check_link and only call it on short pulse. Since intel_hdcp_check_link does its own locking, this ensures we don't deadlock when intel_dp_check_link is called holding connection_mutex.
- Rebased on drm-intel-next
--- drivers/gpu/drm/i915/intel_dp.c | 245 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 238 insertions(+), 7 deletions(-)
drivers/gpu/drm/i915/intel_dp.c +238 -7
@@ -36,7 +36,9 @@#include <drm/drm_atomic_helper.h> #include <drm/drm_crtc.h> #include <drm/drm_crtc_helper.h> +#include <drm/drm_dp_helper.h> #include <drm/drm_edid.h> +#include <drm/drm_hdcp.h> #include "intel_drv.h" #include <drm/i915_drm.h> #include "i915_drv.h"
@@ -1025,10 +1027,29 @@ static uint32_t skl_get_aux_send_ctl(struct intel_dp *intel_dp,DP_AUX_CH_CTL_SYNC_PULSE_SKL (32 ); } +static uint32_t intel_dp_get_aux_send_ctl (struct intel_dp *intel_dp, +bool has_aux_irq, +int send_bytes, +uint32_t aux_clock_divider, +bool aksv_write) +{ +uint32_t val =0 ; + +if (aksv_write) { + send_bytes +=5 ; + val |=DP_AUX_CH_CTL_AUX_AKSV_SELECT ; + } + +return val | intel_dp->get_aux_send_ctl (intel_dp, + has_aux_irq, + send_bytes, + aux_clock_divider); +} +static int intel_dp_aux_ch (struct intel_dp *intel_dp,const uint8_t *send,int send_bytes, -uint8_t *recv,int recv_size) +uint8_t *recv,int recv_size,bool aksv_write) {struct intel_digital_port *intel_dig_port =dp_to_dig_port (intel_dp); struct drm_i915_private *dev_priv =
@@ -1088,10 +1109,11 @@ intel_dp_aux_ch(struct intel_dp *intel_dp, }while ((aux_clock_divider = intel_dp->get_aux_clock_divider (intel_dp, clock++))) { -u32 send_ctl = intel_dp->get_aux_send_ctl (intel_dp, - has_aux_irq, - send_bytes, - aux_clock_divider); +u32 send_ctl =intel_dp_get_aux_send_ctl (intel_dp, + has_aux_irq, + send_bytes, + aux_clock_divider, + aksv_write);/* Must try at least 3 times according to DP spec */ for (try =0 ; try <5 ; try++) {
@@ -1228,7 +1250,8 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)if (msg->buffer)memcpy (txbuf +HEADER_SIZE , msg->buffer, msg->size); - ret =intel_dp_aux_ch (intel_dp, txbuf, txsize, rxbuf, rxsize); + ret =intel_dp_aux_ch (intel_dp, txbuf, txsize, rxbuf, rxsize, + false);if (ret >0 ) { msg->reply = rxbuf[0 ] >>4 ;
@@ -1250,7 +1273,8 @@ intel_dp_aux_transfer(struct drm_dp_aux *aux, struct drm_dp_aux_msg *msg)if (WARN_ON (rxsize >20 ))return -E2BIG ; - ret =intel_dp_aux_ch (intel_dp, txbuf, txsize, rxbuf, rxsize); + ret =intel_dp_aux_ch (intel_dp, txbuf, txsize, rxbuf, rxsize, + false);if (ret >0 ) { msg->reply = rxbuf[0 ] >>4 ;/*
@@ -4373,6 +4397,9 @@ intel_dp_short_pulse(struct intel_dp *intel_dp)drm_kms_helper_hotplug_event (&dev_priv->drm); } +/* Short pulse can signify loss of hdcp authentication */ +intel_hdcp_check_link (intel_dp->attached_connector); +return true; }
@@ -4963,6 +4990,203 @@ void intel_dp_encoder_suspend(struct intel_encoder *intel_encoder)pps_unlock (intel_dp); } +static +int intel_dp_hdcp_write_an_aksv (struct intel_digital_port *intel_dig_port, +u8 *an) +{ +struct intel_dp *intel_dp =enc_to_intel_dp (&intel_dig_port->base.base); +uint8_t txbuf[4 ], rxbuf[2 ], reply =0 ; +ssize_t dpcd_ret; +int ret; + +/* Output An first, that's easy */ + dpcd_ret =drm_dp_dpcd_write (&intel_dig_port->dp.aux,DP_AUX_HDCP_AN , + an,DRM_HDCP_AN_LEN ); +if (dpcd_ret !=DRM_HDCP_AN_LEN ) { +DRM_ERROR ("Failed to write An over DP/AUX (%ld)\n" , dpcd_ret); +return dpcd_ret >=0 ? -EIO : dpcd_ret; + } + +/* +* Since Aksv is Oh-So-Secret, we can't access it in software. So in +* order to get it on the wire, we need to create the AUX header as if +* we were writing the data, and then tickle the hardware to output the +* data once the header is sent out. +*/ + txbuf[0 ] = (DP_AUX_NATIVE_WRITE <<4 ) | + ((DP_AUX_HDCP_AKSV >>16 ) &0xf ); + txbuf[1 ] = (DP_AUX_HDCP_AKSV >>8 ) &0xff ; + txbuf[2 ] =DP_AUX_HDCP_AKSV &0xff ; + txbuf[3 ] =DRM_HDCP_KSV_LEN -1 ; + + ret =intel_dp_aux_ch (intel_dp, txbuf,sizeof (txbuf), rxbuf, +sizeof (rxbuf), true); +if (ret <0 ) { +DRM_ERROR ("Write Aksv over DP/AUX failed (%d)\n" , ret); +return ret; + }else if (ret ==0 ) { +DRM_ERROR ("Aksv write over DP/AUX was empty\n" ); +return -EIO ; + } + + reply = (rxbuf[0 ] >>4 ) &DP_AUX_NATIVE_REPLY_MASK ; +return reply ==DP_AUX_NATIVE_REPLY_ACK ?0 : -EIO ; +} + +static int intel_dp_hdcp_read_bksv (struct intel_digital_port *intel_dig_port, +u8 *bksv) +{ +ssize_t ret; + ret =drm_dp_dpcd_read (&intel_dig_port->dp.aux,DP_AUX_HDCP_BKSV , bksv, +DRM_HDCP_KSV_LEN ); +if (ret !=DRM_HDCP_KSV_LEN ) { +DRM_ERROR ("Read Bksv from DP/AUX failed (%ld)\n" , ret); +return ret >=0 ? -EIO : ret; + } +return 0 ; +} + +static int intel_dp_hdcp_read_bstatus (struct intel_digital_port *intel_dig_port, +u8 *bstatus) +{ +ssize_t ret; +/* +* For some reason the HDMI and DP HDCP specs call this register +* definition by different names. In the HDMI spec, it's called BSTATUS, +* but in DP it's called BINFO. +*/ + ret =drm_dp_dpcd_read (&intel_dig_port->dp.aux,DP_AUX_HDCP_BINFO , + bstatus,DRM_HDCP_BSTATUS_LEN ); +if (ret !=DRM_HDCP_BSTATUS_LEN ) { +DRM_ERROR ("Read bstatus from DP/AUX failed (%ld)\n" , ret); +return ret >=0 ? -EIO : ret; + } +return 0 ; +} + +static +int intel_dp_hdcp_repeater_present (struct intel_digital_port *intel_dig_port, +bool *repeater_present) +{ +ssize_t ret; +u8 bcaps; + ret =drm_dp_dpcd_read (&intel_dig_port->dp.aux,DP_AUX_HDCP_BCAPS , + &bcaps,1 ); +if (ret !=1 ) { +DRM_ERROR ("Read bcaps from DP/AUX failed (%ld)\n" , ret); +return ret >=0 ? -EIO : ret; + } + *repeater_present = bcaps &DP_BCAPS_REPEATER_PRESENT ; +return 0 ; +} + +static +int intel_dp_hdcp_read_ri_prime (struct intel_digital_port *intel_dig_port, +u8 *ri_prime) +{ +ssize_t ret; + ret =drm_dp_dpcd_read (&intel_dig_port->dp.aux,DP_AUX_HDCP_RI_PRIME , + ri_prime,DRM_HDCP_RI_LEN ); +if (ret !=DRM_HDCP_RI_LEN ) { +DRM_ERROR ("Read Ri' from DP/AUX failed (%ld)\n" , ret); +return ret >=0 ? -EIO : ret; + } +return 0 ; +} + +static +int intel_dp_hdcp_read_ksv_ready (struct intel_digital_port *intel_dig_port, +bool *ksv_ready) +{ +ssize_t ret; +u8 bstatus; + ret =drm_dp_dpcd_read (&intel_dig_port->dp.aux,DP_AUX_HDCP_BSTATUS , + &bstatus,1 ); +if (ret !=1 ) { +DRM_ERROR ("Read bstatus from DP/AUX failed (%ld)\n" , ret); +return ret >=0 ? -EIO : ret; + } + *ksv_ready = bstatus &DP_BSTATUS_READY ; +return 0 ; +} + +static +int intel_dp_hdcp_read_ksv_fifo (struct intel_digital_port *intel_dig_port, +int num_downstream,u8 *ksv_fifo) +{ +ssize_t ret; +int i; + +// KSV list is read via 15 byte window (3 entries @ 5 bytes each) +for (i =0 ; i < num_downstream; i +=3 ) { +size_t len =min (num_downstream - i,3 ) *DRM_HDCP_KSV_LEN ; + ret =drm_dp_dpcd_read (&intel_dig_port->dp.aux, +DP_AUX_HDCP_KSV_FIFO , + ksv_fifo + i *DRM_HDCP_KSV_LEN , + len); +if (ret != len) { +DRM_ERROR ("Read ksv[%d] from DP/AUX failed (%ld)\n" , i, + ret); +return ret >=0 ? -EIO : ret; + } + } +return 0 ; +} + +static +int intel_dp_hdcp_read_v_prime_part (struct intel_digital_port *intel_dig_port, +int i,u32 *part) +{ +ssize_t ret; + +if (i >=DRM_HDCP_V_PRIME_NUM_PARTS ) +return -EINVAL ; + + ret =drm_dp_dpcd_read (&intel_dig_port->dp.aux, +DP_AUX_HDCP_V_PRIME (i), part, +DRM_HDCP_V_PRIME_PART_LEN ); +if (ret !=DRM_HDCP_V_PRIME_PART_LEN ) { +DRM_ERROR ("Read v'[%d] from DP/AUX failed (%ld)\n" , i, ret); +return ret >=0 ? -EIO : ret; + } +return 0 ; +} + +static +int intel_dp_hdcp_toggle_signalling (struct intel_digital_port *intel_dig_port, +bool enable) +{ +/* Not used for single stream DisplayPort setups */ +return 0 ; +} + +static +bool intel_dp_hdcp_check_link (struct intel_digital_port *intel_dig_port) +{ +ssize_t ret; +u8 bstatus; + ret =drm_dp_dpcd_read (&intel_dig_port->dp.aux,DP_AUX_HDCP_BSTATUS , + &bstatus,1 ); +if (ret !=1 ) { +DRM_ERROR ("Read bstatus from DP/AUX failed (%ld)\n" , ret); +return ret >=0 ? -EIO : ret; + } +return !(bstatus &DP_BSTATUS_LINK_FAILURE ); +} + +static const struct intel_hdcp_shim intel_dp_hdcp_shim = { + .write_an_aksv = intel_dp_hdcp_write_an_aksv, + .read_bksv = intel_dp_hdcp_read_bksv, + .read_bstatus = intel_dp_hdcp_read_bstatus, + .repeater_present = intel_dp_hdcp_repeater_present, + .read_ri_prime = intel_dp_hdcp_read_ri_prime, + .read_ksv_ready = intel_dp_hdcp_read_ksv_ready, + .read_ksv_fifo = intel_dp_hdcp_read_ksv_fifo, + .read_v_prime_part = intel_dp_hdcp_read_v_prime_part, + .toggle_signalling = intel_dp_hdcp_toggle_signalling, + .check_link = intel_dp_hdcp_check_link, +}; +static void intel_edp_panel_vdd_sanitize (struct intel_dp *intel_dp) {struct drm_i915_private *dev_priv =to_i915 (intel_dp_to_dev (intel_dp));
@@ -6066,6 +6290,13 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,intel_dp_add_properties (intel_dp, connector); +if (INTEL_GEN (dev_priv) >=9 && !intel_dp_is_edp (intel_dp)) { +drm_connector_attach_content_protection_property (connector); + intel_connector->hdcp_shim = &intel_dp_hdcp_shim; +mutex_init (&intel_connector->hdcp_mutex); +INIT_DELAYED_WORK (&intel_connector->hdcp_work, intel_hdcp_work); + } +/* For G4X desktop chip, PEG_BAND_GAP_DATA 3:0 must first be written * 0xd. Failure to do so will result in spurious interrupts being * generated on the port when a cable is not attached.
Signature · 1 line
2.15.0.531.g2ccb3012c9-goog
Patchwork
CI✗ Fi.CI.BAT: failure for drm/i915: Implement HDCP (rev2)
In reply to Sean Paul== Series Details ==
== Series Details ==
Series: drm/i915: Implement HDCP (rev2)
URL : https://patchwork.freedesktop.org/series/34671/
State : failure
== Summary ==
Applying: drm: Fix link-status kerneldoc line lengths
error: Failed to merge in the changes.
Using index info to reconstruct a base tree...
M drivers/gpu/drm/drm_connector.c
Falling back to patching base and 3-way merge... Auto-merging drivers/gpu/drm/drm_connector.c
CONFLICT (content): Merge conflict in drivers/gpu/drm/drm_connector.c Patch failed at 0001 drm: Fix link-status kerneldoc line lengths The copy of the patch that failed is found in: .git/rebase-apply/patch When you have resolved this problem, run "git am --continue". If you prefer to skip this patch, run "git am --skip" instead. To restore the original branch and stop patching, run "git am --abort".
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Hi Sean,
Quoted 9 lines · Sean Paul
Ok, here's v2 of the HDCP patchset, no longer RFC since I've tackled the TODO list I set out in the first version (Annotated below for convenience).
The big changes to take note of in v2 is locking. To account for atomic async + the property's mutability, I'm using a dedicated mutex and moved property setting on the kernel side to the worker. I think this is actually a lot easier to read, and it opens the door to future improvements such as not doing the enable/disable via modeset.
Quoted 11 lines
TODO:
- DONE: Add kerneldoc for property
- DONE: Fix '//' comments
- DONE: Change to MIT license
- DONE: Improve documentation ondrm_intel_hdcp_shim
- DONE: Fix async commit locking (ie: don't useconnection_mutex)
- DONE: Don't changeconnector->statein enable, defer to worker
- Rebase on Ville's gmbus fixes (thanks Ville)
- Looks like these haven't landed, but I've rebased on drm-intel-next
- Add igt coverage for the feature.
- Working on this now
Looking at this patch series it seems that there is no drm support to get the BKSV from the i915, right? If you want to use the i915 (or any HDMI/DP output) in a repeater scenario then userspace has to be able to obtain that information so it can be added to the BKSV of the HDMI receiver.
For the record, the V4L2 subsystem used by HDMI receivers doesn't support HDCP yet, although patches exist.
I can understand that you are not (yet) adding repeater support, but it should be documented somewhere in the patch series that this is not there yet and that a standard DRM API would be needed to obtain the BKSV from the transmitter.
Second question: has this been tested with a MST hub?
Regards,
Hans
Quoted 29 lines
Thanks!
Sean
Sean Paul (8):
drm: Fix link-status kerneldoc line lengths drm/i915: Add more control towait_forroutines
drm: Add Content Protection property
drm: Add some HDCP related #defines drm/i915: Add HDCP framework + base implementation drm/i915: Add function to output Aksv over GMBUS drm/i915: Implement HDCP for HDMI drm/i915: Implement HDCP for DisplayPortdrivers/gpu/drm/drm_atomic.c | 8 + drivers/gpu/drm/drm_connector.c | 80 ++++- drivers/gpu/drm/drm_sysfs.c | 1 + drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_reg.h | 85 +++++ drivers/gpu/drm/i915/intel_atomic.c | 26 +- drivers/gpu/drm/i915/intel_ddi.c | 64 ++++ drivers/gpu/drm/i915/intel_dp.c | 245 ++++++++++++- drivers/gpu/drm/i915/intel_drv.h | 98 +++++- drivers/gpu/drm/i915/intel_hdcp.c | 684 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_hdmi.c | 254 +++++++++++++ drivers/gpu/drm/i915/intel_i2c.c | 54 ++- drivers/gpu/drm/i915/intel_uncore.c | 23 +-
Quoted 9 lines
drivers/gpu/drm/i915/intel_uncore.h | 14 +- include/drm/drm_connector.h | 16 + include/drm/drm_dp_helper.h | 17 + include/drm/drm_hdcp.h | 56 +++ include/uapi/drm/drm_mode.h | 4 + 19 files changed, 1697 insertions(+), 34 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_hdcp.c create mode 100644 include/drm/drm_hdcp.h
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Quoted 24 lines · Hans Verkuil
Hi Sean,
Quoted 9 lines · Sean Paul
Ok, here's v2 of the HDCP patchset, no longer RFC since I've tackled the TODO list I set out in the first version (Annotated below for convenience).
The big changes to take note of in v2 is locking. To account for atomic async + the property's mutability, I'm using a dedicated mutex and moved property setting on the kernel side to the worker. I think this is actually a lot easier to read, and it opens the door to future improvements such as not doing the enable/disable via modeset.
Quoted 11 lines
TODO:
- DONE: Add kerneldoc for property
- DONE: Fix '//' comments
- DONE: Change to MIT license
- DONE: Improve documentation ondrm_intel_hdcp_shim
- DONE: Fix async commit locking (ie: don't useconnection_mutex)
- DONE: Don't changeconnector->statein enable, defer to worker
- Rebase on Ville's gmbus fixes (thanks Ville)
- Looks like these haven't landed, but I've rebased on drm-intel-next
- Add igt coverage for the feature.
- Working on this now
Quoted 5 lines
Looking at this patch series it seems that there is no drm support to get the BKSV from the i915, right? If you want to use the i915 (or any HDMI/DP output) in a repeater scenario then userspace has to be able to obtain that information so it can be added to the BKSV of the HDMI receiver.
Hi Hans,
Repeater support is implemented in intel_hdcp_auth_downstream()
Quoted 9 lines
For the record, the V4L2 subsystem used by HDMI receivers doesn't support HDCP yet, although patches exist.
I can understand that you are not (yet) adding repeater support, but it should be documented somewhere in the patch series that this is not there yet and that a standard DRM API would be needed to obtain the BKSV from the transmitter.
Second question: has this been tested with a MST hub?
No, MST is not supported at the moment (there's a TODO in the code)
Sean
Quoted 43 lines
Regards,
Hans
Quoted 38 lines
Thanks!
Sean
Sean Paul (8):
drm: Fix link-status kerneldoc line lengths drm/i915: Add more control towait_forroutines
drm: Add Content Protection property
drm: Add some HDCP related #defines drm/i915: Add HDCP framework + base implementation drm/i915: Add function to output Aksv over GMBUS drm/i915: Implement HDCP for HDMI drm/i915: Implement HDCP for DisplayPortdrivers/gpu/drm/drm_atomic.c | 8 + drivers/gpu/drm/drm_connector.c | 80 ++++- drivers/gpu/drm/drm_sysfs.c | 1 + drivers/gpu/drm/i915/Makefile | 1 + drivers/gpu/drm/i915/i915_drv.h | 1 + drivers/gpu/drm/i915/i915_reg.h | 85 +++++ drivers/gpu/drm/i915/intel_atomic.c | 26 +- drivers/gpu/drm/i915/intel_ddi.c | 64 ++++ drivers/gpu/drm/i915/intel_dp.c | 245 ++++++++++++- drivers/gpu/drm/i915/intel_drv.h | 98 +++++- drivers/gpu/drm/i915/intel_hdcp.c | 684 ++++++++++++++++++++++++++++++++++++ drivers/gpu/drm/i915/intel_hdmi.c | 254 +++++++++++++ drivers/gpu/drm/i915/intel_i2c.c | 54 ++- drivers/gpu/drm/i915/intel_uncore.c | 23 +- drivers/gpu/drm/i915/intel_uncore.h | 14 +- include/drm/drm_connector.h | 16 + include/drm/drm_dp_helper.h | 17 + include/drm/drm_hdcp.h | 56 +++ include/uapi/drm/drm_mode.h | 4 + 19 files changed, 1697 insertions(+), 34 deletions(-) create mode 100644 drivers/gpu/drm/i915/intel_hdcp.c create mode 100644 include/drm/drm_hdcp.h
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx