media: cx88: add IR remote support for NotOnlyTV LV3H
Subsystems (2)
PATCH v2 1/1 media: cx88: add IR remote support for NotOnlyTV LV3H
The PCI hybrid card NotOnlyTV LV3H has a built-in IR receiver connected via I2C bus, currently not supported. This receiver is probably present in more Geniatech cards. It has no capability for repeating when a key is held down.
Add support for this built-in IR receiver. Use the existing Total Media In Hand_02 remote keytable (Geniatech Mygica X8507) which matches exactly the LV3H remote.
---
changes in v2:
- Save a bitwise operation when no key is pressed
- Simplify the code
drivers/media/i2c/ir-kbd-i2c.c | 47 +++++++++++++++++++++++++++++ drivers/media/pci/cx88/cx88-input.c | 2 +- drivers/media/pci/cx88/cx88-video.c | 1 + include/media/i2c/ir-kbd-i2c.h | 1 + 4 files changed, 50 insertions(+), 1 deletion(-)
drivers/media/i2c/ir-kbd-i2c.c +47 -0
@@ -238,6 +238,43 @@ static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol,return 1 ; } +static int get_key_geniatech (struct IR_i2c *ir,enum rc_proto *protocol, +u32 *scancode,u8 *toggle) +{ +int i, rc; +unsigned char b; + +/* poll IR chip */ +for (i =0 ; i <4 ; i++) { + rc =i2c_master_recv (ir->c, &b,1 ); +if (rc ==1 ) +break ; +msleep (1 ); + } +if (rc !=1 ) { +dev_dbg (&ir->rc->dev,"read error\n" ); +if (rc <0 ) +return rc; +return -EIO ; + } + +/* don't repeat the key */ +if (ir->old == b) +return 0 ; + ir->old = b; + +/* decode to RC5 */ + b &=0x7f ; + b = (b -1 ) /2 ; + +dev_dbg (&ir->rc->dev,"key %02x\n" , b); + + *protocol =RC_PROTO_RC5 ; + *scancode = b; + *toggle = ir->old >>7 ; +return 1 ; +} +static int get_key_avermedia_cardbus (struct IR_i2c *ir,enum rc_proto *protocol,u32 *scancode,u8 *toggle) {
@@ -766,6 +803,13 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) rc_proto =RC_PROTO_BIT_OTHER ; ir_codes =RC_MAP_EMPTY ;break ; +case 0x33 : + name ="Geniatech" ; + ir->get_key = get_key_geniatech; + rc_proto =RC_PROTO_BIT_RC5 ; + ir_codes =RC_MAP_TOTAL_MEDIA_IN_HAND_02 ; + ir->old =0xfc ; +break ;case 0x6b : name ="FusionHDTV" ; ir->get_key = get_key_fusionhdtv;
@@ -825,6 +869,9 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)case IR_KBD_GET_KEY_KNC1 : ir->get_key = get_key_knc1;break ; +case IR_KBD_GET_KEY_GENIATECH : + ir->get_key = get_key_geniatech; +break ;case IR_KBD_GET_KEY_FUSIONHDTV : ir->get_key = get_key_fusionhdtv;break ;
drivers/media/pci/cx88/cx88-input.c +1 -1
@@ -586,7 +586,7 @@ void cx88_i2c_init_ir(struct cx88_core *core) {struct i2c_board_info info;static const unsigned short default_addr_list[] = { -0x18 ,0x6b ,0x71 , +0x18 ,0x33 ,0x6b ,0x71 ,I2C_CLIENT_END };static const unsigned short pvr2000_addr_list[] = {
drivers/media/pci/cx88/cx88-video.c +1 -0
@@ -1388,6 +1388,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, } fallthrough;case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO : +case CX88_BOARD_NOTONLYTV_LV3H :request_module ("ir-kbd-i2c" ); }
include/media/i2c/ir-kbd-i2c.h +1 -0
@@ -35,6 +35,7 @@ enum ir_kbd_get_key_fn {IR_KBD_GET_KEY_PIXELVIEW ,IR_KBD_GET_KEY_HAUP ,IR_KBD_GET_KEY_KNC1 , +IR_KBD_GET_KEY_GENIATECH ,IR_KBD_GET_KEY_FUSIONHDTV ,IR_KBD_GET_KEY_HAUP_XVR , IR_KBD_GET_KEY_AVERMEDIA_CARDBUS,
Signature · 1 line
2.35.1
Hi Daniel,
Sorry about the long delay for reviewing this. I missed this patch, sorry.
Quoted 32 lines · Daniel González Cabanelas
The PCI hybrid card NotOnlyTV LV3H has a built-in IR receiver connected via I2C bus, currently not supported. This receiver is probably present in more Geniatech cards. It has no capability for repeating when a key is held down.
Add support for this built-in IR receiver. Use the existing Total Media In
Hand_02remote keytable (Geniatech Mygica X8507) which matches exactly the LV3H remote.Signed-off-by Daniel González Cabanelas <[email protected]>Signed-off-by Marek Kidawski <[email protected]>---
changes in v2:
- Save a bitwise operation when no key is pressed
- Simplify the codedrivers/media/i2c/ir-kbd-i2c.c | 47 +++++++++++++++++++++++++++++ drivers/media/pci/cx88/cx88-input.c | 2 +- drivers/media/pci/cx88/cx88-video.c | 1 + include/media/i2c/ir-kbd-i2c.h | 1 + 4 files changed, 50 insertions(+), 1 deletion(-)drivers/media/i2c/ir-kbd-i2c.c +2
-0@@ -238,6 +238,43 @@ static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol,return 1 ; } +static int get_key_geniatech (struct IR_i2c *ir,enum rc_proto *protocol, +u32 *scancode,u8 *toggle)
drivers/media/i2c/ir-kbd-i2c.c static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol, · line 252
Quoted 10 lines
drivers/media/i2c/ir-kbd-i2c.c +10
-0+{ +int i, rc; +unsigned char b; + +/* poll IR chip */ +for (i =0 ; i <4 ; i++) { + rc =i2c_master_recv (ir->c, &b,1 ); +if (rc ==1 ) +break ; +msleep (1 );
checkpatch.pl rightfully points out the following:
WARNING: msleep < 20ms can sleep for up to 20ms; see Documentation/timers/timers-howto.rst
msleep(1) will sleep for at least 20ms. I think this is what you want here; mdelay(1) might introduce busy-cycles every second, surely we do not what to that.
Is the sleep needed at all?
Thanks
Sean
Quoted 94 lines
drivers/media/i2c/ir-kbd-i2c.c +35
-0+ } +if (rc !=1 ) { +dev_dbg (&ir->rc->dev,"read error\n" ); +if (rc <0 ) +return rc; +return -EIO ; + } + +/* don't repeat the key */ +if (ir->old == b) +return 0 ; + ir->old = b; + +/* decode to RC5 */ + b &=0x7f ; + b = (b -1 ) /2 ; + +dev_dbg (&ir->rc->dev,"key %02x\n" , b); + + *protocol =RC_PROTO_RC5 ; + *scancode = b; + *toggle = ir->old >>7 ; +return 1 ; +} +static int get_key_avermedia_cardbus (struct IR_i2c *ir,enum rc_proto *protocol,u32 *scancode,u8 *toggle) {@@ -766,6 +803,13 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) rc_proto =RC_PROTO_BIT_OTHER ; ir_codes =RC_MAP_EMPTY ;break ; +case 0x33 : + name ="Geniatech" ; + ir->get_key = get_key_geniatech; + rc_proto =RC_PROTO_BIT_RC5 ; + ir_codes =RC_MAP_TOTAL_MEDIA_IN_HAND_02 ; + ir->old =0xfc ; +break ;case 0x6b : name ="FusionHDTV" ; ir->get_key = get_key_fusionhdtv;@@ -825,6 +869,9 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)case IR_KBD_GET_KEY_KNC1 : ir->get_key = get_key_knc1;break ; +case IR_KBD_GET_KEY_GENIATECH : + ir->get_key = get_key_geniatech; +break ;case IR_KBD_GET_KEY_FUSIONHDTV : ir->get_key = get_key_fusionhdtv;break ;drivers/media/pci/cx88/cx88-input.c +1
-1@@ -586,7 +586,7 @@ void cx88_i2c_init_ir(struct cx88_core *core) {struct i2c_board_info info;static const unsigned short default_addr_list[] = { -0x18 ,0x6b ,0x71 , +0x18 ,0x33 ,0x6b ,0x71 ,I2C_CLIENT_END };static const unsigned short pvr2000_addr_list[] = {drivers/media/pci/cx88/cx88-video.c +1
-0@@ -1388,6 +1388,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, } fallthrough;case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO : +case CX88_BOARD_NOTONLYTV_LV3H :request_module ("ir-kbd-i2c" ); }include/media/i2c/ir-kbd-i2c.h +1
-0@@ -35,6 +35,7 @@ enum ir_kbd_get_key_fn {IR_KBD_GET_KEY_PIXELVIEW ,IR_KBD_GET_KEY_HAUP ,IR_KBD_GET_KEY_KNC1 , +IR_KBD_GET_KEY_GENIATECH ,IR_KBD_GET_KEY_FUSIONHDTV ,IR_KBD_GET_KEY_HAUP_XVR , IR_KBD_GET_KEY_AVERMEDIA_CARDBUS,Signature · 1 line
2.35.1
Hi Sean,
some amount of delay is required or the loop won't be effective enough. I made tests with delays up to 8 ms and they worked ok. The precision isn't important, so msleep will work ok here.
Regards
Daniel
Quoted 158 lines · Sean Young
Hi Daniel,
Sorry about the long delay for reviewing this. I missed this patch, sorry.
Quoted 32 lines · Daniel González Cabanelas
The PCI hybrid card NotOnlyTV LV3H has a built-in IR receiver connected via I2C bus, currently not supported. This receiver is probably present in more Geniatech cards. It has no capability for repeating when a key is held down.
Add support for this built-in IR receiver. Use the existing Total Media In
Hand_02remote keytable (Geniatech Mygica X8507) which matches exactly the LV3H remote.Signed-off-by Daniel González Cabanelas <[email protected]>Signed-off-by Marek Kidawski <[email protected]>---
changes in v2:
- Save a bitwise operation when no key is pressed
- Simplify the codedrivers/media/i2c/ir-kbd-i2c.c | 47 +++++++++++++++++++++++++++++ drivers/media/pci/cx88/cx88-input.c | 2 +- drivers/media/pci/cx88/cx88-video.c | 1 + include/media/i2c/ir-kbd-i2c.h | 1 + 4 files changed, 50 insertions(+), 1 deletion(-)drivers/media/i2c/ir-kbd-i2c.c +2
-0@@ -238,6 +238,43 @@ static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol,return 1 ; } +static int get_key_geniatech (struct IR_i2c *ir,enum rc_proto *protocol, +u32 *scancode,u8 *toggle)drivers/media/i2c/ir-kbd-i2c.c static int get_key_knc1(struct IR_i2c *ir, enum rc_proto *protocol, · line 252
Quoted 10 lines
drivers/media/i2c/ir-kbd-i2c.c +10
-0+{ +int i, rc; +unsigned char b; + +/* poll IR chip */ +for (i =0 ; i <4 ; i++) { + rc =i2c_master_recv (ir->c, &b,1 ); +if (rc ==1 ) +break ; +msleep (1 );checkpatch.pl rightfully points out the following:
WARNING: msleep < 20ms can sleep for up to 20ms; see
Documentation/timers/timers-howto.rstmsleep(1) will sleep for at least 20ms. I think this is what you want here; mdelay(1) might introduce busy-cycles every second, surely we do not what to that.
Is the sleep needed at all?
Thanks
Sean
Quoted 94 lines
drivers/media/i2c/ir-kbd-i2c.c +35
-0+ } +if (rc !=1 ) { +dev_dbg (&ir->rc->dev,"read error\n" ); +if (rc <0 ) +return rc; +return -EIO ; + } + +/* don't repeat the key */ +if (ir->old == b) +return 0 ; + ir->old = b; + +/* decode to RC5 */ + b &=0x7f ; + b = (b -1 ) /2 ; + +dev_dbg (&ir->rc->dev,"key %02x\n" , b); + + *protocol =RC_PROTO_RC5 ; + *scancode = b; + *toggle = ir->old >>7 ; +return 1 ; +} +static int get_key_avermedia_cardbus (struct IR_i2c *ir,enum rc_proto *protocol,u32 *scancode,u8 *toggle) {@@ -766,6 +803,13 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id) rc_proto =RC_PROTO_BIT_OTHER ; ir_codes =RC_MAP_EMPTY ;break ; +case 0x33 : + name ="Geniatech" ; + ir->get_key = get_key_geniatech; + rc_proto =RC_PROTO_BIT_RC5 ; + ir_codes =RC_MAP_TOTAL_MEDIA_IN_HAND_02 ; + ir->old =0xfc ; +break ;case 0x6b : name ="FusionHDTV" ; ir->get_key = get_key_fusionhdtv;@@ -825,6 +869,9 @@ static int ir_probe(struct i2c_client *client, const struct i2c_device_id *id)case IR_KBD_GET_KEY_KNC1 : ir->get_key = get_key_knc1;break ; +case IR_KBD_GET_KEY_GENIATECH : + ir->get_key = get_key_geniatech; +break ;case IR_KBD_GET_KEY_FUSIONHDTV : ir->get_key = get_key_fusionhdtv;break ;drivers/media/pci/cx88/cx88-input.c +1
-1@@ -586,7 +586,7 @@ void cx88_i2c_init_ir(struct cx88_core *core) {struct i2c_board_info info;static const unsigned short default_addr_list[] = { -0x18 ,0x6b ,0x71 , +0x18 ,0x33 ,0x6b ,0x71 ,I2C_CLIENT_END };static const unsigned short pvr2000_addr_list[] = {drivers/media/pci/cx88/cx88-video.c +1
-0@@ -1388,6 +1388,7 @@ static int cx8800_initdev(struct pci_dev *pci_dev, } fallthrough;case CX88_BOARD_DVICO_FUSIONHDTV_5_PCI_NANO : +case CX88_BOARD_NOTONLYTV_LV3H :request_module ("ir-kbd-i2c" ); }include/media/i2c/ir-kbd-i2c.h +1
-1@@ -35,6 +35,7 @@ enum ir_kbd_get_key_fn {IR_KBD_GET_KEY_PIXELVIEW ,IR_KBD_GET_KEY_HAUP ,IR_KBD_GET_KEY_KNC1 , +IR_KBD_GET_KEY_GENIATECH ,IR_KBD_GET_KEY_FUSIONHDTV ,IR_KBD_GET_KEY_HAUP_XVR , IR_KBD_GET_KEY_AVERMEDIA_CARDBUS, --2.35.1