Skip to contentSkip to conversation

LED control

PATCH In review Jean-Francois Moine 5 participants 9 messages Mar 14, 2009 – Mar 17, 2009 Media (V4L/DVB)

lore
Share & tools
lore
#1 lore raw

Review

Quoted 7 lines · On Sat, 14 Mar 2009 12:59:23 +0100 Jean-Francois Moine <[email protected]> wrote:
(quoted diff) +7 -0
+	    <entry><constant>V4L2_CID_LEDS</constant></entry>
+	    <entry>integer</entry>
+	    <entry>Switch on or off the LEDs or illuminators of the device.
+In the control value, each LED may be coded in one bit (0: off, 1: on) or in
+many bits (light intensity).</entry>
+	  </row>
+	  <row>

The idea of having some sort of control over the LEDs is interesting, but we should have a better way of controlling it. If the LED may have more than one bit, maybe the better would be to create more than one CID entry. Something like:

V4L2_CID_LED_POWER - for showing that the camera is being used
V4L2_CID_LED_LIGHT - for normal white light
V4L2_CID_LED_INFRARED - for dark light, using infrared
...

This way a driver can enumberate what kind of leds are available, and get the power intensity range for each individual one.

Cheers,
Mauro

#2 lore raw
Quoted 16 lines · On Sat, 14 Mar 2009 09:17:47 -0300 Mauro Carvalho Chehab…

Review

Quoted 7 lines · On Sat, 14 Mar 2009 12:59:23 +0100 Jean-Francois Moine <[email protected]> wrote:
(quoted diff) +3 -0
+	    <entry><constant>V4L2_CID_LEDS</constant></entry>
+	    <entry>integer</entry>
+	    <entry>Switch on or off the LEDs or illuminators of

the device. +In the control value, each LED may be coded in one bit (0: off, 1: on) or in +many bits (light intensity).</entry>

(quoted diff) +2 -0
+	  </row>
+	  <row>

The idea of having some sort of control over the LEDs is interesting, but we should have a better way of controlling it. If the LED may have more than one bit, maybe the better would be to create more than one CID entry. Something like:

Quoted 7 lines

V4L2_CID_LED_POWER - for showing that the camera is being used
V4L2_CID_LED_LIGHT - for normal white light
V4L2_CID_LED_INFRARED - for dark light, using infrared
...

This way a driver can enumberate what kind of leds are available, and get the power intensity range for each individual one.

OK for V4L2_CID_LED_INFRARED: I already know a webcam type which needs such a control, but I don't know if it is associated to a LED or to a sensor capability.

I heard of some webcams with many LEDs (up to 6) and some of these last ones may be independently switched on or off. But, actually, I don't heard about individual or global LED power.

So, as I understand your controls, V4L2_CID_LED_LIGHT would contain a bit array, one bit for each LED, and V4L2_CID_LED_POWER would give the light intensity for all LEDs. This last control might be added later if needed.

Am I right?

Cheers.

Signature · 2 lines
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#3 lore raw
In reply to Mauro Carvalho Chehab
Quoted 15 lines · Mauro Carvalho Chehab

Review

Quoted 7 lines · On Sat, 14 Mar 2009 12:59:23 +0100 Jean-Francois Moine <[email protected]> wrote:
(quoted diff) +7 -0
+	    <entry><constant>V4L2_CID_LEDS</constant></entry>
+	    <entry>integer</entry>
+	    <entry>Switch on or off the LEDs or illuminators of the device.
+In the control value, each LED may be coded in one bit (0: off, 1: on) or in
+many bits (light intensity).</entry>
+	  </row>
+	  <row>

The idea of having some sort of control over the LEDs is interesting, but we should have a better way of controlling it. If the LED may have more than one bit, maybe the better would be to create more than one CID entry. Something like:

Quoted 7 lines

V4L2_CID_LED_POWER - for showing that the camera is being used
V4L2_CID_LED_LIGHT - for normal white light
V4L2_CID_LED_INFRARED - for dark light, using infrared
...

This way a driver can enumberate what kind of leds are available, and get the power intensity range for each individual one.

Just some random thought of mine of the subject of LED control:

I have an EVK board that has 4 LED's on it.

They are red and of the on/off type. (Although I suppose someday someone might install a dual color LED unit (red & green) or tri-color LED unit (red yellow green) on a piece of equipment.)

They are controlled by GPIOs.

Right now the cx18 driver implicitly controls them when switching between audio inputs, tuner, and radio. However, I was going to internally make an "LED Controller" v4l2_subdevice to handle them.

So I agree that *if* giving control of LEDs to the user application supports valid use cases, then the API spec needs some more thought.

There are at least these uses for LED's in devices:

