diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-26 21:59:59 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2016-07-26 21:59:59 -0400 |
| commit | 9c1958fc326a0a0a533ec8e86ea6fa30977207de (patch) | |
| tree | 9d76e6a146c2622fad0eefbb8ff0503caefe33cc /include | |
| parent | 1b3fc0bef8859268d542230172f80e85553fdab4 (diff) | |
| parent | 009a620848218d521f008141c62f56bf19294dd9 (diff) | |
Merge tag 'media/v4.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media
Pull media updates from Mauro Carvalho Chehab:
- new framework support for HDMI CEC and remote control support
- new encoding codec driver for Mediatek SoC
- new frontend driver: helene tuner
- added support for NetUp almost universal devices, with supports
DVB-C/S/S2/T/T2 and ISDB-T
- the mn88472 frontend driver got promoted from staging
- a new driver for RCar video input
- some soc_camera legacy drivers got removed: timb, omap1, mx2, mx3
- lots of driver cleanups, improvements and fixups
* tag 'media/v4.8-1' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-media: (377 commits)
[media] cec: always check all_device_types and features
[media] cec: poll should check if there is room in the tx queue
[media] vivid: support monitor all mode
[media] cec: fix test for unconfigured adapter in main message loop
[media] cec: limit the size of the transmit queue
[media] cec: zero unused msg part after msg->len
[media] cec: don't set fh to NULL in CEC_TRANSMIT
[media] cec: clear all status fields before transmit and always fill in sequence
[media] cec: CEC_RECEIVE overwrote the timeout field
[media] cxd2841er: Reading SNR for DVB-C added
[media] cxd2841er: Reading BER and UCB for DVB-C added
[media] cxd2841er: fix switch-case for DVB-C
[media] cxd2841er: fix signal strength scale for ISDB-T
[media] cxd2841er: adjust the dB scale for DVB-C
[media] cxd2841er: provide signal strength for DVB-C
[media] cxd2841er: fix BER report via DVBv5 stats API
[media] mb86a20s: apply mask to val after checking for read failure
[media] airspy: fix error logic during device register
[media] s5p-cec/TODO: add TODO item
[media] cec/TODO: drop comment about sphinx documentation
...
Diffstat (limited to 'include')
| -rw-r--r-- | include/linux/cec-funcs.h | 1899 | ||||
| -rw-r--r-- | include/linux/cec.h | 1011 | ||||
| -rw-r--r-- | include/linux/of_reserved_mem.h | 25 | ||||
| -rw-r--r-- | include/media/cec-edid.h | 104 | ||||
| -rw-r--r-- | include/media/cec.h | 241 | ||||
| -rw-r--r-- | include/media/davinci/vpbe_display.h | 2 | ||||
| -rw-r--r-- | include/media/i2c/adv7511.h | 6 | ||||
| -rw-r--r-- | include/media/i2c/adv7604.h | 2 | ||||
| -rw-r--r-- | include/media/i2c/adv7842.h | 2 | ||||
| -rw-r--r-- | include/media/media-device.h | 5 | ||||
| -rw-r--r-- | include/media/media-devnode.h | 46 | ||||
| -rw-r--r-- | include/media/rc-core.h | 3 | ||||
| -rw-r--r-- | include/media/rc-map.h | 6 | ||||
| -rw-r--r-- | include/media/rcar-fcp.h | 37 | ||||
| -rw-r--r-- | include/media/v4l2-ctrls.h | 34 | ||||
| -rw-r--r-- | include/media/v4l2-subdev.h | 21 | ||||
| -rw-r--r-- | include/media/videobuf2-core.h | 24 | ||||
| -rw-r--r-- | include/media/videobuf2-dma-contig.h | 11 | ||||
| -rw-r--r-- | include/media/videobuf2-dma-sg.h | 3 | ||||
| -rw-r--r-- | include/media/vsp1.h | 29 | ||||
| -rw-r--r-- | include/uapi/linux/media.h | 10 | ||||
| -rw-r--r-- | include/uapi/linux/serio.h | 1 | ||||
| -rw-r--r-- | include/uapi/linux/videodev2.h | 14 | ||||
| -rw-r--r-- | include/uapi/linux/vsp1.h | 34 |
24 files changed, 3419 insertions, 151 deletions
diff --git a/include/linux/cec-funcs.h b/include/linux/cec-funcs.h new file mode 100644 index 000000000000..82c3d3b7269d --- /dev/null +++ b/include/linux/cec-funcs.h | |||
| @@ -0,0 +1,1899 @@ | |||
| 1 | /* | ||
| 2 | * cec - HDMI Consumer Electronics Control message functions | ||
| 3 | * | ||
| 4 | * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved. | ||
| 5 | * | ||
| 6 | * This program is free software; you may redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; version 2 of the License. | ||
| 9 | * | ||
| 10 | * Alternatively you can redistribute this file under the terms of the | ||
| 11 | * BSD license as stated below: | ||
| 12 | * | ||
| 13 | * Redistribution and use in source and binary forms, with or without | ||
| 14 | * modification, are permitted provided that the following conditions | ||
| 15 | * are met: | ||
| 16 | * 1. Redistributions of source code must retain the above copyright | ||
| 17 | * notice, this list of conditions and the following disclaimer. | ||
| 18 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 19 | * notice, this list of conditions and the following disclaimer in | ||
| 20 | * the documentation and/or other materials provided with the | ||
| 21 | * distribution. | ||
| 22 | * 3. The names of its contributors may not be used to endorse or promote | ||
| 23 | * products derived from this software without specific prior written | ||
| 24 | * permission. | ||
| 25 | * | ||
| 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 27 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| 29 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
| 30 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
| 31 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 32 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 33 | * SOFTWARE. | ||
| 34 | */ | ||
| 35 | |||
| 36 | /* | ||
| 37 | * Note: this framework is still in staging and it is likely the API | ||
| 38 | * will change before it goes out of staging. | ||
| 39 | * | ||
| 40 | * Once it is moved out of staging this header will move to uapi. | ||
| 41 | */ | ||
| 42 | #ifndef _CEC_UAPI_FUNCS_H | ||
| 43 | #define _CEC_UAPI_FUNCS_H | ||
| 44 | |||
| 45 | #include <linux/cec.h> | ||
| 46 | |||
| 47 | /* One Touch Play Feature */ | ||
| 48 | static inline void cec_msg_active_source(struct cec_msg *msg, __u16 phys_addr) | ||
| 49 | { | ||
| 50 | msg->len = 4; | ||
| 51 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 52 | msg->msg[1] = CEC_MSG_ACTIVE_SOURCE; | ||
| 53 | msg->msg[2] = phys_addr >> 8; | ||
| 54 | msg->msg[3] = phys_addr & 0xff; | ||
| 55 | } | ||
| 56 | |||
| 57 | static inline void cec_ops_active_source(const struct cec_msg *msg, | ||
| 58 | __u16 *phys_addr) | ||
| 59 | { | ||
| 60 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 61 | } | ||
| 62 | |||
| 63 | static inline void cec_msg_image_view_on(struct cec_msg *msg) | ||
| 64 | { | ||
| 65 | msg->len = 2; | ||
| 66 | msg->msg[1] = CEC_MSG_IMAGE_VIEW_ON; | ||
| 67 | } | ||
| 68 | |||
| 69 | static inline void cec_msg_text_view_on(struct cec_msg *msg) | ||
| 70 | { | ||
| 71 | msg->len = 2; | ||
| 72 | msg->msg[1] = CEC_MSG_TEXT_VIEW_ON; | ||
| 73 | } | ||
| 74 | |||
| 75 | |||
| 76 | /* Routing Control Feature */ | ||
| 77 | static inline void cec_msg_inactive_source(struct cec_msg *msg, | ||
| 78 | __u16 phys_addr) | ||
| 79 | { | ||
| 80 | msg->len = 4; | ||
| 81 | msg->msg[1] = CEC_MSG_INACTIVE_SOURCE; | ||
| 82 | msg->msg[2] = phys_addr >> 8; | ||
| 83 | msg->msg[3] = phys_addr & 0xff; | ||
| 84 | } | ||
| 85 | |||
| 86 | static inline void cec_ops_inactive_source(const struct cec_msg *msg, | ||
| 87 | __u16 *phys_addr) | ||
| 88 | { | ||
| 89 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 90 | } | ||
| 91 | |||
| 92 | static inline void cec_msg_request_active_source(struct cec_msg *msg, | ||
| 93 | bool reply) | ||
| 94 | { | ||
| 95 | msg->len = 2; | ||
| 96 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 97 | msg->msg[1] = CEC_MSG_REQUEST_ACTIVE_SOURCE; | ||
| 98 | msg->reply = reply ? CEC_MSG_ACTIVE_SOURCE : 0; | ||
| 99 | } | ||
| 100 | |||
| 101 | static inline void cec_msg_routing_information(struct cec_msg *msg, | ||
| 102 | __u16 phys_addr) | ||
| 103 | { | ||
| 104 | msg->len = 4; | ||
| 105 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 106 | msg->msg[1] = CEC_MSG_ROUTING_INFORMATION; | ||
| 107 | msg->msg[2] = phys_addr >> 8; | ||
| 108 | msg->msg[3] = phys_addr & 0xff; | ||
| 109 | } | ||
| 110 | |||
| 111 | static inline void cec_ops_routing_information(const struct cec_msg *msg, | ||
| 112 | __u16 *phys_addr) | ||
| 113 | { | ||
| 114 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 115 | } | ||
| 116 | |||
| 117 | static inline void cec_msg_routing_change(struct cec_msg *msg, | ||
| 118 | bool reply, | ||
| 119 | __u16 orig_phys_addr, | ||
| 120 | __u16 new_phys_addr) | ||
| 121 | { | ||
| 122 | msg->len = 6; | ||
| 123 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 124 | msg->msg[1] = CEC_MSG_ROUTING_CHANGE; | ||
| 125 | msg->msg[2] = orig_phys_addr >> 8; | ||
| 126 | msg->msg[3] = orig_phys_addr & 0xff; | ||
| 127 | msg->msg[4] = new_phys_addr >> 8; | ||
| 128 | msg->msg[5] = new_phys_addr & 0xff; | ||
| 129 | msg->reply = reply ? CEC_MSG_ROUTING_INFORMATION : 0; | ||
| 130 | } | ||
| 131 | |||
| 132 | static inline void cec_ops_routing_change(const struct cec_msg *msg, | ||
| 133 | __u16 *orig_phys_addr, | ||
| 134 | __u16 *new_phys_addr) | ||
| 135 | { | ||
| 136 | *orig_phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 137 | *new_phys_addr = (msg->msg[4] << 8) | msg->msg[5]; | ||
| 138 | } | ||
| 139 | |||
| 140 | static inline void cec_msg_set_stream_path(struct cec_msg *msg, __u16 phys_addr) | ||
| 141 | { | ||
| 142 | msg->len = 4; | ||
| 143 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 144 | msg->msg[1] = CEC_MSG_SET_STREAM_PATH; | ||
| 145 | msg->msg[2] = phys_addr >> 8; | ||
| 146 | msg->msg[3] = phys_addr & 0xff; | ||
| 147 | } | ||
| 148 | |||
| 149 | static inline void cec_ops_set_stream_path(const struct cec_msg *msg, | ||
| 150 | __u16 *phys_addr) | ||
| 151 | { | ||
| 152 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 153 | } | ||
| 154 | |||
| 155 | |||
| 156 | /* Standby Feature */ | ||
| 157 | static inline void cec_msg_standby(struct cec_msg *msg) | ||
| 158 | { | ||
| 159 | msg->len = 2; | ||
| 160 | msg->msg[1] = CEC_MSG_STANDBY; | ||
| 161 | } | ||
| 162 | |||
| 163 | |||
| 164 | /* One Touch Record Feature */ | ||
| 165 | static inline void cec_msg_record_off(struct cec_msg *msg) | ||
| 166 | { | ||
| 167 | msg->len = 2; | ||
| 168 | msg->msg[1] = CEC_MSG_RECORD_OFF; | ||
| 169 | } | ||
| 170 | |||
| 171 | struct cec_op_arib_data { | ||
| 172 | __u16 transport_id; | ||
| 173 | __u16 service_id; | ||
| 174 | __u16 orig_network_id; | ||
| 175 | }; | ||
| 176 | |||
| 177 | struct cec_op_atsc_data { | ||
| 178 | __u16 transport_id; | ||
| 179 | __u16 program_number; | ||
| 180 | }; | ||
| 181 | |||
| 182 | struct cec_op_dvb_data { | ||
| 183 | __u16 transport_id; | ||
| 184 | __u16 service_id; | ||
| 185 | __u16 orig_network_id; | ||
| 186 | }; | ||
| 187 | |||
| 188 | struct cec_op_channel_data { | ||
| 189 | __u8 channel_number_fmt; | ||
| 190 | __u16 major; | ||
| 191 | __u16 minor; | ||
| 192 | }; | ||
| 193 | |||
| 194 | struct cec_op_digital_service_id { | ||
| 195 | __u8 service_id_method; | ||
| 196 | __u8 dig_bcast_system; | ||
| 197 | union { | ||
| 198 | struct cec_op_arib_data arib; | ||
| 199 | struct cec_op_atsc_data atsc; | ||
| 200 | struct cec_op_dvb_data dvb; | ||
| 201 | struct cec_op_channel_data channel; | ||
| 202 | }; | ||
| 203 | }; | ||
| 204 | |||
| 205 | struct cec_op_record_src { | ||
| 206 | __u8 type; | ||
| 207 | union { | ||
| 208 | struct cec_op_digital_service_id digital; | ||
| 209 | struct { | ||
| 210 | __u8 ana_bcast_type; | ||
| 211 | __u16 ana_freq; | ||
| 212 | __u8 bcast_system; | ||
| 213 | } analog; | ||
| 214 | struct { | ||
| 215 | __u8 plug; | ||
| 216 | } ext_plug; | ||
| 217 | struct { | ||
| 218 | __u16 phys_addr; | ||
| 219 | } ext_phys_addr; | ||
| 220 | }; | ||
| 221 | }; | ||
| 222 | |||
| 223 | static inline void cec_set_digital_service_id(__u8 *msg, | ||
| 224 | const struct cec_op_digital_service_id *digital) | ||
| 225 | { | ||
| 226 | *msg++ = (digital->service_id_method << 7) | digital->dig_bcast_system; | ||
| 227 | if (digital->service_id_method == CEC_OP_SERVICE_ID_METHOD_BY_CHANNEL) { | ||
| 228 | *msg++ = (digital->channel.channel_number_fmt << 2) | | ||
| 229 | (digital->channel.major >> 8); | ||
| 230 | *msg++ = digital->channel.major && 0xff; | ||
| 231 | *msg++ = digital->channel.minor >> 8; | ||
| 232 | *msg++ = digital->channel.minor & 0xff; | ||
| 233 | *msg++ = 0; | ||
| 234 | *msg++ = 0; | ||
| 235 | return; | ||
| 236 | } | ||
| 237 | switch (digital->dig_bcast_system) { | ||
| 238 | case CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_GEN: | ||
| 239 | case CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_CABLE: | ||
| 240 | case CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_SAT: | ||
| 241 | case CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_T: | ||
| 242 | *msg++ = digital->atsc.transport_id >> 8; | ||
| 243 | *msg++ = digital->atsc.transport_id & 0xff; | ||
| 244 | *msg++ = digital->atsc.program_number >> 8; | ||
| 245 | *msg++ = digital->atsc.program_number & 0xff; | ||
| 246 | *msg++ = 0; | ||
| 247 | *msg++ = 0; | ||
| 248 | break; | ||
| 249 | default: | ||
| 250 | *msg++ = digital->dvb.transport_id >> 8; | ||
| 251 | *msg++ = digital->dvb.transport_id & 0xff; | ||
| 252 | *msg++ = digital->dvb.service_id >> 8; | ||
| 253 | *msg++ = digital->dvb.service_id & 0xff; | ||
| 254 | *msg++ = digital->dvb.orig_network_id >> 8; | ||
| 255 | *msg++ = digital->dvb.orig_network_id & 0xff; | ||
| 256 | break; | ||
| 257 | } | ||
| 258 | } | ||
| 259 | |||
| 260 | static inline void cec_get_digital_service_id(const __u8 *msg, | ||
| 261 | struct cec_op_digital_service_id *digital) | ||
| 262 | { | ||
| 263 | digital->service_id_method = msg[0] >> 7; | ||
| 264 | digital->dig_bcast_system = msg[0] & 0x7f; | ||
| 265 | if (digital->service_id_method == CEC_OP_SERVICE_ID_METHOD_BY_CHANNEL) { | ||
| 266 | digital->channel.channel_number_fmt = msg[1] >> 2; | ||
| 267 | digital->channel.major = ((msg[1] & 3) << 6) | msg[2]; | ||
| 268 | digital->channel.minor = (msg[3] << 8) | msg[4]; | ||
| 269 | return; | ||
| 270 | } | ||
| 271 | digital->dvb.transport_id = (msg[1] << 8) | msg[2]; | ||
| 272 | digital->dvb.service_id = (msg[3] << 8) | msg[4]; | ||
| 273 | digital->dvb.orig_network_id = (msg[5] << 8) | msg[6]; | ||
| 274 | } | ||
| 275 | |||
| 276 | static inline void cec_msg_record_on_own(struct cec_msg *msg) | ||
| 277 | { | ||
| 278 | msg->len = 3; | ||
| 279 | msg->msg[1] = CEC_MSG_RECORD_ON; | ||
| 280 | msg->msg[2] = CEC_OP_RECORD_SRC_OWN; | ||
| 281 | } | ||
| 282 | |||
| 283 | static inline void cec_msg_record_on_digital(struct cec_msg *msg, | ||
| 284 | const struct cec_op_digital_service_id *digital) | ||
| 285 | { | ||
| 286 | msg->len = 10; | ||
| 287 | msg->msg[1] = CEC_MSG_RECORD_ON; | ||
| 288 | msg->msg[2] = CEC_OP_RECORD_SRC_DIGITAL; | ||
| 289 | cec_set_digital_service_id(msg->msg + 3, digital); | ||
| 290 | } | ||
| 291 | |||
| 292 | static inline void cec_msg_record_on_analog(struct cec_msg *msg, | ||
| 293 | __u8 ana_bcast_type, | ||
| 294 | __u16 ana_freq, | ||
| 295 | __u8 bcast_system) | ||
| 296 | { | ||
| 297 | msg->len = 7; | ||
| 298 | msg->msg[1] = CEC_MSG_RECORD_ON; | ||
| 299 | msg->msg[2] = CEC_OP_RECORD_SRC_ANALOG; | ||
| 300 | msg->msg[3] = ana_bcast_type; | ||
| 301 | msg->msg[4] = ana_freq >> 8; | ||
| 302 | msg->msg[5] = ana_freq & 0xff; | ||
| 303 | msg->msg[6] = bcast_system; | ||
| 304 | } | ||
| 305 | |||
| 306 | static inline void cec_msg_record_on_plug(struct cec_msg *msg, | ||
| 307 | __u8 plug) | ||
| 308 | { | ||
| 309 | msg->len = 4; | ||
| 310 | msg->msg[1] = CEC_MSG_RECORD_ON; | ||
| 311 | msg->msg[2] = CEC_OP_RECORD_SRC_EXT_PLUG; | ||
| 312 | msg->msg[3] = plug; | ||
| 313 | } | ||
| 314 | |||
| 315 | static inline void cec_msg_record_on_phys_addr(struct cec_msg *msg, | ||
| 316 | __u16 phys_addr) | ||
| 317 | { | ||
| 318 | msg->len = 5; | ||
| 319 | msg->msg[1] = CEC_MSG_RECORD_ON; | ||
| 320 | msg->msg[2] = CEC_OP_RECORD_SRC_EXT_PHYS_ADDR; | ||
| 321 | msg->msg[3] = phys_addr >> 8; | ||
| 322 | msg->msg[4] = phys_addr & 0xff; | ||
| 323 | } | ||
| 324 | |||
| 325 | static inline void cec_msg_record_on(struct cec_msg *msg, | ||
| 326 | const struct cec_op_record_src *rec_src) | ||
| 327 | { | ||
| 328 | switch (rec_src->type) { | ||
| 329 | case CEC_OP_RECORD_SRC_OWN: | ||
| 330 | cec_msg_record_on_own(msg); | ||
| 331 | break; | ||
| 332 | case CEC_OP_RECORD_SRC_DIGITAL: | ||
| 333 | cec_msg_record_on_digital(msg, &rec_src->digital); | ||
| 334 | break; | ||
| 335 | case CEC_OP_RECORD_SRC_ANALOG: | ||
| 336 | cec_msg_record_on_analog(msg, | ||
| 337 | rec_src->analog.ana_bcast_type, | ||
| 338 | rec_src->analog.ana_freq, | ||
| 339 | rec_src->analog.bcast_system); | ||
| 340 | break; | ||
| 341 | case CEC_OP_RECORD_SRC_EXT_PLUG: | ||
| 342 | cec_msg_record_on_plug(msg, rec_src->ext_plug.plug); | ||
| 343 | break; | ||
| 344 | case CEC_OP_RECORD_SRC_EXT_PHYS_ADDR: | ||
| 345 | cec_msg_record_on_phys_addr(msg, | ||
| 346 | rec_src->ext_phys_addr.phys_addr); | ||
| 347 | break; | ||
| 348 | } | ||
| 349 | } | ||
| 350 | |||
| 351 | static inline void cec_ops_record_on(const struct cec_msg *msg, | ||
| 352 | struct cec_op_record_src *rec_src) | ||
| 353 | { | ||
| 354 | rec_src->type = msg->msg[2]; | ||
| 355 | switch (rec_src->type) { | ||
| 356 | case CEC_OP_RECORD_SRC_OWN: | ||
| 357 | break; | ||
| 358 | case CEC_OP_RECORD_SRC_DIGITAL: | ||
| 359 | cec_get_digital_service_id(msg->msg + 3, &rec_src->digital); | ||
| 360 | break; | ||
| 361 | case CEC_OP_RECORD_SRC_ANALOG: | ||
| 362 | rec_src->analog.ana_bcast_type = msg->msg[3]; | ||
| 363 | rec_src->analog.ana_freq = | ||
| 364 | (msg->msg[4] << 8) | msg->msg[5]; | ||
| 365 | rec_src->analog.bcast_system = msg->msg[6]; | ||
| 366 | break; | ||
| 367 | case CEC_OP_RECORD_SRC_EXT_PLUG: | ||
| 368 | rec_src->ext_plug.plug = msg->msg[3]; | ||
| 369 | break; | ||
| 370 | case CEC_OP_RECORD_SRC_EXT_PHYS_ADDR: | ||
| 371 | rec_src->ext_phys_addr.phys_addr = | ||
| 372 | (msg->msg[3] << 8) | msg->msg[4]; | ||
| 373 | break; | ||
| 374 | } | ||
| 375 | } | ||
| 376 | |||
| 377 | static inline void cec_msg_record_status(struct cec_msg *msg, __u8 rec_status) | ||
| 378 | { | ||
| 379 | msg->len = 3; | ||
| 380 | msg->msg[1] = CEC_MSG_RECORD_STATUS; | ||
| 381 | msg->msg[2] = rec_status; | ||
| 382 | } | ||
| 383 | |||
| 384 | static inline void cec_ops_record_status(const struct cec_msg *msg, | ||
| 385 | __u8 *rec_status) | ||
| 386 | { | ||
| 387 | *rec_status = msg->msg[2]; | ||
| 388 | } | ||
| 389 | |||
| 390 | static inline void cec_msg_record_tv_screen(struct cec_msg *msg, | ||
| 391 | bool reply) | ||
| 392 | { | ||
| 393 | msg->len = 2; | ||
| 394 | msg->msg[1] = CEC_MSG_RECORD_TV_SCREEN; | ||
| 395 | msg->reply = reply ? CEC_MSG_RECORD_ON : 0; | ||
| 396 | } | ||
| 397 | |||
| 398 | |||
| 399 | /* Timer Programming Feature */ | ||
| 400 | static inline void cec_msg_timer_status(struct cec_msg *msg, | ||
| 401 | __u8 timer_overlap_warning, | ||
| 402 | __u8 media_info, | ||
| 403 | __u8 prog_info, | ||
| 404 | __u8 prog_error, | ||
| 405 | __u8 duration_hr, | ||
| 406 | __u8 duration_min) | ||
| 407 | { | ||
| 408 | msg->len = 3; | ||
| 409 | msg->msg[1] = CEC_MSG_TIMER_STATUS; | ||
| 410 | msg->msg[2] = (timer_overlap_warning << 7) | | ||
| 411 | (media_info << 5) | | ||
| 412 | (prog_info ? 0x10 : 0) | | ||
| 413 | (prog_info ? prog_info : prog_error); | ||
| 414 | if (prog_info == CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE || | ||
| 415 | prog_info == CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE || | ||
| 416 | prog_error == CEC_OP_PROG_ERROR_DUPLICATE) { | ||
| 417 | msg->len += 2; | ||
| 418 | msg->msg[3] = ((duration_hr / 10) << 4) | (duration_hr % 10); | ||
| 419 | msg->msg[4] = ((duration_min / 10) << 4) | (duration_min % 10); | ||
| 420 | } | ||
| 421 | } | ||
| 422 | |||
| 423 | static inline void cec_ops_timer_status(const struct cec_msg *msg, | ||
| 424 | __u8 *timer_overlap_warning, | ||
| 425 | __u8 *media_info, | ||
| 426 | __u8 *prog_info, | ||
| 427 | __u8 *prog_error, | ||
| 428 | __u8 *duration_hr, | ||
| 429 | __u8 *duration_min) | ||
| 430 | { | ||
| 431 | *timer_overlap_warning = msg->msg[2] >> 7; | ||
| 432 | *media_info = (msg->msg[2] >> 5) & 3; | ||
| 433 | if (msg->msg[2] & 0x10) { | ||
| 434 | *prog_info = msg->msg[2] & 0xf; | ||
| 435 | *prog_error = 0; | ||
| 436 | } else { | ||
| 437 | *prog_info = 0; | ||
| 438 | *prog_error = msg->msg[2] & 0xf; | ||
| 439 | } | ||
| 440 | if (*prog_info == CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE || | ||
| 441 | *prog_info == CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE || | ||
| 442 | *prog_error == CEC_OP_PROG_ERROR_DUPLICATE) { | ||
| 443 | *duration_hr = (msg->msg[3] >> 4) * 10 + (msg->msg[3] & 0xf); | ||
| 444 | *duration_min = (msg->msg[4] >> 4) * 10 + (msg->msg[4] & 0xf); | ||
| 445 | } else { | ||
| 446 | *duration_hr = *duration_min = 0; | ||
| 447 | } | ||
| 448 | } | ||
| 449 | |||
| 450 | static inline void cec_msg_timer_cleared_status(struct cec_msg *msg, | ||
| 451 | __u8 timer_cleared_status) | ||
| 452 | { | ||
| 453 | msg->len = 3; | ||
| 454 | msg->msg[1] = CEC_MSG_TIMER_CLEARED_STATUS; | ||
| 455 | msg->msg[2] = timer_cleared_status; | ||
| 456 | } | ||
| 457 | |||
| 458 | static inline void cec_ops_timer_cleared_status(const struct cec_msg *msg, | ||
| 459 | __u8 *timer_cleared_status) | ||
| 460 | { | ||
| 461 | *timer_cleared_status = msg->msg[2]; | ||
| 462 | } | ||
| 463 | |||
| 464 | static inline void cec_msg_clear_analogue_timer(struct cec_msg *msg, | ||
| 465 | bool reply, | ||
| 466 | __u8 day, | ||
| 467 | __u8 month, | ||
| 468 | __u8 start_hr, | ||
| 469 | __u8 start_min, | ||
| 470 | __u8 duration_hr, | ||
| 471 | __u8 duration_min, | ||
| 472 | __u8 recording_seq, | ||
| 473 | __u8 ana_bcast_type, | ||
| 474 | __u16 ana_freq, | ||
| 475 | __u8 bcast_system) | ||
| 476 | { | ||
| 477 | msg->len = 13; | ||
| 478 | msg->msg[1] = CEC_MSG_CLEAR_ANALOGUE_TIMER; | ||
| 479 | msg->msg[2] = day; | ||
| 480 | msg->msg[3] = month; | ||
| 481 | /* Hours and minutes are in BCD format */ | ||
| 482 | msg->msg[4] = ((start_hr / 10) << 4) | (start_hr % 10); | ||
| 483 | msg->msg[5] = ((start_min / 10) << 4) | (start_min % 10); | ||
| 484 | msg->msg[6] = ((duration_hr / 10) << 4) | (duration_hr % 10); | ||
| 485 | msg->msg[7] = ((duration_min / 10) << 4) | (duration_min % 10); | ||
| 486 | msg->msg[8] = recording_seq; | ||
| 487 | msg->msg[9] = ana_bcast_type; | ||
| 488 | msg->msg[10] = ana_freq >> 8; | ||
| 489 | msg->msg[11] = ana_freq & 0xff; | ||
| 490 | msg->msg[12] = bcast_system; | ||
| 491 | msg->reply = reply ? CEC_MSG_TIMER_CLEARED_STATUS : 0; | ||
| 492 | } | ||
| 493 | |||
| 494 | static inline void cec_ops_clear_analogue_timer(const struct cec_msg *msg, | ||
| 495 | __u8 *day, | ||
| 496 | __u8 *month, | ||
| 497 | __u8 *start_hr, | ||
| 498 | __u8 *start_min, | ||
| 499 | __u8 *duration_hr, | ||
| 500 | __u8 *duration_min, | ||
| 501 | __u8 *recording_seq, | ||
| 502 | __u8 *ana_bcast_type, | ||
| 503 | __u16 *ana_freq, | ||
| 504 | __u8 *bcast_system) | ||
| 505 | { | ||
| 506 | *day = msg->msg[2]; | ||
| 507 | *month = msg->msg[3]; | ||
| 508 | /* Hours and minutes are in BCD format */ | ||
| 509 | *start_hr = (msg->msg[4] >> 4) * 10 + (msg->msg[4] & 0xf); | ||
| 510 | *start_min = (msg->msg[5] >> 4) * 10 + (msg->msg[5] & 0xf); | ||
| 511 | *duration_hr = (msg->msg[6] >> 4) * 10 + (msg->msg[6] & 0xf); | ||
| 512 | *duration_min = (msg->msg[7] >> 4) * 10 + (msg->msg[7] & 0xf); | ||
| 513 | *recording_seq = msg->msg[8]; | ||
| 514 | *ana_bcast_type = msg->msg[9]; | ||
| 515 | *ana_freq = (msg->msg[10] << 8) | msg->msg[11]; | ||
| 516 | *bcast_system = msg->msg[12]; | ||
| 517 | } | ||
| 518 | |||
| 519 | static inline void cec_msg_clear_digital_timer(struct cec_msg *msg, | ||
| 520 | bool reply, | ||
| 521 | __u8 day, | ||
| 522 | __u8 month, | ||
| 523 | __u8 start_hr, | ||
| 524 | __u8 start_min, | ||
| 525 | __u8 duration_hr, | ||
| 526 | __u8 duration_min, | ||
| 527 | __u8 recording_seq, | ||
| 528 | const struct cec_op_digital_service_id *digital) | ||
| 529 | { | ||
| 530 | msg->len = 16; | ||
| 531 | msg->reply = reply ? CEC_MSG_TIMER_CLEARED_STATUS : 0; | ||
| 532 | msg->msg[1] = CEC_MSG_CLEAR_DIGITAL_TIMER; | ||
| 533 | msg->msg[2] = day; | ||
| 534 | msg->msg[3] = month; | ||
| 535 | /* Hours and minutes are in BCD format */ | ||
| 536 | msg->msg[4] = ((start_hr / 10) << 4) | (start_hr % 10); | ||
| 537 | msg->msg[5] = ((start_min / 10) << 4) | (start_min % 10); | ||
| 538 | msg->msg[6] = ((duration_hr / 10) << 4) | (duration_hr % 10); | ||
| 539 | msg->msg[7] = ((duration_min / 10) << 4) | (duration_min % 10); | ||
| 540 | msg->msg[8] = recording_seq; | ||
| 541 | cec_set_digital_service_id(msg->msg + 9, digital); | ||
| 542 | } | ||
| 543 | |||
| 544 | static inline void cec_ops_clear_digital_timer(const struct cec_msg *msg, | ||
| 545 | __u8 *day, | ||
| 546 | __u8 *month, | ||
| 547 | __u8 *start_hr, | ||
| 548 | __u8 *start_min, | ||
| 549 | __u8 *duration_hr, | ||
| 550 | __u8 *duration_min, | ||
| 551 | __u8 *recording_seq, | ||
| 552 | struct cec_op_digital_service_id *digital) | ||
| 553 | { | ||
| 554 | *day = msg->msg[2]; | ||
| 555 | *month = msg->msg[3]; | ||
| 556 | /* Hours and minutes are in BCD format */ | ||
| 557 | *start_hr = (msg->msg[4] >> 4) * 10 + (msg->msg[4] & 0xf); | ||
| 558 | *start_min = (msg->msg[5] >> 4) * 10 + (msg->msg[5] & 0xf); | ||
| 559 | *duration_hr = (msg->msg[6] >> 4) * 10 + (msg->msg[6] & 0xf); | ||
| 560 | *duration_min = (msg->msg[7] >> 4) * 10 + (msg->msg[7] & 0xf); | ||
| 561 | *recording_seq = msg->msg[8]; | ||
| 562 | cec_get_digital_service_id(msg->msg + 9, digital); | ||
| 563 | } | ||
| 564 | |||
| 565 | static inline void cec_msg_clear_ext_timer(struct cec_msg *msg, | ||
| 566 | bool reply, | ||
| 567 | __u8 day, | ||
| 568 | __u8 month, | ||
| 569 | __u8 start_hr, | ||
| 570 | __u8 start_min, | ||
| 571 | __u8 duration_hr, | ||
| 572 | __u8 duration_min, | ||
| 573 | __u8 recording_seq, | ||
| 574 | __u8 ext_src_spec, | ||
| 575 | __u8 plug, | ||
| 576 | __u16 phys_addr) | ||
| 577 | { | ||
| 578 | msg->len = 13; | ||
| 579 | msg->msg[1] = CEC_MSG_CLEAR_EXT_TIMER; | ||
| 580 | msg->msg[2] = day; | ||
| 581 | msg->msg[3] = month; | ||
| 582 | /* Hours and minutes are in BCD format */ | ||
| 583 | msg->msg[4] = ((start_hr / 10) << 4) | (start_hr % 10); | ||
| 584 | msg->msg[5] = ((start_min / 10) << 4) | (start_min % 10); | ||
| 585 | msg->msg[6] = ((duration_hr / 10) << 4) | (duration_hr % 10); | ||
| 586 | msg->msg[7] = ((duration_min / 10) << 4) | (duration_min % 10); | ||
| 587 | msg->msg[8] = recording_seq; | ||
| 588 | msg->msg[9] = ext_src_spec; | ||
| 589 | msg->msg[10] = plug; | ||
| 590 | msg->msg[11] = phys_addr >> 8; | ||
| 591 | msg->msg[12] = phys_addr & 0xff; | ||
| 592 | msg->reply = reply ? CEC_MSG_TIMER_CLEARED_STATUS : 0; | ||
| 593 | } | ||
| 594 | |||
| 595 | static inline void cec_ops_clear_ext_timer(const struct cec_msg *msg, | ||
| 596 | __u8 *day, | ||
| 597 | __u8 *month, | ||
| 598 | __u8 *start_hr, | ||
| 599 | __u8 *start_min, | ||
| 600 | __u8 *duration_hr, | ||
| 601 | __u8 *duration_min, | ||
| 602 | __u8 *recording_seq, | ||
| 603 | __u8 *ext_src_spec, | ||
| 604 | __u8 *plug, | ||
| 605 | __u16 *phys_addr) | ||
| 606 | { | ||
| 607 | *day = msg->msg[2]; | ||
| 608 | *month = msg->msg[3]; | ||
| 609 | /* Hours and minutes are in BCD format */ | ||
| 610 | *start_hr = (msg->msg[4] >> 4) * 10 + (msg->msg[4] & 0xf); | ||
| 611 | *start_min = (msg->msg[5] >> 4) * 10 + (msg->msg[5] & 0xf); | ||
| 612 | *duration_hr = (msg->msg[6] >> 4) * 10 + (msg->msg[6] & 0xf); | ||
| 613 | *duration_min = (msg->msg[7] >> 4) * 10 + (msg->msg[7] & 0xf); | ||
| 614 | *recording_seq = msg->msg[8]; | ||
| 615 | *ext_src_spec = msg->msg[9]; | ||
| 616 | *plug = msg->msg[10]; | ||
| 617 | *phys_addr = (msg->msg[11] << 8) | msg->msg[12]; | ||
| 618 | } | ||
| 619 | |||
| 620 | static inline void cec_msg_set_analogue_timer(struct cec_msg *msg, | ||
| 621 | bool reply, | ||
| 622 | __u8 day, | ||
| 623 | __u8 month, | ||
| 624 | __u8 start_hr, | ||
| 625 | __u8 start_min, | ||
| 626 | __u8 duration_hr, | ||
| 627 | __u8 duration_min, | ||
| 628 | __u8 recording_seq, | ||
| 629 | __u8 ana_bcast_type, | ||
| 630 | __u16 ana_freq, | ||
| 631 | __u8 bcast_system) | ||
| 632 | { | ||
| 633 | msg->len = 13; | ||
| 634 | msg->msg[1] = CEC_MSG_SET_ANALOGUE_TIMER; | ||
| 635 | msg->msg[2] = day; | ||
| 636 | msg->msg[3] = month; | ||
| 637 | /* Hours and minutes are in BCD format */ | ||
| 638 | msg->msg[4] = ((start_hr / 10) << 4) | (start_hr % 10); | ||
| 639 | msg->msg[5] = ((start_min / 10) << 4) | (start_min % 10); | ||
| 640 | msg->msg[6] = ((duration_hr / 10) << 4) | (duration_hr % 10); | ||
| 641 | msg->msg[7] = ((duration_min / 10) << 4) | (duration_min % 10); | ||
| 642 | msg->msg[8] = recording_seq; | ||
| 643 | msg->msg[9] = ana_bcast_type; | ||
| 644 | msg->msg[10] = ana_freq >> 8; | ||
| 645 | msg->msg[11] = ana_freq & 0xff; | ||
| 646 | msg->msg[12] = bcast_system; | ||
| 647 | msg->reply = reply ? CEC_MSG_TIMER_STATUS : 0; | ||
| 648 | } | ||
| 649 | |||
| 650 | static inline void cec_ops_set_analogue_timer(const struct cec_msg *msg, | ||
| 651 | __u8 *day, | ||
| 652 | __u8 *month, | ||
| 653 | __u8 *start_hr, | ||
| 654 | __u8 *start_min, | ||
| 655 | __u8 *duration_hr, | ||
| 656 | __u8 *duration_min, | ||
| 657 | __u8 *recording_seq, | ||
| 658 | __u8 *ana_bcast_type, | ||
| 659 | __u16 *ana_freq, | ||
| 660 | __u8 *bcast_system) | ||
| 661 | { | ||
| 662 | *day = msg->msg[2]; | ||
| 663 | *month = msg->msg[3]; | ||
| 664 | /* Hours and minutes are in BCD format */ | ||
| 665 | *start_hr = (msg->msg[4] >> 4) * 10 + (msg->msg[4] & 0xf); | ||
| 666 | *start_min = (msg->msg[5] >> 4) * 10 + (msg->msg[5] & 0xf); | ||
| 667 | *duration_hr = (msg->msg[6] >> 4) * 10 + (msg->msg[6] & 0xf); | ||
| 668 | *duration_min = (msg->msg[7] >> 4) * 10 + (msg->msg[7] & 0xf); | ||
| 669 | *recording_seq = msg->msg[8]; | ||
| 670 | *ana_bcast_type = msg->msg[9]; | ||
| 671 | *ana_freq = (msg->msg[10] << 8) | msg->msg[11]; | ||
| 672 | *bcast_system = msg->msg[12]; | ||
| 673 | } | ||
| 674 | |||
| 675 | static inline void cec_msg_set_digital_timer(struct cec_msg *msg, | ||
| 676 | bool reply, | ||
| 677 | __u8 day, | ||
| 678 | __u8 month, | ||
| 679 | __u8 start_hr, | ||
| 680 | __u8 start_min, | ||
| 681 | __u8 duration_hr, | ||
| 682 | __u8 duration_min, | ||
| 683 | __u8 recording_seq, | ||
| 684 | const struct cec_op_digital_service_id *digital) | ||
| 685 | { | ||
| 686 | msg->len = 16; | ||
| 687 | msg->reply = reply ? CEC_MSG_TIMER_STATUS : 0; | ||
| 688 | msg->msg[1] = CEC_MSG_SET_DIGITAL_TIMER; | ||
| 689 | msg->msg[2] = day; | ||
| 690 | msg->msg[3] = month; | ||
| 691 | /* Hours and minutes are in BCD format */ | ||
| 692 | msg->msg[4] = ((start_hr / 10) << 4) | (start_hr % 10); | ||
| 693 | msg->msg[5] = ((start_min / 10) << 4) | (start_min % 10); | ||
| 694 | msg->msg[6] = ((duration_hr / 10) << 4) | (duration_hr % 10); | ||
| 695 | msg->msg[7] = ((duration_min / 10) << 4) | (duration_min % 10); | ||
| 696 | msg->msg[8] = recording_seq; | ||
| 697 | cec_set_digital_service_id(msg->msg + 9, digital); | ||
| 698 | } | ||
| 699 | |||
| 700 | static inline void cec_ops_set_digital_timer(const struct cec_msg *msg, | ||
| 701 | __u8 *day, | ||
| 702 | __u8 *month, | ||
| 703 | __u8 *start_hr, | ||
| 704 | __u8 *start_min, | ||
| 705 | __u8 *duration_hr, | ||
| 706 | __u8 *duration_min, | ||
| 707 | __u8 *recording_seq, | ||
| 708 | struct cec_op_digital_service_id *digital) | ||
| 709 | { | ||
| 710 | *day = msg->msg[2]; | ||
| 711 | *month = msg->msg[3]; | ||
| 712 | /* Hours and minutes are in BCD format */ | ||
| 713 | *start_hr = (msg->msg[4] >> 4) * 10 + (msg->msg[4] & 0xf); | ||
| 714 | *start_min = (msg->msg[5] >> 4) * 10 + (msg->msg[5] & 0xf); | ||
| 715 | *duration_hr = (msg->msg[6] >> 4) * 10 + (msg->msg[6] & 0xf); | ||
| 716 | *duration_min = (msg->msg[7] >> 4) * 10 + (msg->msg[7] & 0xf); | ||
| 717 | *recording_seq = msg->msg[8]; | ||
| 718 | cec_get_digital_service_id(msg->msg + 9, digital); | ||
| 719 | } | ||
| 720 | |||
| 721 | static inline void cec_msg_set_ext_timer(struct cec_msg *msg, | ||
| 722 | bool reply, | ||
| 723 | __u8 day, | ||
| 724 | __u8 month, | ||
| 725 | __u8 start_hr, | ||
| 726 | __u8 start_min, | ||
| 727 | __u8 duration_hr, | ||
| 728 | __u8 duration_min, | ||
| 729 | __u8 recording_seq, | ||
| 730 | __u8 ext_src_spec, | ||
| 731 | __u8 plug, | ||
| 732 | __u16 phys_addr) | ||
| 733 | { | ||
| 734 | msg->len = 13; | ||
| 735 | msg->msg[1] = CEC_MSG_SET_EXT_TIMER; | ||
| 736 | msg->msg[2] = day; | ||
| 737 | msg->msg[3] = month; | ||
| 738 | /* Hours and minutes are in BCD format */ | ||
| 739 | msg->msg[4] = ((start_hr / 10) << 4) | (start_hr % 10); | ||
| 740 | msg->msg[5] = ((start_min / 10) << 4) | (start_min % 10); | ||
| 741 | msg->msg[6] = ((duration_hr / 10) << 4) | (duration_hr % 10); | ||
| 742 | msg->msg[7] = ((duration_min / 10) << 4) | (duration_min % 10); | ||
| 743 | msg->msg[8] = recording_seq; | ||
| 744 | msg->msg[9] = ext_src_spec; | ||
| 745 | msg->msg[10] = plug; | ||
| 746 | msg->msg[11] = phys_addr >> 8; | ||
| 747 | msg->msg[12] = phys_addr & 0xff; | ||
| 748 | msg->reply = reply ? CEC_MSG_TIMER_STATUS : 0; | ||
| 749 | } | ||
| 750 | |||
| 751 | static inline void cec_ops_set_ext_timer(const struct cec_msg *msg, | ||
| 752 | __u8 *day, | ||
| 753 | __u8 *month, | ||
| 754 | __u8 *start_hr, | ||
| 755 | __u8 *start_min, | ||
| 756 | __u8 *duration_hr, | ||
| 757 | __u8 *duration_min, | ||
| 758 | __u8 *recording_seq, | ||
| 759 | __u8 *ext_src_spec, | ||
| 760 | __u8 *plug, | ||
| 761 | __u16 *phys_addr) | ||
| 762 | { | ||
| 763 | *day = msg->msg[2]; | ||
| 764 | *month = msg->msg[3]; | ||
| 765 | /* Hours and minutes are in BCD format */ | ||
| 766 | *start_hr = (msg->msg[4] >> 4) * 10 + (msg->msg[4] & 0xf); | ||
| 767 | *start_min = (msg->msg[5] >> 4) * 10 + (msg->msg[5] & 0xf); | ||
| 768 | *duration_hr = (msg->msg[6] >> 4) * 10 + (msg->msg[6] & 0xf); | ||
| 769 | *duration_min = (msg->msg[7] >> 4) * 10 + (msg->msg[7] & 0xf); | ||
| 770 | *recording_seq = msg->msg[8]; | ||
| 771 | *ext_src_spec = msg->msg[9]; | ||
| 772 | *plug = msg->msg[10]; | ||
| 773 | *phys_addr = (msg->msg[11] << 8) | msg->msg[12]; | ||
| 774 | } | ||
| 775 | |||
| 776 | static inline void cec_msg_set_timer_program_title(struct cec_msg *msg, | ||
| 777 | const char *prog_title) | ||
| 778 | { | ||
| 779 | unsigned int len = strlen(prog_title); | ||
| 780 | |||
| 781 | if (len > 14) | ||
| 782 | len = 14; | ||
| 783 | msg->len = 2 + len; | ||
| 784 | msg->msg[1] = CEC_MSG_SET_TIMER_PROGRAM_TITLE; | ||
| 785 | memcpy(msg->msg + 2, prog_title, len); | ||
| 786 | } | ||
| 787 | |||
| 788 | static inline void cec_ops_set_timer_program_title(const struct cec_msg *msg, | ||
| 789 | char *prog_title) | ||
| 790 | { | ||
| 791 | unsigned int len = msg->len > 2 ? msg->len - 2 : 0; | ||
| 792 | |||
| 793 | if (len > 14) | ||
| 794 | len = 14; | ||
| 795 | memcpy(prog_title, msg->msg + 2, len); | ||
| 796 | prog_title[len] = '\0'; | ||
| 797 | } | ||
| 798 | |||
| 799 | /* System Information Feature */ | ||
| 800 | static inline void cec_msg_cec_version(struct cec_msg *msg, __u8 cec_version) | ||
| 801 | { | ||
| 802 | msg->len = 3; | ||
| 803 | msg->msg[1] = CEC_MSG_CEC_VERSION; | ||
| 804 | msg->msg[2] = cec_version; | ||
| 805 | } | ||
| 806 | |||
| 807 | static inline void cec_ops_cec_version(const struct cec_msg *msg, | ||
| 808 | __u8 *cec_version) | ||
| 809 | { | ||
| 810 | *cec_version = msg->msg[2]; | ||
| 811 | } | ||
| 812 | |||
| 813 | static inline void cec_msg_get_cec_version(struct cec_msg *msg, | ||
| 814 | bool reply) | ||
| 815 | { | ||
| 816 | msg->len = 2; | ||
| 817 | msg->msg[1] = CEC_MSG_GET_CEC_VERSION; | ||
| 818 | msg->reply = reply ? CEC_MSG_CEC_VERSION : 0; | ||
| 819 | } | ||
| 820 | |||
| 821 | static inline void cec_msg_report_physical_addr(struct cec_msg *msg, | ||
| 822 | __u16 phys_addr, __u8 prim_devtype) | ||
| 823 | { | ||
| 824 | msg->len = 5; | ||
| 825 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 826 | msg->msg[1] = CEC_MSG_REPORT_PHYSICAL_ADDR; | ||
| 827 | msg->msg[2] = phys_addr >> 8; | ||
| 828 | msg->msg[3] = phys_addr & 0xff; | ||
| 829 | msg->msg[4] = prim_devtype; | ||
| 830 | } | ||
| 831 | |||
| 832 | static inline void cec_ops_report_physical_addr(const struct cec_msg *msg, | ||
| 833 | __u16 *phys_addr, __u8 *prim_devtype) | ||
| 834 | { | ||
| 835 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 836 | *prim_devtype = msg->msg[4]; | ||
| 837 | } | ||
| 838 | |||
| 839 | static inline void cec_msg_give_physical_addr(struct cec_msg *msg, | ||
| 840 | bool reply) | ||
| 841 | { | ||
| 842 | msg->len = 2; | ||
| 843 | msg->msg[1] = CEC_MSG_GIVE_PHYSICAL_ADDR; | ||
| 844 | msg->reply = reply ? CEC_MSG_REPORT_PHYSICAL_ADDR : 0; | ||
| 845 | } | ||
| 846 | |||
| 847 | static inline void cec_msg_set_menu_language(struct cec_msg *msg, | ||
| 848 | const char *language) | ||
| 849 | { | ||
| 850 | msg->len = 5; | ||
| 851 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 852 | msg->msg[1] = CEC_MSG_SET_MENU_LANGUAGE; | ||
| 853 | memcpy(msg->msg + 2, language, 3); | ||
| 854 | } | ||
| 855 | |||
| 856 | static inline void cec_ops_set_menu_language(const struct cec_msg *msg, | ||
| 857 | char *language) | ||
| 858 | { | ||
| 859 | memcpy(language, msg->msg + 2, 3); | ||
| 860 | language[3] = '\0'; | ||
| 861 | } | ||
| 862 | |||
| 863 | static inline void cec_msg_get_menu_language(struct cec_msg *msg, | ||
| 864 | bool reply) | ||
| 865 | { | ||
| 866 | msg->len = 2; | ||
| 867 | msg->msg[1] = CEC_MSG_GET_MENU_LANGUAGE; | ||
| 868 | msg->reply = reply ? CEC_MSG_SET_MENU_LANGUAGE : 0; | ||
| 869 | } | ||
| 870 | |||
| 871 | /* | ||
| 872 | * Assumes a single RC Profile byte and a single Device Features byte, | ||
| 873 | * i.e. no extended features are supported by this helper function. | ||
| 874 | * | ||
| 875 | * As of CEC 2.0 no extended features are defined, should those be added | ||
| 876 | * in the future, then this function needs to be adapted or a new function | ||
| 877 | * should be added. | ||
| 878 | */ | ||
| 879 | static inline void cec_msg_report_features(struct cec_msg *msg, | ||
| 880 | __u8 cec_version, __u8 all_device_types, | ||
| 881 | __u8 rc_profile, __u8 dev_features) | ||
| 882 | { | ||
| 883 | msg->len = 6; | ||
| 884 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 885 | msg->msg[1] = CEC_MSG_REPORT_FEATURES; | ||
| 886 | msg->msg[2] = cec_version; | ||
| 887 | msg->msg[3] = all_device_types; | ||
| 888 | msg->msg[4] = rc_profile; | ||
| 889 | msg->msg[5] = dev_features; | ||
| 890 | } | ||
| 891 | |||
| 892 | static inline void cec_ops_report_features(const struct cec_msg *msg, | ||
| 893 | __u8 *cec_version, __u8 *all_device_types, | ||
| 894 | const __u8 **rc_profile, const __u8 **dev_features) | ||
| 895 | { | ||
| 896 | const __u8 *p = &msg->msg[4]; | ||
| 897 | |||
| 898 | *cec_version = msg->msg[2]; | ||
| 899 | *all_device_types = msg->msg[3]; | ||
| 900 | *rc_profile = p; | ||
| 901 | while (p < &msg->msg[14] && (*p & CEC_OP_FEAT_EXT)) | ||
| 902 | p++; | ||
| 903 | if (!(*p & CEC_OP_FEAT_EXT)) { | ||
| 904 | *dev_features = p + 1; | ||
| 905 | while (p < &msg->msg[15] && (*p & CEC_OP_FEAT_EXT)) | ||
| 906 | p++; | ||
| 907 | } | ||
| 908 | if (*p & CEC_OP_FEAT_EXT) | ||
| 909 | *rc_profile = *dev_features = NULL; | ||
| 910 | } | ||
| 911 | |||
| 912 | static inline void cec_msg_give_features(struct cec_msg *msg, | ||
| 913 | bool reply) | ||
| 914 | { | ||
| 915 | msg->len = 2; | ||
| 916 | msg->msg[1] = CEC_MSG_GIVE_FEATURES; | ||
| 917 | msg->reply = reply ? CEC_MSG_REPORT_FEATURES : 0; | ||
| 918 | } | ||
| 919 | |||
| 920 | /* Deck Control Feature */ | ||
| 921 | static inline void cec_msg_deck_control(struct cec_msg *msg, | ||
| 922 | __u8 deck_control_mode) | ||
| 923 | { | ||
| 924 | msg->len = 3; | ||
| 925 | msg->msg[1] = CEC_MSG_DECK_CONTROL; | ||
| 926 | msg->msg[2] = deck_control_mode; | ||
| 927 | } | ||
| 928 | |||
| 929 | static inline void cec_ops_deck_control(const struct cec_msg *msg, | ||
| 930 | __u8 *deck_control_mode) | ||
| 931 | { | ||
| 932 | *deck_control_mode = msg->msg[2]; | ||
| 933 | } | ||
| 934 | |||
| 935 | static inline void cec_msg_deck_status(struct cec_msg *msg, | ||
| 936 | __u8 deck_info) | ||
| 937 | { | ||
| 938 | msg->len = 3; | ||
| 939 | msg->msg[1] = CEC_MSG_DECK_STATUS; | ||
| 940 | msg->msg[2] = deck_info; | ||
| 941 | } | ||
| 942 | |||
| 943 | static inline void cec_ops_deck_status(const struct cec_msg *msg, | ||
| 944 | __u8 *deck_info) | ||
| 945 | { | ||
| 946 | *deck_info = msg->msg[2]; | ||
| 947 | } | ||
| 948 | |||
| 949 | static inline void cec_msg_give_deck_status(struct cec_msg *msg, | ||
| 950 | bool reply, | ||
| 951 | __u8 status_req) | ||
| 952 | { | ||
| 953 | msg->len = 3; | ||
| 954 | msg->msg[1] = CEC_MSG_GIVE_DECK_STATUS; | ||
| 955 | msg->msg[2] = status_req; | ||
| 956 | msg->reply = reply ? CEC_MSG_DECK_STATUS : 0; | ||
| 957 | } | ||
| 958 | |||
| 959 | static inline void cec_ops_give_deck_status(const struct cec_msg *msg, | ||
| 960 | __u8 *status_req) | ||
| 961 | { | ||
| 962 | *status_req = msg->msg[2]; | ||
| 963 | } | ||
| 964 | |||
| 965 | static inline void cec_msg_play(struct cec_msg *msg, | ||
| 966 | __u8 play_mode) | ||
| 967 | { | ||
| 968 | msg->len = 3; | ||
| 969 | msg->msg[1] = CEC_MSG_PLAY; | ||
| 970 | msg->msg[2] = play_mode; | ||
| 971 | } | ||
| 972 | |||
| 973 | static inline void cec_ops_play(const struct cec_msg *msg, | ||
| 974 | __u8 *play_mode) | ||
| 975 | { | ||
| 976 | *play_mode = msg->msg[2]; | ||
| 977 | } | ||
| 978 | |||
| 979 | |||
| 980 | /* Tuner Control Feature */ | ||
| 981 | struct cec_op_tuner_device_info { | ||
| 982 | __u8 rec_flag; | ||
| 983 | __u8 tuner_display_info; | ||
| 984 | bool is_analog; | ||
| 985 | union { | ||
| 986 | struct cec_op_digital_service_id digital; | ||
| 987 | struct { | ||
| 988 | __u8 ana_bcast_type; | ||
| 989 | __u16 ana_freq; | ||
| 990 | __u8 bcast_system; | ||
| 991 | } analog; | ||
| 992 | }; | ||
| 993 | }; | ||
| 994 | |||
| 995 | static inline void cec_msg_tuner_device_status_analog(struct cec_msg *msg, | ||
| 996 | __u8 rec_flag, | ||
| 997 | __u8 tuner_display_info, | ||
| 998 | __u8 ana_bcast_type, | ||
| 999 | __u16 ana_freq, | ||
| 1000 | __u8 bcast_system) | ||
| 1001 | { | ||
| 1002 | msg->len = 7; | ||
| 1003 | msg->msg[1] = CEC_MSG_TUNER_DEVICE_STATUS; | ||
| 1004 | msg->msg[2] = (rec_flag << 7) | tuner_display_info; | ||
| 1005 | msg->msg[3] = ana_bcast_type; | ||
| 1006 | msg->msg[4] = ana_freq >> 8; | ||
| 1007 | msg->msg[5] = ana_freq & 0xff; | ||
| 1008 | msg->msg[6] = bcast_system; | ||
| 1009 | } | ||
| 1010 | |||
| 1011 | static inline void cec_msg_tuner_device_status_digital(struct cec_msg *msg, | ||
| 1012 | __u8 rec_flag, __u8 tuner_display_info, | ||
| 1013 | const struct cec_op_digital_service_id *digital) | ||
| 1014 | { | ||
| 1015 | msg->len = 10; | ||
| 1016 | msg->msg[1] = CEC_MSG_TUNER_DEVICE_STATUS; | ||
| 1017 | msg->msg[2] = (rec_flag << 7) | tuner_display_info; | ||
| 1018 | cec_set_digital_service_id(msg->msg + 3, digital); | ||
| 1019 | } | ||
| 1020 | |||
| 1021 | static inline void cec_msg_tuner_device_status(struct cec_msg *msg, | ||
| 1022 | const struct cec_op_tuner_device_info *tuner_dev_info) | ||
| 1023 | { | ||
| 1024 | if (tuner_dev_info->is_analog) | ||
| 1025 | cec_msg_tuner_device_status_analog(msg, | ||
| 1026 | tuner_dev_info->rec_flag, | ||
| 1027 | tuner_dev_info->tuner_display_info, | ||
| 1028 | tuner_dev_info->analog.ana_bcast_type, | ||
| 1029 | tuner_dev_info->analog.ana_freq, | ||
| 1030 | tuner_dev_info->analog.bcast_system); | ||
| 1031 | else | ||
| 1032 | cec_msg_tuner_device_status_digital(msg, | ||
| 1033 | tuner_dev_info->rec_flag, | ||
| 1034 | tuner_dev_info->tuner_display_info, | ||
| 1035 | &tuner_dev_info->digital); | ||
| 1036 | } | ||
| 1037 | |||
| 1038 | static inline void cec_ops_tuner_device_status(const struct cec_msg *msg, | ||
| 1039 | struct cec_op_tuner_device_info *tuner_dev_info) | ||
| 1040 | { | ||
| 1041 | tuner_dev_info->is_analog = msg->len < 10; | ||
| 1042 | tuner_dev_info->rec_flag = msg->msg[2] >> 7; | ||
| 1043 | tuner_dev_info->tuner_display_info = msg->msg[2] & 0x7f; | ||
| 1044 | if (tuner_dev_info->is_analog) { | ||
| 1045 | tuner_dev_info->analog.ana_bcast_type = msg->msg[3]; | ||
| 1046 | tuner_dev_info->analog.ana_freq = (msg->msg[4] << 8) | msg->msg[5]; | ||
| 1047 | tuner_dev_info->analog.bcast_system = msg->msg[6]; | ||
| 1048 | return; | ||
| 1049 | } | ||
| 1050 | cec_get_digital_service_id(msg->msg + 3, &tuner_dev_info->digital); | ||
| 1051 | } | ||
| 1052 | |||
| 1053 | static inline void cec_msg_give_tuner_device_status(struct cec_msg *msg, | ||
| 1054 | bool reply, | ||
| 1055 | __u8 status_req) | ||
| 1056 | { | ||
| 1057 | msg->len = 3; | ||
| 1058 | msg->msg[1] = CEC_MSG_GIVE_TUNER_DEVICE_STATUS; | ||
| 1059 | msg->msg[2] = status_req; | ||
| 1060 | msg->reply = reply ? CEC_MSG_TUNER_DEVICE_STATUS : 0; | ||
| 1061 | } | ||
| 1062 | |||
| 1063 | static inline void cec_ops_give_tuner_device_status(const struct cec_msg *msg, | ||
| 1064 | __u8 *status_req) | ||
| 1065 | { | ||
| 1066 | *status_req = msg->msg[2]; | ||
| 1067 | } | ||
| 1068 | |||
| 1069 | static inline void cec_msg_select_analogue_service(struct cec_msg *msg, | ||
| 1070 | __u8 ana_bcast_type, | ||
| 1071 | __u16 ana_freq, | ||
| 1072 | __u8 bcast_system) | ||
| 1073 | { | ||
| 1074 | msg->len = 6; | ||
| 1075 | msg->msg[1] = CEC_MSG_SELECT_ANALOGUE_SERVICE; | ||
| 1076 | msg->msg[2] = ana_bcast_type; | ||
| 1077 | msg->msg[3] = ana_freq >> 8; | ||
| 1078 | msg->msg[4] = ana_freq & 0xff; | ||
| 1079 | msg->msg[5] = bcast_system; | ||
| 1080 | } | ||
| 1081 | |||
| 1082 | static inline void cec_ops_select_analogue_service(const struct cec_msg *msg, | ||
| 1083 | __u8 *ana_bcast_type, | ||
| 1084 | __u16 *ana_freq, | ||
| 1085 | __u8 *bcast_system) | ||
| 1086 | { | ||
| 1087 | *ana_bcast_type = msg->msg[2]; | ||
| 1088 | *ana_freq = (msg->msg[3] << 8) | msg->msg[4]; | ||
| 1089 | *bcast_system = msg->msg[5]; | ||
| 1090 | } | ||
| 1091 | |||
| 1092 | static inline void cec_msg_select_digital_service(struct cec_msg *msg, | ||
| 1093 | const struct cec_op_digital_service_id *digital) | ||
| 1094 | { | ||
| 1095 | msg->len = 9; | ||
| 1096 | msg->msg[1] = CEC_MSG_SELECT_DIGITAL_SERVICE; | ||
| 1097 | cec_set_digital_service_id(msg->msg + 2, digital); | ||
| 1098 | } | ||
| 1099 | |||
| 1100 | static inline void cec_ops_select_digital_service(const struct cec_msg *msg, | ||
| 1101 | struct cec_op_digital_service_id *digital) | ||
| 1102 | { | ||
| 1103 | cec_get_digital_service_id(msg->msg + 2, digital); | ||
| 1104 | } | ||
| 1105 | |||
| 1106 | static inline void cec_msg_tuner_step_decrement(struct cec_msg *msg) | ||
| 1107 | { | ||
| 1108 | msg->len = 2; | ||
| 1109 | msg->msg[1] = CEC_MSG_TUNER_STEP_DECREMENT; | ||
| 1110 | } | ||
| 1111 | |||
| 1112 | static inline void cec_msg_tuner_step_increment(struct cec_msg *msg) | ||
| 1113 | { | ||
| 1114 | msg->len = 2; | ||
| 1115 | msg->msg[1] = CEC_MSG_TUNER_STEP_INCREMENT; | ||
| 1116 | } | ||
| 1117 | |||
| 1118 | |||
| 1119 | /* Vendor Specific Commands Feature */ | ||
| 1120 | static inline void cec_msg_device_vendor_id(struct cec_msg *msg, __u32 vendor_id) | ||
| 1121 | { | ||
| 1122 | msg->len = 5; | ||
| 1123 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1124 | msg->msg[1] = CEC_MSG_DEVICE_VENDOR_ID; | ||
| 1125 | msg->msg[2] = vendor_id >> 16; | ||
| 1126 | msg->msg[3] = (vendor_id >> 8) & 0xff; | ||
| 1127 | msg->msg[4] = vendor_id & 0xff; | ||
| 1128 | } | ||
| 1129 | |||
| 1130 | static inline void cec_ops_device_vendor_id(const struct cec_msg *msg, | ||
| 1131 | __u32 *vendor_id) | ||
| 1132 | { | ||
| 1133 | *vendor_id = (msg->msg[2] << 16) | (msg->msg[3] << 8) | msg->msg[4]; | ||
| 1134 | } | ||
| 1135 | |||
| 1136 | static inline void cec_msg_give_device_vendor_id(struct cec_msg *msg, | ||
| 1137 | bool reply) | ||
| 1138 | { | ||
| 1139 | msg->len = 2; | ||
| 1140 | msg->msg[1] = CEC_MSG_GIVE_DEVICE_VENDOR_ID; | ||
| 1141 | msg->reply = reply ? CEC_MSG_DEVICE_VENDOR_ID : 0; | ||
| 1142 | } | ||
| 1143 | |||
| 1144 | static inline void cec_msg_vendor_remote_button_up(struct cec_msg *msg) | ||
| 1145 | { | ||
| 1146 | msg->len = 2; | ||
| 1147 | msg->msg[1] = CEC_MSG_VENDOR_REMOTE_BUTTON_UP; | ||
| 1148 | } | ||
| 1149 | |||
| 1150 | |||
| 1151 | /* OSD Display Feature */ | ||
| 1152 | static inline void cec_msg_set_osd_string(struct cec_msg *msg, | ||
| 1153 | __u8 disp_ctl, | ||
| 1154 | const char *osd) | ||
| 1155 | { | ||
| 1156 | unsigned int len = strlen(osd); | ||
| 1157 | |||
| 1158 | if (len > 13) | ||
| 1159 | len = 13; | ||
| 1160 | msg->len = 3 + len; | ||
| 1161 | msg->msg[1] = CEC_MSG_SET_OSD_STRING; | ||
| 1162 | msg->msg[2] = disp_ctl; | ||
| 1163 | memcpy(msg->msg + 3, osd, len); | ||
| 1164 | } | ||
| 1165 | |||
| 1166 | static inline void cec_ops_set_osd_string(const struct cec_msg *msg, | ||
| 1167 | __u8 *disp_ctl, | ||
| 1168 | char *osd) | ||
| 1169 | { | ||
| 1170 | unsigned int len = msg->len > 3 ? msg->len - 3 : 0; | ||
| 1171 | |||
| 1172 | *disp_ctl = msg->msg[2]; | ||
| 1173 | if (len > 13) | ||
| 1174 | len = 13; | ||
| 1175 | memcpy(osd, msg->msg + 3, len); | ||
| 1176 | osd[len] = '\0'; | ||
| 1177 | } | ||
| 1178 | |||
| 1179 | |||
| 1180 | /* Device OSD Transfer Feature */ | ||
| 1181 | static inline void cec_msg_set_osd_name(struct cec_msg *msg, const char *name) | ||
| 1182 | { | ||
| 1183 | unsigned int len = strlen(name); | ||
| 1184 | |||
| 1185 | if (len > 14) | ||
| 1186 | len = 14; | ||
| 1187 | msg->len = 2 + len; | ||
| 1188 | msg->msg[1] = CEC_MSG_SET_OSD_NAME; | ||
| 1189 | memcpy(msg->msg + 2, name, len); | ||
| 1190 | } | ||
| 1191 | |||
| 1192 | static inline void cec_ops_set_osd_name(const struct cec_msg *msg, | ||
| 1193 | char *name) | ||
| 1194 | { | ||
| 1195 | unsigned int len = msg->len > 2 ? msg->len - 2 : 0; | ||
| 1196 | |||
| 1197 | if (len > 14) | ||
| 1198 | len = 14; | ||
| 1199 | memcpy(name, msg->msg + 2, len); | ||
| 1200 | name[len] = '\0'; | ||
| 1201 | } | ||
| 1202 | |||
| 1203 | static inline void cec_msg_give_osd_name(struct cec_msg *msg, | ||
| 1204 | bool reply) | ||
| 1205 | { | ||
| 1206 | msg->len = 2; | ||
| 1207 | msg->msg[1] = CEC_MSG_GIVE_OSD_NAME; | ||
| 1208 | msg->reply = reply ? CEC_MSG_SET_OSD_NAME : 0; | ||
| 1209 | } | ||
| 1210 | |||
| 1211 | |||
| 1212 | /* Device Menu Control Feature */ | ||
| 1213 | static inline void cec_msg_menu_status(struct cec_msg *msg, | ||
| 1214 | __u8 menu_state) | ||
| 1215 | { | ||
| 1216 | msg->len = 3; | ||
| 1217 | msg->msg[1] = CEC_MSG_MENU_STATUS; | ||
| 1218 | msg->msg[2] = menu_state; | ||
| 1219 | } | ||
| 1220 | |||
| 1221 | static inline void cec_ops_menu_status(const struct cec_msg *msg, | ||
| 1222 | __u8 *menu_state) | ||
| 1223 | { | ||
| 1224 | *menu_state = msg->msg[2]; | ||
| 1225 | } | ||
| 1226 | |||
| 1227 | static inline void cec_msg_menu_request(struct cec_msg *msg, | ||
| 1228 | bool reply, | ||
| 1229 | __u8 menu_req) | ||
| 1230 | { | ||
| 1231 | msg->len = 3; | ||
| 1232 | msg->msg[1] = CEC_MSG_MENU_REQUEST; | ||
| 1233 | msg->msg[2] = menu_req; | ||
| 1234 | msg->reply = reply ? CEC_MSG_MENU_STATUS : 0; | ||
| 1235 | } | ||
| 1236 | |||
| 1237 | static inline void cec_ops_menu_request(const struct cec_msg *msg, | ||
| 1238 | __u8 *menu_req) | ||
| 1239 | { | ||
| 1240 | *menu_req = msg->msg[2]; | ||
| 1241 | } | ||
| 1242 | |||
| 1243 | struct cec_op_ui_command { | ||
| 1244 | __u8 ui_cmd; | ||
| 1245 | bool has_opt_arg; | ||
| 1246 | union { | ||
| 1247 | struct cec_op_channel_data channel_identifier; | ||
| 1248 | __u8 ui_broadcast_type; | ||
| 1249 | __u8 ui_sound_presentation_control; | ||
| 1250 | __u8 play_mode; | ||
| 1251 | __u8 ui_function_media; | ||
| 1252 | __u8 ui_function_select_av_input; | ||
| 1253 | __u8 ui_function_select_audio_input; | ||
| 1254 | }; | ||
| 1255 | }; | ||
| 1256 | |||
| 1257 | static inline void cec_msg_user_control_pressed(struct cec_msg *msg, | ||
| 1258 | const struct cec_op_ui_command *ui_cmd) | ||
| 1259 | { | ||
| 1260 | msg->len = 3; | ||
| 1261 | msg->msg[1] = CEC_MSG_USER_CONTROL_PRESSED; | ||
| 1262 | msg->msg[2] = ui_cmd->ui_cmd; | ||
| 1263 | if (!ui_cmd->has_opt_arg) | ||
| 1264 | return; | ||
| 1265 | switch (ui_cmd->ui_cmd) { | ||
| 1266 | case 0x56: | ||
| 1267 | case 0x57: | ||
| 1268 | case 0x60: | ||
| 1269 | case 0x68: | ||
| 1270 | case 0x69: | ||
| 1271 | case 0x6a: | ||
| 1272 | /* The optional operand is one byte for all these ui commands */ | ||
| 1273 | msg->len++; | ||
| 1274 | msg->msg[3] = ui_cmd->play_mode; | ||
| 1275 | break; | ||
| 1276 | case 0x67: | ||
| 1277 | msg->len += 4; | ||
| 1278 | msg->msg[3] = (ui_cmd->channel_identifier.channel_number_fmt << 2) | | ||
| 1279 | (ui_cmd->channel_identifier.major >> 8); | ||
| 1280 | msg->msg[4] = ui_cmd->channel_identifier.major && 0xff; | ||
| 1281 | msg->msg[5] = ui_cmd->channel_identifier.minor >> 8; | ||
| 1282 | msg->msg[6] = ui_cmd->channel_identifier.minor & 0xff; | ||
| 1283 | break; | ||
| 1284 | } | ||
| 1285 | } | ||
| 1286 | |||
| 1287 | static inline void cec_ops_user_control_pressed(const struct cec_msg *msg, | ||
| 1288 | struct cec_op_ui_command *ui_cmd) | ||
| 1289 | { | ||
| 1290 | ui_cmd->ui_cmd = msg->msg[2]; | ||
| 1291 | ui_cmd->has_opt_arg = false; | ||
| 1292 | if (msg->len == 3) | ||
| 1293 | return; | ||
| 1294 | switch (ui_cmd->ui_cmd) { | ||
| 1295 | case 0x56: | ||
| 1296 | case 0x57: | ||
| 1297 | case 0x60: | ||
| 1298 | case 0x68: | ||
| 1299 | case 0x69: | ||
| 1300 | case 0x6a: | ||
| 1301 | /* The optional operand is one byte for all these ui commands */ | ||
| 1302 | ui_cmd->play_mode = msg->msg[3]; | ||
| 1303 | ui_cmd->has_opt_arg = true; | ||
| 1304 | break; | ||
| 1305 | case 0x67: | ||
| 1306 | if (msg->len < 7) | ||
| 1307 | break; | ||
| 1308 | ui_cmd->has_opt_arg = true; | ||
| 1309 | ui_cmd->channel_identifier.channel_number_fmt = msg->msg[3] >> 2; | ||
| 1310 | ui_cmd->channel_identifier.major = ((msg->msg[3] & 3) << 6) | msg->msg[4]; | ||
| 1311 | ui_cmd->channel_identifier.minor = (msg->msg[5] << 8) | msg->msg[6]; | ||
| 1312 | break; | ||
| 1313 | } | ||
| 1314 | } | ||
| 1315 | |||
| 1316 | static inline void cec_msg_user_control_released(struct cec_msg *msg) | ||
| 1317 | { | ||
| 1318 | msg->len = 2; | ||
| 1319 | msg->msg[1] = CEC_MSG_USER_CONTROL_RELEASED; | ||
| 1320 | } | ||
| 1321 | |||
| 1322 | /* Remote Control Passthrough Feature */ | ||
| 1323 | |||
| 1324 | /* Power Status Feature */ | ||
| 1325 | static inline void cec_msg_report_power_status(struct cec_msg *msg, | ||
| 1326 | __u8 pwr_state) | ||
| 1327 | { | ||
| 1328 | msg->len = 3; | ||
| 1329 | msg->msg[1] = CEC_MSG_REPORT_POWER_STATUS; | ||
| 1330 | msg->msg[2] = pwr_state; | ||
| 1331 | } | ||
| 1332 | |||
| 1333 | static inline void cec_ops_report_power_status(const struct cec_msg *msg, | ||
| 1334 | __u8 *pwr_state) | ||
| 1335 | { | ||
| 1336 | *pwr_state = msg->msg[2]; | ||
| 1337 | } | ||
| 1338 | |||
| 1339 | static inline void cec_msg_give_device_power_status(struct cec_msg *msg, | ||
| 1340 | bool reply) | ||
| 1341 | { | ||
| 1342 | msg->len = 2; | ||
| 1343 | msg->msg[1] = CEC_MSG_GIVE_DEVICE_POWER_STATUS; | ||
| 1344 | msg->reply = reply ? CEC_MSG_REPORT_POWER_STATUS : 0; | ||
| 1345 | } | ||
| 1346 | |||
| 1347 | /* General Protocol Messages */ | ||
| 1348 | static inline void cec_msg_feature_abort(struct cec_msg *msg, | ||
| 1349 | __u8 abort_msg, __u8 reason) | ||
| 1350 | { | ||
| 1351 | msg->len = 4; | ||
| 1352 | msg->msg[1] = CEC_MSG_FEATURE_ABORT; | ||
| 1353 | msg->msg[2] = abort_msg; | ||
| 1354 | msg->msg[3] = reason; | ||
| 1355 | } | ||
| 1356 | |||
| 1357 | static inline void cec_ops_feature_abort(const struct cec_msg *msg, | ||
| 1358 | __u8 *abort_msg, __u8 *reason) | ||
| 1359 | { | ||
| 1360 | *abort_msg = msg->msg[2]; | ||
| 1361 | *reason = msg->msg[3]; | ||
| 1362 | } | ||
| 1363 | |||
| 1364 | /* This changes the current message into a feature abort message */ | ||
| 1365 | static inline void cec_msg_reply_feature_abort(struct cec_msg *msg, __u8 reason) | ||
| 1366 | { | ||
| 1367 | cec_msg_set_reply_to(msg, msg); | ||
| 1368 | msg->len = 4; | ||
| 1369 | msg->msg[2] = msg->msg[1]; | ||
| 1370 | msg->msg[3] = reason; | ||
| 1371 | msg->msg[1] = CEC_MSG_FEATURE_ABORT; | ||
| 1372 | } | ||
| 1373 | |||
| 1374 | static inline void cec_msg_abort(struct cec_msg *msg) | ||
| 1375 | { | ||
| 1376 | msg->len = 2; | ||
| 1377 | msg->msg[1] = CEC_MSG_ABORT; | ||
| 1378 | } | ||
| 1379 | |||
| 1380 | |||
| 1381 | /* System Audio Control Feature */ | ||
| 1382 | static inline void cec_msg_report_audio_status(struct cec_msg *msg, | ||
| 1383 | __u8 aud_mute_status, | ||
| 1384 | __u8 aud_vol_status) | ||
| 1385 | { | ||
| 1386 | msg->len = 3; | ||
| 1387 | msg->msg[1] = CEC_MSG_REPORT_AUDIO_STATUS; | ||
| 1388 | msg->msg[2] = (aud_mute_status << 7) | (aud_vol_status & 0x7f); | ||
| 1389 | } | ||
| 1390 | |||
| 1391 | static inline void cec_ops_report_audio_status(const struct cec_msg *msg, | ||
| 1392 | __u8 *aud_mute_status, | ||
| 1393 | __u8 *aud_vol_status) | ||
| 1394 | { | ||
| 1395 | *aud_mute_status = msg->msg[2] >> 7; | ||
| 1396 | *aud_vol_status = msg->msg[2] & 0x7f; | ||
| 1397 | } | ||
| 1398 | |||
| 1399 | static inline void cec_msg_give_audio_status(struct cec_msg *msg, | ||
| 1400 | bool reply) | ||
| 1401 | { | ||
| 1402 | msg->len = 2; | ||
| 1403 | msg->msg[1] = CEC_MSG_GIVE_AUDIO_STATUS; | ||
| 1404 | msg->reply = reply ? CEC_MSG_REPORT_AUDIO_STATUS : 0; | ||
| 1405 | } | ||
| 1406 | |||
| 1407 | static inline void cec_msg_set_system_audio_mode(struct cec_msg *msg, | ||
| 1408 | __u8 sys_aud_status) | ||
| 1409 | { | ||
| 1410 | msg->len = 3; | ||
| 1411 | msg->msg[1] = CEC_MSG_SET_SYSTEM_AUDIO_MODE; | ||
| 1412 | msg->msg[2] = sys_aud_status; | ||
| 1413 | } | ||
| 1414 | |||
| 1415 | static inline void cec_ops_set_system_audio_mode(const struct cec_msg *msg, | ||
| 1416 | __u8 *sys_aud_status) | ||
| 1417 | { | ||
| 1418 | *sys_aud_status = msg->msg[2]; | ||
| 1419 | } | ||
| 1420 | |||
| 1421 | static inline void cec_msg_system_audio_mode_request(struct cec_msg *msg, | ||
| 1422 | bool reply, | ||
| 1423 | __u16 phys_addr) | ||
| 1424 | { | ||
| 1425 | msg->len = phys_addr == 0xffff ? 2 : 4; | ||
| 1426 | msg->msg[1] = CEC_MSG_SYSTEM_AUDIO_MODE_REQUEST; | ||
| 1427 | msg->msg[2] = phys_addr >> 8; | ||
| 1428 | msg->msg[3] = phys_addr & 0xff; | ||
| 1429 | msg->reply = reply ? CEC_MSG_SET_SYSTEM_AUDIO_MODE : 0; | ||
| 1430 | |||
| 1431 | } | ||
| 1432 | |||
| 1433 | static inline void cec_ops_system_audio_mode_request(const struct cec_msg *msg, | ||
| 1434 | __u16 *phys_addr) | ||
| 1435 | { | ||
| 1436 | if (msg->len < 4) | ||
| 1437 | *phys_addr = 0xffff; | ||
| 1438 | else | ||
| 1439 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1440 | } | ||
| 1441 | |||
| 1442 | static inline void cec_msg_system_audio_mode_status(struct cec_msg *msg, | ||
| 1443 | __u8 sys_aud_status) | ||
| 1444 | { | ||
| 1445 | msg->len = 3; | ||
| 1446 | msg->msg[1] = CEC_MSG_SYSTEM_AUDIO_MODE_STATUS; | ||
| 1447 | msg->msg[2] = sys_aud_status; | ||
| 1448 | } | ||
| 1449 | |||
| 1450 | static inline void cec_ops_system_audio_mode_status(const struct cec_msg *msg, | ||
| 1451 | __u8 *sys_aud_status) | ||
| 1452 | { | ||
| 1453 | *sys_aud_status = msg->msg[2]; | ||
| 1454 | } | ||
| 1455 | |||
| 1456 | static inline void cec_msg_give_system_audio_mode_status(struct cec_msg *msg, | ||
| 1457 | bool reply) | ||
| 1458 | { | ||
| 1459 | msg->len = 2; | ||
| 1460 | msg->msg[1] = CEC_MSG_GIVE_SYSTEM_AUDIO_MODE_STATUS; | ||
| 1461 | msg->reply = reply ? CEC_MSG_SYSTEM_AUDIO_MODE_STATUS : 0; | ||
| 1462 | } | ||
| 1463 | |||
| 1464 | static inline void cec_msg_report_short_audio_descriptor(struct cec_msg *msg, | ||
| 1465 | __u8 num_descriptors, | ||
| 1466 | const __u32 *descriptors) | ||
| 1467 | { | ||
| 1468 | unsigned int i; | ||
| 1469 | |||
| 1470 | if (num_descriptors > 4) | ||
| 1471 | num_descriptors = 4; | ||
| 1472 | msg->len = 2 + num_descriptors * 3; | ||
| 1473 | msg->msg[1] = CEC_MSG_REPORT_SHORT_AUDIO_DESCRIPTOR; | ||
| 1474 | for (i = 0; i < num_descriptors; i++) { | ||
| 1475 | msg->msg[2 + i * 3] = (descriptors[i] >> 16) & 0xff; | ||
| 1476 | msg->msg[3 + i * 3] = (descriptors[i] >> 8) & 0xff; | ||
| 1477 | msg->msg[4 + i * 3] = descriptors[i] & 0xff; | ||
| 1478 | } | ||
| 1479 | } | ||
| 1480 | |||
| 1481 | static inline void cec_ops_report_short_audio_descriptor(const struct cec_msg *msg, | ||
| 1482 | __u8 *num_descriptors, | ||
| 1483 | __u32 *descriptors) | ||
| 1484 | { | ||
| 1485 | unsigned int i; | ||
| 1486 | |||
| 1487 | *num_descriptors = (msg->len - 2) / 3; | ||
| 1488 | if (*num_descriptors > 4) | ||
| 1489 | *num_descriptors = 4; | ||
| 1490 | for (i = 0; i < *num_descriptors; i++) | ||
| 1491 | descriptors[i] = (msg->msg[2 + i * 3] << 16) | | ||
| 1492 | (msg->msg[3 + i * 3] << 8) | | ||
| 1493 | msg->msg[4 + i * 3]; | ||
| 1494 | } | ||
| 1495 | |||
| 1496 | static inline void cec_msg_request_short_audio_descriptor(struct cec_msg *msg, | ||
| 1497 | bool reply, | ||
| 1498 | __u8 num_descriptors, | ||
| 1499 | const __u8 *audio_format_id, | ||
| 1500 | const __u8 *audio_format_code) | ||
| 1501 | { | ||
| 1502 | unsigned int i; | ||
| 1503 | |||
| 1504 | if (num_descriptors > 4) | ||
| 1505 | num_descriptors = 4; | ||
| 1506 | msg->len = 2 + num_descriptors; | ||
| 1507 | msg->msg[1] = CEC_MSG_REQUEST_SHORT_AUDIO_DESCRIPTOR; | ||
| 1508 | msg->reply = reply ? CEC_MSG_REPORT_SHORT_AUDIO_DESCRIPTOR : 0; | ||
| 1509 | for (i = 0; i < num_descriptors; i++) | ||
| 1510 | msg->msg[2 + i] = (audio_format_id[i] << 6) | | ||
| 1511 | (audio_format_code[i] & 0x3f); | ||
| 1512 | } | ||
| 1513 | |||
| 1514 | static inline void cec_ops_request_short_audio_descriptor(const struct cec_msg *msg, | ||
| 1515 | __u8 *num_descriptors, | ||
| 1516 | __u8 *audio_format_id, | ||
| 1517 | __u8 *audio_format_code) | ||
| 1518 | { | ||
| 1519 | unsigned int i; | ||
| 1520 | |||
| 1521 | *num_descriptors = msg->len - 2; | ||
| 1522 | if (*num_descriptors > 4) | ||
| 1523 | *num_descriptors = 4; | ||
| 1524 | for (i = 0; i < *num_descriptors; i++) { | ||
| 1525 | audio_format_id[i] = msg->msg[2 + i] >> 6; | ||
| 1526 | audio_format_code[i] = msg->msg[2 + i] & 0x3f; | ||
| 1527 | } | ||
| 1528 | } | ||
| 1529 | |||
| 1530 | |||
| 1531 | /* Audio Rate Control Feature */ | ||
| 1532 | static inline void cec_msg_set_audio_rate(struct cec_msg *msg, | ||
| 1533 | __u8 audio_rate) | ||
| 1534 | { | ||
| 1535 | msg->len = 3; | ||
| 1536 | msg->msg[1] = CEC_MSG_SET_AUDIO_RATE; | ||
| 1537 | msg->msg[2] = audio_rate; | ||
| 1538 | } | ||
| 1539 | |||
| 1540 | static inline void cec_ops_set_audio_rate(const struct cec_msg *msg, | ||
| 1541 | __u8 *audio_rate) | ||
| 1542 | { | ||
| 1543 | *audio_rate = msg->msg[2]; | ||
| 1544 | } | ||
| 1545 | |||
| 1546 | |||
| 1547 | /* Audio Return Channel Control Feature */ | ||
| 1548 | static inline void cec_msg_report_arc_initiated(struct cec_msg *msg) | ||
| 1549 | { | ||
| 1550 | msg->len = 2; | ||
| 1551 | msg->msg[1] = CEC_MSG_REPORT_ARC_INITIATED; | ||
| 1552 | } | ||
| 1553 | |||
| 1554 | static inline void cec_msg_initiate_arc(struct cec_msg *msg, | ||
| 1555 | bool reply) | ||
| 1556 | { | ||
| 1557 | msg->len = 2; | ||
| 1558 | msg->msg[1] = CEC_MSG_INITIATE_ARC; | ||
| 1559 | msg->reply = reply ? CEC_MSG_REPORT_ARC_INITIATED : 0; | ||
| 1560 | } | ||
| 1561 | |||
| 1562 | static inline void cec_msg_request_arc_initiation(struct cec_msg *msg, | ||
| 1563 | bool reply) | ||
| 1564 | { | ||
| 1565 | msg->len = 2; | ||
| 1566 | msg->msg[1] = CEC_MSG_REQUEST_ARC_INITIATION; | ||
| 1567 | msg->reply = reply ? CEC_MSG_INITIATE_ARC : 0; | ||
| 1568 | } | ||
| 1569 | |||
| 1570 | static inline void cec_msg_report_arc_terminated(struct cec_msg *msg) | ||
| 1571 | { | ||
| 1572 | msg->len = 2; | ||
| 1573 | msg->msg[1] = CEC_MSG_REPORT_ARC_TERMINATED; | ||
| 1574 | } | ||
| 1575 | |||
| 1576 | static inline void cec_msg_terminate_arc(struct cec_msg *msg, | ||
| 1577 | bool reply) | ||
| 1578 | { | ||
| 1579 | msg->len = 2; | ||
| 1580 | msg->msg[1] = CEC_MSG_TERMINATE_ARC; | ||
| 1581 | msg->reply = reply ? CEC_MSG_REPORT_ARC_TERMINATED : 0; | ||
| 1582 | } | ||
| 1583 | |||
| 1584 | static inline void cec_msg_request_arc_termination(struct cec_msg *msg, | ||
| 1585 | bool reply) | ||
| 1586 | { | ||
| 1587 | msg->len = 2; | ||
| 1588 | msg->msg[1] = CEC_MSG_REQUEST_ARC_TERMINATION; | ||
| 1589 | msg->reply = reply ? CEC_MSG_TERMINATE_ARC : 0; | ||
| 1590 | } | ||
| 1591 | |||
| 1592 | |||
| 1593 | /* Dynamic Audio Lipsync Feature */ | ||
| 1594 | /* Only for CEC 2.0 and up */ | ||
| 1595 | static inline void cec_msg_report_current_latency(struct cec_msg *msg, | ||
| 1596 | __u16 phys_addr, | ||
| 1597 | __u8 video_latency, | ||
| 1598 | __u8 low_latency_mode, | ||
| 1599 | __u8 audio_out_compensated, | ||
| 1600 | __u8 audio_out_delay) | ||
| 1601 | { | ||
| 1602 | msg->len = 7; | ||
| 1603 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1604 | msg->msg[1] = CEC_MSG_REPORT_CURRENT_LATENCY; | ||
| 1605 | msg->msg[2] = phys_addr >> 8; | ||
| 1606 | msg->msg[3] = phys_addr & 0xff; | ||
| 1607 | msg->msg[4] = video_latency; | ||
| 1608 | msg->msg[5] = (low_latency_mode << 2) | audio_out_compensated; | ||
| 1609 | msg->msg[6] = audio_out_delay; | ||
| 1610 | } | ||
| 1611 | |||
| 1612 | static inline void cec_ops_report_current_latency(const struct cec_msg *msg, | ||
| 1613 | __u16 *phys_addr, | ||
| 1614 | __u8 *video_latency, | ||
| 1615 | __u8 *low_latency_mode, | ||
| 1616 | __u8 *audio_out_compensated, | ||
| 1617 | __u8 *audio_out_delay) | ||
| 1618 | { | ||
| 1619 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1620 | *video_latency = msg->msg[4]; | ||
| 1621 | *low_latency_mode = (msg->msg[5] >> 2) & 1; | ||
| 1622 | *audio_out_compensated = msg->msg[5] & 3; | ||
| 1623 | *audio_out_delay = msg->msg[6]; | ||
| 1624 | } | ||
| 1625 | |||
| 1626 | static inline void cec_msg_request_current_latency(struct cec_msg *msg, | ||
| 1627 | bool reply, | ||
| 1628 | __u16 phys_addr) | ||
| 1629 | { | ||
| 1630 | msg->len = 4; | ||
| 1631 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1632 | msg->msg[1] = CEC_MSG_REQUEST_CURRENT_LATENCY; | ||
| 1633 | msg->msg[2] = phys_addr >> 8; | ||
| 1634 | msg->msg[3] = phys_addr & 0xff; | ||
| 1635 | msg->reply = reply ? CEC_MSG_REPORT_CURRENT_LATENCY : 0; | ||
| 1636 | } | ||
| 1637 | |||
| 1638 | static inline void cec_ops_request_current_latency(const struct cec_msg *msg, | ||
| 1639 | __u16 *phys_addr) | ||
| 1640 | { | ||
| 1641 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1642 | } | ||
| 1643 | |||
| 1644 | |||
| 1645 | /* Capability Discovery and Control Feature */ | ||
| 1646 | static inline void cec_msg_cdc_hec_inquire_state(struct cec_msg *msg, | ||
| 1647 | __u16 phys_addr1, | ||
| 1648 | __u16 phys_addr2) | ||
| 1649 | { | ||
| 1650 | msg->len = 9; | ||
| 1651 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1652 | msg->msg[1] = CEC_MSG_CDC_MESSAGE; | ||
| 1653 | /* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */ | ||
| 1654 | msg->msg[4] = CEC_MSG_CDC_HEC_INQUIRE_STATE; | ||
| 1655 | msg->msg[5] = phys_addr1 >> 8; | ||
| 1656 | msg->msg[6] = phys_addr1 & 0xff; | ||
| 1657 | msg->msg[7] = phys_addr2 >> 8; | ||
| 1658 | msg->msg[8] = phys_addr2 & 0xff; | ||
| 1659 | } | ||
| 1660 | |||
| 1661 | static inline void cec_ops_cdc_hec_inquire_state(const struct cec_msg *msg, | ||
| 1662 | __u16 *phys_addr, | ||
| 1663 | __u16 *phys_addr1, | ||
| 1664 | __u16 *phys_addr2) | ||
| 1665 | { | ||
| 1666 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1667 | *phys_addr1 = (msg->msg[5] << 8) | msg->msg[6]; | ||
| 1668 | *phys_addr2 = (msg->msg[7] << 8) | msg->msg[8]; | ||
| 1669 | } | ||
| 1670 | |||
| 1671 | static inline void cec_msg_cdc_hec_report_state(struct cec_msg *msg, | ||
| 1672 | __u16 target_phys_addr, | ||
| 1673 | __u8 hec_func_state, | ||
| 1674 | __u8 host_func_state, | ||
| 1675 | __u8 enc_func_state, | ||
| 1676 | __u8 cdc_errcode, | ||
| 1677 | __u8 has_field, | ||
| 1678 | __u16 hec_field) | ||
| 1679 | { | ||
| 1680 | msg->len = has_field ? 10 : 8; | ||
| 1681 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1682 | msg->msg[1] = CEC_MSG_CDC_MESSAGE; | ||
| 1683 | /* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */ | ||
| 1684 | msg->msg[4] = CEC_MSG_CDC_HEC_REPORT_STATE; | ||
| 1685 | msg->msg[5] = target_phys_addr >> 8; | ||
| 1686 | msg->msg[6] = target_phys_addr & 0xff; | ||
| 1687 | msg->msg[7] = (hec_func_state << 6) | | ||
| 1688 | (host_func_state << 4) | | ||
| 1689 | (enc_func_state << 2) | | ||
| 1690 | cdc_errcode; | ||
| 1691 | if (has_field) { | ||
| 1692 | msg->msg[8] = hec_field >> 8; | ||
| 1693 | msg->msg[9] = hec_field & 0xff; | ||
| 1694 | } | ||
| 1695 | } | ||
| 1696 | |||
| 1697 | static inline void cec_ops_cdc_hec_report_state(const struct cec_msg *msg, | ||
| 1698 | __u16 *phys_addr, | ||
| 1699 | __u16 *target_phys_addr, | ||
| 1700 | __u8 *hec_func_state, | ||
| 1701 | __u8 *host_func_state, | ||
| 1702 | __u8 *enc_func_state, | ||
| 1703 | __u8 *cdc_errcode, | ||
| 1704 | __u8 *has_field, | ||
| 1705 | __u16 *hec_field) | ||
| 1706 | { | ||
| 1707 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1708 | *target_phys_addr = (msg->msg[5] << 8) | msg->msg[6]; | ||
| 1709 | *hec_func_state = msg->msg[7] >> 6; | ||
| 1710 | *host_func_state = (msg->msg[7] >> 4) & 3; | ||
| 1711 | *enc_func_state = (msg->msg[7] >> 4) & 3; | ||
| 1712 | *cdc_errcode = msg->msg[7] & 3; | ||
| 1713 | *has_field = msg->len >= 10; | ||
| 1714 | *hec_field = *has_field ? ((msg->msg[8] << 8) | msg->msg[9]) : 0; | ||
| 1715 | } | ||
| 1716 | |||
| 1717 | static inline void cec_msg_cdc_hec_set_state(struct cec_msg *msg, | ||
| 1718 | __u16 phys_addr1, | ||
| 1719 | __u16 phys_addr2, | ||
| 1720 | __u8 hec_set_state, | ||
| 1721 | __u16 phys_addr3, | ||
| 1722 | __u16 phys_addr4, | ||
| 1723 | __u16 phys_addr5) | ||
| 1724 | { | ||
| 1725 | msg->len = 10; | ||
| 1726 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1727 | msg->msg[1] = CEC_MSG_CDC_MESSAGE; | ||
| 1728 | /* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */ | ||
| 1729 | msg->msg[4] = CEC_MSG_CDC_HEC_INQUIRE_STATE; | ||
| 1730 | msg->msg[5] = phys_addr1 >> 8; | ||
| 1731 | msg->msg[6] = phys_addr1 & 0xff; | ||
| 1732 | msg->msg[7] = phys_addr2 >> 8; | ||
| 1733 | msg->msg[8] = phys_addr2 & 0xff; | ||
| 1734 | msg->msg[9] = hec_set_state; | ||
| 1735 | if (phys_addr3 != CEC_PHYS_ADDR_INVALID) { | ||
| 1736 | msg->msg[msg->len++] = phys_addr3 >> 8; | ||
| 1737 | msg->msg[msg->len++] = phys_addr3 & 0xff; | ||
| 1738 | if (phys_addr4 != CEC_PHYS_ADDR_INVALID) { | ||
| 1739 | msg->msg[msg->len++] = phys_addr4 >> 8; | ||
| 1740 | msg->msg[msg->len++] = phys_addr4 & 0xff; | ||
| 1741 | if (phys_addr5 != CEC_PHYS_ADDR_INVALID) { | ||
| 1742 | msg->msg[msg->len++] = phys_addr5 >> 8; | ||
| 1743 | msg->msg[msg->len++] = phys_addr5 & 0xff; | ||
| 1744 | } | ||
| 1745 | } | ||
| 1746 | } | ||
| 1747 | } | ||
| 1748 | |||
| 1749 | static inline void cec_ops_cdc_hec_set_state(const struct cec_msg *msg, | ||
| 1750 | __u16 *phys_addr, | ||
| 1751 | __u16 *phys_addr1, | ||
| 1752 | __u16 *phys_addr2, | ||
| 1753 | __u8 *hec_set_state, | ||
| 1754 | __u16 *phys_addr3, | ||
| 1755 | __u16 *phys_addr4, | ||
| 1756 | __u16 *phys_addr5) | ||
| 1757 | { | ||
| 1758 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1759 | *phys_addr1 = (msg->msg[5] << 8) | msg->msg[6]; | ||
| 1760 | *phys_addr2 = (msg->msg[7] << 8) | msg->msg[8]; | ||
| 1761 | *hec_set_state = msg->msg[9]; | ||
| 1762 | *phys_addr3 = *phys_addr4 = *phys_addr5 = CEC_PHYS_ADDR_INVALID; | ||
| 1763 | if (msg->len >= 12) | ||
| 1764 | *phys_addr3 = (msg->msg[10] << 8) | msg->msg[11]; | ||
| 1765 | if (msg->len >= 14) | ||
| 1766 | *phys_addr4 = (msg->msg[12] << 8) | msg->msg[13]; | ||
| 1767 | if (msg->len >= 16) | ||
| 1768 | *phys_addr5 = (msg->msg[14] << 8) | msg->msg[15]; | ||
| 1769 | } | ||
| 1770 | |||
| 1771 | static inline void cec_msg_cdc_hec_set_state_adjacent(struct cec_msg *msg, | ||
| 1772 | __u16 phys_addr1, | ||
| 1773 | __u8 hec_set_state) | ||
| 1774 | { | ||
| 1775 | msg->len = 8; | ||
| 1776 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1777 | msg->msg[1] = CEC_MSG_CDC_MESSAGE; | ||
| 1778 | /* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */ | ||
| 1779 | msg->msg[4] = CEC_MSG_CDC_HEC_SET_STATE_ADJACENT; | ||
| 1780 | msg->msg[5] = phys_addr1 >> 8; | ||
| 1781 | msg->msg[6] = phys_addr1 & 0xff; | ||
| 1782 | msg->msg[7] = hec_set_state; | ||
| 1783 | } | ||
| 1784 | |||
| 1785 | static inline void cec_ops_cdc_hec_set_state_adjacent(const struct cec_msg *msg, | ||
| 1786 | __u16 *phys_addr, | ||
| 1787 | __u16 *phys_addr1, | ||
| 1788 | __u8 *hec_set_state) | ||
| 1789 | { | ||
| 1790 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1791 | *phys_addr1 = (msg->msg[5] << 8) | msg->msg[6]; | ||
| 1792 | *hec_set_state = msg->msg[7]; | ||
| 1793 | } | ||
| 1794 | |||
| 1795 | static inline void cec_msg_cdc_hec_request_deactivation(struct cec_msg *msg, | ||
| 1796 | __u16 phys_addr1, | ||
| 1797 | __u16 phys_addr2, | ||
| 1798 | __u16 phys_addr3) | ||
| 1799 | { | ||
| 1800 | msg->len = 11; | ||
| 1801 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1802 | msg->msg[1] = CEC_MSG_CDC_MESSAGE; | ||
| 1803 | /* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */ | ||
| 1804 | msg->msg[4] = CEC_MSG_CDC_HEC_REQUEST_DEACTIVATION; | ||
| 1805 | msg->msg[5] = phys_addr1 >> 8; | ||
| 1806 | msg->msg[6] = phys_addr1 & 0xff; | ||
| 1807 | msg->msg[7] = phys_addr2 >> 8; | ||
| 1808 | msg->msg[8] = phys_addr2 & 0xff; | ||
| 1809 | msg->msg[9] = phys_addr3 >> 8; | ||
| 1810 | msg->msg[10] = phys_addr3 & 0xff; | ||
| 1811 | } | ||
| 1812 | |||
| 1813 | static inline void cec_ops_cdc_hec_request_deactivation(const struct cec_msg *msg, | ||
| 1814 | __u16 *phys_addr, | ||
| 1815 | __u16 *phys_addr1, | ||
| 1816 | __u16 *phys_addr2, | ||
| 1817 | __u16 *phys_addr3) | ||
| 1818 | { | ||
| 1819 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1820 | *phys_addr1 = (msg->msg[5] << 8) | msg->msg[6]; | ||
| 1821 | *phys_addr2 = (msg->msg[7] << 8) | msg->msg[8]; | ||
| 1822 | *phys_addr3 = (msg->msg[9] << 8) | msg->msg[10]; | ||
| 1823 | } | ||
| 1824 | |||
| 1825 | static inline void cec_msg_cdc_hec_notify_alive(struct cec_msg *msg) | ||
| 1826 | { | ||
| 1827 | msg->len = 5; | ||
| 1828 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1829 | msg->msg[1] = CEC_MSG_CDC_MESSAGE; | ||
| 1830 | /* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */ | ||
| 1831 | msg->msg[4] = CEC_MSG_CDC_HEC_NOTIFY_ALIVE; | ||
| 1832 | } | ||
| 1833 | |||
| 1834 | static inline void cec_ops_cdc_hec_notify_alive(const struct cec_msg *msg, | ||
| 1835 | __u16 *phys_addr) | ||
| 1836 | { | ||
| 1837 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1838 | } | ||
| 1839 | |||
| 1840 | static inline void cec_msg_cdc_hec_discover(struct cec_msg *msg) | ||
| 1841 | { | ||
| 1842 | msg->len = 5; | ||
| 1843 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1844 | msg->msg[1] = CEC_MSG_CDC_MESSAGE; | ||
| 1845 | /* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */ | ||
| 1846 | msg->msg[4] = CEC_MSG_CDC_HEC_DISCOVER; | ||
| 1847 | } | ||
| 1848 | |||
| 1849 | static inline void cec_ops_cdc_hec_discover(const struct cec_msg *msg, | ||
| 1850 | __u16 *phys_addr) | ||
| 1851 | { | ||
| 1852 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1853 | } | ||
| 1854 | |||
| 1855 | static inline void cec_msg_cdc_hpd_set_state(struct cec_msg *msg, | ||
| 1856 | __u8 input_port, | ||
| 1857 | __u8 hpd_state) | ||
| 1858 | { | ||
| 1859 | msg->len = 6; | ||
| 1860 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1861 | msg->msg[1] = CEC_MSG_CDC_MESSAGE; | ||
| 1862 | /* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */ | ||
| 1863 | msg->msg[4] = CEC_MSG_CDC_HPD_SET_STATE; | ||
| 1864 | msg->msg[5] = (input_port << 4) | hpd_state; | ||
| 1865 | } | ||
| 1866 | |||
| 1867 | static inline void cec_ops_cdc_hpd_set_state(const struct cec_msg *msg, | ||
| 1868 | __u16 *phys_addr, | ||
| 1869 | __u8 *input_port, | ||
| 1870 | __u8 *hpd_state) | ||
| 1871 | { | ||
| 1872 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1873 | *input_port = msg->msg[5] >> 4; | ||
| 1874 | *hpd_state = msg->msg[5] & 0xf; | ||
| 1875 | } | ||
| 1876 | |||
| 1877 | static inline void cec_msg_cdc_hpd_report_state(struct cec_msg *msg, | ||
| 1878 | __u8 hpd_state, | ||
| 1879 | __u8 hpd_error) | ||
| 1880 | { | ||
| 1881 | msg->len = 6; | ||
| 1882 | msg->msg[0] |= 0xf; /* broadcast */ | ||
| 1883 | msg->msg[1] = CEC_MSG_CDC_MESSAGE; | ||
| 1884 | /* msg[2] and msg[3] (phys_addr) are filled in by the CEC framework */ | ||
| 1885 | msg->msg[4] = CEC_MSG_CDC_HPD_REPORT_STATE; | ||
| 1886 | msg->msg[5] = (hpd_state << 4) | hpd_error; | ||
| 1887 | } | ||
| 1888 | |||
| 1889 | static inline void cec_ops_cdc_hpd_report_state(const struct cec_msg *msg, | ||
| 1890 | __u16 *phys_addr, | ||
| 1891 | __u8 *hpd_state, | ||
| 1892 | __u8 *hpd_error) | ||
| 1893 | { | ||
| 1894 | *phys_addr = (msg->msg[2] << 8) | msg->msg[3]; | ||
| 1895 | *hpd_state = msg->msg[5] >> 4; | ||
| 1896 | *hpd_error = msg->msg[5] & 0xf; | ||
| 1897 | } | ||
| 1898 | |||
| 1899 | #endif | ||
diff --git a/include/linux/cec.h b/include/linux/cec.h new file mode 100644 index 000000000000..b3e22893a002 --- /dev/null +++ b/include/linux/cec.h | |||
| @@ -0,0 +1,1011 @@ | |||
| 1 | /* | ||
| 2 | * cec - HDMI Consumer Electronics Control public header | ||
| 3 | * | ||
| 4 | * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved. | ||
| 5 | * | ||
| 6 | * This program is free software; you may redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; version 2 of the License. | ||
| 9 | * | ||
| 10 | * Alternatively you can redistribute this file under the terms of the | ||
| 11 | * BSD license as stated below: | ||
| 12 | * | ||
| 13 | * Redistribution and use in source and binary forms, with or without | ||
| 14 | * modification, are permitted provided that the following conditions | ||
| 15 | * are met: | ||
| 16 | * 1. Redistributions of source code must retain the above copyright | ||
| 17 | * notice, this list of conditions and the following disclaimer. | ||
| 18 | * 2. Redistributions in binary form must reproduce the above copyright | ||
| 19 | * notice, this list of conditions and the following disclaimer in | ||
| 20 | * the documentation and/or other materials provided with the | ||
| 21 | * distribution. | ||
| 22 | * 3. The names of its contributors may not be used to endorse or promote | ||
| 23 | * products derived from this software without specific prior written | ||
| 24 | * permission. | ||
| 25 | * | ||
| 26 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 27 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 28 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| 29 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
| 30 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
| 31 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 32 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 33 | * SOFTWARE. | ||
| 34 | */ | ||
| 35 | |||
| 36 | /* | ||
| 37 | * Note: this framework is still in staging and it is likely the API | ||
| 38 | * will change before it goes out of staging. | ||
| 39 | * | ||
| 40 | * Once it is moved out of staging this header will move to uapi. | ||
| 41 | */ | ||
| 42 | #ifndef _CEC_UAPI_H | ||
| 43 | #define _CEC_UAPI_H | ||
| 44 | |||
| 45 | #include <linux/types.h> | ||
| 46 | |||
| 47 | #define CEC_MAX_MSG_SIZE 16 | ||
| 48 | |||
| 49 | /** | ||
| 50 | * struct cec_msg - CEC message structure. | ||
| 51 | * @tx_ts: Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by the | ||
| 52 | * driver when the message transmission has finished. | ||
| 53 | * @rx_ts: Timestamp in nanoseconds using CLOCK_MONOTONIC. Set by the | ||
| 54 | * driver when the message was received. | ||
| 55 | * @len: Length in bytes of the message. | ||
| 56 | * @timeout: The timeout (in ms) that is used to timeout CEC_RECEIVE. | ||
| 57 | * Set to 0 if you want to wait forever. This timeout can also be | ||
| 58 | * used with CEC_TRANSMIT as the timeout for waiting for a reply. | ||
| 59 | * If 0, then it will use a 1 second timeout instead of waiting | ||
| 60 | * forever as is done with CEC_RECEIVE. | ||
| 61 | * @sequence: The framework assigns a sequence number to messages that are | ||
| 62 | * sent. This can be used to track replies to previously sent | ||
| 63 | * messages. | ||
| 64 | * @flags: Set to 0. | ||
| 65 | * @msg: The message payload. | ||
| 66 | * @reply: This field is ignored with CEC_RECEIVE and is only used by | ||
| 67 | * CEC_TRANSMIT. If non-zero, then wait for a reply with this | ||
| 68 | * opcode. Set to CEC_MSG_FEATURE_ABORT if you want to wait for | ||
| 69 | * a possible ABORT reply. If there was an error when sending the | ||
| 70 | * msg or FeatureAbort was returned, then reply is set to 0. | ||
| 71 | * If reply is non-zero upon return, then len/msg are set to | ||
| 72 | * the received message. | ||
| 73 | * If reply is zero upon return and status has the | ||
| 74 | * CEC_TX_STATUS_FEATURE_ABORT bit set, then len/msg are set to | ||
| 75 | * the received feature abort message. | ||
| 76 | * If reply is zero upon return and status has the | ||
| 77 | * CEC_TX_STATUS_MAX_RETRIES bit set, then no reply was seen at | ||
| 78 | * all. If reply is non-zero for CEC_TRANSMIT and the message is a | ||
| 79 | * broadcast, then -EINVAL is returned. | ||
| 80 | * if reply is non-zero, then timeout is set to 1000 (the required | ||
| 81 | * maximum response time). | ||
| 82 | * @rx_status: The message receive status bits. Set by the driver. | ||
| 83 | * @tx_status: The message transmit status bits. Set by the driver. | ||
| 84 | * @tx_arb_lost_cnt: The number of 'Arbitration Lost' events. Set by the driver. | ||
| 85 | * @tx_nack_cnt: The number of 'Not Acknowledged' events. Set by the driver. | ||
| 86 | * @tx_low_drive_cnt: The number of 'Low Drive Detected' events. Set by the | ||
| 87 | * driver. | ||
| 88 | * @tx_error_cnt: The number of 'Error' events. Set by the driver. | ||
| 89 | */ | ||
| 90 | struct cec_msg { | ||
| 91 | __u64 tx_ts; | ||
| 92 | __u64 rx_ts; | ||
| 93 | __u32 len; | ||
| 94 | __u32 timeout; | ||
| 95 | __u32 sequence; | ||
| 96 | __u32 flags; | ||
| 97 | __u8 msg[CEC_MAX_MSG_SIZE]; | ||
| 98 | __u8 reply; | ||
| 99 | __u8 rx_status; | ||
| 100 | __u8 tx_status; | ||
| 101 | __u8 tx_arb_lost_cnt; | ||
| 102 | __u8 tx_nack_cnt; | ||
| 103 | __u8 tx_low_drive_cnt; | ||
| 104 | __u8 tx_error_cnt; | ||
| 105 | }; | ||
| 106 | |||
| 107 | /** | ||
| 108 | * cec_msg_initiator - return the initiator's logical address. | ||
| 109 | * @msg: the message structure | ||
| 110 | */ | ||
| 111 | static inline __u8 cec_msg_initiator(const struct cec_msg *msg) | ||
| 112 | { | ||
| 113 | return msg->msg[0] >> 4; | ||
| 114 | } | ||
| 115 | |||
| 116 | /** | ||
| 117 | * cec_msg_destination - return the destination's logical address. | ||
| 118 | * @msg: the message structure | ||
| 119 | */ | ||
| 120 | static inline __u8 cec_msg_destination(const struct cec_msg *msg) | ||
| 121 | { | ||
| 122 | return msg->msg[0] & 0xf; | ||
| 123 | } | ||
| 124 | |||
| 125 | /** | ||
| 126 | * cec_msg_opcode - return the opcode of the message, -1 for poll | ||
| 127 | * @msg: the message structure | ||
| 128 | */ | ||
| 129 | static inline int cec_msg_opcode(const struct cec_msg *msg) | ||
| 130 | { | ||
| 131 | return msg->len > 1 ? msg->msg[1] : -1; | ||
| 132 | } | ||
| 133 | |||
| 134 | /** | ||
| 135 | * cec_msg_is_broadcast - return true if this is a broadcast message. | ||
| 136 | * @msg: the message structure | ||
| 137 | */ | ||
| 138 | static inline bool cec_msg_is_broadcast(const struct cec_msg *msg) | ||
| 139 | { | ||
| 140 | return (msg->msg[0] & 0xf) == 0xf; | ||
| 141 | } | ||
| 142 | |||
| 143 | /** | ||
| 144 | * cec_msg_init - initialize the message structure. | ||
| 145 | * @msg: the message structure | ||
| 146 | * @initiator: the logical address of the initiator | ||
| 147 | * @destination:the logical address of the destination (0xf for broadcast) | ||
| 148 | * | ||
| 149 | * The whole structure is zeroed, the len field is set to 1 (i.e. a poll | ||
| 150 | * message) and the initiator and destination are filled in. | ||
| 151 | */ | ||
| 152 | static inline void cec_msg_init(struct cec_msg *msg, | ||
| 153 | __u8 initiator, __u8 destination) | ||
| 154 | { | ||
| 155 | memset(msg, 0, sizeof(*msg)); | ||
| 156 | msg->msg[0] = (initiator << 4) | destination; | ||
| 157 | msg->len = 1; | ||
| 158 | } | ||
| 159 | |||
| 160 | /** | ||
| 161 | * cec_msg_set_reply_to - fill in destination/initiator in a reply message. | ||
| 162 | * @msg: the message structure for the reply | ||
| 163 | * @orig: the original message structure | ||
| 164 | * | ||
| 165 | * Set the msg destination to the orig initiator and the msg initiator to the | ||
| 166 | * orig destination. Note that msg and orig may be the same pointer, in which | ||
| 167 | * case the change is done in place. | ||
| 168 | */ | ||
| 169 | static inline void cec_msg_set_reply_to(struct cec_msg *msg, | ||
| 170 | struct cec_msg *orig) | ||
| 171 | { | ||
| 172 | /* The destination becomes the initiator and vice versa */ | ||
| 173 | msg->msg[0] = (cec_msg_destination(orig) << 4) | | ||
| 174 | cec_msg_initiator(orig); | ||
| 175 | msg->reply = msg->timeout = 0; | ||
| 176 | } | ||
| 177 | |||
| 178 | /* cec status field */ | ||
| 179 | #define CEC_TX_STATUS_OK (1 << 0) | ||
| 180 | #define CEC_TX_STATUS_ARB_LOST (1 << 1) | ||
| 181 | #define CEC_TX_STATUS_NACK (1 << 2) | ||
| 182 | #define CEC_TX_STATUS_LOW_DRIVE (1 << 3) | ||
| 183 | #define CEC_TX_STATUS_ERROR (1 << 4) | ||
| 184 | #define CEC_TX_STATUS_MAX_RETRIES (1 << 5) | ||
| 185 | |||
| 186 | #define CEC_RX_STATUS_OK (1 << 0) | ||
| 187 | #define CEC_RX_STATUS_TIMEOUT (1 << 1) | ||
| 188 | #define CEC_RX_STATUS_FEATURE_ABORT (1 << 2) | ||
| 189 | |||
| 190 | static inline bool cec_msg_status_is_ok(const struct cec_msg *msg) | ||
| 191 | { | ||
| 192 | if (msg->tx_status && !(msg->tx_status & CEC_TX_STATUS_OK)) | ||
| 193 | return false; | ||
| 194 | if (msg->rx_status && !(msg->rx_status & CEC_RX_STATUS_OK)) | ||
| 195 | return false; | ||
| 196 | if (!msg->tx_status && !msg->rx_status) | ||
| 197 | return false; | ||
| 198 | return !(msg->rx_status & CEC_RX_STATUS_FEATURE_ABORT); | ||
| 199 | } | ||
| 200 | |||
| 201 | #define CEC_LOG_ADDR_INVALID 0xff | ||
| 202 | #define CEC_PHYS_ADDR_INVALID 0xffff | ||
| 203 | |||
| 204 | /* | ||
| 205 | * The maximum number of logical addresses one device can be assigned to. | ||
| 206 | * The CEC 2.0 spec allows for only 2 logical addresses at the moment. The | ||
| 207 | * Analog Devices CEC hardware supports 3. So let's go wild and go for 4. | ||
| 208 | */ | ||
| 209 | #define CEC_MAX_LOG_ADDRS 4 | ||
| 210 | |||
| 211 | /* The logical addresses defined by CEC 2.0 */ | ||
| 212 | #define CEC_LOG_ADDR_TV 0 | ||
| 213 | #define CEC_LOG_ADDR_RECORD_1 1 | ||
| 214 | #define CEC_LOG_ADDR_RECORD_2 2 | ||
| 215 | #define CEC_LOG_ADDR_TUNER_1 3 | ||
| 216 | #define CEC_LOG_ADDR_PLAYBACK_1 4 | ||
| 217 | #define CEC_LOG_ADDR_AUDIOSYSTEM 5 | ||
| 218 | #define CEC_LOG_ADDR_TUNER_2 6 | ||
| 219 | #define CEC_LOG_ADDR_TUNER_3 7 | ||
| 220 | #define CEC_LOG_ADDR_PLAYBACK_2 8 | ||
| 221 | #define CEC_LOG_ADDR_RECORD_3 9 | ||
| 222 | #define CEC_LOG_ADDR_TUNER_4 10 | ||
| 223 | #define CEC_LOG_ADDR_PLAYBACK_3 11 | ||
| 224 | #define CEC_LOG_ADDR_BACKUP_1 12 | ||
| 225 | #define CEC_LOG_ADDR_BACKUP_2 13 | ||
| 226 | #define CEC_LOG_ADDR_SPECIFIC 14 | ||
| 227 | #define CEC_LOG_ADDR_UNREGISTERED 15 /* as initiator address */ | ||
| 228 | #define CEC_LOG_ADDR_BROADCAST 15 /* ad destination address */ | ||
| 229 | |||
| 230 | /* The logical address types that the CEC device wants to claim */ | ||
| 231 | #define CEC_LOG_ADDR_TYPE_TV 0 | ||
| 232 | #define CEC_LOG_ADDR_TYPE_RECORD 1 | ||
| 233 | #define CEC_LOG_ADDR_TYPE_TUNER 2 | ||
| 234 | #define CEC_LOG_ADDR_TYPE_PLAYBACK 3 | ||
| 235 | #define CEC_LOG_ADDR_TYPE_AUDIOSYSTEM 4 | ||
| 236 | #define CEC_LOG_ADDR_TYPE_SPECIFIC 5 | ||
| 237 | #define CEC_LOG_ADDR_TYPE_UNREGISTERED 6 | ||
| 238 | /* | ||
| 239 | * Switches should use UNREGISTERED. | ||
| 240 | * Processors should use SPECIFIC. | ||
| 241 | */ | ||
| 242 | |||
| 243 | #define CEC_LOG_ADDR_MASK_TV (1 << CEC_LOG_ADDR_TV) | ||
| 244 | #define CEC_LOG_ADDR_MASK_RECORD ((1 << CEC_LOG_ADDR_RECORD_1) | \ | ||
| 245 | (1 << CEC_LOG_ADDR_RECORD_2) | \ | ||
| 246 | (1 << CEC_LOG_ADDR_RECORD_3)) | ||
| 247 | #define CEC_LOG_ADDR_MASK_TUNER ((1 << CEC_LOG_ADDR_TUNER_1) | \ | ||
| 248 | (1 << CEC_LOG_ADDR_TUNER_2) | \ | ||
| 249 | (1 << CEC_LOG_ADDR_TUNER_3) | \ | ||
| 250 | (1 << CEC_LOG_ADDR_TUNER_4)) | ||
| 251 | #define CEC_LOG_ADDR_MASK_PLAYBACK ((1 << CEC_LOG_ADDR_PLAYBACK_1) | \ | ||
| 252 | (1 << CEC_LOG_ADDR_PLAYBACK_2) | \ | ||
| 253 | (1 << CEC_LOG_ADDR_PLAYBACK_3)) | ||
| 254 | #define CEC_LOG_ADDR_MASK_AUDIOSYSTEM (1 << CEC_LOG_ADDR_AUDIOSYSTEM) | ||
| 255 | #define CEC_LOG_ADDR_MASK_BACKUP ((1 << CEC_LOG_ADDR_BACKUP_1) | \ | ||
| 256 | (1 << CEC_LOG_ADDR_BACKUP_2)) | ||
| 257 | #define CEC_LOG_ADDR_MASK_SPECIFIC (1 << CEC_LOG_ADDR_SPECIFIC) | ||
| 258 | #define CEC_LOG_ADDR_MASK_UNREGISTERED (1 << CEC_LOG_ADDR_UNREGISTERED) | ||
| 259 | |||
| 260 | static inline bool cec_has_tv(__u16 log_addr_mask) | ||
| 261 | { | ||
| 262 | return log_addr_mask & CEC_LOG_ADDR_MASK_TV; | ||
| 263 | } | ||
| 264 | |||
| 265 | static inline bool cec_has_record(__u16 log_addr_mask) | ||
| 266 | { | ||
| 267 | return log_addr_mask & CEC_LOG_ADDR_MASK_RECORD; | ||
| 268 | } | ||
| 269 | |||
| 270 | static inline bool cec_has_tuner(__u16 log_addr_mask) | ||
| 271 | { | ||
| 272 | return log_addr_mask & CEC_LOG_ADDR_MASK_TUNER; | ||
| 273 | } | ||
| 274 | |||
| 275 | static inline bool cec_has_playback(__u16 log_addr_mask) | ||
| 276 | { | ||
| 277 | return log_addr_mask & CEC_LOG_ADDR_MASK_PLAYBACK; | ||
| 278 | } | ||
| 279 | |||
| 280 | static inline bool cec_has_audiosystem(__u16 log_addr_mask) | ||
| 281 | { | ||
| 282 | return log_addr_mask & CEC_LOG_ADDR_MASK_AUDIOSYSTEM; | ||
| 283 | } | ||
| 284 | |||
| 285 | static inline bool cec_has_backup(__u16 log_addr_mask) | ||
| 286 | { | ||
| 287 | return log_addr_mask & CEC_LOG_ADDR_MASK_BACKUP; | ||
| 288 | } | ||
| 289 | |||
| 290 | static inline bool cec_has_specific(__u16 log_addr_mask) | ||
| 291 | { | ||
| 292 | return log_addr_mask & CEC_LOG_ADDR_MASK_SPECIFIC; | ||
| 293 | } | ||
| 294 | |||
| 295 | static inline bool cec_is_unregistered(__u16 log_addr_mask) | ||
| 296 | { | ||
| 297 | return log_addr_mask & CEC_LOG_ADDR_MASK_UNREGISTERED; | ||
| 298 | } | ||
| 299 | |||
| 300 | static inline bool cec_is_unconfigured(__u16 log_addr_mask) | ||
| 301 | { | ||
| 302 | return log_addr_mask == 0; | ||
| 303 | } | ||
| 304 | |||
| 305 | /* | ||
| 306 | * Use this if there is no vendor ID (CEC_G_VENDOR_ID) or if the vendor ID | ||
| 307 | * should be disabled (CEC_S_VENDOR_ID) | ||
| 308 | */ | ||
| 309 | #define CEC_VENDOR_ID_NONE 0xffffffff | ||
| 310 | |||
| 311 | /* The message handling modes */ | ||
| 312 | /* Modes for initiator */ | ||
| 313 | #define CEC_MODE_NO_INITIATOR (0x0 << 0) | ||
| 314 | #define CEC_MODE_INITIATOR (0x1 << 0) | ||
| 315 | #define CEC_MODE_EXCL_INITIATOR (0x2 << 0) | ||
| 316 | #define CEC_MODE_INITIATOR_MSK 0x0f | ||
| 317 | |||
| 318 | /* Modes for follower */ | ||
| 319 | #define CEC_MODE_NO_FOLLOWER (0x0 << 4) | ||
| 320 | #define CEC_MODE_FOLLOWER (0x1 << 4) | ||
| 321 | #define CEC_MODE_EXCL_FOLLOWER (0x2 << 4) | ||
| 322 | #define CEC_MODE_EXCL_FOLLOWER_PASSTHRU (0x3 << 4) | ||
| 323 | #define CEC_MODE_MONITOR (0xe << 4) | ||
| 324 | #define CEC_MODE_MONITOR_ALL (0xf << 4) | ||
| 325 | #define CEC_MODE_FOLLOWER_MSK 0xf0 | ||
| 326 | |||
| 327 | /* Userspace has to configure the physical address */ | ||
| 328 | #define CEC_CAP_PHYS_ADDR (1 << 0) | ||
| 329 | /* Userspace has to configure the logical addresses */ | ||
| 330 | #define CEC_CAP_LOG_ADDRS (1 << 1) | ||
| 331 | /* Userspace can transmit messages (and thus become follower as well) */ | ||
| 332 | #define CEC_CAP_TRANSMIT (1 << 2) | ||
| 333 | /* | ||
| 334 | * Passthrough all messages instead of processing them. | ||
| 335 | */ | ||
| 336 | #define CEC_CAP_PASSTHROUGH (1 << 3) | ||
| 337 | /* Supports remote control */ | ||
| 338 | #define CEC_CAP_RC (1 << 4) | ||
| 339 | /* Hardware can monitor all messages, not just directed and broadcast. */ | ||
| 340 | #define CEC_CAP_MONITOR_ALL (1 << 5) | ||
| 341 | |||
| 342 | /** | ||
| 343 | * struct cec_caps - CEC capabilities structure. | ||
| 344 | * @driver: name of the CEC device driver. | ||
| 345 | * @name: name of the CEC device. @driver + @name must be unique. | ||
| 346 | * @available_log_addrs: number of available logical addresses. | ||
| 347 | * @capabilities: capabilities of the CEC adapter. | ||
| 348 | * @version: version of the CEC adapter framework. | ||
| 349 | */ | ||
| 350 | struct cec_caps { | ||
| 351 | char driver[32]; | ||
| 352 | char name[32]; | ||
| 353 | __u32 available_log_addrs; | ||
| 354 | __u32 capabilities; | ||
| 355 | __u32 version; | ||
| 356 | }; | ||
| 357 | |||
| 358 | /** | ||
| 359 | * struct cec_log_addrs - CEC logical addresses structure. | ||
| 360 | * @log_addr: the claimed logical addresses. Set by the driver. | ||
| 361 | * @log_addr_mask: current logical address mask. Set by the driver. | ||
| 362 | * @cec_version: the CEC version that the adapter should implement. Set by the | ||
| 363 | * caller. | ||
| 364 | * @num_log_addrs: how many logical addresses should be claimed. Set by the | ||
| 365 | * caller. | ||
| 366 | * @vendor_id: the vendor ID of the device. Set by the caller. | ||
| 367 | * @flags: set to 0. | ||
| 368 | * @osd_name: the OSD name of the device. Set by the caller. | ||
| 369 | * @primary_device_type: the primary device type for each logical address. | ||
| 370 | * Set by the caller. | ||
| 371 | * @log_addr_type: the logical address types. Set by the caller. | ||
| 372 | * @all_device_types: CEC 2.0: all device types represented by the logical | ||
| 373 | * address. Set by the caller. | ||
| 374 | * @features: CEC 2.0: The logical address features. Set by the caller. | ||
| 375 | */ | ||
| 376 | struct cec_log_addrs { | ||
| 377 | __u8 log_addr[CEC_MAX_LOG_ADDRS]; | ||
| 378 | __u16 log_addr_mask; | ||
| 379 | __u8 cec_version; | ||
| 380 | __u8 num_log_addrs; | ||
| 381 | __u32 vendor_id; | ||
| 382 | __u32 flags; | ||
| 383 | char osd_name[15]; | ||
| 384 | __u8 primary_device_type[CEC_MAX_LOG_ADDRS]; | ||
| 385 | __u8 log_addr_type[CEC_MAX_LOG_ADDRS]; | ||
| 386 | |||
| 387 | /* CEC 2.0 */ | ||
| 388 | __u8 all_device_types[CEC_MAX_LOG_ADDRS]; | ||
| 389 | __u8 features[CEC_MAX_LOG_ADDRS][12]; | ||
| 390 | }; | ||
| 391 | |||
| 392 | /* Events */ | ||
| 393 | |||
| 394 | /* Event that occurs when the adapter state changes */ | ||
| 395 | #define CEC_EVENT_STATE_CHANGE 1 | ||
| 396 | /* | ||
| 397 | * This event is sent when messages are lost because the application | ||
| 398 | * didn't empty the message queue in time | ||
| 399 | */ | ||
| 400 | #define CEC_EVENT_LOST_MSGS 2 | ||
| 401 | |||
| 402 | #define CEC_EVENT_FL_INITIAL_STATE (1 << 0) | ||
| 403 | |||
| 404 | /** | ||
| 405 | * struct cec_event_state_change - used when the CEC adapter changes state. | ||
| 406 | * @phys_addr: the current physical address | ||
| 407 | * @log_addr_mask: the current logical address mask | ||
| 408 | */ | ||
| 409 | struct cec_event_state_change { | ||
| 410 | __u16 phys_addr; | ||
| 411 | __u16 log_addr_mask; | ||
| 412 | }; | ||
| 413 | |||
| 414 | /** | ||
| 415 | * struct cec_event_lost_msgs - tells you how many messages were lost due. | ||
| 416 | * @lost_msgs: how many messages were lost. | ||
| 417 | */ | ||
| 418 | struct cec_event_lost_msgs { | ||
| 419 | __u32 lost_msgs; | ||
| 420 | }; | ||
| 421 | |||
| 422 | /** | ||
| 423 | * struct cec_event - CEC event structure | ||
| 424 | * @ts: the timestamp of when the event was sent. | ||
| 425 | * @event: the event. | ||
| 426 | * array. | ||
| 427 | * @state_change: the event payload for CEC_EVENT_STATE_CHANGE. | ||
| 428 | * @lost_msgs: the event payload for CEC_EVENT_LOST_MSGS. | ||
| 429 | * @raw: array to pad the union. | ||
| 430 | */ | ||
| 431 | struct cec_event { | ||
| 432 | __u64 ts; | ||
| 433 | __u32 event; | ||
| 434 | __u32 flags; | ||
| 435 | union { | ||
| 436 | struct cec_event_state_change state_change; | ||
| 437 | struct cec_event_lost_msgs lost_msgs; | ||
| 438 | __u32 raw[16]; | ||
| 439 | }; | ||
| 440 | }; | ||
| 441 | |||
| 442 | /* ioctls */ | ||
| 443 | |||
| 444 | /* Adapter capabilities */ | ||
| 445 | #define CEC_ADAP_G_CAPS _IOWR('a', 0, struct cec_caps) | ||
| 446 | |||
| 447 | /* | ||
| 448 | * phys_addr is either 0 (if this is the CEC root device) | ||
| 449 | * or a valid physical address obtained from the sink's EDID | ||
| 450 | * as read by this CEC device (if this is a source device) | ||
| 451 | * or a physical address obtained and modified from a sink | ||
| 452 | * EDID and used for a sink CEC device. | ||
| 453 | * If nothing is connected, then phys_addr is 0xffff. | ||
| 454 | * See HDMI 1.4b, section 8.7 (Physical Address). | ||
| 455 | * | ||
| 456 | * The CEC_ADAP_S_PHYS_ADDR ioctl may not be available if that is handled | ||
| 457 | * internally. | ||
| 458 | */ | ||
| 459 | #define CEC_ADAP_G_PHYS_ADDR _IOR('a', 1, __u16) | ||
| 460 | #define CEC_ADAP_S_PHYS_ADDR _IOW('a', 2, __u16) | ||
| 461 | |||
| 462 | /* | ||
| 463 | * Configure the CEC adapter. It sets the device type and which | ||
| 464 | * logical types it will try to claim. It will return which | ||
| 465 | * logical addresses it could actually claim. | ||
| 466 | * An error is returned if the adapter is disabled or if there | ||
| 467 | * is no physical address assigned. | ||
| 468 | */ | ||
| 469 | |||
| 470 | #define CEC_ADAP_G_LOG_ADDRS _IOR('a', 3, struct cec_log_addrs) | ||
| 471 | #define CEC_ADAP_S_LOG_ADDRS _IOWR('a', 4, struct cec_log_addrs) | ||
| 472 | |||
| 473 | /* Transmit/receive a CEC command */ | ||
| 474 | #define CEC_TRANSMIT _IOWR('a', 5, struct cec_msg) | ||
| 475 | #define CEC_RECEIVE _IOWR('a', 6, struct cec_msg) | ||
| 476 | |||
| 477 | /* Dequeue CEC events */ | ||
| 478 | #define CEC_DQEVENT _IOWR('a', 7, struct cec_event) | ||
| 479 | |||
| 480 | /* | ||
| 481 | * Get and set the message handling mode for this filehandle. | ||
| 482 | */ | ||
| 483 | #define CEC_G_MODE _IOR('a', 8, __u32) | ||
| 484 | #define CEC_S_MODE _IOW('a', 9, __u32) | ||
| 485 | |||
| 486 | /* | ||
| 487 | * The remainder of this header defines all CEC messages and operands. | ||
| 488 | * The format matters since it the cec-ctl utility parses it to generate | ||
| 489 | * code for implementing all these messages. | ||
| 490 | * | ||
| 491 | * Comments ending with 'Feature' group messages for each feature. | ||
| 492 | * If messages are part of multiple features, then the "Has also" | ||
| 493 | * comment is used to list the previously defined messages that are | ||
| 494 | * supported by the feature. | ||
| 495 | * | ||
| 496 | * Before operands are defined a comment is added that gives the | ||
| 497 | * name of the operand and in brackets the variable name of the | ||
| 498 | * corresponding argument in the cec-funcs.h function. | ||
| 499 | */ | ||
| 500 | |||
| 501 | /* Messages */ | ||
| 502 | |||
| 503 | /* One Touch Play Feature */ | ||
| 504 | #define CEC_MSG_ACTIVE_SOURCE 0x82 | ||
| 505 | #define CEC_MSG_IMAGE_VIEW_ON 0x04 | ||
| 506 | #define CEC_MSG_TEXT_VIEW_ON 0x0d | ||
| 507 | |||
| 508 | |||
| 509 | /* Routing Control Feature */ | ||
| 510 | |||
| 511 | /* | ||
| 512 | * Has also: | ||
| 513 | * CEC_MSG_ACTIVE_SOURCE | ||
| 514 | */ | ||
| 515 | |||
| 516 | #define CEC_MSG_INACTIVE_SOURCE 0x9d | ||
| 517 | #define CEC_MSG_REQUEST_ACTIVE_SOURCE 0x85 | ||
| 518 | #define CEC_MSG_ROUTING_CHANGE 0x80 | ||
| 519 | #define CEC_MSG_ROUTING_INFORMATION 0x81 | ||
| 520 | #define CEC_MSG_SET_STREAM_PATH 0x86 | ||
| 521 | |||
| 522 | |||
| 523 | /* Standby Feature */ | ||
| 524 | #define CEC_MSG_STANDBY 0x36 | ||
| 525 | |||
| 526 | |||
| 527 | /* One Touch Record Feature */ | ||
| 528 | #define CEC_MSG_RECORD_OFF 0x0b | ||
| 529 | #define CEC_MSG_RECORD_ON 0x09 | ||
| 530 | /* Record Source Type Operand (rec_src_type) */ | ||
| 531 | #define CEC_OP_RECORD_SRC_OWN 1 | ||
| 532 | #define CEC_OP_RECORD_SRC_DIGITAL 2 | ||
| 533 | #define CEC_OP_RECORD_SRC_ANALOG 3 | ||
| 534 | #define CEC_OP_RECORD_SRC_EXT_PLUG 4 | ||
| 535 | #define CEC_OP_RECORD_SRC_EXT_PHYS_ADDR 5 | ||
| 536 | /* Service Identification Method Operand (service_id_method) */ | ||
| 537 | #define CEC_OP_SERVICE_ID_METHOD_BY_DIG_ID 0 | ||
| 538 | #define CEC_OP_SERVICE_ID_METHOD_BY_CHANNEL 1 | ||
| 539 | /* Digital Service Broadcast System Operand (dig_bcast_system) */ | ||
| 540 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_GEN 0x00 | ||
| 541 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_GEN 0x01 | ||
| 542 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_GEN 0x02 | ||
| 543 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_BS 0x08 | ||
| 544 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_CS 0x09 | ||
| 545 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ARIB_T 0x0a | ||
| 546 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_CABLE 0x10 | ||
| 547 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_SAT 0x11 | ||
| 548 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_ATSC_T 0x12 | ||
| 549 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_C 0x18 | ||
| 550 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_S 0x19 | ||
| 551 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_S2 0x1a | ||
| 552 | #define CEC_OP_DIG_SERVICE_BCAST_SYSTEM_DVB_T 0x1b | ||
| 553 | /* Analogue Broadcast Type Operand (ana_bcast_type) */ | ||
| 554 | #define CEC_OP_ANA_BCAST_TYPE_CABLE 0 | ||
| 555 | #define CEC_OP_ANA_BCAST_TYPE_SATELLITE 1 | ||
| 556 | #define CEC_OP_ANA_BCAST_TYPE_TERRESTRIAL 2 | ||
| 557 | /* Broadcast System Operand (bcast_system) */ | ||
| 558 | #define CEC_OP_BCAST_SYSTEM_PAL_BG 0x00 | ||
| 559 | #define CEC_OP_BCAST_SYSTEM_SECAM_LQ 0x01 /* SECAM L' */ | ||
| 560 | #define CEC_OP_BCAST_SYSTEM_PAL_M 0x02 | ||
| 561 | #define CEC_OP_BCAST_SYSTEM_NTSC_M 0x03 | ||
| 562 | #define CEC_OP_BCAST_SYSTEM_PAL_I 0x04 | ||
| 563 | #define CEC_OP_BCAST_SYSTEM_SECAM_DK 0x05 | ||
| 564 | #define CEC_OP_BCAST_SYSTEM_SECAM_BG 0x06 | ||
| 565 | #define CEC_OP_BCAST_SYSTEM_SECAM_L 0x07 | ||
| 566 | #define CEC_OP_BCAST_SYSTEM_PAL_DK 0x08 | ||
| 567 | #define CEC_OP_BCAST_SYSTEM_OTHER 0x1f | ||
| 568 | /* Channel Number Format Operand (channel_number_fmt) */ | ||
| 569 | #define CEC_OP_CHANNEL_NUMBER_FMT_1_PART 0x01 | ||
| 570 | #define CEC_OP_CHANNEL_NUMBER_FMT_2_PART 0x02 | ||
| 571 | |||
| 572 | #define CEC_MSG_RECORD_STATUS 0x0a | ||
| 573 | /* Record Status Operand (rec_status) */ | ||
| 574 | #define CEC_OP_RECORD_STATUS_CUR_SRC 0x01 | ||
| 575 | #define CEC_OP_RECORD_STATUS_DIG_SERVICE 0x02 | ||
| 576 | #define CEC_OP_RECORD_STATUS_ANA_SERVICE 0x03 | ||
| 577 | #define CEC_OP_RECORD_STATUS_EXT_INPUT 0x04 | ||
| 578 | #define CEC_OP_RECORD_STATUS_NO_DIG_SERVICE 0x05 | ||
| 579 | #define CEC_OP_RECORD_STATUS_NO_ANA_SERVICE 0x06 | ||
| 580 | #define CEC_OP_RECORD_STATUS_NO_SERVICE 0x07 | ||
| 581 | #define CEC_OP_RECORD_STATUS_INVALID_EXT_PLUG 0x09 | ||
| 582 | #define CEC_OP_RECORD_STATUS_INVALID_EXT_PHYS_ADDR 0x0a | ||
| 583 | #define CEC_OP_RECORD_STATUS_UNSUP_CA 0x0b | ||
| 584 | #define CEC_OP_RECORD_STATUS_NO_CA_ENTITLEMENTS 0x0c | ||
| 585 | #define CEC_OP_RECORD_STATUS_CANT_COPY_SRC 0x0d | ||
| 586 | #define CEC_OP_RECORD_STATUS_NO_MORE_COPIES 0x0e | ||
| 587 | #define CEC_OP_RECORD_STATUS_NO_MEDIA 0x10 | ||
| 588 | #define CEC_OP_RECORD_STATUS_PLAYING 0x11 | ||
| 589 | #define CEC_OP_RECORD_STATUS_ALREADY_RECORDING 0x12 | ||
| 590 | #define CEC_OP_RECORD_STATUS_MEDIA_PROT 0x13 | ||
| 591 | #define CEC_OP_RECORD_STATUS_NO_SIGNAL 0x14 | ||
| 592 | #define CEC_OP_RECORD_STATUS_MEDIA_PROBLEM 0x15 | ||
| 593 | #define CEC_OP_RECORD_STATUS_NO_SPACE 0x16 | ||
| 594 | #define CEC_OP_RECORD_STATUS_PARENTAL_LOCK 0x17 | ||
| 595 | #define CEC_OP_RECORD_STATUS_TERMINATED_OK 0x1a | ||
| 596 | #define CEC_OP_RECORD_STATUS_ALREADY_TERM 0x1b | ||
| 597 | #define CEC_OP_RECORD_STATUS_OTHER 0x1f | ||
| 598 | |||
| 599 | #define CEC_MSG_RECORD_TV_SCREEN 0x0f | ||
| 600 | |||
| 601 | |||
| 602 | /* Timer Programming Feature */ | ||
| 603 | #define CEC_MSG_CLEAR_ANALOGUE_TIMER 0x33 | ||
| 604 | /* Recording Sequence Operand (recording_seq) */ | ||
| 605 | #define CEC_OP_REC_SEQ_SUNDAY 0x01 | ||
| 606 | #define CEC_OP_REC_SEQ_MONDAY 0x02 | ||
| 607 | #define CEC_OP_REC_SEQ_TUESDAY 0x04 | ||
| 608 | #define CEC_OP_REC_SEQ_WEDNESDAY 0x08 | ||
| 609 | #define CEC_OP_REC_SEQ_THURSDAY 0x10 | ||
| 610 | #define CEC_OP_REC_SEQ_FRIDAY 0x20 | ||
| 611 | #define CEC_OP_REC_SEQ_SATERDAY 0x40 | ||
| 612 | #define CEC_OP_REC_SEQ_ONCE_ONLY 0x00 | ||
| 613 | |||
| 614 | #define CEC_MSG_CLEAR_DIGITAL_TIMER 0x99 | ||
| 615 | |||
| 616 | #define CEC_MSG_CLEAR_EXT_TIMER 0xa1 | ||
| 617 | /* External Source Specifier Operand (ext_src_spec) */ | ||
| 618 | #define CEC_OP_EXT_SRC_PLUG 0x04 | ||
| 619 | #define CEC_OP_EXT_SRC_PHYS_ADDR 0x05 | ||
| 620 | |||
| 621 | #define CEC_MSG_SET_ANALOGUE_TIMER 0x34 | ||
| 622 | #define CEC_MSG_SET_DIGITAL_TIMER 0x97 | ||
| 623 | #define CEC_MSG_SET_EXT_TIMER 0xa2 | ||
| 624 | |||
| 625 | #define CEC_MSG_SET_TIMER_PROGRAM_TITLE 0x67 | ||
| 626 | #define CEC_MSG_TIMER_CLEARED_STATUS 0x43 | ||
| 627 | /* Timer Cleared Status Data Operand (timer_cleared_status) */ | ||
| 628 | #define CEC_OP_TIMER_CLR_STAT_RECORDING 0x00 | ||
| 629 | #define CEC_OP_TIMER_CLR_STAT_NO_MATCHING 0x01 | ||
| 630 | #define CEC_OP_TIMER_CLR_STAT_NO_INFO 0x02 | ||
| 631 | #define CEC_OP_TIMER_CLR_STAT_CLEARED 0x80 | ||
| 632 | |||
| 633 | #define CEC_MSG_TIMER_STATUS 0x35 | ||
| 634 | /* Timer Overlap Warning Operand (timer_overlap_warning) */ | ||
| 635 | #define CEC_OP_TIMER_OVERLAP_WARNING_NO_OVERLAP 0 | ||
| 636 | #define CEC_OP_TIMER_OVERLAP_WARNING_OVERLAP 1 | ||
| 637 | /* Media Info Operand (media_info) */ | ||
| 638 | #define CEC_OP_MEDIA_INFO_UNPROT_MEDIA 0 | ||
| 639 | #define CEC_OP_MEDIA_INFO_PROT_MEDIA 1 | ||
| 640 | #define CEC_OP_MEDIA_INFO_NO_MEDIA 2 | ||
| 641 | /* Programmed Indicator Operand (prog_indicator) */ | ||
| 642 | #define CEC_OP_PROG_IND_NOT_PROGRAMMED 0 | ||
| 643 | #define CEC_OP_PROG_IND_PROGRAMMED 1 | ||
| 644 | /* Programmed Info Operand (prog_info) */ | ||
| 645 | #define CEC_OP_PROG_INFO_ENOUGH_SPACE 0x08 | ||
| 646 | #define CEC_OP_PROG_INFO_NOT_ENOUGH_SPACE 0x09 | ||
| 647 | #define CEC_OP_PROG_INFO_MIGHT_NOT_BE_ENOUGH_SPACE 0x0b | ||
| 648 | #define CEC_OP_PROG_INFO_NONE_AVAILABLE 0x0a | ||
| 649 | /* Not Programmed Error Info Operand (prog_error) */ | ||
| 650 | #define CEC_OP_PROG_ERROR_NO_FREE_TIMER 0x01 | ||
| 651 | #define CEC_OP_PROG_ERROR_DATE_OUT_OF_RANGE 0x02 | ||
| 652 | #define CEC_OP_PROG_ERROR_REC_SEQ_ERROR 0x03 | ||
| 653 | #define CEC_OP_PROG_ERROR_INV_EXT_PLUG 0x04 | ||
| 654 | #define CEC_OP_PROG_ERROR_INV_EXT_PHYS_ADDR 0x05 | ||
| 655 | #define CEC_OP_PROG_ERROR_CA_UNSUPP 0x06 | ||
| 656 | #define CEC_OP_PROG_ERROR_INSUF_CA_ENTITLEMENTS 0x07 | ||
| 657 | #define CEC_OP_PROG_ERROR_RESOLUTION_UNSUPP 0x08 | ||
| 658 | #define CEC_OP_PROG_ERROR_PARENTAL_LOCK 0x09 | ||
| 659 | #define CEC_OP_PROG_ERROR_CLOCK_FAILURE 0x0a | ||
| 660 | #define CEC_OP_PROG_ERROR_DUPLICATE 0x0e | ||
| 661 | |||
| 662 | |||
| 663 | /* System Information Feature */ | ||
| 664 | #define CEC_MSG_CEC_VERSION 0x9e | ||
| 665 | /* CEC Version Operand (cec_version) */ | ||
| 666 | #define CEC_OP_CEC_VERSION_1_3A 4 | ||
| 667 | #define CEC_OP_CEC_VERSION_1_4 5 | ||
| 668 | #define CEC_OP_CEC_VERSION_2_0 6 | ||
| 669 | |||
| 670 | #define CEC_MSG_GET_CEC_VERSION 0x9f | ||
| 671 | #define CEC_MSG_GIVE_PHYSICAL_ADDR 0x83 | ||
| 672 | #define CEC_MSG_GET_MENU_LANGUAGE 0x91 | ||
| 673 | #define CEC_MSG_REPORT_PHYSICAL_ADDR 0x84 | ||
| 674 | /* Primary Device Type Operand (prim_devtype) */ | ||
| 675 | #define CEC_OP_PRIM_DEVTYPE_TV 0 | ||
| 676 | #define CEC_OP_PRIM_DEVTYPE_RECORD 1 | ||
| 677 | #define CEC_OP_PRIM_DEVTYPE_TUNER 3 | ||
| 678 | #define CEC_OP_PRIM_DEVTYPE_PLAYBACK 4 | ||
| 679 | #define CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM 5 | ||
| 680 | #define CEC_OP_PRIM_DEVTYPE_SWITCH 6 | ||
| 681 | #define CEC_OP_PRIM_DEVTYPE_PROCESSOR 7 | ||
| 682 | |||
| 683 | #define CEC_MSG_SET_MENU_LANGUAGE 0x32 | ||
| 684 | #define CEC_MSG_REPORT_FEATURES 0xa6 /* HDMI 2.0 */ | ||
| 685 | /* All Device Types Operand (all_device_types) */ | ||
| 686 | #define CEC_OP_ALL_DEVTYPE_TV 0x80 | ||
| 687 | #define CEC_OP_ALL_DEVTYPE_RECORD 0x40 | ||
| 688 | #define CEC_OP_ALL_DEVTYPE_TUNER 0x20 | ||
| 689 | #define CEC_OP_ALL_DEVTYPE_PLAYBACK 0x10 | ||
| 690 | #define CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM 0x08 | ||
| 691 | #define CEC_OP_ALL_DEVTYPE_SWITCH 0x04 | ||
| 692 | /* | ||
| 693 | * And if you wondering what happened to PROCESSOR devices: those should | ||
| 694 | * be mapped to a SWITCH. | ||
| 695 | */ | ||
| 696 | |||
| 697 | /* Valid for RC Profile and Device Feature operands */ | ||
| 698 | #define CEC_OP_FEAT_EXT 0x80 /* Extension bit */ | ||
| 699 | /* RC Profile Operand (rc_profile) */ | ||
| 700 | #define CEC_OP_FEAT_RC_TV_PROFILE_NONE 0x00 | ||
| 701 | #define CEC_OP_FEAT_RC_TV_PROFILE_1 0x02 | ||
| 702 | #define CEC_OP_FEAT_RC_TV_PROFILE_2 0x06 | ||
| 703 | #define CEC_OP_FEAT_RC_TV_PROFILE_3 0x0a | ||
| 704 | #define CEC_OP_FEAT_RC_TV_PROFILE_4 0x0e | ||
| 705 | #define CEC_OP_FEAT_RC_SRC_HAS_DEV_ROOT_MENU 0x50 | ||
| 706 | #define CEC_OP_FEAT_RC_SRC_HAS_DEV_SETUP_MENU 0x48 | ||
| 707 | #define CEC_OP_FEAT_RC_SRC_HAS_CONTENTS_MENU 0x44 | ||
| 708 | #define CEC_OP_FEAT_RC_SRC_HAS_MEDIA_TOP_MENU 0x42 | ||
| 709 | #define CEC_OP_FEAT_RC_SRC_HAS_MEDIA_CONTEXT_MENU 0x41 | ||
| 710 | /* Device Feature Operand (dev_features) */ | ||
| 711 | #define CEC_OP_FEAT_DEV_HAS_RECORD_TV_SCREEN 0x40 | ||
| 712 | #define CEC_OP_FEAT_DEV_HAS_SET_OSD_STRING 0x20 | ||
| 713 | #define CEC_OP_FEAT_DEV_HAS_DECK_CONTROL 0x10 | ||
| 714 | #define CEC_OP_FEAT_DEV_HAS_SET_AUDIO_RATE 0x08 | ||
| 715 | #define CEC_OP_FEAT_DEV_SINK_HAS_ARC_TX 0x04 | ||
| 716 | #define CEC_OP_FEAT_DEV_SOURCE_HAS_ARC_RX 0x02 | ||
| 717 | |||
| 718 | #define CEC_MSG_GIVE_FEATURES 0xa5 /* HDMI 2.0 */ | ||
| 719 | |||
| 720 | |||
| 721 | /* Deck Control Feature */ | ||
| 722 | #define CEC_MSG_DECK_CONTROL 0x42 | ||
| 723 | /* Deck Control Mode Operand (deck_control_mode) */ | ||
| 724 | #define CEC_OP_DECK_CTL_MODE_SKIP_FWD 1 | ||
| 725 | #define CEC_OP_DECK_CTL_MODE_SKIP_REV 2 | ||
| 726 | #define CEC_OP_DECK_CTL_MODE_STOP 3 | ||
| 727 | #define CEC_OP_DECK_CTL_MODE_EJECT 4 | ||
| 728 | |||
| 729 | #define CEC_MSG_DECK_STATUS 0x1b | ||
| 730 | /* Deck Info Operand (deck_info) */ | ||
| 731 | #define CEC_OP_DECK_INFO_PLAY 0x11 | ||
| 732 | #define CEC_OP_DECK_INFO_RECORD 0x12 | ||
| 733 | #define CEC_OP_DECK_INFO_PLAY_REV 0x13 | ||
| 734 | #define CEC_OP_DECK_INFO_STILL 0x14 | ||
| 735 | #define CEC_OP_DECK_INFO_SLOW 0x15 | ||
| 736 | #define CEC_OP_DECK_INFO_SLOW_REV 0x16 | ||
| 737 | #define CEC_OP_DECK_INFO_FAST_FWD 0x17 | ||
| 738 | #define CEC_OP_DECK_INFO_FAST_REV 0x18 | ||
| 739 | #define CEC_OP_DECK_INFO_NO_MEDIA 0x19 | ||
| 740 | #define CEC_OP_DECK_INFO_STOP 0x1a | ||
| 741 | #define CEC_OP_DECK_INFO_SKIP_FWD 0x1b | ||
| 742 | #define CEC_OP_DECK_INFO_SKIP_REV 0x1c | ||
| 743 | #define CEC_OP_DECK_INFO_INDEX_SEARCH_FWD 0x1d | ||
| 744 | #define CEC_OP_DECK_INFO_INDEX_SEARCH_REV 0x1e | ||
| 745 | #define CEC_OP_DECK_INFO_OTHER 0x1f | ||
| 746 | |||
| 747 | #define CEC_MSG_GIVE_DECK_STATUS 0x1a | ||
| 748 | /* Status Request Operand (status_req) */ | ||
| 749 | #define CEC_OP_STATUS_REQ_ON 1 | ||
| 750 | #define CEC_OP_STATUS_REQ_OFF 2 | ||
| 751 | #define CEC_OP_STATUS_REQ_ONCE 3 | ||
| 752 | |||
| 753 | #define CEC_MSG_PLAY 0x41 | ||
| 754 | /* Play Mode Operand (play_mode) */ | ||
| 755 | #define CEC_OP_PLAY_MODE_PLAY_FWD 0x24 | ||
| 756 | #define CEC_OP_PLAY_MODE_PLAY_REV 0x20 | ||
| 757 | #define CEC_OP_PLAY_MODE_PLAY_STILL 0x25 | ||
| 758 | #define CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MIN 0x05 | ||
| 759 | #define CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MED 0x06 | ||
| 760 | #define CEC_OP_PLAY_MODE_PLAY_FAST_FWD_MAX 0x07 | ||
| 761 | #define CEC_OP_PLAY_MODE_PLAY_FAST_REV_MIN 0x09 | ||
| 762 | #define CEC_OP_PLAY_MODE_PLAY_FAST_REV_MED 0x0a | ||
| 763 | #define CEC_OP_PLAY_MODE_PLAY_FAST_REV_MAX 0x0b | ||
| 764 | #define CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MIN 0x15 | ||
| 765 | #define CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MED 0x16 | ||
| 766 | #define CEC_OP_PLAY_MODE_PLAY_SLOW_FWD_MAX 0x17 | ||
| 767 | #define CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MIN 0x19 | ||
| 768 | #define CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MED 0x1a | ||
| 769 | #define CEC_OP_PLAY_MODE_PLAY_SLOW_REV_MAX 0x1b | ||
| 770 | |||
| 771 | |||
| 772 | /* Tuner Control Feature */ | ||
| 773 | #define CEC_MSG_GIVE_TUNER_DEVICE_STATUS 0x08 | ||
| 774 | #define CEC_MSG_SELECT_ANALOGUE_SERVICE 0x92 | ||
| 775 | #define CEC_MSG_SELECT_DIGITAL_SERVICE 0x93 | ||
| 776 | #define CEC_MSG_TUNER_DEVICE_STATUS 0x07 | ||
| 777 | /* Recording Flag Operand (rec_flag) */ | ||
| 778 | #define CEC_OP_REC_FLAG_USED 0 | ||
| 779 | #define CEC_OP_REC_FLAG_NOT_USED 1 | ||
| 780 | /* Tuner Display Info Operand (tuner_display_info) */ | ||
| 781 | #define CEC_OP_TUNER_DISPLAY_INFO_DIGITAL 0 | ||
| 782 | #define CEC_OP_TUNER_DISPLAY_INFO_NONE 1 | ||
| 783 | #define CEC_OP_TUNER_DISPLAY_INFO_ANALOGUE 2 | ||
| 784 | |||
| 785 | #define CEC_MSG_TUNER_STEP_DECREMENT 0x06 | ||
| 786 | #define CEC_MSG_TUNER_STEP_INCREMENT 0x05 | ||
| 787 | |||
| 788 | |||
| 789 | /* Vendor Specific Commands Feature */ | ||
| 790 | |||
| 791 | /* | ||
| 792 | * Has also: | ||
| 793 | * CEC_MSG_CEC_VERSION | ||
| 794 | * CEC_MSG_GET_CEC_VERSION | ||
| 795 | */ | ||
| 796 | #define CEC_MSG_DEVICE_VENDOR_ID 0x87 | ||
| 797 | #define CEC_MSG_GIVE_DEVICE_VENDOR_ID 0x8c | ||
| 798 | #define CEC_MSG_VENDOR_COMMAND 0x89 | ||
| 799 | #define CEC_MSG_VENDOR_COMMAND_WITH_ID 0xa0 | ||
| 800 | #define CEC_MSG_VENDOR_REMOTE_BUTTON_DOWN 0x8a | ||
| 801 | #define CEC_MSG_VENDOR_REMOTE_BUTTON_UP 0x8b | ||
| 802 | |||
| 803 | |||
| 804 | /* OSD Display Feature */ | ||
| 805 | #define CEC_MSG_SET_OSD_STRING 0x64 | ||
| 806 | /* Display Control Operand (disp_ctl) */ | ||
| 807 | #define CEC_OP_DISP_CTL_DEFAULT 0x00 | ||
| 808 | #define CEC_OP_DISP_CTL_UNTIL_CLEARED 0x40 | ||
| 809 | #define CEC_OP_DISP_CTL_CLEAR 0x80 | ||
| 810 | |||
| 811 | |||
| 812 | /* Device OSD Transfer Feature */ | ||
| 813 | #define CEC_MSG_GIVE_OSD_NAME 0x46 | ||
| 814 | #define CEC_MSG_SET_OSD_NAME 0x47 | ||
| 815 | |||
| 816 | |||
| 817 | /* Device Menu Control Feature */ | ||
| 818 | #define CEC_MSG_MENU_REQUEST 0x8d | ||
| 819 | /* Menu Request Type Operand (menu_req) */ | ||
| 820 | #define CEC_OP_MENU_REQUEST_ACTIVATE 0x00 | ||
| 821 | #define CEC_OP_MENU_REQUEST_DEACTIVATE 0x01 | ||
| 822 | #define CEC_OP_MENU_REQUEST_QUERY 0x02 | ||
| 823 | |||
| 824 | #define CEC_MSG_MENU_STATUS 0x8e | ||
| 825 | /* Menu State Operand (menu_state) */ | ||
| 826 | #define CEC_OP_MENU_STATE_ACTIVATED 0x00 | ||
| 827 | #define CEC_OP_MENU_STATE_DEACTIVATED 0x01 | ||
| 828 | |||
| 829 | #define CEC_MSG_USER_CONTROL_PRESSED 0x44 | ||
| 830 | /* UI Broadcast Type Operand (ui_bcast_type) */ | ||
| 831 | #define CEC_OP_UI_BCAST_TYPE_TOGGLE_ALL 0x00 | ||
| 832 | #define CEC_OP_UI_BCAST_TYPE_TOGGLE_DIG_ANA 0x01 | ||
| 833 | #define CEC_OP_UI_BCAST_TYPE_ANALOGUE 0x10 | ||
| 834 | #define CEC_OP_UI_BCAST_TYPE_ANALOGUE_T 0x20 | ||
| 835 | #define CEC_OP_UI_BCAST_TYPE_ANALOGUE_CABLE 0x30 | ||
| 836 | #define CEC_OP_UI_BCAST_TYPE_ANALOGUE_SAT 0x40 | ||
| 837 | #define CEC_OP_UI_BCAST_TYPE_DIGITAL 0x50 | ||
| 838 | #define CEC_OP_UI_BCAST_TYPE_DIGITAL_T 0x60 | ||
| 839 | #define CEC_OP_UI_BCAST_TYPE_DIGITAL_CABLE 0x70 | ||
| 840 | #define CEC_OP_UI_BCAST_TYPE_DIGITAL_SAT 0x80 | ||
| 841 | #define CEC_OP_UI_BCAST_TYPE_DIGITAL_COM_SAT 0x90 | ||
| 842 | #define CEC_OP_UI_BCAST_TYPE_DIGITAL_COM_SAT2 0x91 | ||
| 843 | #define CEC_OP_UI_BCAST_TYPE_IP 0xa0 | ||
| 844 | /* UI Sound Presentation Control Operand (ui_snd_pres_ctl) */ | ||
| 845 | #define CEC_OP_UI_SND_PRES_CTL_DUAL_MONO 0x10 | ||
| 846 | #define CEC_OP_UI_SND_PRES_CTL_KARAOKE 0x20 | ||
| 847 | #define CEC_OP_UI_SND_PRES_CTL_DOWNMIX 0x80 | ||
| 848 | #define CEC_OP_UI_SND_PRES_CTL_REVERB 0x90 | ||
| 849 | #define CEC_OP_UI_SND_PRES_CTL_EQUALIZER 0xa0 | ||
| 850 | #define CEC_OP_UI_SND_PRES_CTL_BASS_UP 0xb1 | ||
| 851 | #define CEC_OP_UI_SND_PRES_CTL_BASS_NEUTRAL 0xb2 | ||
| 852 | #define CEC_OP_UI_SND_PRES_CTL_BASS_DOWN 0xb3 | ||
| 853 | #define CEC_OP_UI_SND_PRES_CTL_TREBLE_UP 0xc1 | ||
| 854 | #define CEC_OP_UI_SND_PRES_CTL_TREBLE_NEUTRAL 0xc2 | ||
| 855 | #define CEC_OP_UI_SND_PRES_CTL_TREBLE_DOWN 0xc3 | ||
| 856 | |||
| 857 | #define CEC_MSG_USER_CONTROL_RELEASED 0x45 | ||
| 858 | |||
| 859 | |||
| 860 | /* Remote Control Passthrough Feature */ | ||
| 861 | |||
| 862 | /* | ||
| 863 | * Has also: | ||
| 864 | * CEC_MSG_USER_CONTROL_PRESSED | ||
| 865 | * CEC_MSG_USER_CONTROL_RELEASED | ||
| 866 | */ | ||
| 867 | |||
| 868 | |||
| 869 | /* Power Status Feature */ | ||
| 870 | #define CEC_MSG_GIVE_DEVICE_POWER_STATUS 0x8f | ||
| 871 | #define CEC_MSG_REPORT_POWER_STATUS 0x90 | ||
| 872 | /* Power Status Operand (pwr_state) */ | ||
| 873 | #define CEC_OP_POWER_STATUS_ON 0 | ||
| 874 | #define CEC_OP_POWER_STATUS_STANDBY 1 | ||
| 875 | #define CEC_OP_POWER_STATUS_TO_ON 2 | ||
| 876 | #define CEC_OP_POWER_STATUS_TO_STANDBY 3 | ||
| 877 | |||
| 878 | |||
| 879 | /* General Protocol Messages */ | ||
| 880 | #define CEC_MSG_FEATURE_ABORT 0x00 | ||
| 881 | /* Abort Reason Operand (reason) */ | ||
| 882 | #define CEC_OP_ABORT_UNRECOGNIZED_OP 0 | ||
| 883 | #define CEC_OP_ABORT_INCORRECT_MODE 1 | ||
| 884 | #define CEC_OP_ABORT_NO_SOURCE 2 | ||
| 885 | #define CEC_OP_ABORT_INVALID_OP 3 | ||
| 886 | #define CEC_OP_ABORT_REFUSED 4 | ||
| 887 | #define CEC_OP_ABORT_UNDETERMINED 5 | ||
| 888 | |||
| 889 | #define CEC_MSG_ABORT 0xff | ||
| 890 | |||
| 891 | |||
| 892 | /* System Audio Control Feature */ | ||
| 893 | |||
| 894 | /* | ||
| 895 | * Has also: | ||
| 896 | * CEC_MSG_USER_CONTROL_PRESSED | ||
| 897 | * CEC_MSG_USER_CONTROL_RELEASED | ||
| 898 | */ | ||
| 899 | #define CEC_MSG_GIVE_AUDIO_STATUS 0x71 | ||
| 900 | #define CEC_MSG_GIVE_SYSTEM_AUDIO_MODE_STATUS 0x7d | ||
| 901 | #define CEC_MSG_REPORT_AUDIO_STATUS 0x7a | ||
| 902 | /* Audio Mute Status Operand (aud_mute_status) */ | ||
| 903 | #define CEC_OP_AUD_MUTE_STATUS_OFF 0 | ||
| 904 | #define CEC_OP_AUD_MUTE_STATUS_ON 1 | ||
| 905 | |||
| 906 | #define CEC_MSG_REPORT_SHORT_AUDIO_DESCRIPTOR 0xa3 | ||
| 907 | #define CEC_MSG_REQUEST_SHORT_AUDIO_DESCRIPTOR 0xa4 | ||
| 908 | #define CEC_MSG_SET_SYSTEM_AUDIO_MODE 0x72 | ||
| 909 | /* System Audio Status Operand (sys_aud_status) */ | ||
| 910 | #define CEC_OP_SYS_AUD_STATUS_OFF 0 | ||
| 911 | #define CEC_OP_SYS_AUD_STATUS_ON 1 | ||
| 912 | |||
| 913 | #define CEC_MSG_SYSTEM_AUDIO_MODE_REQUEST 0x70 | ||
| 914 | #define CEC_MSG_SYSTEM_AUDIO_MODE_STATUS 0x7e | ||
| 915 | /* Audio Format ID Operand (audio_format_id) */ | ||
| 916 | #define CEC_OP_AUD_FMT_ID_CEA861 0 | ||
| 917 | #define CEC_OP_AUD_FMT_ID_CEA861_CXT 1 | ||
| 918 | |||
| 919 | |||
| 920 | /* Audio Rate Control Feature */ | ||
| 921 | #define CEC_MSG_SET_AUDIO_RATE 0x9a | ||
| 922 | /* Audio Rate Operand (audio_rate) */ | ||
| 923 | #define CEC_OP_AUD_RATE_OFF 0 | ||
| 924 | #define CEC_OP_AUD_RATE_WIDE_STD 1 | ||
| 925 | #define CEC_OP_AUD_RATE_WIDE_FAST 2 | ||
| 926 | #define CEC_OP_AUD_RATE_WIDE_SLOW 3 | ||
| 927 | #define CEC_OP_AUD_RATE_NARROW_STD 4 | ||
| 928 | #define CEC_OP_AUD_RATE_NARROW_FAST 5 | ||
| 929 | #define CEC_OP_AUD_RATE_NARROW_SLOW 6 | ||
| 930 | |||
| 931 | |||
| 932 | /* Audio Return Channel Control Feature */ | ||
| 933 | #define CEC_MSG_INITIATE_ARC 0xc0 | ||
| 934 | #define CEC_MSG_REPORT_ARC_INITIATED 0xc1 | ||
| 935 | #define CEC_MSG_REPORT_ARC_TERMINATED 0xc2 | ||
| 936 | #define CEC_MSG_REQUEST_ARC_INITIATION 0xc3 | ||
| 937 | #define CEC_MSG_REQUEST_ARC_TERMINATION 0xc4 | ||
| 938 | #define CEC_MSG_TERMINATE_ARC 0xc5 | ||
| 939 | |||
| 940 | |||
| 941 | /* Dynamic Audio Lipsync Feature */ | ||
| 942 | /* Only for CEC 2.0 and up */ | ||
| 943 | #define CEC_MSG_REQUEST_CURRENT_LATENCY 0xa7 | ||
| 944 | #define CEC_MSG_REPORT_CURRENT_LATENCY 0xa8 | ||
| 945 | /* Low Latency Mode Operand (low_latency_mode) */ | ||
| 946 | #define CEC_OP_LOW_LATENCY_MODE_OFF 0 | ||
| 947 | #define CEC_OP_LOW_LATENCY_MODE_ON 1 | ||
| 948 | /* Audio Output Compensated Operand (audio_out_compensated) */ | ||
| 949 | #define CEC_OP_AUD_OUT_COMPENSATED_NA 0 | ||
| 950 | #define CEC_OP_AUD_OUT_COMPENSATED_DELAY 1 | ||
| 951 | #define CEC_OP_AUD_OUT_COMPENSATED_NO_DELAY 2 | ||
| 952 | #define CEC_OP_AUD_OUT_COMPENSATED_PARTIAL_DELAY 3 | ||
| 953 | |||
| 954 | |||
| 955 | /* Capability Discovery and Control Feature */ | ||
| 956 | #define CEC_MSG_CDC_MESSAGE 0xf8 | ||
| 957 | /* Ethernet-over-HDMI: nobody ever does this... */ | ||
| 958 | #define CEC_MSG_CDC_HEC_INQUIRE_STATE 0x00 | ||
| 959 | #define CEC_MSG_CDC_HEC_REPORT_STATE 0x01 | ||
| 960 | /* HEC Functionality State Operand (hec_func_state) */ | ||
| 961 | #define CEC_OP_HEC_FUNC_STATE_NOT_SUPPORTED 0 | ||
| 962 | #define CEC_OP_HEC_FUNC_STATE_INACTIVE 1 | ||
| 963 | #define CEC_OP_HEC_FUNC_STATE_ACTIVE 2 | ||
| 964 | #define CEC_OP_HEC_FUNC_STATE_ACTIVATION_FIELD 3 | ||
| 965 | /* Host Functionality State Operand (host_func_state) */ | ||
| 966 | #define CEC_OP_HOST_FUNC_STATE_NOT_SUPPORTED 0 | ||
| 967 | #define CEC_OP_HOST_FUNC_STATE_INACTIVE 1 | ||
| 968 | #define CEC_OP_HOST_FUNC_STATE_ACTIVE 2 | ||
| 969 | /* ENC Functionality State Operand (enc_func_state) */ | ||
| 970 | #define CEC_OP_ENC_FUNC_STATE_EXT_CON_NOT_SUPPORTED 0 | ||
| 971 | #define CEC_OP_ENC_FUNC_STATE_EXT_CON_INACTIVE 1 | ||
| 972 | #define CEC_OP_ENC_FUNC_STATE_EXT_CON_ACTIVE 2 | ||
| 973 | /* CDC Error Code Operand (cdc_errcode) */ | ||
| 974 | #define CEC_OP_CDC_ERROR_CODE_NONE 0 | ||
| 975 | #define CEC_OP_CDC_ERROR_CODE_CAP_UNSUPPORTED 1 | ||
| 976 | #define CEC_OP_CDC_ERROR_CODE_WRONG_STATE 2 | ||
| 977 | #define CEC_OP_CDC_ERROR_CODE_OTHER 3 | ||
| 978 | /* HEC Support Operand (hec_support) */ | ||
| 979 | #define CEC_OP_HEC_SUPPORT_NO 0 | ||
| 980 | #define CEC_OP_HEC_SUPPORT_YES 1 | ||
| 981 | /* HEC Activation Operand (hec_activation) */ | ||
| 982 | #define CEC_OP_HEC_ACTIVATION_ON 0 | ||
| 983 | #define CEC_OP_HEC_ACTIVATION_OFF 1 | ||
| 984 | |||
| 985 | #define CEC_MSG_CDC_HEC_SET_STATE_ADJACENT 0x02 | ||
| 986 | #define CEC_MSG_CDC_HEC_SET_STATE 0x03 | ||
| 987 | /* HEC Set State Operand (hec_set_state) */ | ||
| 988 | #define CEC_OP_HEC_SET_STATE_DEACTIVATE 0 | ||
| 989 | #define CEC_OP_HEC_SET_STATE_ACTIVATE 1 | ||
| 990 | |||
| 991 | #define CEC_MSG_CDC_HEC_REQUEST_DEACTIVATION 0x04 | ||
| 992 | #define CEC_MSG_CDC_HEC_NOTIFY_ALIVE 0x05 | ||
| 993 | #define CEC_MSG_CDC_HEC_DISCOVER 0x06 | ||
| 994 | /* Hotplug Detect messages */ | ||
| 995 | #define CEC_MSG_CDC_HPD_SET_STATE 0x10 | ||
| 996 | /* HPD State Operand (hpd_state) */ | ||
| 997 | #define CEC_OP_HPD_STATE_CP_EDID_DISABLE 0 | ||
| 998 | #define CEC_OP_HPD_STATE_CP_EDID_ENABLE 1 | ||
| 999 | #define CEC_OP_HPD_STATE_CP_EDID_DISABLE_ENABLE 2 | ||
| 1000 | #define CEC_OP_HPD_STATE_EDID_DISABLE 3 | ||
| 1001 | #define CEC_OP_HPD_STATE_EDID_ENABLE 4 | ||
| 1002 | #define CEC_OP_HPD_STATE_EDID_DISABLE_ENABLE 5 | ||
| 1003 | #define CEC_MSG_CDC_HPD_REPORT_STATE 0x11 | ||
| 1004 | /* HPD Error Code Operand (hpd_error) */ | ||
| 1005 | #define CEC_OP_HPD_ERROR_NONE 0 | ||
| 1006 | #define CEC_OP_HPD_ERROR_INITIATOR_NOT_CAPABLE 1 | ||
| 1007 | #define CEC_OP_HPD_ERROR_INITIATOR_WRONG_STATE 2 | ||
| 1008 | #define CEC_OP_HPD_ERROR_OTHER 3 | ||
| 1009 | #define CEC_OP_HPD_ERROR_NONE_NO_VIDEO 4 | ||
| 1010 | |||
| 1011 | #endif | ||
diff --git a/include/linux/of_reserved_mem.h b/include/linux/of_reserved_mem.h index c201060e0c6d..f8e1992d6423 100644 --- a/include/linux/of_reserved_mem.h +++ b/include/linux/of_reserved_mem.h | |||
| @@ -1,7 +1,8 @@ | |||
| 1 | #ifndef __OF_RESERVED_MEM_H | 1 | #ifndef __OF_RESERVED_MEM_H |
| 2 | #define __OF_RESERVED_MEM_H | 2 | #define __OF_RESERVED_MEM_H |
| 3 | 3 | ||
| 4 | struct device; | 4 | #include <linux/device.h> |
| 5 | |||
| 5 | struct of_phandle_args; | 6 | struct of_phandle_args; |
| 6 | struct reserved_mem_ops; | 7 | struct reserved_mem_ops; |
| 7 | 8 | ||
| @@ -28,7 +29,9 @@ typedef int (*reservedmem_of_init_fn)(struct reserved_mem *rmem); | |||
| 28 | _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn) | 29 | _OF_DECLARE(reservedmem, name, compat, init, reservedmem_of_init_fn) |
| 29 | 30 | ||
| 30 | #ifdef CONFIG_OF_RESERVED_MEM | 31 | #ifdef CONFIG_OF_RESERVED_MEM |
| 31 | int of_reserved_mem_device_init(struct device *dev); | 32 | |
| 33 | int of_reserved_mem_device_init_by_idx(struct device *dev, | ||
| 34 | struct device_node *np, int idx); | ||
| 32 | void of_reserved_mem_device_release(struct device *dev); | 35 | void of_reserved_mem_device_release(struct device *dev); |
| 33 | 36 | ||
| 34 | int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, | 37 | int early_init_dt_alloc_reserved_memory_arch(phys_addr_t size, |
| @@ -42,7 +45,8 @@ void fdt_init_reserved_mem(void); | |||
| 42 | void fdt_reserved_mem_save_node(unsigned long node, const char *uname, | 45 | void fdt_reserved_mem_save_node(unsigned long node, const char *uname, |
| 43 | phys_addr_t base, phys_addr_t size); | 46 | phys_addr_t base, phys_addr_t size); |
| 44 | #else | 47 | #else |
| 45 | static inline int of_reserved_mem_device_init(struct device *dev) | 48 | static inline int of_reserved_mem_device_init_by_idx(struct device *dev, |
| 49 | struct device_node *np, int idx) | ||
| 46 | { | 50 | { |
| 47 | return -ENOSYS; | 51 | return -ENOSYS; |
| 48 | } | 52 | } |
| @@ -53,4 +57,19 @@ static inline void fdt_reserved_mem_save_node(unsigned long node, | |||
| 53 | const char *uname, phys_addr_t base, phys_addr_t size) { } | 57 | const char *uname, phys_addr_t base, phys_addr_t size) { } |
| 54 | #endif | 58 | #endif |
| 55 | 59 | ||
| 60 | /** | ||
| 61 | * of_reserved_mem_device_init() - assign reserved memory region to given device | ||
| 62 | * @dev: Pointer to the device to configure | ||
| 63 | * | ||
| 64 | * This function assigns respective DMA-mapping operations based on the first | ||
| 65 | * reserved memory region specified by 'memory-region' property in device tree | ||
| 66 | * node of the given device. | ||
| 67 | * | ||
| 68 | * Returns error code or zero on success. | ||
| 69 | */ | ||
| 70 | static inline int of_reserved_mem_device_init(struct device *dev) | ||
| 71 | { | ||
| 72 | return of_reserved_mem_device_init_by_idx(dev, dev->of_node, 0); | ||
| 73 | } | ||
| 74 | |||
| 56 | #endif /* __OF_RESERVED_MEM_H */ | 75 | #endif /* __OF_RESERVED_MEM_H */ |
diff --git a/include/media/cec-edid.h b/include/media/cec-edid.h new file mode 100644 index 000000000000..bdf731ecba1a --- /dev/null +++ b/include/media/cec-edid.h | |||
| @@ -0,0 +1,104 @@ | |||
| 1 | /* | ||
| 2 | * cec-edid - HDMI Consumer Electronics Control & EDID helpers | ||
| 3 | * | ||
| 4 | * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved. | ||
| 5 | * | ||
| 6 | * This program is free software; you may redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; version 2 of the License. | ||
| 9 | * | ||
| 10 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 11 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 12 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| 13 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
| 14 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
| 15 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 16 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 17 | * SOFTWARE. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef _MEDIA_CEC_EDID_H | ||
| 21 | #define _MEDIA_CEC_EDID_H | ||
| 22 | |||
| 23 | #include <linux/types.h> | ||
| 24 | |||
| 25 | #define CEC_PHYS_ADDR_INVALID 0xffff | ||
| 26 | #define cec_phys_addr_exp(pa) \ | ||
| 27 | ((pa) >> 12), ((pa) >> 8) & 0xf, ((pa) >> 4) & 0xf, (pa) & 0xf | ||
| 28 | |||
| 29 | /** | ||
| 30 | * cec_get_edid_phys_addr() - find and return the physical address | ||
| 31 | * | ||
| 32 | * @edid: pointer to the EDID data | ||
| 33 | * @size: size in bytes of the EDID data | ||
| 34 | * @offset: If not %NULL then the location of the physical address | ||
| 35 | * bytes in the EDID will be returned here. This is set to 0 | ||
| 36 | * if there is no physical address found. | ||
| 37 | * | ||
| 38 | * Return: the physical address or CEC_PHYS_ADDR_INVALID if there is none. | ||
| 39 | */ | ||
| 40 | u16 cec_get_edid_phys_addr(const u8 *edid, unsigned int size, | ||
| 41 | unsigned int *offset); | ||
| 42 | |||
| 43 | /** | ||
| 44 | * cec_set_edid_phys_addr() - find and set the physical address | ||
| 45 | * | ||
| 46 | * @edid: pointer to the EDID data | ||
| 47 | * @size: size in bytes of the EDID data | ||
| 48 | * @phys_addr: the new physical address | ||
| 49 | * | ||
| 50 | * This function finds the location of the physical address in the EDID | ||
| 51 | * and fills in the given physical address and updates the checksum | ||
| 52 | * at the end of the EDID block. It does nothing if the EDID doesn't | ||
| 53 | * contain a physical address. | ||
| 54 | */ | ||
| 55 | void cec_set_edid_phys_addr(u8 *edid, unsigned int size, u16 phys_addr); | ||
| 56 | |||
| 57 | /** | ||
| 58 | * cec_phys_addr_for_input() - calculate the PA for an input | ||
| 59 | * | ||
| 60 | * @phys_addr: the physical address of the parent | ||
| 61 | * @input: the number of the input port, must be between 1 and 15 | ||
| 62 | * | ||
| 63 | * This function calculates a new physical address based on the input | ||
| 64 | * port number. For example: | ||
| 65 | * | ||
| 66 | * PA = 0.0.0.0 and input = 2 becomes 2.0.0.0 | ||
| 67 | * | ||
| 68 | * PA = 3.0.0.0 and input = 1 becomes 3.1.0.0 | ||
| 69 | * | ||
| 70 | * PA = 3.2.1.0 and input = 5 becomes 3.2.1.5 | ||
| 71 | * | ||
| 72 | * PA = 3.2.1.3 and input = 5 becomes f.f.f.f since it maxed out the depth. | ||
| 73 | * | ||
| 74 | * Return: the new physical address or CEC_PHYS_ADDR_INVALID. | ||
| 75 | */ | ||
| 76 | u16 cec_phys_addr_for_input(u16 phys_addr, u8 input); | ||
| 77 | |||
| 78 | /** | ||
| 79 | * cec_phys_addr_validate() - validate a physical address from an EDID | ||
| 80 | * | ||
| 81 | * @phys_addr: the physical address to validate | ||
| 82 | * @parent: if not %NULL, then this is filled with the parents PA. | ||
| 83 | * @port: if not %NULL, then this is filled with the input port. | ||
| 84 | * | ||
| 85 | * This validates a physical address as read from an EDID. If the | ||
| 86 | * PA is invalid (such as 1.0.1.0 since '0' is only allowed at the end), | ||
| 87 | * then it will return -EINVAL. | ||
| 88 | * | ||
| 89 | * The parent PA is passed into %parent and the input port is passed into | ||
| 90 | * %port. For example: | ||
| 91 | * | ||
| 92 | * PA = 0.0.0.0: has parent 0.0.0.0 and input port 0. | ||
| 93 | * | ||
| 94 | * PA = 1.0.0.0: has parent 0.0.0.0 and input port 1. | ||
| 95 | * | ||
| 96 | * PA = 3.2.0.0: has parent 3.0.0.0 and input port 2. | ||
| 97 | * | ||
| 98 | * PA = f.f.f.f: has parent f.f.f.f and input port 0. | ||
| 99 | * | ||
| 100 | * Return: 0 if the PA is valid, -EINVAL if not. | ||
| 101 | */ | ||
| 102 | int cec_phys_addr_validate(u16 phys_addr, u16 *parent, u16 *port); | ||
| 103 | |||
| 104 | #endif /* _MEDIA_CEC_EDID_H */ | ||
diff --git a/include/media/cec.h b/include/media/cec.h new file mode 100644 index 000000000000..dc7854b855f3 --- /dev/null +++ b/include/media/cec.h | |||
| @@ -0,0 +1,241 @@ | |||
| 1 | /* | ||
| 2 | * cec - HDMI Consumer Electronics Control support header | ||
| 3 | * | ||
| 4 | * Copyright 2016 Cisco Systems, Inc. and/or its affiliates. All rights reserved. | ||
| 5 | * | ||
| 6 | * This program is free software; you may redistribute it and/or modify | ||
| 7 | * it under the terms of the GNU General Public License as published by | ||
| 8 | * the Free Software Foundation; version 2 of the License. | ||
| 9 | * | ||
| 10 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| 11 | * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| 12 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| 13 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS | ||
| 14 | * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN | ||
| 15 | * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN | ||
| 16 | * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| 17 | * SOFTWARE. | ||
| 18 | */ | ||
| 19 | |||
| 20 | #ifndef _MEDIA_CEC_H | ||
| 21 | #define _MEDIA_CEC_H | ||
| 22 | |||
| 23 | #include <linux/poll.h> | ||
| 24 | #include <linux/fs.h> | ||
| 25 | #include <linux/debugfs.h> | ||
| 26 | #include <linux/device.h> | ||
| 27 | #include <linux/cdev.h> | ||
| 28 | #include <linux/kthread.h> | ||
| 29 | #include <linux/timer.h> | ||
| 30 | #include <linux/cec-funcs.h> | ||
| 31 | #include <media/rc-core.h> | ||
| 32 | #include <media/cec-edid.h> | ||
| 33 | |||
| 34 | /** | ||
| 35 | * struct cec_devnode - cec device node | ||
| 36 | * @dev: cec device | ||
| 37 | * @cdev: cec character device | ||
| 38 | * @parent: parent device | ||
| 39 | * @minor: device node minor number | ||
| 40 | * @registered: the device was correctly registered | ||
| 41 | * @unregistered: the device was unregistered | ||
| 42 | * @fhs_lock: lock to control access to the filehandle list | ||
| 43 | * @fhs: the list of open filehandles (cec_fh) | ||
| 44 | * | ||
| 45 | * This structure represents a cec-related device node. | ||
| 46 | * | ||
| 47 | * The @parent is a physical device. It must be set by core or device drivers | ||
| 48 | * before registering the node. | ||
| 49 | */ | ||
| 50 | struct cec_devnode { | ||
| 51 | /* sysfs */ | ||
| 52 | struct device dev; | ||
| 53 | struct cdev cdev; | ||
| 54 | struct device *parent; | ||
| 55 | |||
| 56 | /* device info */ | ||
| 57 | int minor; | ||
| 58 | bool registered; | ||
| 59 | bool unregistered; | ||
| 60 | struct mutex fhs_lock; | ||
| 61 | struct list_head fhs; | ||
| 62 | }; | ||
| 63 | |||
| 64 | struct cec_adapter; | ||
| 65 | struct cec_data; | ||
| 66 | |||
| 67 | struct cec_data { | ||
| 68 | struct list_head list; | ||
| 69 | struct list_head xfer_list; | ||
| 70 | struct cec_adapter *adap; | ||
| 71 | struct cec_msg msg; | ||
| 72 | struct cec_fh *fh; | ||
| 73 | struct delayed_work work; | ||
| 74 | struct completion c; | ||
| 75 | u8 attempts; | ||
| 76 | bool new_initiator; | ||
| 77 | bool blocking; | ||
| 78 | bool completed; | ||
| 79 | }; | ||
| 80 | |||
| 81 | struct cec_msg_entry { | ||
| 82 | struct list_head list; | ||
| 83 | struct cec_msg msg; | ||
| 84 | }; | ||
| 85 | |||
| 86 | #define CEC_NUM_EVENTS CEC_EVENT_LOST_MSGS | ||
| 87 | |||
| 88 | struct cec_fh { | ||
| 89 | struct list_head list; | ||
| 90 | struct list_head xfer_list; | ||
| 91 | struct cec_adapter *adap; | ||
| 92 | u8 mode_initiator; | ||
| 93 | u8 mode_follower; | ||
| 94 | |||
| 95 | /* Events */ | ||
| 96 | wait_queue_head_t wait; | ||
| 97 | unsigned int pending_events; | ||
| 98 | struct cec_event events[CEC_NUM_EVENTS]; | ||
| 99 | struct mutex lock; | ||
| 100 | struct list_head msgs; /* queued messages */ | ||
| 101 | unsigned int queued_msgs; | ||
| 102 | }; | ||
| 103 | |||
| 104 | #define CEC_SIGNAL_FREE_TIME_RETRY 3 | ||
| 105 | #define CEC_SIGNAL_FREE_TIME_NEW_INITIATOR 5 | ||
| 106 | #define CEC_SIGNAL_FREE_TIME_NEXT_XFER 7 | ||
| 107 | |||
| 108 | /* The nominal data bit period is 2.4 ms */ | ||
| 109 | #define CEC_FREE_TIME_TO_USEC(ft) ((ft) * 2400) | ||
| 110 | |||
| 111 | struct cec_adap_ops { | ||
| 112 | /* Low-level callbacks */ | ||
| 113 | int (*adap_enable)(struct cec_adapter *adap, bool enable); | ||
| 114 | int (*adap_monitor_all_enable)(struct cec_adapter *adap, bool enable); | ||
| 115 | int (*adap_log_addr)(struct cec_adapter *adap, u8 logical_addr); | ||
| 116 | int (*adap_transmit)(struct cec_adapter *adap, u8 attempts, | ||
| 117 | u32 signal_free_time, struct cec_msg *msg); | ||
| 118 | void (*adap_status)(struct cec_adapter *adap, struct seq_file *file); | ||
| 119 | |||
| 120 | /* High-level CEC message callback */ | ||
| 121 | int (*received)(struct cec_adapter *adap, struct cec_msg *msg); | ||
| 122 | }; | ||
| 123 | |||
| 124 | /* | ||
| 125 | * The minimum message length you can receive (excepting poll messages) is 2. | ||
| 126 | * With a transfer rate of at most 36 bytes per second this makes 18 messages | ||
| 127 | * per second worst case. | ||
| 128 | * | ||
| 129 | * We queue at most 3 seconds worth of received messages. The CEC specification | ||
| 130 | * requires that messages are replied to within a second, so 3 seconds should | ||
| 131 | * give more than enough margin. Since most messages are actually more than 2 | ||
| 132 | * bytes, this is in practice a lot more than 3 seconds. | ||
| 133 | */ | ||
| 134 | #define CEC_MAX_MSG_RX_QUEUE_SZ (18 * 3) | ||
| 135 | |||
| 136 | /* | ||
| 137 | * The transmit queue is limited to 1 second worth of messages (worst case). | ||
| 138 | * Messages can be transmitted by userspace and kernel space. But for both it | ||
| 139 | * makes no sense to have a lot of messages queued up. One second seems | ||
| 140 | * reasonable. | ||
| 141 | */ | ||
| 142 | #define CEC_MAX_MSG_TX_QUEUE_SZ (18 * 1) | ||
| 143 | |||
| 144 | struct cec_adapter { | ||
| 145 | struct module *owner; | ||
| 146 | char name[32]; | ||
| 147 | struct cec_devnode devnode; | ||
| 148 | struct mutex lock; | ||
| 149 | struct rc_dev *rc; | ||
| 150 | |||
| 151 | struct list_head transmit_queue; | ||
| 152 | unsigned int transmit_queue_sz; | ||
| 153 | struct list_head wait_queue; | ||
| 154 | struct cec_data *transmitting; | ||
| 155 | |||
| 156 | struct task_struct *kthread_config; | ||
| 157 | struct completion config_completion; | ||
| 158 | |||
| 159 | struct task_struct *kthread; | ||
| 160 | wait_queue_head_t kthread_waitq; | ||
| 161 | wait_queue_head_t waitq; | ||
| 162 | |||
| 163 | const struct cec_adap_ops *ops; | ||
| 164 | void *priv; | ||
| 165 | u32 capabilities; | ||
| 166 | u8 available_log_addrs; | ||
| 167 | |||
| 168 | u16 phys_addr; | ||
| 169 | bool is_configuring; | ||
| 170 | bool is_configured; | ||
| 171 | u32 monitor_all_cnt; | ||
| 172 | u32 follower_cnt; | ||
| 173 | struct cec_fh *cec_follower; | ||
| 174 | struct cec_fh *cec_initiator; | ||
| 175 | bool passthrough; | ||
| 176 | struct cec_log_addrs log_addrs; | ||
| 177 | |||
| 178 | struct dentry *cec_dir; | ||
| 179 | struct dentry *status_file; | ||
| 180 | |||
| 181 | u16 phys_addrs[15]; | ||
| 182 | u32 sequence; | ||
| 183 | |||
| 184 | char input_name[32]; | ||
| 185 | char input_phys[32]; | ||
| 186 | char input_drv[32]; | ||
| 187 | }; | ||
| 188 | |||
| 189 | static inline bool cec_has_log_addr(const struct cec_adapter *adap, u8 log_addr) | ||
| 190 | { | ||
| 191 | return adap->log_addrs.log_addr_mask & (1 << log_addr); | ||
| 192 | } | ||
| 193 | |||
| 194 | static inline bool cec_is_sink(const struct cec_adapter *adap) | ||
| 195 | { | ||
| 196 | return adap->phys_addr == 0; | ||
| 197 | } | ||
| 198 | |||
| 199 | #if IS_ENABLED(CONFIG_MEDIA_CEC) | ||
| 200 | struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops, | ||
| 201 | void *priv, const char *name, u32 caps, u8 available_las, | ||
| 202 | struct device *parent); | ||
| 203 | int cec_register_adapter(struct cec_adapter *adap); | ||
| 204 | void cec_unregister_adapter(struct cec_adapter *adap); | ||
| 205 | void cec_delete_adapter(struct cec_adapter *adap); | ||
| 206 | |||
| 207 | int cec_s_log_addrs(struct cec_adapter *adap, struct cec_log_addrs *log_addrs, | ||
| 208 | bool block); | ||
| 209 | void cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, | ||
| 210 | bool block); | ||
| 211 | int cec_transmit_msg(struct cec_adapter *adap, struct cec_msg *msg, | ||
| 212 | bool block); | ||
| 213 | |||
| 214 | /* Called by the adapter */ | ||
| 215 | void cec_transmit_done(struct cec_adapter *adap, u8 status, u8 arb_lost_cnt, | ||
| 216 | u8 nack_cnt, u8 low_drive_cnt, u8 error_cnt); | ||
| 217 | void cec_received_msg(struct cec_adapter *adap, struct cec_msg *msg); | ||
| 218 | |||
| 219 | #else | ||
| 220 | |||
| 221 | static inline int cec_register_adapter(struct cec_adapter *adap) | ||
| 222 | { | ||
| 223 | return 0; | ||
| 224 | } | ||
| 225 | |||
| 226 | static inline void cec_unregister_adapter(struct cec_adapter *adap) | ||
| 227 | { | ||
| 228 | } | ||
| 229 | |||
| 230 | static inline void cec_delete_adapter(struct cec_adapter *adap) | ||
| 231 | { | ||
| 232 | } | ||
| 233 | |||
| 234 | static inline void cec_s_phys_addr(struct cec_adapter *adap, u16 phys_addr, | ||
| 235 | bool block) | ||
| 236 | { | ||
| 237 | } | ||
| 238 | |||
| 239 | #endif | ||
| 240 | |||
| 241 | #endif /* _MEDIA_CEC_H */ | ||
diff --git a/include/media/davinci/vpbe_display.h b/include/media/davinci/vpbe_display.h index e14a9370b67e..12783fd823f8 100644 --- a/include/media/davinci/vpbe_display.h +++ b/include/media/davinci/vpbe_display.h | |||
| @@ -81,8 +81,6 @@ struct vpbe_layer { | |||
| 81 | * Buffer queue used in video-buf | 81 | * Buffer queue used in video-buf |
| 82 | */ | 82 | */ |
| 83 | struct vb2_queue buffer_queue; | 83 | struct vb2_queue buffer_queue; |
| 84 | /* allocator-specific contexts for each plane */ | ||
| 85 | struct vb2_alloc_ctx *alloc_ctx; | ||
| 86 | /* Queue of filled frames */ | 84 | /* Queue of filled frames */ |
| 87 | struct list_head dma_queue; | 85 | struct list_head dma_queue; |
| 88 | /* Used in video-buf */ | 86 | /* Used in video-buf */ |
diff --git a/include/media/i2c/adv7511.h b/include/media/i2c/adv7511.h index d83b91d80764..61c3d711cc69 100644 --- a/include/media/i2c/adv7511.h +++ b/include/media/i2c/adv7511.h | |||
| @@ -32,11 +32,7 @@ struct adv7511_monitor_detect { | |||
| 32 | struct adv7511_edid_detect { | 32 | struct adv7511_edid_detect { |
| 33 | int present; | 33 | int present; |
| 34 | int segment; | 34 | int segment; |
| 35 | }; | 35 | uint16_t phys_addr; |
| 36 | |||
| 37 | struct adv7511_cec_arg { | ||
| 38 | void *arg; | ||
| 39 | u32 f_flags; | ||
| 40 | }; | 36 | }; |
| 41 | 37 | ||
| 42 | struct adv7511_platform_data { | 38 | struct adv7511_platform_data { |
diff --git a/include/media/i2c/adv7604.h b/include/media/i2c/adv7604.h index a913859bfd30..2e6857dee0cc 100644 --- a/include/media/i2c/adv7604.h +++ b/include/media/i2c/adv7604.h | |||
| @@ -121,8 +121,6 @@ struct adv76xx_platform_data { | |||
| 121 | 121 | ||
| 122 | /* IO register 0x02 */ | 122 | /* IO register 0x02 */ |
| 123 | unsigned alt_gamma:1; | 123 | unsigned alt_gamma:1; |
| 124 | unsigned op_656_range:1; | ||
| 125 | unsigned alt_data_sat:1; | ||
| 126 | 124 | ||
| 127 | /* IO register 0x05 */ | 125 | /* IO register 0x05 */ |
| 128 | unsigned blank_data:1; | 126 | unsigned blank_data:1; |
diff --git a/include/media/i2c/adv7842.h b/include/media/i2c/adv7842.h index bc249709bf35..7f53ada9bdf1 100644 --- a/include/media/i2c/adv7842.h +++ b/include/media/i2c/adv7842.h | |||
| @@ -165,8 +165,6 @@ struct adv7842_platform_data { | |||
| 165 | 165 | ||
| 166 | /* IO register 0x02 */ | 166 | /* IO register 0x02 */ |
| 167 | unsigned alt_gamma:1; | 167 | unsigned alt_gamma:1; |
| 168 | unsigned op_656_range:1; | ||
| 169 | unsigned alt_data_sat:1; | ||
| 170 | 168 | ||
| 171 | /* IO register 0x05 */ | 169 | /* IO register 0x05 */ |
| 172 | unsigned blank_data:1; | 170 | unsigned blank_data:1; |
diff --git a/include/media/media-device.h b/include/media/media-device.h index a9b33c47310d..f743ae2210ee 100644 --- a/include/media/media-device.h +++ b/include/media/media-device.h | |||
| @@ -347,7 +347,7 @@ struct media_entity_notify { | |||
| 347 | struct media_device { | 347 | struct media_device { |
| 348 | /* dev->driver_data points to this struct. */ | 348 | /* dev->driver_data points to this struct. */ |
| 349 | struct device *dev; | 349 | struct device *dev; |
| 350 | struct media_devnode devnode; | 350 | struct media_devnode *devnode; |
| 351 | 351 | ||
| 352 | char model[32]; | 352 | char model[32]; |
| 353 | char driver_name[32]; | 353 | char driver_name[32]; |
| @@ -393,9 +393,6 @@ struct usb_device; | |||
| 393 | #define MEDIA_DEV_NOTIFY_PRE_LINK_CH 0 | 393 | #define MEDIA_DEV_NOTIFY_PRE_LINK_CH 0 |
| 394 | #define MEDIA_DEV_NOTIFY_POST_LINK_CH 1 | 394 | #define MEDIA_DEV_NOTIFY_POST_LINK_CH 1 |
| 395 | 395 | ||
| 396 | /* media_devnode to media_device */ | ||
| 397 | #define to_media_device(node) container_of(node, struct media_device, devnode) | ||
| 398 | |||
| 399 | /** | 396 | /** |
| 400 | * media_entity_enum_init - Initialise an entity enumeration | 397 | * media_entity_enum_init - Initialise an entity enumeration |
| 401 | * | 398 | * |
diff --git a/include/media/media-devnode.h b/include/media/media-devnode.h index fe42f08e72bd..37d494805944 100644 --- a/include/media/media-devnode.h +++ b/include/media/media-devnode.h | |||
| @@ -33,6 +33,8 @@ | |||
| 33 | #include <linux/device.h> | 33 | #include <linux/device.h> |
| 34 | #include <linux/cdev.h> | 34 | #include <linux/cdev.h> |
| 35 | 35 | ||
| 36 | struct media_device; | ||
| 37 | |||
| 36 | /* | 38 | /* |
| 37 | * Flag to mark the media_devnode struct as registered. Drivers must not touch | 39 | * Flag to mark the media_devnode struct as registered. Drivers must not touch |
| 38 | * this flag directly, it will be set and cleared by media_devnode_register and | 40 | * this flag directly, it will be set and cleared by media_devnode_register and |
| @@ -67,8 +69,9 @@ struct media_file_operations { | |||
| 67 | 69 | ||
| 68 | /** | 70 | /** |
| 69 | * struct media_devnode - Media device node | 71 | * struct media_devnode - Media device node |
| 72 | * @media_dev: pointer to struct &media_device | ||
| 70 | * @fops: pointer to struct &media_file_operations with media device ops | 73 | * @fops: pointer to struct &media_file_operations with media device ops |
| 71 | * @dev: struct device pointer for the media controller device | 74 | * @dev: pointer to struct &device containing the media controller device |
| 72 | * @cdev: struct cdev pointer character device | 75 | * @cdev: struct cdev pointer character device |
| 73 | * @parent: parent device | 76 | * @parent: parent device |
| 74 | * @minor: device node minor number | 77 | * @minor: device node minor number |
| @@ -81,6 +84,8 @@ struct media_file_operations { | |||
| 81 | * before registering the node. | 84 | * before registering the node. |
| 82 | */ | 85 | */ |
| 83 | struct media_devnode { | 86 | struct media_devnode { |
| 87 | struct media_device *media_dev; | ||
| 88 | |||
| 84 | /* device ops */ | 89 | /* device ops */ |
| 85 | const struct media_file_operations *fops; | 90 | const struct media_file_operations *fops; |
| 86 | 91 | ||
| @@ -94,7 +99,7 @@ struct media_devnode { | |||
| 94 | unsigned long flags; /* Use bitops to access flags */ | 99 | unsigned long flags; /* Use bitops to access flags */ |
| 95 | 100 | ||
| 96 | /* callbacks */ | 101 | /* callbacks */ |
| 97 | void (*release)(struct media_devnode *mdev); | 102 | void (*release)(struct media_devnode *devnode); |
| 98 | }; | 103 | }; |
| 99 | 104 | ||
| 100 | /* dev to media_devnode */ | 105 | /* dev to media_devnode */ |
| @@ -103,7 +108,8 @@ struct media_devnode { | |||
| 103 | /** | 108 | /** |
| 104 | * media_devnode_register - register a media device node | 109 | * media_devnode_register - register a media device node |
| 105 | * | 110 | * |
| 106 | * @mdev: media device node structure we want to register | 111 | * @mdev: struct media_device we want to register a device node |
| 112 | * @devnode: media device node structure we want to register | ||
| 107 | * @owner: should be filled with %THIS_MODULE | 113 | * @owner: should be filled with %THIS_MODULE |
| 108 | * | 114 | * |
| 109 | * The registration code assigns minor numbers and registers the new device node | 115 | * The registration code assigns minor numbers and registers the new device node |
| @@ -116,20 +122,33 @@ struct media_devnode { | |||
| 116 | * the media_devnode structure is *not* called, so the caller is responsible for | 122 | * the media_devnode structure is *not* called, so the caller is responsible for |
| 117 | * freeing any data. | 123 | * freeing any data. |
| 118 | */ | 124 | */ |
| 119 | int __must_check media_devnode_register(struct media_devnode *mdev, | 125 | int __must_check media_devnode_register(struct media_device *mdev, |
| 126 | struct media_devnode *devnode, | ||
| 120 | struct module *owner); | 127 | struct module *owner); |
| 121 | 128 | ||
| 122 | /** | 129 | /** |
| 130 | * media_devnode_unregister_prepare - clear the media device node register bit | ||
| 131 | * @devnode: the device node to prepare for unregister | ||
| 132 | * | ||
| 133 | * This clears the passed device register bit. Future open calls will be met | ||
| 134 | * with errors. Should be called before media_devnode_unregister() to avoid | ||
| 135 | * races with unregister and device file open calls. | ||
| 136 | * | ||
| 137 | * This function can safely be called if the device node has never been | ||
| 138 | * registered or has already been unregistered. | ||
| 139 | */ | ||
| 140 | void media_devnode_unregister_prepare(struct media_devnode *devnode); | ||
| 141 | |||
| 142 | /** | ||
| 123 | * media_devnode_unregister - unregister a media device node | 143 | * media_devnode_unregister - unregister a media device node |
| 124 | * @mdev: the device node to unregister | 144 | * @devnode: the device node to unregister |
| 125 | * | 145 | * |
| 126 | * This unregisters the passed device. Future open calls will be met with | 146 | * This unregisters the passed device. Future open calls will be met with |
| 127 | * errors. | 147 | * errors. |
| 128 | * | 148 | * |
| 129 | * This function can safely be called if the device node has never been | 149 | * Should be called after media_devnode_unregister_prepare() |
| 130 | * registered or has already been unregistered. | ||
| 131 | */ | 150 | */ |
| 132 | void media_devnode_unregister(struct media_devnode *mdev); | 151 | void media_devnode_unregister(struct media_devnode *devnode); |
| 133 | 152 | ||
| 134 | /** | 153 | /** |
| 135 | * media_devnode_data - returns a pointer to the &media_devnode | 154 | * media_devnode_data - returns a pointer to the &media_devnode |
| @@ -145,11 +164,16 @@ static inline struct media_devnode *media_devnode_data(struct file *filp) | |||
| 145 | * media_devnode_is_registered - returns true if &media_devnode is registered; | 164 | * media_devnode_is_registered - returns true if &media_devnode is registered; |
| 146 | * false otherwise. | 165 | * false otherwise. |
| 147 | * | 166 | * |
| 148 | * @mdev: pointer to struct &media_devnode. | 167 | * @devnode: pointer to struct &media_devnode. |
| 168 | * | ||
| 169 | * Note: If mdev is NULL, it also returns false. | ||
| 149 | */ | 170 | */ |
| 150 | static inline int media_devnode_is_registered(struct media_devnode *mdev) | 171 | static inline int media_devnode_is_registered(struct media_devnode *devnode) |
| 151 | { | 172 | { |
| 152 | return test_bit(MEDIA_FLAG_REGISTERED, &mdev->flags); | 173 | if (!devnode) |
| 174 | return false; | ||
| 175 | |||
| 176 | return test_bit(MEDIA_FLAG_REGISTERED, &devnode->flags); | ||
| 153 | } | 177 | } |
| 154 | 178 | ||
| 155 | #endif /* _MEDIA_DEVNODE_H */ | 179 | #endif /* _MEDIA_DEVNODE_H */ |
diff --git a/include/media/rc-core.h b/include/media/rc-core.h index b6586a91129c..324232cfc08d 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h | |||
| @@ -119,6 +119,7 @@ enum rc_filter_type { | |||
| 119 | * @s_carrier_report: enable carrier reports | 119 | * @s_carrier_report: enable carrier reports |
| 120 | * @s_filter: set the scancode filter | 120 | * @s_filter: set the scancode filter |
| 121 | * @s_wakeup_filter: set the wakeup scancode filter | 121 | * @s_wakeup_filter: set the wakeup scancode filter |
| 122 | * @s_timeout: set hardware timeout in ns | ||
| 122 | */ | 123 | */ |
| 123 | struct rc_dev { | 124 | struct rc_dev { |
| 124 | struct device dev; | 125 | struct device dev; |
| @@ -174,6 +175,8 @@ struct rc_dev { | |||
| 174 | struct rc_scancode_filter *filter); | 175 | struct rc_scancode_filter *filter); |
| 175 | int (*s_wakeup_filter)(struct rc_dev *dev, | 176 | int (*s_wakeup_filter)(struct rc_dev *dev, |
| 176 | struct rc_scancode_filter *filter); | 177 | struct rc_scancode_filter *filter); |
| 178 | int (*s_timeout)(struct rc_dev *dev, | ||
| 179 | unsigned int timeout); | ||
| 177 | }; | 180 | }; |
| 178 | 181 | ||
| 179 | #define to_rc_dev(d) container_of(d, struct rc_dev, dev) | 182 | #define to_rc_dev(d) container_of(d, struct rc_dev, dev) |
diff --git a/include/media/rc-map.h b/include/media/rc-map.h index 7844e9879497..a459129dd554 100644 --- a/include/media/rc-map.h +++ b/include/media/rc-map.h | |||
| @@ -31,6 +31,7 @@ enum rc_type { | |||
| 31 | RC_TYPE_RC6_MCE = 16, /* MCE (Philips RC6-6A-32 subtype) protocol */ | 31 | RC_TYPE_RC6_MCE = 16, /* MCE (Philips RC6-6A-32 subtype) protocol */ |
| 32 | RC_TYPE_SHARP = 17, /* Sharp protocol */ | 32 | RC_TYPE_SHARP = 17, /* Sharp protocol */ |
| 33 | RC_TYPE_XMP = 18, /* XMP protocol */ | 33 | RC_TYPE_XMP = 18, /* XMP protocol */ |
| 34 | RC_TYPE_CEC = 19, /* CEC protocol */ | ||
| 34 | }; | 35 | }; |
| 35 | 36 | ||
| 36 | #define RC_BIT_NONE 0ULL | 37 | #define RC_BIT_NONE 0ULL |
| @@ -53,6 +54,7 @@ enum rc_type { | |||
| 53 | #define RC_BIT_RC6_MCE (1ULL << RC_TYPE_RC6_MCE) | 54 | #define RC_BIT_RC6_MCE (1ULL << RC_TYPE_RC6_MCE) |
| 54 | #define RC_BIT_SHARP (1ULL << RC_TYPE_SHARP) | 55 | #define RC_BIT_SHARP (1ULL << RC_TYPE_SHARP) |
| 55 | #define RC_BIT_XMP (1ULL << RC_TYPE_XMP) | 56 | #define RC_BIT_XMP (1ULL << RC_TYPE_XMP) |
| 57 | #define RC_BIT_CEC (1ULL << RC_TYPE_CEC) | ||
| 56 | 58 | ||
| 57 | #define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | \ | 59 | #define RC_BIT_ALL (RC_BIT_UNKNOWN | RC_BIT_OTHER | \ |
| 58 | RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \ | 60 | RC_BIT_RC5 | RC_BIT_RC5X | RC_BIT_RC5_SZ | \ |
| @@ -61,7 +63,7 @@ enum rc_type { | |||
| 61 | RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \ | 63 | RC_BIT_NEC | RC_BIT_SANYO | RC_BIT_MCE_KBD | \ |
| 62 | RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \ | 64 | RC_BIT_RC6_0 | RC_BIT_RC6_6A_20 | RC_BIT_RC6_6A_24 | \ |
| 63 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \ | 65 | RC_BIT_RC6_6A_32 | RC_BIT_RC6_MCE | RC_BIT_SHARP | \ |
| 64 | RC_BIT_XMP) | 66 | RC_BIT_XMP | RC_BIT_CEC) |
| 65 | 67 | ||
| 66 | 68 | ||
| 67 | #define RC_SCANCODE_UNKNOWN(x) (x) | 69 | #define RC_SCANCODE_UNKNOWN(x) (x) |
| @@ -123,6 +125,7 @@ void rc_map_init(void); | |||
| 123 | #define RC_MAP_BEHOLD_COLUMBUS "rc-behold-columbus" | 125 | #define RC_MAP_BEHOLD_COLUMBUS "rc-behold-columbus" |
| 124 | #define RC_MAP_BEHOLD "rc-behold" | 126 | #define RC_MAP_BEHOLD "rc-behold" |
| 125 | #define RC_MAP_BUDGET_CI_OLD "rc-budget-ci-old" | 127 | #define RC_MAP_BUDGET_CI_OLD "rc-budget-ci-old" |
| 128 | #define RC_MAP_CEC "rc-cec" | ||
| 126 | #define RC_MAP_CINERGY_1400 "rc-cinergy-1400" | 129 | #define RC_MAP_CINERGY_1400 "rc-cinergy-1400" |
| 127 | #define RC_MAP_CINERGY "rc-cinergy" | 130 | #define RC_MAP_CINERGY "rc-cinergy" |
| 128 | #define RC_MAP_DELOCK_61959 "rc-delock-61959" | 131 | #define RC_MAP_DELOCK_61959 "rc-delock-61959" |
| @@ -133,6 +136,7 @@ void rc_map_init(void); | |||
| 133 | #define RC_MAP_DM1105_NEC "rc-dm1105-nec" | 136 | #define RC_MAP_DM1105_NEC "rc-dm1105-nec" |
| 134 | #define RC_MAP_DNTV_LIVE_DVBT_PRO "rc-dntv-live-dvbt-pro" | 137 | #define RC_MAP_DNTV_LIVE_DVBT_PRO "rc-dntv-live-dvbt-pro" |
| 135 | #define RC_MAP_DNTV_LIVE_DVB_T "rc-dntv-live-dvb-t" | 138 | #define RC_MAP_DNTV_LIVE_DVB_T "rc-dntv-live-dvb-t" |
| 139 | #define RC_MAP_DTT200U "rc-dtt200u" | ||
| 136 | #define RC_MAP_DVBSKY "rc-dvbsky" | 140 | #define RC_MAP_DVBSKY "rc-dvbsky" |
| 137 | #define RC_MAP_EMPTY "rc-empty" | 141 | #define RC_MAP_EMPTY "rc-empty" |
| 138 | #define RC_MAP_EM_TERRATEC "rc-em-terratec" | 142 | #define RC_MAP_EM_TERRATEC "rc-em-terratec" |
diff --git a/include/media/rcar-fcp.h b/include/media/rcar-fcp.h new file mode 100644 index 000000000000..4c7fc77eaf29 --- /dev/null +++ b/include/media/rcar-fcp.h | |||
| @@ -0,0 +1,37 @@ | |||
| 1 | /* | ||
| 2 | * rcar-fcp.h -- R-Car Frame Compression Processor Driver | ||
| 3 | * | ||
| 4 | * Copyright (C) 2016 Renesas Electronics Corporation | ||
| 5 | * | ||
| 6 | * Contact: Laurent Pinchart (laurent.pinchart@ideasonboard.com) | ||
| 7 | * | ||
| 8 | * This program is free software; you can redistribute it and/or modify | ||
| 9 | * it under the terms of the GNU General Public License as published by | ||
| 10 | * the Free Software Foundation; either version 2 of the License, or | ||
| 11 | * (at your option) any later version. | ||
| 12 | */ | ||
| 13 | #ifndef __MEDIA_RCAR_FCP_H__ | ||
| 14 | #define __MEDIA_RCAR_FCP_H__ | ||
| 15 | |||
| 16 | struct device_node; | ||
| 17 | struct rcar_fcp_device; | ||
| 18 | |||
| 19 | #if IS_ENABLED(CONFIG_VIDEO_RENESAS_FCP) | ||
| 20 | struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np); | ||
| 21 | void rcar_fcp_put(struct rcar_fcp_device *fcp); | ||
| 22 | int rcar_fcp_enable(struct rcar_fcp_device *fcp); | ||
| 23 | void rcar_fcp_disable(struct rcar_fcp_device *fcp); | ||
| 24 | #else | ||
| 25 | static inline struct rcar_fcp_device *rcar_fcp_get(const struct device_node *np) | ||
| 26 | { | ||
| 27 | return ERR_PTR(-ENOENT); | ||
| 28 | } | ||
| 29 | static inline void rcar_fcp_put(struct rcar_fcp_device *fcp) { } | ||
| 30 | static inline int rcar_fcp_enable(struct rcar_fcp_device *fcp) | ||
| 31 | { | ||
| 32 | return -ENOSYS; | ||
| 33 | } | ||
| 34 | static inline void rcar_fcp_disable(struct rcar_fcp_device *fcp) { } | ||
| 35 | #endif | ||
| 36 | |||
| 37 | #endif /* __MEDIA_RCAR_FCP_H__ */ | ||
diff --git a/include/media/v4l2-ctrls.h b/include/media/v4l2-ctrls.h index 0bc9b35b8f3e..8b59336b2217 100644 --- a/include/media/v4l2-ctrls.h +++ b/include/media/v4l2-ctrls.h | |||
| @@ -759,9 +759,9 @@ s32 v4l2_ctrl_g_ctrl(struct v4l2_ctrl *ctrl); | |||
| 759 | * @ctrl: The control. | 759 | * @ctrl: The control. |
| 760 | * @val: The new value. | 760 | * @val: The new value. |
| 761 | * | 761 | * |
| 762 | * This set the control's new value safely by going through the control | 762 | * This sets the control's new value safely by going through the control |
| 763 | * framework. This function will lock the control's handler, so it cannot be | 763 | * framework. This function assumes the control's handler is already locked, |
| 764 | * used from within the &v4l2_ctrl_ops functions. | 764 | * allowing it to be used from within the &v4l2_ctrl_ops functions. |
| 765 | * | 765 | * |
| 766 | * This function is for integer type controls only. | 766 | * This function is for integer type controls only. |
| 767 | */ | 767 | */ |
| @@ -771,7 +771,7 @@ int __v4l2_ctrl_s_ctrl(struct v4l2_ctrl *ctrl, s32 val); | |||
| 771 | * @ctrl: The control. | 771 | * @ctrl: The control. |
| 772 | * @val: The new value. | 772 | * @val: The new value. |
| 773 | * | 773 | * |
| 774 | * This set the control's new value safely by going through the control | 774 | * This sets the control's new value safely by going through the control |
| 775 | * framework. This function will lock the control's handler, so it cannot be | 775 | * framework. This function will lock the control's handler, so it cannot be |
| 776 | * used from within the &v4l2_ctrl_ops functions. | 776 | * used from within the &v4l2_ctrl_ops functions. |
| 777 | * | 777 | * |
| @@ -807,9 +807,9 @@ s64 v4l2_ctrl_g_ctrl_int64(struct v4l2_ctrl *ctrl); | |||
| 807 | * @ctrl: The control. | 807 | * @ctrl: The control. |
| 808 | * @val: The new value. | 808 | * @val: The new value. |
| 809 | * | 809 | * |
| 810 | * This set the control's new value safely by going through the control | 810 | * This sets the control's new value safely by going through the control |
| 811 | * framework. This function will lock the control's handler, so it cannot be | 811 | * framework. This function assumes the control's handler is already locked, |
| 812 | * used from within the &v4l2_ctrl_ops functions. | 812 | * allowing it to be used from within the &v4l2_ctrl_ops functions. |
| 813 | * | 813 | * |
| 814 | * This function is for 64-bit integer type controls only. | 814 | * This function is for 64-bit integer type controls only. |
| 815 | */ | 815 | */ |
| @@ -821,7 +821,7 @@ int __v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val); | |||
| 821 | * @ctrl: The control. | 821 | * @ctrl: The control. |
| 822 | * @val: The new value. | 822 | * @val: The new value. |
| 823 | * | 823 | * |
| 824 | * This set the control's new value safely by going through the control | 824 | * This sets the control's new value safely by going through the control |
| 825 | * framework. This function will lock the control's handler, so it cannot be | 825 | * framework. This function will lock the control's handler, so it cannot be |
| 826 | * used from within the &v4l2_ctrl_ops functions. | 826 | * used from within the &v4l2_ctrl_ops functions. |
| 827 | * | 827 | * |
| @@ -843,9 +843,9 @@ static inline int v4l2_ctrl_s_ctrl_int64(struct v4l2_ctrl *ctrl, s64 val) | |||
| 843 | * @ctrl: The control. | 843 | * @ctrl: The control. |
| 844 | * @s: The new string. | 844 | * @s: The new string. |
| 845 | * | 845 | * |
| 846 | * This set the control's new string safely by going through the control | 846 | * This sets the control's new string safely by going through the control |
| 847 | * framework. This function will lock the control's handler, so it cannot be | 847 | * framework. This function assumes the control's handler is already locked, |
| 848 | * used from within the &v4l2_ctrl_ops functions. | 848 | * allowing it to be used from within the &v4l2_ctrl_ops functions. |
| 849 | * | 849 | * |
| 850 | * This function is for string type controls only. | 850 | * This function is for string type controls only. |
| 851 | */ | 851 | */ |
| @@ -857,7 +857,7 @@ int __v4l2_ctrl_s_ctrl_string(struct v4l2_ctrl *ctrl, const char *s); | |||
| 857 | * @ctrl: The control. | 857 | * @ctrl: The control. |
| 858 | * @s: The new string. | 858 | * @s: The new string. |
| 859 | * | 859 | * |
| 860 | * This set the control's new string safely by going through the control | 860 | * This sets the control's new string safely by going through the control |
| 861 | * framework. This function will lock the control's handler, so it cannot be | 861 | * framework. This function will lock the control's handler, so it cannot be |
| 862 | * used from within the &v4l2_ctrl_ops functions. | 862 | * used from within the &v4l2_ctrl_ops functions. |
| 863 | * | 863 | * |
| @@ -903,16 +903,6 @@ int v4l2_try_ext_ctrls(struct v4l2_ctrl_handler *hdl, struct v4l2_ext_controls * | |||
| 903 | int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, | 903 | int v4l2_s_ext_ctrls(struct v4l2_fh *fh, struct v4l2_ctrl_handler *hdl, |
| 904 | struct v4l2_ext_controls *c); | 904 | struct v4l2_ext_controls *c); |
| 905 | 905 | ||
| 906 | /* Helpers for subdevices. If the associated ctrl_handler == NULL then they | ||
| 907 | will all return -EINVAL. */ | ||
| 908 | int v4l2_subdev_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc); | ||
| 909 | int v4l2_subdev_querymenu(struct v4l2_subdev *sd, struct v4l2_querymenu *qm); | ||
| 910 | int v4l2_subdev_g_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs); | ||
| 911 | int v4l2_subdev_try_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs); | ||
| 912 | int v4l2_subdev_s_ext_ctrls(struct v4l2_subdev *sd, struct v4l2_ext_controls *cs); | ||
| 913 | int v4l2_subdev_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl); | ||
| 914 | int v4l2_subdev_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl); | ||
| 915 | |||
| 916 | /* Can be used as a subscribe_event function that just subscribes control | 906 | /* Can be used as a subscribe_event function that just subscribes control |
| 917 | events. */ | 907 | events. */ |
| 918 | int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, | 908 | int v4l2_ctrl_subdev_subscribe_event(struct v4l2_subdev *sd, struct v4l2_fh *fh, |
diff --git a/include/media/v4l2-subdev.h b/include/media/v4l2-subdev.h index 32fc7a4beb5e..c672efc4f87b 100644 --- a/include/media/v4l2-subdev.h +++ b/include/media/v4l2-subdev.h | |||
| @@ -143,20 +143,6 @@ struct v4l2_subdev_io_pin_config { | |||
| 143 | * @s_gpio: set GPIO pins. Very simple right now, might need to be extended with | 143 | * @s_gpio: set GPIO pins. Very simple right now, might need to be extended with |
| 144 | * a direction argument if needed. | 144 | * a direction argument if needed. |
| 145 | * | 145 | * |
| 146 | * @queryctrl: callback for VIDIOC_QUERYCTL ioctl handler code. | ||
| 147 | * | ||
| 148 | * @g_ctrl: callback for VIDIOC_G_CTRL ioctl handler code. | ||
| 149 | * | ||
| 150 | * @s_ctrl: callback for VIDIOC_S_CTRL ioctl handler code. | ||
| 151 | * | ||
| 152 | * @g_ext_ctrls: callback for VIDIOC_G_EXT_CTRLS ioctl handler code. | ||
| 153 | * | ||
| 154 | * @s_ext_ctrls: callback for VIDIOC_S_EXT_CTRLS ioctl handler code. | ||
| 155 | * | ||
| 156 | * @try_ext_ctrls: callback for VIDIOC_TRY_EXT_CTRLS ioctl handler code. | ||
| 157 | * | ||
| 158 | * @querymenu: callback for VIDIOC_QUERYMENU ioctl handler code. | ||
| 159 | * | ||
| 160 | * @ioctl: called at the end of ioctl() syscall handler at the V4L2 core. | 146 | * @ioctl: called at the end of ioctl() syscall handler at the V4L2 core. |
| 161 | * used to provide support for private ioctls used on the driver. | 147 | * used to provide support for private ioctls used on the driver. |
| 162 | * | 148 | * |
| @@ -190,13 +176,6 @@ struct v4l2_subdev_core_ops { | |||
| 190 | int (*load_fw)(struct v4l2_subdev *sd); | 176 | int (*load_fw)(struct v4l2_subdev *sd); |
| 191 | int (*reset)(struct v4l2_subdev *sd, u32 val); | 177 | int (*reset)(struct v4l2_subdev *sd, u32 val); |
| 192 | int (*s_gpio)(struct v4l2_subdev *sd, u32 val); | 178 | int (*s_gpio)(struct v4l2_subdev *sd, u32 val); |
| 193 | int (*queryctrl)(struct v4l2_subdev *sd, struct v4l2_queryctrl *qc); | ||
| 194 | int (*g_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl); | ||
| 195 | int (*s_ctrl)(struct v4l2_subdev *sd, struct v4l2_control *ctrl); | ||
| 196 | int (*g_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls); | ||
| 197 | int (*s_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls); | ||
| 198 | int (*try_ext_ctrls)(struct v4l2_subdev *sd, struct v4l2_ext_controls *ctrls); | ||
| 199 | int (*querymenu)(struct v4l2_subdev *sd, struct v4l2_querymenu *qm); | ||
| 200 | long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg); | 179 | long (*ioctl)(struct v4l2_subdev *sd, unsigned int cmd, void *arg); |
| 201 | #ifdef CONFIG_COMPAT | 180 | #ifdef CONFIG_COMPAT |
| 202 | long (*compat_ioctl32)(struct v4l2_subdev *sd, unsigned int cmd, | 181 | long (*compat_ioctl32)(struct v4l2_subdev *sd, unsigned int cmd, |
diff --git a/include/media/videobuf2-core.h b/include/media/videobuf2-core.h index 88e3ab496e8f..bea81c9e3758 100644 --- a/include/media/videobuf2-core.h +++ b/include/media/videobuf2-core.h | |||
| @@ -27,7 +27,6 @@ enum vb2_memory { | |||
| 27 | VB2_MEMORY_DMABUF = 4, | 27 | VB2_MEMORY_DMABUF = 4, |
| 28 | }; | 28 | }; |
| 29 | 29 | ||
| 30 | struct vb2_alloc_ctx; | ||
| 31 | struct vb2_fileio_data; | 30 | struct vb2_fileio_data; |
| 32 | struct vb2_threadio_data; | 31 | struct vb2_threadio_data; |
| 33 | 32 | ||
| @@ -57,7 +56,7 @@ struct vb2_threadio_data; | |||
| 57 | * @put_userptr: inform the allocator that a USERPTR buffer will no longer | 56 | * @put_userptr: inform the allocator that a USERPTR buffer will no longer |
| 58 | * be used. | 57 | * be used. |
| 59 | * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation; | 58 | * @attach_dmabuf: attach a shared struct dma_buf for a hardware operation; |
| 60 | * used for DMABUF memory types; alloc_ctx is the alloc context | 59 | * used for DMABUF memory types; dev is the alloc device |
| 61 | * dbuf is the shared dma_buf; returns NULL on failure; | 60 | * dbuf is the shared dma_buf; returns NULL on failure; |
| 62 | * allocator private per-buffer structure on success; | 61 | * allocator private per-buffer structure on success; |
| 63 | * this needs to be used for further accesses to the buffer. | 62 | * this needs to be used for further accesses to the buffer. |
| @@ -93,13 +92,13 @@ struct vb2_threadio_data; | |||
| 93 | * unmap_dmabuf. | 92 | * unmap_dmabuf. |
| 94 | */ | 93 | */ |
| 95 | struct vb2_mem_ops { | 94 | struct vb2_mem_ops { |
| 96 | void *(*alloc)(void *alloc_ctx, unsigned long size, | 95 | void *(*alloc)(struct device *dev, const struct dma_attrs *attrs, |
| 97 | enum dma_data_direction dma_dir, | 96 | unsigned long size, enum dma_data_direction dma_dir, |
| 98 | gfp_t gfp_flags); | 97 | gfp_t gfp_flags); |
| 99 | void (*put)(void *buf_priv); | 98 | void (*put)(void *buf_priv); |
| 100 | struct dma_buf *(*get_dmabuf)(void *buf_priv, unsigned long flags); | 99 | struct dma_buf *(*get_dmabuf)(void *buf_priv, unsigned long flags); |
| 101 | 100 | ||
| 102 | void *(*get_userptr)(void *alloc_ctx, unsigned long vaddr, | 101 | void *(*get_userptr)(struct device *dev, unsigned long vaddr, |
| 103 | unsigned long size, | 102 | unsigned long size, |
| 104 | enum dma_data_direction dma_dir); | 103 | enum dma_data_direction dma_dir); |
| 105 | void (*put_userptr)(void *buf_priv); | 104 | void (*put_userptr)(void *buf_priv); |
| @@ -107,7 +106,7 @@ struct vb2_mem_ops { | |||
| 107 | void (*prepare)(void *buf_priv); | 106 | void (*prepare)(void *buf_priv); |
| 108 | void (*finish)(void *buf_priv); | 107 | void (*finish)(void *buf_priv); |
| 109 | 108 | ||
| 110 | void *(*attach_dmabuf)(void *alloc_ctx, struct dma_buf *dbuf, | 109 | void *(*attach_dmabuf)(struct device *dev, struct dma_buf *dbuf, |
| 111 | unsigned long size, | 110 | unsigned long size, |
| 112 | enum dma_data_direction dma_dir); | 111 | enum dma_data_direction dma_dir); |
| 113 | void (*detach_dmabuf)(void *buf_priv); | 112 | void (*detach_dmabuf)(void *buf_priv); |
| @@ -282,7 +281,7 @@ struct vb2_buffer { | |||
| 282 | * in *num_buffers, the required number of planes per | 281 | * in *num_buffers, the required number of planes per |
| 283 | * buffer in *num_planes, the size of each plane should be | 282 | * buffer in *num_planes, the size of each plane should be |
| 284 | * set in the sizes[] array and optional per-plane | 283 | * set in the sizes[] array and optional per-plane |
| 285 | * allocator specific context in the alloc_ctxs[] array. | 284 | * allocator specific device in the alloc_devs[] array. |
| 286 | * When called from VIDIOC_REQBUFS, *num_planes == 0, the | 285 | * When called from VIDIOC_REQBUFS, *num_planes == 0, the |
| 287 | * driver has to use the currently configured format to | 286 | * driver has to use the currently configured format to |
| 288 | * determine the plane sizes and *num_buffers is the total | 287 | * determine the plane sizes and *num_buffers is the total |
| @@ -356,7 +355,7 @@ struct vb2_buffer { | |||
| 356 | struct vb2_ops { | 355 | struct vb2_ops { |
| 357 | int (*queue_setup)(struct vb2_queue *q, | 356 | int (*queue_setup)(struct vb2_queue *q, |
| 358 | unsigned int *num_buffers, unsigned int *num_planes, | 357 | unsigned int *num_buffers, unsigned int *num_planes, |
| 359 | unsigned int sizes[], void *alloc_ctxs[]); | 358 | unsigned int sizes[], struct device *alloc_devs[]); |
| 360 | 359 | ||
| 361 | void (*wait_prepare)(struct vb2_queue *q); | 360 | void (*wait_prepare)(struct vb2_queue *q); |
| 362 | void (*wait_finish)(struct vb2_queue *q); | 361 | void (*wait_finish)(struct vb2_queue *q); |
| @@ -401,6 +400,9 @@ struct vb2_buf_ops { | |||
| 401 | * caller. For example, for V4L2, it should match | 400 | * caller. For example, for V4L2, it should match |
| 402 | * the V4L2_BUF_TYPE_* in include/uapi/linux/videodev2.h | 401 | * the V4L2_BUF_TYPE_* in include/uapi/linux/videodev2.h |
| 403 | * @io_modes: supported io methods (see vb2_io_modes enum) | 402 | * @io_modes: supported io methods (see vb2_io_modes enum) |
| 403 | * @dev: device to use for the default allocation context if the driver | ||
| 404 | * doesn't fill in the @alloc_devs array. | ||
| 405 | * @dma_attrs: DMA attributes to use for the DMA. May be NULL. | ||
| 404 | * @fileio_read_once: report EOF after reading the first buffer | 406 | * @fileio_read_once: report EOF after reading the first buffer |
| 405 | * @fileio_write_immediately: queue buffer after each write() call | 407 | * @fileio_write_immediately: queue buffer after each write() call |
| 406 | * @allow_zero_bytesused: allow bytesused == 0 to be passed to the driver | 408 | * @allow_zero_bytesused: allow bytesused == 0 to be passed to the driver |
| @@ -447,7 +449,7 @@ struct vb2_buf_ops { | |||
| 447 | * @done_list: list of buffers ready to be dequeued to userspace | 449 | * @done_list: list of buffers ready to be dequeued to userspace |
| 448 | * @done_lock: lock to protect done_list list | 450 | * @done_lock: lock to protect done_list list |
| 449 | * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued | 451 | * @done_wq: waitqueue for processes waiting for buffers ready to be dequeued |
| 450 | * @alloc_ctx: memory type/allocator-specific contexts for each plane | 452 | * @alloc_devs: memory type/allocator-specific per-plane device |
| 451 | * @streaming: current streaming state | 453 | * @streaming: current streaming state |
| 452 | * @start_streaming_called: start_streaming() was called successfully and we | 454 | * @start_streaming_called: start_streaming() was called successfully and we |
| 453 | * started streaming. | 455 | * started streaming. |
| @@ -467,6 +469,8 @@ struct vb2_buf_ops { | |||
| 467 | struct vb2_queue { | 469 | struct vb2_queue { |
| 468 | unsigned int type; | 470 | unsigned int type; |
| 469 | unsigned int io_modes; | 471 | unsigned int io_modes; |
| 472 | struct device *dev; | ||
| 473 | const struct dma_attrs *dma_attrs; | ||
| 470 | unsigned fileio_read_once:1; | 474 | unsigned fileio_read_once:1; |
| 471 | unsigned fileio_write_immediately:1; | 475 | unsigned fileio_write_immediately:1; |
| 472 | unsigned allow_zero_bytesused:1; | 476 | unsigned allow_zero_bytesused:1; |
| @@ -499,7 +503,7 @@ struct vb2_queue { | |||
| 499 | spinlock_t done_lock; | 503 | spinlock_t done_lock; |
| 500 | wait_queue_head_t done_wq; | 504 | wait_queue_head_t done_wq; |
| 501 | 505 | ||
| 502 | void *alloc_ctx[VB2_MAX_PLANES]; | 506 | struct device *alloc_devs[VB2_MAX_PLANES]; |
| 503 | 507 | ||
| 504 | unsigned int streaming:1; | 508 | unsigned int streaming:1; |
| 505 | unsigned int start_streaming_called:1; | 509 | unsigned int start_streaming_called:1; |
diff --git a/include/media/videobuf2-dma-contig.h b/include/media/videobuf2-dma-contig.h index 2087c9a68be3..df2aabee3401 100644 --- a/include/media/videobuf2-dma-contig.h +++ b/include/media/videobuf2-dma-contig.h | |||
| @@ -26,15 +26,8 @@ vb2_dma_contig_plane_dma_addr(struct vb2_buffer *vb, unsigned int plane_no) | |||
| 26 | return *addr; | 26 | return *addr; |
| 27 | } | 27 | } |
| 28 | 28 | ||
| 29 | void *vb2_dma_contig_init_ctx_attrs(struct device *dev, | 29 | int vb2_dma_contig_set_max_seg_size(struct device *dev, unsigned int size); |
| 30 | struct dma_attrs *attrs); | 30 | void vb2_dma_contig_clear_max_seg_size(struct device *dev); |
| 31 | |||
| 32 | static inline void *vb2_dma_contig_init_ctx(struct device *dev) | ||
| 33 | { | ||
| 34 | return vb2_dma_contig_init_ctx_attrs(dev, NULL); | ||
| 35 | } | ||
| 36 | |||
| 37 | void vb2_dma_contig_cleanup_ctx(void *alloc_ctx); | ||
| 38 | 31 | ||
| 39 | extern const struct vb2_mem_ops vb2_dma_contig_memops; | 32 | extern const struct vb2_mem_ops vb2_dma_contig_memops; |
| 40 | 33 | ||
diff --git a/include/media/videobuf2-dma-sg.h b/include/media/videobuf2-dma-sg.h index 8d1083f83c3d..52afa0e2bb17 100644 --- a/include/media/videobuf2-dma-sg.h +++ b/include/media/videobuf2-dma-sg.h | |||
| @@ -21,9 +21,6 @@ static inline struct sg_table *vb2_dma_sg_plane_desc( | |||
| 21 | return (struct sg_table *)vb2_plane_cookie(vb, plane_no); | 21 | return (struct sg_table *)vb2_plane_cookie(vb, plane_no); |
| 22 | } | 22 | } |
| 23 | 23 | ||
| 24 | void *vb2_dma_sg_init_ctx(struct device *dev); | ||
| 25 | void vb2_dma_sg_cleanup_ctx(void *alloc_ctx); | ||
| 26 | |||
| 27 | extern const struct vb2_mem_ops vb2_dma_sg_memops; | 24 | extern const struct vb2_mem_ops vb2_dma_sg_memops; |
| 28 | 25 | ||
| 29 | #endif | 26 | #endif |
diff --git a/include/media/vsp1.h b/include/media/vsp1.h index 3e654a0455bd..9322d9775fb7 100644 --- a/include/media/vsp1.h +++ b/include/media/vsp1.h | |||
| @@ -14,31 +14,28 @@ | |||
| 14 | #define __MEDIA_VSP1_H__ | 14 | #define __MEDIA_VSP1_H__ |
| 15 | 15 | ||
| 16 | #include <linux/types.h> | 16 | #include <linux/types.h> |
| 17 | #include <linux/videodev2.h> | ||
| 17 | 18 | ||
| 18 | struct device; | 19 | struct device; |
| 19 | struct v4l2_rect; | ||
| 20 | 20 | ||
| 21 | int vsp1_du_init(struct device *dev); | 21 | int vsp1_du_init(struct device *dev); |
| 22 | 22 | ||
| 23 | int vsp1_du_setup_lif(struct device *dev, unsigned int width, | 23 | int vsp1_du_setup_lif(struct device *dev, unsigned int width, |
| 24 | unsigned int height); | 24 | unsigned int height); |
| 25 | 25 | ||
| 26 | struct vsp1_du_atomic_config { | ||
| 27 | u32 pixelformat; | ||
| 28 | unsigned int pitch; | ||
| 29 | dma_addr_t mem[2]; | ||
| 30 | struct v4l2_rect src; | ||
| 31 | struct v4l2_rect dst; | ||
| 32 | unsigned int alpha; | ||
| 33 | unsigned int zpos; | ||
| 34 | }; | ||
| 35 | |||
| 26 | void vsp1_du_atomic_begin(struct device *dev); | 36 | void vsp1_du_atomic_begin(struct device *dev); |
| 27 | int vsp1_du_atomic_update_ext(struct device *dev, unsigned int rpf, | 37 | int vsp1_du_atomic_update(struct device *dev, unsigned int rpf, |
| 28 | u32 pixelformat, unsigned int pitch, | 38 | const struct vsp1_du_atomic_config *cfg); |
| 29 | dma_addr_t mem[2], const struct v4l2_rect *src, | ||
| 30 | const struct v4l2_rect *dst, unsigned int alpha, | ||
| 31 | unsigned int zpos); | ||
| 32 | void vsp1_du_atomic_flush(struct device *dev); | 39 | void vsp1_du_atomic_flush(struct device *dev); |
| 33 | 40 | ||
| 34 | static inline int vsp1_du_atomic_update(struct device *dev, | ||
| 35 | unsigned int rpf_index, u32 pixelformat, | ||
| 36 | unsigned int pitch, dma_addr_t mem[2], | ||
| 37 | const struct v4l2_rect *src, | ||
| 38 | const struct v4l2_rect *dst) | ||
| 39 | { | ||
| 40 | return vsp1_du_atomic_update_ext(dev, rpf_index, pixelformat, pitch, | ||
| 41 | mem, src, dst, 255, 0); | ||
| 42 | } | ||
| 43 | |||
| 44 | #endif /* __MEDIA_VSP1_H__ */ | 41 | #endif /* __MEDIA_VSP1_H__ */ |
diff --git a/include/uapi/linux/media.h b/include/uapi/linux/media.h index df59edee25d1..7acf0f634f70 100644 --- a/include/uapi/linux/media.h +++ b/include/uapi/linux/media.h | |||
| @@ -95,6 +95,16 @@ struct media_device_info { | |||
| 95 | #define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 0x03003) | 95 | #define MEDIA_ENT_F_AUDIO_MIXER (MEDIA_ENT_F_BASE + 0x03003) |
| 96 | 96 | ||
| 97 | /* | 97 | /* |
| 98 | * Processing entities | ||
| 99 | */ | ||
| 100 | #define MEDIA_ENT_F_PROC_VIDEO_COMPOSER (MEDIA_ENT_F_BASE + 0x4001) | ||
| 101 | #define MEDIA_ENT_F_PROC_VIDEO_PIXEL_FORMATTER (MEDIA_ENT_F_BASE + 0x4002) | ||
| 102 | #define MEDIA_ENT_F_PROC_VIDEO_PIXEL_ENC_CONV (MEDIA_ENT_F_BASE + 0x4003) | ||
| 103 | #define MEDIA_ENT_F_PROC_VIDEO_LUT (MEDIA_ENT_F_BASE + 0x4004) | ||
| 104 | #define MEDIA_ENT_F_PROC_VIDEO_SCALER (MEDIA_ENT_F_BASE + 0x4005) | ||
| 105 | #define MEDIA_ENT_F_PROC_VIDEO_STATISTICS (MEDIA_ENT_F_BASE + 0x4006) | ||
| 106 | |||
| 107 | /* | ||
| 98 | * Connectors | 108 | * Connectors |
| 99 | */ | 109 | */ |
| 100 | /* It is a responsibility of the entity drivers to add connectors and links */ | 110 | /* It is a responsibility of the entity drivers to add connectors and links */ |
diff --git a/include/uapi/linux/serio.h b/include/uapi/linux/serio.h index c2ea1698257f..f2447a83ac8d 100644 --- a/include/uapi/linux/serio.h +++ b/include/uapi/linux/serio.h | |||
| @@ -78,5 +78,6 @@ | |||
| 78 | #define SERIO_TSC40 0x3d | 78 | #define SERIO_TSC40 0x3d |
| 79 | #define SERIO_WACOM_IV 0x3e | 79 | #define SERIO_WACOM_IV 0x3e |
| 80 | #define SERIO_EGALAX 0x3f | 80 | #define SERIO_EGALAX 0x3f |
| 81 | #define SERIO_PULSE8_CEC 0x40 | ||
| 81 | 82 | ||
| 82 | #endif /* _UAPI_SERIO_H */ | 83 | #endif /* _UAPI_SERIO_H */ |
diff --git a/include/uapi/linux/videodev2.h b/include/uapi/linux/videodev2.h index 8f951917be74..724f43e69d03 100644 --- a/include/uapi/linux/videodev2.h +++ b/include/uapi/linux/videodev2.h | |||
| @@ -504,22 +504,16 @@ struct v4l2_pix_format { | |||
| 504 | #define V4L2_PIX_FMT_UV8 v4l2_fourcc('U', 'V', '8', ' ') /* 8 UV 4:4 */ | 504 | #define V4L2_PIX_FMT_UV8 v4l2_fourcc('U', 'V', '8', ' ') /* 8 UV 4:4 */ |
| 505 | 505 | ||
| 506 | /* Luminance+Chrominance formats */ | 506 | /* Luminance+Chrominance formats */ |
| 507 | #define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */ | ||
| 508 | #define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */ | ||
| 509 | #define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */ | 507 | #define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V') /* 16 YUV 4:2:2 */ |
| 510 | #define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */ | 508 | #define V4L2_PIX_FMT_YYUV v4l2_fourcc('Y', 'Y', 'U', 'V') /* 16 YUV 4:2:2 */ |
| 511 | #define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */ | 509 | #define V4L2_PIX_FMT_YVYU v4l2_fourcc('Y', 'V', 'Y', 'U') /* 16 YVU 4:2:2 */ |
| 512 | #define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */ | 510 | #define V4L2_PIX_FMT_UYVY v4l2_fourcc('U', 'Y', 'V', 'Y') /* 16 YUV 4:2:2 */ |
| 513 | #define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */ | 511 | #define V4L2_PIX_FMT_VYUY v4l2_fourcc('V', 'Y', 'U', 'Y') /* 16 YUV 4:2:2 */ |
| 514 | #define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */ | ||
| 515 | #define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 16 YVU411 planar */ | ||
| 516 | #define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ | 512 | #define V4L2_PIX_FMT_Y41P v4l2_fourcc('Y', '4', '1', 'P') /* 12 YUV 4:1:1 */ |
| 517 | #define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */ | 513 | #define V4L2_PIX_FMT_YUV444 v4l2_fourcc('Y', '4', '4', '4') /* 16 xxxxyyyy uuuuvvvv */ |
| 518 | #define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */ | 514 | #define V4L2_PIX_FMT_YUV555 v4l2_fourcc('Y', 'U', 'V', 'O') /* 16 YUV-5-5-5 */ |
| 519 | #define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */ | 515 | #define V4L2_PIX_FMT_YUV565 v4l2_fourcc('Y', 'U', 'V', 'P') /* 16 YUV-5-6-5 */ |
| 520 | #define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */ | 516 | #define V4L2_PIX_FMT_YUV32 v4l2_fourcc('Y', 'U', 'V', '4') /* 32 YUV-8-8-8-8 */ |
| 521 | #define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */ | ||
| 522 | #define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */ | ||
| 523 | #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */ | 517 | #define V4L2_PIX_FMT_HI240 v4l2_fourcc('H', 'I', '2', '4') /* 8 8-bit color */ |
| 524 | #define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */ | 518 | #define V4L2_PIX_FMT_HM12 v4l2_fourcc('H', 'M', '1', '2') /* 8 YUV 4:2:0 16x16 macroblocks */ |
| 525 | #define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */ | 519 | #define V4L2_PIX_FMT_M420 v4l2_fourcc('M', '4', '2', '0') /* 12 YUV 4:2:0 2 lines y, 1 line uv interleaved */ |
| @@ -540,6 +534,14 @@ struct v4l2_pix_format { | |||
| 540 | #define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */ | 534 | #define V4L2_PIX_FMT_NV12MT v4l2_fourcc('T', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 64x32 macroblocks */ |
| 541 | #define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 macroblocks */ | 535 | #define V4L2_PIX_FMT_NV12MT_16X16 v4l2_fourcc('V', 'M', '1', '2') /* 12 Y/CbCr 4:2:0 16x16 macroblocks */ |
| 542 | 536 | ||
| 537 | /* three planes - Y Cb, Cr */ | ||
| 538 | #define V4L2_PIX_FMT_YUV410 v4l2_fourcc('Y', 'U', 'V', '9') /* 9 YUV 4:1:0 */ | ||
| 539 | #define V4L2_PIX_FMT_YVU410 v4l2_fourcc('Y', 'V', 'U', '9') /* 9 YVU 4:1:0 */ | ||
| 540 | #define V4L2_PIX_FMT_YUV411P v4l2_fourcc('4', '1', '1', 'P') /* 12 YVU411 planar */ | ||
| 541 | #define V4L2_PIX_FMT_YUV420 v4l2_fourcc('Y', 'U', '1', '2') /* 12 YUV 4:2:0 */ | ||
| 542 | #define V4L2_PIX_FMT_YVU420 v4l2_fourcc('Y', 'V', '1', '2') /* 12 YVU 4:2:0 */ | ||
| 543 | #define V4L2_PIX_FMT_YUV422P v4l2_fourcc('4', '2', '2', 'P') /* 16 YVU422 planar */ | ||
| 544 | |||
| 543 | /* three non contiguous planes - Y, Cb, Cr */ | 545 | /* three non contiguous planes - Y, Cb, Cr */ |
| 544 | #define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12 YUV420 planar */ | 546 | #define V4L2_PIX_FMT_YUV420M v4l2_fourcc('Y', 'M', '1', '2') /* 12 YUV420 planar */ |
| 545 | #define V4L2_PIX_FMT_YVU420M v4l2_fourcc('Y', 'M', '2', '1') /* 12 YVU420 planar */ | 547 | #define V4L2_PIX_FMT_YVU420M v4l2_fourcc('Y', 'M', '2', '1') /* 12 YVU420 planar */ |
diff --git a/include/uapi/linux/vsp1.h b/include/uapi/linux/vsp1.h deleted file mode 100644 index 9a823696d816..000000000000 --- a/include/uapi/linux/vsp1.h +++ /dev/null | |||
| @@ -1,34 +0,0 @@ | |||
| 1 | /* | ||
| 2 | * vsp1.h | ||
| 3 | * | ||
| 4 | * Renesas R-Car VSP1 - User-space API | ||
| 5 | * | ||
| 6 | * Copyright (C) 2013 Renesas Corporation | ||
| 7 | * | ||
| 8 | * Contacts: Laurent Pinchart <laurent.pinchart@ideasonboard.com> | ||
| 9 | * | ||
| 10 | * This program is free software; you can redistribute it and/or modify | ||
| 11 | * it under the terms of the GNU General Public License version 2 as | ||
| 12 | * published by the Free Software Foundation. | ||
| 13 | */ | ||
| 14 | |||
| 15 | #ifndef __VSP1_USER_H__ | ||
| 16 | #define __VSP1_USER_H__ | ||
| 17 | |||
| 18 | #include <linux/types.h> | ||
| 19 | #include <linux/videodev2.h> | ||
| 20 | |||
| 21 | /* | ||
| 22 | * Private IOCTLs | ||
| 23 | * | ||
| 24 | * VIDIOC_VSP1_LUT_CONFIG - Configure the lookup table | ||
| 25 | */ | ||
| 26 | |||
| 27 | #define VIDIOC_VSP1_LUT_CONFIG \ | ||
| 28 | _IOWR('V', BASE_VIDIOC_PRIVATE + 1, struct vsp1_lut_config) | ||
| 29 | |||
| 30 | struct vsp1_lut_config { | ||
| 31 | __u32 lut[256]; | ||
| 32 | }; | ||
| 33 | |||
| 34 | #endif /* __VSP1_USER_H__ */ | ||
