ODROID-COMMON: media: rc: Add new IR receiver to specify gpio number for IR sensor

This driver helps to register the device of GPIO based IR receiver, "gpio-ir-recv"
with the gpio number and pulse trigger when driver is loading. For example,

	# modprobe gpio-ir-recv
	# modprobe gpioplug-ir-recv gpio_nr=473 active_low=1

Change-Id: I377be5e1d1926d0e777b7e18feef7f0d4bc45f40
Signed-off-by: Joy Cho <joy.cho@hardkernel.com>
Signed-off-by: Dongjin Kim <tobetter@gmail.com>
This commit is contained in:
Joy Cho
2018-03-15 12:05:54 +09:00
committed by Dongjin Kim
parent 673c2ae93d
commit a5e86984f7
3 changed files with 101 additions and 0 deletions

View File

@@ -367,6 +367,16 @@ config IR_GPIO_CIR
To compile this driver as a module, choose M here: the module will
be called gpio-ir-recv.
config IR_GPIOPLUG_CIR
tristate "GPIOPLUG IR remote control"
depends on RC_CORE
select IR_GPIO_CIR
---help---
Say Y if you want to use GPIOPLUG based IR Receiver.
To compile this driver as a module, choose M here: the module will
be called gpio-ir-recv.
config RC_ST
tristate "ST remote control receiver"
depends on RC_CORE

View File

@@ -32,6 +32,7 @@ obj-$(CONFIG_IR_WINBOND_CIR) += winbond-cir.o
obj-$(CONFIG_RC_LOOPBACK) += rc-loopback.o
obj-$(CONFIG_IR_GPIO_CIR) += gpio-ir-recv.o
obj-$(CONFIG_IR_IGORPLUGUSB) += igorplugusb.o
obj-$(CONFIG_IR_GPIOPLUG_CIR) += gpioplug-ir-recv.o
obj-$(CONFIG_IR_IGUANA) += iguanair.o
obj-$(CONFIG_IR_TTUSBIR) += ttusbir.o
obj-$(CONFIG_RC_ST) += st_rc.o

View File

@@ -0,0 +1,90 @@
/*
* Pluggable GPIO IR receiver
*
* Copyright (c) 2015-2019 Dongjin Kim (tobetter@gmail.com)
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*/
#include <linux/kernel.h>
#include <linux/init.h>
#include <linux/module.h>
#include <linux/gpio.h>
#include <linux/slab.h>
#include <linux/platform_device.h>
#include <linux/platform_data/media/gpio-ir-recv.h>
static unsigned gpio_nr = -1;
module_param(gpio_nr, uint, 0);
MODULE_PARM_DESC(gpio_nr, "GPIO number to receive IR pulse");
static bool active_low = 1;
module_param(active_low, bool, 0);
MODULE_PARM_DESC(active_low,
"IR pulse trigger level, (1=low active, 0=high active");
static struct platform_device *pdev;
static struct gpio_ir_recv_platform_data *pdata;
static int __init gpio_init(void)
{
int rc = -ENOMEM;
if (gpio_nr == -1) {
pr_err("gpioplug-ir-recv: missing module parameter: 'gpio_nr'\n");
return -EINVAL;
}
pdev = platform_device_alloc(GPIO_IR_DRIVER_NAME, -1);
if (!pdev)
return rc;
pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
if (!pdata)
goto err_free_platform_data;
pdev->dev.platform_data = pdata;
pdata->gpio_nr = gpio_nr;
pdata->active_low = active_low;
pdata->allowed_protos = 0;
pdata->map_name = NULL;
rc = platform_device_add(pdev);
if (rc < 0)
goto err_free_device;
dev_info(&pdev->dev,
"IR driver is initialized (gpio_nr=%d, pulse level=%s)\n",
pdata->gpio_nr, pdata->active_low ? "low" : "high");
return request_module("gpio-ir-recv");
err_free_platform_data:
kfree(pdata);
err_free_device:
platform_device_put(pdev);
return rc;
}
static void __exit gpio_exit(void)
{
dev_info(&pdev->dev, "gpioplug-ir-recv: IR driver is removed\n");
platform_device_unregister(pdev);
}
MODULE_DESCRIPTION("GPIO IR Receiver driver");
MODULE_LICENSE("GPL v2");
module_init(gpio_init);
module_exit(gpio_exit);