rc-core: ir-core to rc-core conversion
Subsystems (3)
cover rc-core: ir-core to rc-core conversion
This is my current patch queue, the main change is to make struct rc_dev the primary interface for rc drivers and to abstract away the fact that there's an input device lurking in there somewhere. The first three patches in the set are preparations for the change.
I've also converted winbond-cir over to rc-core.
Given the changes, these patches touch every single driver. Obviously I haven't tested them all due to a lack of hardware (I have made sure that all drivers compile without any warnings and I have tested the end result on mceusb and winbond-cir hardware).
---
David Härdeman (5):
rc-code: merge and rename ir-core
rc-core: remove remaining users of the ir-functions keyhandlers
imon: split mouse events to a separate input dev
rc-core: make struct rc_dev the primary interface for rc drivers
rc-core: convert winbond-cir
drivers/input/misc/Kconfig | 18 drivers/input/misc/Makefile | 1 drivers/input/misc/winbond-cir.c | 1608 --------------------------- drivers/media/IR/Kconfig | 17 drivers/media/IR/Makefile | 4 drivers/media/IR/ene_ir.c | 121 +- drivers/media/IR/ene_ir.h | 3 drivers/media/IR/imon.c | 267 +++- drivers/media/IR/ir-core-priv.h | 26 drivers/media/IR/ir-functions.c | 98 -- drivers/media/IR/ir-jvc-decoder.c | 13 drivers/media/IR/ir-keytable.c | 565 --------- drivers/media/IR/ir-lirc-codec.c | 111 +- drivers/media/IR/ir-nec-decoder.c | 15 drivers/media/IR/ir-raw-event.c | 379 ------ drivers/media/IR/ir-rc5-decoder.c | 13 drivers/media/IR/ir-rc6-decoder.c | 17 drivers/media/IR/ir-sony-decoder.c | 11 drivers/media/IR/ir-sysfs.c | 340 ------ drivers/media/IR/mceusb.c | 93 +- drivers/media/IR/rc-core.c | 1316 ++++++++++++++++++++++ drivers/media/IR/rc-map.c | 107 -- drivers/media/IR/streamzap.c | 75 + drivers/media/IR/winbond-cir.c | 934 ++++++++++++++++ drivers/media/dvb/dm1105/dm1105.c | 40 - drivers/media/dvb/dvb-usb/dib0700.h | 2 drivers/media/dvb/dvb-usb/dib0700_core.c | 11 drivers/media/dvb/dvb-usb/dib0700_devices.c | 116 +- drivers/media/dvb/dvb-usb/dvb-usb-remote.c | 78 + drivers/media/dvb/dvb-usb/dvb-usb.h | 12 drivers/media/dvb/mantis/mantis_common.h | 4 drivers/media/dvb/mantis/mantis_input.c | 74 + drivers/media/dvb/siano/smscoreapi.c | 2 drivers/media/dvb/siano/smsir.c | 52 - drivers/media/dvb/siano/smsir.h | 3 drivers/media/dvb/ttpci/budget-ci.c | 49 - drivers/media/video/bt8xx/bttv-input.c | 68 - drivers/media/video/bt8xx/bttvp.h | 1 drivers/media/video/cx18/cx18-i2c.c | 1 drivers/media/video/cx23885/cx23885-input.c | 64 + drivers/media/video/cx23885/cx23885.h | 3 drivers/media/video/cx88/cx88-input.c | 86 + drivers/media/video/em28xx/em28xx-input.c | 72 + drivers/media/video/ir-kbd-i2c.c | 39 - drivers/media/video/ivtv/ivtv-i2c.c | 3 drivers/media/video/saa7134/saa7134-input.c | 122 +- drivers/staging/tm6000/tm6000-input.c | 97 +- include/media/ir-common.h | 33 - include/media/ir-core.h | 193 +-- include/media/ir-kbd-i2c.h | 6 50 files changed, 3171 insertions(+), 4212 deletions(-) delete mode 100644 drivers/input/misc/winbond-cir.c delete mode 100644 drivers/media/IR/ir-keytable.c delete mode 100644 drivers/media/IR/ir-raw-event.c delete mode 100644 drivers/media/IR/ir-sysfs.c create mode 100644 drivers/media/IR/rc-core.c delete mode 100644 drivers/media/IR/rc-map.c create mode 100644 drivers/media/IR/winbond-cir.c
Signature · 1 line
David Härdeman
PATCH 1/5 rc-code: merge and rename ir-core
This patch merges the files which makes up ir-core and renames the resulting module to rc-core. IMHO this makes it much easier to hack on the core module since all code is in one file.
This also allows some simplification of ir-core-priv.h as fewer internal functions need to be exposed.
--- drivers/media/IR/Makefile | 3 drivers/media/IR/ir-core-priv.h | 16 drivers/media/IR/ir-keytable.c | 565 ---------------- drivers/media/IR/ir-raw-event.c | 379 ----------- drivers/media/IR/ir-sysfs.c | 340 ---------- drivers/media/IR/rc-core.c | 1337 +++++++++++++++++++++++++++++++++++++++ drivers/media/IR/rc-map.c | 107 --- include/media/ir-core.h | 3 8 files changed, 1338 insertions(+), 1412 deletions(-) delete mode 100644 drivers/media/IR/ir-keytable.c delete mode 100644 drivers/media/IR/ir-raw-event.c delete mode 100644 drivers/media/IR/ir-sysfs.c create mode 100644 drivers/media/IR/rc-core.c delete mode 100644 drivers/media/IR/rc-map.c
drivers/media/IR/Makefile +1 -2
@@ -1,9 +1,8 @@ ir-common-objs := ir-functions.o -ir-core-objs := ir-keytable.o ir-sysfs.o ir-raw-event.o rc-map.o obj-y += keymaps/ -obj-$(CONFIG_IR_CORE) += ir-core.o +obj-$(CONFIG_IR_CORE) += rc-core.o obj-$(CONFIG_VIDEO_IR) += ir-common.o obj-$(CONFIG_LIRC) += lirc_dev.o obj-$(CONFIG_IR_NEC_DECODER) += ir-nec-decoder.o
drivers/media/IR/ir-core-priv.h +0 -16
@@ -110,26 +110,10 @@ static inline void decrease_duration(struct ir_raw_event *ev, unsigned duration)#define TO_US (duration) DIV_ROUND_CLOSEST((duration), 1000)#define TO_STR (is_pulse) ((is_pulse) ? "pulse" : "space")#define IS_RESET (ev) (ev.duration == 0) -/* -* Routines from ir-sysfs.c - Meant to be called only internally inside -* ir-core -*/ - -int ir_register_class (struct input_dev *input_dev); -void ir_unregister_class (struct input_dev *input_dev); -/* -* Routines from ir-raw-event.c to be used internally and by decoders -*/ -u64 ir_raw_get_allowed_protocols (void ); -int ir_raw_event_register (struct input_dev *input_dev); -void ir_raw_event_unregister (struct input_dev *input_dev);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-keytable.c deleted +0 -565
565 lines not on this page · raw message
drivers/media/IR/ir-raw-event.c deleted +0 -379
379 lines not on this page · raw message
drivers/media/IR/ir-sysfs.c deleted +0 -340
340 lines not on this page · raw message
drivers/media/IR/rc-core.c new file +1337 -0
1,337 lines not on this page · raw message
drivers/media/IR/rc-map.c deleted +0 -107
107 lines not on this page · raw message
include/media/ir-core.h +0 -3
@@ -115,7 +115,6 @@ enum raw_event_type {#define to_ir_input_dev (_attr) container_of(_attr, struct ir_input_dev, attr) -/* From ir-keytable.c */ int __ir_input_register(struct input_dev *dev, const struct ir_scancode_table *ir_codes, struct ir_dev_props *props,
@@ -159,8 +158,6 @@ void ir_repeat(struct input_dev *dev);void ir_keydown (struct input_dev *dev,int scancode,u8 toggle);u32 ir_g_keycode_from_table (struct input_dev *input_dev,u32 scancode); -/* From ir-raw-event.c */ -struct ir_raw_event {unsigned pulse:1 ;unsigned duration:31 ;
PATCH 2/5 rc-core: remove remaining users of the ir-functions keyhandlers
In reply to David HärdemanThis patch removes the remaining usages of the ir_input_nokey() and ir_input_keydown() functions provided by drivers/media/IR/ir-functions.c by using the corresponding functionality in rc-core directly instead.
--- drivers/media/IR/ir-functions.c | 98 ++--------------------- drivers/media/IR/rc-core.c | 115 ++++++++++++++++++++------- drivers/media/video/bt8xx/bttv-input.c | 27 ++---- drivers/media/video/bt8xx/bttvp.h | 1 drivers/media/video/cx18/cx18-i2c.c | 1 drivers/media/video/cx88/cx88-input.c | 24 ++---- drivers/media/video/ir-kbd-i2c.c | 14 --- drivers/media/video/ivtv/ivtv-i2c.c | 3 - drivers/media/video/saa7134/saa7134-input.c | 50 ++---------- drivers/staging/tm6000/tm6000-input.c | 12 +-- include/media/ir-common.h | 30 +------ include/media/ir-core.h | 2 include/media/ir-kbd-i2c.h | 4 - 13 files changed, 131 insertions(+), 250 deletions(-)
drivers/media/IR/ir-functions.c +8 -90
@@ -1,7 +1,7 @@/* -* -* some common structs and functions to handle infrared remotes via -* input layer ... +* some common functions to handle infrared remote protocol decoding for +* drivers which have not yet been (or can't be) converted to use the +* regular protocol decoders... * * (c) 2003 Gerd Knorr <[email protected]> [SuSE Labs] *
@@ -31,67 +31,6 @@MODULE_AUTHOR ("Gerd Knorr <[email protected]> [SuSE Labs]" );MODULE_LICENSE ("GPL" ); -static int repeat =1 ; -module_param (repeat, int,0444 ); -MODULE_PARM_DESC (repeat,"auto-repeat for IR keys (default: on)" ); - -/* -------------------------------------------------------------------------- */ - -static void ir_input_key_event (struct input_dev *dev,struct ir_input_state *ir) -{ -if (KEY_RESERVED == ir->keycode) { -printk (KERN_INFO "%s: unknown key: key=0x%02x down=%d\n" , - dev->name, ir->ir_key, ir->keypressed); -return ; - } -IR_dprintk (1 ,"%s: key event code=%d down=%d\n" , - dev->name,ir->keycode,ir->keypressed); -input_report_key (dev,ir->keycode,ir->keypressed); -input_sync (dev); -} - -/* -------------------------------------------------------------------------- */ - -int ir_input_init (struct input_dev *dev,struct ir_input_state *ir, -const u64 ir_type) -{ - ir->ir_type = ir_type; - -if (repeat) -set_bit (EV_REP , dev->evbit); - -return 0 ; -} -EXPORT_SYMBOL_GPL (ir_input_init); - - -void ir_input_nokey (struct input_dev *dev,struct ir_input_state *ir) -{ -if (ir->keypressed) { - ir->keypressed =0 ; -ir_input_key_event (dev,ir); - } -} -EXPORT_SYMBOL_GPL (ir_input_nokey); - -void ir_input_keydown (struct input_dev *dev,struct ir_input_state *ir, -u32 ir_key) -{ -u32 keycode =ir_g_keycode_from_table (dev, ir_key); - -if (ir->keypressed && ir->keycode != keycode) { - ir->keypressed =0 ; -ir_input_key_event (dev,ir); - } -if (!ir->keypressed) { - ir->ir_key = ir_key; - ir->keycode = keycode; - ir->keypressed =1 ; -ir_input_key_event (dev,ir); - } -} -EXPORT_SYMBOL_GPL (ir_input_keydown); -/* -------------------------------------------------------------------------- */ /* extract mask bits out of data and pack them into the result */ u32 ir_extract_bits (u32 data,u32 mask)
@@ -284,7 +223,7 @@ void ir_rc5_timer_end(unsigned long data) {struct card_ir *ir = (struct card_ir *)data;struct timeval tv; -unsigned long current_jiffies, timeout; +unsigned long current_jiffies;u32 gap;u32 rc5 =0 ;
@@ -325,32 +264,11 @@ void ir_rc5_timer_end(unsigned long data)u32 toggle =RC5_TOGGLE (rc5);u32 instr =RC5_INSTR (rc5); -/* Good code, decide if repeat/repress */ -if (toggle !=RC5_TOGGLE (ir->last_rc5) || - instr !=RC5_INSTR (ir->last_rc5)) { -IR_dprintk (1 ,"ir-common: instruction %x, toggle %x\n" , instr, - toggle); -ir_input_nokey (ir->dev, &ir->ir); -ir_input_keydown (ir->dev, &ir->ir, instr); - } - -/* Set/reset key-up timer */ - timeout = current_jiffies + -msecs_to_jiffies (ir->rc5_key_timeout); -mod_timer (&ir->timer_keyup, timeout); - -/* Save code for repeat test */ - ir->last_rc5 = rc5; +/* Good code */ +ir_keydown (ir->dev, instr, toggle); +IR_dprintk (1 ,"ir-common: instruction %x, toggle %x\n" , + instr, toggle); } } }EXPORT_SYMBOL_GPL (ir_rc5_timer_end); - -void ir_rc5_timer_keyup (unsigned long data) -{ -struct card_ir *ir = (struct card_ir *)data; - -IR_dprintk (1 ,"ir-common: key released\n" ); -ir_input_nokey (ir->dev, &ir->ir); -} -EXPORT_SYMBOL_GPL (ir_rc5_timer_keyup);
drivers/media/IR/rc-core.c +86 -29
171 lines not on this page · raw message
drivers/media/video/bt8xx/bttv-input.c +7 -20
@@ -38,8 +38,6 @@ module_param(repeat_period, int, 0644);static int ir_rc5_remote_gap =885 ;module_param (ir_rc5_remote_gap, int,0644 ); -static int ir_rc5_key_timeout =200 ; -module_param (ir_rc5_key_timeout, int,0644 );#undef dprintk #define dprintk(arg...) do { \
@@ -76,16 +74,15 @@ static void ir_handle_key(struct bttv *btv)if ((ir->mask_keydown && (0 != (gpio & ir->mask_keydown))) || (ir->mask_keyup && (0 == (gpio & ir->mask_keyup)))) { -ir_input_keydown (ir->dev, &ir->ir, data); +ir_keydown_notimeout (ir->dev, data,0 ); }else {/* HACK: Probably, ir->mask_keydown is missing for this board */ if (btv->c.type ==BTTV_BOARD_WINFAST2000 ) -ir_input_keydown (ir->dev, &ir->ir, data); +ir_keydown (ir->dev, data,0 ); -ir_input_nokey (ir->dev,&ir->ir); +ir_keyup (ir->dev); } - }static void ir_enltv_handle_key (struct bttv *btv)
@@ -107,9 +104,9 @@ static void ir_enltv_handle_key(struct bttv *btv) gpio, data, (gpio & ir->mask_keyup) ? " up" : "up/down"); -ir_input_keydown (ir->dev, &ir->ir, data); +ir_keydown_notimeout (ir->dev, data,0 );if (keyup) -ir_input_nokey (ir->dev, &ir->ir); +ir_keyup (ir->dev); }else {if ((ir->last_gpio &1 <<31 ) == keyup)return ;
@@ -119,9 +116,9 @@ static void ir_enltv_handle_key(struct bttv *btv) (gpio & ir->mask_keyup) ? " up" : "down");if (keyup) -ir_input_nokey (ir->dev, &ir->ir); +ir_keyup (ir->dev);else -ir_input_keydown (ir->dev, &ir->ir, data); +ir_keydown_notimeout (ir->dev, data,0 ); } ir->last_gpio = data | keyup;
@@ -215,14 +212,9 @@ static void bttv_ir_start(struct bttv *btv, struct card_ir *ir)init_timer (&ir->timer_end); ir->timer_end.function = ir_rc5_timer_end; ir->timer_end.data = (unsigned long )ir; - -init_timer (&ir->timer_keyup); - ir->timer_keyup.function = ir_rc5_timer_keyup; - ir->timer_keyup.data = (unsigned long )ir; ir->shift_by =1 ; ir->start =3 ; ir->addr =0x0 ; - ir->rc5_key_timeout = ir_rc5_key_timeout; ir->rc5_remote_gap = ir_rc5_remote_gap; } }
@@ -250,7 +242,6 @@ int bttv_input_init(struct bttv *btv)struct card_ir *ir;char *ir_codes =NULL ;struct input_dev *input_dev; -u64 ir_type =IR_TYPE_OTHER ;int err = -ENOMEM ;if (!btv->has_remote)
@@ -371,10 +362,6 @@ int bttv_input_init(struct bttv *btv)snprintf (ir->phys,sizeof (ir->phys),"pci-%s/ir0" ,pci_name (btv->c.pci)); - err =ir_input_init (input_dev, &ir->ir, ir_type); -if (err <0 ) - goto err_out_free; - input_dev->name = ir->name; input_dev->phys = ir->phys; input_dev->id.bustype =BUS_PCI ;
drivers/media/video/bt8xx/bttvp.h +0 -1
@@ -301,7 +301,6 @@ struct bttv_pll_info {/* for gpio-connected remote control */ struct bttv_input {struct input_dev *dev; -struct ir_input_state ir;char name[32 ];char phys[32 ];u32 mask_keycode;
drivers/media/video/cx18/cx18-i2c.c +0 -1
@@ -111,7 +111,6 @@ static int cx18_i2c_new_ir(struct cx18 *cx, struct i2c_adapter *adap, u32 hw,case CX18_HW_Z8F0811_IR_RX_HAUP : init_data->ir_codes =RC_MAP_HAUPPAUGE_NEW ; init_data->internal_get_key_func =IR_KBD_GET_KEY_HAUP_XVR ; - init_data->type =IR_TYPE_RC5 ; init_data->name = cx->card_name; info.platform_data = init_data;break ;
drivers/media/video/cx88/cx88-input.c +10 -14
@@ -41,7 +41,6 @@ struct cx88_IR {struct cx88_core *core;struct input_dev *input;struct ir_dev_props props; -u64 ir_type;int users;
@@ -125,21 +124,27 @@ static void cx88_ir_handle_key(struct cx88_IR *ir) data = (data <<4 ) | ((gpio_key &0xf0 ) >>4 ); -ir_keydown (ir->input, data,0 ); +ir_keydown_notimeout (ir->input, data,0 ); +ir_keyup (ir->input); }else if (ir->mask_keydown) {/* bit set on keydown */ if (gpio & ir->mask_keydown) -ir_keydown (ir->input, data,0 ); +ir_keydown_notimeout (ir->input, data,0 ); +else +ir_keyup (ir->input); }else if (ir->mask_keyup) {/* bit cleared on keydown */ if (0 == (gpio & ir->mask_keyup)) -ir_keydown (ir->input, data,0 ); +ir_keydown_notimeout (ir->input, data,0 ); +else +ir_keyup (ir->input); }else {/* can't distinguish keydown/up :-/ */ -ir_keydown (ir->input, data,0 ); +ir_keydown_notimeout (ir->input, data,0 ); +ir_keyup (ir->input); } }
@@ -238,7 +243,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)struct cx88_IR *ir;struct input_dev *input_dev;char *ir_codes =NULL ; -u64 ir_type =IR_TYPE_OTHER ;int err = -ENOMEM ;u32 hardware_mask =0 ;/* For devices with a hardware mask, when * used with a full-code IR table
@@ -264,7 +268,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)break ;case CX88_BOARD_TERRATEC_CINERGY_1400_DVB_T1 : ir_codes =RC_MAP_CINERGY_1400 ; - ir_type =IR_TYPE_NEC ; ir->sampling =0xeb04 ;/* address */ break ;case CX88_BOARD_HAUPPAUGE :
@@ -279,7 +282,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)case CX88_BOARD_PCHDTV_HD5500 :case CX88_BOARD_HAUPPAUGE_IRONLY : ir_codes =RC_MAP_HAUPPAUGE_NEW ; - ir_type =IR_TYPE_RC5 ; ir->sampling =1 ;break ;case CX88_BOARD_WINFAST_DTV2000H :
@@ -367,18 +369,15 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)case CX88_BOARD_PROF_7301 :case CX88_BOARD_PROF_6200 : ir_codes =RC_MAP_TBS_NEC ; - ir_type =IR_TYPE_NEC ; ir->sampling =0xff00 ;/* address */ break ;case CX88_BOARD_TEVII_S460 :case CX88_BOARD_TEVII_S420 : ir_codes =RC_MAP_TEVII_NEC ; - ir_type =IR_TYPE_NEC ; ir->sampling =0xff00 ;/* address */ break ;case CX88_BOARD_DNTV_LIVE_DVB_T_PRO : ir_codes =RC_MAP_DNTV_LIVE_DVBT_PRO ; - ir_type =IR_TYPE_NEC ; ir->sampling =0xff00 ;/* address */ break ;case CX88_BOARD_NORWOOD_MICRO :
@@ -396,7 +395,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)break ;case CX88_BOARD_PINNACLE_PCTV_HD_800i: ir_codes =RC_MAP_PINNACLE_PCTV_HD ; - ir_type =IR_TYPE_RC5 ; ir->sampling =1 ;break ;case CX88_BOARD_POWERCOLOR_REAL_ANGEL :
@@ -431,8 +429,6 @@ int cx88_ir_init(struct cx88_core *core, struct pci_dev *pci)snprintf (ir->name,sizeof (ir->name),"cx88 IR (%s)" , core->board.name);snprintf (ir->phys,sizeof (ir->phys),"pci-%s/ir0" ,pci_name (pci)); - ir->ir_type = ir_type; - input_dev->name = ir->name; input_dev->phys = ir->phys; input_dev->id.bustype =BUS_PCI ;
drivers/media/video/ir-kbd-i2c.c +1 -13
@@ -296,7 +296,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) {char *ir_codes =NULL ;const char *name =NULL ; -u64 ir_type =0 ;struct IR_i2c *ir;struct input_dev *input_dev;struct i2c_adapter *adap = client->adapter;
@@ -318,13 +317,11 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)case 0x64 : name ="Pixelview" ; ir->get_key = get_key_pixelview; - ir_type =IR_TYPE_OTHER ; ir_codes =RC_MAP_EMPTY ;break ;case 0x4b : name ="PV951" ; ir->get_key = get_key_pv951; - ir_type =IR_TYPE_OTHER ; ir_codes =RC_MAP_PV951 ;break ;case 0x18 :
@@ -332,7 +329,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)case 0x1a : name ="Hauppauge" ; ir->get_key = get_key_haup; - ir_type =IR_TYPE_RC5 ;if (hauppauge ==1 ) { ir_codes =RC_MAP_HAUPPAUGE_NEW ; }else {
@@ -342,13 +338,11 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)case 0x30 : name ="KNC One" ; ir->get_key = get_key_knc1; - ir_type =IR_TYPE_OTHER ; ir_codes =RC_MAP_EMPTY ;break ;case 0x6b : name ="FusionHDTV" ; ir->get_key = get_key_fusionhdtv; - ir_type =IR_TYPE_RC5 ; ir_codes =RC_MAP_FUSIONHDTV_MCE ;break ;case 0x0b :
@@ -359,7 +353,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)/* Handled by cx88-input */ name = adap->id ==I2C_HW_B_CX2341X ?"CX2341x remote" :"CX2388x remote" ; - ir_type =IR_TYPE_RC5 ; ir->get_key = get_key_haup_xvr;if (hauppauge ==1 ) { ir_codes =RC_MAP_HAUPPAUGE_NEW ;
@@ -369,13 +362,11 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) }else {/* Handled by saa7134-input */ name ="SAA713x remote" ; - ir_type =IR_TYPE_OTHER ; }break ;case 0x40 : name ="AVerMedia Cardbus remote" ; ir->get_key = get_key_avermedia_cardbus; - ir_type =IR_TYPE_OTHER ; ir_codes =RC_MAP_AVERMEDIA_CARDBUS ;break ; }
@@ -387,8 +378,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) ir_codes = init_data->ir_codes; name = init_data->name; -if (init_data->type) - ir_type = init_data->type;switch (init_data->internal_get_key_func) {case IR_KBD_GET_KEY_CUSTOM :
@@ -420,7 +409,7 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) }/* Make sure we are all setup before going on */ -if (!name || !ir->get_key || !ir_type || !ir_codes) { +if (!name || !ir->get_key || !ir_codes) {dprintk (1 ,": Unsupported device at address 0x%02x\n" , addr); err = -ENODEV ;
@@ -436,7 +425,6 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) dev_name(&client->dev));/* init + register input device */ - ir->ir_type = ir_type; input_dev->id.bustype =BUS_I2C ; input_dev->name = ir->name; input_dev->phys = ir->phys;
drivers/media/video/ivtv/ivtv-i2c.c +0 -3
@@ -197,7 +197,6 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr) init_data->ir_codes =RC_MAP_AVERMEDIA_CARDBUS ; init_data->internal_get_key_func =IR_KBD_GET_KEY_AVERMEDIA_CARDBUS ; - init_data->type =IR_TYPE_OTHER ; init_data->name ="AVerMedia AVerTV card" ;break ;case IVTV_HW_I2C_IR_RX_HAUP_EXT :
@@ -205,14 +204,12 @@ static int ivtv_i2c_new_ir(struct ivtv *itv, u32 hw, const char *type, u8 addr)/* Default to old black remote */ init_data->ir_codes =RC_MAP_RC5_TV ; init_data->internal_get_key_func =IR_KBD_GET_KEY_HAUP ; - init_data->type =IR_TYPE_RC5 ; init_data->name = itv->card_name;break ;case IVTV_HW_Z8F0811_IR_RX_HAUP :/* Default to grey remote */ init_data->ir_codes =RC_MAP_HAUPPAUGE_NEW ; init_data->internal_get_key_func =IR_KBD_GET_KEY_HAUP_XVR ; - init_data->type =IR_TYPE_RC5 ; init_data->name = itv->card_name;break ; }
drivers/media/video/saa7134/saa7134-input.c +10 -40
123 lines not on this page · raw message
drivers/staging/tm6000/tm6000-input.c +3 -9
@@ -25,7 +25,6 @@#include <linux/usb.h> #include <media/ir-core.h> -#include <media/ir-common.h> #include "tm6000.h" #include "tm6000-regs.h"
@@ -52,7 +51,6 @@ struct tm6000_ir_poll_result {struct tm6000_IR {struct tm6000_core *dev;struct ir_input_dev *input; -struct ir_input_state ir;char name[32 ];char phys[32 ];
@@ -184,10 +182,9 @@ static void tm6000_ir_handle_key(struct tm6000_IR *ir) poll_result.rc_data[0], poll_result.rc_data[1]);if (poll_result.rc_data[0 ] !=0xff && ir->key ==1 ) { -ir_input_keydown (ir->input->input_dev, &ir->ir, - poll_result.rc_data[0 ] | poll_result.rc_data[1 ] <<8 ); - -ir_input_nokey (ir->input->input_dev, &ir->ir); +ir_keydown (ir->input->input_dev, + poll_result.rc_data[0 ] | poll_result.rc_data[1 ] <<8 , +0 ); ir->key =0 ; }return ;
@@ -274,9 +271,6 @@ int tm6000_ir_init(struct tm6000_core *dev)strlcat (ir->phys,"/input0" ,sizeof (ir->phys));tm6000_ir_change_protocol (ir,IR_TYPE_UNKNOWN ); - err =ir_input_init (ir_input_dev->input_dev, &ir->ir,IR_TYPE_OTHER ); -if (err <0 ) - goto err_out_free; ir_input_dev->input_dev->name = ir->name; ir_input_dev->input_dev->phys = ir->phys;
include/media/ir-common.h +3 -27
@@ -1,7 +1,7 @@/* -* -* some common structs and functions to handle infrared remotes via -* input layer ... +* some common functions to handle infrared remote protocol decoding for +* drivers which have not yet been (or can't be) converted to use the +* regular protocol decoders... * * (c) 2003 Gerd Knorr <[email protected]> [SuSE Labs] *
@@ -33,30 +33,17 @@#define RC5_ADDR (x) (((x)>>6)&31)#define RC5_INSTR (x) ((x)&63) -struct ir_input_state { -/* configuration */ -u64 ir_type; - -/* key info */ -u32 ir_key;/* ir scancode */ -u32 keycode;/* linux key code */ -int keypressed;/* current state */ -}; -/* this was saa7134_ir and bttv_ir, moved here for * rc5 decoding. */ struct card_ir {struct input_dev *dev; -struct ir_input_state ir;char name[32 ];char phys[32 ];int users; -u32 running:1 ;struct ir_dev_props props;/* Usual gpio signalling */ -u32 mask_keycode;u32 mask_keydown;u32 mask_keyup;
@@ -65,7 +52,6 @@ struct card_ir {int shift_by;int start;// What should RC5_START() be int addr;// What RC5_ADDR() should be. -int rc5_key_timeout;int rc5_remote_gap;struct work_struct work;struct timer_list timer;
@@ -73,8 +59,6 @@ struct card_ir {/* RC5 gpio */ u32 rc5_gpio;struct timer_list timer_end;/* timer_end for code completion */ -struct timer_list timer_keyup;/* timer_end for key release */ -u32 last_rc5;/* last good rc5 code */ u32 last_bit;/* last raw bit seen */ u32 code;/* raw code under construction */ struct timeval base_time;/* time of last seen code */
@@ -89,19 +73,11 @@ struct card_ir { };/* Routines from ir-functions.c */ - -int ir_input_init (struct input_dev *dev,struct ir_input_state *ir, -const u64 ir_type); -void ir_input_nokey (struct input_dev *dev,struct ir_input_state *ir); -void ir_input_keydown (struct input_dev *dev,struct ir_input_state *ir, -u32 ir_key);u32 ir_extract_bits (u32 data,u32 mask);int ir_dump_samples (u32 *samples,int count);int ir_decode_biphase (u32 *samples,int count,int low,int high);int ir_decode_pulsedistance (u32 *samples,int count,int low,int high);u32 ir_rc5_decode (unsigned int code); -void ir_rc5_timer_end (unsigned long data); -void ir_rc5_timer_keyup (unsigned long data);#endif
include/media/ir-core.h +2 -0
@@ -155,7 +155,9 @@ static inline int ir_input_register(struct input_dev *dev,void ir_input_unregister (struct input_dev *input_dev);void ir_repeat (struct input_dev *dev); +void ir_keyup (struct input_dev *dev);void ir_keydown (struct input_dev *dev,int scancode,u8 toggle); +void ir_keydown_notimeout (struct input_dev *dev,int scancode,u8 toggle);u32 ir_g_keycode_from_table (struct input_dev *input_dev,u32 scancode);struct ir_raw_event {
include/media/ir-kbd-i2c.h +1 -3
@@ -10,8 +10,7 @@ struct IR_i2c {struct i2c_client *c;struct input_dev *input; -struct ir_input_state ir; -u64 ir_type; +/* Used to avoid fast repeating */ unsigned char old;
@@ -36,7 +35,6 @@ enum ir_kbd_get_key_fn {struct IR_i2c_init_data {char *ir_codes;const char *name; -u64 type;/* IR_TYPE_RC5, etc */ /* * Specify either a function pointer or a value indicating one of * ir_kbd_i2c's internal get_key functions
PATCH 3/5 imon: split mouse events to a separate input dev
In reply to David HärdemanThis is a stab at separating the mouse (and front panel/knob) events out to a separate input device. This is necessary in preparation for the next patch which makes the rc-core input dev opaque to rc drivers.
I can't verify the correctness of the patch beyond the fact that it compiles without warnings. The driver has resisted most of my attempts at understanding it properly...for example, the double calls to le64_to_cpu() and be64_to_cpu() which are applied in imon_incoming_packet() and imon_panel_key_lookup() would amount to a bswab64() call, irregardless of the cpu endianness, and I think the code wouldn't have worked on a big-endian machine...
--- drivers/media/IR/imon.c | 261 +++++++++++++++++++++++++++-------------------- 1 files changed, 150 insertions(+), 111 deletions(-)
drivers/media/IR/imon.c +150 -111
@@ -121,21 +121,27 @@ struct imon_context {u16 vendor;/* usb vendor ID */ u16 product;/* usb product ID */ -struct input_dev *idev;/* input device for remote */ +struct input_dev *rdev;/* input device for remote */ +struct input_dev *idev;/* input device for front panel/knob and +* remote (fake) mouse +*/ struct input_dev *touch;/* input device for touchscreen */ u32 kc;/* current input keycode */ u32 last_keycode;/* last reported input keycode */ +u32 rc_scancode;/* the computed remote scancode */ +u8 rc_toggle;/* the computed remote toggle */ u64 ir_type;/* iMON or MCE (RC6) IR protocol? */ -u8 mce_toggle_bit;/* last mce toggle bit */ bool release_code;/* some keys send a release code */ u8 display_type;/* store the display type */ bool pad_mouse;/* toggle kbd(0)/mouse(1) mode */ +char name_rdev[128 ];/* rc device name */ +char phys_rdev[64 ];/* rc device phys path */ +char name_idev[128 ];/* input device name */ char phys_idev[64 ];/* input device phys path */ -struct timer_list itimer;/* input device timer, need for rc6 */ char name_touch[128 ];/* touch screen name */ char phys_touch[64 ];/* touch screen phys path */
@@ -956,17 +962,6 @@ static void usb_tx_callback(struct urb *urb) }/** -* mce/rc6 keypresses have no distinct release code, use timer -*/ -static void imon_mce_timeout (unsigned long data) -{ -struct imon_context *ictx = (struct imon_context *)data; - -input_report_key (ictx->idev, ictx->last_keycode,0 ); -input_sync (ictx->idev); -} - -/** * report touchscreen input */ static void imon_touch_display_timeout (unsigned long data)
@@ -1006,9 +1001,6 @@ int imon_ir_change_protocol(void *priv, u64 ir_type)dev_dbg (dev,"Configuring IR receiver for MCE protocol\n" ); ir_proto_packet[0 ] =0x01 ; pad_mouse = false; -init_timer (&ictx->itimer); - ictx->itimer.data = (unsigned long )ictx; - ictx->itimer.function = imon_mce_timeout;break ;case IR_TYPE_UNKNOWN :case IR_TYPE_OTHER :
@@ -1147,20 +1139,21 @@ static int stabilize(int a, int b, u16 timeout, u16 threshold)return result; } -static u32 imon_remote_key_lookup (struct imon_context *ictx,u32 hw_code) +static u32 imon_remote_key_lookup (struct imon_context *ictx,u32 scancode) { -u32 scancode =be32_to_cpu (hw_code);u32 keycode;u32 release;bool is_release_code = false;/* Look for the initial press of a button */ - keycode =ir_g_keycode_from_table (ictx->idev, scancode); + keycode =ir_g_keycode_from_table (ictx->rdev, scancode); + ictx->rc_toggle =0x0 ; + ictx->rc_scancode = scancode;/* Look for the release of a button */ if (keycode ==KEY_RESERVED ) { release = scancode & ~0x4000 ; - keycode =ir_g_keycode_from_table (ictx->idev, release); + keycode =ir_g_keycode_from_table (ictx->rdev, release);if (keycode !=KEY_RESERVED ) is_release_code = true; }
@@ -1170,9 +1163,8 @@ static u32 imon_remote_key_lookup(struct imon_context *ictx, u32 hw_code)return keycode; } -static u32 imon_mce_key_lookup (struct imon_context *ictx,u32 hw_code) +static u32 imon_mce_key_lookup (struct imon_context *ictx,u32 scancode) { -u32 scancode =be32_to_cpu (hw_code);u32 keycode;#define MCE_KEY_MASK 0x7000
@@ -1186,18 +1178,18 @@ static u32 imon_mce_key_lookup(struct imon_context *ictx, u32 hw_code)* but we can't or them into all codes, as some keys are decoded in * a different way w/o the same use of the toggle bit... */ -if ((scancode >>24 ) &0x80 ) +if (scancode &0x80000000 ) scancode = scancode |MCE_KEY_MASK |MCE_TOGGLE_BIT ; - keycode =ir_g_keycode_from_table (ictx->idev, scancode); + ictx->rc_scancode = scancode; + keycode =ir_g_keycode_from_table (ictx->rdev, scancode);return keycode; } -static u32 imon_panel_key_lookup (u64 hw_code) +static u32 imon_panel_key_lookup (u64 code) {int i; -u64 code =be64_to_cpu (hw_code);u32 keycode =KEY_RESERVED ;for (i =0 ; i <ARRAY_SIZE (imon_panel_key_table); i++) {
@@ -1284,8 +1276,7 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf)int dir =0 ;char rel_x =0x00 , rel_y =0x00 ;u16 timeout, threshold; -u64 temp_key; -u32 remote_key; +u32 scancode =0 ;/* * The imon directional pad functions more like a touchpad. Bytes 3 & 4
@@ -1314,21 +1305,26 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf) } buf[2 ] = dir &0xFF ; buf[3 ] = (dir >>8 ) &0xFF ; -memcpy (&temp_key, buf,sizeof (temp_key)); - remote_key = (u32) (le64_to_cpu (temp_key) - &0xffffffff ); - ictx->kc =imon_remote_key_lookup (ictx, - remote_key); + scancode =be32_to_cpu (*((u32 *)buf)); } }else { +/* Hack alert: instead of using keycodes, +* we have to use hardcoded scancodes +*/ if (abs (rel_y) >abs (rel_x)) { buf[2 ] = (rel_y >0 ) ?0x7F :0x80 ; buf[3 ] =0 ; - ictx->kc = (rel_y >0 ) ?KEY_DOWN :KEY_UP ; +if (rel_y >0 ) + scancode =0x01007f00 ;/* DOWN */ +else + scancode =0x01008000 ;/* UP */ }else { buf[2 ] =0 ; buf[3 ] = (rel_x >0 ) ?0x7F :0x80 ; - ictx->kc = (rel_x >0 ) ?KEY_RIGHT :KEY_LEFT ; +if (rel_x >0 ) + scancode =0x0100007f ;/* RIGHT */ +else + scancode =0x01000080 ;/* LEFT */ } }
@@ -1370,29 +1366,37 @@ static void imon_pad_to_keys(struct imon_context *ictx, unsigned char *buf) } buf[2 ] = dir &0xFF ; buf[3 ] = (dir >>8 ) &0xFF ; -memcpy (&temp_key, buf,sizeof (temp_key)); - remote_key = (u32) (le64_to_cpu (temp_key) &0xffffffff ); - ictx->kc =imon_remote_key_lookup (ictx, remote_key); + scancode =be32_to_cpu (*((u32 *)buf)); }else { +/* Hack alert: instead of using keycodes, +* we have to use hardcoded scancodes +*/ if (abs (rel_y) >abs (rel_x)) { buf[2 ] = (rel_y >0 ) ?0x7F :0x80 ; buf[3 ] =0 ; - ictx->kc = (rel_y >0 ) ?KEY_DOWN :KEY_UP ; +if (rel_y >0 ) + scancode =0x01007f00 ;/* DOWN */ +else + scancode =0x01008000 ;/* UP */ }else { buf[2 ] =0 ; buf[3 ] = (rel_x >0 ) ?0x7F :0x80 ; - ictx->kc = (rel_x >0 ) ?KEY_RIGHT :KEY_LEFT ; +if (rel_x >0 ) + scancode =0x0100007f ;/* RIGHT */ +else + scancode =0x01000080 ;/* LEFT */ } } } + +if (scancode) + ictx->kc =imon_remote_key_lookup (ictx, scancode); }static int imon_parse_press_type (struct imon_context *ictx,unsigned char *buf,u8 ktype) {int press_type =0 ; -int rep_delay = ictx->idev->rep[REP_DELAY ]; -int rep_period = ictx->idev->rep[REP_PERIOD ];/* key release of 0x02XXXXXX key */ if (ictx->kc ==KEY_RESERVED && buf[0 ] ==0x02 && buf[3 ] ==0x00 )
@@ -1408,22 +1412,10 @@ static int imon_parse_press_type(struct imon_context *ictx, buf[2] == 0x81 && buf[3] == 0xb7) ictx->kc = ictx->last_keycode; -/* mce-specific button handling */ +/* mce-specific button handling, no keyup events */ else if (ktype == IMON_KEY_MCE) { -/* initial press */ -if (ictx->kc != ictx->last_keycode - || buf[2 ] != ictx->mce_toggle_bit) { - ictx->last_keycode = ictx->kc; - ictx->mce_toggle_bit = buf[2 ]; - press_type =1 ; -mod_timer (&ictx->itimer, - jiffies +msecs_to_jiffies (rep_delay)); -/* repeat */ - }else { - press_type =2 ; -mod_timer (&ictx->itimer, - jiffies +msecs_to_jiffies (rep_period)); - } + ictx->rc_toggle = buf[2 ]; + press_type =1 ;/* incoherent or irrelevant data */ } else if (ictx->kc == KEY_RESERVED)
@@ -1452,15 +1444,13 @@ static void imon_incoming_packet(struct imon_context *ictx,u32 kc;bool norelease = false;int i; -u64 temp_key; -u64 panel_key =0 ; -u32 remote_key =0 ; +u64 scancode;struct input_dev *idev =NULL ;int press_type =0 ;int msec;struct timeval t;static struct timeval prev_time = {0 ,0 }; -u8 ktype =IMON_KEY_IMON ; +u8 ktype; idev = ictx->idev;
@@ -1469,19 +1459,21 @@ static void imon_incoming_packet(struct imon_context *ictx,return ;/* Figure out what key was pressed */ -memcpy (&temp_key, buf,sizeof (temp_key));if (len ==8 && buf[7 ] ==0xee ) { + scancode =be64_to_cpu (*((u64 *)buf)); ktype =IMON_KEY_PANEL ; - panel_key =le64_to_cpu (temp_key); - kc =imon_panel_key_lookup (panel_key); + kc =imon_panel_key_lookup (scancode); }else { - remote_key = (u32) (le64_to_cpu (temp_key) &0xffffffff ); + scancode =be32_to_cpu (*((u32 *)buf));if (ictx->ir_type ==IR_TYPE_RC6 ) { + ktype =IMON_KEY_IMON ;if (buf[0 ] ==0x80 ) ktype =IMON_KEY_MCE ; - kc =imon_mce_key_lookup (ictx, remote_key); - }else - kc =imon_remote_key_lookup (ictx, remote_key); + kc =imon_mce_key_lookup (ictx, scancode); + }else { + ktype =IMON_KEY_IMON ; + kc =imon_remote_key_lookup (ictx, scancode); + } }/* keyboard/mouse mode toggle button */
@@ -1504,7 +1496,7 @@ static void imon_incoming_packet(struct imon_context *ictx,if (ictx->display_type ==IMON_DISPLAY_TYPE_VGA && len ==8 && buf[7 ] ==0x86 ) {imon_touch_event (ictx, buf); - +return ;/* look for mouse events with pad in mouse mode */ }else if (ictx->pad_mouse) {if (imon_mouse_event (ictx, buf, len))
@@ -1531,12 +1523,25 @@ static void imon_incoming_packet(struct imon_context *ictx,if (press_type <0 ) goto not_input_data; +if (ktype ==IMON_KEY_MCE ) { +ir_keydown (ictx->rdev, ictx->rc_scancode, ictx->rc_toggle); + ictx->last_keycode = ictx->kc; +return ; + }else if (ktype ==IMON_KEY_IMON ) { +if (press_type ==0 ) +ir_keyup (ictx->rdev); +else +ir_keydown_notimeout (ictx->rdev, ictx->rc_scancode,0 ); + ictx->last_keycode = ictx->kc; +return ; + } + +/* Only panel type events left to process */ if (ictx->kc ==KEY_UNKNOWN ) goto unknown_key; -/* KEY_MUTE repeats from MCE and knob need to be suppressed */ -if ((ictx->kc ==KEY_MUTE && ictx->kc == ictx->last_keycode) - && (buf[7 ] ==0xee || ktype ==IMON_KEY_MCE )) { +/* KEY_MUTE repeats from knob need to be suppressed */ +if (ictx->kc ==KEY_MUTE && ictx->kc == ictx->last_keycode) {do_gettimeofday (&t); msec =tv2int (&t, &prev_time); prev_time = t;
@@ -1547,11 +1552,9 @@ static void imon_incoming_packet(struct imon_context *ictx,input_report_key (idev, ictx->kc, press_type);input_sync (idev); -/* panel keys and some remote keys don't generate a release */ -if (panel_key || norelease) { -input_report_key (idev, ictx->kc,0 ); -input_sync (idev); - } +/* panel keys don't generate a release */ +input_report_key (idev, ictx->kc,0 ); +input_sync (idev); ictx->last_keycode = ictx->kc;
@@ -1559,8 +1562,7 @@ static void imon_incoming_packet(struct imon_context *ictx, unknown_key:dev_info (dev,"%s: unknown keypress, code 0x%llx\n" , __func__, - (panel_key ?be64_to_cpu (panel_key) : -be32_to_cpu (remote_key))); + (long long )scancode);return ; not_input_data:
@@ -1651,31 +1653,71 @@ static void usb_rx_callback_intf1(struct urb *urb)usb_submit_urb (ictx->rx_urb_intf1,GFP_ATOMIC ); } +static struct input_dev *imon_init_rdev (struct imon_context *ictx) +{ +struct input_dev *rdev; +struct ir_dev_props *props; +int ret; + + rdev =input_allocate_device (); + props =kzalloc (sizeof (*props),GFP_KERNEL ); +if (!rdev || !props) { +dev_err (ictx->dev,"remote control dev allocation failed\n" ); + goto out; + } + +snprintf (ictx->name_rdev,sizeof (ictx->name_rdev), +"iMON Remote (%04x:%04x)" , ictx->vendor, ictx->product); +usb_make_path (ictx->usbdev_intf0, ictx->phys_rdev, +sizeof (ictx->phys_rdev)); +strlcat (ictx->phys_rdev,"/input0" ,sizeof (ictx->phys_rdev)); + + rdev->name = ictx->name_rdev; + rdev->phys = ictx->phys_rdev; +usb_to_input_id (ictx->usbdev_intf0, &rdev->id); + rdev->dev.parent = ictx->dev; + rdev->evbit[0 ] =BIT_MASK (EV_KEY ) |BIT_MASK (EV_REP ); +input_set_drvdata (rdev, ictx); + + props->priv = ictx; + props->driver_type =RC_DRIVER_SCANCODE ; + props->allowed_protos =IR_TYPE_OTHER |IR_TYPE_RC6 ;/* iMON PAD or MCE */ + props->change_protocol = imon_ir_change_protocol; + ictx->props = props; + + ret =ir_input_register (rdev,RC_MAP_IMON_PAD , props,MOD_NAME ); +if (ret <0 ) { +dev_err (ictx->dev,"remote input dev register failed\n" ); + goto out; + } + +return rdev; + +out: +kfree (props); +input_free_device (rdev); +return NULL ; +} +static struct input_dev *imon_init_idev (struct imon_context *ictx) {struct input_dev *idev; -struct ir_dev_props *props;int ret, i; idev =input_allocate_device ();if (!idev) { -dev_err (ictx->dev,"remote input dev allocation failed\n" ); - goto idev_alloc_failed; - } - - props =kzalloc (sizeof (struct ir_dev_props ),GFP_KERNEL ); -if (!props) { -dev_err (ictx->dev,"remote ir dev props allocation failed\n" ); - goto props_alloc_failed; +dev_err (ictx->dev,"input dev allocation failed\n" ); + goto out; }snprintf (ictx->name_idev,sizeof (ictx->name_idev), -"iMON Remote (%04x:%04x)" , ictx->vendor, ictx->product); +"iMON Front Panel, Knob and Mouse (%04x:%04x)" , + ictx->vendor, ictx->product); idev->name = ictx->name_idev;usb_make_path (ictx->usbdev_intf0, ictx->phys_idev,sizeof (ictx->phys_idev)); -strlcat (ictx->phys_idev,"/input0" ,sizeof (ictx->phys_idev)); +strlcat (ictx->phys_idev,"/input1" ,sizeof (ictx->phys_idev)); idev->phys = ictx->phys_idev; idev->evbit[0 ] =BIT_MASK (EV_KEY ) |BIT_MASK (EV_REP ) |BIT_MASK (EV_REL );
@@ -1691,30 +1733,20 @@ static struct input_dev *imon_init_idev(struct imon_context *ictx)__set_bit (kc, idev->keybit); } - props->priv = ictx; - props->driver_type =RC_DRIVER_SCANCODE ; -/* IR_TYPE_OTHER maps to iMON PAD remote, IR_TYPE_RC6 to MCE remote */ - props->allowed_protos =IR_TYPE_OTHER |IR_TYPE_RC6 ; - props->change_protocol = imon_ir_change_protocol; - ictx->props = props; -usb_to_input_id (ictx->usbdev_intf0, &idev->id); idev->dev.parent = ictx->dev; +input_set_drvdata (idev, ictx); - ret =ir_input_register (idev,RC_MAP_IMON_PAD , props,MOD_NAME ); + ret =input_register_device (idev);if (ret <0 ) { -dev_err (ictx->dev,"remote input dev register failed\n" ); - goto idev_register_failed; +dev_err (ictx->dev,"input dev register failed\n" ); + goto out; }return idev; -idev_register_failed: -kfree (props); -props_alloc_failed: +out:input_free_device (idev); -idev_alloc_failed: -return NULL ; }
@@ -1736,7 +1768,7 @@ static struct input_dev *imon_init_touch(struct imon_context *ictx)usb_make_path (ictx->usbdev_intf1, ictx->phys_touch,sizeof (ictx->phys_touch)); -strlcat (ictx->phys_touch,"/input1" ,sizeof (ictx->phys_touch)); +strlcat (ictx->phys_touch,"/input2" ,sizeof (ictx->phys_touch)); touch->phys = ictx->phys_touch; touch->evbit[0] =
@@ -1911,6 +1943,12 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf) goto idev_setup_failed; } + ictx->rdev =imon_init_rdev (ictx); +if (!ictx->rdev) { +dev_err (dev,"%s: rc device setup failed\n" , __func__); + goto rdev_setup_failed; + } + usb_fill_int_urb(ictx->rx_urb_intf0, ictx->usbdev_intf0, usb_rcvintpipe(ictx->usbdev_intf0, ictx->rx_endpoint_intf0->bEndpointAddress),
@@ -1928,7 +1966,9 @@ static struct imon_context *imon_init_intf0(struct usb_interface *intf)return ictx; urb_submit_failed: -ir_input_unregister (ictx->idev); +ir_input_unregister (ictx->rdev); +rdev_setup_failed: +input_unregister_device (ictx->idev); idev_setup_failed: find_endpoint_failed:mutex_unlock (&ictx->lock);
@@ -2289,7 +2329,8 @@ static void __devexit imon_disconnect(struct usb_interface *interface)if (ifnum ==0 ) { ictx->dev_present_intf0 = false;usb_kill_urb (ictx->rx_urb_intf0); -ir_input_unregister (ictx->idev); +input_unregister_device (ictx->idev); +ir_input_unregister (ictx->rdev);if (ictx->display_supported) {if (ictx->display_type ==IMON_DISPLAY_TYPE_LCD )usb_deregister_dev (interface, &imon_lcd_class);
@@ -2310,8 +2351,6 @@ static void __devexit imon_disconnect(struct usb_interface *interface)if (!ictx->display_isopen)free_imon_context (ictx); }else { -if (ictx->ir_type ==IR_TYPE_RC6 ) -del_timer_sync (&ictx->itimer);mutex_unlock (&ictx->lock); }
PATCH 4/5 rc-core: make struct rc_dev the primary interface for rc drivers
In reply to David HärdemanThis patch merges the ir_input_dev and ir_dev_props structs into a single struct called rc_dev. The drivers and various functions in rc-core used by the drivers are also changed to use rc_dev as the primary interface when dealing with rc-core.
This means that the input_dev is abstracted away from the drivers which is necessary if we ever want to support multiple input devs per rc device.
The new API is similar to what the input subsystem uses, i.e:rc_device_alloc()rc_device_free()rc_device_register()rc_device_unregister()
--- drivers/media/IR/ene_ir.c | 121 ++--- drivers/media/IR/ene_ir.h | 3 drivers/media/IR/imon.c | 54 +- drivers/media/IR/ir-core-priv.h | 10 drivers/media/IR/ir-jvc-decoder.c | 13 drivers/media/IR/ir-lirc-codec.c | 111 ++-- drivers/media/IR/ir-nec-decoder.c | 15 - drivers/media/IR/ir-rc5-decoder.c | 13 drivers/media/IR/ir-rc6-decoder.c | 17 - drivers/media/IR/ir-sony-decoder.c | 11 drivers/media/IR/mceusb.c | 93 +-- drivers/media/IR/rc-core.c | 726 ++++++++++++--------------- drivers/media/IR/streamzap.c | 75 +-- drivers/media/dvb/dm1105/dm1105.c | 40 + drivers/media/dvb/dvb-usb/dib0700.h | 2 drivers/media/dvb/dvb-usb/dib0700_core.c | 11 drivers/media/dvb/dvb-usb/dib0700_devices.c | 116 +--- drivers/media/dvb/dvb-usb/dvb-usb-remote.c | 78 ++- drivers/media/dvb/dvb-usb/dvb-usb.h | 12 drivers/media/dvb/mantis/mantis_common.h | 4 drivers/media/dvb/mantis/mantis_input.c | 74 ++- drivers/media/dvb/siano/smscoreapi.c | 2 drivers/media/dvb/siano/smsir.c | 52 +- drivers/media/dvb/siano/smsir.h | 3 drivers/media/dvb/ttpci/budget-ci.c | 49 +- drivers/media/video/bt8xx/bttv-input.c | 41 +- drivers/media/video/cx23885/cx23885-input.c | 64 +- drivers/media/video/cx23885/cx23885.h | 3 drivers/media/video/cx88/cx88-input.c | 78 +-- drivers/media/video/em28xx/em28xx-input.c | 72 +-- drivers/media/video/ir-kbd-i2c.c | 25 + drivers/media/video/saa7134/saa7134-input.c | 72 +-- drivers/staging/tm6000/tm6000-input.c | 87 +-- include/media/ir-common.h | 3 include/media/ir-core.h | 192 +++---- include/media/ir-kbd-i2c.h | 2 36 files changed, 1066 insertions(+), 1278 deletions(-)
drivers/media/IR/ene_ir.c +58 -63
@@ -263,13 +263,13 @@ static void ene_rx_set_inputs(struct ene_device *dev) ENE_CIR_CONF2_LEARN2 : 0, ENE_CIR_CONF2_LEARN2);if (dev->rx_fan_input_inuse) { - dev->props->rx_resolution =ENE_SAMPLE_PERIOD_FAN *1000 ; + dev->rc->rx_resolution =ENE_SAMPLE_PERIOD_FAN *1000 ; - dev->props->timeout = + dev->rc->timeout =ENE_FAN_VALUE_MASK *ENE_SAMPLE_PERIOD_FAN *1000 ; }else { - dev->props->rx_resolution = sample_period *1000 ; - dev->props->timeout =ENE_MAXGAP *1000 ; + dev->rc->rx_resolution = sample_period *1000 ; + dev->rc->timeout =ENE_MAXGAP *1000 ; } }
@@ -305,8 +305,8 @@ static void ene_rx_enable(struct ene_device *dev) ENE_FW1_ENABLE | ENE_FW1_IRQ);/* enter idle mode */ -ir_raw_event_set_idle (dev->idev,1 ); -ir_raw_event_reset (dev->idev); +ir_raw_event_set_idle (dev->rc,1 ); +ir_raw_event_reset (dev->rc); }
@@ -322,8 +322,8 @@ static void ene_rx_disable(struct ene_device *dev)/* disable hardware IRQ and firmware flag */ ene_hw_write_reg_mask (dev,ENE_FW1 ,0 ,ENE_FW1_ENABLE |ENE_FW1_IRQ ); -ir_raw_event_set_idle (dev->idev,1 ); -ir_raw_event_reset (dev->idev); +ir_raw_event_set_idle (dev->rc,1 ); +ir_raw_event_reset (dev->rc); }
@@ -561,7 +561,7 @@ static irqreturn_t ene_isr(int irq, void *data)#if 0 /* TODO */ if (dev->carrier_detect_enabled && carrier) -ir_raw_event_report_frequency (dev->idev, carrier); +ir_raw_event_report_frequency (dev->rc, carrier);#endif for (i =0 ; i <ENE_SAMPLES_SIZE ; i++) {
@@ -598,10 +598,10 @@ static irqreturn_t ene_isr(int irq, void *data) ev.duration = hw_sample *1000 ; ev.pulse = pulse; -ir_raw_event_store_with_filter (dev->idev, &ev); +ir_raw_event_store_with_filter (dev->rc, &ev); } -ir_raw_event_handle (dev->idev); +ir_raw_event_handle (dev->rc); unlock:spin_unlock_irqrestore (&dev->hw_lock, flags);return retval;
@@ -624,9 +624,9 @@ static void ene_setup_settings(struct ene_device *dev) }/* outside interface: called on first open*/ -static int ene_open (void *data) +static int ene_open (struct rc_dev *rc) { -struct ene_device *dev = (struct ene_device *)data; +struct ene_device *dev = (struct ene_device *)rc->priv;unsigned long flags;spin_lock_irqsave (&dev->hw_lock, flags);
@@ -638,9 +638,9 @@ static int ene_open(void *data) }/* outside interface: called on device close*/ -static void ene_close (void *data) +static void ene_close (struct rc_dev *rc) { -struct ene_device *dev = (struct ene_device *)data; +struct ene_device *dev = (struct ene_device *)rc->priv;unsigned long flags;spin_lock_irqsave (&dev->hw_lock, flags);
@@ -650,9 +650,9 @@ static void ene_close(void *data) }/* outside interface: set transmitter mask */ -static int ene_set_tx_mask (void *data,u32 tx_mask) +static int ene_set_tx_mask (struct rc_dev *rc,u32 tx_mask) { -struct ene_device *dev = (struct ene_device *)data; +struct ene_device *dev = (struct ene_device *)rc->priv;unsigned long flags;ene_dbg ("TX: attempt to set transmitter mask %02x" , tx_mask);
@@ -670,9 +670,9 @@ static int ene_set_tx_mask(void *data, u32 tx_mask) }/* outside interface : set tx carrier */ -static int ene_set_tx_carrier (void *data,u32 carrier) +static int ene_set_tx_carrier (struct rc_dev *rc,u32 carrier) { -struct ene_device *dev = (struct ene_device *)data; +struct ene_device *dev = (struct ene_device *)rc->priv;unsigned long flags;u32 period =1000000 / carrier;/* (1 / freq) (* # usec in 1 sec) */
@@ -698,9 +698,9 @@ static int ene_set_tx_carrier(void *data, u32 carrier)/* outside interface: enable learning mode */ -static int ene_set_learning_mode (void *data,int enable) +static int ene_set_learning_mode (struct rc_dev *rc,int enable) { -struct ene_device *dev = (struct ene_device *)data; +struct ene_device *dev = (struct ene_device *)rc->priv;unsigned long flags;if (enable == dev->learning_enabled)return 0 ;
@@ -713,18 +713,17 @@ static int ene_set_learning_mode(void *data, int enable) }/* outside interface: set rec carrier */ -static int ene_set_rec_carrier (void *data,u32 min,u32 max) +static int ene_set_rec_carrier (struct rc_dev *rc,u32 min,u32 max) { -struct ene_device *dev = (struct ene_device *)data; -ene_set_learning_mode (dev, +ene_set_learning_mode (rc, max >ENE_NORMAL_RX_HI || min <ENE_NORMAL_RX_LOW );return 0 ; }/* outside interface: enable or disable idle mode */ -static void ene_rx_set_idle (void *data,int idle) +static void ene_rx_set_idle (struct rc_dev *rc,int idle) { -struct ene_device *dev = (struct ene_device *)data; +struct ene_device *dev = (struct ene_device *)rc->priv;ene_dbg ("%sabling idle mode" , idle ?"en" :"dis" ); ene_hw_write_reg_mask(dev, ENE_CIR_SAMPLE_PERIOD,
@@ -734,9 +733,9 @@ static void ene_rx_set_idle(void *data, int idle)/* outside interface: transmit */ -static int ene_transmit (void *data,int *buf,u32 n) +static int ene_transmit (struct rc_dev *rc,int *buf,u32 n) { -struct ene_device *dev = (struct ene_device *)data; +struct ene_device *dev = (struct ene_device *)rc->priv;unsigned long flags; dev->tx_buffer = buf;
@@ -775,17 +774,15 @@ static int ene_transmit(void *data, int *buf, u32 n)static int ene_probe (struct pnp_dev *pnp_dev,const struct pnp_device_id *id) {int error = -ENOMEM ; -struct ir_dev_props *ir_props; -struct input_dev *input_dev; +struct rc_dev *rc;struct ene_device *dev;/* allocate memory */ - input_dev =input_allocate_device (); - ir_props =kzalloc (sizeof (struct ir_dev_props ),GFP_KERNEL ); dev =kzalloc (sizeof (struct ene_device ),GFP_KERNEL ); + rc =rc_allocate_device (); -if (!input_dev || !ir_props || !dev) - goto error; +if (!dev || !rc) + goto error_free;/* validate resources */ error = -ENODEV ;
@@ -828,21 +825,22 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) "Simulation of TX activated\n"); } - ir_props->driver_type =RC_DRIVER_IR_RAW ; - ir_props->allowed_protos =IR_TYPE_ALL ; - ir_props->priv = dev; - ir_props->open = ene_open; - ir_props->close = ene_close; - ir_props->min_timeout =ENE_MINGAP *1000 ; - ir_props->max_timeout =ENE_MAXGAP *1000 ; - ir_props->timeout =ENE_MAXGAP *1000 ; + rc->driver_name =ENE_DRIVER_NAME ; + rc->map_name =RC_MAP_RC6_MCE ; + rc->driver_type =RC_DRIVER_IR_RAW ; + rc->allowed_protos =IR_TYPE_ALL ; + rc->priv = dev; + rc->open = ene_open; + rc->close = ene_close; + rc->min_timeout =ENE_MINGAP *1000 ; + rc->max_timeout =ENE_MAXGAP *1000 ; + rc->timeout =ENE_MAXGAP *1000 ;if (dev->hw_revision ==ENE_HW_B ) - ir_props->s_idle = ene_rx_set_idle; + rc->s_idle = ene_rx_set_idle; - dev->props = ir_props; - dev->idev = input_dev; + dev->rc = rc;/* don't allow too short/long sample periods */ if (sample_period <5 || sample_period >0x7F )
@@ -859,21 +857,21 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) sample_period =75 ; } - ir_props->rx_resolution = sample_period *1000 ; + rc->rx_resolution = sample_period *1000 ;if (dev->hw_learning_and_tx_capable) { - ir_props->s_learning_mode = ene_set_learning_mode; + rc->s_learning_mode = ene_set_learning_mode;if (input ==0 ) - ir_props->s_rx_carrier_range = ene_set_rec_carrier; + rc->s_rx_carrier_range = ene_set_rec_carrier;init_completion (&dev->tx_complete); - ir_props->tx_ir = ene_transmit; - ir_props->s_tx_mask = ene_set_tx_mask; - ir_props->s_tx_carrier = ene_set_tx_carrier; - ir_props->tx_resolution =ENE_TX_SMPL_PERIOD *1000 ; -/* ir_props->s_carrier_report = ene_set_carrier_report; */ + rc->tx_ir = ene_transmit; + rc->s_tx_mask = ene_set_tx_mask; + rc->s_tx_carrier = ene_set_tx_carrier; + rc->tx_resolution =ENE_TX_SMPL_PERIOD *1000 ; +/* rc->s_carrier_report = ene_set_carrier_report; */ }
@@ -881,17 +879,15 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id)device_set_wakeup_enable (&pnp_dev->dev,1 );if (dev->hw_learning_and_tx_capable) - input_dev->name ="ENE eHome Infrared Remote Transceiver" ; + dev->rc->input_name ="ENE eHome Infrared Remote Transceiver" ;else - input_dev->name ="ENE eHome Infrared Remote Receiver" ; + dev->rc->input_name ="ENE eHome Infrared Remote Receiver" ; - error = -ENODEV ; -if (ir_input_register (input_dev,RC_MAP_RC6_MCE , ir_props, -ENE_DRIVER_NAME )) + error =rc_register_device (rc); +if (error) goto error; -ene_printk (KERN_NOTICE ,"driver has been succesfully loaded\n" );return 0 ; error:
@@ -900,8 +896,8 @@ error:if (dev->hw_io)release_region (dev->hw_io,ENE_MAX_IO ); -input_free_device (input_dev); -kfree (ir_props); +error_free: +rc_free_device (rc);kfree (dev);return error; }
@@ -918,8 +914,7 @@ static void ene_remove(struct pnp_dev *pnp_dev)free_irq (dev->irq, dev);release_region (dev->hw_io,ENE_MAX_IO ); -ir_input_unregister (dev->idev); -kfree (dev->props); +rc_unregister_device (dev->rc);kfree (dev); }
drivers/media/IR/ene_ir.h +1 -2
@@ -189,8 +189,7 @@struct ene_device {struct pnp_dev *pnp_dev; -struct input_dev *idev; -struct ir_dev_props *props; +struct rc_dev *rc;int in_use;/* hw IO settings */
drivers/media/IR/imon.c +24 -30
125 lines not on this page · raw message
drivers/media/IR/ir-core-priv.h +5 -5
@@ -23,11 +23,11 @@ struct ir_raw_handler {struct list_head list;u64 protocols;/* which are handled by this handler */ -int (*decode)(struct input_dev *input_dev,struct ir_raw_event event); +int (*decode)(struct rc_dev *dev,struct ir_raw_event event);/* These two should only be used by the lirc decoder */ -int (*raw_register)(struct input_dev *input_dev); -int (*raw_unregister)(struct input_dev *input_dev); +int (*raw_register)(struct rc_dev *dev); +int (*raw_unregister)(struct rc_dev *dev); };struct ir_raw_event_ctrl {
@@ -36,7 +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 input_dev *input_dev;/* pointer to the parent input_dev */ +struct rc_dev *dev;/* pointer to the parent rc_dev */ u64 enabled_protocols;/* enabled raw protocol decoders */ /* raw decoder state follows */
@@ -77,7 +77,7 @@ struct ir_raw_event_ctrl {bool toggle; } jvc;struct lirc_codec { -struct ir_input_dev *ir_dev; +struct rc_dev *dev;struct lirc_driver *drv;int carrier_low; } lirc;
drivers/media/IR/ir-jvc-decoder.c +6 -7
@@ -37,17 +37,16 @@ enum jvc_state {/** * ir_jvc_decode() - Decode one JVC pulse or space -* @input_dev: the struct input_dev descriptor of the device +* @dev: the struct rc_dev descriptor of the device * @duration: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine */ -static int ir_jvc_decode (struct input_dev *input_dev,struct ir_raw_event ev) +static int ir_jvc_decode (struct rc_dev *dev,struct ir_raw_event ev) { -struct ir_input_dev *ir_dev =input_get_drvdata (input_dev); -struct jvc_dec *data = &ir_dev->raw->jvc; +struct jvc_dec *data = &dev->raw->jvc; -if (!(ir_dev->raw->enabled_protocols &IR_TYPE_JVC )) +if (!(dev->raw->enabled_protocols &IR_TYPE_JVC ))return 0 ;if (IS_RESET (ev)) {
@@ -139,12 +138,12 @@ again: 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); +ir_keydown (dev, scancode, data->toggle); data->first = false; data->old_bits = data->bits; }else if (data->bits == data->old_bits) {IR_dprintk (1 ,"JVC repeat\n" ); -ir_repeat (input_dev); +ir_repeat (dev); }else {IR_dprintk (1 ,"JVC invalid repeat msg\n" );break ;
drivers/media/IR/ir-lirc-codec.c +51 -60
267 lines not on this page · raw message
drivers/media/IR/ir-nec-decoder.c +7 -8
@@ -39,19 +39,18 @@ enum nec_state {/** * ir_nec_decode() - Decode one NEC pulse or space -* @input_dev: the struct input_dev descriptor of the device +* @dev: the struct rc_dev descriptor of the device * @duration: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine */ -static int ir_nec_decode (struct input_dev *input_dev,struct ir_raw_event ev) +static int ir_nec_decode (struct rc_dev *dev,struct ir_raw_event ev) { -struct ir_input_dev *ir_dev =input_get_drvdata (input_dev); -struct nec_dec *data = &ir_dev->raw->nec; +struct nec_dec *data = &dev->raw->nec;u32 scancode;u8 address, not_address, command, not_command; -if (!(ir_dev->raw->enabled_protocols &IR_TYPE_NEC )) +if (!(dev->raw->enabled_protocols &IR_TYPE_NEC ))return 0 ;if (IS_RESET (ev)) {
@@ -88,7 +87,7 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev) data->state =STATE_BIT_PULSE ;return 0 ; }else if (eq_margin (ev.duration,NEC_REPEAT_SPACE ,NEC_UNIT /2 )) { -ir_repeat (input_dev); +ir_repeat (dev);IR_dprintk (1 ,"Repeat last key\n" ); data->state =STATE_TRAILER_PULSE ;return 0 ;
@@ -114,7 +113,7 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev) geq_margin(ev.duration, NEC_TRAILER_SPACE, NEC_UNIT / 2)) {IR_dprintk (1 ,"Repeat last key\n" ); -ir_repeat (input_dev); +ir_repeat (dev); data->state =STATE_INACTIVE ;return 0 ;
@@ -178,7 +177,7 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev)if (data->is_nec_x) data->necx_repeat = true; -ir_keydown (input_dev, scancode,0 ); +ir_keydown (dev, scancode,0 ); data->state =STATE_INACTIVE ;return 0 ; }
drivers/media/IR/ir-rc5-decoder.c +6 -7
@@ -40,19 +40,18 @@ enum rc5_state {/** * ir_rc5_decode() - Decode one RC-5 pulse or space -* @input_dev: the struct input_dev descriptor of the device +* @dev: the struct rc_dev descriptor of the device * @ev: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine */ -static int ir_rc5_decode (struct input_dev *input_dev,struct ir_raw_event ev) +static int ir_rc5_decode (struct rc_dev *dev,struct ir_raw_event ev) { -struct ir_input_dev *ir_dev =input_get_drvdata (input_dev); -struct rc5_dec *data = &ir_dev->raw->rc5; +struct rc5_dec *data = &dev->raw->rc5;u8 toggle;u32 scancode; -if (!(ir_dev->raw->enabled_protocols &IR_TYPE_RC5 )) +if (!(dev->raw->enabled_protocols &IR_TYPE_RC5 ))return 0 ;if (IS_RESET (ev)) {
@@ -95,7 +94,7 @@ again:return 0 ;case STATE_BIT_END : -if (!is_transition (&ev, &ir_dev->raw->prev_ev)) +if (!is_transition (&ev, &dev->raw->prev_ev))break ;if (data->count == data->wanted_bits)
@@ -150,7 +149,7 @@ again: scancode, toggle); } -ir_keydown (input_dev, scancode, toggle); +ir_keydown (dev, scancode, toggle); data->state =STATE_INACTIVE ;return 0 ; }
drivers/media/IR/ir-rc6-decoder.c +8 -9
@@ -70,19 +70,18 @@ static enum rc6_mode rc6_mode(struct rc6_dec *data)/** * ir_rc6_decode() - Decode one RC6 pulse or space -* @input_dev: the struct input_dev descriptor of the device +* @dev: the struct rc_dev descriptor of the device * @ev: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine */ -static int ir_rc6_decode (struct input_dev *input_dev,struct ir_raw_event ev) +static int ir_rc6_decode (struct rc_dev *dev,struct ir_raw_event ev) { -struct ir_input_dev *ir_dev =input_get_drvdata (input_dev); -struct rc6_dec *data = &ir_dev->raw->rc6; +struct rc6_dec *data = &dev->raw->rc6;u32 scancode;u8 toggle; -if (!(ir_dev->raw->enabled_protocols &IR_TYPE_RC6 )) +if (!(dev->raw->enabled_protocols &IR_TYPE_RC6 ))return 0 ;if (IS_RESET (ev)) {
@@ -138,7 +137,7 @@ again:return 0 ;case STATE_HEADER_BIT_END : -if (!is_transition (&ev, &ir_dev->raw->prev_ev)) +if (!is_transition (&ev, &dev->raw->prev_ev))break ;if (data->count ==RC6_HEADER_NBITS )
@@ -158,7 +157,7 @@ again:return 0 ;case STATE_TOGGLE_END : -if (!is_transition (&ev, &ir_dev->raw->prev_ev) || +if (!is_transition (&ev, &dev->raw->prev_ev) || !geq_margin (ev.duration,RC6_TOGGLE_END ,RC6_UNIT /2 ))break ;
@@ -203,7 +202,7 @@ again:return 0 ;case STATE_BODY_BIT_END : -if (!is_transition (&ev, &ir_dev->raw->prev_ev)) +if (!is_transition (&ev, &dev->raw->prev_ev))break ;if (data->count == data->wanted_bits)
@@ -242,7 +241,7 @@ again: goto out; } -ir_keydown (input_dev, scancode, toggle); +ir_keydown (dev, scancode, toggle); data->state =STATE_INACTIVE ;return 0 ; }
drivers/media/IR/ir-sony-decoder.c +5 -6
@@ -33,19 +33,18 @@ enum sony_state {/** * ir_sony_decode() - Decode one Sony pulse or space -* @input_dev: the struct input_dev descriptor of the device +* @dev: the struct rc_dev descriptor of the device * @ev: the struct ir_raw_event descriptor of the pulse/space * * This function returns -EINVAL if the pulse violates the state machine */ -static int ir_sony_decode (struct input_dev *input_dev,struct ir_raw_event ev) +static int ir_sony_decode (struct rc_dev *dev,struct ir_raw_event ev) { -struct ir_input_dev *ir_dev =input_get_drvdata (input_dev); -struct sony_dec *data = &ir_dev->raw->sony; +struct sony_dec *data = &dev->raw->sony;u32 scancode;u8 device, subdevice, function; -if (!(ir_dev->raw->enabled_protocols &IR_TYPE_SONY )) +if (!(dev->raw->enabled_protocols &IR_TYPE_SONY ))return 0 ;if (IS_RESET (ev)) {
@@ -143,7 +142,7 @@ static int ir_sony_decode(struct input_dev *input_dev, struct ir_raw_event ev) scancode = device <<16 | subdevice <<8 | function;IR_dprintk (1 ,"Sony(%u) scancode 0x%05x\n" , data->count, scancode); -ir_keydown (input_dev, scancode,0 ); +ir_keydown (dev, scancode,0 ); data->state =STATE_INACTIVE ;return 0 ; }
drivers/media/IR/mceusb.c +40 -53
188 lines not on this page · raw message
drivers/media/IR/rc-core.c +324 -402
1,241 lines not on this page · raw message
drivers/media/IR/streamzap.c +32 -43
162 lines not on this page · raw message
drivers/media/dvb/dm1105/dm1105.c +21 -19
@@ -266,7 +266,7 @@ static void dm1105_card_list(struct pci_dev *pci)/* infrared remote control */ struct infrared { -struct input_dev *input_dev; +struct rc_dev *dev;char input_phys[32 ];struct work_struct work;u32 ir_command;
@@ -532,7 +532,7 @@ static void dm1105_emit_key(struct work_struct *work) data = (ircom >>8 ) &0x7f ; -ir_keydown (ir->input_dev, data,0 ); +ir_keydown (ir->dev, data,0 ); }/* work handler */
@@ -593,46 +593,48 @@ static irqreturn_t dm1105_irq(int irq, void *dev_id)int __devinit dm1105_ir_init (struct dm1105_dev *dm1105) { -struct input_dev *input_dev; -char *ir_codes =RC_MAP_DM1105_NEC ; +struct rc_dev *dev;int err = -ENOMEM ; - input_dev =input_allocate_device (); -if (!input_dev) + dev =rc_allocate_device (); +if (!dev)return -ENOMEM ; - dm1105->ir.input_dev = input_dev;snprintf (dm1105->ir.input_phys,sizeof (dm1105->ir.input_phys),"pci-%s/ir0" ,pci_name (dm1105->pdev)); - input_dev->name ="DVB on-card IR receiver" ; - input_dev->phys = dm1105->ir.input_phys; - input_dev->id.bustype =BUS_PCI ; - input_dev->id.version =1 ; + dev->driver_name =MODULE_NAME ; + dev->map_name =RC_MAP_DM1105_NEC ; + dev->driver_type =RC_DRIVER_SCANCODE ; + dev->input_name ="DVB on-card IR receiver" ; + dev->input_phys = dm1105->ir.input_phys; + dev->input_id.bustype =BUS_PCI ; + dev->input_id.version =1 ;if (dm1105->pdev->subsystem_vendor) { - input_dev->id.vendor = dm1105->pdev->subsystem_vendor; - input_dev->id.product = dm1105->pdev->subsystem_device; + dev->input_id.vendor = dm1105->pdev->subsystem_vendor; + dev->input_id.product = dm1105->pdev->subsystem_device; }else { - input_dev->id.vendor = dm1105->pdev->vendor; - input_dev->id.product = dm1105->pdev->device; + dev->input_id.vendor = dm1105->pdev->vendor; + dev->input_id.product = dm1105->pdev->device; } - input_dev->dev.parent = &dm1105->pdev->dev; + dev->dev.parent = &dm1105->pdev->dev;INIT_WORK (&dm1105->ir.work, dm1105_emit_key); - err =ir_input_register (input_dev, ir_codes,NULL ,MODULE_NAME ); + err =rc_register_device (dev);if (err <0 ) { -input_free_device (input_dev); +rc_free_device (dev);return err; } + dm1105->ir.dev = dev;return 0 ; } void __devexit dm1105_ir_exit(struct dm1105_dev *dm1105) { -ir_input_unregister (dm1105->ir.input_dev); +rc_unregister_device (dm1105->ir.dev); }static int __devinit dm1105_hw_init (struct dm1105_dev *dev)
drivers/media/dvb/dvb-usb/dib0700.h +1 -1
@@ -60,7 +60,7 @@ extern int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff);extern struct i2c_algorithm dib0700_i2c_algo;extern int dib0700_identify_state (struct usb_device *udev,struct dvb_usb_device_properties *props,struct dvb_usb_device_description **desc,int *cold); -extern int dib0700_change_protocol (void *priv,u64 ir_type); +extern int dib0700_change_protocol (struct rc_dev *rc,u64 ir_type);extern int dib0700_device_count;extern int dvb_usb_dib0700_ir_proto;
drivers/media/dvb/dvb-usb/dib0700_core.c +4 -7
@@ -471,9 +471,9 @@ int dib0700_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)return dib0700_ctrl_wr (adap->dev, b,4 ); } -int dib0700_change_protocol (void *priv,u64 ir_type) +int dib0700_change_protocol (struct rc_dev *rc,u64 ir_type) { -struct dvb_usb_device *d = priv; +struct dvb_usb_device *d = rc->priv;struct dib0700_state *st = d->priv;u8 rc_setup[3 ] = {REQUEST_SET_RC ,0 ,0 };int new_proto, ret;
@@ -535,7 +535,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)if (d ==NULL )return ; -if (d->rc_input_dev ==NULL ) { +if (d->rc_dev ==NULL ) {/* This will occur if disable_rc_polling=1 */ usb_free_urb (purb);return ;
@@ -600,7 +600,7 @@ static void dib0700_rc_urb_completion(struct urb *purb) goto resubmit; } -ir_keydown (d->rc_input_dev, keycode, toggle); +ir_keydown (d->rc_dev, keycode, toggle); resubmit:/* Clean the buffer before we requeue */
@@ -673,9 +673,6 @@ static int dib0700_probe(struct usb_interface *intf,else dev->props.rc.core.bulk_mode = false; -/* Need a higher delay, to avoid wrong repeat */ - dev->rc_input_dev->rep[REP_DELAY ] =500 ; -dib0700_rc_setup (dev);return 0 ;
drivers/media/dvb/dvb-usb/dib0700_devices.c +30 -86
211 lines not on this page · raw message
drivers/media/dvb/dvb-usb/dvb-usb-remote.c +47 -31
127 lines not on this page · raw message
drivers/media/dvb/dvb-usb/dvb-usb.h +8 -4
@@ -180,18 +180,20 @@ struct dvb_rc_legacy {* struct dvb_rc properties of remote controller, using rc-core * @rc_codes: name of rc codes table * @protocol: type of protocol(s) currently used by the driver +* @allowed_protos: protocol(s) supported by the driver +* @change_protocol: callback to change protocol * @rc_query: called to query an event event. * @rc_interval: time in ms between two queries. -* @rc_props: remote controller properties * @bulk_mode: device supports bulk mode for RC (disable polling mode) */ struct dvb_rc {char *rc_codes;u64 protocol; +u64 allowed_protos; +int (*change_protocol)(struct rc_dev *dev,u64 ir_type);char *module_name;int (*rc_query) (struct dvb_usb_device *d);int rc_interval; -struct ir_dev_props rc_props;bool bulk_mode;/* uses bulk mode */ };
@@ -385,7 +387,8 @@ struct dvb_usb_adapter {* * @i2c_adap: device's i2c_adapter if it uses I2CoverUSB * -* @rc_input_dev: input device for the remote control. +* @rc_dev: rc device for the remote control (rc-core mode) +* @input_dev: input device for the remote control (legacy mode) * @rc_query_work: struct work_struct frequent rc queries * @last_event: last triggered event * @last_state: last state (no, pressed, repeat)
@@ -418,7 +421,8 @@ struct dvb_usb_device {struct dvb_usb_adapter adapter[MAX_NO_OF_ADAPTER_PER_DEVICE ];/* remote control */ -struct input_dev *rc_input_dev; +struct rc_dev *rc_dev; +struct input_dev *input_dev;char rc_phys[64 ];struct delayed_work rc_query_work;u32 last_event;
drivers/media/dvb/mantis/mantis_common.h +3 -1
Lines of this file are not shown. View the raw message.
drivers/media/dvb/mantis/mantis_input.c +41 -33
74 lines not on this page · raw message
drivers/media/dvb/siano/smsir.c +27 -25
52 lines not on this page · raw message
drivers/media/dvb/ttpci/budget-ci.c +22 -27
49 lines not on this page · raw message
drivers/media/video/bt8xx/bttv-input.c +18 -23
41 lines not on this page · raw message
drivers/media/video/cx23885/cx23885-input.c +30 -34
64 lines not on this page · raw message
drivers/media/video/cx88/cx88-input.c +40 -38
78 lines not on this page · raw message
drivers/media/video/em28xx/em28xx-input.c +33 -39
72 lines not on this page · raw message
drivers/media/video/saa7134/saa7134-input.c +30 -42
72 lines not on this page · raw message
drivers/staging/tm6000/tm6000-input.c +39 -48
87 lines not on this page · raw message
include/media/ir-core.h +86 -106
192 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Part of the diff is not shown here. View the raw message.
PATCH 5/5 rc-core: convert winbond-cir
In reply to David HärdemanMove winbond-cir from drivers/input/misc/ into drivers/media/IR/ and convert it to use rc-core.
--- drivers/input/misc/Kconfig | 18 drivers/input/misc/Makefile | 1 drivers/input/misc/winbond-cir.c | 1608 -------------------------------------- drivers/media/IR/Kconfig | 17 drivers/media/IR/Makefile | 1 drivers/media/IR/winbond-cir.c | 934 ++++++++++++++++++++++ 6 files changed, 952 insertions(+), 1627 deletions(-) delete mode 100644 drivers/input/misc/winbond-cir.c create mode 100644 drivers/media/IR/winbond-cir.c
drivers/input/misc/Kconfig +0 -18
@@ -284,24 +284,6 @@ config INPUT_SGI_BTNS To compile this driver as a module, choose M here: the module will be called sgi_btns. -config INPUT_WINBOND_CIR - tristate "Winbond IR remote control" - depends on X86 && PNP - select NEW_LEDS - select LEDS_CLASS - select LEDS_TRIGGERS - select BITREVERSE - help - Say Y here if you want to use the IR remote functionality found - in some Winbond SuperI/O chips. Currently only the WPCD376I - chip is supported (included in some Intel Media series motherboards). - - IR Receive and wake-on-IR from suspend and power-off is currently - supported. - - To compile this driver as a module, choose M here: the module will be - called winbond_cir. - config HP_SDC_RTC tristate "HP SDC Real Time Clock" depends on (GSC || HP300) && SERIO
drivers/input/misc/Makefile +0 -1
@@ -37,7 +37,6 @@ obj-$(CONFIG_INPUT_SPARCSPKR) += sparcspkr.o obj-$(CONFIG_INPUT_TWL4030_PWRBUTTON) += twl4030-pwrbutton.o obj-$(CONFIG_INPUT_TWL4030_VIBRA) += twl4030-vibra.o obj-$(CONFIG_INPUT_UINPUT) += uinput.o -obj-$(CONFIG_INPUT_WINBOND_CIR) += winbond-cir.o obj-$(CONFIG_INPUT_WISTRON_BTNS) += wistron_btns.o obj-$(CONFIG_INPUT_WM831X_ON) += wm831x-on.o obj-$(CONFIG_INPUT_YEALINK) += yealink.o
drivers/input/misc/winbond-cir.c deleted +0 -1608
1,608 lines not on this page · raw message
drivers/media/IR/Kconfig +17 -0
@@ -139,4 +139,21 @@ config IR_STREAMZAP To compile this driver as a module, choose M here: the module will be called streamzap. +config IR_WINBOND_CIR + tristate "Winbond IR remote control" + depends on X86 && PNP + depends on IR_CORE + select NEW_LEDS + select LEDS_CLASS + select LEDS_TRIGGERS + select BITREVERSE + ---help--- + Say Y here if you want to use the IR remote functionality found + in some Winbond SuperI/O chips. Currently only the WPCD376I + chip is supported (included in some Intel Media series + motherboards). + + To compile this driver as a module, choose M here: the module will + be called winbond_cir. + endif #IR_CORE
drivers/media/IR/Makefile +1 -0
@@ -17,3 +17,4 @@ obj-$(CONFIG_IR_IMON) += imon.o obj-$(CONFIG_IR_MCEUSB) += mceusb.o obj-$(CONFIG_IR_ENE) += ene_ir.o obj-$(CONFIG_IR_STREAMZAP) += streamzap.o +obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o
drivers/media/IR/winbond-cir.c new file +934 -0
934 lines not on this page · raw message
Quoted 4 lines · David Härdeman
This is my current patch queue, the main change is to make struct
rc_devthe primary interface for rc drivers and to abstract away the fact that there's an input device lurking in there somewhere. The first three patches in the set are preparations for the change.
And I forgot to mention it, but the patches are now against media_tree, branch staging/v2.6.37...
Signature · 1 line
David Härdeman