From patchwork Fri Oct 15 15:07:52 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 256901 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 o9FFGOVA012873 for ; Fri, 15 Oct 2010 15:16:24 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756161Ab0JOPQX (ORCPT ); Fri, 15 Oct 2010 11:16:23 -0400 Received: from mail-fx0-f46.google.com ([209.85.161.46]:64150 "EHLO mail-fx0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756153Ab0JOPQW (ORCPT ); Fri, 15 Oct 2010 11:16:22 -0400 Received: by mail-fx0-f46.google.com with SMTP id 4so496650fxm.19 for ; Fri, 15 Oct 2010 08:16:19 -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=n7nLbI5ZqoDO2F6DhCPLo+/otwzwCLwdQhNH7mAHo3IONI7UIueu+//xy1jzFK2ILt ielndX5LP3Py6Jt9yUPf9UKN8IjPF8cKx1s8kGOGJZ77CV27Ahg2eIG3vg0RX0d+QF31 tPQ5VOtq/GvvycQ9/SfSLxY9brtA4T1C76G+4= 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=xUCegosWW+pz69syfZiQehSVOL2HhvqCRnVX/3BUYogjL6hf9RjFtJydrqZM3O++e1 dfsTHeXUNmUVo2ThS060qay1nf69bew1x7k1qe2qHaf7tSpn98oqyas6D7h2R/OF4w30 ec7W+UU6c1JWA2macdGKi0OPQvjrYQOWPA8Hw= Received: by 10.204.51.200 with SMTP id e8mr816221bkg.155.1287155305464; Fri, 15 Oct 2010 08:08:25 -0700 (PDT) Received: from maxim-laptop ([77.125.7.102]) by mx.google.com with ESMTPS id t10sm6907156bkj.16.2010.10.15.08.08.22 (version=SSLv3 cipher=RC4-MD5); Fri, 15 Oct 2010 08:08:24 -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 6/7] IR: ene_ir: add support for carrier reports Date: Fri, 15 Oct 2010 17:07:52 +0200 Message-Id: <1287155273-16171-7-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1287155273-16171-1-git-send-email-maximlevitsky@gmail.com> References: <1287155273-16171-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 15:16:24 +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);