From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Mauro Carvalho Chehab <mchehab@redhat.com>
Cc: "Frank Schäfer" <fschaefer.oss@googlemail.com>,
"Antti Palosaari" <crope@iki.fi>,
"Devin Heitmueller" <dheitmueller@kernellabs.com>,
"Matthew Gyurgyik" <matthew@pyther.net>,
"Linux Media Mailing List" <linux-media@vger.kernel.org>,
"David Härdeman" <david@hardeman.nu>
Subject: Re: em28xx: msi Digivox ATSC board id [0db0:8810]
Date: Fri, 14 Dec 2012 22:26:31 -0200 [thread overview]
Message-ID: <20121214222631.1f191d6e@redhat.com> (raw)
In-Reply-To: <20121214173950.79bb963e@redhat.com>
Em Fri, 14 Dec 2012 17:39:50 -0200
Mauro Carvalho Chehab <mchehab@redhat.com> escreveu:
> > Anyway, first we have to GET the bytes from the hardware. That's our
> > current problem !
> > And the hardware seems to need a different setup for reg 0x50 for the
> > different NEC sub protocols.
> > Which means that the we need to know the sub protocol BEFORE we get any
> > bytes from the device.
>
> No. All em28xx needs is to make sure that the NEC protocol will return
> the full 32 bits scancode.
It seems a way easier/quicker to just add the proper support there at the
driver than keep answering to this thread ;)
Tested here with a Terratec HTC stick, and using two different IR's:
- a Terratec IR (address code 0x14 - standard NEC);
- a Pixelview IR (address code 0x866b - 24 bits NEC).
All tests were done with the very latest version of ir-keytable, found at
v4l-utils.git tree (http://git.linuxtv.org/v4l-utils.git).
See the results, with the Terratec table loaded (default when the
driver is loaded):
# ir-keytable -t
Testing events. Please, press CTRL-C to abort.
# Terratec IR
1355529698.198046: event type EV_MSC(0x04): scancode = 0x1402
1355529698.198046: event type EV_KEY(0x01) key_down: KEY_1(0x0001)
1355529698.198046: event type EV_SYN(0x00).
11355529698.298170: event type EV_MSC(0x04): scancode = 0x1402
1355529698.298170: event type EV_SYN(0x00).
1355529698.547998: event type EV_KEY(0x01) key_up: KEY_1(0x0001)
1355529698.547998: event type EV_SYN(0x00).
# Pixelview IR
1355530261.416415: event type EV_MSC(0x04): scancode = 0x866b01
1355530261.416415: event type EV_SYN(0x00).
1355530262.216301: event type EV_MSC(0x04): scancode = 0x866b0b
1355530262.216301: event type EV_SYN(0x00).
Replacing the keytable to the Pixelview's one:
# ir-keytable -w /etc/rc_keymaps/pixelview_002t -c
Read pixelview_002t table
Old keytable cleared
Wrote 26 keycode(s) to driver
Protocols changed to NEC
# ir-keytable -t
Testing events. Please, press CTRL-C to abort.
1355530569.420398: event type EV_MSC(0x04): scancode = 0x1402
1355530569.420398: event type EV_SYN(0x00).
1355530588.120409: event type EV_MSC(0x04): scancode = 0x866b01
1355530588.120409: event type EV_KEY(0x01) key_down: KEY_1(0x0001)
1355530591.670077: event type EV_SYN(0x00).
And, finally, keeping both keytables active at the same time:
# ir-keytable -c -w /etc/rc_keymaps/pixelview_002t -w /etc/rc_keymaps/nec_terratec_cinergy_xs
Read pixelview_002t table
Read nec_terratec_cinergy_xs table
Old keytable cleared
Wrote 74 keycode(s) to driver
Protocols changed to NEC
# sudo ir-keytable -t
Testing events. Please, press CTRL-C to abort.
1355530856.325201: event type EV_MSC(0x04): scancode = 0x866b01
1355530856.325201: event type EV_KEY(0x01) key_down: KEY_1(0x0001)
1355530856.325201: event type EV_SYN(0x00).
11355530856.575070: event type EV_KEY(0x01) key_up: KEY_1(0x0001)
1355530856.575070: event type EV_SYN(0x00).
1355530869.125226: event type EV_MSC(0x04): scancode = 0x1402
1355530869.125226: event type EV_KEY(0x01) key_down: KEY_1(0x0001)
1355530869.125226: event type EV_SYN(0x00).
11355530869.225216: event type EV_MSC(0x04): scancode = 0x1402
1355530869.225216: event type EV_SYN(0x00).
1355530869.475075: event type EV_KEY(0x01) key_up: KEY_1(0x0001)
1355530869.475075: event type EV_SYN(0x00).
-
em28xx: add support for 24bits/32 bits NEC variants on em2874 and upper
By disabling the NEC parity check, it is possible to handle all 3 NEC
protocol variants (32, 24 or 16 bits).
Change the driver in order to handle all of them.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/usb/em28xx/em28xx-input.c b/drivers/media/usb/em28xx/em28xx-input.c
index 97d36b4..c84e4c8 100644
--- a/drivers/media/usb/em28xx/em28xx-input.c
+++ b/drivers/media/usb/em28xx/em28xx-input.c
@@ -57,8 +57,8 @@ MODULE_PARM_DESC(ir_debug, "enable debug messages [IR]");
struct em28xx_ir_poll_result {
unsigned int toggle_bit:1;
unsigned int read_count:7;
- u8 rc_address;
- u8 rc_data[4]; /* 1 byte on em2860/2880, 4 on em2874 */
+
+ u32 scancode;
};
struct em28xx_IR {
@@ -72,6 +72,7 @@ struct em28xx_IR {
struct delayed_work work;
unsigned int full_code:1;
unsigned int last_readcount;
+ u64 rc_type;
int (*get_key)(struct em28xx_IR *, struct em28xx_ir_poll_result *);
};
@@ -236,11 +237,8 @@ static int default_polling_getkey(struct em28xx_IR *ir,
/* Infrared read count (Reg 0x45[6:0] */
poll_result->read_count = (msg[0] & 0x7f);
- /* Remote Control Address (Reg 0x46) */
- poll_result->rc_address = msg[1];
-
- /* Remote Control Data (Reg 0x47) */
- poll_result->rc_data[0] = msg[2];
+ /* Remote Control Address/Data (Regs 0x46/0x47) */
+ poll_result->scancode = msg[1] << 8 | msg[2];
return 0;
}
@@ -266,13 +264,30 @@ static int em2874_polling_getkey(struct em28xx_IR *ir,
/* Infrared read count (Reg 0x51[6:0] */
poll_result->read_count = (msg[0] & 0x7f);
- /* Remote Control Address (Reg 0x52) */
- poll_result->rc_address = msg[1];
-
- /* Remote Control Data (Reg 0x53-55) */
- poll_result->rc_data[0] = msg[2];
- poll_result->rc_data[1] = msg[3];
- poll_result->rc_data[2] = msg[4];
+ /* Remote Control Address (Reg 0x52) */
+ /* Remote Control Data (Reg 0x53-0x55) */
+ switch (ir->rc_type) {
+ case RC_TYPE_RC5:
+ poll_result->scancode = msg[1] << 8 | msg[2];
+ break;
+ case RC_TYPE_NEC:
+ if ((msg[3] ^ msg[4]) != 0xff) /* 32 bits NEC */
+ poll_result->scancode = (msg[1] << 24) |
+ (msg[2] << 16) |
+ (msg[3] << 8) |
+ msg[4];
+ else if ((msg[1] ^ msg[2]) != 0xff) /* 24 bits NEC */
+ poll_result->scancode = (msg[1] << 16) |
+ (msg[3] << 8) |
+ msg[4];
+ else /* Normal NEC */
+ poll_result->scancode = msg[1] << 8 | msg[3];
+ break;
+ default:
+ poll_result->scancode = (msg[1] << 24) | (msg[2] << 16) |
+ (msg[3] << 8) | msg[4];
+ break;
+ }
return 0;
}
@@ -294,17 +309,16 @@ static void em28xx_ir_handle_key(struct em28xx_IR *ir)
}
if (unlikely(poll_result.read_count != ir->last_readcount)) {
- dprintk("%s: toggle: %d, count: %d, key 0x%02x%02x\n", __func__,
+ dprintk("%s: toggle: %d, count: %d, key 0x%04x\n", __func__,
poll_result.toggle_bit, poll_result.read_count,
- poll_result.rc_address, poll_result.rc_data[0]);
+ poll_result.scancode);
if (ir->full_code)
rc_keydown(ir->rc,
- poll_result.rc_address << 8 |
- poll_result.rc_data[0],
+ poll_result.scancode,
poll_result.toggle_bit);
else
rc_keydown(ir->rc,
- poll_result.rc_data[0],
+ poll_result.scancode & 0xff,
poll_result.toggle_bit);
if (ir->dev->chip_id == CHIP_ID_EM2874 ||
@@ -359,11 +373,13 @@ static int em28xx_ir_change_protocol(struct rc_dev *rc_dev, u64 rc_type)
ir->full_code = 1;
} else if (rc_type == RC_TYPE_NEC) {
dev->board.xclk &= ~EM28XX_XCLK_IR_RC5_MODE;
- ir_config = EM2874_IR_NEC;
+ ir_config = EM2874_IR_NEC | EM2874_IR_NEC_NO_PARITY;
ir->full_code = 1;
} else if (rc_type != RC_TYPE_UNKNOWN)
rc = -EINVAL;
+ ir->rc_type = rc_type;
+
em28xx_write_reg_bits(dev, EM28XX_R0F_XCLK, dev->board.xclk,
EM28XX_XCLK_IR_RC5_MODE);
diff --git a/drivers/media/usb/em28xx/em28xx-reg.h b/drivers/media/usb/em28xx/em28xx-reg.h
index 6ff3682..2ad3573 100644
--- a/drivers/media/usb/em28xx/em28xx-reg.h
+++ b/drivers/media/usb/em28xx/em28xx-reg.h
@@ -177,6 +177,7 @@
/* em2874 IR config register (0x50) */
#define EM2874_IR_NEC 0x00
+#define EM2874_IR_NEC_NO_PARITY 0x01
#define EM2874_IR_RC5 0x04
#define EM2874_IR_RC6_MODE_0 0x08
#define EM2874_IR_RC6_MODE_6A 0x0b
next prev parent reply other threads:[~2012-12-15 0:27 UTC|newest]
Thread overview: 107+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-28 2:31 em28xx: msi Digivox ATSC board id [0db0:8810] Matthew Gyurgyik
2012-11-28 20:47 ` Frank Schäfer
2012-11-28 22:29 ` Matthew Gyurgyik
2012-11-28 22:55 ` Antti Palosaari
2012-11-29 2:05 ` Matthew Gyurgyik
2012-11-29 2:15 ` Antti Palosaari
2012-11-29 19:28 ` Frank Schäfer
2012-11-29 19:46 ` Antti Palosaari
2012-11-30 1:45 ` Matthew Gyurgyik
2012-12-02 11:44 ` Frank Schäfer
2012-12-02 14:23 ` Antti Palosaari
2012-12-02 17:18 ` Frank Schäfer
2012-12-03 18:16 ` Frank Schäfer
2012-12-04 2:15 ` Matthew Gyurgyik
2012-12-04 2:29 ` Devin Heitmueller
2012-12-04 2:42 ` Matthew Gyurgyik
2012-12-04 2:58 ` Devin Heitmueller
2012-12-04 21:06 ` Frank Schäfer
2012-12-05 3:41 ` Matthew Gyurgyik
2012-12-05 12:35 ` Antti Palosaari
2012-12-05 21:35 ` Matthew Gyurgyik
2012-12-05 22:01 ` Antti Palosaari
2012-12-05 22:33 ` Matthew Gyurgyik
2012-12-06 0:55 ` Antti Palosaari
2012-12-06 2:16 ` Matthew Gyurgyik
2012-12-06 21:49 ` Frank Schäfer
2012-12-06 21:57 ` Devin Heitmueller
2012-12-06 22:01 ` Frank Schäfer
2012-12-06 22:03 ` Devin Heitmueller
2012-12-06 22:12 ` Frank Schäfer
2012-12-06 22:41 ` Matthew Gyurgyik
2012-12-06 22:58 ` Matthew Gyurgyik
2012-12-07 1:40 ` Matthew Gyurgyik
2012-12-07 3:21 ` Devin Heitmueller
2012-12-07 11:49 ` Matthew Gyurgyik
2012-12-08 13:52 ` Frank Schäfer
2012-12-08 14:10 ` Matthew Gyurgyik
2012-12-08 15:20 ` Frank Schäfer
[not found] ` <50C3701D.9000700@pyther .net>
[not found] ` <50C37DA8.4080608@googlemai l.com>
[not found] ` <50C3B3EB.40606@pyther .net>
[not found] ` <50C3B567.3070300@i ki.fi>
2012-12-08 16:51 ` Matthew Gyurgyik
2012-12-08 17:49 ` Frank Schäfer
2012-12-08 21:40 ` Matthew Gyurgyik
2012-12-08 21:47 ` Antti Palosaari
2012-12-08 22:04 ` Matthew Gyurgyik
2012-12-09 12:48 ` Frank Schäfer
2012-12-09 14:50 ` Matthew Gyurgyik
2012-12-09 15:46 ` Devin Heitmueller
2012-12-09 16:19 ` Frank Schäfer
2012-12-09 16:23 ` Frank Schäfer
2012-12-09 17:06 ` Frank Schäfer
2012-12-09 17:53 ` Matthew Gyurgyik
2012-12-10 15:39 ` Frank Schäfer
2012-12-10 15:46 ` Devin Heitmueller
2012-12-10 16:01 ` Frank Schäfer
2012-12-10 16:13 ` Devin Heitmueller
2012-12-10 17:57 ` Antti Palosaari
2012-12-10 19:24 ` Frank Schäfer
2012-12-10 20:48 ` Antti Palosaari
2012-12-11 20:51 ` Frank Schäfer
2012-12-11 20:59 ` Antti Palosaari
2012-12-12 21:25 ` Frank Schäfer
2012-12-12 21:34 ` Frank Schäfer
2012-12-13 15:09 ` Antti Palosaari
2012-12-13 16:02 ` Frank Schäfer
2012-12-13 20:23 ` Mauro Carvalho Chehab
2012-12-14 15:33 ` Frank Schäfer
2012-12-14 16:32 ` Antti Palosaari
2012-12-14 16:40 ` Antti Palosaari
2012-12-14 19:39 ` Mauro Carvalho Chehab
2012-12-15 0:26 ` Mauro Carvalho Chehab [this message]
2012-12-15 0:34 ` Mauro Carvalho Chehab
2012-12-15 0:56 ` Antti Palosaari
2012-12-15 1:03 ` Mauro Carvalho Chehab
2012-12-15 1:12 ` Antti Palosaari
2012-12-15 1:39 ` Mauro Carvalho Chehab
2012-12-15 1:54 ` Mauro Carvalho Chehab
2012-12-15 13:11 ` Frank Schäfer
2012-12-15 13:34 ` Mauro Carvalho Chehab
2012-12-15 13:38 ` Antti Palosaari
2012-12-15 16:21 ` Frank Schäfer
2012-12-15 16:51 ` Antti Palosaari
2012-12-16 18:15 ` Frank Schäfer
2012-12-17 1:09 ` Matthew Gyurgyik
2012-12-17 1:26 ` Antti Palosaari
2012-12-17 1:37 ` Matthew Gyurgyik
2012-12-17 9:33 ` Antti Palosaari
2012-12-17 11:08 ` Antti Palosaari
2012-12-17 11:17 ` Matthew Gyurgyik
2012-12-17 12:30 ` Antti Palosaari
2012-12-17 15:53 ` Mauro Carvalho Chehab
2012-12-17 16:14 ` Mauro Carvalho Chehab
2012-12-18 2:27 ` Matthew Gyurgyik
2012-12-18 3:08 ` Matthew Gyurgyik
2013-01-02 20:59 ` Antti Palosaari
2013-01-03 2:53 ` Matthew Gyurgyik
2013-01-20 14:40 ` Matthew Gyurgyik
2013-01-20 17:46 ` Antti Palosaari
2013-02-16 23:38 ` Matthew Gyurgyik
2013-02-24 22:23 ` Antti Palosaari
2013-02-25 1:58 ` Matthew Gyurgyik
2013-01-03 0:18 ` David Härdeman
2012-12-13 20:07 ` Mauro Carvalho Chehab
2012-12-13 20:36 ` Mauro Carvalho Chehab
2012-12-13 19:57 ` Mauro Carvalho Chehab
2012-12-13 20:04 ` Mauro Carvalho Chehab
2012-12-10 16:01 ` Matthew Gyurgyik
2012-12-06 2:32 ` Matthew Gyurgyik
2012-12-06 21:52 ` Frank Schäfer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20121214222631.1f191d6e@redhat.com \
--to=mchehab@redhat.com \
--cc=crope@iki.fi \
--cc=david@hardeman.nu \
--cc=dheitmueller@kernellabs.com \
--cc=fschaefer.oss@googlemail.com \
--cc=linux-media@vger.kernel.org \
--cc=matthew@pyther.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).