1 /*
2 * Copyright (c) 2021-2023 Huawei Device Co., Ltd.
3 *
4 * HDF is dual licensed: you can use it either under the terms of
5 * the GPL, or the BSD license, at your option.
6 * See the LICENSE file in the root of this repository for complete details.
7 */
8
9 #include "hdf_log.h"
10 #include "hdmi_core.h"
11 #include "securec.h"
12
13 #define HDF_LOG_TAG hdmi_infoframe_c
14
15 #define HDMI_IEEE_OUI_1_4_1ST 0x03
16 #define HDMI_IEEE_OUI_1_4_2ND 0x0C
17 #define HDMI_IEEE_OUI_1_4_3RD 0x00
18
HdmiInfoFrameFillCheckSum(uint8_t * data,uint32_t len)19 static void HdmiInfoFrameFillCheckSum(uint8_t *data, uint32_t len)
20 {
21 uint32_t i;
22 uint8_t checkSum = 0;
23
24 for (i = 0; i < len; i++) {
25 checkSum += data[i];
26 }
27 if (checkSum > 0) {
28 /*
29 * The checksum shall be calculated such that a byte-wide sum of all three bytes of the Packet Header and
30 * all valid bytes of the InfoFrame Packet contents(determined by InfoFrame_length), plus the checksum itself,
31 * equals zero.
32 */
33 data[UINT8_ARRAY_TELEMENT_3] = HDMI_INFOFRAME_CHECKSUM - checkSum;
34 }
35 }
36
HdmiInfoFrameFillHeader(const struct HdmiInfoFrameHeader * header,uint8_t * data,uint32_t len)37 static void HdmiInfoFrameFillHeader(const struct HdmiInfoFrameHeader *header, uint8_t *data, uint32_t len)
38 {
39 if (len < HDMI_INFOFRAME_PACKET_HEADER_LEN) {
40 HDF_LOGE("len = %u, val is too small.", len);
41 return;
42 }
43 data[UINT8_ARRAY_TELEMENT_0] = header->type;
44 data[UINT8_ARRAY_TELEMENT_1] = header->verNum;
45 data[UINT8_ARRAY_TELEMENT_2] = header->len;
46 }
47
HdmiInfoFramePacketVsEncoding(union HdmiInfoFrameInfo * infoFrame,uint8_t * data,uint32_t len)48 static int32_t HdmiInfoFramePacketVsEncoding(union HdmiInfoFrameInfo *infoFrame, uint8_t *data, uint32_t len)
49 {
50 uint32_t length;
51 struct HdmiVs14VsifContent *vsifContent = NULL;
52 struct HdmiVsUserVsifContent *userContent = NULL;
53 struct HdmiVsInfoFrame *vs = &(infoFrame->vs);
54
55 length = HDMI_INFOFRAME_PACKET_HEADER_LEN + vs->len;
56 if (len < length) {
57 HDF_LOGE("len = %u, val is too small.", len);
58 return HDF_ERR_INVALID_PARAM;
59 }
60 if (memset_s(data, len, 0, len) != EOK) {
61 HDF_LOGE("memset_s fail.");
62 return HDF_ERR_IO;
63 }
64
65 HdmiInfoFrameFillHeader(&(infoFrame->header), data, len);
66 if (vs->vsifContent.vsif.oui == HDMI_IEEE_OUI_1_4) {
67 data[UINT8_ARRAY_TELEMENT_4] = HDMI_IEEE_OUI_1_4_1ST;
68 data[UINT8_ARRAY_TELEMENT_5] = HDMI_IEEE_OUI_1_4_2ND;
69 data[UINT8_ARRAY_TELEMENT_6] = HDMI_IEEE_OUI_1_4_3RD;
70 vsifContent = &(vs->vsifContent.vsif);
71 userContent = &(vs->vsifContent.userVsif);
72 data[UINT8_ARRAY_TELEMENT_7] = ((uint8_t)vsifContent->format & HDMI_VENDOR_1_4_FORMAT_MARK) <<
73 HDMI_VENDOR_1_4_FORMAT_SHIFT;
74 if (vsifContent->format == HDMI_VS_VIDEO_FORMAT_4K) {
75 data[UINT8_ARRAY_TELEMENT_8] = vsifContent->vic;
76 return HDF_SUCCESS;
77 } else if (vsifContent->format == HDMI_VS_VIDEO_FORMAT_3D) {
78 data[UINT8_ARRAY_TELEMENT_8] = ((uint8_t)vsifContent->_3dStruct & HDMI_VENDOR_3D_STRUCTURE_MARK) <<
79 HDMI_VENDOR_3D_STRUCTURE_SHIFT;
80 }
81 data[UINT8_ARRAY_TELEMENT_9] = ((uint8_t)vsifContent->_3dExtData & HDMI_VENDOR_3D_EXT_DATA_MARK) <<
82 HDMI_VENDOR_3D_EXT_DATA_SHIFT;
83 if (vsifContent->_3dMetaPresent == false) {
84 if (userContent->len == 0 || (userContent->len + length) > len) {
85 return HDF_SUCCESS;
86 }
87 if (memcpy_s(&data[length], (len - length), userContent->data, userContent->len) != EOK) {
88 HDF_LOGE("memcpy_s fail.");
89 return HDF_ERR_IO;
90 }
91 length += userContent->len;
92 }
93 }
94 HdmiInfoFrameFillCheckSum(data, length);
95 return HDF_SUCCESS;
96 }
97
HdmiInfoFramePacketAviEncoding(union HdmiInfoFrameInfo * infoFrame,uint8_t * data,uint32_t len)98 static int32_t HdmiInfoFramePacketAviEncoding(union HdmiInfoFrameInfo *infoFrame, uint8_t *data, uint32_t len)
99 {
100 uint32_t length;
101 uint8_t *buff = data;
102 struct HdmiAviInfoFrame *avi = &(infoFrame->avi);
103
104 length = HDMI_INFOFRAME_PACKET_HEADER_LEN + avi->len;
105 if (len < length) {
106 HDF_LOGE("len = %u, val is too small.", len);
107 return HDF_ERR_INVALID_PARAM;
108 }
109 if (memset_s(buff, len, 0, len) != EOK) {
110 HDF_LOGE("memset_s fail.");
111 return HDF_ERR_IO;
112 }
113
114 HdmiInfoFrameFillHeader(&(infoFrame->header), data, len);
115 buff += HDMI_INFOFRAME_PACKET_HEADER_LEN;
116 /* PB1 */
117 buff[UINT8_ARRAY_TELEMENT_0] |= ((uint8_t)avi->colorSpace & HDMI_AVI_COLOR_SPACE_MARK) <<
118 HDMI_AVI_COLOR_SPACE_SHIFT;
119 buff[UINT8_ARRAY_TELEMENT_0] |= ((uint8_t)avi->scanMode & HDMI_AVI_SCAN_MODE_MARK);
120 if (avi->activeFormatInformationPresent == true) {
121 buff[UINT8_ARRAY_TELEMENT_0] |= (1 << HDMI_AVI_ACTIVE_INFORMATION_SHIFT);
122 }
123 if (avi->horizBarInfoPresent == true) {
124 buff[UINT8_ARRAY_TELEMENT_0] |= (1 << HDMI_AVI_HORIZONTAL_BAR_SHIFT);
125 }
126 if (avi->vertBarInfoPresent == true) {
127 buff[UINT8_ARRAY_TELEMENT_0] |= (1 << HDMI_AVI_VERTICAL_BAR_SHIFT);
128 }
129 /* PB2 */
130 buff[UINT8_ARRAY_TELEMENT_1] |= ((uint8_t)avi->colorimetry & HDMI_AVI_COLORIMETRY_MARK) <<
131 HDMI_AVI_COLORIMETRY_SHIFT;
132 buff[UINT8_ARRAY_TELEMENT_1] |= ((uint8_t)avi->pictureAspect & HDMI_AVI_PICTURE_ASPECT_RATE_MARK) <<
133 HDMI_AVI_PICTURE_ASPECT_RATE_SHIFT;
134 buff[UINT8_ARRAY_TELEMENT_1] |= ((uint8_t)avi->activeAspect & HDMI_AVI_ACTIVE_FORMAT_ASPECT_RATE_MARK);
135 /* PB3 */
136 buff[UINT8_ARRAY_TELEMENT_2] |= ((uint8_t)avi->extColorimetry & HDMI_AVI_EXT_COLORIMETRY_MARK) <<
137 HDMI_AVI_EXT_COLORIMETRY_SHIFT;
138 buff[UINT8_ARRAY_TELEMENT_2] |= ((uint8_t)avi->range & HDMI_AVI_EXT_QUANTIZATION_RANGE_MARK) <<
139 HDMI_AVI_EXT_QUANTIZATION_RANGE_SHIFT;
140 buff[UINT8_ARRAY_TELEMENT_2] |= ((uint8_t)avi->nups & HDMI_AVI_NUPS_RANGE_MARK);
141 if (avi->itc == true) {
142 buff[UINT8_ARRAY_TELEMENT_2] |= (1 << HDMI_AVI_IT_CONTENT_SHIFT);
143 }
144 /* PB4 */
145 buff[UINT8_ARRAY_TELEMENT_3] = avi->vic;
146 /* PB5 */
147 buff[UINT8_ARRAY_TELEMENT_4] |= ((uint8_t)avi->yccRange & HDMI_AVI_YCC_QUANTIZATION_RANGE_MARK) <<
148 HDMI_AVI_YCC_QUANTIZATION_RANGE_SHIFT;
149 buff[UINT8_ARRAY_TELEMENT_4] |= ((uint8_t)avi->itcType & HDMI_AVI_IT_CONTENT_TYPE_MARK) <<
150 HDMI_AVI_IT_CONTENT_TYPE_SHIFT;
151 buff[UINT8_ARRAY_TELEMENT_4] |= (avi->pixelRepetitionFactor & HDMI_AVI_PIXEL_REPETION_FACTOR_MARK);
152 /* PB6 */
153 buff[UINT8_ARRAY_TELEMENT_5] = (uint8_t)(avi->topBar & HDMI_AVI_BAR_MODE_MARK);
154 /* PB7 */
155 buff[UINT8_ARRAY_TELEMENT_6] = (uint8_t)((avi->topBar >> HDMI_AVI_BAR_MODE_SHIFT) & HDMI_AVI_BAR_MODE_MARK);
156 /* PB8 */
157 buff[UINT8_ARRAY_TELEMENT_7] = (uint8_t)(avi->bottomBar & HDMI_AVI_BAR_MODE_MARK);
158 /* PB9 */
159 buff[UINT8_ARRAY_TELEMENT_8] = (uint8_t)((avi->bottomBar >> HDMI_AVI_BAR_MODE_SHIFT) & HDMI_AVI_BAR_MODE_MARK);
160 /* PB10 */
161 buff[UINT8_ARRAY_TELEMENT_9] = (uint8_t)(avi->leftBar & HDMI_AVI_BAR_MODE_MARK);
162 /* PB11 */
163 buff[UINT8_ARRAY_TELEMENT_10] = (uint8_t)((avi->leftBar >> HDMI_AVI_BAR_MODE_SHIFT) & HDMI_AVI_BAR_MODE_MARK);
164 /* PB12 */
165 buff[UINT8_ARRAY_TELEMENT_11] = (uint8_t)(avi->rightBar & HDMI_AVI_BAR_MODE_MARK);
166 /* PB13 */
167 buff[UINT8_ARRAY_TELEMENT_12] = (uint8_t)((avi->rightBar >> HDMI_AVI_BAR_MODE_SHIFT) & HDMI_AVI_BAR_MODE_MARK);
168 HdmiInfoFrameFillCheckSum(data, length);
169 return HDF_SUCCESS;
170 }
171
HdmiInfoFramePacketSpdEncoding(union HdmiInfoFrameInfo * infoFrame,uint8_t * data,uint32_t len)172 static int32_t HdmiInfoFramePacketSpdEncoding(union HdmiInfoFrameInfo *infoFrame, uint8_t *data, uint32_t len)
173 {
174 uint32_t length;
175 uint8_t *buff = data;
176 struct HdmiSpdInfoFrame *spd = &(infoFrame->spd);
177
178 length = HDMI_INFOFRAME_PACKET_HEADER_LEN + spd->len;
179 if (len < length) {
180 HDF_LOGE("len = %u, val is too small.", len);
181 return HDF_ERR_INVALID_PARAM;
182 }
183 if (memset_s(buff, len, 0, len) != EOK) {
184 HDF_LOGE("memset_s fail.");
185 return HDF_ERR_IO;
186 }
187
188 buff += HDMI_INFOFRAME_PACKET_HEADER_LEN;
189 /* PB1~PB8 */
190 if (memcpy_s(buff, (len - HDMI_INFOFRAME_PACKET_HEADER_LEN), spd->vendorName, sizeof(spd->vendorName)) != EOK) {
191 HDF_LOGE("memcpy_s fail.");
192 return HDF_ERR_IO;
193 }
194 buff += HDMI_SPD_VENDOR_NAME_LEN;
195 /* PB9~PB24 */
196 if (memcpy_s(buff, (len - HDMI_INFOFRAME_PACKET_HEADER_LEN - HDMI_SPD_VENDOR_NAME_LEN),
197 spd->productDescription, sizeof(spd->productDescription)) != EOK) {
198 HDF_LOGE("memcpy_s fail.");
199 return HDF_ERR_IO;
200 }
201 buff += HDMI_SPD_PRODUCT_DESCRIPTION_LEN;
202 /* PB25 */
203 buff[UINT8_ARRAY_TELEMENT_0] = spd->sdi;
204 HdmiInfoFrameFillCheckSum(data, length);
205 return HDF_SUCCESS;
206 }
207
HdmiInfoFramePacketAudioEncoding(union HdmiInfoFrameInfo * infoFrame,uint8_t * data,uint32_t len)208 static int32_t HdmiInfoFramePacketAudioEncoding(union HdmiInfoFrameInfo *infoFrame, uint8_t *data, uint32_t len)
209 {
210 uint32_t length;
211 uint8_t *buff = data;
212 struct HdmiAudioInfoFrame *audio = &(infoFrame->audio);
213
214 length = HDMI_INFOFRAME_PACKET_HEADER_LEN + audio->len;
215 if (len < length) {
216 HDF_LOGE("len = %u, val is too small.", len);
217 return HDF_ERR_INVALID_PARAM;
218 }
219 if (memset_s(buff, len, 0, len) != EOK) {
220 HDF_LOGE("memset_s fail.");
221 return HDF_ERR_IO;
222 }
223
224 HdmiInfoFrameFillHeader(&(infoFrame->header), data, len);
225 buff += HDMI_INFOFRAME_PACKET_HEADER_LEN;
226 /* PB1 */
227 buff[UINT8_ARRAY_TELEMENT_0] |= ((uint8_t)audio->codingType & HDMI_AUDIO_CODING_TYPE_MARK) <<
228 HDMI_AUDIO_CODING_TYPE_SHIFT;
229 buff[UINT8_ARRAY_TELEMENT_0] |= ((uint8_t)audio->channelCount & HDMI_AUDIO_CHANNEL_COUNT_MARK);
230 /* PB2 */
231 buff[UINT8_ARRAY_TELEMENT_1] |= ((uint8_t)audio->sampleFreq & HDMI_AUDIO_SAMPLE_FREQUENCY_MARK) <<
232 HDMI_AUDIO_SAMPLE_FREQUENCY_SHIFT;
233 buff[UINT8_ARRAY_TELEMENT_1] |= ((uint8_t)audio->sampleSize & HDMI_AUDIO_SAMPLE_SIZE_MARK);
234 /* PB3 */
235 buff[UINT8_ARRAY_TELEMENT_2] |= ((uint8_t)audio->codingExtType & HDMI_AUDIO_CXT_MARK);
236 /* PB4 */
237 buff[UINT8_ARRAY_TELEMENT_3] |= audio->channelAllocation;
238 /* PB5 */
239 buff[UINT8_ARRAY_TELEMENT_4] |= ((uint8_t)audio->levelShiftValue & HDMI_AUDIO_LEVEL_SHIFT_VALUE_MARK) <<
240 HDMI_AUDIO_LEVEL_SHIFT_VALUE_SHIFT;
241 buff[UINT8_ARRAY_TELEMENT_4] |= ((uint8_t)audio->playBackLevel & HDMI_AUDIO_LEF_PLAYBACK_LEVEL_MARK);
242 if (audio->dmInh == true) {
243 buff[UINT8_ARRAY_TELEMENT_4] |= (1 << HDMI_AUDIO_DM_INH_SHIFT);
244 }
245 HdmiInfoFrameFillCheckSum(data, length);
246 return HDF_SUCCESS;
247 }
248
HdmiInfoFramePacketDrmEncoding(union HdmiInfoFrameInfo * infoFrame,uint8_t * data,uint32_t len)249 static int32_t HdmiInfoFramePacketDrmEncoding(union HdmiInfoFrameInfo *infoFrame, uint8_t *data, uint32_t len)
250 {
251 uint32_t length;
252 uint8_t *buff = data;
253 struct HdmiDrmInfoFrame *drm = &(infoFrame->drm);
254 struct HdmiStaticMetadataDescriptor1st *des = &(drm->des.type1);
255
256 length = HDMI_INFOFRAME_PACKET_HEADER_LEN + drm->len;
257 if (len < length) {
258 HDF_LOGE("len = %u, val is too small.", len);
259 return HDF_ERR_INVALID_PARAM;
260 }
261 if (memset_s(buff, len, 0, len) != EOK) {
262 HDF_LOGE("memset_s fail.");
263 return HDF_ERR_IO;
264 }
265
266 HdmiInfoFrameFillHeader(&(infoFrame->header), data, len);
267 buff += HDMI_INFOFRAME_PACKET_HEADER_LEN;
268 /* PB1 */
269 buff[UINT8_ARRAY_TELEMENT_0] = drm->eotfType;
270 /* PB2 */
271 buff[UINT8_ARRAY_TELEMENT_1] = drm->metadataType;
272 /* PB3 */
273 buff[UINT8_ARRAY_TELEMENT_2] = (uint8_t)(des->displayPrimaries0X & HDMI_DRM_METADATA_MARK);
274 /* PB4 */
275 buff[UINT8_ARRAY_TELEMENT_3] = (uint8_t)((des->displayPrimaries0X >> HDMI_DRM_METADATA_SHIFT) &
276 HDMI_DRM_METADATA_MARK);
277 /* PB5 */
278 buff[UINT8_ARRAY_TELEMENT_4] = (uint8_t)(des->displayPrimaries0Y & HDMI_DRM_METADATA_MARK);
279 /* PB6 */
280 buff[UINT8_ARRAY_TELEMENT_5] = (uint8_t)((des->displayPrimaries0Y & HDMI_DRM_METADATA_MARK) &
281 HDMI_DRM_METADATA_MARK);
282 /* PB7 */
283 buff[UINT8_ARRAY_TELEMENT_6] = (uint8_t)(des->displayPrimaries1X & HDMI_DRM_METADATA_MARK);
284 /* PB8 */
285 buff[UINT8_ARRAY_TELEMENT_7] = (uint8_t)((des->displayPrimaries1X & HDMI_DRM_METADATA_MARK) &
286 HDMI_DRM_METADATA_MARK);
287 /* PB9 */
288 buff[UINT8_ARRAY_TELEMENT_8] = (uint8_t)(des->displayPrimaries1Y & HDMI_DRM_METADATA_MARK);
289 /* PB10 */
290 buff[UINT8_ARRAY_TELEMENT_9] = (uint8_t)((des->displayPrimaries1Y & HDMI_DRM_METADATA_MARK) &
291 HDMI_DRM_METADATA_MARK);
292 /* PB11 */
293 buff[UINT8_ARRAY_TELEMENT_10] = (uint8_t)(des->displayPrimaries2X & HDMI_DRM_METADATA_MARK);
294 /* PB12 */
295 buff[UINT8_ARRAY_TELEMENT_11] = (uint8_t)((des->displayPrimaries2X & HDMI_DRM_METADATA_MARK) &
296 HDMI_DRM_METADATA_MARK);
297 /* PB13 */
298 buff[UINT8_ARRAY_TELEMENT_12] = (uint8_t)(des->displayPrimaries2Y & HDMI_DRM_METADATA_MARK);
299 /* PB14 */
300 buff[UINT8_ARRAY_TELEMENT_13] = (uint8_t)((des->displayPrimaries2Y & HDMI_DRM_METADATA_MARK) &
301 HDMI_DRM_METADATA_MARK);
302 /* PB15 */
303 buff[UINT8_ARRAY_TELEMENT_14] = (uint8_t)(des->whitePointX & HDMI_DRM_METADATA_MARK);
304 /* PB16 */
305 buff[UINT8_ARRAY_TELEMENT_15] = (uint8_t)((des->whitePointX & HDMI_DRM_METADATA_MARK) & HDMI_DRM_METADATA_MARK);
306 /* PB17 */
307 buff[UINT8_ARRAY_TELEMENT_16] = (uint8_t)(des->whitePointY & HDMI_DRM_METADATA_MARK);
308 /* PB18 */
309 buff[UINT8_ARRAY_TELEMENT_17] = (uint8_t)((des->whitePointY & HDMI_DRM_METADATA_MARK) & HDMI_DRM_METADATA_MARK);
310 /* PB19 */
311 buff[UINT8_ARRAY_TELEMENT_18] = (uint8_t)(des->maxDisplayMasteringLuminance & HDMI_DRM_METADATA_MARK);
312 /* PB20 */
313 buff[UINT8_ARRAY_TELEMENT_19] = (uint8_t)((des->maxDisplayMasteringLuminance & HDMI_DRM_METADATA_MARK) &
314 HDMI_DRM_METADATA_MARK);
315 /* PB21 */
316 buff[UINT8_ARRAY_TELEMENT_20] = (uint8_t)(des->minDisplayMasteringLuminance & HDMI_DRM_METADATA_MARK);
317 /* PB22 */
318 buff[UINT8_ARRAY_TELEMENT_21] = (uint8_t)((des->minDisplayMasteringLuminance & HDMI_DRM_METADATA_MARK) &
319 HDMI_DRM_METADATA_MARK);
320 /* PB23 */
321 buff[UINT8_ARRAY_TELEMENT_22] = (uint8_t)(des->maxContentLightLevel & HDMI_DRM_METADATA_MARK);
322 /* PB24 */
323 buff[UINT8_ARRAY_TELEMENT_23] = (uint8_t)((des->maxContentLightLevel & HDMI_DRM_METADATA_MARK) &
324 HDMI_DRM_METADATA_MARK);
325 /* PB25 */
326 buff[UINT8_ARRAY_TELEMENT_24] = (uint8_t)(des->maxFrameAverageLightLevel & HDMI_DRM_METADATA_MARK);
327 /* PB26 */
328 buff[UINT8_ARRAY_TELEMENT_25] = (uint8_t)((des->maxFrameAverageLightLevel & HDMI_DRM_METADATA_MARK) &
329 HDMI_DRM_METADATA_MARK);
330 HdmiInfoFrameFillCheckSum(data, length);
331 return HDF_SUCCESS;
332 }
333
HdmiInfoFramePacketEncoding(union HdmiInfoFrameInfo * infoFrame,enum HdmiPacketType type,uint8_t * data,uint32_t len)334 static int32_t HdmiInfoFramePacketEncoding(union HdmiInfoFrameInfo *infoFrame,
335 enum HdmiPacketType type, uint8_t *data, uint32_t len)
336 {
337 int32_t ret;
338
339 if (infoFrame == NULL || data == NULL) {
340 HDF_LOGE("input param is invalid.");
341 return HDF_ERR_INVALID_PARAM;
342 }
343
344 switch (type) {
345 case HDMI_INFOFRAME_PACKET_TYPE_VS:
346 ret = HdmiInfoFramePacketVsEncoding(infoFrame, data, len);
347 break;
348 case HDMI_INFOFRAME_PACKET_TYPE_AVI:
349 ret = HdmiInfoFramePacketAviEncoding(infoFrame, data, len);
350 break;
351 case HDMI_INFOFRAME_PACKET_TYPE_SPD:
352 ret = HdmiInfoFramePacketSpdEncoding(infoFrame, data, len);
353 break;
354 case HDMI_INFOFRAME_PACKET_TYPE_AUDIO:
355 ret = HdmiInfoFramePacketAudioEncoding(infoFrame, data, len);
356 break;
357 case HDMI_INFOFRAME_PACKET_TYPE_DRM:
358 ret = HdmiInfoFramePacketDrmEncoding(infoFrame, data, len);
359 break;
360 default:
361 HDF_LOGD("type %d not support.", type);
362 ret = HDF_ERR_NOT_SUPPORT;
363 }
364 return ret;
365 }
366
HdmiInfoFrameSend(struct HdmiInfoFrame * frame,union HdmiInfoFrameInfo * infoFrame)367 static int32_t HdmiInfoFrameSend(struct HdmiInfoFrame *frame, union HdmiInfoFrameInfo *infoFrame)
368 {
369 uint8_t buffer[HDMI_INFOFRAME_LEN] = {0};
370 struct HdmiCntlr *cntlr = NULL;
371 int32_t ret;
372
373 if (frame == NULL || frame->priv == NULL || infoFrame == NULL) {
374 HDF_LOGE("HdmiInfoFrameSend: input param is invalid.");
375 return HDF_ERR_INVALID_PARAM;
376 }
377 cntlr = (struct HdmiCntlr *)frame->priv;
378 if (cntlr->ops == NULL || cntlr->ops->infoFrameSend == NULL || cntlr->ops->infoFrameEnable == NULL) {
379 HDF_LOGD("HdmiInfoFrameSend not support.");
380 return HDF_ERR_NOT_SUPPORT;
381 }
382
383 ret = HdmiInfoFramePacketEncoding(infoFrame, infoFrame->header.type, buffer, HDMI_INFOFRAME_LEN);
384 if (ret != HDF_SUCCESS) {
385 HDF_LOGE("encding infoFrame %d fail", infoFrame->header.type);
386 return ret;
387 }
388
389 HdmiCntlrLock(cntlr);
390 cntlr->ops->infoFrameEnable(cntlr, infoFrame->header.type, false);
391 ret = cntlr->ops->infoFrameSend(cntlr, infoFrame->header.type, buffer, HDMI_INFOFRAME_LEN);
392 if (ret != HDF_SUCCESS) {
393 HDF_LOGE("send infoFrame %d fail", infoFrame->header.type);
394 HdmiCntlrUnlock(cntlr);
395 return ret;
396 }
397 cntlr->ops->infoFrameEnable(cntlr, infoFrame->header.type, true);
398 HdmiCntlrUnlock(cntlr);
399 return HDF_SUCCESS;
400 }
401
HdmiFillAviHdrInfoFrame(struct HdmiAviInfoFrame * avi,const struct HdmiVideoAttr * videoAttr,const struct HdmiHdrAttr * hdrAttr,const struct HdmiCommonAttr * commAttr)402 static void HdmiFillAviHdrInfoFrame(struct HdmiAviInfoFrame *avi, const struct HdmiVideoAttr *videoAttr,
403 const struct HdmiHdrAttr *hdrAttr, const struct HdmiCommonAttr *commAttr)
404 {
405 switch (hdrAttr->mode) {
406 case HDMI_HDR_MODE_CEA_861_3:
407 case HDMI_HDR_MODE_CEA_861_3_AUTHEN:
408 avi->colorimetry = videoAttr->colorimetry;
409 avi->extColorimetry = videoAttr->extColorimetry;
410 avi->colorSpace = commAttr->colorSpace;
411 if (hdrAttr->mode == HDMI_HDR_MODE_CEA_861_3_AUTHEN) {
412 avi->colorSpace = HDMI_COLOR_SPACE_YCBCR422;
413 }
414 avi->range = videoAttr->quantization;
415 avi->yccRange = videoAttr->yccQuantization;
416 break;
417 case HDMI_HDR_MODE_DOLBY_NORMAL:
418 avi->colorSpace = HDMI_COLOR_SPACE_YCBCR422;
419 avi->colorimetry = (videoAttr->xvycc == true) ? HDMI_COLORIMETRY_EXTENDED : videoAttr->colorimetry;
420 avi->extColorimetry = videoAttr->extColorimetry;
421 avi->range = videoAttr->quantization;
422 avi->yccRange = HDMI_YCC_QUANTIZATION_RANGE_FULL;
423 break;
424 case HDMI_HDR_MODE_DOLBY_TUNNELING:
425 avi->colorSpace = HDMI_COLOR_SPACE_RGB;
426 avi->colorimetry = (videoAttr->xvycc == true) ? HDMI_COLORIMETRY_EXTENDED : videoAttr->colorimetry;
427 avi->extColorimetry = videoAttr->extColorimetry;
428 avi->range = HDMI_QUANTIZATION_RANGE_FULL;
429 avi->yccRange = videoAttr->yccQuantization;
430 break;
431 default:
432 avi->colorSpace = commAttr->colorSpace;
433 avi->colorimetry = (videoAttr->xvycc == true) ? HDMI_COLORIMETRY_EXTENDED : videoAttr->colorimetry;
434 avi->extColorimetry = videoAttr->extColorimetry;
435 avi->range = videoAttr->quantization;
436 avi->yccRange = videoAttr->yccQuantization;
437 break;
438 }
439 }
440
HdmiFillAviInfoFrameVersion(struct HdmiAviInfoFrame * avi)441 static void HdmiFillAviInfoFrameVersion(struct HdmiAviInfoFrame *avi)
442 {
443 /*
444 * see hdmi spec2.0 10.1.
445 * The Y2 and VIC7 bits are simply set to zero in a Version 2 AVI InfoFrame and might not be decoded by
446 * some Sinks. A Version 3 AVI InfoFrame shall be used and the Version field set to 0x03 (indicating that
447 * the Sink shall decode the additional most-significant bits) whenever either of the most-significant bits
448 * Y2 or VIC7 are set to '1'. If both Y2 and VIC7 are set to '0', then a Version 2 AVI InfoFrame shall be used
449 * and the Version field shall be set to 0x02 (indicating that the Sink does not have to decode the additional
450 * most-significant bits).
451 */
452 avi->verNum = HDMI_AVI_VERSION2;
453 if (((uint32_t)avi->colorSpace & HDMI_AVI_Y2_MASK) > 0 ||
454 (avi->vic > HDMI_VIC_5120X2160P100_64_27)) {
455 avi->verNum = HDMI_AVI_VERSION3;
456 } else if (avi->colorimetry == HDMI_COLORIMETRY_EXTENDED &&
457 avi->extColorimetry == HDMI_EXTENDED_COLORIMETRY_ADDITIONAL) {
458 /*
459 * (C1,C0) is (1,1) and (EC2,EC1,EC0) is (1,1,1), version shall be 4.
460 * All fields of the Version 4 AVI InfoFrame are the same as Version 3 AVI InfoFrame,
461 * except for the InfoFrame Version Number, Length of AVI InfoFrame, and additional Data Byte 14.
462 */
463 avi->verNum = HDMI_AVI_VERSION4;
464 (avi->len)++;
465 }
466 }
467
HdmiFillAviInfoFrame(struct HdmiAviInfoFrame * avi,struct HdmiVideoAttr * videoAttr,struct HdmiHdrAttr * hdrAttr,struct HdmiCommonAttr * commAttr)468 static void HdmiFillAviInfoFrame(struct HdmiAviInfoFrame *avi,
469 struct HdmiVideoAttr *videoAttr, struct HdmiHdrAttr *hdrAttr, struct HdmiCommonAttr *commAttr)
470 {
471 bool enable3d = true;
472
473 if (memset_s(avi, sizeof(struct HdmiAviInfoFrame), 0, sizeof(struct HdmiAviInfoFrame)) != EOK) {
474 HDF_LOGE("fill vsif, memset_s fail.");
475 return;
476 }
477 avi->type = HDMI_INFOFRAME_PACKET_TYPE_AVI;
478 avi->len = HDMI_AVI_INFOFRAME_LEN;
479
480 avi->activeFormatInformationPresent = true;
481 avi->colorSpace = commAttr->colorSpace;
482 avi->activeAspect = videoAttr->activeAspect;
483 avi->pictureAspect = videoAttr->aspect;
484 avi->colorimetry = (videoAttr->xvycc == true) ? HDMI_COLORIMETRY_EXTENDED : videoAttr->colorimetry;
485 avi->nups = videoAttr->nups;
486
487 avi->range = videoAttr->quantization;
488 avi->extColorimetry = videoAttr->extColorimetry;
489 if (videoAttr->_3dStruct >= HDMI_VS_VIDEO_3D_BUTT) {
490 enable3d = false;
491 }
492 avi->vic = HdmiCommonGetVic(videoAttr->timing, videoAttr->aspect, enable3d);
493 avi->pixelRepetitionFactor = (uint8_t)videoAttr->pixelRepeat;
494 avi->yccRange = videoAttr->yccQuantization;
495 HdmiFillAviHdrInfoFrame(avi, videoAttr, hdrAttr, commAttr);
496 HdmiFillAviInfoFrameVersion(avi);
497 }
498
HdmiAviInfoFrameSend(struct HdmiInfoFrame * frame,bool enable)499 int32_t HdmiAviInfoFrameSend(struct HdmiInfoFrame *frame, bool enable)
500 {
501 struct HdmiCntlr *cntlr = NULL;
502 union HdmiInfoFrameInfo infoFrame = {0};
503
504 if (frame == NULL || frame->priv == NULL) {
505 HDF_LOGE("HdmiAviInfoFrameSend: input param is invalid.");
506 return HDF_ERR_INVALID_PARAM;
507 }
508 cntlr = (struct HdmiCntlr *)frame->priv;
509 if (cntlr->ops == NULL || cntlr->ops->infoFrameEnable == NULL || cntlr->ops->infoFrameSend == NULL) {
510 HDF_LOGD("HdmiAviInfoFrameSend not support.");
511 return HDF_ERR_NOT_SUPPORT;
512 }
513
514 if (enable == false) {
515 cntlr->ops->infoFrameEnable(cntlr, HDMI_INFOFRAME_PACKET_TYPE_AVI, false);
516 return HDF_SUCCESS;
517 }
518 HdmiFillAviInfoFrame(&(frame->avi), &(cntlr->attr.videoAttr), &(cntlr->attr.hdrAttr), &(cntlr->attr.commAttr));
519 infoFrame.avi = frame->avi;
520 return HdmiInfoFrameSend(frame, &infoFrame);
521 }
522
HdmiFillAudioInfoFrame(struct HdmiAudioInfoFrame * audio,const struct HdmiAudioAttr * audioAttr)523 static void HdmiFillAudioInfoFrame(struct HdmiAudioInfoFrame *audio, const struct HdmiAudioAttr *audioAttr)
524 {
525 if (memset_s(audio, sizeof(struct HdmiAudioInfoFrame), 0, sizeof(struct HdmiAudioInfoFrame)) != EOK) {
526 HDF_LOGE("fill vsif, memset_s fail.");
527 return;
528 }
529 audio->type = HDMI_INFOFRAME_PACKET_TYPE_AUDIO;
530 audio->len = HDMI_AUDIO_INFOFRAME_LEN;
531 audio->verNum = HDMI_AUDIO_INFOFRAME_VERSION;
532
533 /* fill channels. */
534 if (audioAttr->ifType != HDMI_AUDIO_IF_TYPE_I2S) {
535 HDF_LOGI("audio channel refer to stream.");
536 } else {
537 HDF_LOGI("audio channel %u \n", audioAttr->channels);
538 // 2 means the number of channels
539 audio->channelCount = (audioAttr->channels >= 2) ? (audioAttr->channels - 1) : 0;
540 }
541
542 /* fill coding type. */
543 if (audioAttr->codingType == HDMI_AUDIO_CODING_TYPE_AC3 ||
544 audioAttr->codingType == HDMI_AUDIO_CODING_TYPE_DTS ||
545 audioAttr->codingType == HDMI_AUDIO_CODING_TYPE_EAC3 ||
546 audioAttr->codingType == HDMI_AUDIO_CODING_TYPE_DTS_HD) {
547 audio->codingType = audioAttr->codingType;
548 } else {
549 audio->codingType = HDMI_AUDIO_CODING_TYPE_STREAM;
550 }
551
552 /* fill CA field. see CEA-861-D table 20. */
553 switch (audioAttr->channels) {
554 case HDMI_AUDIO_FORMAT_CHANNEL_3:
555 audio->channelAllocation = 0x01; /* 1 channel */
556 break;
557 case HDMI_AUDIO_FORMAT_CHANNEL_6:
558 audio->channelAllocation = 0x0b; /* 3, 4 channel */
559 break;
560 case HDMI_AUDIO_FORMAT_CHANNEL_8:
561 audio->channelAllocation = 0x13; /* 1, 2, 5 channel */
562 break;
563 default:
564 audio->channelAllocation = 0x00; /* 0 channel */
565 break;
566 }
567 }
568
HdmiAudioInfoFrameSend(struct HdmiInfoFrame * frame,bool enable)569 int32_t HdmiAudioInfoFrameSend(struct HdmiInfoFrame *frame, bool enable)
570 {
571 struct HdmiCntlr *cntlr = NULL;
572 union HdmiInfoFrameInfo infoFrame = {0};
573
574 if (frame == NULL || frame->priv == NULL) {
575 HDF_LOGE("HdmiAudioInfoFrameSend: input param is invalid.");
576 return HDF_ERR_INVALID_PARAM;
577 }
578 cntlr = (struct HdmiCntlr *)frame->priv;
579 if (cntlr->ops == NULL || cntlr->ops->infoFrameEnable == NULL) {
580 HDF_LOGD("HdmiAudioInfoFrameSend not support.");
581 return HDF_ERR_NOT_SUPPORT;
582 }
583
584 if (enable == false) {
585 HdmiCntlrLock(cntlr);
586 cntlr->ops->infoFrameEnable(cntlr, HDMI_INFOFRAME_PACKET_TYPE_AUDIO, false);
587 HdmiCntlrUnlock(cntlr);
588 return HDF_SUCCESS;
589 }
590 HdmiFillAudioInfoFrame(&(frame->audio), &(cntlr->attr.audioAttr));
591 infoFrame.audio = frame->audio;
592 return HdmiInfoFrameSend(frame, &infoFrame);
593 }
594
HdmiFillDrmInfoFrame(struct HdmiDrmInfoFrame * drm,const struct HdmiHdrAttr * hdrAttr)595 static void HdmiFillDrmInfoFrame(struct HdmiDrmInfoFrame *drm, const struct HdmiHdrAttr *hdrAttr)
596 {
597 if (memset_s(drm, sizeof(struct HdmiDrmInfoFrame), 0, sizeof(struct HdmiDrmInfoFrame)) != EOK) {
598 HDF_LOGE("fill vsif, memset_s fail.");
599 return;
600 }
601 drm->type = HDMI_INFOFRAME_PACKET_TYPE_DRM;
602 drm->len = HDMI_DRM_INFOFRAME_LEN;
603 drm->verNum = HDMI_DRM_INFOFRAME_VERSION;
604 drm->eotfType = hdrAttr->eotfType;
605 drm->metadataType = hdrAttr->metadataType;
606 drm->des = hdrAttr->descriptor;
607 }
608
HdmiDrmInfoFrameSend(struct HdmiInfoFrame * frame,bool enable)609 int32_t HdmiDrmInfoFrameSend(struct HdmiInfoFrame *frame, bool enable)
610 {
611 struct HdmiCntlr *cntlr = NULL;
612 union HdmiInfoFrameInfo infoFrame = {0};
613
614 if (frame == NULL || frame->priv == NULL) {
615 HDF_LOGE("HdmiDrmInfoFrameSend: input param is invalid.");
616 return HDF_ERR_INVALID_PARAM;
617 }
618 cntlr = (struct HdmiCntlr *)frame->priv;
619 if (cntlr->ops == NULL || cntlr->ops->infoFrameEnable == NULL) {
620 HDF_LOGD("HdmiDrmInfoFrameSend not support.");
621 return HDF_ERR_NOT_SUPPORT;
622 }
623
624 if (enable == false) {
625 cntlr->ops->infoFrameEnable(cntlr, HDMI_INFOFRAME_PACKET_TYPE_DRM, false);
626 return HDF_SUCCESS;
627 }
628 HdmiFillDrmInfoFrame(&(frame->drm), &(cntlr->attr.hdrAttr));
629 infoFrame.drm = frame->drm;
630 return HdmiInfoFrameSend(frame, &infoFrame);
631 }
632
HdmiGetVsifLength(struct HdmiVs14VsifContent * _14Vsif,bool dolbyEnable,bool hdrSupport)633 static uint8_t HdmiGetVsifLength(struct HdmiVs14VsifContent *_14Vsif, bool dolbyEnable, bool hdrSupport)
634 {
635 uint8_t length = 0x07;
636
637 if (hdrSupport == true) {
638 if (dolbyEnable == true) {
639 length = 0x18;
640 } else if (_14Vsif->format == HDMI_VS_VIDEO_FORMAT_4K) {
641 length = 0x05;
642 } else if (_14Vsif->format == HDMI_VS_VIDEO_FORMAT_3D) {
643 length = 0x07;
644 } else {
645 length = 0x04;
646 }
647 }
648 return length;
649 }
650
HdmiFill14Vsif(struct HdmiVsInfoFrame * vs,const struct HdmiVideoAttr * videoAttr)651 static void HdmiFill14Vsif(struct HdmiVsInfoFrame *vs, const struct HdmiVideoAttr *videoAttr)
652 {
653 struct HdmiVideo4kInfo *info = NULL;
654 struct HdmiVs14VsifContent *vsif = &(vs->vsifContent.vsif);
655 enum HdmiVic vic;
656 uint32_t cnt;
657
658 vsif->oui = HDMI_IEEE_OUI_1_4;
659 vic = HdmiCommonGetVic(videoAttr->timing, videoAttr->aspect, false);
660 if ((vic == HDMI_VIC_3840X2160P24_16_9 || vic == HDMI_VIC_3840X2160P25_16_9 ||
661 vic == HDMI_VIC_3840X2160P30_16_9 || vic == HDMI_VIC_4096X2160P24_256_135) &&
662 videoAttr->_3dStruct == HDMI_VS_VIDEO_3D_BUTT) {
663 vsif->format = HDMI_VS_VIDEO_FORMAT_4K;
664 for (cnt = 0; cnt <= HDMI_VIDEO_4K_CODES_MAX; cnt++) {
665 info = HdmiCommonGetVideo4kInfo(cnt);
666 if (info != NULL && info->timing == videoAttr->timing) {
667 vsif->vic = info->_4kVic;
668 break;
669 }
670 }
671 } else if (videoAttr->_3dStruct < HDMI_VS_VIDEO_3D_BUTT) { // common 3D
672 vsif->format = HDMI_VS_VIDEO_FORMAT_3D;
673 vsif->_3dStruct = videoAttr->_3dStruct;
674 } else {
675 vsif->format = HDMI_VS_VIDEO_FORMAT_NULL;
676 vsif->_3dStruct = videoAttr->_3dStruct;
677 }
678 }
679
HdmiFillVsInfoFrame(struct HdmiInfoFrame * frame,const struct HdmiVideoAttr * videoAttr,bool dolbyEnable,bool hdrSupport)680 static void HdmiFillVsInfoFrame(struct HdmiInfoFrame *frame, const struct HdmiVideoAttr *videoAttr,
681 bool dolbyEnable, bool hdrSupport)
682 {
683 struct HdmiVsInfoFrame *vs = &(frame->vs);
684 int32_t ret;
685
686 ret = memset_s(vs, sizeof(struct HdmiVsInfoFrame), 0, sizeof(struct HdmiVsInfoFrame));
687 if (ret != EOK) {
688 HDF_LOGE("fill vsif, memset_s fail.");
689 return;
690 }
691 vs->type = HDMI_INFOFRAME_PACKET_TYPE_VS;
692 vs->verNum = HDMI_VSIF_VERSION;
693 HdmiFill14Vsif(vs, videoAttr);
694 vs->len = HdmiGetVsifLength(&(vs->vsifContent.vsif), dolbyEnable, hdrSupport);
695 /* fill user vendor data */
696 vs->vsifContent.userVsif.len = frame->userVsif.len;
697 ret = memcpy_s(vs->vsifContent.userVsif.data, HDMI_VENDOR_USER_DATA_MAX_LEN,
698 frame->userVsif.data, frame->userVsif.len);
699 if (ret != EOK) {
700 HDF_LOGE("fill vsif, memcpy_s fail.");
701 }
702 }
703
HdmiVsInfoFrameSend(struct HdmiInfoFrame * frame,bool enable,bool dolbyEnable)704 int32_t HdmiVsInfoFrameSend(struct HdmiInfoFrame *frame, bool enable, bool dolbyEnable)
705 {
706 struct HdmiCntlr *cntlr = NULL;
707 union HdmiInfoFrameInfo infoFrame = {0};
708
709 if (frame == NULL || frame->priv == NULL) {
710 HDF_LOGE("HdmiVsInfoFrameSend: input param is invalid.");
711 return HDF_ERR_INVALID_PARAM;
712 }
713 cntlr = (struct HdmiCntlr *)frame->priv;
714 if (cntlr->ops == NULL || cntlr->ops->infoFrameEnable == NULL) {
715 HDF_LOGD("HdmiVsInfoFrameSend not support.");
716 return HDF_ERR_NOT_SUPPORT;
717 }
718
719 if (enable == false) {
720 cntlr->ops->infoFrameEnable(cntlr, HDMI_INFOFRAME_PACKET_TYPE_VS, false);
721 return HDF_SUCCESS;
722 }
723 HdmiFillVsInfoFrame(frame, &(cntlr->attr.videoAttr), dolbyEnable, frame->hdrSupport);
724 infoFrame.vs = frame->vs;
725 return HdmiInfoFrameSend(frame, &infoFrame);
726 }
727
HdmiFillSpdInfoFrame(struct HdmiSpdInfoFrame * spd,const char * vendorName,const char * productName,enum HdmiSpdSdi sdi)728 static void HdmiFillSpdInfoFrame(struct HdmiSpdInfoFrame *spd,
729 const char *vendorName, const char *productName,
730 enum HdmiSpdSdi sdi)
731 {
732 uint32_t len;
733 uint32_t length;
734
735 if (memset_s(spd, sizeof(struct HdmiSpdInfoFrame), 0, sizeof(struct HdmiSpdInfoFrame)) != EOK) {
736 HDF_LOGE("fill spd infoFrame, memset_s fail.");
737 return;
738 }
739 spd->type = HDMI_INFOFRAME_PACKET_TYPE_SPD;
740 spd->len = HDMI_SPD_INFOFRAME_LEN;
741 spd->verNum = HDMI_SPD_VERSION;
742 spd->sdi = sdi;
743
744 len = (uint32_t)strlen(vendorName);
745 length = (uint32_t)sizeof(spd->vendorName);
746 length = (length > len) ? len : length;
747 if (memcpy_s(spd->vendorName, length, vendorName, length) != EOK) {
748 HDF_LOGE("fill spd infoFrame vendor name, memcpy_s fail.");
749 }
750
751 len = (uint32_t)strlen(productName);
752 length = (uint32_t)sizeof(spd->productDescription);
753 length = (length > len) ? len : length;
754 if (memcpy_s(spd->productDescription, length, productName, length) != EOK) {
755 HDF_LOGE("fill spd infoFrame product name, memcpy_s fail.");
756 }
757 }
758
HdmiSpdInfoFrameSend(struct HdmiInfoFrame * frame,bool enable,const char * vendorName,const char * productName,enum HdmiSpdSdi sdi)759 int32_t HdmiSpdInfoFrameSend(struct HdmiInfoFrame *frame, bool enable,
760 const char *vendorName, const char *productName, enum HdmiSpdSdi sdi)
761 {
762 struct HdmiCntlr *cntlr = NULL;
763 union HdmiInfoFrameInfo infoFrame = {0};
764
765 if (frame == NULL || frame->priv == NULL) {
766 HDF_LOGE("HdmiSpdInfoFrameSend: input param is invalid.");
767 return HDF_ERR_INVALID_PARAM;
768 }
769 cntlr = (struct HdmiCntlr *)frame->priv;
770 if (cntlr->ops == NULL || cntlr->ops->infoFrameEnable == NULL) {
771 HDF_LOGD("HdmiSpdInfoFrameSend not support.");
772 return HDF_ERR_NOT_SUPPORT;
773 }
774
775 if (enable == false) {
776 cntlr->ops->infoFrameEnable(cntlr, HDMI_INFOFRAME_PACKET_TYPE_SPD, false);
777 return HDF_SUCCESS;
778 }
779 HdmiFillSpdInfoFrame(&(frame->spd), vendorName, productName, sdi);
780 infoFrame.spd = frame->spd;
781 return HdmiInfoFrameSend(frame, &infoFrame);
782 }
783
HdmiInfoFrameGetInfo(struct HdmiInfoFrame * frame,enum HdmiPacketType type,union HdmiInfoFrameInfo * infoFrame)784 int32_t HdmiInfoFrameGetInfo(struct HdmiInfoFrame *frame, enum HdmiPacketType type,
785 union HdmiInfoFrameInfo *infoFrame)
786 {
787 if (frame == NULL || infoFrame == NULL) {
788 return HDF_ERR_INVALID_PARAM;
789 }
790
791 switch (type) {
792 case HDMI_INFOFRAME_PACKET_TYPE_VS:
793 infoFrame->vs = frame->vs;
794 break;
795 case HDMI_INFOFRAME_PACKET_TYPE_AVI:
796 infoFrame->avi = frame->avi;
797 break;
798 case HDMI_INFOFRAME_PACKET_TYPE_AUDIO:
799 infoFrame->audio = frame->audio;
800 break;
801 case HDMI_INFOFRAME_PACKET_TYPE_DRM:
802 infoFrame->drm = frame->drm;
803 break;
804 default:
805 HDF_LOGD("infoFrame %d not support get", type);
806 return HDF_ERR_INVALID_PARAM;
807 }
808 return HDF_SUCCESS;
809 }
810
HdmiInfoFrameSetInfo(struct HdmiInfoFrame * frame,enum HdmiPacketType type,union HdmiInfoFrameInfo * infoFrame)811 int32_t HdmiInfoFrameSetInfo(struct HdmiInfoFrame *frame, enum HdmiPacketType type,
812 union HdmiInfoFrameInfo *infoFrame)
813 {
814 if (frame == NULL || infoFrame == NULL) {
815 return HDF_ERR_INVALID_PARAM;
816 }
817
818 switch (type) {
819 case HDMI_INFOFRAME_PACKET_TYPE_VS:
820 frame->vs = infoFrame->vs;
821 break;
822 case HDMI_INFOFRAME_PACKET_TYPE_AVI:
823 frame->avi = infoFrame->avi;
824 break;
825 case HDMI_INFOFRAME_PACKET_TYPE_AUDIO:
826 frame->audio = infoFrame->audio;
827 break;
828 case HDMI_INFOFRAME_PACKET_TYPE_DRM:
829 frame->drm = infoFrame->drm;
830 break;
831 default:
832 HDF_LOGD("infoFrame %d not support set", type);
833 return HDF_ERR_INVALID_PARAM;
834 }
835 return HDF_SUCCESS;
836 }
837