From: "David Härdeman" <david@hardeman.nu>
To: linux-media@vger.kernel.org
Cc: m.chehab@samsung.com
Subject: [PATCH 28/49] rc-core: add an ioctl for setting IR TX settings
Date: Fri, 04 Apr 2014 01:33:37 +0200 [thread overview]
Message-ID: <20140403233337.27099.52201.stgit@zeus.muc.hardeman.nu> (raw)
In-Reply-To: <20140403232420.27099.94872.stgit@zeus.muc.hardeman.nu>
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 <david@hardeman.nu>
---
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(-)
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)
next prev parent reply other threads:[~2014-04-03 23:33 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-04-03 23:31 [PATCH 00/49] rc-core: my current patch queue David Härdeman
2014-04-03 23:31 ` [PATCH 01/49] bt8xx: fixup RC5 decoding David Härdeman
2014-04-03 23:31 ` [PATCH 02/49] rc-core: improve ir-kbd-i2c get_key functions David Härdeman
2014-04-03 23:31 ` [PATCH 03/49] rc-core: document the protocol type David Härdeman
2014-04-03 23:31 ` [PATCH 04/49] rc-core: do not change 32bit NEC scancode format for now David Härdeman
2014-04-04 13:18 ` James Hogan
2014-04-03 23:31 ` [PATCH 05/49] rc-core: split dev->s_filter David Härdeman
2014-04-04 13:08 ` James Hogan
2014-04-03 23:31 ` [PATCH 06/49] rc-core: remove generic scancode filter David Härdeman
2014-04-04 13:30 ` James Hogan
2014-04-03 23:31 ` [PATCH 07/49] dib0700: NEC scancode cleanup David Härdeman
2014-04-03 23:31 ` [PATCH 08/49] lmedm04: " David Härdeman
2014-04-03 23:32 ` [PATCH 09/49] saa7134: NEC scancode fix David Härdeman
2014-04-03 23:32 ` [PATCH 10/49] [RFC] rc-core: use the full 32 bits for NEC scancodes David Härdeman
2014-04-03 23:32 ` [PATCH 11/49] [RFC] rc-core: don't throw away protocol information David Härdeman
2014-04-03 23:32 ` [PATCH 12/49] rc-core: simplify sysfs code David Härdeman
2014-04-03 23:32 ` [PATCH 13/49] rc-core: remove protocol arrays David Härdeman
2014-04-03 23:32 ` [PATCH 14/49] rc-core: rename dev->scanmask to dev->scancode_mask David Härdeman
2014-04-03 23:32 ` [PATCH 15/49] rc-core: merge rc5 and streamzap decoders David Härdeman
2014-04-03 23:32 ` [PATCH 16/49] rc-core: use an IDA rather than a bitmap David Härdeman
2014-07-25 22:39 ` Mauro Carvalho Chehab
2014-04-03 23:32 ` [PATCH 17/49] rc-core: add chardev David Härdeman
2014-04-03 23:32 ` [PATCH 18/49] rc-core: allow chardev to be read David Härdeman
2014-04-03 23:32 ` [PATCH 19/49] rc-core: use a kfifo for TX data David Härdeman
2014-04-03 23:32 ` [PATCH 20/49] rc-core: allow chardev to be written David Härdeman
2014-04-03 23:33 ` [PATCH 21/49] rc-core: add ioctl support to the rc chardev David Härdeman
2014-04-03 23:33 ` [PATCH 22/49] rc-core: add an ioctl for getting IR RX settings David Härdeman
2014-04-03 23:33 ` [PATCH 23/49] rc-loopback: add RCIOCGIRRX ioctl support David Härdeman
2014-04-03 23:33 ` [PATCH 24/49] rc-core: add an ioctl for setting IR RX settings David Härdeman
2014-04-03 23:33 ` [PATCH 25/49] rc-loopback: add RCIOCSIRRX ioctl support David Härdeman
2014-04-03 23:33 ` [PATCH 26/49] rc-core: add an ioctl for getting IR TX settings David Härdeman
2014-04-03 23:33 ` [PATCH 27/49] rc-loopback: add RCIOCGIRTX ioctl support David Härdeman
2014-04-03 23:33 ` David Härdeman [this message]
2014-04-03 23:33 ` [PATCH 29/49] rc-loopback: add RCIOCSIRTX " David Härdeman
2014-04-03 23:33 ` [PATCH 30/49] rc-core: leave the internals of rc_dev alone David Härdeman
2014-07-24 1:50 ` Mauro Carvalho Chehab
2014-04-03 23:33 ` [PATCH 31/49] rc-core: split rc-main.c into rc-main.c and rc-keytable.c David Härdeman
2014-07-25 22:44 ` Mauro Carvalho Chehab
2014-04-03 23:33 ` [PATCH 32/49] rc-core: prepare for multiple keytables David Härdeman
2014-07-25 22:52 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 33/49] rc-core: make the keytable of rc_dev an array David Härdeman
2014-04-03 23:34 ` [PATCH 34/49] rc-core: add ioctls for adding/removing keytables from userspace David Härdeman
2014-04-03 23:34 ` [PATCH 35/49] rc-core: remove redundant spinlock David Härdeman
2014-04-03 23:34 ` [PATCH 36/49] rc-core: make keytable RCU-friendly David Härdeman
2014-04-03 23:34 ` [PATCH 37/49] rc-core: allow empty keymaps David Härdeman
2014-07-25 22:58 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 38/49] rc-core: rename ir-raw.c David Härdeman
2014-04-03 23:34 ` [PATCH 39/49] rc-core: make IR raw handling a separate module David Härdeman
2014-07-25 23:04 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 40/49] rc-ir-raw: simplify locking David Härdeman
2014-07-25 23:08 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 41/49] rc-core: rename mutex David Härdeman
2014-04-10 21:28 ` James Hogan
2014-07-25 23:12 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 42/49] rc-ir-raw: atomic reads of protocols David Härdeman
2014-07-25 23:13 ` Mauro Carvalho Chehab
2014-04-03 23:34 ` [PATCH 43/49] rc-core: fix various sparse warnings David Härdeman
2014-04-03 23:34 ` [PATCH 44/49] rc-core: don't report scancodes via input devices David Härdeman
2014-07-25 23:16 ` Mauro Carvalho Chehab
2014-04-03 23:35 ` [PATCH 45/49] rc-ir-raw: add various rc_events David Härdeman
2014-07-25 23:16 ` Mauro Carvalho Chehab
2014-04-03 23:35 ` [PATCH 46/49] rc-core: use struct rc_event for all rc communication David Härdeman
2014-07-25 23:19 ` Mauro Carvalho Chehab
2014-04-03 23:35 ` [PATCH 47/49] rc-core: add keytable events David Härdeman
2014-04-03 23:35 ` [PATCH 48/49] rc-core: move remaining keytable functions David Härdeman
2014-04-03 23:35 ` [PATCH 49/49] rc-core: make rc-core.h userspace friendly David Härdeman
2014-04-04 2:05 ` [PATCH 00/49] rc-core: my current patch queue Mauro Carvalho Chehab
2014-06-26 20:07 ` David Härdeman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20140403233337.27099.52201.stgit@zeus.muc.hardeman.nu \
--to=david@hardeman.nu \
--cc=linux-media@vger.kernel.org \
--cc=m.chehab@samsung.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox