[PATCH v3 2/3] Subject: [PATCH] drm/mediatek/dp: Add HDCP2.x feature for DisplayPort

CK Hu (胡俊光) ck.hu at mediatek.com
Wed Jul 17 23:23:14 PDT 2024


Hi, Mac:

On Sat, 2024-06-08 at 20:01 +0800, mac.shen wrote:
> Changes in v3:
> - refine the function to get system time
> - refine the flow to do HDCP with content type and
>   protection value which set by user space
> - refine the flow to update content protection
> - refine the flow to do HDCP2.x authentication
> per suggestion from the previous thread:
> https://urldefense.com/v3/__https://patchwork.kernel.org/project/linux-mediatek__;!!CTRNKA9wMg0ARbw!md6xUiYN88D2YmETs8FQgaExM2zH8S1SmAEU9GRchwpNsXOyDFul3ziVKhRpCJaj8Rcn-gvM-801runjwA$ 
> /patch/20240205055055.25340-3-mac.shen at mediatek.com/
> 
> Signed-off-by: mac.shen <mac.shen at mediatek.com>
> ---

[snip]

> +/* Authentication flow starts from here */
> +static int dp_tx_hdcp2x_key_exchange(struct mtk_hdcp_info *hdcp_info)
> +{
> +	struct mtk_dp *mtk_dp = container_of(hdcp_info, struct mtk_dp, hdcp_info);
> +	bool stored;
> +	int ret;
> +
> +	if (!hdcp_info->hdcp2_info.capable)
> +		return -EAGAIN;
> +
> +	ret = dp_tx_hdcp2x_init(hdcp_info);
> +	if (ret)
> +		return ret;
> +
> +	ret = dp_tx_hdcp2x_write_ake_init(hdcp_info);
> +	if (ret)
> +		return ret;
> +
> +	ret = dp_tx_hdcp2x_read_ake_send_cert(hdcp_info);
> +	if (ret)
> +		return ret;
> +
> +	hdcp_info->hdcp2_info.repeater =
> +		HDCP_2_2_RX_REPEATER(hdcp_info->hdcp2_info.hdcp_rx.send_cert.rx_caps[2]);
> +
> +	if (drm_hdcp_check_ksvs_revoked(mtk_dp->drm_dev,
> +					hdcp_info->hdcp2_info.hdcp_rx.send_cert.cert_rx.receiver_id,
> +					1) > 0) {
> +		dev_err(mtk_dp->dev, "[HDCP2.X] Receiver ID is revoked\n");
> +		return -EPERM;
> +	}
> +
> +	ret = tee_ake_certificate(hdcp_info,
> +				  (u8 *)&hdcp_info->hdcp2_info.hdcp_rx.cert_rx, &stored,
> +		hdcp_info->hdcp2_info.ake_stored_km.e_kh_km_m +
> +		HDCP_2_2_E_KH_KM_LEN,
> +		hdcp_info->hdcp2_info.ake_stored_km.e_kh_km_m);
> +	if (ret)
> +		return ret;
> +
> +	hdcp_info->hdcp2_info.stored_km = stored;
> +
> +	if (!hdcp_info->hdcp2_info.stored_km) {
> +		ret = tee_enc_rsaes_oaep(hdcp_info,
> +					 hdcp_info->hdcp2_info.hdcp_tx.no_stored_km.e_kpub_km);
> +		if (ret)
> +			return ret;
> +
> +		ret = dp_tx_hdcp2x_write_ake_no_stored_km(hdcp_info);
> +		if (ret)
> +			return ret;
> +
> +	} else {
> +		ret = dp_tx_hdcp2x_write_ake_stored_km(hdcp_info);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	ret = dp_tx_hdcp2x_read_ake_send_hprime(hdcp_info);
> +	if (ret)
> +		return ret;
> +
> +	ret = tee_ake_h_prime(hdcp_info,
> +			      hdcp_info->hdcp2_info.hdcp_tx.ake_init.r_tx,
> +		hdcp_info->hdcp2_info.hdcp_rx.send_cert.r_rx,
> +		hdcp_info->hdcp2_info.hdcp_rx.send_cert.rx_caps,
> +		(u8 *)&hdcp_info->hdcp2_info.hdcp_tx.tx_caps,
> +		hdcp_info->hdcp2_info.hdcp_rx.send_hprime.h_prime,
> +		HDCP_2_2_H_PRIME_LEN);

hdcp_info->hdcp2_info.hdcp_tx.ake_init,
hdcp_info->hdcp2_info.hdcp_rx.send_cert,
hdcp_info->hdcp2_info.hdcp_rx.send_hprime,
hdcp_info->hdcp2_info.hdcp_tx.no_stored_km,
hdcp_info->hdcp2_info.stored_km,
hdcp_info->hdcp2_info.hdcp_rx.pairing_info

are used only in dp_tx_hdcp2x_key_exchange(), so make them as local variable in dp_tx_hdcp2x_key_exchange().

hdcp_info->hdcp2_info.hdcp_tx.tx_caps is constant value, so use t_tx_caps[] directly instead of using hdcp_info->hdcp2_info.hdcp_tx.tx_caps.

Regards,
CK

> +	if (ret) {
> +		if (hdcp_info->hdcp2_info.stored_km)
> +			tee_clear_paring(hdcp_info);
> +		return ret;
> +	}
> +
> +	if (!hdcp_info->hdcp2_info.stored_km) {
> +		ret = dp_tx_hdcp2x_read_ake_send_pairing_info(hdcp_info);
> +		if (ret)
> +			return ret;
> +
> +		/* Store m, km, Ekh(km) */
> +		ret = tee_ake_paring(hdcp_info,
> +				     hdcp_info->hdcp2_info.hdcp_rx.pairing_info.e_kh_km);
> +		if (ret)
> +			return ret;
> +	}
> +
> +	return 0;
> +}
> +


More information about the Linux-mediatek mailing list