Re: [PATCH] media: i2c: add new driver for single string flash.

2015-06-02 Thread Sakari Ailus
Hi Daniel and Andy,

My apologies for a late answer; you can always ping me.

On Wed, Jan 21, 2015 at 10:12:05AM +0900, Daniel Jeong wrote:
 Hi.
 On Mon, 2015-01-19 at 17:25 +0900, Daniel Jeong wrote:
 This patch adds the driver for the single string flash products of TI.
 Several single string flash controllers of TI have similar register map
 and bit data. This driver supports four products,lm3556, lm3561, lm3642
 and lm3648.
 Why not to name it as lm3648 to be in align with other drivers?
 I tried to match it with the above line. I will fix it.
 
 Or even better solution (I suppose) to create a library and on top of
 that one driver per each device?
 
 Sakari, what do you think?
 Sakrai, I'd like to keep it but please let me know your opinion.

The rest of the drivers use the chip name. If you google for ti single
string flash, this patch is actually what you get as the second hit. The
first one is lm3639a spec which is not included in the above list. :-)

I'd use the chip name, e.g. lm3556.

In the future you should implement LED flash class drivers for such devices
instead, the V4L2 flash LED class wrapper gives you V4L2 flash API as well.
I think this one is good to go from that viewpoint though IMO, as the flash
API wrapper was not ready back then. Feel free to convert the driver though.

There's an additional matter to consider: lm3556 is partially supported by a
LED class drivers. Perhaps the plain LED class support could be replaced by
LED flash class support and the old driver renamed, as it'd only support a
single chip then.

 Signed-off-by: Daniel Jeong gshark.je...@gmail.com
 ---
   drivers/media/i2c/Kconfig   |9 +
   drivers/media/i2c/Makefile  |1 +
   drivers/media/i2c/ti-ss-flash.c |  744 
  +++
   include/media/ti-ss-flash.h |   33 ++
   4 files changed, 787 insertions(+)
   create mode 100644 drivers/media/i2c/ti-ss-flash.c
   create mode 100644 include/media/ti-ss-flash.h
 
 diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
 index 205d713..886c1fb 100644
 --- a/drivers/media/i2c/Kconfig
 +++ b/drivers/media/i2c/Kconfig
 @@ -638,6 +638,15 @@ config VIDEO_LM3646
   This is a driver for the lm3646 dual flash controllers. It controls
   flash, torch LEDs.
 +config VIDEO_TI_SS_FLASH
 +   tristate TI Single String Flash driver support

