aboutsummaryrefslogtreecommitdiff
path: root/drivers/misc/mediatek/hdmi/Sii8338/si_drv_ext.c
blob: 10548053f5e25eaf05104588f17e33d37b66613e (plain) (blame)
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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
#include "si_common.h"
#include "si_mhl_tx_api.h"
#include "si_drv_mhl_tx.h"
#include "si_platform.h"
#include "si_drv_ext.h"
#ifdef AMF_SRC
#include "AMF_Lib.h"
static AVModeDescription_t AVModeDescription;
static void AVModeReport(void)
{
	uint16_t OldDebugFormat;
	OldDebugFormat = SiiOsDebugGetConfig();
	SiiOsDebugSetConfig(SII_OS_DEBUG_FORMAT_SIMPLE);
	TX_DEBUG_PRINT(("HF:%d", (int)AVModeDescription.HDMIVideoFormat));
	switch (AVModeDescription.HDMIVideoFormat) {
	case VMD_HDMIFORMAT_CEA_VIC:
		TX_DEBUG_PRINT((" (CEA VIC)"));
		break;
	case VMD_HDMIFORMAT_HDMI_VIC:
		TX_DEBUG_PRINT((" (HDMI VIC)"));
		break;
	case VMD_HDMIFORMAT_3D:
		TX_DEBUG_PRINT((" (3D)"));
		break;
	case VMD_HDMIFORMAT_PC:
		TX_DEBUG_PRINT((" (PC)"));
		break;
	default:
		TX_DEBUG_PRINT((" (Illegal)"));
		break;
	}
	TX_DEBUG_PRINT((" VIC:%d", (int)AVModeDescription.VIC));
	TX_DEBUG_PRINT((" A:%x", (int)AVModeDescription.AspectRatio));
	switch (AVModeDescription.AspectRatio) {
	case VMD_ASPECT_RATIO_4x3:
		TX_DEBUG_PRINT((" (4x3)"));
		break;
	case VMD_ASPECT_RATIO_16x9:
		TX_DEBUG_PRINT((" (16x9)"));
		break;
	default:
		TX_DEBUG_PRINT((" (Illegal)"));
		break;
	}
	TX_DEBUG_PRINT((" ICS:%d", (int)AVModeDescription.ColorSpace));
	switch (AVModeDescription.ColorSpace) {
	case VMD_COLOR_SPACE_RGB:
		TX_DEBUG_PRINT((" (RGB)"));
		break;
	case VMD_COLOR_SPACE_YCBCR422:
		TX_DEBUG_PRINT((" (YCBCR422)"));
		break;
	case VMD_COLOR_SPACE_YCBCR444:
		TX_DEBUG_PRINT((" (YCBCR444)"));
		break;
	default:
		TX_DEBUG_PRINT((" (Illegal)"));
		break;
	}
	TX_DEBUG_PRINT((" ICD:%d", (int)AVModeDescription.ColorDepth));
	switch (AVModeDescription.ColorDepth) {
	case VMD_COLOR_DEPTH_8BIT:
		TX_DEBUG_PRINT((" (8BIT)"));
		break;
	case VMD_COLOR_DEPTH_10BIT:
		TX_DEBUG_PRINT((" (10BIT)"));
		break;
	case VMD_COLOR_DEPTH_12BIT:
		TX_DEBUG_PRINT((" (12BIT)"));
		break;
	case VMD_COLOR_DEPTH_16BIT:
		TX_DEBUG_PRINT((" (16BIT)"));
		break;
	default:
		TX_DEBUG_PRINT((" (Illegal)"));
		break;
	}
	TX_DEBUG_PRINT((" HA:%d", (int)AVModeDescription.HDCPAuthenticated));
	if (AVModeDescription.HDCPAuthenticated == VMD_HDCP_AUTHENTICATED) {
		TX_DEBUG_PRINT((" (Authenticated)\n"));
	} else {
		TX_DEBUG_PRINT((" (NOT Authenticated)\n"));
	}
	if (AVModeDescription.HDMIVideoFormat == VMD_HDMIFORMAT_3D) {
		TX_DEBUG_PRINT((" 3D:%d", (int)AVModeDescription.ThreeDStructure));
		switch (AVModeDescription.ThreeDStructure) {
		case VMD_3D_EXT_DATA_MAP:
			TX_DEBUG_PRINT((" (Ext Data Map)\n"));
			break;
		case VMD_3D_FRAMEPACKING:
			TX_DEBUG_PRINT((" (Frame Packing)\n"));
			break;
		case VMD_3D_FIELDALTERNATIVE:
			TX_DEBUG_PRINT((" (Field Alternating)\n"));
			break;
		case VMD_3D_LINEALTERNATIVE:
			TX_DEBUG_PRINT(("(Line Alternating)\n"));
			break;
		case VMD_3D_SIDEBYSIDEFULL:
			TX_DEBUG_PRINT((" (Side-by-side Full)\n"));
			break;
		case VMD_3D_LDEPTH:
			TX_DEBUG_PRINT((" (L Depth)\n"));
			break;
		case VMD_3D_LDEPTHGRAPHICS:
			TX_DEBUG_PRINT((" (L Depth Graphics)\n"));
			break;
		case VMD_3D_SIDEBYSIDEHALF:
			TX_DEBUG_PRINT((" (Side-by-side half)"));
			TX_DEBUG_PRINT((" 3Dx:%d\n", (int)AVModeDescription.ThreeDExtData));
			break;
		default:
			TX_DEBUG_PRINT((" (Illegal)"));
			break;
		}
	}
	switch (AVModeDescription.Audiotype) {
	case 0x00:
		TX_DEBUG_PRINT((" AUD: 44.1kHz "));
		break;
	case 0x01:
		TX_DEBUG_PRINT((" AUD: not indicated "));
		break;
	case 0x02:
		TX_DEBUG_PRINT((" AUD: 48kHz "));
		break;
	case 0x03:
		TX_DEBUG_PRINT((" AUD: 32kHz "));
		break;
	case 0x04:
		TX_DEBUG_PRINT((" AUD: 22.05kHz "));
		break;
	case 0x06:
		TX_DEBUG_PRINT((" AUD: 24kHz "));
		break;
	case 0x08:
		TX_DEBUG_PRINT((" AUD: 88.2kHz "));
		break;
	case 0x09:
		TX_DEBUG_PRINT((" AUD: 768kHz "));
		break;
	case 0x0A:
		TX_DEBUG_PRINT((" AUD: 96kHz "));
		break;
	case 0x0C:
		TX_DEBUG_PRINT((" AUD: 176.4kHz "));
		break;
	case 0x0E:
		TX_DEBUG_PRINT((" AUD: 192kHz "));
		break;
	default:
		TX_DEBUG_PRINT((" AUD: Illegal"));
		break;
	}
	TX_DEBUG_PRINT(("\n"));
	SiiOsDebugSetConfig(OldDebugFormat);
}

