LED / flash API integration
Subsystems (5)
v6 cover LED / flash API integration
This is a sixth non-RFC version of LED / flash API integration series [1]. It is based on linux_next-20150427.
================
Changes since v5
================
- renamed v4l2-flash module to v4l2-flash-led-class and applied other related modifications spotted by Sakari
- fixed not released of_node reference in max77693-led driver
================
Changes since v4
================
- adapted leds-max77693 and leds-aat1290 drivers to the recent modifications in leds/common.txt bindings documentation and changed the behaviour when properties are missing
- modified DT bindings documenation for the aforementioned drivers
- removed unjustified use of goto in the leds-aat1290 driver
- fixed lack of of_node_put in leds-aat1290 driver, after parsing DT child node
- removed patch adding 'skyworks' vendor prefix, as the entry has been recently added
================
Changes since v2
================
- improved leds/common DT bindings documentation
- improved max77693-led DT documentation
- fixed validation of DT confguration for leds-max77693 by minimal values in joint iouts case
- removed trigger-type property from leds-max77693 bindings and adjusted the driver accordingly
- improved LED Flash class documentation related to v4l2-flash sub-device initialization
- excluded from leds-aat1290 DT bindings documentation the part related to handling external strobe sources
================
Changes since v1
================
- excluded exynos4-is media device related patches, as there is consenus required related to flash devices handling in media device DT bindings
- modifications around LED Flash class settings and v4l2 flash config initialization in LED Flash class drivers and v4l2-flash wrapper
- switched to using DT node name as a device name for leds-max77693 and leds-aat1290 drivers, in case DT 'label' property is absent
- dropped OF dependecy for v4l2-flash wrapper
- moved LED_FAULTS definitions from led-class-flash.h to uapi/linux/leds.h
- allowed for multiple clients of v4l2-flash sub-device
======================
Changes since RFC v13:
======================
- reduced number of patches - some of them have been merged
- slightly modified max77693-led device naming
- fixed issues in v4l2-flash helpers detected with yavta
- cleaned up AAT1290 device tree documentation
- added GPIOLIB dependecy to AAT1290 related entry in Kconfig
Thanks,
Jacek Anaszewski
[1] http://www.spinics.net/lists/kernel/msg1944538.html
Jacek Anaszewski (10):
leds: unify the location of led-trigger API
DT: Add documentation for the mfd Maxim max77693
leds: Add support for max77693 mfd flash cell
DT: Add documentation for the Skyworks AAT1290
leds: Add driver for AAT1290 flash LED controller
media: Add registration helpers for V4L2 flash sub-devices
Documentation: leds: Add description of v4l2-flash sub-device
leds: max77693: add support for V4L2 Flash sub-device
DT: aat1290: Document handling external strobe sources
leds: aat1290: add support for V4L2 Flash sub-device
.../devicetree/bindings/leds/leds-aat1290.txt | 73 ++ Documentation/devicetree/bindings/mfd/max77693.txt | 67 ++ Documentation/leds/leds-class-flash.txt | 47 + drivers/leds/Kconfig | 19 + drivers/leds/Makefile | 2 + drivers/leds/leds-aat1290.c | 577 ++++++++++ drivers/leds/leds-max77693.c | 1104 ++++++++++++++++++++ drivers/leds/leds.h | 24 - drivers/media/v4l2-core/Kconfig | 11 + drivers/media/v4l2-core/Makefile | 2 + drivers/media/v4l2-core/v4l2-flash-led-class.c | 626 +++++++++++ include/linux/leds.h | 25 + include/media/v4l2-flash-led-class.h | 145 +++ 13 files changed, 2698 insertions(+), 24 deletions(-) create mode 100644 Documentation/devicetree/bindings/leds/leds-aat1290.txt create mode 100644 drivers/leds/leds-aat1290.c create mode 100644 drivers/leds/leds-max77693.c create mode 100644 drivers/media/v4l2-core/v4l2-flash-led-class.c create mode 100644 include/media/v4l2-flash-led-class.h
Signature · 1 line
1.7.9.5
PATCH v6 1/10 leds: unify the location of led-trigger API
Part of led-trigger API was in the private drivers/leds/leds.h header. Move it to the include/linux/leds.h header to unify the API location and announce it as public. It has been already exported from led-triggers.c with EXPORT_SYMBOL_GPL macro. The no-op definitions are changed from macros to inline to match the style of the surrounding code.
--- drivers/leds/leds.h | 24 ------------------------ include/linux/leds.h | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 24 deletions(-)
drivers/leds/leds.h +0 -24
@@ -13,7 +13,6 @@#ifndef __LEDS_H_INCLUDED#define __LEDS_H_INCLUDED -#include <linux/device.h> #include <linux/rwsem.h> #include <linux/leds.h>
@@ -50,27 +49,4 @@ void led_stop_software_blink(struct led_classdev *led_cdev);extern struct rw_semaphore leds_list_lock;extern struct list_head leds_list; -#ifdef CONFIG_LEDS_TRIGGERS -void led_trigger_set_default (struct led_classdev *led_cdev); -void led_trigger_set (struct led_classdev *led_cdev, -struct led_trigger *trigger); -void led_trigger_remove (struct led_classdev *led_cdev); - -static inline void *led_get_trigger_data (struct led_classdev *led_cdev) -{ -return led_cdev->trigger_data; -} - -#else -#define led_trigger_set_default (x) do {} while (0) -#define led_trigger_set (x, y) do {} while (0) -#define led_trigger_remove (x) do {} while (0) -#define led_get_trigger_data (x) (NULL) -#endif - -ssize_t led_trigger_store (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count); -ssize_t led_trigger_show (struct device *dev,struct device_attribute *attr, -char *buf); -#endif /* __LEDS_H_INCLUDED */
include/linux/leds.h +25 -0
@@ -12,6 +12,7 @@#ifndef __LINUX_LEDS_H_INCLUDED#define __LINUX_LEDS_H_INCLUDED +#include <linux/device.h> #include <linux/list.h> #include <linux/mutex.h> #include <linux/rwsem.h>
@@ -222,6 +223,11 @@ struct led_trigger {struct list_head next_trig; }; +ssize_t led_trigger_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count); +ssize_t led_trigger_show (struct device *dev,struct device_attribute *attr, +char *buf); +/* Registration functions for complex triggers */ extern int led_trigger_register (struct led_trigger *trigger);extern void led_trigger_unregister (struct led_trigger *trigger);
@@ -238,6 +244,16 @@ extern void led_trigger_blink_oneshot(struct led_trigger *trigger,unsigned long *delay_on, unsigned long *delay_off, int invert); +extern void led_trigger_set_default (struct led_classdev *led_cdev); +extern void led_trigger_set (struct led_classdev *led_cdev, +struct led_trigger *trigger); +extern void led_trigger_remove (struct led_classdev *led_cdev); + +static inline void *led_get_trigger_data (struct led_classdev *led_cdev) +{ +return led_cdev->trigger_data; +} +/** * led_trigger_rename_static - rename a trigger * @name: the new trigger name
@@ -267,6 +283,15 @@ static inline void led_trigger_register_simple(const char *name,static inline void led_trigger_unregister_simple (struct led_trigger *trigger) {}static inline void led_trigger_event (struct led_trigger *trigger,enum led_brightness event) {} +static inline void led_trigger_set_default (struct led_classdev *led_cdev) {} +static inline void led_trigger_set (struct led_classdev *led_cdev, +struct led_trigger *trigger) {} +static inline void led_trigger_remove (struct led_classdev *led_cdev) {} +static inline void *led_get_trigger_data (struct led_classdev *led_cdev) +{ +return NULL ; +} +#endif /* CONFIG_LEDS_TRIGGERS */ /* Trigger specific functions */
Signature · 1 line
1.7.9.5
Bryan Wu
AppliedRe: [PATCH v6 01/10] leds: unify the location of led-trigger API
Quoted 10 lines · Jacek Anaszewski
Part of led-trigger API was in the private
drivers/leds/leds.hheader. Move it to theinclude/linux/leds.hheader to unify the API location and announce it as public. It has been already exported fromled-triggers.cwithEXPORT_SYMBOL_GPLmacro. The no-op definitions are changed from macros to inline to match the style of the surrounding code.Signed-off-by Jacek Anaszewski <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>Acked-by Sakari Ailus <[email protected]>
Applied, thanks,
-Bryan
Quoted 105 lines
--- drivers/leds/leds.h | 24 ------------------------ include/linux/leds.h | 25 +++++++++++++++++++++++++ 2 files changed, 25 insertions(+), 24 deletions(-)drivers/leds/leds.h +0
-24@@ -13,7 +13,6 @@#ifndef __LEDS_H_INCLUDED#define __LEDS_H_INCLUDED -#include <linux/device.h> #include <linux/rwsem.h> #include <linux/leds.h> @@ -50,27 +49,4 @@ void led_stop_software_blink(struct led_classdev *led_cdev);extern struct rw_semaphore leds_list_lock;extern struct list_head leds_list; -#ifdef CONFIG_LEDS_TRIGGERS -void led_trigger_set_default (struct led_classdev *led_cdev); -void led_trigger_set (struct led_classdev *led_cdev, -struct led_trigger *trigger); -void led_trigger_remove (struct led_classdev *led_cdev); - -static inline void *led_get_trigger_data (struct led_classdev *led_cdev) -{ -return led_cdev->trigger_data; -} - -#else -#define led_trigger_set_default (x) do {} while (0) -#define led_trigger_set (x, y) do {} while (0) -#define led_trigger_remove (x) do {} while (0) -#define led_get_trigger_data (x) (NULL) -#endif - -ssize_t led_trigger_store (struct device *dev,struct device_attribute *attr, -const char *buf,size_t count); -ssize_t led_trigger_show (struct device *dev,struct device_attribute *attr, -char *buf); -#endif /* __LEDS_H_INCLUDED */ include/linux/leds.h +25
-1@@ -12,6 +12,7 @@#ifndef __LINUX_LEDS_H_INCLUDED#define __LINUX_LEDS_H_INCLUDED +#include <linux/device.h> #include <linux/list.h> #include <linux/mutex.h> #include <linux/rwsem.h> @@ -222,6 +223,11 @@ struct led_trigger {struct list_head next_trig; }; +ssize_t led_trigger_store (struct device *dev,struct device_attribute *attr, +const char *buf,size_t count); +ssize_t led_trigger_show (struct device *dev,struct device_attribute *attr, +char *buf); +/* Registration functions for complex triggers */ extern int led_trigger_register (struct led_trigger *trigger);extern void led_trigger_unregister (struct led_trigger *trigger);@@ -238,6 +244,16 @@ extern void led_trigger_blink_oneshot(struct led_trigger *trigger,unsigned long *delay_on, unsigned long *delay_off, int invert); +extern void led_trigger_set_default (struct led_classdev *led_cdev); +extern void led_trigger_set (struct led_classdev *led_cdev, +struct led_trigger *trigger); +extern void led_trigger_remove (struct led_classdev *led_cdev); + +static inline void *led_get_trigger_data (struct led_classdev *led_cdev) +{ +return led_cdev->trigger_data; +} +/** * led_trigger_rename_static - rename a trigger * @name: the new trigger name @@ -267,6 +283,15 @@ static inline void led_trigger_register_simple(const char *name,static inline void led_trigger_unregister_simple (struct led_trigger *trigger) {}static inline void led_trigger_event (struct led_trigger *trigger,enum led_brightness event) {} +static inline void led_trigger_set_default (struct led_classdev *led_cdev) {} +static inline void led_trigger_set (struct led_classdev *led_cdev, +struct led_trigger *trigger) {} +static inline void led_trigger_remove (struct led_classdev *led_cdev) {} +static inline void *led_get_trigger_data (struct led_classdev *led_cdev) +{ +return NULL ; +} +#endif /* CONFIG_LEDS_TRIGGERS */ /* Trigger specific functions */ --1.7.9.5
PATCH v6 2/10 DT: Add documentation for the mfd Maxim max77693
In reply to Jacek AnaszewskiThis patch adds device tree binding documentation for the flash cell of the Maxim max77693 multifunctional device.
--- Documentation/devicetree/bindings/mfd/max77693.txt | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+)
Documentation/devicetree/bindings/mfd/max77693.txt +67 -0
@@ -76,7 +76,60 @@ Optional properties: Valid values: 4300000, 4700000, 4800000, 4900000 Default: 4300000 +- led : the LED submodule device node + +There are two LED outputs available - FLED1 and FLED2. Each of them can +control a separate LED or they can be connected together to double +the maximum current for a single connected LED. One LED is represented +by one child node. + +Required properties: +- compatible : Must be "maxim,max77693-led". + +Optional properties: +- maxim,boost-mode : + In boost mode the device can produce up to 1.2A of total current + on both outputs. The maximum current on each output is reduced + to 625mA then. If not enabled explicitly, boost setting defaults to + LEDS_BOOST_FIXED in case both current sources are used. + Possible values: + LEDS_BOOST_OFF (0) - no boost, + LEDS_BOOST_ADAPTIVE (1) - adaptive mode, + LEDS_BOOST_FIXED (2) - fixed mode. +- maxim,boost-mvout : Output voltage of the boost module in millivolts. + Valid values: 3300 - 5500, step by 25 (rounded down) + Default: 3300 +- maxim,mvsys-min : Low input voltage level in millivolts. Flash is not fired + if chip estimates that system voltage could drop below this level due + to flash power consumption. + Valid values: 2400 - 3400, step by 33 (rounded down) + Default: 2400 + +Required properties for the LED child node: +- led-sources : see Documentation/devicetree/bindings/leds/common.txt; + device current output identifiers: 0 - FLED1, 1 - FLED2 +- led-max-microamp : see Documentation/devicetree/bindings/leds/common.txt + Valid values for a LED connected to one FLED output: + 15625 - 250000, step by 15625 (rounded down) + Valid values for a LED connected to both FLED outputs: + 15625 - 500000, step by 15625 (rounded down) +- flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt + Valid values for a single LED connected to one FLED output + (boost mode must be turned off): + 15625 - 1000000, step by 15625 (rounded down) + Valid values for a single LED connected to both FLED outputs: + 15625 - 1250000, step by 15625 (rounded down) + Valid values for two LEDs case: + 15625 - 625000, step by 15625 (rounded down) +- flash-max-timeout-us : see Documentation/devicetree/bindings/leds/common.txt + Valid values: 62500 - 1000000, step by 62500 (rounded down) + +Optional properties for the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + Example: +#include <dt-bindings/leds/common.h> + max77693@66 { compatible = "maxim,max77693"; reg = <0x66>;
@@ -117,5 +170,19 @@ Example: maxim,thermal-regulation-celsius = <75>; maxim,battery-overcurrent-microamp = <3000000>; maxim,charge-input-threshold-microvolt = <4300000>; + + led { + compatible = "maxim,max77693-led"; + maxim,boost-mode = <LEDS_BOOST_FIXED>; + maxim,boost-mvout = <5000>; + maxim,mvsys-min = <2400>; + + camera_flash: flash-led { + label = "max77693-flash"; + led-sources = <0>, <1>; + led-max-microamp = <500000>; + flash-max-microamp = <1250000>; + flash-max-timeout-us = <1000000>; + }; }; };
Signature · 1 line
1.7.9.5
A message that is not in the archive (sent off-list or not yet received): 1430205530-20873-3-git-send-email-j.anaszewski-Sze3O3UU22JBDgjK7y7TUQ@public.gmane.org
Re: [PATCH v6 02/10] DT: Add documentation for the mfd Maxim max77693
Quoted 12 lines · Jacek Anaszewski
This patch adds device tree binding documentation for the flash cell of the Maxim max77693 multifunctional device.
Signed-off-by Jacek Anaszewski <[email protected]>Signed-off-by Andrzej Hajda <[email protected]>Acked-by Kyungmin Park <[email protected]>Cc Lee Jones <[email protected]>Cc Chanwoo Choi <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <rpurdie-Fm38FmjxZ/[email protected]>
Quoted 3 lines
--- Documentation/devicetree/bindings/mfd/max77693.txt | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+)
Requires a LED Ack.
Signature · 8 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog -- To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Bryan Wu
Acked-byRe: [PATCH v6 02/10] DT: Add documentation for the mfd Maxim max77693
Quoted 18 lines · Lee Jones
Quoted 12 lines · Jacek Anaszewski
This patch adds device tree binding documentation for the flash cell of the Maxim max77693 multifunctional device.
Signed-off-by Jacek Anaszewski <[email protected]>Signed-off-by Andrzej Hajda <[email protected]>Acked-by Kyungmin Park <[email protected]>Acked-by Sakari Ailus <[email protected]>Cc Lee Jones <[email protected]>Cc Chanwoo Choi <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>Quoted 3 lines
--- Documentation/devicetree/bindings/mfd/max77693.txt | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+)
Quoted 2 lines
Requires a LED Ack.
Please go with my Ack:
Thanks,
-Bryan
Re: [PATCH v6 02/10] DT: Add documentation for the mfd Maxim max77693
In reply to Jacek AnaszewskiQuoted 12 lines · Jacek Anaszewski
This patch adds device tree binding documentation for the flash cell of the Maxim max77693 multifunctional device.
Signed-off-by Jacek Anaszewski <[email protected]>Signed-off-by Andrzej Hajda <[email protected]>Acked-by Kyungmin Park <[email protected]>Acked-by Sakari Ailus <[email protected]>Cc Lee Jones <[email protected]>Cc Chanwoo Choi <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>
Quoted 3 lines
--- Documentation/devicetree/bindings/mfd/max77693.txt | 67 ++++++++++++++++++++ 1 file changed, 67 insertions(+)
Applied with Bryan's Ack.
Quoted 85 lines
Documentation/devicetree/bindings/mfd/max77693.txt +67
-0@@ -76,7 +76,60 @@ Optional properties: Valid values: 4300000, 4700000, 4800000, 4900000 Default: 4300000 +- led : the LED submodule device node + +There are two LED outputs available - FLED1 and FLED2. Each of them can +control a separate LED or they can be connected together to double +the maximum current for a single connected LED. One LED is represented +by one child node. + +Required properties: +- compatible : Must be "maxim,max77693-led". + +Optional properties: +- maxim,boost-mode : + In boost mode the device can produce up to 1.2A of total current + on both outputs. The maximum current on each output is reduced + to 625mA then. If not enabled explicitly, boost setting defaults to + LEDS_BOOST_FIXED in case both current sources are used. + Possible values: + LEDS_BOOST_OFF (0) - no boost, + LEDS_BOOST_ADAPTIVE (1) - adaptive mode, + LEDS_BOOST_FIXED (2) - fixed mode. +- maxim,boost-mvout : Output voltage of the boost module in millivolts. + Valid values: 3300 - 5500, step by 25 (rounded down) + Default: 3300 +- maxim,mvsys-min : Low input voltage level in millivolts. Flash is not fired + if chip estimates that system voltage could drop below this level due + to flash power consumption. + Valid values: 2400 - 3400, step by 33 (rounded down) + Default: 2400 + +Required properties for the LED child node: +- led-sources : see Documentation/devicetree/bindings/leds/common.txt; + device current output identifiers: 0 - FLED1, 1 - FLED2 +- led-max-microamp : see Documentation/devicetree/bindings/leds/common.txt + Valid values for a LED connected to one FLED output: + 15625 - 250000, step by 15625 (rounded down) + Valid values for a LED connected to both FLED outputs: + 15625 - 500000, step by 15625 (rounded down) +- flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt + Valid values for a single LED connected to one FLED output + (boost mode must be turned off): + 15625 - 1000000, step by 15625 (rounded down) + Valid values for a single LED connected to both FLED outputs: + 15625 - 1250000, step by 15625 (rounded down) + Valid values for two LEDs case: + 15625 - 625000, step by 15625 (rounded down) +- flash-max-timeout-us : see Documentation/devicetree/bindings/leds/common.txt + Valid values: 62500 - 1000000, step by 62500 (rounded down) + +Optional properties for the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + Example: +#include <dt-bindings/leds/common.h> + max77693@66 { compatible = "maxim,max77693"; reg = <0x66>;@@ -117,5 +170,19 @@ Example: maxim,thermal-regulation-celsius = <75>; maxim,battery-overcurrent-microamp = <3000000>; maxim,charge-input-threshold-microvolt = <4300000>; + + led { + compatible = "maxim,max77693-led"; + maxim,boost-mode = <LEDS_BOOST_FIXED>; + maxim,boost-mvout = <5000>; + maxim,mvsys-min = <2400>; + + camera_flash: flash-led { + label = "max77693-flash"; + led-sources = <0>, <1>; + led-max-microamp = <500000>; + flash-max-microamp = <1250000>; + flash-max-timeout-us = <1000000>; + }; }; };
Signature · 4 lines
Lee Jones Linaro STMicroelectronics Landing Team Lead Linaro.org │ Open source software for ARM SoCs Follow Linaro: Facebook | Twitter | Blog
PATCH v6 3/10 leds: Add support for max77693 mfd flash cell
In reply to Jacek AnaszewskiThis patch adds led-flash support to Maxim max77693 chipset. A device can be exposed to user space through LED subsystem sysfs interface. Device supports up to two leds which can work in flash and torch mode. The leds can be triggered externally or by software.
--- drivers/leds/Kconfig | 10 + drivers/leds/Makefile | 1 + drivers/leds/leds-max77693.c | 988 ++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 999 insertions(+) create mode 100644 drivers/leds/leds-max77693.c
drivers/leds/Kconfig +10 -0
@@ -475,6 +475,16 @@ config LEDS_TLC591XX This option enables support for Texas Instruments TLC59108 and TLC59116 LED controllers. +config LEDS_MAX77693 + tristate "LED support for MAX77693 Flash" + depends on LEDS_CLASS_FLASH + depends on MFD_MAX77693 + depends on OF + help + This option enables support for the flash part of the MAX77693 + multifunction device. It has build in control for two leds in flash + and torch mode. + config LEDS_MAX8997 tristate "LED support for MAX8997 PMIC" depends on LEDS_CLASS && MFD_MAX8997
drivers/leds/Makefile +1 -0
@@ -53,6 +53,7 @@ obj-$(CONFIG_LEDS_MC13783) += leds-mc13783.o obj-$(CONFIG_LEDS_NS2) += leds-ns2.o obj-$(CONFIG_LEDS_NETXBIG) += leds-netxbig.o obj-$(CONFIG_LEDS_ASIC3) += leds-asic3.o +obj-$(CONFIG_LEDS_MAX77693) += leds-max77693.o obj-$(CONFIG_LEDS_MAX8997) += leds-max8997.o obj-$(CONFIG_LEDS_LM355x) += leds-lm355x.o obj-$(CONFIG_LEDS_BLINKM) += leds-blinkm.o
drivers/leds/leds-max77693.c new file +988 -0
988 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v6 03/10] leds: Add support for max77693 mfd flash cell
Hi Jacek,
Quoted 6 lines · Jacek Anaszewski
This patch adds led-flash support to Maxim max77693 chipset. A device can be exposed to user space through LED subsystem sysfs interface. Device supports up to two leds which can work in flash and torch mode. The leds can be triggered externally or by software.
Quoted 7 lines
Signed-off-by Jacek Anaszewski <[email protected]>Signed-off-by Andrzej Hajda <[email protected]>Acked-by Kyungmin Park <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>Cc Lee Jones <[email protected]>Cc Chanwoo Choi <[email protected]>
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Bryan Wu
AppliedRe: [PATCH v6 03/10] leds: Add support for max77693 mfd flash cell
Quoted 17 lines · Sakari Ailus
Hi Jacek,
Quoted 6 lines · Jacek Anaszewski
This patch adds led-flash support to Maxim max77693 chipset. A device can be exposed to user space through LED subsystem sysfs interface. Device supports up to two leds which can work in flash and torch mode. The leds can be triggered externally or by software.
Quoted 7 lines
Signed-off-by Jacek Anaszewski <[email protected]>Signed-off-by Andrzej Hajda <[email protected]>Acked-by Kyungmin Park <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>Cc Lee Jones <[email protected]>Cc Chanwoo Choi <[email protected]>
Quoted 1 line
Acked-by Sakari Ailus <[email protected]>
Applied, thanks,
-Bryan
PATCH v6 4/10 DT: Add documentation for the Skyworks AAT1290
In reply to Jacek AnaszewskiThis patch adds device tree binding documentation for 1.5A Step-Up Current Regulator for Flash LEDs.
--- .../devicetree/bindings/leds/leds-aat1290.txt | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-aat1290.txt
Documentation/devicetree/bindings/leds/leds-aat1290.txt new file +41 -0
@@ -0,0 +1,41 @@ +* Skyworks Solutions, Inc. AAT1290 Current Regulator for Flash LEDs + +The device is controlled through two pins: FL_EN and EN_SET. The pins when, +asserted high, enable flash strobe and movie mode (max 1/2 of flash current) +respectively. + +Required properties: + +- compatible : Must be "skyworks,aat1290". +- flen-gpios : Must be device tree identifier of the flash device FL_EN pin. +- enset-gpios : Must be device tree identifier of the flash device EN_SET pin. + +A discrete LED element connected to the device must be represented by a child +node - see Documentation/devicetree/bindings/leds/common.txt. + +Required properties of the LED child node: +- led-max-microamp : see Documentation/devicetree/bindings/leds/common.txt +- flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt + Maximum flash LED supply current can be calculated using + following formula: I = 1A * 162kohm / Rset. +- flash-timeout-us : see Documentation/devicetree/bindings/leds/common.txt + Maximum flash timeout can be calculated using following + formula: T = 8.82 * 10^9 * Ct. + +Optional properties of the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + +Example (by Ct = 220nF, Rset = 160kohm): + +aat1290 { + compatible = "skyworks,aat1290"; + flen-gpios = <&gpj1 1 GPIO_ACTIVE_HIGH>; + enset-gpios = <&gpj1 2 GPIO_ACTIVE_HIGH>; + + camera_flash: flash-led { + label = "aat1290-flash"; + led-max-microamp = <520833>; + flash-max-microamp = <1012500>; + flash-timeout-us = <1940000>; + }; +};
Signature · 1 line
1.7.9.5
Bryan Wu
AppliedRe: [PATCH v6 04/10] DT: Add documentation for the Skyworks AAT1290
Quoted 3 lines · Jacek Anaszewski
This patch adds device tree binding documentation for 1.5A Step-Up Current Regulator for Flash LEDs.
Applied, thanks,
-Bryan
Quoted 61 lines
Signed-off-by Jacek Anaszewski <[email protected]>Acked-by Kyungmin Park <[email protected]>Acked-by Sakari Ailus <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>--- .../devicetree/bindings/leds/leds-aat1290.txt | 41 ++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 Documentation/devicetree/bindings/leds/leds-aat1290.txtDocumentation/devicetree/bindings/leds/leds-aat1290.txt new file +41
-1@@ -0,0 +1,41 @@ +* Skyworks Solutions, Inc. AAT1290 Current Regulator for Flash LEDs + +The device is controlled through two pins: FL_EN and EN_SET. The pins when, +asserted high, enable flash strobe and movie mode (max 1/2 of flash current) +respectively. + +Required properties: + +- compatible : Must be "skyworks,aat1290". +- flen-gpios : Must be device tree identifier of the flash device FL_EN pin. +- enset-gpios : Must be device tree identifier of the flash device EN_SET pin. + +A discrete LED element connected to the device must be represented by a child +node - see Documentation/devicetree/bindings/leds/common.txt. + +Required properties of the LED child node: +- led-max-microamp : see Documentation/devicetree/bindings/leds/common.txt +- flash-max-microamp : see Documentation/devicetree/bindings/leds/common.txt + Maximum flash LED supply current can be calculated using + following formula: I = 1A * 162kohm / Rset. +- flash-timeout-us : see Documentation/devicetree/bindings/leds/common.txt + Maximum flash timeout can be calculated using following + formula: T = 8.82 * 10^9 * Ct. + +Optional properties of the LED child node: +- label : see Documentation/devicetree/bindings/leds/common.txt + +Example (by Ct = 220nF, Rset = 160kohm): + +aat1290 { + compatible = "skyworks,aat1290"; + flen-gpios = <&gpj1 1 GPIO_ACTIVE_HIGH>; + enset-gpios = <&gpj1 2 GPIO_ACTIVE_HIGH>; + + camera_flash: flash-led { + label = "aat1290-flash"; + led-max-microamp = <520833>; + flash-max-microamp = <1012500>; + flash-timeout-us = <1940000>; + }; +}; --1.7.9.5
PATCH v6 5/10 leds: Add driver for AAT1290 flash LED controller
In reply to Jacek AnaszewskiThis patch adds a driver for the 1.5A Step-Up Current Regulator for Flash LEDs. The device is programmed through a Skyworks proprietary AS2Cwire serial digital interface.
--- drivers/leds/Kconfig | 8 + drivers/leds/Makefile | 1 + drivers/leds/leds-aat1290.c | 452 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 461 insertions(+) create mode 100644 drivers/leds/leds-aat1290.c
drivers/leds/Kconfig +8 -0
@@ -42,6 +42,14 @@ config LEDS_88PM860X This option enables support for on-chip LED drivers found on Marvell Semiconductor 88PM8606 PMIC. +config LEDS_AAT1290 + tristate "LED support for the AAT1290" + depends on LEDS_CLASS_FLASH + depends on GPIOLIB + depends on OF + help + This option enables support for the LEDs on the AAT1290. + config LEDS_LM3530 tristate "LCD Backlight driver for LM3530" depends on LEDS_CLASS
drivers/leds/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_LEDS_TRIGGERS) += led-triggers.o # LED Platform Drivers obj-$(CONFIG_LEDS_88PM860X) += leds-88pm860x.o +obj-$(CONFIG_LEDS_AAT1290) += leds-aat1290.o obj-$(CONFIG_LEDS_BD2802) += leds-bd2802.o obj-$(CONFIG_LEDS_LOCOMO) += leds-locomo.o obj-$(CONFIG_LEDS_LM3530) += leds-lm3530.o
drivers/leds/leds-aat1290.c new file +452 -0
452 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v6 05/10] leds: Add driver for AAT1290 flash LED controller
Quoted 9 lines · Jacek Anaszewski
This patch adds a driver for the 1.5A Step-Up Current Regulator for Flash LEDs. The device is programmed through a Skyworks proprietary AS2Cwire serial digital interface.
Signed-off-by Jacek Anaszewski <[email protected]>Acked-by Kyungmin Park <[email protected]>Acked-by Sakari Ailus <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Bryan Wu
AppliedRe: [PATCH v6 05/10] leds: Add driver for AAT1290 flash LED controller
Quoted 5 lines · Sakari Ailus
Quoted 4 lines · Jacek Anaszewski
This patch adds a driver for the 1.5A Step-Up Current Regulator for Flash LEDs. The device is programmed through a Skyworks proprietary AS2Cwire serial digital interface.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Jacek Anaszewski <[email protected]>Acked-by Kyungmin Park <[email protected]>Acked-by Sakari Ailus <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>Acked-by Sakari Ailus <[email protected]>
Applied, thanks,
-Bryan
Quoted 3 lines
--
Sakari Ailus
e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v6 05/10] leds: Add driver for AAT1290 flash LED controller
In reply to Jacek Anaszewskidrivers/leds/leds-aat1290.c line 54
Quoted 8 lines
drivers/leds/leds-aat1290.c new file +7
-0+struct aat1290_led_config_data { +/* maximum LED current in movie mode */ +u32 max_mm_current; +/* maximum LED current in flash mode */ +u32 max_flash_current; +/* maximum flash timeout */ +u32 max_flash_tm;
Ok, the comments tell us what should be already obvious from the variable names... but it would be nice to add units. (mA? uA? msec?) (I guess in subsequent patch).
Pavel
Signature · 2 lines
(english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html
PATCH v6 6/10 media: Add registration helpers for V4L2 flash sub-devices
In reply to Jacek AnaszewskiThis patch adds helper functions for registering/unregistering LED Flash class devices as V4L2 sub-devices. The functions should be called from the LED subsystem device driver. In case the support for V4L2 Flash sub-devices is disabled in the kernel config the functions' empty versions will be used.
--- drivers/media/v4l2-core/Kconfig | 11 + drivers/media/v4l2-core/Makefile | 2 + drivers/media/v4l2-core/v4l2-flash-led-class.c | 626 ++++++++++++++++++++++++ include/media/v4l2-flash-led-class.h | 145 ++++++ 4 files changed, 784 insertions(+) create mode 100644 drivers/media/v4l2-core/v4l2-flash-led-class.c create mode 100644 include/media/v4l2-flash-led-class.h
drivers/media/v4l2-core/Kconfig +11 -0
@@ -44,6 +44,17 @@ config V4L2_MEM2MEM_DEV tristate depends on VIDEOBUF2_CORE +# Used by LED subsystem flash drivers +config V4L2_FLASH_LED_CLASS + tristate "V4L2 flash API for LED flash class devices" + depends on VIDEO_V4L2_SUBDEV_API + depends on LEDS_CLASS_FLASH + ---help--- + Say Y here to enable V4L2 flash API support for LED flash + class drivers. + + When in doubt, say N. + # Used by drivers that need Videobuf modules config VIDEOBUF_GEN tristate
drivers/media/v4l2-core/Makefile +2 -0
@@ -22,6 +22,8 @@ obj-$(CONFIG_VIDEO_TUNER) += tuner.o obj-$(CONFIG_V4L2_MEM2MEM_DEV) += v4l2-mem2mem.o +obj-$(CONFIG_V4L2_FLASH_LED_CLASS) += v4l2-flash-led-class.o + obj-$(CONFIG_VIDEOBUF_GEN) += videobuf-core.o obj-$(CONFIG_VIDEOBUF_DMA_SG) += videobuf-dma-sg.o obj-$(CONFIG_VIDEOBUF_DMA_CONTIG) += videobuf-dma-contig.o
drivers/media/v4l2-core/v4l2-flash-led-class.c new file +626 -0
626 lines not on this page · raw message
include/media/v4l2-flash-led-class.h new file +145 -0
145 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v6 06/10] media: Add registration helpers for V4L2 flash sub-devices
Hi Jacek,
On Tue, Apr 28, 2015 at 09:18:46AM +0200, Jacek Anaszewski wrote:
...
Quoted 7 lines
include/media/v4l2-flash-led-class.h new file +7
-0+enum ctrl_init_data_id { +LED_MODE , +TORCH_INTENSITY , +FLASH_INTENSITY , +INDICATOR_INTENSITY , +FLASH_TIMEOUT , +STROBE_SOURCE ,
include/media/v4l2-flash-led-class.h line 39
Quoted 10 lines
include/media/v4l2-flash-led-class.h new file +10
-0+/* +* Only above values are applicable to +* the 'ctrls' array in the struct v4l2_flash. +*/ +FLASH_STROBE , +STROBE_STOP , +STROBE_STATUS , +FLASH_FAULT , + NUM_FLASH_CTRLS, +};
How about moving these to the .c file and allocating space for struct v4l2_flash.ctrls?
I don't object this enum as such, but the names are pretty generic and there's a single instance of using them in the header which easily can be avoided.
With this change,
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
PATCH v6 7/10 Documentation: leds: Add description of v4l2-flash sub-device
In reply to Jacek AnaszewskiThis patch extends LED Flash class documention by the description of interactions with v4l2-flash sub-device.
--- Documentation/leds/leds-class-flash.txt | 47 +++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+)
Documentation/leds/leds-class-flash.txt +47 -0
@@ -20,3 +20,50 @@ Following sysfs attributes are exposed for controlling flash LED devices: - max_flash_timeout - flash_strobe - flash_fault + + +V4L2 flash wrapper for flash LEDs +================================= + +A LED subsystem driver can be controlled also from the level of VideoForLinux2 +subsystem. In order to enable this CONFIG_V4L2_FLASH_LED_CLASS symbol has to +be defined in the kernel config. + +The driver must call the v4l2_flash_init function to get registered in the +V4L2 subsystem. The function takes three arguments: +- fled_cdev : the LED Flash class device to wrap +- ops : V4L2 specific ops + * external_strobe_set - defines the source of the flash LED strobe - + V4L2_CID_FLASH_STROBE control or external source, typically + a sensor, which makes it possible to synchronise the flash + strobe start with exposure start, + * intensity_to_led_brightness and led_brightness_to_intensity - perform + enum led_brightness <-> V4L2 intensity conversion in a device + specific manner - they can be used for devices with non-linear + LED current scale. +- config : configuration for V4L2 Flash sub-device + * dev_name - the name of the media entity, unique in the system, + * flash_faults - bitmask of flash faults that the LED Flash class + device can report; corresponding LED_FAULT* bit definitions are + available in <linux/led-class-flash.h>, + * intensity - constraints for the LED in the TORCH or INDICATOR mode, + in microamperes, + * has_external_strobe - determines whether the flash strobe source + can be switched to external, + * indicator_led - signifies that a led is of indicator type, which + implies that it can have only two V4L2 controls: + V4L2_CID_FLASH_INDICATOR_INTENSITY and V4L2_CID_FLASH_FAULT. + +On remove the v4l2_flash_release function has to be called, which takes one +argument - struct v4l2_flash pointer returned previously by v4l2_flash_init. + +Please refer to drivers/leds/leds-max77693.c for an exemplary usage of the +v4l2 flash API. + +Once the V4L2 sub-device is registered by the driver which created the Media +controller device, the sub-device node acts just as a node of a native V4L2 +flash API device would. The calls are simply routed to the LED flash API. + +Opening the V4L2 flash sub-device makes the LED subsystem sysfs interface +unavailable. The interface is re-enabled after the V4L2 flash sub-device +is closed.
Signature · 1 line
1.7.9.5
Re: [PATCH v6 07/10] Documentation: leds: Add description of v4l2-flash sub-device
Hi Jacek,
On Tue, Apr 28, 2015 at 09:18:47AM +0200, Jacek Anaszewski wrote:
...
Documentation/leds/leds-class-flash.txt Following sysfs attributes are exposed for controlling flash LED devices: · line 61
Quoted 5 lines
Documentation/leds/leds-class-flash.txt +5
-0+On remove the v4l2_flash_release function has to be called, which takes one +argument - struct v4l2_flash pointer returned previously by v4l2_flash_init. + +Please refer to drivers/leds/leds-max77693.c for an exemplary usage of the +v4l2 flash API.
s/v4l2 flash API/V4L2 flash wrapper/ .
Signature · 4 lines
Regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
PATCH v6 8/10 leds: max77693: add support for V4L2 Flash sub-device
In reply to Jacek AnaszewskiAdd support for V4L2 Flash sub-device to the max77693 LED Flash class driver. The support allows for V4L2 Flash sub-device to take the control of the LED Flash class device.
--- drivers/leds/leds-max77693.c | 128 ++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 122 insertions(+), 6 deletions(-)
drivers/leds/leds-max77693.c +122 -6
@@ -20,6 +20,7 @@#include <linux/regmap.h> #include <linux/slab.h> #include <linux/workqueue.h> +#include <media/v4l2-flash-led-class.h> #define MODE_OFF 0#define MODE_FLASH (a) (1 << (a))
@@ -62,6 +63,8 @@ struct max77693_sub_led {struct led_classdev_flash fled_cdev;/* assures led-triggers compatibility */ struct work_struct work_brightness_set; +/* V4L2 Flash device */ +struct v4l2_flash *v4l2_flash;/* brightness cache */ unsigned int torch_brightness;
@@ -634,7 +637,8 @@ static int max77693_led_flash_timeout_set( }static int max77693_led_parse_dt (struct max77693_led_device *led, -struct max77693_led_config_data *cfg) +struct max77693_led_config_data *cfg, +struct device_node **sub_nodes) {struct device *dev = &led->pdev->dev;struct max77693_sub_led *sub_leds = led->sub_leds;
@@ -681,6 +685,13 @@ static int max77693_led_parse_dt(struct max77693_led_device *led,return -EINVAL ; } +if (sub_nodes[fled_id]) { +dev_err (dev, +"Conflicting \"led-sources\" DT properties\n" ); +return -EINVAL ; + } + + sub_nodes[fled_id] = child_node; sub_leds[fled_id].fled_id = fled_id; cfg->label[fled_id] =
@@ -793,11 +804,12 @@ static void max77693_led_validate_configuration(struct max77693_led_device *led, }static int max77693_led_get_configuration (struct max77693_led_device *led, -struct max77693_led_config_data *cfg) +struct max77693_led_config_data *cfg, +struct device_node **sub_nodes) {int ret; - ret =max77693_led_parse_dt (led, cfg); + ret =max77693_led_parse_dt (led, cfg, sub_nodes);if (ret <0 )return ret;
@@ -845,6 +857,66 @@ static void max77693_init_flash_settings(struct max77693_sub_led *sub_led, setting->val = setting->max; } +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) + +static int max77693_led_external_strobe_set ( +struct v4l2_flash *v4l2_flash, +bool enable) +{ +struct max77693_sub_led *sub_led = +flcdev_to_sub_led (v4l2_flash->fled_cdev); +struct max77693_led_device *led =sub_led_to_led (sub_led); +int fled_id = sub_led->fled_id; +int ret; + +mutex_lock (&led->lock); + +if (enable) + ret =max77693_add_mode (led,MODE_FLASH_EXTERNAL (fled_id)); +else + ret =max77693_clear_mode (led,MODE_FLASH_EXTERNAL (fled_id)); + +mutex_unlock (&led->lock); + +return ret; +} + +static void max77693_init_v4l2_flash_config (struct max77693_sub_led *sub_led, +struct max77693_led_config_data *led_cfg, +struct v4l2_flash_config *v4l2_sd_cfg) +{ +struct max77693_led_device *led =sub_led_to_led (sub_led); +struct device *dev = &led->pdev->dev; +struct max77693_dev *iodev =dev_get_drvdata (dev->parent); +struct i2c_client *i2c = iodev->i2c; +struct led_flash_setting *s; + +snprintf (v4l2_sd_cfg->dev_name,sizeof (v4l2_sd_cfg->dev_name), +"%s %d-%04x" , sub_led->fled_cdev.led_cdev.name, +i2c_adapter_id (i2c->adapter), i2c->addr); + + s = &v4l2_sd_cfg->intensity; + s->min =TORCH_IOUT_MIN ; + s->max = sub_led->fled_cdev.led_cdev.max_brightness *TORCH_IOUT_STEP ; + s->step =TORCH_IOUT_STEP ; + s->val = s->max; + +/* Init flash faults config */ + v4l2_sd_cfg->flash_faults =LED_FAULT_OVER_VOLTAGE | +LED_FAULT_SHORT_CIRCUIT | +LED_FAULT_OVER_CURRENT ; + + v4l2_sd_cfg->has_external_strobe = true; +} + +static const struct v4l2_flash_ops v4l2_flash_ops = { + .external_strobe_set = max77693_led_external_strobe_set, +}; + +#else +#define max77693_init_v4l2_flash_config (sub_led, led_cfg, v4l2_sd_cfg) +#endif +static void max77693_init_fled_cdev (struct max77693_sub_led *sub_led,struct max77693_led_config_data *led_cfg) {
@@ -877,12 +949,49 @@ static void max77693_init_fled_cdev(struct max77693_sub_led *sub_led, sub_led->flash_timeout = fled_cdev->timeout.val; } +static int max77693_register_led (struct max77693_sub_led *sub_led, +struct max77693_led_config_data *led_cfg, +struct device_node *sub_node) +{ +struct max77693_led_device *led =sub_led_to_led (sub_led); +struct led_classdev_flash *fled_cdev = &sub_led->fled_cdev; +struct device *dev = &led->pdev->dev; +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) +struct v4l2_flash_config v4l2_sd_cfg = {}; +#endif +int ret; + +/* Register in the LED subsystem */ + ret =led_classdev_flash_register (dev, fled_cdev); +if (ret <0 ) +return ret; + +max77693_init_v4l2_flash_config (sub_led, led_cfg, &v4l2_sd_cfg); + + fled_cdev->led_cdev.dev->of_node = sub_node; + +/* Register in the V4L2 subsystem. */ + sub_led->v4l2_flash =v4l2_flash_init (fled_cdev, &v4l2_flash_ops, + &v4l2_sd_cfg); +if (IS_ERR (sub_led->v4l2_flash)) { + ret =PTR_ERR (sub_led->v4l2_flash); + goto err_v4l2_flash_init; + } + +return 0 ; + +err_v4l2_flash_init: +led_classdev_flash_unregister (fled_cdev); +return ret; +} +static int max77693_led_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct max77693_dev *iodev =dev_get_drvdata (dev->parent);struct max77693_led_device *led;struct max77693_sub_led *sub_leds; +struct device_node *sub_nodes[2 ] = {};struct max77693_led_config_data led_cfg = {};int init_fled_cdev[2 ], i, ret;
@@ -896,7 +1005,7 @@ static int max77693_led_probe(struct platform_device *pdev) sub_leds = led->sub_leds;platform_set_drvdata (pdev, led); - ret =max77693_led_get_configuration (led, &led_cfg); + ret =max77693_led_get_configuration (led, &led_cfg, sub_nodes);if (ret <0 )return ret;
@@ -918,8 +1027,12 @@ static int max77693_led_probe(struct platform_device *pdev)/* Initialize LED Flash class device */ max77693_init_fled_cdev (&sub_leds[i], &led_cfg); -/* Register LED Flash class device */ - ret =led_classdev_flash_register (dev, &sub_leds[i].fled_cdev); +/* +* Register LED Flash class device and corresponding +* V4L2 Flash device. +*/ + ret =max77693_register_led (&sub_leds[i], &led_cfg, + sub_nodes[i]);if (ret <0 ) {/* * At this moment FLED1 might have been already
@@ -938,6 +1051,7 @@ err_register_led2:/* It is possible than only FLED2 was to be registered */ if (!init_fled_cdev[FLED1 ]) goto err_register_led1; +v4l2_flash_release (sub_leds[FLED1 ].v4l2_flash);led_classdev_flash_unregister (&sub_leds[FLED1 ].fled_cdev); err_register_led1:mutex_destroy (&led->lock);
@@ -951,11 +1065,13 @@ static int max77693_led_remove(struct platform_device *pdev)struct max77693_sub_led *sub_leds = led->sub_leds;if (led->iout_joint ||max77693_fled_used (led,FLED1 )) { +v4l2_flash_release (sub_leds[FLED1 ].v4l2_flash);led_classdev_flash_unregister (&sub_leds[FLED1 ].fled_cdev);cancel_work_sync (&sub_leds[FLED1 ].work_brightness_set); }if (!led->iout_joint &&max77693_fled_used (led,FLED2 )) { +v4l2_flash_release (sub_leds[FLED2 ].v4l2_flash);led_classdev_flash_unregister (&sub_leds[FLED2 ].fled_cdev);cancel_work_sync (&sub_leds[FLED2 ].work_brightness_set); }
Signature · 1 line
1.7.9.5
Re: [PATCH v6 08/10] leds: max77693: add support for V4L2 Flash sub-device
Quoted 9 lines · Jacek Anaszewski
Add support for V4L2 Flash sub-device to the max77693 LED Flash class driver. The support allows for V4L2 Flash sub-device to take the control of the LED Flash class device.
Signed-off-by Jacek Anaszewski <[email protected]>Acked-by Kyungmin Park <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>Cc Sakari Ailus <[email protected]>
Signature · 2 lines
Sakari Ailus e-mail: [email protected] XMPP: [email protected]
PATCH v6 9/10 DT: aat1290: Document handling external strobe sources
In reply to Jacek AnaszewskiThis patch adds documentation for a pinctrl-names property. The property, when present, is used for switching the source of the strobe signal for the device.
--- .../devicetree/bindings/leds/leds-aat1290.txt | 36 ++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-)
Documentation/devicetree/bindings/leds/leds-aat1290.txt +34 -2
@@ -2,7 +2,9 @@ The device is controlled through two pins: FL_EN and EN_SET. The pins when, asserted high, enable flash strobe and movie mode (max 1/2 of flash current) -respectively. +respectively. In order to add a capability of selecting the strobe signal source +(e.g. CPU or camera sensor) there is an additional switch required, independent +of the flash chip. The switch is controlled with pin control. Required properties:
@@ -10,6 +12,13 @@ Required properties: - flen-gpios : Must be device tree identifier of the flash device FL_EN pin. - enset-gpios : Must be device tree identifier of the flash device EN_SET pin. +Optional properties: +- pinctrl-names : Must contain entries: "default", "host", "isp". Entries + "default" and "host" must refer to the same pin configuration + node, which sets the host as a strobe signal provider. Entry + "isp" must refer to the pin configuration node, which sets the + ISP as a strobe signal provider. + A discrete LED element connected to the device must be represented by a child node - see Documentation/devicetree/bindings/leds/common.txt.
@@ -25,13 +34,22 @@ Required properties of the LED child node: Optional properties of the LED child node: - label : see Documentation/devicetree/bindings/leds/common.txt -Example (by Ct = 220nF, Rset = 160kohm): +Example (by Ct = 220nF, Rset = 160kohm and exynos4412-trats2 board with +a switch that allows for routing strobe signal either from the host or from +the camera sensor): + +#include "exynos4412.dtsi" aat1290 { compatible = "skyworks,aat1290"; flen-gpios = <&gpj1 1 GPIO_ACTIVE_HIGH>; enset-gpios = <&gpj1 2 GPIO_ACTIVE_HIGH>; + pinctrl-names = "default", "host", "isp"; + pinctrl-0 = <&camera_flash_host>; + pinctrl-1 = <&camera_flash_host>; + pinctrl-2 = <&camera_flash_isp>; + camera_flash: flash-led { label = "aat1290-flash"; led-max-microamp = <520833>;
@@ -39,3 +57,17 @@ aat1290 { flash-timeout-us = <1940000>; }; }; + +&pinctrl_0 { + camera_flash_host: camera-flash-host { + samsung,pins = "gpj1-0"; + samsung,pin-function = <1>; + samsung,pin-val = <0>; + }; + + camera_flash_isp: camera-flash-isp { + samsung,pins = "gpj1-0"; + samsung,pin-function = <1>; + samsung,pin-val = <1>; + }; +};
Signature · 1 line
1.7.9.5
PATCH v6 10/10 leds: aat1290: add support for V4L2 Flash sub-device
In reply to Jacek AnaszewskiAdd support for V4L2 Flash sub-device to the aat1290 LED Flash class driver. The support allows for V4L2 Flash sub-device to take the control of the LED Flash class device.
--- drivers/leds/Kconfig | 1 + drivers/leds/leds-aat1290.c | 137 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 132 insertions(+), 6 deletions(-)
drivers/leds/Kconfig +1 -0
@@ -47,6 +47,7 @@ config LEDS_AAT1290 depends on LEDS_CLASS_FLASH depends on GPIOLIB depends on OF + depends on PINCTRL help This option enables support for the LEDs on the AAT1290.
drivers/leds/leds-aat1290.c +131 -6
237 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Re: [PATCH v6 10/10] leds: aat1290: add support for V4L2 Flash sub-device
Hi Jacek,
Quoted 250 lines · Jacek Anaszewski
Add support for V4L2 Flash sub-device to the aat1290 LED Flash class driver. The support allows for V4L2 Flash sub-device to take the control of the LED Flash class device.
Signed-off-by Jacek Anaszewski <[email protected]>Acked-by Kyungmin Park <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>Cc Sakari Ailus <[email protected]>--- drivers/leds/Kconfig | 1 + drivers/leds/leds-aat1290.c | 137 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 132 insertions(+), 6 deletions(-)drivers/leds/Kconfig +1
-0@@ -47,6 +47,7 @@ config LEDS_AAT1290 depends on LEDS_CLASS_FLASH depends on GPIOLIB depends on OF + depends on PINCTRL help This option enables support for the LEDs on the AAT1290.drivers/leds/leds-aat1290.c +115
-6@@ -17,9 +17,11 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/workqueue.h> +#include <media/v4l2-flash-led-class.h> #define AAT1290_MOVIE_MODE_CURRENT_ADDR 17#define AAT1290_MAX_MM_CURR_PERCENT_0 16@@ -52,6 +54,8 @@ struct aat1290_led_config_data {u32 max_flash_current;/* maximum flash timeout */ u32 max_flash_tm; +/* external strobe capability */ +bool has_external_strobe;/* max LED brightness level */ enum led_brightness max_brightness; };@@ -64,6 +68,8 @@ struct aat1290_led {/* corresponding LED Flash class device */ struct led_classdev_flash fled_cdev; +/* V4L2 Flash device */ +struct v4l2_flash *v4l2_flash;/* FLEN pin */ struct gpio_desc *gpio_fl_en;@@ -230,11 +236,15 @@ static int aat1290_led_flash_timeout_set(struct led_classdev_flash *fled_cdev, }static int aat1290_led_parse_dt (struct aat1290_led *led, -struct aat1290_led_config_data *cfg) +struct aat1290_led_config_data *cfg, +struct device_node **sub_node) {struct led_classdev *led_cdev = &led->fled_cdev.led_cdev;struct device *dev = &led->pdev->dev;struct device_node *child_node; +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) +struct pinctrl *pinctrl; +#endif int ret =0 ; led->gpio_fl_en =devm_gpiod_get (dev,"flen" );@@ -251,6 +261,17 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,return ret; } +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) + pinctrl =devm_pinctrl_get_select_default (&led->pdev->dev); +if (IS_ERR (pinctrl)) { + cfg->has_external_strobe = false; +dev_info (dev, +"No support for external strobe detected.\n" ); + }else { + cfg->has_external_strobe = true; + } +#endif + child_node =of_get_next_available_child (dev->of_node,NULL );if (!child_node) {dev_err (dev,"No DT child node found for connected LED.\n" );@@ -288,6 +309,8 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,of_node_put (child_node); + *sub_node = child_node; +return ret; }@@ -316,7 +339,8 @@ int init_mm_current_scale(struct aat1290_led *led,int i, max_mm_current =AAT1290_MAX_MM_CURRENT (cfg->max_flash_current); - led->mm_current_scale =kzalloc (sizeof (max_mm_current_percent), + led->mm_current_scale =devm_kzalloc (&led->pdev->dev, +sizeof (max_mm_current_percent),GFP_KERNEL );if (!led->mm_current_scale)return -ENOMEM ;@@ -329,11 +353,12 @@ int init_mm_current_scale(struct aat1290_led *led, }static int aat1290_led_get_configuration (struct aat1290_led *led, -struct aat1290_led_config_data *cfg) +struct aat1290_led_config_data *cfg, +struct device_node **sub_node) {int ret; - ret =aat1290_led_parse_dt (led, cfg); + ret =aat1290_led_parse_dt (led, cfg, sub_node);if (ret <0 )return ret;/* @@ -346,7 +371,10 @@ static int aat1290_led_get_configuration(struct aat1290_led *led,aat1290_led_validate_mm_current (led, cfg); -kfree (led->mm_current_scale); +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) +#else +devm_kfree (&led->pdev->dev, led->mm_current_scale); +#endif return 0 ; }@@ -365,6 +393,83 @@ static void aat1290_init_flash_timeout(struct aat1290_led *led, setting->val = setting->max; } +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) +enum led_brightness aat1290_intensity_to_brightness ( +struct v4l2_flash *v4l2_flash, +s32 intensity) +{ +struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; +struct aat1290_led *led =fled_cdev_to_led (fled_cdev); +int i; + +for (i =AAT1290_MM_CURRENT_SCALE_SIZE -1 ; i >=0 ; --i) +if (intensity >= led->mm_current_scale[i]) +return i +1 ; + +return 1 ; +} + +s32 aat1290_brightness_to_intensity (struct v4l2_flash *v4l2_flash, +enum led_brightness brightness) +{ +struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; +struct aat1290_led *led =fled_cdev_to_led (fled_cdev); + +return led->mm_current_scale[brightness -1 ]; +} + +static int aat1290_led_external_strobe_set (struct v4l2_flash *v4l2_flash, +bool enable) +{ +struct aat1290_led *led =fled_cdev_to_led (v4l2_flash->fled_cdev); +struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; +struct led_classdev *led_cdev = &fled_cdev->led_cdev; +struct pinctrl *pinctrl; + +gpiod_direction_output (led->gpio_fl_en,0 ); +gpiod_direction_output (led->gpio_en_set,0 ); + + led->movie_mode = false; + led_cdev->brightness =0 ; + + pinctrl =devm_pinctrl_get_select (&led->pdev->dev, + enable ?"isp" :"host" ); +if (IS_ERR (pinctrl)) { +dev_warn (&led->pdev->dev,"Unable to switch strobe source.\n" ); +return PTR_ERR (pinctrl); + } + +return 0 ; +} + +static void aat1290_init_v4l2_flash_config (struct aat1290_led *led, +struct aat1290_led_config_data *led_cfg, +struct v4l2_flash_config *v4l2_sd_cfg) +{ +struct led_classdev *led_cdev = &led->fled_cdev.led_cdev; +struct led_flash_setting *s; + +strlcpy (v4l2_sd_cfg->dev_name, led_cdev->name, +sizeof (v4l2_sd_cfg->dev_name)); + + s = &v4l2_sd_cfg->intensity; + s->min = led->mm_current_scale[0 ]; + s->max = led_cfg->max_mm_current; + s->step =1 ; + s->val = s->max; + + v4l2_sd_cfg->has_external_strobe = led_cfg->has_external_strobe; +} + +static const struct v4l2_flash_ops v4l2_flash_ops = { + .external_strobe_set = aat1290_led_external_strobe_set, + .intensity_to_led_brightness = aat1290_intensity_to_brightness, + .led_brightness_to_intensity = aat1290_brightness_to_intensity, +}; +#else +#define aat1290_init_v4l2_flash_config (led, led_cfg, v4l2_sd_cfg) +#endif +static const struct led_flash_ops flash_ops = { .strobe_set = aat1290_led_flash_strobe_set, .timeout_set = aat1290_led_flash_timeout_set,@@ -373,10 +478,14 @@ static const struct led_flash_ops flash_ops = {static int aat1290_led_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +struct device_node *sub_node =NULL ;struct aat1290_led *led;struct led_classdev *led_cdev;struct led_classdev_flash *fled_cdev;struct aat1290_led_config_data led_cfg = {}; +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) +struct v4l2_flash_config v4l2_sd_cfg = {}; +#endif int ret; led =devm_kzalloc (dev,sizeof (*led),GFP_KERNEL );@@ -390,7 +499,7 @@ static int aat1290_led_probe(struct platform_device *pdev) fled_cdev->ops = &flash_ops; led_cdev = &fled_cdev->led_cdev; - ret =aat1290_led_get_configuration (led, &led_cfg); + ret =aat1290_led_get_configuration (led, &led_cfg, &sub_node);if (ret <0 )return ret;
drivers/leds/leds-aat1290.c static int aat1290_led_probe(struct platform_device *pdev) · line 524
Quoted 6 lines
drivers/leds/leds-aat1290.c +3
-0@@ -410,8 +519,23 @@ static int aat1290_led_probe(struct platform_device *pdev)if (ret <0 ) goto err_flash_register; +aat1290_init_v4l2_flash_config (led, &led_cfg, &v4l2_sd_cfg); + + led_cdev->dev->of_node = sub_node;
What's the reason for this? I can't immediately see how this is being used.
There's also a problem with references, you should grab it here and release when it's no longer used.
Quoted 25 lines
drivers/leds/leds-aat1290.c +13
-0+ +/* Create V4L2 Flash subdev. */ + led->v4l2_flash =v4l2_flash_init (fled_cdev, + &v4l2_flash_ops, + &v4l2_sd_cfg); +if (IS_ERR (led->v4l2_flash)) { + ret =PTR_ERR (led->v4l2_flash); + goto error_v4l2_flash_init; + } +return 0 ; +error_v4l2_flash_init: +led_classdev_flash_unregister (fled_cdev); err_flash_register:mutex_destroy (&led->lock);@@ -422,6 +546,7 @@ static int aat1290_led_remove(struct platform_device *pdev) {struct aat1290_led *led =platform_get_drvdata (pdev); +v4l2_flash_release (led->v4l2_flash);led_classdev_flash_unregister (&led->fled_cdev);cancel_work_sync (&led->work_brightness_set);
Signature · 4 lines
Kind regards, Sakari Ailus e-mail: [email protected] XMPP: [email protected]
Re: [PATCH v6 10/10] leds: aat1290: add support for V4L2 Flash sub-device
Hi Sakari,
Quoted 256 lines · Sakari Ailus
Hi Jacek,
Quoted 253 lines · Jacek Anaszewski
Add support for V4L2 Flash sub-device to the aat1290 LED Flash class driver. The support allows for V4L2 Flash sub-device to take the control of the LED Flash class device.
Signed-off-by Jacek Anaszewski <[email protected]>Acked-by Kyungmin Park <[email protected]>Cc Bryan Wu <[email protected]>Cc Richard Purdie <[email protected]>Cc Sakari Ailus <[email protected]>--- drivers/leds/Kconfig | 1 + drivers/leds/leds-aat1290.c | 137 +++++++++++++++++++++++++++++++++++++++++-- 2 files changed, 132 insertions(+), 6 deletions(-)drivers/leds/Kconfig +1
-0@@ -47,6 +47,7 @@ config LEDS_AAT1290 depends on LEDS_CLASS_FLASH depends on GPIOLIB depends on OF + depends on PINCTRL help This option enables support for the LEDs on the AAT1290.drivers/leds/leds-aat1290.c +115
-6@@ -17,9 +17,11 @@#include <linux/module.h> #include <linux/mutex.h> #include <linux/of.h> +#include <linux/pinctrl/consumer.h> #include <linux/platform_device.h> #include <linux/slab.h> #include <linux/workqueue.h> +#include <media/v4l2-flash-led-class.h> #define AAT1290_MOVIE_MODE_CURRENT_ADDR 17#define AAT1290_MAX_MM_CURR_PERCENT_0 16@@ -52,6 +54,8 @@ struct aat1290_led_config_data {u32 max_flash_current;/* maximum flash timeout */ u32 max_flash_tm; +/* external strobe capability */ +bool has_external_strobe;/* max LED brightness level */ enum led_brightness max_brightness; };@@ -64,6 +68,8 @@ struct aat1290_led {/* corresponding LED Flash class device */ struct led_classdev_flash fled_cdev; +/* V4L2 Flash device */ +struct v4l2_flash *v4l2_flash;/* FLEN pin */ struct gpio_desc *gpio_fl_en;@@ -230,11 +236,15 @@ static int aat1290_led_flash_timeout_set(struct led_classdev_flash *fled_cdev, }static int aat1290_led_parse_dt (struct aat1290_led *led, -struct aat1290_led_config_data *cfg) +struct aat1290_led_config_data *cfg, +struct device_node **sub_node) {struct led_classdev *led_cdev = &led->fled_cdev.led_cdev;struct device *dev = &led->pdev->dev;struct device_node *child_node; +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) +struct pinctrl *pinctrl; +#endif int ret =0 ; led->gpio_fl_en =devm_gpiod_get (dev,"flen" );@@ -251,6 +261,17 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,return ret; } +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) + pinctrl =devm_pinctrl_get_select_default (&led->pdev->dev); +if (IS_ERR (pinctrl)) { + cfg->has_external_strobe = false; +dev_info (dev, +"No support for external strobe detected.\n" ); + }else { + cfg->has_external_strobe = true; + } +#endif + child_node =of_get_next_available_child (dev->of_node,NULL );if (!child_node) {dev_err (dev,"No DT child node found for connected LED.\n" );@@ -288,6 +309,8 @@ static int aat1290_led_parse_dt(struct aat1290_led *led,of_node_put (child_node); + *sub_node = child_node; +return ret; }@@ -316,7 +339,8 @@ int init_mm_current_scale(struct aat1290_led *led,int i, max_mm_current =AAT1290_MAX_MM_CURRENT (cfg->max_flash_current); - led->mm_current_scale =kzalloc (sizeof (max_mm_current_percent), + led->mm_current_scale =devm_kzalloc (&led->pdev->dev, +sizeof (max_mm_current_percent),GFP_KERNEL );if (!led->mm_current_scale)return -ENOMEM ;@@ -329,11 +353,12 @@ int init_mm_current_scale(struct aat1290_led *led, }static int aat1290_led_get_configuration (struct aat1290_led *led, -struct aat1290_led_config_data *cfg) +struct aat1290_led_config_data *cfg, +struct device_node **sub_node) {int ret; - ret =aat1290_led_parse_dt (led, cfg); + ret =aat1290_led_parse_dt (led, cfg, sub_node);if (ret <0 )return ret;/* @@ -346,7 +371,10 @@ static int aat1290_led_get_configuration(struct aat1290_led *led,aat1290_led_validate_mm_current (led, cfg); -kfree (led->mm_current_scale); +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) +#else +devm_kfree (&led->pdev->dev, led->mm_current_scale); +#endif return 0 ; }@@ -365,6 +393,83 @@ static void aat1290_init_flash_timeout(struct aat1290_led *led, setting->val = setting->max; } +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) +enum led_brightness aat1290_intensity_to_brightness ( +struct v4l2_flash *v4l2_flash, +s32 intensity) +{ +struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; +struct aat1290_led *led =fled_cdev_to_led (fled_cdev); +int i; + +for (i =AAT1290_MM_CURRENT_SCALE_SIZE -1 ; i >=0 ; --i) +if (intensity >= led->mm_current_scale[i]) +return i +1 ; + +return 1 ; +} + +s32 aat1290_brightness_to_intensity (struct v4l2_flash *v4l2_flash, +enum led_brightness brightness) +{ +struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; +struct aat1290_led *led =fled_cdev_to_led (fled_cdev); + +return led->mm_current_scale[brightness -1 ]; +} + +static int aat1290_led_external_strobe_set (struct v4l2_flash *v4l2_flash, +bool enable) +{ +struct aat1290_led *led =fled_cdev_to_led (v4l2_flash->fled_cdev); +struct led_classdev_flash *fled_cdev = v4l2_flash->fled_cdev; +struct led_classdev *led_cdev = &fled_cdev->led_cdev; +struct pinctrl *pinctrl; + +gpiod_direction_output (led->gpio_fl_en,0 ); +gpiod_direction_output (led->gpio_en_set,0 ); + + led->movie_mode = false; + led_cdev->brightness =0 ; + + pinctrl =devm_pinctrl_get_select (&led->pdev->dev, + enable ?"isp" :"host" ); +if (IS_ERR (pinctrl)) { +dev_warn (&led->pdev->dev,"Unable to switch strobe source.\n" ); +return PTR_ERR (pinctrl); + } + +return 0 ; +} + +static void aat1290_init_v4l2_flash_config (struct aat1290_led *led, +struct aat1290_led_config_data *led_cfg, +struct v4l2_flash_config *v4l2_sd_cfg) +{ +struct led_classdev *led_cdev = &led->fled_cdev.led_cdev; +struct led_flash_setting *s; + +strlcpy (v4l2_sd_cfg->dev_name, led_cdev->name, +sizeof (v4l2_sd_cfg->dev_name)); + + s = &v4l2_sd_cfg->intensity; + s->min = led->mm_current_scale[0 ]; + s->max = led_cfg->max_mm_current; + s->step =1 ; + s->val = s->max; + + v4l2_sd_cfg->has_external_strobe = led_cfg->has_external_strobe; +} + +static const struct v4l2_flash_ops v4l2_flash_ops = { + .external_strobe_set = aat1290_led_external_strobe_set, + .intensity_to_led_brightness = aat1290_intensity_to_brightness, + .led_brightness_to_intensity = aat1290_brightness_to_intensity, +}; +#else +#define aat1290_init_v4l2_flash_config (led, led_cfg, v4l2_sd_cfg) +#endif +static const struct led_flash_ops flash_ops = { .strobe_set = aat1290_led_flash_strobe_set, .timeout_set = aat1290_led_flash_timeout_set,@@ -373,10 +478,14 @@ static const struct led_flash_ops flash_ops = {static int aat1290_led_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev; +struct device_node *sub_node =NULL ;struct aat1290_led *led;struct led_classdev *led_cdev;struct led_classdev_flash *fled_cdev;struct aat1290_led_config_data led_cfg = {}; +#if IS_ENABLED (CONFIG_V4L2_FLASH_LED_CLASS ) +struct v4l2_flash_config v4l2_sd_cfg = {}; +#endif int ret; led =devm_kzalloc (dev,sizeof (*led),GFP_KERNEL );@@ -390,7 +499,7 @@ static int aat1290_led_probe(struct platform_device *pdev) fled_cdev->ops = &flash_ops; led_cdev = &fled_cdev->led_cdev; - ret =aat1290_led_get_configuration (led, &led_cfg); + ret =aat1290_led_get_configuration (led, &led_cfg, &sub_node);if (ret <0 )return ret;@@ -410,8 +519,23 @@ static int aat1290_led_probe(struct platform_device *pdev)if (ret <0 ) goto err_flash_register;
Quoted 5 lines
drivers/leds/leds-aat1290.c static int aat1290_led_probe(struct platform_device *pdev) · line 524
Quoted 3 lines
drivers/leds/leds-aat1290.c +3
-0+aat1290_init_v4l2_flash_config (led, &led_cfg, &v4l2_sd_cfg); + + led_cdev->dev->of_node = sub_node;What's the reason for this? I can't immediately see how this is being used.
The of_node is used for async sub-device registration. There is a call made in v4l2_sync_belongs:
match(sd->dev, asd).
In this case match_of is used which does the comparison:dev->of_node == asd->match.of.node.
In v4l2_flash_init an assignment is made: sd->dev = led_cdev->dev
Quoted 2 lines
There's also a problem with references, you should grab it here and release when it's no longer used.
The reference is grabbed in v4l2_flash_init.
Quoted 26 lines
Quoted 25 lines
drivers/leds/leds-aat1290.c +13
-0+ +/* Create V4L2 Flash subdev. */ + led->v4l2_flash =v4l2_flash_init (fled_cdev, + &v4l2_flash_ops, + &v4l2_sd_cfg); +if (IS_ERR (led->v4l2_flash)) { + ret =PTR_ERR (led->v4l2_flash); + goto error_v4l2_flash_init; + } +return 0 ; +error_v4l2_flash_init: +led_classdev_flash_unregister (fled_cdev); err_flash_register:mutex_destroy (&led->lock);@@ -422,6 +546,7 @@ static int aat1290_led_remove(struct platform_device *pdev) {struct aat1290_led *led =platform_get_drvdata (pdev); +v4l2_flash_release (led->v4l2_flash);led_classdev_flash_unregister (&led->fled_cdev);cancel_work_sync (&led->work_brightness_set);
Signature · 2 lines
Best Regards, Jacek Anaszewski