diff --git a/drivers/media/i2c/aw36518.c b/drivers/media/i2c/aw36518.c index 7d38470d3206..ddacd4fb9ddd 100644 --- a/drivers/media/i2c/aw36518.c +++ b/drivers/media/i2c/aw36518.c @@ -5,6 +5,7 @@ * Copyright (C) 2022 Fuzhou Rockchip Electronics Co., Ltd. * * V0.0X01.0X00 init version. + * V0.0X01.0X01 fix power off torch not off issue. */ #include @@ -21,7 +22,7 @@ #include #include -#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x0) +#define DRIVER_VERSION KERNEL_VERSION(0, 0x01, 0x01) #define AW36518_NAME "aw36518" #define AW36518_REG_ID 0x00 @@ -32,6 +33,8 @@ #define AW36518_REG_LED0_TORCH_CUR 0x05 #define AW36518_REG_LED1_FLASH_CUR 0x03 #define AW36518_REG_LED1_TORCH_CUR 0x05 +#define AW36518_HW_TORCH BIT(4) +#define AW36518_HW_STROBE BIT(5) #define AW36518_REG_FAULT 0x0A #define AW36518_REG_FL_SC 0x70 @@ -294,11 +297,25 @@ static int aw36518_set_mode(struct aw36518_flash *flash, ret = aw36518_i2c_write(flash, 0x01, 0x0C); ret |= aw36518_flash_brt(flash, LED0); } else if (mode == V4L2_FLASH_LED_MODE_TORCH) { - ret = aw36518_i2c_write(flash, 0x01, 0x08); + //ret = aw36518_i2c_write(flash, 0x01, 0x08); + /* hw torch/strobe io trigger torch */ + ret = aw36518_i2c_write(flash, 0x01, AW36518_HW_TORCH); ret |= aw36518_torch_brt(flash, LED0); ret |= aw36518_led_on(flash, true); + if (flash->torch_gpio) { + v4l2_dbg(1, debug, &flash->leds[id].sd, + "%s:set torch gpio high.\n", __func__); + gpiod_set_value_cansleep(flash->torch_gpio, 1); + } + } else { ret = aw36518_i2c_write(flash, 0x01, 0x00); + if (flash->torch_gpio) { + v4l2_dbg(1, debug, &flash->leds[id].sd, + "%s:set torch gpio low.\n", __func__); + gpiod_set_value_cansleep(flash->torch_gpio, 0); + } + } return ret; @@ -696,8 +713,9 @@ static int aw36518_of_init(struct i2c_client *client, flash->en_gpio = devm_gpiod_get(&client->dev, "enable", GPIOD_OUT_LOW); if (IS_ERR(flash->en_gpio)) { - dev_err(&client->dev, "get enable-gpio failed\n"); - goto err; + flash->en_gpio = NULL; + dev_warn(&client->dev, + "get enable-gpio failed, using assist light mode\n"); } flash->torch_gpio = devm_gpiod_get(&client->dev, @@ -718,7 +736,7 @@ static int aw36518_of_init(struct i2c_client *client, } flash->tx_gpio = devm_gpiod_get(&client->dev, "tx", GPIOD_OUT_LOW); - if (IS_ERR(flash->strobe_gpio)) { + if (IS_ERR(flash->tx_gpio)) { flash->tx_gpio = NULL; dev_warn(&client->dev, "get tx-gpio failed, using assist light mode\n"); @@ -790,6 +808,10 @@ static int aw36518_init_device(struct aw36518_flash *flash) /* tx input default low */ if (flash->tx_gpio) gpiod_direction_output(flash->tx_gpio, 0); + /* STROBE/Torch input default low */ + if (flash->torch_gpio) + gpiod_set_value_cansleep(flash->torch_gpio, 0); + return ret; }