From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: unlisted-recipients:; (no To-header on input)@bombadil.infradead.org
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: [PATCH 2/6] V4L/DVB: dib0700: Fix RC protocol logic to properly handle NEC/NECx and RC-5
Date: Sun, 1 Aug 2010 17:17:16 -0300 [thread overview]
Message-ID: <20100801171716.2e84d901@pedra> (raw)
In-Reply-To: <cover.1280693675.git.mchehab@redhat.com>
Simplifies the logic for handling firmware 1.20 RC messages, fixing the
logic.
While here, I tried to use a RC-6 remote controller from my TV set, but it
didn't work with dib0700. Not sure why, but maybe this never worked.
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index d73a688..fe81834 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -499,7 +499,7 @@ int dib0700_change_protocol(void *priv, u64 ir_type)
return ret;
}
- d->props.rc.core.protocol = new_proto;
+ d->props.rc.core.protocol = ir_type;
return ret;
}
@@ -511,7 +511,13 @@ int dib0700_change_protocol(void *priv, u64 ir_type)
struct dib0700_rc_response {
u8 report_id;
u8 data_state;
- u16 system;
+ union {
+ u16 system16;
+ struct {
+ u8 system;
+ u8 not_system;
+ };
+ };
u8 data;
u8 not_data;
};
@@ -521,9 +527,8 @@ static void dib0700_rc_urb_completion(struct urb *purb)
{
struct dvb_usb_device *d = purb->context;
struct dib0700_state *st;
- struct dib0700_rc_response poll_reply;
- u8 *buf;
- u32 keycode;
+ struct dib0700_rc_response *poll_reply;
+ u32 uninitialized_var(keycode);
u8 toggle;
deb_info("%s()\n", __func__);
@@ -537,7 +542,7 @@ static void dib0700_rc_urb_completion(struct urb *purb)
}
st = d->priv;
- buf = (u8 *)purb->transfer_buffer;
+ poll_reply = purb->transfer_buffer;
if (purb->status < 0) {
deb_info("discontinuing polling\n");
@@ -550,52 +555,51 @@ static void dib0700_rc_urb_completion(struct urb *purb)
goto resubmit;
}
- deb_data("IR raw %02X %02X %02X %02X %02X %02X (len %d)\n", buf[0],
- buf[1], buf[2], buf[3], buf[4], buf[5], purb->actual_length);
+ deb_data("IR ID = %02X state = %02X System = %02X %02X Cmd = %02X %02X (len %d)\n",
+ poll_reply->report_id, poll_reply->data_state,
+ poll_reply->system, poll_reply->not_system,
+ poll_reply->data, poll_reply->not_data,
+ purb->actual_length);
switch (d->props.rc.core.protocol) {
case IR_TYPE_NEC:
- poll_reply.data_state = 0;
- poll_reply.system = buf[2];
- poll_reply.data = buf[4];
- poll_reply.not_data = buf[5];
toggle = 0;
/* NEC protocol sends repeat code as 0 0 0 FF */
- if ((poll_reply.system == 0x00) && (poll_reply.data == 0x00)
- && (poll_reply.not_data == 0xff)) {
- poll_reply.data_state = 2;
+ if ((poll_reply->system == 0x00) && (poll_reply->data == 0x00)
+ && (poll_reply->not_data == 0xff)) {
+ poll_reply->data_state = 2;
break;
}
+ if ((poll_reply->system ^ poll_reply->not_system) != 0xff) {
+ deb_data("NEC extended protocol\n");
+ /* NEC extended code - 24 bits */
+ keycode = poll_reply->system16 << 8 | poll_reply->data;
+ } else {
+ deb_data("NEC normal protocol\n");
+ /* normal NEC code - 16 bits */
+ keycode = poll_reply->system << 8 | poll_reply->data;
+ }
+
break;
default:
+ deb_data("RC5 protocol\n");
/* RC5 Protocol */
- /* TODO: need to check the mapping for RC6 */
- poll_reply.report_id = buf[0];
- poll_reply.data_state = buf[1];
- poll_reply.system = (buf[2] << 8) | buf[3];
- poll_reply.data = buf[4];
- poll_reply.not_data = buf[5];
-
- toggle = poll_reply.report_id;
+ toggle = poll_reply->report_id;
+ keycode = poll_reply->system16 << 8 | poll_reply->data;
break;
}
- if ((poll_reply.data + poll_reply.not_data) != 0xff) {
+ if ((poll_reply->data + poll_reply->not_data) != 0xff) {
/* Key failed integrity check */
err("key failed integrity check: %04x %02x %02x",
- poll_reply.system,
- poll_reply.data, poll_reply.not_data);
+ poll_reply->system,
+ poll_reply->data, poll_reply->not_data);
goto resubmit;
}
- deb_data("rid=%02x ds=%02x sm=%04x d=%02x nd=%02x\n",
- poll_reply.report_id, poll_reply.data_state,
- poll_reply.system, poll_reply.data, poll_reply.not_data);
-
- keycode = poll_reply.system << 8 | poll_reply.data;
ir_keydown(d->rc_input_dev, keycode, toggle);
resubmit:
--
1.7.1
next prev parent reply other threads:[~2010-08-01 20:18 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <cover.1280693675.git.mchehab@redhat.com>
2010-08-01 20:17 ` [PATCH 1/6] V4L/DVB: dib0700: properly implement IR change_protocol Mauro Carvalho Chehab
2010-08-01 20:17 ` Mauro Carvalho Chehab [this message]
2010-08-01 20:17 ` [PATCH 3/6] V4L/DVB: smsusb: enable IR port for Hauppauge WinTV MiniStick Mauro Carvalho Chehab
2010-08-02 7:27 ` Richard Zidlicky
2010-08-03 2:01 ` Mauro Carvalho Chehab
2010-08-03 13:05 ` Richard Zidlicky
2010-08-03 13:32 ` Mauro Carvalho Chehab
2010-08-03 14:21 ` Jarod Wilson
2010-08-03 14:46 ` Richard Zidlicky
2010-08-03 15:23 ` Mauro Carvalho Chehab
2010-08-04 7:30 ` Richard Zidlicky
2010-08-01 20:21 ` [PATCH 4/6] V4L/DVB: standardize names at rc-dib0700 tables Mauro Carvalho Chehab
2010-08-01 20:21 ` [PATCH 5/6] V4L/DVB: sms: properly initialize IR phys and IR name Mauro Carvalho Chehab
2010-08-01 20:21 ` [PATCH 6/6] V4L/DVB: sms: Convert IR support to use the Remote Controller core Mauro Carvalho Chehab
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=20100801171716.2e84d901@pedra \
--to=mchehab@redhat.com \
--cc=linux-media@vger.kernel.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.