aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2014-02-28 18:17:05 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-11 12:28:20 -0400
commitab88c66deace78989aa71cb139284cf7fb227ba4 (patch)
tree26f8bb54eddd1fc41ba758ab5c2c70c5ca553d53 /drivers/media/rc
parentacff5f24732acc8a55d0a0f0ee1d19442267df63 (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>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r--drivers/media/rc/rc-main.c82
1 files changed, 48 insertions, 34 deletions
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 */
811struct 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 */
984struct 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 */
1131static DEVICE_ATTR(protocols, S_IRUGO | S_IWUSR, 1142static RC_PROTO_ATTR(protocols, S_IRUGO | S_IWUSR,
1132 show_protocols, store_protocols); 1143 show_protocols, store_protocols, RC_FILTER_NORMAL);
1144static RC_PROTO_ATTR(wakeup_protocols, S_IRUGO | S_IWUSR,
1145 show_protocols, store_protocols, RC_FILTER_WAKEUP);
1133static RC_FILTER_ATTR(filter, S_IRUGO|S_IWUSR, 1146static 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);
1135static RC_FILTER_ATTR(filter_mask, S_IRUGO|S_IWUSR, 1148static 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
1142static struct attribute *rc_dev_attrs[] = { 1155static 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,