0001 .. SPDX-License-Identifier: GPL-2.0 OR GFDL-1.1-no-invariants-or-later
0002
0003 .. _Remote_controllers_Protocols:
0004
0005 *****************************************
0006 Remote Controller Protocols and Scancodes
0007 *****************************************
0008
0009 IR is encoded as a series of pulses and spaces, using a protocol. These
0010 protocols can encode e.g. an address (which device should respond) and a
0011 command: what it should do. The values for these are not always consistent
0012 across different devices for a given protocol.
0013
0014 Therefore out the output of the IR decoder is a scancode; a single u32
0015 value. Using keymap tables this can be mapped to linux key codes.
0016
0017 Other things can be encoded too. Some IR protocols encode a toggle bit; this
0018 is to distinguish whether the same button is being held down, or has been
0019 released and pressed again. If has been released and pressed again, the
0020 toggle bit will invert from one IR message to the next.
0021
0022 Some remotes have a pointer-type device which can used to control the
0023 mouse; some air conditioning systems can have their target temperature
0024 target set in IR.
0025
0026 The following are the protocols the kernel knows about and also lists
0027 how scancodes are encoded for each protocol.
0028
0029 rc-5 (RC_PROTO_RC5)
0030 -------------------
0031
0032 This IR protocol uses manchester encoding to encode 14 bits. There is a
0033 detailed description here https://www.sbprojects.net/knowledge/ir/rc5.php.
0034
0035 The scancode encoding is *not* consistent with the lirc daemon (lircd) rc5
0036 protocol, or the manchester BPF decoder.
0037
0038 .. flat-table:: rc5 bits scancode mapping
0039 :widths: 1 1 2
0040
0041 * - rc-5 bit
0042
0043 - scancode bit
0044
0045 - description
0046
0047 * - 1
0048
0049 - none
0050
0051 - Start bit, always set
0052
0053 * - 1
0054
0055 - 6 (inverted)
0056
0057 - 2nd start bit in rc5, re-used as 6th command bit
0058
0059 * - 1
0060
0061 - none
0062
0063 - Toggle bit
0064
0065 * - 5
0066
0067 - 8 to 13
0068
0069 - Address
0070
0071 * - 6
0072
0073 - 0 to 5
0074
0075 - Command
0076
0077 There is a variant of rc5 called either rc5x or extended rc5
0078 where there the second stop bit is the 6th commmand bit, but inverted.
0079 This is done so it the scancodes and encoding is compatible with existing
0080 schemes. This bit is stored in bit 6 of the scancode, inverted. This is
0081 done to keep it compatible with plain rc-5 where there are two start bits.
0082
0083 rc-5-sz (RC_PROTO_RC5_SZ)
0084 -------------------------
0085 This is much like rc-5 but one bit longer. The scancode is encoded
0086 differently.
0087
0088 .. flat-table:: rc-5-sz bits scancode mapping
0089 :widths: 1 1 2
0090
0091 * - rc-5-sz bits
0092
0093 - scancode bit
0094
0095 - description
0096
0097 * - 1
0098
0099 - none
0100
0101 - Start bit, always set
0102
0103 * - 1
0104
0105 - 13
0106
0107 - Address bit
0108
0109 * - 1
0110
0111 - none
0112
0113 - Toggle bit
0114
0115 * - 6
0116
0117 - 6 to 11
0118
0119 - Address
0120
0121 * - 6
0122
0123 - 0 to 5
0124
0125 - Command
0126
0127 rc-5x-20 (RC_PROTO_RC5X_20)
0128 ---------------------------
0129
0130 This rc-5 extended to encoded 20 bits. The is a 3555 microseconds space
0131 after the 8th bit.
0132
0133 .. flat-table:: rc-5x-20 bits scancode mapping
0134 :widths: 1 1 2
0135
0136 * - rc-5-sz bits
0137
0138 - scancode bit
0139
0140 - description
0141
0142 * - 1
0143
0144 - none
0145
0146 - Start bit, always set
0147
0148 * - 1
0149
0150 - 14
0151
0152 - Address bit
0153
0154 * - 1
0155
0156 - none
0157
0158 - Toggle bit
0159
0160 * - 5
0161
0162 - 16 to 20
0163
0164 - Address
0165
0166 * - 6
0167
0168 - 8 to 13
0169
0170 - Address
0171
0172 * - 6
0173
0174 - 0 to 5
0175
0176 - Command
0177
0178
0179 jvc (RC_PROTO_JVC)
0180 ------------------
0181
0182 The jvc protocol is much like nec, without the inverted values. It is
0183 described here https://www.sbprojects.net/knowledge/ir/jvc.php.
0184
0185 The scancode is a 16 bits value, where the address is the lower 8 bits
0186 and the command the higher 8 bits; this is reversed from IR order.
0187
0188 sony-12 (RC_PROTO_SONY12)
0189 -------------------------
0190
0191 The sony protocol is a pulse-width encoding. There are three variants,
0192 which just differ in number of bits and scancode encoding.
0193
0194 .. flat-table:: sony-12 bits scancode mapping
0195 :widths: 1 1 2
0196
0197 * - sony-12 bits
0198
0199 - scancode bit
0200
0201 - description
0202
0203 * - 5
0204
0205 - 16 to 20
0206
0207 - device
0208
0209 * - 7
0210
0211 - 0 to 6
0212
0213 - function
0214
0215 sony-15 (RC_PROTO_SONY15)
0216 -------------------------
0217
0218 The sony protocol is a pulse-width encoding. There are three variants,
0219 which just differ in number of bits and scancode encoding.
0220
0221 .. flat-table:: sony-12 bits scancode mapping
0222 :widths: 1 1 2
0223
0224 * - sony-12 bits
0225
0226 - scancode bit
0227
0228 - description
0229
0230 * - 8
0231
0232 - 16 to 23
0233
0234 - device
0235
0236 * - 7
0237
0238 - 0 to 6
0239
0240 - function
0241
0242 sony-20 (RC_PROTO_SONY20)
0243 -------------------------
0244
0245 The sony protocol is a pulse-width encoding. There are three variants,
0246 which just differ in number of bits and scancode encoding.
0247
0248 .. flat-table:: sony-20 bits scancode mapping
0249 :widths: 1 1 2
0250
0251 * - sony-20 bits
0252
0253 - scancode bit
0254
0255 - description
0256
0257 * - 5
0258
0259 - 16 to 20
0260
0261 - device
0262
0263 * - 7
0264
0265 - 0 to 7
0266
0267 - device
0268
0269 * - 8
0270
0271 - 8 to 15
0272
0273 - extended bits
0274
0275 nec (RC_PROTO_NEC)
0276 ------------------
0277
0278 The nec protocol encodes an 8 bit address and an 8 bit command. It is
0279 described here https://www.sbprojects.net/knowledge/ir/nec.php. Note
0280 that the protocol sends least significant bit first.
0281
0282 As a check, the nec protocol sends the address and command twice; the
0283 second time it is inverted. This is done for verification.
0284
0285 A plain nec IR message has 16 bits; the high 8 bits are the address
0286 and the low 8 bits are the command.
0287
0288 nec-x (RC_PROTO_NECX)
0289 ---------------------
0290
0291 Extended nec has a 16 bit address and a 8 bit command. This is encoded
0292 as a 24 bit value as you would expect, with the lower 8 bits the command
0293 and the upper 16 bits the address.
0294
0295 nec-32 (RC_PROTO_NEC32)
0296 -----------------------
0297
0298 nec-32 does not send an inverted address or an inverted command; the
0299 entire message, all 32 bits, are used.
0300
0301 For this to be decoded correctly, the second 8 bits must not be the
0302 inverted value of the first, and also the last 8 bits must not be the
0303 inverted value of the third 8 bit value.
0304
0305 The scancode has a somewhat unusual encoding.
0306
0307 .. flat-table:: nec-32 bits scancode mapping
0308
0309 * - nec-32 bits
0310
0311 - scancode bit
0312
0313 * - First 8 bits
0314
0315 - 16 to 23
0316
0317 * - Second 8 bits
0318
0319 - 24 to 31
0320
0321 * - Third 8 bits
0322
0323 - 0 to 7
0324
0325 * - Fourth 8 bits
0326
0327 - 8 to 15
0328
0329 sanyo (RC_PROTO_SANYO)
0330 ----------------------
0331
0332 The sanyo protocol is like the nec protocol, but with 13 bits address
0333 rather than 8 bits. Both the address and the command are followed by
0334 their inverted versions, but these are not present in the scancodes.
0335
0336 Bis 8 to 20 of the scancode is the 13 bits address, and the lower 8
0337 bits are the command.
0338
0339 mcir2-kbd (RC_PROTO_MCIR2_KBD)
0340 ------------------------------
0341
0342 This protocol is generated by the Microsoft MCE keyboard for keyboard
0343 events. Refer to the ir-mce_kbd-decoder.c to see how it is encoded.
0344
0345 mcir2-mse (RC_PROTO_MCIR2_MSE)
0346 ------------------------------
0347
0348 This protocol is generated by the Microsoft MCE keyboard for pointer
0349 events. Refer to the ir-mce_kbd-decoder.c to see how it is encoded.
0350
0351 rc-6-0 (RC_PROTO_RC6_0)
0352 -----------------------
0353
0354 This is the rc-6 in mode 0. rc-6 is described here
0355 https://www.sbprojects.net/knowledge/ir/rc6.php.
0356 The scancode is the exact 16 bits as in the protocol. There is also a
0357 toggle bit.
0358
0359 rc-6-6a-20 (RC_PROTO_RC6_6A_20)
0360 -------------------------------
0361
0362 This is the rc-6 in mode 6a, 20 bits. rc-6 is described here
0363 https://www.sbprojects.net/knowledge/ir/rc6.php.
0364 The scancode is the exact 20 bits
0365 as in the protocol. There is also a toggle bit.
0366
0367 rc-6-6a-24 (RC_PROTO_RC6_6A_24)
0368 -------------------------------
0369
0370 This is the rc-6 in mode 6a, 24 bits. rc-6 is described here
0371 https://www.sbprojects.net/knowledge/ir/rc6.php.
0372 The scancode is the exact 24 bits
0373 as in the protocol. There is also a toggle bit.
0374
0375 rc-6-6a-32 (RC_PROTO_RC6_6A_32)
0376 -------------------------------
0377
0378 This is the rc-6 in mode 6a, 32 bits. rc-6 is described here
0379 https://www.sbprojects.net/knowledge/ir/rc6.php.
0380 The upper 16 bits are the vendor,
0381 and the lower 16 bits are the vendor-specific bits. This protocol is
0382 for the non-Microsoft MCE variant (vendor != 0x800f).
0383
0384
0385 rc-6-mce (RC_PROTO_RC6_MCE)
0386 ---------------------------
0387
0388 This is the rc-6 in mode 6a, 32 bits. The upper 16 bits are the vendor,
0389 and the lower 16 bits are the vendor-specific bits. This protocol is
0390 for the Microsoft MCE variant (vendor = 0x800f). The toggle bit in the
0391 protocol itself is ignored, and the 16th bit should be takes as the toggle
0392 bit.
0393
0394 sharp (RC_PROTO_SHARP)
0395 ----------------------
0396
0397 This is a protocol used by Sharp VCRs, is described here
0398 https://www.sbprojects.net/knowledge/ir/sharp.php. There is a very long
0399 (40ms) space between the normal and inverted values, and some IR receivers
0400 cannot decode this.
0401
0402 There is a 5 bit address and a 8 bit command. In the scancode the address is
0403 in bits 8 to 12, and the command in bits 0 to 7.
0404
0405 xmp (RC_PROTO_XMP)
0406 ------------------
0407
0408 This protocol has several versions and only version 1 is supported. Refer
0409 to the decoder (ir-xmp-decoder.c) to see how it is encoded.
0410
0411
0412 cec (RC_PROTO_CEC)
0413 ------------------
0414
0415 This is not an IR protocol, this is a protocol over CEC. The CEC
0416 infrastructure uses rc-core for handling CEC commands, so that they
0417 can easily be remapped.
0418
0419 imon (RC_PROTO_IMON)
0420 --------------------
0421
0422 This protocol is used by Antec Veris/SoundGraph iMON remotes.
0423
0424 The protocol
0425 describes both button presses and pointer movements. The protocol encodes
0426 31 bits, and the scancode is simply the 31 bits with the top bit always 0.
0427
0428 rc-mm-12 (RC_PROTO_RCMM12)
0429 --------------------------
0430
0431 The rc-mm protocol is described here
0432 https://www.sbprojects.net/knowledge/ir/rcmm.php. The scancode is simply
0433 the 12 bits.
0434
0435 rc-mm-24 (RC_PROTO_RCMM24)
0436 --------------------------
0437
0438 The rc-mm protocol is described here
0439 https://www.sbprojects.net/knowledge/ir/rcmm.php. The scancode is simply
0440 the 24 bits.
0441
0442 rc-mm-32 (RC_PROTO_RCMM32)
0443 --------------------------
0444
0445 The rc-mm protocol is described here
0446 https://www.sbprojects.net/knowledge/ir/rcmm.php. The scancode is simply
0447 the 32 bits.
0448
0449 xbox-dvd (RC_PROTO_XBOX_DVD)
0450 ----------------------------
0451
0452 This protocol is used by XBox DVD Remote, which was made for the original
0453 XBox. There is no in-kernel decoder or encoder for this protocol. The usb
0454 device decodes the protocol. There is a BPF decoder available in v4l-utils.