Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lirc_rpi: Added inverted transmitter support #228

Merged
merged 1 commit into from
Feb 24, 2013
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 11 additions & 6 deletions drivers/staging/media/lirc/lirc_rpi.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ static int debug;
static int sense = -1;
/* use softcarrier by default */
static int softcarrier = 1;
/* 0 = do not invert output, 1 = invert output */
static int invert = 0;

struct gpio_chip *gpiochip;
struct irq_chip *irqchip;
Expand Down Expand Up @@ -135,10 +137,10 @@ static long send_pulse_softcarrier(unsigned long length)
actual = 0; target = 0; flag = 0;
while (actual < length) {
if (flag) {
gpiochip->set(gpiochip, gpio_out_pin, 0);
gpiochip->set(gpiochip, gpio_out_pin, invert);
target += space_width;
} else {
gpiochip->set(gpiochip, gpio_out_pin, 1);
gpiochip->set(gpiochip, gpio_out_pin, !invert);
target += pulse_width;
}
d = (target - actual -
Expand All @@ -162,15 +164,15 @@ static long send_pulse(unsigned long length)
if (softcarrier) {
return send_pulse_softcarrier(length);
} else {
gpiochip->set(gpiochip, gpio_out_pin, 1);
gpiochip->set(gpiochip, gpio_out_pin, !invert);
safe_udelay(length);
return 0;
}
}

static void send_space(long length)
{
gpiochip->set(gpiochip, gpio_out_pin, 0);
gpiochip->set(gpiochip, gpio_out_pin, invert);
if (length <= 0)
return;
safe_udelay(length);
Expand Down Expand Up @@ -318,7 +320,7 @@ static int init_port(void)

gpiochip->direction_input(gpiochip, gpio_in_pin);
gpiochip->direction_output(gpiochip, gpio_out_pin, 1);
gpiochip->set(gpiochip, gpio_out_pin, 0);
gpiochip->set(gpiochip, gpio_out_pin, invert);

irq = gpiochip->to_irq(gpiochip, gpio_in_pin);
dprintk("to_irq %d\n", irq);
Expand Down Expand Up @@ -457,7 +459,7 @@ static ssize_t lirc_write(struct file *file, const char *buf,
else
delta = send_pulse(wbuf[i]);
}
gpiochip->set(gpiochip, gpio_out_pin, 0);
gpiochip->set(gpiochip, gpio_out_pin, invert);

spin_unlock_irqrestore(&lock, flags);
kfree(wbuf);
Expand Down Expand Up @@ -683,5 +685,8 @@ MODULE_PARM_DESC(sense, "Override autodetection of IR receiver circuit"
module_param(softcarrier, bool, S_IRUGO);
MODULE_PARM_DESC(softcarrier, "Software carrier (0 = off, 1 = on, default on)");

module_param(invert, bool, S_IRUGO);
MODULE_PARM_DESC(invert, "Invert output (0 = off, 1 = on, default off");

module_param(debug, bool, S_IRUGO | S_IWUSR);
MODULE_PARM_DESC(debug, "Enable debugging messages");