Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (C) 2019 Intel Corporation.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Authors:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Ramalingam C <ramalingam.c@intel.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #include <linux/device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) #include <linux/err.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) #include <linux/gfp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/export.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/firmware.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <drm/drm_hdcp.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <drm/drm_sysfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <drm/drm_print.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <drm/drm_device.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) #include <drm/drm_property.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include <drm/drm_mode_object.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include <drm/drm_connector.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) #include "drm_internal.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) static inline void drm_hdcp_print_ksv(const u8 *ksv)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) 	DRM_DEBUG("\t%#02x, %#02x, %#02x, %#02x, %#02x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 		  ksv[0], ksv[1], ksv[2], ksv[3], ksv[4]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) static u32 drm_hdcp_get_revoked_ksv_count(const u8 *buf, u32 vrls_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 	u32 parsed_bytes = 0, ksv_count = 0, vrl_ksv_cnt, vrl_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) 	while (parsed_bytes < vrls_length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 		vrl_ksv_cnt = *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 		ksv_count += vrl_ksv_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		vrl_sz = (vrl_ksv_cnt * DRM_HDCP_KSV_LEN) + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		buf += vrl_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 		parsed_bytes += vrl_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 	 * When vrls are not valid, ksvs are not considered.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 	 * Hence SRM will be discarded.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	if (parsed_bytes != vrls_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 		ksv_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	return ksv_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) static u32 drm_hdcp_get_revoked_ksvs(const u8 *buf, u8 **revoked_ksv_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 				     u32 vrls_length)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	u32 vrl_ksv_cnt, vrl_ksv_sz, vrl_idx = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) 	u32 parsed_bytes = 0, ksv_count = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) 		vrl_ksv_cnt = *buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 		vrl_ksv_sz = vrl_ksv_cnt * DRM_HDCP_KSV_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) 		buf++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) 		DRM_DEBUG("vrl: %d, Revoked KSVs: %d\n", vrl_idx++,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 			  vrl_ksv_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 		memcpy((*revoked_ksv_list) + (ksv_count * DRM_HDCP_KSV_LEN),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 		       buf, vrl_ksv_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 		ksv_count += vrl_ksv_cnt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 		buf += vrl_ksv_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 		parsed_bytes += (vrl_ksv_sz + 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	} while (parsed_bytes < vrls_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 	return ksv_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) static inline u32 get_vrl_length(const u8 *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 	return drm_hdcp_be24_to_cpu(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) static int drm_hdcp_parse_hdcp1_srm(const u8 *buf, size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 				    u8 **revoked_ksv_list, u32 *revoked_ksv_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	struct hdcp_srm_header *header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 	u32 vrl_length, ksv_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 	if (count < (sizeof(struct hdcp_srm_header) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 	    DRM_HDCP_1_4_VRL_LENGTH_SIZE + DRM_HDCP_1_4_DCP_SIG_SIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		DRM_ERROR("Invalid blob length\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 	header = (struct hdcp_srm_header *)buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 	DRM_DEBUG("SRM ID: 0x%x, SRM Ver: 0x%x, SRM Gen No: 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		  header->srm_id,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 		  be16_to_cpu(header->srm_version), header->srm_gen_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	WARN_ON(header->reserved);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	buf = buf + sizeof(*header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 	vrl_length = get_vrl_length(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 	if (count < (sizeof(struct hdcp_srm_header) + vrl_length) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 	    vrl_length < (DRM_HDCP_1_4_VRL_LENGTH_SIZE +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 			  DRM_HDCP_1_4_DCP_SIG_SIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		DRM_ERROR("Invalid blob length or vrl length\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 	/* Length of the all vrls combined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	vrl_length -= (DRM_HDCP_1_4_VRL_LENGTH_SIZE +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 		       DRM_HDCP_1_4_DCP_SIG_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 	if (!vrl_length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 		DRM_ERROR("No vrl found\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	buf += DRM_HDCP_1_4_VRL_LENGTH_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) 	ksv_count = drm_hdcp_get_revoked_ksv_count(buf, vrl_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	if (!ksv_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) 		DRM_DEBUG("Revoked KSV count is 0\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	*revoked_ksv_list = kcalloc(ksv_count, DRM_HDCP_KSV_LEN, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	if (!*revoked_ksv_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 		DRM_ERROR("Out of Memory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	if (drm_hdcp_get_revoked_ksvs(buf, revoked_ksv_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 				      vrl_length) != ksv_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 		*revoked_ksv_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 		kfree(*revoked_ksv_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 	*revoked_ksv_cnt = ksv_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) static int drm_hdcp_parse_hdcp2_srm(const u8 *buf, size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) 				    u8 **revoked_ksv_list, u32 *revoked_ksv_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 	struct hdcp_srm_header *header;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) 	u32 vrl_length, ksv_count, ksv_sz;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) 	if (count < (sizeof(struct hdcp_srm_header) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	    DRM_HDCP_2_VRL_LENGTH_SIZE + DRM_HDCP_2_DCP_SIG_SIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) 		DRM_ERROR("Invalid blob length\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	header = (struct hdcp_srm_header *)buf;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	DRM_DEBUG("SRM ID: 0x%x, SRM Ver: 0x%x, SRM Gen No: 0x%x\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 		  header->srm_id & DRM_HDCP_SRM_ID_MASK,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 		  be16_to_cpu(header->srm_version), header->srm_gen_no);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) 	if (header->reserved)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	buf = buf + sizeof(*header);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	vrl_length = get_vrl_length(buf);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	if (count < (sizeof(struct hdcp_srm_header) + vrl_length) ||
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	    vrl_length < (DRM_HDCP_2_VRL_LENGTH_SIZE +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	    DRM_HDCP_2_DCP_SIG_SIZE)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 		DRM_ERROR("Invalid blob length or vrl length\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	/* Length of the all vrls combined */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	vrl_length -= (DRM_HDCP_2_VRL_LENGTH_SIZE +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) 		       DRM_HDCP_2_DCP_SIG_SIZE);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) 	if (!vrl_length) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		DRM_ERROR("No vrl found\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 	buf += DRM_HDCP_2_VRL_LENGTH_SIZE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	ksv_count = (*buf << 2) | DRM_HDCP_2_KSV_COUNT_2_LSBITS(*(buf + 1));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 	if (!ksv_count) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 		DRM_DEBUG("Revoked KSV count is 0\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	*revoked_ksv_list = kcalloc(ksv_count, DRM_HDCP_KSV_LEN, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	if (!*revoked_ksv_list) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		DRM_ERROR("Out of Memory\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 	ksv_sz = ksv_count * DRM_HDCP_KSV_LEN;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	buf += DRM_HDCP_2_NO_OF_DEV_PLUS_RESERVED_SZ;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	DRM_DEBUG("Revoked KSVs: %d\n", ksv_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 	memcpy(*revoked_ksv_list, buf, ksv_sz);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	*revoked_ksv_cnt = ksv_count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) static inline bool is_srm_version_hdcp1(const u8 *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	return *buf == (u8)(DRM_HDCP_1_4_SRM_ID << 4);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) static inline bool is_srm_version_hdcp2(const u8 *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) 	return *buf == (u8)(DRM_HDCP_2_SRM_ID << 4 | DRM_HDCP_2_INDICATOR);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) static int drm_hdcp_srm_update(const u8 *buf, size_t count,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 			       u8 **revoked_ksv_list, u32 *revoked_ksv_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	if (count < sizeof(struct hdcp_srm_header))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) 	if (is_srm_version_hdcp1(buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) 		return drm_hdcp_parse_hdcp1_srm(buf, count, revoked_ksv_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 						revoked_ksv_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 	else if (is_srm_version_hdcp2(buf))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 		return drm_hdcp_parse_hdcp2_srm(buf, count, revoked_ksv_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 						revoked_ksv_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) static int drm_hdcp_request_srm(struct drm_device *drm_dev,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 				u8 **revoked_ksv_list, u32 *revoked_ksv_cnt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 	char fw_name[36] = "display_hdcp_srm.bin";
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 	const struct firmware *fw;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) 	ret = request_firmware_direct(&fw, (const char *)fw_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 				      drm_dev->dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) 	if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) 		*revoked_ksv_cnt = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 		*revoked_ksv_list = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 		ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 		goto exit;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 	if (fw->size && fw->data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 		ret = drm_hdcp_srm_update(fw->data, fw->size, revoked_ksv_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 					  revoked_ksv_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) exit:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 	release_firmware(fw);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)  * drm_hdcp_check_ksvs_revoked - Check the revoked status of the IDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263)  * @drm_dev: drm_device for which HDCP revocation check is requested
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264)  * @ksvs: List of KSVs (HDCP receiver IDs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265)  * @ksv_count: KSV count passed in through @ksvs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267)  * This function reads the HDCP System renewability Message(SRM Table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268)  * from userspace as a firmware and parses it for the revoked HDCP
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269)  * KSVs(Receiver IDs) detected by DCP LLC. Once the revoked KSVs are known,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270)  * revoked state of the KSVs in the list passed in by display drivers are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271)  * decided and response is sent.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273)  * SRM should be presented in the name of "display_hdcp_srm.bin".
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275)  * Format of the SRM table, that userspace needs to write into the binary file,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276)  * is defined at:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277)  * 1. Renewability chapter on 55th page of HDCP 1.4 specification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278)  * https://www.digital-cp.com/sites/default/files/specifications/HDCP%20Specification%20Rev1_4_Secure.pdf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279)  * 2. Renewability chapter on 63rd page of HDCP 2.2 specification
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280)  * https://www.digital-cp.com/sites/default/files/specifications/HDCP%20on%20HDMI%20Specification%20Rev2_2_Final1.pdf
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283)  * Count of the revoked KSVs or -ve error number incase of the failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) int drm_hdcp_check_ksvs_revoked(struct drm_device *drm_dev, u8 *ksvs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 				u32 ksv_count)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 	u32 revoked_ksv_cnt = 0, i, j;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	u8 *revoked_ksv_list = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	int ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 	ret = drm_hdcp_request_srm(drm_dev, &revoked_ksv_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) 				   &revoked_ksv_cnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 	if (ret)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) 		return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	/* revoked_ksv_cnt will be zero when above function failed */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	for (i = 0; i < revoked_ksv_cnt; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 		for  (j = 0; j < ksv_count; j++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 			if (!memcmp(&ksvs[j * DRM_HDCP_KSV_LEN],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 				    &revoked_ksv_list[i * DRM_HDCP_KSV_LEN],
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 				    DRM_HDCP_KSV_LEN)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 				DRM_DEBUG("Revoked KSV is ");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 				drm_hdcp_print_ksv(&ksvs[j * DRM_HDCP_KSV_LEN]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 				ret++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	kfree(revoked_ksv_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) EXPORT_SYMBOL_GPL(drm_hdcp_check_ksvs_revoked);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) static struct drm_prop_enum_list drm_cp_enum_list[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	{ DRM_MODE_CONTENT_PROTECTION_UNDESIRED, "Undesired" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 	{ DRM_MODE_CONTENT_PROTECTION_DESIRED, "Desired" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 	{ DRM_MODE_CONTENT_PROTECTION_ENABLED, "Enabled" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) DRM_ENUM_NAME_FN(drm_get_content_protection_name, drm_cp_enum_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) static struct drm_prop_enum_list drm_hdcp_content_type_enum_list[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 	{ DRM_MODE_HDCP_CONTENT_TYPE0, "HDCP Type0" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	{ DRM_MODE_HDCP_CONTENT_TYPE1, "HDCP Type1" },
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) DRM_ENUM_NAME_FN(drm_get_hdcp_content_type_name,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		 drm_hdcp_content_type_enum_list)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328)  * drm_connector_attach_content_protection_property - attach content protection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329)  * property
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331)  * @connector: connector to attach CP property on.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332)  * @hdcp_content_type: is HDCP Content Type property needed for connector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334)  * This is used to add support for content protection on select connectors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335)  * Content Protection is intentionally vague to allow for different underlying
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336)  * technologies, however it is most implemented by HDCP.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338)  * When hdcp_content_type is true enum property called HDCP Content Type is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339)  * created (if it is not already) and attached to the connector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341)  * This property is used for sending the protected content's stream type
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342)  * from userspace to kernel on selected connectors. Protected content provider
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343)  * will decide their type of their content and declare the same to kernel.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345)  * Content type will be used during the HDCP 2.2 authentication.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346)  * Content type will be set to &drm_connector_state.hdcp_content_type.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348)  * The content protection will be set to &drm_connector_state.content_protection
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350)  * When kernel triggered content protection state change like DESIRED->ENABLED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351)  * and ENABLED->DESIRED, will use drm_hdcp_update_content_protection() to update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352)  * the content protection state of a connector.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354)  * Returns:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355)  * Zero on success, negative errno on failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) int drm_connector_attach_content_protection_property(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 		struct drm_connector *connector, bool hdcp_content_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	struct drm_device *dev = connector->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	struct drm_property *prop =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 			dev->mode_config.content_protection_property;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	if (!prop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 		prop = drm_property_create_enum(dev, 0, "Content Protection",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) 						drm_cp_enum_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 						ARRAY_SIZE(drm_cp_enum_list));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) 	if (!prop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	drm_object_attach_property(&connector->base, prop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 				   DRM_MODE_CONTENT_PROTECTION_UNDESIRED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	dev->mode_config.content_protection_property = prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	if (!hdcp_content_type)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	prop = dev->mode_config.hdcp_content_type_property;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	if (!prop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 		prop = drm_property_create_enum(dev, 0, "HDCP Content Type",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 					drm_hdcp_content_type_enum_list,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 					ARRAY_SIZE(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 					drm_hdcp_content_type_enum_list));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	if (!prop)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	drm_object_attach_property(&connector->base, prop,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 				   DRM_MODE_HDCP_CONTENT_TYPE0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	dev->mode_config.hdcp_content_type_property = prop;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) EXPORT_SYMBOL(drm_connector_attach_content_protection_property);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396)  * drm_hdcp_update_content_protection - Updates the content protection state
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397)  * of a connector
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399)  * @connector: drm_connector on which content protection state needs an update
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400)  * @val: New state of the content protection property
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402)  * This function can be used by display drivers, to update the kernel triggered
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403)  * content protection state changes of a drm_connector such as DESIRED->ENABLED
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404)  * and ENABLED->DESIRED. No uevent for DESIRED->UNDESIRED or ENABLED->UNDESIRED,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405)  * as userspace is triggering such state change and kernel performs it without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406)  * fail.This function update the new state of the property into the connector's
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407)  * state and generate an uevent to notify the userspace.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) void drm_hdcp_update_content_protection(struct drm_connector *connector,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 					u64 val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	struct drm_device *dev = connector->dev;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 	struct drm_connector_state *state = connector->state;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 	WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 	if (state->content_protection == val)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 	state->content_protection = val;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	drm_sysfs_connector_status_event(connector,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 				 dev->mode_config.content_protection_property);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) EXPORT_SYMBOL(drm_hdcp_update_content_protection);