You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by je...@apache.org on 2024/03/11 14:44:46 UTC
(nuttx) branch master updated (47026978bf -> bac0228825)
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
from 47026978bf libs/libc/string: fix memmem() boundary case when needle is at end of haystack
new 75a0a08a4d drivers/video: Modify control id definition
new f1bc6aada3 drivers/video/isx019: Fix supported ISO sensitivity
new fdf9f00952 drivers/video/isx012: Fix control type of some parameters
new dc82022769 drivers/video/isx019: Fix control type of some parameters
new 76e91a69f7 drivers/video/isx019: Fix maximum value of exposure time
new 33f7923d72 drivers/video/isx019: Fix bug that initial exposure time is not correct
new fd5c2d4922 drivers/video/isx019: Fix bug that read value is not correct
new 865c88e34b drivers/video: Add elems setting
new de3bee313e drivers/video/isx019: Fix control type about some parameters
new 8f0ed67339 drivers/video/isx019: Fix mismatch bug of HUE value
new ae970a8ed3 drivers/video: Fix bug that can not use scene mode
new 2b04210b16 drivers/video/isx019: Fix default ISO sensitivity
new baa2dc5cad drivers/video/isx019: Store initial gamma value
new 3419f018a4 drivers/video/isx019: Delete unnecessary code
new bac0228825 drivers/video/isx012: Fix buffer overrun of isx012_putreg()
The 15 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
drivers/video/isx012.c | 20 +-
drivers/video/isx019.c | 392 +++++++++++++++++++++++++----------
drivers/video/isx019_range.h | 2 +-
drivers/video/video.c | 81 ++++----
include/nuttx/video/imgsensor.h | 86 ++++----
include/nuttx/video/video_controls.h | 142 +++++++------
include/sys/videoio.h | 6 +-
7 files changed, 462 insertions(+), 267 deletions(-)
(nuttx) 10/15: drivers/video/isx019: Fix mismatch bug of HUE value
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 8f0ed67339305e3d0c9f1fe11b9f0372b371c4cb
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Mon Jan 22 14:04:11 2024 +0900
drivers/video/isx019: Fix mismatch bug of HUE value
Because the ratio between API value and ISX019 register value
is 128 : 90 about HUE, some different API values become the
same register value.
So, store the value specified by application in setting,
and return the stored value in getting so that the gotten value
is the same as the setting value by application.
---
drivers/video/isx019.c | 60 +++++++++++++++++++++++++++++++++++++-------------
1 file changed, 45 insertions(+), 15 deletions(-)
diff --git a/drivers/video/isx019.c b/drivers/video/isx019.c
index 07081bb3d8..e767eee8ec 100644
--- a/drivers/video/isx019.c
+++ b/drivers/video/isx019.c
@@ -236,6 +236,7 @@ struct isx019_dev_s
isx019_rect_t clip_still;
double gamma;
int32_t jpg_quality;
+ int32_t hue;
imgsensor_colorfx_t colorfx;
};
@@ -1403,6 +1404,10 @@ static int isx019_init(FAR struct imgsensor_s *sensor)
priv->clock_ratio = (float)clk / ISX019_STANDARD_MASTER_CLOCK;
store_default_value(priv);
+ /* Store initial HUE value for getting current value API. */
+
+ priv->hue = priv->default_value.hue;
+
return OK;
}
@@ -2094,16 +2099,6 @@ static int32_t convert_brightness_reg2is(int32_t val)
return (val / 4);
}
-static int32_t convert_hue_is2reg(int32_t val)
-{
- return (val * 90) / 128;
-}
-
-static int32_t convert_hue_reg2is(int32_t val)
-{
- return (val * 128) / 90;
-}
-
static int32_t convert_hdr_is2reg(int32_t val)
{
int32_t ret = AEWDMODE_AUTO;
@@ -2180,11 +2175,6 @@ static convert_t get_reginfo(uint32_t id, bool is_set,
cvrt = not_convert;
break;
- case IMGSENSOR_ID_HUE:
- SET_REGINFO_INT8(reg, CAT_PICTTUNE, UIHUE);
- cvrt = is_set ? convert_hue_is2reg : convert_hue_reg2is;
- break;
-
case IMGSENSOR_ID_EXPOSURE:
SET_REGINFO_INT8(reg, CAT_AEDGRM, EVSEL);
cvrt = not_convert;
@@ -2207,6 +2197,23 @@ static convert_t get_reginfo(uint32_t id, bool is_set,
return cvrt;
}
+static int set_hue(FAR isx019_dev_t *priv,
+ imgsensor_value_t val)
+{
+ int ret;
+ int val32 = val.value32 * 90 / 128;
+
+ ret = isx019_i2c_write(priv, CAT_PICTTUNE, UIHUE, &val32, 1);
+ if (ret == OK)
+ {
+ /* Store value before conversion for get_hue(). */
+
+ priv->hue = val.value32;
+ }
+
+ return ret;
+}
+
static void set_flip(FAR uint8_t *flip, uint8_t direction, int32_t val)
{
DEBUGASSERT(flip);
@@ -3034,6 +3041,10 @@ static setvalue_t set_value_func(uint32_t id)
switch (id)
{
+ case IMGSENSOR_ID_HUE:
+ func = set_hue;
+ break;
+
case IMGSENSOR_ID_GAMMA:
func = set_gamma;
break;
@@ -3117,6 +3128,21 @@ static setvalue_t set_value_func(uint32_t id)
return func;
}
+static int get_hue(FAR isx019_dev_t *priv,
+ FAR imgsensor_value_t *val)
+{
+ if (val == NULL)
+ {
+ return -EINVAL;
+ }
+
+ /* Return stored value without reading register. */
+
+ val->value32 = priv->hue;
+
+ return OK;
+}
+
static int32_t get_flip(FAR uint8_t *flip, uint8_t direction)
{
DEBUGASSERT(flip);
@@ -3526,6 +3552,10 @@ static getvalue_t get_value_func(uint32_t id)
switch (id)
{
+ case IMGSENSOR_ID_HUE:
+ func = get_hue;
+ break;
+
case IMGSENSOR_ID_GAMMA:
func = get_gamma;
break;
(nuttx) 04/15: drivers/video/isx019: Fix control type of some parameters
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit dc82022769a3721097fc07ca2aac923626e08dd0
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Tue Oct 17 13:36:26 2023 +0900
drivers/video/isx019: Fix control type of some parameters
Fix control type of some parameters according to specification.
---
drivers/video/isx019.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/drivers/video/isx019.c b/drivers/video/isx019.c
index 7ca13b53aa..ea089bd0ad 100644
--- a/drivers/video/isx019.c
+++ b/drivers/video/isx019.c
@@ -1882,7 +1882,7 @@ static int isx019_get_supported_value(FAR struct imgsensor_s *sensor,
break;
case IMGSENSOR_ID_AUTO_WHITE_BALANCE:
- val->type = IMGSENSOR_CTRL_TYPE_INTEGER;
+ val->type = IMGSENSOR_CTRL_TYPE_BOOLEAN;
SET_RANGE(val->u.range, MIN_AWB, MAX_AWB,
STEP_AWB, def->awb);
break;
@@ -1900,25 +1900,25 @@ static int isx019_get_supported_value(FAR struct imgsensor_s *sensor,
break;
case IMGSENSOR_ID_HFLIP_VIDEO:
- val->type = IMGSENSOR_CTRL_TYPE_INTEGER;
+ val->type = IMGSENSOR_CTRL_TYPE_BOOLEAN;
SET_RANGE(val->u.range, MIN_HFLIP, MAX_HFLIP,
STEP_HFLIP, def->hflip_video);
break;
case IMGSENSOR_ID_VFLIP_VIDEO:
- val->type = IMGSENSOR_CTRL_TYPE_INTEGER;
+ val->type = IMGSENSOR_CTRL_TYPE_BOOLEAN;
SET_RANGE(val->u.range, MIN_VFLIP, MAX_VFLIP,
STEP_VFLIP, def->vflip_video);
break;
case IMGSENSOR_ID_HFLIP_STILL:
- val->type = IMGSENSOR_CTRL_TYPE_INTEGER;
+ val->type = IMGSENSOR_CTRL_TYPE_BOOLEAN;
SET_RANGE(val->u.range, MIN_HFLIP, MAX_HFLIP,
STEP_HFLIP, def->hflip_still);
break;
case IMGSENSOR_ID_VFLIP_STILL:
- val->type = IMGSENSOR_CTRL_TYPE_INTEGER;
+ val->type = IMGSENSOR_CTRL_TYPE_BOOLEAN;
SET_RANGE(val->u.range, MIN_VFLIP, MAX_VFLIP,
STEP_VFLIP, def->hflip_still);
break;
(nuttx) 06/15: drivers/video/isx019: Fix bug that initial exposure time is not correct
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 33f7923d7247fdbb34fe92821c9ef9e418533361
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Thu Dec 21 13:40:57 2023 +0900
drivers/video/isx019: Fix bug that initial exposure time is not correct
Because exposure time calculation needs the cxd56xx clock value,
get the cxd56xx clock value before saving initial value.
---
drivers/video/isx019.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/video/isx019.c b/drivers/video/isx019.c
index ea089bd0ad..a763328c94 100644
--- a/drivers/video/isx019.c
+++ b/drivers/video/isx019.c
@@ -1354,9 +1354,14 @@ static int isx019_init(FAR struct imgsensor_s *sensor)
fpga_init(priv);
initialize_wbmode(priv);
initialize_jpg_quality(priv);
- store_default_value(priv);
+
+ /* Because store_default_value() needs the clock ratio,
+ * clock_ratio has to be calculated first.
+ */
+
clk = board_isx019_get_master_clock();
priv->clock_ratio = (float)clk / ISX019_STANDARD_MASTER_CLOCK;
+ store_default_value(priv);
return OK;
}
(nuttx) 01/15: drivers/video: Modify control id definition
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 75a0a08a4dd3d487b858e7e4ff7a8f7e4b753970
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Wed Oct 11 20:53:43 2023 +0900
drivers/video: Modify control id definition
Modify control id definition to avoid duplication even if
the control ids belong to the same control class.
Also, not refer to control class in driver.
---
drivers/video/video.c | 34 +++------
include/nuttx/video/imgsensor.h | 86 ++++++++++-----------
include/nuttx/video/video_controls.h | 142 +++++++++++++++++++++--------------
include/sys/videoio.h | 6 +-
4 files changed, 142 insertions(+), 126 deletions(-)
diff --git a/drivers/video/video.c b/drivers/video/video.c
index 105e2d8745..069445ca30 100644
--- a/drivers/video/video.c
+++ b/drivers/video/video.c
@@ -53,8 +53,6 @@
#define VIDEO_REMAINING_CAPNUM_INFINITY (-1)
-#define VIDEO_ID(x, y) (((x) << 16) | (y))
-
/****************************************************************************
* Private Types
****************************************************************************/
@@ -2157,8 +2155,7 @@ static int video_query_ext_ctrl(FAR struct video_mng_s *vmng,
attr->nr_of_dims = 0;
memset(attr->dims, 0, sizeof(attr->dims));
- if (attr->ctrl_class == V4L2_CTRL_CLASS_CAMERA &&
- attr->id == V4L2_CID_SCENE_MODE)
+ if (attr->id == V4L2_CID_SCENE_MODE)
{
/* Scene mode is processed in only video driver. */
@@ -2172,9 +2169,7 @@ static int video_query_ext_ctrl(FAR struct video_mng_s *vmng,
}
else
{
- ret = IMGSENSOR_GET_SUPPORTED_VALUE(vmng->imgsensor,
- VIDEO_ID(attr->ctrl_class, attr->id),
- &value);
+ ret = IMGSENSOR_GET_SUPPORTED_VALUE(vmng->imgsensor, attr->id, &value);
if (ret < 0)
{
return ret;
@@ -2209,8 +2204,7 @@ static int video_query_ext_ctrl(FAR struct video_mng_s *vmng,
break;
}
- set_parameter_name(VIDEO_ID(attr->ctrl_class, attr->id),
- attr->name);
+ set_parameter_name(attr->id, attr->name);
}
return OK;
@@ -2229,8 +2223,7 @@ static int video_querymenu(FAR video_mng_t *vmng,
return -EINVAL;
}
- if (menu->ctrl_class == V4L2_CTRL_CLASS_CAMERA &&
- menu->id == V4L2_CID_SCENE_MODE)
+ if (menu->id == V4L2_CID_SCENE_MODE)
{
/* Scene mode is processed in only video driver. */
@@ -2244,8 +2237,8 @@ static int video_querymenu(FAR video_mng_t *vmng,
else
{
ret = IMGSENSOR_GET_SUPPORTED_VALUE(vmng->imgsensor,
- VIDEO_ID(menu->ctrl_class, menu->id),
- &value);
+ menu->id,
+ &value);
if (ret < 0)
{
return ret;
@@ -2351,7 +2344,7 @@ static int video_g_ext_ctrls(FAR struct video_mng_s *priv,
cnt++, control++)
{
ret = IMGSENSOR_GET_VALUE(priv->imgsensor,
- VIDEO_ID(ctrls->ctrl_class, control->id),
+ control->id,
control->size,
(imgsensor_value_t *)&control->value64);
if (ret < 0)
@@ -2488,15 +2481,14 @@ static int video_s_ext_ctrls(FAR struct video_mng_s *priv,
cnt < ctrls->count;
cnt++, control++)
{
- if (ctrls->ctrl_class == V4L2_CTRL_CLASS_CAMERA &&
- control->id == V4L2_CID_SCENE_MODE)
+ if (control->id == V4L2_CID_SCENE_MODE)
{
ret = reflect_scene_parameter(priv, control->value);
}
else
{
ret = IMGSENSOR_SET_VALUE(priv->imgsensor,
- VIDEO_ID(ctrls->ctrl_class, control->id),
+ control->id,
control->size,
(imgsensor_value_t)control->value64);
if (ret == 0)
@@ -2504,7 +2496,7 @@ static int video_s_ext_ctrls(FAR struct video_mng_s *priv,
if (priv->video_scene_mode == V4L2_SCENE_MODE_NONE)
{
save_scene_param(priv, V4L2_SCENE_MODE_NONE,
- VIDEO_ID(ctrls->ctrl_class, control->id),
+ control->id,
control);
}
}
@@ -2745,7 +2737,7 @@ static int video_g_ext_ctrls_scene(FAR video_mng_t *vmng,
cnt++, control++)
{
ret = read_scene_param(vmng, ctrls->mode,
- VIDEO_ID(ctrls->control.ctrl_class, control->id),
+ control->id,
control);
if (ret != OK)
{
@@ -3060,9 +3052,7 @@ static int video_s_ext_ctrls_scene(FAR struct video_mng_s *vmng,
cnt < ctrls->control.count;
cnt++, control++)
{
- ret = save_scene_param(vmng, ctrls->mode,
- VIDEO_ID(ctrls->control.ctrl_class, control->id),
- control);
+ ret = save_scene_param(vmng, ctrls->mode, control->id, control);
if (ret != OK)
{
ctrls->control.error_idx = cnt;
diff --git a/include/nuttx/video/imgsensor.h b/include/nuttx/video/imgsensor.h
index 36fa9baef1..b643e86603 100644
--- a/include/nuttx/video/imgsensor.h
+++ b/include/nuttx/video/imgsensor.h
@@ -34,49 +34,49 @@
/* Camera parameter IDs */
-#define IMGSENSOR_ID_BRIGHTNESS (0x00000000)
-#define IMGSENSOR_ID_CONTRAST (0x00000001)
-#define IMGSENSOR_ID_SATURATION (0x00000002)
-#define IMGSENSOR_ID_HUE (0x00000003)
-#define IMGSENSOR_ID_AUTO_WHITE_BALANCE (0x00000004)
-#define IMGSENSOR_ID_RED_BALANCE (0x00000005)
-#define IMGSENSOR_ID_BLUE_BALANCE (0x00000006)
-#define IMGSENSOR_ID_GAMMA (0x00000007)
-#define IMGSENSOR_ID_GAMMA_CURVE (0x00000008)
-#define IMGSENSOR_ID_EXPOSURE (0x00000009)
-#define IMGSENSOR_ID_HFLIP_VIDEO (0x0000000a)
-#define IMGSENSOR_ID_VFLIP_VIDEO (0x0000000b)
-#define IMGSENSOR_ID_HFLIP_STILL (0x0000000c)
-#define IMGSENSOR_ID_VFLIP_STILL (0x0000000d)
-#define IMGSENSOR_ID_SHARPNESS (0x0000000e)
-#define IMGSENSOR_ID_COLOR_KILLER (0x0000000f)
-#define IMGSENSOR_ID_COLORFX (0x00000010)
-#define IMGSENSOR_ID_AUTOBRIGHTNESS (0x00000011)
-#define IMGSENSOR_ID_ROTATE (0x00000012)
-#define IMGSENSOR_ID_EXPOSURE_AUTO (0x00010000)
-#define IMGSENSOR_ID_EXPOSURE_ABSOLUTE (0x00010001)
-#define IMGSENSOR_ID_FOCUS_ABSOLUTE (0x00010002)
-#define IMGSENSOR_ID_FOCUS_RELATIVE (0x00010003)
-#define IMGSENSOR_ID_FOCUS_AUTO (0x00010004)
-#define IMGSENSOR_ID_ZOOM_ABSOLUTE (0x00010005)
-#define IMGSENSOR_ID_ZOOM_RELATIVE (0x00010006)
-#define IMGSENSOR_ID_ZOOM_CONTINUOUS (0x00010007)
-#define IMGSENSOR_ID_IRIS_ABSOLUTE (0x00010008)
-#define IMGSENSOR_ID_IRIS_RELATIVE (0x00010009)
-#define IMGSENSOR_ID_AUTO_N_PRESET_WB (0x0001000a)
-#define IMGSENSOR_ID_WIDE_DYNAMIC_RANGE (0x0001000b)
-#define IMGSENSOR_ID_IMG_STABILIZATION (0x0001000c)
-#define IMGSENSOR_ID_ISO_SENSITIVITY (0x0001000d)
-#define IMGSENSOR_ID_ISO_SENSITIVITY_AUTO (0x0001000e)
-#define IMGSENSOR_ID_EXPOSURE_METERING (0x0001000f)
-#define IMGSENSOR_ID_SPOT_POSITION (0x00010016)
-#define IMGSENSOR_ID_3A_LOCK (0x00010011)
-#define IMGSENSOR_ID_AUTO_FOCUS_START (0x00010012)
-#define IMGSENSOR_ID_AUTO_FOCUS_STOP (0x00010013)
-#define IMGSENSOR_ID_3A_PARAMETER (0x00010014)
-#define IMGSENSOR_ID_3A_STATUS (0x00010015)
-#define IMGSENSOR_ID_FLASH_LED_MODE (0x00020000)
-#define IMGSENSOR_ID_JPEG_QUALITY (0x00030000)
+#define IMGSENSOR_ID_BRIGHTNESS V4L2_CID_BRIGHTNESS
+#define IMGSENSOR_ID_CONTRAST V4L2_CID_CONTRAST
+#define IMGSENSOR_ID_SATURATION V4L2_CID_SATURATION
+#define IMGSENSOR_ID_HUE V4L2_CID_HUE
+#define IMGSENSOR_ID_AUTO_WHITE_BALANCE V4L2_CID_AUTO_WHITE_BALANCE
+#define IMGSENSOR_ID_RED_BALANCE V4L2_CID_RED_BALANCE
+#define IMGSENSOR_ID_BLUE_BALANCE V4L2_CID_BLUE_BALANCE
+#define IMGSENSOR_ID_GAMMA V4L2_CID_GAMMA
+#define IMGSENSOR_ID_GAMMA_CURVE V4L2_CID_GAMMA_CURVE
+#define IMGSENSOR_ID_EXPOSURE V4L2_CID_EXPOSURE
+#define IMGSENSOR_ID_HFLIP_VIDEO V4L2_CID_HFLIP
+#define IMGSENSOR_ID_VFLIP_VIDEO V4L2_CID_VFLIP
+#define IMGSENSOR_ID_HFLIP_STILL V4L2_CID_HFLIP_STILL
+#define IMGSENSOR_ID_VFLIP_STILL V4L2_CID_VFLIP_STILL
+#define IMGSENSOR_ID_SHARPNESS V4L2_CID_SHARPNESS
+#define IMGSENSOR_ID_COLOR_KILLER V4L2_CID_COLOR_KILLER
+#define IMGSENSOR_ID_COLORFX V4L2_CID_COLORFX
+#define IMGSENSOR_ID_AUTOBRIGHTNESS V4L2_CID_AUTOBRIGHTNESS
+#define IMGSENSOR_ID_ROTATE V4L2_CID_ROTATE
+#define IMGSENSOR_ID_EXPOSURE_AUTO V4L2_CID_EXPOSURE_AUTO
+#define IMGSENSOR_ID_EXPOSURE_ABSOLUTE V4L2_CID_EXPOSURE_ABSOLUTE
+#define IMGSENSOR_ID_FOCUS_ABSOLUTE V4L2_CID_FOCUS_ABSOLUTE
+#define IMGSENSOR_ID_FOCUS_RELATIVE V4L2_CID_FOCUS_RELATIVE
+#define IMGSENSOR_ID_FOCUS_AUTO V4L2_CID_FOCUS_AUTO
+#define IMGSENSOR_ID_ZOOM_ABSOLUTE V4L2_CID_ZOOM_ABSOLUTE
+#define IMGSENSOR_ID_ZOOM_RELATIVE V4L2_CID_ZOOM_RELATIVE
+#define IMGSENSOR_ID_ZOOM_CONTINUOUS V4L2_CID_ZOOM_CONTINUOUS
+#define IMGSENSOR_ID_IRIS_ABSOLUTE V4L2_CID_IRIS_ABSOLUTE
+#define IMGSENSOR_ID_IRIS_RELATIVE V4L2_CID_IRIS_RELATIVE
+#define IMGSENSOR_ID_AUTO_N_PRESET_WB V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE
+#define IMGSENSOR_ID_WIDE_DYNAMIC_RANGE V4L2_CID_WIDE_DYNAMIC_RANGE
+#define IMGSENSOR_ID_IMG_STABILIZATION V4L2_CID_IMAGE_STABILIZATION
+#define IMGSENSOR_ID_ISO_SENSITIVITY V4L2_CID_ISO_SENSITIVITY
+#define IMGSENSOR_ID_ISO_SENSITIVITY_AUTO V4L2_CID_ISO_SENSITIVITY_AUTO
+#define IMGSENSOR_ID_EXPOSURE_METERING V4L2_CID_EXPOSURE_METERING
+#define IMGSENSOR_ID_SPOT_POSITION V4L2_CID_EXPOSURE_METERING_SPOT_POSITION
+#define IMGSENSOR_ID_3A_LOCK V4L2_CID_3A_LOCK
+#define IMGSENSOR_ID_AUTO_FOCUS_START V4L2_CID_AUTO_FOCUS_START
+#define IMGSENSOR_ID_AUTO_FOCUS_STOP V4L2_CID_AUTO_FOCUS_STOP
+#define IMGSENSOR_ID_3A_PARAMETER V4L2_CID_3A_PARAMETER
+#define IMGSENSOR_ID_3A_STATUS V4L2_CID_3A_STATUS
+#define IMGSENSOR_ID_FLASH_LED_MODE V4L2_CID_FLASH_LED_MODE
+#define IMGSENSOR_ID_JPEG_QUALITY V4L2_CID_JPEG_COMPRESSION_QUALITY
#define IMGSENSOR_ID_CLIP_VIDEO (0xFFFF0000)
#define IMGSENSOR_ID_CLIP_STILL (0xFFFF0001)
diff --git a/include/nuttx/video/video_controls.h b/include/nuttx/video/video_controls.h
index 17324ea4bb..492d02bed0 100644
--- a/include/nuttx/video/video_controls.h
+++ b/include/nuttx/video/video_controls.h
@@ -31,30 +31,47 @@
/* Control classes */
-#define V4L2_CTRL_CLASS_USER (0x0000) /* Old-style 'user' controls */
-#define V4L2_CTRL_CLASS_CAMERA (0x0001) /* Camera class controls */
-#define V4L2_CTRL_CLASS_FLASH (0x0002) /* Camera flash controls */
-#define V4L2_CTRL_CLASS_JPEG (0x0003) /* JPEG-compression controls */
+#define V4L2_CTRL_CLASS_USER (0x0100) /* Old-style 'user' controls */
+#define V4L2_CTRL_CLASS_CAMERA (0x0200) /* Camera class controls */
+#define V4L2_CTRL_CLASS_FLASH (0x0300) /* Camera flash controls */
+#define V4L2_CTRL_CLASS_JPEG (0x0400) /* JPEG-compression controls */
+
+#define USER_CID(v) (V4L2_CTRL_CLASS_USER + (v))
+#define CAMERA_CID(v) (V4L2_CTRL_CLASS_CAMERA + (v))
+#define FLASH_CID(v) (V4L2_CTRL_CLASS_FLASH + (v))
+#define JPEG_CID(v) (V4L2_CTRL_CLASS_JPEG + (v))
/* User-class control IDs */
-#define V4L2_CID_BRIGHTNESS (0) /* Brightness */
-#define V4L2_CID_CONTRAST (1) /* Contrast */
-#define V4L2_CID_SATURATION (2) /* Saturation */
-#define V4L2_CID_HUE (3) /* Hue */
-#define V4L2_CID_AUTO_WHITE_BALANCE (4) /* AWB */
-#define V4L2_CID_RED_BALANCE (5) /* Red balance */
-#define V4L2_CID_BLUE_BALANCE (6) /* Blue balance */
-#define V4L2_CID_GAMMA (7) /* Gamma value adjustment */
-#define V4L2_CID_GAMMA_CURVE (8) /* Gamma curve adjustment */
-#define V4L2_CID_EXPOSURE (9) /* Exposure value */
-#define V4L2_CID_HFLIP (10) /* Mirror horizontally(VIDEO) */
-#define V4L2_CID_VFLIP (11) /* Mirror vertically(VIDEO) */
-#define V4L2_CID_HFLIP_STILL (12) /* Mirror horizontally(STILL) */
-#define V4L2_CID_VFLIP_STILL (13) /* Mirror vertically(STILL) */
-#define V4L2_CID_SHARPNESS (14) /* Sharpness */
-#define V4L2_CID_COLOR_KILLER (15) /* Color killer */
-#define V4L2_CID_COLORFX (16) /* Color effect */
+#define V4L2_CID_BRIGHTNESS USER_CID(0) /* Brightness */
+#define V4L2_CID_CONTRAST USER_CID(1) /* Contrast */
+#define V4L2_CID_SATURATION USER_CID(2) /* Saturation */
+#define V4L2_CID_HUE USER_CID(3) /* Hue */
+#define V4L2_CID_AUTO_WHITE_BALANCE USER_CID(4) /* AWB */
+#define V4L2_CID_RED_BALANCE USER_CID(5) /* Red balance */
+#define V4L2_CID_BLUE_BALANCE USER_CID(6) /* Blue balance */
+#define V4L2_CID_GAMMA USER_CID(7) /* Gamma value adjustment */
+#define V4L2_CID_GAMMA_CURVE USER_CID(8) /* Gamma curve adjustment */
+#define V4L2_CID_EXPOSURE USER_CID(9) /* Exposure value */
+
+/* Mirror horizontally(VIDEO) */
+
+#define V4L2_CID_HFLIP USER_CID(10)
+
+/* Mirror vertically(VIDEO) */
+
+#define V4L2_CID_VFLIP USER_CID(11)
+
+/* Mirror horizontally(STILL) */
+
+#define V4L2_CID_HFLIP_STILL USER_CID(12)
+
+/* Mirror vertically(STILL) */
+
+#define V4L2_CID_VFLIP_STILL USER_CID(13)
+#define V4L2_CID_SHARPNESS USER_CID(14) /* Sharpness */
+#define V4L2_CID_COLOR_KILLER USER_CID(15) /* Color killer */
+#define V4L2_CID_COLORFX USER_CID(16) /* Color effect */
/* Enumeration for V4L2_CID_COLORFX */
@@ -78,12 +95,13 @@ enum v4l2_colorfx
V4L2_COLORFX_SET_CBCR = 15, /* Set CbCr */
V4L2_COLORFX_PASTEL = 16 /* Pastel */
};
-#define V4L2_CID_AUTOBRIGHTNESS (17) /* Auto brightness */
-#define V4L2_CID_ROTATE (18) /* Rotation */
+
+#define V4L2_CID_AUTOBRIGHTNESS USER_CID(17) /* Auto brightness */
+#define V4L2_CID_ROTATE USER_CID(18) /* Rotation */
/* Camera class control IDs */
-#define V4L2_CID_EXPOSURE_AUTO (0) /* Auto exposure */
+#define V4L2_CID_EXPOSURE_AUTO CAMERA_CID(0) /* Auto exposure */
/* Enumeration for V4L2_CID_EXPOSURE_AUTO */
@@ -105,20 +123,23 @@ enum v4l2_exposure_auto_type
V4L2_EXPOSURE_APERTURE_PRIORITY = 3
};
-#define V4L2_CID_EXPOSURE_ABSOLUTE (1) /* Exposure time */
-#define V4L2_CID_FOCUS_ABSOLUTE (2) /* Focus */
-#define V4L2_CID_FOCUS_RELATIVE (3) /* Focus */
-#define V4L2_CID_FOCUS_AUTO (4) /* Auto focus */
+#define V4L2_CID_EXPOSURE_ABSOLUTE CAMERA_CID(1) /* Exposure time */
+
+#define V4L2_CID_FOCUS_ABSOLUTE CAMERA_CID(2) /* Focus */
+#define V4L2_CID_FOCUS_RELATIVE CAMERA_CID(3) /* Focus */
+#define V4L2_CID_FOCUS_AUTO CAMERA_CID(4) /* Auto focus */
+
+#define V4L2_CID_ZOOM_ABSOLUTE CAMERA_CID(5) /* Zoom(absolute) */
+#define V4L2_CID_ZOOM_RELATIVE CAMERA_CID(6) /* Zoom(relative) */
+#define V4L2_CID_ZOOM_CONTINUOUS CAMERA_CID(7) /* Continuous zoom */
-#define V4L2_CID_ZOOM_ABSOLUTE (5) /* Zoom(absolute) */
-#define V4L2_CID_ZOOM_RELATIVE (6) /* Zoom(relative) */
-#define V4L2_CID_ZOOM_CONTINUOUS (7) /* Continuous zoom */
+#define V4L2_CID_IRIS_ABSOLUTE CAMERA_CID(8) /* Iris(absolute) */
+#define V4L2_CID_IRIS_RELATIVE CAMERA_CID(9) /* Iris(relative) */
-#define V4L2_CID_IRIS_ABSOLUTE (8) /* Iris(absolute) */
-#define V4L2_CID_IRIS_RELATIVE (9) /* Iris(relative) */
+/* Preset white balance */
-#define V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE (10) /* Preset white balance */
+#define V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE CAMERA_CID(10)
/* Enumeration for V4L2_CID_AUTO_N_PRESET_WHITE_BALANCE */
@@ -136,11 +157,16 @@ enum v4l2_auto_n_preset_white_balance
V4L2_WHITE_BALANCE_SHADE = 9, /* Shade */
};
-#define V4L2_CID_WIDE_DYNAMIC_RANGE (11) /* Wide dynamic range */
-#define V4L2_CID_IMAGE_STABILIZATION (12) /* Image stabilization */
+#define V4L2_CID_WIDE_DYNAMIC_RANGE CAMERA_CID(11) /* Wide dynamic range */
+
+/* Image stabilization */
+
+#define V4L2_CID_IMAGE_STABILIZATION CAMERA_CID(12)
+#define V4L2_CID_ISO_SENSITIVITY CAMERA_CID(13) /* ISO sensitivity */
+
+/* Auto ISO sensitivity */
-#define V4L2_CID_ISO_SENSITIVITY (13) /* ISO sensitivity */
-#define V4L2_CID_ISO_SENSITIVITY_AUTO (14) /* Auto ISO sensitivity */
+#define V4L2_CID_ISO_SENSITIVITY_AUTO CAMERA_CID(14)
/* Enumeration for V4L2_CID_ISO_SENSITIVITY_AUTO */
@@ -150,7 +176,7 @@ enum v4l2_iso_sensitivity_auto_type
V4L2_ISO_SENSITIVITY_AUTO = 1, /* Automatic */
};
-#define V4L2_CID_EXPOSURE_METERING (15) /* Exposure metering */
+#define V4L2_CID_EXPOSURE_METERING CAMERA_CID(15) /* Exposure metering */
/* Enumeration for V4L2_CID_EXPOSURE_METERING */
@@ -162,7 +188,7 @@ enum v4l2_exposure_metering
V4L2_EXPOSURE_METERING_MATRIX = 3, /* Matrix */
};
-#define V4L2_CID_SCENE_MODE (16) /* Scene selection */
+#define V4L2_CID_SCENE_MODE CAMERA_CID(16) /* Scene selection */
/* Enumeration for V4L2_CID_SCENE_MODE */
@@ -185,31 +211,31 @@ enum v4l2_scene_mode
V4L2_SCENE_MODE_MAX = 14 /* Max number */
};
-#define V4L2_CID_3A_LOCK (17) /* Lock 3A */
-#define V4L2_LOCK_EXPOSURE (1 << 0) /* Exposure bit for
- * V4L2_CID_3A_LOCK */
-#define V4L2_LOCK_WHITE_BALANCE (1 << 1) /* White balance bit for
- * V4L2_CID_3A_LOCK */
-#define V4L2_LOCK_FOCUS (1 << 2) /* Focus bit for
- * V4L2_CID_3A_LOCK */
+#define V4L2_CID_3A_LOCK CAMERA_CID(17) /* Lock 3A */
+#define V4L2_LOCK_EXPOSURE (1 << 0) /* Exposure bit for
+ * V4L2_CID_3A_LOCK */
+#define V4L2_LOCK_WHITE_BALANCE (1 << 1) /* White balance bit for
+ * V4L2_CID_3A_LOCK */
+#define V4L2_LOCK_FOCUS (1 << 2) /* Focus bit for
+ * V4L2_CID_3A_LOCK */
-#define V4L2_CID_AUTO_FOCUS_START (18) /* Start single AF */
-#define V4L2_CID_AUTO_FOCUS_STOP (19) /* Stop single AF */
+#define V4L2_CID_AUTO_FOCUS_START CAMERA_CID(18) /* Start single AF */
+#define V4L2_CID_AUTO_FOCUS_STOP CAMERA_CID(19) /* Stop single AF */
-#define V4L2_CID_3A_PARAMETER (20) /* 3A parameter */
-#define V4L2_CID_3A_STATUS (21) /* 3A status */
-#define V4L2_3A_STATUS_STABLE (0) /* 3A is stable */
-#define V4L2_3A_STATUS_AE_OPERATING (1 << 0) /* AE is operating */
-#define V4L2_3A_STATUS_AWB_OPERATING (1 << 1) /* AWB is operating */
-#define V4L2_3A_STATUS_AF_OPERATING (1 << 2) /* AF is operating */
+#define V4L2_CID_3A_PARAMETER CAMERA_CID(20) /* 3A parameter */
+#define V4L2_CID_3A_STATUS CAMERA_CID(21) /* 3A status */
+#define V4L2_3A_STATUS_STABLE (0) /* 3A is stable */
+#define V4L2_3A_STATUS_AE_OPERATING (1 << 0) /* AE is operating */
+#define V4L2_3A_STATUS_AWB_OPERATING (1 << 1) /* AWB is operating */
+#define V4L2_3A_STATUS_AF_OPERATING (1 << 2) /* AF is operating */
/* Spot position in spot exposure metering */
-#define V4L2_CID_EXPOSURE_METERING_SPOT_POSITION (22)
+#define V4L2_CID_EXPOSURE_METERING_SPOT_POSITION CAMERA_CID(22)
/* Flash and privacy (indicator) light controls */
-#define V4L2_CID_FLASH_LED_MODE (0)
+#define V4L2_CID_FLASH_LED_MODE FLASH_CID(0)
/* Enumeration for V4L2_CID_FLASH_LED_MODE */
@@ -222,6 +248,6 @@ enum v4l2_flash_led_mode
/* JPEG-class control IDs */
-#define V4L2_CID_JPEG_COMPRESSION_QUALITY (0) /* JPEG quality */
+#define V4L2_CID_JPEG_COMPRESSION_QUALITY JPEG_CID(0) /* JPEG quality */
#endif /* __INCLUDE_NUTTX_VIDEO_VIDEO_CONTROLS_H */
diff --git a/include/sys/videoio.h b/include/sys/videoio.h
index 1576bd51c9..939c01da12 100644
--- a/include/sys/videoio.h
+++ b/include/sys/videoio.h
@@ -1141,7 +1141,7 @@ enum v4l2_ctrl_type
struct v4l2_queryctrl
{
- uint16_t ctrl_class; /* Control class */
+ uint16_t ctrl_class; /* Control class(not used) */
uint16_t id; /* Control id */
uint16_t type; /* enum #v4l2_ctrl_type */
char name[32]; /* Name of control */
@@ -1153,7 +1153,7 @@ struct v4l2_queryctrl
struct v4l2_query_ext_ctrl
{
- uint16_t ctrl_class; /* Control class */
+ uint16_t ctrl_class; /* Control class(not used) */
uint16_t id; /* Control id */
uint16_t type; /* enum #v4l2_ctrl_type */
char name[32]; /* Name of control */
@@ -1170,7 +1170,7 @@ struct v4l2_query_ext_ctrl
struct v4l2_querymenu
{
- uint16_t ctrl_class; /* Camera control class */
+ uint16_t ctrl_class; /* Camera control class(not used) */
uint16_t id; /* Camera control id */
uint32_t index; /* Index of menu. */
union
(nuttx) 07/15: drivers/video/isx019: Fix bug that read value is not correct
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit fd5c2d49225cb51a6831c2f67925a4d4bed42e84
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Thu Dec 21 15:26:35 2023 +0900
drivers/video/isx019: Fix bug that read value is not correct
About parameter whose register size is less than 4 bytes,
when transfer read value to API parameter, cast appropriately
to avoid the following problems.
- Read value includes garbage value
- Negative value becomes huge positive value
---
drivers/video/isx019.c | 61 +++++++++++++++++++++++++++++++++++++++-----------
1 file changed, 48 insertions(+), 13 deletions(-)
diff --git a/drivers/video/isx019.c b/drivers/video/isx019.c
index a763328c94..d7aa292414 100644
--- a/drivers/video/isx019.c
+++ b/drivers/video/isx019.c
@@ -99,14 +99,27 @@
/* For set_value() and get_value() I/F */
-#define SET_REGINFO(a, c, o, s) do \
+#define SET_REGINFO(a, c, o, t, s) do \
{ \
(a)->category = (c); \
(a)->offset = (o); \
+ (a)->type = (t); \
(a)->size = (s); \
} \
while (0);
+/* Register type, which represents the number of bits and
+ * whether it is signed or unsigned.
+ */
+
+#define ISX019_REGTYPE_INT8 (0)
+#define ISX019_REGTYPE_UINT8 (1)
+#define ISX019_REGTYPE_INT16 (2)
+
+#define SET_REGINFO_INT8(a, c, o) SET_REGINFO(a, c, o, ISX019_REGTYPE_INT8, 1)
+#define SET_REGINFO_UINT8(a, c, o) SET_REGINFO(a, c, o, ISX019_REGTYPE_UINT8, 1)
+#define SET_REGINFO_INT16(a, c, o) SET_REGINFO(a, c, o, ISX019_REGTYPE_INT16, 2)
+
#define VALIDATE_RANGE(v, min, max, step) (((v) >= (min)) && \
((v) <= (max)) && \
(((v) - (min)) % (step) == 0))
@@ -239,6 +252,7 @@ struct isx019_reginfo_s
{
uint16_t category;
uint16_t offset;
+ uint8_t type;
uint8_t size;
};
@@ -2040,12 +2054,12 @@ static int32_t not_convert(int32_t val)
static int32_t convert_brightness_is2reg(int32_t val)
{
- return (val << 2);
+ return (val * 4);
}
static int32_t convert_brightness_reg2is(int32_t val)
{
- return (val >> 2);
+ return (val / 4);
}
static int32_t convert_hue_is2reg(int32_t val)
@@ -2119,38 +2133,38 @@ static convert_t get_reginfo(uint32_t id, bool is_set,
switch (id)
{
case IMGSENSOR_ID_BRIGHTNESS:
- SET_REGINFO(reg, CAT_PICTTUNE, UIBRIGHTNESS, 2);
+ SET_REGINFO_INT16(reg, CAT_PICTTUNE, UIBRIGHTNESS);
cvrt = is_set ? convert_brightness_is2reg
: convert_brightness_reg2is;
break;
case IMGSENSOR_ID_CONTRAST:
- SET_REGINFO(reg, CAT_PICTTUNE, UICONTRAST, 1);
+ SET_REGINFO_UINT8(reg, CAT_PICTTUNE, UICONTRAST);
cvrt = not_convert;
break;
case IMGSENSOR_ID_SATURATION:
- SET_REGINFO(reg, CAT_PICTTUNE, UISATURATION, 1);
+ SET_REGINFO_UINT8(reg, CAT_PICTTUNE, UISATURATION);
cvrt = not_convert;
break;
case IMGSENSOR_ID_HUE:
- SET_REGINFO(reg, CAT_PICTTUNE, UIHUE, 1);
+ SET_REGINFO_INT8(reg, CAT_PICTTUNE, UIHUE);
cvrt = is_set ? convert_hue_is2reg : convert_hue_reg2is;
break;
case IMGSENSOR_ID_EXPOSURE:
- SET_REGINFO(reg, CAT_AEDGRM, EVSEL, 1);
+ SET_REGINFO_INT8(reg, CAT_AEDGRM, EVSEL);
cvrt = not_convert;
break;
case IMGSENSOR_ID_SHARPNESS:
- SET_REGINFO(reg, CAT_PICTTUNE, UISHARPNESS, 1);
+ SET_REGINFO_UINT8(reg, CAT_PICTTUNE, UISHARPNESS);
cvrt = not_convert;
break;
case IMGSENSOR_ID_WIDE_DYNAMIC_RANGE:
- SET_REGINFO(reg, CAT_AEWD, AEWDMODE, 1);
+ SET_REGINFO_UINT8(reg, CAT_AEWD, AEWDMODE);
cvrt = is_set ? convert_hdr_is2reg : convert_hdr_reg2is;
break;
@@ -3568,16 +3582,37 @@ static int isx019_get_value(FAR struct imgsensor_s *sensor,
isx019_reginfo_t reg;
convert_t cvrt;
getvalue_t get;
- int32_t val32;
+ union
+ {
+ int32_t i32;
+ int16_t i16;
+ int8_t i8;
+ } regval;
DEBUGASSERT(val);
cvrt = get_reginfo(id, false, ®);
if (cvrt)
{
+ memset(®val, 0, sizeof(regval));
ret = isx019_i2c_read(priv,
- reg.category, reg.offset, &val32, reg.size);
- val->value32 = cvrt(val32);
+ reg.category, reg.offset, ®val.i32, reg.size);
+
+ switch (reg.type)
+ {
+ case ISX019_REGTYPE_INT8:
+ regval.i32 = (int32_t)regval.i8;
+ break;
+
+ case ISX019_REGTYPE_INT16:
+ regval.i32 = (int32_t)regval.i16;
+ break;
+
+ default:
+ break;
+ }
+
+ val->value32 = cvrt(regval.i32);
}
else
{
(nuttx) 05/15: drivers/video/isx019: Fix maximum value of exposure time
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 76e91a69f78e4e4411fb3f342ae48a89ca16813c
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Thu Dec 21 13:30:29 2023 +0900
drivers/video/isx019: Fix maximum value of exposure time
Modify maximum value of exposure time from 102000 to 2740
according to hardware specification.
---
drivers/video/isx019_range.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/isx019_range.h b/drivers/video/isx019_range.h
index 35365a148e..9489c1fc12 100644
--- a/drivers/video/isx019_range.h
+++ b/drivers/video/isx019_range.h
@@ -77,7 +77,7 @@
#define STEP_AE (1)
#define MIN_EXPOSURETIME (1)
-#define MAX_EXPOSURETIME (102000)
+#define MAX_EXPOSURETIME (2740)
#define STEP_EXPOSURETIME (1)
#define MIN_WBMODE (0)
(nuttx) 15/15: drivers/video/isx012: Fix buffer overrun of isx012_putreg()
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit bac0228825ee93af86b66ee1d69081f54b248d4c
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Tue Dec 19 15:25:59 2023 +0900
drivers/video/isx012: Fix buffer overrun of isx012_putreg()
The maximum size of ISX012 register is 4 bytes.
So, extend temporary buffer size.
Detected by CodeSonar 141893
---
drivers/video/isx012.c | 14 ++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)
diff --git a/drivers/video/isx012.c b/drivers/video/isx012.c
index 5c4b69bb90..d612a689c7 100644
--- a/drivers/video/isx012.c
+++ b/drivers/video/isx012.c
@@ -216,7 +216,7 @@ typedef struct isx012_dev_s isx012_dev_t;
static uint16_t isx012_getreg(FAR isx012_dev_t *priv,
uint16_t regaddr, uint16_t regsize);
static int isx012_putreg(FAR isx012_dev_t *priv, uint16_t regaddr,
- uint16_t regval, uint16_t regsize);
+ uint32_t regval, uint16_t regsize);
static int isx012_putreglist(FAR isx012_dev_t *priv,
FAR const isx012_reg_t *reglist, size_t nentries);
#ifdef ISX012_CHECK_IN_DETAIL
@@ -676,8 +676,8 @@ static uint16_t isx012_getreg(FAR isx012_dev_t *priv,
uint16_t regaddr, uint16_t regsize)
{
struct i2c_config_s config;
- volatile uint16_t regval = 0;
- volatile uint8_t buffer[2];
+ uint16_t regval = 0;
+ uint8_t buffer[2];
int ret;
/* Set up the I2C configuration */
@@ -719,12 +719,14 @@ static uint16_t isx012_getreg(FAR isx012_dev_t *priv,
}
static int isx012_putreg(FAR isx012_dev_t *priv,
- uint16_t regaddr, uint16_t regval, uint16_t regsize)
+ uint16_t regaddr, uint32_t regval, uint16_t regsize)
{
struct i2c_config_s config;
- volatile uint8_t buffer[4];
+ uint8_t buffer[6];
int ret;
+ DEBUGASSERT(regsize <= 4);
+
/* Set up the I2C configuration */
config.frequency = priv->i2c_freq;
@@ -779,7 +781,7 @@ static int isx012_chk_int_state(FAR isx012_dev_t *priv,
uint32_t wait_time, uint32_t timeout)
{
int ret = 0;
- volatile uint8_t data;
+ uint8_t data;
uint32_t time = 0;
nxsig_usleep(delay_time * 1000);
(nuttx) 03/15: drivers/video/isx012: Fix control type of some parameters
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit fdf9f009529b40e48842b6367fb08fab4513ffaf
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Tue Oct 17 13:31:00 2023 +0900
drivers/video/isx012: Fix control type of some parameters
Fix control type of some parameters according to specification.
---
drivers/video/isx012.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/video/isx012.c b/drivers/video/isx012.c
index cc6200bee2..5c4b69bb90 100644
--- a/drivers/video/isx012.c
+++ b/drivers/video/isx012.c
@@ -1764,7 +1764,7 @@ static int isx012_get_supported_value(FAR struct imgsensor_s *sensor,
break;
case IMGSENSOR_ID_CONTRAST:
- value->type = IMGSENSOR_CTRL_TYPE_U8FIXEDPOINT_Q7;
+ value->type = IMGSENSOR_CTRL_TYPE_INTEGER;
range->minimum = ISX012_MIN_CONTRAST;
range->maximum = ISX012_MAX_CONTRAST;
range->step = ISX012_STEP_CONTRAST;
@@ -1808,7 +1808,7 @@ static int isx012_get_supported_value(FAR struct imgsensor_s *sensor,
break;
case IMGSENSOR_ID_EXPOSURE:
- value->type = IMGSENSOR_CTRL_TYPE_INTEGER_TIMES_3;
+ value->type = IMGSENSOR_CTRL_TYPE_INTEGER;
range->minimum = ISX012_MIN_EXPOSURE;
range->maximum = ISX012_MAX_EXPOSURE;
range->step = ISX012_STEP_EXPOSURE;
@@ -1925,7 +1925,7 @@ static int isx012_get_supported_value(FAR struct imgsensor_s *sensor,
break;
case IMGSENSOR_ID_WIDE_DYNAMIC_RANGE:
- value->type = IMGSENSOR_CTRL_TYPE_BOOLEAN;
+ value->type = IMGSENSOR_CTRL_TYPE_INTEGER;
range->minimum = ISX012_MIN_YGAMMA;
range->maximum = ISX012_MAX_YGAMMA;
range->step = ISX012_STEP_YGAMMA;
(nuttx) 14/15: drivers/video/isx019: Delete unnecessary code
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 3419f018a432ce33192d5423bd33314c731c15a8
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Fri Jan 26 20:15:14 2024 +0900
drivers/video/isx019: Delete unnecessary code
Because of misunderstanding spec, unnecessary codes exist.
Delete them.
---
drivers/video/isx019.c | 22 ++--------------------
1 file changed, 2 insertions(+), 20 deletions(-)
diff --git a/drivers/video/isx019.c b/drivers/video/isx019.c
index 1da6d4bb84..794cbc3736 100644
--- a/drivers/video/isx019.c
+++ b/drivers/video/isx019.c
@@ -940,20 +940,11 @@ static int fpga_i2c_write(FAR isx019_dev_t *priv, uint8_t addr,
DEBUGASSERT(size <= FPGA_I2C_REGSIZE_MAX);
- config.frequency = ISX019_I2C_FREQUENCY;
- config.address = ISX019_I2C_SLVADDR;
- config.addrlen = ISX019_I2C_SLVADDR_LEN;
-
- nxmutex_lock(&priv->i2c_lock);
-
- /* ISX019 requires that send read command to ISX019 before FPGA access. */
-
- send_read_cmd(priv, &config, CAT_VERSION, ROM_VERSION, 1);
-
config.frequency = FPGA_I2C_FREQUENCY;
config.address = FPGA_I2C_SLVADDR;
config.addrlen = FPGA_I2C_SLVADDR_LEN;
+ nxmutex_lock(&priv->i2c_lock);
buf[FPGA_I2C_OFFSET_ADDR] = addr;
memcpy(&buf[FPGA_I2C_OFFSET_WRITEDATA], data, size);
ret = i2c_write(priv->i2c,
@@ -973,20 +964,11 @@ static int fpga_i2c_read(FAR isx019_dev_t *priv, uint8_t addr,
DEBUGASSERT(size <= FPGA_I2C_REGSIZE_MAX);
- config.frequency = ISX019_I2C_FREQUENCY;
- config.address = ISX019_I2C_SLVADDR;
- config.addrlen = ISX019_I2C_SLVADDR_LEN;
-
- nxmutex_lock(&priv->i2c_lock);
-
- /* ISX019 requires that send read command to ISX019 before FPGA access. */
-
- send_read_cmd(priv, &config, CAT_VERSION, ROM_VERSION, 1);
-
config.frequency = FPGA_I2C_FREQUENCY;
config.address = FPGA_I2C_SLVADDR;
config.addrlen = FPGA_I2C_SLVADDR_LEN;
+ nxmutex_lock(&priv->i2c_lock);
ret = i2c_write(priv->i2c,
&config,
&addr,
(nuttx) 12/15: drivers/video/isx019: Fix default ISO sensitivity
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 2b04210b16df8bb54cb715537efb8edd79ed171d
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Mon Jan 22 19:03:20 2024 +0900
drivers/video/isx019: Fix default ISO sensitivity
ISX019's ISO sensitivity is in auto adjustment mode by default.
Then, default ISO sensitivity value should be auto adjusted value.
---
drivers/video/isx019.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/video/isx019.c b/drivers/video/isx019.c
index e767eee8ec..bd3b18397a 100644
--- a/drivers/video/isx019.c
+++ b/drivers/video/isx019.c
@@ -2020,7 +2020,7 @@ static int isx019_get_supported_value(FAR struct imgsensor_s *sensor,
SET_DISCRETE(val->u.discrete,
NR_ISO,
g_isx019_iso,
- 0);
+ def->iso);
break;
case IMGSENSOR_ID_ISO_SENSITIVITY_AUTO:
(nuttx) 11/15: drivers/video: Fix bug that can not use scene mode
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit ae970a8ed3e42f38718413fa9dc67c83d3cf630f
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Mon Jan 22 17:09:41 2024 +0900
drivers/video: Fix bug that can not use scene mode
Because the mode is set in scene parameter table,
All scene modes was recognized as disabled.
---
drivers/video/video.c | 48 ++++++++++++++++++++++++++++--------------------
1 file changed, 28 insertions(+), 20 deletions(-)
diff --git a/drivers/video/video.c b/drivers/video/video.c
index c66e24a0aa..a661e9e5b5 100644
--- a/drivers/video/video.c
+++ b/drivers/video/video.c
@@ -839,6 +839,7 @@ static int initialize_scene_parameter(FAR video_mng_t *vmng,
return -ENOMEM;
}
+ sp->mode = mode;
sp->brightness = get_default_value(vmng, IMGSENSOR_ID_BRIGHTNESS);
sp->contrast = get_default_value(vmng, IMGSENSOR_ID_CONTRAST);
sp->saturation = get_default_value(vmng, IMGSENSOR_ID_SATURATION);
@@ -898,51 +899,51 @@ static void initialize_scenes_parameter(FAR video_mng_t *vmng)
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_BACKLIGHT */
#ifdef CONFIG_VIDEO_SCENE_BEACHSNOW
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_BEACHSNOW,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_BEACH_SNOW,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_BEACHSNOW */
#ifdef CONFIG_VIDEO_SCENE_CANDLELIGHT
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_CANDLELIGHT,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_CANDLE_LIGHT,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_CANDLELIGHT */
#ifdef CONFIG_VIDEO_SCENE_DAWNDUSK
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_DAWNDUSK,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_DAWN_DUSK,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_DAWNDUSK */
#ifdef CONFIG_VIDEO_SCENE_FALLCOLORS
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_FALLCOLORS,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_FALL_COLORS,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_FALLCOLORS */
#ifdef CONFIG_VIDEO_SCENE_FIREWORKS
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_FIREWORKS,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_FIREWORKS,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_FIREWORKS */
#ifdef CONFIG_VIDEO_SCENE_LANDSCAPE
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_LANDSCAPE,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_LANDSCAPE,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_LANDSCAPE */
#ifdef CONFIG_VIDEO_SCENE_NIGHT
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_NIGHT,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_NIGHT,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_NIGHT */
#ifdef CONFIG_VIDEO_SCENE_PARTYINDOOR
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_PARTYINDOOR,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_PARTY_INDOOR,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_PARTYINDOOR */
#ifdef CONFIG_VIDEO_SCENE_PORTRAIT
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_PORTRAIT,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_PORTRAIT,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_PORTRAIT */
#ifdef CONFIG_VIDEO_SCENE_SPORTS
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_SPORTS,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_SPORTS,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_SPORTS */
#ifdef CONFIG_VIDEO_SCENE_SUNSET
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_SUNSET,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_SUNSET,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_SUNSET */
#ifdef CONFIG_VIDEO_SCENE_TEXT
- initialize_scene_parameter(vmng, CONFIG_VIDEO_SCENE_TEXT,
+ initialize_scene_parameter(vmng, V4L2_SCENE_MODE_TEXT,
&vmng->video_scene_param[vmng->video_scence_num++]);
#endif /* CONFIG_VIDEO_SCENE_TEXT */
}
@@ -2344,16 +2345,23 @@ static int video_g_ext_ctrls(FAR struct video_mng_s *priv,
cnt < ctrls->count;
cnt++, control++)
{
- ret = IMGSENSOR_GET_VALUE(priv->imgsensor,
- control->id,
- control->size,
- (imgsensor_value_t *)&control->value64);
- if (ret < 0)
+ if (control->id == V4L2_CID_SCENE_MODE)
{
- /* Set cnt in that error occurred */
+ control->value = priv->video_scene_mode;
+ }
+ else
+ {
+ ret = IMGSENSOR_GET_VALUE(priv->imgsensor,
+ control->id,
+ control->size,
+ (imgsensor_value_t *)&control->value64);
+ if (ret < 0)
+ {
+ /* Set cnt in that error occurred */
- ctrls->error_idx = cnt;
- return ret;
+ ctrls->error_idx = cnt;
+ return ret;
+ }
}
}
(nuttx) 13/15: drivers/video/isx019: Store initial gamma value
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit baa2dc5cad84c96f8a306916d36e5a190e007bf0
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Mon Jan 22 19:13:29 2024 +0900
drivers/video/isx019: Store initial gamma value
Set initial gamma value to enable application to get
the correct initial gamma value.
---
drivers/video/isx019.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/video/isx019.c b/drivers/video/isx019.c
index bd3b18397a..1da6d4bb84 100644
--- a/drivers/video/isx019.c
+++ b/drivers/video/isx019.c
@@ -1396,6 +1396,10 @@ static int isx019_init(FAR struct imgsensor_s *sensor)
initialize_wbmode(priv);
initialize_jpg_quality(priv);
+ /* Set initial gamma value for getting current value API. */
+
+ priv->gamma = 1000;
+
/* Because store_default_value() needs the clock ratio,
* clock_ratio has to be calculated first.
*/
(nuttx) 09/15: drivers/video/isx019: Fix control type about some parameters
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit de3bee313ed556688e49688aae07f2a8c049d71e
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Fri Jan 19 10:59:17 2024 +0900
drivers/video/isx019: Fix control type about some parameters
About IMGSENSOR_ID_EXPOSURE_AUTO, IMGSENSOR_ID_ISO_SENSITIVITY_AUTO,
and IMGSENSOR_ID_EXPOSURE_METERING, enumerations are defined.
So, control type should be not integer but integer menu.
---
drivers/video/isx019.c | 52 ++++++++++++++++++++++++++++++++++++++++----------
1 file changed, 42 insertions(+), 10 deletions(-)
diff --git a/drivers/video/isx019.c b/drivers/video/isx019.c
index d7aa292414..07081bb3d8 100644
--- a/drivers/video/isx019.c
+++ b/drivers/video/isx019.c
@@ -810,7 +810,7 @@ static const int32_t g_isx019_wbmode[] =
#define NR_WBMODE (sizeof(g_isx019_wbmode) / sizeof(int32_t))
-static int32_t g_isx019_iso[] =
+static const int32_t g_isx019_iso[] =
{
1000, /* ISO1 */
1200, /* ISO1.2 */
@@ -900,6 +900,32 @@ static const uint8_t g_isx019_gain[] =
38, /* gain for ISO5000 */
};
+static const int32_t g_isx019_iso_auto[] =
+{
+ IMGSENSOR_ISO_SENSITIVITY_MANUAL,
+ IMGSENSOR_ISO_SENSITIVITY_AUTO,
+};
+
+#define NR_ISO_AUTO (sizeof(g_isx019_iso_auto) / sizeof(int32_t))
+
+static const int32_t g_isx019_metering[] =
+{
+ IMGSENSOR_EXPOSURE_METERING_AVERAGE,
+ IMGSENSOR_EXPOSURE_METERING_CENTER_WEIGHTED,
+ IMGSENSOR_EXPOSURE_METERING_SPOT,
+ IMGSENSOR_EXPOSURE_METERING_MATRIX,
+};
+
+#define NR_METERING (sizeof(g_isx019_metering) / sizeof(int32_t))
+
+static const int32_t g_isx019_ae[] =
+{
+ IMGSENSOR_EXPOSURE_AUTO,
+ IMGSENSOR_EXPOSURE_MANUAL,
+};
+
+#define NR_AE (sizeof(g_isx019_ae) / sizeof(int32_t))
+
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -1957,9 +1983,11 @@ static int isx019_get_supported_value(FAR struct imgsensor_s *sensor,
break;
case IMGSENSOR_ID_EXPOSURE_AUTO:
- val->type = IMGSENSOR_CTRL_TYPE_INTEGER;
- SET_RANGE(val->u.range, MIN_AE, MAX_AE,
- STEP_AE, def->ae);
+ val->type = IMGSENSOR_CTRL_TYPE_INTEGER_MENU;
+ SET_DISCRETE(val->u.discrete,
+ NR_AE,
+ g_isx019_ae,
+ IMGSENSOR_EXPOSURE_AUTO);
break;
case IMGSENSOR_ID_EXPOSURE_ABSOLUTE:
@@ -1991,15 +2019,19 @@ static int isx019_get_supported_value(FAR struct imgsensor_s *sensor,
break;
case IMGSENSOR_ID_ISO_SENSITIVITY_AUTO:
- val->type = IMGSENSOR_CTRL_TYPE_INTEGER;
- SET_RANGE(val->u.range, MIN_AUTOISO, MAX_AUTOISO,
- STEP_AUTOISO, def->iso_auto);
+ val->type = IMGSENSOR_CTRL_TYPE_INTEGER_MENU;
+ SET_DISCRETE(val->u.discrete,
+ NR_ISO_AUTO,
+ g_isx019_iso_auto,
+ IMGSENSOR_ISO_SENSITIVITY_AUTO);
break;
case IMGSENSOR_ID_EXPOSURE_METERING:
- val->type = IMGSENSOR_CTRL_TYPE_INTEGER;
- SET_RANGE(val->u.range, MIN_METER, MAX_METER,
- STEP_METER, def->meter);
+ val->type = IMGSENSOR_CTRL_TYPE_INTEGER_MENU;
+ SET_DISCRETE(val->u.discrete,
+ NR_METERING,
+ g_isx019_metering,
+ IMGSENSOR_EXPOSURE_METERING_AVERAGE);
break;
case IMGSENSOR_ID_SPOT_POSITION:
(nuttx) 02/15: drivers/video/isx019: Fix supported ISO sensitivity
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit f1bc6aada3136e5503f593562e42727cfdf7c0b5
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Tue Oct 17 10:09:40 2023 +0900
drivers/video/isx019: Fix supported ISO sensitivity
Support not continuous values but discrete values.
---
drivers/video/isx019.c | 180 +++++++++++++++++++++++++++++++++++--------------
1 file changed, 130 insertions(+), 50 deletions(-)
diff --git a/drivers/video/isx019.c b/drivers/video/isx019.c
index fd4796ef05..7ca13b53aa 100644
--- a/drivers/video/isx019.c
+++ b/drivers/video/isx019.c
@@ -221,7 +221,6 @@ struct isx019_dev_s
uint8_t flip_still;
isx019_rect_t clip_video;
isx019_rect_t clip_still;
- int32_t iso;
double gamma;
int32_t jpg_quality;
imgsensor_colorfx_t colorfx;
@@ -797,6 +796,96 @@ static const int32_t g_isx019_wbmode[] =
#define NR_WBMODE (sizeof(g_isx019_wbmode) / sizeof(int32_t))
+static int32_t g_isx019_iso[] =
+{
+ 1000, /* ISO1 */
+ 1200, /* ISO1.2 */
+ 1600, /* ISO1.6 */
+ 2000, /* ISO2 */
+ 2500, /* ISO2.5 */
+ 3000, /* ISO3 */
+ 4000, /* ISO4 */
+ 5000, /* ISO5 */
+ 6000, /* ISO6 */
+ 8000, /* ISO8 */
+ 10000, /* ISO10 */
+ 12000, /* ISO12 */
+ 16000, /* ISO16 */
+ 20000, /* ISO20 */
+ 25000, /* ISO25 */
+ 32000, /* ISO32 */
+ 40000, /* ISO40 */
+ 50000, /* ISO50 */
+ 64000, /* ISO64 */
+ 80000, /* ISO80 */
+ 100000, /* ISO100 */
+ 125000, /* ISO125 */
+ 160000, /* ISO160 */
+ 200000, /* ISO200 */
+ 250000, /* ISO250 */
+ 320000, /* ISO320 */
+ 400000, /* ISO400 */
+ 500000, /* ISO500 */
+ 640000, /* ISO640 */
+ 800000, /* ISO800 */
+ 1000000, /* ISO1000 */
+ 1250000, /* ISO1250 */
+ 1600000, /* ISO1600 */
+ 2000000, /* ISO2000 */
+ 2500000, /* ISO2500 */
+ 3200000, /* ISO3200 */
+ 4000000, /* ISO4000 */
+ 5000000, /* ISO5000 */
+};
+
+#define NR_ISO (sizeof(g_isx019_iso) / sizeof(int32_t))
+
+/* Gain values corresponding to each element of g_isx019_iso table.
+ * This needs to have the same size as g_isx019_iso.
+ */
+
+static const uint8_t g_isx019_gain[] =
+{
+ 1, /* gain for ISO1 */
+ 2, /* gain for ISO1.2 */
+ 3, /* gain for ISO1.6 */
+ 4, /* gain for ISO2 */
+ 5, /* gain for ISO2.5 */
+ 6, /* gain for ISO3 */
+ 7, /* gain for ISO4 */
+ 8, /* gain for ISO5 */
+ 9, /* gain for ISO6 */
+ 10, /* gain for ISO8 */
+ 11, /* gain for ISO10 */
+ 12, /* gain for ISO12 */
+ 13, /* gain for ISO16 */
+ 14, /* gain for ISO20 */
+ 15, /* gain for ISO25 */
+ 16, /* gain for ISO32 */
+ 17, /* gain for ISO40 */
+ 18, /* gain for ISO50 */
+ 19, /* gain for ISO64 */
+ 20, /* gain for ISO80 */
+ 21, /* gain for ISO100 */
+ 22, /* gain for ISO125 */
+ 23, /* gain for ISO160 */
+ 24, /* gain for ISO200 */
+ 25, /* gain for ISO250 */
+ 26, /* gain for ISO320 */
+ 27, /* gain for ISO400 */
+ 28, /* gain for ISO500 */
+ 29, /* gain for ISO640 */
+ 30, /* gain for ISO800 */
+ 31, /* gain for ISO1000 */
+ 32, /* gain for ISO1250 */
+ 33, /* gain for ISO1600 */
+ 34, /* gain for ISO2000 */
+ 35, /* gain for ISO2500 */
+ 36, /* gain for ISO3200 */
+ 37, /* gain for ISO4000 */
+ 38, /* gain for ISO5000 */
+};
+
/****************************************************************************
* Private Functions
****************************************************************************/
@@ -1875,9 +1964,11 @@ static int isx019_get_supported_value(FAR struct imgsensor_s *sensor,
break;
case IMGSENSOR_ID_ISO_SENSITIVITY:
- val->type = IMGSENSOR_CTRL_TYPE_INTEGER;
- SET_RANGE(val->u.range, MIN_ISO, MAX_ISO,
- STEP_ISO, def->iso);
+ val->type = IMGSENSOR_CTRL_TYPE_INTEGER_MENU;
+ SET_DISCRETE(val->u.discrete,
+ NR_ISO,
+ g_isx019_iso,
+ 0);
break;
case IMGSENSOR_ID_ISO_SENSITIVITY_AUTO:
@@ -2578,18 +2669,21 @@ static int set_3aparameter(FAR isx019_dev_t *priv,
return OK;
}
-static uint16_t calc_gain(double iso)
+static uint16_t get_gain_from_iso(int32_t iso)
{
- double gain;
+ int i;
- gain = 1 + 10 * log(iso) / M_LN10;
+ for (i = 0; i < NR_ISO; i++)
+ {
+ if (g_isx019_iso[i] == iso)
+ {
+ break;
+ }
+ }
- /* In the above formula, the unit of gain is dB.
- * Because the register has the 0.1dB unit,
- * return 10 times dB value.
- */
+ /* Return gain corresponding to specified ISO sensitivity. */
- return (uint16_t)(gain * 10);
+ return (uint16_t)g_isx019_gain[i];
}
static int set_iso(FAR isx019_dev_t *priv,
@@ -2601,10 +2695,9 @@ static int set_iso(FAR isx019_dev_t *priv,
* So, calculate gain from ISO sensitivity.
*/
- gain = calc_gain(val.value32 / 1000);
+ gain = get_gain_from_iso(val.value32) * 10;
isx019_i2c_write(priv, CAT_CATAE, GAIN_PRIMODE, &gain, 2);
- priv->iso = val.value32;
return OK;
}
@@ -2617,7 +2710,6 @@ static int set_iso_auto(FAR isx019_dev_t *priv,
if (val.value32 == IMGSENSOR_ISO_SENSITIVITY_AUTO)
{
gain = 0;
- priv->iso = 0;
}
else /* IMGSENSOR_ISO_SENSITIVITY_MANUAL */
{
@@ -2635,8 +2727,6 @@ static int set_iso_auto(FAR isx019_dev_t *priv,
isx019_i2c_read(priv, CAT_AECOM, GAIN_LEVEL, &buf, 1);
gain = buf * 3;
}
-
- priv->iso = val.value32;
}
return isx019_i2c_write(priv, CAT_CATAE, GAIN_PRIMODE, &gain, 2);
@@ -3293,56 +3383,46 @@ static int get_3astatus(FAR isx019_dev_t *priv,
return OK;
}
-static double calc_iso(double gain)
+static int32_t get_iso_from_gain(uint8_t gain)
{
- int k;
- double z;
- double r;
-
- /* ISO sensitivity = 10^((gain - 1) / 10)
- * So, replace z = (gain - 1) / 10 and
- * calculate 10^z.
- */
+ int i;
- /* Divide z into integer and other parts.
- * z = log10(E) (k * ln2 + r)
- * (k : integer, r < 0.5 * ln2)
- *
- * Then, 10^z = (2^k) * e^r (r < 0.5 * ln2)
- */
+ /* g_isx019_gain and g_isx019_iso has the common index. */
- z = (gain - 1) / 10;
+ for (i = 0; i < NR_ISO; i++)
+ {
+ if (g_isx019_gain[i] == gain)
+ {
+ break;
+ }
+ }
- k = z * M_LN10 / M_LN2;
- r = z * M_LN10 - k * M_LN2;
+ if (i >= NR_ISO)
+ {
+ i = NR_ISO - 1;
+ }
- return (1 << k) * exp(r);
+ return g_isx019_iso[i];
}
static int get_iso(FAR isx019_dev_t *priv,
FAR imgsensor_value_t *val)
{
- uint8_t buf = 0;
+ uint8_t gain = 0;
if (val == NULL)
{
return -EINVAL;
}
- if (priv->iso == 0)
- {
- /* iso = 0 means auto adjustment mode.
- * In such a case, get gain from auto adjustment value register,
- * which has the unit 0.3dB, and convert the gain to ISO.
- */
+ /* The current gain value register has the 0.3dB unit.
+ * So, round the gain to integer, and convert to ISO.
+ */
- isx019_i2c_read(priv, CAT_AECOM, GAIN_LEVEL, &buf, 1);
- val->value32 = calc_iso((double)buf * 0.3) * USEC_PER_MSEC;
- }
- else
- {
- val->value32 = priv->iso;
- }
+ isx019_i2c_read(priv, CAT_AECOM, GAIN_LEVEL, &gain, 1);
+ gain = ((gain * 3) + 5) / 10;
+
+ val->value32 = get_iso_from_gain(gain);
return OK;
}
(nuttx) 08/15: drivers/video: Add elems setting
Posted by je...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
jerpelea pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git
commit 865c88e34b9e5e64e481c319bc3571e33175f25c
Author: SPRESENSE <41...@users.noreply.github.com>
AuthorDate: Thu Jan 18 16:51:02 2024 +0900
drivers/video: Add elems setting
Add elems setting to ioctl(VIDIOC_QUERY_EXT_CTRL)
for V4L2 compatibility.
---
drivers/video/video.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/video/video.c b/drivers/video/video.c
index 069445ca30..c66e24a0aa 100644
--- a/drivers/video/video.c
+++ b/drivers/video/video.c
@@ -2152,6 +2152,7 @@ static int video_query_ext_ctrl(FAR struct video_mng_s *vmng,
attr->flags = 0;
attr->elem_size = 0;
+ attr->elems = 1;
attr->nr_of_dims = 0;
memset(attr->dims, 0, sizeof(attr->dims));