1 // SPDX-License-Identifier: GPL-2.0-or-later 2 /* Keytable for the CEC remote control 3 * 4 * Copyright (c) 2015 by Kamil Debski 5 */ 6 7 #include <media/rc-map.h> 8 #include <linux/module.h> 9 10 /* 11 * CEC Spec "High-Definition Multimedia Interface Specification" can be obtained 12 * here: http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf 13 * The list of control codes is listed in Table 27: User Control Codes p. 95 14 */ 15 16 static struct rc_map_table cec[] = { 17 { 0x00, KEY_OK }, 18 { 0x01, KEY_UP }, 19 { 0x02, KEY_DOWN }, 20 { 0x03, KEY_LEFT }, 21 { 0x04, KEY_RIGHT }, 22 { 0x05, KEY_RIGHT_UP }, 23 { 0x06, KEY_RIGHT_DOWN }, 24 { 0x07, KEY_LEFT_UP }, 25 { 0x08, KEY_LEFT_DOWN }, 26 { 0x09, KEY_ROOT_MENU }, /* CEC Spec: Device Root Menu - see Note 2 */ 27 /* 28 * Note 2: This is the initial display that a device shows. It is 29 * device-dependent and can be, for example, a contents menu, setup 30 * menu, favorite menu or other menu. The actual menu displayed 31 * may also depend on the device's current state. 32 */ 33 { 0x0a, KEY_SETUP }, 34 { 0x0b, KEY_MENU }, /* CEC Spec: Contents Menu */ 35 { 0x0c, KEY_FAVORITES }, /* CEC Spec: Favorite Menu */ 36 { 0x0d, KEY_EXIT }, 37 /* 0x0e-0x0f: Reserved */ 38 { 0x10, KEY_MEDIA_TOP_MENU }, 39 { 0x11, KEY_CONTEXT_MENU }, 40 /* 0x12-0x1c: Reserved */ 41 { 0x1d, KEY_DIGITS }, /* CEC Spec: select/toggle a Number Entry Mode */ 42 { 0x1e, KEY_NUMERIC_11 }, 43 { 0x1f, KEY_NUMERIC_12 }, 44 /* 0x20-0x29: Keys 0 to 9 */ 45 { 0x20, KEY_NUMERIC_0 }, 46 { 0x21, KEY_NUMERIC_1 }, 47 { 0x22, KEY_NUMERIC_2 }, 48 { 0x23, KEY_NUMERIC_3 }, 49 { 0x24, KEY_NUMERIC_4 }, 50 { 0x25, KEY_NUMERIC_5 }, 51 { 0x26, KEY_NUMERIC_6 }, 52 { 0x27, KEY_NUMERIC_7 }, 53 { 0x28, KEY_NUMERIC_8 }, 54 { 0x29, KEY_NUMERIC_9 }, 55 { 0x2a, KEY_DOT }, 56 { 0x2b, KEY_ENTER }, 57 { 0x2c, KEY_CLEAR }, 58 /* 0x2d-0x2e: Reserved */ 59 { 0x2f, KEY_NEXT_FAVORITE }, /* CEC Spec: Next Favorite */ 60 { 0x30, KEY_CHANNELUP }, 61 { 0x31, KEY_CHANNELDOWN }, 62 { 0x32, KEY_PREVIOUS }, /* CEC Spec: Previous Channel */ 63 { 0x33, KEY_SOUND }, /* CEC Spec: Sound Select */ 64 { 0x34, KEY_VIDEO }, /* 0x34: CEC Spec: Input Select */ 65 { 0x35, KEY_INFO }, /* CEC Spec: Display Information */ 66 { 0x36, KEY_HELP }, 67 { 0x37, KEY_PAGEUP }, 68 { 0x38, KEY_PAGEDOWN }, 69 /* 0x39-0x3f: Reserved */ 70 { 0x40, KEY_POWER }, 71 { 0x41, KEY_VOLUMEUP }, 72 { 0x42, KEY_VOLUMEDOWN }, 73 { 0x43, KEY_MUTE }, 74 { 0x44, KEY_PLAYCD }, 75 { 0x45, KEY_STOPCD }, 76 { 0x46, KEY_PAUSECD }, 77 { 0x47, KEY_RECORD }, 78 { 0x48, KEY_REWIND }, 79 { 0x49, KEY_FASTFORWARD }, 80 { 0x4a, KEY_EJECTCD }, /* CEC Spec: Eject */ 81 { 0x4b, KEY_FORWARD }, 82 { 0x4c, KEY_BACK }, 83 { 0x4d, KEY_STOP_RECORD }, /* CEC Spec: Stop-Record */ 84 { 0x4e, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record */ 85 /* 0x4f: Reserved */ 86 { 0x50, KEY_ANGLE }, 87 { 0x51, KEY_TV2 }, 88 { 0x52, KEY_VOD }, /* CEC Spec: Video on Demand */ 89 { 0x53, KEY_EPG }, 90 { 0x54, KEY_TIME }, /* CEC Spec: Timer */ 91 { 0x55, KEY_CONFIG }, 92 /* 93 * The following codes are hard to implement at this moment, as they 94 * carry an additional additional argument. Most likely changes to RC 95 * framework are necessary. 96 * For now they are interpreted by the CEC framework as non keycodes 97 * and are passed as messages enabling user application to parse them. 98 */ 99 /* 0x56: CEC Spec: Select Broadcast Type */ 100 /* 0x57: CEC Spec: Select Sound presentation */ 101 { 0x58, KEY_AUDIO_DESC }, /* CEC 2.0 and up */ 102 { 0x59, KEY_WWW }, /* CEC 2.0 and up */ 103 { 0x5a, KEY_3D_MODE }, /* CEC 2.0 and up */ 104 /* 0x5b-0x5f: Reserved */ 105 { 0x60, KEY_PLAYCD }, /* CEC Spec: Play Function */ 106 { 0x6005, KEY_FASTFORWARD }, 107 { 0x6006, KEY_FASTFORWARD }, 108 { 0x6007, KEY_FASTFORWARD }, 109 { 0x6015, KEY_SLOW }, 110 { 0x6016, KEY_SLOW }, 111 { 0x6017, KEY_SLOW }, 112 { 0x6009, KEY_FASTREVERSE }, 113 { 0x600a, KEY_FASTREVERSE }, 114 { 0x600b, KEY_FASTREVERSE }, 115 { 0x6019, KEY_SLOWREVERSE }, 116 { 0x601a, KEY_SLOWREVERSE }, 117 { 0x601b, KEY_SLOWREVERSE }, 118 { 0x6020, KEY_REWIND }, 119 { 0x6024, KEY_PLAYCD }, 120 { 0x6025, KEY_PAUSECD }, 121 { 0x61, KEY_PLAYPAUSE }, /* CEC Spec: Pause-Play Function */ 122 { 0x62, KEY_RECORD }, /* Spec: Record Function */ 123 { 0x63, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record Function */ 124 { 0x64, KEY_STOPCD }, /* CEC Spec: Stop Function */ 125 { 0x65, KEY_MUTE }, /* CEC Spec: Mute Function */ 126 { 0x66, KEY_UNMUTE }, /* CEC Spec: Restore the volume */ 127 /* 128 * The following codes are hard to implement at this moment, as they 129 * carry an additional additional argument. Most likely changes to RC 130 * framework are necessary. 131 * For now they are interpreted by the CEC framework as non keycodes 132 * and are passed as messages enabling user application to parse them. 133 */ 134 /* 0x67: CEC Spec: Tune Function */ 135 /* 0x68: CEC Spec: Seleect Media Function */ 136 /* 0x69: CEC Spec: Select A/V Input Function */ 137 /* 0x6a: CEC Spec: Select Audio Input Function */ 138 { 0x6b, KEY_POWER }, /* CEC Spec: Power Toggle Function */ 139 { 0x6c, KEY_SLEEP }, /* CEC Spec: Power Off Function */ 140 { 0x6d, KEY_WAKEUP }, /* CEC Spec: Power On Function */ 141 /* 0x6e-0x70: Reserved */ 142 { 0x71, KEY_BLUE }, /* CEC Spec: F1 (Blue) */ 143 { 0x72, KEY_RED }, /* CEC Spec: F2 (Red) */ 144 { 0x73, KEY_GREEN }, /* CEC Spec: F3 (Green) */ 145 { 0x74, KEY_YELLOW }, /* CEC Spec: F4 (Yellow) */ 146 { 0x75, KEY_F5 }, 147 { 0x76, KEY_DATA }, /* CEC Spec: Data - see Note 3 */ 148 /* 149 * Note 3: This is used, for example, to enter or leave a digital TV 150 * data broadcast application. 151 */ 152 /* 0x77-0xff: Reserved */ 153 }; 154 155 static struct rc_map_list cec_map = { 156 .map = { 157 .scan = cec, 158 .size = ARRAY_SIZE(cec), 159 .rc_proto = RC_PROTO_CEC, 160 .name = RC_MAP_CEC, 161 } 162 }; 163 164 static int __init init_rc_map_cec(void) 165 { 166 return rc_map_register(&cec_map); 167 } 168 169 static void __exit exit_rc_map_cec(void) 170 { 171 rc_map_unregister(&cec_map); 172 } 173 174 module_init(init_rc_map_cec); 175 module_exit(exit_rc_map_cec); 176 177 MODULE_LICENSE("GPL"); 178 MODULE_AUTHOR("Kamil Debski"); 179