Lines Matching full:flash
4 * General device driver for TI lm3559, lm3560, FLASH LED Driver
68 static int lm3560_mode_ctrl(struct lm3560_flash *flash) in lm3560_mode_ctrl() argument
72 switch (flash->led_mode) { in lm3560_mode_ctrl()
74 rval = regmap_update_bits(flash->regmap, in lm3560_mode_ctrl()
78 rval = regmap_update_bits(flash->regmap, in lm3560_mode_ctrl()
82 rval = regmap_update_bits(flash->regmap, in lm3560_mode_ctrl()
90 static int lm3560_enable_ctrl(struct lm3560_flash *flash, in lm3560_enable_ctrl() argument
97 rval = regmap_update_bits(flash->regmap, in lm3560_enable_ctrl()
100 rval = regmap_update_bits(flash->regmap, in lm3560_enable_ctrl()
104 rval = regmap_update_bits(flash->regmap, in lm3560_enable_ctrl()
107 rval = regmap_update_bits(flash->regmap, in lm3560_enable_ctrl()
114 static int lm3560_torch_brt_ctrl(struct lm3560_flash *flash, in lm3560_torch_brt_ctrl() argument
121 return lm3560_enable_ctrl(flash, led_no, false); in lm3560_torch_brt_ctrl()
123 rval = lm3560_enable_ctrl(flash, led_no, true); in lm3560_torch_brt_ctrl()
127 rval = regmap_update_bits(flash->regmap, in lm3560_torch_brt_ctrl()
130 rval = regmap_update_bits(flash->regmap, in lm3560_torch_brt_ctrl()
137 static int lm3560_flash_brt_ctrl(struct lm3560_flash *flash, in lm3560_flash_brt_ctrl() argument
144 return lm3560_enable_ctrl(flash, led_no, false); in lm3560_flash_brt_ctrl()
146 rval = lm3560_enable_ctrl(flash, led_no, true); in lm3560_flash_brt_ctrl()
150 rval = regmap_update_bits(flash->regmap, in lm3560_flash_brt_ctrl()
153 rval = regmap_update_bits(flash->regmap, in lm3560_flash_brt_ctrl()
162 struct lm3560_flash *flash = to_lm3560_flash(ctrl, led_no); in lm3560_get_ctrl() local
165 mutex_lock(&flash->lock); in lm3560_get_ctrl()
170 rval = regmap_read(flash->regmap, REG_FLAG, ®_val); in lm3560_get_ctrl()
183 mutex_unlock(&flash->lock); in lm3560_get_ctrl()
189 struct lm3560_flash *flash = to_lm3560_flash(ctrl, led_no); in lm3560_set_ctrl() local
193 mutex_lock(&flash->lock); in lm3560_set_ctrl()
197 flash->led_mode = ctrl->val; in lm3560_set_ctrl()
198 if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH) in lm3560_set_ctrl()
199 rval = lm3560_mode_ctrl(flash); in lm3560_set_ctrl()
203 rval = regmap_update_bits(flash->regmap, in lm3560_set_ctrl()
210 if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH) { in lm3560_set_ctrl()
214 flash->led_mode = V4L2_FLASH_LED_MODE_FLASH; in lm3560_set_ctrl()
215 rval = lm3560_mode_ctrl(flash); in lm3560_set_ctrl()
219 if (flash->led_mode != V4L2_FLASH_LED_MODE_FLASH) { in lm3560_set_ctrl()
223 flash->led_mode = V4L2_FLASH_LED_MODE_NONE; in lm3560_set_ctrl()
224 rval = lm3560_mode_ctrl(flash); in lm3560_set_ctrl()
229 rval = regmap_update_bits(flash->regmap, in lm3560_set_ctrl()
234 rval = lm3560_flash_brt_ctrl(flash, led_no, ctrl->val); in lm3560_set_ctrl()
238 rval = lm3560_torch_brt_ctrl(flash, led_no, ctrl->val); in lm3560_set_ctrl()
243 mutex_unlock(&flash->lock); in lm3560_set_ctrl()
278 static int lm3560_init_controls(struct lm3560_flash *flash, in lm3560_init_controls() argument
282 u32 max_flash_brt = flash->pdata->max_flash_brt[led_no]; in lm3560_init_controls()
283 u32 max_torch_brt = flash->pdata->max_torch_brt[led_no]; in lm3560_init_controls()
284 struct v4l2_ctrl_handler *hdl = &flash->ctrls_led[led_no]; in lm3560_init_controls()
289 /* flash mode */ in lm3560_init_controls()
293 flash->led_mode = V4L2_FLASH_LED_MODE_NONE; in lm3560_init_controls()
295 /* flash source */ in lm3560_init_controls()
299 /* flash strobe */ in lm3560_init_controls()
302 /* flash strobe stop */ in lm3560_init_controls()
305 /* flash strobe timeout */ in lm3560_init_controls()
308 flash->pdata->max_flash_timeout, in lm3560_init_controls()
310 flash->pdata->max_flash_timeout); in lm3560_init_controls()
312 /* flash brt */ in lm3560_init_controls()
334 flash->subdev_led[led_no].ctrl_handler = hdl; in lm3560_init_controls()
349 static int lm3560_subdev_init(struct lm3560_flash *flash, in lm3560_subdev_init() argument
352 struct i2c_client *client = to_i2c_client(flash->dev); in lm3560_subdev_init()
355 v4l2_i2c_subdev_init(&flash->subdev_led[led_no], client, &lm3560_ops); in lm3560_subdev_init()
356 flash->subdev_led[led_no].flags |= V4L2_SUBDEV_FL_HAS_DEVNODE; in lm3560_subdev_init()
357 strscpy(flash->subdev_led[led_no].name, led_name, in lm3560_subdev_init()
358 sizeof(flash->subdev_led[led_no].name)); in lm3560_subdev_init()
359 rval = lm3560_init_controls(flash, led_no); in lm3560_subdev_init()
362 rval = media_entity_pads_init(&flash->subdev_led[led_no].entity, 0, NULL); in lm3560_subdev_init()
365 flash->subdev_led[led_no].entity.function = MEDIA_ENT_F_FLASH; in lm3560_subdev_init()
370 v4l2_ctrl_handler_free(&flash->ctrls_led[led_no]); in lm3560_subdev_init()
374 static int lm3560_init_device(struct lm3560_flash *flash) in lm3560_init_device() argument
380 rval = regmap_update_bits(flash->regmap, in lm3560_init_device()
381 REG_FLASH_TOUT, 0x60, flash->pdata->peak); in lm3560_init_device()
385 flash->led_mode = V4L2_FLASH_LED_MODE_NONE; in lm3560_init_device()
386 rval = lm3560_mode_ctrl(flash); in lm3560_init_device()
390 rval = regmap_read(flash->regmap, REG_FLAG, ®_val); in lm3560_init_device()
397 struct lm3560_flash *flash; in lm3560_probe() local
401 flash = devm_kzalloc(&client->dev, sizeof(*flash), GFP_KERNEL); in lm3560_probe()
402 if (flash == NULL) in lm3560_probe()
405 flash->regmap = devm_regmap_init_i2c(client, &lm3560_regmap); in lm3560_probe()
406 if (IS_ERR(flash->regmap)) { in lm3560_probe()
407 rval = PTR_ERR(flash->regmap); in lm3560_probe()
425 flash->pdata = pdata; in lm3560_probe()
426 flash->dev = &client->dev; in lm3560_probe()
427 mutex_init(&flash->lock); in lm3560_probe()
429 rval = lm3560_subdev_init(flash, LM3560_LED0, "lm3560-led0"); in lm3560_probe()
433 rval = lm3560_subdev_init(flash, LM3560_LED1, "lm3560-led1"); in lm3560_probe()
437 rval = lm3560_init_device(flash); in lm3560_probe()
441 i2c_set_clientdata(client, flash); in lm3560_probe()
448 struct lm3560_flash *flash = i2c_get_clientdata(client); in lm3560_remove() local
452 v4l2_device_unregister_subdev(&flash->subdev_led[i]); in lm3560_remove()
453 v4l2_ctrl_handler_free(&flash->ctrls_led[i]); in lm3560_remove()
454 media_entity_cleanup(&flash->subdev_led[i].entity); in lm3560_remove()
482 MODULE_DESCRIPTION("Texas Instruments LM3560 LED flash driver");