Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 1 | .. -*- coding: utf-8; mode: rst -*- |
| 2 | |
Markus Heiser | 21c6269 | 2016-07-08 20:55:43 +0200 | [diff] [blame] | 3 | .. _CEC_DQEVENT: |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 4 | |
| 5 | ***************** |
| 6 | ioctl CEC_DQEVENT |
| 7 | ***************** |
| 8 | |
Markus Heiser | 21c6269 | 2016-07-08 20:55:43 +0200 | [diff] [blame] | 9 | Name |
| 10 | ==== |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 11 | |
Markus Heiser | 21c6269 | 2016-07-08 20:55:43 +0200 | [diff] [blame] | 12 | CEC_DQEVENT - Dequeue a CEC event |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 13 | |
| 14 | |
| 15 | Synopsis |
| 16 | ======== |
| 17 | |
Markus Heiser | 9cd3476 | 2016-08-15 16:08:28 +0200 | [diff] [blame] | 18 | .. c:function:: int ioctl( int fd, int request, struct cec_event *argp ) |
| 19 | :name: CEC_DQEVENT |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 20 | |
| 21 | Arguments |
| 22 | ========= |
| 23 | |
| 24 | ``fd`` |
| 25 | File descriptor returned by :ref:`open() <cec-func-open>`. |
| 26 | |
| 27 | ``request`` |
| 28 | CEC_DQEVENT |
| 29 | |
| 30 | ``argp`` |
| 31 | |
| 32 | |
| 33 | Description |
| 34 | =========== |
| 35 | |
Mauro Carvalho Chehab | 706f8a9 | 2016-07-10 11:57:43 -0300 | [diff] [blame] | 36 | .. note:: This documents the proposed CEC API. This API is not yet finalized |
| 37 | and is currently only available as a staging kernel module. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 38 | |
| 39 | CEC devices can send asynchronous events. These can be retrieved by |
Markus Heiser | 9cd3476 | 2016-08-15 16:08:28 +0200 | [diff] [blame] | 40 | calling :c:func:`CEC_DQEVENT`. If the file descriptor is in |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 41 | non-blocking mode and no event is pending, then it will return -1 and |
Hans Verkuil | e5208ed | 2016-07-19 06:26:13 -0300 | [diff] [blame] | 42 | set errno to the ``EAGAIN`` error code. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 43 | |
| 44 | The internal event queues are per-filehandle and per-event type. If |
| 45 | there is no more room in a queue then the last event is overwritten with |
| 46 | the new one. This means that intermediate results can be thrown away but |
| 47 | that the latest event is always available. This also means that is it |
| 48 | possible to read two successive events that have the same value (e.g. |
Mauro Carvalho Chehab | cc0fe5c | 2016-07-13 10:22:38 -0300 | [diff] [blame] | 49 | two :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>` events with |
| 50 | the same state). In that case the intermediate state changes were lost but |
| 51 | it is guaranteed that the state did change in between the two events. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 52 | |
| 53 | |
Mauro Carvalho Chehab | 96f69e0 | 2016-07-09 10:25:05 -0300 | [diff] [blame] | 54 | .. _cec-event-state-change_s: |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 55 | |
| 56 | .. flat-table:: struct cec_event_state_change |
| 57 | :header-rows: 0 |
| 58 | :stub-columns: 0 |
Mauro Carvalho Chehab | b2a5843 | 2016-07-08 17:59:27 -0300 | [diff] [blame] | 59 | :widths: 1 1 8 |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 60 | |
| 61 | |
| 62 | - .. row 1 |
| 63 | |
| 64 | - __u16 |
| 65 | |
| 66 | - ``phys_addr`` |
| 67 | |
Hans Verkuil | 277f963 | 2016-08-10 06:00:53 -0300 | [diff] [blame] | 68 | - The current physical address. This is ``CEC_PHYS_ADDR_INVALID`` if no |
| 69 | valid physical address is set. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 70 | |
| 71 | - .. row 2 |
| 72 | |
| 73 | - __u16 |
| 74 | |
| 75 | - ``log_addr_mask`` |
| 76 | |
Hans Verkuil | 277f963 | 2016-08-10 06:00:53 -0300 | [diff] [blame] | 77 | - The current set of claimed logical addresses. This is 0 if no logical |
| 78 | addresses are claimed or if ``phys_addr`` is ``CEC_PHYS_ADDR_INVALID``. |
| 79 | If bit 15 is set (``1 << CEC_LOG_ADDR_UNREGISTERED``) then this device |
| 80 | has the unregistered logical address. In that case all other bits are 0. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 81 | |
| 82 | |
| 83 | |
Mauro Carvalho Chehab | 96f69e0 | 2016-07-09 10:25:05 -0300 | [diff] [blame] | 84 | .. _cec-event-lost-msgs_s: |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 85 | |
| 86 | .. flat-table:: struct cec_event_lost_msgs |
| 87 | :header-rows: 0 |
| 88 | :stub-columns: 0 |
Mauro Carvalho Chehab | b2a5843 | 2016-07-08 17:59:27 -0300 | [diff] [blame] | 89 | :widths: 1 1 16 |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 90 | |
| 91 | |
| 92 | - .. row 1 |
| 93 | |
| 94 | - __u32 |
| 95 | |
| 96 | - ``lost_msgs`` |
| 97 | |
| 98 | - Set to the number of lost messages since the filehandle was opened |
Mauro Carvalho Chehab | 706f8a9 | 2016-07-10 11:57:43 -0300 | [diff] [blame] | 99 | or since the last time this event was dequeued for this |
| 100 | filehandle. The messages lost are the oldest messages. So when a |
| 101 | new message arrives and there is no more room, then the oldest |
| 102 | message is discarded to make room for the new one. The internal |
| 103 | size of the message queue guarantees that all messages received in |
| 104 | the last two seconds will be stored. Since messages should be |
| 105 | replied to within a second according to the CEC specification, |
| 106 | this is more than enough. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 107 | |
| 108 | |
| 109 | |
| 110 | .. _cec-event: |
| 111 | |
| 112 | .. flat-table:: struct cec_event |
| 113 | :header-rows: 0 |
| 114 | :stub-columns: 0 |
Mauro Carvalho Chehab | b2a5843 | 2016-07-08 17:59:27 -0300 | [diff] [blame] | 115 | :widths: 1 1 1 8 |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 116 | |
| 117 | |
| 118 | - .. row 1 |
| 119 | |
| 120 | - __u64 |
| 121 | |
| 122 | - ``ts`` |
| 123 | |
| 124 | - Timestamp of the event in ns. |
Hans Verkuil | e5208ed | 2016-07-19 06:26:13 -0300 | [diff] [blame] | 125 | The timestamp has been taken from the ``CLOCK_MONOTONIC`` clock. To access |
| 126 | the same clock from userspace use :c:func:`clock_gettime(2)`. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 127 | |
| 128 | - |
| 129 | |
| 130 | - .. row 2 |
| 131 | |
| 132 | - __u32 |
| 133 | |
| 134 | - ``event`` |
| 135 | |
| 136 | - The CEC event type, see :ref:`cec-events`. |
| 137 | |
| 138 | - |
| 139 | |
| 140 | - .. row 3 |
| 141 | |
| 142 | - __u32 |
| 143 | |
| 144 | - ``flags`` |
| 145 | |
| 146 | - Event flags, see :ref:`cec-event-flags`. |
| 147 | |
| 148 | - |
| 149 | |
| 150 | - .. row 4 |
| 151 | |
| 152 | - union |
| 153 | |
| 154 | - (anonymous) |
| 155 | |
| 156 | - |
| 157 | - |
| 158 | |
| 159 | - .. row 5 |
| 160 | |
| 161 | - |
| 162 | - struct cec_event_state_change |
| 163 | |
| 164 | - ``state_change`` |
| 165 | |
Mauro Carvalho Chehab | 96f69e0 | 2016-07-09 10:25:05 -0300 | [diff] [blame] | 166 | - The new adapter state as sent by the :ref:`CEC_EVENT_STATE_CHANGE <CEC-EVENT-STATE-CHANGE>` |
Mauro Carvalho Chehab | 706f8a9 | 2016-07-10 11:57:43 -0300 | [diff] [blame] | 167 | event. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 168 | |
| 169 | - .. row 6 |
| 170 | |
| 171 | - |
| 172 | - struct cec_event_lost_msgs |
| 173 | |
| 174 | - ``lost_msgs`` |
| 175 | |
Mauro Carvalho Chehab | 96f69e0 | 2016-07-09 10:25:05 -0300 | [diff] [blame] | 176 | - The number of lost messages as sent by the :ref:`CEC_EVENT_LOST_MSGS <CEC-EVENT-LOST-MSGS>` |
Mauro Carvalho Chehab | 706f8a9 | 2016-07-10 11:57:43 -0300 | [diff] [blame] | 177 | event. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 178 | |
| 179 | |
| 180 | |
| 181 | .. _cec-events: |
| 182 | |
| 183 | .. flat-table:: CEC Events Types |
| 184 | :header-rows: 0 |
| 185 | :stub-columns: 0 |
Mauro Carvalho Chehab | b2a5843 | 2016-07-08 17:59:27 -0300 | [diff] [blame] | 186 | :widths: 3 1 16 |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 187 | |
| 188 | |
Mauro Carvalho Chehab | 96f69e0 | 2016-07-09 10:25:05 -0300 | [diff] [blame] | 189 | - .. _`CEC-EVENT-STATE-CHANGE`: |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 190 | |
| 191 | - ``CEC_EVENT_STATE_CHANGE`` |
| 192 | |
| 193 | - 1 |
| 194 | |
| 195 | - Generated when the CEC Adapter's state changes. When open() is |
Mauro Carvalho Chehab | 706f8a9 | 2016-07-10 11:57:43 -0300 | [diff] [blame] | 196 | called an initial event will be generated for that filehandle with |
| 197 | the CEC Adapter's state at that time. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 198 | |
Mauro Carvalho Chehab | 96f69e0 | 2016-07-09 10:25:05 -0300 | [diff] [blame] | 199 | - .. _`CEC-EVENT-LOST-MSGS`: |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 200 | |
| 201 | - ``CEC_EVENT_LOST_MSGS`` |
| 202 | |
| 203 | - 2 |
| 204 | |
| 205 | - Generated if one or more CEC messages were lost because the |
Mauro Carvalho Chehab | 706f8a9 | 2016-07-10 11:57:43 -0300 | [diff] [blame] | 206 | application didn't dequeue CEC messages fast enough. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 207 | |
| 208 | |
| 209 | |
| 210 | .. _cec-event-flags: |
| 211 | |
| 212 | .. flat-table:: CEC Event Flags |
| 213 | :header-rows: 0 |
| 214 | :stub-columns: 0 |
Mauro Carvalho Chehab | b2a5843 | 2016-07-08 17:59:27 -0300 | [diff] [blame] | 215 | :widths: 3 1 8 |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 216 | |
| 217 | |
Mauro Carvalho Chehab | 96f69e0 | 2016-07-09 10:25:05 -0300 | [diff] [blame] | 218 | - .. _`CEC-EVENT-FL-INITIAL-VALUE`: |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 219 | |
| 220 | - ``CEC_EVENT_FL_INITIAL_VALUE`` |
| 221 | |
| 222 | - 1 |
| 223 | |
| 224 | - Set for the initial events that are generated when the device is |
Mauro Carvalho Chehab | 706f8a9 | 2016-07-10 11:57:43 -0300 | [diff] [blame] | 225 | opened. See the table above for which events do this. This allows |
| 226 | applications to learn the initial state of the CEC adapter at |
| 227 | open() time. |
Markus Heiser | e2460b1 | 2016-07-08 20:55:42 +0200 | [diff] [blame] | 228 | |
| 229 | |
| 230 | |
| 231 | Return Value |
| 232 | ============ |
| 233 | |
| 234 | On success 0 is returned, on error -1 and the ``errno`` variable is set |
| 235 | appropriately. The generic error codes are described at the |
| 236 | :ref:`Generic Error Codes <gen-errors>` chapter. |