mirror of
https://github.com/rd-stuffs/msm-4.14.git
synced 2025-02-20 11:45:48 +08:00
* refs/heads/tmp-f960b38: Linux 4.14.159 of: unittest: fix memory leak in attach_node_and_children raid5: need to set STRIPE_HANDLE for batch head gpiolib: acpi: Add Terra Pad 1061 to the run_edge_events_on_boot_blacklist kernel/module.c: wakeup processes in module_wq on module unload gfs2: fix glock reference problem in gfs2_trans_remove_revoke net/mlx5e: Fix SFF 8472 eeprom length sunrpc: fix crash when cache_head become valid before update workqueue: Fix missing kfree(rescuer) in destroy_workqueue() blk-mq: make sure that line break can be printed mfd: rk808: Fix RK818 ID template ext4: fix a bug in ext4_wait_for_tail_page_commit mm/shmem.c: cast the type of unmap_start to u64 firmware: qcom: scm: Ensure 'a0' status code is treated as signed ext4: work around deleting a file with i_nlink == 0 safely powerpc: Fix vDSO clock_getres() powerpc: Avoid clang warnings around setjmp and longjmp ath10k: fix fw crash by moving chip reset after napi disabled media: vimc: fix component match compare mlxsw: spectrum_router: Refresh nexthop neighbour when it becomes dead power: supply: cpcap-battery: Fix signed counter sample register x86/MCE/AMD: Carve out the MC4_MISC thresholding quirk x86/MCE/AMD: Turn off MC4_MISC thresholding on all family 0x15 models e100: Fix passing zero to 'PTR_ERR' warning in e100_load_ucode_wait drbd: Change drbd_request_detach_interruptible's return type to int scsi: lpfc: Correct code setting non existent bits in sli4 ABORT WQE scsi: lpfc: Cap NPIV vports to 256 omap: pdata-quirks: remove openpandora quirks for mmc3 and wl1251 phy: renesas: rcar-gen3-usb2: Fix sysfs interface of "role" iio: adis16480: Add debugfs_reg_access entry xhci: make sure interrupts are restored to correct state xhci: Fix memory leak in xhci_add_in_port() scsi: qla2xxx: Fix message indicating vectors used by driver scsi: qla2xxx: Always check the qla2x00_wait_for_hba_online() return value scsi: qla2xxx: Fix qla24xx_process_bidir_cmd() scsi: qla2xxx: Fix session lookup in qlt_abort_work() scsi: qla2xxx: Fix DMA unmap leak scsi: zfcp: trace channel log even for FCP command responses block: fix single range discard merge reiserfs: fix extended attributes on the root directory ext4: Fix credit estimate for final inode freeing quota: fix livelock in dquot_writeback_dquots ext2: check err when partial != NULL quota: Check that quota is not dirty before release video/hdmi: Fix AVI bar unpack powerpc/xive: Skip ioremap() of ESB pages for LSI interrupts powerpc: Allow flush_icache_range to work across ranges >4GB powerpc/xive: Prevent page fault issues in the machine crash handler powerpc: Allow 64bit VDSO __kernel_sync_dicache to work across ranges >4GB ppdev: fix PPGETTIME/PPSETTIME ioctls ARM: dts: omap3-tao3530: Fix incorrect MMC card detection GPIO polarity mmc: host: omap_hsmmc: add code for special init of wl1251 to get rid of pandora_wl1251_init_card pinctrl: samsung: Fix device node refcount leaks in S3C64xx wakeup controller init pinctrl: samsung: Fix device node refcount leaks in init code pinctrl: samsung: Fix device node refcount leaks in S3C24xx wakeup controller init pinctrl: samsung: Add of_node_put() before return in error path ACPI: PM: Avoid attaching ACPI PM domain to certain devices ACPI: bus: Fix NULL pointer check in acpi_bus_get_private_data() ACPI: OSL: only free map once in osl.c cpufreq: powernv: fix stack bloat and hard limit on number of CPUs PM / devfreq: Lock devfreq in trans_stat_show intel_th: pci: Add Tiger Lake CPU support intel_th: pci: Add Ice Lake CPU support intel_th: Fix a double put_device() in error path cpuidle: Do not unset the driver if it is there already media: cec.h: CEC_OP_REC_FLAG_ values were swapped media: radio: wl1273: fix interrupt masking on release media: bdisp: fix memleak on release s390/mm: properly clear _PAGE_NOEXEC bit when it is not supported ar5523: check NULL before memcpy() in ar5523_cmd() cgroup: pids: use atomic64_t for pids->limit blk-mq: avoid sysfs buffer overflow with too many CPU cores ASoC: Jack: Fix NULL pointer dereference in snd_soc_jack_report workqueue: Fix pwq ref leak in rescuer_thread() workqueue: Fix spurious sanity check failures in destroy_workqueue() dm zoned: reduce overhead of backing device checks hwrng: omap - Fix RNG wait loop timeout watchdog: aspeed: Fix clock behaviour for ast2600 md/raid0: Fix an error message in raid0_make_request() ALSA: hda - Fix pending unsol events at shutdown ovl: relax WARN_ON() on rename to self lib: raid6: fix awk build warnings rtlwifi: rtl8192de: Fix missing enable interrupt flag rtlwifi: rtl8192de: Fix missing callback that tests for hw release of buffer rtlwifi: rtl8192de: Fix missing code to retrieve RX buffer address btrfs: record all roots for rename exchange on a subvol Btrfs: send, skip backreference walking for extents with many references btrfs: Remove btrfs_bio::flags member Btrfs: fix negative subv_writers counter and data space leak after buffered write btrfs: use refcount_inc_not_zero in kill_all_nodes btrfs: check page->mapping when loading free space cache usb: dwc3: ep0: Clear started flag on completion virtio-balloon: fix managed page counts when migrating pages between zones mtd: spear_smi: Fix Write Burst mode tpm: add check after commands attribs tab allocation usb: mon: Fix a deadlock in usbmon between mmap and read usb: core: urb: fix URB structure initialization function USB: adutux: fix interface sanity check USB: serial: io_edgeport: fix epic endpoint lookup USB: idmouse: fix interface sanity checks USB: atm: ueagle-atm: add missing endpoint check iio: humidity: hdc100x: fix IIO_HUMIDITYRELATIVE channel reporting ARM: dts: pandora-common: define wl1251 as child node of mmc3 xhci: handle some XHCI_TRUST_TX_LENGTH quirks cases as default behaviour. xhci: Increase STS_HALT timeout in xhci_suspend() usb: xhci: only set D3hot for pci device staging: gigaset: add endpoint-type sanity check staging: gigaset: fix illegal free on probe errors staging: gigaset: fix general protection fault on probe staging: rtl8712: fix interface sanity check staging: rtl8188eu: fix interface sanity check usb: Allow USB device to be warm reset in suspended state USB: documentation: flags on usb-storage versus UAS USB: uas: heed CAPACITY_HEURISTICS USB: uas: honor flag to avoid CAPACITY16 media: venus: remove invalid compat_ioctl32 handler scsi: qla2xxx: Fix driver unload hang usb: gadget: pch_udc: fix use after free usb: gadget: configfs: Fix missing spin_lock_init() appletalk: Set error code if register_snap_client failed appletalk: Fix potential NULL pointer dereference in unregister_snap_client KVM: x86: fix out-of-bounds write in KVM_GET_EMULATED_CPUID (CVE-2019-19332) ASoC: rsnd: fixup MIX kctrl registration binder: Handle start==NULL in binder_update_page_range() thermal: Fix deadlock in thermal thermal_zone_device_check iomap: Fix pipe page leakage during splicing RDMA/qib: Validate ->show()/store() callbacks before calling them spi: atmel: Fix CS high support crypto: user - fix memory leak in crypto_report crypto: ecdh - fix big endian bug in ECC library crypto: ccp - fix uninitialized list head crypto: af_alg - cast ki_complete ternary op to int crypto: crypto4xx - fix double-free in crypto4xx_destroy_sdr KVM: x86: fix presentation of TSX feature in ARCH_CAPABILITIES KVM: x86: do not modify masked bits of shared MSRs KVM: arm/arm64: vgic: Don't rely on the wrong pending table drm/i810: Prevent underflow in ioctl jbd2: Fix possible overflow in jbd2_log_space_left() kernfs: fix ino wrap-around detection can: slcan: Fix use-after-free Read in slcan_open tty: vt: keyboard: reject invalid keycodes CIFS: Fix SMB2 oplock break processing CIFS: Fix NULL-pointer dereference in smb2_push_mandatory_locks x86/PCI: Avoid AMD FCH XHCI USB PME# from D0 defect Input: Fix memory leak in psxpad_spi_probe coresight: etm4x: Fix input validation for sysfs. Input: goodix - add upside-down quirk for Teclast X89 tablet Input: synaptics-rmi4 - don't increment rmiaddr for SMBus transfers Input: synaptics-rmi4 - re-enable IRQs in f34v7_do_reflash Input: synaptics - switch another X1 Carbon 6 to RMI/SMbus ALSA: hda - Add mute led support for HP ProBook 645 G4 ALSA: pcm: oss: Avoid potential buffer overflows ALSA: hda/realtek - Dell headphone has noise on unmute for ALC236 fuse: verify attributes fuse: verify nlink sched/fair: Scale bandwidth quota and period without losing quota/period ratio precision tcp: exit if nothing to retransmit on RTO timeout net: aquantia: fix RSS table and key sizes media: vimc: fix start stream when link is disabled ARM: dts: sunxi: Fix PMU compatible strings usb: mtu3: fix dbginfo in qmu_tx_zlp_error_handler mlx4: Use snprintf instead of complicated strcpy IB/hfi1: Close VNIC sdma_progress sleep window IB/hfi1: Ignore LNI errors before DC8051 transitions to Polling state mlxsw: spectrum_router: Relax GRE decap matching check firmware: qcom: scm: fix compilation error when disabled media: stkwebcam: Bugfix for wrong return values tty: Don't block on IO when ldisc change is pending nfsd: Return EPERM, not EACCES, in some SETATTR cases MIPS: OCTEON: cvmx_pko_mem_debug8: use oldest forward compatible definition clk: renesas: r8a77995: Correct parent clock of DU powerpc/math-emu: Update macros from GCC pstore/ram: Avoid NULL deref in ftrace merging failure path net/mlx4_core: Fix return codes of unsupported operations dlm: fix invalid cluster name warning ARM: dts: realview: Fix some more duplicate regulator nodes clk: sunxi-ng: h3/h5: Fix CSI_MCLK parent ARM: dts: pxa: clean up USB controller nodes mtd: fix mtd_oobavail() incoherent returned value kbuild: fix single target build for external module modpost: skip ELF local symbols during section mismatch check tcp: fix SNMP TCP timeout under-estimation tcp: fix SNMP under-estimation on failed retransmission tcp: fix off-by-one bug on aborting window-probing socket ARM: dts: realview-pbx: Fix duplicate regulator nodes ARM: dts: mmp2: fix the gpio interrupt cell number net/x25: fix null_x25_address handling net/x25: fix called/calling length calculation in x25_parse_address_block arm64: dts: meson-gxl-khadas-vim: fix GPIO lines names arm64: dts: meson-gxbb-odroidc2: fix GPIO lines names arm64: dts: meson-gxbb-nanopi-k2: fix GPIO lines names arm64: dts: meson-gxl-libretech-cc: fix GPIO lines names ARM: OMAP1/2: fix SoC name printing ASoC: au8540: use 64-bit arithmetic instead of 32-bit nfsd: fix a warning in __cld_pipe_upcall() ARM: debug: enable UART1 for socfpga Cyclone5 dlm: NULL check before kmem_cache_destroy is not needed ARM: dts: sun8i: v3s: Change pinctrl nodes to avoid warning ARM: dts: sun5i: a10s: Fix HDMI output DTC warning ASoC: rsnd: tidyup registering method for rsnd_kctrl_new() lockd: fix decoding of TEST results i2c: imx: don't print error message on probe defer serial: imx: fix error handling in console_setup altera-stapl: check for a null key before strcasecmp'ing it dma-mapping: fix return type of dma_set_max_seg_size() sparc: Correct ctx->saw_frame_pointer logic. f2fs: fix to allow node segment for GC by ioctl path ARM: dts: rockchip: Assign the proper GPIO clocks for rv1108 ARM: dts: rockchip: Fix the PMU interrupt number for rv1108 f2fs: change segment to section in f2fs_ioc_gc_range f2fs: fix count of seg_freed to make sec_freed correct ACPI: fix acpi_find_child_device() invocation in acpi_preset_companion() usb: dwc3: don't log probe deferrals; but do log other error codes usb: dwc3: debugfs: Properly print/set link state for HS dmaengine: dw-dmac: implement dma protection control setting dmaengine: coh901318: Remove unused variable dmaengine: coh901318: Fix a double-lock bug media: cec: report Vendor ID after initialization media: pulse8-cec: return 0 when invalidating the logical address ARM: dts: exynos: Use Samsung SoC specific compatible for DWC2 module rtc: dt-binding: abx80x: fix resistance scale rtc: max8997: Fix the returned value in case of error in 'max8997_rtc_read_alarm()' math-emu/soft-fp.h: (_FP_ROUND_ZERO) cast 0 to void to fix warning net/smc: use after free fix in smc_wr_tx_put_slot() MIPS: OCTEON: octeon-platform: fix typing iomap: sub-block dio needs to zeroout beyond EOF net-next/hinic:fix a bug in set mac address regulator: Fix return value of _set_load() stub clk: rockchip: fix ID of 8ch clock of I2S1 for rk3328 clk: rockchip: fix I2S1 clock gate register for rk3328 mm/vmstat.c: fix NUMA statistics updates Staging: iio: adt7316: Fix i2c data reading, set the data field pinctrl: qcom: ssbi-gpio: fix gpio-hog related boot issues crypto: bcm - fix normal/non key hash algorithm failure crypto: ecc - check for invalid values in the key verification test scsi: zfcp: drop default switch case which might paper over missing case net: dsa: mv88e6xxx: Work around mv886e6161 SERDES missing MII_PHYSID2 MIPS: SiByte: Enable ZONE_DMA32 for LittleSur dlm: fix missing idr_destroy for recover_idr ARM: dts: rockchip: Fix rk3288-rock2 vcc_flash name clk: rockchip: fix rk3188 sclk_mac_lbtest parameter ordering clk: rockchip: fix rk3188 sclk_smc gate data i40e: don't restart nway if autoneg not supported rtc: s3c-rtc: Avoid using broken ALMYEAR register net: ethernet: ti: cpts: correct debug for expired txq skb extcon: max8997: Fix lack of path setting in USB device mode dlm: fix possible call to kfree() for non-initialized pointer clk: sunxi-ng: a64: Fix gate bit of DSI DPHY net/mlx5: Release resource on error flow ARM: 8813/1: Make aligned 2-byte getuser()/putuser() atomic on ARMv6+ iwlwifi: mvm: Send non offchannel traffic via AP sta iwlwifi: mvm: synchronize TID queue removal cxgb4vf: fix memleak in mac_hlist initialization serial: core: Allow processing sysrq at port unlock time i2c: core: fix use after free in of_i2c_notify net: ep93xx_eth: fix mismatch of request_mem_region in remove rsxx: add missed destroy_workqueue calls in remove ALSA: pcm: Fix stream lock usage in snd_pcm_period_elapsed() sched/core: Avoid spurious lock dependencies Input: cyttsp4_core - fix use after free bug xfrm: release device reference for invalid state NFC: nxp-nci: Fix NULL pointer dereference after I2C communication error audit_get_nd(): don't unlock parent too early exportfs_decode_fh(): negative pinned may become positive without the parent locked iwlwifi: pcie: don't consider IV len in A-MSDU RDMA/hns: Correct the value of HNS_ROCE_HEM_CHUNK_LEN autofs: fix a leak in autofs_expire_indirect() serial: ifx6x60: add missed pm_runtime_disable serial: serial_core: Perform NULL checks for break_ctl ops serial: pl011: Fix DMA ->flush_buffer() tty: serial: msm_serial: Fix flow control tty: serial: fsl_lpuart: use the sg count from dma_map_sg usb: gadget: u_serial: add missing port entry locking arm64: tegra: Fix 'active-low' warning for Jetson TX1 regulator rsi: release skb if rsi_prepare_beacon fails ANDROID: staging: android: ion: Fix build when CONFIG_ION_SYSTEM_HEAP=n ANDROID: staging: android: ion: Expose total heap and pool sizes via sysfs UPSTREAM: include/linux/slab.h: fix sparse warning in kmalloc_type() UPSTREAM: mm, slab: shorten kmalloc cache names for large sizes UPSTREAM: mm, proc: add KReclaimable to /proc/meminfo BACKPORT: mm: rename and change semantics of nr_indirectly_reclaimable_bytes UPSTREAM: dcache: allocate external names from reclaimable kmalloc caches BACKPORT: mm, slab/slub: introduce kmalloc-reclaimable caches UPSTREAM: mm, slab: combine kmalloc_caches and kmalloc_dma_caches ANDROID: kbuild: disable SCS by default in allmodconfig ANDROID: arm64: cuttlefish_defconfig: enable LTO, CFI, and SCS BACKPORT: FROMLIST: arm64: implement Shadow Call Stack FROMLIST: arm64: disable SCS for hypervisor code BACKPORT: FROMLIST: arm64: vdso: disable Shadow Call Stack FROMLIST: arm64: preserve x18 when CPU is suspended FROMLIST: arm64: reserve x18 from general allocation with SCS FROMLIST: arm64: disable function graph tracing with SCS FROMLIST: scs: add support for stack usage debugging FROMLIST: scs: add accounting FROMLIST: add support for Clang's Shadow Call Stack (SCS) FROMLIST: arm64: kernel: avoid x18 in __cpu_soft_restart FROMLIST: arm64: kvm: stop treating register x18 as caller save FROMLIST: arm64/lib: copy_page: avoid x18 register in assembler code FROMLIST: arm64: mm: avoid x18 in idmap_kpti_install_ng_mappings ANDROID: use non-canonical CFI jump tables ANDROID: arm64: add __nocfi to __apply_alternatives ANDROID: arm64: add __pa_function ANDROID: arm64: allow ThinLTO to be selected ANDROID: soc/tegra: disable ARCH_TEGRA_210_SOC with LTO FROMLIST: arm64: fix alternatives with LLVM's integrated assembler ANDROID: irqchip/gic-v3: rename gic_of_init to work around a ThinLTO+CFI bug ANDROID: kbuild: limit LTO inlining ANDROID: kbuild: merge module sections with LTO ANDROID: init: ensure initcall ordering with LTO Revert "ANDROID: HACK: init: ensure initcall ordering with LTO" ANDROID: add support for ThinLTO ANDROID: Switch to LLD ANDROID: clang: update to 10.0.1 ANDROID: arm64: add atomic_ll_sc.o to obj-y if using lld ANDROID: enable ARM64_ERRATUM_843419 by default with LTO_CLANG ANDROID: kbuild: allow lld to be used with CONFIG_LTO_CLANG ANDROID: Makefile: set -Qunused-arguments sooner BACKPORT: FROMLIST: Makefile: lld: tell clang to use lld BACKPORT: FROMLIST: Makefile: lld: set -O2 linker flag when linking with LLD ANDROID: scripts/Kbuild: add ld-name support for ld.lld UPSTREAM: bpf: permit multiple bpf attachments for a single perf event UPSTREAM: bpf: use the same condition in perf event set/free bpf handler UPSTREAM: bpf: multi program support for cgroup+bpf BACKPORT: serdev: make synchronous write return bytes written UPSTREAM: gnss: serial: fix synchronous write timeout UPSTREAM: gnss: fix potential error pointer dereference BACKPORT: gnss: add receiver type support UPSTREAM: dt-bindings: add generic gnss binding UPSTREAM: gnss: add generic serial driver ANDROID: cuttlefish_defconfig: Enable CONFIG_SERIAL_DEV_BUS ANDROID: cuttlefish_defconfig: Enable CONFIG_GNSS BACKPORT: gnss: add GNSS receiver subsystem UPSTREAM: arm64: Validate tagged addresses in access_ok() called from kernel threads BACKPORT: ARM: 8905/1: Emit __gnu_mcount_nc when using Clang 10.0.0 or newer fs/lock: skip lock owner pid translation in case we are in init_pid_ns f2fs: stop GC when the victim becomes fully valid f2fs: expose main_blkaddr in sysfs f2fs: choose hardlimit when softlimit is larger than hardlimit in f2fs_statfs_project() f2fs: Fix deadlock in f2fs_gc() context during atomic files handling f2fs: show f2fs instance in printk_ratelimited f2fs: fix potential overflow f2fs: fix to update dir's i_pino during cross_rename f2fs: support aligned pinned file f2fs: avoid kernel panic on corruption test f2fs: fix wrong description in document f2fs: cache global IPU bio f2fs: fix to avoid memory leakage in f2fs_listxattr f2fs: check total_segments from devices in raw_super f2fs: update multi-dev metadata in resize_fs f2fs: mark recovery flag correctly in read_raw_super_block() f2fs: fix to update time in lazytime mode vfs: don't allow writes to swap files mm: set S_SWAPFILE on blockdev swap devices Conflicts: drivers/Makefile drivers/staging/android/ion/ion.c drivers/staging/android/ion/ion.h drivers/staging/android/ion/ion_page_pool.c drivers/usb/dwc3/core.c drivers/usb/dwc3/debugfs.c drivers/usb/dwc3/ep0.c fs/f2fs/data.c include/linux/mmzone.h mm/vmstat.c Discarded below patches, as usb patches not applicable and block patch causing stability issues: usb: dwc3: ep0: Clear started flag on completion usb: dwc3: don't log probe deferrals; but do log other error codes block: fix single range discard merge Fixed build errors in below files: drivers/gpu/msm/kgsl_pool.c drivers/staging/android/ion/ion_page_pool.c kernel/taskstats.c Fixed bootup issue in: arch/arm64/mm/proc.s Change-Id: I0a16824c251c14c63af78f9cfd9ede5e82c427fc Signed-off-by: Srinivasarao P <spathi@codeaurora.org> Signed-off-by: Blagovest Kolenichev <bkolenichev@codeaurora.org>
1262 lines
33 KiB
C
1262 lines
33 KiB
C
/*
|
|
* 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 <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, ...) dev_printk(level, dev, fmt, ##__VA_ARGS__)
|
|
|
|
static u8 hdmi_infoframe_checksum(u8 *ptr, size_t size)
|
|
{
|
|
u8 csum = 0;
|
|
size_t i;
|
|
|
|
/* compute checksum */
|
|
for (i = 0; i < size; i++)
|
|
csum += ptr[i];
|
|
|
|
return 256 - csum;
|
|
}
|
|
|
|
static void hdmi_infoframe_set_checksum(void *buffer, size_t size)
|
|
{
|
|
u8 *ptr = buffer;
|
|
|
|
ptr[3] = hdmi_infoframe_checksum(buffer, size);
|
|
}
|
|
|
|
/**
|
|
* hdmi_avi_infoframe_init() - initialize an HDMI AVI infoframe
|
|
* @frame: HDMI AVI infoframe
|
|
*
|
|
* Returns 0 on success or a negative error code on failure.
|
|
*/
|
|
int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame)
|
|
{
|
|
memset(frame, 0, sizeof(*frame));
|
|
|
|
frame->type = HDMI_INFOFRAME_TYPE_AVI;
|
|
frame->version = 2;
|
|
frame->length = HDMI_AVI_INFOFRAME_SIZE;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_avi_infoframe_init);
|
|
|
|
/**
|
|
* hdmi_avi_infoframe_pack() - 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(struct hdmi_avi_infoframe *frame, void *buffer,
|
|
size_t size)
|
|
{
|
|
u8 *ptr = buffer;
|
|
size_t length;
|
|
|
|
length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
|
|
|
|
if (size < length)
|
|
return -ENOSPC;
|
|
|
|
memset(buffer, 0, size);
|
|
|
|
ptr[0] = frame->type;
|
|
ptr[1] = frame->version;
|
|
ptr[2] = frame->length;
|
|
ptr[3] = 0; /* checksum */
|
|
|
|
/* start infoframe payload */
|
|
ptr += HDMI_INFOFRAME_HEADER_SIZE;
|
|
|
|
ptr[0] = ((frame->colorspace & 0x3) << 5) | (frame->scan_mode & 0x3);
|
|
|
|
/*
|
|
* Data byte 1, bit 4 has to be set if we provide the active format
|
|
* aspect ratio
|
|
*/
|
|
if (frame->active_aspect & 0xf)
|
|
ptr[0] |= BIT(4);
|
|
|
|
/* Bit 3 and 2 indicate if we transmit horizontal/vertical bar data */
|
|
if (frame->top_bar || frame->bottom_bar)
|
|
ptr[0] |= BIT(3);
|
|
|
|
if (frame->left_bar || frame->right_bar)
|
|
ptr[0] |= BIT(2);
|
|
|
|
ptr[1] = ((frame->colorimetry & 0x3) << 6) |
|
|
((frame->picture_aspect & 0x3) << 4) |
|
|
(frame->active_aspect & 0xf);
|
|
|
|
ptr[2] = ((frame->extended_colorimetry & 0x7) << 4) |
|
|
((frame->quantization_range & 0x3) << 2) |
|
|
(frame->nups & 0x3);
|
|
|
|
if (frame->itc)
|
|
ptr[2] |= BIT(7);
|
|
|
|
ptr[3] = frame->video_code & 0x7f;
|
|
|
|
ptr[4] = ((frame->ycc_quantization_range & 0x3) << 6) |
|
|
((frame->content_type & 0x3) << 4) |
|
|
(frame->pixel_repeat & 0xf);
|
|
|
|
ptr[5] = frame->top_bar & 0xff;
|
|
ptr[6] = (frame->top_bar >> 8) & 0xff;
|
|
ptr[7] = frame->bottom_bar & 0xff;
|
|
ptr[8] = (frame->bottom_bar >> 8) & 0xff;
|
|
ptr[9] = frame->left_bar & 0xff;
|
|
ptr[10] = (frame->left_bar >> 8) & 0xff;
|
|
ptr[11] = frame->right_bar & 0xff;
|
|
ptr[12] = (frame->right_bar >> 8) & 0xff;
|
|
|
|
hdmi_infoframe_set_checksum(buffer, length);
|
|
|
|
return length;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_avi_infoframe_pack);
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
memset(frame, 0, sizeof(*frame));
|
|
|
|
frame->type = HDMI_INFOFRAME_TYPE_SPD;
|
|
frame->version = 1;
|
|
frame->length = HDMI_SPD_INFOFRAME_SIZE;
|
|
|
|
strncpy(frame->vendor, vendor, sizeof(frame->vendor));
|
|
strncpy(frame->product, product, sizeof(frame->product));
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_spd_infoframe_init);
|
|
|
|
/**
|
|
* hdmi_spd_infoframe_pack() - 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(struct hdmi_spd_infoframe *frame, void *buffer,
|
|
size_t size)
|
|
{
|
|
u8 *ptr = buffer;
|
|
size_t length;
|
|
|
|
length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
|
|
|
|
if (size < length)
|
|
return -ENOSPC;
|
|
|
|
memset(buffer, 0, size);
|
|
|
|
ptr[0] = frame->type;
|
|
ptr[1] = frame->version;
|
|
ptr[2] = frame->length;
|
|
ptr[3] = 0; /* checksum */
|
|
|
|
/* start infoframe payload */
|
|
ptr += HDMI_INFOFRAME_HEADER_SIZE;
|
|
|
|
memcpy(ptr, frame->vendor, sizeof(frame->vendor));
|
|
memcpy(ptr + 8, frame->product, sizeof(frame->product));
|
|
|
|
ptr[24] = frame->sdi;
|
|
|
|
hdmi_infoframe_set_checksum(buffer, length);
|
|
|
|
return length;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_spd_infoframe_pack);
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
memset(frame, 0, sizeof(*frame));
|
|
|
|
frame->type = HDMI_INFOFRAME_TYPE_AUDIO;
|
|
frame->version = 1;
|
|
frame->length = HDMI_AUDIO_INFOFRAME_SIZE;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_audio_infoframe_init);
|
|
|
|
/**
|
|
* hdmi_audio_infoframe_pack() - 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(struct hdmi_audio_infoframe *frame,
|
|
void *buffer, size_t size)
|
|
{
|
|
unsigned char channels;
|
|
u8 *ptr = buffer;
|
|
size_t length;
|
|
|
|
length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
|
|
|
|
if (size < length)
|
|
return -ENOSPC;
|
|
|
|
memset(buffer, 0, size);
|
|
|
|
if (frame->channels >= 2)
|
|
channels = frame->channels - 1;
|
|
else
|
|
channels = 0;
|
|
|
|
ptr[0] = frame->type;
|
|
ptr[1] = frame->version;
|
|
ptr[2] = frame->length;
|
|
ptr[3] = 0; /* checksum */
|
|
|
|
/* start infoframe payload */
|
|
ptr += HDMI_INFOFRAME_HEADER_SIZE;
|
|
|
|
ptr[0] = ((frame->coding_type & 0xf) << 4) | (channels & 0x7);
|
|
ptr[1] = ((frame->sample_frequency & 0x7) << 2) |
|
|
(frame->sample_size & 0x3);
|
|
ptr[2] = frame->coding_type_ext & 0x1f;
|
|
ptr[3] = frame->channel_allocation;
|
|
ptr[4] = (frame->level_shift_value & 0xf) << 3;
|
|
|
|
if (frame->downmix_inhibit)
|
|
ptr[4] |= BIT(7);
|
|
|
|
hdmi_infoframe_set_checksum(buffer, length);
|
|
|
|
return length;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_audio_infoframe_pack);
|
|
|
|
/**
|
|
* 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)
|
|
{
|
|
memset(frame, 0, sizeof(*frame));
|
|
|
|
frame->type = HDMI_INFOFRAME_TYPE_VENDOR;
|
|
frame->version = 1;
|
|
|
|
frame->oui = HDMI_IEEE_OUI;
|
|
|
|
/*
|
|
* 0 is a valid value for s3d_struct, so we use a special "not set"
|
|
* value
|
|
*/
|
|
frame->s3d_struct = HDMI_3D_STRUCTURE_INVALID;
|
|
|
|
return 0;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_vendor_infoframe_init);
|
|
|
|
static int hdmi_vendor_infoframe_length(const struct 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;
|
|
else if (frame->vic != 0 || frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
|
|
return 5;
|
|
else
|
|
return 4;
|
|
}
|
|
|
|
/**
|
|
* hdmi_vendor_infoframe_pack() - 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(struct hdmi_vendor_infoframe *frame,
|
|
void *buffer, size_t size)
|
|
{
|
|
u8 *ptr = buffer;
|
|
size_t length;
|
|
|
|
/* only one of those can be supplied */
|
|
if (frame->vic != 0 && frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID)
|
|
return -EINVAL;
|
|
|
|
frame->length = hdmi_vendor_infoframe_length(frame);
|
|
|
|
length = HDMI_INFOFRAME_HEADER_SIZE + frame->length;
|
|
|
|
if (size < length)
|
|
return -ENOSPC;
|
|
|
|
memset(buffer, 0, size);
|
|
|
|
ptr[0] = frame->type;
|
|
ptr[1] = frame->version;
|
|
ptr[2] = frame->length;
|
|
ptr[3] = 0; /* checksum */
|
|
|
|
/* HDMI OUI */
|
|
ptr[4] = 0x03;
|
|
ptr[5] = 0x0c;
|
|
ptr[6] = 0x00;
|
|
|
|
if (frame->s3d_struct != HDMI_3D_STRUCTURE_INVALID) {
|
|
ptr[7] = 0x2 << 5; /* video format */
|
|
ptr[8] = (frame->s3d_struct & 0xf) << 4;
|
|
if (frame->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF)
|
|
ptr[9] = (frame->s3d_ext_data & 0xf) << 4;
|
|
} else if (frame->vic) {
|
|
ptr[7] = 0x1 << 5; /* video format */
|
|
ptr[8] = frame->vic;
|
|
} else {
|
|
ptr[7] = 0x0 << 5; /* video format */
|
|
}
|
|
|
|
hdmi_infoframe_set_checksum(buffer, length);
|
|
|
|
return length;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_vendor_infoframe_pack);
|
|
|
|
/*
|
|
* hdmi_vendor_any_infoframe_pack() - write a vendor infoframe to binary buffer
|
|
*/
|
|
static ssize_t
|
|
hdmi_vendor_any_infoframe_pack(union hdmi_vendor_any_infoframe *frame,
|
|
void *buffer, size_t size)
|
|
{
|
|
/* we only know about HDMI vendor infoframes */
|
|
if (frame->any.oui != HDMI_IEEE_OUI)
|
|
return -EINVAL;
|
|
|
|
return hdmi_vendor_infoframe_pack(&frame->hdmi, buffer, size);
|
|
}
|
|
|
|
/**
|
|
* hdmi_infoframe_pack() - 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(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_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;
|
|
}
|
|
|
|
return length;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_infoframe_pack);
|
|
|
|
static const char *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";
|
|
}
|
|
return "Reserved";
|
|
}
|
|
|
|
static void hdmi_infoframe_log_header(const char *level,
|
|
struct device *dev,
|
|
struct hdmi_any_infoframe *frame)
|
|
{
|
|
hdmi_log("HDMI infoframe: %s, version %u, length %u\n",
|
|
hdmi_infoframe_type_get_name(frame->type),
|
|
frame->version, frame->length);
|
|
}
|
|
|
|
static const char *hdmi_colorspace_get_name(enum hdmi_colorspace colorspace)
|
|
{
|
|
switch (colorspace) {
|
|
case HDMI_COLORSPACE_RGB:
|
|
return "RGB";
|
|
case HDMI_COLORSPACE_YUV422:
|
|
return "YCbCr 4:2:2";
|
|
case HDMI_COLORSPACE_YUV444:
|
|
return "YCbCr 4:4:4";
|
|
case HDMI_COLORSPACE_YUV420:
|
|
return "YCbCr 4:2:0";
|
|
case HDMI_COLORSPACE_RESERVED4:
|
|
return "Reserved (4)";
|
|
case HDMI_COLORSPACE_RESERVED5:
|
|
return "Reserved (5)";
|
|
case HDMI_COLORSPACE_RESERVED6:
|
|
return "Reserved (6)";
|
|
case HDMI_COLORSPACE_IDO_DEFINED:
|
|
return "IDO Defined";
|
|
}
|
|
return "Invalid";
|
|
}
|
|
|
|
static const char *hdmi_scan_mode_get_name(enum hdmi_scan_mode scan_mode)
|
|
{
|
|
switch (scan_mode) {
|
|
case HDMI_SCAN_MODE_NONE:
|
|
return "No Data";
|
|
case HDMI_SCAN_MODE_OVERSCAN:
|
|
return "Overscan";
|
|
case HDMI_SCAN_MODE_UNDERSCAN:
|
|
return "Underscan";
|
|
case HDMI_SCAN_MODE_RESERVED:
|
|
return "Reserved";
|
|
}
|
|
return "Invalid";
|
|
}
|
|
|
|
static const char *hdmi_colorimetry_get_name(enum hdmi_colorimetry colorimetry)
|
|
{
|
|
switch (colorimetry) {
|
|
case HDMI_COLORIMETRY_NONE:
|
|
return "No Data";
|
|
case HDMI_COLORIMETRY_ITU_601:
|
|
return "ITU601";
|
|
case HDMI_COLORIMETRY_ITU_709:
|
|
return "ITU709";
|
|
case HDMI_COLORIMETRY_EXTENDED:
|
|
return "Extended";
|
|
}
|
|
return "Invalid";
|
|
}
|
|
|
|
static const char *
|
|
hdmi_picture_aspect_get_name(enum hdmi_picture_aspect picture_aspect)
|
|
{
|
|
switch (picture_aspect) {
|
|
case HDMI_PICTURE_ASPECT_NONE:
|
|
return "No Data";
|
|
case HDMI_PICTURE_ASPECT_4_3:
|
|
return "4:3";
|
|
case HDMI_PICTURE_ASPECT_16_9:
|
|
return "16:9";
|
|
case HDMI_PICTURE_ASPECT_64_27:
|
|
return "64:27";
|
|
case HDMI_PICTURE_ASPECT_256_135:
|
|
return "256:135";
|
|
case HDMI_PICTURE_ASPECT_RESERVED:
|
|
return "Reserved";
|
|
}
|
|
return "Invalid";
|
|
}
|
|
|
|
static const char *
|
|
hdmi_active_aspect_get_name(enum hdmi_active_aspect active_aspect)
|
|
{
|
|
if (active_aspect < 0 || active_aspect > 0xf)
|
|
return "Invalid";
|
|
|
|
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";
|
|
}
|
|
|
|
static const char *
|
|
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_ADOBE_YCC_601:
|
|
return "Adobe YCC 601";
|
|
case HDMI_EXTENDED_COLORIMETRY_ADOBE_RGB:
|
|
return "Adobe RGB";
|
|
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";
|
|
}
|
|
|
|
static const char *
|
|
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";
|
|
}
|
|
|
|
static const char *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";
|
|
}
|
|
|
|
static const char *
|
|
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";
|
|
}
|
|
|
|
static const char *
|
|
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";
|
|
}
|
|
|
|
/**
|
|
* hdmi_avi_infoframe_log() - log info of HDMI AVI infoframe
|
|
* @level: logging level
|
|
* @dev: device
|
|
* @frame: HDMI AVI infoframe
|
|
*/
|
|
static void hdmi_avi_infoframe_log(const char *level,
|
|
struct device *dev,
|
|
struct hdmi_avi_infoframe *frame)
|
|
{
|
|
hdmi_infoframe_log_header(level, dev,
|
|
(struct hdmi_any_infoframe *)frame);
|
|
|
|
hdmi_log(" colorspace: %s\n",
|
|
hdmi_colorspace_get_name(frame->colorspace));
|
|
hdmi_log(" scan mode: %s\n",
|
|
hdmi_scan_mode_get_name(frame->scan_mode));
|
|
hdmi_log(" colorimetry: %s\n",
|
|
hdmi_colorimetry_get_name(frame->colorimetry));
|
|
hdmi_log(" picture aspect: %s\n",
|
|
hdmi_picture_aspect_get_name(frame->picture_aspect));
|
|
hdmi_log(" active aspect: %s\n",
|
|
hdmi_active_aspect_get_name(frame->active_aspect));
|
|
hdmi_log(" itc: %s\n", frame->itc ? "IT Content" : "No Data");
|
|
hdmi_log(" extended colorimetry: %s\n",
|
|
hdmi_extended_colorimetry_get_name(frame->extended_colorimetry));
|
|
hdmi_log(" quantization range: %s\n",
|
|
hdmi_quantization_range_get_name(frame->quantization_range));
|
|
hdmi_log(" nups: %s\n", hdmi_nups_get_name(frame->nups));
|
|
hdmi_log(" video code: %u\n", frame->video_code);
|
|
hdmi_log(" ycc quantization range: %s\n",
|
|
hdmi_ycc_quantization_range_get_name(frame->ycc_quantization_range));
|
|
hdmi_log(" hdmi content type: %s\n",
|
|
hdmi_content_type_get_name(frame->content_type));
|
|
hdmi_log(" pixel repeat: %u\n", frame->pixel_repeat);
|
|
hdmi_log(" bar top %u, bottom %u, left %u, right %u\n",
|
|
frame->top_bar, frame->bottom_bar,
|
|
frame->left_bar, frame->right_bar);
|
|
}
|
|
|
|
static const char *hdmi_spd_sdi_get_name(enum hdmi_spd_sdi sdi)
|
|
{
|
|
if (sdi < 0 || sdi > HDMI_SPD_SDI_MAX)
|
|
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";
|
|
default:
|
|
return "Reserved";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* hdmi_spd_infoframe_log() - log info of HDMI SPD infoframe
|
|
* @level: logging level
|
|
* @dev: device
|
|
* @frame: HDMI SPD infoframe
|
|
*/
|
|
static void hdmi_spd_infoframe_log(const char *level,
|
|
struct device *dev,
|
|
struct hdmi_spd_infoframe *frame)
|
|
{
|
|
u8 buf[17];
|
|
|
|
hdmi_infoframe_log_header(level, dev,
|
|
(struct hdmi_any_infoframe *)frame);
|
|
|
|
memset(buf, 0, sizeof(buf));
|
|
|
|
strncpy(buf, frame->vendor, 8);
|
|
hdmi_log(" vendor: %s\n", buf);
|
|
strncpy(buf, frame->product, 16);
|
|
hdmi_log(" product: %s\n", buf);
|
|
hdmi_log(" source device information: %s (0x%x)\n",
|
|
hdmi_spd_sdi_get_name(frame->sdi), frame->sdi);
|
|
}
|
|
|
|
static const char *
|
|
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";
|
|
}
|
|
|
|
static const char *
|
|
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";
|
|
}
|
|
|
|
static const char *
|
|
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";
|
|
}
|
|
|
|
static const char *
|
|
hdmi_audio_coding_type_ext_get_name(enum hdmi_audio_coding_type_ext ctx)
|
|
{
|
|
if (ctx < 0 || ctx > HDMI_AUDIO_CODING_TYPE_EXT_MAX)
|
|
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";
|
|
default:
|
|
return "Reserved";
|
|
}
|
|
}
|
|
|
|
/**
|
|
* hdmi_audio_infoframe_log() - log info of HDMI AUDIO infoframe
|
|
* @level: logging level
|
|
* @dev: device
|
|
* @frame: HDMI AUDIO infoframe
|
|
*/
|
|
static void hdmi_audio_infoframe_log(const char *level,
|
|
struct device *dev,
|
|
struct hdmi_audio_infoframe *frame)
|
|
{
|
|
hdmi_infoframe_log_header(level, dev,
|
|
(struct hdmi_any_infoframe *)frame);
|
|
|
|
if (frame->channels)
|
|
hdmi_log(" channels: %u\n", frame->channels - 1);
|
|
else
|
|
hdmi_log(" channels: Refer to stream header\n");
|
|
hdmi_log(" coding type: %s\n",
|
|
hdmi_audio_coding_type_get_name(frame->coding_type));
|
|
hdmi_log(" sample size: %s\n",
|
|
hdmi_audio_sample_size_get_name(frame->sample_size));
|
|
hdmi_log(" sample frequency: %s\n",
|
|
hdmi_audio_sample_frequency_get_name(frame->sample_frequency));
|
|
hdmi_log(" coding type ext: %s\n",
|
|
hdmi_audio_coding_type_ext_get_name(frame->coding_type_ext));
|
|
hdmi_log(" channel allocation: 0x%x\n",
|
|
frame->channel_allocation);
|
|
hdmi_log(" level shift value: %u dB\n",
|
|
frame->level_shift_value);
|
|
hdmi_log(" downmix inhibit: %s\n",
|
|
frame->downmix_inhibit ? "Yes" : "No");
|
|
}
|
|
|
|
static const char *
|
|
hdmi_3d_structure_get_name(enum hdmi_3d_structure s3d_struct)
|
|
{
|
|
if (s3d_struct < 0 || s3d_struct > 0xf)
|
|
return "Invalid";
|
|
|
|
switch (s3d_struct) {
|
|
case HDMI_3D_STRUCTURE_FRAME_PACKING:
|
|
return "Frame Packing";
|
|
case HDMI_3D_STRUCTURE_FIELD_ALTERNATIVE:
|
|
return "Field Alternative";
|
|
case HDMI_3D_STRUCTURE_LINE_ALTERNATIVE:
|
|
return "Line Alternative";
|
|
case HDMI_3D_STRUCTURE_SIDE_BY_SIDE_FULL:
|
|
return "Side-by-side (Full)";
|
|
case HDMI_3D_STRUCTURE_L_DEPTH:
|
|
return "L + Depth";
|
|
case HDMI_3D_STRUCTURE_L_DEPTH_GFX_GFX_DEPTH:
|
|
return "L + Depth + Graphics + Graphics-depth";
|
|
case HDMI_3D_STRUCTURE_TOP_AND_BOTTOM:
|
|
return "Top-and-Bottom";
|
|
case HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF:
|
|
return "Side-by-side (Half)";
|
|
default:
|
|
break;
|
|
}
|
|
return "Reserved";
|
|
}
|
|
|
|
/**
|
|
* hdmi_vendor_infoframe_log() - log info of HDMI VENDOR infoframe
|
|
* @level: logging level
|
|
* @dev: device
|
|
* @frame: HDMI VENDOR infoframe
|
|
*/
|
|
static void
|
|
hdmi_vendor_any_infoframe_log(const char *level,
|
|
struct device *dev,
|
|
union hdmi_vendor_any_infoframe *frame)
|
|
{
|
|
struct hdmi_vendor_infoframe *hvf = &frame->hdmi;
|
|
|
|
hdmi_infoframe_log_header(level, dev,
|
|
(struct hdmi_any_infoframe *)frame);
|
|
|
|
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(const char *level,
|
|
struct device *dev,
|
|
union 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;
|
|
}
|
|
}
|
|
EXPORT_SYMBOL(hdmi_infoframe_log);
|
|
|
|
/**
|
|
* hdmi_avi_infoframe_unpack() - unpack binary buffer to a HDMI AVI infoframe
|
|
* @buffer: source buffer
|
|
* @frame: HDMI AVI infoframe
|
|
*
|
|
* 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,
|
|
void *buffer)
|
|
{
|
|
u8 *ptr = buffer;
|
|
int ret;
|
|
|
|
if (ptr[0] != HDMI_INFOFRAME_TYPE_AVI ||
|
|
ptr[1] != 2 ||
|
|
ptr[2] != HDMI_AVI_INFOFRAME_SIZE)
|
|
return -EINVAL;
|
|
|
|
if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(AVI)) != 0)
|
|
return -EINVAL;
|
|
|
|
ret = hdmi_avi_infoframe_init(frame);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ptr += HDMI_INFOFRAME_HEADER_SIZE;
|
|
|
|
frame->colorspace = (ptr[0] >> 5) & 0x3;
|
|
if (ptr[0] & 0x10)
|
|
frame->active_aspect = ptr[1] & 0xf;
|
|
if (ptr[0] & 0x8) {
|
|
frame->top_bar = (ptr[6] << 8) | ptr[5];
|
|
frame->bottom_bar = (ptr[8] << 8) | ptr[7];
|
|
}
|
|
if (ptr[0] & 0x4) {
|
|
frame->left_bar = (ptr[10] << 8) | ptr[9];
|
|
frame->right_bar = (ptr[12] << 8) | ptr[11];
|
|
}
|
|
frame->scan_mode = ptr[0] & 0x3;
|
|
|
|
frame->colorimetry = (ptr[1] >> 6) & 0x3;
|
|
frame->picture_aspect = (ptr[1] >> 4) & 0x3;
|
|
frame->active_aspect = ptr[1] & 0xf;
|
|
|
|
frame->itc = ptr[2] & 0x80 ? true : false;
|
|
frame->extended_colorimetry = (ptr[2] >> 4) & 0x7;
|
|
frame->quantization_range = (ptr[2] >> 2) & 0x3;
|
|
frame->nups = ptr[2] & 0x3;
|
|
|
|
frame->video_code = ptr[3] & 0x7f;
|
|
frame->ycc_quantization_range = (ptr[4] >> 6) & 0x3;
|
|
frame->content_type = (ptr[4] >> 4) & 0x3;
|
|
|
|
frame->pixel_repeat = ptr[4] & 0xf;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* hdmi_spd_infoframe_unpack() - unpack binary buffer to a HDMI SPD infoframe
|
|
* @buffer: source buffer
|
|
* @frame: HDMI SPD infoframe
|
|
*
|
|
* 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,
|
|
void *buffer)
|
|
{
|
|
u8 *ptr = buffer;
|
|
int ret;
|
|
|
|
if (ptr[0] != HDMI_INFOFRAME_TYPE_SPD ||
|
|
ptr[1] != 1 ||
|
|
ptr[2] != HDMI_SPD_INFOFRAME_SIZE) {
|
|
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
|
|
* @buffer: source buffer
|
|
* @frame: HDMI Audio infoframe
|
|
*
|
|
* 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,
|
|
void *buffer)
|
|
{
|
|
u8 *ptr = buffer;
|
|
int ret;
|
|
|
|
if (ptr[0] != HDMI_INFOFRAME_TYPE_AUDIO ||
|
|
ptr[1] != 1 ||
|
|
ptr[2] != HDMI_AUDIO_INFOFRAME_SIZE) {
|
|
return -EINVAL;
|
|
}
|
|
|
|
if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(AUDIO)) != 0)
|
|
return -EINVAL;
|
|
|
|
ret = hdmi_audio_infoframe_init(frame);
|
|
if (ret)
|
|
return ret;
|
|
|
|
ptr += HDMI_INFOFRAME_HEADER_SIZE;
|
|
|
|
frame->channels = ptr[0] & 0x7;
|
|
frame->coding_type = (ptr[0] >> 4) & 0xf;
|
|
frame->sample_size = ptr[1] & 0x3;
|
|
frame->sample_frequency = (ptr[1] >> 2) & 0x7;
|
|
frame->coding_type_ext = ptr[2] & 0x1f;
|
|
frame->channel_allocation = ptr[3];
|
|
frame->level_shift_value = (ptr[4] >> 3) & 0xf;
|
|
frame->downmix_inhibit = ptr[4] & 0x80 ? true : false;
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* hdmi_vendor_infoframe_unpack() - unpack binary buffer to a HDMI vendor infoframe
|
|
* @buffer: source buffer
|
|
* @frame: HDMI Vendor infoframe
|
|
*
|
|
* 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,
|
|
void *buffer)
|
|
{
|
|
u8 *ptr = buffer;
|
|
size_t length;
|
|
int ret;
|
|
u8 hdmi_video_format;
|
|
struct hdmi_vendor_infoframe *hvf = &frame->hdmi;
|
|
|
|
if (ptr[0] != HDMI_INFOFRAME_TYPE_VENDOR ||
|
|
ptr[1] != 1 ||
|
|
(ptr[2] != 4 && ptr[2] != 5 && ptr[2] != 6))
|
|
return -EINVAL;
|
|
|
|
length = ptr[2];
|
|
|
|
if (hdmi_infoframe_checksum(buffer,
|
|
HDMI_INFOFRAME_HEADER_SIZE + length) != 0)
|
|
return -EINVAL;
|
|
|
|
ptr += HDMI_INFOFRAME_HEADER_SIZE;
|
|
|
|
/* HDMI OUI */
|
|
if ((ptr[0] != 0x03) ||
|
|
(ptr[1] != 0x0c) ||
|
|
(ptr[2] != 0x00))
|
|
return -EINVAL;
|
|
|
|
hdmi_video_format = ptr[3] >> 5;
|
|
|
|
if (hdmi_video_format > 0x2)
|
|
return -EINVAL;
|
|
|
|
ret = hdmi_vendor_infoframe_init(hvf);
|
|
if (ret)
|
|
return ret;
|
|
|
|
hvf->length = length;
|
|
|
|
if (hdmi_video_format == 0x2) {
|
|
if (length != 5 && length != 6)
|
|
return -EINVAL;
|
|
hvf->s3d_struct = ptr[4] >> 4;
|
|
if (hvf->s3d_struct >= HDMI_3D_STRUCTURE_SIDE_BY_SIDE_HALF) {
|
|
if (length != 6)
|
|
return -EINVAL;
|
|
hvf->s3d_ext_data = ptr[5] >> 4;
|
|
}
|
|
} else if (hdmi_video_format == 0x1) {
|
|
if (length != 5)
|
|
return -EINVAL;
|
|
hvf->vic = ptr[4];
|
|
} else {
|
|
if (length != 4)
|
|
return -EINVAL;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|
|
/**
|
|
* hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe
|
|
* @buffer: source buffer
|
|
* @frame: HDMI infoframe
|
|
*
|
|
* 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, void *buffer)
|
|
{
|
|
int ret;
|
|
u8 *ptr = buffer;
|
|
|
|
switch (ptr[0]) {
|
|
case HDMI_INFOFRAME_TYPE_AVI:
|
|
ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer);
|
|
break;
|
|
case HDMI_INFOFRAME_TYPE_SPD:
|
|
ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer);
|
|
break;
|
|
case HDMI_INFOFRAME_TYPE_AUDIO:
|
|
ret = hdmi_audio_infoframe_unpack(&frame->audio, buffer);
|
|
break;
|
|
case HDMI_INFOFRAME_TYPE_VENDOR:
|
|
ret = hdmi_vendor_any_infoframe_unpack(&frame->vendor, buffer);
|
|
break;
|
|
default:
|
|
ret = -EINVAL;
|
|
break;
|
|
}
|
|
|
|
return ret;
|
|
}
|
|
EXPORT_SYMBOL(hdmi_infoframe_unpack);
|