Re: [PATCH v7 2/3] [media] rc: add sunxi-ir driver
From: Hans de Goede <hidden>
Date: 2014-05-20 07:18:59
Hi, On 05/19/2014 10:26 PM, David Härdeman wrote:
On Thu, May 15, 2014 at 03:56:41AM +0600, Alexander Bersenev wrote:quoted
This patch adds driver for sunxi IR controller. It is based on Alexsey Shestacov's work based on the original driver supplied by Allwinner....quoted
+static irqreturn_t sunxi_ir_irq(int irqno, void *dev_id) +{ + unsigned long status; + unsigned char dt; + unsigned int cnt, rc; + struct sunxi_ir *ir = dev_id; + DEFINE_IR_RAW_EVENT(rawir); + + spin_lock(&ir->ir_lock); + + status = readl(ir->base + SUNXI_IR_RXSTA_REG); + + /* clean all pending statuses */ + writel(status | REG_RXSTA_CLEARALL, ir->base + SUNXI_IR_RXSTA_REG); + + if (status & REG_RXINT_RAI_EN) { + /* How many messages in fifo */ + rc = (status >> REG_RXSTA_RAC__SHIFT) & REG_RXSTA_RAC__MASK; + /* Sanity check */ + rc = rc > SUNXI_IR_FIFO_SIZE ? SUNXI_IR_FIFO_SIZE : rc; + /* If we have data */ + for (cnt = 0; cnt < rc; cnt++) { + /* for each bit in fifo */ + dt = readb(ir->base + SUNXI_IR_RXFIFO_REG); + rawir.pulse = (dt & 0x80) != 0; + rawir.duration = (dt & 0x7f) * SUNXI_IR_SAMPLE;Can the hardware actually return a zero duration or should that be dt & 0x7f + 1? (Not familiar with this particular hardware but I know I've seen that behaviour before).
Good point, I've just checked and the datasheet says the reported pulse duration can be up to 128, so that would make the range 1-128 not 0-127, so I believe we indeed need to add 1 to this. Regards, Hans -- You received this message because you are subscribed to the Google Groups "linux-sunxi" group. To unsubscribe from this group and stop receiving emails from it, send an email to linux-sunxi+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/d/optout.