summaryrefslogtreecommitdiff
path: root/exynos-hdcp2-dplink-inter.c
blob: 843e9d227d7adf4ba218c533c08cc3d64c9578f1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
/*
 * drivers/soc/samsung/exynos-hdcp/dp_link/exynos-hdcp2-dplink.c
 *
 * Copyright (c) 2015 Samsung Electronics Co., Ltd.
 *		http://www.samsung.com
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 as
 * published by the Free Software Foundation.
 */
#include <linux/module.h>
#include <linux/slab.h>
#include <linux/uaccess.h>
#include <linux/smc.h>
#include <asm/cacheflush.h>
#include <soc/samsung/exynos-smc.h>
#include <linux/types.h>
#include <linux/delay.h>

#include "exynos-hdcp2.h"
#include "exynos-hdcp2-log.h"
#include "exynos-hdcp2-dplink.h"
#include "exynos-hdcp2-dplink-inter.h"
#include "exynos-hdcp2-dplink-if.h"
#include "exynos-hdcp2-dplink-auth.h"

#define DRM_WAIT_RETRY_COUNT	1000
/* current link data */
enum auth_state auth_proc_state;
EXPORT_SYMBOL_GPL(auth_proc_state);
enum dp_state dp_hdcp_state;
EXPORT_SYMBOL_GPL(dp_hdcp_state);

int hdcp_dplink_auth_check(enum auth_signal hdcp_signal)
{
	int ret = 0;

#if defined(CONFIG_HDCP2_FUNC_TEST_MODE)
	ret = exynos_smc(SMC_DRM_HDCP_FUNC_TEST, 1, 0, 0);
#endif
	switch (hdcp_signal) {
		case HDCP_DRM_OFF:
			return ret;
		case HDCP_DRM_ON:
			ret = exynos_smc(SMC_DRM_HDCP_AUTH_INFO, DP_HDCP22_DISABLE, 0, 0);
			dplink_clear_irqflag_all();
			ret = hdcp_dplink_authenticate();
			return ret;
		case HDCP_RP_READY:
			if (auth_proc_state == HDCP_AUTH_PROCESS_DONE) {
				ret = hdcp_dplink_authenticate();
				if (ret == 0)
					auth_proc_state = HDCP_AUTH_PROCESS_DONE;
			}
			return 0;
		default:
			ret = HDCP_ERROR_INVALID_STATE;
			break;
	}
	return ret;
}
EXPORT_SYMBOL_GPL(hdcp_dplink_auth_check);

int hdcp_dplink_get_rxstatus(uint8_t *status)
{
	int ret = 0;

	ret = hdcp_dplink_get_rxinfo(status);
	return ret;
}
EXPORT_SYMBOL_GPL(hdcp_dplink_get_rxstatus);

int hdcp_dplink_set_paring_available(void)
{
	hdcp_info("pairing avaible\n");
	return dplink_set_paring_available();
}
EXPORT_SYMBOL_GPL(hdcp_dplink_set_paring_available);

int hdcp_dplink_set_hprime_available(void)
{
	hdcp_info("h-prime avaible\n");
	return dplink_set_hprime_available();
}
EXPORT_SYMBOL_GPL(hdcp_dplink_set_hprime_available);

int hdcp_dplink_set_rp_ready(void)
{
	hdcp_info("ready avaible\n");
	return dplink_set_rp_ready();
}
EXPORT_SYMBOL_GPL(hdcp_dplink_set_rp_ready);

int hdcp_dplink_set_reauth(void)
{
	uint64_t ret = 0;

	hdcp_info("reauth requested.\n");
	ret = exynos_smc(SMC_DRM_HDCP_AUTH_INFO, DP_HDCP22_DISABLE, 0, 0);
	return dplink_set_reauth_req();
}
EXPORT_SYMBOL_GPL(hdcp_dplink_set_reauth);

int hdcp_dplink_set_integrity_fail(void)
{
	uint64_t ret = 0;

	hdcp_info("integrity check fail.\n");
	ret = exynos_smc(SMC_DRM_HDCP_AUTH_INFO, DP_HDCP22_DISABLE, 0, 0);
	return dplink_set_integrity_fail();
}
EXPORT_SYMBOL_GPL(hdcp_dplink_set_integrity_fail);

int hdcp_dplink_cancel_auth(void)
{
	uint64_t ret = 0;

	hdcp_info("Cancel authenticate.\n");
	ret = exynos_smc(SMC_DRM_HDCP_AUTH_INFO, DP_HPD_STATUS_ZERO, 0, 0);
	auth_proc_state = HDCP_AUTH_PROCESS_STOP;

	return dplink_set_integrity_fail();
}
EXPORT_SYMBOL_GPL(hdcp_dplink_cancel_auth);

void hdcp_dplink_clear_all(void)
{
	uint64_t ret = 0;

	hdcp_info("HDCP flag clear\n");
	ret = exynos_smc(SMC_DRM_HDCP_AUTH_INFO, DP_HDCP22_DISABLE, 0, 0);
	dplink_clear_irqflag_all();
}
EXPORT_SYMBOL_GPL(hdcp_dplink_clear_all);

void hdcp_dplink_connect_state(enum dp_state state)
{
	uint64_t ret = 0;

	dp_hdcp_state = state;
	hdcp_info("Displayport connect info (%d)\n", dp_hdcp_state);
	ret = exynos_smc(SMC_DRM_DP_CONNECT_INFO, dp_hdcp_state, 0, 0);
}
EXPORT_SYMBOL_GPL(hdcp_dplink_connect_state);
MODULE_LICENSE("GPL");