mirror of
https://github.com/apache/nuttx.git
synced 2026-05-22 05:42:05 +08:00
drivers/camera: Support the private data for imgsensor and imgdata
Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
committed by
Alin Jerpelea
parent
372fee9412
commit
55679aec5f
@@ -204,63 +204,72 @@ static int cisif_intc_handler(int irq, void *context, void *arg);
|
||||
|
||||
/* video image data operations */
|
||||
|
||||
static int cxd56_cisif_init(void);
|
||||
static int cxd56_cisif_uninit(void);
|
||||
static int cxd56_cisif_init(struct imgdata_s *data);
|
||||
static int cxd56_cisif_uninit(struct imgdata_s *data);
|
||||
static int cxd56_cisif_validate_frame_setting
|
||||
(uint8_t nr_datafmt,
|
||||
(struct imgdata_s *data,
|
||||
uint8_t nr_datafmt,
|
||||
imgdata_format_t *datafmt,
|
||||
imgdata_interval_t *interval);
|
||||
static int cxd56_cisif_start_capture
|
||||
(uint8_t nr_datafmt,
|
||||
(struct imgdata_s *data,
|
||||
uint8_t nr_datafmt,
|
||||
imgdata_format_t *datafmt,
|
||||
imgdata_interval_t *interval,
|
||||
imgdata_capture_t callback);
|
||||
static int cxd56_cisif_stop_capture(void);
|
||||
static int cxd56_cisif_validate_buf(uint8_t *addr, uint32_t size);
|
||||
static int cxd56_cisif_set_buf(uint8_t *addr, uint32_t size);
|
||||
static int cxd56_cisif_stop_capture(struct imgdata_s *data);
|
||||
static int cxd56_cisif_validate_buf(struct imgdata_s *data,
|
||||
uint8_t *addr, uint32_t size);
|
||||
static int cxd56_cisif_set_buf(struct imgdata_s *data,
|
||||
uint8_t *addr, uint32_t size);
|
||||
|
||||
const intc_func_table g_intcomp_func[] =
|
||||
{
|
||||
cisif_vs_int, /* VS_INT */
|
||||
NULL, /* EOY_INT */
|
||||
NULL, /* SOY_INT */
|
||||
NULL, /* EOI_INT */
|
||||
NULL, /* SOI_INT */
|
||||
NULL, /* YCC_VACT_END_INT */
|
||||
NULL, /* JPG_VACT_END_INT */
|
||||
cisif_ycc_axi_trdn_int, /* YCC_AXI_TRDN_INT */
|
||||
cisif_ycc_nstorage_int, /* YCC_NSTORAGE_INT */
|
||||
NULL, /* YCC_DAREA_END_INT */
|
||||
cisif_jpg_axi_trdn_int, /* JPG_AXI_TRDN_INT */
|
||||
cisif_jpg_nstorage_int, /* JPG_NSTORAGE_INT */
|
||||
NULL, /* JPG_DAREA_END_INT */
|
||||
NULL, /* reserve */
|
||||
NULL, /* reserve */
|
||||
NULL, /* VLATCH_INT */
|
||||
cisif_ycc_err_int, /* SIZE_OVER_INT */
|
||||
cisif_ycc_err_int, /* SIZE_UNDER_INT */
|
||||
cisif_ycc_err_int, /* YCC_MARKER_ERR_INT */
|
||||
cisif_ycc_err_int, /* YCC_AXI_TRERR_INT */
|
||||
cisif_ycc_err_int, /* YCC_FIFO_OVF_INT */
|
||||
cisif_ycc_err_int, /* YCC_MEM_OVF_INT */
|
||||
NULL, /* reserve */
|
||||
NULL, /* reserve */
|
||||
cisif_jpg_err_int, /* JPG_MARKER_ERR_INT */
|
||||
cisif_jpg_err_int, /* JPG_AXI_TRERR_INT */
|
||||
cisif_jpg_err_int, /* JPG_FIFO_OVF_INT */
|
||||
cisif_jpg_err_int, /* JPG_MEM_OVF_INT */
|
||||
cisif_jpg_err_int, /* JPG_ERR_STATUS_INT */
|
||||
};
|
||||
static const intc_func_table g_intcomp_func[] =
|
||||
{
|
||||
cisif_vs_int, /* VS_INT */
|
||||
NULL, /* EOY_INT */
|
||||
NULL, /* SOY_INT */
|
||||
NULL, /* EOI_INT */
|
||||
NULL, /* SOI_INT */
|
||||
NULL, /* YCC_VACT_END_INT */
|
||||
NULL, /* JPG_VACT_END_INT */
|
||||
cisif_ycc_axi_trdn_int, /* YCC_AXI_TRDN_INT */
|
||||
cisif_ycc_nstorage_int, /* YCC_NSTORAGE_INT */
|
||||
NULL, /* YCC_DAREA_END_INT */
|
||||
cisif_jpg_axi_trdn_int, /* JPG_AXI_TRDN_INT */
|
||||
cisif_jpg_nstorage_int, /* JPG_NSTORAGE_INT */
|
||||
NULL, /* JPG_DAREA_END_INT */
|
||||
NULL, /* reserve */
|
||||
NULL, /* reserve */
|
||||
NULL, /* VLATCH_INT */
|
||||
cisif_ycc_err_int, /* SIZE_OVER_INT */
|
||||
cisif_ycc_err_int, /* SIZE_UNDER_INT */
|
||||
cisif_ycc_err_int, /* YCC_MARKER_ERR_INT */
|
||||
cisif_ycc_err_int, /* YCC_AXI_TRERR_INT */
|
||||
cisif_ycc_err_int, /* YCC_FIFO_OVF_INT */
|
||||
cisif_ycc_err_int, /* YCC_MEM_OVF_INT */
|
||||
NULL, /* reserve */
|
||||
NULL, /* reserve */
|
||||
cisif_jpg_err_int, /* JPG_MARKER_ERR_INT */
|
||||
cisif_jpg_err_int, /* JPG_AXI_TRERR_INT */
|
||||
cisif_jpg_err_int, /* JPG_FIFO_OVF_INT */
|
||||
cisif_jpg_err_int, /* JPG_MEM_OVF_INT */
|
||||
cisif_jpg_err_int, /* JPG_ERR_STATUS_INT */
|
||||
};
|
||||
|
||||
const struct imgdata_ops_s g_cxd56_cisif_ops =
|
||||
{
|
||||
.init = cxd56_cisif_init,
|
||||
.uninit = cxd56_cisif_uninit,
|
||||
.set_buf = cxd56_cisif_set_buf,
|
||||
.validate_frame_setting = cxd56_cisif_validate_frame_setting,
|
||||
.start_capture = cxd56_cisif_start_capture,
|
||||
.stop_capture = cxd56_cisif_stop_capture,
|
||||
};
|
||||
static const struct imgdata_ops_s g_cxd56_cisif_ops =
|
||||
{
|
||||
.init = cxd56_cisif_init,
|
||||
.uninit = cxd56_cisif_uninit,
|
||||
.set_buf = cxd56_cisif_set_buf,
|
||||
.validate_frame_setting = cxd56_cisif_validate_frame_setting,
|
||||
.start_capture = cxd56_cisif_start_capture,
|
||||
.stop_capture = cxd56_cisif_stop_capture,
|
||||
};
|
||||
|
||||
static struct imgdata_s g_cxd56_cisif =
|
||||
{
|
||||
&g_cxd56_cisif_ops
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
@@ -764,7 +773,7 @@ static int cisif_chk_yuvfrmsize(int w, int h)
|
||||
* cxd56_cisif_init
|
||||
****************************************************************************/
|
||||
|
||||
static int cxd56_cisif_init(void)
|
||||
static int cxd56_cisif_init(struct imgdata_s *data)
|
||||
{
|
||||
if (g_state != STATE_STANDBY)
|
||||
{
|
||||
@@ -802,7 +811,7 @@ static int cxd56_cisif_init(void)
|
||||
* cxd56_cisif_uninit
|
||||
****************************************************************************/
|
||||
|
||||
static int cxd56_cisif_uninit(void)
|
||||
static int cxd56_cisif_uninit(struct imgdata_s *data)
|
||||
{
|
||||
if (g_state != STATE_READY)
|
||||
{
|
||||
@@ -837,7 +846,8 @@ static int cxd56_cisif_uninit(void)
|
||||
****************************************************************************/
|
||||
|
||||
static int cxd56_cisif_start_capture
|
||||
(uint8_t nr_fmt,
|
||||
(struct imgdata_s *data,
|
||||
uint8_t nr_fmt,
|
||||
imgdata_format_t *fmt,
|
||||
imgdata_interval_t *interval,
|
||||
imgdata_capture_t callback)
|
||||
@@ -936,7 +946,7 @@ static int cxd56_cisif_start_capture
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int cxd56_cisif_stop_capture(void)
|
||||
static int cxd56_cisif_stop_capture(struct imgdata_s *data)
|
||||
{
|
||||
g_state = STATE_READY;
|
||||
cisif_reg_write(CISIF_DIN_ENABLE, 0);
|
||||
@@ -946,7 +956,8 @@ static int cxd56_cisif_stop_capture(void)
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int cxd56_cisif_validate_buf(uint8_t *addr, uint32_t size)
|
||||
static int cxd56_cisif_validate_buf(struct imgdata_s *data,
|
||||
uint8_t *addr, uint32_t size)
|
||||
{
|
||||
if (ILLEGAL_BUFADDR_ALIGNMENT(addr) ||
|
||||
size == 0)
|
||||
@@ -957,7 +968,8 @@ static int cxd56_cisif_validate_buf(uint8_t *addr, uint32_t size)
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int cxd56_cisif_set_buf(uint8_t *addr, uint32_t size)
|
||||
static int cxd56_cisif_set_buf(struct imgdata_s *data,
|
||||
uint8_t *addr, uint32_t size)
|
||||
{
|
||||
int ret;
|
||||
uint32_t mode;
|
||||
@@ -965,7 +977,7 @@ static int cxd56_cisif_set_buf(uint8_t *addr, uint32_t size)
|
||||
uint16_t w;
|
||||
uint16_t h;
|
||||
|
||||
ret = cxd56_cisif_validate_buf(addr, size);
|
||||
ret = cxd56_cisif_validate_buf(data, addr, size);
|
||||
if (ret != OK)
|
||||
{
|
||||
return ret;
|
||||
@@ -1009,7 +1021,8 @@ static int cxd56_cisif_set_buf(uint8_t *addr, uint32_t size)
|
||||
}
|
||||
|
||||
static int cxd56_cisif_validate_frame_setting
|
||||
(uint8_t nr_datafmt,
|
||||
(struct imgdata_s *data,
|
||||
uint8_t nr_datafmt,
|
||||
imgdata_format_t *datafmt,
|
||||
imgdata_interval_t *interval)
|
||||
{
|
||||
@@ -1079,7 +1092,7 @@ static int cxd56_cisif_validate_frame_setting
|
||||
|
||||
int cxd56_cisif_initialize(void)
|
||||
{
|
||||
imgdata_register(&g_cxd56_cisif_ops);
|
||||
imgdata_register(&g_cxd56_cisif);
|
||||
return OK;
|
||||
}
|
||||
|
||||
|
||||
+184
-153
@@ -41,6 +41,8 @@
|
||||
|
||||
typedef struct
|
||||
{
|
||||
struct imgdata_s data;
|
||||
struct imgsensor_s sensor;
|
||||
imgdata_capture_t capture_cb;
|
||||
uint32_t buf_size;
|
||||
uint8_t *next_buf;
|
||||
@@ -53,36 +55,39 @@ typedef struct
|
||||
|
||||
/* Video image sensor operations */
|
||||
|
||||
static bool sim_video_is_available(void);
|
||||
static int sim_video_init(void);
|
||||
static int sim_video_uninit(void);
|
||||
static const char *sim_video_get_driver_name(void);
|
||||
static int sim_video_validate_frame_setting(imgsensor_stream_type_t type,
|
||||
static bool sim_video_is_available(struct imgsensor_s *sensor);
|
||||
static int sim_video_init(struct imgsensor_s *sensor);
|
||||
static int sim_video_uninit(struct imgsensor_s *sensor);
|
||||
static const char *sim_video_get_driver_name(struct imgsensor_s *sensor);
|
||||
static int sim_video_validate_frame_setting(struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_datafmt,
|
||||
imgsensor_format_t *datafmts,
|
||||
imgsensor_interval_t *interval);
|
||||
static int sim_video_start_capture(imgsensor_stream_type_t type,
|
||||
static int sim_video_start_capture(struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_datafmt,
|
||||
imgsensor_format_t *datafmts,
|
||||
imgsensor_interval_t *interval);
|
||||
static int sim_video_stop_capture(imgsensor_stream_type_t type);
|
||||
static int sim_video_stop_capture(struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type);
|
||||
|
||||
/* Video image data operations */
|
||||
|
||||
static int sim_video_data_init(void);
|
||||
static int sim_video_data_uninit(void);
|
||||
static int sim_video_data_validate_frame_setting(uint8_t nr_datafmt,
|
||||
static int sim_video_data_init(struct imgdata_s *data);
|
||||
static int sim_video_data_uninit(struct imgdata_s *data);
|
||||
static int sim_video_data_validate_frame_setting(struct imgdata_s *data,
|
||||
uint8_t nr_datafmt,
|
||||
imgdata_format_t *datafmt,
|
||||
imgdata_interval_t *interv);
|
||||
static int sim_video_data_start_capture(uint8_t nr_datafmt,
|
||||
static int sim_video_data_start_capture(struct imgdata_s *data,
|
||||
uint8_t nr_datafmt,
|
||||
imgdata_format_t *datafmt,
|
||||
imgdata_interval_t *interval,
|
||||
imgdata_capture_t callback);
|
||||
static int sim_video_data_stop_capture(void);
|
||||
static int sim_video_data_validate_buf(uint8_t *addr, uint32_t size);
|
||||
static int sim_video_data_set_buf(uint8_t *addr, uint32_t size);
|
||||
|
||||
static uint32_t imgdata_fmt_to_v4l2(uint32_t pixelformat);
|
||||
static int sim_video_data_stop_capture(struct imgdata_s *data);
|
||||
static int sim_video_data_set_buf(struct imgdata_s *data,
|
||||
uint8_t *addr, uint32_t size);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
@@ -109,141 +114,22 @@ static const struct imgdata_ops_s g_sim_video_data_ops =
|
||||
.stop_capture = sim_video_data_stop_capture,
|
||||
};
|
||||
|
||||
static sim_video_priv_t g_sim_video_priv;
|
||||
static sim_video_priv_t g_sim_video_priv =
|
||||
{
|
||||
.data =
|
||||
{
|
||||
&g_sim_video_data_ops
|
||||
},
|
||||
.sensor =
|
||||
{
|
||||
&g_sim_video_ops
|
||||
}
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
/* Sensor op functions are mostly dummy */
|
||||
|
||||
static bool sim_video_is_available(void)
|
||||
{
|
||||
return host_video_is_available(CONFIG_HOST_VIDEO_DEV_PATH);
|
||||
}
|
||||
|
||||
static int sim_video_init(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_uninit(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *sim_video_get_driver_name(void)
|
||||
{
|
||||
return "V4L2 NuttX Sim Driver";
|
||||
}
|
||||
|
||||
static int sim_video_validate_frame_setting(imgsensor_stream_type_t type,
|
||||
uint8_t nr_fmt,
|
||||
imgsensor_format_t *fmt,
|
||||
imgsensor_interval_t *interval)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_start_capture(imgsensor_stream_type_t type,
|
||||
uint8_t nr_fmt,
|
||||
imgsensor_format_t *fmt,
|
||||
imgsensor_interval_t *interval)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_stop_capture(imgsensor_stream_type_t type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Data op functions do all the real work */
|
||||
|
||||
static int sim_video_data_init(void)
|
||||
{
|
||||
memset(&g_sim_video_priv, 0, sizeof(g_sim_video_priv));
|
||||
g_sim_video_priv.vdev = host_video_init(CONFIG_HOST_VIDEO_DEV_PATH);
|
||||
if (g_sim_video_priv.vdev == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_data_uninit(void)
|
||||
{
|
||||
return host_video_uninit(g_sim_video_priv.vdev);
|
||||
}
|
||||
|
||||
static int sim_video_data_validate_buf(uint8_t *addr, uint32_t size)
|
||||
{
|
||||
if (!addr || ((uintptr_t)(addr) & 0x1f))
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_data_set_buf(uint8_t *addr, uint32_t size)
|
||||
{
|
||||
if (sim_video_data_validate_buf(addr, size) < 0)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
g_sim_video_priv.next_buf = addr;
|
||||
g_sim_video_priv.buf_size = size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_data_validate_frame_setting(uint8_t nr_datafmt,
|
||||
imgdata_format_t *datafmt,
|
||||
imgdata_interval_t *interv)
|
||||
{
|
||||
uint32_t v4l2_fmt;
|
||||
|
||||
if (nr_datafmt > 1)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
v4l2_fmt = imgdata_fmt_to_v4l2(datafmt->pixelformat);
|
||||
return host_video_try_fmt(g_sim_video_priv.vdev, datafmt->width,
|
||||
datafmt->height, v4l2_fmt, interv->denominator,
|
||||
interv->numerator);
|
||||
}
|
||||
|
||||
static int sim_video_data_start_capture(uint8_t nr_datafmt,
|
||||
imgdata_format_t *datafmt,
|
||||
imgdata_interval_t *interval,
|
||||
imgdata_capture_t callback)
|
||||
{
|
||||
int ret;
|
||||
|
||||
ret = host_video_set_fmt(g_sim_video_priv.vdev,
|
||||
datafmt[IMGDATA_FMT_MAIN].width,
|
||||
datafmt[IMGDATA_FMT_MAIN].height,
|
||||
imgdata_fmt_to_v4l2(
|
||||
datafmt[IMGDATA_FMT_MAIN].pixelformat),
|
||||
interval->denominator, interval->numerator);
|
||||
if (ret < 0 && ret != -EBUSY)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
g_sim_video_priv.capture_cb = callback;
|
||||
return host_video_start_capture(g_sim_video_priv.vdev);
|
||||
}
|
||||
|
||||
static int sim_video_data_stop_capture(void)
|
||||
{
|
||||
g_sim_video_priv.next_buf = NULL;
|
||||
return host_video_stop_capture(g_sim_video_priv.vdev);
|
||||
}
|
||||
|
||||
/* Helper functions */
|
||||
|
||||
static uint32_t imgdata_fmt_to_v4l2(uint32_t pixelformat)
|
||||
@@ -285,14 +171,160 @@ static uint32_t imgdata_fmt_to_v4l2(uint32_t pixelformat)
|
||||
return fourcc;
|
||||
}
|
||||
|
||||
/* Sensor op functions are mostly dummy */
|
||||
|
||||
static bool sim_video_is_available(struct imgsensor_s *sensor)
|
||||
{
|
||||
return host_video_is_available(CONFIG_HOST_VIDEO_DEV_PATH);
|
||||
}
|
||||
|
||||
static int sim_video_init(struct imgsensor_s *sensor)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_uninit(struct imgsensor_s *sensor)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const char *sim_video_get_driver_name(struct imgsensor_s *sensor)
|
||||
{
|
||||
return "V4L2 NuttX Sim Driver";
|
||||
}
|
||||
|
||||
static int sim_video_validate_frame_setting(struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_fmt,
|
||||
imgsensor_format_t *fmt,
|
||||
imgsensor_interval_t *interval)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_start_capture(struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_fmt,
|
||||
imgsensor_format_t *fmt,
|
||||
imgsensor_interval_t *interval)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_stop_capture(struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Data op functions do all the real work */
|
||||
|
||||
static int sim_video_data_init(struct imgdata_s *data)
|
||||
{
|
||||
sim_video_priv_t *priv = (sim_video_priv_t *)data;
|
||||
|
||||
priv->vdev = host_video_init(CONFIG_HOST_VIDEO_DEV_PATH);
|
||||
if (priv->vdev == NULL)
|
||||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_data_uninit(struct imgdata_s *data)
|
||||
{
|
||||
sim_video_priv_t *priv = (sim_video_priv_t *)data;
|
||||
|
||||
return host_video_uninit(priv->vdev);
|
||||
}
|
||||
|
||||
static int sim_video_data_validate_buf(uint8_t *addr, uint32_t size)
|
||||
{
|
||||
if (!addr || ((uintptr_t)(addr) & 0x1f))
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_data_set_buf(struct imgdata_s *data,
|
||||
uint8_t *addr, uint32_t size)
|
||||
{
|
||||
sim_video_priv_t *priv = (sim_video_priv_t *)data;
|
||||
|
||||
if (sim_video_data_validate_buf(addr, size) < 0)
|
||||
{
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
priv->next_buf = addr;
|
||||
priv->buf_size = size;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int sim_video_data_validate_frame_setting(struct imgdata_s *data,
|
||||
uint8_t nr_datafmt,
|
||||
imgdata_format_t *datafmt,
|
||||
imgdata_interval_t *interv)
|
||||
{
|
||||
sim_video_priv_t *priv = (sim_video_priv_t *)data;
|
||||
uint32_t v4l2_fmt;
|
||||
|
||||
if (nr_datafmt > 1)
|
||||
{
|
||||
return -ENOTSUP;
|
||||
}
|
||||
|
||||
v4l2_fmt = imgdata_fmt_to_v4l2(datafmt->pixelformat);
|
||||
return host_video_try_fmt(priv->vdev, datafmt->width,
|
||||
datafmt->height, v4l2_fmt, interv->denominator,
|
||||
interv->numerator);
|
||||
}
|
||||
|
||||
static int sim_video_data_start_capture(struct imgdata_s *data,
|
||||
uint8_t nr_datafmt,
|
||||
imgdata_format_t *datafmt,
|
||||
imgdata_interval_t *interval,
|
||||
imgdata_capture_t callback)
|
||||
{
|
||||
sim_video_priv_t *priv = (sim_video_priv_t *)data;
|
||||
int ret;
|
||||
|
||||
ret = host_video_set_fmt(priv->vdev,
|
||||
datafmt[IMGDATA_FMT_MAIN].width,
|
||||
datafmt[IMGDATA_FMT_MAIN].height,
|
||||
imgdata_fmt_to_v4l2(
|
||||
datafmt[IMGDATA_FMT_MAIN].pixelformat),
|
||||
interval->denominator, interval->numerator);
|
||||
if (ret < 0 && ret != -EBUSY)
|
||||
{
|
||||
return ret;
|
||||
}
|
||||
|
||||
priv->capture_cb = callback;
|
||||
return host_video_start_capture(priv->vdev);
|
||||
}
|
||||
|
||||
static int sim_video_data_stop_capture(struct imgdata_s *data)
|
||||
{
|
||||
sim_video_priv_t *priv = (sim_video_priv_t *)data;
|
||||
|
||||
priv->next_buf = NULL;
|
||||
return host_video_stop_capture(priv->vdev);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
int sim_video_initialize(void)
|
||||
{
|
||||
imgsensor_register(&g_sim_video_ops);
|
||||
imgdata_register(&g_sim_video_data_ops);
|
||||
sim_video_priv_t *priv = &g_sim_video_priv;
|
||||
|
||||
imgsensor_register(&priv->sensor);
|
||||
imgdata_register(&priv->data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -303,16 +335,15 @@ int sim_video_uninitialize(void)
|
||||
|
||||
void sim_video_loop(void)
|
||||
{
|
||||
sim_video_priv_t *priv = &g_sim_video_priv;
|
||||
int ret;
|
||||
|
||||
if (g_sim_video_priv.next_buf)
|
||||
if (priv->next_buf)
|
||||
{
|
||||
ret = host_video_dqbuf(g_sim_video_priv.vdev,
|
||||
g_sim_video_priv.next_buf,
|
||||
g_sim_video_priv.buf_size);
|
||||
ret = host_video_dqbuf(priv->vdev, priv->next_buf, priv->buf_size);
|
||||
if (ret > 0)
|
||||
{
|
||||
g_sim_video_priv.capture_cb(0, ret);
|
||||
priv->capture_cb(0, ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+74
-65
@@ -187,6 +187,7 @@ typedef struct isx012_rect_s isx012_rect_t;
|
||||
|
||||
struct isx012_dev_s
|
||||
{
|
||||
struct imgsensor_s sensor;
|
||||
mutex_t i2c_lock;
|
||||
FAR struct i2c_master_s *i2c; /* I2C interface */
|
||||
uint8_t i2c_addr; /* I2C address */
|
||||
@@ -230,43 +231,41 @@ static int isx012_change_device_state(FAR isx012_dev_t *priv,
|
||||
isx012_state_t state);
|
||||
static int isx012_replace_frameinterval_to_regval
|
||||
(FAR imgsensor_interval_t *interval);
|
||||
static int8_t isx012_get_maximum_fps
|
||||
(uint8_t nr_datafmt,
|
||||
FAR imgsensor_format_t *datafmt);
|
||||
static int8_t isx012_get_maximum_fps(uint8_t nr_datafmt,
|
||||
FAR imgsensor_format_t *datafmt);
|
||||
static int isx012_set_shd(FAR isx012_dev_t *priv);
|
||||
static bool is_movie_needed(uint8_t fmt, uint8_t fps);
|
||||
|
||||
/* image sensor device operations interface */
|
||||
|
||||
static bool isx012_is_available(void);
|
||||
static int isx012_init(void);
|
||||
static int isx012_uninit(void);
|
||||
static FAR const char *isx012_get_driver_name(void);
|
||||
static int isx012_validate_frame_setting(imgsensor_stream_type_t type,
|
||||
static bool isx012_is_available(FAR struct imgsensor_s *sensor);
|
||||
static int isx012_init(FAR struct imgsensor_s *sensor);
|
||||
static int isx012_uninit(FAR struct imgsensor_s *sensor);
|
||||
static FAR const char *
|
||||
isx012_get_driver_name(FAR struct imgsensor_s *sensor);
|
||||
static int isx012_validate_frame_setting(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_datafmt,
|
||||
FAR imgsensor_format_t *datafmts,
|
||||
FAR imgsensor_interval_t *interval);
|
||||
static int isx012_start_capture(imgsensor_stream_type_t type,
|
||||
static int isx012_start_capture(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_datafmt,
|
||||
FAR imgsensor_format_t *datafmts,
|
||||
FAR imgsensor_interval_t *interval);
|
||||
static int isx012_stop_capture(imgsensor_stream_type_t type);
|
||||
static int isx012_get_supported_value
|
||||
(uint32_t id, FAR imgsensor_supported_value_t *value);
|
||||
static int isx012_get_value
|
||||
(uint32_t id, uint32_t size, FAR imgsensor_value_t *value);
|
||||
static int isx012_set_value
|
||||
(uint32_t id, uint32_t size, imgsensor_value_t value);
|
||||
static int isx012_stop_capture(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type);
|
||||
static int isx012_get_supported_value(FAR struct imgsensor_s *sensor,
|
||||
uint32_t id, FAR imgsensor_supported_value_t *value);
|
||||
static int isx012_get_value(FAR struct imgsensor_s *sensor,
|
||||
uint32_t id, uint32_t size, FAR imgsensor_value_t *value);
|
||||
static int isx012_set_value(FAR struct imgsensor_s *sensor,
|
||||
uint32_t id, uint32_t size, imgsensor_value_t value);
|
||||
|
||||
/****************************************************************************
|
||||
* Private Data
|
||||
****************************************************************************/
|
||||
|
||||
static isx012_dev_t g_isx012_private =
|
||||
{
|
||||
NXMUTEX_INITIALIZER,
|
||||
};
|
||||
|
||||
#ifndef ISX012_NOT_USE_NSTBY
|
||||
static const isx012_reg_t g_isx012_presleep[] =
|
||||
{
|
||||
@@ -537,7 +536,7 @@ static const isx012_reg_t g_isx012_shd_wb[] =
|
||||
|
||||
#define ISX012_SHD_WB_NENTRIES ARRAY_NENTRIES(g_isx012_shd_wb)
|
||||
|
||||
static int32_t g_isx012_colorfx_actual[] =
|
||||
static const int32_t g_isx012_colorfx_actual[] =
|
||||
{
|
||||
IMGSENSOR_COLORFX_NONE,
|
||||
IMGSENSOR_COLORFX_BW,
|
||||
@@ -548,7 +547,7 @@ static int32_t g_isx012_colorfx_actual[] =
|
||||
IMGSENSOR_COLORFX_PASTEL
|
||||
};
|
||||
|
||||
static uint8_t g_isx012_colorfx_regval[] =
|
||||
static const uint8_t g_isx012_colorfx_regval[] =
|
||||
{
|
||||
REGVAL_EFFECT_NONE,
|
||||
REGVAL_EFFECT_MONOTONE,
|
||||
@@ -559,7 +558,7 @@ static uint8_t g_isx012_colorfx_regval[] =
|
||||
REGVAL_EFFECT_PASTEL
|
||||
};
|
||||
|
||||
static int32_t g_isx012_presetwb_actual[] =
|
||||
static const int32_t g_isx012_presetwb_actual[] =
|
||||
{
|
||||
IMGSENSOR_WHITE_BALANCE_AUTO,
|
||||
IMGSENSOR_WHITE_BALANCE_INCANDESCENT,
|
||||
@@ -569,7 +568,7 @@ static int32_t g_isx012_presetwb_actual[] =
|
||||
IMGSENSOR_WHITE_BALANCE_SHADE
|
||||
};
|
||||
|
||||
static uint8_t g_isx012_presetwb_regval[] =
|
||||
static const uint8_t g_isx012_presetwb_regval[] =
|
||||
{
|
||||
REGVAL_AWB_ATM,
|
||||
REGVAL_AWB_LIGHTBULB,
|
||||
@@ -579,7 +578,7 @@ static uint8_t g_isx012_presetwb_regval[] =
|
||||
REGVAL_AWB_SHADE
|
||||
};
|
||||
|
||||
static int32_t g_isx012_photometry_actual[] =
|
||||
static const int32_t g_isx012_photometry_actual[] =
|
||||
{
|
||||
IMGSENSOR_EXPOSURE_METERING_AVERAGE,
|
||||
IMGSENSOR_EXPOSURE_METERING_CENTER_WEIGHTED,
|
||||
@@ -587,7 +586,7 @@ static int32_t g_isx012_photometry_actual[] =
|
||||
IMGSENSOR_EXPOSURE_METERING_MATRIX
|
||||
};
|
||||
|
||||
static uint8_t g_isx012_photometry_regval[] =
|
||||
static const uint8_t g_isx012_photometry_regval[] =
|
||||
{
|
||||
REGVAL_PHOTOMETRY_AVERAGE,
|
||||
REGVAL_PHOTOMETRY_CENTERWEIGHT,
|
||||
@@ -595,7 +594,7 @@ static uint8_t g_isx012_photometry_regval[] =
|
||||
REGVAL_PHOTOMETRY_MULTIPATTERN
|
||||
};
|
||||
|
||||
static int32_t g_isx012_iso_actual[] =
|
||||
static const int32_t g_isx012_iso_actual[] =
|
||||
{
|
||||
25 * 1000,
|
||||
32 * 1000,
|
||||
@@ -618,7 +617,7 @@ static int32_t g_isx012_iso_actual[] =
|
||||
1600 * 1000
|
||||
};
|
||||
|
||||
static uint8_t g_isx012_iso_regval[] =
|
||||
static const uint8_t g_isx012_iso_regval[] =
|
||||
{
|
||||
REGVAL_ISO_25,
|
||||
REGVAL_ISO_32,
|
||||
@@ -641,7 +640,7 @@ static uint8_t g_isx012_iso_regval[] =
|
||||
REGVAL_ISO_1600
|
||||
};
|
||||
|
||||
static struct imgsensor_ops_s g_isx012_ops =
|
||||
static const struct imgsensor_ops_s g_isx012_ops =
|
||||
{
|
||||
isx012_is_available, /* is HW available */
|
||||
isx012_init, /* init */
|
||||
@@ -656,6 +655,14 @@ static struct imgsensor_ops_s g_isx012_ops =
|
||||
isx012_set_value /* set_value */
|
||||
};
|
||||
|
||||
static isx012_dev_t g_isx012_private =
|
||||
{
|
||||
{
|
||||
&g_isx012_ops,
|
||||
},
|
||||
NXMUTEX_INITIALIZER,
|
||||
};
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
@@ -676,7 +683,7 @@ static uint16_t isx012_getreg(FAR isx012_dev_t *priv,
|
||||
buffer[0] = regaddr >> 8;
|
||||
buffer[1] = regaddr & 0xff;
|
||||
|
||||
nxmutex_lock(&g_isx012_private.i2c_lock);
|
||||
nxmutex_lock(&priv->i2c_lock);
|
||||
|
||||
/* Write the register address */
|
||||
|
||||
@@ -696,7 +703,7 @@ static uint16_t isx012_getreg(FAR isx012_dev_t *priv,
|
||||
}
|
||||
}
|
||||
|
||||
nxmutex_unlock(&g_isx012_private.i2c_lock);
|
||||
nxmutex_unlock(&priv->i2c_lock);
|
||||
|
||||
if (ret >= 0)
|
||||
{
|
||||
@@ -726,7 +733,7 @@ static int isx012_putreg(FAR isx012_dev_t *priv,
|
||||
|
||||
memcpy((FAR uint8_t *)&buffer[2], (FAR uint8_t *)®val, regsize);
|
||||
|
||||
nxmutex_lock(&g_isx012_private.i2c_lock);
|
||||
nxmutex_lock(&priv->i2c_lock);
|
||||
|
||||
/* And do it */
|
||||
|
||||
@@ -737,7 +744,7 @@ static int isx012_putreg(FAR isx012_dev_t *priv,
|
||||
verr("i2c_write failed: %d\n", ret);
|
||||
}
|
||||
|
||||
nxmutex_unlock(&g_isx012_private.i2c_lock);
|
||||
nxmutex_unlock(&priv->i2c_lock);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -1320,7 +1327,7 @@ static int isx012_change_device_state(FAR isx012_dev_t *priv,
|
||||
return OK;
|
||||
}
|
||||
|
||||
int init_isx012(FAR struct isx012_dev_s *priv)
|
||||
int init_isx012(FAR isx012_dev_t *priv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@@ -1406,26 +1413,27 @@ int init_isx012(FAR struct isx012_dev_s *priv)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static bool isx012_is_available(void)
|
||||
static bool isx012_is_available(FAR struct imgsensor_s *sensor)
|
||||
{
|
||||
FAR isx012_dev_t *priv = (FAR isx012_dev_t *)sensor;
|
||||
bool ret;
|
||||
|
||||
isx012_init();
|
||||
isx012_init(sensor);
|
||||
|
||||
/* Try to access via I2C.
|
||||
* Select DEVICESTS register, which has positive value.
|
||||
*/
|
||||
|
||||
ret = (isx012_getreg(&g_isx012_private, DEVICESTS, 1) == DEVICESTS_SLEEP);
|
||||
ret = (isx012_getreg(priv, DEVICESTS, 1) == DEVICESTS_SLEEP);
|
||||
|
||||
isx012_uninit();
|
||||
isx012_uninit(sensor);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int isx012_init(void)
|
||||
static int isx012_init(FAR struct imgsensor_s *sensor)
|
||||
{
|
||||
FAR struct isx012_dev_s *priv = &g_isx012_private;
|
||||
FAR isx012_dev_t *priv = (FAR isx012_dev_t *)sensor;
|
||||
int ret = 0;
|
||||
|
||||
priv->i2c = board_isx012_initialize();
|
||||
@@ -1451,9 +1459,9 @@ static int isx012_init(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int isx012_uninit(void)
|
||||
static int isx012_uninit(FAR struct imgsensor_s *sensor)
|
||||
{
|
||||
FAR struct isx012_dev_s *priv = &g_isx012_private;
|
||||
FAR isx012_dev_t *priv = (FAR isx012_dev_t *)sensor;
|
||||
|
||||
int ret = 0;
|
||||
|
||||
@@ -1479,7 +1487,7 @@ static int isx012_uninit(void)
|
||||
return ret;
|
||||
}
|
||||
|
||||
static FAR const char *isx012_get_driver_name(void)
|
||||
static FAR const char *isx012_get_driver_name(FAR struct imgsensor_s *sensor)
|
||||
{
|
||||
return "ISX012";
|
||||
}
|
||||
@@ -1665,7 +1673,8 @@ static int isx012_replace_frameinterval_to_regval
|
||||
}
|
||||
}
|
||||
|
||||
static int isx012_validate_frame_setting(imgsensor_stream_type_t type,
|
||||
static int isx012_validate_frame_setting(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_fmt,
|
||||
FAR imgsensor_format_t *fmt,
|
||||
FAR imgsensor_interval_t *interval)
|
||||
@@ -1704,16 +1713,16 @@ static int isx012_validate_frame_setting(imgsensor_stream_type_t type,
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int isx012_start_capture(imgsensor_stream_type_t type,
|
||||
static int isx012_start_capture(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_fmt,
|
||||
FAR imgsensor_format_t *fmt,
|
||||
FAR imgsensor_interval_t *interval)
|
||||
{
|
||||
FAR isx012_dev_t *priv = (FAR isx012_dev_t *)sensor;
|
||||
int ret;
|
||||
|
||||
FAR struct isx012_dev_s *priv = &g_isx012_private;
|
||||
|
||||
ret = isx012_validate_frame_setting(type, nr_fmt, fmt, interval);
|
||||
ret = isx012_validate_frame_setting(sensor, type, nr_fmt, fmt, interval);
|
||||
if (ret != OK)
|
||||
{
|
||||
return ret;
|
||||
@@ -1722,13 +1731,14 @@ static int isx012_start_capture(imgsensor_stream_type_t type,
|
||||
return isx012_set_mode_param(priv, type, nr_fmt, fmt, interval);
|
||||
}
|
||||
|
||||
static int isx012_stop_capture(imgsensor_stream_type_t type)
|
||||
static int isx012_stop_capture(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type)
|
||||
{
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int isx012_get_supported_value
|
||||
(uint32_t id, FAR imgsensor_supported_value_t *value)
|
||||
static int isx012_get_supported_value(FAR struct imgsensor_s *sensor,
|
||||
uint32_t id, FAR imgsensor_supported_value_t *value)
|
||||
{
|
||||
int ret = OK;
|
||||
FAR imgsensor_capability_range_t *range = &value->u.range;
|
||||
@@ -1971,11 +1981,11 @@ static int isx012_get_supported_value
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int isx012_get_value(uint32_t id,
|
||||
uint32_t size,
|
||||
static int isx012_get_value(FAR struct imgsensor_s *sensor,
|
||||
uint32_t id, uint32_t size,
|
||||
FAR imgsensor_value_t *value)
|
||||
{
|
||||
FAR struct isx012_dev_s *priv = &g_isx012_private;
|
||||
FAR isx012_dev_t *priv = (FAR isx012_dev_t *)sensor;
|
||||
uint16_t readvalue;
|
||||
uint8_t cnt;
|
||||
uint8_t threea_enable;
|
||||
@@ -2346,11 +2356,11 @@ static int set_clip(uint32_t size,
|
||||
return OK;
|
||||
}
|
||||
|
||||
static int isx012_set_value(uint32_t id,
|
||||
uint32_t size,
|
||||
static int isx012_set_value(FAR struct imgsensor_s *sensor,
|
||||
uint32_t id, uint32_t size,
|
||||
imgsensor_value_t value)
|
||||
{
|
||||
FAR struct isx012_dev_s *priv = &g_isx012_private;
|
||||
FAR isx012_dev_t *priv = (FAR isx012_dev_t *)sensor;
|
||||
int ret = -EINVAL;
|
||||
uint8_t cnt;
|
||||
FAR uint16_t *write_src;
|
||||
@@ -2783,8 +2793,7 @@ static int isx012_set_value(uint32_t id,
|
||||
case IMGSENSOR_ID_ISO_SENSITIVITY:
|
||||
for (cnt = 0; cnt < ARRAY_NENTRIES(g_isx012_iso_actual); cnt++)
|
||||
{
|
||||
if (g_isx012_iso_actual[cnt]
|
||||
== value.value32)
|
||||
if (g_isx012_iso_actual[cnt] == value.value32)
|
||||
{
|
||||
ret = isx012_putreg(priv,
|
||||
ISX012_REG_ISO,
|
||||
@@ -2833,8 +2842,7 @@ static int isx012_set_value(uint32_t id,
|
||||
cnt < ARRAY_NENTRIES(g_isx012_photometry_actual);
|
||||
cnt++)
|
||||
{
|
||||
if (g_isx012_photometry_actual[cnt]
|
||||
== value.value32)
|
||||
if (g_isx012_photometry_actual[cnt] == value.value32)
|
||||
{
|
||||
ret = isx012_putreg(priv,
|
||||
ISX012_REG_PHOTOMETRY,
|
||||
@@ -3144,12 +3152,12 @@ static int isx012_set_shd(FAR isx012_dev_t *priv)
|
||||
|
||||
int isx012_initialize(void)
|
||||
{
|
||||
FAR isx012_dev_t *priv = &g_isx012_private;
|
||||
int ret;
|
||||
FAR struct isx012_dev_s *priv = &g_isx012_private;
|
||||
|
||||
/* Register image sensor operations variable */
|
||||
|
||||
ret = imgsensor_register(&g_isx012_ops);
|
||||
ret = imgsensor_register(&priv->sensor);
|
||||
if (ret != OK)
|
||||
{
|
||||
verr("Failed to register ops to video driver.\n");
|
||||
@@ -3172,6 +3180,7 @@ int isx012_uninitialize(void)
|
||||
#ifdef CONFIG_VIDEO_ISX012_REGDEBUG
|
||||
int isx012_read_register(uint16_t addr, FAR uint8_t *buf, uint8_t size)
|
||||
{
|
||||
FAR isx012_dev_t *priv = &g_isx012_private;
|
||||
uint16_t buf16;
|
||||
|
||||
if (buf == NULL)
|
||||
@@ -3184,7 +3193,7 @@ int isx012_read_register(uint16_t addr, FAR uint8_t *buf, uint8_t size)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
buf16 = isx012_getreg(&g_isx012_private, addr, size);
|
||||
buf16 = isx012_getreg(priv, addr, size);
|
||||
memcpy(buf, &buf16, size);
|
||||
return OK;
|
||||
}
|
||||
|
||||
+418
-338
File diff suppressed because it is too large
Load Diff
+70
-143
File diff suppressed because it is too large
Load Diff
@@ -45,6 +45,23 @@
|
||||
#define IMGDATA_PIX_FMT_YUYV (6)
|
||||
#define IMGDATA_PIX_FMT_YUV420P (7)
|
||||
|
||||
/* Method access helper macros */
|
||||
|
||||
#define IMGDATA_INIT(d) \
|
||||
((d)->ops->init ? (d)->ops->init(d) : -ENOTTY)
|
||||
#define IMGDATA_UNINIT(d) \
|
||||
((d)->ops->uninit ? (d)->ops->uninit(d) : -ENOTTY)
|
||||
#define IMGDATA_SET_BUF(d, a, s) \
|
||||
((d)->ops->set_buf ? (d)->ops->set_buf(d, a, s) : NULL)
|
||||
#define IMGDATA_VALIDATE_FRAME_SETTING(d, n, f, i) \
|
||||
((d)->ops->validate_frame_setting ? \
|
||||
(d)->ops->validate_frame_setting(d, n, f, i) : -ENOTTY)
|
||||
#define IMGDATA_START_CAPTURE(d, n, f, i, c) \
|
||||
((d)->ops->start_capture ? \
|
||||
(d)->ops->start_capture(d, n, f, i, c) : -ENOTTY)
|
||||
#define IMGDATA_STOP_CAPTURE(d) \
|
||||
((d)->ops->stop_capture ? (d)->ops->stop_capture(d) : -ENOTTY)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@@ -68,21 +85,35 @@ typedef int (*imgdata_capture_t)(uint8_t result, uint32_t size);
|
||||
|
||||
/* Structure for Data Control I/F */
|
||||
|
||||
struct imgdata_s;
|
||||
struct imgdata_ops_s
|
||||
{
|
||||
CODE int (*init)(void);
|
||||
CODE int (*uninit)(void);
|
||||
CODE int (*init)(FAR struct imgdata_s *data);
|
||||
CODE int (*uninit)(FAR struct imgdata_s *data);
|
||||
|
||||
CODE int (*set_buf)(uint8_t *addr, uint32_t size);
|
||||
CODE int (*set_buf)(FAR struct imgdata_s *data,
|
||||
uint8_t *addr, uint32_t size);
|
||||
|
||||
CODE int (*validate_frame_setting)(uint8_t nr_datafmts,
|
||||
CODE int (*validate_frame_setting)(FAR struct imgdata_s *data,
|
||||
uint8_t nr_datafmts,
|
||||
FAR imgdata_format_t *datafmts,
|
||||
FAR imgdata_interval_t *interval);
|
||||
CODE int (*start_capture)(uint8_t nr_datafmts,
|
||||
CODE int (*start_capture)(FAR struct imgdata_s *data,
|
||||
uint8_t nr_datafmts,
|
||||
FAR imgdata_format_t *datafmts,
|
||||
FAR imgdata_interval_t *interval,
|
||||
FAR imgdata_capture_t callback);
|
||||
CODE int (*stop_capture)(void);
|
||||
CODE int (*stop_capture)(FAR struct imgdata_s *data);
|
||||
};
|
||||
|
||||
/* Image data private data. This structure only defines the initial fields
|
||||
* of the structure visible to the client. The specific implementation may
|
||||
* add additional, device specific fields after the vtable.
|
||||
*/
|
||||
|
||||
struct imgdata_s
|
||||
{
|
||||
FAR const struct imgdata_ops_s *ops;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
@@ -99,7 +130,7 @@ extern "C"
|
||||
|
||||
/* Register image data operations. */
|
||||
|
||||
void imgdata_register(FAR const struct imgdata_ops_s *ops);
|
||||
void imgdata_register(FAR struct imgdata_s *data);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
||||
@@ -121,6 +121,35 @@
|
||||
#define IMGSENSOR_PIX_FMT_YUYV (6)
|
||||
#define IMGSENSOR_PIX_FMT_YUV420P (7)
|
||||
|
||||
/* Method access helper macros */
|
||||
|
||||
#define IMGSENSOR_IS_AVAILABLE(s) \
|
||||
((s)->ops->is_available ? (s)->ops->is_available(s) : false)
|
||||
#define IMGSENSOR_INIT(s) \
|
||||
((s)->ops->init ? (s)->ops->init(s) : -ENOTTY)
|
||||
#define IMGSENSOR_UNINIT(s) \
|
||||
((s)->ops->uninit ? (s)->ops->uninit(s) : -ENOTTY)
|
||||
#define IMGSENSOR_GET_DRIVER_NAME(s) \
|
||||
((s)->ops->get_driver_name ? (s)->ops->get_driver_name(s) : NULL)
|
||||
#define IMGSENSOR_VALIDATE_FRAME_SETTING(s, t, n, f, i) \
|
||||
((s)->ops->validate_frame_setting ? \
|
||||
(s)->ops->validate_frame_setting(s, t, n, f, i) : -ENOTTY)
|
||||
#define IMGSENSOR_START_CAPTURE(s, t, n, f, i) \
|
||||
((s)->ops->start_capture ? \
|
||||
(s)->ops->start_capture(s, t, n, f, i) : -ENOTTY)
|
||||
#define IMGSENSOR_STOP_CAPTURE(s, t) \
|
||||
((s)->ops->stop_capture ? (s)->ops->stop_capture(s, t) : -ENOTTY)
|
||||
#define IMGSENSOR_GET_FRAME_INTERVAL(s, t, i) \
|
||||
((s)->ops->get_frame_interval ? \
|
||||
(s)->ops->get_frame_interval(s, t, i) : -ENOTTY)
|
||||
#define IMGSENSOR_GET_SUPPORTED_VALUE(s, i, v) \
|
||||
((s)->ops->get_supported_value ? \
|
||||
(s)->ops->get_supported_value(s, i, v) : -ENOTTY)
|
||||
#define IMGSENSOR_GET_VALUE(s, i, l, v) \
|
||||
((s)->ops->get_value ? (s)->ops->get_value(s, i, l, v) : -ENOTTY)
|
||||
#define IMGSENSOR_SET_VALUE(s, i, l, v) \
|
||||
((s)->ops->set_value ? (s)->ops->set_value(s, i, l, v) : -ENOTTY)
|
||||
|
||||
/****************************************************************************
|
||||
* Public Types
|
||||
****************************************************************************/
|
||||
@@ -265,7 +294,7 @@ typedef struct imgsensor_capability_range_s
|
||||
typedef struct imgsensor_capability_discrete_s
|
||||
{
|
||||
int8_t nr_values;
|
||||
int32_t *values;
|
||||
FAR const int32_t *values;
|
||||
int32_t default_value;
|
||||
} imgsensor_capability_discrete_t;
|
||||
|
||||
@@ -321,33 +350,49 @@ typedef union imgsensor_value_u
|
||||
|
||||
/* Structure for Image Sensor I/F */
|
||||
|
||||
struct imgsensor_s;
|
||||
struct imgsensor_ops_s
|
||||
{
|
||||
CODE bool (*is_available)(void);
|
||||
CODE int (*init)(void);
|
||||
CODE int (*uninit)(void);
|
||||
CODE const char * (*get_driver_name)(void);
|
||||
CODE int (*validate_frame_setting)(imgsensor_stream_type_t type,
|
||||
CODE bool (*is_available)(FAR struct imgsensor_s *sensor);
|
||||
CODE int (*init)(FAR struct imgsensor_s *sensor);
|
||||
CODE int (*uninit)(FAR struct imgsensor_s *sensor);
|
||||
CODE const char * (*get_driver_name)(FAR struct imgsensor_s *sensor);
|
||||
CODE int (*validate_frame_setting)(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_datafmts,
|
||||
FAR imgsensor_format_t *datafmts,
|
||||
FAR imgsensor_interval_t *interval);
|
||||
CODE int (*start_capture)(imgsensor_stream_type_t type,
|
||||
CODE int (*start_capture)(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
uint8_t nr_datafmts,
|
||||
FAR imgsensor_format_t *datafmts,
|
||||
FAR imgsensor_interval_t *interval);
|
||||
CODE int (*stop_capture)(imgsensor_stream_type_t type);
|
||||
CODE int (*get_frame_interval)(imgsensor_stream_type_t type,
|
||||
CODE int (*stop_capture)(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type);
|
||||
CODE int (*get_frame_interval)(FAR struct imgsensor_s *sensor,
|
||||
imgsensor_stream_type_t type,
|
||||
FAR imgsensor_interval_t *interval);
|
||||
CODE int (*get_supported_value)(uint32_t id,
|
||||
CODE int (*get_supported_value)(FAR struct imgsensor_s *sensor,
|
||||
uint32_t id,
|
||||
FAR imgsensor_supported_value_t *value);
|
||||
CODE int (*get_value)(uint32_t id,
|
||||
uint32_t size,
|
||||
CODE int (*get_value)(FAR struct imgsensor_s *sensor,
|
||||
uint32_t id, uint32_t size,
|
||||
FAR imgsensor_value_t *value);
|
||||
CODE int (*set_value)(uint32_t id,
|
||||
uint32_t size,
|
||||
CODE int (*set_value)(FAR struct imgsensor_s *sensor,
|
||||
uint32_t id, uint32_t size,
|
||||
imgsensor_value_t value);
|
||||
};
|
||||
|
||||
/* Image sensor private data. This structure only defines the initial fields
|
||||
* of the structure visible to the client. The specific implementation may
|
||||
* add additional, device specific fields after the vtable.
|
||||
*/
|
||||
|
||||
struct imgsensor_s
|
||||
{
|
||||
FAR const struct imgsensor_ops_s *ops;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
@@ -362,7 +407,7 @@ extern "C"
|
||||
|
||||
/* Register image sensor operations. */
|
||||
|
||||
int imgsensor_register(FAR const struct imgsensor_ops_s *ops);
|
||||
int imgsensor_register(FAR struct imgsensor_s *sensor);
|
||||
|
||||
#undef EXTERN
|
||||
#ifdef __cplusplus
|
||||
|
||||
Reference in New Issue
Block a user