http://blog.csdn.net/wangjianzhongfj/article/details/42764437
http://www.docin.com/p-970537368.html
rk3128原生安卓代码里。按红外遥控器的时候,灯是不闪的。在这里,我把如何进行灯闪的问题解决一下。哈!
在kernelsrcarcharmootdts
k3128-box-rk88.dts增加gpio控制led的节点
rockchip_leds_gpio {
compatible = "rockchip-leds-gpio";
led-gpios = <&gpio0 GPIO_D2 GPIO_ACTIVE_LOW>, <&gpio0 GPIO_B0 GPIO_ACTIVE_LOW>;
status = "okay";
};
gpio_poweroff {
compatible = "gpio-poweroff";
gpios = <&gpio1 GPIO_A2 GPIO_ACTIVE_LOW>;
};
在kernelsrcarcharmconfigs
ockchip_defconfig里,配置leds。
CONFIG_LEDS_TRIGGERS=y
CONFIG_LEDS_TRIGGER_BACKLIGHT=y
CONFIG_LEDS_TRIGGER_DEFAULT_ON=y
然后增加代码目录路径
kernelsrcdriversleds
ockchip-leds-gpio.c
[javascript] view
plain copy
-
-
-
-
-
-
-
-
-
-
-
-
-
#include
-
#include
-
#include
-
#include
-
#include
-
#include
-
#include
-
#include
-
#include
-
#include
-
#include
-
#include
-
#include
-
-
#define TAG "ROCKCHIP_LEDS_GPIO"
-
#if 0
-
#define D(fmt, arg...) printk("D>>> %s->%s(%d): " fmt, TAG, __FUNCTION__, __LINE__, ##arg)
-
#else
-
#define D(fmt, arg...)
-
#endif
-
#define E(fmt, arg...) printk("E>>> %s->%s(%d): " fmt, TAG, __FUNCTION__, __LINE__, ##arg)
-
#define I(fmt, arg...) printk("I>>> %s->%s(%d): " fmt, TAG, __FUNCTION__, __LINE__, ##arg)
-
-
#define GPIO_LOW 0
-
#define GPIO_HIGH 1
-
-
#define LED_ON 0
-
#define LED_OFF 1
-
-
struct rk_gpio_leds_ctl_io {
-
unsigned int power_green;
-
unsigned int power_red;
-
-
unsigned int ir_red;
-
};
-
-
struct rk_gpio_leds_priv {
-
struct rk_gpio_leds_ctl_io leds;
-
struct timer_list led_timer;
-
unsigned int ir_red_status;
-
unsigned int ir_red_first_resume;
-
unsigned int suspend_state;
-
};
-
-
struct rk_gpio_leds_priv *g_privdata = NULL;
-
-
static ssize_t led_store(struct device *dev, struct device_attribute *attr, const char *cmd, size_t count)
-
{
-
struct platform_device *pdev = to_platform_device(dev);
-
struct rk_gpio_leds_priv *priv = platform_get_drvdata(pdev);
-
-
-
-
if (true == priv->suspend_state)
-
{
-
return count;
-
}
-
-
if(0 == strcmp("IR_LED_ON", cmd))
-
{
-
gpio_set_value(priv->leds.ir_red, GPIO_HIGH);
-
}
-
else if(0 == strcmp("IR_LED_OFF", cmd))
-
{
-
gpio_set_value(priv->leds.ir_red, GPIO_LOW);
-
}
-
-
return count;
-
}
-
static ssize_t led_show(struct device *dev, struct device_attribute *attr, char *buf)
-
{
-
return 0;
-
}
-
static DEVICE_ATTR(led_ctl, 0777, led_show, led_store);
-
-
-
static void rk_gpio_led_early_suspend(void)
-
{
-
struct rk_gpio_leds_priv *priv = g_privdata;
-
-
if (priv)
-
{
-
-
gpio_set_value(priv->leds.power_green, GPIO_LOW);
-
gpio_set_value(priv->leds.power_red, GPIO_HIGH);
-
}
-
-
return;
-
}
-
-
static void rk_gpio_led_early_resume(void)
-
{
-
struct rk_gpio_leds_priv *priv = g_privdata;
-