media: cec: add CEC LIP support
Subsystems (2)
v2 cover media: cec: add CEC LIP support
Add support for the new CEC Latency Indication Protocol messages.
The last patch makes it more consistent how CEC 2.0-only messages are indicated in the header.
Changes since v1:
- added missing media: prefix in subject
- fixed a coding style issue (space after '*')
The remaining coding style issues are consistent with the existing style of the header. Mainly to keep it readable.
Regards,
Hans
Hans Verkuil (4):
media: include/uapi/linux/cec*.h: add CEC LIP support
Documentation: media: add CEC opcodes
media: cec: core: add LIP support
media: include/uapi/linux/cec*: clarify which msgs are CEC 2.0
.../media/cec/cec.h.rst.exceptions | 23 +++ drivers/media/cec/core/cec-adap.c | 9 + include/uapi/linux/cec-funcs.h | 182 ++++++++++++++++++ include/uapi/linux/cec.h | 31 ++- 4 files changed, 241 insertions(+), 4 deletions(-)
Signature · 1 line
2.53.0
PATCH v2 1/4 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.
--- include/uapi/linux/cec-funcs.h | 182 +++++++++++++++++++++++++++++++++ include/uapi/linux/cec.h | 24 +++++ 2 files changed, 206 insertions(+)
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, } +/* Latency Indication Protocol Feature */ +/* Only for CEC 2.0 and up */ +static inline void cec_msg_request_lip_support (struct cec_msg *msg, +int reply,__u16 phys_addr) +{ + msg->len =4 ; + msg->msg[1 ] =CEC_MSG_REQUEST_LIP_SUPPORT ; + msg->msg[2 ] = phys_addr >>8 ; + msg->msg[3 ] = phys_addr &0xff ; + msg->reply = reply ?CEC_MSG_REPORT_LIP_SUPPORT :0 ; +} + +static inline void cec_ops_request_lip_support (const struct cec_msg *msg, +__u16 *phys_addr) +{ + *phys_addr = (msg->msg[2 ] <<8 ) | msg->msg[3 ]; +} + +static inline void cec_msg_report_lip_support (struct cec_msg *msg,__u32 sqid) +{ + msg->len =6 ; + msg->msg[1 ] =CEC_MSG_REPORT_LIP_SUPPORT ; + msg->msg[2 ] = sqid >>24 ; + msg->msg[3 ] = (sqid >>16 ) &0xff ; + msg->msg[4 ] = (sqid >>8 ) &0xff ; + msg->msg[5 ] = sqid &0xff ; +} + +static inline void cec_ops_report_lip_support (const struct cec_msg *msg, +__u32 *sqid) +{ + *sqid = (msg->msg[2 ] <<24 ) | (msg->msg[3 ] <<16 ) | + (msg->msg[4 ] <<8 ) | msg->msg[5 ]; +} + +static inline void cec_msg_request_audio_and_video_latency (struct cec_msg *msg, +int reply,__u8 video_format, +__u8 hdr_format,__u8 vrr_format, +__u8 audio_format, +__u8 audio_format_extension) +{ + msg->len =6 ; + msg->msg[1 ] =CEC_MSG_REQUEST_AUDIO_AND_VIDEO_LATENCY ; + msg->msg[2 ] = video_format; + msg->msg[3 ] = hdr_format; + msg->msg[4 ] = vrr_format; + msg->msg[5 ] = audio_format; +if (audio_format >=1 && audio_format <=31 ) { + msg->msg[6 ] = audio_format_extension; + msg->len++; + } + msg->reply = reply ?CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY :0 ; +} + +static inline void cec_ops_request_audio_and_video_latency (const struct cec_msg *msg, +__u8 *video_format, +__u8 *hdr_format, +__u8 *vrr_format, +__u8 *audio_format, +__u8 *audio_format_extension) +{ + *video_format = msg->msg[2 ]; + *hdr_format = msg->msg[3 ]; + *vrr_format = msg->msg[4 ]; + *audio_format = msg->msg[5 ]; + *audio_format_extension = msg->len >6 ? msg->msg[6 ] :0 ; +} + +static inline void cec_msg_report_audio_and_video_latency (struct cec_msg *msg, +__u16 video_latency, +__u16 audio_latency) +{ + msg->len =6 ; + msg->msg[1 ] =CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY ; + msg->msg[2 ] = video_latency >>8 ; + msg->msg[3 ] = video_latency &0xff ; + msg->msg[4 ] = audio_latency >>8 ; + msg->msg[5 ] = audio_latency &0xff ; +} + +static inline void cec_ops_report_audio_and_video_latency (const struct cec_msg *msg, +__u16 *video_latency, +__u16 *audio_latency) +{ + *video_latency = (msg->msg[2 ] <<8 ) | msg->msg[3 ]; + *audio_latency = (msg->msg[4 ] <<8 ) | msg->msg[5 ]; +} + +static inline void cec_msg_request_audio_latency (struct cec_msg *msg, +int reply, +__u8 audio_format, +__u8 audio_format_extension) +{ + msg->len =3 ; + msg->msg[1 ] =CEC_MSG_REQUEST_AUDIO_LATENCY ; + msg->msg[2 ] = audio_format; +if (audio_format >=1 && audio_format <=31 ) { + msg->msg[3 ] = audio_format_extension; + msg->len++; + } + msg->reply = reply ?CEC_MSG_REPORT_AUDIO_LATENCY :0 ; +} + +static inline void cec_ops_request_audio_latency (const struct cec_msg *msg, +__u8 *audio_format, +__u8 *audio_format_extension) +{ + *audio_format = msg->msg[2 ]; + *audio_format_extension = msg->len >3 ? msg->msg[3 ] :0 ; +} + +static inline void cec_msg_report_audio_latency (struct cec_msg *msg, +__u16 audio_latency) +{ + msg->len =4 ; + msg->msg[1 ] =CEC_MSG_REPORT_AUDIO_LATENCY ; + msg->msg[2 ] = audio_latency >>8 ; + msg->msg[3 ] = audio_latency &0xff ; +} + +static inline void cec_ops_report_audio_latency (const struct cec_msg *msg, +__u16 *audio_latency) +{ + *audio_latency = (msg->msg[2 ] <<8 ) | msg->msg[3 ]; +} + +static inline void cec_msg_request_video_latency (struct cec_msg *msg, +int reply,__u8 video_format, +__u8 hdr_format, +__u8 vrr_format) +{ + msg->len =5 ; + msg->msg[1 ] =CEC_MSG_REQUEST_VIDEO_LATENCY ; + msg->msg[2 ] = video_format; + msg->msg[3 ] = hdr_format; + msg->msg[4 ] = vrr_format; + msg->reply = reply ?CEC_MSG_REPORT_VIDEO_LATENCY :0 ; +} + +static inline void cec_ops_request_video_latency (const struct cec_msg *msg, +__u8 *video_format, +__u8 *hdr_format, +__u8 *vrr_format) +{ + *video_format = msg->msg[2 ]; + *hdr_format = msg->msg[3 ]; + *vrr_format = msg->msg[4 ]; +} + +static inline void cec_msg_report_video_latency (struct cec_msg *msg, +__u16 video_latency) +{ + msg->len =4 ; + msg->msg[1 ] =CEC_MSG_REPORT_VIDEO_LATENCY ; + msg->msg[2 ] = video_latency >>8 ; + msg->msg[3 ] = video_latency &0xff ; +} + +static inline void cec_ops_report_video_latency (const struct cec_msg *msg, +__u16 *video_latency) +{ + *video_latency = (msg->msg[2 ] <<8 ) | msg->msg[3 ]; +} + +static inline void cec_msg_update_sqid (struct cec_msg *msg,__u32 sqid) +{ + msg->len =6 ; + msg->msg[1 ] =CEC_MSG_UPDATE_SQID ; + msg->msg[2 ] = sqid >>24 ; + msg->msg[3 ] = (sqid >>16 ) &0xff ; + msg->msg[4 ] = (sqid >>8 ) &0xff ; + msg->msg[5 ] = sqid &0xff ; +} + +static inline void cec_ops_update_sqid (const struct cec_msg *msg, +__u32 *sqid) +{ + *sqid = (msg->msg[2 ] <<24 ) | (msg->msg[3 ] <<16 ) | + (msg->msg[4 ] <<8 ) | msg->msg[5 ]; +} + +/* Capability Discovery and Control Feature */ static inline void cec_msg_cdc_hec_inquire_state(struct cec_msg *msg, __u16 phys_addr1,
include/uapi/linux/cec.h +24 -0
@@ -1104,6 +1104,30 @@ struct cec_event {#define CEC_OP_AUD_OUT_COMPENSATED_PARTIAL_DELAY 3 +/* Latency Indication Protocol Feature */ +#define CEC_MSG_REQUEST_LIP_SUPPORT 0x50 +#define CEC_MSG_REPORT_LIP_SUPPORT 0x51 +#define CEC_MSG_REQUEST_AUDIO_AND_VIDEO_LATENCY 0x52 +/* HDR Format Operand (hdr_format) */ +#define CEC_OP_HDR_FORMAT_GAMMA_SDR 0 +#define CEC_OP_HDR_FORMAT_GAMMA_HDR 1 +#define CEC_OP_HDR_FORMAT_PQ 2 +#define CEC_OP_HDR_FORMAT_HLG 3 +#define CEC_OP_HDR_FORMAT_DYNAMIC_HDR_TYPE_1 8 +#define CEC_OP_HDR_FORMAT_DYNAMIC_HDR_TYPE_2 9 +#define CEC_OP_HDR_FORMAT_DYNAMIC_HDR_TYPE_4 11 +#define CEC_OP_HDR_FORMAT_DV_SINK_LED 16 +#define CEC_OP_HDR_FORMAT_DV_SOURCE_LED 17 +#define CEC_OP_HDR_FORMAT_HDR10PLUS 24 +#define CEC_OP_HDR_FORMAT_ETSI_TS_103_433 32 +#define CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY 0x53 +#define CEC_MSG_REQUEST_AUDIO_LATENCY 0x54 +#define CEC_MSG_REPORT_AUDIO_LATENCY 0x55 +#define CEC_MSG_REQUEST_VIDEO_LATENCY 0x56 +#define CEC_MSG_REPORT_VIDEO_LATENCY 0x57 +#define CEC_MSG_UPDATE_SQID 0x58 + +/* Capability Discovery and Control Feature */ #define CEC_MSG_CDC_MESSAGE 0xf8/* Ethernet-over-HDMI: nobody ever does this... */
Signature · 1 line
2.53.0
PATCH v2 2/4 Documentation: media: add CEC opcodes
In reply to Hans VerkuilAdd the new opcodes to cec.h.rst.exceptions to avoid documentation build failures.
--- .../media/cec/cec.h.rst.exceptions | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+)
Documentation/userspace-api/media/cec/cec.h.rst.exceptions +23 -0
@@ -524,6 +524,29 @@ ignore define CEC_OP_AUD_OUT_COMPENSATED_DELAY ignore define CEC_OP_AUD_OUT_COMPENSATED_NO_DELAY ignore define CEC_OP_AUD_OUT_COMPENSATED_PARTIAL_DELAY +ignore define CEC_MSG_REQUEST_LIP_SUPPORT +ignore define CEC_MSG_REPORT_LIP_SUPPORT +ignore define CEC_MSG_REQUEST_AUDIO_AND_VIDEO_LATENCY + +ignore define CEC_OP_HDR_FORMAT_GAMMA_SDR +ignore define CEC_OP_HDR_FORMAT_GAMMA_HDR +ignore define CEC_OP_HDR_FORMAT_PQ +ignore define CEC_OP_HDR_FORMAT_HLG +ignore define CEC_OP_HDR_FORMAT_DYNAMIC_HDR_TYPE_1 +ignore define CEC_OP_HDR_FORMAT_DYNAMIC_HDR_TYPE_2 +ignore define CEC_OP_HDR_FORMAT_DYNAMIC_HDR_TYPE_4 +ignore define CEC_OP_HDR_FORMAT_DV_SINK_LED +ignore define CEC_OP_HDR_FORMAT_DV_SOURCE_LED +ignore define CEC_OP_HDR_FORMAT_HDR10PLUS +ignore define CEC_OP_HDR_FORMAT_ETSI_TS_103_433 + +ignore define CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY +ignore define CEC_MSG_REQUEST_AUDIO_LATENCY +ignore define CEC_MSG_REPORT_AUDIO_LATENCY +ignore define CEC_MSG_REQUEST_VIDEO_LATENCY +ignore define CEC_MSG_REPORT_VIDEO_LATENCY +ignore define CEC_MSG_UPDATE_SQID + ignore define CEC_MSG_CDC_MESSAGE ignore define CEC_MSG_CDC_HEC_INQUIRE_STATE
Signature · 1 line
2.53.0
PATCH v2 3/4 media: cec: core: add LIP support
In reply to Hans VerkuilAdd support for the new CEC LIP opcodes.
--- drivers/media/cec/core/cec-adap.c | 9 +++++++++ 1 file changed, 9 insertions(+)
drivers/media/cec/core/cec-adap.c +9 -0
@@ -1098,6 +1098,15 @@ static const u8 cec_msg_size[256] = { [CEC_MSG_REQUEST_CURRENT_LATENCY] = 4 | BCAST, [CEC_MSG_REPORT_CURRENT_LATENCY] = 6 | BCAST, [CEC_MSG_CDC_MESSAGE] = 2 | BCAST, + [CEC_MSG_REQUEST_LIP_SUPPORT] = 4 | DIRECTED, + [CEC_MSG_REPORT_LIP_SUPPORT] = 6 | DIRECTED, + [CEC_MSG_REQUEST_AUDIO_AND_VIDEO_LATENCY] = 6 | DIRECTED, + [CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY] = 6 | DIRECTED, + [CEC_MSG_REQUEST_AUDIO_LATENCY] = 3 | DIRECTED, + [CEC_MSG_REPORT_AUDIO_LATENCY] = 4 | DIRECTED, + [CEC_MSG_REQUEST_VIDEO_LATENCY] = 5 | DIRECTED, + [CEC_MSG_REPORT_VIDEO_LATENCY] = 4 | DIRECTED, + [CEC_MSG_UPDATE_SQID] = 6 | DIRECTED, };/* Called by the CEC adapter if a message is received */
Signature · 1 line
2.53.0
PATCH v2 4/4 media: include/uapi/linux/cec*: clarify which msgs are CEC 2.0
In reply to Hans VerkuilDrop comments about CEC 2.0 from cec-funcs.h.
In cec.h clearly comment messages that are CEC 2.0 specific as such. Also rename references to HDMI 2.0 to CEC 2.0.
The <Request/Report Current Latency> messages were marked as CEC 2.0 only. That is wrong, these messages are explicitly allowed for any CEC version.
--- include/uapi/linux/cec.h | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-)
include/uapi/linux/cec.h +12 -13
@@ -742,7 +742,7 @@ struct cec_event {#define CEC_OP_PRIM_DEVTYPE_PROCESSOR 7#define CEC_MSG_SET_MENU_LANGUAGE 0x32 -#define CEC_MSG_REPORT_FEATURES 0xa6/* HDMI 2.0 */ +#define CEC_MSG_REPORT_FEATURES 0xa6/* CEC 2.0 */ /* All Device Types Operand (all_device_types) */ #define CEC_OP_ALL_DEVTYPE_TV 0x80#define CEC_OP_ALL_DEVTYPE_RECORD 0x40
@@ -777,7 +777,7 @@ struct cec_event {#define CEC_OP_FEAT_DEV_SOURCE_HAS_ARC_RX 0x02#define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_VOLUME_LEVEL 0x01 -#define CEC_MSG_GIVE_FEATURES 0xa5/* HDMI 2.0 */ +#define CEC_MSG_GIVE_FEATURES 0xa5/* CEC 2.0 */ /* Deck Control Feature */
@@ -1067,7 +1067,7 @@ struct cec_event {#define CEC_OP_AUD_FMT_ID_CEA861 0#define CEC_OP_AUD_FMT_ID_CEA861_CXT 1 -#define CEC_MSG_SET_AUDIO_VOLUME_LEVEL 0x73 +#define CEC_MSG_SET_AUDIO_VOLUME_LEVEL 0x73/* CEC 2.0 */ /* Audio Rate Control Feature */ #define CEC_MSG_SET_AUDIO_RATE 0x9a
@@ -1091,7 +1091,6 @@ struct cec_event {/* Dynamic Audio Lipsync Feature */ -/* Only for CEC 2.0 and up */ #define CEC_MSG_REQUEST_CURRENT_LATENCY 0xa7#define CEC_MSG_REPORT_CURRENT_LATENCY 0xa8/* Low Latency Mode Operand (low_latency_mode) */
@@ -1105,9 +1104,9 @@ struct cec_event {/* Latency Indication Protocol Feature */ -#define CEC_MSG_REQUEST_LIP_SUPPORT 0x50 -#define CEC_MSG_REPORT_LIP_SUPPORT 0x51 -#define CEC_MSG_REQUEST_AUDIO_AND_VIDEO_LATENCY 0x52 +#define CEC_MSG_REQUEST_LIP_SUPPORT 0x50/* CEC 2.0 */ +#define CEC_MSG_REPORT_LIP_SUPPORT 0x51/* CEC 2.0 */ +#define CEC_MSG_REQUEST_AUDIO_AND_VIDEO_LATENCY 0x52/* CEC 2.0 */ /* HDR Format Operand (hdr_format) */ #define CEC_OP_HDR_FORMAT_GAMMA_SDR 0#define CEC_OP_HDR_FORMAT_GAMMA_HDR 1
@@ -1120,12 +1119,12 @@ struct cec_event {#define CEC_OP_HDR_FORMAT_DV_SOURCE_LED 17#define CEC_OP_HDR_FORMAT_HDR10PLUS 24#define CEC_OP_HDR_FORMAT_ETSI_TS_103_433 32 -#define CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY 0x53 -#define CEC_MSG_REQUEST_AUDIO_LATENCY 0x54 -#define CEC_MSG_REPORT_AUDIO_LATENCY 0x55 -#define CEC_MSG_REQUEST_VIDEO_LATENCY 0x56 -#define CEC_MSG_REPORT_VIDEO_LATENCY 0x57 -#define CEC_MSG_UPDATE_SQID 0x58 +#define CEC_MSG_REPORT_AUDIO_AND_VIDEO_LATENCY 0x53/* CEC 2.0 */ +#define CEC_MSG_REQUEST_AUDIO_LATENCY 0x54/* CEC 2.0 */ +#define CEC_MSG_REPORT_AUDIO_LATENCY 0x55/* CEC 2.0 */ +#define CEC_MSG_REQUEST_VIDEO_LATENCY 0x56/* CEC 2.0 */ +#define CEC_MSG_REPORT_VIDEO_LATENCY 0x57/* CEC 2.0 */ +#define CEC_MSG_UPDATE_SQID 0x58/* CEC 2.0 */ /* Capability Discovery and Control Feature */
Signature · 1 line
2.53.0