162306a36Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
262306a36Sopenharmony_ci/* Keytable for the CEC remote control
362306a36Sopenharmony_ci *
462306a36Sopenharmony_ci * This keymap is unusual in that it can't be built as a module,
562306a36Sopenharmony_ci * instead it is registered directly in rc-main.c if CONFIG_MEDIA_CEC_RC
662306a36Sopenharmony_ci * is set. This is because it can be called from drm_dp_cec_set_edid() via
762306a36Sopenharmony_ci * cec_register_adapter() in an asynchronous context, and it is not
862306a36Sopenharmony_ci * allowed to use request_module() to load rc-cec.ko in that case.
962306a36Sopenharmony_ci *
1062306a36Sopenharmony_ci * Since this keymap is only used if CONFIG_MEDIA_CEC_RC is set, we
1162306a36Sopenharmony_ci * just compile this keymap into the rc-core module and never as a
1262306a36Sopenharmony_ci * separate module.
1362306a36Sopenharmony_ci *
1462306a36Sopenharmony_ci * Copyright (c) 2015 by Kamil Debski
1562306a36Sopenharmony_ci */
1662306a36Sopenharmony_ci
1762306a36Sopenharmony_ci#include <media/rc-map.h>
1862306a36Sopenharmony_ci#include <linux/module.h>
1962306a36Sopenharmony_ci
2062306a36Sopenharmony_ci/*
2162306a36Sopenharmony_ci * CEC Spec "High-Definition Multimedia Interface Specification" can be obtained
2262306a36Sopenharmony_ci * here: http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf
2362306a36Sopenharmony_ci * The list of control codes is listed in Table 27: User Control Codes p. 95
2462306a36Sopenharmony_ci */
2562306a36Sopenharmony_ci
2662306a36Sopenharmony_cistatic struct rc_map_table cec[] = {
2762306a36Sopenharmony_ci	{ 0x00, KEY_OK },
2862306a36Sopenharmony_ci	{ 0x01, KEY_UP },
2962306a36Sopenharmony_ci	{ 0x02, KEY_DOWN },
3062306a36Sopenharmony_ci	{ 0x03, KEY_LEFT },
3162306a36Sopenharmony_ci	{ 0x04, KEY_RIGHT },
3262306a36Sopenharmony_ci	{ 0x05, KEY_RIGHT_UP },
3362306a36Sopenharmony_ci	{ 0x06, KEY_RIGHT_DOWN },
3462306a36Sopenharmony_ci	{ 0x07, KEY_LEFT_UP },
3562306a36Sopenharmony_ci	{ 0x08, KEY_LEFT_DOWN },
3662306a36Sopenharmony_ci	{ 0x09, KEY_ROOT_MENU }, /* CEC Spec: Device Root Menu - see Note 2 */
3762306a36Sopenharmony_ci	/*
3862306a36Sopenharmony_ci	 * Note 2: This is the initial display that a device shows. It is
3962306a36Sopenharmony_ci	 * device-dependent and can be, for example, a contents menu, setup
4062306a36Sopenharmony_ci	 * menu, favorite menu or other menu. The actual menu displayed
4162306a36Sopenharmony_ci	 * may also depend on the device's current state.
4262306a36Sopenharmony_ci	 */
4362306a36Sopenharmony_ci	{ 0x0a, KEY_SETUP },
4462306a36Sopenharmony_ci	{ 0x0b, KEY_MENU }, /* CEC Spec: Contents Menu */
4562306a36Sopenharmony_ci	{ 0x0c, KEY_FAVORITES }, /* CEC Spec: Favorite Menu */
4662306a36Sopenharmony_ci	{ 0x0d, KEY_EXIT },
4762306a36Sopenharmony_ci	/* 0x0e-0x0f: Reserved */
4862306a36Sopenharmony_ci	{ 0x10, KEY_MEDIA_TOP_MENU },
4962306a36Sopenharmony_ci	{ 0x11, KEY_CONTEXT_MENU },
5062306a36Sopenharmony_ci	/* 0x12-0x1c: Reserved */
5162306a36Sopenharmony_ci	{ 0x1d, KEY_DIGITS }, /* CEC Spec: select/toggle a Number Entry Mode */
5262306a36Sopenharmony_ci	{ 0x1e, KEY_NUMERIC_11 },
5362306a36Sopenharmony_ci	{ 0x1f, KEY_NUMERIC_12 },
5462306a36Sopenharmony_ci	/* 0x20-0x29: Keys 0 to 9 */
5562306a36Sopenharmony_ci	{ 0x20, KEY_NUMERIC_0 },
5662306a36Sopenharmony_ci	{ 0x21, KEY_NUMERIC_1 },
5762306a36Sopenharmony_ci	{ 0x22, KEY_NUMERIC_2 },
5862306a36Sopenharmony_ci	{ 0x23, KEY_NUMERIC_3 },
5962306a36Sopenharmony_ci	{ 0x24, KEY_NUMERIC_4 },
6062306a36Sopenharmony_ci	{ 0x25, KEY_NUMERIC_5 },
6162306a36Sopenharmony_ci	{ 0x26, KEY_NUMERIC_6 },
6262306a36Sopenharmony_ci	{ 0x27, KEY_NUMERIC_7 },
6362306a36Sopenharmony_ci	{ 0x28, KEY_NUMERIC_8 },
6462306a36Sopenharmony_ci	{ 0x29, KEY_NUMERIC_9 },
6562306a36Sopenharmony_ci	{ 0x2a, KEY_DOT },
6662306a36Sopenharmony_ci	{ 0x2b, KEY_ENTER },
6762306a36Sopenharmony_ci	{ 0x2c, KEY_CLEAR },
6862306a36Sopenharmony_ci	/* 0x2d-0x2e: Reserved */
6962306a36Sopenharmony_ci	{ 0x2f, KEY_NEXT_FAVORITE }, /* CEC Spec: Next Favorite */
7062306a36Sopenharmony_ci	{ 0x30, KEY_CHANNELUP },
7162306a36Sopenharmony_ci	{ 0x31, KEY_CHANNELDOWN },
7262306a36Sopenharmony_ci	{ 0x32, KEY_PREVIOUS }, /* CEC Spec: Previous Channel */
7362306a36Sopenharmony_ci	{ 0x33, KEY_SOUND }, /* CEC Spec: Sound Select */
7462306a36Sopenharmony_ci	{ 0x34, KEY_VIDEO }, /* 0x34: CEC Spec: Input Select */
7562306a36Sopenharmony_ci	{ 0x35, KEY_INFO }, /* CEC Spec: Display Information */
7662306a36Sopenharmony_ci	{ 0x36, KEY_HELP },
7762306a36Sopenharmony_ci	{ 0x37, KEY_PAGEUP },
7862306a36Sopenharmony_ci	{ 0x38, KEY_PAGEDOWN },
7962306a36Sopenharmony_ci	/* 0x39-0x3f: Reserved */
8062306a36Sopenharmony_ci	{ 0x40, KEY_POWER },
8162306a36Sopenharmony_ci	{ 0x41, KEY_VOLUMEUP },
8262306a36Sopenharmony_ci	{ 0x42, KEY_VOLUMEDOWN },
8362306a36Sopenharmony_ci	{ 0x43, KEY_MUTE },
8462306a36Sopenharmony_ci	{ 0x44, KEY_PLAYCD },
8562306a36Sopenharmony_ci	{ 0x45, KEY_STOPCD },
8662306a36Sopenharmony_ci	{ 0x46, KEY_PAUSECD },
8762306a36Sopenharmony_ci	{ 0x47, KEY_RECORD },
8862306a36Sopenharmony_ci	{ 0x48, KEY_REWIND },
8962306a36Sopenharmony_ci	{ 0x49, KEY_FASTFORWARD },
9062306a36Sopenharmony_ci	{ 0x4a, KEY_EJECTCD }, /* CEC Spec: Eject */
9162306a36Sopenharmony_ci	{ 0x4b, KEY_FORWARD },
9262306a36Sopenharmony_ci	{ 0x4c, KEY_BACK },
9362306a36Sopenharmony_ci	{ 0x4d, KEY_STOP_RECORD }, /* CEC Spec: Stop-Record */
9462306a36Sopenharmony_ci	{ 0x4e, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record */
9562306a36Sopenharmony_ci	/* 0x4f: Reserved */
9662306a36Sopenharmony_ci	{ 0x50, KEY_ANGLE },
9762306a36Sopenharmony_ci	{ 0x51, KEY_TV2 },
9862306a36Sopenharmony_ci	{ 0x52, KEY_VOD }, /* CEC Spec: Video on Demand */
9962306a36Sopenharmony_ci	{ 0x53, KEY_EPG },
10062306a36Sopenharmony_ci	{ 0x54, KEY_TIME }, /* CEC Spec: Timer */
10162306a36Sopenharmony_ci	{ 0x55, KEY_CONFIG },
10262306a36Sopenharmony_ci	/*
10362306a36Sopenharmony_ci	 * The following codes are hard to implement at this moment, as they
10462306a36Sopenharmony_ci	 * carry an additional additional argument. Most likely changes to RC
10562306a36Sopenharmony_ci	 * framework are necessary.
10662306a36Sopenharmony_ci	 * For now they are interpreted by the CEC framework as non keycodes
10762306a36Sopenharmony_ci	 * and are passed as messages enabling user application to parse them.
10862306a36Sopenharmony_ci	 */
10962306a36Sopenharmony_ci	/* 0x56: CEC Spec: Select Broadcast Type */
11062306a36Sopenharmony_ci	/* 0x57: CEC Spec: Select Sound presentation */
11162306a36Sopenharmony_ci	{ 0x58, KEY_AUDIO_DESC }, /* CEC 2.0 and up */
11262306a36Sopenharmony_ci	{ 0x59, KEY_WWW }, /* CEC 2.0 and up */
11362306a36Sopenharmony_ci	{ 0x5a, KEY_3D_MODE }, /* CEC 2.0 and up */
11462306a36Sopenharmony_ci	/* 0x5b-0x5f: Reserved */
11562306a36Sopenharmony_ci	{ 0x60, KEY_PLAYCD }, /* CEC Spec: Play Function */
11662306a36Sopenharmony_ci	{ 0x6005, KEY_FASTFORWARD },
11762306a36Sopenharmony_ci	{ 0x6006, KEY_FASTFORWARD },
11862306a36Sopenharmony_ci	{ 0x6007, KEY_FASTFORWARD },
11962306a36Sopenharmony_ci	{ 0x6015, KEY_SLOW },
12062306a36Sopenharmony_ci	{ 0x6016, KEY_SLOW },
12162306a36Sopenharmony_ci	{ 0x6017, KEY_SLOW },
12262306a36Sopenharmony_ci	{ 0x6009, KEY_FASTREVERSE },
12362306a36Sopenharmony_ci	{ 0x600a, KEY_FASTREVERSE },
12462306a36Sopenharmony_ci	{ 0x600b, KEY_FASTREVERSE },
12562306a36Sopenharmony_ci	{ 0x6019, KEY_SLOWREVERSE },
12662306a36Sopenharmony_ci	{ 0x601a, KEY_SLOWREVERSE },
12762306a36Sopenharmony_ci	{ 0x601b, KEY_SLOWREVERSE },
12862306a36Sopenharmony_ci	{ 0x6020, KEY_REWIND },
12962306a36Sopenharmony_ci	{ 0x6024, KEY_PLAYCD },
13062306a36Sopenharmony_ci	{ 0x6025, KEY_PAUSECD },
13162306a36Sopenharmony_ci	{ 0x61, KEY_PLAYPAUSE }, /* CEC Spec: Pause-Play Function */
13262306a36Sopenharmony_ci	{ 0x62, KEY_RECORD }, /* Spec: Record Function */
13362306a36Sopenharmony_ci	{ 0x63, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record Function */
13462306a36Sopenharmony_ci	{ 0x64, KEY_STOPCD }, /* CEC Spec: Stop Function */
13562306a36Sopenharmony_ci	{ 0x65, KEY_MUTE }, /* CEC Spec: Mute Function */
13662306a36Sopenharmony_ci	{ 0x66, KEY_UNMUTE }, /* CEC Spec: Restore the volume */
13762306a36Sopenharmony_ci	/*
13862306a36Sopenharmony_ci	 * The following codes are hard to implement at this moment, as they
13962306a36Sopenharmony_ci	 * carry an additional additional argument. Most likely changes to RC
14062306a36Sopenharmony_ci	 * framework are necessary.
14162306a36Sopenharmony_ci	 * For now they are interpreted by the CEC framework as non keycodes
14262306a36Sopenharmony_ci	 * and are passed as messages enabling user application to parse them.
14362306a36Sopenharmony_ci	 */
14462306a36Sopenharmony_ci	/* 0x67: CEC Spec: Tune Function */
14562306a36Sopenharmony_ci	/* 0x68: CEC Spec: Seleect Media Function */
14662306a36Sopenharmony_ci	/* 0x69: CEC Spec: Select A/V Input Function */
14762306a36Sopenharmony_ci	/* 0x6a: CEC Spec: Select Audio Input Function */
14862306a36Sopenharmony_ci	{ 0x6b, KEY_POWER }, /* CEC Spec: Power Toggle Function */
14962306a36Sopenharmony_ci	{ 0x6c, KEY_SLEEP }, /* CEC Spec: Power Off Function */
15062306a36Sopenharmony_ci	{ 0x6d, KEY_WAKEUP }, /* CEC Spec: Power On Function */
15162306a36Sopenharmony_ci	/* 0x6e-0x70: Reserved */
15262306a36Sopenharmony_ci	{ 0x71, KEY_BLUE }, /* CEC Spec: F1 (Blue) */
15362306a36Sopenharmony_ci	{ 0x72, KEY_RED }, /* CEC Spec: F2 (Red) */
15462306a36Sopenharmony_ci	{ 0x73, KEY_GREEN }, /* CEC Spec: F3 (Green) */
15562306a36Sopenharmony_ci	{ 0x74, KEY_YELLOW }, /* CEC Spec: F4 (Yellow) */
15662306a36Sopenharmony_ci	{ 0x75, KEY_F5 },
15762306a36Sopenharmony_ci	{ 0x76, KEY_DATA }, /* CEC Spec: Data - see Note 3 */
15862306a36Sopenharmony_ci	/*
15962306a36Sopenharmony_ci	 * Note 3: This is used, for example, to enter or leave a digital TV
16062306a36Sopenharmony_ci	 * data broadcast application.
16162306a36Sopenharmony_ci	 */
16262306a36Sopenharmony_ci	/* 0x77-0xff: Reserved */
16362306a36Sopenharmony_ci};
16462306a36Sopenharmony_ci
16562306a36Sopenharmony_cistruct rc_map_list cec_map = {
16662306a36Sopenharmony_ci	.map = {
16762306a36Sopenharmony_ci		.scan		= cec,
16862306a36Sopenharmony_ci		.size		= ARRAY_SIZE(cec),
16962306a36Sopenharmony_ci		.rc_proto	= RC_PROTO_CEC,
17062306a36Sopenharmony_ci		.name		= RC_MAP_CEC,
17162306a36Sopenharmony_ci	}
17262306a36Sopenharmony_ci};
173