Skip to content

Commit 933519a

Browse files
committed
Merge tag 'topic/hdcp-2018-02-13' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
Add HDCP support to i915 drm driver. * tag 'topic/hdcp-2018-02-13' of git://anongit.freedesktop.org/drm/drm-misc: (26 commits) drm/i915: fix misalignment in HDCP register def drm/i915: Reauthenticate HDCP on failure drm/i915: Detect panel's hdcp capability drm/i915: Optimize HDCP key load drm/i915: Retry HDCP bksv read drm/i915: Connector info in HDCP debug msgs drm/i915: Stop encryption for repeater with no sink drm/i915: Handle failure from 2nd stage HDCP auth drm/i915: Downgrade hdcp logs from INFO to DEBUG_KMS drm/i915: Restore HDCP DRM_INFO when with no downstream drm/i915: Check for downstream topology errors drm/i915: Start repeater auth on READY/CP_IRQ drm/i915: II stage HDCP auth for repeater only drm/i915: Extending HDCP for HSW, BDW and BXT+ drm/i915/dp: Fix compilation of intel_dp_hdcp_check_link drm/i915: Only disable HDCP when it's active drm/i915: Don't allow HDCP on PORT E/F drm/i915: Implement HDCP for DisplayPort drm/i915: Implement HDCP for HDMI drm/i915: Add function to output Aksv over GMBUS ...
2 parents 76ea0f3 + 2834d9d commit 933519a

19 files changed

Lines changed: 1820 additions & 43 deletions

