Default [Q] Is it possible to control the brightness of the LED camera flash?

Hi

I am doing a project which involves improving the efficiency of barcode scanning using smartphone cameras. One of the aspects I am looking at is scanning in low light. Currently in low light conditions applications such as ZXing barcode scanner will turn on the LED camera light, although without the ability to control brightness it can cause glare. My goal is to perhaps control the brightness of the LED using pulse width modulation. How would I go about doing this? The only devices I have at my disposal are a Nexus 4 and Samsung Galaxy S4, and I have been mainly concentrating on the Nexus 4 as I believe this is the platform I have the best chance of achieving my goals. So far I am under the impression that I will need to modify the kernel for one of these devices to achieve what I want? Am I on the right track or is there another way?

Thanks for reading