/* * 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. */ #include <drm/display/drm_dp.h> #include <linux/bitops.h> #include <linux/bug.h> #include <linux/errno.h> #include <linux/export.h> #include <linux/hdmi.h> #include <linux/string.h> #include <linux/device.h> #define hdmi_log(fmt, ...) … static u8 hdmi_infoframe_checksum(const u8 *ptr, size_t size) { … } static void hdmi_infoframe_set_checksum(void *buffer, size_t size) { … } /** * hdmi_avi_infoframe_init() - initialize an HDMI AVI infoframe * @frame: HDMI AVI infoframe */ void hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame) { … } EXPORT_SYMBOL(…); static int hdmi_avi_infoframe_check_only(const struct hdmi_avi_infoframe *frame) { … } /** * 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) { … } EXPORT_SYMBOL(…); /** * 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(const struct hdmi_avi_infoframe *frame, void *buffer, size_t size) { … } EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); /** * hdmi_spd_infoframe_init() - initialize an HDMI SPD infoframe * @frame: HDMI SPD infoframe * @vendor: vendor string * @product: product string * * Returns 0 on success or a negative error code on failure. */ int hdmi_spd_infoframe_init(struct hdmi_spd_infoframe *frame, const char *vendor, const char *product) { … } EXPORT_SYMBOL(…); static int hdmi_spd_infoframe_check_only(const struct hdmi_spd_infoframe *frame) { … } /** * 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) { … } EXPORT_SYMBOL(…); /** * 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(const struct hdmi_spd_infoframe *frame, void *buffer, size_t size) { … } EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); /** * hdmi_audio_infoframe_init() - initialize an HDMI audio infoframe * @frame: HDMI audio infoframe * * Returns 0 on success or a negative error code on failure. */ int hdmi_audio_infoframe_init(struct hdmi_audio_infoframe *frame) { … } EXPORT_SYMBOL(…); static int hdmi_audio_infoframe_check_only(const struct hdmi_audio_infoframe *frame) { … } /** * 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(const struct hdmi_audio_infoframe *frame) { … } EXPORT_SYMBOL(…); static void hdmi_audio_infoframe_pack_payload(const struct hdmi_audio_infoframe *frame, u8 *buffer) { … } /** * 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(const struct hdmi_audio_infoframe *frame, void *buffer, size_t size) { … } EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); /** * 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(const struct hdmi_audio_infoframe *frame, struct dp_sdp *sdp, u8 dp_version) { … } EXPORT_SYMBOL(…); /** * hdmi_vendor_infoframe_init() - initialize an HDMI vendor infoframe * @frame: HDMI vendor infoframe * * Returns 0 on success or a negative error code on failure. */ int hdmi_vendor_infoframe_init(struct hdmi_vendor_infoframe *frame) { … } EXPORT_SYMBOL(…); static int hdmi_vendor_infoframe_length(const struct hdmi_vendor_infoframe *frame) { … } static int hdmi_vendor_infoframe_check_only(const struct hdmi_vendor_infoframe *frame) { … } /** * 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) { … } EXPORT_SYMBOL(…); /** * 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(const struct hdmi_vendor_infoframe *frame, void *buffer, size_t size) { … } EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); static int hdmi_vendor_any_infoframe_check_only(const union hdmi_vendor_any_infoframe *frame) { … } /** * 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) { … } EXPORT_SYMBOL(…); static int hdmi_drm_infoframe_check_only(const struct hdmi_drm_infoframe *frame) { … } /** * 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) { … } EXPORT_SYMBOL(…); /** * 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(const struct hdmi_drm_infoframe *frame, void *buffer, size_t size) { … } EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); /* * hdmi_vendor_any_infoframe_check() - check a vendor infoframe */ static int hdmi_vendor_any_infoframe_check(union hdmi_vendor_any_infoframe *frame) { … } /* * hdmi_vendor_any_infoframe_pack_only() - write a vendor infoframe to binary buffer */ static ssize_t hdmi_vendor_any_infoframe_pack_only(const union hdmi_vendor_any_infoframe *frame, void *buffer, size_t size) { … } /* * hdmi_vendor_any_infoframe_pack() - check a vendor infoframe, * and write it to binary buffer */ static ssize_t hdmi_vendor_any_infoframe_pack(union hdmi_vendor_any_infoframe *frame, void *buffer, size_t size) { … } /** * hdmi_infoframe_check() - check a HDMI 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_infoframe_check(union hdmi_infoframe *frame) { … } EXPORT_SYMBOL(…); /** * 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(const union hdmi_infoframe *frame, void *buffer, size_t size) { … } EXPORT_SYMBOL(…); /** * 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) { … } EXPORT_SYMBOL(…); static const char *hdmi_infoframe_type_get_name(enum hdmi_infoframe_type type) { … } static void hdmi_infoframe_log_header(const char *level, struct device *dev, const struct hdmi_any_infoframe *frame) { … } static const char *hdmi_colorspace_get_name(enum hdmi_colorspace colorspace) { … } static const char *hdmi_scan_mode_get_name(enum hdmi_scan_mode scan_mode) { … } static const char *hdmi_colorimetry_get_name(enum hdmi_colorimetry colorimetry) { … } static const char * hdmi_picture_aspect_get_name(enum hdmi_picture_aspect picture_aspect) { … } static const char * hdmi_active_aspect_get_name(enum hdmi_active_aspect active_aspect) { … } static const char * hdmi_extended_colorimetry_get_name(enum hdmi_extended_colorimetry ext_col) { … } static const char * hdmi_quantization_range_get_name(enum hdmi_quantization_range qrange) { … } static const char *hdmi_nups_get_name(enum hdmi_nups nups) { … } static const char * hdmi_ycc_quantization_range_get_name(enum hdmi_ycc_quantization_range qrange) { … } static const char * hdmi_content_type_get_name(enum hdmi_content_type content_type) { … } static void hdmi_avi_infoframe_log(const char *level, struct device *dev, const struct hdmi_avi_infoframe *frame) { … } static const char *hdmi_spd_sdi_get_name(enum hdmi_spd_sdi sdi) { … } static void hdmi_spd_infoframe_log(const char *level, struct device *dev, const struct hdmi_spd_infoframe *frame) { … } static const char * hdmi_audio_coding_type_get_name(enum hdmi_audio_coding_type coding_type) { … } static const char * hdmi_audio_sample_size_get_name(enum hdmi_audio_sample_size sample_size) { … } static const char * hdmi_audio_sample_frequency_get_name(enum hdmi_audio_sample_frequency freq) { … } static const char * hdmi_audio_coding_type_ext_get_name(enum hdmi_audio_coding_type_ext ctx) { … } static void hdmi_audio_infoframe_log(const char *level, struct device *dev, const struct hdmi_audio_infoframe *frame) { … } static void hdmi_drm_infoframe_log(const char *level, struct device *dev, const struct hdmi_drm_infoframe *frame) { … } static const char * hdmi_3d_structure_get_name(enum hdmi_3d_structure s3d_struct) { … } static void hdmi_vendor_any_infoframe_log(const char *level, struct device *dev, const union hdmi_vendor_any_infoframe *frame) { … } /** * hdmi_infoframe_log() - log info of HDMI infoframe * @level: logging level * @dev: device * @frame: HDMI infoframe */ void hdmi_infoframe_log(const char *level, struct device *dev, const union hdmi_infoframe *frame) { … } EXPORT_SYMBOL(…); /** * 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. */ static int hdmi_avi_infoframe_unpack(struct hdmi_avi_infoframe *frame, const void *buffer, size_t size) { … } /** * 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. */ static int hdmi_spd_infoframe_unpack(struct hdmi_spd_infoframe *frame, const void *buffer, size_t size) { … } /** * 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. */ static int hdmi_audio_infoframe_unpack(struct hdmi_audio_infoframe *frame, const void *buffer, size_t size) { … } /** * 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. */ static int hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame, const void *buffer, size_t size) { … } /** * hdmi_drm_infoframe_unpack_only() - unpack binary buffer of CTA-861-G DRM * infoframe DataBytes to a HDMI DRM * infoframe * @frame: HDMI DRM infoframe * @buffer: source buffer * @size: size of buffer * * Unpacks CTA-861-G DRM infoframe DataBytes contained in the binary @buffer * into a structured @frame of the HDMI Dynamic Range and Mastering (DRM) * infoframe. * * Returns 0 on success or a negative error code on failure. */ int hdmi_drm_infoframe_unpack_only(struct hdmi_drm_infoframe *frame, const void *buffer, size_t size) { … } EXPORT_SYMBOL(…); /** * 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. */ static int hdmi_drm_infoframe_unpack(struct hdmi_drm_infoframe *frame, const void *buffer, size_t size) { … } /** * 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, const void *buffer, size_t size) { … } EXPORT_SYMBOL(…);