Skip to contentSkip to conversation

V4L2 API for flash devices and the adp1653 flash controller driver

RFC Superseded Sakari Ailus 2 participants 12 messages May 16, 2011 – Jun 10, 2011

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

cover V4L2 API for flash devices and the adp1653 flash controller driver

Hi,

This is a patchset which implements RFC v4 of V4L2 API for flash devices [1], with minor modifications, and adds the adp1653 flash controller driver.

What was changed was that the V4L2_CID_FLASH_STROBE_MODE control was renamed to V4L2_CID_FLASH_STROBE_SOURCE. Also the related enum has been renamed correspondingly.

Laurent: I didn't add the text from the RFC to the flash controls documentation since I'm inclined to think it doesn't actually belong there. Much of it is suggesting what could be done in future or defining the scope of the interface. Both are mostly related to further development activities. That said, there definitely is important information in the RFC although much of it isn't directly related to the flash controls. If we want to add (some of) that to the V4L2 documentation, where should it be put?

[1] http://www.spinics.net/lists/linux-media/msg32030.html

Cheers,

Signature · 2 lines
Sakari Ailus
[email protected]
#1 lore raw

PATCH 1/3 v4l: Add a class and a set of controls for flash devices.

From: Sakari Ailus <[email protected]>

Add a control class and a set of controls to support LED and Xenon flash devices. An example of such a device is the adp1653.

---
 drivers/media/video/v4l2-ctrls.c |   45 ++++++++++++++++++++++++++++++++++++++
 include/linux/videodev2.h        |   36 ++++++++++++++++++++++++++++++
 2 files changed, 81 insertions(+), 0 deletions(-)
drivers/media/video/v4l2-ctrls.c +45 -0
index 2412f08..74aae36 100644
@@ -216,6 +216,17 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		"75 useconds",
 		NULL,
 	};
+	static const char * const flash_led_mode[] = {
+		"Off",
+		"Flash",
+		"Torch",
+		NULL,
+	};
+	static const char * const flash_strobe_source[] = {
+		"Software",
+		"External",
+		NULL,
+	};
 
 	switch (id) {
 	case V4L2_CID_MPEG_AUDIO_SAMPLING_FREQ:
@@ -256,6 +267,10 @@ const char * const *v4l2_ctrl_get_menu(u32 id)
 		return colorfx;
 	case V4L2_CID_TUNE_PREEMPHASIS:
 		return tune_preemphasis;
+	case V4L2_CID_FLASH_LED_MODE:
+		return flash_led_mode;
+	case V4L2_CID_FLASH_STROBE_SOURCE:
+		return flash_strobe_source;
 	default:
 		return NULL;
 	}
@@ -389,6 +404,21 @@ const char *v4l2_ctrl_get_name(u32 id)
 	case V4L2_CID_TUNE_POWER_LEVEL:		return "Tune Power Level";
 	case V4L2_CID_TUNE_ANTENNA_CAPACITOR:	return "Tune Antenna Capacitor";
 
+	/* Flash controls */
+	case V4L2_CID_FLASH_CLASS:		return "Flash controls";
+	case V4L2_CID_FLASH_LED_MODE:		return "LED mode";
+	case V4L2_CID_FLASH_STROBE_SOURCE:	return "Strobe source";
+	case V4L2_CID_FLASH_STROBE:		return "Strobe";
+	case V4L2_CID_FLASH_STROBE_STOP:	return "Stop strobe";
+	case V4L2_CID_FLASH_STROBE_STATUS:	return "Strobe status";
+	case V4L2_CID_FLASH_TIMEOUT:		return "Strobe timeout";
+	case V4L2_CID_FLASH_INTENSITY:		return "Intensity, flash mode";
+	case V4L2_CID_FLASH_TORCH_INTENSITY:	return "Intensity, torch mode";
+	case V4L2_CID_FLASH_INDICATOR_INTENSITY: return "Intensity, indicator";
+	case V4L2_CID_FLASH_FAULT:		return "Faults";
+	case V4L2_CID_FLASH_CHARGE:		return "Charge";
+	case V4L2_CID_FLASH_READY:		return "Ready to strobe";
+
 	default:
 		return NULL;
 	}
@@ -423,12 +453,17 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_PILOT_TONE_ENABLED:
 	case V4L2_CID_ILLUMINATORS_1:
 	case V4L2_CID_ILLUMINATORS_2:
+	case V4L2_CID_FLASH_STROBE_STATUS:
+	case V4L2_CID_FLASH_CHARGE:
+	case V4L2_CID_FLASH_READY:
 		*type = V4L2_CTRL_TYPE_BOOLEAN;
 		*min = 0;
 		*max = *step = 1;
 		break;
 	case V4L2_CID_PAN_RESET:
 	case V4L2_CID_TILT_RESET:
+	case V4L2_CID_FLASH_STROBE:
+	case V4L2_CID_FLASH_STROBE_STOP:
 		*type = V4L2_CTRL_TYPE_BUTTON;
 		*flags |= V4L2_CTRL_FLAG_WRITE_ONLY;
 		*min = *max = *step = *def = 0;
@@ -452,6 +487,8 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_EXPOSURE_AUTO:
 	case V4L2_CID_COLORFX:
 	case V4L2_CID_TUNE_PREEMPHASIS:
+	case V4L2_CID_FLASH_LED_MODE:
+	case V4L2_CID_FLASH_STROBE_SOURCE:
 		*type = V4L2_CTRL_TYPE_MENU;
 		break;
 	case V4L2_CID_RDS_TX_PS_NAME:
@@ -462,6 +499,7 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_CAMERA_CLASS:
 	case V4L2_CID_MPEG_CLASS:
 	case V4L2_CID_FM_TX_CLASS:
+	case V4L2_CID_FLASH_CLASS:
 		*type = V4L2_CTRL_TYPE_CTRL_CLASS;
 		/* You can neither read not write these */
 		*flags |= V4L2_CTRL_FLAG_READ_ONLY | V4L2_CTRL_FLAG_WRITE_ONLY;
@@ -474,6 +512,9 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 		/* Max is calculated as RGB888 that is 2^24 */
 		*max = 0xFFFFFF;
 		break;
