From patchwork Sun Jun 26 21:06:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Martin Blumenstingl X-Patchwork-Id: 9199609 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7859160754 for ; Sun, 26 Jun 2016 21:07:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 63B3E28555 for ; Sun, 26 Jun 2016 21:07:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 56C4128557; Sun, 26 Jun 2016 21:07:04 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.1 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,FREEMAIL_FROM,RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 10A4E28555 for ; Sun, 26 Jun 2016 21:07:04 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHHGf-0001MT-MU; Sun, 26 Jun 2016 21:07:01 +0000 Received: from mail-wm0-x242.google.com ([2a00:1450:400c:c09::242]) by bombadil.infradead.org with esmtps (Exim 4.85_2 #1 (Red Hat Linux)) id 1bHHGY-0001JK-N9; Sun, 26 Jun 2016 21:06:55 +0000 Received: by mail-wm0-x242.google.com with SMTP id 187so19778390wmz.1; Sun, 26 Jun 2016 14:06:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=F7qfUs7zkGEaWvVE73gIZzOXUN2PPA73+fSaWxXQjo8=; b=hwckuHQnuctWE01b439CiQA/a3stjGGGnn9lyIPHN9xO5neJ+g/6V+dKONuF3uGIWQ ryxc/Sc6+kJcQ7ka0OUdwhiyQBypepIRdFkyykCLR8GBcCaVIGWZHGw88d9EycdSPJ+R KyM/V6MtpVQl9omdbUOlII1uANjASOZHFXBfjHyX4zSAln7r/1xFIp/edJf+eXzmHGud pBtrVK/uJt67GrkUvsP2X2zSVGboNVR8CRBD0bOUzMDl5K5YW2Ow98NCDpM4PWb8yUiB qGlQsIRBlyc3wwmgwWs08TbjyrAouIkXqerWlsVLYyCDQoT74csw1QZzhDZPK/wCS2PK 09MQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=F7qfUs7zkGEaWvVE73gIZzOXUN2PPA73+fSaWxXQjo8=; b=E/Fp4IhqL3xgu1k/og3Ivvo5uDc+H8dBDZ6fMw1ZhwsG2nFqx9+RbvuYEI2h4v8HAn WW5rATAp5XnY2Qf1sOZ97PlMXut5J676fbF6SVwY5T+q1//o/ICzJzqEmTKp9maS/Xcv P2FkYPpFqGOMUetwxXpK5lqEmi9BnC5vqkVHRFE/Zii8q3kczMYM4sK3t9tvHKgxIbET 51irnUx4E0XDbCLZX4U5dixPV+xMVeEO10m5AcfIEBcszNlYXK3wqXNHIz/hDAQ5UfgX qvaLgtFrZ7ct1pTAjL2Gq4IAxUrzRsVvXDp5hRiQWr/JXqztJo2s09i9UCrPQ0vUjqnm biPA== X-Gm-Message-State: ALyK8tL2NfLKbpq8A8vNMgvclr+WCaDvza6ndd4t+i7Vdu/PjbHXSM+a11wrS/k7RGP6mw== X-Received: by 10.194.165.233 with SMTP id zb9mr13939070wjb.172.1466975191876; Sun, 26 Jun 2016 14:06:31 -0700 (PDT) Received: from blackbox.darklights.net (p200300DCD3CD1B04BC56BB9C73E3153B.dip0.t-ipconnect.de. [2003:dc:d3cd:1b04:bc56:bb9c:73e3:153b]) by smtp.googlemail.com with ESMTPSA id el4sm3639812wjd.23.2016.06.26.14.06.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 26 Jun 2016 14:06:30 -0700 (PDT) From: Martin Blumenstingl To: b.galvani@gmail.com, linux-media@vger.kernel.org, linux-amlogic@lists.infradead.org Subject: [PATCH v2 1/2] media: rc: meson-ir: fix enabling raw/soft-decoding mode Date: Sun, 26 Jun 2016 23:06:21 +0200 Message-Id: <20160626210622.5257-2-martin.blumenstingl@googlemail.com> X-Mailer: git-send-email 2.9.0 In-Reply-To: <20160626210622.5257-1-martin.blumenstingl@googlemail.com> References: <20160626210622.5257-1-martin.blumenstingl@googlemail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160626_140654_946934_F06AB4BE X-CRM114-Status: GOOD ( 11.75 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: mark.rutland@arm.com, devicetree@vger.kernel.org, pawel.moll@arm.com, Martin Blumenstingl , khilman@baylibre.com, tobetter@gmail.com, robh+dt@kernel.org, carlo@caione.org, mchehab@kernel.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+patchwork-linux-amlogic=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP According to the datasheet of Meson8b (S805) and GXBB (S905) the decoding mode is configured in AO_MF_IR_DEC_REG2 (offset 0x20) using bits 0-3. The "duration" field may not be set correctly when any of the hardware decoding modes. This can happen while a "default" decoding mode (either set by the bootloader or the chip's default, which uses NEC as it's default) is used. While here, I also added defines for the protocols which can be decoded by the hardware (more work is needed to be actually able to use them though). Signed-off-by: Martin Blumenstingl --- changes in v1 -> v2: - fixed subject of the patch to include meson-ir - fixed double-shifting of the decoder mode values drivers/media/rc/meson-ir.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/drivers/media/rc/meson-ir.c b/drivers/media/rc/meson-ir.c index fcc3b82..622a4160 100644 --- a/drivers/media/rc/meson-ir.c +++ b/drivers/media/rc/meson-ir.c @@ -32,13 +32,10 @@ #define IR_DEC_FRAME 0x14 #define IR_DEC_STATUS 0x18 #define IR_DEC_REG1 0x1c +#define IR_DEC_REG2 0x20 #define REG0_RATE_MASK (BIT(11) - 1) -#define REG1_MODE_MASK (BIT(7) | BIT(8)) -#define REG1_MODE_NEC (0 << 7) -#define REG1_MODE_GENERAL (2 << 7) - #define REG1_TIME_IV_SHIFT 16 #define REG1_TIME_IV_MASK ((BIT(13) - 1) << REG1_TIME_IV_SHIFT) @@ -51,6 +48,20 @@ #define REG1_RESET BIT(0) #define REG1_ENABLE BIT(15) +#define REG2_DEC_MODE_SHIFT 0 +#define REG2_DEC_MODE_MASK GENMASK(3, REG2_DEC_MODE_SHIFT) +#define REG2_DEC_MODE_NEC 0x0 +#define REG2_DEC_MODE_RAW 0x2 +#define REG2_DEC_MODE_THOMSON 0x4 +#define REG2_DEC_MODE_TOSHIBA 0x5 +#define REG2_DEC_MODE_SONY 0x6 +#define REG2_DEC_MODE_RC5 0x7 +#define REG2_DEC_MODE_RC6 0x9 +#define REG2_DEC_MODE_RCMM 0xa +#define REG2_DEC_MODE_DUOKAN 0xb +#define REG2_DEC_MODE_COMCAST 0xe +#define REG2_DEC_MODE_SANYO 0xf + #define STATUS_IR_DEC_IN BIT(8) #define MESON_TRATE 10 /* us */ @@ -158,8 +169,9 @@ static int meson_ir_probe(struct platform_device *pdev) /* Reset the decoder */ meson_ir_set_mask(ir, IR_DEC_REG1, REG1_RESET, REG1_RESET); meson_ir_set_mask(ir, IR_DEC_REG1, REG1_RESET, 0); - /* Set general operation mode */ - meson_ir_set_mask(ir, IR_DEC_REG1, REG1_MODE_MASK, REG1_MODE_GENERAL); + /* Enable raw/soft-decode mode */ + meson_ir_set_mask(ir, IR_DEC_REG2, REG2_DEC_MODE_MASK, + REG2_DEC_MODE_RAW << REG2_DEC_MODE_SHIFT); /* Set rate */ meson_ir_set_mask(ir, IR_DEC_REG0, REG0_RATE_MASK, MESON_TRATE - 1); /* IRQ on rising and falling edges */