Lines Matching refs:flash
49 static int adp1653_update_hw(struct adp1653_flash *flash) in adp1653_update_hw() argument
51 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_update_hw()
57 flash->indicator_intensity->val) in adp1653_update_hw()
60 switch (flash->led_mode->val) { in adp1653_update_hw()
66 config |= TIMEOUT_US_TO_CODE(flash->flash_timeout->val) in adp1653_update_hw()
72 flash->torch_intensity->val) in adp1653_update_hw()
88 static int adp1653_get_fault(struct adp1653_flash *flash) in adp1653_get_fault() argument
90 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_get_fault()
98 flash->fault |= fault; in adp1653_get_fault()
100 if (!flash->fault) in adp1653_get_fault()
108 flash->led_mode->val = V4L2_FLASH_LED_MODE_NONE; in adp1653_get_fault()
110 rval = adp1653_update_hw(flash); in adp1653_get_fault()
114 return flash->fault; in adp1653_get_fault()
117 static int adp1653_strobe(struct adp1653_flash *flash, int enable) in adp1653_strobe() argument
119 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_strobe()
121 flash->indicator_intensity->val) in adp1653_strobe()
125 if (flash->led_mode->val != V4L2_FLASH_LED_MODE_FLASH) in adp1653_strobe()
133 flash->flash_intensity->val) in adp1653_strobe()
153 struct adp1653_flash *flash = in adp1653_get_ctrl() local
157 rval = adp1653_get_fault(flash); in adp1653_get_ctrl()
163 if (flash->fault & ADP1653_REG_FAULT_FLT_SCP) in adp1653_get_ctrl()
165 if (flash->fault & ADP1653_REG_FAULT_FLT_OT) in adp1653_get_ctrl()
167 if (flash->fault & ADP1653_REG_FAULT_FLT_TMR) in adp1653_get_ctrl()
169 if (flash->fault & ADP1653_REG_FAULT_FLT_OV) in adp1653_get_ctrl()
172 flash->fault = 0; in adp1653_get_ctrl()
179 struct adp1653_flash *flash = in adp1653_set_ctrl() local
183 rval = adp1653_get_fault(flash); in adp1653_set_ctrl()
196 return adp1653_strobe(flash, 1); in adp1653_set_ctrl()
198 return adp1653_strobe(flash, 0); in adp1653_set_ctrl()
201 return adp1653_update_hw(flash); in adp1653_set_ctrl()
209 static int adp1653_init_controls(struct adp1653_flash *flash) in adp1653_init_controls() argument
213 v4l2_ctrl_handler_init(&flash->ctrls, 9); in adp1653_init_controls()
215 flash->led_mode = in adp1653_init_controls()
216 v4l2_ctrl_new_std_menu(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
219 v4l2_ctrl_new_std_menu(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
222 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
224 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
226 flash->flash_timeout = in adp1653_init_controls()
227 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
229 flash->platform_data->max_flash_timeout, in adp1653_init_controls()
231 flash->platform_data->max_flash_timeout); in adp1653_init_controls()
232 flash->flash_intensity = in adp1653_init_controls()
233 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
236 flash->platform_data->max_flash_intensity, in adp1653_init_controls()
237 1, flash->platform_data->max_flash_intensity); in adp1653_init_controls()
238 flash->torch_intensity = in adp1653_init_controls()
239 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
242 flash->platform_data->max_torch_intensity, in adp1653_init_controls()
244 flash->platform_data->max_torch_intensity); in adp1653_init_controls()
245 flash->indicator_intensity = in adp1653_init_controls()
246 v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
249 flash->platform_data->max_indicator_intensity, in adp1653_init_controls()
252 fault = v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops, in adp1653_init_controls()
258 if (flash->ctrls.error) in adp1653_init_controls()
259 return flash->ctrls.error; in adp1653_init_controls()
263 flash->subdev.ctrl_handler = &flash->ctrls; in adp1653_init_controls()
272 adp1653_init_device(struct adp1653_flash *flash) in adp1653_init_device() argument
274 struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev); in adp1653_init_device()
284 mutex_lock(flash->ctrls.lock); in adp1653_init_device()
286 flash->fault = 0; in adp1653_init_device()
287 rval = adp1653_get_fault(flash); in adp1653_init_device()
288 mutex_unlock(flash->ctrls.lock); in adp1653_init_device()
294 mutex_lock(flash->ctrls.lock); in adp1653_init_device()
295 rval = adp1653_update_hw(flash); in adp1653_init_device()
296 mutex_unlock(flash->ctrls.lock); in adp1653_init_device()
307 __adp1653_set_power(struct adp1653_flash *flash, int on) in __adp1653_set_power() argument
311 ret = flash->platform_data->power(&flash->subdev, on); in __adp1653_set_power()
318 ret = adp1653_init_device(flash); in __adp1653_set_power()
320 flash->platform_data->power(&flash->subdev, 0); in __adp1653_set_power()
328 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_set_power() local
331 mutex_lock(&flash->power_lock); in adp1653_set_power()
336 if (flash->power_count == !on) { in adp1653_set_power()
337 ret = __adp1653_set_power(flash, !!on); in adp1653_set_power()
343 flash->power_count += on ? 1 : -1; in adp1653_set_power()
344 WARN_ON(flash->power_count < 0); in adp1653_set_power()
347 mutex_unlock(&flash->power_lock); in adp1653_set_power()
383 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_suspend() local
385 if (!flash->power_count) in adp1653_suspend()
388 return __adp1653_set_power(flash, 0); in adp1653_suspend()
395 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_resume() local
397 if (!flash->power_count) in adp1653_resume()
400 return __adp1653_set_power(flash, 1); in adp1653_resume()
413 struct adp1653_flash *flash; in adp1653_probe() local
420 flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); in adp1653_probe()
421 if (flash == NULL) in adp1653_probe()
424 flash->platform_data = client->dev.platform_data; in adp1653_probe()
426 mutex_init(&flash->power_lock); in adp1653_probe()
428 v4l2_i2c_subdev_init(&flash->subdev, client, &adp1653_ops); in adp1653_probe()
429 flash->subdev.internal_ops = &adp1653_internal_ops; in adp1653_probe()
430 flash->subdev.flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in adp1653_probe()
432 ret = adp1653_init_controls(flash); in adp1653_probe()
436 ret = media_entity_init(&flash->subdev.entity, 0, NULL, 0); in adp1653_probe()
440 flash->subdev.entity.type = MEDIA_ENT_T_V4L2_SUBDEV_FLASH; in adp1653_probe()
445 v4l2_ctrl_handler_free(&flash->ctrls); in adp1653_probe()
452 struct adp1653_flash *flash = to_adp1653_flash(subdev); in adp1653_remove() local
454 v4l2_device_unregister_subdev(&flash->subdev); in adp1653_remove()
455 v4l2_ctrl_handler_free(&flash->ctrls); in adp1653_remove()
456 media_entity_cleanup(&flash->subdev.entity); in adp1653_remove()