1. Simple indicator/display
2. Subject matter illumination for video/image capture (I'm guessing)
3. Area illimunation to provide a reference level to an on board sensor (i.e. IR motion detection?)
4. Transmission of data (e.g IR remotes)

The first questions to answer in all of these cases

1. "Should this be controllable from userspace?"

2. "Should it be a user control?"
(When the whole sensor orientation feedback thing came up and Hans spoke of a good "fit" in the API for sensor feedback, I concluded that there isn't a terribly good place in the V4L2 API for sensor feedback, miscellaneous input, or indicator status. Nor is there a good way to enumerate them. Maybe I'm missing something.)

For a subcase of a display indicator to indicate device "power on", if the driver can control that at all (they should be tied to the output of a voltage regulator really) why would you want a use app to "lie" to the user and say power is off?

OK. That's the end of my random thoughts.

Regards,
Andy

Quoted 2 lines

Cheers,
Mauro

#4 lore raw
In reply to Mauro Carvalho Chehab
Quoted 15 lines · Mauro Carvalho Chehab

Review

Quoted 7 lines · On Sat, 14 Mar 2009 12:59:23 +0100 Jean-Francois Moine <[email protected]> wrote:
(quoted diff) +7 -0
+	    <entry><constant>V4L2_CID_LEDS</constant></entry>
+	    <entry>integer</entry>
+	    <entry>Switch on or off the LEDs or illuminators of the device.
+In the control value, each LED may be coded in one bit (0: off, 1: on) or in
+many bits (light intensity).</entry>
+	  </row>
+	  <row>

The idea of having some sort of control over the LEDs is interesting, but we should have a better way of controlling it. If the LED may have more than one bit, maybe the better would be to create more than one CID entry. Something like:

Quoted 7 lines

V4L2_CID_LED_POWER - for showing that the camera is being used
V4L2_CID_LED_LIGHT - for normal white light
V4L2_CID_LED_INFRARED - for dark light, using infrared
...

This way a driver can enumberate what kind of leds are available, and get the power intensity range for each individual one.

There is already a sysfs led interface, you could just have the driver export the leds to the led subsystem and use that.

#5 lore raw
Quoted 2 lines · On Sat, 14 Mar 2009 13:16:11 -0700 (PDT) Trent Piepho <[email protected]>…

There is already a sysfs led interface, you could just have the driver export the leds to the led subsystem and use that.

Yes, but:
- this asks to have a kernel generated with CONFIG_NEW_LEDS,
- the user must use some new program to access /sys/class/leds/<device>,
- he must know how the LEDs of his webcam are named in the /sys tree.

While, when the LEDs are handled by a simple control, the user may quickly change all webcam parameters from a single program as v4l2-ctl.

Signature · 2 lines
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/
#6 lore raw
Quoted 6 lines · On Sunday 15 March 2009 10:50:37 Jean-Francois Moine wrote:

On Sat, 14 Mar 2009 13:16:11 -0700 (PDT)

Quoted 2 lines · Trent Piepho

There is already a sysfs led interface, you could just have the driver export the leds to the led subsystem and use that.

Quoted 7 lines

Yes, but:
- this asks to have a kernel generated with CONFIG_NEW_LEDS,
- the user must use some new program to access /sys/class/leds/<device>,
- he must know how the LEDs of his webcam are named in the /sys tree.

While, when the LEDs are handled by a simple control, the user may quickly change all webcam parameters from a single program as v4l2-ctl.

This would work if devices only exported a few simple LED controls. If we throw multi-color blinking LEDs in the mix we will need a complete LED API anyway.

Laurent Pinchart

#7 lore raw
In reply to Jean-Francois Moine
Quoted 8 lines · Jean-Francois Moine
Quoted 2 lines · On Sat, 14 Mar 2009 13:16:11 -0700 (PDT) Trent Piepho <[email protected]>…

There is already a sysfs led interface, you could just have the driver export the leds to the led subsystem and use that.

Yes, but:
- this asks to have a kernel generated with CONFIG_NEW_LEDS,

So?

Quoted 1 line

- the user must use some new program to access /sys/class/leds/<device>,

echo, cat?

Quoted 1 line

- he must know how the LEDs of his webcam are named in the /sys tree.

Just give them a name like video0:power and it will be easy enough to associate them with the device. I think links in sysfs would do it to, /sys/class/video4linux/video0/device/<ledname> or something like that.

The advantage of using the led class is that you get support for triggers and automatic blink functions, etc.

#8 lore raw
Quoted 12 lines · On Sun, 15 Mar 2009 08:14:56 -0700 (PDT) Trent Piepho <[email protected]>…
Quoted 1 line

- this asks to have a kernel generated with CONFIG_NEW_LEDS,

So?

Quoted 2 lines

- the user must use some new program to
access /sys/class/leds/<device>,

echo, cat?

Quoted 2 lines

- he must know how the LEDs of his webcam are named in the /sys tree.

Quoted 7 lines

Just give them a name like video0:power and it will be easy enough to associate them with the device. I think links in sysfs would do it to, /sys/class/video4linux/video0/device/<ledname> or something like that.

The advantage of using the led class is that you get support for triggers and automatic blink functions, etc.

Sorry for I don't see the usage of blinking the LEDs for a webcam.

Again, using the led class makes me wonder about:

1) The end users.

Many Linux users don't know the kernel internal, nor which of the too many applications they should use to make their devices work. If no developper creates a tool to handle the webcams, the users have to search again and again. Even if there is a full documentation, they will try anything and eventually ask the kernel developpers why they cannot have their LEDs switched on.

Actually, there are a few programs that can handle the webcam parameters. In fact I know only 'v4l2-ctl': I did not succeeded to compile qv4l2; v4l2ucp has been removed from Debian; and, anyway, these programs don't handle the VIDIOC_G_JPEGCOMP and VIDIOC_S_JPEGCOMP ioctls.

2) The memory overhead.

Using the led class adds more kernel code and asks the webcam drivers to create a new device. Also, the function called for changing the LED brighness cannot sleep, so the use a workqueue is required.

On contrary, with a webcam control, only one byte (for 8 LEDs) is added to the webcam structure and the change is immediatly done in the ioctl.

3) The development time.

I already spent 2 hours to look how the led class was working. I am not sure to develop a full LED mechanism in less than 5 to 8 hours, and, as I cannot test it by myself, I will have to wait for testers to know if the various protections (USB access, USB disconnection) work in all cases.

Otherwise, adding a new control in a driver may be done in less than half an hour, and, sure, it will work well at the first go!

Signature · 2 lines
Ken ar c'hentañ	|	      ** Breizh ha Linux atav! **
Jef		|		http://moinejf.free.fr/