+	case V4L2_CID_FLASH_FAULT:
+		*type = V4L2_CTRL_TYPE_BITMASK;
+		break;
 	default:
 		*type = V4L2_CTRL_TYPE_INTEGER;
 		break;
@@ -519,6 +560,10 @@ void v4l2_ctrl_fill(u32 id, const char **name, enum v4l2_ctrl_type *type,
 	case V4L2_CID_ZOOM_RELATIVE:
 		*flags |= V4L2_CTRL_FLAG_WRITE_ONLY;
 		break;
+	case V4L2_CID_FLASH_STROBE_STATUS:
+	case V4L2_CID_FLASH_READY:
+		*flags |= V4L2_CTRL_FLAG_READ_ONLY;
+		break;
 	}
 }
 EXPORT_SYMBOL(v4l2_ctrl_fill);
include/linux/videodev2.h +36 -0
index be82c8e..e364350 100644
@@ -1022,6 +1022,7 @@ struct v4l2_ext_controls {
 #define V4L2_CTRL_CLASS_MPEG 0x00990000	/* MPEG-compression controls */
 #define V4L2_CTRL_CLASS_CAMERA 0x009a0000	/* Camera class controls */
 #define V4L2_CTRL_CLASS_FM_TX 0x009b0000	/* FM Modulator control class */
+#define V4L2_CTRL_CLASS_FLASH 0x009c0000	/* Camera flash controls */
 
 #define V4L2_CTRL_ID_MASK      	  (0x0fffffff)
 #define V4L2_CTRL_ID2CLASS(id)    ((id) & 0x0fff0000UL)
@@ -1423,6 +1424,41 @@ enum v4l2_preemphasis {
 #define V4L2_CID_TUNE_POWER_LEVEL		(V4L2_CID_FM_TX_CLASS_BASE + 113)
 #define V4L2_CID_TUNE_ANTENNA_CAPACITOR		(V4L2_CID_FM_TX_CLASS_BASE + 114)
 
+/* Flash and privacy (indicator) light controls */
+#define V4L2_CID_FLASH_CLASS_BASE		(V4L2_CTRL_CLASS_FLASH | 0x900)
+#define V4L2_CID_FLASH_CLASS			(V4L2_CTRL_CLASS_FLASH | 1)
+
+#define V4L2_CID_FLASH_LED_MODE			(V4L2_CID_FLASH_CLASS_BASE + 1)
+enum v4l2_flash_led_mode {
+	V4L2_FLASH_LED_MODE_NONE,
+	V4L2_FLASH_LED_MODE_FLASH,
+	V4L2_FLASH_LED_MODE_TORCH,
+};
+
+#define V4L2_CID_FLASH_STROBE_SOURCE		(V4L2_CID_FLASH_CLASS_BASE + 2)
+enum v4l2_flash_strobe_source {
+	V4L2_FLASH_STROBE_SOURCE_SOFTWARE,
+	V4L2_FLASH_STROBE_SOURCE_EXTERNAL,
+};
+
+#define V4L2_CID_FLASH_STROBE			(V4L2_CID_FLASH_CLASS_BASE + 3)
+#define V4L2_CID_FLASH_STROBE_STOP		(V4L2_CID_FLASH_CLASS_BASE + 4)
+#define V4L2_CID_FLASH_STROBE_STATUS		(V4L2_CID_FLASH_CLASS_BASE + 5)
+
+#define V4L2_CID_FLASH_TIMEOUT			(V4L2_CID_FLASH_CLASS_BASE + 6)
+#define V4L2_CID_FLASH_INTENSITY		(V4L2_CID_FLASH_CLASS_BASE + 7)
+#define V4L2_CID_FLASH_TORCH_INTENSITY		(V4L2_CID_FLASH_CLASS_BASE + 8)
+#define V4L2_CID_FLASH_INDICATOR_INTENSITY	(V4L2_CID_FLASH_CLASS_BASE + 9)
+
+#define V4L2_CID_FLASH_FAULT			(V4L2_CID_FLASH_CLASS_BASE + 10)
+#define V4L2_FLASH_FAULT_OVER_VOLTAGE		(1 << 0)
+#define V4L2_FLASH_FAULT_TIMEOUT		(1 << 1)
+#define V4L2_FLASH_FAULT_OVER_TEMPERATURE	(1 << 2)
+#define V4L2_FLASH_FAULT_SHORT_CIRCUIT		(1 << 3)
+
+#define V4L2_CID_FLASH_CHARGE			(V4L2_CID_FLASH_CLASS_BASE + 11)
+#define V4L2_CID_FLASH_READY			(V4L2_CID_FLASH_CLASS_BASE + 12)
+
 /*
  *	T U N I N G
  */
Signature · 1 line
1.7.2.5
#2 lore raw

PATCH 2/3 v4l: Add flash control documentation

In reply to Sakari Ailus

Add documentation for V4L2 flash controls.

---
 Documentation/DocBook/v4l/controls.xml           |  216 ++++++++++++++++++++++
 Documentation/DocBook/v4l/vidioc-g-ext-ctrls.xml |    7 +
 2 files changed, 223 insertions(+), 0 deletions(-)
Documentation/DocBook/v4l/controls.xml +216 -0
index a920ee8..124d5d8 100644
@@ -2092,6 +2092,222 @@ manually or automatically if set to zero. Unit, range and step are driver-specif
 <para>For more details about RDS specification, refer to
 <xref linkend="en50067" /> document, from CENELEC.</para>
     </section>
+
+    <section id="flash-controls">
+      <title>Flash Control Reference</title>
+
+      <para>
+	The V4L2 flash controls are intended to provide generic access
+	to flash controller devices. Flash controller devices are
+	typically used in digital cameras.
+      </para>
+
+      <para>
+	The interface can support both LED and xenon flash devices. 
+      </para>
+
+      <table pgwide="1" frame="none" id="flash-control-id">
+      <title>Flash Control IDs</title>
+
+      <tgroup cols="4">
+	<colspec colname="c1" colwidth="1*" />
+	<colspec colname="c2" colwidth="6*" />
+	<colspec colname="c3" colwidth="2*" />
+	<colspec colname="c4" colwidth="6*" />
+	<spanspec namest="c1" nameend="c2" spanname="id" />
+	<spanspec namest="c2" nameend="c4" spanname="descr" />
+	<thead>
+	  <row>
+	    <entry spanname="id" align="left">ID</entry>
+	    <entry align="left">Type</entry>
+	  </row><row rowsep="1"><entry spanname="descr" align="left">Description</entry>
+	  </row>
+	</thead>
+	<tbody valign="top">
+	  <row><entry></entry></row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_CLASS</constant></entry>
+	    <entry>class</entry>
+	  </row>
+          <row>
+	    <entry spanname="descr">The FLASH class descriptor.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_LED_MODE</constant></entry>
+	    <entry>menu</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">Defines the mode of the flash LED,
+	    the high-power white LED attached to the flash
+	    controller.</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_FLASH_LED_MODE_NONE</constant></entry>
+		  <entry>Off.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_FLASH_LED_MODE_FLASH</constant></entry>
+		  <entry>Flash mode.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_FLASH_LED_MODE_TORCH</constant></entry>
+		  <entry>Torch mode. See V4L2_CID_FLASH_TORCH_INTENSITY.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_STROBE_SOURCE</constant></entry>
+	    <entry>menu</entry>
+	  </row>
+	  <row><entry spanname="descr">Defines the mode of the
+	  flash LED strobe.</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_FLASH_STROBE_SOURCE_SOFTWARE</constant></entry>
+		  <entry>The flash strobe is triggered by using
+		  the V4L2_CID_FLASH_STROBE control.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_FLASH_STROBE_SOURCE_EXTERNAL</constant></entry>
+		  <entry>The flash strobe is triggered by an
+		  external source. Typically this is a sensor,
+		  which makes it possible to synchronises the
+		  flash strobe start to exposure start.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_STROBE</constant></entry>
+	    <entry>button</entry>
+	  </row>
+          <row>
+	    <entry spanname="descr">Strobe flash. Valid when
+	    V4L2_CID_FLASH_LED_MODE is set to
+	    V4L2_FLASH_LED_MODE_FLASH and V4L2_CID_FLASH_STROBE_SOURCE
+	    is set to V4L2_FLASH_STROBE_SOURCE_SOFTWARE.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_STROBE_STOP</constant></entry>
+	    <entry>button</entry>
+	  </row>
+          <row><entry spanname="descr">Stop flash strobe immediately.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_STROBE_STATUS</constant></entry>
+	    <entry>boolean</entry>
+	  </row>
+          <row>
+	    <entry spanname="descr">Strobe status: whether the flash
+	    is strobing at the moment or not. This is a read-only
+	    control.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_TIMEOUT</constant></entry>
+	    <entry>integer</entry>
+	  </row>
+          <row>
+	    <entry spanname="descr">Hardware timeout for flash. The
+	    flash strobe is stopped after this period of time has
+	    passed from the start of the strobe.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_INTENSITY</constant></entry>
+	    <entry>integer</entry>
+	  </row>
+          <row>
+	    <entry spanname="descr">Intensity of the flash strobe when
+	    the flash LED is in flash mode
+	    (V4L2_FLASH_LED_MODE_FLASH).</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_TORCH_INTENSITY</constant></entry>
+	    <entry>integer</entry>
+	  </row>
+          <row>
+	    <entry spanname="descr">Intensity of the flash LED in
+	    torch mode (V4L2_FLASH_LED_MODE_TORCH). Intensity of zero
+	    (0) means off.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_INDICATOR_INTENSITY</constant></entry>
+	    <entry>integer</entry>
+	  </row>
+          <row>
+	    <entry spanname="descr">Intensity of the indicator LED.
+	    The indicator LED may be fully independent of the flash
+	    LED. Intensity of zero (0) means off.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_FAULT</constant></entry>
+	    <entry>bitmask</entry>
+	  </row>
+	  <row>
+	    <entry spanname="descr">Faults related to the flash. The
+	    faults tell about specific problems in the flash chip
+	    itself or the LEDs attached to it. Reading the control
+	    will clear it.</entry>
+	  </row>
+	  <row>
+	    <entrytbl spanname="descr" cols="2">
+	      <tbody valign="top">
+		<row>
+		  <entry><constant>V4L2_FLASH_FAULT_OVER_VOLTAGE</constant></entry>
+		  <entry>Flash controller voltage to the flash LED
+		  has exceeded the limit specific to the flash
+		  controller.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_FLASH_FAULT_TIMEOUT</constant></entry>
+		  <entry>The flash strobe was still on when
+		  the timeout set by the user ---
+		  V4L2_CID_FLASH_TIMEOUT control --- has expired.
+		  Not all flash controllers may set this in all
+		  such conditions.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_FLASH_FAULT_OVER_TEMPERATURE</constant></entry>
+		  <entry>The flash controller has overheated.</entry>
+		</row>
+		<row>
+		  <entry><constant>V4L2_FLASH_FAULT_SHORT_CIRCUIT</constant></entry>
+		  <entry>The short circuit protection of the flash
+		  controller has been triggered.</entry>
+		</row>
+	      </tbody>
+	    </entrytbl>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_CHARGE</constant></entry>
+	    <entry>boolean</entry>
+	  </row>
+          <row><entry spanname="descr">Enable or disable charging of the xenon
+          flash capacitor.</entry>
+	  </row>
+	  <row>
+	    <entry spanname="id"><constant>V4L2_CID_FLASH_READY</constant></entry>
+	    <entry>boolean</entry>
+	  </row>
+          <row>
+	    <entry spanname="descr">Is the flash ready to strobe?
+	    Xenon flashes require their capacitors charged before
+	    strobing. LED flashes often require a cooldown period
+	    after strobe during which another strobe will not be
+	    possible. This is a read-only control.</entry>
+	  </row>
+	  <row><entry></entry></row>
+	</tbody>
+      </tgroup>
+      </table>
+
+    </section>
 </section>
 
   <!--
Documentation/DocBook/v4l/vidioc-g-ext-ctrls.xml +7 -0
index 3aa7f8f..c37bd86 100644
@@ -250,6 +250,13 @@ These controls are described in <xref
 These controls are described in <xref
 		linkend="fm-tx-controls" />.</entry>
 	  </row>
+	  <row>
+	    <entry><constant>V4L2_CTRL_CLASS_FLASH</constant></entry>
+	    <entry>0x9c0000</entry>
+	    <entry>The class containing flash device controls.
+These controls are described in <xref
+		linkend="flash-controls" />.</entry>
+	  </row>
 	</tbody>
       </tgroup>
     </table>
Signature · 1 line
1.7.2.5
#3 lore raw

PATCH 3/3 adp1653: Add driver for LED flash controller

In reply to Sakari Ailus

This patch adds the driver for the adp1653 LED flash controller. This controller supports a high power led in flash and torch modes and an indicator light, sometimes also called privacy light.

The adp1653 is used on the Nokia N900.

---
 drivers/media/video/Kconfig   |    7 +
 drivers/media/video/Makefile  |    2 +
 drivers/media/video/adp1653.c |  453 +++++++++++++++++++++++++++++++++++++++++
 include/media/adp1653.h       |   94 +++++++++
 4 files changed, 556 insertions(+), 0 deletions(-)
 create mode 100644 drivers/media/video/adp1653.c
 create mode 100644 include/media/adp1653.h
drivers/media/video/Kconfig +7 -0
index 00f51dd..c004dbb 100644
@@ -344,6 +344,13 @@ config VIDEO_TCM825X
 	  This is a driver for the Toshiba TCM825x VGA camera sensor.
 	  It is used for example in Nokia N800.
 
+config VIDEO_ADP1653
+	tristate "ADP1653 flash support"
+	depends on I2C && VIDEO_V4L2 && MEDIA_CONTROLLER
+	---help---
+	  This is a driver for the ADP1653 flash controller. It is used for
+	  example in Nokia N900.
+
 config VIDEO_SAA7110
 	tristate "Philips SAA7110 video decoder"
 	depends on VIDEO_V4L2 && I2C
drivers/media/video/Makefile +2 -0
index ace5d8b..abdf021 100644
@@ -131,6 +131,8 @@ obj-$(CONFIG_VIDEO_VIA_CAMERA) += via-camera.o
 
 obj-$(CONFIG_VIDEO_OMAP3)	+= omap3isp/
 
+obj-$(CONFIG_VIDEO_ADP1653)	+= adp1653.o
+
 obj-$(CONFIG_USB_ZR364XX)       += zr364xx.o
 obj-$(CONFIG_USB_STKWEBCAM)     += stkwebcam.o
 
drivers/media/video/adp1653.c new file +453 -0

453 lines not on this page · raw message

include/media/adp1653.h new file +94 -0

94 lines not on this page · raw message

Signature · 1 line
1.7.2.5
#4 lore raw

Re: [PATCH 3/3] adp1653: Add driver for LED flash controller

Hi Sakari,

Thanks for the patch.

Quoted 10 lines · On Monday 16 May 2011 15:00:39 Sakari Ailus wrote:

This patch adds the driver for the adp1653 LED flash controller. This controller supports a high power led in flash and torch modes and an indicator light, sometimes also called privacy light.

The adp1653 is used on the Nokia N900.

[snip]

Quoted 5 lines
drivers/media/video/adp1653.c new file +0 -0
new file mode 100644
index 0000000..92ea38b

[snip]

Quoted 18 lines
drivers/media/video/adp1653.c new file +18 -0
+/* Write values into ADP1653 registers. */
+static int adp1653_update_hw(struct adp1653_flash *flash)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev);
+	u8 out_sel;
+	u8 config = 0;
+	int rval;
+
+	out_sel = flash->indicator_intensity->val
+		<< ADP1653_REG_OUT_SEL_ILED_SHIFT;
+
+	switch (flash->led_mode->val) {
+	case V4L2_FLASH_LED_MODE_NONE:
+		break;
+	case V4L2_FLASH_LED_MODE_FLASH:
+		/* Flash mode, light on with strobe, duration from timer */
+		config = ADP1653_REG_CONFIG_TMR_CFG;
+		config |= TIMEOUT_US_TO_CODE(flash->flash_timeout->val)

drivers/media/video/adp1653.c line 76

Quoted 10 lines
drivers/media/video/adp1653.c new file +10 -0
+			  << ADP1653_REG_CONFIG_TMR_SET_SHIFT;
+		break;
+	case V4L2_FLASH_LED_MODE_TORCH:
+		/* Torch mode, light immediately on, duration indefinite */
+		out_sel |= flash->torch_intensity->val
+			   << ADP1653_REG_OUT_SEL_HPLED_SHIFT;
+		break;
+	}
+
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL, out_sel);

