From patchwork Thu Apr 3 23:33:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?b?RGF2aWQgSMODwqRyZGVtYW4=?= X-Patchwork-Id: 3934931 Return-Path: X-Original-To: patchwork-linux-media@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 2F40FBFF02 for ; Thu, 3 Apr 2014 23:33:44 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 38B2E20306 for ; Thu, 3 Apr 2014 23:33:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 304C320303 for ; Thu, 3 Apr 2014 23:33:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754032AbaDCXdk (ORCPT ); Thu, 3 Apr 2014 19:33:40 -0400 Received: from hardeman.nu ([95.142.160.32]:40319 "EHLO hardeman.nu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754019AbaDCXdj (ORCPT ); Thu, 3 Apr 2014 19:33:39 -0400 Received: from zeus.hardeman.nu (unknown [IPv6:2001:a60:16f7:7000:b8ab:ce09:22ee:d164]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by vader.hardeman.nu (Postfix) with ESMTPSA id F190E273; Fri, 4 Apr 2014 01:33:37 +0200 (CEST) Received: by zeus.hardeman.nu (Postfix, from userid 1000) id 8E74FC600FA; Fri, 4 Apr 2014 01:33:37 +0200 (CEST) Subject: [PATCH 28/49] rc-core: add an ioctl for setting IR TX settings From: David =?utf-8?b?SMOkcmRlbWFu?= To: linux-media@vger.kernel.org Cc: m.chehab@samsung.com Date: Fri, 04 Apr 2014 01:33:37 +0200 Message-ID: <20140403233337.27099.52201.stgit@zeus.muc.hardeman.nu> In-Reply-To: <20140403232420.27099.94872.stgit@zeus.muc.hardeman.nu> References: <20140403232420.27099.94872.stgit@zeus.muc.hardeman.nu> User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org X-Spam-Status: No, score=-7.5 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This adds a complementary ioctl to allow IR TX settings to be changed. Much like the RCIOCSIRRX functionality, userspace is expected to call RCIOCGIRTX, change values and then call RCIOCSIRTX and finally inspect the struct rc_ir_tx to see the results. Also, LIRC is changed to use the new functionality as an alternative to the old one and another bunch of operations in struct rc_dev are now deprecated. Signed-off-by: David Härdeman --- drivers/media/rc/ir-lirc-codec.c | 42 +++++++++++++++++++++++++++++--------- drivers/media/rc/rc-main.c | 13 ++++++++++++ include/media/rc-core.h | 13 ++++++++---- 3 files changed, 54 insertions(+), 14 deletions(-) -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/rc/ir-lirc-codec.c b/drivers/media/rc/ir-lirc-codec.c index 6e31c83..7b56f21 100644 --- a/drivers/media/rc/ir-lirc-codec.c +++ b/drivers/media/rc/ir-lirc-codec.c @@ -189,6 +189,7 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, int ret = 0; __u32 val = 0, tmp; struct rc_ir_rx rx; + struct rc_ir_tx tx; lirc = lirc_get_pdata(filep); if (!lirc) @@ -218,25 +219,46 @@ static long ir_lirc_ioctl(struct file *filep, unsigned int cmd, /* TX settings */ case LIRC_SET_TRANSMITTER_MASK: - if (!dev->s_tx_mask) - return -ENOSYS; + if (dev->s_tx_mask) + return dev->s_tx_mask(dev, val); - return dev->s_tx_mask(dev, val); + if (dev->get_ir_tx && dev->set_ir_tx) { + memset(&tx, 0, sizeof(tx)); + dev->get_ir_tx(dev, &tx); + tx.tx_enabled = val; + return dev->set_ir_tx(dev, &tx); + } + + return -ENOSYS; case LIRC_SET_SEND_CARRIER: - if (!dev->s_tx_carrier) - return -ENOSYS; + if (dev->s_tx_carrier) + return dev->s_tx_carrier(dev, val); - return dev->s_tx_carrier(dev, val); + if (dev->get_ir_tx && dev->set_ir_tx) { + memset(&tx, 0, sizeof(tx)); + dev->get_ir_tx(dev, &tx); + tx.freq = val; + return dev->set_ir_tx(dev, &tx); + } - case LIRC_SET_SEND_DUTY_CYCLE: - if (!dev->s_tx_duty_cycle) - return -ENOSYS; + return -ENOSYS; + case LIRC_SET_SEND_DUTY_CYCLE: if (val <= 0 || val >= 100) return -EINVAL; - return dev->s_tx_duty_cycle(dev, val); + if (dev->s_tx_duty_cycle) + return dev->s_tx_duty_cycle(dev, val); + + if (dev->get_ir_tx && dev->set_ir_tx) { + memset(&tx, 0, sizeof(tx)); + dev->get_ir_tx(dev, &tx); + tx.duty = val; + return dev->set_ir_tx(dev, &tx); + } + + return -ENOSYS; /* RX settings */ case LIRC_SET_REC_CARRIER: diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c index 611d24d..cc2f713 100644 --- a/drivers/media/rc/rc-main.c +++ b/drivers/media/rc/rc-main.c @@ -1714,6 +1714,19 @@ static long rc_do_ioctl(struct rc_dev *dev, unsigned int cmd, unsigned long arg) return 0; + case RCIOCSIRTX: + if (!dev->set_ir_tx) + return -ENOSYS; + + if (copy_from_user(&tx, p, sizeof(tx))) + return -EFAULT; + + error = dev->set_ir_tx(dev, &tx); + if (error) + return error; + + /* Fall through */ + case RCIOCGIRTX: memset(&tx, 0, sizeof(tx)); diff --git a/include/media/rc-core.h b/include/media/rc-core.h index 566ae7d..eacb735 100644 --- a/include/media/rc-core.h +++ b/include/media/rc-core.h @@ -116,8 +116,11 @@ struct rc_ir_rx { /* get ir tx parameters */ #define RCIOCGIRTX _IOC(_IOC_READ, RC_IOC_MAGIC, 0x05, sizeof(struct rc_ir_tx)) +/* set ir tx parameters */ +#define RCIOCSIRTX _IOC(_IOC_WRITE, RC_IOC_MAGIC, 0x05, sizeof(struct rc_ir_tx)) + /** - * struct rc_ir_tx - used to get all IR TX parameters in one go + * struct rc_ir_tx - used to get/set all IR TX parameters in one go * @flags: device specific flags * @tx_supported: bitmask of supported transmitters * @tx_enabled: bitmask of enabled transmitters @@ -293,9 +296,9 @@ enum rc_filter_type { * is opened. * @close: callback to allow drivers to disable polling/irq when IR input device * is opened. - * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs) - * @s_tx_carrier: set transmit carrier frequency - * @s_tx_duty_cycle: set transmit duty cycle (0% - 100%) + * @s_tx_mask: set transmitter mask (for devices with multiple tx outputs, deprecated) + * @s_tx_carrier: set transmit carrier frequency (deprecated) + * @s_tx_duty_cycle: set transmit duty cycle (0% - 100%, deprecated) * @s_rx_carrier: inform driver about expected carrier (deprecated) * @tx_ir: transmit IR * @s_idle: enable/disable hardware idle mode, upon which, @@ -307,6 +310,7 @@ enum rc_filter_type { * @get_ir_rx: allow driver to provide rx settings * @set_ir_rx: allow driver to change rx settings * @get_ir_tx: allow driver to provide tx settings + * @set_ir_tx: allow driver to change tx settings */ struct rc_dev { struct device dev; @@ -371,6 +375,7 @@ struct rc_dev { void (*get_ir_rx)(struct rc_dev *dev, struct rc_ir_rx *rx); int (*set_ir_rx)(struct rc_dev *dev, struct rc_ir_rx *rx); void (*get_ir_tx)(struct rc_dev *dev, struct rc_ir_tx *tx); + int (*set_ir_tx)(struct rc_dev *dev, struct rc_ir_tx *tx); }; #define to_rc_dev(d) container_of(d, struct rc_dev, dev)