From patchwork Sat Oct 16 22:56:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxim Levitsky X-Patchwork-Id: 259441 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 o9GMumug021835 for ; Sat, 16 Oct 2010 22:56:48 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756693Ab0JPW4q (ORCPT ); Sat, 16 Oct 2010 18:56:46 -0400 Received: from mail-bw0-f46.google.com ([209.85.214.46]:43564 "EHLO mail-bw0-f46.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756602Ab0JPW4p (ORCPT ); Sat, 16 Oct 2010 18:56:45 -0400 Received: by bwz15 with SMTP id 15so2033486bwz.19 for ; Sat, 16 Oct 2010 15:56:44 -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=kSoxFNC95xCP25o6Qod3TYGNUkVdIuzfHqhRtkI4vFawNKxvyUyyW/tjtIiXG3SKap PIY2xpYkqh+yONL7tOOTM3Fs6WZJ//CCWEh4fkvqrUfQaNzSSPscbWNAK5MAvJobz3tc L+AUWbDs2MXw5w0tm1kqNCZ3fa4FDDEwHgtiA= 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=SBQQSL/rvjjY6Skou4fESdttFOflJwZHD/Kmit4vnF/titCTAPk4j4gyaHZut4eOP2 Dy8/Mk2UzXqxk7CnCe3k/8cas/qYUp21io66EB4Sz1VpaHxOzvvEssCPxPLUEN6MkPKN YBYUh5Qv5Zctize85fnDds0YafslqFooUNKuQ= Received: by 10.204.129.210 with SMTP id p18mr2578702bks.85.1287269804353; Sat, 16 Oct 2010 15:56:44 -0700 (PDT) Received: from maxim-laptop ([77.125.83.191]) by mx.google.com with ESMTPS id o12sm13939737bkb.21.2010.10.16.15.56.41 (version=SSLv3 cipher=RC4-MD5); Sat, 16 Oct 2010 15:56:43 -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 2/3] IR: ene_ir: add support for carrier reports Date: Sun, 17 Oct 2010 00:56:29 +0200 Message-Id: <1287269790-17605-3-git-send-email-maximlevitsky@gmail.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1287269790-17605-1-git-send-email-maximlevitsky@gmail.com> References: <1287269790-17605-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]); Sat, 16 Oct 2010 22:56:49 +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);