out_sel can be used uninitialized here.

Quoted 9 lines
drivers/media/video/adp1653.c new file +9 -0
+	if (rval < 0)
+		return rval;
+
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_CONFIG, config);
+	if (rval < 0)
+		return rval;
+
+	return 0;
+}

[snip]

Quoted 6 lines
drivers/media/video/adp1653.c new file +6 -0
+static int adp1653_get_ctrl(struct v4l2_ctrl *ctrl)
+{
+	struct adp1653_flash *flash =
+		container_of(ctrl->handler, struct adp1653_flash, ctrls);
+	struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev);
+	int fault;

drivers/media/video/adp1653.c line 134

Quoted 10 lines
drivers/media/video/adp1653.c new file +10 -0
+	int rval;
+
+	fault = i2c_smbus_read_byte_data(client, ADP1653_REG_FAULT);
+	if (IS_ERR_VALUE(fault))
+		return fault;
+
+	/* Clear faults. */
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL, 0);
+	if (IS_ERR_VALUE(rval))
+		return rval;

If several applications read controls, only one of them will be notified of faults. Shouldn't clearing the fault be handled explicitly by writing to a control ? I know this changes the API :-)

drivers/media/video/adp1653.c line 139

Quoted 4 lines
drivers/media/video/adp1653.c new file +4 -0
+	/* Restore configuration. */
+	rval = adp1653_update_hw(flash);
+	if (IS_ERR_VALUE(rval))
+		return rval;

