Skip to content

Commit 1756c03

Browse files
committed
[LIRC]rc: Add HDMI CEC protoctol handling
ref: https://patchwork.kernel.org/patch/6328561/ https://patchwork.kernel.org/patch/6328521/ Change-Id: I7ed8a4a19f3b671d6cc02d9328776138234b936b Reviewed-on: https://tp-biosrd-v02/gerrit/81412 Reviewed-by: Scorpio Chang(張志賢) <Scorpio_Chang@asus.com> Tested-by: Scorpio Chang(張志賢) <Scorpio_Chang@asus.com>
1 parent 36c7982 commit 1756c03

14 files changed

Lines changed: 185 additions & 17 deletions

File tree

arch/arm/configs/miniarm-rk3288_defconfig

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,8 +792,12 @@ CONFIG_W1_SLAVE_THERM=y
792792
CONFIG_RK_CHAR_DRIVERS=y
793793
CONFIG_RK3288_DEVGPIOMEM=y
794794
CONFIG_RTC_DRV_DS1307=m
795+
CONFIG_MEDIA_RC_SUPPORT=y
795796
CONFIG_RC_CORE=y
797+
CONFIG_RC_MAP=y
798+
CONFIG_RC_DECODERS=y
796799
CONFIG_LIRC=y
800+
CONFIG_IR_LIRC_CODEC=y
797801
CONFIG_IR_NEC_DECODER=y
798802
CONFIG_IR_RC5_DECODER=y
799803
CONFIG_IR_RC6_DECODER=y
@@ -802,6 +806,8 @@ CONFIG_IR_SONY_DECODER=y
802806
CONFIG_IR_SANYO_DECODER=y
803807
CONFIG_IR_SHARP_DECODER=y
804808
CONFIG_IR_MCE_KBD_DECODER=y
805-
CONFIG_IR_LIRC_CODEC=y
806809
CONFIG_IR_XMP_DECODER=y
807-
CONFIG_MEDIA_RC_SUPPORT=y
810+
CONFIG_LIRC_RPI=y
811+
CONFIG_RC_DEVICES=y
812+
CONFIG_LIRC_STAGING=y
813+
CONFIG_STAGING_MEDIA=y

drivers/media/cec/cec-adap.c

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1699,10 +1699,7 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
16991699
!(adap->log_addrs.flags & CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU))
17001700
break;
17011701

