~martijnbraam/Megapixels#5: 
Add flashlight support

Can be done by simple led control and some config stuffs

Status
REPORTED
Submitter
~martijnbraam
Assigned to
No-one
Submitted
2 years ago
Updated
1 year, 24 days ago
Labels
Feature

~tobias 2 years ago

Just FYI: Some Android camera apps have a so called "Display Flash" if the phone has no flash for the front camera. That is simply showing a white image with full brightens to simulate a flash.

~benjamin-schaaf 1 year, 10 months ago

I've pushed an implementation for both an LED and a display flash to the "flash" branch on my fork.

~martijnbraam 1 year, 10 months ago

looks like your current implementation uses sysfs to talk to the leds, which isn't the ideal way to do this. v4l2 has an interface to integrate the flash led which the flash driver for the PinePhone supports, but we're having some issues with that driver when it actually integrates in the dtb so it's currently disabled. Using the leds directly with sysfs has some permission issues.

Also for the flash sysfs interface it shouldn't use the max_brightness stuff since that's for torch mode, not flashing. For flashing you write to the flash_strobe file which fires the led for a short duration, but way brighter.

~benjamin-schaaf 1 year, 10 months ago

but we're having some issues with that driver when it actually integrates in the dtb so it's currently disabled

Speaking of issues, the camera drivers are completely broken on Mobian currently, so unfortunately I can't really do much testing unless I downgrade to the previous kernel.

Also for the flash sysfs interface it shouldn't use the max_brightness stuff since that's for torch mode, not flashing. For flashing you write to the flash_strobe file which fires the led for a short duration, but way brighter.

That's cool, thanks for the tip. My main concern was that the timing wouldn't line up taking such an approach - probably not a problem when done through v4l.

In terms of fixing the various driver bugs, I've tried to take a look at it but while the driver implementation itself seems rather straightforward the actual things it's doing don't make much sense to me. I've read through the whole spec for the ov5640 but it seems like the driver is using a number of undocumented registers? For the record I haven't done any driver development before, but is there anything I can do to help?

~martijnbraam 1 year, 10 months ago

I haven't really encountered any fully undocumented registers, they are usually just badly documented or documented in seperate appnotes (like for autofocus)

This is the manual I've been using: https://cdn.sparkfun.com/datasheets/Sensors/LightImaging/OV5640_datasheet.pdf

I expect there are a bunch of issues with my autofocus patch, which can raise an ETIMEOUT error in places where vl42 doesn't expect it.

The flash_strobe isn't super short so it shouldn't really have timing issues, especially since we mostly use the first frame now in postprocessing. Having the timing regulated by v4l2 is definetly nicer though.

~benjamin-schaaf 1 year, 9 months ago

Sorry for the long delay, I've pushed a change that uses flash_strobe now. Not sure if you'll want to merge it if there's already v4l2 fixes for that incoming? I didn't come across any permission issues while developing.

~benjamin-schaaf 1 year, 24 days ago

Register here or Log in to comment, or comment via email.