Re: [PATCH v10.1] leds: aat1290: add support for V4L2 Flash sub-device
On Fri, Jun 19, 2015 at 09:33:22AM +0200, Jacek Anaszewski wrote: > 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 > Acked-by: Kyungmin Park > Cc: Bryan Wu > Cc: Richard Purdie > Cc: Sakari Ailus Acked-by: Sakari Ailus -- Sakari Ailus e-mail: sakari.ai...@iki.fi XMPP: sai...@retiisi.org.uk -- To unsubscribe from this list: send the line "unsubscribe linux-media" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v10.1] leds: aat1290: add support for V4L2 Flash sub-device
On Fri, Jun 19, 2015 at 12:33 AM, Jacek Anaszewski wrote: > 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. > I used this one to replace the old one. -Bryan > Signed-off-by: Jacek Anaszewski > Acked-by: Kyungmin Park > Cc: Bryan Wu > Cc: Richard Purdie > Cc: Sakari Ailus > --- > - fixed sparse warnings by adding 'static' modifiers to the functions: > * aat1290_intensity_to_brightness > * aat1290_brightness_to_intensity > > drivers/leds/Kconfig|1 + > drivers/leds/leds-aat1290.c | 137 > +-- > 2 files changed, 132 insertions(+), 6 deletions(-) > > diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig > index 14876d3..a1013c5 100644 > --- a/drivers/leds/Kconfig > +++ b/drivers/leds/Kconfig > @@ -44,6 +44,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. > > diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c > index b055882..2a5254c 100644 > --- a/drivers/leds/leds-aat1290.c > +++ b/drivers/leds/leds-aat1290.c > @@ -17,9 +17,11 @@ > #include > #include > #include > +#include > #include > #include > #include > +#include > > #define AAT1290_MOVIE_MODE_CURRENT_ADDR17 > #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", GPIOD_ASIS); > @@ -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 @@ static 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 @@ static 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_cu
[PATCH v10.1] leds: aat1290: add support for V4L2 Flash sub-device
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 Acked-by: Kyungmin Park Cc: Bryan Wu Cc: Richard Purdie Cc: Sakari Ailus --- - fixed sparse warnings by adding 'static' modifiers to the functions: * aat1290_intensity_to_brightness * aat1290_brightness_to_intensity drivers/leds/Kconfig|1 + drivers/leds/leds-aat1290.c | 137 +-- 2 files changed, 132 insertions(+), 6 deletions(-) diff --git a/drivers/leds/Kconfig b/drivers/leds/Kconfig index 14876d3..a1013c5 100644 --- a/drivers/leds/Kconfig +++ b/drivers/leds/Kconfig @@ -44,6 +44,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. diff --git a/drivers/leds/leds-aat1290.c b/drivers/leds/leds-aat1290.c index b055882..2a5254c 100644 --- a/drivers/leds/leds-aat1290.c +++ b/drivers/leds/leds-aat1290.c @@ -17,9 +17,11 @@ #include #include #include +#include #include #include #include +#include #define AAT1290_MOVIE_MODE_CURRENT_ADDR17 #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", GPIOD_ASIS); @@ -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 @@ static 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 @@ static 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,88 @@ static void aat1290_init_flash_timeout(struct aat1290_led *led, setting->val = setting->max; } +#if IS_ENABLED(CONFIG_V4L2_FLA