From patchwork Fri Feb 28 23:28:57 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Hogan X-Patchwork-Id: 3745101 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 887AE9F2F7 for ; Fri, 28 Feb 2014 23:30:00 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 85567200DE for ; Fri, 28 Feb 2014 23:29:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 2A4BF200ED for ; Fri, 28 Feb 2014 23:29:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752566AbaB1X34 (ORCPT ); Fri, 28 Feb 2014 18:29:56 -0500 Received: from mail-wi0-f179.google.com ([209.85.212.179]:57666 "EHLO mail-wi0-f179.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752265AbaB1X3y (ORCPT ); Fri, 28 Feb 2014 18:29:54 -0500 Received: by mail-wi0-f179.google.com with SMTP id bs8so1216629wib.6 for ; Fri, 28 Feb 2014 15:29:53 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=9XJ2Y91Hy11FhGqVCHGM6wR+4/gKYjD689/abKWGs/M=; b=LY+plRe/ceNRwhJCt1FEiDv5YK5QwaKjWcMrIgYXz86c0zWwARWPy2oAgZP9zn3SWm nIWLyouNRvOsLzJPAUB+fOLhCY9lOWwmgSS+PhOCNdFOgjteHG5eNM61vt1RPlzZBdGI 7Ajb0KoB9yAX6Svz7jouayu1p4kYdSh041ziAVm5PtpSzM0ybJkWuFGpfTBmfRZg/3YD ft5wX764gKVUcnkDcUB7SQh9rBBM07HKBeYV1LCh3Abj4b28qt4pd8XCvDdvQb5SHxMw 9YdM1/v1c3H1CDArcfnp+1AWDNdB3iL2qYM1pomonJuV3NHoQpvQOsRBbiHEnFvV3zLe LE0g== X-Gm-Message-State: ALoCoQmbHtkbMDmomXdOi9sho80vzn2gYTlmAsoCiu+jAoQYBE05BTFyRGPR4s0gUnXMJVB/s6ly X-Received: by 10.180.101.230 with SMTP id fj6mr5531576wib.27.1393630193674; Fri, 28 Feb 2014 15:29:53 -0800 (PST) Received: from radagast.lan (jahogan.plus.com. [212.159.75.221]) by mx.google.com with ESMTPSA id lz3sm9172173wic.1.2014.02.28.15.29.52 for (version=TLSv1.2 cipher=AES128-GCM-SHA256 bits=128/128); Fri, 28 Feb 2014 15:29:53 -0800 (PST) From: James Hogan To: Mauro Carvalho Chehab , linux-media@vger.kernel.org Cc: James Hogan Subject: [PATCH v4 07/10] rc: img-ir: add JVC decoder module Date: Fri, 28 Feb 2014 23:28:57 +0000 Message-Id: <1393630140-31765-8-git-send-email-james.hogan@imgtec.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1393630140-31765-1-git-send-email-james.hogan@imgtec.com> References: <1393630140-31765-1-git-send-email-james.hogan@imgtec.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, 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 Add an img-ir module for decoding the JVC infrared protocol. Signed-off-by: James Hogan Cc: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org --- v2: - Update to new scancode interface (32-bit NEC). - Update to new filtering interface (generic struct rc_scancode_filter). - Remove modularity and dynamic registration/unregistration, adding JVC directly to the list of decoders in img-ir-hw.c. --- drivers/media/rc/img-ir/Kconfig | 7 +++ drivers/media/rc/img-ir/Makefile | 1 + drivers/media/rc/img-ir/img-ir-hw.c | 4 ++ drivers/media/rc/img-ir/img-ir-jvc.c | 92 ++++++++++++++++++++++++++++++++++++ 4 files changed, 104 insertions(+) create mode 100644 drivers/media/rc/img-ir/img-ir-jvc.c diff --git a/drivers/media/rc/img-ir/Kconfig b/drivers/media/rc/img-ir/Kconfig index 28498a2..96006fbf 100644 --- a/drivers/media/rc/img-ir/Kconfig +++ b/drivers/media/rc/img-ir/Kconfig @@ -31,3 +31,10 @@ config IR_IMG_NEC help Say Y here to enable support for the NEC, extended NEC, and 32-bit NEC protocols in the ImgTec infrared decoder block. + +config IR_IMG_JVC + bool "JVC protocol support" + depends on IR_IMG_HW + help + Say Y here to enable support for the JVC protocol in the ImgTec + infrared decoder block. diff --git a/drivers/media/rc/img-ir/Makefile b/drivers/media/rc/img-ir/Makefile index c409197..c5f8f06 100644 --- a/drivers/media/rc/img-ir/Makefile +++ b/drivers/media/rc/img-ir/Makefile @@ -2,6 +2,7 @@ img-ir-y := img-ir-core.o img-ir-$(CONFIG_IR_IMG_RAW) += img-ir-raw.o img-ir-$(CONFIG_IR_IMG_HW) += img-ir-hw.o img-ir-$(CONFIG_IR_IMG_NEC) += img-ir-nec.o +img-ir-$(CONFIG_IR_IMG_JVC) += img-ir-jvc.o img-ir-objs := $(img-ir-y) obj-$(CONFIG_IR_IMG) += img-ir.o diff --git a/drivers/media/rc/img-ir/img-ir-hw.c b/drivers/media/rc/img-ir/img-ir-hw.c index 139f2c7..81c50e3 100644 --- a/drivers/media/rc/img-ir/img-ir-hw.c +++ b/drivers/media/rc/img-ir/img-ir-hw.c @@ -21,12 +21,16 @@ static DEFINE_SPINLOCK(img_ir_decoders_lock); extern struct img_ir_decoder img_ir_nec; +extern struct img_ir_decoder img_ir_jvc; static bool img_ir_decoders_preprocessed; static struct img_ir_decoder *img_ir_decoders[] = { #ifdef CONFIG_IR_IMG_NEC &img_ir_nec, #endif +#ifdef CONFIG_IR_IMG_JVC + &img_ir_jvc, +#endif NULL }; diff --git a/drivers/media/rc/img-ir/img-ir-jvc.c b/drivers/media/rc/img-ir/img-ir-jvc.c new file mode 100644 index 0000000..ae55867 --- /dev/null +++ b/drivers/media/rc/img-ir/img-ir-jvc.c @@ -0,0 +1,92 @@ +/* + * ImgTec IR Decoder setup for JVC protocol. + * + * Copyright 2012-2014 Imagination Technologies Ltd. + */ + +#include "img-ir-hw.h" + +/* Convert JVC data to a scancode */ +static int img_ir_jvc_scancode(int len, u64 raw, int *scancode, u64 protocols) +{ + unsigned int cust, data; + + if (len != 16) + return -EINVAL; + + cust = (raw >> 0) & 0xff; + data = (raw >> 8) & 0xff; + + *scancode = cust << 8 | data; + return IMG_IR_SCANCODE; +} + +/* Convert JVC scancode to JVC data filter */ +static int img_ir_jvc_filter(const struct rc_scancode_filter *in, + struct img_ir_filter *out, u64 protocols) +{ + unsigned int cust, data; + unsigned int cust_m, data_m; + + cust = (in->data >> 8) & 0xff; + cust_m = (in->mask >> 8) & 0xff; + data = (in->data >> 0) & 0xff; + data_m = (in->mask >> 0) & 0xff; + + out->data = cust | data << 8; + out->mask = cust_m | data_m << 8; + + return 0; +} + +/* + * JVC decoder + * See also http://www.sbprojects.com/knowledge/ir/jvc.php + * http://support.jvc.com/consumer/support/documents/RemoteCodes.pdf + */ +struct img_ir_decoder img_ir_jvc = { + .type = RC_BIT_JVC, + .control = { + .decoden = 1, + .code_type = IMG_IR_CODETYPE_PULSEDIST, + .decodend2 = 1, + }, + /* main timings */ + .unit = 527500, /* 527.5 us */ + .timings = { + /* leader symbol */ + .ldr = { + .pulse = { 16 /* 8.44 ms */ }, + .space = { 8 /* 4.22 ms */ }, + }, + /* 0 symbol */ + .s00 = { + .pulse = { 1 /* 527.5 us +-60 us */ }, + .space = { 1 /* 527.5 us */ }, + }, + /* 1 symbol */ + .s01 = { + .pulse = { 1 /* 527.5 us +-60 us */ }, + .space = { 3 /* 1.5825 ms +-40 us */ }, + }, + /* 0 symbol (no leader) */ + .s00 = { + .pulse = { 1 /* 527.5 us +-60 us */ }, + .space = { 1 /* 527.5 us */ }, + }, + /* 1 symbol (no leader) */ + .s01 = { + .pulse = { 1 /* 527.5 us +-60 us */ }, + .space = { 3 /* 1.5825 ms +-40 us */ }, + }, + /* free time */ + .ft = { + .minlen = 16, + .maxlen = 16, + .ft_min = 10, /* 5.275 ms */ + }, + }, + /* scancode logic */ + .scancode = img_ir_jvc_scancode, + .filter = img_ir_jvc_filter, +};