From patchwork Sun Sep 5 22:22:44 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 157091 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 o85MMtwS008961 for ; Sun, 5 Sep 2010 22:23:16 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754531Ab0IEWXQ (ORCPT ); Sun, 5 Sep 2010 18:23:16 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:34156 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753678Ab0IEWXQ (ORCPT ); Sun, 5 Sep 2010 18:23:16 -0400 Received: by mail-fx0-f46.google.com with SMTP id 13so2219369fxm.19 for ; Sun, 05 Sep 2010 15:23:15 -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=RsDGM1FCuYzzeW8EHYdbsvUf48oipvekZLUYbpgTdrg=; b=HIE9CfymtDEhEII3xcK2UoMyKB0dB06yG+taBOmX9KKY/nRRTEEIr0DzE6xiG9vp1o 5A+BnR9FkIi8UiSO/W8PjBJz99uqNObjy3cCiMklk79EVjnANRaNvCce2mV+Qb+nPd+B AEqzHfebWvamtDg28b1LYNm22K/yhe0xChzM0= 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=CZ3ZIctGAdcEjqY2Y1SDs34JB/R701ZNiPfWbGNyrj8vaqg1XefQM1SayNBf3tmLih P7rio9aI6iHz83WOtvFrwmOEw25ezKJ1dfeRZLtn7t6eHJB9u663VD9m8tqwoKvmy0kZ wb3qd9q7JuncQnICcNlOsqujg+R9Y/u05AviI= Received: by 10.223.114.204 with SMTP id f12mr1856157faq.34.1283725395428; Sun, 05 Sep 2010 15:23:15 -0700 (PDT) Received: from localhost.localdomain (IGLD-84-228-233-189.inter.net.il [84.228.233.189]) by mx.google.com with ESMTPS id u8sm2055880fah.36.2010.09.05.15.23.11 (version=SSLv3 cipher=RC4-MD5); Sun, 05 Sep 2010 15:23:12 -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, Maxim Levitsky Subject: [PATCH 8/8] IR: ene_ir: add support for carrier reports Date: Mon, 6 Sep 2010 01:22:44 +0300 Message-Id: <1283725364-4053-9-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1283725364-4053-1-git-send-email-maximlevitsky@gmail.com> References: <1283725364-4053-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]); Sun, 05 Sep 2010 22:23:17 +0000 (UTC) diff --git a/drivers/media/IR/ene_ir.c b/drivers/media/IR/ene_ir.c index dc32509..f1ee153 100644 --- a/drivers/media/IR/ene_ir.c +++ b/drivers/media/IR/ene_ir.c @@ -192,10 +192,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; @@ -208,13 +209,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 */ @@ -728,7 +732,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 @@ -903,6 +907,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) { @@ -1032,7 +1053,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);