Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/i915: Attach content type property

Attaches the content type property for HDCP2.2 capable connectors.

Implements the update of content type from property and apply the
restriction on HDCP version selection.

Need ACK for content type property from userspace consumer.

v2:
s/cp_content_type/content_protection_type [daniel]
disable at hdcp_atomic_check to avoid check at atomic_set_property
[Maarten]
v3:
s/content_protection_type/hdcp_content_type [Pekka]
v4:
hdcp disable incase of type change is moved into commit [daniel].
v5:
Simplified the Type change procedure. [Daniel]
v6:
Type change with UNDESIRED state is ignored.

Signed-off-by: Ramalingam C <ramalingam.c@intel.com>
Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Pekka Paalanen <pekka.paalanen@collabora.com>
Acked-by: Jani Nikula <jani.nikula@intel.com>
Link: https://patchwork.freedesktop.org/patch/320959/?series=57232&rev=14

+62 -22
+33 -6
drivers/gpu/drm/i915/display/intel_ddi.c
··· 3511 3511 /* Enable hdcp if it's desired */ 3512 3512 if (conn_state->content_protection == 3513 3513 DRM_MODE_CONTENT_PROTECTION_DESIRED) 3514 - intel_hdcp_enable(to_intel_connector(conn_state->connector)); 3514 + intel_hdcp_enable(to_intel_connector(conn_state->connector), 3515 + (u8)conn_state->hdcp_content_type); 3515 3516 } 3516 3517 3517 3518 static void intel_disable_ddi_dp(struct intel_encoder *encoder, ··· 3581 3580 const struct intel_crtc_state *crtc_state, 3582 3581 const struct drm_connector_state *conn_state) 3583 3582 { 3583 + struct intel_connector *connector = 3584 + to_intel_connector(conn_state->connector); 3585 + struct intel_hdcp *hdcp = &connector->hdcp; 3586 + bool content_protection_type_changed = 3587 + (conn_state->hdcp_content_type != hdcp->content_type && 3588 + conn_state->content_protection != 3589 + DRM_MODE_CONTENT_PROTECTION_UNDESIRED); 3590 + 3584 3591 if (!intel_crtc_has_type(crtc_state, INTEL_OUTPUT_HDMI)) 3585 3592 intel_ddi_update_pipe_dp(encoder, crtc_state, conn_state); 3586 3593 3594 + /* 3595 + * During the HDCP encryption session if Type change is requested, 3596 + * disable the HDCP and reenable it with new TYPE value. 3597 + */ 3587 3598 if (conn_state->content_protection == 3588 - DRM_MODE_CONTENT_PROTECTION_DESIRED) 3589 - intel_hdcp_enable(to_intel_connector(conn_state->connector)); 3590 - else if (conn_state->content_protection == 3591 - DRM_MODE_CONTENT_PROTECTION_UNDESIRED) 3592 - intel_hdcp_disable(to_intel_connector(conn_state->connector)); 3599 + DRM_MODE_CONTENT_PROTECTION_UNDESIRED || 3600 + content_protection_type_changed) 3601 + intel_hdcp_disable(connector); 3602 + 3603 + /* 3604 + * Mark the hdcp state as DESIRED after the hdcp disable of type 3605 + * change procedure. 3606 + */ 3607 + if (content_protection_type_changed) { 3608 + mutex_lock(&hdcp->mutex); 3609 + hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED; 3610 + schedule_work(&hdcp->prop_work); 3611 + mutex_unlock(&hdcp->mutex); 3612 + } 3613 + 3614 + if (conn_state->content_protection == 3615 + DRM_MODE_CONTENT_PROTECTION_DESIRED || 3616 + content_protection_type_changed) 3617 + intel_hdcp_enable(connector, (u8)conn_state->hdcp_content_type); 3593 3618 } 3594 3619 3595 3620 static void intel_ddi_set_fia_lane_count(struct intel_encoder *encoder,
+28 -15
drivers/gpu/drm/i915/display/intel_hdcp.c
··· 1748 1748 .unbind = i915_hdcp_component_unbind, 1749 1749 }; 1750 1750 1751 - static inline int initialize_hdcp_port_data(struct intel_connector *connector) 1751 + static inline int initialize_hdcp_port_data(struct intel_connector *connector, 1752 + const struct intel_hdcp_shim *shim) 1752 1753 { 1753 1754 struct intel_hdcp *hdcp = &connector->hdcp; 1754 1755 struct hdcp_port_data *data = &hdcp->port_data; 1755 1756 1756 1757 data->port = connector->encoder->port; 1757 1758 data->port_type = (u8)HDCP_PORT_TYPE_INTEGRATED; 1758 - data->protocol = (u8)hdcp->shim->protocol; 1759 + data->protocol = (u8)shim->protocol; 1759 1760 1760 1761 data->k = 1; 1761 1762 if (!data->streams) ··· 1806 1805 } 1807 1806 } 1808 1807 1809 - static void intel_hdcp2_init(struct intel_connector *connector) 1808 + static void intel_hdcp2_init(struct intel_connector *connector, 1809 + const struct intel_hdcp_shim *shim) 1810 1810 { 1811 1811 struct intel_hdcp *hdcp = &connector->hdcp; 1812 1812 int ret; 1813 1813 1814 - ret = initialize_hdcp_port_data(connector); 1814 + ret = initialize_hdcp_port_data(connector, shim); 1815 1815 if (ret) { 1816 1816 DRM_DEBUG_KMS("Mei hdcp data init failed\n"); 1817 1817 return; ··· 1831 1829 if (!shim) 1832 1830 return -EINVAL; 1833 1831 1832 + if (is_hdcp2_supported(dev_priv)) 1833 + intel_hdcp2_init(connector, shim); 1834 + 1834 1835 ret = 1835 1836 drm_connector_attach_content_protection_property(&connector->base, 1836 - false); 1837 - if (ret) 1837 + hdcp->hdcp2_supported); 1838 + if (ret) { 1839 + hdcp->hdcp2_supported = false; 1840 + kfree(hdcp->port_data.streams); 1838 1841 return ret; 1842 + } 1839 1843 1840 1844 hdcp->shim = shim; 1841 1845 mutex_init(&hdcp->mutex); 1842 1846 INIT_DELAYED_WORK(&hdcp->check_work, intel_hdcp_check_work); 1843 1847 INIT_WORK(&hdcp->prop_work, intel_hdcp_prop_work); 1844 - 1845 - if (is_hdcp2_supported(dev_priv)) 1846 - intel_hdcp2_init(connector); 1847 1848 init_waitqueue_head(&hdcp->cp_irq_queue); 1848 1849 1849 1850 return 0; 1850 1851 } 1851 1852 1852 - int intel_hdcp_enable(struct intel_connector *connector) 1853 + int intel_hdcp_enable(struct intel_connector *connector, u8 content_type) 1853 1854 { 1854 1855 struct intel_hdcp *hdcp = &connector->hdcp; 1855 1856 unsigned long check_link_interval = DRM_HDCP_CHECK_PERIOD_MS; ··· 1863 1858 1864 1859 mutex_lock(&hdcp->mutex); 1865 1860 WARN_ON(hdcp->value == DRM_MODE_CONTENT_PROTECTION_ENABLED); 1861 + hdcp->content_type = content_type; 1866 1862 1867 1863 /* 1868 1864 * Considering that HDCP2.2 is more secure than HDCP1.4, If the setup ··· 1875 1869 check_link_interval = DRM_HDCP2_CHECK_PERIOD_MS; 1876 1870 } 1877 1871 1878 - /* When HDCP2.2 fails, HDCP1.4 will be attempted */ 1879 - if (ret && intel_hdcp_capable(connector)) { 1872 + /* 1873 + * When HDCP2.2 fails and Content Type is not Type1, HDCP1.4 will 1874 + * be attempted. 1875 + */ 1876 + if (ret && intel_hdcp_capable(connector) && 1877 + hdcp->content_type != DRM_MODE_HDCP_CONTENT_TYPE1) { 1880 1878 ret = _intel_hdcp_enable(connector); 1881 1879 } 1882 1880 ··· 1962 1952 1963 1953 /* 1964 1954 * Nothing to do if the state didn't change, or HDCP was activated since 1965 - * the last commit 1955 + * the last commit. And also no change in hdcp content type. 1966 1956 */ 1967 1957 if (old_cp == new_cp || 1968 1958 (old_cp == DRM_MODE_CONTENT_PROTECTION_DESIRED && 1969 - new_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED)) 1970 - return; 1959 + new_cp == DRM_MODE_CONTENT_PROTECTION_ENABLED)) { 1960 + if (old_state->hdcp_content_type == 1961 + new_state->hdcp_content_type) 1962 + return; 1963 + } 1971 1964 1972 1965 crtc_state = drm_atomic_get_new_crtc_state(new_state->state, 1973 1966 new_state->crtc);
+1 -1
drivers/gpu/drm/i915/display/intel_hdcp.h
··· 21 21 struct drm_connector_state *new_state); 22 22 int intel_hdcp_init(struct intel_connector *connector, 23 23 const struct intel_hdcp_shim *hdcp_shim); 24 - int intel_hdcp_enable(struct intel_connector *connector); 24 + int intel_hdcp_enable(struct intel_connector *connector, u8 content_type); 25 25 int intel_hdcp_disable(struct intel_connector *connector); 26 26 bool is_hdcp_supported(struct drm_i915_private *dev_priv, enum port port); 27 27 bool intel_hdcp_capable(struct intel_connector *connector);