From patchwork Sun Jan 26 21:50:24 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?QW50dGkgU2VwcMOkbMOk?= X-Patchwork-Id: 3540141 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id E2DE3C02DC for ; Sun, 26 Jan 2014 21:51:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 455D920117 for ; Sun, 26 Jan 2014 21:51:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D9BA720122 for ; Sun, 26 Jan 2014 21:51:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753470AbaAZVvJ (ORCPT ); Sun, 26 Jan 2014 16:51:09 -0500 Received: from mail-lb0-f174.google.com ([209.85.217.174]:60654 "EHLO mail-lb0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753125AbaAZVvH (ORCPT ); Sun, 26 Jan 2014 16:51:07 -0500 Received: by mail-lb0-f174.google.com with SMTP id l4so3905800lbv.19 for ; Sun, 26 Jan 2014 13:51:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-type:content-transfer-encoding; bh=jMMXrwsQSWySLW/4B0zj+3RhCntzdblTr3ow0dKgwvE=; b=awr6PRniXDi/ZE+i/CrvKCz0mVtX/eGmnpoA1rAcQ/ecJfn9dLn9Fq4QhKxYH9NAZL q5KyHYva0KYLd4cSY1fmMBWYmSqGziciAJlAd/X7S0WoYojmsEkjijs8bUGuGqTS+2u1 9YpD4Zh+uHYqhBTVqxdS+fM7ndccZmGIpDTjXntGGwgkRcGjXlgrqjE86RvB55zLca6/ 2msrgx4iPCdbO/iPmeQp4d92CJcur0Ou5szuBa14Hu8NWLhL2kRUrGu/FmK7EX9AbaSI iJnE3xGTWF/ji1xuyTjy3nkvn7dXZeBNxnfr7MulX5ZKdYuGlVHzJvmkAn3EFr25r3nu DNfg== X-Received: by 10.152.23.132 with SMTP id m4mr582054laf.34.1390773066730; Sun, 26 Jan 2014 13:51:06 -0800 (PST) Received: from pixie.elisa-laajakaista.fi (a88-114-92-24.elisa-laajakaista.fi. [88.114.92.24]) by mx.google.com with ESMTPSA id h7sm9767468lbj.1.2014.01.26.13.51.05 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jan 2014 13:51:05 -0800 (PST) From: =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= To: linux-media@vger.kernel.org Cc: Mauro Carvalho Chehab , Sean Young , =?UTF-8?q?Antti=20Sepp=C3=A4l=C3=A4?= Subject: [RFCv2 PATCH 3/5] rc-loopback: Add support for reading/writing wakeup scancodes via sysfs Date: Sun, 26 Jan 2014 23:50:24 +0200 Message-Id: <1390773026-567-4-git-send-email-a.seppala@gmail.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1390773026-567-1-git-send-email-a.seppala@gmail.com> References: <1390773026-567-1-git-send-email-a.seppala@gmail.com> MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.3 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch adds sample support for reading/writing the wakeup scancodes to rc-loopback device driver. Signed-off-by: Antti Seppälä --- drivers/media/rc/rc-loopback.c | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/drivers/media/rc/rc-loopback.c b/drivers/media/rc/rc-loopback.c index 53d0282..46e76ad 100644 --- a/drivers/media/rc/rc-loopback.c +++ b/drivers/media/rc/rc-loopback.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #define DRIVER_NAME "rc-loopback" @@ -45,6 +46,7 @@ struct loopback_dev { bool carrierreport; u32 rxcarriermin; u32 rxcarriermax; + u32 wakeup_scancode; }; static struct loopback_dev loopdev; @@ -176,6 +178,41 @@ static int loop_set_carrier_report(struct rc_dev *dev, int enable) return 0; } +static int loop_wakeup_codes(struct rc_dev *dev, + struct list_head *wakeup_code_list, int write) +{ + u32 value = 0; + struct rc_wakeup_code *code; + struct loopback_dev *lodev = dev->priv; + + dprintk("%sing wakeup codes\n", write ? "writ" : "read"); + + if (write) { + code = list_first_entry_or_null(wakeup_code_list, + struct rc_wakeup_code, + list_item); + if (code) + value = code->value; + + if (dev->enabled_wake_protos & RC_BIT_RC5) { + if (value > 0xFFF) + return -EINVAL; + } else if (dev->enabled_wake_protos & RC_BIT_RC6_0) { + if (value > 0xFFFF) + return -EINVAL; + } + + lodev->wakeup_scancode = value; + } else { + code = kmalloc(sizeof(struct rc_wakeup_code), GFP_KERNEL); + if (!code) + return -ENOMEM; + code->value = lodev->wakeup_scancode; + list_add_tail(&code->list_item, wakeup_code_list); + } + return 0; +} + static int __init loop_init(void) { struct rc_dev *rc; @@ -196,6 +233,8 @@ static int __init loop_init(void) rc->priv = &loopdev; rc->driver_type = RC_DRIVER_IR_RAW; rc->allowed_protos = RC_BIT_ALL; + rc->allowed_wake_protos = RC_BIT_RC6_0 | RC_BIT_RC5; + rc->enabled_wake_protos = RC_BIT_RC6_0; rc->timeout = 100 * 1000 * 1000; /* 100 ms */ rc->min_timeout = 1; rc->max_timeout = UINT_MAX; @@ -209,6 +248,7 @@ static int __init loop_init(void) rc->s_idle = loop_set_idle; rc->s_learning_mode = loop_set_learning_mode; rc->s_carrier_report = loop_set_carrier_report; + rc->s_wakeup_codes = loop_wakeup_codes; loopdev.txmask = RXMASK_REGULAR; loopdev.txcarrier = 36000;