public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Jarod Wilson <jarod@wilsonet.com>
Cc: Linux Media Mailing List <linux-media@vger.kernel.org>
Subject: Re: [PATCH 4/4] [media] mceusb: Fix parser for Polaris
Date: Thu, 21 Oct 2010 18:38:18 -0200	[thread overview]
Message-ID: <4CC0A4BA.4080105@redhat.com> (raw)
In-Reply-To: <21DE3D7F-2805-4A11-AE29-9713FA58F66D@wilsonet.com>

Em 21-10-2010 18:06, Jarod Wilson escreveu:
> On Oct 21, 2010, at 10:07 AM, Mauro Carvalho Chehab wrote:
> 
>> Add a parser for polaris mce. On this device, sometimes, a control
>> data appears together with the IR data, causing problems at the parser.
>> Also, it signalizes the end of a data with a 0x80 value. The normal
>> parser would believe that this is a time with 0x1f size, but cx231xx
>> provides just one byte for it.
>>
>> I'm not sure if the new parser would work for other devices (probably, it
>> will), but the better is to just write it as a new parser, to avoid breaking
>> support for other supported IR devices.
> 
> After staring at it for a while, I think it would work okay for all 2nd and 3rd-gen mceusb devices, but it would almost certainly break 1st-gen, as it can have distinct IR data packets split across urb -- that's the whole reason for the if rem == 0 check in the existing routine.
> 
> Ultimately though, this routine isn't that much different, and I *think* I see a way to extend the existing routine with some of the code from this one to make it work better for the polaris device.
> 
> Will still go ahead with some review comments here though.
> 
>> diff --git a/drivers/media/IR/mceusb.c b/drivers/media/IR/mceusb.c
>> index 609bf3d..7210760 100644
>> --- a/drivers/media/IR/mceusb.c
>> +++ b/drivers/media/IR/mceusb.c
>> @@ -265,6 +265,7 @@ struct mceusb_dev {
>> 		u32 connected:1;
>> 		u32 tx_mask_inverted:1;
>> 		u32 microsoft_gen1:1;
>> +		u32 is_polaris:1;
>> 		u32 reserved:29;
> 
> reserved should be decremented by 1 here if adding another flag.

Ok. By curiosity, why are you reserving space on a bit array like that?


>> 	} flags;
>>
>> @@ -697,6 +698,90 @@ static int mceusb_set_tx_carrier(void *priv, u32 carrier)
>> 	return carrier;
>> }
>>
>> +static void mceusb_parse_polaris(struct mceusb_dev *ir, int buf_len)
>> +{
>> +	struct ir_raw_event rawir;
>> +	int i;
>> +	u8 cmd;
>> +
>> +	while (i < buf_len) {
> 
> i is being used uninitialized here.

Ops!

>> +		cmd = ir->buf_in[i];
>> +
>> +		/* Discard any non-IR cmd */
>> +
>> +		if ((cmd & 0xe0) >> 5 != 4) {
> 
> I'd probably just stick with if ((cmd & 0xe0) != 0x80), or even != MCE_PULSE_BIT, since we have a #define for 0x80 already. (Though its not quite an accurate name in this case).

Ok.
 
>> +			i++;
>> +			if (i >= buf_len)
>> +				return;
>> +
>> +			cmd = ir->buf_in[i];	/* sub cmd */
>> +			i++;
>> +			switch (cmd) {
>> +			case 0x08:
>> +			case 0x14:
>> +			case 0x17:
>> +				i += 1;
>> +				break;
>> +			case 0x11:
>> +				i += 5;
>> +				break;
>> +			case 0x06:
>> +			case 0x81:
>> +			case 0x15:
>> +			case 0x16:
>> +				i += 2;
>> +				break;
> 
> #define's for each of these hex values would be good, if we can determine what they actually are.

Maybe we can determine a few of them, as they also occur at the debug parsing loop.

>> +		} else if (cmd == 0x80) {
>> +			/*
>> +			 * Special case: timeout event on cx231xx
>> +			 * Is it needed to check if is_polaris?
>> +			 */
>> +			rawir.pulse = 0;
>> +			rawir.duration = IR_MAX_DURATION;
>> +			dev_dbg(ir->dev, "Storing %s with duration %d\n",
>> +				rawir.pulse ? "pulse" : "space",
>> +				rawir.duration);
>> +
>> +			ir_raw_event_store(ir->idev, &rawir);
> 
> I think this and the prior hunk are really the only things that need to be grafted into the existing routine to make it behave with this device. Lemme see what I can come up with...

True, although the double loop at the original logic is a bit confusing. I suspect you did it to handle
the (cmd & 0xe0) != 0x80 condition, probably at the gen1 times, and then you modified it to handle other
devices. 

Cheers,
Mauro


  reply	other threads:[~2010-10-21 20:38 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <cover.1287669886.git.mchehab@redhat.com>
2010-10-21 14:07 ` [PATCH 1/4] [media] cx231xx: Fix compilation breakage if DVB is not selected Mauro Carvalho Chehab
2010-10-21 15:23   ` Jarod Wilson
2010-10-21 14:07 ` [PATCH 2/4] [media] ir-raw-event: Fix a stupid error at a printk Mauro Carvalho Chehab
2010-10-21 15:23   ` Jarod Wilson
2010-10-21 14:07 ` [PATCH 3/4] [media] mceusb: Improve parser to get codes sent together with IR RX data Mauro Carvalho Chehab
2010-10-21 18:53   ` Jarod Wilson
2010-10-21 14:07 ` [PATCH 4/4] [media] mceusb: Fix parser for Polaris Mauro Carvalho Chehab
2010-10-21 20:06   ` Jarod Wilson
2010-10-21 20:38     ` Mauro Carvalho Chehab [this message]
2010-10-21 21:06       ` Jarod Wilson
2010-10-21 21:24         ` 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=4CC0A4BA.4080105@redhat.com \
    --to=mchehab@redhat.com \
    --cc=jarod@wilsonet.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox