Skip to contentSkip to conversation

media: vimc: fla: Add virtual flash subdevice

PATCH Superseded Lucas A. M. Magalhães 1 participant 1 message Oct 7, 2019 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 media: vimc: fla: Add virtual flash subdevice

From: Lucas A. M. Magalhaes <[email protected]>

Add a virtual subdevice to simulate the flash control API. Those are the supported controls:
v4l2-ctl -d /dev/v4l-subdev6 -L
Flash Controls

                       led_mode 0x009c0901 (menu)   : min=0 max=2 default=1 value=1
                                0: Off
                                1: Flash
                                2: Torch
                  strobe_source 0x009c0902 (menu)   : min=0 max=1 default=0 value=0
                                0: Software
                                1: External
                         strobe 0x009c0903 (button) : flags=write-only, execute-on-write
                    stop_strobe 0x009c0904 (button) : flags=write-only, execute-on-write
                  strobe_status 0x009c0905 (bool)   : default=0 value=0 flags=read-only
                 strobe_timeout 0x009c0906 (int)    : min=50 max=400 step=50 default=50 value=400
           intensity_flash_mode 0x009c0907 (int)    : min=23040 max=1499600 step=11718 default=23040 value=23040
           intensity_torch_mode 0x009c0908 (int)    : min=2530 max=187100 step=1460 default=2530 value=2530
            intensity_indicator 0x009c0909 (int)    : min=0 max=255 step=1 default=0 value=0
                         faults 0x009c090a (bitmask): max=0x00000002 default=0x00000000 value=0x00000000

---
Hi,

I've copied some values from another driver (lm3646) to make it more realistic, as suggested by Hans. All values except for V4L2_CID_FLASH_INDICATOR_INTENSITY, which I couldn't find any implementation.

The v4l-compliance is failing. From the documentation V4L2_CID_FLASH_STROBE should just work if the V4L2_CID_FLASH_STROBE_SOURCE is "Software" and the V4L2_CID_FLASH_LED_MODE is "Flash", otherwise it should fail. With the standard values configured for the V4L2_CID_FLASH_STROBE will not fail. But during the tests v4l-compliance sets V4L2_CID_FLASH_LED_MODE to "Torch" and V4L2_CID_FLASH_STROBE_SOURCE to "External" which makes V4L2_CID_FLASH_STROBE to fail. How do I proceed? Should the v4l-compliance be changed?

Changes in v3:
- Fix style errors
- Use more realistic numbers for the controllers
- Change from kthread to workqueue
- Change commit message for the new controllers values

Changes in v2:
- Fix v4l2-complience errors
- Add V4L2_CID_FLASH_STROBE_STATUS behavior
- Add V4L2_CID_FLASH_STROBE restrictions
- Remove vimc_fla_g_volatile_ctrl
- Remove unnecessarie V4L2_CID_FLASH_CLASS
- Change varables names

 drivers/media/platform/vimc/Makefile      |   2 +-
 drivers/media/platform/vimc/vimc-common.c |   2 +
 drivers/media/platform/vimc/vimc-common.h |   4 +
 drivers/media/platform/vimc/vimc-core.c   |   5 +
 drivers/media/platform/vimc/vimc-flash.c  | 248 ++++++++++++++++++++++
 5 files changed, 260 insertions(+), 1 deletion(-)
 create mode 100644 drivers/media/platform/vimc/vimc-flash.c
drivers/media/platform/vimc/Makefile +1 -1
index a53b2b532e9f..e759bbb04b14 100644
@@ -1,6 +1,6 @@
 # SPDX-License-Identifier: GPL-2.0
 vimc-y := vimc-core.o vimc-common.o vimc-streamer.o vimc-capture.o \
-		vimc-debayer.o vimc-scaler.o vimc-sensor.o
+		vimc-debayer.o vimc-scaler.o vimc-sensor.o vimc-flash.o
 
 obj-$(CONFIG_VIDEO_VIMC) += vimc.o
 
drivers/media/platform/vimc/vimc-common.c +2 -0
index a3120f4f7a90..cb786de75573 100644
@@ -203,6 +203,8 @@ struct media_pad *vimc_pads_init(u16 num_pads, const unsigned long *pads_flag)
 	struct media_pad *pads;
 	unsigned int i;
 
+	if (!num_pads)
+		return NULL;
 	/* Allocate memory for the pads */
 	pads = kcalloc(num_pads, sizeof(*pads), GFP_KERNEL);
 	if (!pads)
drivers/media/platform/vimc/vimc-common.h +4 -0
index 698db7c07645..19815f0f4d40 100644
@@ -169,6 +169,10 @@ struct vimc_ent_device *vimc_sen_add(struct vimc_device *vimc,
 				     const char *vcfg_name);
 void vimc_sen_rm(struct vimc_device *vimc, struct vimc_ent_device *ved);
 
+struct vimc_ent_device *vimc_fla_add(struct vimc_device *vimc,
+				     const char *vcfg_name);
+void vimc_fla_rm(struct vimc_device *vimc, struct vimc_ent_device *ved);
+
 /**
  * vimc_pads_init - initialize pads
  *
drivers/media/platform/vimc/vimc-core.c +5 -0
index 6e3e5c91ae39..5f6c750d3d8d 100644
@@ -91,6 +91,11 @@ static struct vimc_ent_config ent_config[] = {
 		.add = vimc_cap_add,
 		.rm = vimc_cap_rm,
 	},
+	{
+		.name = "Flash Controller",
+		.add = vimc_fla_add,
+		.rm = vimc_fla_rm,
+	}
 };
 
 static const struct vimc_ent_link ent_links[] = {
drivers/media/platform/vimc/vimc-flash.c new file +248 -0

248 lines not on this page · raw message

Signature · 1 line
2.23.0