From patchwork Sat Jul 31 14:59:20 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 116188 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter.kernel.org (8.14.4/8.14.3) with ESMTP id o6VFfh3s024126 for ; Sat, 31 Jul 2010 15:49:42 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756213Ab0GaO75 (ORCPT ); Sat, 31 Jul 2010 10:59:57 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:55010 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756103Ab0GaO7s (ORCPT ); Sat, 31 Jul 2010 10:59:48 -0400 Received: by mail-bw0-f46.google.com with SMTP id 1so870874bwz.19 for ; Sat, 31 Jul 2010 07:59:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:from:to:cc:subject:date :message-id:x-mailer:in-reply-to:references; bh=y4saEjevFwEJGJGsFCBGG7mBmB25RE6wRVvkpqIS+KQ=; b=ZwB878KENvs3Vw7pvBSzbrpE/gdbd1G3XgB2YNLzvQaDptIHmjbYjR8y1jlBYostpO owR6uMAIDpMlrlPI8n2P+UE1nyqdT8YQENY9bZW307UXJJsru0Q2a4yeMCmOJ6/+mhWb Q7YmMZXeMaUTzPBL9N5FNnlm5dPWLYXS4TcvY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer:in-reply-to:references; b=M8cOCXrBvK9CzTomaPsoPKKAVp8UTHuxtZfWHrwK6du4+QFUmuf4M7H6MFcBsFCbQh eTCxeqD/oj56pm+QL42oH6euDTSUa7hzsuT/3d+GB74a4qBUBKT4PlZOnPAWoS0zdFa6 UdhIiruRK6+9xAPn6EEuQPIl8y88vAlUqigY0= Received: by 10.204.47.193 with SMTP id o1mr2258942bkf.134.1280588387251; Sat, 31 Jul 2010 07:59:47 -0700 (PDT) Received: from localhost.localdomain (IGLD-84-228-252-15.inter.net.il [84.228.252.15]) by mx.google.com with ESMTPS id a9sm2445428bky.23.2010.07.31.07.59.45 (version=SSLv3 cipher=RC4-MD5); Sat, 31 Jul 2010 07:59:46 -0700 (PDT) From: Maxim Levitsky To: lirc-list@lists.sourceforge.net Cc: Jarod Wilson , linux-input@vger.kernel.org, linux-media@vger.kernel.org, Mauro Carvalho Chehab , Christoph Bartelmus , Maxim Levitsky Subject: [PATCH 07/13] IR: NECX: support repeat Date: Sat, 31 Jul 2010 17:59:20 +0300 Message-Id: <1280588366-26101-8-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1280588366-26101-1-git-send-email-maximlevitsky@gmail.com> References: <1280588366-26101-1-git-send-email-maximlevitsky@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter.kernel.org [140.211.167.41]); Sat, 31 Jul 2010 15:49:49 +0000 (UTC) diff --git a/drivers/media/IR/ir-core-priv.h b/drivers/media/IR/ir-core-priv.h index 84c7a9a..502d477 100644 --- a/drivers/media/IR/ir-core-priv.h +++ b/drivers/media/IR/ir-core-priv.h @@ -45,6 +45,8 @@ struct ir_raw_event_ctrl { int state; unsigned count; u32 bits; + bool is_nec_x; + bool necx_repeat; } nec; struct rc5_dec { int state; diff --git a/drivers/media/IR/ir-nec-decoder.c b/drivers/media/IR/ir-nec-decoder.c index 1c0cf03..d597421 100644 --- a/drivers/media/IR/ir-nec-decoder.c +++ b/drivers/media/IR/ir-nec-decoder.c @@ -26,6 +26,7 @@ #define NEC_BIT_1_SPACE (3 * NEC_UNIT) #define NEC_TRAILER_PULSE (1 * NEC_UNIT) #define NEC_TRAILER_SPACE (10 * NEC_UNIT) /* even longer in reality */ +#define NECX_REPEAT_BITS 1 enum nec_state { STATE_INACTIVE, @@ -67,8 +68,12 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev) if (!ev.pulse) break; - if (!eq_margin(ev.duration, NEC_HEADER_PULSE, NEC_UNIT / 2) && - !eq_margin(ev.duration, NECX_HEADER_PULSE, NEC_UNIT / 2)) + if (eq_margin(ev.duration, NEC_HEADER_PULSE, NEC_UNIT / 2)) { + data->is_nec_x = false; + data->necx_repeat = false; + } else if (eq_margin(ev.duration, NECX_HEADER_PULSE, NEC_UNIT / 2)) + data->is_nec_x = true; + else break; data->count = 0; @@ -105,6 +110,17 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev) if (ev.pulse) break; + if (data->necx_repeat && data->count == NECX_REPEAT_BITS && + geq_margin(ev.duration, + NEC_TRAILER_SPACE, NEC_UNIT / 2)) { + IR_dprintk(1, "Repeat last key\n"); + ir_repeat(input_dev); + data->state = STATE_INACTIVE; + return 0; + + } else if (data->count > NECX_REPEAT_BITS) + data->necx_repeat = false; + data->bits <<= 1; if (eq_margin(ev.duration, NEC_BIT_1_SPACE, NEC_UNIT / 2)) data->bits |= 1; @@ -159,6 +175,9 @@ static int ir_nec_decode(struct input_dev *input_dev, struct ir_raw_event ev) IR_dprintk(1, "NEC scancode 0x%04x\n", scancode); } + if (data->is_nec_x) + data->necx_repeat = true; + ir_keydown(input_dev, scancode, 0); data->state = STATE_INACTIVE; return 0;