xref: /linux/drivers/media/rc/keymaps/rc-cec.c (revision 2874c5fd284268364ece81a7bd936f3c8168e567)
1*2874c5fdSThomas Gleixner // SPDX-License-Identifier: GPL-2.0-or-later
27b2cd0d8SKamil Debski /* Keytable for the CEC remote control
37b2cd0d8SKamil Debski  *
47b2cd0d8SKamil Debski  * Copyright (c) 2015 by Kamil Debski
57b2cd0d8SKamil Debski  */
67b2cd0d8SKamil Debski 
77b2cd0d8SKamil Debski #include <media/rc-map.h>
87b2cd0d8SKamil Debski #include <linux/module.h>
97b2cd0d8SKamil Debski 
107b2cd0d8SKamil Debski /*
117b2cd0d8SKamil Debski  * CEC Spec "High-Definition Multimedia Interface Specification" can be obtained
127b2cd0d8SKamil Debski  * here: http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf
137b2cd0d8SKamil Debski  * The list of control codes is listed in Table 27: User Control Codes p. 95
147b2cd0d8SKamil Debski  */
157b2cd0d8SKamil Debski 
167b2cd0d8SKamil Debski static struct rc_map_table cec[] = {
177b2cd0d8SKamil Debski 	{ 0x00, KEY_OK },
187b2cd0d8SKamil Debski 	{ 0x01, KEY_UP },
197b2cd0d8SKamil Debski 	{ 0x02, KEY_DOWN },
207b2cd0d8SKamil Debski 	{ 0x03, KEY_LEFT },
217b2cd0d8SKamil Debski 	{ 0x04, KEY_RIGHT },
227b2cd0d8SKamil Debski 	{ 0x05, KEY_RIGHT_UP },
237b2cd0d8SKamil Debski 	{ 0x06, KEY_RIGHT_DOWN },
247b2cd0d8SKamil Debski 	{ 0x07, KEY_LEFT_UP },
257b2cd0d8SKamil Debski 	{ 0x08, KEY_LEFT_DOWN },
267b2cd0d8SKamil Debski 	{ 0x09, KEY_ROOT_MENU }, /* CEC Spec: Device Root Menu - see Note 2 */
277b2cd0d8SKamil Debski 	/*
287b2cd0d8SKamil Debski 	 * Note 2: This is the initial display that a device shows. It is
297b2cd0d8SKamil Debski 	 * device-dependent and can be, for example, a contents menu, setup
307b2cd0d8SKamil Debski 	 * menu, favorite menu or other menu. The actual menu displayed
317b2cd0d8SKamil Debski 	 * may also depend on the device's current state.
327b2cd0d8SKamil Debski 	 */
337b2cd0d8SKamil Debski 	{ 0x0a, KEY_SETUP },
347b2cd0d8SKamil Debski 	{ 0x0b, KEY_MENU }, /* CEC Spec: Contents Menu */
357b2cd0d8SKamil Debski 	{ 0x0c, KEY_FAVORITES }, /* CEC Spec: Favorite Menu */
367b2cd0d8SKamil Debski 	{ 0x0d, KEY_EXIT },
377b2cd0d8SKamil Debski 	/* 0x0e-0x0f: Reserved */
387b2cd0d8SKamil Debski 	{ 0x10, KEY_MEDIA_TOP_MENU },
397b2cd0d8SKamil Debski 	{ 0x11, KEY_CONTEXT_MENU },
407b2cd0d8SKamil Debski 	/* 0x12-0x1c: Reserved */
417b2cd0d8SKamil Debski 	{ 0x1d, KEY_DIGITS }, /* CEC Spec: select/toggle a Number Entry Mode */
427b2cd0d8SKamil Debski 	{ 0x1e, KEY_NUMERIC_11 },
437b2cd0d8SKamil Debski 	{ 0x1f, KEY_NUMERIC_12 },
447b2cd0d8SKamil Debski 	/* 0x20-0x29: Keys 0 to 9 */
457b2cd0d8SKamil Debski 	{ 0x20, KEY_NUMERIC_0 },
467b2cd0d8SKamil Debski 	{ 0x21, KEY_NUMERIC_1 },
477b2cd0d8SKamil Debski 	{ 0x22, KEY_NUMERIC_2 },
487b2cd0d8SKamil Debski 	{ 0x23, KEY_NUMERIC_3 },
497b2cd0d8SKamil Debski 	{ 0x24, KEY_NUMERIC_4 },
507b2cd0d8SKamil Debski 	{ 0x25, KEY_NUMERIC_5 },
517b2cd0d8SKamil Debski 	{ 0x26, KEY_NUMERIC_6 },
527b2cd0d8SKamil Debski 	{ 0x27, KEY_NUMERIC_7 },
537b2cd0d8SKamil Debski 	{ 0x28, KEY_NUMERIC_8 },
547b2cd0d8SKamil Debski 	{ 0x29, KEY_NUMERIC_9 },
557b2cd0d8SKamil Debski 	{ 0x2a, KEY_DOT },
567b2cd0d8SKamil Debski 	{ 0x2b, KEY_ENTER },
577b2cd0d8SKamil Debski 	{ 0x2c, KEY_CLEAR },
587b2cd0d8SKamil Debski 	/* 0x2d-0x2e: Reserved */
597b2cd0d8SKamil Debski 	{ 0x2f, KEY_NEXT_FAVORITE }, /* CEC Spec: Next Favorite */
607b2cd0d8SKamil Debski 	{ 0x30, KEY_CHANNELUP },
617b2cd0d8SKamil Debski 	{ 0x31, KEY_CHANNELDOWN },
627b2cd0d8SKamil Debski 	{ 0x32, KEY_PREVIOUS }, /* CEC Spec: Previous Channel */
637b2cd0d8SKamil Debski 	{ 0x33, KEY_SOUND }, /* CEC Spec: Sound Select */
647b2cd0d8SKamil Debski 	{ 0x34, KEY_VIDEO }, /* 0x34: CEC Spec: Input Select */
657b2cd0d8SKamil Debski 	{ 0x35, KEY_INFO }, /* CEC Spec: Display Information */
667b2cd0d8SKamil Debski 	{ 0x36, KEY_HELP },
677b2cd0d8SKamil Debski 	{ 0x37, KEY_PAGEUP },
687b2cd0d8SKamil Debski 	{ 0x38, KEY_PAGEDOWN },
697b2cd0d8SKamil Debski 	/* 0x39-0x3f: Reserved */
707b2cd0d8SKamil Debski 	{ 0x40, KEY_POWER },
717b2cd0d8SKamil Debski 	{ 0x41, KEY_VOLUMEUP },
727b2cd0d8SKamil Debski 	{ 0x42, KEY_VOLUMEDOWN },
737b2cd0d8SKamil Debski 	{ 0x43, KEY_MUTE },
747b2cd0d8SKamil Debski 	{ 0x44, KEY_PLAYCD },
757b2cd0d8SKamil Debski 	{ 0x45, KEY_STOPCD },
767b2cd0d8SKamil Debski 	{ 0x46, KEY_PAUSECD },
777b2cd0d8SKamil Debski 	{ 0x47, KEY_RECORD },
787b2cd0d8SKamil Debski 	{ 0x48, KEY_REWIND },
797b2cd0d8SKamil Debski 	{ 0x49, KEY_FASTFORWARD },
807b2cd0d8SKamil Debski 	{ 0x4a, KEY_EJECTCD }, /* CEC Spec: Eject */
817b2cd0d8SKamil Debski 	{ 0x4b, KEY_FORWARD },
827b2cd0d8SKamil Debski 	{ 0x4c, KEY_BACK },
837b2cd0d8SKamil Debski 	{ 0x4d, KEY_STOP_RECORD }, /* CEC Spec: Stop-Record */
847b2cd0d8SKamil Debski 	{ 0x4e, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record */
857b2cd0d8SKamil Debski 	/* 0x4f: Reserved */
867b2cd0d8SKamil Debski 	{ 0x50, KEY_ANGLE },
877b2cd0d8SKamil Debski 	{ 0x51, KEY_TV2 },
887b2cd0d8SKamil Debski 	{ 0x52, KEY_VOD }, /* CEC Spec: Video on Demand */
897b2cd0d8SKamil Debski 	{ 0x53, KEY_EPG },
907b2cd0d8SKamil Debski 	{ 0x54, KEY_TIME }, /* CEC Spec: Timer */
917b2cd0d8SKamil Debski 	{ 0x55, KEY_CONFIG },
927b2cd0d8SKamil Debski 	/*
937b2cd0d8SKamil Debski 	 * The following codes are hard to implement at this moment, as they
947b2cd0d8SKamil Debski 	 * carry an additional additional argument. Most likely changes to RC
957b2cd0d8SKamil Debski 	 * framework are necessary.
967b2cd0d8SKamil Debski 	 * For now they are interpreted by the CEC framework as non keycodes
977b2cd0d8SKamil Debski 	 * and are passed as messages enabling user application to parse them.
987b2cd0d8SKamil Debski 	 */
997b2cd0d8SKamil Debski 	/* 0x56: CEC Spec: Select Broadcast Type */
1007b2cd0d8SKamil Debski 	/* 0x57: CEC Spec: Select Sound presentation */
1017b2cd0d8SKamil Debski 	{ 0x58, KEY_AUDIO_DESC }, /* CEC 2.0 and up */
1027b2cd0d8SKamil Debski 	{ 0x59, KEY_WWW }, /* CEC 2.0 and up */
1037b2cd0d8SKamil Debski 	{ 0x5a, KEY_3D_MODE }, /* CEC 2.0 and up */
1047b2cd0d8SKamil Debski 	/* 0x5b-0x5f: Reserved */
1057b2cd0d8SKamil Debski 	{ 0x60, KEY_PLAYCD }, /* CEC Spec: Play Function */
1067b2cd0d8SKamil Debski 	{ 0x6005, KEY_FASTFORWARD },
1077b2cd0d8SKamil Debski 	{ 0x6006, KEY_FASTFORWARD },
1087b2cd0d8SKamil Debski 	{ 0x6007, KEY_FASTFORWARD },
1097b2cd0d8SKamil Debski 	{ 0x6015, KEY_SLOW },
1107b2cd0d8SKamil Debski 	{ 0x6016, KEY_SLOW },
1117b2cd0d8SKamil Debski 	{ 0x6017, KEY_SLOW },
1127b2cd0d8SKamil Debski 	{ 0x6009, KEY_FASTREVERSE },
1137b2cd0d8SKamil Debski 	{ 0x600a, KEY_FASTREVERSE },
1147b2cd0d8SKamil Debski 	{ 0x600b, KEY_FASTREVERSE },
1157b2cd0d8SKamil Debski 	{ 0x6019, KEY_SLOWREVERSE },
1167b2cd0d8SKamil Debski 	{ 0x601a, KEY_SLOWREVERSE },
1177b2cd0d8SKamil Debski 	{ 0x601b, KEY_SLOWREVERSE },
1187b2cd0d8SKamil Debski 	{ 0x6020, KEY_REWIND },
1197b2cd0d8SKamil Debski 	{ 0x6024, KEY_PLAYCD },
1207b2cd0d8SKamil Debski 	{ 0x6025, KEY_PAUSECD },
1217b2cd0d8SKamil Debski 	{ 0x61, KEY_PLAYPAUSE }, /* CEC Spec: Pause-Play Function */
1227b2cd0d8SKamil Debski 	{ 0x62, KEY_RECORD }, /* Spec: Record Function */
1237b2cd0d8SKamil Debski 	{ 0x63, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record Function */
1247b2cd0d8SKamil Debski 	{ 0x64, KEY_STOPCD }, /* CEC Spec: Stop Function */
1257b2cd0d8SKamil Debski 	{ 0x65, KEY_MUTE }, /* CEC Spec: Mute Function */
1267b2cd0d8SKamil Debski 	{ 0x66, KEY_UNMUTE }, /* CEC Spec: Restore the volume */
1277b2cd0d8SKamil Debski 	/*
1287b2cd0d8SKamil Debski 	 * The following codes are hard to implement at this moment, as they
1297b2cd0d8SKamil Debski 	 * carry an additional additional argument. Most likely changes to RC
1307b2cd0d8SKamil Debski 	 * framework are necessary.
1317b2cd0d8SKamil Debski 	 * For now they are interpreted by the CEC framework as non keycodes
1327b2cd0d8SKamil Debski 	 * and are passed as messages enabling user application to parse them.
1337b2cd0d8SKamil Debski 	 */
1347b2cd0d8SKamil Debski 	/* 0x67: CEC Spec: Tune Function */
1357b2cd0d8SKamil Debski 	/* 0x68: CEC Spec: Seleect Media Function */
1367b2cd0d8SKamil Debski 	/* 0x69: CEC Spec: Select A/V Input Function */
1377b2cd0d8SKamil Debski 	/* 0x6a: CEC Spec: Select Audio Input Function */
1387b2cd0d8SKamil Debski 	{ 0x6b, KEY_POWER }, /* CEC Spec: Power Toggle Function */
1397b2cd0d8SKamil Debski 	{ 0x6c, KEY_SLEEP }, /* CEC Spec: Power Off Function */
1407b2cd0d8SKamil Debski 	{ 0x6d, KEY_WAKEUP }, /* CEC Spec: Power On Function */
1417b2cd0d8SKamil Debski 	/* 0x6e-0x70: Reserved */
1427b2cd0d8SKamil Debski 	{ 0x71, KEY_BLUE }, /* CEC Spec: F1 (Blue) */
1437b2cd0d8SKamil Debski 	{ 0x72, KEY_RED }, /* CEC Spec: F2 (Red) */
1447b2cd0d8SKamil Debski 	{ 0x73, KEY_GREEN }, /* CEC Spec: F3 (Green) */
1457b2cd0d8SKamil Debski 	{ 0x74, KEY_YELLOW }, /* CEC Spec: F4 (Yellow) */
1467b2cd0d8SKamil Debski 	{ 0x75, KEY_F5 },
1477b2cd0d8SKamil Debski 	{ 0x76, KEY_DATA }, /* CEC Spec: Data - see Note 3 */
1487b2cd0d8SKamil Debski 	/*
1497b2cd0d8SKamil Debski 	 * Note 3: This is used, for example, to enter or leave a digital TV
1507b2cd0d8SKamil Debski 	 * data broadcast application.
1517b2cd0d8SKamil Debski 	 */
1527b2cd0d8SKamil Debski 	/* 0x77-0xff: Reserved */
1537b2cd0d8SKamil Debski };
1547b2cd0d8SKamil Debski 
1557b2cd0d8SKamil Debski static struct rc_map_list cec_map = {
1567b2cd0d8SKamil Debski 	.map = {
1577b2cd0d8SKamil Debski 		.scan		= cec,
1587b2cd0d8SKamil Debski 		.size		= ARRAY_SIZE(cec),
1596d741bfeSSean Young 		.rc_proto	= RC_PROTO_CEC,
1607b2cd0d8SKamil Debski 		.name		= RC_MAP_CEC,
1617b2cd0d8SKamil Debski 	}
1627b2cd0d8SKamil Debski };
1637b2cd0d8SKamil Debski 
1647b2cd0d8SKamil Debski static int __init init_rc_map_cec(void)
1657b2cd0d8SKamil Debski {
1667b2cd0d8SKamil Debski 	return rc_map_register(&cec_map);
1677b2cd0d8SKamil Debski }
1687b2cd0d8SKamil Debski 
1697b2cd0d8SKamil Debski static void __exit exit_rc_map_cec(void)
1707b2cd0d8SKamil Debski {
1717b2cd0d8SKamil Debski 	rc_map_unregister(&cec_map);
1727b2cd0d8SKamil Debski }
1737b2cd0d8SKamil Debski 
1747b2cd0d8SKamil Debski module_init(init_rc_map_cec);
1757b2cd0d8SKamil Debski module_exit(exit_rc_map_cec);
1767b2cd0d8SKamil Debski 
1777b2cd0d8SKamil Debski MODULE_LICENSE("GPL");
1787b2cd0d8SKamil Debski MODULE_AUTHOR("Kamil Debski");
179