.. | .. |
---|
53 | 53 | /** |
---|
54 | 54 | * hdmi_avi_infoframe_init() - initialize an HDMI AVI infoframe |
---|
55 | 55 | * @frame: HDMI AVI infoframe |
---|
56 | | - * |
---|
57 | | - * Returns 0 on success or a negative error code on failure. |
---|
58 | 56 | */ |
---|
59 | | -int hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame) |
---|
| 57 | +void hdmi_avi_infoframe_init(struct hdmi_avi_infoframe *frame) |
---|
60 | 58 | { |
---|
61 | 59 | memset(frame, 0, sizeof(*frame)); |
---|
62 | 60 | |
---|
63 | 61 | frame->type = HDMI_INFOFRAME_TYPE_AVI; |
---|
64 | 62 | frame->version = 2; |
---|
65 | 63 | frame->length = HDMI_AVI_INFOFRAME_SIZE; |
---|
66 | | - |
---|
67 | | - return 0; |
---|
68 | 64 | } |
---|
69 | 65 | EXPORT_SYMBOL(hdmi_avi_infoframe_init); |
---|
70 | 66 | |
---|
.. | .. |
---|
499 | 495 | * value |
---|
500 | 496 | */ |
---|
501 | 497 | frame->s3d_struct = HDMI_3D_STRUCTURE_INVALID; |
---|
502 | | - frame->length = 4; |
---|
| 498 | + frame->length = HDMI_VENDOR_INFOFRAME_SIZE; |
---|
503 | 499 | |
---|
504 | 500 | return 0; |
---|
505 | 501 | } |
---|
.. | .. |
---|
997 | 993 | |
---|
998 | 994 | static void hdmi_infoframe_log_header(const char *level, |
---|
999 | 995 | struct device *dev, |
---|
1000 | | - struct hdmi_any_infoframe *frame) |
---|
| 996 | + const struct hdmi_any_infoframe *frame) |
---|
1001 | 997 | { |
---|
1002 | 998 | hdmi_log("HDMI infoframe: %s, version %u, length %u\n", |
---|
1003 | 999 | hdmi_infoframe_type_get_name(frame->type), |
---|
.. | .. |
---|
1191 | 1187 | return "Invalid"; |
---|
1192 | 1188 | } |
---|
1193 | 1189 | |
---|
1194 | | -/** |
---|
1195 | | - * hdmi_avi_infoframe_log() - log info of HDMI AVI infoframe |
---|
1196 | | - * @level: logging level |
---|
1197 | | - * @dev: device |
---|
1198 | | - * @frame: HDMI AVI infoframe |
---|
1199 | | - */ |
---|
1200 | 1190 | static void hdmi_avi_infoframe_log(const char *level, |
---|
1201 | 1191 | struct device *dev, |
---|
1202 | | - struct hdmi_avi_infoframe *frame) |
---|
| 1192 | + const struct hdmi_avi_infoframe *frame) |
---|
1203 | 1193 | { |
---|
1204 | 1194 | hdmi_infoframe_log_header(level, dev, |
---|
1205 | | - (struct hdmi_any_infoframe *)frame); |
---|
| 1195 | + (const struct hdmi_any_infoframe *)frame); |
---|
1206 | 1196 | |
---|
1207 | 1197 | hdmi_log(" colorspace: %s\n", |
---|
1208 | 1198 | hdmi_colorspace_get_name(frame->colorspace)); |
---|
.. | .. |
---|
1268 | 1258 | return "Reserved"; |
---|
1269 | 1259 | } |
---|
1270 | 1260 | |
---|
1271 | | -/** |
---|
1272 | | - * hdmi_spd_infoframe_log() - log info of HDMI SPD infoframe |
---|
1273 | | - * @level: logging level |
---|
1274 | | - * @dev: device |
---|
1275 | | - * @frame: HDMI SPD infoframe |
---|
1276 | | - */ |
---|
1277 | 1261 | static void hdmi_spd_infoframe_log(const char *level, |
---|
1278 | 1262 | struct device *dev, |
---|
1279 | | - struct hdmi_spd_infoframe *frame) |
---|
| 1263 | + const struct hdmi_spd_infoframe *frame) |
---|
1280 | 1264 | { |
---|
1281 | 1265 | u8 buf[17]; |
---|
1282 | 1266 | |
---|
1283 | 1267 | hdmi_infoframe_log_header(level, dev, |
---|
1284 | | - (struct hdmi_any_infoframe *)frame); |
---|
| 1268 | + (const struct hdmi_any_infoframe *)frame); |
---|
1285 | 1269 | |
---|
1286 | 1270 | memset(buf, 0, sizeof(buf)); |
---|
1287 | 1271 | |
---|
.. | .. |
---|
1404 | 1388 | return "Reserved"; |
---|
1405 | 1389 | } |
---|
1406 | 1390 | |
---|
1407 | | -/** |
---|
1408 | | - * hdmi_audio_infoframe_log() - log info of HDMI AUDIO infoframe |
---|
1409 | | - * @level: logging level |
---|
1410 | | - * @dev: device |
---|
1411 | | - * @frame: HDMI AUDIO infoframe |
---|
1412 | | - */ |
---|
1413 | 1391 | static void hdmi_audio_infoframe_log(const char *level, |
---|
1414 | 1392 | struct device *dev, |
---|
1415 | | - struct hdmi_audio_infoframe *frame) |
---|
| 1393 | + const struct hdmi_audio_infoframe *frame) |
---|
1416 | 1394 | { |
---|
1417 | 1395 | hdmi_infoframe_log_header(level, dev, |
---|
1418 | | - (struct hdmi_any_infoframe *)frame); |
---|
| 1396 | + (const struct hdmi_any_infoframe *)frame); |
---|
1419 | 1397 | |
---|
1420 | 1398 | if (frame->channels) |
---|
1421 | 1399 | hdmi_log(" channels: %u\n", frame->channels - 1); |
---|
.. | .. |
---|
1437 | 1415 | frame->downmix_inhibit ? "Yes" : "No"); |
---|
1438 | 1416 | } |
---|
1439 | 1417 | |
---|
1440 | | -/** |
---|
1441 | | - * hdmi_drm_infoframe_log() - log info of HDMI DRM infoframe |
---|
1442 | | - * @level: logging level |
---|
1443 | | - * @dev: device |
---|
1444 | | - * @frame: HDMI DRM infoframe |
---|
1445 | | - */ |
---|
1446 | 1418 | static void hdmi_drm_infoframe_log(const char *level, |
---|
1447 | 1419 | struct device *dev, |
---|
1448 | 1420 | const struct hdmi_drm_infoframe *frame) |
---|
.. | .. |
---|
1500 | 1472 | return "Reserved"; |
---|
1501 | 1473 | } |
---|
1502 | 1474 | |
---|
1503 | | -/** |
---|
1504 | | - * hdmi_vendor_infoframe_log() - log info of HDMI VENDOR infoframe |
---|
1505 | | - * @level: logging level |
---|
1506 | | - * @dev: device |
---|
1507 | | - * @frame: HDMI VENDOR infoframe |
---|
1508 | | - */ |
---|
1509 | 1475 | static void |
---|
1510 | 1476 | hdmi_vendor_any_infoframe_log(const char *level, |
---|
1511 | 1477 | struct device *dev, |
---|
1512 | | - union hdmi_vendor_any_infoframe *frame) |
---|
| 1478 | + const union hdmi_vendor_any_infoframe *frame) |
---|
1513 | 1479 | { |
---|
1514 | | - struct hdmi_vendor_infoframe *hvf = &frame->hdmi; |
---|
| 1480 | + const struct hdmi_vendor_infoframe *hvf = &frame->hdmi; |
---|
1515 | 1481 | |
---|
1516 | 1482 | hdmi_infoframe_log_header(level, dev, |
---|
1517 | | - (struct hdmi_any_infoframe *)frame); |
---|
| 1483 | + (const struct hdmi_any_infoframe *)frame); |
---|
1518 | 1484 | |
---|
1519 | 1485 | if (frame->any.oui != HDMI_IEEE_OUI) { |
---|
1520 | 1486 | hdmi_log(" not a HDMI vendor infoframe\n"); |
---|
.. | .. |
---|
1544 | 1510 | */ |
---|
1545 | 1511 | void hdmi_infoframe_log(const char *level, |
---|
1546 | 1512 | struct device *dev, |
---|
1547 | | - union hdmi_infoframe *frame) |
---|
| 1513 | + const union hdmi_infoframe *frame) |
---|
1548 | 1514 | { |
---|
1549 | 1515 | switch (frame->any.type) { |
---|
1550 | 1516 | case HDMI_INFOFRAME_TYPE_AVI: |
---|
.. | .. |
---|
1583 | 1549 | const void *buffer, size_t size) |
---|
1584 | 1550 | { |
---|
1585 | 1551 | const u8 *ptr = buffer; |
---|
1586 | | - int ret; |
---|
1587 | 1552 | |
---|
1588 | 1553 | if (size < HDMI_INFOFRAME_SIZE(AVI)) |
---|
1589 | 1554 | return -EINVAL; |
---|
.. | .. |
---|
1596 | 1561 | if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(AVI)) != 0) |
---|
1597 | 1562 | return -EINVAL; |
---|
1598 | 1563 | |
---|
1599 | | - ret = hdmi_avi_infoframe_init(frame); |
---|
1600 | | - if (ret) |
---|
1601 | | - return ret; |
---|
| 1564 | + hdmi_avi_infoframe_init(frame); |
---|
1602 | 1565 | |
---|
1603 | 1566 | ptr += HDMI_INFOFRAME_HEADER_SIZE; |
---|
1604 | 1567 | |
---|
.. | .. |
---|
1805 | 1768 | } |
---|
1806 | 1769 | |
---|
1807 | 1770 | /** |
---|
1808 | | - * hdmi_drm_infoframe_unpack() - unpack binary buffer to a HDMI DRM infoframe |
---|
| 1771 | + * hdmi_drm_infoframe_unpack_only() - unpack binary buffer of CTA-861-G DRM |
---|
| 1772 | + * infoframe DataBytes to a HDMI DRM |
---|
| 1773 | + * infoframe |
---|
1809 | 1774 | * @frame: HDMI DRM infoframe |
---|
1810 | 1775 | * @buffer: source buffer |
---|
1811 | 1776 | * @size: size of buffer |
---|
1812 | 1777 | * |
---|
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. |
---|
| 1778 | + * Unpacks CTA-861-G DRM infoframe DataBytes contained in the binary @buffer |
---|
| 1779 | + * into a structured @frame of the HDMI Dynamic Range and Mastering (DRM) |
---|
| 1780 | + * infoframe. |
---|
1817 | 1781 | * |
---|
1818 | 1782 | * Returns 0 on success or a negative error code on failure. |
---|
1819 | 1783 | */ |
---|
1820 | | -static int hdmi_drm_infoframe_unpack(struct hdmi_drm_infoframe *frame, |
---|
1821 | | - const void *buffer, size_t size) |
---|
| 1784 | +int hdmi_drm_infoframe_unpack_only(struct hdmi_drm_infoframe *frame, |
---|
| 1785 | + const void *buffer, size_t size) |
---|
1822 | 1786 | { |
---|
1823 | 1787 | const u8 *ptr = buffer; |
---|
1824 | 1788 | const u8 *temp; |
---|
.. | .. |
---|
1827 | 1791 | int ret; |
---|
1828 | 1792 | int i; |
---|
1829 | 1793 | |
---|
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) |
---|
| 1794 | + if (size < HDMI_DRM_INFOFRAME_SIZE) |
---|
1839 | 1795 | return -EINVAL; |
---|
1840 | 1796 | |
---|
1841 | 1797 | ret = hdmi_drm_infoframe_init(frame); |
---|
1842 | 1798 | if (ret) |
---|
1843 | 1799 | return ret; |
---|
1844 | | - |
---|
1845 | | - ptr += HDMI_INFOFRAME_HEADER_SIZE; |
---|
1846 | 1800 | |
---|
1847 | 1801 | frame->eotf = ptr[0] & 0x7; |
---|
1848 | 1802 | frame->metadata_type = ptr[1] & 0x7; |
---|
.. | .. |
---|
1851 | 1805 | for (i = 0; i < 3; i++) { |
---|
1852 | 1806 | x_lsb = *temp++; |
---|
1853 | 1807 | x_msb = *temp++; |
---|
1854 | | - frame->display_primaries[i].x = (x_msb << 8) | x_lsb; |
---|
| 1808 | + frame->display_primaries[i].x = (x_msb << 8) | x_lsb; |
---|
1855 | 1809 | y_lsb = *temp++; |
---|
1856 | 1810 | y_msb = *temp++; |
---|
1857 | 1811 | frame->display_primaries[i].y = (y_msb << 8) | y_lsb; |
---|
.. | .. |
---|
1867 | 1821 | |
---|
1868 | 1822 | return 0; |
---|
1869 | 1823 | } |
---|
| 1824 | +EXPORT_SYMBOL(hdmi_drm_infoframe_unpack_only); |
---|
| 1825 | + |
---|
| 1826 | +/** |
---|
| 1827 | + * hdmi_drm_infoframe_unpack() - unpack binary buffer to a HDMI DRM infoframe |
---|
| 1828 | + * @frame: HDMI DRM infoframe |
---|
| 1829 | + * @buffer: source buffer |
---|
| 1830 | + * @size: size of buffer |
---|
| 1831 | + * |
---|
| 1832 | + * Unpacks the CTA-861-G DRM infoframe contained in the binary @buffer into |
---|
| 1833 | + * a structured @frame of the HDMI Dynamic Range and Mastering (DRM) |
---|
| 1834 | + * infoframe. It also verifies the checksum as required by section 5.3.5 of |
---|
| 1835 | + * the HDMI 1.4 specification. |
---|
| 1836 | + * |
---|
| 1837 | + * Returns 0 on success or a negative error code on failure. |
---|
| 1838 | + */ |
---|
| 1839 | +static int hdmi_drm_infoframe_unpack(struct hdmi_drm_infoframe *frame, |
---|
| 1840 | + const void *buffer, size_t size) |
---|
| 1841 | +{ |
---|
| 1842 | + const u8 *ptr = buffer; |
---|
| 1843 | + int ret; |
---|
| 1844 | + |
---|
| 1845 | + if (size < HDMI_INFOFRAME_SIZE(DRM)) |
---|
| 1846 | + return -EINVAL; |
---|
| 1847 | + |
---|
| 1848 | + if (ptr[0] != HDMI_INFOFRAME_TYPE_DRM || |
---|
| 1849 | + ptr[1] != 1 || |
---|
| 1850 | + ptr[2] != HDMI_DRM_INFOFRAME_SIZE) |
---|
| 1851 | + return -EINVAL; |
---|
| 1852 | + |
---|
| 1853 | + if (hdmi_infoframe_checksum(buffer, HDMI_INFOFRAME_SIZE(DRM)) != 0) |
---|
| 1854 | + return -EINVAL; |
---|
| 1855 | + |
---|
| 1856 | + ret = hdmi_drm_infoframe_unpack_only(frame, ptr + HDMI_INFOFRAME_HEADER_SIZE, |
---|
| 1857 | + size - HDMI_INFOFRAME_HEADER_SIZE); |
---|
| 1858 | + return ret; |
---|
| 1859 | +} |
---|
1870 | 1860 | |
---|
1871 | 1861 | /** |
---|
1872 | 1862 | * hdmi_infoframe_unpack() - unpack binary buffer to a HDMI infoframe |
---|