Lines Matching full:flash
51 static int adp1653_update_hw(struct adp1653_flash *flash) in adp1653_update_hw() argument
53 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_update_hw()
59 flash->indicator_intensity->val) in adp1653_update_hw()
62 switch (flash->led_mode->val) { in adp1653_update_hw()
66 /* Flash mode, light on with strobe, duration from timer */ in adp1653_update_hw()
68 config |= TIMEOUT_US_TO_CODE(flash->flash_timeout->val) in adp1653_update_hw()
74 flash->torch_intensity->val) in adp1653_update_hw()
90 static int adp1653_get_fault(struct adp1653_flash *flash) in adp1653_get_fault() argument
92 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_get_fault()
100 flash->fault |= fault; in adp1653_get_fault()
102 if (!flash->fault) in adp1653_get_fault()
110 flash->led_mode->val = V4L2_FLASH_LED_MODE_NONE; in adp1653_get_fault()
112 rval = adp1653_update_hw(flash); in adp1653_get_fault()
116 return flash->fault; in adp1653_get_fault()
119 static int adp1653_strobe(struct adp1653_flash *flash, int enable) in adp1653_strobe() argument
121 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_strobe()
123 flash->indicator_intensity->val) in adp1653_strobe()
127 if (flash->led_mode->val != V4L2_FLASH_LED_MODE_FLASH) in adp1653_strobe()
135 flash->flash_intensity->val) in adp1653_strobe()
155 struct adp1653_flash *flash = in adp1653_get_ctrl() local
159 rval = adp1653_get_fault(flash); in adp1653_get_ctrl()
165 if (flash->fault & ADP1653_REG_FAULT_FLT_SCP) in adp1653_get_ctrl()
167 if (flash->fault & ADP1653_REG_FAULT_FLT_OT) in adp1653_get_ctrl()
169 if (flash->fault & ADP1653_REG_FAULT_FLT_TMR) in adp1653_get_ctrl()
171 if (flash->fault & ADP1653_REG_FAULT_FLT_OV) in adp1653_get_ctrl()
174 flash->fault = 0; in adp1653_get_ctrl()
181 struct adp1653_flash *flash = in adp1653_set_ctrl() local
185 rval = adp1653_get_fault(flash); in adp1653_set_ctrl()
198 return adp1653_strobe(flash, 1); in adp1653_set_ctrl()
200 return adp1653_strobe(flash, 0); in adp1653_set_ctrl()
203 return adp1653_update_hw(flash); in adp1653_set_ctrl()
211 static int adp1653_init_controls(struct adp1653_flash *flash) in adp1653_init_controls() argument
215 v4l2_ctrl_handler_init(&flash->ctrls, 9); in adp1653_init_controls()
217 flash->led_mode = in adp1653_init_controls()
218 v4l2_ctrl_new_std_menu(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
221 v4l2_ctrl_new_std_menu(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
224 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
226 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
228 flash->flash_timeout = in adp1653_init_controls()
229 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
231 flash->platform_data->max_flash_timeout, in adp1653_init_controls()
233 flash->platform_data->max_flash_timeout); in adp1653_init_controls()
234 flash->flash_intensity = in adp1653_init_controls()
235 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
238 flash->platform_data->max_flash_intensity, in adp1653_init_controls()
239 1, flash->platform_data->max_flash_intensity); in adp1653_init_controls()
240 flash->torch_intensity = in adp1653_init_controls()
241 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
244 flash->platform_data->max_torch_intensity, in adp1653_init_controls()
246 flash->platform_data->max_torch_intensity); in adp1653_init_controls()
247 flash->indicator_intensity = in adp1653_init_controls()
248 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
251 flash->platform_data->max_indicator_intensity, in adp1653_init_controls()
254 fault = v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
260 if (flash->ctrls.error) in adp1653_init_controls()
261 return flash->ctrls.error; in adp1653_init_controls()
265 flash->subdev.ctrl_handler = &flash->ctrls; in adp1653_init_controls()
274 adp1653_init_device(struct adp1653_flash *flash) in adp1653_init_device() argument
276 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_init_device()
286 mutex_lock(&flash->ctrls.lock); in adp1653_init_device()
288 flash->fault = 0; in adp1653_init_device()
289 rval = adp1653_get_fault(flash); in adp1653_init_device()
290 mutex_unlock(&flash->ctrls.lock); in adp1653_init_device()
296 mutex_lock(&flash->ctrls.lock); in adp1653_init_device()
297 rval = adp1653_update_hw(flash); in adp1653_init_device()
298 mutex_unlock(&flash->ctrls.lock); in adp1653_init_device()
309 __adp1653_set_power(struct adp1653_flash *flash, int on) in __adp1653_set_power() argument
313 ret = flash->platform_data->power(&flash->subdev, on); in __adp1653_set_power()
320 ret = adp1653_init_device(flash); in __adp1653_set_power()
322 flash->platform_data->power(&flash->subdev, 0); in __adp1653_set_power()
330 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_set_power() local
333 mutex_lock(&flash->power_lock); in adp1653_set_power()
338 if (flash->power_count == !on) { in adp1653_set_power()
339 ret = __adp1653_set_power(flash, !!on); in adp1653_set_power()
345 flash->power_count += on ? 1 : -1; in adp1653_set_power()
346 WARN_ON(flash->power_count < 0); in adp1653_set_power()
349 mutex_unlock(&flash->power_lock); in adp1653_set_power()
385 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_suspend() local
387 if (!flash->power_count) in adp1653_suspend()
390 return __adp1653_set_power(flash, 0); in adp1653_suspend()
397 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_resume() local
399 if (!flash->power_count) in adp1653_resume()
402 return __adp1653_set_power(flash, 1); in adp1653_resume()
415 struct adp1653_flash *flash; in adp1653_probe() local
422 flash = kzalloc(sizeof(*flash), GFP_KERNEL); in adp1653_probe()
423 if (flash == NULL) in adp1653_probe()
426 flash->platform_data = client->dev.platform_data; in adp1653_probe()
428 mutex_init(&flash->power_lock); in adp1653_probe()
430 v4l2_i2c_subdev_init(&flash->subdev, client, &adp1653_ops); in adp1653_probe()
431 flash->subdev.internal_ops = &adp1653_internal_ops; in adp1653_probe()
432 flash->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in adp1653_probe()
434 ret = adp1653_init_controls(flash); in adp1653_probe()
438 ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0); in adp1653_probe()
442 flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; in adp1653_probe()
447 v4l2_ctrl_handler_free(&flash->ctrls); in adp1653_probe()
448 kfree(flash); in adp1653_probe()
455 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_remove() local
457 v4l2_device_unregister_subdev(&flash->subdev); in adp1653_remove()
458 v4l2_ctrl_handler_free(&flash->ctrls); in adp1653_remove()
459 media_entity_cleanup(&flash->subdev.entity); in adp1653_remove()
460 kfree(flash); in adp1653_remove()
505 MODULE_DESCRIPTION("Analog Devices ADP1653 LED flash driver");