Skip to main content

linux_cec_sys/
ioctls.rs

1/*
2 * Copyright © 2024 Valve Software
3 *
4 * Based in part on linux/cec.h
5 * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9use nix::{ioctl_read, ioctl_readwrite, ioctl_write_ptr};
10
11use crate::structs::*;
12use crate::{MessageHandlingMode, PhysicalAddress};
13
14/* Adapter capabilities */
15ioctl_readwrite!(adapter_get_capabilities, b'a', 0, cec_caps);
16
17/*
18 * phys_addr is either 0 (if this is the CEC root device)
19 * or a valid physical address obtained from the sink's EDID
20 * as read by this CEC device (if this is a source device)
21 * or a physical address obtained and modified from a sink
22 * EDID and used for a sink CEC device.
23 * If nothing is connected, then phys_addr is 0xffff.
24 * See HDMI 1.4b, section 8.7 (Physical Address).
25 *
26 * The CEC_ADAP_S_PHYS_ADDR ioctl may not be available if that is handled
27 * internally.
28 */
29ioctl_read!(adapter_get_physical_address, b'a', 1, PhysicalAddress);
30ioctl_write_ptr!(adapter_set_physical_address, b'a', 2, PhysicalAddress);
31
32/*
33 * Configure the CEC adapter. It sets the device type and which
34 * logical types it will try to claim. It will return which
35 * logical addresses it could actually claim.
36 * An error is returned if the adapter is disabled or if there
37 * is no physical address assigned.
38 */
39ioctl_read!(adapter_get_logical_addresses, b'a', 3, cec_log_addrs);
40ioctl_readwrite!(adapter_set_logical_addresses, b'a', 4, cec_log_addrs);
41
42/* Transmit/receive a CEC command */
43ioctl_readwrite!(transmit_message, b'a', 5, cec_msg);
44ioctl_readwrite!(receive_message, b'a', 6, cec_msg);
45
46/* Dequeue CEC events */
47ioctl_readwrite!(dequeue_event, b'a', 7, cec_event);
48
49/*
50 * Get and set the message handling mode for this filehandle.
51 */
52ioctl_read!(get_mode, b'a', 8, MessageHandlingMode);
53ioctl_write_ptr!(set_mode, b'a', 9, MessageHandlingMode);
54
55/* Get the connector info */
56ioctl_read!(adapter_get_connector_info, b'a', 10, cec_connector_info);