The list of the chip names fits here, how about putting those instead?

 +   depends on I2C  VIDEO_V4L2  MEDIA_CONTROLLER
 +   depends on MEDIA_CAMERA_SUPPORT
 +   select REGMAP_I2C
 +   ---help---
 + This is a driver for the signle string flash controllers of TI.
 + It supports LM3556, LM3561, LM3642 and LM3648.
 +
   comment Video improvement chips
   config VIDEO_UPD64031A
 diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
 index 98589001..0e523ec 100644
 --- a/drivers/media/i2c/Makefile
 +++ b/drivers/media/i2c/Makefile
 @@ -73,6 +73,7 @@ obj-$(CONFIG_VIDEO_ADP1653)   += adp1653.o
   obj-$(CONFIG_VIDEO_AS3645A)   += as3645a.o
   obj-$(CONFIG_VIDEO_LM3560)+= lm3560.o
   obj-$(CONFIG_VIDEO_LM3646)+= lm3646.o
 +obj-$(CONFIG_VIDEO_TI_SS_FLASH)+= ti-ss-flash.o
   obj-$(CONFIG_VIDEO_SMIAPP_PLL)+= smiapp-pll.o
   obj-$(CONFIG_VIDEO_AK881X)+= ak881x.o
   obj-$(CONFIG_VIDEO_IR_I2C)  += ir-kbd-i2c.o
 diff --git a/drivers/media/i2c/ti-ss-flash.c 
 b/drivers/media/i2c/ti-ss-flash.c
 new file mode 100644
 index 000..035aeba
 --- /dev/null
 +++ b/drivers/media/i2c/ti-ss-flash.c
 @@ -0,0 +1,744 @@
 +/*
 + * drivers/media/i2c/ti-ss-flash.c
 + * General device driver for Single String FLASH LED Drivers of TI
 + * It covers lm3556, lm3561, lm3642 and lm3648.
 + *
 + * Copyright (C) 2015 Texas Instruments
 + *
 + * Contact: Daniel Jeong gshark.je...@gmail.com
 + * Ldd-Mlp ldd-...@list.ti.com
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * version 2 as published by the Free Software Foundation.
 + *
 + */
 +
 +#include linux/delay.h
 +#include linux/i2c.h
 +#include linux/module.h
 +#include linux/of_device.h
 +#include linux/regmap.h
 +#include linux/slab.h
 +#include linux/videodev2.h
 +#include media/ti-ss-flash.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-device.h
 +
 +/* operation mode */
 +enum led_opmode {
 +   OPMODE_SHDN = 0x0,
 +   OPMODE_INDI_IR,
 +   OPMODE_TORCH,
 +   OPMODE_FLASH,
 +};
 +
 +/*
 + * register data
 + * @reg : register
 + * @mask : mask bits
 + * @shift : bit shift of data
 + */
 +struct ctrl_reg {
 +   unsigned int reg;
 +   unsigned int mask;
 +   unsigned int shift;
 +};
 +
 +/*
 + * unit data
 + * @min : min value of brightness or timeout
 + *brightness : uA
 + *   timeout: ms
 + * @step : step value of brightness or timeout
 + *brightness : uA
 + *   timeout: ms
 + * @knee: knee point of step of brightness/timeout
 + *

Re: [PATCH] media: i2c: add new driver for single string flash.

2015-01-20 Thread Daniel Jeong

Hi.

On Mon, 2015-01-19 at 17:25 +0900, Daniel Jeong wrote:

This patch adds the driver for the single string flash products of TI.
Several single string flash controllers of TI have similar register map
and bit data. This driver supports four products,lm3556, lm3561, lm3642
and lm3648.

Why not to name it as lm3648 to be in align with other drivers?

I tried to match it with the above line. I will fix it.


Or even better solution (I suppose) to create a library and on top of
that one driver per each device?

Sakari, what do you think?

Sakrai, I'd like to keep it but please let me know your opinion.

Signed-off-by: Daniel Jeong gshark.je...@gmail.com
---
  drivers/media/i2c/Kconfig   |9 +
  drivers/media/i2c/Makefile  |1 +
  drivers/media/i2c/ti-ss-flash.c |  744 +++
  include/media/ti-ss-flash.h |   33 ++
  4 files changed, 787 insertions(+)
  create mode 100644 drivers/media/i2c/ti-ss-flash.c
  create mode 100644 include/media/ti-ss-flash.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 205d713..886c1fb 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -638,6 +638,15 @@ config VIDEO_LM3646
  This is a driver for the lm3646 dual flash controllers. It controls
  flash, torch LEDs.
  
+config VIDEO_TI_SS_FLASH

+   tristate TI Single String Flash driver support
+   depends on I2C  VIDEO_V4L2  MEDIA_CONTROLLER
+   depends on MEDIA_CAMERA_SUPPORT
+   select REGMAP_I2C
+   ---help---
+ This is a driver for the signle string flash controllers of TI.
+ It supports LM3556, LM3561, LM3642 and LM3648.
+
  comment Video improvement chips
  
  config VIDEO_UPD64031A

diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 98589001..0e523ec 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -73,6 +73,7 @@ obj-$(CONFIG_VIDEO_ADP1653)   += adp1653.o
  obj-$(CONFIG_VIDEO_AS3645A)   += as3645a.o
  obj-$(CONFIG_VIDEO_LM3560)+= lm3560.o
  obj-$(CONFIG_VIDEO_LM3646)+= lm3646.o
+obj-$(CONFIG_VIDEO_TI_SS_FLASH)+= ti-ss-flash.o
  obj-$(CONFIG_VIDEO_SMIAPP_PLL)+= smiapp-pll.o
  obj-$(CONFIG_VIDEO_AK881X)+= ak881x.o
  obj-$(CONFIG_VIDEO_IR_I2C)  += ir-kbd-i2c.o
diff --git a/drivers/media/i2c/ti-ss-flash.c b/drivers/media/i2c/ti-ss-flash.c
new file mode 100644
index 000..035aeba
--- /dev/null
+++ b/drivers/media/i2c/ti-ss-flash.c
@@ -0,0 +1,744 @@
+/*
+ * drivers/media/i2c/ti-ss-flash.c
+ * General device driver for Single String FLASH LED Drivers of TI
+ * It covers lm3556, lm3561, lm3642 and lm3648.
+ *
+ * Copyright (C) 2015 Texas Instruments
+ *
+ * Contact: Daniel Jeong gshark.je...@gmail.com
+ * Ldd-Mlp ldd-...@list.ti.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ */
+
+#include linux/delay.h
+#include linux/i2c.h
+#include linux/module.h
+#include linux/of_device.h
+#include linux/regmap.h
+#include linux/slab.h
+#include linux/videodev2.h
+#include media/ti-ss-flash.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-device.h
+
+/* operation mode */
+enum led_opmode {
+   OPMODE_SHDN = 0x0,
+   OPMODE_INDI_IR,
+   OPMODE_TORCH,
+   OPMODE_FLASH,
+};
+
+/*
+ * register data
+ * @reg : register
+ * @mask : mask bits
+ * @shift : bit shift of data
+ */
+struct ctrl_reg {
+   unsigned int reg;
+   unsigned int mask;
+   unsigned int shift;
+};
+
+/*
+ * unit data
+ * @min : min value of brightness or timeout
+ *brightness : uA
+ *   timeout: ms
+ * @step : step value of brightness or timeout
+ *brightness : uA
+ *   timeout: ms
+ * @knee: knee point of step of brightness/timeout
+ *brightness : uA
+ *   timeout: ms
+ * @knee_step : step value of brightness or timeout after knee point
+ *brightness : uA
+ *   timeout: ms
+ * @max : max value of brightness or timeout
+ *brightness : uA
+ *   timeout: ms
+ * @ctrl : register info to control brightness or timeout
+ */
+struct ssflash_config {
+   unsigned int min;
+   unsigned int step;
+   unsigned int knee;
+   unsigned int knee_step;
+   unsigned int max;
+   struct ctrl_reg ctrl;
+};
+
+/*
+ * @reg : fault register
+ * @mask : fault mask bit
+ * @v4l2_fault : bit mapping to V4L2_FLASH_FAULT_
+ *   refer to include//uapi/linux/v4l2-controls.h
+ */
+struct ssflash_fault {
+   unsigned int reg;
+   unsigned int mask;
+   unsigned int v4l2_fault;
+};
+
+#define NUM_V4L2_FAULT 9
+
+/*
+ * ssflash data
+ * @name: device name
+ * @mode: operation mode control data
+ * @flash_br: flash brightness register and bit data
+ * @timeout: timeout control data
+ * @strobe: strobe 

[PATCH] media: i2c: add new driver for single string flash.

2015-01-19 Thread Daniel Jeong
This patch adds the driver for the single string flash products of TI.
Several single string flash controllers of TI have similar register map
and bit data. This driver supports four products,lm3556, lm3561, lm3642
and lm3648.

Signed-off-by: Daniel Jeong gshark.je...@gmail.com
---
 drivers/media/i2c/Kconfig   |9 +
 drivers/media/i2c/Makefile  |1 +
 drivers/media/i2c/ti-ss-flash.c |  744 +++
 include/media/ti-ss-flash.h |   33 ++
 4 files changed, 787 insertions(+)
 create mode 100644 drivers/media/i2c/ti-ss-flash.c
 create mode 100644 include/media/ti-ss-flash.h

diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
index 205d713..886c1fb 100644
--- a/drivers/media/i2c/Kconfig
+++ b/drivers/media/i2c/Kconfig
@@ -638,6 +638,15 @@ config VIDEO_LM3646
  This is a driver for the lm3646 dual flash controllers. It controls
  flash, torch LEDs.
 
+config VIDEO_TI_SS_FLASH
+   tristate TI Single String Flash driver support
+   depends on I2C  VIDEO_V4L2  MEDIA_CONTROLLER
+   depends on MEDIA_CAMERA_SUPPORT
+   select REGMAP_I2C
+   ---help---
+ This is a driver for the signle string flash controllers of TI.
+ It supports LM3556, LM3561, LM3642 and LM3648.
+
 comment Video improvement chips
 
 config VIDEO_UPD64031A
diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
index 98589001..0e523ec 100644
--- a/drivers/media/i2c/Makefile
+++ b/drivers/media/i2c/Makefile
@@ -73,6 +73,7 @@ obj-$(CONFIG_VIDEO_ADP1653)   += adp1653.o
 obj-$(CONFIG_VIDEO_AS3645A)+= as3645a.o
 obj-$(CONFIG_VIDEO_LM3560) += lm3560.o
 obj-$(CONFIG_VIDEO_LM3646) += lm3646.o
+obj-$(CONFIG_VIDEO_TI_SS_FLASH)+= ti-ss-flash.o
 obj-$(CONFIG_VIDEO_SMIAPP_PLL) += smiapp-pll.o
 obj-$(CONFIG_VIDEO_AK881X) += ak881x.o
 obj-$(CONFIG_VIDEO_IR_I2C)  += ir-kbd-i2c.o
diff --git a/drivers/media/i2c/ti-ss-flash.c b/drivers/media/i2c/ti-ss-flash.c
new file mode 100644
index 000..035aeba
--- /dev/null
+++ b/drivers/media/i2c/ti-ss-flash.c
@@ -0,0 +1,744 @@
+/*
+ * drivers/media/i2c/ti-ss-flash.c
+ * General device driver for Single String FLASH LED Drivers of TI
+ * It covers lm3556, lm3561, lm3642 and lm3648.
+ *
+ * Copyright (C) 2015 Texas Instruments
+ *
+ * Contact: Daniel Jeong gshark.je...@gmail.com
+ * Ldd-Mlp ldd-...@list.ti.com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * version 2 as published by the Free Software Foundation.
+ *
+ */
+
+#include linux/delay.h
+#include linux/i2c.h
+#include linux/module.h
+#include linux/of_device.h
+#include linux/regmap.h
+#include linux/slab.h
+#include linux/videodev2.h
+#include media/ti-ss-flash.h
+#include media/v4l2-ctrls.h
+#include media/v4l2-device.h
+
+/* operation mode */
+enum led_opmode {
+   OPMODE_SHDN = 0x0,
+   OPMODE_INDI_IR,
+   OPMODE_TORCH,
+   OPMODE_FLASH,
+};
+
+/*
+ * register data
+ * @reg : register
+ * @mask : mask bits
+ * @shift : bit shift of data
+ */
+struct ctrl_reg {
+   unsigned int reg;
+   unsigned int mask;
+   unsigned int shift;
+};
+
+/*
+ * unit data
+ * @min : min value of brightness or timeout
+ *brightness : uA
+ *   timeout: ms
+ * @step : step value of brightness or timeout
+ *brightness : uA
+ *   timeout: ms
+ * @knee: knee point of step of brightness/timeout
+ *brightness : uA
+ *   timeout: ms
+ * @knee_step : step value of brightness or timeout after knee point
+ *brightness : uA
+ *   timeout: ms
+ * @max : max value of brightness or timeout
+ *brightness : uA
+ *   timeout: ms
+ * @ctrl : register info to control brightness or timeout
+ */
+struct ssflash_config {
+   unsigned int min;
+   unsigned int step;
+   unsigned int knee;
+   unsigned int knee_step;
+   unsigned int max;
+   struct ctrl_reg ctrl;
+};
+
+/*
+ * @reg : fault register
+ * @mask : fault mask bit
+ * @v4l2_fault : bit mapping to V4L2_FLASH_FAULT_
+ *   refer to include//uapi/linux/v4l2-controls.h
+ */
+struct ssflash_fault {
+   unsigned int reg;
+   unsigned int mask;
+   unsigned int v4l2_fault;
+};
+
+#define NUM_V4L2_FAULT 9
+
+/*
+ * ssflash data
+ * @name: device name
+ * @mode: operation mode control data
+ * @flash_br: flash brightness register and bit data
+ * @timeout: timeout control data
+ * @strobe: strobe control data
+ * @torch_br: torch brightness register and bit data
+ * @fault: fault data
+ * @func: initialize function
+ */
+struct ssflash_data {
+   char *name;
+   struct ctrl_reg mode;
+   struct ssflash_config flash_br;
+   struct ssflash_config timeout;
+   struct ctrl_reg strobe;
+
+   struct ssflash_config torch_br;
+   struct ssflash_fault fault[NUM_V4L2_FAULT];
+
+  

Re: [PATCH] media: i2c: add new driver for single string flash.

2015-01-19 Thread Andy Shevchenko
On Mon, 2015-01-19 at 17:25 +0900, Daniel Jeong wrote:
 This patch adds the driver for the single string flash products of TI.
 Several single string flash controllers of TI have similar register map
 and bit data. This driver supports four products,lm3556, lm3561, lm3642
 and lm3648.

Why not to name it as lm3648 to be in align with other drivers?

Or even better solution (I suppose) to create a library and on top of
that one driver per each device?

Sakari, what do you think?

 
 Signed-off-by: Daniel Jeong gshark.je...@gmail.com
 ---
  drivers/media/i2c/Kconfig   |9 +
  drivers/media/i2c/Makefile  |1 +
  drivers/media/i2c/ti-ss-flash.c |  744 
 +++
  include/media/ti-ss-flash.h |   33 ++
  4 files changed, 787 insertions(+)
  create mode 100644 drivers/media/i2c/ti-ss-flash.c
  create mode 100644 include/media/ti-ss-flash.h
 
 diff --git a/drivers/media/i2c/Kconfig b/drivers/media/i2c/Kconfig
 index 205d713..886c1fb 100644
 --- a/drivers/media/i2c/Kconfig
 +++ b/drivers/media/i2c/Kconfig
 @@ -638,6 +638,15 @@ config VIDEO_LM3646
 This is a driver for the lm3646 dual flash controllers. It controls
 flash, torch LEDs.
  
 +config VIDEO_TI_SS_FLASH
 + tristate TI Single String Flash driver support
 + depends on I2C  VIDEO_V4L2  MEDIA_CONTROLLER
 + depends on MEDIA_CAMERA_SUPPORT
 + select REGMAP_I2C
 + ---help---
 +   This is a driver for the signle string flash controllers of TI.
 +   It supports LM3556, LM3561, LM3642 and LM3648.
 +
  comment Video improvement chips
  
  config VIDEO_UPD64031A
 diff --git a/drivers/media/i2c/Makefile b/drivers/media/i2c/Makefile
 index 98589001..0e523ec 100644
 --- a/drivers/media/i2c/Makefile
 +++ b/drivers/media/i2c/Makefile
 @@ -73,6 +73,7 @@ obj-$(CONFIG_VIDEO_ADP1653) += adp1653.o
  obj-$(CONFIG_VIDEO_AS3645A)  += as3645a.o
  obj-$(CONFIG_VIDEO_LM3560)   += lm3560.o
  obj-$(CONFIG_VIDEO_LM3646)   += lm3646.o
 +obj-$(CONFIG_VIDEO_TI_SS_FLASH)  += ti-ss-flash.o
  obj-$(CONFIG_VIDEO_SMIAPP_PLL)   += smiapp-pll.o
  obj-$(CONFIG_VIDEO_AK881X)   += ak881x.o
  obj-$(CONFIG_VIDEO_IR_I2C)  += ir-kbd-i2c.o
 diff --git a/drivers/media/i2c/ti-ss-flash.c b/drivers/media/i2c/ti-ss-flash.c
 new file mode 100644
 index 000..035aeba
 --- /dev/null
 +++ b/drivers/media/i2c/ti-ss-flash.c
 @@ -0,0 +1,744 @@
 +/*
 + * drivers/media/i2c/ti-ss-flash.c
 + * General device driver for Single String FLASH LED Drivers of TI
 + * It covers lm3556, lm3561, lm3642 and lm3648.
 + *
 + * Copyright (C) 2015 Texas Instruments
 + *
 + * Contact: Daniel Jeong gshark.je...@gmail.com
 + *   Ldd-Mlp ldd-...@list.ti.com
 + *
 + * This program is free software; you can redistribute it and/or
 + * modify it under the terms of the GNU General Public License
 + * version 2 as published by the Free Software Foundation.
 + *
 + */
 +
 +#include linux/delay.h
 +#include linux/i2c.h
 +#include linux/module.h
 +#include linux/of_device.h
 +#include linux/regmap.h
 +#include linux/slab.h
 +#include linux/videodev2.h
 +#include media/ti-ss-flash.h
 +#include media/v4l2-ctrls.h
 +#include media/v4l2-device.h
 +
 +/* operation mode */
 +enum led_opmode {
 + OPMODE_SHDN = 0x0,
 + OPMODE_INDI_IR,
 + OPMODE_TORCH,
 + OPMODE_FLASH,
 +};
 +
 +/*
 + * register data
 + * @reg : register
 + * @mask : mask bits
 + * @shift : bit shift of data
 + */
 +struct ctrl_reg {
 + unsigned int reg;
 + unsigned int mask;
 + unsigned int shift;
 +};
 +
 +/*
 + * unit data
 + * @min : min value of brightness or timeout
 + *brightness : uA
 + * timeout: ms
 + * @step : step value of brightness or timeout
 + *brightness : uA
 + * timeout: ms
 + * @knee: knee point of step of brightness/timeout
 + *brightness : uA
 + * timeout: ms
 + * @knee_step : step value of brightness or timeout after knee point
 + *brightness : uA
 + * timeout: ms
 + * @max : max value of brightness or timeout
 + *brightness : uA
 + * timeout: ms
 + * @ctrl : register info to control brightness or timeout
 + */
 +struct ssflash_config {
 + unsigned int min;
 + unsigned int step;
 + unsigned int knee;
 + unsigned int knee_step;
 + unsigned int max;
 + struct ctrl_reg ctrl;
 +};
 +
 +/*
 + * @reg : fault register
 + * @mask : fault mask bit
 + * @v4l2_fault : bit mapping to V4L2_FLASH_FAULT_
 + *   refer to include//uapi/linux/v4l2-controls.h
 + */
 +struct ssflash_fault {
 + unsigned int reg;
 + unsigned int mask;
 + unsigned int v4l2_fault;
 +};
 +
 +#define NUM_V4L2_FAULT 9
 +
 +/*
 + * ssflash data
 + * @name: device name
 + * @mode: operation mode control data
 + * @flash_br: flash brightness register and bit data
 + * @timeout: timeout control data
 + * @strobe: strobe control data
 + * @torch_br: torch brightness register and bit data
 + *