Will that produce expected results ? For instance, if a fault was detected during flash strobe, won't it try to re-strobe the flash ? Shouldn't the user be required to explicitly re-strobe the flash or turn the torch (or indicator) on after a fault ? Once again this should be clarified in the API :-)

Quoted 13 lines
drivers/media/video/adp1653.c new file +13 -0
+	ctrl->cur.val = 0;
+
+	if (fault & ADP1653_REG_FAULT_FLT_SCP)
+		ctrl->cur.val |= V4L2_FLASH_FAULT_SHORT_CIRCUIT;
+	if (fault & ADP1653_REG_FAULT_FLT_OT)
+		ctrl->cur.val |= V4L2_FLASH_FAULT_OVER_TEMPERATURE;
+	if (fault & ADP1653_REG_FAULT_FLT_TMR)
+		ctrl->cur.val |= V4L2_FLASH_FAULT_TIMEOUT;
+	if (fault & ADP1653_REG_FAULT_FLT_OV)
+		ctrl->cur.val |= V4L2_FLASH_FAULT_OVER_VOLTAGE;
+
+	return 0;
+}

[snip]

Quoted 12 lines
drivers/media/video/adp1653.c new file +12 -0
+static int
+adp1653_init_device(struct adp1653_flash *flash)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev);
+	int rval;
+
+	/* Clear FAULT register by writing zero to OUT_SEL */
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL, 0);
+	if (rval < 0) {
+		dev_err(&client->dev, "failed writing fault register\n");
+		return -EIO;
+	}

