diff options
author | James Hogan <james.hogan@imgtec.com> | 2014-02-28 18:17:05 -0500 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-03-11 12:28:20 -0400 |
commit | ab88c66deace78989aa71cb139284cf7fb227ba4 (patch) | |
tree | 26f8bb54eddd1fc41ba758ab5c2c70c5ca553d53 | |
parent | acff5f24732acc8a55d0a0f0ee1d19442267df63 (diff) |
[media] rc: add wakeup_protocols sysfs file
Add a wakeup_protocols sysfs file which controls the new
rc_dev::enabled_protocols[RC_FILTER_WAKEUP], which is the mask of
protocols that are used for the wakeup filter.
A new RC driver callback change_wakeup_protocol() is called to change
the wakeup protocol mask.
Signed-off-by: James Hogan <james.hogan@imgtec.com>
Reviewed-by: Antti Seppälä <a.seppala@gmail.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
-rw-r--r-- | Documentation/ABI/testing/sysfs-class-rc | 23 | ||||
-rw-r--r-- | Documentation/DocBook/media/v4l/remote_controllers.xml | 20 | ||||
-rw-r--r-- | drivers/media/rc/rc-main.c | 82 | ||||
-rw-r--r-- | include/media/rc-core.h | 3 |
4 files changed, 90 insertions, 38 deletions
diff --git a/Documentation/ABI/testing/sysfs-class-rc b/Documentation/ABI/testing/sysfs-class-rc index c0e1d14cae6e..b65674da43bb 100644 --- a/Documentation/ABI/testing/sysfs-class-rc +++ b/Documentation/ABI/testing/sysfs-class-rc | |||
@@ -61,6 +61,25 @@ Description: | |||
61 | an error. | 61 | an error. |
62 | This value may be reset to 0 if the current protocol is altered. | 62 | This value may be reset to 0 if the current protocol is altered. |
63 | 63 | ||
64 | What: /sys/class/rc/rcN/wakeup_protocols | ||
65 | Date: Feb 2014 | ||
66 | KernelVersion: 3.15 | ||
67 | Contact: Mauro Carvalho Chehab <m.chehab@samsung.com> | ||
68 | Description: | ||
69 | Reading this file returns a list of available protocols to use | ||
70 | for the wakeup filter, something like: | ||
71 | "rc5 rc6 nec jvc [sony]" | ||
72 | The enabled wakeup protocol is shown in [] brackets. | ||
73 | Writing "+proto" will add a protocol to the list of enabled | ||
74 | wakeup protocols. | ||
75 | Writing "-proto" will remove a protocol from the list of enabled | ||
76 | wakeup protocols. | ||
77 | Writing "proto" will use "proto" for wakeup events. | ||
78 | Writing "none" will disable wakeup. | ||
79 | Write fails with EINVAL if an invalid protocol combination or | ||
80 | unknown protocol name is used, or if wakeup is not supported by | ||
81 | the hardware. | ||
82 | |||
64 | What: /sys/class/rc/rcN/wakeup_filter | 83 | What: /sys/class/rc/rcN/wakeup_filter |
65 | Date: Jan 2014 | 84 | Date: Jan 2014 |
66 | KernelVersion: 3.15 | 85 | KernelVersion: 3.15 |
@@ -74,7 +93,7 @@ Description: | |||
74 | scancodes which match the filter will wake the system from e.g. | 93 | scancodes which match the filter will wake the system from e.g. |
75 | suspend to RAM or power off. | 94 | suspend to RAM or power off. |
76 | Otherwise the write will fail with an error. | 95 | Otherwise the write will fail with an error. |
77 | This value may be reset to 0 if the current protocol is altered. | 96 | This value may be reset to 0 if the wakeup protocol is altered. |
78 | 97 | ||
79 | What: /sys/class/rc/rcN/wakeup_filter_mask | 98 | What: /sys/class/rc/rcN/wakeup_filter_mask |
80 | Date: Jan 2014 | 99 | Date: Jan 2014 |
@@ -89,4 +108,4 @@ Description: | |||
89 | scancodes which match the filter will wake the system from e.g. | 108 | scancodes which match the filter will wake the system from e.g. |
90 | suspend to RAM or power off. | 109 | suspend to RAM or power off. |
91 | Otherwise the write will fail with an error. | 110 | Otherwise the write will fail with an error. |
92 | This value may be reset to 0 if the current protocol is altered. | 111 | This value may be reset to 0 if the wakeup protocol is altered. |
diff --git a/Documentation/DocBook/media/v4l/remote_controllers.xml b/Documentation/DocBook/media/v4l/remote_controllers.xml index c440a81f14c0..5124a6c4daa8 100644 --- a/Documentation/DocBook/media/v4l/remote_controllers.xml +++ b/Documentation/DocBook/media/v4l/remote_controllers.xml | |||
@@ -102,6 +102,22 @@ an error.</para> | |||
102 | <para>This value may be reset to 0 if the current protocol is altered.</para> | 102 | <para>This value may be reset to 0 if the current protocol is altered.</para> |
103 | 103 | ||
104 | </section> | 104 | </section> |
105 | <section id="sys_class_rc_rcN_wakeup_protocols"> | ||
106 | <title>/sys/class/rc/rcN/wakeup_protocols</title> | ||
107 | <para>Reading this file returns a list of available protocols to use for the | ||
108 | wakeup filter, something like:</para> | ||
109 | <para><constant>rc5 rc6 nec jvc [sony]</constant></para> | ||
110 | <para>The enabled wakeup protocol is shown in [] brackets.</para> | ||
111 | <para>Writing "+proto" will add a protocol to the list of enabled wakeup | ||
112 | protocols.</para> | ||
113 | <para>Writing "-proto" will remove a protocol from the list of enabled wakeup | ||
114 | protocols.</para> | ||
115 | <para>Writing "proto" will use "proto" for wakeup events.</para> | ||
116 | <para>Writing "none" will disable wakeup.</para> | ||
117 | <para>Write fails with EINVAL if an invalid protocol combination or unknown | ||
118 | protocol name is used, or if wakeup is not supported by the hardware.</para> | ||
119 | |||
120 | </section> | ||
105 | <section id="sys_class_rc_rcN_wakeup_filter"> | 121 | <section id="sys_class_rc_rcN_wakeup_filter"> |
106 | <title>/sys/class/rc/rcN/wakeup_filter</title> | 122 | <title>/sys/class/rc/rcN/wakeup_filter</title> |
107 | <para>Sets the scancode wakeup filter expected value. | 123 | <para>Sets the scancode wakeup filter expected value. |
@@ -112,7 +128,7 @@ to trigger a system wake event.</para> | |||
112 | scancodes which match the filter will wake the system from e.g. | 128 | scancodes which match the filter will wake the system from e.g. |
113 | suspend to RAM or power off. | 129 | suspend to RAM or power off. |
114 | Otherwise the write will fail with an error.</para> | 130 | Otherwise the write will fail with an error.</para> |
115 | <para>This value may be reset to 0 if the current protocol is altered.</para> | 131 | <para>This value may be reset to 0 if the wakeup protocol is altered.</para> |
116 | 132 | ||
117 | </section> | 133 | </section> |
118 | <section id="sys_class_rc_rcN_wakeup_filter_mask"> | 134 | <section id="sys_class_rc_rcN_wakeup_filter_mask"> |
@@ -125,7 +141,7 @@ expected value to trigger a system wake event.</para> | |||
125 | scancodes which match the filter will wake the system from e.g. | 141 | scancodes which match the filter will wake the system from e.g. |
126 | suspend to RAM or power off. | 142 | suspend to RAM or power off. |
127 | Otherwise the write will fail with an error.</para> | 143 | Otherwise the write will fail with an error.</para> |
128 | <para>This value may be reset to 0 if the current protocol is altered.</para> | 144 | <para>This value may be reset to 0 if the wakeup protocol is altered.</para> |
129 | </section> | 145 | </section> |
130 | </section> | 146 | </section> |
131 | 147 | ||
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 309d791e4e26..e6e3ec7141bf 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
@@ -803,13 +803,38 @@ static struct { | |||
803 | }; | 803 | }; |
804 | 804 | ||
805 | /** | 805 | /** |
806 | * show_protocols() - shows the current IR protocol(s) | 806 | * struct rc_filter_attribute - Device attribute relating to a filter type. |
807 | * @attr: Device attribute. | ||
808 | * @type: Filter type. | ||
809 | * @mask: false for filter value, true for filter mask. | ||
810 | */ | ||
811 | struct rc_filter_attribute { | ||
812 | struct device_attribute attr; | ||
813 | enum rc_filter_type type; | ||
814 | bool mask; | ||
815 | }; | ||
816 | #define to_rc_filter_attr(a) container_of(a, struct rc_filter_attribute, attr) | ||
817 | |||
818 | #define RC_PROTO_ATTR(_name, _mode, _show, _store, _type) \ | ||
819 | struct rc_filter_attribute dev_attr_##_name = { \ | ||
820 | .attr = __ATTR(_name, _mode, _show, _store), \ | ||
821 | .type = (_type), \ | ||
822 | } | ||
823 | #define RC_FILTER_ATTR(_name, _mode, _show, _store, _type, _mask) \ | ||
824 | struct rc_filter_attribute dev_attr_##_name = { \ | ||
825 | .attr = __ATTR(_name, _mode, _show, _store), \ | ||
826 | .type = (_type), \ | ||
827 | .mask = (_mask), \ | ||
828 | } | ||
829 | |||
830 | /** | ||
831 | * show_protocols() - shows the current/wakeup IR protocol(s) | ||
807 | * @device: the device descriptor | 832 | * @device: the device descriptor |
808 | * @mattr: the device attribute struct (unused) | 833 | * @mattr: the device attribute struct (unused) |
809 | * @buf: a pointer to the output buffer | 834 | * @buf: a pointer to the output buffer |
810 | * | 835 | * |
811 | * This routine is a callback routine for input read the IR protocol type(s). | 836 | * This routine is a callback routine for input read the IR protocol type(s). |
812 | * it is trigged by reading /sys/class/rc/rc?/protocols. | 837 | * it is trigged by reading /sys/class/rc/rc?/[wakeup_]protocols. |
813 | * It returns the protocol names of supported protocols. | 838 | * It returns the protocol names of supported protocols. |
814 | * Enabled protocols are printed in brackets. | 839 | * Enabled protocols are printed in brackets. |
815 | * | 840 | * |
@@ -820,6 +845,7 @@ static ssize_t show_protocols(struct device *device, | |||
820 | struct device_attribute *mattr, char *buf) | 845 | struct device_attribute *mattr, char *buf) |
821 | { | 846 | { |
822 | struct rc_dev *dev = to_rc_dev(device); | 847 | struct rc_dev *dev = to_rc_dev(device); |
848 | struct rc_filter_attribute *fattr = to_rc_filter_attr(mattr); | ||
823 | u64 allowed, enabled; | 849 | u64 allowed, enabled; |
824 | char *tmp = buf; | 850 | char *tmp = buf; |
825 | int i; | 851 | int i; |
@@ -830,9 +856,10 @@ static ssize_t show_protocols(struct device *device, | |||
830 | 856 | ||
831 | mutex_lock(&dev->lock); | 857 | mutex_lock(&dev->lock); |
832 | 858 | ||
833 | enabled = dev->enabled_protocols[RC_FILTER_NORMAL]; | 859 | enabled = dev->enabled_protocols[fattr->type]; |
834 | if (dev->driver_type == RC_DRIVER_SCANCODE) | 860 | if (dev->driver_type == RC_DRIVER_SCANCODE || |
835 | allowed = dev->allowed_protocols[RC_FILTER_NORMAL]; | 861 | fattr->type == RC_FILTER_WAKEUP) |
862 | allowed = dev->allowed_protocols[fattr->type]; | ||
836 | else if (dev->raw) | 863 | else if (dev->raw) |
837 | allowed = ir_raw_get_allowed_protocols(); | 864 | allowed = ir_raw_get_allowed_protocols(); |
838 | else { | 865 | else { |
@@ -864,14 +891,14 @@ static ssize_t show_protocols(struct device *device, | |||
864 | } | 891 | } |
865 | 892 | ||
866 | /** | 893 | /** |
867 | * store_protocols() - changes the current IR protocol(s) | 894 | * store_protocols() - changes the current/wakeup IR protocol(s) |
868 | * @device: the device descriptor | 895 | * @device: the device descriptor |
869 | * @mattr: the device attribute struct (unused) | 896 | * @mattr: the device attribute struct (unused) |
870 | * @buf: a pointer to the input buffer | 897 | * @buf: a pointer to the input buffer |
871 | * @len: length of the input buffer | 898 | * @len: length of the input buffer |
872 | * | 899 | * |
873 | * This routine is for changing the IR protocol type. | 900 | * This routine is for changing the IR protocol type. |
874 | * It is trigged by writing to /sys/class/rc/rc?/protocols. | 901 | * It is trigged by writing to /sys/class/rc/rc?/[wakeup_]protocols. |
875 | * Writing "+proto" will add a protocol to the list of enabled protocols. | 902 | * Writing "+proto" will add a protocol to the list of enabled protocols. |
876 | * Writing "-proto" will remove a protocol from the list of enabled protocols. | 903 | * Writing "-proto" will remove a protocol from the list of enabled protocols. |
877 | * Writing "proto" will enable only "proto". | 904 | * Writing "proto" will enable only "proto". |
@@ -888,12 +915,14 @@ static ssize_t store_protocols(struct device *device, | |||
888 | size_t len) | 915 | size_t len) |
889 | { | 916 | { |
890 | struct rc_dev *dev = to_rc_dev(device); | 917 | struct rc_dev *dev = to_rc_dev(device); |
918 | struct rc_filter_attribute *fattr = to_rc_filter_attr(mattr); | ||
891 | bool enable, disable; | 919 | bool enable, disable; |
892 | const char *tmp; | 920 | const char *tmp; |
893 | u64 type; | 921 | u64 type; |
894 | u64 mask; | 922 | u64 mask; |
895 | int rc, i, count = 0; | 923 | int rc, i, count = 0; |
896 | ssize_t ret; | 924 | ssize_t ret; |
925 | int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); | ||
897 | 926 | ||
898 | /* Device is being removed */ | 927 | /* Device is being removed */ |
899 | if (!dev) | 928 | if (!dev) |
@@ -906,7 +935,7 @@ static ssize_t store_protocols(struct device *device, | |||
906 | ret = -EINVAL; | 935 | ret = -EINVAL; |
907 | goto out; | 936 | goto out; |
908 | } | 937 | } |
909 | type = dev->enabled_protocols[RC_FILTER_NORMAL]; | 938 | type = dev->enabled_protocols[fattr->type]; |
910 | 939 | ||
911 | while ((tmp = strsep((char **) &data, " \n")) != NULL) { | 940 | while ((tmp = strsep((char **) &data, " \n")) != NULL) { |
912 | if (!*tmp) | 941 | if (!*tmp) |
@@ -954,8 +983,10 @@ static ssize_t store_protocols(struct device *device, | |||
954 | goto out; | 983 | goto out; |
955 | } | 984 | } |
956 | 985 | ||
957 | if (dev->change_protocol) { | 986 | change_protocol = (fattr->type == RC_FILTER_NORMAL) |
958 | rc = dev->change_protocol(dev, &type); | 987 | ? dev->change_protocol : dev->change_wakeup_protocol; |
988 | if (change_protocol) { | ||
989 | rc = change_protocol(dev, &type); | ||
959 | if (rc < 0) { | 990 | if (rc < 0) { |
960 | IR_dprintk(1, "Error setting protocols to 0x%llx\n", | 991 | IR_dprintk(1, "Error setting protocols to 0x%llx\n", |
961 | (long long)type); | 992 | (long long)type); |
@@ -964,7 +995,7 @@ static ssize_t store_protocols(struct device *device, | |||
964 | } | 995 | } |
965 | } | 996 | } |
966 | 997 | ||
967 | dev->enabled_protocols[RC_FILTER_NORMAL] = type; | 998 | dev->enabled_protocols[fattr->type] = type; |
968 | IR_dprintk(1, "Current protocol(s): 0x%llx\n", | 999 | IR_dprintk(1, "Current protocol(s): 0x%llx\n", |
969 | (long long)type); | 1000 | (long long)type); |
970 | 1001 | ||
@@ -976,26 +1007,6 @@ out: | |||
976 | } | 1007 | } |
977 | 1008 | ||
978 | /** | 1009 | /** |
979 | * struct rc_filter_attribute - Device attribute relating to a filter type. | ||
980 | * @attr: Device attribute. | ||
981 | * @type: Filter type. | ||
982 | * @mask: false for filter value, true for filter mask. | ||
983 | */ | ||
984 | struct rc_filter_attribute { | ||
985 | struct device_attribute attr; | ||
986 | enum rc_filter_type type; | ||
987 | bool mask; | ||
988 | }; | ||
989 | #define to_rc_filter_attr(a) container_of(a, struct rc_filter_attribute, attr) | ||
990 | |||
991 | #define RC_FILTER_ATTR(_name, _mode, _show, _store, _type, _mask) \ | ||
992 | struct rc_filter_attribute dev_attr_##_name = { \ | ||
993 | .attr = __ATTR(_name, _mode, _show, _store), \ | ||
994 | .type = (_type), \ | ||
995 | .mask = (_mask), \ | ||
996 | } | ||
997 | |||
998 | /** | ||
999 | * show_filter() - shows the current scancode filter value or mask | 1010 | * show_filter() - shows the current scancode filter value or mask |
1000 | * @device: the device descriptor | 1011 | * @device: the device descriptor |
1001 | * @attr: the device attribute struct | 1012 | * @attr: the device attribute struct |
@@ -1128,8 +1139,10 @@ static int rc_dev_uevent(struct device *device, struct kobj_uevent_env *env) | |||
1128 | /* | 1139 | /* |
1129 | * Static device attribute struct with the sysfs attributes for IR's | 1140 | * Static device attribute struct with the sysfs attributes for IR's |
1130 | */ | 1141 | */ |
1131 | static DEVICE_ATTR(protocols, S_IRUGO | S_IWUSR, | 1142 | static RC_PROTO_ATTR(protocols, S_IRUGO | S_IWUSR, |
1132 | show_protocols, store_protocols); | 1143 | show_protocols, store_protocols, RC_FILTER_NORMAL); |
1144 | static RC_PROTO_ATTR(wakeup_protocols, S_IRUGO | S_IWUSR, | ||
1145 | show_protocols, store_protocols, RC_FILTER_WAKEUP); | ||
1133 | static RC_FILTER_ATTR(filter, S_IRUGO|S_IWUSR, | 1146 | static RC_FILTER_ATTR(filter, S_IRUGO|S_IWUSR, |
1134 | show_filter, store_filter, RC_FILTER_NORMAL, false); | 1147 | show_filter, store_filter, RC_FILTER_NORMAL, false); |
1135 | static RC_FILTER_ATTR(filter_mask, S_IRUGO|S_IWUSR, | 1148 | static RC_FILTER_ATTR(filter_mask, S_IRUGO|S_IWUSR, |
@@ -1140,7 +1153,8 @@ static RC_FILTER_ATTR(wakeup_filter_mask, S_IRUGO|S_IWUSR, | |||
1140 | show_filter, store_filter, RC_FILTER_WAKEUP, true); | 1153 | show_filter, store_filter, RC_FILTER_WAKEUP, true); |
1141 | 1154 | ||
1142 | static struct attribute *rc_dev_attrs[] = { | 1155 | static struct attribute *rc_dev_attrs[] = { |
1143 | &dev_attr_protocols.attr, | 1156 | &dev_attr_protocols.attr.attr, |
1157 | &dev_attr_wakeup_protocols.attr.attr, | ||
1144 | &dev_attr_filter.attr.attr, | 1158 | &dev_attr_filter.attr.attr, |
1145 | &dev_attr_filter_mask.attr.attr, | 1159 | &dev_attr_filter_mask.attr.attr, |
1146 | &dev_attr_wakeup_filter.attr.attr, | 1160 | &dev_attr_wakeup_filter.attr.attr, |
diff --git a/include/media/rc-core.h b/include/media/rc-core.h index f165115597f5..0b9f890ce431 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h | |||
@@ -97,6 +97,8 @@ enum rc_filter_type { | |||
97 | * @tx_resolution: resolution (in ns) of output sampler | 97 | * @tx_resolution: resolution (in ns) of output sampler |
98 | * @scancode_filters: scancode filters (indexed by enum rc_filter_type) | 98 | * @scancode_filters: scancode filters (indexed by enum rc_filter_type) |
99 | * @change_protocol: allow changing the protocol used on hardware decoders | 99 | * @change_protocol: allow changing the protocol used on hardware decoders |
100 | * @change_wakeup_protocol: allow changing the protocol used for wakeup | ||
101 | * filtering | ||
100 | * @open: callback to allow drivers to enable polling/irq when IR input device | 102 | * @open: callback to allow drivers to enable polling/irq when IR input device |
101 | * is opened. | 103 | * is opened. |
102 | * @close: callback to allow drivers to disable polling/irq when IR input device | 104 | * @close: callback to allow drivers to disable polling/irq when IR input device |
@@ -145,6 +147,7 @@ struct rc_dev { | |||
145 | u32 tx_resolution; | 147 | u32 tx_resolution; |
146 | struct rc_scancode_filter scancode_filters[RC_FILTER_MAX]; | 148 | struct rc_scancode_filter scancode_filters[RC_FILTER_MAX]; |
147 | int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); | 149 | int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); |
150 | int (*change_wakeup_protocol)(struct rc_dev *dev, u64 *rc_type); | ||
148 | int (*open)(struct rc_dev *dev); | 151 | int (*open)(struct rc_dev *dev); |
149 | void (*close)(struct rc_dev *dev); | 152 | void (*close)(struct rc_dev *dev); |
150 | int (*s_tx_mask)(struct rc_dev *dev, u32 mask); | 153 | int (*s_tx_mask)(struct rc_dev *dev, u32 mask); |