History

media: include/uapi/linux/cec*.h: add CEC LIP support

Add support for the new Latency Indication Protocol feature. This adds the opcodes and the wrapper functions.

Hans Verkuil committed 5 months ago

Commit 65efd131 parent a1db83c2 files · +206 −0Browse files

Showing the changes to include/uapi (2 of 2 files). Show all

Unified · Split

2 files
  1. include/uapi/linux/cec-funcs.h +182 −0
  2. include/uapi/linux/cec.h +24 −0
include/uapi/linux/cec-funcs.h+182−0
@@ -1701,6 +1701,188 @@ static inline void cec_ops_request_current_latency(const struct cec_msg *msg, · 1700 unmodified lines
17011701 }
17021702
17031703
1704+/* Latency Indication Protocol Feature */
1705+/* Only for CEC 2.0 and up */
1706+static inline void cec_msg_request_lip_support(struct cec_msg *msg,
1707+ int reply, __u16 phys_addr)
1708+{
1709+ msg->len = 4;
1710+ msg->msg[1] = CEC_MSG_REQUEST_LIP_SUPPORT;
1711+ msg->msg[2] = phys_addr >> 8;
1712+ msg->msg[3] = phys_addr & 0xff;
1713+ msg->reply = reply ? CEC_MSG_REPORT_LIP_SUPPORT : 0;
1714+}
1715+
1716+static inline void cec_ops_request_lip_support(const struct cec_msg *msg,
1717+ __u16 *phys_addr)
1718+{
1719+ *phys_addr = (msg->msg[2] << 8) | msg->msg[3];
1720+}
1721+
1722+static inline void cec_msg_report_lip_support(struct cec_msg *msg, __u32 sqid)
1723+{
1724+ msg->len = 6;
1725+ msg->msg[1] = CEC_MSG_REPORT_LIP_SUPPORT;
1726+ msg->msg[2] = sqid >> 24;
1727+ msg->msg[3] = (sqid >> 16) & 0xff;
1728+ msg->msg[4] = (sqid >> 8) & 0xff;
1729+ msg->msg[5] = sqid & 0xff;
1730+}
1731+
1732+static inline void cec_ops_report_lip_support(const struct cec_msg *msg,
1733+ __u32 *sqid)
1734+{
1735+ *sqid = (msg->msg[2] << 24) | (msg->msg[3] << 16) |
1736+ (msg->msg[4] << 8) | msg->msg[5];
1737+}
1738+
1739+static inline void cec_msg_request_audio_and_video_latency(struct cec_msg *msg,
1740+ int reply, __u8 video_format,
1741+ __u8 hdr_format, __u8 vrr_format,
1742+ __u8 audio_format,
1743+ __u8 audio_format_extension)
1744+{
1745+ msg->len = 6;
1746+ msg->msg[1] = CEC_MSG_REQUEST_AUDIO_AND_VIDEO_LATENCY;
1747+ msg->msg[2] = video_format;
1748+ msg->msg[3] = hdr_format;
1749+ msg->msg[4] = vrr_format;
1750+ msg->msg[5] = audio_format;
1751+ if (audio_format >= 1 && audio_format <= 31) {
1752+ msg->msg[6] = audio_format_extension;
1753+ msg->len++;
1754+ }
1755+ msg->reply = reply ? CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY : 0;
1756+}
1757+
1758+static inline void cec_ops_request_audio_and_video_latency(const struct cec_msg *msg,
1759+ __u8 *video_format,
1760+ __u8 *hdr_format,
1761+ __u8 *vrr_format,
1762+ __u8 *audio_format,
1763+ __u8 *audio_format_extension)
1764+{
1765+ *video_format = msg->msg[2];
1766+ *hdr_format = msg->msg[3];
1767+ *vrr_format = msg->msg[4];
1768+ *audio_format = msg->msg[5];
1769+ *audio_format_extension = msg->len > 6 ? msg->msg[6] : 0;
1770+}
1771+
1772+static inline void cec_msg_report_audio_and_video_latency(struct cec_msg *msg,
1773+ __u16 video_latency,
1774+ __u16 audio_latency)
1775+{
1776+ msg->len = 6;
1777+ msg->msg[1] = CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY;
1778+ msg->msg[2] = video_latency >> 8;
1779+ msg->msg[3] = video_latency & 0xff;
1780+ msg->msg[4] = audio_latency >> 8;
1781+ msg->msg[5] = audio_latency & 0xff;
1782+}
1783+
1784+static inline void cec_ops_report_audio_and_video_latency(const struct cec_msg *msg,
1785+ __u16 *video_latency,
1786+ __u16 *audio_latency)
1787+{
1788+ *video_latency = (msg->msg[2] << 8) | msg->msg[3];
1789+ *audio_latency = (msg->msg[4] << 8) | msg->msg[5];
1790+}
1791+
1792+static inline void cec_msg_request_audio_latency(struct cec_msg *msg,
1793+ int reply,
1794+ __u8 audio_format,
1795+ __u8 audio_format_extension)
1796+{
1797+ msg->len = 3;
1798+ msg->msg[1] = CEC_MSG_REQUEST_AUDIO_LATENCY;
1799+ msg->msg[2] = audio_format;
1800+ if (audio_format >= 1 && audio_format <= 31) {
1801+ msg->msg[3] = audio_format_extension;
1802+ msg->len++;
1803+ }
1804+ msg->reply = reply ? CEC_MSG_REPORT_AUDIO_LATENCY : 0;
1805+}
1806+
1807+static inline void cec_ops_request_audio_latency(const struct cec_msg *msg,
1808+ __u8 *audio_format,
1809+ __u8 *audio_format_extension)
1810+{
1811+ *audio_format = msg->msg[2];
1812+ *audio_format_extension = msg->len > 3 ? msg->msg[3] : 0;
1813+}
1814+
1815+static inline void cec_msg_report_audio_latency(struct cec_msg *msg,
1816+ __u16 audio_latency)
1817+{
1818+ msg->len = 4;
1819+ msg->msg[1] = CEC_MSG_REPORT_AUDIO_LATENCY;
1820+ msg->msg[2] = audio_latency >> 8;
1821+ msg->msg[3] = audio_latency & 0xff;
1822+}
1823+
1824+static inline void cec_ops_report_audio_latency(const struct cec_msg *msg,
1825+ __u16 *audio_latency)
1826+{
1827+ *audio_latency = (msg->msg[2] << 8) | msg->msg[3];
1828+}
1829+
1830+static inline void cec_msg_request_video_latency(struct cec_msg *msg,
1831+ int reply, __u8 video_format,
1832+ __u8 hdr_format,
1833+ __u8 vrr_format)
1834+{
1835+ msg->len = 5;
1836+ msg->msg[1] = CEC_MSG_REQUEST_VIDEO_LATENCY;
1837+ msg->msg[2] = video_format;
1838+ msg->msg[3] = hdr_format;
1839+ msg->msg[4] = vrr_format;
1840+ msg->reply = reply ? CEC_MSG_REPORT_VIDEO_LATENCY : 0;
1841+}
1842+
1843+static inline void cec_ops_request_video_latency(const struct cec_msg *msg,
1844+ __u8 *video_format,
1845+ __u8 *hdr_format,
1846+ __u8 *vrr_format)
1847+{
1848+ *video_format = msg->msg[2];
1849+ *hdr_format = msg->msg[3];
1850+ *vrr_format = msg->msg[4];
1851+}
1852+
1853+static inline void cec_msg_report_video_latency(struct cec_msg *msg,
1854+ __u16 video_latency)
1855+{
1856+ msg->len = 4;
1857+ msg->msg[1] = CEC_MSG_REPORT_VIDEO_LATENCY;
1858+ msg->msg[2] = video_latency >> 8;
1859+ msg->msg[3] = video_latency & 0xff;
1860+}
1861+
1862+static inline void cec_ops_report_video_latency(const struct cec_msg *msg,
1863+ __u16 *video_latency)
1864+{
1865+ *video_latency = (msg->msg[2] << 8) | msg->msg[3];
1866+}
1867+
1868+static inline void cec_msg_update_sqid(struct cec_msg *msg, __u32 sqid)
1869+{
1870+ msg->len = 6;
1871+ msg->msg[1] = CEC_MSG_UPDATE_SQID;
1872+ msg->msg[2] = sqid >> 24;
1873+ msg->msg[3] = (sqid >> 16) & 0xff;
1874+ msg->msg[4] = (sqid >> 8) & 0xff;
1875+ msg->msg[5] = sqid & 0xff;
1876+}
1877+
1878+static inline void cec_ops_update_sqid(const struct cec_msg *msg,
1879+ __u32 *sqid)
1880+{
1881+ *sqid = (msg->msg[2] << 24) | (msg->msg[3] << 16) |
1882+ (msg->msg[4] << 8) | msg->msg[5];
1883+}
1884+
1885+
17041886 /* Capability Discovery and Control Feature */
17051887 static inline void cec_msg_cdc_hec_inquire_state(struct cec_msg *msg,
17061888 __u16 phys_addr1,
include/uapi/linux/cec.h+24−0
@@ -1104,6 +1104,30 @@ struct cec_event { · 1103 unmodified lines
11041104 #define CEC_OP_AUD_OUT_COMPENSATED_PARTIAL_DELAY 3
11051105
11061106
1107+/* Latency Indication Protocol Feature */
1108+#define CEC_MSG_REQUEST_LIP_SUPPORT 0x50
1109+#define CEC_MSG_REPORT_LIP_SUPPORT 0x51
1110+#define CEC_MSG_REQUEST_AUDIO_AND_VIDEO_LATENCY 0x52
1111+/* HDR Format Operand (hdr_format) */
1112+#define CEC_OP_HDR_FORMAT_GAMMA_SDR 0
1113+#define CEC_OP_HDR_FORMAT_GAMMA_HDR 1
1114+#define CEC_OP_HDR_FORMAT_PQ 2
1115+#define CEC_OP_HDR_FORMAT_HLG 3
1116+#define CEC_OP_HDR_FORMAT_DYNAMIC_HDR_TYPE_1 8
1117+#define CEC_OP_HDR_FORMAT_DYNAMIC_HDR_TYPE_2 9
1118+#define CEC_OP_HDR_FORMAT_DYNAMIC_HDR_TYPE_4 11
1119+#define CEC_OP_HDR_FORMAT_DV_SINK_LED 16
1120+#define CEC_OP_HDR_FORMAT_DV_SOURCE_LED 17
1121+#define CEC_OP_HDR_FORMAT_HDR10PLUS 24
1122+#define CEC_OP_HDR_FORMAT_ETSI_TS_103_433 32
1123+#define CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY 0x53
1124+#define CEC_MSG_REQUEST_AUDIO_LATENCY 0x54
1125+#define CEC_MSG_REPORT_AUDIO_LATENCY 0x55
1126+#define CEC_MSG_REQUEST_VIDEO_LATENCY 0x56
1127+#define CEC_MSG_REPORT_VIDEO_LATENCY 0x57
1128+#define CEC_MSG_UPDATE_SQID 0x58
1129+
1130+
11071131 /* Capability Discovery and Control Feature */
11081132 #define CEC_MSG_CDC_MESSAGE 0xf8
11091133 /* Ethernet-over-HDMI: nobody ever does this... */