Lines Matching refs:flash
47 static int adp1653_update_hw(struct adp1653_flash *flash) in adp1653_update_hw() argument
49 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_update_hw()
55 flash->indicator_intensity->val) in adp1653_update_hw()
58 switch (flash->led_mode->val) { in adp1653_update_hw()
64 config |= TIMEOUT_US_TO_CODE(flash->flash_timeout->val) in adp1653_update_hw()
70 flash->torch_intensity->val) in adp1653_update_hw()
86 static int adp1653_get_fault(struct adp1653_flash *flash) in adp1653_get_fault() argument
88 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_get_fault()
96 flash->fault |= fault; in adp1653_get_fault()
98 if (!flash->fault) in adp1653_get_fault()
106 flash->led_mode->val = V4L2_FLASH_LED_MODE_NONE; in adp1653_get_fault()
108 rval = adp1653_update_hw(flash); in adp1653_get_fault()
112 return flash->fault; in adp1653_get_fault()
115 static int adp1653_strobe(struct adp1653_flash *flash, int enable) in adp1653_strobe() argument
117 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_strobe()
119 flash->indicator_intensity->val) in adp1653_strobe()
123 if (flash->led_mode->val != V4L2_FLASH_LED_MODE_FLASH) in adp1653_strobe()
131 flash->flash_intensity->val) in adp1653_strobe()
151 struct adp1653_flash *flash = in adp1653_get_ctrl() local
155 rval = adp1653_get_fault(flash); in adp1653_get_ctrl()
161 if (flash->fault & ADP1653_REG_FAULT_FLT_SCP) in adp1653_get_ctrl()
163 if (flash->fault & ADP1653_REG_FAULT_FLT_OT) in adp1653_get_ctrl()
165 if (flash->fault & ADP1653_REG_FAULT_FLT_TMR) in adp1653_get_ctrl()
167 if (flash->fault & ADP1653_REG_FAULT_FLT_OV) in adp1653_get_ctrl()
170 flash->fault = 0; in adp1653_get_ctrl()
177 struct adp1653_flash *flash = in adp1653_set_ctrl() local
181 rval = adp1653_get_fault(flash); in adp1653_set_ctrl()
194 return adp1653_strobe(flash, 1); in adp1653_set_ctrl()
196 return adp1653_strobe(flash, 0); in adp1653_set_ctrl()
199 return adp1653_update_hw(flash); in adp1653_set_ctrl()
207 static int adp1653_init_controls(struct adp1653_flash *flash) in adp1653_init_controls() argument
211 v4l2_ctrl_handler_init(&flash->ctrls, 9); in adp1653_init_controls()
213 flash->led_mode = in adp1653_init_controls()
214 v4l2_ctrl_new_std_menu(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
217 v4l2_ctrl_new_std_menu(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
220 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
222 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
224 flash->flash_timeout = in adp1653_init_controls()
225 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
227 flash->platform_data->max_flash_timeout, in adp1653_init_controls()
229 flash->platform_data->max_flash_timeout); in adp1653_init_controls()
230 flash->flash_intensity = in adp1653_init_controls()
231 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
234 flash->platform_data->max_flash_intensity, in adp1653_init_controls()
235 1, flash->platform_data->max_flash_intensity); in adp1653_init_controls()
236 flash->torch_intensity = in adp1653_init_controls()
237 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
240 flash->platform_data->max_torch_intensity, in adp1653_init_controls()
242 flash->platform_data->max_torch_intensity); in adp1653_init_controls()
243 flash->indicator_intensity = in adp1653_init_controls()
244 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
247 flash->platform_data->max_indicator_intensity, in adp1653_init_controls()
250 fault = v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
256 if (flash->ctrls.error) in adp1653_init_controls()
257 return flash->ctrls.error; in adp1653_init_controls()
261 flash->subdev.ctrl_handler = &flash->ctrls; in adp1653_init_controls()
270 adp1653_init_device(struct adp1653_flash *flash) in adp1653_init_device() argument
272 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_init_device()
282 mutex_lock(flash->ctrls.lock); in adp1653_init_device()
284 flash->fault = 0; in adp1653_init_device()
285 rval = adp1653_get_fault(flash); in adp1653_init_device()
286 mutex_unlock(flash->ctrls.lock); in adp1653_init_device()
292 mutex_lock(flash->ctrls.lock); in adp1653_init_device()
293 rval = adp1653_update_hw(flash); in adp1653_init_device()
294 mutex_unlock(flash->ctrls.lock); in adp1653_init_device()
305 __adp1653_set_power(struct adp1653_flash *flash, int on) in __adp1653_set_power() argument
309 if (flash->platform_data->power) { in __adp1653_set_power()
310 ret = flash->platform_data->power(&flash->subdev, on); in __adp1653_set_power()
314 gpiod_set_value(flash->platform_data->enable_gpio, on); in __adp1653_set_power()
323 ret = adp1653_init_device(flash); in __adp1653_set_power()
327 if (flash->platform_data->power) in __adp1653_set_power()
328 flash->platform_data->power(&flash->subdev, 0); in __adp1653_set_power()
330 gpiod_set_value(flash->platform_data->enable_gpio, 0); in __adp1653_set_power()
338 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_set_power() local
341 mutex_lock(&flash->power_lock); in adp1653_set_power()
346 if (flash->power_count == !on) { in adp1653_set_power()
347 ret = __adp1653_set_power(flash, !!on); in adp1653_set_power()
353 flash->power_count += on ? 1 : -1; in adp1653_set_power()
354 WARN_ON(flash->power_count < 0); in adp1653_set_power()
357 mutex_unlock(&flash->power_lock); in adp1653_set_power()
393 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_suspend() local
395 if (!flash->power_count) in adp1653_suspend()
398 return __adp1653_set_power(flash, 0); in adp1653_suspend()
405 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_resume() local
407 if (!flash->power_count) in adp1653_resume()
410 return __adp1653_set_power(flash, 1); in adp1653_resume()
421 struct adp1653_flash *flash, in adp1653_of_init() argument
430 flash->platform_data = pd; in adp1653_of_init()
480 struct adp1653_flash *flash; in adp1653_probe() local
483 flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); in adp1653_probe()
484 if (flash == NULL) in adp1653_probe()
488 ret = adp1653_of_init(client, flash, client->dev.of_node); in adp1653_probe()
497 flash->platform_data = client->dev.platform_data; in adp1653_probe()
500 mutex_init(&flash->power_lock); in adp1653_probe()
502 v4l2_i2c_subdev_init(&flash->subdev, client, &adp1653_ops); in adp1653_probe()
503 flash->subdev.internal_ops = &adp1653_internal_ops; in adp1653_probe()
504 flash->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in adp1653_probe()
506 ret = adp1653_init_controls(flash); in adp1653_probe()
510 ret = media_entity_pads_init(&flash->subdev.entity, 0, NULL); in adp1653_probe()
514 flash->subdev.entity.function = MEDIA_ENT_F_FLASH; in adp1653_probe()
520 v4l2_ctrl_handler_free(&flash->ctrls); in adp1653_probe()
527 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_remove() local
529 v4l2_device_unregister_subdev(&flash->subdev); in adp1653_remove()
530 v4l2_ctrl_handler_free(&flash->ctrls); in adp1653_remove()
531 media_entity_cleanup(&flash->subdev.entity); in adp1653_remove()