1702-
/* Disable this since the original setting without define CONFIG_RC_CORE
1703-
* However, if add the define above, it still lacks some part of cec.
1704-
*/
1705-
#if 0 //IS_REACHABLE(CONFIG_RC_CORE)
1702+
#if IS_REACHABLE(CONFIG_RC_CORE)
17061703
switch (msg->msg[2]) {
17071704
/*
17081705
* Play function, this message can have variable length
@@ -1739,7 +1736,7 @@ static int cec_receive_notify(struct cec_adapter *adap, struct cec_msg *msg,
17391736
if (!(adap->capabilities & CEC_CAP_RC) ||
17401737
!(adap->log_addrs.flags & CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU))
17411738
break;
1742-
#if 0 //IS_REACHABLE(CONFIG_RC_CORE)
1739+
#if IS_REACHABLE(CONFIG_RC_CORE)
17431740
rc_keyup(adap->rc);
17441741
#endif
17451742
break;

drivers/media/cec/cec-core.c

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,10 +237,7 @@ struct cec_adapter *cec_allocate_adapter(const struct cec_adap_ops *ops,
237237
if (!(caps & CEC_CAP_RC))
238238
return adap;
239239

240-
/* Disable this since the original setting without define CONFIG_RC_CORE
241-
* However, if add the define above, it still lacks some part of cec.
242-
*/
243-
#if 0 //IS_REACHABLE(CONFIG_RC_CORE) // disable this since the original setting without define CONFIG_RC_CORE
240+
#if IS_REACHABLE(CONFIG_RC_CORE)
244241
/* Prepare the RC input device */
245242
adap->rc = rc_allocate_device();
246243
if (!adap->rc) {
@@ -288,7 +285,7 @@ int cec_register_adapter(struct cec_adapter *adap,
288285
adap->owner = parent->driver->owner;
289286
adap->devnode.dev.parent = parent;
290287

291-
#if 0//IS_REACHABLE(CONFIG_RC_CORE)
288+
#if IS_REACHABLE(CONFIG_RC_CORE)
292289
adap->rc->dev.parent = parent;
293290
if (adap->capabilities & CEC_CAP_RC) {
294291
res = rc_register_device(adap->rc);
@@ -305,7 +302,7 @@ int cec_register_adapter(struct cec_adapter *adap,
305302

306303
res = cec_devnode_register(&adap->devnode, adap->owner);
307304
if (res) {
308-
#if 0// IS_REACHABLE(CONFIG_RC_CORE)
305+
#if IS_REACHABLE(CONFIG_RC_CORE)
309306
/* Note: rc_unregister also calls rc_free */
310307
rc_unregister_device(adap->rc);
311308
adap->rc = NULL;
@@ -340,7 +337,7 @@ void cec_unregister_adapter(struct cec_adapter *adap)
340337
if (IS_ERR_OR_NULL(adap))
341338
return;
342339

343-
#if 0 //IS_REACHABLE(CONFIG_RC_CORE)
340+
#if IS_REACHABLE(CONFIG_RC_CORE)
344341
/* Note: rc_unregister also calls rc_free */
345342
rc_unregister_device(adap->rc);
346343
adap->rc = NULL;
@@ -360,7 +357,7 @@ void cec_delete_adapter(struct cec_adapter *adap)
360357
kthread_stop(adap->kthread);
361358
if (adap->kthread_config)
362359
kthread_stop(adap->kthread_config);
363-
#if 0 //IS_REACHABLE(CONFIG_RC_CORE)
360+
#if IS_REACHABLE(CONFIG_RC_CORE)
364361
rc_free_device(adap->rc);
365362
#endif
366363
kfree(adap);

drivers/media/rc/keymaps/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \
1818
rc-behold.o \
1919
rc-behold-columbus.o \
2020
rc-budget-ci-old.o \
21+
rc-cec.o \
2122
rc-cinergy-1400.o \
2223
rc-cinergy.o \
2324
rc-delock-61959.o \

drivers/media/rc/keymaps/rc-cec.c

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
/* Keytable for the CEC remote control
2+
*
3+
* Copyright (c) 2015 by Kamil Debski
4+
*
5+
* This program is free software; you can redistribute it and/or modify
6+
* it under the terms of the GNU General Public License as published by
7+
* the Free Software Foundation; either version 2 of the License, or
8+
* (at your option) any later version.
9+
*/
10+
11+
#include <media/rc-map.h>
12+
#include <linux/module.h>
13+
14+
/* CEC Spec "High-Definition Multimedia Interface Specification" can be obtained
15+
* here: http://xtreamerdev.googlecode.com/files/CEC_Specs.pdf
16+
* The list of control codes is listed in Table 27: User Control Codes p. 95 */
17+
18+
static struct rc_map_table cec[] = {
19+
{ 0x00, KEY_OK },
20+
{ 0x01, KEY_UP },
21+
{ 0x02, KEY_DOWN },
22+
{ 0x03, KEY_LEFT },
23+
{ 0x04, KEY_RIGHT },
24+
{ 0x05, KEY_RIGHT_UP },
25+
{ 0x06, KEY_RIGHT_DOWN },
26+
{ 0x07, KEY_LEFT_UP },
27+
{ 0x08, KEY_LEFT_DOWN },
28+
{ 0x09, KEY_CONTEXT_MENU }, /* CEC Spec: Root Menu - see Note 2 */
29+
/* Note 2: This is the initial display that a device shows. It is
30+
* device-dependent and can be, for example, a contents menu, setup
31+
* menu, favorite menu or other menu. The actual menu displayed
32+
* may also depend on the device's current state. */
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-0x1f: Reserved */
38+
/* 0x20-0x29: Keys 0 to 9 */
39+
{ 0x20, KEY_NUMERIC_0 },
40+
{ 0x21, KEY_NUMERIC_1 },
41+
{ 0x22, KEY_NUMERIC_2 },
42+
{ 0x23, KEY_NUMERIC_3 },
43+
{ 0x24, KEY_NUMERIC_4 },
44+
{ 0x25, KEY_NUMERIC_5 },
45+
{ 0x26, KEY_NUMERIC_6 },
46+
{ 0x27, KEY_NUMERIC_7 },
47+
{ 0x28, KEY_NUMERIC_8 },
48+
{ 0x29, KEY_NUMERIC_9 },
49+
{ 0x2a, KEY_DOT },
50+
{ 0x2b, KEY_ENTER },
51+
{ 0x2c, KEY_CLEAR },
52+
/* 0x2d-0x2e: Reserved */
53+
{ 0x2f, KEY_NEXT_FAVORITE }, /* CEC Spec: Next Favorite */
54+
{ 0x30, KEY_CHANNELUP },
55+
{ 0x31, KEY_CHANNELDOWN },
56+
{ 0x32, KEY_PREVIOUS }, /* CEC Spec: Previous Channel */
57+
{ 0x33, KEY_SOUND }, /* CEC Spec: Sound Select */
58+
{ 0x34, KEY_VIDEO }, /* 0x34: CEC Spec: Input Select */
59+
{ 0x35, KEY_INFO }, /* CEC Spec: Display Information */
60+
{ 0x36, KEY_HELP },
61+
{ 0x37, KEY_PAGEUP },
62+
{ 0x38, KEY_PAGEDOWN },
63+
/* 0x39-0x3f: Reserved */
64+
{ 0x40, KEY_POWER },
65+
{ 0x41, KEY_VOLUMEUP },
66+
{ 0x42, KEY_VOLUMEDOWN },
67+
{ 0x43, KEY_MUTE },
68+
{ 0x44, KEY_PLAY },
69+
{ 0x45, KEY_STOP },
70+
{ 0x46, KEY_PAUSE },
71+
{ 0x47, KEY_RECORD },
72+
{ 0x48, KEY_REWIND },
73+
{ 0x49, KEY_FASTFORWARD },
74+
{ 0x4a, KEY_EJECTCD }, /* CEC Spec: Eject */
75+
{ 0x4b, KEY_FORWARD },
76+
{ 0x4c, KEY_BACK },
77+
{ 0x4d, KEY_STOP_RECORD }, /* CEC Spec: Stop-Record */
78+
{ 0x4e, KEY_PAUSE_RECORD }, /* CEC Spec: Pause-Record */
79+
/* 0x4f: Reserved */
80+
{ 0x50, KEY_ANGLE },
81+
{ 0x51, KEY_TV2 },
82+
{ 0x52, KEY_VOD }, /* CEC Spec: Video on Demand */
83+
{ 0x53, KEY_EPG },
84+
{ 0x54, KEY_TIME }, /* CEC Spec: Timer */
85+
{ 0x55, KEY_CONFIG },
86+
/* 0x56-0x5f: Reserved */
87+
{ 0x60, KEY_PLAY }, /* CEC Spec: Play Function */
88+
{ 0x6024, KEY_PLAY },
89+
{ 0x6020, KEY_PAUSE },
90+
{ 0x61, KEY_PLAYPAUSE }, /* CEC Spec: Pause-Play Function */
91+
{ 0x62, KEY_RECORD }, /* Spec: Record Function */
92+
{ 0x63, KEY_PAUSE }, /* CEC Spec: Pause-Record Function */
93+
{ 0x64, KEY_STOP }, /* CEC Spec: Stop Function */
94+
{ 0x65, KEY_MUTE }, /* CEC Spec: Mute Function */
95+
{ 0x66, KEY_UNMUTE }, /* CEC Spec: Restore the volume */
96+
/* The following codes are hard to implement at this moment, as they
97+
* carry an additional additional argument. Most likely changes to RC
98+
* framework are necessary.
99+
* For now they are interpreted by the CEC framework as non keycodes
100+
* and are passed as messages enabling user application to parse them.
101+
* */
102+
/* 0x67: CEC Spec: Tune Function */
103+
/* 0x68: CEC Spec: Seleect Media Function */
104+
/* 0x69: CEC Spec: Select A/V Input Function */
105+
/* 0x6a: CEC Spec: Select Audio Input Function */
106+
{ 0x6b, KEY_POWER }, /* CEC Spec: Power Toggle Function */
107+
{ 0x6c, KEY_SLEEP }, /* CEC Spec: Power Off Function */
108+
{ 0x6d, KEY_WAKEUP }, /* CEC Spec: Power On Function */
109+
/* 0x6e-0x70: Reserved */
110+
{ 0x71, KEY_BLUE }, /* CEC Spec: F1 (Blue) */
111+
{ 0x72, KEY_RED }, /* CEC Spec: F2 (Red) */
112+
{ 0x73, KEY_GREEN }, /* CEC Spec: F3 (Green) */
113+
{ 0x74, KEY_YELLOW }, /* CEC Spec: F4 (Yellow) */
114+
{ 0x75, KEY_F5 },
115+
{ 0x76, KEY_DVB }, /* CEC Spec: Data - see Note 3 */
116+
/* Note 3: This is used, for example, to enter or leave a digital TV
117+
* data broadcast application. */
118+
/* 0x77-0xff: Reserved */
119+
};
120+
121+
static struct rc_map_list cec_map = {
122+
.map = {
123+
.scan = cec,
124+
.size = ARRAY_SIZE(cec),
125+
.rc_type = RC_TYPE_CEC,
126+
.name = RC_MAP_CEC,
127+
}
128+
};
129+
130+
static int __init init_rc_map_cec(void)
131+
{
132+
return rc_map_register(&cec_map);
133+
}
134+
135+
static void __exit exit_rc_map_cec(void)
136+
{
137+
rc_map_unregister(&cec_map);
138+
}
139+
140+
module_init(init_rc_map_cec);
141+
module_exit(exit_rc_map_cec);
142+
143+
MODULE_LICENSE("GPL");
144+
MODULE_AUTHOR("Kamil Debski");

drivers/media/rc/rc-main.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -801,6 +801,7 @@ static struct {
801801
{ RC_BIT_SHARP, "sharp" },
802802
{ RC_BIT_MCE_KBD, "mce_kbd" },
803803
{ RC_BIT_XMP, "xmp" },
804+
{ RC_BIT_CEC, "cec" },
804805
};
805806

806807
/**

drivers/misc/Makefile

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,4 +63,3 @@ obj-$(CONFIG_UID_SYS_STATS) += uid_sys_stats.o
6363
obj-$(CONFIG_MEMORY_STATE_TIME) += memory_state_time.o
6464
obj-$(CONFIG_USB_CAM_GPIO) += usb_cam_gpio.o
6565
obj-$(CONFIG_TINKER_MCU) += tinker_mcu.o
66-
obj-m += lirc_rpi.o

drivers/staging/media/lirc/Kconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ config LIRC_PARALLEL
3232
help
3333
Driver for Homebrew Parallel Port Receivers
3434

35+
config LIRC_RPI
36+
tristate "Homebrew GPIO Port Receiver/Transmitter for the RaspberryPi"
37+
depends on LIRC
38+
help
39+
Driver for Homebrew GPIO Port Receiver/Transmitter for the RaspberryPi
40+
3541
config LIRC_SASEM
3642
tristate "Sasem USB IR Remote"
3743
depends on LIRC && USB

drivers/staging/media/lirc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
obj-$(CONFIG_LIRC_BT829) += lirc_bt829.o
77
obj-$(CONFIG_LIRC_IMON) += lirc_imon.o
88
obj-$(CONFIG_LIRC_PARALLEL) += lirc_parallel.o
9+
obj-$(CONFIG_LIRC_RPI) += lirc_rpi.o
910
obj-$(CONFIG_LIRC_SASEM) += lirc_sasem.o
1011
obj-$(CONFIG_LIRC_SERIAL) += lirc_serial.o
1112
obj-$(CONFIG_LIRC_SIR) += lirc_sir.o

0 commit comments

Comments
 (0)