drivers/media/video/adp1653.c line 259

Quoted 10 lines
drivers/media/video/adp1653.c new file +10 -0
+
+	/* Read FAULT register */
+	rval = i2c_smbus_read_byte_data(client, ADP1653_REG_FAULT);
+	if (rval < 0) {
+		dev_err(&client->dev, "failed reading fault register\n");
+		return -EIO;
+	}
+
+	if ((rval & 0x0f) != 0) {
+		dev_err(&client->dev, "device fault\n");

You could print the fault value, that could help debugging problems.

Quoted 14 lines
drivers/media/video/adp1653.c new file +14 -0
+		return -EIO;
+	}
+
+	mutex_lock(&flash->ctrls.lock);
+	rval = adp1653_update_hw(flash);
+	mutex_unlock(&flash->ctrls.lock);
+	if (rval) {
+		dev_err(&client->dev,
+			"adp1653_update_hw failed at %s\n", __func__);
+		return -EIO;
+	}
+
+	return 0;
+}

[snip]

Signature · 3 lines
Regards,

Laurent Pinchart
#5 lore raw

Re: [PATCH 3/3] adp1653: Add driver for LED flash controller

Quoted 3 lines · Laurent Pinchart

Hi Sakari,

Thanks for the patch.

Thanks for the comments! :-)

Quoted 44 lines · On Monday 16 May 2011 15:00:39 Sakari Ailus wrote:
Quoted 10 lines

This patch adds the driver for the adp1653 LED flash controller. This controller supports a high power led in flash and torch modes and an indicator light, sometimes also called privacy light.

The adp1653 is used on the Nokia N900.

[snip]

Quoted 5 lines
drivers/media/video/adp1653.c new file +0 -0
new file mode 100644
index 0000000..92ea38b

[snip]

Quoted 22 lines
drivers/media/video/adp1653.c new file +22 -0
+/* Write values into ADP1653 registers. */
+static int adp1653_update_hw(struct adp1653_flash *flash)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev);
+	u8 out_sel;
+	u8 config = 0;
+	int rval;
+
+	out_sel = flash->indicator_intensity->val
+		<< ADP1653_REG_OUT_SEL_ILED_SHIFT;
+
+	switch (flash->led_mode->val) {
+	case V4L2_FLASH_LED_MODE_NONE:
+		break;
+	case V4L2_FLASH_LED_MODE_FLASH:
+		/* Flash mode, light on with strobe, duration from timer */
+		config = ADP1653_REG_CONFIG_TMR_CFG;
+		config |= TIMEOUT_US_TO_CODE(flash->flash_timeout->val)
+			  << ADP1653_REG_CONFIG_TMR_SET_SHIFT;
+		break;
+	case V4L2_FLASH_LED_MODE_TORCH:
+		/* Torch mode, light immediately on, duration indefinite */
Quoted 8 lines

drivers/media/video/adp1653.c line 76

Quoted 6 lines
drivers/media/video/adp1653.c new file +6 -0
+		out_sel |= flash->torch_intensity->val
+			   << ADP1653_REG_OUT_SEL_HPLED_SHIFT;
+		break;
+	}
+
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL, out_sel);

out_sel can be used uninitialized here.

I don't think so. It's assigned a value in the beginning of the function.

Quoted 24 lines
Quoted 9 lines
drivers/media/video/adp1653.c new file +9 -0
+	if (rval < 0)
+		return rval;
+
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_CONFIG, config);
+	if (rval < 0)
+		return rval;
+
+	return 0;
+}

[snip]

Quoted 12 lines
drivers/media/video/adp1653.c new file +12 -0
+static int adp1653_get_ctrl(struct v4l2_ctrl *ctrl)
+{
+	struct adp1653_flash *flash =
+		container_of(ctrl->handler, struct adp1653_flash, ctrls);
+	struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev);
+	int fault;
+	int rval;
+
+	fault = i2c_smbus_read_byte_data(client, ADP1653_REG_FAULT);
+	if (IS_ERR_VALUE(fault))
+		return fault;
+
Quoted 8 lines

drivers/media/video/adp1653.c line 134

Quoted 4 lines
drivers/media/video/adp1653.c new file +4 -0
+	/* Clear faults. */
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL, 0);
+	if (IS_ERR_VALUE(rval))
+		return rval;

If several applications read controls, only one of them will be notified of faults. Shouldn't clearing the fault be handled explicitly by writing to a control ? I know this changes the API :-)

This is true.

Although I can't imagine right now why two separate processes should be so interested in the faults but it is still entirely possible that someone does that since it's permitted by the interface.

