/* SPDX-License-Identifier: ((GPL-2.0 WITH Linux-syscall-note) OR BSD-3-Clause) */ /* * cec - HDMI Consumer Electronics Control public header * * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
*/
/** * struct cec_msg - CEC message structure. * @tx_ts: Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by the * driver when the message transmission has finished. * @rx_ts: Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by the * driver when the message was received. * @len: Length in bytes of the message. * @timeout: The timeout (in ms) that is used to timeout CEC_RECEIVE. * Set to 0 if you want to wait forever. This timeout can also be * used with CEC_TRANSMIT as the timeout for waiting for a reply. * If 0, then it will use a 1 second timeout instead of waiting * forever as is done with CEC_RECEIVE. * @sequence: The framework assigns a sequence number to messages that are * sent. This can be used to track replies to previously sent * messages. * @flags: Set to 0. * @msg: The message payload. * @reply: This field is ignored with CEC_RECEIVE and is only used by * CEC_TRANSMIT. If non-zero, then wait for a reply with this * opcode. Set to CEC_MSG_FEATURE_ABORT if you want to wait for * a possible ABORT reply. If there was an error when sending the * msg or FeatureAbort was returned, then reply is set to 0. * If reply is non-zero upon return, then len/msg are set to * the received message. * If reply is zero upon return and status has the * CEC_TX_STATUS_FEATURE_ABORT bit set, then len/msg are set to * the received feature abort message. * If reply is zero upon return and status has the * CEC_TX_STATUS_MAX_RETRIES bit set, then no reply was seen at * all. If reply is non-zero for CEC_TRANSMIT and the message is a * broadcast, then -EINVAL is returned. * if reply is non-zero, then timeout is set to 1000 (the required * maximum response time). * @rx_status: The message receive status bits. Set by the driver. * @tx_status: The message transmit status bits. Set by the driver. * @tx_arb_lost_cnt: The number of 'Arbitration Lost' events. Set by the driver. * @tx_nack_cnt: The number of 'Not Acknowledged' events. Set by the driver. * @tx_low_drive_cnt: The number of 'Low Drive Detected' events. Set by the * driver. * @tx_error_cnt: The number of 'Error' events. Set by the driver.
*/ struct cec_msg {
__u64 tx_ts;
__u64 rx_ts;
__u32 len;
__u32 timeout;
__u32 sequence;
__u32 flags;
__u8 msg[CEC_MAX_MSG_SIZE];
__u8 reply;
__u8 rx_status;
__u8 tx_status;
__u8 tx_arb_lost_cnt;
__u8 tx_nack_cnt;
__u8 tx_low_drive_cnt;
__u8 tx_error_cnt;
};
/** * cec_msg_opcode - return the opcode of the message, -1 for poll * @msg: the message structure
*/ staticinlineint cec_msg_opcode(conststruct cec_msg *msg)
{ return msg->len > 1 ? msg->msg[1] : -1;
}
/** * cec_msg_is_broadcast - return true if this is a broadcast message. * @msg: the message structure
*/ staticinlineint cec_msg_is_broadcast(conststruct cec_msg *msg)
{ return (msg->msg[0] & 0xf) == 0xf;
}
/** * cec_msg_init - initialize the message structure. * @msg: the message structure * @initiator: the logical address of the initiator * @destination:the logical address of the destination (0xf for broadcast) * * The whole structure is zeroed, the len field is set to 1 (i.e. a poll * message) and the initiator and destination are filled in.
*/ staticinlinevoid cec_msg_init(struct cec_msg *msg,
__u8 initiator, __u8 destination)
{
memset(msg, 0, sizeof(*msg));
msg->msg[0] = (initiator << 4) | destination;
msg->len = 1;
}
/** * cec_msg_set_reply_to - fill in destination/initiator in a reply message. * @msg: the message structure for the reply * @orig: the original message structure * * Set the msg destination to the orig initiator and the msg initiator to the * orig destination. Note that msg and orig may be the same pointer, in which * case the change is done in place. * * It also zeroes the reply, timeout and flags fields.
*/ staticinlinevoid cec_msg_set_reply_to(struct cec_msg *msg, struct cec_msg *orig)
{ /* The destination becomes the initiator and vice versa */
msg->msg[0] = (cec_msg_destination(orig) << 4) |
cec_msg_initiator(orig);
msg->reply = 0;
msg->timeout = 0;
msg->flags = 0;
}
/** * cec_msg_recv_is_tx_result - return true if this message contains the * result of an earlier non-blocking transmit * @msg: the message structure from CEC_RECEIVE
*/ staticinlineint cec_msg_recv_is_tx_result(conststruct cec_msg *msg)
{ return msg->sequence && msg->tx_status && !msg->rx_status;
}
/** * cec_msg_recv_is_rx_result - return true if this message contains the * reply of an earlier non-blocking transmit * @msg: the message structure from CEC_RECEIVE
*/ staticinlineint cec_msg_recv_is_rx_result(conststruct cec_msg *msg)
{ return msg->sequence && !msg->tx_status && msg->rx_status;
}
/* * The maximum number of logical addresses one device can be assigned to. * The CEC 2.0 spec allows for only 2 logical addresses at the moment. The * Analog Devices CEC hardware supports 3. So let's go wild and go for 4.
*/ #define CEC_MAX_LOG_ADDRS 4
/* * Use this if there is no vendor ID (CEC_G_VENDOR_ID) or if the vendor ID * should be disabled (CEC_S_VENDOR_ID)
*/ #define CEC_VENDOR_ID_NONE 0xffffffff
/* Userspace has to configure the physical address */ #define CEC_CAP_PHYS_ADDR (1 << 0) /* Userspace has to configure the logical addresses */ #define CEC_CAP_LOG_ADDRS (1 << 1) /* Userspace can transmit messages (and thus become follower as well) */ #define CEC_CAP_TRANSMIT (1 << 2) /* * Passthrough all messages instead of processing them.
*/ #define CEC_CAP_PASSTHROUGH (1 << 3) /* Supports remote control */ #define CEC_CAP_RC (1 << 4) /* Hardware can monitor all messages, not just directed and broadcast. */ #define CEC_CAP_MONITOR_ALL (1 << 5) /* Hardware can use CEC only if the HDMI HPD pin is high. */ #define CEC_CAP_NEEDS_HPD (1 << 6) /* Hardware can monitor CEC pin transitions */ #define CEC_CAP_MONITOR_PIN (1 << 7) /* CEC_ADAP_G_CONNECTOR_INFO is available */ #define CEC_CAP_CONNECTOR_INFO (1 << 8) /* CEC_MSG_FL_REPLY_VENDOR_ID is available */ #define CEC_CAP_REPLY_VENDOR_ID (1 << 9)
/** * struct cec_caps - CEC capabilities structure. * @driver: name of the CEC device driver. * @name: name of the CEC device. @driver + @name must be unique. * @available_log_addrs: number of available logical addresses. * @capabilities: capabilities of the CEC adapter. * @version: version of the CEC adapter framework.
*/ struct cec_caps { char driver[32]; char name[32];
__u32 available_log_addrs;
__u32 capabilities;
__u32 version;
};
/** * struct cec_log_addrs - CEC logical addresses structure. * @log_addr: the claimed logical addresses. Set by the driver. * @log_addr_mask: current logical address mask. Set by the driver. * @cec_version: the CEC version that the adapter should implement. Set by the * caller. * @num_log_addrs: how many logical addresses should be claimed. Set by the * caller. * @vendor_id: the vendor ID of the device. Set by the caller. * @flags: flags. * @osd_name: the OSD name of the device. Set by the caller. * @primary_device_type: the primary device type for each logical address. * Set by the caller. * @log_addr_type: the logical address types. Set by the caller. * @all_device_types: CEC 2.0: all device types represented by the logical * address. Set by the caller. * @features: CEC 2.0: The logical address features. Set by the caller.
*/ struct cec_log_addrs {
__u8 log_addr[CEC_MAX_LOG_ADDRS];
__u16 log_addr_mask;
__u8 cec_version;
__u8 num_log_addrs;
__u32 vendor_id;
__u32 flags; char osd_name[15];
__u8 primary_device_type[CEC_MAX_LOG_ADDRS];
__u8 log_addr_type[CEC_MAX_LOG_ADDRS];
/** * struct cec_connector_info - tells if and which connector is * associated with the CEC adapter. * @type: connector type (if any) * @drm: drm connector info * @raw: array to pad the union
*/ struct cec_connector_info {
__u32 type; union { struct cec_drm_connector_info drm;
__u32 raw[16];
};
};
/* Events */
/* Event that occurs when the adapter state changes */ #define CEC_EVENT_STATE_CHANGE 1 /* * This event is sent when messages are lost because the application * didn't empty the message queue in time
*/ #define CEC_EVENT_LOST_MSGS 2 #define CEC_EVENT_PIN_CEC_LOW 3 #define CEC_EVENT_PIN_CEC_HIGH 4 #define CEC_EVENT_PIN_HPD_LOW 5 #define CEC_EVENT_PIN_HPD_HIGH 6 #define CEC_EVENT_PIN_5V_LOW 7 #define CEC_EVENT_PIN_5V_HIGH 8
/** * struct cec_event_state_change - used when the CEC adapter changes state. * @phys_addr: the current physical address * @log_addr_mask: the current logical address mask * @have_conn_info: if non-zero, then HDMI connector information is available. * This field is only valid if CEC_CAP_CONNECTOR_INFO is set. If that * capability is set and @have_conn_info is zero, then that indicates * that the HDMI connector device is not instantiated, either because * the HDMI driver is still configuring the device or because the HDMI * device was unbound.
*/ struct cec_event_state_change {
__u16 phys_addr;
__u16 log_addr_mask;
__u16 have_conn_info;
};
/** * struct cec_event_lost_msgs - tells you how many messages were lost. * @lost_msgs: how many messages were lost.
*/ struct cec_event_lost_msgs {
__u32 lost_msgs;
};
/** * struct cec_event - CEC event structure * @ts: the timestamp of when the event was sent. * @event: the event. * @flags: event flags. * @state_change: the event payload for CEC_EVENT_STATE_CHANGE. * @lost_msgs: the event payload for CEC_EVENT_LOST_MSGS. * @raw: array to pad the union.
*/ struct cec_event {
__u64 ts;
__u32 event;
__u32 flags; union { struct cec_event_state_change state_change; struct cec_event_lost_msgs lost_msgs;
__u32 raw[16];
};
};
/* * phys_addr is either 0 (if this is the CEC root device) * or a valid physical address obtained from the sink's EDID * as read by this CEC device (if this is a source device) * or a physical address obtained and modified from a sink * EDID and used for a sink CEC device. * If nothing is connected, then phys_addr is 0xffff. * See HDMI 1.4b, section 8.7 (Physical Address). * * The CEC_ADAP_S_PHYS_ADDR ioctl may not be available if that is handled * internally.
*/ #define CEC_ADAP_G_PHYS_ADDR _IOR('a', 1, __u16) #define CEC_ADAP_S_PHYS_ADDR _IOW('a', 2, __u16)
/* * Configure the CEC adapter. It sets the device type and which * logical types it will try to claim. It will return which * logical addresses it could actually claim. * An error is returned if the adapter is disabled or if there * is no physical address assigned.
*/
/* * Get and set the message handling mode for this filehandle.
*/ #define CEC_G_MODE _IOR('a', 8, __u32) #define CEC_S_MODE _IOW('a', 9, __u32)
/* Get the connector info */ #define CEC_ADAP_G_CONNECTOR_INFO _IOR('a', 10, struct cec_connector_info)
/* * The remainder of this header defines all CEC messages and operands. * The format matters since it the cec-ctl utility parses it to generate * code for implementing all these messages. * * Comments ending with 'Feature' group messages for each feature. * If messages are part of multiple features, then the "Has also" * comment is used to list the previously defined messages that are * supported by the feature. * * Before operands are defined a comment is added that gives the * name of the operand and in brackets the variable name of the * corresponding argument in the cec-funcs.h function.
*/
/* Messages */
/* One Touch Play Feature */ #define CEC_MSG_ACTIVE_SOURCE 0x82 #define CEC_MSG_IMAGE_VIEW_ON 0x04 #define CEC_MSG_TEXT_VIEW_ON 0x0d
#define CEC_MSG_SET_MENU_LANGUAGE 0x32 #define CEC_MSG_REPORT_FEATURES 0xa6 /* HDMI 2.0 */ /* All Device Types Operand (all_device_types) */ #define CEC_OP_ALL_DEVTYPE_TV 0x80 #define CEC_OP_ALL_DEVTYPE_RECORD 0x40 #define CEC_OP_ALL_DEVTYPE_TUNER 0x20 #define CEC_OP_ALL_DEVTYPE_PLAYBACK 0x10 #define CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM 0x08 #define CEC_OP_ALL_DEVTYPE_SWITCH 0x04 /* * And if you wondering what happened to PROCESSOR devices: those should * be mapped to a SWITCH.
*/
/* Helper functions to identify the 'special' CEC devices */
staticinlineint cec_is_2nd_tv(conststruct cec_log_addrs *las)
{ /* * It is a second TV if the logical address is 14 or 15 and the * primary device type is a TV.
*/ return las->num_log_addrs &&
las->log_addr[0] >= CEC_LOG_ADDR_SPECIFIC &&
las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_TV;
}
staticinlineint cec_is_processor(conststruct cec_log_addrs *las)
{ /* * It is a processor if the logical address is 12-15 and the * primary device type is a Processor.
*/ return las->num_log_addrs &&
las->log_addr[0] >= CEC_LOG_ADDR_BACKUP_1 &&
las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_PROCESSOR;
}
staticinlineint cec_is_switch(conststruct cec_log_addrs *las)
{ /* * It is a switch if the logical address is 15 and the * primary device type is a Switch and the CDC-Only flag is not set.
*/ return las->num_log_addrs == 1 &&
las->log_addr[0] == CEC_LOG_ADDR_UNREGISTERED &&
las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_SWITCH &&
!(las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY);
}
staticinlineint cec_is_cdc_only(conststruct cec_log_addrs *las)
{ /* * It is a CDC-only device if the logical address is 15 and the * primary device type is a Switch and the CDC-Only flag is set.
*/ return las->num_log_addrs == 1 &&
las->log_addr[0] == CEC_LOG_ADDR_UNREGISTERED &&
las->primary_device_type[0] == CEC_OP_PRIM_DEVTYPE_SWITCH &&
(las->flags & CEC_LOG_ADDRS_FL_CDC_ONLY);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.