diff options
author | David Härdeman | 2012-10-12 00:11:54 +0200 |
---|---|---|
committer | Mauro Carvalho Chehab | 2012-10-27 15:49:51 +0200 |
commit | c003ab1bedf028db15b0185b683d5c387204e8f5 (patch) | |
tree | 00f608e80e897589492eb2274c46ffb9fde769cf /drivers/media/usb/em28xx/em28xx-input.c | |
parent | [media] media/ir_rx51: use module_platform_driver macro (diff) | |
download | kernel-qcow2-linux-c003ab1bedf028db15b0185b683d5c387204e8f5.tar.gz kernel-qcow2-linux-c003ab1bedf028db15b0185b683d5c387204e8f5.tar.xz kernel-qcow2-linux-c003ab1bedf028db15b0185b683d5c387204e8f5.zip |
[media] rc-core: add separate defines for protocol bitmaps and numbers
The RC_TYPE_* defines are currently used both where a single protocol is
expected and where a bitmap of protocols is expected.
Functions like rc_keydown() and functions which add/remove entries to the
keytable want a single protocol. Future userspace APIs would also
benefit from numeric protocols (rather than bitmap ones). Keytables are
smaller if they can use a small(ish) integer rather than a bitmap.
Other functions or struct members (e.g. allowed_protos,
enabled_protocols, etc) accept multiple protocols and need a bitmap.
Using different types reduces the risk of programmer error. Using a
protocol enum whereever possible also makes for a more future-proof
user-space API as we don't need to worry about a sufficient number of
bits being available (e.g. in structs used for ioctl() calls).
The use of both a number and a corresponding bit is dalso one in e.g.
the input subsystem as well (see all the references to set/clear bit when
changing keytables for example).
This patch separate the different usages in preparation for
upcoming patches.
Where a single protocol is expected, enum rc_type is used; where one or more
protocol(s) are expected, something like u64 is used.
The patch has been rewritten so that the format of the sysfs "protocols"
file is no longer altered (at the loss of some detail). The file itself
should probably be deprecated in the future though.
Signed-off-by: David Härdeman <david@hardeman.nu>
Cc: Andy Walls <awalls@md.metrocast.net>
Cc: Maxim Levitsky <maximlevitsky@gmail.com>
Cc: Antti Palosaari <crope@iki.fi>
Cc: Mike Isely <isely@pobox.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/usb/em28xx/em28xx-input.c')
-rw-r--r-- | drivers/media/usb/em28xx/em28xx-input.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c index 97d36b4f19db..660bf803c9e4 100644 --- a/drivers/media/usb/em28xx/em28xx-input.c +++ b/drivers/media/usb/em28xx/em28xx-input.c @@ -345,7 +345,7 @@ static void em28xx_ir_stop(struct rc_dev *rc) cancel_delayed_work_sync(&ir->work); } -static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 rc_type) +static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 *rc_type) { int rc = 0; struct em28xx_IR *ir = rc_dev->priv; @@ -354,14 +354,16 @@ static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 rc_type) /* Adjust xclk based o IR table for RC5/NEC tables */ - if (rc_type == RC_TYPE_RC5) { + if (*rc_type & RC_BIT_RC5) { dev->board.xclk |= EM28XX_XCLK_IR_RC5_MODE; ir->full_code = 1; - } else if (rc_type == RC_TYPE_NEC) { + *rc_type = RC_BIT_RC5; + } else if (*rc_type & RC_BIT_NEC) { dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE; ir_config = EM2874_IR_NEC; ir->full_code = 1; - } else if (rc_type != RC_TYPE_UNKNOWN) + *rc_type = RC_BIT_NEC; + } else if (*rc_type != RC_BIT_UNKNOWN) rc = -EINVAL; em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk, @@ -524,6 +526,7 @@ static int em28xx_ir_init(struct em28xx *dev) struct em28xx_IR *ir; struct rc_dev *rc; int err = -ENOMEM; + u64 rc_type; if (dev->board.ir_codes == NULL) { /* No remote control support */ @@ -546,14 +549,15 @@ static int em28xx_ir_init(struct em28xx *dev) * em2874 supports more protocols. For now, let's just announce * the two protocols that were already tested */ - rc->allowed_protos = RC_TYPE_RC5 | RC_TYPE_NEC; + rc->allowed_protos = RC_BIT_RC5 | RC_BIT_NEC; rc->priv = ir; rc->change_protocol = em28xx_ir_change_protocol; rc->open = em28xx_ir_start; rc->close = em28xx_ir_stop; /* By default, keep protocol field untouched */ - err = em28xx_ir_change_protocol(rc, RC_TYPE_UNKNOWN); + rc_type = RC_BIT_UNKNOWN; + err = em28xx_ir_change_protocol(rc, &rc_type); if (err) goto err_out_free; |