diff options
author | Uma Shankar <uma.shankar@intel.com> | 2019-05-16 10:10:16 -0400 |
---|---|---|
committer | Ville Syrjälä <ville.syrjala@linux.intel.com> | 2019-05-22 15:46:35 -0400 |
commit | 270afb37ae34fc1499d166f6edf4bc472f529d96 (patch) | |
tree | e9dfeac489f2704bb5a2ae43a5555befb2b86fb1 /drivers | |
parent | b5e3eed1eeb363c148e2935d9d3c12c30a280de6 (diff) |
video/hdmi: Add Unpack function for DRM infoframe
Added unpack function for DRM infoframe for dynamic
range and mastering infoframe readout.
v2: Addressed Ville's review comments.
Suggested-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Signed-off-by: Uma Shankar <uma.shankar@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/1558015817-12025-12-git-send-email-uma.shankar@intel.com
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/video/hdmi.c | 67 |
1 files changed, 67 insertions, 0 deletions
diff --git a/drivers/video/hdmi.c b/drivers/video/hdmi.c index 481f0367dfd3..b99ba01dfed5 100644 --- a/drivers/video/hdmi.c +++ b/drivers/video/hdmi.c | |||
@@ -1805,6 +1805,70 @@ hdmi_vendor_any_infoframe_unpack(union hdmi_vendor_any_infoframe *frame, | |||
1805 | } | 1805 | } |
1806 | 1806 | ||
1807 | /** | 1807 | /** |
1808 | * hdmi_drm_infoframe_unpack() - unpack binary buffer to a HDMI DRM infoframe | ||
1809 | * @frame: HDMI DRM infoframe | ||
1810 | * @buffer: source buffer | ||
1811 | * @size: size of buffer | ||
1812 | * | ||
1813 | * Unpacks the information contained in binary @buffer into a structured | ||
1814 | * @frame of the HDMI Dynamic Range and Mastering (DRM) information frame. | ||
1815 | * Also verifies the checksum as required by section 5.3.5 of the HDMI 1.4 | ||
1816 | * specification. | ||
1817 | * | ||
1818 | * Returns 0 on success or a negative error code on failure. | ||
1819 | */ | ||
1820 | static int hdmi_drm_infoframe_unpack(struct hdmi_drm_infoframe *frame, | ||
1821 | const void *buffer, size_t size) | ||
1822 | { | ||
1823 | const u8 *ptr = buffer; | ||
1824 | const u8 *temp; | ||
1825 | u8 x_lsb, x_msb; | ||
1826 | u8 y_lsb, y_msb; | ||
1827 | int ret; | ||
1828 | int i; | ||
1829 | |||
1830 | if (size < HDMI_INFOFRAME_SIZE(DRM)) | ||
1831 | return -EINVAL; | ||
1832 | |||
1833 | if (ptr[0] != HDMI_INFOFRAME_TYPE_DRM || | ||
1834 | ptr[1] != 1 || | ||
1835 | ptr[2] != HDMI_DRM_INFOFRAME_SIZE) | ||
1836 | return -EINVAL; | ||
1837 | |||
1838 | if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(DRM)) != 0) | ||
1839 | return -EINVAL; | ||
1840 | |||
1841 | ret = hdmi_drm_infoframe_init(frame); | ||
1842 | if (ret) | ||
1843 | return ret; | ||
1844 | |||
1845 | ptr += HDMI_INFOFRAME_HEADER_SIZE; | ||
1846 | |||
1847 | frame->eotf = ptr[0] & 0x7; | ||
1848 | frame->metadata_type = ptr[1] & 0x7; | ||
1849 | |||
1850 | temp = ptr + 2; | ||
1851 | for (i = 0; i < 3; i++) { | ||
1852 | x_lsb = *temp++; | ||
1853 | x_msb = *temp++; | ||
1854 | frame->display_primaries[i].x = (x_msb << 8) | x_lsb; | ||
1855 | y_lsb = *temp++; | ||
1856 | y_msb = *temp++; | ||
1857 | frame->display_primaries[i].y = (y_msb << 8) | y_lsb; | ||
1858 | } | ||
1859 | |||
1860 | frame->white_point.x = (ptr[15] << 8) | ptr[14]; | ||
1861 | frame->white_point.y = (ptr[17] << 8) | ptr[16]; | ||
1862 | |||
1863 | frame->max_display_mastering_luminance = (ptr[19] << 8) | ptr[18]; | ||
1864 | frame->min_display_mastering_luminance = (ptr[21] << 8) | ptr[20]; | ||
1865 | frame->max_cll = (ptr[23] << 8) | ptr[22]; | ||
1866 | frame->max_fall = (ptr[25] << 8) | ptr[24]; | ||
1867 | |||
1868 | return 0; | ||
1869 | } | ||
1870 | |||
1871 | /** | ||
1808 | * hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe | 1872 | * hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe |
1809 | * @frame: HDMI infoframe | 1873 | * @frame: HDMI infoframe |
1810 | * @buffer: source buffer | 1874 | * @buffer: source buffer |
@@ -1830,6 +1894,9 @@ int hdmi_infoframe_unpack(union hdmi_infoframe *frame, | |||
1830 | case HDMI_INFOFRAME_TYPE_AVI: | 1894 | case HDMI_INFOFRAME_TYPE_AVI: |
1831 | ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer, size); | 1895 | ret = hdmi_avi_infoframe_unpack(&frame->avi, buffer, size); |
1832 | break; | 1896 | break; |
1897 | case HDMI_INFOFRAME_TYPE_DRM: | ||
1898 | ret = hdmi_drm_infoframe_unpack(&frame->drm, buffer, size); | ||
1899 | break; | ||
1833 | case HDMI_INFOFRAME_TYPE_SPD: | 1900 | case HDMI_INFOFRAME_TYPE_SPD: |
1834 | ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer, size); | 1901 | ret = hdmi_spd_infoframe_unpack(&frame->spd, buffer, size); |
1835 | break; | 1902 | break; |