diff --git a/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi.c b/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi.c index 47bee42c59fa..64914585c9a5 100644 --- a/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi.c +++ b/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi.c @@ -372,6 +372,135 @@ static ssize_t _sde_hdmi_edid_vendor_name_read(struct file *file, return len; } +static ssize_t _sde_hdmi_src_hdcp14_support_read(struct file *file, + char __user *buff, + size_t count, + loff_t *ppos) +{ + struct sde_hdmi *display = file->private_data; + char buf[SZ_128]; + u32 len = 0; + + if (!display) + return -ENODEV; + + if (!display->ctrl.ctrl) { + SDE_ERROR("hdmi is NULL\n"); + return -ENOMEM; + } + + SDE_HDMI_DEBUG("%s +", __func__); + if (*ppos) + return 0; + + if (display->hdcp14_present) + len += snprintf(buf, SZ_128 - len, "true\n"); + else + len += snprintf(buf, SZ_128 - len, "false\n"); + + if (copy_to_user(buff, buf, len)) + return -EFAULT; + + *ppos += len; + SDE_HDMI_DEBUG("%s - ", __func__); + return len; +} + +static ssize_t _sde_hdmi_src_hdcp22_support_read(struct file *file, + char __user *buff, + size_t count, + loff_t *ppos) +{ + struct sde_hdmi *display = file->private_data; + char buf[SZ_128]; + u32 len = 0; + + if (!display) + return -ENODEV; + + if (!display->ctrl.ctrl) { + SDE_ERROR("hdmi is NULL\n"); + return -ENOMEM; + } + + SDE_HDMI_DEBUG("%s +", __func__); + if (*ppos) + return 0; + + if (display->src_hdcp22_support) + len += snprintf(buf, SZ_128 - len, "true\n"); + else + len += snprintf(buf, SZ_128 - len, "false\n"); + + if (copy_to_user(buff, buf, len)) + return -EFAULT; + + *ppos += len; + SDE_HDMI_DEBUG("%s - ", __func__); + return len; +} + +static ssize_t _sde_hdmi_sink_hdcp22_support_read(struct file *file, + char __user *buff, + size_t count, + loff_t *ppos) +{ + struct sde_hdmi *display = file->private_data; + char buf[SZ_128]; + u32 len = 0; + + if (!display) + return -ENODEV; + + if (!display->ctrl.ctrl) { + SDE_ERROR("hdmi is NULL\n"); + return -ENOMEM; + } + + SDE_HDMI_DEBUG("%s +", __func__); + if (*ppos) + return 0; + + if (display->sink_hdcp22_support) + len += snprintf(buf, SZ_128 - len, "true\n"); + else + len += snprintf(buf, SZ_128 - len, "false\n"); + + if (copy_to_user(buff, buf, len)) + return -EFAULT; + + *ppos += len; + SDE_HDMI_DEBUG("%s - ", __func__); + return len; +} + +static ssize_t _sde_hdmi_hdcp_state_read(struct file *file, + char __user *buff, + size_t count, + loff_t *ppos) +{ + struct sde_hdmi *display = file->private_data; + char buf[SZ_128]; + u32 len = 0; + + if (!display) + return -ENODEV; + + SDE_HDMI_DEBUG("%s +", __func__); + if (*ppos) + return 0; + + len += snprintf(buf, SZ_128 - len, "HDCP state : %s\n", + sde_hdcp_state_name(display->hdcp_status)); + + if (copy_to_user(buff, buf, len)) + return -EFAULT; + + *ppos += len; + SDE_HDMI_DEBUG("%s - ", __func__); + return len; +} + static const struct file_operations dump_info_fops = { .open = simple_open, .read = _sde_hdmi_debugfs_dump_info_read, @@ -407,6 +536,26 @@ static const struct file_operations edid_vendor_name_fops = { .read = _sde_hdmi_edid_vendor_name_read, }; +static const struct file_operations hdcp_src_14_support_fops = { + .open = simple_open, + .read = _sde_hdmi_src_hdcp14_support_read, +}; + +static const struct file_operations hdcp_src_22_support_fops = { + .open = simple_open, + .read = _sde_hdmi_src_hdcp22_support_read, +}; + +static const struct file_operations hdcp_sink_22_support_fops = { + .open = simple_open, + .read = _sde_hdmi_sink_hdcp22_support_read, +}; + +static const struct file_operations sde_hdmi_hdcp_state_fops = { + .open = simple_open, + .read = _sde_hdmi_hdcp_state_read, +}; + static u64 _sde_hdmi_clip_valid_pclk(struct drm_display_mode *mode, u64 pclk_in) { u32 pclk_delta, pclk; @@ -624,6 +773,8 @@ static int _sde_hdmi_debugfs_init(struct sde_hdmi *display) struct dentry *dir, *dump_file, *edid_modes; struct dentry *edid_vsdb_info, *edid_hdr_info, *edid_hfvsdb_info; struct dentry *edid_vcdb_info, *edid_vendor_name, *pll_file; + struct dentry *src_hdcp14_support, *src_hdcp22_support; + struct dentry *sink_hdcp22_support, *hdmi_hdcp_state; dir = debugfs_create_dir(display->name, NULL); if (!dir) { @@ -734,6 +885,58 @@ static int _sde_hdmi_debugfs_init(struct sde_hdmi *display) goto error_remove_dir; } + src_hdcp14_support = debugfs_create_file("src_hdcp14_support", + 0444, + dir, + display, + &hdcp_src_14_support_fops); + + if (IS_ERR_OR_NULL(src_hdcp14_support)) { + rc = PTR_ERR(src_hdcp14_support); + SDE_ERROR("[%s]debugfs create file failed, rc=%d\n", + display->name, rc); + goto error_remove_dir; + } + + src_hdcp22_support = debugfs_create_file("src_hdcp22_support", + 0444, + dir, + display, + &hdcp_src_22_support_fops); + + if (IS_ERR_OR_NULL(src_hdcp22_support)) { + rc = PTR_ERR(src_hdcp22_support); + SDE_ERROR("[%s]debugfs create file failed, rc=%d\n", + display->name, rc); + goto error_remove_dir; + } + + sink_hdcp22_support = debugfs_create_file("sink_hdcp22_support", + 0444, + dir, + display, + &hdcp_sink_22_support_fops); + + if (IS_ERR_OR_NULL(sink_hdcp22_support)) { + rc = PTR_ERR(sink_hdcp22_support); + SDE_ERROR("[%s]debugfs create file failed, rc=%d\n", + display->name, rc); + goto error_remove_dir; + } + + hdmi_hdcp_state = debugfs_create_file("hdmi_hdcp_state", + 0444, + dir, + display, + &sde_hdmi_hdcp_state_fops); + + if (IS_ERR_OR_NULL(hdmi_hdcp_state)) { + rc = PTR_ERR(hdmi_hdcp_state); + SDE_ERROR("[%s]debugfs create file failed, rc=%d\n", + display->name, rc); + goto error_remove_dir; + } + display->root = dir; return rc; error_remove_dir: diff --git a/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi.h b/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi.h index 6b6518287028..84d8720969be 100644 --- a/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi.h +++ b/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi.h @@ -142,6 +142,9 @@ struct sde_hdmi { u8 hdcp_status; u32 enc_lvl; bool auth_state; + bool sink_hdcp22_support; + bool src_hdcp22_support; + /*hold final data *based on hdcp support */ diff --git a/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi_bridge.c b/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi_bridge.c index 6b01d02930f8..6c4549ffe21a 100644 --- a/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi_bridge.c +++ b/drivers/gpu/drm/msm/hdmi-staging/sde_hdmi_bridge.c @@ -385,11 +385,19 @@ static void sde_hdmi_update_hdcp_info(struct drm_connector *connector) if (fd) ops = sde_hdmi_hdcp2p2_start(fd); + /* If ops is true, sink supports hdcp */ + if (ops) + display->sink_hdcp22_support = true; + if (ops && ops->feature_supported) display->hdcp22_present = ops->feature_supported(fd); else display->hdcp22_present = false; + /* if hdcp22_present is true, src supports hdcp 2p2 */ + if (display->hdcp22_present) + display->src_hdcp22_support = true; + if (!display->hdcp22_present) { if (display->hdcp1_use_sw_keys) { display->hdcp14_present =