Lines Matching refs:flash

75 static int lm3560_mode_ctrl(struct lm3560_flash *flash)  in lm3560_mode_ctrl()  argument
79 switch (flash->led_mode) { in lm3560_mode_ctrl()
81 rval = regmap_update_bits(flash->regmap, in lm3560_mode_ctrl()
85 rval = regmap_update_bits(flash->regmap, in lm3560_mode_ctrl()
89 rval = regmap_update_bits(flash->regmap, in lm3560_mode_ctrl()
97 static int lm3560_enable_ctrl(struct lm3560_flash *flash, in lm3560_enable_ctrl() argument
104 rval = regmap_update_bits(flash->regmap, in lm3560_enable_ctrl()
107 rval = regmap_update_bits(flash->regmap, in lm3560_enable_ctrl()
111 rval = regmap_update_bits(flash->regmap, in lm3560_enable_ctrl()
114 rval = regmap_update_bits(flash->regmap, in lm3560_enable_ctrl()
121 static int lm3560_torch_brt_ctrl(struct lm3560_flash *flash, in lm3560_torch_brt_ctrl() argument
128 return lm3560_enable_ctrl(flash, led_no, false); in lm3560_torch_brt_ctrl()
130 rval = lm3560_enable_ctrl(flash, led_no, true); in lm3560_torch_brt_ctrl()
134 rval = regmap_update_bits(flash->regmap, in lm3560_torch_brt_ctrl()
137 rval = regmap_update_bits(flash->regmap, in lm3560_torch_brt_ctrl()
144 static int lm3560_flash_brt_ctrl(struct lm3560_flash *flash, in lm3560_flash_brt_ctrl() argument
151 return lm3560_enable_ctrl(flash, led_no, false); in lm3560_flash_brt_ctrl()
153 rval = lm3560_enable_ctrl(flash, led_no, true); in lm3560_flash_brt_ctrl()
157 rval = regmap_update_bits(flash->regmap, in lm3560_flash_brt_ctrl()
160 rval = regmap_update_bits(flash->regmap, in lm3560_flash_brt_ctrl()
169 struct lm3560_flash *flash = to_lm3560_flash(ctrl, led_no); in lm3560_get_ctrl() local
172 mutex_lock(&flash->lock); in lm3560_get_ctrl()
177 rval = regmap_read(flash->regmap, REG_FLAG, &reg_val); in lm3560_get_ctrl()
190 mutex_unlock(&flash->lock); in lm3560_get_ctrl()
196 struct lm3560_flash *flash = to_lm3560_flash(ctrl, led_no); in lm3560_set_ctrl() local
200 mutex_lock(&flash->lock); in lm3560_set_ctrl()
204 flash->led_mode = ctrl->val; in lm3560_set_ctrl()
205 if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH) in lm3560_set_ctrl()
206 rval = lm3560_mode_ctrl(flash); in lm3560_set_ctrl()
210 rval = regmap_update_bits(flash->regmap, in lm3560_set_ctrl()
217 if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH) { in lm3560_set_ctrl()
221 flash->led_mode = V4L2_FLASH_LED_MODE_FLASH; in lm3560_set_ctrl()
222 rval = lm3560_mode_ctrl(flash); in lm3560_set_ctrl()
226 if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH) { in lm3560_set_ctrl()
230 flash->led_mode = V4L2_FLASH_LED_MODE_NONE; in lm3560_set_ctrl()
231 rval = lm3560_mode_ctrl(flash); in lm3560_set_ctrl()
236 rval = regmap_update_bits(flash->regmap, in lm3560_set_ctrl()
241 rval = lm3560_flash_brt_ctrl(flash, led_no, ctrl->val); in lm3560_set_ctrl()
245 rval = lm3560_torch_brt_ctrl(flash, led_no, ctrl->val); in lm3560_set_ctrl()
250 mutex_unlock(&flash->lock); in lm3560_set_ctrl()
285 static int lm3560_init_controls(struct lm3560_flash *flash, in lm3560_init_controls() argument
289 u32 max_flash_brt = flash->pdata->max_flash_brt[led_no]; in lm3560_init_controls()
290 u32 max_torch_brt = flash->pdata->max_torch_brt[led_no]; in lm3560_init_controls()
291 struct v4l2_ctrl_handler *hdl = &flash->ctrls_led[led_no]; in lm3560_init_controls()
300 flash->led_mode = V4L2_FLASH_LED_MODE_NONE; in lm3560_init_controls()
315 flash->pdata->max_flash_timeout, in lm3560_init_controls()
317 flash->pdata->max_flash_timeout); in lm3560_init_controls()
341 flash->subdev_led[led_no].ctrl_handler = hdl; in lm3560_init_controls()
356 static int lm3560_subdev_init(struct lm3560_flash *flash, in lm3560_subdev_init() argument
359 struct i2c_client *client = to_i2c_client(flash->dev); in lm3560_subdev_init()
362 v4l2_i2c_subdev_init(&flash->subdev_led[led_no], client, &lm3560_ops); in lm3560_subdev_init()
363 flash->subdev_led[led_no].flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in lm3560_subdev_init()
364 strcpy(flash->subdev_led[led_no].name, led_name); in lm3560_subdev_init()
365 rval = lm3560_init_controls(flash, led_no); in lm3560_subdev_init()
368 rval = media_entity_init(&flash->subdev_led[led_no].entity, 0, NULL, 0); in lm3560_subdev_init()
371 flash->subdev_led[led_no].entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; in lm3560_subdev_init()
376 v4l2_ctrl_handler_free(&flash->ctrls_led[led_no]); in lm3560_subdev_init()
380 static int lm3560_init_device(struct lm3560_flash *flash) in lm3560_init_device() argument
386 rval = regmap_update_bits(flash->regmap, in lm3560_init_device()
387 REG_FLASH_TOUT, 0x60, flash->pdata->peak); in lm3560_init_device()
391 flash->led_mode = V4L2_FLASH_LED_MODE_NONE; in lm3560_init_device()
392 rval = lm3560_mode_ctrl(flash); in lm3560_init_device()
396 rval = regmap_read(flash->regmap, REG_FLAG, &reg_val); in lm3560_init_device()
403 struct lm3560_flash *flash; in lm3560_probe() local
407 flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); in lm3560_probe()
408 if (flash == NULL) in lm3560_probe()
411 flash->regmap = devm_regmap_init_i2c(client, &lm3560_regmap); in lm3560_probe()
412 if (IS_ERR(flash->regmap)) { in lm3560_probe()
413 rval = PTR_ERR(flash->regmap); in lm3560_probe()
431 flash->pdata = pdata; in lm3560_probe()
432 flash->dev = &client->dev; in lm3560_probe()
433 mutex_init(&flash->lock); in lm3560_probe()
435 rval = lm3560_subdev_init(flash, LM3560_LED0, "lm3560-led0"); in lm3560_probe()
439 rval = lm3560_subdev_init(flash, LM3560_LED1, "lm3560-led1"); in lm3560_probe()
443 rval = lm3560_init_device(flash); in lm3560_probe()
447 i2c_set_clientdata(client, flash); in lm3560_probe()
454 struct lm3560_flash *flash = i2c_get_clientdata(client); in lm3560_remove() local
458 v4l2_device_unregister_subdev(&flash->subdev_led[i]); in lm3560_remove()
459 v4l2_ctrl_handler_free(&flash->ctrls_led[i]); in lm3560_remove()
460 media_entity_cleanup(&flash->subdev_led[i].entity); in lm3560_remove()