Having to write zero to faults to clear them isn't good either since it might mean missing faults that are triggered between reading and writing this control.

Perhaps this would make sense as a file handle specific control?

The control documentation says that the faults are cleared when the register is read, but the adp1653 also clears the faults whenever writing zero to out_sel which happens also in other circumstances, for example when changing mode from flash to torch when the torch intensity is zero, or when indicator intensity is zero in other modes.

Quoted 7 lines

drivers/media/video/adp1653.c line 139

Quoted 4 lines
drivers/media/video/adp1653.c new file +4 -0
+	/* Restore configuration. */
+	rval = adp1653_update_hw(flash);
+	if (IS_ERR_VALUE(rval))
+		return rval;

Will that produce expected results ? For instance, if a fault was detected during flash strobe, won't it try to re-strobe the flash ? Shouldn't the user

No. Flash is strobed using adp1653_strobe().

Quoted 2 lines

be required to explicitly re-strobe the flash or turn the torch (or indicator) on after a fault ? Once again this should be clarified in the API :-)

The mode won't be changed from the flash but to strobe again, the user has to push V4L2_CID_FLASH_STROBE again.

The adp1653 doesn't have any torch (as such) or indicator faults; some other chips do have indicator faults at least. Using the torch mode might trigger faults, too, since it's the same LED; just the power isn't that high.

Quoted 32 lines
Quoted 13 lines
drivers/media/video/adp1653.c new file +13 -0
+	ctrl->cur.val = 0;
+
+	if (fault & ADP1653_REG_FAULT_FLT_SCP)
+		ctrl->cur.val |= V4L2_FLASH_FAULT_SHORT_CIRCUIT;
+	if (fault & ADP1653_REG_FAULT_FLT_OT)
+		ctrl->cur.val |= V4L2_FLASH_FAULT_OVER_TEMPERATURE;
+	if (fault & ADP1653_REG_FAULT_FLT_TMR)
+		ctrl->cur.val |= V4L2_FLASH_FAULT_TIMEOUT;
+	if (fault & ADP1653_REG_FAULT_FLT_OV)
+		ctrl->cur.val |= V4L2_FLASH_FAULT_OVER_VOLTAGE;
+
+	return 0;
+}

[snip]

Quoted 16 lines
drivers/media/video/adp1653.c new file +16 -0
+static int
+adp1653_init_device(struct adp1653_flash *flash)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev);
+	int rval;
+
+	/* Clear FAULT register by writing zero to OUT_SEL */
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL, 0);
+	if (rval < 0) {
+		dev_err(&client->dev, "failed writing fault register\n");
+		return -EIO;
+	}
+
+	/* Read FAULT register */
+	rval = i2c_smbus_read_byte_data(client, ADP1653_REG_FAULT);
+	if (rval < 0) {
Quoted 8 lines

drivers/media/video/adp1653.c line 259

Quoted 6 lines
drivers/media/video/adp1653.c new file +6 -0
+		dev_err(&client->dev, "failed reading fault register\n");
+		return -EIO;
+	}
+
+	if ((rval & 0x0f) != 0) {
+		dev_err(&client->dev, "device fault\n");

You could print the fault value, that could help debugging problems.

I'll change that.

Quoted 8 lines
Quoted 8 lines
drivers/media/video/adp1653.c new file +8 -0
+		return -EIO;
+	}
+
+	mutex_lock(&flash->ctrls.lock);
+	rval = adp1653_update_hw(flash);
+	mutex_unlock(&flash->ctrls.lock);
+	if (rval) {
+		dev_err(&client->dev,
Quoted 9 lines
Quoted 6 lines
drivers/media/video/adp1653.c new file +6 -0
+			"adp1653_update_hw failed at %s\n", __func__);
+		return -EIO;
+	}
+
+	return 0;
+}

[snip]

Regards,

Signature · 2 lines
Sakari Ailus
[email protected]
#6 lore raw

Re: [PATCH 3/3] adp1653: Add driver for LED flash controller

Hi Sakari,

Quoted 55 lines · On Tuesday 17 May 2011 07:38:38 Sakari Ailus wrote:
Quoted 45 lines · Laurent Pinchart
Quoted 10 lines · On Monday 16 May 2011 15:00:39 Sakari Ailus wrote:

This patch adds the driver for the adp1653 LED flash controller. This controller supports a high power led in flash and torch modes and an indicator light, sometimes also called privacy light.

The adp1653 is used on the Nokia N900.

[snip]

Quoted 5 lines
(quoted diff) +0 -0

b/drivers/media/video/adp1653.c new file mode 100644 index 0000000..92ea38b

drivers/media/video/adp1653.c new file +0 -0

[snip]

Quoted 23 lines
drivers/media/video/adp1653.c new file +23 -0
+/* Write values into ADP1653 registers. */
+static int adp1653_update_hw(struct adp1653_flash *flash)
+{
+	struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev);
+	u8 out_sel;
+	u8 config = 0;
+	int rval;
+
+	out_sel = flash->indicator_intensity->val
+		<< ADP1653_REG_OUT_SEL_ILED_SHIFT;
+
+	switch (flash->led_mode->val) {
+	case V4L2_FLASH_LED_MODE_NONE:
+		break;
+	case V4L2_FLASH_LED_MODE_FLASH:
+		/* Flash mode, light on with strobe, duration from timer */
+		config = ADP1653_REG_CONFIG_TMR_CFG;
+		config |= TIMEOUT_US_TO_CODE(flash->flash_timeout->val)
+			  << ADP1653_REG_CONFIG_TMR_SET_SHIFT;
+		break;
+	case V4L2_FLASH_LED_MODE_TORCH:
+		/* Torch mode, light immediately on, duration indefinite */
+		out_sel |= flash->torch_intensity->val
Quoted 8 lines
Quoted 6 lines
drivers/media/video/adp1653.c new file +5 -0
+			   << ADP1653_REG_OUT_SEL_HPLED_SHIFT;
+		break;
+	}
+
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL,

out_sel);

out_sel can be used uninitialized here.

Quoted 1 line

I don't think so. It's assigned a value in the beginning of the function.