bool_t CheckExtVideo(void)
{
	bool_t video_change = false;
	if (AMF_Poll(false) != 0) {
		video_change = true;
		AMF_GetAVModeDescription(&AVModeDescription);
		PRINT("RX AV mode from AMF:\n");
		AVModeReport();
		if (AVModeDescription.VIC == 0) {
			video_change = false;
		}
	}
	return video_change;
}

unsigned char GetExt_AudioType(void)
{
	inAudioTypes_t audio_type;
	if (AVModeDescription.VIC == 0) {
		audio_type = AUD_INVALID;
	} else {
		switch (AVModeDescription.Audiotype) {
		case 0x00:
			audio_type = I2S_44;
			break;
		case 0x02:
			audio_type = I2S_48;
			break;
		case 0x03:
			audio_type = I2S_32;
			break;
		case 0x08:
			audio_type = I2S_88;
			break;
		case 0x0A:
			audio_type = I2S_96;
			break;
		case 0x0C:
			audio_type = I2S_176;
			break;
		case 0x0E:
			audio_type = I2S_192;
			break;
		default:
			audio_type = AUD_INVALID;
			break;
		}
	}
	return audio_type;
}

uint8_t GetExt_inputColorSpace(void)
{
	return AVModeDescription.ColorSpace;
}

uint8_t GetExt_inputVideoCode(void)
{
	return AVModeDescription.VIC;
}

uint8_t GetExt_inputcolorimetryAspectRatio(void)
{
	if (AVModeDescription.AspectRatio == VMD_ASPECT_RATIO_4x3)
		return 0x18;
	else
		return 0x28;
}

uint8_t GetExt_inputAR(void)
{
	return AVModeDescription.AspectRatio;
}

void InitExtVideo(void)
{
	TX_DEBUG_PRINT(("AMFlib initialize.\n"));
	AMF_Init(false);
}

void TriggerExtInt(void)
{
#ifdef __KERLNEL__
	AMF_TriggerSWInt();
#endif
}
#else
static void AVModeReport(void)
{
	return;
}

bool_t CheckExtVideo(void)
{
	return false;
}

unsigned char GetExt_AudioType(void)
{
	return 0;
}

uint8_t GetExt_inputColorSpace(void)
{
	return 0;
}

uint8_t GetExt_inputVideoCode(void)
{
	return 0;
}

uint8_t GetExt_inputcolorimetryAspectRatio(void)
{
	return 0;
}

uint8_t GetExt_inputAR(void)
{
	return 0;
}

void InitExtVideo(void)
{
}

void TriggerExtInt(void)
{
}
#endif