Hi Hans, Thanks for the review. Sorry about the style mistakes, will be careful next time. Just a couple of questions. On Fri, Sep 20, 2019 at 8:32 AM Hans Verkuil <hverkuil@xxxxxxxxx> wrote: > > > +static int vimc_fla_s_ctrl(struct v4l2_ctrl *c) > > +{ > > + > > + struct vimc_fla_device *vfla = > > + container_of(c->handler, struct vimc_fla_device, hdl); > > + > > + switch (c->id) { > > + case V4L2_CID_FLASH_LED_MODE: > > + vfla->led_mode = c->val; > > + return 0; > > + case V4L2_CID_FLASH_STROBE_SOURCE: > > + vfla->strobe_source = c->val; > > + return 0; > > + case V4L2_CID_FLASH_STROBE: > > + if (vfla->led_mode != V4L2_FLASH_LED_MODE_FLASH || > > + vfla->strobe_source != V4L2_FLASH_STROBE_SOURCE_SOFTWARE){ > > + return -EILSEQ; > > + } > > + vfla->is_strobe = true; > > + vfla->kthread = kthread_run(vimc_fla_strobe_thread, vfla, "vimc-flash thread"); > > What if the thread is already running? > > I wonder what existing flash drivers do if V4L2_CID_FLASH_STROBE is called > repeatedly. Perhaps returning EBUSY if strobe is still active makes sense here. > > It would also be a nice feature if keeping the strobe on for more than X seconds > would create a V4L2_FLASH_FAULT_LED_OVER_TEMPERATURE fault. > How would you expect this? At this point I will never cross the maximum timeout configured. I don't expect a driver to fail if I set a value within the configuration borders. > > + v4l2_ctrl_new_std_menu(&vfla->hdl, &vimc_fla_ctrl_ops, > > + V4L2_CID_FLASH_LED_MODE, > > + V4L2_FLASH_LED_MODE_TORCH, ~0x7, > > + V4L2_FLASH_LED_MODE_NONE); > > + v4l2_ctrl_new_std_menu(&vfla->hdl, &vimc_fla_ctrl_ops, > > + V4L2_CID_FLASH_STROBE_SOURCE, 0x1, ~0x3, > > + V4L2_FLASH_STROBE_SOURCE_SOFTWARE); > > + v4l2_ctrl_new_std(&vfla->hdl, &vimc_fla_ctrl_ops, > > + V4L2_CID_FLASH_STROBE, 0, 0, 0, 0); > > + v4l2_ctrl_new_std(&vfla->hdl, &vimc_fla_ctrl_ops, > > + V4L2_CID_FLASH_STROBE_STOP, 0, 0, 0, 0); > > + v4l2_ctrl_new_std(&vfla->hdl, &vimc_fla_ctrl_ops, > > + V4L2_CID_FLASH_TIMEOUT, 0, > > + VIMC_FLASH_TIMEOUT_MAX, > > + VIMC_FLASH_TIMEOUT_STEP, > > + VIMC_FLASH_TIMEOUT_STEP); > > + v4l2_ctrl_new_std(&vfla->hdl, &vimc_fla_ctrl_ops, > > + V4L2_CID_FLASH_TORCH_INTENSITY, 0, 255, 1, 255); > > + v4l2_ctrl_new_std(&vfla->hdl, &vimc_fla_ctrl_ops, > > + V4L2_CID_FLASH_INTENSITY, 0, 255, 1, 255); > > + v4l2_ctrl_new_std(&vfla->hdl, &vimc_fla_ctrl_ops,V4L2_CID_FLASH_INDICATOR_INTENSITY > > + V4L2_CID_FLASH_INDICATOR_INTENSITY, 0, 255, 1, 255); > > Can you look at existing flash drivers and copy the min/max/step/def values? > > The values here are rather arbitrary. It would be nice if it was a bit more > realistic. I didn't found any driver implementing V4L2_CID_FLASH_INDICATOR_INTENSITY. Do you have any examples for this? For the other ones I'm copying the lm3646 for the other ones. Regards, Lucas