My bad, I missed that. Sorry.

Quoted 39 lines
Quoted 24 lines
Quoted 9 lines
drivers/media/video/adp1653.c new file +9 -0
+	if (rval < 0)
+		return rval;
+
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_CONFIG, config);
+	if (rval < 0)
+		return rval;
+
+	return 0;
+}

[snip]

Quoted 12 lines
drivers/media/video/adp1653.c new file +12 -0
+static int adp1653_get_ctrl(struct v4l2_ctrl *ctrl)
+{
+	struct adp1653_flash *flash =
+		container_of(ctrl->handler, struct adp1653_flash, ctrls);
+	struct i2c_client *client = v4l2_get_subdevdata(&flash->subdev);
+	int fault;
+	int rval;
+
+	fault = i2c_smbus_read_byte_data(client, ADP1653_REG_FAULT);
+	if (IS_ERR_VALUE(fault))
+		return fault;
+
Quoted 8 lines

drivers/media/video/adp1653.c line 134

Quoted 4 lines
drivers/media/video/adp1653.c new file +4 -0
+	/* Clear faults. */
+	rval = i2c_smbus_write_byte_data(client, ADP1653_REG_OUT_SEL, 0);
+	if (IS_ERR_VALUE(rval))
+		return rval;

If several applications read controls, only one of them will be notified of faults. Shouldn't clearing the fault be handled explicitly by writing to a control ? I know this changes the API :-)

This is true.

Although I can't imagine right now why two separate processes should be so interested in the faults but it is still entirely possible that someone does that since it's permitted by the interface.

Quoted 5 lines

Having to write zero to faults to clear them isn't good either since it might mean missing faults that are triggered between reading and writing this control.

Perhaps this would make sense as a file handle specific control?

Good question. Control events will help I guess, maybe that's the solution.

Quoted 21 lines

The control documentation says that the faults are cleared when the register is read, but the adp1653 also clears the faults whenever writing zero to out_sel which happens also in other circumstances, for example when changing mode from flash to torch when the torch intensity is zero, or when indicator intensity is zero in other modes.

Quoted 8 lines

drivers/media/video/adp1653.c line 139

Quoted 4 lines
drivers/media/video/adp1653.c new file +4 -0
+	/* Restore configuration. */
+	rval = adp1653_update_hw(flash);
+	if (IS_ERR_VALUE(rval))
+		return rval;

Will that produce expected results ? For instance, if a fault was detected during flash strobe, won't it try to re-strobe the flash ? Shouldn't the user

No. Flash is strobed using adp1653_strobe().

Quoted 3 lines

be required to explicitly re-strobe the flash or turn the torch (or indicator) on after a fault ? Once again this should be clarified in the API :-)

Quoted 7 lines

The mode won't be changed from the flash but to strobe again, the user has to push V4L2_CID_FLASH_STROBE again.

The adp1653 doesn't have any torch (as such) or indicator faults; some other chips do have indicator faults at least. Using the torch mode might trigger faults, too, since it's the same LED; just the power isn't that high.

When an over-current fault is detected, shouldn't the mode be set back to none ? If we just clear the fault and reprogram the registers, the torch will be turned back on, and the fault will likely happen again.

Signature · 3 lines
Regards,

Laurent Pinchart
#7 lore raw

Re: [PATCH 3/3] adp1653: Add driver for LED flash controller

Quoted 1 line · Laurent Pinchart

Hi Sakari,

Hi Laurent,

Quoted 1 line · On Tuesday 17 May 2011 07:38:38 Sakari Ailus wrote:

[clip]

Quoted 11 lines
Quoted 11 lines
Quoted 4 lines

If several applications read controls, only one of them will be notified of faults. Shouldn't clearing the fault be handled explicitly by writing to a control ? I know this changes the API :-)

This is true.

Although I can't imagine right now why two separate processes should be so interested in the faults but it is still entirely possible that someone does that since it's permitted by the interface.

Quoted 7 lines
Quoted 5 lines

Having to write zero to faults to clear them isn't good either since it might mean missing faults that are triggered between reading and writing this control.

Perhaps this would make sense as a file handle specific control?

Good question. Control events will help I guess, maybe that's the solution.

They would help, yes, but in the case of N900 we don't have that luxury since there's no interrupt line from the adp1653 to OMAP. So if one user would read the control, the others would get notified. Yes, that would work, too.

The use case is mostly theoretical and that's actually best the hardware can offer, so I think this is good. No special arrangements needed then.

So reading the value will reset the faults?

Quoted 24 lines
Quoted 24 lines

The control documentation says that the faults are cleared when the register is read, but the adp1653 also clears the faults whenever writing zero to out_sel which happens also in other circumstances, for example when changing mode from flash to torch when the torch intensity is zero, or when indicator intensity is zero in other modes.

Quoted 8 lines

drivers/media/video/adp1653.c line 139

Quoted 4 lines
drivers/media/video/adp1653.c new file +4 -0
+	/* Restore configuration. */
+	rval = adp1653_update_hw(flash);
+	if (IS_ERR_VALUE(rval))
+		return rval;

Will that produce expected results ? For instance, if a fault was detected during flash strobe, won't it try to re-strobe the flash ? Shouldn't the user

No. Flash is strobed using adp1653_strobe().

Quoted 3 lines

be required to explicitly re-strobe the flash or turn the torch (or indicator) on after a fault ? Once again this should be clarified in the API :-)

The mode won't be changed from the flash but to strobe again, the user has to push V4L2_CID_FLASH_STROBE again.

Quoted 8 lines
Quoted 4 lines

The adp1653 doesn't have any torch (as such) or indicator faults; some other chips do have indicator faults at least. Using the torch mode might trigger faults, too, since it's the same LED; just the power isn't that high.

When an over-current fault is detected, shouldn't the mode be set back to none ? If we just clear the fault and reprogram the registers, the torch will be turned back on, and the fault will likely happen again.

That's a good point.

Over-temperature, over-voltage, and short circuit faults should change the LED mode to be set to none. This is likely chip independent behaviour but on the other hand, not all the chips implement all the faults.

Regards,

Signature · 2 lines
Sakari Ailus
[email protected]
#8 lore raw

