From patchwork Fri Oct 15 16:06:38 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 257151 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id o9FGwwg5007453 for ; Fri, 15 Oct 2010 16:58:58 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932103Ab0JOQ6x (ORCPT ); Fri, 15 Oct 2010 12:58:53 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:41199 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932185Ab0JOQ6w (ORCPT ); Fri, 15 Oct 2010 12:58:52 -0400 Received: by fxm4 with SMTP id 4so619467fxm.19 for ; Fri, 15 Oct 2010 09:58:51 -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=ZxlOGxWQa+Vrje+GSTEAcITab9Th5jpBOn6XSG2KL/k=; b=lpHHSDm9mRMDQqeHghXAFP/ol5oejrKED+FNS/4+1P3XoOp464LGoY0xLfuqGgN4Ql 9n9ded/jHvbB2sr1lWZ9lewNQpt3GNbjEqHv+T/2pc2fbYo3Qig7AQszlLJcAon0Ym5i cM2RmSTOkh02IwzLPlyf6aSQt1IH2tUbi4PdE= 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=ZyZa2PLUOotT2m0OrpDbsahHOXbSkFvvU8h6CZeLVf/IyA2G/AlSIs1lGZKIZjUtUP cAIicKmiXJBFxnoCqV1SxXjwiGmlm4voY58rREq8BDTqa1l84OVdcN2TPn50isjdwksa VmEevPKYCLypgC2+YtGkfTatOJxEw9RKspg4s= Received: by 10.204.79.147 with SMTP id p19mr870789bkk.129.1287158829213; Fri, 15 Oct 2010 09:07:09 -0700 (PDT) Received: from maxim-laptop ([77.125.87.13]) by mx.google.com with ESMTPS id y19sm12677302bkw.6.2010.10.15.09.07.04 (version=SSLv3 cipher=RC4-MD5); Fri, 15 Oct 2010 09:07:06 -0700 (PDT) From: Maxim Levitsky To: lirc-list@lists.sourceforge.net Cc: Jarod Wilson , =?UTF-8?q?David=20H=C3=A4rdeman?= , mchehab@infradead.org, linux-input@vger.kernel.org, linux-media@vger.kernel.org, Maxim Levitsky Subject: [PATCH 4/5] IR: ene_ir: add support for carrier reports Date: Fri, 15 Oct 2010 18:06:38 +0200 Message-Id: <1287158799-21486-5-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1287158799-21486-1-git-send-email-maximlevitsky@gmail.com> References: <1287158799-21486-1-git-send-email-maximlevitsky@gmail.com> Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Fri, 15 Oct 2010 16:58:58 +0000 (UTC) diff --git a/drivers/media/IR/ene_ir.c b/drivers/media/IR/ene_ir.c index 8639621..1962652 100644 --- a/drivers/media/IR/ene_ir.c +++ b/drivers/media/IR/ene_ir.c @@ -193,10 +193,11 @@ static int ene_hw_detect(struct ene_device *dev) /* Sense current received carrier */ void ene_rx_sense_carrier(struct ene_device *dev) { + DEFINE_IR_RAW_EVENT(ev); + + int carrier, duty_cycle; int period = ene_read_reg(dev, ENE_CIRCAR_PRD); int hperiod = ene_read_reg(dev, ENE_CIRCAR_HPRD); - int carrier, duty_cycle; - if (!(period & ENE_CIRCAR_PRD_VALID)) return; @@ -209,13 +210,16 @@ void ene_rx_sense_carrier(struct ene_device *dev) dbg("RX: hardware carrier period = %02x", period); dbg("RX: hardware carrier pulse period = %02x", hperiod); - carrier = 2000000 / period; duty_cycle = (hperiod * 100) / period; dbg("RX: sensed carrier = %d Hz, duty cycle %d%%", - carrier, duty_cycle); - - /* TODO: Send carrier & duty cycle to IR layer */ + carrier, duty_cycle); + if (dev->carrier_detect_enabled) { + ev.carrier_report = true; + ev.carrier = carrier; + ev.duty_cycle = duty_cycle; + ir_raw_event_store(dev->idev, &ev); + } } /* this enables/disables the CIR RX engine */ @@ -724,7 +728,7 @@ static irqreturn_t ene_isr(int irq, void *data) dbg_verbose("RX interrupt"); - if (dev->carrier_detect_enabled || debug) + if (dev->hw_learning_and_tx_capable) ene_rx_sense_carrier(dev); /* On hardware that don't support extra buffer we need to trust @@ -897,6 +901,23 @@ static int ene_set_learning_mode(void *data, int enable) return 0; } +static int ene_set_carrier_report(void *data, int enable) +{ + struct ene_device *dev = (struct ene_device *)data; + unsigned long flags; + + if (enable == dev->carrier_detect_enabled) + return 0; + + spin_lock_irqsave(&dev->hw_lock, flags); + dev->carrier_detect_enabled = enable; + ene_rx_disable(dev); + ene_rx_setup(dev); + ene_rx_enable(dev); + spin_unlock_irqrestore(&dev->hw_lock, flags); + return 0; +} + /* outside interface: enable or disable idle mode */ static void ene_rx_set_idle(void *data, bool idle) { @@ -1029,7 +1050,7 @@ static int ene_probe(struct pnp_dev *pnp_dev, const struct pnp_device_id *id) ir_props->s_tx_mask = ene_set_tx_mask; ir_props->s_tx_carrier = ene_set_tx_carrier; ir_props->s_tx_duty_cycle = ene_set_tx_duty_cycle; - /* ir_props->s_carrier_report = ene_set_carrier_report; */ + ir_props->s_carrier_report = ene_set_carrier_report; } ene_setup_hw_buffer(dev);