‎drivers/gpu/drm/drm_atomic.c‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1224,6 +1224,12 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
12241224
state->picture_aspect_ratio = val;
12251225
} else if (property == connector->scaling_mode_property) {
12261226
state->scaling_mode = val;
1227+
} else if (property == connector->content_protection_property) {
1228+
if (val == DRM_MODE_CONTENT_PROTECTION_ENABLED) {
1229+
DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
1230+
return -EINVAL;
1231+
}
1232+
state->content_protection = val;
12271233
} else if (connector->funcs->atomic_set_property) {
12281234
return connector->funcs->atomic_set_property(connector,
12291235
state, property, val);
@@ -1303,6 +1309,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
13031309
*val = state->picture_aspect_ratio;
13041310
} else if (property == connector->scaling_mode_property) {
13051311
*val = state->scaling_mode;
1312+
} else if (property == connector->content_protection_property) {
1313+
*val = state->content_protection;
13061314
} else if (connector->funcs->atomic_get_property) {
13071315
return connector->funcs->atomic_get_property(connector,
13081316
state, property, val);

‎drivers/gpu/drm/drm_connector.c‎

Lines changed: 83 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -761,6 +761,13 @@ static const struct drm_prop_enum_list drm_tv_subconnector_enum_list[] = {
761761
DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
762762
drm_tv_subconnector_enum_list)
763763

764+
static struct drm_prop_enum_list drm_cp_enum_list[] = {
765+
{ DRM_MODE_CONTENT_PROTECTION_UNDESIRED, "Undesired" },
766+
{ DRM_MODE_CONTENT_PROTECTION_DESIRED, "Desired" },
767+
{ DRM_MODE_CONTENT_PROTECTION_ENABLED, "Enabled" },
768+
};
769+
DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list)
770+
764771
/**
765772
* DOC: standard connector properties
766773
*
@@ -822,14 +829,50 @@ DRM_ENUM_NAME_FN(drm_get_tv_subconnector_name,
822829
* should update this value using drm_mode_connector_set_tile_property().
823830
* Userspace cannot change this property.
824831
* link-status:
825-
* Connector link-status property to indicate the status of link. The default
826-
* value of link-status is "GOOD". If something fails during or after modeset,
827-
* the kernel driver may set this to "BAD" and issue a hotplug uevent. Drivers
828-
* should update this value using drm_mode_connector_set_link_status_property().
832+
* Connector link-status property to indicate the status of link. The
833+
* default value of link-status is "GOOD". If something fails during or
834+
* after modeset, the kernel driver may set this to "BAD" and issue a
835+
* hotplug uevent. Drivers should update this value using
836+
* drm_mode_connector_set_link_status_property().
829837
* non_desktop:
830838
* Indicates the output should be ignored for purposes of displaying a
831839
* standard desktop environment or console. This is most likely because
832840
* the output device is not rectilinear.
841+
* Content Protection:
842+
* This property is used by userspace to request the kernel protect future
843+
* content communicated over the link. When requested, kernel will apply
844+
* the appropriate means of protection (most often HDCP), and use the
845+
* property to tell userspace the protection is active.
846+
*
847+
* Drivers can set this up by calling
848+
* drm_connector_attach_content_protection_property() on initialization.
849+
*
850+
* The value of this property can be one of the following:
851+
*
852+
* - DRM_MODE_CONTENT_PROTECTION_UNDESIRED = 0
853+
* The link is not protected, content is transmitted in the clear.
854+
* - DRM_MODE_CONTENT_PROTECTION_DESIRED = 1
855+
* Userspace has requested content protection, but the link is not
856+
* currently protected. When in this state, kernel should enable
857+
* Content Protection as soon as possible.
858+
* - DRM_MODE_CONTENT_PROTECTION_ENABLED = 2
859+
* Userspace has requested content protection, and the link is
860+
* protected. Only the driver can set the property to this value.
861+
* If userspace attempts to set to ENABLED, kernel will return
862+
* -EINVAL.
863+
*
864+
* A few guidelines:
865+
*
866+
* - DESIRED state should be preserved until userspace de-asserts it by
867+
* setting the property to UNDESIRED. This means ENABLED should only
868+
* transition to UNDESIRED when the user explicitly requests it.
869+
* - If the state is DESIRED, kernel should attempt to re-authenticate the
870+
* link whenever possible. This includes across disable/enable, dpms,
871+
* hotplug, downstream device changes, link status failures, etc..
872+
* - Userspace is responsible for polling the property to determine when
873+
* the value transitions from ENABLED to DESIRED. This signifies the link
874+
* is no longer protected and userspace should take appropriate action
875+
* (whatever that might be).
833876
*
834877
* Connectors also have one standardized atomic property:
835878
*
@@ -1130,6 +1173,42 @@ int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
11301173
}
11311174
EXPORT_SYMBOL(drm_connector_attach_scaling_mode_property);
11321175

1176+
/**
1177+
* drm_connector_attach_content_protection_property - attach content protection
1178+
* property
1179+
*
1180+
* @connector: connector to attach CP property on.
1181+
*
1182+
* This is used to add support for content protection on select connectors.
1183+
* Content Protection is intentionally vague to allow for different underlying
1184+
* technologies, however it is most implemented by HDCP.
1185+
*
1186+
* The content protection will be set to &drm_connector_state.content_protection
1187+
*
1188+
* Returns:
1189+
* Zero on success, negative errno on failure.
1190+
*/
1191+
int drm_connector_attach_content_protection_property(
1192+
struct drm_connector *connector)
1193+
{
1194+
struct drm_device *dev = connector->dev;
1195+
struct drm_property *prop;
1196+
1197+
prop = drm_property_create_enum(dev, 0, "Content Protection",
1198+
drm_cp_enum_list,
1199+
ARRAY_SIZE(drm_cp_enum_list));
1200+
if (!prop)
1201+
return -ENOMEM;
1202+
1203+
drm_object_attach_property(&connector->base, prop,
1204+
DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
1205+
1206+
connector->content_protection_property = prop;
1207+
1208+
return 0;
1209+
}
1210+
EXPORT_SYMBOL(drm_connector_attach_content_protection_property);
1211+
11331212
/**
11341213
* drm_mode_create_aspect_ratio_property - create aspect ratio property
11351214
* @dev: DRM device

‎drivers/gpu/drm/i915/Makefile‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ i915-y += intel_audio.o \
109109
intel_fbc.o \
110110
intel_fifo_underrun.o \
111111
intel_frontbuffer.o \
112+
intel_hdcp.o \
112113
intel_hotplug.o \
113114
intel_modes.o \
114115
intel_overlay.o \

‎drivers/gpu/drm/i915/i915_drv.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3661,6 +3661,7 @@ extern int intel_setup_gmbus(struct drm_i915_private *dev_priv);
36613661
extern void intel_teardown_gmbus(struct drm_i915_private *dev_priv);
36623662
extern bool intel_gmbus_is_valid_pin(struct drm_i915_private *dev_priv,
36633663
unsigned int pin);
3664+
extern int intel_gmbus_output_aksv(struct i2c_adapter *adapter);
36643665

36653666
extern struct i2c_adapter *
36663667
intel_gmbus_get_adapter(struct drm_i915_private *dev_priv, unsigned int pin);

‎drivers/gpu/drm/i915/i915_reg.h‎

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3074,6 +3074,7 @@ enum i915_power_well_id {
30743074
# define GPIO_DATA_PULLUP_DISABLE (1 << 13)
30753075

30763076
#define GMBUS0 _MMIO(dev_priv->gpio_mmio_base + 0x5100) /* clock/port select */
3077+
#define GMBUS_AKSV_SELECT (1<<11)
30773078
#define GMBUS_RATE_100KHZ (0<<8)
30783079
#define GMBUS_RATE_50KHZ (1<<8)
30793080
#define GMBUS_RATE_400KHZ (2<<8) /* reserved on Pineview */
@@ -8165,6 +8166,7 @@ enum {
81658166
#define GEN9_MEM_LATENCY_LEVEL_1_5_SHIFT 8
81668167
#define GEN9_MEM_LATENCY_LEVEL_2_6_SHIFT 16
81678168
#define GEN9_MEM_LATENCY_LEVEL_3_7_SHIFT 24
8169+
#define SKL_PCODE_LOAD_HDCP_KEYS 0x5
81688170
#define SKL_PCODE_CDCLK_CONTROL 0x7
81698171
#define SKL_CDCLK_PREPARE_FOR_CHANGE 0x3
81708172
#define SKL_CDCLK_READY_FOR_CHANGE 0x1
@@ -8480,6 +8482,88 @@ enum skl_power_gate {
84808482
#define CNL_AUX_ANAOVRD1_ENABLE (1<<16)
84818483
#define CNL_AUX_ANAOVRD1_LDO_BYPASS (1<<23)
84828484

8485+
/* HDCP Key Registers */
8486+
#define HDCP_KEY_CONF _MMIO(0x66c00)
8487+
#define HDCP_AKSV_SEND_TRIGGER BIT(31)
8488+
#define HDCP_CLEAR_KEYS_TRIGGER BIT(30)
8489+
#define HDCP_KEY_LOAD_TRIGGER BIT(8)
8490+
#define HDCP_KEY_STATUS _MMIO(0x66c04)
8491+
#define HDCP_FUSE_IN_PROGRESS BIT(7)
8492+
#define HDCP_FUSE_ERROR BIT(6)
8493+
#define HDCP_FUSE_DONE BIT(5)
8494+
#define HDCP_KEY_LOAD_STATUS BIT(1)
8495+
#define HDCP_KEY_LOAD_DONE BIT(0)
8496+
#define HDCP_AKSV_LO _MMIO(0x66c10)
8497+
#define HDCP_AKSV_HI _MMIO(0x66c14)
8498+
8499+
/* HDCP Repeater Registers */
8500+
#define HDCP_REP_CTL _MMIO(0x66d00)
8501+
#define HDCP_DDIB_REP_PRESENT BIT(30)
8502+
#define HDCP_DDIA_REP_PRESENT BIT(29)
8503+
#define HDCP_DDIC_REP_PRESENT BIT(28)
8504+
#define HDCP_DDID_REP_PRESENT BIT(27)
8505+
#define HDCP_DDIF_REP_PRESENT BIT(26)
8506+
#define HDCP_DDIE_REP_PRESENT BIT(25)
8507+
#define HDCP_DDIB_SHA1_M0 (1 << 20)
8508+
#define HDCP_DDIA_SHA1_M0 (2 << 20)
8509+
#define HDCP_DDIC_SHA1_M0 (3 << 20)
8510+
#define HDCP_DDID_SHA1_M0 (4 << 20)
8511+
#define HDCP_DDIF_SHA1_M0 (5 << 20)
8512+
#define HDCP_DDIE_SHA1_M0 (6 << 20) /* Bspec says 5? */
8513+
#define HDCP_SHA1_BUSY BIT(16)
8514+
#define HDCP_SHA1_READY BIT(17)
8515+
#define HDCP_SHA1_COMPLETE BIT(18)
8516+
#define HDCP_SHA1_V_MATCH BIT(19)
8517+
#define HDCP_SHA1_TEXT_32 (1 << 1)
8518+
#define HDCP_SHA1_COMPLETE_HASH (2 << 1)
8519+
#define HDCP_SHA1_TEXT_24 (4 << 1)
8520+
#define HDCP_SHA1_TEXT_16 (5 << 1)
8521+
#define HDCP_SHA1_TEXT_8 (6 << 1)
8522+
#define HDCP_SHA1_TEXT_0 (7 << 1)
8523+
#define HDCP_SHA_V_PRIME_H0 _MMIO(0x66d04)
8524+
#define HDCP_SHA_V_PRIME_H1 _MMIO(0x66d08)
8525+
#define HDCP_SHA_V_PRIME_H2 _MMIO(0x66d0C)
8526+
#define HDCP_SHA_V_PRIME_H3 _MMIO(0x66d10)
8527+
#define HDCP_SHA_V_PRIME_H4 _MMIO(0x66d14)
8528+
#define HDCP_SHA_V_PRIME(h) _MMIO((0x66d04 + h * 4))
8529+
#define HDCP_SHA_TEXT _MMIO(0x66d18)
8530+
8531+
/* HDCP Auth Registers */
8532+
#define _PORTA_HDCP_AUTHENC 0x66800
8533+
#define _PORTB_HDCP_AUTHENC 0x66500
8534+
#define _PORTC_HDCP_AUTHENC 0x66600
8535+
#define _PORTD_HDCP_AUTHENC 0x66700
8536+
#define _PORTE_HDCP_AUTHENC 0x66A00
8537+
#define _PORTF_HDCP_AUTHENC 0x66900
8538+
#define _PORT_HDCP_AUTHENC(port, x) _MMIO(_PICK(port, \
8539+
_PORTA_HDCP_AUTHENC, \
8540+
_PORTB_HDCP_AUTHENC, \
8541+
_PORTC_HDCP_AUTHENC, \
8542+
_PORTD_HDCP_AUTHENC, \
8543+
_PORTE_HDCP_AUTHENC, \
8544+
_PORTF_HDCP_AUTHENC) + x)
8545+
#define PORT_HDCP_CONF(port) _PORT_HDCP_AUTHENC(port, 0x0)
8546+
#define HDCP_CONF_CAPTURE_AN BIT(0)
8547+
#define HDCP_CONF_AUTH_AND_ENC (BIT(1) | BIT(0))
8548+
#define PORT_HDCP_ANINIT(port) _PORT_HDCP_AUTHENC(port, 0x4)
8549+
#define PORT_HDCP_ANLO(port) _PORT_HDCP_AUTHENC(port, 0x8)
8550+
#define PORT_HDCP_ANHI(port) _PORT_HDCP_AUTHENC(port, 0xC)
8551+
#define PORT_HDCP_BKSVLO(port) _PORT_HDCP_AUTHENC(port, 0x10)
8552+
#define PORT_HDCP_BKSVHI(port) _PORT_HDCP_AUTHENC(port, 0x14)
8553+
#define PORT_HDCP_RPRIME(port) _PORT_HDCP_AUTHENC(port, 0x18)
8554+
#define PORT_HDCP_STATUS(port) _PORT_HDCP_AUTHENC(port, 0x1C)
8555+
#define HDCP_STATUS_STREAM_A_ENC BIT(31)
8556+
#define HDCP_STATUS_STREAM_B_ENC BIT(30)
8557+
#define HDCP_STATUS_STREAM_C_ENC BIT(29)
8558+
#define HDCP_STATUS_STREAM_D_ENC BIT(28)
8559+
#define HDCP_STATUS_AUTH BIT(21)
8560+
#define HDCP_STATUS_ENC BIT(20)
8561+
#define HDCP_STATUS_RI_MATCH BIT(19)
8562+
#define HDCP_STATUS_R0_READY BIT(18)
8563+
#define HDCP_STATUS_AN_READY BIT(17)
8564+
#define HDCP_STATUS_CIPHER BIT(16)
8565+
#define HDCP_STATUS_FRAME_CNT(x) ((x >> 8) & 0xff)
8566+
84838567
/* Per-pipe DDI Function Control */
84848568
#define _TRANS_DDI_FUNC_CTL_A 0x60400
84858569
#define _TRANS_DDI_FUNC_CTL_B 0x61400
@@ -8511,6 +8595,7 @@ enum skl_power_gate {
85118595
#define TRANS_DDI_EDP_INPUT_A_ONOFF (4<<12)
85128596
#define TRANS_DDI_EDP_INPUT_B_ONOFF (5<<12)
85138597
#define TRANS_DDI_EDP_INPUT_C_ONOFF (6<<12)
8598+
#define TRANS_DDI_HDCP_SIGNALLING (1<<9)
85148599
#define TRANS_DDI_DP_VC_PAYLOAD_ALLOC (1<<8)
85158600
#define TRANS_DDI_HDMI_SCRAMBLER_CTS_ENABLE (1<<7)
85168601
#define TRANS_DDI_HDMI_SCRAMBLER_RESET_FREQ (1<<6)

‎drivers/gpu/drm/i915/intel_atomic.c‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,8 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,
110110
to_intel_digital_connector_state(old_state);
111111
struct drm_crtc_state *crtc_state;
112112

113+
intel_hdcp_atomic_check(conn, old_state, new_state);
114+
113115
if (!new_state->crtc)
114116
return 0;
115117

‎drivers/gpu/drm/i915/intel_ddi.c‎

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1615,6 +1615,35 @@ void intel_ddi_disable_transcoder_func(struct drm_i915_private *dev_priv,
16151615
I915_WRITE(reg, val);
16161616
}
16171617

1618+
int intel_ddi_toggle_hdcp_signalling(struct intel_encoder *intel_encoder,
1619+
bool enable)
1620+
{
1621+
struct drm_device *dev = intel_encoder->base.dev;
1622+
struct drm_i915_private *dev_priv = to_i915(dev);
1623+
enum pipe pipe = 0;
1624+
int ret = 0;
1625+
uint32_t tmp;
1626+
1627+
if (WARN_ON(!intel_display_power_get_if_enabled(dev_priv,
1628+
intel_encoder->power_domain)))
1629+
return -ENXIO;
1630+
1631+
if (WARN_ON(!intel_encoder->get_hw_state(intel_encoder, &pipe))) {
1632+
ret = -EIO;
1633+
goto out;
1634+
}
1635+
1636+
tmp = I915_READ(TRANS_DDI_FUNC_CTL(pipe));
1637+
if (enable)
1638+
tmp |= TRANS_DDI_HDCP_SIGNALLING;
1639+
else
1640+
tmp &= ~TRANS_DDI_HDCP_SIGNALLING;
1641+
I915_WRITE(TRANS_DDI_FUNC_CTL(pipe), tmp);
1642+
out:
1643+
intel_display_power_put(dev_priv, intel_encoder->power_domain);
1644+
return ret;
1645+
}
1646+
16181647
bool intel_ddi_connector_get_hw_state(struct intel_connector *intel_connector)
16191648
{
16201649
struct drm_device *dev = intel_connector->base.dev;
@@ -2465,6 +2494,11 @@ static void intel_enable_ddi(struct intel_encoder *encoder,
24652494
intel_enable_ddi_hdmi(encoder, crtc_state, conn_state);
24662495
else
24672496
intel_enable_ddi_dp(encoder, crtc_state, conn_state);
2497+
2498+
/* Enable hdcp if it's desired */
2499+
if (conn_state->content_protection ==
2500+
DRM_MODE_CONTENT_PROTECTION_DESIRED)
2501+
intel_hdcp_enable(to_intel_connector(conn_state->connector));
24682502
}
24692503

24702504
static void intel_disable_ddi_dp(struct intel_encoder *encoder,
@@ -2499,6 +2533,8 @@ static void intel_disable_ddi(struct intel_encoder *encoder,
24992533
const struct intel_crtc_state *old_crtc_state,
25002534
const struct drm_connector_state *old_conn_state)
25012535
{
2536+
intel_hdcp_disable(to_intel_connector(old_conn_state->connector));
2537+
25022538
if (intel_crtc_has_type(old_crtc_state, INTEL_OUTPUT_HDMI))
25032539
intel_disable_ddi_hdmi(encoder, old_crtc_state, old_conn_state);
25042540
else

‎drivers/gpu/drm/i915/intel_display.c‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15297,6 +15297,10 @@ static void intel_hpd_poll_fini(struct drm_device *dev)
1529715297
for_each_intel_connector_iter(connector, &conn_iter) {
1529815298
if (connector->modeset_retry_work.func)
1529915299
cancel_work_sync(&connector->modeset_retry_work);
15300+
if (connector->hdcp_shim) {
15301+
cancel_delayed_work_sync(&connector->hdcp_check_work);
15302+
cancel_work_sync(&connector->hdcp_prop_work);
15303+
}
1530015304
}
1530115305
drm_connector_list_iter_end(&conn_iter);
1530215306
}

0 commit comments

Comments
 (0)