Re: [PATCH 3/3] adp1653: Add driver for LED flash controller

Hi Sakari,

Quoted 28 lines · On Tuesday 17 May 2011 12:47:25 Sakari Ailus wrote:
Quoted 1 line · Laurent Pinchart

On Tuesday 17 May 2011 07:38:38 Sakari Ailus wrote:

[clip]

Quoted 10 lines
Quoted 10 lines
Quoted 3 lines

If several applications read controls, only one of them will be notified of faults. Shouldn't clearing the fault be handled explicitly by writing to a control ? I know this changes the API :-)

This is true.

Although I can't imagine right now why two separate processes should be so interested in the faults but it is still entirely possible that someone does that since it's permitted by the interface.

Quoted 8 lines
Quoted 5 lines

Having to write zero to faults to clear them isn't good either since it might mean missing faults that are triggered between reading and writing this control.

Perhaps this would make sense as a file handle specific control?

Good question. Control events will help I guess, maybe that's the solution.

They would help, yes, but in the case of N900 we don't have that luxury since there's no interrupt line from the adp1653 to OMAP. So if one user would read the control, the others would get notified. Yes, that would work, too.

Quoted 4 lines

The use case is mostly theoretical and that's actually best the hardware can offer, so I think this is good. No special arrangements needed then.

So reading the value will reset the faults?

OK, let's leave it that way, at least for now.

Quoted 33 lines
Quoted 24 lines
Quoted 24 lines

The control documentation says that the faults are cleared when the register is read, but the adp1653 also clears the faults whenever writing zero to out_sel which happens also in other circumstances, for example when changing mode from flash to torch when the torch intensity is zero, or when indicator intensity is zero in other modes.

Quoted 8 lines

drivers/media/video/adp1653.c line 139

Quoted 4 lines
drivers/media/video/adp1653.c new file +4 -0
+	/* Restore configuration. */
+	rval = adp1653_update_hw(flash);
+	if (IS_ERR_VALUE(rval))
+		return rval;

Will that produce expected results ? For instance, if a fault was detected during flash strobe, won't it try to re-strobe the flash ? Shouldn't the user

No. Flash is strobed using adp1653_strobe().

Quoted 3 lines

be required to explicitly re-strobe the flash or turn the torch (or indicator) on after a fault ? Once again this should be clarified in the API :-)

The mode won't be changed from the flash but to strobe again, the user has to push V4L2_CID_FLASH_STROBE again.

Quoted 8 lines
Quoted 4 lines

The adp1653 doesn't have any torch (as such) or indicator faults; some other chips do have indicator faults at least. Using the torch mode might trigger faults, too, since it's the same LED; just the power isn't that high.

When an over-current fault is detected, shouldn't the mode be set back to none ? If we just clear the fault and reprogram the registers, the torch will be turned back on, and the fault will likely happen again.

Quoted 5 lines

That's a good point.

Over-temperature, over-voltage, and short circuit faults should change the LED mode to be set to none. This is likely chip independent behaviour but on the other hand, not all the chips implement all the faults.

If the chip doesn't implement faults handling there little we can do. For chips that do implement faults handling, let's switch the LED mode to none when a fault is detected.

Signature · 3 lines
Regards,

Laurent Pinchart
#9 lore raw

Re: [PATCH 3/3] adp1653: Add driver for LED flash controller

In reply to Sakari Ailus

Hi Sakari,

Quoted 10 lines · On Monday 16 May 2011 15:00:39 Sakari Ailus wrote:

This patch adds the driver for the adp1653 LED flash controller. This controller supports a high power led in flash and torch modes and an indicator light, sometimes also called privacy light.

The adp1653 is used on the Nokia N900.

[snip]

drivers/media/video/adp1653.c line 217

Quoted 4 lines
drivers/media/video/adp1653.c new file +4 -0
+	v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops,
+			  V4L2_CID_FLASH_FAULT, 0, V4L2_FLASH_FAULT_OVER_VOLTAGE
+			  | V4L2_FLASH_FAULT_OVER_TEMPERATURE
+			  | V4L2_FLASH_FAULT_SHORT_CIRCUIT, 0, 0);

You need to mark the fault control as volatile.

Signature · 3 lines
Regards,

Laurent Pinchart
#10 lore raw

Re: [PATCH 3/3] adp1653: Add driver for LED flash controller

Quoted 14 lines · Laurent Pinchart

Hi Sakari,

Quoted 10 lines · On Monday 16 May 2011 15:00:39 Sakari Ailus wrote:

This patch adds the driver for the adp1653 LED flash controller. This controller supports a high power led in flash and torch modes and an indicator light, sometimes also called privacy light.

The adp1653 is used on the Nokia N900.

Quoted 8 lines

[snip]

drivers/media/video/adp1653.c line 217

Quoted 4 lines
drivers/media/video/adp1653.c new file +4 -0
+	v4l2_ctrl_new_std(&flash->ctrls, &adp1653_ctrl_ops,
+			  V4L2_CID_FLASH_FAULT, 0, V4L2_FLASH_FAULT_OVER_VOLTAGE
+			  | V4L2_FLASH_FAULT_OVER_TEMPERATURE
+			  | V4L2_FLASH_FAULT_SHORT_CIRCUIT, 0, 0);

You need to mark the fault control as volatile.

Thanks for catching this!

I'll fix it for the pull req.

Cheers,

Signature · 2 lines
Sakari Ailus
[email protected]
#11 lore raw
In reply to Sakari Ailus
Quoted 4 lines · Sakari Ailus

Hi,

This is a patchset which implements RFC v4 of V4L2 API for flash devices [1], with minor modifications, and adds the adp1653 flash controller driver.

Replying to myself, the associated board code for the N900 isn't part of this patchset. It's are available here with the rest of the drivers:

<URL:https://www.gitorious.org/omap3camera/pages/Home>

My current intention is to fix the board code in the future with the rest of the drivers as I don't see very much use for the flash driver before the et8ek8 image sensor driver.

The patches in the patchset itself are in the rx51-002-upstream branch.

Regards,

Signature · 2 lines
Sakari Ailus
[email protected]