diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-04 10:38:08 -0700 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2010-08-04 10:38:08 -0700 |
commit | f63b759c44b0561c76a67894c734157df3313b42 (patch) | |
tree | 4e9638f6c1aa5c0faa62ad4213282cc7cb39772a /drivers/media/IR/ir-jvc-decoder.c | |
parent | 4a35cee066df1b1958e25e71595b3845d06b192e (diff) | |
parent | 844a9e93d7fcd910cd94f6eb262e2cc43cacbe56 (diff) |
Merge branch 'v4l_for_2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6
* 'v4l_for_2.6.35' of git://git.kernel.org/pub/scm/linux/kernel/git/mchehab/linux-2.6: (243 commits)
V4L/DVB: sms: Convert IR support to use the Remote Controller core
V4L/DVB: sms: properly initialize IR phys and IR name
V4L/DVB: standardize names at rc-dib0700 tables
V4L/DVB: smsusb: enable IR port for Hauppauge WinTV MiniStick
V4L/DVB: dib0700: Fix RC protocol logic to properly handle NEC/NECx and RC-5
V4L/DVB: dib0700: properly implement IR change_protocol
V4L/DVB: dib0700: break keytable into NEC and RC-5 variants
V4L/DVB: dib0700: avoid bad repeat
V4L/DVB: Port dib0700 to rc-core
V4L/DVB: Add a keymap file with dib0700 table
V4L/DVB: dvb-usb: add support for rc-core mode
V4L/DVB: dvb-usb: prepare drivers for using rc-core
V4L/DVB: dvb-usb: get rid of struct dvb_usb_rc_key
V4L/DVB: rj54n1cb0c: fix a comment in the driver
V4L/DVB: V4L2: sh_vou: VOU does support the full PAL resolution too
V4L/DVB: V4L2: sh_mobile_camera_ceu: add support for CSI2
V4L/DVB: V4L2: soc-camera: add a MIPI CSI-2 driver for SH-Mobile platforms
V4L/DVB: V4L2: soc-camera: export soc-camera bus type for notifications
V4L/DVB: V4L2: mediabus: add 12-bit Bayer and YUV420 pixel formats
V4L/DVB: mediabus: fix ambiguous pixel code names
...
Diffstat (limited to 'drivers/media/IR/ir-jvc-decoder.c')
-rw-r--r-- | drivers/media/IR/ir-jvc-decoder.c | 152 |
1 files changed, 9 insertions, 143 deletions
diff --git a/drivers/media/IR/ir-jvc-decoder.c b/drivers/media/IR/ir-jvc-decoder.c index 0b804944cbb..8894d8b3604 100644 --- a/drivers/media/IR/ir-jvc-decoder.c +++ b/drivers/media/IR/ir-jvc-decoder.c @@ -25,10 +25,6 @@ #define JVC_TRAILER_PULSE (1 * JVC_UNIT) #define JVC_TRAILER_SPACE (35 * JVC_UNIT) -/* Used to register jvc_decoder clients */ -static LIST_HEAD(decoder_list); -DEFINE_SPINLOCK(decoder_lock); - enum jvc_state { STATE_INACTIVE, STATE_HEADER_SPACE, @@ -38,87 +34,6 @@ enum jvc_state { STATE_TRAILER_SPACE, }; -struct decoder_data { - struct list_head list; - struct ir_input_dev *ir_dev; - int enabled:1; - - /* State machine control */ - enum jvc_state state; - u16 jvc_bits; - u16 jvc_old_bits; - unsigned count; - bool first; - bool toggle; -}; - - -/** - * get_decoder_data() - gets decoder data - * @input_dev: input device - * - * Returns the struct decoder_data that corresponds to a device - */ -static struct decoder_data *get_decoder_data(struct ir_input_dev *ir_dev) -{ - struct decoder_data *data = NULL; - - spin_lock(&decoder_lock); - list_for_each_entry(data, &decoder_list, list) { - if (data->ir_dev == ir_dev) - break; - } - spin_unlock(&decoder_lock); - return data; -} - -static ssize_t store_enabled(struct device *d, - struct device_attribute *mattr, - const char *buf, - size_t len) -{ - unsigned long value; - struct ir_input_dev *ir_dev = dev_get_drvdata(d); - struct decoder_data *data = get_decoder_data(ir_dev); - - if (!data) - return -EINVAL; - - if (strict_strtoul(buf, 10, &value) || value > 1) - return -EINVAL; - - data->enabled = value; - - return len; -} - -static ssize_t show_enabled(struct device *d, - struct device_attribute *mattr, char *buf) -{ - struct ir_input_dev *ir_dev = dev_get_drvdata(d); - struct decoder_data *data = get_decoder_data(ir_dev); - - if (!data) - return -EINVAL; - - if (data->enabled) - return sprintf(buf, "1\n"); - else - return sprintf(buf, "0\n"); -} - -static DEVICE_ATTR(enabled, S_IRUGO | S_IWUSR, show_enabled, store_enabled); - -static struct attribute *decoder_attributes[] = { - &dev_attr_enabled.attr, - NULL -}; - -static struct attribute_group decoder_attribute_group = { - .name = "jvc_decoder", - .attrs = decoder_attributes, -}; - /** * ir_jvc_decode() - Decode one JVC pulse or space * @input_dev: the struct input_dev descriptor of the device @@ -128,14 +43,10 @@ static struct attribute_group decoder_attribute_group = { */ static int ir_jvc_decode(struct input_dev *input_dev, struct ir_raw_event ev) { - struct decoder_data *data; struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); + struct jvc_dec *data = &ir_dev->raw->jvc; - data = get_decoder_data(ir_dev); - if (!data) - return -EINVAL; - - if (!data->enabled) + if (!(ir_dev->raw->enabled_protocols & IR_TYPE_JVC)) return 0; if (IS_RESET(ev)) { @@ -188,9 +99,9 @@ static int ir_jvc_decode(struct input_dev *input_dev, struct ir_raw_event ev) if (ev.pulse) break; - data->jvc_bits <<= 1; + data->bits <<= 1; if (eq_margin(ev.duration, JVC_BIT_1_SPACE, JVC_UNIT / 2)) { - data->jvc_bits |= 1; + data->bits |= 1; decrease_duration(&ev, JVC_BIT_1_SPACE); } else if (eq_margin(ev.duration, JVC_BIT_0_SPACE, JVC_UNIT / 2)) decrease_duration(&ev, JVC_BIT_0_SPACE); @@ -223,13 +134,13 @@ static int ir_jvc_decode(struct input_dev *input_dev, struct ir_raw_event ev) if (data->first) { u32 scancode; - scancode = (bitrev8((data->jvc_bits >> 8) & 0xff) << 8) | - (bitrev8((data->jvc_bits >> 0) & 0xff) << 0); + scancode = (bitrev8((data->bits >> 8) & 0xff) << 8) | + (bitrev8((data->bits >> 0) & 0xff) << 0); IR_dprintk(1, "JVC scancode 0x%04x\n", scancode); ir_keydown(input_dev, scancode, data->toggle); data->first = false; - data->jvc_old_bits = data->jvc_bits; - } else if (data->jvc_bits == data->jvc_old_bits) { + data->old_bits = data->bits; + } else if (data->bits == data->old_bits) { IR_dprintk(1, "JVC repeat\n"); ir_repeat(input_dev); } else { @@ -249,54 +160,9 @@ out: return -EINVAL; } -static int ir_jvc_register(struct input_dev *input_dev) -{ - struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); - struct decoder_data *data; - int rc; - - rc = sysfs_create_group(&ir_dev->dev.kobj, &decoder_attribute_group); - if (rc < 0) - return rc; - - data = kzalloc(sizeof(*data), GFP_KERNEL); - if (!data) { - sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group); - return -ENOMEM; - } - - data->ir_dev = ir_dev; - data->enabled = 1; - - spin_lock(&decoder_lock); - list_add_tail(&data->list, &decoder_list); - spin_unlock(&decoder_lock); - - return 0; -} - -static int ir_jvc_unregister(struct input_dev *input_dev) -{ - struct ir_input_dev *ir_dev = input_get_drvdata(input_dev); - static struct decoder_data *data; - - data = get_decoder_data(ir_dev); - if (!data) - return 0; - - sysfs_remove_group(&ir_dev->dev.kobj, &decoder_attribute_group); - - spin_lock(&decoder_lock); - list_del(&data->list); - spin_unlock(&decoder_lock); - - return 0; -} - static struct ir_raw_handler jvc_handler = { + .protocols = IR_TYPE_JVC, .decode = ir_jvc_decode, - .raw_register = ir_jvc_register, - .raw_unregister = ir_jvc_unregister, }; static int __init ir_jvc_decode_init(void) |