diff options
author | David Härdeman <david@hardeman.nu> | 2014-04-04 18:06:01 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <m.chehab@samsung.com> | 2014-04-06 10:30:25 -0400 |
commit | 23c843b5eb11198e7de3a2af0756d1f897117932 (patch) | |
tree | 9a6a57b60b9d048f105d8585c1e84b0e2d4a3bc0 /drivers/media | |
parent | 42f5e630e06326fa47b3ba86e572b51c36b0a3b1 (diff) |
[media] rc-core: split dev->s_filter
Overloading dev->s_filter to do two different functions (set wakeup filters
and generic hardware filters) makes it impossible to tell what the
hardware actually supports, so create a separate dev->s_wakeup_filter and
make the distinction explicit.
Signed-off-by: David Härdeman <david@hardeman.nu>
Acked-by: James Hogan <james.hogan@imgtec.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media')
-rw-r--r-- | drivers/media/rc/img-ir/img-ir-hw.c | 15 | ||||
-rw-r--r-- | drivers/media/rc/rc-main.c | 24 |
2 files changed, 31 insertions, 8 deletions
diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c index 579a52b3edce..0127dd257a57 100644 --- a/drivers/media/rc/img-ir/img-ir-hw.c +++ b/drivers/media/rc/img-ir/img-ir-hw.c | |||
@@ -504,6 +504,18 @@ unlock: | |||
504 | return ret; | 504 | return ret; |
505 | } | 505 | } |
506 | 506 | ||
507 | static int img_ir_set_normal_filter(struct rc_dev *dev, | ||
508 | struct rc_scancode_filter *sc_filter) | ||
509 | { | ||
510 | return img_ir_set_filter(dev, RC_FILTER_NORMAL, sc_filter); | ||
511 | } | ||
512 | |||
513 | static int img_ir_set_wakeup_filter(struct rc_dev *dev, | ||
514 | struct rc_scancode_filter *sc_filter) | ||
515 | { | ||
516 | return img_ir_set_filter(dev, RC_FILTER_WAKEUP, sc_filter); | ||
517 | } | ||
518 | |||
507 | /** | 519 | /** |
508 | * img_ir_set_decoder() - Set the current decoder. | 520 | * img_ir_set_decoder() - Set the current decoder. |
509 | * @priv: IR private data. | 521 | * @priv: IR private data. |
@@ -986,7 +998,8 @@ int img_ir_probe_hw(struct img_ir_priv *priv) | |||
986 | rdev->map_name = RC_MAP_EMPTY; | 998 | rdev->map_name = RC_MAP_EMPTY; |
987 | rc_set_allowed_protocols(rdev, img_ir_allowed_protos(priv)); | 999 | rc_set_allowed_protocols(rdev, img_ir_allowed_protos(priv)); |
988 | rdev->input_name = "IMG Infrared Decoder"; | 1000 | rdev->input_name = "IMG Infrared Decoder"; |
989 | rdev->s_filter = img_ir_set_filter; | 1001 | rdev->s_filter = img_ir_set_normal_filter; |
1002 | rdev->s_wakeup_filter = img_ir_set_wakeup_filter; | ||
990 | 1003 | ||
991 | /* Register hardware decoder */ | 1004 | /* Register hardware decoder */ |
992 | error = rc_register_device(rdev); | 1005 | error = rc_register_device(rdev); |
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 99697aae92ff..ecbc20c4252e 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c | |||
@@ -923,6 +923,7 @@ static ssize_t store_protocols(struct device *device, | |||
923 | int rc, i, count = 0; | 923 | int rc, i, count = 0; |
924 | ssize_t ret; | 924 | ssize_t ret; |
925 | int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); | 925 | int (*change_protocol)(struct rc_dev *dev, u64 *rc_type); |
926 | int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter *filter); | ||
926 | struct rc_scancode_filter local_filter, *filter; | 927 | struct rc_scancode_filter local_filter, *filter; |
927 | 928 | ||
928 | /* Device is being removed */ | 929 | /* Device is being removed */ |
@@ -1007,24 +1008,27 @@ static ssize_t store_protocols(struct device *device, | |||
1007 | * Fall back to clearing the filter. | 1008 | * Fall back to clearing the filter. |
1008 | */ | 1009 | */ |
1009 | filter = &dev->scancode_filters[fattr->type]; | 1010 | filter = &dev->scancode_filters[fattr->type]; |
1011 | set_filter = (fattr->type == RC_FILTER_NORMAL) | ||
1012 | ? dev->s_filter : dev->s_wakeup_filter; | ||
1013 | |||
1010 | if (old_type != type && filter->mask) { | 1014 | if (old_type != type && filter->mask) { |
1011 | local_filter = *filter; | 1015 | local_filter = *filter; |
1012 | if (!type) { | 1016 | if (!type) { |
1013 | /* no protocol => clear filter */ | 1017 | /* no protocol => clear filter */ |
1014 | ret = -1; | 1018 | ret = -1; |
1015 | } else if (!dev->s_filter) { | 1019 | } else if (!set_filter) { |
1016 | /* generic filtering => accept any filter */ | 1020 | /* generic filtering => accept any filter */ |
1017 | ret = 0; | 1021 | ret = 0; |
1018 | } else { | 1022 | } else { |
1019 | /* hardware filtering => try setting, otherwise clear */ | 1023 | /* hardware filtering => try setting, otherwise clear */ |
1020 | ret = dev->s_filter(dev, fattr->type, &local_filter); | 1024 | ret = set_filter(dev, &local_filter); |
1021 | } | 1025 | } |
1022 | if (ret < 0) { | 1026 | if (ret < 0) { |
1023 | /* clear the filter */ | 1027 | /* clear the filter */ |
1024 | local_filter.data = 0; | 1028 | local_filter.data = 0; |
1025 | local_filter.mask = 0; | 1029 | local_filter.mask = 0; |
1026 | if (dev->s_filter) | 1030 | if (set_filter) |
1027 | dev->s_filter(dev, fattr->type, &local_filter); | 1031 | set_filter(dev, &local_filter); |
1028 | } | 1032 | } |
1029 | 1033 | ||
1030 | /* commit the new filter */ | 1034 | /* commit the new filter */ |
@@ -1106,6 +1110,7 @@ static ssize_t store_filter(struct device *device, | |||
1106 | struct rc_scancode_filter local_filter, *filter; | 1110 | struct rc_scancode_filter local_filter, *filter; |
1107 | int ret; | 1111 | int ret; |
1108 | unsigned long val; | 1112 | unsigned long val; |
1113 | int (*set_filter)(struct rc_dev *dev, struct rc_scancode_filter *filter); | ||
1109 | 1114 | ||
1110 | /* Device is being removed */ | 1115 | /* Device is being removed */ |
1111 | if (!dev) | 1116 | if (!dev) |
@@ -1115,8 +1120,11 @@ static ssize_t store_filter(struct device *device, | |||
1115 | if (ret < 0) | 1120 | if (ret < 0) |
1116 | return ret; | 1121 | return ret; |
1117 | 1122 | ||
1123 | set_filter = (fattr->type == RC_FILTER_NORMAL) ? dev->s_filter : | ||
1124 | dev->s_wakeup_filter; | ||
1125 | |||
1118 | /* Scancode filter not supported (but still accept 0) */ | 1126 | /* Scancode filter not supported (but still accept 0) */ |
1119 | if (!dev->s_filter && fattr->type != RC_FILTER_NORMAL) | 1127 | if (!set_filter && fattr->type == RC_FILTER_WAKEUP) |
1120 | return val ? -EINVAL : count; | 1128 | return val ? -EINVAL : count; |
1121 | 1129 | ||
1122 | mutex_lock(&dev->lock); | 1130 | mutex_lock(&dev->lock); |
@@ -1128,13 +1136,15 @@ static ssize_t store_filter(struct device *device, | |||
1128 | local_filter.mask = val; | 1136 | local_filter.mask = val; |
1129 | else | 1137 | else |
1130 | local_filter.data = val; | 1138 | local_filter.data = val; |
1139 | |||
1131 | if (!dev->enabled_protocols[fattr->type] && local_filter.mask) { | 1140 | if (!dev->enabled_protocols[fattr->type] && local_filter.mask) { |
1132 | /* refuse to set a filter unless a protocol is enabled */ | 1141 | /* refuse to set a filter unless a protocol is enabled */ |
1133 | ret = -EINVAL; | 1142 | ret = -EINVAL; |
1134 | goto unlock; | 1143 | goto unlock; |
1135 | } | 1144 | } |
1136 | if (dev->s_filter) { | 1145 | |
1137 | ret = dev->s_filter(dev, fattr->type, &local_filter); | 1146 | if (set_filter) { |
1147 | ret = set_filter(dev, &local_filter); | ||
1138 | if (ret < 0) | 1148 | if (ret < 0) |
1139 | goto unlock; | 1149 | goto unlock; |
1140 | } | 1150 | } |