Commit 1195a28d authored by Sean Young's avatar Sean Young Committed by Mauro Carvalho Chehab

media: gpio-ir-tx: allow transmission without carrier

Some IR protocols do not use a carrier.
Signed-off-by: default avatarSean Young <sean@mess.org>
Signed-off-by: default avatarMauro Carvalho Chehab <mchehab+huawei@kernel.org>
parent ea8912b7
...@@ -42,7 +42,7 @@ static int gpio_ir_tx_set_carrier(struct rc_dev *dev, u32 carrier) ...@@ -42,7 +42,7 @@ static int gpio_ir_tx_set_carrier(struct rc_dev *dev, u32 carrier)
{ {
struct gpio_ir *gpio_ir = dev->priv; struct gpio_ir *gpio_ir = dev->priv;
if (!carrier) if (carrier > 500000)
return -EINVAL; return -EINVAL;
gpio_ir->carrier = carrier; gpio_ir->carrier = carrier;
...@@ -50,10 +50,35 @@ static int gpio_ir_tx_set_carrier(struct rc_dev *dev, u32 carrier) ...@@ -50,10 +50,35 @@ static int gpio_ir_tx_set_carrier(struct rc_dev *dev, u32 carrier)
return 0; return 0;
} }
static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf, static void gpio_ir_tx_unmodulated(struct gpio_ir *gpio_ir, uint *txbuf,
unsigned int count) uint count)
{
unsigned long flags;
ktime_t edge;
s32 delta;
int i;
spin_lock_irqsave(&gpio_ir->lock, flags);
edge = ktime_get();
for (i = 0; i < count; i++) {
gpiod_set_value(gpio_ir->gpio, !(i % 2));
edge = ktime_add_us(edge, txbuf[i]);
delta = ktime_us_delta(edge, ktime_get());
if (delta > 0)
udelay(delta);
}
gpiod_set_value(gpio_ir->gpio, 0);
spin_unlock_irqrestore(&gpio_ir->lock, flags);
}
static void gpio_ir_tx_modulated(struct gpio_ir *gpio_ir, uint *txbuf,
uint count)
{ {
struct gpio_ir *gpio_ir = dev->priv;
unsigned long flags; unsigned long flags;
ktime_t edge; ktime_t edge;
/* /*
...@@ -105,6 +130,17 @@ static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf, ...@@ -105,6 +130,17 @@ static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
} }
spin_unlock_irqrestore(&gpio_ir->lock, flags); spin_unlock_irqrestore(&gpio_ir->lock, flags);
}
static int gpio_ir_tx(struct rc_dev *dev, unsigned int *txbuf,
unsigned int count)
{
struct gpio_ir *gpio_ir = dev->priv;
if (gpio_ir->carrier)
gpio_ir_tx_modulated(gpio_ir, txbuf, count);
else
gpio_ir_tx_unmodulated(gpio_ir, txbuf, count);
return count; return count;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment