Lines Matching full:flash

38 static int adp1653_update_hw(struct adp1653_flash *flash)  in adp1653_update_hw()  argument
40 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_update_hw()
46 flash->indicator_intensity->val) in adp1653_update_hw()
49 switch (flash->led_mode->val) { in adp1653_update_hw()
53 /* Flash mode, light on with strobe, duration from timer */ in adp1653_update_hw()
55 config |= TIMEOUT_US_TO_CODE(flash->flash_timeout->val) in adp1653_update_hw()
61 flash->torch_intensity->val) in adp1653_update_hw()
77 static int adp1653_get_fault(struct adp1653_flash *flash) in adp1653_get_fault() argument
79 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_get_fault()
87 flash->fault |= fault; in adp1653_get_fault()
89 if (!flash->fault) in adp1653_get_fault()
97 flash->led_mode->val = V4L2_FLASH_LED_MODE_NONE; in adp1653_get_fault()
99 rval = adp1653_update_hw(flash); in adp1653_get_fault()
103 return flash->fault; in adp1653_get_fault()
106 static int adp1653_strobe(struct adp1653_flash *flash, int enable) in adp1653_strobe() argument
108 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_strobe()
110 flash->indicator_intensity->val) in adp1653_strobe()
114 if (flash->led_mode->val != V4L2_FLASH_LED_MODE_FLASH) in adp1653_strobe()
122 flash->flash_intensity->val) in adp1653_strobe()
142 struct adp1653_flash *flash = in adp1653_get_ctrl() local
146 rval = adp1653_get_fault(flash); in adp1653_get_ctrl()
152 if (flash->fault & ADP1653_REG_FAULT_FLT_SCP) in adp1653_get_ctrl()
154 if (flash->fault & ADP1653_REG_FAULT_FLT_OT) in adp1653_get_ctrl()
156 if (flash->fault & ADP1653_REG_FAULT_FLT_TMR) in adp1653_get_ctrl()
158 if (flash->fault & ADP1653_REG_FAULT_FLT_OV) in adp1653_get_ctrl()
161 flash->fault = 0; in adp1653_get_ctrl()
168 struct adp1653_flash *flash = in adp1653_set_ctrl() local
172 rval = adp1653_get_fault(flash); in adp1653_set_ctrl()
185 return adp1653_strobe(flash, 1); in adp1653_set_ctrl()
187 return adp1653_strobe(flash, 0); in adp1653_set_ctrl()
190 return adp1653_update_hw(flash); in adp1653_set_ctrl()
198 static int adp1653_init_controls(struct adp1653_flash *flash) in adp1653_init_controls() argument
202 v4l2_ctrl_handler_init(&flash->ctrls, 9); in adp1653_init_controls()
204 flash->led_mode = in adp1653_init_controls()
205 v4l2_ctrl_new_std_menu(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
208 v4l2_ctrl_new_std_menu(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
211 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
213 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
215 flash->flash_timeout = in adp1653_init_controls()
216 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
218 flash->platform_data->max_flash_timeout, in adp1653_init_controls()
220 flash->platform_data->max_flash_timeout); in adp1653_init_controls()
221 flash->flash_intensity = in adp1653_init_controls()
222 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
225 flash->platform_data->max_flash_intensity, in adp1653_init_controls()
226 1, flash->platform_data->max_flash_intensity); in adp1653_init_controls()
227 flash->torch_intensity = in adp1653_init_controls()
228 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
231 flash->platform_data->max_torch_intensity, in adp1653_init_controls()
233 flash->platform_data->max_torch_intensity); in adp1653_init_controls()
234 flash->indicator_intensity = in adp1653_init_controls()
235 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
238 flash->platform_data->max_indicator_intensity, in adp1653_init_controls()
241 fault = v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
247 if (flash->ctrls.error) in adp1653_init_controls()
248 return flash->ctrls.error; in adp1653_init_controls()
252 flash->subdev.ctrl_handler = &flash->ctrls; in adp1653_init_controls()
261 adp1653_init_device(struct adp1653_flash *flash) in adp1653_init_device() argument
263 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_init_device()
273 mutex_lock(flash->ctrls.lock); in adp1653_init_device()
275 flash->fault = 0; in adp1653_init_device()
276 rval = adp1653_get_fault(flash); in adp1653_init_device()
277 mutex_unlock(flash->ctrls.lock); in adp1653_init_device()
283 mutex_lock(flash->ctrls.lock); in adp1653_init_device()
284 rval = adp1653_update_hw(flash); in adp1653_init_device()
285 mutex_unlock(flash->ctrls.lock); in adp1653_init_device()
296 __adp1653_set_power(struct adp1653_flash *flash, int on) in __adp1653_set_power() argument
300 if (flash->platform_data->power) { in __adp1653_set_power()
301 ret = flash->platform_data->power(&flash->subdev, on); in __adp1653_set_power()
305 gpiod_set_value(flash->platform_data->enable_gpio, on); in __adp1653_set_power()
314 ret = adp1653_init_device(flash); in __adp1653_set_power()
318 if (flash->platform_data->power) in __adp1653_set_power()
319 flash->platform_data->power(&flash->subdev, 0); in __adp1653_set_power()
321 gpiod_set_value(flash->platform_data->enable_gpio, 0); in __adp1653_set_power()
329 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_set_power() local
332 mutex_lock(&flash->power_lock); in adp1653_set_power()
337 if (flash->power_count == !on) { in adp1653_set_power()
338 ret = __adp1653_set_power(flash, !!on); in adp1653_set_power()
344 flash->power_count += on ? 1 : -1; in adp1653_set_power()
345 WARN_ON(flash->power_count < 0); in adp1653_set_power()
348 mutex_unlock(&flash->power_lock); in adp1653_set_power()
384 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_suspend() local
386 if (!flash->power_count) in adp1653_suspend()
389 return __adp1653_set_power(flash, 0); in adp1653_suspend()
396 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_resume() local
398 if (!flash->power_count) in adp1653_resume()
401 return __adp1653_set_power(flash, 1); in adp1653_resume()
412 struct adp1653_flash *flash, in adp1653_of_init() argument
421 flash->platform_data = pd; in adp1653_of_init()
423 child = of_get_child_by_name(node, "flash"); in adp1653_of_init()
427 if (of_property_read_u32(child, "flash-timeout-us", in adp1653_of_init()
431 if (of_property_read_u32(child, "flash-max-microamp", in adp1653_of_init()
471 struct adp1653_flash *flash; in adp1653_probe() local
474 flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); in adp1653_probe()
475 if (flash == NULL) in adp1653_probe()
479 ret = adp1653_of_init(client, flash, client->dev.of_node); in adp1653_probe()
488 flash->platform_data = client->dev.platform_data; in adp1653_probe()
491 mutex_init(&flash->power_lock); in adp1653_probe()
493 v4l2_i2c_subdev_init(&flash->subdev, client, &adp1653_ops); in adp1653_probe()
494 flash->subdev.internal_ops = &adp1653_internal_ops; in adp1653_probe()
495 flash->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in adp1653_probe()
497 ret = adp1653_init_controls(flash); in adp1653_probe()
501 ret = media_entity_pads_init(&flash->subdev.entity, 0, NULL); in adp1653_probe()
505 flash->subdev.entity.function = MEDIA_ENT_F_FLASH; in adp1653_probe()
511 v4l2_ctrl_handler_free(&flash->ctrls); in adp1653_probe()
518 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_remove() local
520 v4l2_device_unregister_subdev(&flash->subdev); in adp1653_remove()
521 v4l2_ctrl_handler_free(&flash->ctrls); in adp1653_remove()
522 media_entity_cleanup(&flash->subdev.entity); in adp1653_remove()
551 MODULE_DESCRIPTION("Analog Devices ADP1653 LED flash driver");