Android 10 解决在呼吸灯变暗的情况下修改呼吸灯时间生效慢

— a/kernel-4.14/drivers/leds/leds-wd3153d.c
+++ b/kernel-4.14/drivers/leds/leds-wd3153d.c
@@ -93,7 +93,7 @@
#define WD_REG_LED_BRIGHTNESS_BASE 0x34
#define WD_REG_TIMESET0_BASE 0x37
#define WD_REG_TIMESET1_BASE 0x38

+#define WD_REG_TIMESET2_BASE 0x39
/* register bits */
#define WD3153_CHIPID 0x33
#define WD_LED_MOUDLE_ENABLE_MASK 0x01
@@ -412,12 +412,17 @@ static ssize_t wd3153_led_time_store(struct device *dev,
struct wd3153_led *led =
container_of(led_cdev, struct wd3153_led, cdev);
int rc, rise_time_ms, hold_time_ms, fall_time_ms, off_time_ms;

  •   u8 val;
      rc = sscanf(buf, "%d %d %d %d",
                      &rise_time_ms, &hold_time_ms,
                      &fall_time_ms, &off_time_ms);
    
      mutex_lock(&led->pdata->led->lock);
    
  •   wd3153_read(led, WD_REG_GLOBAL_CONTROL, &val);
    
  •   // printk("zdc WD_REG_GLOBAL_CONTROL val 0x%x", val);
    
  •   val &= 0xFE;
    
  •   // printk("zdc WD_REG_GLOBAL_CONTROL val 0x%x", val);
    
  •   wd3153_write(led, WD_REG_GLOBAL_CONTROL, val);
      led->pdata->rise_time_ms = (rise_time_ms > MAX_RISE_TIME_MS) ?
                              MAX_RISE_TIME_MS : rise_time_ms;
      led->pdata->hold_time_ms = (hold_time_ms > MAX_HOLD_TIME_MS) ?
    

@@ -431,12 +436,59 @@ static ssize_t wd3153_led_time_store(struct device *dev,
return len;
}

+static ssize_t wd3153_reg_show(struct device *dev,

  •                           struct device_attribute *attr, char *buf)
    

+{

  •   struct led_classdev *led_cdev = dev_get_drvdata(dev);
    
  •   struct wd3153_led *led =
    
  •                   container_of(led_cdev, struct wd3153_led, cdev);
    
  •   u8 val;         
    
  •   int size, i;
    
  •   char *buf0 = buf;
    
  •   wd3153_read(led, WD_REG_RESET, &val);
    
  •   size = snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", WD_REG_RESET, val);
    
  •   buf += size;
    
  •   wd3153_read(led, WD_REG_GLOBAL_CONTROL, &val);
    
  •   size =snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", WD_REG_GLOBAL_CONTROL, val);
    
  •   buf += size;
    
  •   wd3153_read(led, WD_REG_LED_STATUS, &val);
    
  •   size = snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", WD_REG_LED_STATUS, val);
    
  •   buf += size;
    
  •   wd3153_read(led, 0x03, &val);
    
  •   size = snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", 0x03, val);
    
  •   buf += size;
    
  •   wd3153_read(led, WD_REG_LED_ENABLE, &val);
    
  •   size = snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", WD_REG_LED_ENABLE, val);
    
  •   buf += size;
    
  •   for (i = 0;i < 3;i++){
    
  •           wd3153_read(led, (WD_REG_LED_CONFIG_BASE + i), &val);
    
  •           size = snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", (WD_REG_LED_CONFIG_BASE + i), val);
    
  •           buf += size;
    
  •           wd3153_read(led, (WD_REG_LED_BRIGHTNESS_BASE + i), &val);
    
  •           size = snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", (WD_REG_LED_BRIGHTNESS_BASE + i), val);
    
  •           buf += size;
    
  •           wd3153_read(led, (WD_REG_TIMESET0_BASE + i * 3), &val);
    
  •           size = snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", (WD_REG_TIMESET0_BASE + i * 3), val);
    
  •           buf += size;
    
  •           wd3153_read(led, (WD_REG_TIMESET1_BASE + i * 3), &val);
    
  •           size = snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", (WD_REG_TIMESET1_BASE + i * 3), val);
    
  •           buf += size;
    
  •           wd3153_read(led, (WD_REG_TIMESET2_BASE + i * 3), &val);
    
  •           size = snprintf(buf, PAGE_SIZE, "reg  0x%x val 0x%x\n", (WD_REG_TIMESET2_BASE + i * 3), val);
    
  •           buf += size;
    
  •   }
    
  •   return buf - buf0;
    

+}
+
static DEVICE_ATTR(blink, 0664, NULL, wd3153_store_blink);
static DEVICE_ATTR(led_time, 0664, wd3153_led_time_show, wd3153_led_time_store);
+static DEVICE_ATTR(reg, 0664, wd3153_reg_show, NULL);

static struct attribute *wd3153_led_attributes[] = {
&dev_attr_blink.attr,
&dev_attr_led_time.attr,

  •   &dev_attr_reg.attr,
      NULL,
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值