From patchwork Thu Jun 23 18:40:01 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dmitry Torokhov X-Patchwork-Id: 912822 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.4) with ESMTP id p5NIeOYj015875 for ; Thu, 23 Jun 2011 18:40:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1759896Ab1FWSkU (ORCPT ); Thu, 23 Jun 2011 14:40:20 -0400 Received: from mail-pz0-f46.google.com ([209.85.210.46]:38104 "EHLO mail-pz0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759825Ab1FWSkS (ORCPT ); Thu, 23 Jun 2011 14:40:18 -0400 Received: by pzk9 with SMTP id 9so1340804pzk.19 for ; Thu, 23 Jun 2011 11:40:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:date:from:to:cc:subject:message-id:references :mime-version:content-type:content-disposition:in-reply-to :user-agent; bh=45LW5KU30KJYgVY16y6pQ2XB54+Bye6KfjK54PTwwq8=; b=wG6KKJz1fBaWNyXwLtirYpuDdstZbjToaANFygn0mx5AHFZTlwPtDVJgsTIeUSoI0e 0nA733pfJQQu9Li33vaTYtoCPagVXGa/xSaXwdjUGfAxDCsbbWG7UBAxal4HIHK3oHiD HlY3KR6tjGdsNZOm2/G9sPNduAHOrKE9r9org= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:references:mime-version :content-type:content-disposition:in-reply-to:user-agent; b=OnLbob6FKHfzf0Ablm3CYG1yU0dwkdUAyv2o8A40vFku+bV9ldVMBzeBlcf0j/QEHd 2mgb9SrkRHgL2XnsMUmf6txR6uaPcWnR9hP4uZZOW3y0lV7FMKu9zqHyIcP1iwLhkAEx l7tIP3qWP1JvMCgYmLsVqzJncFB8XI8KQQHdw= Received: by 10.68.21.33 with SMTP id s1mr1226758pbe.510.1308854417391; Thu, 23 Jun 2011 11:40:17 -0700 (PDT) Received: from mailhub.coreip.homeip.net (c-98-234-113-65.hsd1.ca.comcast.net [98.234.113.65]) by mx.google.com with ESMTPS id g2sm1401214pbh.95.2011.06.23.11.40.15 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 23 Jun 2011 11:40:16 -0700 (PDT) Date: Thu, 23 Jun 2011 11:40:01 -0700 From: Dmitry Torokhov To: Jarod Wilson Cc: linux-media@vger.kernel.org, Mauro Carvalho Chehab , Jeff Brown Subject: Re: [PATCH] [media] rc: call input_sync after scancode reports Message-ID: <20110623183957.GC14950@core.coreip.homeip.net> References: <1308851886-4607-1-git-send-email-jarod@redhat.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1308851886-4607-1-git-send-email-jarod@redhat.com> User-Agent: Mutt/1.5.21 (2010-09-15) 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.6 (demeter1.kernel.org [140.211.167.41]); Thu, 23 Jun 2011 18:40:24 +0000 (UTC) Hi Jarod, On Thu, Jun 23, 2011 at 01:58:06PM -0400, Jarod Wilson wrote: > @@ -623,6 +624,7 @@ static void ir_do_keydown(struct rc_dev *dev, int scancode, > u32 keycode, u8 toggle) > { > input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); > + input_sync(dev->input_dev); > > /* Repeat event? */ > if (dev->keypressed && It looks like we would be issuing up to 3 input_sync() for a single keypress... Order of events is wrong too (we first issue MSC_SCAN for new key and then release old key). How about we change it a bit like in the patch below? diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index f57cd56..237cf84 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -597,6 +597,7 @@ void rc_repeat(struct rc_dev *dev) spin_lock_irqsave(&dev->keylock, flags); input_event(dev->input_dev, EV_MSC, MSC_SCAN, dev->last_scancode); + input_sync(dev->input_dev); if (!dev->keypressed) goto out; @@ -622,29 +623,31 @@ EXPORT_SYMBOL_GPL(rc_repeat); static void ir_do_keydown(struct rc_dev *dev, int scancode, u32 keycode, u8 toggle) { - input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); - - /* Repeat event? */ - if (dev->keypressed && - dev->last_scancode == scancode && - dev->last_toggle == toggle) - return; + bool new_event = !dev->keypressed || + dev->last_scancode != scancode || + dev->last_toggle != toggle; + + if (new_event && dev->keypressed) { + /* Release old keypress */ + IR_dprintk(1, "keyup previous key 0x%04x\n", dev->last_keycode); + input_report_key(dev->input_dev, dev->last_keycode, 0); + dev->keypressed = false; + } - /* Release old keypress */ - ir_do_keyup(dev); + input_event(dev->input_dev, EV_MSC, MSC_SCAN, scancode); - dev->last_scancode = scancode; - dev->last_toggle = toggle; - dev->last_keycode = keycode; + if (new_event && keycode != KEY_RESERVED) { + /* Register a keypress */ + dev->keypressed = true; + IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n", + dev->input_name, keycode, scancode); + input_report_key(dev->input_dev, dev->last_keycode, 1); - if (keycode == KEY_RESERVED) - return; + dev->last_scancode = scancode; + dev->last_toggle = toggle; + dev->last_keycode = keycode; + } - /* Register a keypress */ - dev->keypressed = true; - IR_dprintk(1, "%s: key down event, key 0x%04x, scancode 0x%04x\n", - dev->input_name, keycode, scancode); - input_report_key(dev->input_dev, dev->last_keycode, 1); input_sync(dev->input_dev); }