drivers/video: Add 3A parameter control
Provide functions which get and set the 3A (Auto white balance/Auto exposure/Auto focus) parameters. These are achieved by the ioctl request codes VIDIOC_G_EXT_CTRLS and VIDIOC_S_EXT_CTRLS which have the following settings: 1. ctrl_class = V4L2_CTRL_CLASS_CAMERA 2. id = V4L2_CID_3A_PARAMETER Also, provide function which get the 3A adjustment status. This is achieved by the ioctl request codes VIDIOC_G_EXT_CTRLS which has the following settings: 1. ctrl_class = V4L2_CTRL_CLASS_CAMERA 2. id = V4L2_CID_3A_STATUS
This commit is contained in:
parent
28ba7f4a1e
commit
45e9c2c8f5
@ -2385,6 +2385,29 @@ static int isx012_get_range_of_ctrlval(FAR struct v4l2_query_ext_ctrl *range)
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case V4L2_CID_3A_PARAMETER:
|
||||||
|
range->type = V4L2_CTRL_TYPE_U16;
|
||||||
|
range->minimum = 0;
|
||||||
|
range->maximum = 65535;
|
||||||
|
range->step = 1;
|
||||||
|
range->elems = 3;
|
||||||
|
strncpy(range->name,
|
||||||
|
"AWB/AE parameter",
|
||||||
|
sizeof(range->name));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case V4L2_CID_3A_STATUS:
|
||||||
|
range->type = V4L2_CTRL_TYPE_INTEGER;
|
||||||
|
range->minimum = 0;
|
||||||
|
range->maximum = 3;
|
||||||
|
range->step = 1;
|
||||||
|
strncpy(range->name,
|
||||||
|
"AWB/AE status",
|
||||||
|
sizeof(range->name));
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default: /* Unsupported control id */
|
default: /* Unsupported control id */
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -2505,6 +2528,7 @@ static int isx012_get_ctrlval(uint16_t ctrl_class,
|
|||||||
FAR struct isx012_dev_s *priv = &g_isx012_private;
|
FAR struct isx012_dev_s *priv = &g_isx012_private;
|
||||||
int16_t readvalue;
|
int16_t readvalue;
|
||||||
uint8_t cnt;
|
uint8_t cnt;
|
||||||
|
uint8_t threea_enable;
|
||||||
uint16_t read_src;
|
uint16_t read_src;
|
||||||
uint16_t *read_dst;
|
uint16_t *read_dst;
|
||||||
int ret = -EINVAL;
|
int ret = -EINVAL;
|
||||||
@ -2825,6 +2849,76 @@ static int isx012_get_ctrlval(uint16_t ctrl_class,
|
|||||||
|
|
||||||
control->value = g_isx012_supported_photometry[cnt].v4l2;
|
control->value = g_isx012_supported_photometry[cnt].v4l2;
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case V4L2_CID_3A_PARAMETER:
|
||||||
|
if (control->p_u16 == NULL)
|
||||||
|
{
|
||||||
|
return -EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Get AWB parameter */
|
||||||
|
|
||||||
|
control->p_u16[0] = isx012_getreg(priv,
|
||||||
|
RATIO_R,
|
||||||
|
2);
|
||||||
|
control->p_u16[1] = isx012_getreg(priv,
|
||||||
|
RATIO_B,
|
||||||
|
2);
|
||||||
|
|
||||||
|
/* Get AE parameter */
|
||||||
|
|
||||||
|
control->p_u16[2] = isx012_getreg(priv,
|
||||||
|
AELEVEL,
|
||||||
|
2);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
|
case V4L2_CID_3A_STATUS:
|
||||||
|
|
||||||
|
/* Initialize returned status */
|
||||||
|
|
||||||
|
control->value = V4L2_3A_STATUS_STABLE;
|
||||||
|
|
||||||
|
/* Get AWB/AE enable or not */
|
||||||
|
|
||||||
|
threea_enable = isx012_getreg(priv,
|
||||||
|
CPUEXT,
|
||||||
|
1);
|
||||||
|
|
||||||
|
/* Check AWB */
|
||||||
|
|
||||||
|
if ((threea_enable & REGVAL_CPUEXT_BIT_AWBSTOP)
|
||||||
|
!= REGVAL_CPUEXT_BIT_AWBSTOP)
|
||||||
|
{
|
||||||
|
/* Check AWB status */
|
||||||
|
|
||||||
|
readvalue = isx012_getreg(priv,
|
||||||
|
AWBSTS,
|
||||||
|
1);
|
||||||
|
if (readvalue != REGVAL_AWBSTS_STOP) /* AWB is not stopped */
|
||||||
|
{
|
||||||
|
control->value |= V4L2_3A_STATUS_AWB_OPERATING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Check AE */
|
||||||
|
|
||||||
|
if ((threea_enable & REGVAL_CPUEXT_BIT_AESTOP)
|
||||||
|
!= REGVAL_CPUEXT_BIT_AESTOP)
|
||||||
|
{
|
||||||
|
/* Check AE status */
|
||||||
|
|
||||||
|
readvalue = isx012_getreg(priv,
|
||||||
|
AESTS,
|
||||||
|
1);
|
||||||
|
if (readvalue != REGVAL_AESTS_STOP) /* AE is not stopped */
|
||||||
|
{
|
||||||
|
control->value |= V4L2_3A_STATUS_AE_OPERATING;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
default: /* Unsupported control id */
|
default: /* Unsupported control id */
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
@ -3385,6 +3479,39 @@ static int isx012_set_ctrlval(uint16_t ctrl_class,
|
|||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case V4L2_CID_3A_PARAMETER:
|
||||||
|
|
||||||
|
/* AWB parameter : red */
|
||||||
|
|
||||||
|
ret = isx012_putreg(priv,
|
||||||
|
INIT_CONT_INR,
|
||||||
|
control->p_u16[0],
|
||||||
|
2);
|
||||||
|
ret = isx012_putreg(priv,
|
||||||
|
INIT_CONT_OUTR,
|
||||||
|
control->p_u16[0],
|
||||||
|
2);
|
||||||
|
|
||||||
|
/* AWB parameter : blue */
|
||||||
|
|
||||||
|
ret = isx012_putreg(priv,
|
||||||
|
INIT_CONT_INB,
|
||||||
|
control->p_u16[1],
|
||||||
|
2);
|
||||||
|
ret = isx012_putreg(priv,
|
||||||
|
INIT_CONT_OUTB,
|
||||||
|
control->p_u16[1],
|
||||||
|
2);
|
||||||
|
|
||||||
|
/* AE parameter */
|
||||||
|
|
||||||
|
ret = isx012_putreg(priv,
|
||||||
|
AE_START_LEVEL,
|
||||||
|
control->p_u16[2],
|
||||||
|
2);
|
||||||
|
|
||||||
|
break;
|
||||||
|
|
||||||
default: /* Unsupported control id */
|
default: /* Unsupported control id */
|
||||||
|
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -681,12 +681,17 @@
|
|||||||
#define AESPEED_INIT (AE_BASE+0x0031)
|
#define AESPEED_INIT (AE_BASE+0x0031)
|
||||||
#define AESPEED_FAST (AE_BASE+0x0032)
|
#define AESPEED_FAST (AE_BASE+0x0032)
|
||||||
#define FASTMOVE_TIMEOUT (AE_BASE+0x003D)
|
#define FASTMOVE_TIMEOUT (AE_BASE+0x003D)
|
||||||
|
#define AE_START_LEVEL (AE_BASE+0x0040)
|
||||||
|
|
||||||
/* AWB OFFSET */
|
/* AWB OFFSET */
|
||||||
|
|
||||||
#define ATW_INITMASK (AWB_BASE+0x0004)
|
#define ATW_INITMASK (AWB_BASE+0x0004)
|
||||||
#define INIT_GAINS (AWB_BASE+0x0023)
|
#define INIT_GAINS (AWB_BASE+0x0023)
|
||||||
#define INIT_SFTLMT (AWB_BASE+0x002C)
|
#define INIT_SFTLMT (AWB_BASE+0x002C)
|
||||||
|
#define INIT_CONT_INR (AWB_BASE+0x0038)
|
||||||
|
#define INIT_CONT_INB (AWB_BASE+0x003A)
|
||||||
|
#define INIT_CONT_OUTR (AWB_BASE+0x003C)
|
||||||
|
#define INIT_CONT_OUTB (AWB_BASE+0x003E)
|
||||||
|
|
||||||
/* AF OFFSET */
|
/* AF OFFSET */
|
||||||
|
|
||||||
@ -803,6 +808,7 @@
|
|||||||
/* AUTOCOM OFFSET */
|
/* AUTOCOM OFFSET */
|
||||||
|
|
||||||
#define MIPIOUT_EN (AUTOCOM_BASE+0x0031)
|
#define MIPIOUT_EN (AUTOCOM_BASE+0x0031)
|
||||||
|
#define AELEVEL (AUTOCOM_BASE+0x0099)
|
||||||
|
|
||||||
/* VFRMPARA OFFSET */
|
/* VFRMPARA OFFSET */
|
||||||
|
|
||||||
@ -1258,6 +1264,10 @@
|
|||||||
|
|
||||||
/* SOUT OFFSET */
|
/* SOUT OFFSET */
|
||||||
|
|
||||||
|
#define AESTS (SOUT_BASE+0x0000)
|
||||||
|
#define AWBSTS (SOUT_BASE+0x0024)
|
||||||
|
#define RATIO_R (SOUT_BASE+0x002E)
|
||||||
|
#define RATIO_B (SOUT_BASE+0x0030)
|
||||||
#define CAP_END_F (SOUT_BASE+0x0078)
|
#define CAP_END_F (SOUT_BASE+0x0078)
|
||||||
#define AF_STATE (SOUT_BASE+0x018A)
|
#define AF_STATE (SOUT_BASE+0x018A)
|
||||||
#define AF_RESULT (SOUT_BASE+0x018B)
|
#define AF_RESULT (SOUT_BASE+0x018B)
|
||||||
@ -1338,6 +1348,9 @@
|
|||||||
#define REGVAL_CPUEXT_BIT_AESTOP (0x02)
|
#define REGVAL_CPUEXT_BIT_AESTOP (0x02)
|
||||||
#define REGVAL_CPUEXT_BIT_AWBSTOP (0x04)
|
#define REGVAL_CPUEXT_BIT_AWBSTOP (0x04)
|
||||||
|
|
||||||
|
#define REGVAL_AESTS_STOP (0)
|
||||||
|
#define REGVAL_AWBSTS_STOP (2)
|
||||||
|
|
||||||
#define REGVAL_READVECT_BIT_V (0x01)
|
#define REGVAL_READVECT_BIT_V (0x01)
|
||||||
#define REGVAL_READVECT_BIT_H (0x02)
|
#define REGVAL_READVECT_BIT_H (0x02)
|
||||||
|
|
||||||
|
@ -201,15 +201,22 @@ enum v4l2_scene_mode
|
|||||||
|
|
||||||
#define V4L2_CID_3A_LOCK (17) /**< Lock 3A */
|
#define V4L2_CID_3A_LOCK (17) /**< Lock 3A */
|
||||||
#define V4L2_LOCK_EXPOSURE (1 << 0) /**< Exposure bit for
|
#define V4L2_LOCK_EXPOSURE (1 << 0) /**< Exposure bit for
|
||||||
V4L2_CID_3A_LOCK */
|
* V4L2_CID_3A_LOCK */
|
||||||
#define V4L2_LOCK_WHITE_BALANCE (1 << 1) /**< White balance bit for
|
#define V4L2_LOCK_WHITE_BALANCE (1 << 1) /**< White balance bit for
|
||||||
V4L2_CID_3A_LOCK */
|
* V4L2_CID_3A_LOCK */
|
||||||
#define V4L2_LOCK_FOCUS (1 << 2) /**< Focus bit for
|
#define V4L2_LOCK_FOCUS (1 << 2) /**< Focus bit for
|
||||||
V4L2_CID_3A_LOCK */
|
* V4L2_CID_3A_LOCK */
|
||||||
|
|
||||||
#define V4L2_CID_AUTO_FOCUS_START (18) /**< Start single AF */
|
#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_STOP (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 */
|
||||||
|
|
||||||
/** Flash and privacy (indicator) light controls */
|
/** Flash and privacy (indicator) light controls */
|
||||||
|
|
||||||
#define V4L2_CID_FLASH_LED_MODE (0)
|
#define V4L2_CID_FLASH_LED_MODE (0)
|
||||||
|
Loading…
Reference in New Issue
Block a user