/* * Copyright (C) 2012 Avionic Design GmbH * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sub license, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE.
*/
if (frame->picture_aspect > HDMI_PICTURE_ASPECT_16_9) return -EINVAL;
return 0;
}
/** * hdmi_avi_infoframe_check() - check a HDMI AVI infoframe * @frame: HDMI AVI infoframe * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields. * * Returns 0 on success or a negative error code on failure.
*/ int hdmi_avi_infoframe_check(struct hdmi_avi_infoframe *frame)
{ return hdmi_avi_infoframe_check_only(frame);
}
EXPORT_SYMBOL(hdmi_avi_infoframe_check);
/** * hdmi_avi_infoframe_pack_only() - write HDMI AVI infoframe to binary buffer * @frame: HDMI AVI infoframe * @buffer: destination buffer * @size: size of buffer * * Packs the information contained in the @frame structure into a binary * representation that can be written into the corresponding controller * registers. Also computes the checksum as required by section 5.3.5 of * the HDMI 1.4 specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_avi_infoframe_pack_only(conststruct hdmi_avi_infoframe *frame, void *buffer, size_t size)
{
u8 *ptr = buffer;
size_t length; int ret;
ret = hdmi_avi_infoframe_check_only(frame); if (ret) return ret;
/** * hdmi_avi_infoframe_pack() - check a HDMI AVI infoframe, * and write it to binary buffer * @frame: HDMI AVI infoframe * @buffer: destination buffer * @size: size of buffer * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields, after which it packs the information * contained in the @frame structure into a binary representation that * can be written into the corresponding controller registers. This function * also computes the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_avi_infoframe_pack(struct hdmi_avi_infoframe *frame, void *buffer, size_t size)
{ int ret;
ret = hdmi_avi_infoframe_check(frame); if (ret) return ret;
/** * hdmi_spd_infoframe_check() - check a HDMI SPD infoframe * @frame: HDMI SPD infoframe * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields. * * Returns 0 on success or a negative error code on failure.
*/ int hdmi_spd_infoframe_check(struct hdmi_spd_infoframe *frame)
{ return hdmi_spd_infoframe_check_only(frame);
}
EXPORT_SYMBOL(hdmi_spd_infoframe_check);
/** * hdmi_spd_infoframe_pack_only() - write HDMI SPD infoframe to binary buffer * @frame: HDMI SPD infoframe * @buffer: destination buffer * @size: size of buffer * * Packs the information contained in the @frame structure into a binary * representation that can be written into the corresponding controller * registers. Also computes the checksum as required by section 5.3.5 of * the HDMI 1.4 specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_spd_infoframe_pack_only(conststruct hdmi_spd_infoframe *frame, void *buffer, size_t size)
{
u8 *ptr = buffer;
size_t length; int ret;
ret = hdmi_spd_infoframe_check_only(frame); if (ret) return ret;
/** * hdmi_spd_infoframe_pack() - check a HDMI SPD infoframe, * and write it to binary buffer * @frame: HDMI SPD infoframe * @buffer: destination buffer * @size: size of buffer * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields, after which it packs the information * contained in the @frame structure into a binary representation that * can be written into the corresponding controller registers. This function * also computes the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_spd_infoframe_pack(struct hdmi_spd_infoframe *frame, void *buffer, size_t size)
{ int ret;
ret = hdmi_spd_infoframe_check(frame); if (ret) return ret;
/** * hdmi_audio_infoframe_check() - check a HDMI audio infoframe * @frame: HDMI audio infoframe * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields. * * Returns 0 on success or a negative error code on failure.
*/ int hdmi_audio_infoframe_check(conststruct hdmi_audio_infoframe *frame)
{ return hdmi_audio_infoframe_check_only(frame);
}
EXPORT_SYMBOL(hdmi_audio_infoframe_check);
if (frame->downmix_inhibit)
buffer[4] |= BIT(7);
}
/** * hdmi_audio_infoframe_pack_only() - write HDMI audio infoframe to binary buffer * @frame: HDMI audio infoframe * @buffer: destination buffer * @size: size of buffer * * Packs the information contained in the @frame structure into a binary * representation that can be written into the corresponding controller * registers. Also computes the checksum as required by section 5.3.5 of * the HDMI 1.4 specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_audio_infoframe_pack_only(conststruct hdmi_audio_infoframe *frame, void *buffer, size_t size)
{
u8 *ptr = buffer;
size_t length; int ret;
ret = hdmi_audio_infoframe_check_only(frame); if (ret) return ret;
/** * hdmi_audio_infoframe_pack() - check a HDMI Audio infoframe, * and write it to binary buffer * @frame: HDMI Audio infoframe * @buffer: destination buffer * @size: size of buffer * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields, after which it packs the information * contained in the @frame structure into a binary representation that * can be written into the corresponding controller registers. This function * also computes the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_audio_infoframe_pack(struct hdmi_audio_infoframe *frame, void *buffer, size_t size)
{ int ret;
ret = hdmi_audio_infoframe_check(frame); if (ret) return ret;
/** * hdmi_audio_infoframe_pack_for_dp - Pack a HDMI Audio infoframe for DisplayPort * * @frame: HDMI Audio infoframe * @sdp: Secondary data packet for DisplayPort. * @dp_version: DisplayPort version to be encoded in the header * * Packs a HDMI Audio Infoframe to be sent over DisplayPort. This function * fills the secondary data packet to be used for DisplayPort. * * Return: Number of total written bytes or a negative errno on failure.
*/
ssize_t
hdmi_audio_infoframe_pack_for_dp(conststruct hdmi_audio_infoframe *frame, struct dp_sdp *sdp, u8 dp_version)
{ int ret;
ret = hdmi_audio_infoframe_check(frame); if (ret) return ret;
/* * 0 is a valid value for s3d_struct, so we use a special "not set" * value
*/
frame->s3d_struct = HDMI_3D_STRUCTURE_INVALID;
frame->length = HDMI_VENDOR_INFOFRAME_SIZE;
staticint hdmi_vendor_infoframe_length(conststruct hdmi_vendor_infoframe *frame)
{ /* for side by side (half) we also need to provide 3D_Ext_Data */ if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) return 6; elseif (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) return 5; else return 4;
}
/* only one of those can be supplied */ if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) return -EINVAL;
if (frame->length != hdmi_vendor_infoframe_length(frame)) return -EINVAL;
return 0;
}
/** * hdmi_vendor_infoframe_check() - check a HDMI vendor infoframe * @frame: HDMI infoframe * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields. * * Returns 0 on success or a negative error code on failure.
*/ int hdmi_vendor_infoframe_check(struct hdmi_vendor_infoframe *frame)
{
frame->length = hdmi_vendor_infoframe_length(frame);
/** * hdmi_vendor_infoframe_pack_only() - write a HDMI vendor infoframe to binary buffer * @frame: HDMI infoframe * @buffer: destination buffer * @size: size of buffer * * Packs the information contained in the @frame structure into a binary * representation that can be written into the corresponding controller * registers. Also computes the checksum as required by section 5.3.5 of * the HDMI 1.4 specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_vendor_infoframe_pack_only(conststruct hdmi_vendor_infoframe *frame, void *buffer, size_t size)
{
u8 *ptr = buffer;
size_t length; int ret;
ret = hdmi_vendor_infoframe_check_only(frame); if (ret) return ret;
/** * hdmi_vendor_infoframe_pack() - check a HDMI Vendor infoframe, * and write it to binary buffer * @frame: HDMI Vendor infoframe * @buffer: destination buffer * @size: size of buffer * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields, after which it packs the information * contained in the @frame structure into a binary representation that * can be written into the corresponding controller registers. This function * also computes the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_vendor_infoframe_pack(struct hdmi_vendor_infoframe *frame, void *buffer, size_t size)
{ int ret;
ret = hdmi_vendor_infoframe_check(frame); if (ret) return ret;
/** * hdmi_drm_infoframe_init() - initialize an HDMI Dynaminc Range and * mastering infoframe * @frame: HDMI DRM infoframe * * Returns 0 on success or a negative error code on failure.
*/ int hdmi_drm_infoframe_init(struct hdmi_drm_infoframe *frame)
{
memset(frame, 0, sizeof(*frame));
if (frame->length != HDMI_DRM_INFOFRAME_SIZE) return -EINVAL;
return 0;
}
/** * hdmi_drm_infoframe_check() - check a HDMI DRM infoframe * @frame: HDMI DRM infoframe * * Validates that the infoframe is consistent. * Returns 0 on success or a negative error code on failure.
*/ int hdmi_drm_infoframe_check(struct hdmi_drm_infoframe *frame)
{ return hdmi_drm_infoframe_check_only(frame);
}
EXPORT_SYMBOL(hdmi_drm_infoframe_check);
/** * hdmi_drm_infoframe_pack_only() - write HDMI DRM infoframe to binary buffer * @frame: HDMI DRM infoframe * @buffer: destination buffer * @size: size of buffer * * Packs the information contained in the @frame structure into a binary * representation that can be written into the corresponding controller * registers. Also computes the checksum as required by section 5.3.5 of * the HDMI 1.4 specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_drm_infoframe_pack_only(conststruct hdmi_drm_infoframe *frame, void *buffer, size_t size)
{
u8 *ptr = buffer;
size_t length; int i;
/** * hdmi_drm_infoframe_pack() - check a HDMI DRM infoframe, * and write it to binary buffer * @frame: HDMI DRM infoframe * @buffer: destination buffer * @size: size of buffer * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields, after which it packs the information * contained in the @frame structure into a binary representation that * can be written into the corresponding controller registers. This function * also computes the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t hdmi_drm_infoframe_pack(struct hdmi_drm_infoframe *frame, void *buffer, size_t size)
{ int ret;
ret = hdmi_drm_infoframe_check(frame); if (ret) return ret;
/** * hdmi_infoframe_pack_only() - write a HDMI infoframe to binary buffer * @frame: HDMI infoframe * @buffer: destination buffer * @size: size of buffer * * Packs the information contained in the @frame structure into a binary * representation that can be written into the corresponding controller * registers. Also computes the checksum as required by section 5.3.5 of * the HDMI 1.4 specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t
hdmi_infoframe_pack_only(constunion hdmi_infoframe *frame, void *buffer, size_t size)
{
ssize_t length;
switch (frame->any.type) { case HDMI_INFOFRAME_TYPE_AVI:
length = hdmi_avi_infoframe_pack_only(&frame->avi,
buffer, size); break; case HDMI_INFOFRAME_TYPE_DRM:
length = hdmi_drm_infoframe_pack_only(&frame->drm,
buffer, size); break; case HDMI_INFOFRAME_TYPE_SPD:
length = hdmi_spd_infoframe_pack_only(&frame->spd,
buffer, size); break; case HDMI_INFOFRAME_TYPE_AUDIO:
length = hdmi_audio_infoframe_pack_only(&frame->audio,
buffer, size); break; case HDMI_INFOFRAME_TYPE_VENDOR:
length = hdmi_vendor_any_infoframe_pack_only(&frame->vendor,
buffer, size); break; default:
WARN(1, "Bad infoframe type %d\n", frame->any.type);
length = -EINVAL;
}
/** * hdmi_infoframe_pack() - check a HDMI infoframe, * and write it to binary buffer * @frame: HDMI infoframe * @buffer: destination buffer * @size: size of buffer * * Validates that the infoframe is consistent and updates derived fields * (eg. length) based on other fields, after which it packs the information * contained in the @frame structure into a binary representation that * can be written into the corresponding controller registers. This function * also computes the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns the number of bytes packed into the binary buffer or a negative * error code on failure.
*/
ssize_t
hdmi_infoframe_pack(union hdmi_infoframe *frame, void *buffer, size_t size)
{
ssize_t length;
switch (frame->any.type) { case HDMI_INFOFRAME_TYPE_AVI:
length = hdmi_avi_infoframe_pack(&frame->avi, buffer, size); break; case HDMI_INFOFRAME_TYPE_DRM:
length = hdmi_drm_infoframe_pack(&frame->drm, buffer, size); break; case HDMI_INFOFRAME_TYPE_SPD:
length = hdmi_spd_infoframe_pack(&frame->spd, buffer, size); break; case HDMI_INFOFRAME_TYPE_AUDIO:
length = hdmi_audio_infoframe_pack(&frame->audio, buffer, size); break; case HDMI_INFOFRAME_TYPE_VENDOR:
length = hdmi_vendor_any_infoframe_pack(&frame->vendor,
buffer, size); break; default:
WARN(1, "Bad infoframe type %d\n", frame->any.type);
length = -EINVAL;
}
staticconstchar *hdmi_infoframe_type_get_name(enum hdmi_infoframe_type type)
{ if (type < 0x80 || type > 0x9f) return"Invalid"; switch (type) { case HDMI_INFOFRAME_TYPE_VENDOR: return"Vendor"; case HDMI_INFOFRAME_TYPE_AVI: return"Auxiliary Video Information (AVI)"; case HDMI_INFOFRAME_TYPE_SPD: return"Source Product Description (SPD)"; case HDMI_INFOFRAME_TYPE_AUDIO: return"Audio"; case HDMI_INFOFRAME_TYPE_DRM: return"Dynamic Range and Mastering";
} return"Reserved";
}
switch (active_aspect) { case HDMI_ACTIVE_ASPECT_16_9_TOP: return"16:9 Top"; case HDMI_ACTIVE_ASPECT_14_9_TOP: return"14:9 Top"; case HDMI_ACTIVE_ASPECT_16_9_CENTER: return"16:9 Center"; case HDMI_ACTIVE_ASPECT_PICTURE: return"Same as Picture"; case HDMI_ACTIVE_ASPECT_4_3: return"4:3"; case HDMI_ACTIVE_ASPECT_16_9: return"16:9"; case HDMI_ACTIVE_ASPECT_14_9: return"14:9"; case HDMI_ACTIVE_ASPECT_4_3_SP_14_9: return"4:3 SP 14:9"; case HDMI_ACTIVE_ASPECT_16_9_SP_14_9: return"16:9 SP 14:9"; case HDMI_ACTIVE_ASPECT_16_9_SP_4_3: return"16:9 SP 4:3";
} return"Reserved";
}
staticconstchar *
hdmi_extended_colorimetry_get_name(enum hdmi_extended_colorimetry ext_col)
{ switch (ext_col) { case HDMI_EXTENDED_COLORIMETRY_XV_YCC_601: return"xvYCC 601"; case HDMI_EXTENDED_COLORIMETRY_XV_YCC_709: return"xvYCC 709"; case HDMI_EXTENDED_COLORIMETRY_S_YCC_601: return"sYCC 601"; case HDMI_EXTENDED_COLORIMETRY_OPYCC_601: return"opYCC 601"; case HDMI_EXTENDED_COLORIMETRY_OPRGB: return"opRGB"; case HDMI_EXTENDED_COLORIMETRY_BT2020_CONST_LUM: return"BT.2020 Constant Luminance"; case HDMI_EXTENDED_COLORIMETRY_BT2020: return"BT.2020"; case HDMI_EXTENDED_COLORIMETRY_RESERVED: return"Reserved";
} return"Invalid";
}
staticconstchar *
hdmi_quantization_range_get_name(enum hdmi_quantization_range qrange)
{ switch (qrange) { case HDMI_QUANTIZATION_RANGE_DEFAULT: return"Default"; case HDMI_QUANTIZATION_RANGE_LIMITED: return"Limited"; case HDMI_QUANTIZATION_RANGE_FULL: return"Full"; case HDMI_QUANTIZATION_RANGE_RESERVED: return"Reserved";
} return"Invalid";
}
staticconstchar *hdmi_nups_get_name(enum hdmi_nups nups)
{ switch (nups) { case HDMI_NUPS_UNKNOWN: return"Unknown Non-uniform Scaling"; case HDMI_NUPS_HORIZONTAL: return"Horizontally Scaled"; case HDMI_NUPS_VERTICAL: return"Vertically Scaled"; case HDMI_NUPS_BOTH: return"Horizontally and Vertically Scaled";
} return"Invalid";
}
staticconstchar *
hdmi_ycc_quantization_range_get_name(enum hdmi_ycc_quantization_range qrange)
{ switch (qrange) { case HDMI_YCC_QUANTIZATION_RANGE_LIMITED: return"Limited"; case HDMI_YCC_QUANTIZATION_RANGE_FULL: return"Full";
} return"Invalid";
}
staticconstchar *
hdmi_content_type_get_name(enum hdmi_content_type content_type)
{ switch (content_type) { case HDMI_CONTENT_TYPE_GRAPHICS: return"Graphics"; case HDMI_CONTENT_TYPE_PHOTO: return"Photo"; case HDMI_CONTENT_TYPE_CINEMA: return"Cinema"; case HDMI_CONTENT_TYPE_GAME: return"Game";
} return"Invalid";
}
staticconstchar *hdmi_spd_sdi_get_name(enum hdmi_spd_sdi sdi)
{ if (sdi < 0 || sdi > 0xff) return"Invalid"; switch (sdi) { case HDMI_SPD_SDI_UNKNOWN: return"Unknown"; case HDMI_SPD_SDI_DSTB: return"Digital STB"; case HDMI_SPD_SDI_DVDP: return"DVD Player"; case HDMI_SPD_SDI_DVHS: return"D-VHS"; case HDMI_SPD_SDI_HDDVR: return"HDD Videorecorder"; case HDMI_SPD_SDI_DVC: return"DVC"; case HDMI_SPD_SDI_DSC: return"DSC"; case HDMI_SPD_SDI_VCD: return"Video CD"; case HDMI_SPD_SDI_GAME: return"Game"; case HDMI_SPD_SDI_PC: return"PC General"; case HDMI_SPD_SDI_BD: return"Blu-Ray Disc (BD)"; case HDMI_SPD_SDI_SACD: return"Super Audio CD"; case HDMI_SPD_SDI_HDDVD: return"HD DVD"; case HDMI_SPD_SDI_PMP: return"PMP";
} return"Reserved";
}
staticconstchar *
hdmi_audio_coding_type_get_name(enum hdmi_audio_coding_type coding_type)
{ switch (coding_type) { case HDMI_AUDIO_CODING_TYPE_STREAM: return"Refer to Stream Header"; case HDMI_AUDIO_CODING_TYPE_PCM: return"PCM"; case HDMI_AUDIO_CODING_TYPE_AC3: return"AC-3"; case HDMI_AUDIO_CODING_TYPE_MPEG1: return"MPEG1"; case HDMI_AUDIO_CODING_TYPE_MP3: return"MP3"; case HDMI_AUDIO_CODING_TYPE_MPEG2: return"MPEG2"; case HDMI_AUDIO_CODING_TYPE_AAC_LC: return"AAC"; case HDMI_AUDIO_CODING_TYPE_DTS: return"DTS"; case HDMI_AUDIO_CODING_TYPE_ATRAC: return"ATRAC"; case HDMI_AUDIO_CODING_TYPE_DSD: return"One Bit Audio"; case HDMI_AUDIO_CODING_TYPE_EAC3: return"Dolby Digital +"; case HDMI_AUDIO_CODING_TYPE_DTS_HD: return"DTS-HD"; case HDMI_AUDIO_CODING_TYPE_MLP: return"MAT (MLP)"; case HDMI_AUDIO_CODING_TYPE_DST: return"DST"; case HDMI_AUDIO_CODING_TYPE_WMA_PRO: return"WMA PRO"; case HDMI_AUDIO_CODING_TYPE_CXT: return"Refer to CXT";
} return"Invalid";
}
staticconstchar *
hdmi_audio_sample_size_get_name(enum hdmi_audio_sample_size sample_size)
{ switch (sample_size) { case HDMI_AUDIO_SAMPLE_SIZE_STREAM: return"Refer to Stream Header"; case HDMI_AUDIO_SAMPLE_SIZE_16: return"16 bit"; case HDMI_AUDIO_SAMPLE_SIZE_20: return"20 bit"; case HDMI_AUDIO_SAMPLE_SIZE_24: return"24 bit";
} return"Invalid";
}
staticconstchar *
hdmi_audio_sample_frequency_get_name(enum hdmi_audio_sample_frequency freq)
{ switch (freq) { case HDMI_AUDIO_SAMPLE_FREQUENCY_STREAM: return"Refer to Stream Header"; case HDMI_AUDIO_SAMPLE_FREQUENCY_32000: return"32 kHz"; case HDMI_AUDIO_SAMPLE_FREQUENCY_44100: return"44.1 kHz (CD)"; case HDMI_AUDIO_SAMPLE_FREQUENCY_48000: return"48 kHz"; case HDMI_AUDIO_SAMPLE_FREQUENCY_88200: return"88.2 kHz"; case HDMI_AUDIO_SAMPLE_FREQUENCY_96000: return"96 kHz"; case HDMI_AUDIO_SAMPLE_FREQUENCY_176400: return"176.4 kHz"; case HDMI_AUDIO_SAMPLE_FREQUENCY_192000: return"192 kHz";
} return"Invalid";
}
switch (ctx) { case HDMI_AUDIO_CODING_TYPE_EXT_CT: return"Refer to CT"; case HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC: return"HE AAC"; case HDMI_AUDIO_CODING_TYPE_EXT_HE_AAC_V2: return"HE AAC v2"; case HDMI_AUDIO_CODING_TYPE_EXT_MPEG_SURROUND: return"MPEG SURROUND"; case HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC: return"MPEG-4 HE AAC"; case HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_V2: return"MPEG-4 HE AAC v2"; case HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC: return"MPEG-4 AAC LC"; case HDMI_AUDIO_CODING_TYPE_EXT_DRA: return"DRA"; case HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_HE_AAC_SURROUND: return"MPEG-4 HE AAC + MPEG Surround"; case HDMI_AUDIO_CODING_TYPE_EXT_MPEG4_AAC_LC_SURROUND: return"MPEG-4 AAC LC + MPEG Surround";
} return"Reserved";
}
if (frame->any.oui != HDMI_IEEE_OUI) {
hdmi_log(" not a HDMI vendor infoframe\n"); return;
} if (hvf->vic == 0 && hvf->s3d_struct == HDMI_3D_STRUCTURE_INVALID) {
hdmi_log(" empty frame\n"); return;
}
if (hvf->vic)
hdmi_log(" HDMI VIC: %u\n", hvf->vic); if (hvf->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
hdmi_log(" 3D structure: %s\n",
hdmi_3d_structure_get_name(hvf->s3d_struct)); if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
hdmi_log(" 3D extension data: %d\n",
hvf->s3d_ext_data);
}
}
/** * hdmi_infoframe_log() - log info of HDMI infoframe * @level: logging level * @dev: device * @frame: HDMI infoframe
*/ void hdmi_infoframe_log(constchar *level, struct device *dev, constunion hdmi_infoframe *frame)
{ switch (frame->any.type) { case HDMI_INFOFRAME_TYPE_AVI:
hdmi_avi_infoframe_log(level, dev, &frame->avi); break; case HDMI_INFOFRAME_TYPE_SPD:
hdmi_spd_infoframe_log(level, dev, &frame->spd); break; case HDMI_INFOFRAME_TYPE_AUDIO:
hdmi_audio_infoframe_log(level, dev, &frame->audio); break; case HDMI_INFOFRAME_TYPE_VENDOR:
hdmi_vendor_any_infoframe_log(level, dev, &frame->vendor); break; case HDMI_INFOFRAME_TYPE_DRM:
hdmi_drm_infoframe_log(level, dev, &frame->drm); break;
}
}
EXPORT_SYMBOL(hdmi_infoframe_log);
/** * hdmi_avi_infoframe_unpack() - unpack binary buffer to a HDMI AVI infoframe * @frame: HDMI AVI infoframe * @buffer: source buffer * @size: size of buffer * * Unpacks the information contained in binary @buffer into a structured * @frame of the HDMI Auxiliary Video (AVI) information frame. * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns 0 on success or a negative error code on failure.
*/ staticint hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame, constvoid *buffer, size_t size)
{ const u8 *ptr = buffer;
if (size < HDMI_INFOFRAME_SIZE(AVI)) return -EINVAL;
/** * hdmi_spd_infoframe_unpack() - unpack binary buffer to a HDMI SPD infoframe * @frame: HDMI SPD infoframe * @buffer: source buffer * @size: size of buffer * * Unpacks the information contained in binary @buffer into a structured * @frame of the HDMI Source Product Description (SPD) information frame. * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns 0 on success or a negative error code on failure.
*/ staticint hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame, constvoid *buffer, size_t size)
{ const u8 *ptr = buffer; int ret;
if (size < HDMI_INFOFRAME_SIZE(SPD)) return -EINVAL;
if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(SPD)) != 0) return -EINVAL;
ptr += HDMI_INFOFRAME_HEADER_SIZE;
ret = hdmi_spd_infoframe_init(frame, ptr, ptr + 8); if (ret) return ret;
frame->sdi = ptr[24];
return 0;
}
/** * hdmi_audio_infoframe_unpack() - unpack binary buffer to a HDMI AUDIO infoframe * @frame: HDMI Audio infoframe * @buffer: source buffer * @size: size of buffer * * Unpacks the information contained in binary @buffer into a structured * @frame of the HDMI Audio information frame. * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns 0 on success or a negative error code on failure.
*/ staticint hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame, constvoid *buffer, size_t size)
{ const u8 *ptr = buffer; int ret;
if (size < HDMI_INFOFRAME_SIZE(AUDIO)) return -EINVAL;
/** * hdmi_vendor_any_infoframe_unpack() - unpack binary buffer to a HDMI * vendor infoframe * @frame: HDMI Vendor infoframe * @buffer: source buffer * @size: size of buffer * * Unpacks the information contained in binary @buffer into a structured * @frame of the HDMI Vendor information frame. * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns 0 on success or a negative error code on failure.
*/ staticint
hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame, constvoid *buffer, size_t size)
{ const u8 *ptr = buffer;
size_t length; int ret;
u8 hdmi_video_format; struct hdmi_vendor_infoframe *hvf = &frame->hdmi;
if (size < HDMI_INFOFRAME_HEADER_SIZE) return -EINVAL;
/** * hdmi_drm_infoframe_unpack() - unpack binary buffer to a HDMI DRM infoframe * @frame: HDMI DRM infoframe * @buffer: source buffer * @size: size of buffer * * Unpacks the CTA-861-G DRM infoframe contained in the binary @buffer into * a structured @frame of the HDMI Dynamic Range and Mastering (DRM) * infoframe. It also verifies the checksum as required by section 5.3.5 of * the HDMI 1.4 specification. * * Returns 0 on success or a negative error code on failure.
*/ staticint hdmi_drm_infoframe_unpack(struct hdmi_drm_infoframe *frame, constvoid *buffer, size_t size)
{ const u8 *ptr = buffer; int ret;
if (size < HDMI_INFOFRAME_SIZE(DRM)) return -EINVAL;
/** * hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe * @frame: HDMI infoframe * @buffer: source buffer * @size: size of buffer * * Unpacks the information contained in binary buffer @buffer into a structured * @frame of a HDMI infoframe. * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4 * specification. * * Returns 0 on success or a negative error code on failure.
*/ int hdmi_infoframe_unpack(union hdmi_infoframe *frame, constvoid *buffer, size_t size)
{ int ret; const u8 *ptr = buffer;
if (size < HDMI_INFOFRAME_HEADER_SIZE) return -EINVAL;
switch (ptr[0]) { case HDMI_INFOFRAME_TYPE_AVI:
ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer, size); break; case HDMI_INFOFRAME_TYPE_DRM:
ret = hdmi_drm_infoframe_unpack(&frame->drm, buffer, size); break; case HDMI_INFOFRAME_TYPE_SPD:
ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer, size); break; case HDMI_INFOFRAME_TYPE_AUDIO:
ret = hdmi_audio_infoframe_unpack(&frame->audio, buffer, size); break; case HDMI_INFOFRAME_TYPE_VENDOR:
ret = hdmi_vendor_any_infoframe_unpack(&frame->vendor, buffer, size); break; default:
ret = -EINVAL; break;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.