From patchwork Mon Sep 6 21:26:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 159451 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 o86LQjfd030893 for ; Mon, 6 Sep 2010 21:26:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755740Ab0IFV0q (ORCPT ); Mon, 6 Sep 2010 17:26:46 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:57693 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755709Ab0IFV0n (ORCPT ); Mon, 6 Sep 2010 17:26:43 -0400 Received: by mail-fx0-f46.google.com with SMTP id 13so2662937fxm.19 for ; Mon, 06 Sep 2010 14:26:42 -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=sgaCmh+W0hp5KZ1o5Az5rUcIj3x1cTkKAgslT72Pntx1c39dm+R+Xe2V8QqPvFT/XX LCQBA7UkFpHdCuBs6qEn5Kc77VvnExJsicnuQ3YkI0ywcSzf/8jbgxhKRdJcEMU0lGif Zpq4ufyLUpilKpOweuYHTde26EpQrx0OLzf2U= 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=SdLZnJSZ78kS6i+olNg3fMkMiLyztBgAyYdXebeCREzwNGQjb50koy81pZKkgeQZYZ laetdUFKI0pkeZhxZukSe7YETLNfgjQC52UO71n6Lcj6Y+wAr4J5aPyrMWkvhc5zjfFy 1RGiBBOf0NXep6yBoyZlSKVI6Hhf6nU45YJsI= Received: by 10.223.106.1 with SMTP id v1mr628548fao.47.1283808402629; Mon, 06 Sep 2010 14:26:42 -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 k15sm2504881fai.16.2010.09.06.14.26.40 (version=SSLv3 cipher=RC4-MD5); Mon, 06 Sep 2010 14:26:41 -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 8/8] IR: ene_ir: add support for carrier reports Date: Tue, 7 Sep 2010 00:26:13 +0300 Message-Id: <1283808373-27876-9-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.0.4 In-Reply-To: <1283808373-27876-1-git-send-email-maximlevitsky@gmail.com> References: <1283808373-27876-1-git-send-email-maximlevitsky@gmail.com> Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@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]); Mon, 06 Sep 2010 21:26:48 +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);