IR: few fixes, additions and ENE driver
Subsystems (3)
cover IR: few fixes, additions and ENE driver
Hi,
This is first version of ported ENE driver to ir-core In meanwhile I fixed few bugs, added few things.
Comments are welcome!
Best regards,
Maxim Levitsky
PATCH 1/9 IR: Kconfig fixes
Move IR drives below separate menu.
This allows to disable them.
Also correct a typo.
--- drivers/media/IR/Kconfig | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)
drivers/media/IR/Kconfig +11 -3
@@ -1,8 +1,10 @@ -config IR_CORE - tristate +menuconfig IR_CORE + tristate "Infrared remote controller adapters" depends on INPUT default INPUT +if IR_CORE + config VIDEO_IR tristate depends on IR_CORE
@@ -16,7 +18,7 @@ config LIRC Enable this option to build the Linux Infrared Remote Control (LIRC) core device interface driver. The LIRC interface passes raw IR to and from userspace, where the - LIRC daemon handles protocol decoding for IR reception ann + LIRC daemon handles protocol decoding for IR reception and encoding for IR transmitting (aka "blasting"). source "drivers/media/IR/keymaps/Kconfig"
@@ -102,3 +104,9 @@ config IR_MCEUSB To compile this driver as a module, choose M here: the module will be called mceusb. + + + + + +endif #IR_CORE
Signature · 1 line
1.7.0.4
PATCH 4/9 IR: add helper functions for ir input devices that send ir timing data in small chunks, and alternation between pulses and spaces isn't guaranteed.
In reply to Maxim Levitsky--- drivers/media/IR/ir-core-priv.h | 1 + drivers/media/IR/ir-keytable.c | 2 +- drivers/media/IR/ir-raw-event.c | 86 +++++++++++++++++++++++++++++++++++++++ include/media/ir-core.h | 24 +++++++++- 4 files changed, 109 insertions(+), 4 deletions(-)
drivers/media/IR/ir-core-priv.h +1 -0
@@ -36,6 +36,7 @@ struct ir_raw_event_ctrl {struct kfifo kfifo;/* fifo for the pulse/space durations */ ktime_t last_event;/* when last event occurred */ enum raw_event_type last_type;/* last event type */ +struct ir_raw_event current_sample;/* sample that is not yet pushed to fifo */ struct input_dev *input_dev;/* pointer to the parent input_dev */ u64 enabled_protocols;/* enabled raw protocol decoders */
drivers/media/IR/ir-keytable.c +1 -1
@@ -428,7 +428,7 @@ static void ir_close(struct input_dev *input_dev)*/ int __ir_input_register (struct input_dev *input_dev,const struct ir_scancode_table *rc_tab, -const struct ir_dev_props *props, +struct ir_dev_props *props,const char *driver_name) {struct ir_input_dev *ir_dev;
drivers/media/IR/ir-raw-event.c +86 -0
92 lines not on this page · raw message
include/media/ir-core.h +21 -3
@@ -41,6 +41,9 @@ enum rc_driver_type {* anything with it. Yet, as the same keycode table can be used with other * devices, a mask is provided to allow its usage. Drivers should generally * leave this field in blank +* @timeout: optional time after which device stops sending data +* @min_timeout: minimum timeout supported by device +* @max_timeout: maximum timeout supported by device * @priv: driver-specific data, to be used on the callbacks * @change_protocol: allow changing the protocol used on hardware decoders * @open: callback to allow drivers to enable polling/irq when IR input device
@@ -50,11 +53,19 @@ enum rc_driver_type {* @s_tx_mask: set transmitter mask (for devices with multiple tx outputs) * @s_tx_carrier: set transmit carrier frequency * @tx_ir: transmit IR +* @s_idle: optional: enable/disable hardware idle mode, upon which, +device doesn't interrupt host untill it sees IR data */ struct ir_dev_props {enum rc_driver_type driver_type;unsigned long allowed_protos;u32 scanmask; + +u64 timeout; +u64 min_timeout; +u64 max_timeout; + +void *priv;int (*change_protocol)(void *priv,u64 ir_type);int (*open)(void *priv);
@@ -62,6 +73,7 @@ struct ir_dev_props {int (*s_tx_mask)(void *priv,u32 mask);int (*s_tx_carrier)(void *priv,u32 carrier);int (*tx_ir)(void *priv,int *txbuf,u32 n); +void (*s_idle) (void *priv,int enable); };struct ir_input_dev {
@@ -69,9 +81,10 @@ struct ir_input_dev {char *driver_name;/* Name of the driver module */ struct ir_scancode_table rc_tab;/* scan/key table */ unsigned long devno;/* device number */ -const struct ir_dev_props *props;/* Device properties */ +struct ir_dev_props *props;/* Device properties */ struct ir_raw_event_ctrl *raw;/* for raw pulse/space events */ struct input_dev *input_dev;/* the input device associated with this device */ +int idle;/* key info - needed by IR keycode handlers */ spinlock_t keylock;/* protects the below members */
@@ -95,12 +108,12 @@ enum raw_event_type {/* From ir-keytable.c */ int __ir_input_register (struct input_dev *dev,const struct ir_scancode_table *ir_codes, -const struct ir_dev_props *props, +struct ir_dev_props *props,const char *driver_name);static inline int ir_input_register (struct input_dev *dev,const char *map_name, -const struct ir_dev_props *props, +struct ir_dev_props *props,const char *driver_name) {struct ir_scancode_table *ir_codes;struct ir_input_dev *ir_dev;
@@ -144,6 +157,11 @@ struct ir_raw_event {void ir_raw_event_handle (struct input_dev *input_dev);int ir_raw_event_store (struct input_dev *input_dev,struct ir_raw_event *ev);int ir_raw_event_store_edge (struct input_dev *input_dev,enum raw_event_type type); +int ir_raw_event_store_with_filter (struct input_dev *input_dev, +struct ir_raw_event *ev); + +void ir_raw_event_set_idle (struct input_dev *input_dev,int idle); +static inline void ir_raw_event_reset (struct input_dev *input_dev) {struct ir_raw_event ev = { .pulse = false, .duration =0 };
Signature · 1 line
1.7.0.4
PATCH 7/9 IR: actualy report unknown scancodes the in-kernel decoders found.
In reply to Maxim LevitskyThis way it is possible to use evtest to create keymap for unknown remote. (Providing that in-kernel decoding understands remote's protocol. Hint: it doesn't....)
--- drivers/media/IR/ir-keytable.c | 5 +++++ 1 files changed, 5 insertions(+), 0 deletions(-)
drivers/media/IR/ir-keytable.c +5 -0
@@ -383,9 +383,12 @@ void ir_keydown(struct input_dev *dev, int scancode, u8 toggle) ir->last_toggle = toggle; ir->last_keycode = keycode; +input_event (dev,EV_MSC ,MSC_SCAN , scancode); +if (keycode ==KEY_RESERVED ) goto out; +/* Register a keypress */ ir->keypressed = true; IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n",
@@ -480,6 +483,8 @@ int __ir_input_register(struct input_dev *input_dev,set_bit (EV_KEY , input_dev->evbit);set_bit (EV_REP , input_dev->evbit); +set_bit (EV_MSC , input_dev->evbit); +set_bit (MSC_SCAN , input_dev->mscbit);if (ir_setkeytable (input_dev, &ir_dev->rc_tab, rc_tab)) { rc = -ENOMEM ;
Signature · 1 line
1.7.0.4
PATCH 8/9 IR: Add ENE input driver.
In reply to Maxim Levitsky--- drivers/media/IR/Kconfig | 11 + drivers/media/IR/Makefile | 1 + drivers/media/IR/ene_ir.c | 1019 +++++++++++++++++++++++++++++++++++++++++++++ drivers/media/IR/ene_ir.h | 228 ++++++++++ 4 files changed, 1259 insertions(+), 0 deletions(-) create mode 100644 drivers/media/IR/ene_ir.c create mode 100644 drivers/media/IR/ene_ir.h
drivers/media/IR/Kconfig +11 -0
@@ -105,8 +105,19 @@ config IR_MCEUSB To compile this driver as a module, choose M here: the module will be called mceusb. +config IR_ENE + tristate "ENE eHome Receiver/Transciever (pnp id: ENE0100/ENE02xxx)" + depends on PNP + depends on IR_CORE + ---help--- + Say Y here to enable support for integrated infrared receiver + /transciever made by ENE. + You can see if you have it by looking at lspnp output. + Output should include ENE0100 ENE0200 or something similiar. + To compile this driver as a module, choose M here: the + module will be called ene_ir. endif #IR_CORE
drivers/media/IR/Makefile +1 -0
@@ -16,3 +16,4 @@ obj-$(CONFIG_IR_LIRC_CODEC) += ir-lirc-codec.o # stand-alone IR receivers/transmitters obj-$(CONFIG_IR_IMON) += imon.o obj-$(CONFIG_IR_MCEUSB) += mceusb.o +obj-$(CONFIG_IR_ENE) += ene_ir.o
drivers/media/IR/ene_ir.c new file +1019 -0
1,019 lines not on this page · raw message
drivers/media/IR/ene_ir.h new file +228 -0
228 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 9/9 STAGING: remove ENE driver.
In reply to Maxim LevitskyNow there is ported version of this driver, staging version is redundand and obsolete
--- drivers/staging/lirc/Kconfig | 8 - drivers/staging/lirc/Makefile | 1 - drivers/staging/lirc/lirc_ene0100.c | 646 ----------------------------------- drivers/staging/lirc/lirc_ene0100.h | 169 --------- 4 files changed, 0 insertions(+), 824 deletions(-) delete mode 100644 drivers/staging/lirc/lirc_ene0100.c delete mode 100644 drivers/staging/lirc/lirc_ene0100.h
drivers/staging/lirc/Kconfig +0 -8
@@ -17,14 +17,6 @@ config LIRC_BT829 help Driver for the IR interface on BT829-based hardware -config LIRC_ENE0100 - tristate "ENE KB3924/ENE0100 CIR Port Reciever" - depends on LIRC_STAGING - help - This is a driver for CIR port handled by ENE KB3924 embedded - controller found on some notebooks. - It appears on PNP list as ENE0100. - config LIRC_I2C tristate "I2C Based IR Receivers" depends on LIRC_STAGING
drivers/staging/lirc/Makefile +0 -1
@@ -4,7 +4,6 @@ # Each configuration option enables a list of files. obj-$(CONFIG_LIRC_BT829) += lirc_bt829.o -obj-$(CONFIG_LIRC_ENE0100) += lirc_ene0100.o obj-$(CONFIG_LIRC_I2C) += lirc_i2c.o obj-$(CONFIG_LIRC_IGORPLUGUSB) += lirc_igorplugusb.o obj-$(CONFIG_LIRC_IMON) += lirc_imon.o
drivers/staging/lirc/lirc_ene0100.c deleted +0 -646
646 lines not on this page · raw message
drivers/staging/lirc/lirc_ene0100.h deleted +0 -169
169 lines not on this page · raw message
Signature · 1 line
1.7.0.4
PATCH 2/9 IR: minor fixes:
In reply to Maxim Levitsky* lirc: Don't propagate reset event to userspace
* lirc: Remove strange logic from lirc that would make first sample always be pulse
* Make TO_US macro actualy print what it should.
--- drivers/media/IR/ir-core-priv.h | 3 +-- drivers/media/IR/ir-lirc-codec.c | 14 ++++++++------ drivers/media/IR/ir-raw-event.c | 3 +++ 3 files changed, 12 insertions(+), 8 deletions(-)
drivers/media/IR/ir-core-priv.h +1 -2
@@ -76,7 +76,6 @@ struct ir_raw_event_ctrl {struct lirc_codec {struct ir_input_dev *ir_dev;struct lirc_driver *drv; -int lircdata; } lirc; };
@@ -104,7 +103,7 @@ static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration) ev->duration -= duration; } -#define TO_US (duration) (((duration) + 500) / 1000) +#define TO_US (duration) ((duration) / 1000)#define TO_STR (is_pulse) ((is_pulse) ? "pulse" : "space")#define IS_RESET (ev) (ev.duration == 0)
drivers/media/IR/ir-lirc-codec.c +8 -6
@@ -32,6 +32,7 @@static int ir_lirc_decode (struct input_dev *input_dev,struct ir_raw_event ev) {struct ir_input_dev *ir_dev =input_get_drvdata (input_dev); +int sample;if (!(ir_dev->raw->enabled_protocols &IR_TYPE_LIRC ))return 0 ;
@@ -39,18 +40,21 @@ static int ir_lirc_decode(struct input_dev *input_dev, struct ir_raw_event ev)if (!ir_dev->raw->lirc.drv || !ir_dev->raw->lirc.drv->rbuf)return -EINVAL ; +if (IS_RESET (ev)) +return 0 ; +IR_dprintk (2 ,"LIRC data transfer started (%uus %s)\n" ,TO_US (ev.duration),TO_STR (ev.pulse)); - ir_dev->raw->lirc.lircdata += ev.duration /1000 ; + + sample = ev.duration /1000 ;if (ev.pulse) - ir_dev->raw->lirc.lircdata |=PULSE_BIT ; + sample |=PULSE_BIT ;lirc_buffer_write (ir_dev->raw->lirc.drv->rbuf, - (unsigned char *) &ir_dev->raw->lirc.lircdata); + (unsigned char *) &sample);wake_up (&ir_dev->raw->lirc.drv->rbuf->wait_poll); - ir_dev->raw->lirc.lircdata =0 ;return 0 ; }
@@ -224,8 +228,6 @@ static int ir_lirc_register(struct input_dev *input_dev) ir_dev->raw->lirc.drv = drv; ir_dev->raw->lirc.ir_dev = ir_dev; - ir_dev->raw->lirc.lircdata =PULSE_MASK ; -return 0 ; lirc_register_failed:
drivers/media/IR/ir-raw-event.c +3 -0
@@ -66,6 +66,9 @@ int ir_raw_event_store(struct input_dev *input_dev, struct ir_raw_event *ev)if (!ir->raw)return -EINVAL ; +IR_dprintk (2 ,"sample: (05%dus %s)\n" ,TO_US (ev->duration), +TO_STR (ev->pulse)); +if (kfifo_in (&ir->raw->kfifo, ev,sizeof (*ev)) !=sizeof (*ev))return -ENOMEM ;
Signature · 1 line
1.7.0.4
PATCH 3/9 IR: replace spinlock with mutex.
In reply to Maxim LevitskySome handlers (lirc for example) allocates memory on initialization, doing so in atomic context is cumbersome.
Fixes warning about sleeping function in atomic context.
--- drivers/media/IR/ir-raw-event.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-)
drivers/media/IR/ir-raw-event.c +14 -14
@@ -13,7 +13,7 @@*/ #include <linux/workqueue.h> -#include <linux/spinlock.h> +#include <linux/mutex.h> #include <linux/sched.h> #include "ir-core-priv.h"
@@ -24,7 +24,7 @@static LIST_HEAD (ir_raw_client_list);/* Used to handle IR raw handler extensions */ -static DEFINE_SPINLOCK (ir_raw_handler_lock); +static DEFINE_MUTEX (ir_raw_handler_lock);static LIST_HEAD (ir_raw_handler_list);static u64 available_protocols;
@@ -41,10 +41,10 @@ static void ir_raw_event_work(struct work_struct *work) container_of(work, struct ir_raw_event_ctrl, rx_work);while (kfifo_out (&raw->kfifo, &ev,sizeof (ev)) ==sizeof (ev)) { -spin_lock (&ir_raw_handler_lock); +mutex_lock (&ir_raw_handler_lock);list_for_each_entry (handler, &ir_raw_handler_list, list) handler->decode (raw->input_dev, ev); -spin_unlock (&ir_raw_handler_lock); +mutex_unlock (&ir_raw_handler_lock); raw->prev_ev = ev; } }
@@ -150,9 +150,9 @@ u64 ir_raw_get_allowed_protocols() {u64 protocols; -spin_lock (&ir_raw_handler_lock); +mutex_lock (&ir_raw_handler_lock); protocols = available_protocols; -spin_unlock (&ir_raw_handler_lock); +mutex_unlock (&ir_raw_handler_lock);return protocols; }
@@ -180,12 +180,12 @@ int ir_raw_event_register(struct input_dev *input_dev)return rc; } -spin_lock (&ir_raw_handler_lock); +mutex_lock (&ir_raw_handler_lock);list_add_tail (&ir->raw->list, &ir_raw_client_list);list_for_each_entry (handler, &ir_raw_handler_list, list)if (handler->raw_register) handler->raw_register (ir->raw->input_dev); -spin_unlock (&ir_raw_handler_lock); +mutex_unlock (&ir_raw_handler_lock);return 0 ; }
@@ -200,12 +200,12 @@ void ir_raw_event_unregister(struct input_dev *input_dev)cancel_work_sync (&ir->raw->rx_work); -spin_lock (&ir_raw_handler_lock); +mutex_lock (&ir_raw_handler_lock);list_del (&ir->raw->list);list_for_each_entry (handler, &ir_raw_handler_list, list)if (handler->raw_unregister) handler->raw_unregister (ir->raw->input_dev); -spin_unlock (&ir_raw_handler_lock); +mutex_unlock (&ir_raw_handler_lock);kfifo_free (&ir->raw->kfifo);kfree (ir->raw);
@@ -220,13 +220,13 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler) {struct ir_raw_event_ctrl *raw; -spin_lock (&ir_raw_handler_lock); +mutex_lock (&ir_raw_handler_lock);list_add_tail (&ir_raw_handler->list, &ir_raw_handler_list);if (ir_raw_handler->raw_register)list_for_each_entry (raw, &ir_raw_client_list, list) ir_raw_handler->raw_register (raw->input_dev); available_protocols |= ir_raw_handler->protocols; -spin_unlock (&ir_raw_handler_lock); +mutex_unlock (&ir_raw_handler_lock);return 0 ; }
@@ -236,13 +236,13 @@ void ir_raw_handler_unregister(struct ir_raw_handler *ir_raw_handler) {struct ir_raw_event_ctrl *raw; -spin_lock (&ir_raw_handler_lock); +mutex_lock (&ir_raw_handler_lock);list_del (&ir_raw_handler->list);if (ir_raw_handler->raw_unregister)list_for_each_entry (raw, &ir_raw_client_list, list) ir_raw_handler->raw_unregister (raw->input_dev); available_protocols &= ~ir_raw_handler->protocols; -spin_unlock (&ir_raw_handler_lock); +mutex_unlock (&ir_raw_handler_lock); }EXPORT_SYMBOL (ir_raw_handler_unregister);
Signature · 1 line
1.7.0.4
PATCH 5/9 IR: extend interfaces to support more device settings
In reply to Maxim LevitskyAlso reuse LIRC_SET_MEASURE_CARRIER_MODE as LIRC_SET_LEARN_MODE (LIRC_SET_LEARN_MODE will start carrier reports if possible, and tune receiver to wide band mode)
This IOCTL isn't yet used by lirc, so this won't break userspace.
--- drivers/media/IR/ir-core-priv.h | 2 + drivers/media/IR/ir-lirc-codec.c | 100 ++++++++++++++++++++++++++++++++++---- include/media/ir-core.h | 11 ++++ include/media/lirc.h | 4 +- 4 files changed, 105 insertions(+), 12 deletions(-)
drivers/media/IR/ir-core-priv.h +2 -0
@@ -77,6 +77,8 @@ struct ir_raw_event_ctrl {struct lirc_codec {struct ir_input_dev *ir_dev;struct lirc_driver *drv; +int timeout_report; +int carrier_low; } lirc; };
drivers/media/IR/ir-lirc-codec.c +90 -10
150 lines not on this page · raw message
include/media/ir-core.h +11 -0
@@ -44,6 +44,8 @@ enum rc_driver_type {* @timeout: optional time after which device stops sending data * @min_timeout: minimum timeout supported by device * @max_timeout: maximum timeout supported by device +* @rx_resolution : resolution (in ns) of input sampler +* @tx_resolution: resolution (in ns) of output sampler * @priv: driver-specific data, to be used on the callbacks * @change_protocol: allow changing the protocol used on hardware decoders * @open: callback to allow drivers to enable polling/irq when IR input device
@@ -52,9 +54,12 @@ enum rc_driver_type {* is opened. * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs) * @s_tx_carrier: set transmit carrier frequency +* @s_tx_duty_cycle: set transmit duty cycle (0% - 100%) +* @s_rx_carrier: inform driver about carrier it is expected to handle * @tx_ir: transmit IR * @s_idle: optional: enable/disable hardware idle mode, upon which, device doesn't interrupt host untill it sees IR data +* @s_learning_mode: enable learning mode */ struct ir_dev_props {enum rc_driver_type driver_type;
@@ -65,6 +70,8 @@ struct ir_dev_props {u64 min_timeout;u64 max_timeout; +u32 rx_resolution; +u32 tx_resolution;void *priv;int (*change_protocol)(void *priv,u64 ir_type);
@@ -72,8 +79,12 @@ struct ir_dev_props {void (*close)(void *priv);int (*s_tx_mask)(void *priv,u32 mask);int (*s_tx_carrier)(void *priv,u32 carrier); +int (*s_tx_duty_cycle) (void *priv,u32 duty_cycle); +int (*s_rx_carrier_range) (void *priv,u32 min,u32 max);int (*tx_ir)(void *priv,int *txbuf,u32 n);void (*s_idle) (void *priv,int enable); +int (*s_learning_mode) (void *priv,int enable); + };struct ir_input_dev {
include/media/lirc.h +2 -2
@@ -76,7 +76,7 @@#define LIRC_CAN_SET_REC_TIMEOUT 0x10000000#define LIRC_CAN_SET_REC_FILTER 0x08000000 -#define LIRC_CAN_MEASURE_CARRIER 0x02000000 +#define LIRC_CAN_LEARN_MODE 0x02000000#define LIRC_CAN_SEND (x) ((x)&LIRC_CAN_SEND_MASK)#define LIRC_CAN_REC (x) ((x)&LIRC_CAN_REC_MASK)
@@ -145,7 +145,7 @@* if enabled from the next key press on the driver will send * LIRC_MODE2_FREQUENCY packets */ -#define LIRC_SET_MEASURE_CARRIER_MODE _IOW('i', 0x0000001d, __u32) +#define LIRC_SET_LEARN_MODE _IOW('i', 0x0000001d, __u32)/* * to set a range use
Signature · 1 line
1.7.0.4
PATCH 6/9 IR: actually allow not to compile keymaps in..
In reply to Maxim LevitskyCurrntly, ir device registration fails if keymap requested by driver is not found... Fix that by always compiling in the empty keymap, and using it as a failback
--- drivers/media/IR/ir-core-priv.h | 3 +- drivers/media/IR/ir-sysfs.c | 2 + drivers/media/IR/keymaps/Makefile | 1 - drivers/media/IR/keymaps/rc-empty.c | 44 ----------------------------------- drivers/media/IR/rc-map.c | 23 ++++++++++++++++++ include/media/ir-core.h | 8 ++++- 6 files changed, 33 insertions(+), 48 deletions(-) delete mode 100644 drivers/media/IR/keymaps/rc-empty.c
drivers/media/IR/ir-core-priv.h +2 -1
@@ -128,7 +128,8 @@ int ir_raw_handler_register(struct ir_raw_handler *ir_raw_handler);void ir_raw_handler_unregister (struct ir_raw_handler *ir_raw_handler);void ir_raw_init (void ); - +int ir_rcmap_init (void ); +void ir_rcmap_cleanup (void );/* * Decoder initialization code *
drivers/media/IR/ir-sysfs.c +2 -0
@@ -341,6 +341,7 @@ static int __init ir_core_init(void)/* Initialize/load the decoders/keymap code that will be used */ ir_raw_init (); +ir_rcmap_init ();return 0 ; }
@@ -348,6 +349,7 @@ static int __init ir_core_init(void) static void __exit ir_core_exit(void) {class_unregister (&ir_input_class); +ir_rcmap_cleanup (); }module_init (ir_core_init);
drivers/media/IR/keymaps/Makefile +0 -1
@@ -17,7 +17,6 @@ obj-$(CONFIG_RC_MAP) += rc-adstech-dvb-t-pci.o \ rc-dm1105-nec.o \ rc-dntv-live-dvb-t.o \ rc-dntv-live-dvbt-pro.o \ - rc-empty.o \ rc-em-terratec.o \ rc-encore-enltv2.o \ rc-encore-enltv.o \
drivers/media/IR/keymaps/rc-empty.c deleted +0 -44
44 lines not on this page · raw message
drivers/media/IR/rc-map.c +23 -0
@@ -82,3 +82,26 @@ void ir_unregister_map(struct rc_keymap *map) }EXPORT_SYMBOL_GPL (ir_unregister_map); + +static struct ir_scancode empty[] = { + {0x2a ,KEY_COFFEE }, +}; + +static struct rc_keymap empty_map = { + .map = { + .scan = empty, + .size =ARRAY_SIZE (empty), + .ir_type =IR_TYPE_UNKNOWN ,/* Legacy IR type */ + .name =RC_MAP_EMPTY , + } +}; + +int ir_rcmap_init (void ) +{ +return ir_register_map (&empty_map); +} + +void ir_rcmap_cleanup (void ) +{ +ir_unregister_map (&empty_map); +}
include/media/ir-core.h +6 -2
@@ -134,8 +134,12 @@ static inline int ir_input_register(struct input_dev *dev,return -EINVAL ; ir_codes =get_rc_map (map_name); -if (!ir_codes) -return -EINVAL ; +if (!ir_codes) { + ir_codes =get_rc_map (RC_MAP_EMPTY ); + +if (!ir_codes) +return -EINVAL ; + } rc =__ir_input_register (dev, ir_codes, props, driver_name);if (rc <0 )
Signature · 1 line
1.7.0.4
Re: [PATCH 2/9] IR: minor fixes:
In reply to Maxim LevitskyEm 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 24 lines
* lirc: Don't propagate reset event to userspace
* lirc: Remove strange logic from lirc that would make first sample always be pulse
* MakeTO_USmacro actualy print what it should.Signed-off-by Maxim Levitsky <[email protected]>--- drivers/media/IR/ir-core-priv.h | 3 +-- drivers/media/IR/ir-lirc-codec.c | 14 ++++++++------ drivers/media/IR/ir-raw-event.c | 3 +++ 3 files changed, 12 insertions(+), 8 deletions(-)drivers/media/IR/ir-core-priv.h +0
-1@@ -76,7 +76,6 @@ struct ir_raw_event_ctrl {struct lirc_codec {struct ir_input_dev *ir_dev;struct lirc_driver *drv; -int lircdata; } lirc; };
drivers/media/IR/ir-core-priv.h static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration) · line 106
Quoted 5 lines
drivers/media/IR/ir-core-priv.h +1
-1@@ -104,7 +103,7 @@ static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration) ev->duration -= duration; } -#define TO_US (duration) (((duration) + 500) / 1000) +#define TO_US (duration) ((duration) / 1000)
It is better to keep rounding the duration to its closest value.
Cheers,
Mauro
Re: [PATCH 3/9] IR: replace spinlock with mutex.
In reply to Maxim LevitskyEm 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 3 lines
Some handlers (lirc for example) allocates memory on initialization, doing so in atomic context is cumbersome.
Fixes warning about sleeping function in atomic context.
You should not replace it by a mutex, as the decoding code may happen during IRQ time on several drivers.
If lirc is allocating memory, it should be using GFP_ATOMIC to avoid sleeping.
Cheers,
Mauro
Re: [PATCH 4/9] IR: add helper functions for ir input devices that send ir timing data in small chunks, and alternation between pulses and spaces isn't guaranteed.
In reply to Maxim LevitskyEm 28-07-2010 12:14, Maxim Levitsky escreveu:
Please provide a smaller subject. Feel free to add a more detailed description, but subjects longer then 74 bytes end by causing some troubles when using git commands.
It would be nice to have a good description on this patch, as it provides a method for working around troubles found on problematic devices.
Quoted 25 lines
Signed-off-by Maxim Levitsky <[email protected]>--- drivers/media/IR/ir-core-priv.h | 1 + drivers/media/IR/ir-keytable.c | 2 +- drivers/media/IR/ir-raw-event.c | 86 +++++++++++++++++++++++++++++++++++++++ include/media/ir-core.h | 24 +++++++++- 4 files changed, 109 insertions(+), 4 deletions(-)drivers/media/IR/ir-core-priv.h +1
-0@@ -36,6 +36,7 @@ struct ir_raw_event_ctrl {struct kfifo kfifo;/* fifo for the pulse/space durations */ ktime_t last_event;/* when last event occurred */ enum raw_event_type last_type;/* last event type */ +struct ir_raw_event current_sample;/* sample that is not yet pushed to fifo */ struct input_dev *input_dev;/* pointer to the parent input_dev */ u64 enabled_protocols;/* enabled raw protocol decoders */ drivers/media/IR/ir-keytable.c +0
-0
drivers/media/IR/ir-keytable.c static void ir_close(struct input_dev *input_dev) · line 434
Quoted 8 lines
drivers/media/IR/ir-keytable.c +1
-1@@ -428,7 +428,7 @@ static void ir_close(struct input_dev *input_dev)*/ int __ir_input_register (struct input_dev *input_dev,const struct ir_scancode_table *rc_tab, -const struct ir_dev_props *props, +struct ir_dev_props *props,const char *driver_name) {struct ir_input_dev *ir_dev;
Hmm... why are you removing "const" from ir_dev_props? This change seems unrelated with the patch description.
Quoted 178 lines
drivers/media/IR/ir-raw-event.c +86
-0@@ -129,6 +129,92 @@ int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type typEXPORT_SYMBOL_GPL (ir_raw_event_store_edge);/** +* ir_raw_event_store_with_filter() - pass next pulse/space to decoders with some processing +* @input_dev: the struct input_dev device descriptor +* @type: the type of the event that has occurred +* +* This routine (which may be called from an interrupt context) is used to +* store the beginning of an ir pulse or space (or the start/end of ir +* reception) for the raw ir decoding state machines.\ +* This routine is intended for devices with limited internal buffer +* It automerges samples of same type, and handles timeouts +*/ +int ir_raw_event_store_with_filter (struct input_dev *input_dev, +struct ir_raw_event *ev) +{ +struct ir_input_dev *ir =input_get_drvdata (input_dev); +struct ir_raw_event_ctrl *raw = ir->raw; + +if (!ir->raw || !ir->props) +return -EINVAL ; + +/* Ignore spaces in idle mode */ +if (ir->idle && !ev->pulse) +return 0 ; +else if (ir->idle) +ir_raw_event_set_idle (input_dev,0 ); + +if (!raw->current_sample.duration) { + raw->current_sample = *ev; + }else if (ev->pulse == raw->current_sample.pulse) { + raw->current_sample.duration += ev->duration; + }else { +ir_raw_event_store (input_dev, &raw->current_sample); + raw->current_sample = *ev; + } + +/* Enter idle mode if nessesary */ +if (!ev->pulse && ir->props->timeout && + raw->current_sample.duration >= ir->props->timeout) +ir_raw_event_set_idle (input_dev,1 ); +return 0 ; +} +EXPORT_SYMBOL_GPL (ir_raw_event_store_with_filter); + + +void ir_raw_event_set_idle (struct input_dev *input_dev,int idle) +{ +struct ir_input_dev *ir =input_get_drvdata (input_dev); +struct ir_raw_event_ctrl *raw = ir->raw; +ktime_t now; +u64 delta; + +if (!ir->props) +return ; + +if (!ir->raw) + goto out; + +if (idle) { +IR_dprintk (2 ,"enter idle mode\n" ); + raw->last_event =ktime_get (); + }else { +IR_dprintk (2 ,"exit idle mode\n" ); + + now =ktime_get (); + delta =ktime_to_ns (ktime_sub (now, ir->raw->last_event)); + +WARN_ON (raw->current_sample.pulse); + + raw->current_sample.duration = +min (raw->current_sample.duration + delta, + (u64 )IR_MAX_DURATION ); + +ir_raw_event_store (input_dev, &raw->current_sample); + +if (raw->current_sample.duration ==IR_MAX_DURATION ) +ir_raw_event_reset (input_dev); + + raw->current_sample.duration =0 ; + } +out: +if (ir->props->s_idle) + ir->props->s_idle (ir->props->priv, idle); + ir->idle = idle; +} +EXPORT_SYMBOL_GPL (ir_raw_event_set_idle); + +/** * ir_raw_event_handle() - schedules the decoding of stored ir data * @input_dev: the struct input_dev device descriptor * include/media/ir-core.h +21
-3@@ -41,6 +41,9 @@ enum rc_driver_type {* anything with it. Yet, as the same keycode table can be used with other * devices, a mask is provided to allow its usage. Drivers should generally * leave this field in blank +* @timeout: optional time after which device stops sending data +* @min_timeout: minimum timeout supported by device +* @max_timeout: maximum timeout supported by device * @priv: driver-specific data, to be used on the callbacks * @change_protocol: allow changing the protocol used on hardware decoders * @open: callback to allow drivers to enable polling/irq when IR input device @@ -50,11 +53,19 @@ enum rc_driver_type {* @s_tx_mask: set transmitter mask (for devices with multiple tx outputs) * @s_tx_carrier: set transmit carrier frequency * @tx_ir: transmit IR +* @s_idle: optional: enable/disable hardware idle mode, upon which, +device doesn't interrupt host untill it sees IR data */ struct ir_dev_props {enum rc_driver_type driver_type;unsigned long allowed_protos;u32 scanmask; + +u64 timeout; +u64 min_timeout; +u64 max_timeout; + +void *priv;int (*change_protocol)(void *priv,u64 ir_type);int (*open)(void *priv);@@ -62,6 +73,7 @@ struct ir_dev_props {int (*s_tx_mask)(void *priv,u32 mask);int (*s_tx_carrier)(void *priv,u32 carrier);int (*tx_ir)(void *priv,int *txbuf,u32 n); +void (*s_idle) (void *priv,int enable); };struct ir_input_dev {@@ -69,9 +81,10 @@ struct ir_input_dev {char *driver_name;/* Name of the driver module */ struct ir_scancode_table rc_tab;/* scan/key table */ unsigned long devno;/* device number */ -const struct ir_dev_props *props;/* Device properties */ +struct ir_dev_props *props;/* Device properties */ struct ir_raw_event_ctrl *raw;/* for raw pulse/space events */ struct input_dev *input_dev;/* the input device associated with this device */ +int idle;/* key info - needed by IR keycode handlers */ spinlock_t keylock;/* protects the below members */ @@ -95,12 +108,12 @@ enum raw_event_type {/* From ir-keytable.c */ int __ir_input_register (struct input_dev *dev,const struct ir_scancode_table *ir_codes, -const struct ir_dev_props *props, +struct ir_dev_props *props,const char *driver_name);static inline int ir_input_register (struct input_dev *dev,const char *map_name, -const struct ir_dev_props *props, +struct ir_dev_props *props,const char *driver_name) {struct ir_scancode_table *ir_codes;struct ir_input_dev *ir_dev;@@ -144,6 +157,11 @@ struct ir_raw_event {void ir_raw_event_handle (struct input_dev *input_dev);int ir_raw_event_store (struct input_dev *input_dev,struct ir_raw_event *ev);int ir_raw_event_store_edge (struct input_dev *input_dev,enum raw_event_type type); +int ir_raw_event_store_with_filter (struct input_dev *input_dev, +struct ir_raw_event *ev); + +void ir_raw_event_set_idle (struct input_dev *input_dev,int idle); +static inline void ir_raw_event_reset (struct input_dev *input_dev) {struct ir_raw_event ev = { .pulse = false, .duration =0 };
Re: [PATCH 4/9] IR: add helper functions for ir input devices that send ir timing data in small chunks, and alternation between pulses and spaces isn't guaranteed.
Quoted 4 lines · Mauro Carvalho Chehab
Em 28-07-2010 12:14, Maxim Levitsky escreveu:
Please provide a smaller subject. Feel free to add a more detailed description, but subjects longer then 74 bytes end by causing some troubles when using git commands.
I didn't intend that, I just keep forgetting to add a newline between subject and description..
Quoted 24 lines
It would be nice to have a good description on this patch, as it provides a method for working around troubles found on problematic devices.
Quoted 20 lines
Signed-off-by Maxim Levitsky <[email protected]>--- drivers/media/IR/ir-core-priv.h | 1 + drivers/media/IR/ir-keytable.c | 2 +- drivers/media/IR/ir-raw-event.c | 86 +++++++++++++++++++++++++++++++++++++++ include/media/ir-core.h | 24 +++++++++- 4 files changed, 109 insertions(+), 4 deletions(-)drivers/media/IR/ir-core-priv.h +1
-0@@ -36,6 +36,7 @@ struct ir_raw_event_ctrl {struct kfifo kfifo;/* fifo for the pulse/space durations */ ktime_t last_event;/* when last event occurred */ enum raw_event_type last_type;/* last event type */ +struct ir_raw_event current_sample;/* sample that is not yet pushed to fifo */ struct input_dev *input_dev;/* pointer to the parent input_dev */ u64 enabled_protocols;/* enabled raw protocol decoders */
Quoted 16 lines
drivers/media/IR/ir-keytable.c static void ir_close(struct input_dev *input_dev) · line 434
Quoted 13 lines
drivers/media/IR/ir-keytable.c +1
-1@@ -428,7 +428,7 @@ static void ir_close(struct input_dev *input_dev)*/ int __ir_input_register (struct input_dev *input_dev,const struct ir_scancode_table *rc_tab, -const struct ir_dev_props *props, +struct ir_dev_props *props,const char *driver_name) {struct ir_input_dev *ir_dev;Hmm... why are you removing "const" from
ir_dev_props? This change seems unrelated with the patch description.
Because I add new field 'timeout' I intend to change it in runtime by the driver.
Best regards,
Maxim Levitsky
Quoted 180 lines
Quoted 179 lines
drivers/media/IR/ir-raw-event.c +86
-0@@ -129,6 +129,92 @@ int ir_raw_event_store_edge(struct input_dev *input_dev, enum raw_event_type typEXPORT_SYMBOL_GPL (ir_raw_event_store_edge);/** +* ir_raw_event_store_with_filter() - pass next pulse/space to decoders with some processing +* @input_dev: the struct input_dev device descriptor +* @type: the type of the event that has occurred +* +* This routine (which may be called from an interrupt context) is used to +* store the beginning of an ir pulse or space (or the start/end of ir +* reception) for the raw ir decoding state machines.\ +* This routine is intended for devices with limited internal buffer +* It automerges samples of same type, and handles timeouts +*/ +int ir_raw_event_store_with_filter (struct input_dev *input_dev, +struct ir_raw_event *ev) +{ +struct ir_input_dev *ir =input_get_drvdata (input_dev); +struct ir_raw_event_ctrl *raw = ir->raw; + +if (!ir->raw || !ir->props) +return -EINVAL ; + +/* Ignore spaces in idle mode */ +if (ir->idle && !ev->pulse) +return 0 ; +else if (ir->idle) +ir_raw_event_set_idle (input_dev,0 ); + +if (!raw->current_sample.duration) { + raw->current_sample = *ev; + }else if (ev->pulse == raw->current_sample.pulse) { + raw->current_sample.duration += ev->duration; + }else { +ir_raw_event_store (input_dev, &raw->current_sample); + raw->current_sample = *ev; + } + +/* Enter idle mode if nessesary */ +if (!ev->pulse && ir->props->timeout && + raw->current_sample.duration >= ir->props->timeout) +ir_raw_event_set_idle (input_dev,1 ); +return 0 ; +} +EXPORT_SYMBOL_GPL (ir_raw_event_store_with_filter); + + +void ir_raw_event_set_idle (struct input_dev *input_dev,int idle) +{ +struct ir_input_dev *ir =input_get_drvdata (input_dev); +struct ir_raw_event_ctrl *raw = ir->raw; +ktime_t now; +u64 delta; + +if (!ir->props) +return ; + +if (!ir->raw) + goto out; + +if (idle) { +IR_dprintk (2 ,"enter idle mode\n" ); + raw->last_event =ktime_get (); + }else { +IR_dprintk (2 ,"exit idle mode\n" ); + + now =ktime_get (); + delta =ktime_to_ns (ktime_sub (now, ir->raw->last_event)); + +WARN_ON (raw->current_sample.pulse); + + raw->current_sample.duration = +min (raw->current_sample.duration + delta, + (u64 )IR_MAX_DURATION ); + +ir_raw_event_store (input_dev, &raw->current_sample); + +if (raw->current_sample.duration ==IR_MAX_DURATION ) +ir_raw_event_reset (input_dev); + + raw->current_sample.duration =0 ; + } +out: +if (ir->props->s_idle) + ir->props->s_idle (ir->props->priv, idle); + ir->idle = idle; +} +EXPORT_SYMBOL_GPL (ir_raw_event_set_idle); + +/** * ir_raw_event_handle() - schedules the decoding of stored ir data * @input_dev: the struct input_dev device descriptor * include/media/ir-core.h +21
-3@@ -41,6 +41,9 @@ enum rc_driver_type {* anything with it. Yet, as the same keycode table can be used with other * devices, a mask is provided to allow its usage. Drivers should generally * leave this field in blank +* @timeout: optional time after which device stops sending data +* @min_timeout: minimum timeout supported by device +* @max_timeout: maximum timeout supported by device * @priv: driver-specific data, to be used on the callbacks * @change_protocol: allow changing the protocol used on hardware decoders * @open: callback to allow drivers to enable polling/irq when IR input device @@ -50,11 +53,19 @@ enum rc_driver_type {* @s_tx_mask: set transmitter mask (for devices with multiple tx outputs) * @s_tx_carrier: set transmit carrier frequency * @tx_ir: transmit IR +* @s_idle: optional: enable/disable hardware idle mode, upon which, +device doesn't interrupt host untill it sees IR data */ struct ir_dev_props {enum rc_driver_type driver_type;unsigned long allowed_protos;u32 scanmask; + +u64 timeout; +u64 min_timeout; +u64 max_timeout; + +void *priv;int (*change_protocol)(void *priv,u64 ir_type);int (*open)(void *priv);@@ -62,6 +73,7 @@ struct ir_dev_props {int (*s_tx_mask)(void *priv,u32 mask);int (*s_tx_carrier)(void *priv,u32 carrier);int (*tx_ir)(void *priv,int *txbuf,u32 n); +void (*s_idle) (void *priv,int enable); };struct ir_input_dev {@@ -69,9 +81,10 @@ struct ir_input_dev {char *driver_name;/* Name of the driver module */ struct ir_scancode_table rc_tab;/* scan/key table */ unsigned long devno;/* device number */ -const struct ir_dev_props *props;/* Device properties */ +struct ir_dev_props *props;/* Device properties */ struct ir_raw_event_ctrl *raw;/* for raw pulse/space events */ struct input_dev *input_dev;/* the input device associated with this device */ +int idle;/* key info - needed by IR keycode handlers */ spinlock_t keylock;/* protects the below members */ @@ -95,12 +108,12 @@ enum raw_event_type {/* From ir-keytable.c */ int __ir_input_register (struct input_dev *dev,const struct ir_scancode_table *ir_codes, -const struct ir_dev_props *props, +struct ir_dev_props *props,const char *driver_name);static inline int ir_input_register (struct input_dev *dev,const char *map_name, -const struct ir_dev_props *props, +struct ir_dev_props *props,const char *driver_name) {struct ir_scancode_table *ir_codes;struct ir_input_dev *ir_dev;@@ -144,6 +157,11 @@ struct ir_raw_event {void ir_raw_event_handle (struct input_dev *input_dev);int ir_raw_event_store (struct input_dev *input_dev,struct ir_raw_event *ev);int ir_raw_event_store_edge (struct input_dev *input_dev,enum raw_event_type type); +int ir_raw_event_store_with_filter (struct input_dev *input_dev, +struct ir_raw_event *ev); + +void ir_raw_event_set_idle (struct input_dev *input_dev,int idle); +static inline void ir_raw_event_reset (struct input_dev *input_dev) {struct ir_raw_event ev = { .pulse = false, .duration =0 };
Re: [PATCH 3/9] IR: replace spinlock with mutex.
In reply to Mauro Carvalho ChehabQuoted 7 lines · Mauro Carvalho Chehab
Em 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 3 lines
Some handlers (lirc for example) allocates memory on initialization, doing so in atomic context is cumbersome.
Fixes warning about sleeping function in atomic context.You should not replace it by a mutex, as the decoding code may happen during IRQ time on several drivers.
I though decoding code is run by a work queue?
I don't see any atomic codepath here...
Quoted 2 lines
If lirc is allocating memory, it should be using
GFP_ATOMICto avoid sleeping.
If its really not possible, I can make lirc use GFP_ATOMIC. a bit ugly, but should work.
Best regards,
Re: [PATCH 2/9] IR: minor fixes:
In reply to Mauro Carvalho ChehabQuoted 24 lines · Mauro Carvalho Chehab
Em 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 23 lines
* lirc: Don't propagate reset event to userspace
* lirc: Remove strange logic from lirc that would make first sample always be pulse
* MakeTO_USmacro actualy print what it should.Signed-off-by Maxim Levitsky <[email protected]>--- drivers/media/IR/ir-core-priv.h | 3 +-- drivers/media/IR/ir-lirc-codec.c | 14 ++++++++------ drivers/media/IR/ir-raw-event.c | 3 +++ 3 files changed, 12 insertions(+), 8 deletions(-)drivers/media/IR/ir-core-priv.h +0
-1@@ -76,7 +76,6 @@ struct ir_raw_event_ctrl {struct lirc_codec {struct ir_input_dev *ir_dev;struct lirc_driver *drv; -int lircdata; } lirc; };
Quoted 8 lines
drivers/media/IR/ir-core-priv.h static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration) · line 106
Quoted 6 lines
drivers/media/IR/ir-core-priv.h +1
-1@@ -104,7 +103,7 @@ static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration) ev->duration -= duration; } -#define TO_US (duration) (((duration) + 500) / 1000) +#define TO_US (duration) ((duration) / 1000)It is better to keep rounding the duration to its closest value.
But that breaks if duration is already at maximum. At that case, you see usual signed int wrap from positive to negative, and abnormally large space...
I didn't notice though that you do rounding here.
I replace that with something better.
Best regards,
Maxim Levitsky
Re: [PATCH 5/9] IR: extend interfaces to support more device settings
In reply to Maxim LevitskyEm 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 53 lines
Also reuse
LIRC_SET_MEASURE_CARRIER_MODEasLIRC_SET_LEARN_MODE(LIRC_SET_LEARN_MODEwill start carrier reports if possible, and tune receiver to wide band mode)This IOCTL isn't yet used by lirc, so this won't break userspace.
Signed-off-by Maxim Levitsky <[email protected]>--- drivers/media/IR/ir-core-priv.h | 2 + drivers/media/IR/ir-lirc-codec.c | 100 ++++++++++++++++++++++++++++++++++---- include/media/ir-core.h | 11 ++++ include/media/lirc.h | 4 +- 4 files changed, 105 insertions(+), 12 deletions(-)drivers/media/IR/ir-core-priv.h +2
-0@@ -77,6 +77,8 @@ struct ir_raw_event_ctrl {struct lirc_codec {struct ir_input_dev *ir_dev;struct lirc_driver *drv; +int timeout_report; +int carrier_low; } lirc; };drivers/media/IR/ir-lirc-codec.c +4
-2@@ -96,13 +96,13 @@ out:return ret; } -static long ir_lirc_ioctl (struct file *filep,unsigned int cmd,unsigned long arg) +static long ir_lirc_ioctl (struct file *filep,unsigned int cmd,unsigned long __user arg) {struct lirc_codec *lirc;struct ir_input_dev *ir_dev;int ret =0 ;void *drv_data; -unsigned long val; +unsigned long val =0 ; lirc =lirc_get_pdata (filep);if (!lirc)@@ -116,10 +116,21 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arswitch (cmd) {case LIRC_SET_TRANSMITTER_MASK : +case LIRC_SET_SEND_CARRIER : +case LIRC_SET_SEND_MODE :
drivers/media/IR/ir-lirc-codec.c static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long ar · line 130
Quoted 10 lines
drivers/media/IR/ir-lirc-codec.c +7
-0+case LIRC_SET_REC_TIMEOUT : +case LIRC_SET_REC_TIMEOUT_REPORTS : +case LIRC_SET_LEARN_MODE : +case LIRC_SET_REC_CARRIER : +case LIRC_SET_REC_CARRIER_RANGE : +case LIRC_SET_SEND_DUTY_CYCLE : ret =get_user (val, (unsigned long *)arg);if (ret)return ret; + }
As, in all cases, the argument is an __u32, you can just use this, to get
the arguments for all LIRC_SET_* cases:
if (_IOC_DIR(cmd) & _IOC_WRITE) {
ret = get_user(val, (unsigned long *)arg);
if (ret)
return ret;
}Quoted 22 lines
drivers/media/IR/ir-lirc-codec.c +2
-6+switch (cmd) { +case LIRC_SET_TRANSMITTER_MASK :if (ir_dev->props && ir_dev->props->s_tx_mask) ret = ir_dev->props->s_tx_mask (drv_data, (u32 )val);else @@ -127,10 +138,6 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arbreak ;case LIRC_SET_SEND_CARRIER : - ret =get_user (val, (unsigned long *)arg); -if (ret) -return ret; -if (ir_dev->props && ir_dev->props->s_tx_carrier) ir_dev->props->s_tx_carrier (drv_data, (u32 )val);else @@ -143,14 +150,75 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long arbreak ;case LIRC_SET_SEND_MODE : - ret =get_user (val, (unsigned long *)arg); -if (ret)
drivers/media/IR/ir-lirc-codec.c static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, unsigned long ar · line 160
Quoted 10 lines
drivers/media/IR/ir-lirc-codec.c +4
-2-return ret; -if (val != (LIRC_MODE_PULSE &LIRC_CAN_SEND_MASK ))return -EINVAL ;break ; +case LIRC_GET_REC_RESOLUTION : + val = ir_dev->props->rx_resolution; + ret =put_user (val, (unsigned long *)arg); +break ;
You can use something like this, to handle the LIRC_GET* cases:
switch (cmd) {
...
case LIRC_GET_REC_RESOLUTION:
val = ir_dev->props->rx_resolution;
break;
...
}
if (_IOC_DIR(cmd) & _IOC_READ) {
ret = put_user(val, (unsigned long *)arg);
if (ret)
return ret;
}Quoted 160 lines
drivers/media/IR/ir-lirc-codec.c +73
-0+ +case LIRC_SET_REC_TIMEOUT : +if (val < ir_dev->props->min_timeout || + val > ir_dev->props->max_timeout) +return -EINVAL ; + + ir_dev->props->timeout = val; +break ; + +case LIRC_SET_REC_TIMEOUT_REPORTS : + ir_dev->raw->lirc.timeout_report = !!val; +return 0 ; + +case LIRC_GET_MIN_TIMEOUT : + +if (!ir_dev->props->max_timeout) +return -ENOSYS ; + + ret =put_user (ir_dev->props->min_timeout, (unsigned long *)arg); +break ; +case LIRC_GET_MAX_TIMEOUT : +if (!ir_dev->props->max_timeout) +return -ENOSYS ; + + ret =put_user (ir_dev->props->max_timeout, (unsigned long *)arg); +break ; + +case LIRC_SET_LEARN_MODE : +if (ir_dev->props->s_learning_mode) +return ir_dev->props->s_learning_mode ( + ir_dev->props->priv, !!val); +else +return -ENOSYS ; + +case LIRC_SET_REC_CARRIER : +if (ir_dev->props->s_rx_carrier_range) + ret = ir_dev->props->s_rx_carrier_range ( + ir_dev->props->priv, + ir_dev->raw->lirc.carrier_low, val); +else +return -ENOSYS ; + +if (!ret) + ir_dev->raw->lirc.carrier_low =0 ; +break ; + +case LIRC_SET_REC_CARRIER_RANGE : +if (val >=0 ) + ir_dev->raw->lirc.carrier_low = val; +break ; +case LIRC_SET_SEND_DUTY_CYCLE : + +if (!ir_dev->props->s_tx_duty_cycle) +return -ENOSYS ; + +if (val <=0 || val >=100 ) +return -EINVAL ; + + ir_dev->props->s_tx_duty_cycle (ir_dev->props->priv, val); +break ; +default :return lirc_dev_fop_ioctl (filep, cmd, arg); }@@ -200,13 +268,25 @@ static int ir_lirc_register(struct input_dev *input_dev) features =LIRC_CAN_REC_MODE2 ;if (ir_dev->props->tx_ir) { + features |=LIRC_CAN_SEND_PULSE ;if (ir_dev->props->s_tx_mask) features |=LIRC_CAN_SET_TRANSMITTER_MASK ;if (ir_dev->props->s_tx_carrier) features |=LIRC_CAN_SET_SEND_CARRIER ; + +if (ir_dev->props->s_tx_duty_cycle) + features |=LIRC_CAN_SET_REC_DUTY_CYCLE ; } +if (ir_dev->props->s_rx_carrier_range) + features |=LIRC_CAN_SET_REC_CARRIER | +LIRC_CAN_SET_REC_CARRIER_RANGE ; + +if (ir_dev->props->s_learning_mode) + features |=LIRC_CAN_LEARN_MODE ; + +snprintf (drv->name,sizeof (drv->name),"ir-lirc-codec (%s)" , ir_dev->driver_name); drv->minor =-1 ;include/media/ir-core.h +11
-0@@ -44,6 +44,8 @@ enum rc_driver_type {* @timeout: optional time after which device stops sending data * @min_timeout: minimum timeout supported by device * @max_timeout: maximum timeout supported by device +* @rx_resolution : resolution (in ns) of input sampler +* @tx_resolution: resolution (in ns) of output sampler * @priv: driver-specific data, to be used on the callbacks * @change_protocol: allow changing the protocol used on hardware decoders * @open: callback to allow drivers to enable polling/irq when IR input device @@ -52,9 +54,12 @@ enum rc_driver_type {* is opened. * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs) * @s_tx_carrier: set transmit carrier frequency +* @s_tx_duty_cycle: set transmit duty cycle (0% - 100%) +* @s_rx_carrier: inform driver about carrier it is expected to handle * @tx_ir: transmit IR * @s_idle: optional: enable/disable hardware idle mode, upon which, device doesn't interrupt host untill it sees IR data +* @s_learning_mode: enable learning mode */ struct ir_dev_props {enum rc_driver_type driver_type;@@ -65,6 +70,8 @@ struct ir_dev_props {u64 min_timeout;u64 max_timeout; +u32 rx_resolution; +u32 tx_resolution;void *priv;int (*change_protocol)(void *priv,u64 ir_type);@@ -72,8 +79,12 @@ struct ir_dev_props {void (*close)(void *priv);int (*s_tx_mask)(void *priv,u32 mask);int (*s_tx_carrier)(void *priv,u32 carrier); +int (*s_tx_duty_cycle) (void *priv,u32 duty_cycle); +int (*s_rx_carrier_range) (void *priv,u32 min,u32 max);int (*tx_ir)(void *priv,int *txbuf,u32 n);void (*s_idle) (void *priv,int enable); +int (*s_learning_mode) (void *priv,int enable); + };struct ir_input_dev {include/media/lirc.h +2
-2@@ -76,7 +76,7 @@#define LIRC_CAN_SET_REC_TIMEOUT 0x10000000#define LIRC_CAN_SET_REC_FILTER 0x08000000 -#define LIRC_CAN_MEASURE_CARRIER 0x02000000 +#define LIRC_CAN_LEARN_MODE 0x02000000#define LIRC_CAN_SEND (x) ((x)&LIRC_CAN_SEND_MASK)#define LIRC_CAN_REC (x) ((x)&LIRC_CAN_REC_MASK)@@ -145,7 +145,7 @@* if enabled from the next key press on the driver will send * LIRC_MODE2_FREQUENCY packets */ -#define LIRC_SET_MEASURE_CARRIER_MODE _IOW('i', 0x0000001d, __u32) +#define LIRC_SET_LEARN_MODE _IOW('i', 0x0000001d, __u32)/* * to set a range use
Re: [PATCH 8/9] IR: Add ENE input driver.
In reply to Maxim LevitskyEm 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 1 line
Signed-off-by Maxim Levitsky <[email protected]>
Please, instead of patch 9/9, do a patch moving ENE driver from staging into drivers/media/IR, and then a patch porting it into rc-core. This will allow us to better understand what were done to convert it to rc-core, being an example for others that may work on porting the other drivers to rc-core.
Cheers,
Mauro.
Re: [PATCH 8/9] IR: Add ENE input driver.
Quoted 7 lines · Mauro Carvalho Chehab
Em 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 1 line
Signed-off-by Maxim Levitsky <[email protected]>Please, instead of patch 9/9, do a patch moving ENE driver from staging into
drivers/media/IR, and then a patch porting it into rc-core. This will allow us to better understand what were done to convert it to rc-core, being an example for others that may work on porting the other drivers to rc-core.
The version in staging is outdated.
Should I first update it, and then move?
Best regards,
Maxim Levitsky
Re: [PATCH 8/9] IR: Add ENE input driver.
Quoted 10 lines · Maxim Levitsky
Quoted 7 lines · Mauro Carvalho Chehab
Em 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 1 line
Signed-off-by Maxim Levitsky <[email protected]>Please, instead of patch 9/9, do a patch moving ENE driver from staging into
drivers/media/IR, and then a patch porting it into rc-core. This will allow us to better understand what were done to convert it to rc-core, being an example for others that may work on porting the other drivers to rc-core.The version in staging is outdated.
D'oh, sorry about that.
Quoted 1 line
Should I first update it, and then move?
Yeah, that sounds sane to me.
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH 2/9] IR: minor fixes:
In reply to Maxim LevitskyQuoted 5 lines · Maxim Levitsky
* lirc: Don't propagate reset event to userspace
* lirc: Remove strange logic from lirc that would make first sample always be pulse
* MakeTO_USmacro actualy print what it should.Signed-off-by Maxim Levitsky <[email protected]>
For the ir-lirc-codec-specific bits:
I'm inclined to pull them into my tree now, and the IR_dprintk and TO_US portions can be handled separately.
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH 1/9] IR: Kconfig fixes
In reply to Maxim LevitskyQuoted 36 lines · On Wed, 28 Jul 2010 18:14:03 +0300 Maxim Levitsky wrote:
Move IR drives below separate menu.
This allows to disable them.
Also correct a typo.Signed-off-by Maxim Levitsky <[email protected]>--- drivers/media/IR/Kconfig | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)drivers/media/IR/Kconfig +5
-3@@ -1,8 +1,10 @@ -config IR_CORE - tristate +menuconfig IR_CORE + tristate "Infrared remote controller adapters" depends on INPUT default INPUT +if IR_CORE + config VIDEO_IR tristate depends on IR_CORE@@ -16,7 +18,7 @@ config LIRC Enable this option to build the Linux Infrared Remote Control (LIRC) core device interface driver. The LIRC interface passes raw IR to and from userspace, where the - LIRC daemon handles protocol decoding for IR reception ann + LIRC daemon handles protocol decoding for IR reception and encoding for IR transmitting (aka "blasting"). source "drivers/media/IR/keymaps/Kconfig"
drivers/media/IR/Kconfig config IR_MCEUSB · line 112
Quoted 9 lines
drivers/media/IR/Kconfig +6
-0@@ -102,3 +104,9 @@ config IR_MCEUSB To compile this driver as a module, choose M here: the module will be called mceusb. + + + + + +endif #IR_CORE
I don't think that those extra blank lines are a fix...
---
~Randy
*** Remember to use Documentation/SubmitChecklist when testing your code ***
Re: [PATCH 4/9] IR: add helper functions for ir input devices that send ir timing data in small chunks, and alternation between pulses and spaces isn't guaranteed.
In reply to Maxim LevitskyQuoted 1 line · Maxim Levitsky
Signed-off-by Maxim Levitsky <[email protected]>
With the caveat of requiring an improved changelog, per Mauro's suggestion:
I suspect at least some of this code may be of use to the streamzap driver as well (which I started looking at porting last night, despite my insistence that I was going to work on lirc_zilog first...).
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH 3/9] IR: replace spinlock with mutex.
In reply to Maxim LevitskyQuoted 9 lines · Maxim Levitsky
Quoted 7 lines · Mauro Carvalho Chehab
Em 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 3 lines
Some handlers (lirc for example) allocates memory on initialization, doing so in atomic context is cumbersome.
Fixes warning about sleeping function in atomic context.You should not replace it by a mutex, as the decoding code may happen during IRQ time on several drivers.
I though decoding code is run by a work queue?
Yeah, it is. (INIT_WORK(&ir->raw->rx_work, ir_raw_event_work); in ir_raw_event_register).
Quoted 1 line
I don't see any atomic codepath here...
I think the ir_raw_event_store variants are the only things that are run from an interrupt context, and none of them touch ir_raw_handler_lock. That lock is advertised as being for the protection of ir_raw_handler_list and ir_raw_client_list, which are primarily manipulated by register/unregister functions, and we just lock them when doing actual IR decode work (via said work queue) so we don't feed raw IR somewhere that we shouldn't. I think Maxim is correct here, we should be okay with changing this to a mutex, unless I'm missing something else.
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH 2/9] IR: minor fixes:
In reply to Maxim LevitskyEm 28-07-2010 13:38, Maxim Levitsky escreveu:
Quoted 34 lines · Mauro Carvalho Chehab
Quoted 24 lines
Em 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 23 lines
* lirc: Don't propagate reset event to userspace
* lirc: Remove strange logic from lirc that would make first sample always be pulse
* MakeTO_USmacro actualy print what it should.Signed-off-by Maxim Levitsky <[email protected]>--- drivers/media/IR/ir-core-priv.h | 3 +-- drivers/media/IR/ir-lirc-codec.c | 14 ++++++++------ drivers/media/IR/ir-raw-event.c | 3 +++ 3 files changed, 12 insertions(+), 8 deletions(-)drivers/media/IR/ir-core-priv.h +0
-1@@ -76,7 +76,6 @@ struct ir_raw_event_ctrl {struct lirc_codec {struct ir_input_dev *ir_dev;struct lirc_driver *drv; -int lircdata; } lirc; };Quoted 8 lines
drivers/media/IR/ir-core-priv.h static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration) · line 106
Quoted 6 lines
drivers/media/IR/ir-core-priv.h +1
-1@@ -104,7 +103,7 @@ static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration) ev->duration -= duration; } -#define TO_US (duration) (((duration) + 500) / 1000) +#define TO_US (duration) ((duration) / 1000)It is better to keep rounding the duration to its closest value.
Quoted 6 lines
But that breaks if duration is already at maximum. At that case, you see usual signed int wrap from positive to negative, and abnormally large space...
I didn't notice though that you do rounding here.
I replace that with something better.
There's a function for rounding at kernel. The better is to use it, as it should already solve the signal wrap.
Cheers,
Mauro
Re: [PATCH 6/9] IR: actually allow not to compile keymaps in..
In reply to Maxim LevitskyQuoted 4 lines · Maxim Levitsky
Currntly, ir device registration fails if keymap requested by driver is not found... Fix that by always compiling in the empty keymap, and using it as a failback
Signed-off-by Maxim Levitsky <[email protected]>
I like this one, useful improvement, I think. We even get meaningful output logged as well -- get_rc_map() will let us know the initially requested keymap failed to load, and then will let us know whether or not the empty keymap loaded.
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH 8/9] IR: Add ENE input driver.
In reply to Maxim LevitskyEm 28-07-2010 14:13, Maxim Levitsky escreveu:
Quoted 11 lines · Mauro Carvalho Chehab
Quoted 7 lines
Em 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 1 line
Signed-off-by Maxim Levitsky <[email protected]>Please, instead of patch 9/9, do a patch moving ENE driver from staging into
drivers/media/IR, and then a patch porting it into rc-core. This will allow us to better understand what were done to convert it to rc-core, being an example for others that may work on porting the other drivers to rc-core.The version in staging is outdated.
Should I first update it, and then move?
Yes, please. It shouldn't be hard to produce such patches, and this will help other developers when porting the other drivers. So, it may result on a some gain at the speed for the other ports.
Quoted 8 lines
Best regards,
Maxim Levitsky--
To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 3/9] IR: replace spinlock with mutex.
In reply to Jarod WilsonEm 28-07-2010 14:43, Jarod Wilson escreveu:
Quoted 16 lines · Maxim Levitsky
Quoted 9 lines · Mauro Carvalho Chehab
Quoted 7 lines
Em 28-07-2010 12:14, Maxim Levitsky escreveu:
Quoted 3 lines
Some handlers (lirc for example) allocates memory on initialization, doing so in atomic context is cumbersome.
Fixes warning about sleeping function in atomic context.You should not replace it by a mutex, as the decoding code may happen during IRQ time on several drivers.
I though decoding code is run by a work queue?
Yeah, it is. (
INIT_WORK(&ir->raw->rx_work, ir_raw_event_work); inir_raw_event_register).Quoted 1 line
I don't see any atomic codepath here...
Quoted 8 lines
I think the
ir_raw_event_storevariants are the only things that are run from an interrupt context, and none of them touchir_raw_handler_lock. That lock is advertised as being for the protection ofir_raw_handler_listandir_raw_client_list, which are primarily manipulated by register/unregister functions, and we just lock them when doing actual IR decode work (via said work queue) so we don't feed raw IR somewhere that we shouldn't. I think Maxim is correct here, we should be okay with changing this to a mutex, unless I'm missing something else.
You're probably right. The previous code used to do this at IRQ time, but a latter patch changed it to happen via a workqueue.
So, I'm OK with this patch.
Cheers,
Mauro.
Re: [PATCH 1/9] IR: Kconfig fixes
In reply to Randy DunlapQuoted 39 lines · Randy Dunlap
Quoted 37 lines · On Wed, 28 Jul 2010 18:14:03 +0300 Maxim Levitsky wrote:
Move IR drives below separate menu.
This allows to disable them.
Also correct a typo.Signed-off-by Maxim Levitsky <[email protected]>--- drivers/media/IR/Kconfig | 14 +++++++++++--- 1 files changed, 11 insertions(+), 3 deletions(-)drivers/media/IR/Kconfig +5
-3@@ -1,8 +1,10 @@ -config IR_CORE - tristate +menuconfig IR_CORE + tristate "Infrared remote controller adapters" depends on INPUT default INPUT +if IR_CORE + config VIDEO_IR tristate depends on IR_CORE@@ -16,7 +18,7 @@ config LIRC Enable this option to build the Linux Infrared Remote Control (LIRC) core device interface driver. The LIRC interface passes raw IR to and from userspace, where the - LIRC daemon handles protocol decoding for IR reception ann + LIRC daemon handles protocol decoding for IR reception and encoding for IR transmitting (aka "blasting"). source "drivers/media/IR/keymaps/Kconfig"@@ -102,3 +104,9 @@ config IR_MCEUSB
Quoted 10 lines
drivers/media/IR/Kconfig config IR_MCEUSB · line 112
Quoted 8 lines
drivers/media/IR/Kconfig +6
-0To compile this driver as a module, choose M here: the module will be called mceusb. + + + + + +endif #IR_COREI don't think that those extra blank lines are a fix...
Sure.
This patch series wasn't meant to be prefect, I rushed it a bit out of dour.
When I split the patches, I forgot to remove that whitespace.
Other that that, any more comments?
Best regards,
Maxim Levitsky
Re: [PATCH 5/9] IR: extend interfaces to support more device settings
In reply to Maxim LevitskyQuoted 5 lines · Maxim Levitsky
Also reuse
LIRC_SET_MEASURE_CARRIER_MODEasLIRC_SET_LEARN_MODE(LIRC_SET_LEARN_MODEwill start carrier reports if possible, and tune receiver to wide band mode)This IOCTL isn't yet used by lirc, so this won't break userspace.
Plus, once lirc 0.8.7 is released (Real Soon Now), we'll start working on lirc 0.9.0 with the express goal of it being built against lirc.h as provided by the kernel.
These all generally look good and sane to me, and I'll make use of the LEARN_MODE bits for mceusb after something along these lines is committed.
I like the simplifications Mauro suggested for the ioctl handling. In addition to those, there's a bit of whitespace damage in lirc.h that I'd like to see cleaned up for v2.
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH 4/9] IR: add helper functions for ir input devices that send ir timing data in small chunks, and alternation between pulses and spaces isn't guaranteed.
In reply to Jarod WilsonQuoted 10 lines · Jarod Wilson
Quoted 1 line · Maxim Levitsky
Signed-off-by Maxim Levitsky <[email protected]>With the caveat of requiring an improved changelog, per Mauro's suggestion:
Acked-by Jarod Wilson <[email protected]>I suspect at least some of this code may be of use to the streamzap driver as well (which I started looking at porting last night, despite my insistence that I was going to work on
lirc_zilogfirst...).
One other note: idle looks like it can happily exist as a bool instead of as an int, no?
Signature · 2 lines
Jarod Wilson [email protected]
Re: [PATCH 4/9] IR: add helper functions for ir input devices that send ir timing data in small chunks, and alternation between pulses and spaces isn't guaranteed.
Quoted 6 lines · Jarod Wilson
Quoted 5 lines · Jarod Wilson
Quoted 1 line · Maxim Levitsky
Signed-off-by Maxim Levitsky <[email protected]>With the caveat of requiring an improved changelog, per Mauro's suggestion:
Quoted 9 lines
Quoted 5 lines
Acked-by Jarod Wilson <[email protected]>I suspect at least some of this code may be of use to the streamzap driver as well (which I started looking at porting last night, despite my insistence that I was going to work on
lirc_zilogfirst...).One other note: idle looks like it can happily exist as a bool instead of as an int, no?
sure.
I have a problem with this code however, I just discovered. I pretty much don't know how to solve it currently...
I just posted a mail about it.
Best regards,
Maxim Levitsky