drivers: video: Rearchitect video driver

Rearchitect video driver:
- Define two video I/F(struct imgsensor_ops_s and struct imgdata_ops_s),
  and support them.
- CISIF driver supports new video I/F struct imgdata_ops_s.
- ISX012 driver supports new video I/F struct imgsensor_ops_s.
- Move ISX012 driver to general driver directory.
This commit is contained in:
SPRESENSE 2021-09-15 12:02:33 +09:00 committed by Alin Jerpelea
parent b991b75e87
commit 74df4b70b3
22 changed files with 5684 additions and 4626 deletions

View file

@ -21,54 +21,6 @@
#ifndef __ARCH_ARM_INCLUDE_CXD56XX_CISIF_H
#define __ARCH_ARM_INCLUDE_CXD56XX_CISIF_H
/****************************************************************************
* Public Types
****************************************************************************/
typedef void (*notify_callback_t)(uint8_t code,
uint32_t size,
uint32_t addr);
typedef void (*comp_callback_t)(uint8_t code,
uint32_t size,
uint32_t addr);
struct cisif_init_yuv_param_s
{
uint16_t hsize;
uint16_t vsize;
uint32_t notify_size;
notify_callback_t notify_func;
};
typedef struct cisif_init_yuv_param_s cisif_init_yuv_param_t;
struct cisif_init_jpeg_param_s
{
uint32_t notify_size;
notify_callback_t notify_func;
};
typedef struct cisif_init_jpeg_param_s cisif_init_jpeg_param_t;
struct cisif_sarea_s
{
uint8_t *strg_addr;
uint32_t strg_size;
};
typedef struct cisif_sarea_s cisif_sarea_t;
struct cisif_param_s
{
uint32_t format;
cisif_init_yuv_param_t yuv_param;
cisif_init_jpeg_param_t jpg_param;
cisif_sarea_t sarea;
comp_callback_t comp_func;
};
typedef struct cisif_param_s cisif_param_t;
#ifndef __ASSEMBLY__
#undef EXTERN
@ -84,11 +36,7 @@ extern "C"
* Public Function Prototypes
****************************************************************************/
int cxd56_cisifinit(void);
int cxd56_cisiffinalize(void);
int cxd56_cisifstartcapture(cisif_param_t *param, cisif_sarea_t *sarea);
int cxd56_cisifstopcapture(void);
int cxd56_cisifsetdmabuf(cisif_sarea_t *sarea);
int cxd56_cisif_initialize(void);
#undef EXTERN
#if defined(__cplusplus)

View file

@ -35,8 +35,7 @@
#include <nuttx/arch.h>
#include <arch/chip/cisif.h>
#include <nuttx/video/video.h>
#include <nuttx/video/imgdata.h>
#include "arm_arch.h"
#include "cxd56_clock.h"
@ -52,10 +51,22 @@
/* #define CISIF_DBG_CONTI_CAP */
#define YUV_VSIZE_MIN (64)
#define YUV_HSIZE_MIN (96)
#define YUV_VSIZE_MAX (360)
#define YUV_HSIZE_MAX (480)
#define YUV_VSIZE_STEP (1)
#define YUV_HSIZE_STEP (1)
#define YUV_VSIZE_MIN (64)
#define YUV_HSIZE_MIN (96)
#define YUV_VSIZE_MAX (360)
#define YUV_HSIZE_MAX (480)
#define JPG_VSIZE_STEP (1)
#define JPG_HSIZE_STEP (1)
#define JPG_VSIZE_MIN (64)
#define JPG_HSIZE_MIN (96)
#define JPG_VSIZE_MAX (1944)
#define JPG_HSIZE_MAX (2592)
#define CISIF_FMT_MIN (1)
#define CISIF_FMT_MAX (3)
#define JPG_INT_ALL (JPG_ERR_STATUS_INT | \
JPG_MEM_OVF_INT | \
@ -108,6 +119,40 @@ typedef enum state_e state_t;
typedef void (*intc_func_table)(uint8_t code);
typedef void (*notify_callback_t)(uint8_t code,
uint32_t size,
uint32_t addr);
typedef void (*comp_callback_t)(uint8_t code,
uint32_t size,
uint32_t addr);
struct cisif_yuv_param_s
{
uint16_t hsize;
uint16_t vsize;
uint32_t notify_size;
notify_callback_t notify_func;
};
typedef struct cisif_yuv_param_s cisif_yuv_param_t;
struct cisif_jpg_param_s
{
uint32_t notify_size;
notify_callback_t notify_func;
};
typedef struct cisif_jpg_param_s cisif_jpg_param_t;
struct cisif_param_s
{
uint32_t format;
cisif_yuv_param_t yuv_param;
cisif_jpg_param_t jpg_param;
};
typedef struct cisif_param_s cisif_param_t;
/****************************************************************************
* Private Data
****************************************************************************/
@ -115,9 +160,8 @@ typedef void (*intc_func_table)(uint8_t code);
static state_t g_state = STATE_STANDBY;
static uint32_t g_storage_addr = 0;
notify_callback_t g_jpg_notify_callback_func;
notify_callback_t g_ycc_notify_callback_func;
comp_callback_t g_comp_callback_func;
static notify_callback_t g_jpg_notify_callback_func;
static notify_callback_t g_ycc_notify_callback_func;
static bool g_jpgint_receive;
static bool g_errint_receive;
@ -129,6 +173,8 @@ static uint32_t g_cisif_time_start;
static uint32_t g_cisif_time_stop;
#endif
static imgdata_capture_t g_cxd56_cisif_complete_capture;
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
@ -145,15 +191,32 @@ static void cisif_reg_write(uint16_t reg, uint32_t val);
static uint32_t cisif_reg_read(uint16_t reg);
static int cisif_check_param(cisif_param_t *p);
static int cisif_set_yuv_param(cisif_param_t *p);
static int cisif_set_jpg_param(cisif_param_t *p);
static int cisif_set_yuv_param(cisif_yuv_param_t *p);
static int cisif_set_jpg_param(cisif_jpg_param_t *p);
static int cisif_check_sarea(void *s);
static int cisif_set_yuv_sarea(void *s);
static int cisif_set_jpg_sarea(void *s);
static int cisif_set_intlev_sarea(void *s, uint32_t yuv_size);
static int cisif_set_yuv_sarea(uint8_t *addr, uint32_t size);
static int cisif_set_jpg_sarea(uint8_t *addr, uint32_t size);
static int cisif_set_intlev_sarea(uint8_t *addr,
uint32_t total_size,
uint32_t yuv_size);
static int cisif_intc_handler(int irq, FAR void *context, FAR void *arg);
int cisif_intc_handler(int irq, FAR void *context, FAR void *arg);
/* video image data operations */
static int cxd56_cisif_init(void);
static int cxd56_cisif_uninit(void);
static int cxd56_cisif_validate_frame_setting
(uint8_t nr_datafmt,
FAR imgdata_format_t *datafmt,
FAR imgdata_interval_t *interval);
static int cxd56_cisif_start_capture
(uint8_t nr_datafmt,
FAR imgdata_format_t *datafmt,
FAR 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);
const intc_func_table g_intcomp_func[] =
{
@ -188,6 +251,17 @@ const intc_func_table g_intcomp_func[] =
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,
.validate_buf = cxd56_cisif_validate_buf,
.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,
};
/****************************************************************************
* Private Functions
****************************************************************************/
@ -290,7 +364,7 @@ static void cisif_callback_for_intlev(uint8_t code)
/* Notify and get next addr */
g_comp_callback_func(0, size, g_storage_addr);
g_cxd56_cisif_complete_capture(0, size);
g_jpgint_receive = false;
@ -332,7 +406,7 @@ static void cisif_ycc_axi_trdn_int(uint8_t code)
else
{
size = cisif_reg_read(CISIF_YCC_DSTRG_CONT);
g_comp_callback_func(0, size, g_storage_addr);
g_cxd56_cisif_complete_capture(0, size);
cisif_reg_write(CISIF_YCC_DREAD_CONT, 0);
}
}
@ -382,7 +456,7 @@ static void cisif_jpg_axi_trdn_int(uint8_t code)
else
{
size = cisif_reg_read(CISIF_JPG_DSTRG_CONT);
g_comp_callback_func(0, size, g_storage_addr);
g_cxd56_cisif_complete_capture(0, size);
cisif_reg_write(CISIF_JPG_DREAD_CONT, 0);
}
}
@ -414,7 +488,7 @@ static void cisif_ycc_err_int(uint8_t code)
#endif
size = cisif_reg_read(CISIF_YCC_DSTRG_CONT);
g_comp_callback_func(code, size, g_storage_addr);
g_cxd56_cisif_complete_capture(code, size);
cisif_reg_write(CISIF_YCC_DREAD_CONT, 0);
g_errint_receive = true;
}
@ -426,16 +500,13 @@ static void cisif_ycc_err_int(uint8_t code)
static void cisif_jpg_err_int(uint8_t code)
{
uint32_t size;
uint32_t addr;
#ifdef CISIF_INTR_TRACE
cisif_trace_time_stop("cisif_jpg_err_int");
#endif
addr = g_storage_addr;
size = cisif_reg_read(CISIF_JPG_DSTRG_CONT);
g_comp_callback_func(code, size, addr);
g_cxd56_cisif_complete_capture(code, size);
cisif_reg_write(CISIF_JPG_DREAD_CONT, 0);
g_errint_receive = true;
}
@ -444,7 +515,7 @@ static void cisif_jpg_err_int(uint8_t code)
* cisif_intc_handler
****************************************************************************/
int cisif_intc_handler(int irq, FAR void *context, FAR void *arg)
static int cisif_intc_handler(int irq, FAR void *context, FAR void *arg)
{
uint32_t value;
uint32_t enable;
@ -488,6 +559,19 @@ static uint32_t cisif_reg_read(uint16_t reg)
return getreg32(CXD56_CISIF_BASE + reg);
}
static bool is_uncompressed(uint32_t fmt)
{
bool ret = false;
if ((fmt == IMGDATA_PIX_FMT_UYVY) ||
(fmt == IMGDATA_PIX_FMT_RGB565))
{
ret = true;
}
return ret;
}
/****************************************************************************
* cisif_check_param
****************************************************************************/
@ -499,23 +583,19 @@ static int cisif_check_param(cisif_param_t *p)
return -EINVAL;
}
if (p->comp_func == NULL)
{
return -EINVAL;
}
switch (p->format)
{
case V4L2_PIX_FMT_UYVY:
case V4L2_PIX_FMT_JPEG:
case V4L2_PIX_FMT_JPEG_WITH_SUBIMG:
case IMGDATA_PIX_FMT_UYVY:
case IMGDATA_PIX_FMT_RGB565:
case IMGDATA_PIX_FMT_JPEG:
case IMGDATA_PIX_FMT_JPEG_WITH_SUBIMG:
break;
default:
return -EINVAL;
}
if (p->format != V4L2_PIX_FMT_JPEG)
if (p->format != IMGDATA_PIX_FMT_JPEG)
{
if (p->yuv_param.hsize < YUV_HSIZE_MIN ||
p->yuv_param.hsize > YUV_HSIZE_MAX ||
@ -534,7 +614,7 @@ static int cisif_check_param(cisif_param_t *p)
}
}
if (p->format != V4L2_PIX_FMT_UYVY)
if (!is_uncompressed(p->format))
{
if (p->jpg_param.notify_func != NULL)
{
@ -548,47 +628,26 @@ static int cisif_check_param(cisif_param_t *p)
return OK;
}
/****************************************************************************
* cisif_check_sarea
****************************************************************************/
static int cisif_check_sarea(void *s)
{
if (s == NULL)
{
return -EINVAL;
}
cisif_sarea_t *ss = (cisif_sarea_t *)s;
if (ILLEGAL_BUFADDR_ALIGNMENT(ss->strg_addr) ||
ss->strg_size == 0)
{
return -EINVAL;
}
return OK;
}
/****************************************************************************
* cisif_set_yuvparam
****************************************************************************/
static int cisif_set_yuv_param(cisif_param_t *p)
static int cisif_set_yuv_param(cisif_yuv_param_t *p)
{
uint32_t act_size = 0;
act_size = (p->yuv_param.vsize & 0x1ff) << 16;
act_size |= p->yuv_param.hsize & 0x1ff;
act_size = (p->vsize & 0x1ff) << 16;
act_size |= p->hsize & 0x1ff;
cisif_reg_write(CISIF_ACT_SIZE, act_size);
cisif_reg_write(CISIF_CIS_SIZE, act_size);
/* must align 32 bytes */
cisif_reg_write(CISIF_YCC_NSTRG_SIZE, (p->yuv_param.notify_size
& 0xffffffe0));
cisif_reg_write(CISIF_YCC_NSTRG_SIZE,
(p->notify_size & 0xffffffe0));
g_ycc_notify_callback_func = p->yuv_param.notify_func;
g_ycc_notify_callback_func = p->notify_func;
return OK;
}
@ -597,14 +656,12 @@ static int cisif_set_yuv_param(cisif_param_t *p)
* cisif_set_yuvsarea
****************************************************************************/
static int cisif_set_yuv_sarea(void *s)
static int cisif_set_yuv_sarea(uint8_t *addr, uint32_t size)
{
cisif_sarea_t *ss = (cisif_sarea_t *)s;
/* must align 32 bytes */
cisif_reg_write(CISIF_YCC_DAREA_SIZE, (ss->strg_size & 0xffffffe0));
cisif_reg_write(CISIF_YCC_START_ADDR, CXD56_PHYSADDR(ss->strg_addr));
cisif_reg_write(CISIF_YCC_DAREA_SIZE, (size & 0xffffffe0));
cisif_reg_write(CISIF_YCC_START_ADDR, CXD56_PHYSADDR(addr));
return OK;
}
@ -613,14 +670,14 @@ static int cisif_set_yuv_sarea(void *s)
* cisif_set_jpg_param
****************************************************************************/
static int cisif_set_jpg_param(cisif_param_t *p)
static int cisif_set_jpg_param(cisif_jpg_param_t *p)
{
/* must align 32 bytes */
cisif_reg_write(CISIF_JPG_NSTRG_SIZE, (p->jpg_param.notify_size
cisif_reg_write(CISIF_JPG_NSTRG_SIZE, (p->notify_size
& 0xffffffe0));
g_jpg_notify_callback_func = p->jpg_param.notify_func;
g_jpg_notify_callback_func = p->notify_func;
return OK;
}
@ -629,14 +686,12 @@ static int cisif_set_jpg_param(cisif_param_t *p)
* cisif_set_jpg_sarea
****************************************************************************/
static int cisif_set_jpg_sarea(void *s)
static int cisif_set_jpg_sarea(uint8_t *addr, uint32_t size)
{
cisif_sarea_t *ss = (cisif_sarea_t *)s;
/* must align 32 bytes */
cisif_reg_write(CISIF_JPG_DAREA_SIZE, (ss->strg_size & 0xffffffe0));
cisif_reg_write(CISIF_JPG_START_ADDR, CXD56_PHYSADDR(ss->strg_addr));
cisif_reg_write(CISIF_JPG_DAREA_SIZE, (size & 0xffffffe0));
cisif_reg_write(CISIF_JPG_START_ADDR, CXD56_PHYSADDR(addr));
return OK;
}
@ -645,41 +700,73 @@ static int cisif_set_jpg_sarea(void *s)
* cisif_set_jpg_sarea
****************************************************************************/
static int cisif_set_intlev_sarea(void *s, uint32_t yuv_size)
static int cisif_set_intlev_sarea(uint8_t *addr,
uint32_t total_size,
uint32_t yuv_size)
{
cisif_sarea_t *sarea = (cisif_sarea_t *)s;
cisif_sarea_t sarea_int;
if (sarea->strg_size < yuv_size)
if (total_size < yuv_size)
{
return -EINVAL;
}
/* Set for YUV */
sarea_int.strg_addr = sarea->strg_addr;
sarea_int.strg_size = yuv_size;
cisif_set_yuv_sarea(&sarea_int);
cisif_set_yuv_sarea(addr, yuv_size);
/* Set for JPEG */
sarea_int.strg_addr = sarea->strg_addr + yuv_size;
sarea_int.strg_size = sarea->strg_size - yuv_size;
cisif_set_jpg_sarea(&sarea_int);
cisif_set_jpg_sarea(addr + yuv_size, total_size - yuv_size);
return OK;
}
/****************************************************************************
* Public Functions
* cisif_chk_jpgfrmsize
****************************************************************************/
static int cisif_chk_jpgfrmsize(int w, int h)
{
if ((w < JPG_HSIZE_MIN) ||
(w > JPG_HSIZE_MAX))
{
return -EINVAL;
}
if ((h < JPG_VSIZE_MIN) ||
(h > JPG_VSIZE_MAX))
{
return -EINVAL;
}
return OK;
}
/****************************************************************************
* cxd56_cisifinit
* cisif_chk_yuvfrmsize
****************************************************************************/
int cxd56_cisifinit(void)
static int cisif_chk_yuvfrmsize(int w, int h)
{
if ((w < YUV_HSIZE_MIN) ||
(w > YUV_HSIZE_MAX))
{
return -EINVAL;
}
if ((h < YUV_VSIZE_MIN) ||
(h > YUV_VSIZE_MAX))
{
return -EINVAL;
}
return OK;
}
/****************************************************************************
* cxd56_cisif_init
****************************************************************************/
static int cxd56_cisif_init(void)
{
if (g_state != STATE_STANDBY)
{
@ -708,15 +795,14 @@ int cxd56_cisifinit(void)
#endif
g_state = STATE_READY;
return OK;
}
/****************************************************************************
* cxd56_cisiffinalize
* cxd56_cisif_uninit
****************************************************************************/
int cxd56_cisiffinalize(void)
static int cxd56_cisif_uninit(void)
{
if (g_state != STATE_READY)
{
@ -741,19 +827,28 @@ int cxd56_cisiffinalize(void)
cxd56_img_cisif_clock_disable();
g_state = STATE_STANDBY;
return OK;
}
/****************************************************************************
* cxd56_cisifstartcapturing
* cxd56_cisif_start_capture
****************************************************************************/
int cxd56_cisifstartcapture(
cisif_param_t *param,
cisif_sarea_t *sarea)
static int cxd56_cisif_start_capture
(uint8_t nr_fmt,
FAR imgdata_format_t *fmt,
FAR imgdata_interval_t *interval,
imgdata_capture_t callback)
{
uint32_t cisif_mode;
cisif_param_t param =
{
0
};
cisif_yuv_param_t *yuv = &param.yuv_param;
cisif_jpg_param_t *jpg = &param.jpg_param;
uint32_t mode;
uint32_t interrupts = VS_INT;
int ret;
@ -762,7 +857,22 @@ int cxd56_cisifstartcapture(
return -EPERM;
}
ret = cisif_check_param(param);
param.format = fmt[IMGDATA_FMT_MAIN].pixelformat;
if (param.format != IMGDATA_PIX_FMT_JPEG)
{
if (is_uncompressed(param.format))
{
yuv->hsize = fmt[IMGDATA_FMT_MAIN].width;
yuv->vsize = fmt[IMGDATA_FMT_MAIN].height;
}
else
{
yuv->hsize = fmt[IMGDATA_FMT_SUB].width;
yuv->vsize = fmt[IMGDATA_FMT_SUB].height;
}
}
ret = cisif_check_param(&param);
if (ret != OK)
{
return ret;
@ -770,39 +880,29 @@ int cxd56_cisifstartcapture(
cisif_reg_write(CISIF_INTR_DISABLE, ALL_CLEAR_INT);
ret = cisif_check_sarea(sarea);
if (ret != OK)
switch (param.format)
{
return ret;
}
case IMGDATA_PIX_FMT_UYVY:
case IMGDATA_PIX_FMT_RGB565:
switch (param->format)
{
case V4L2_PIX_FMT_UYVY:
cisif_set_yuv_param(param);
cisif_set_yuv_sarea(sarea);
cisif_set_yuv_param(yuv);
cisif_mode = MODE_YUV_TRS_EN;
mode = MODE_YUV_TRS_EN;
interrupts |= YCC_INT_ALL;
break;
case V4L2_PIX_FMT_JPEG:
cisif_set_jpg_param(param);
cisif_set_jpg_sarea(sarea);
case IMGDATA_PIX_FMT_JPEG:
cisif_set_jpg_param(jpg);
cisif_mode = MODE_JPG_TRS_EN;
mode = MODE_JPG_TRS_EN;
interrupts |= JPG_INT_ALL;
break;
case V4L2_PIX_FMT_JPEG_WITH_SUBIMG:
cisif_set_yuv_param(param);
cisif_set_jpg_param(param);
case IMGDATA_PIX_FMT_JPEG_WITH_SUBIMG:
cisif_set_yuv_param(yuv);
cisif_set_jpg_param(jpg);
cisif_set_intlev_sarea(sarea,
YUV_SIZE(param->yuv_param.vsize,
param->yuv_param.hsize));
cisif_mode = MODE_INTLEV_TRS_EN;
mode = MODE_INTLEV_TRS_EN;
interrupts |= YCC_INT_ALL | JPG_INT_ALL;
g_jpgint_receive = false;
break;
@ -811,8 +911,7 @@ int cxd56_cisifstartcapture(
return -EINVAL;
}
g_comp_callback_func = param->comp_func;
g_storage_addr = (uint32_t)sarea->strg_addr;
g_cxd56_cisif_complete_capture = callback;
g_state = STATE_CAPTURE;
@ -826,17 +925,16 @@ int cxd56_cisifstartcapture(
interrupts |= JPG_NSTORAGE_INT;
}
cisif_reg_write(CISIF_MODE, cisif_mode);
cisif_reg_write(CISIF_MODE, mode);
cisif_reg_write(CISIF_INTR_CLEAR, interrupts);
cisif_reg_write(CISIF_INTR_ENABLE, interrupts);
cisif_reg_write(CISIF_DIN_ENABLE, 1);
cisif_reg_write(CISIF_EXE_CMD, 1);
return OK;
}
int cxd56_cisifstopcapture(void)
static int cxd56_cisif_stop_capture(void)
{
g_state = STATE_READY;
cisif_reg_write(CISIF_DIN_ENABLE, 0);
@ -846,42 +944,54 @@ int cxd56_cisifstopcapture(void)
return OK;
}
int cxd56_cisifsetdmabuf(cisif_sarea_t *sarea)
static int cxd56_cisif_validate_buf(uint8_t *addr, uint32_t size)
{
if (ILLEGAL_BUFADDR_ALIGNMENT(addr) ||
size == 0)
{
return -EINVAL;
}
return OK;
}
static int cxd56_cisif_set_buf(uint8_t *addr, uint32_t size)
{
int ret;
uint32_t cisif_mode;
uint32_t yuv_regsize;
uint32_t yuv_hsize;
uint32_t yuv_vsize;
uint32_t mode;
uint32_t regval;
uint16_t w;
uint16_t h;
ret = cisif_check_sarea(sarea);
ret = cxd56_cisif_validate_buf(addr, size);
if (ret != OK)
{
return ret;
}
cisif_mode = cisif_reg_read(CISIF_MODE);
mode = cisif_reg_read(CISIF_MODE);
switch (cisif_mode)
switch (mode)
{
case MODE_YUV_TRS_EN:
ret = cisif_set_yuv_sarea(sarea);
ret = cisif_set_yuv_sarea(addr, size);
break;
case MODE_JPG_TRS_EN:
ret = cisif_set_jpg_sarea(sarea);
ret = cisif_set_jpg_sarea(addr, size);
break;
default: /* MODE_INTLEV_TRS_EN */
/* Get YUV frame size information */
yuv_regsize = cisif_reg_read(CISIF_ACT_SIZE);
yuv_vsize = (yuv_regsize >> 16) & 0x1ff;
yuv_hsize = yuv_regsize & 0x01ff;
regval = cisif_reg_read(CISIF_ACT_SIZE);
h = (regval >> 16) & 0x1ff;
w = regval & 0x01ff;
ret = cisif_set_intlev_sarea(sarea,
YUV_SIZE(yuv_vsize, yuv_hsize));
ret = cisif_set_intlev_sarea(addr,
size,
YUV_SIZE(w, h));
break;
}
@ -891,7 +1001,83 @@ int cxd56_cisifsetdmabuf(cisif_sarea_t *sarea)
}
cisif_reg_write(CISIF_EXE_CMD, 1);
g_storage_addr = (uint32_t)sarea->strg_addr;
g_storage_addr = (uint32_t)addr;
return ret;
}
static int cxd56_cisif_validate_frame_setting
(uint8_t nr_datafmt,
FAR imgdata_format_t *datafmt,
FAR imgdata_interval_t *interval)
{
int ret = OK;
if ((nr_datafmt < CISIF_FMT_MIN) || (nr_datafmt > CISIF_FMT_MAX))
{
return -EINVAL;
}
switch (datafmt[IMGDATA_FMT_MAIN].pixelformat)
{
case IMGDATA_PIX_FMT_UYVY: /* YUV 4:2:2 */
case IMGDATA_PIX_FMT_RGB565: /* RGB565 */
ret = cisif_chk_yuvfrmsize(datafmt[IMGDATA_FMT_MAIN].width,
datafmt[IMGDATA_FMT_MAIN].height);
break;
case IMGDATA_PIX_FMT_JPEG: /* JPEG */
ret = cisif_chk_jpgfrmsize(datafmt[IMGDATA_FMT_MAIN].width,
datafmt[IMGDATA_FMT_MAIN].height);
break;
case IMGDATA_PIX_FMT_JPEG_WITH_SUBIMG: /* JPEG + YUV 4:2:2 */
if ((nr_datafmt == 2) &&
!is_uncompressed(datafmt[IMGDATA_FMT_SUB].pixelformat))
{
/* Unsupported pixel format */
return -EINVAL;
}
ret = cisif_chk_jpgfrmsize(datafmt[IMGDATA_FMT_MAIN].width,
datafmt[IMGDATA_FMT_MAIN].height);
if (ret != OK)
{
return ret;
}
if (nr_datafmt == 2)
{
ret = cisif_chk_yuvfrmsize
(datafmt[IMGDATA_FMT_SUB].width,
datafmt[IMGDATA_FMT_SUB].height);
}
break;
default: /* Unsupported pixel format */
return -EINVAL;
}
return ret;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* cxd56_cisif_initialize
****************************************************************************/
int cxd56_cisif_initialize(void)
{
imgdata_register(&g_cxd56_cisif_ops);
return OK;
}

View file

@ -184,10 +184,10 @@ int board_isx012_initialize(int i2c_bus_num)
return -ENODEV;
}
ret = isx012_register(i2c);
ret = isx012_initialize(i2c);
if (ret < 0)
{
_err("Error registering ISX012.\n");
_err("Failed to initialize ISX012.\n");
}
return ret;
@ -201,10 +201,10 @@ int board_isx012_uninitialize(void)
/* Initialize i2c device */
ret = isx012_unregister();
ret = isx012_uninitialize();
if (ret < 0)
{
_err("Error unregistering ISX012.\n");
_err("Failed to uninitialize ISX012.\n");
}
if (!i2c)

View file

@ -6,5 +6,4 @@
if SPECIFIC_DRIVERS
source "drivers/platform/audio/Kconfig"
source "drivers/platform/sensors/Kconfig"
source "drivers/platform/camera/Kconfig"
endif

View file

@ -20,4 +20,3 @@
include platform/audio/Make.defs
include platform/sensors/Make.defs
include platform/camera/Make.defs

View file

@ -1,9 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config VIDEO_ISX012
bool "ISX012 Image sensor"
default n
select I2C

View file

@ -1,27 +0,0 @@
############################################################################
# boards/arm/cxd56xx/drivers/camera/Make.defs
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership. The
# ASF licenses this file to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance with the
# License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
#
############################################################################
ifeq ($(CONFIG_VIDEO_ISX012),y)
CSRCS += isx012.c
endif
DEPPATH += --dep-path platform$(DELIM)camera
VPATH += :platform$(DELIM)camera
CFLAGS += $(shell $(INCDIR) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)platform$(DELIM)camera)

File diff suppressed because it is too large Load diff

View file

@ -109,6 +109,10 @@
# include <nuttx/video/fb.h>
#endif
#ifdef CONFIG_CXD56_CISIF
# include <arch/chip/cisif.h>
#endif
#include "spresense.h"
/****************************************************************************
@ -191,9 +195,6 @@ int cxd56_bringup(void)
{
struct pm_cpu_wakelock_s wlock;
int ret;
#ifdef CONFIG_VIDEO_ISX012
FAR const struct video_devops_s *devops;
#endif
ret = nsh_cpucom_initialize();
if (ret < 0)
@ -375,17 +376,19 @@ int cxd56_bringup(void)
ret = board_isx012_initialize(IMAGER_I2C);
if (ret < 0)
{
_err("ERROR: Failed to initialize ISX012 board. %d\n", ret);
}
devops = isx012_initialize();
if (devops == NULL)
{
_err("ERROR: Failed to populate ISX012 devops. %d\n", ret);
ret = ERROR;
_err("ERROR: Failed to initialize ISX012 board. %d\n", errno);
}
#endif /* CONFIG_VIDEO_ISX012 */
#ifdef CONFIG_CXD56_CISIF
ret = cxd56_cisif_initialize();
if (ret < 0)
{
_err("ERROR: Failed to initialize CISIF. %d\n", errno);
ret = ERROR;
}
#endif /* CONFIG_CXD56_CISIF */
#if defined(CONFIG_CXD56_SDIO)
/* In order to prevent Hi-Z from being input to the SD Card controller,
* Initialize SDIO pins to GPIO low output with internal pull-down.

View file

@ -56,6 +56,87 @@ config VIDEO_STREAM
---help---
Enable video Stream support
if VIDEO_STREAM
config VIDEO_SCENE_BACKLIGHT
bool "Enable backlight scene"
default y
---help---
Enable backlight scene
config VIDEO_SCENE_BEACHSNOW
bool "Enable beach snow scene"
default y
---help---
Enable beach snow scene
config VIDEO_SCENE_CANDLELIGHT
bool "Enable candle light scene"
default y
---help---
Enable candle light scene
config VIDEO_SCENE_DAWNDUSK
bool "Enable dawn dusk scene"
default y
---help---
Enable dawn dusk scene
config VIDEO_SCENE_FALLCOLORS
bool "Enable fall colors scene"
default y
---help---
Enable fall colors scene
config VIDEO_SCENE_FIREWORKS
bool "Enable fireworks scene"
default y
---help---
Enable fireworks scene
config VIDEO_SCENE_LANDSCAPE
bool "Enable landscape scene"
default y
---help---
Enable landscape scene
config VIDEO_SCENE_NIGHT
bool "Enable night scene"
default y
---help---
Enable night scene
config VIDEO_SCENE_PARTYINDOOR
bool "Enable party and indoor scene"
default y
---help---
Enable party and indoor scene
config VIDEO_SCENE_PORTRAIT
bool "Enable portrait scene"
default y
---help---
Enable portrait scene
config VIDEO_SCENE_SPORTS
bool "Enable sports scene"
default y
---help---
Enable sports scene
config VIDEO_SCENE_SUNSET
bool "Enable sunset scene"
default y
---help---
Enable sunset scene
config VIDEO_SCENE_TEXT
bool "Enable text scene"
default y
---help---
Enable text scene
endif
config VIDEO_MAX7456
bool "Maxim 7456 Monochrome OSD"
default n
@ -64,6 +145,11 @@ config VIDEO_MAX7456
Support for the Maxim 7456 monochrome on-screen display
multiplexer.
config VIDEO_ISX012
bool "ISX012 Image sensor"
default n
select I2C
config VIDEO_OV2640
bool "OV2640 camera chip"
default n

View file

@ -34,6 +34,10 @@ endif
ifeq ($(CONFIG_I2C),y)
ifeq ($(CONFIG_VIDEO_ISX012),y)
CSRCS += isx012.c
endif
ifeq ($(CONFIG_VIDEO_OV2640),y)
CSRCS += ov2640.c
endif

2917
drivers/video/isx012.c Normal file

File diff suppressed because it is too large Load diff

View file

@ -1,5 +1,5 @@
/****************************************************************************
* include/nuttx/video/isx012_range.h
* drivers/video/isx012_range.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -29,7 +29,6 @@
/* Definition for control brightness */
#define ISX012_TYPE_BRIGHTNESS V4L2_CTRL_TYPE_INTEGER
#define ISX012_NAME_BRIGHTNESS "Brightness"
#define ISX012_DEF_BRIGHTNESS (0)
#define ISX012_MIN_BRIGHTNESS (-128)
#define ISX012_MAX_BRIGHTNESS (127)
@ -40,7 +39,6 @@
/* Definition for control contrast */
#define ISX012_TYPE_CONTRAST V4L2_CTRL_TYPE_U8FIXEDPOINT_Q7
#define ISX012_NAME_CONTRAST "Contrast"
#define ISX012_DEF_CONTRAST (0x80)
#define ISX012_MIN_CONTRAST (0x00)
#define ISX012_MAX_CONTRAST (0xFF)
@ -51,7 +49,6 @@
/* Definition for control saturation */
#define ISX012_TYPE_SATURATION V4L2_CTRL_TYPE_INTEGER
#define ISX012_NAME_SATURATION "Saturation"
#define ISX012_DEF_SATURATION (0)
#define ISX012_MIN_SATURATION (0)
#define ISX012_MAX_SATURATION (255)
@ -62,7 +59,6 @@
/* Definition for control hue */
#define ISX012_TYPE_HUE V4L2_CTRL_TYPE_INTEGER
#define ISX012_NAME_HUE "Hue"
#define ISX012_DEF_HUE (0)
#define ISX012_MIN_HUE (0)
#define ISX012_MAX_HUE (255)
@ -73,7 +69,6 @@
/* Definition for control auto white balance */
#define ISX012_TYPE_AUTOWB V4L2_CTRL_TYPE_BOOLEAN
#define ISX012_NAME_AUTOWB "Automatic white balance"
#define ISX012_DEF_AUTOWB true
#define ISX012_MIN_AUTOWB false
#define ISX012_MAX_AUTOWB true
@ -84,7 +79,6 @@
/* Definition for control red balance */
#define ISX012_TYPE_REDBALANCE V4L2_CTRL_TYPE_INTEGER
#define ISX012_NAME_REDBALANCE "Red balance"
#define ISX012_DEF_REDBALANCE (0)
#define ISX012_MIN_REDBALANCE (0)
#define ISX012_MAX_REDBALANCE (65535)
@ -95,7 +89,6 @@
/* Definition for control blue balance */
#define ISX012_TYPE_BLUEBALANCE V4L2_CTRL_TYPE_INTEGER
#define ISX012_NAME_BLUEBALANCE "Red balance"
#define ISX012_DEF_BLUEBALANCE (0)
#define ISX012_MIN_BLUEBALANCE (0)
#define ISX012_MAX_BLUEBALANCE (65535)
@ -106,7 +99,6 @@
/* Definition for control gamma curve */
#define ISX012_TYPE_GAMMACURVE V4L2_CTRL_TYPE_U16
#define ISX012_NAME_GAMMACURVE "Gamma adjustment(curve)"
#define ISX012_DEF_GAMMACURVE (0)
#define ISX012_MIN_GAMMACURVE (0)
#define ISX012_MAX_GAMMACURVE (511)
@ -119,7 +111,6 @@
/* Definition for control exposure value */
#define ISX012_TYPE_EXPOSURE V4L2_CTRL_TYPE_INTEGER_TIMES_3
#define ISX012_NAME_EXPOSURE "Exposure value"
#define ISX012_DEF_EXPOSURE (0)
#define ISX012_MIN_EXPOSURE (-6)
#define ISX012_MAX_EXPOSURE (6)
@ -130,7 +121,6 @@
/* Definition for control horizontal mirroring(V4L2_BUF_TYPE_VIDEO_CAPTURE) */
#define ISX012_TYPE_HFLIP V4L2_CTRL_TYPE_BOOLEAN
#define ISX012_NAME_HFLIP "Mirror horizontally(VIDEO)"
#define ISX012_DEF_HFLIP false
#define ISX012_MIN_HFLIP false
#define ISX012_MAX_HFLIP true
@ -141,7 +131,6 @@
/* Definition for control vertical mirroring(V4L2_BUF_TYPE_VIDEO_CAPTURE) */
#define ISX012_TYPE_VFLIP V4L2_CTRL_TYPE_BOOLEAN
#define ISX012_NAME_VFLIP "Mirror vertically(VIDEO)"
#define ISX012_DEF_VFLIP false
#define ISX012_MIN_VFLIP false
#define ISX012_MAX_VFLIP true
@ -152,7 +141,6 @@
/* Definition for control horizontal mirroring(V4L2_BUF_TYPE_STILL_CAPTURE) */
#define ISX012_TYPE_HFLIP_STILL V4L2_CTRL_TYPE_BOOLEAN
#define ISX012_NAME_HFLIP_STILL "Mirror horizontally(STILL)"
#define ISX012_DEF_HFLIP_STILL false
#define ISX012_MIN_HFLIP_STILL false
#define ISX012_MAX_HFLIP_STILL true
@ -163,7 +151,6 @@
/* Definition for control vertical mirroring(V4L2_BUF_TYPE_STILL_CAPTURE) */
#define ISX012_TYPE_VFLIP_STILL V4L2_CTRL_TYPE_BOOLEAN
#define ISX012_NAME_VFLIP_STILL "Mirror vertically(STILL)"
#define ISX012_DEF_VFLIP_STILL false
#define ISX012_MIN_VFLIP_STILL false
#define ISX012_MAX_VFLIP_STILL true
@ -174,7 +161,6 @@
/* Definition for control sharpness */
#define ISX012_TYPE_SHARPNESS V4L2_CTRL_TYPE_INTEGER
#define ISX012_NAME_SHARPNESS "Sharpness"
#define ISX012_DEF_SHARPNESS (0)
#define ISX012_MIN_SHARPNESS (0)
#define ISX012_MAX_SHARPNESS (255)
@ -185,7 +171,6 @@
/* Definition for control color killer */
#define ISX012_TYPE_COLORKILLER V4L2_CTRL_TYPE_BOOLEAN
#define ISX012_NAME_COLORKILLER "Color killer"
#define ISX012_DEF_COLORKILLER false
#define ISX012_MIN_COLORKILLER false
#define ISX012_MAX_COLORKILLER true
@ -196,7 +181,6 @@
/* Definition for control color effect */
#define ISX012_TYPE_COLOREFFECT V4L2_CTRL_TYPE_INTEGER_MENU
#define ISX012_NAME_COLOREFFECT "Color effect"
#define ISX012_DEF_COLOREFFECT V4L2_COLORFX_NONE
#define ISX012_MIN_COLOREFFECT (0)
#define ISX012_MAX_COLOREFFECT (6)
@ -207,7 +191,6 @@
/* Definition for control auto exposure */
#define ISX012_TYPE_EXPOSUREAUTO V4L2_CTRL_TYPE_INTEGER
#define ISX012_NAME_EXPOSUREAUTO "Auto Exposure"
#define ISX012_DEF_EXPOSUREAUTO (0)
#define ISX012_MIN_EXPOSUREAUTO (0)
#define ISX012_MAX_EXPOSUREAUTO (1)
@ -220,10 +203,9 @@
/* Definition for control exposure time */
#define ISX012_TYPE_EXPOSURETIME V4L2_CTRL_TYPE_INTEGER
#define ISX012_NAME_EXPOSURETIME "Exposure time(usec)"
#define ISX012_DEF_EXPOSURETIME (0)
#define ISX012_MIN_EXPOSURETIME (1)
#define ISX012_MAX_EXPOSURETIME (10000)
#define ISX012_MAX_EXPOSURETIME (21000)
#define ISX012_STEP_EXPOSURETIME (1)
#define ISX012_REG_EXPOSURETIME SHT_PREMODE_TYPE1
#define ISX012_SIZE_EXPOSURETIME (2)
@ -233,7 +215,6 @@
/* Definition for control photometry */
#define ISX012_TYPE_PHOTOMETRY V4L2_CTRL_TYPE_INTEGER_MENU
#define ISX012_NAME_PHOTOMETRY "Photometry"
#define ISX012_DEF_PHOTOMETRY V4L2_EXPOSURE_METERING_AVERAGE
#define ISX012_MIN_PHOTOMETRY (0)
#define ISX012_MAX_PHOTOMETRY (3)
@ -244,7 +225,6 @@
/* Definition for control zoom */
#define ISX012_TYPE_ZOOM V4L2_CTRL_TYPE_U16FIXEDPOINT_Q8
#define ISX012_NAME_ZOOM "Zoom"
#define ISX012_DEF_ZOOM (0x0100)
#define ISX012_MIN_ZOOM (0x0100)
#define ISX012_MAX_ZOOM (0x1000)
@ -255,7 +235,6 @@
/* Definition for control preset white balance */
#define ISX012_TYPE_PRESETWB V4L2_CTRL_TYPE_INTEGER_MENU
#define ISX012_NAME_PRESETWB "Preset white balance"
#define ISX012_DEF_PRESETWB V4L2_WHITE_BALANCE_AUTO
#define ISX012_MIN_PRESETWB (0)
#define ISX012_MAX_PRESETWB (5)
@ -266,7 +245,6 @@
/* Definition for control YGAMMA adujust */
#define ISX012_TYPE_YGAMMA V4L2_CTRL_TYPE_BOOLEAN
#define ISX012_NAME_YGAMMA "Wide dynamic range"
#define ISX012_DEF_YGAMMA (false)
#define ISX012_MIN_YGAMMA (false)
#define ISX012_MAX_YGAMMA (true)
@ -277,7 +255,6 @@
/* Definition for control ISO sensitivity */
#define ISX012_TYPE_ISO V4L2_CTRL_TYPE_INTEGER_MENU
#define ISX012_NAME_ISO "ISO sensitivity"
#define ISX012_DEF_ISO (0)
#define ISX012_MIN_ISO (0)
#define ISX012_MAX_ISO (18)
@ -288,7 +265,6 @@
/* Definition for control ISO automatic */
#define ISX012_TYPE_ISOAUTO V4L2_CTRL_TYPE_INTEGER_MENU
#define ISX012_NAME_ISOAUTO "Automatic ISO sensitivity"
#define ISX012_DEF_ISOAUTO (false)
#define ISX012_MIN_ISOAUTO (0)
#define ISX012_MAX_ISOAUTO (1)
@ -301,7 +277,6 @@
/* Definition for control 3A lock */
#define ISX012_TYPE_3ALOCK V4L2_CTRL_TYPE_BITMASK
#define ISX012_NAME_3ALOCK "Lock AWB/AE"
#define ISX012_DEF_3ALOCK (0)
#define ISX012_MIN_3ALOCK (0)
#define ISX012_MAX_3ALOCK (3)
@ -312,8 +287,7 @@
/* Definition for control JPEG compression quality */
#define ISX012_TYPE_JPGQUALITY V4L2_CTRL_TYPE_INTEGER
#define ISX012_NAME_JPGQUALITY "JPEG compression quality"
#define ISX012_DEF_JPGQUALITY (75)
#define ISX012_DEF_JPGQUALITY (80)
#define ISX012_MIN_JPGQUALITY (1)
#define ISX012_MAX_JPGQUALITY (100)
#define ISX012_STEP_JPGQUALITY (1)

View file

@ -1,5 +1,5 @@
/****************************************************************************
* include/nuttx/video/isx012_reg.h
* drivers/video/isx012_reg.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
@ -41,6 +41,8 @@
#define MODE_BASE (0x6A00)
#define PICT_BASE (0x6C00)
#define GAMMA_BASE (0x7000)
#define GAMMA1_BASE (0x7200)
#define GAMMA2_BASE (0x7400)
#define JPEG_BASE (0x7800)
#define AUTOCOM_BASE (0x7C00)
#define VFRMPARA_BASE (0x8800)
@ -777,6 +779,18 @@
#define G0_0CLIP_B (GAMMA_BASE+0x0044)
#define G0_KNOT_GAINCTRL_TH_L (GAMMA_BASE+0x0046)
#define G0_KNOT_GAINCTRL_TH_H (GAMMA_BASE+0x0047)
#define G1_LOWGM_ON_R (GAMMA1_BASE+0x003A)
#define G1_0CLIP_R (GAMMA1_BASE+0x003C)
#define G1_LOWGM_ON_G (GAMMA1_BASE+0x003E)
#define G1_0CLIP_G (GAMMA1_BASE+0x0040)
#define G1_LOWGM_ON_B (GAMMA1_BASE+0x0042)
#define G1_0CLIP_B (GAMMA1_BASE+0x0044)
#define G2_LOWGM_ON_R (GAMMA2_BASE+0x003A)
#define G2_0CLIP_R (GAMMA2_BASE+0x003C)
#define G2_LOWGM_ON_G (GAMMA2_BASE+0x003E)
#define G2_0CLIP_G (GAMMA2_BASE+0x0040)
#define G2_LOWGM_ON_B (GAMMA2_BASE+0x0042)
#define G2_0CLIP_B (GAMMA2_BASE+0x0044)
/* JPEG OFFSET */

File diff suppressed because it is too large Load diff

View file

@ -39,11 +39,11 @@ static void init_buf_chain(video_framebuff_t *fbuf)
int i;
vbuf_container_t *tmp;
fbuf->vbuf_empty = fbuf->vbuf_alloced;
fbuf->vbuf_next_dma = NULL;
fbuf->vbuf_dma = NULL;
fbuf->vbuf_top = NULL;
fbuf->vbuf_tail = NULL;
fbuf->vbuf_empty = fbuf->vbuf_alloced;
fbuf->vbuf_next = NULL;
fbuf->vbuf_curr = NULL;
fbuf->vbuf_top = NULL;
fbuf->vbuf_tail = NULL;
tmp = fbuf->vbuf_alloced;
for (i = 0; i < fbuf->container_size - 1; i++)
@ -74,9 +74,9 @@ static inline vbuf_container_t *dequeue_vbuf_unsafe(video_framebuff_t *fbuf)
vbuf_container_t *ret = fbuf->vbuf_top;
if (is_last_one(fbuf))
{
fbuf->vbuf_top = NULL;
fbuf->vbuf_tail = NULL;
fbuf->vbuf_next_dma = NULL;
fbuf->vbuf_top = NULL;
fbuf->vbuf_tail = NULL;
fbuf->vbuf_next = NULL;
}
else
{
@ -97,11 +97,11 @@ static inline vbuf_container_t *dequeue_vbuf_unsafe(video_framebuff_t *fbuf)
void video_framebuff_init(video_framebuff_t *fbuf)
{
fbuf->mode = V4L2_BUF_MODE_RING;
fbuf->vbuf_empty = NULL;
fbuf->vbuf_top = NULL;
fbuf->vbuf_tail = NULL;
fbuf->vbuf_next_dma = NULL;
fbuf->mode = V4L2_BUF_MODE_RING;
fbuf->vbuf_empty = NULL;
fbuf->vbuf_top = NULL;
fbuf->vbuf_tail = NULL;
fbuf->vbuf_next = NULL;
nxsem_init(&fbuf->lock_empty, 0, 1);
}
@ -135,7 +135,7 @@ int video_framebuff_realloc_container(video_framebuff_t *fbuf, int sz)
if (sz > 0)
{
fbuf->vbuf_alloced
= (vbuf_container_t *)kmm_malloc(sizeof(vbuf_container_t)*sz);
= (vbuf_container_t *)kmm_malloc(sizeof(vbuf_container_t)*sz);
if (fbuf->vbuf_alloced == NULL)
{
return -ENOMEM;
@ -154,7 +154,7 @@ vbuf_container_t *video_framebuff_get_container(video_framebuff_t *fbuf)
{
vbuf_container_t *ret;
nxsem_wait(&fbuf->lock_empty);
nxsem_wait_uninterruptible(&fbuf->lock_empty);
ret = fbuf->vbuf_empty;
if (ret)
{
@ -170,7 +170,7 @@ vbuf_container_t *video_framebuff_get_container(video_framebuff_t *fbuf)
void video_framebuff_free_container(video_framebuff_t *fbuf,
vbuf_container_t *cnt)
{
nxsem_wait(&fbuf->lock_empty);
nxsem_wait_uninterruptible(&fbuf->lock_empty);
cnt->next = fbuf->vbuf_empty;
fbuf->vbuf_empty = cnt;
nxsem_post(&fbuf->lock_empty);
@ -186,15 +186,15 @@ void video_framebuff_queue_container(video_framebuff_t *fbuf,
{
fbuf->vbuf_tail->next = tgt;
fbuf->vbuf_tail = tgt;
if (fbuf->vbuf_next_dma == NULL)
if (fbuf->vbuf_next == NULL)
{
fbuf->vbuf_next_dma = tgt;
fbuf->vbuf_next = tgt;
}
}
else
{
fbuf->vbuf_top = fbuf->vbuf_tail = tgt;
fbuf->vbuf_next_dma = tgt;
fbuf->vbuf_next = tgt;
}
if (fbuf->mode == V4L2_BUF_MODE_RING)
@ -215,7 +215,7 @@ vbuf_container_t *video_framebuff_dq_valid_container(video_framebuff_t *fbuf)
vbuf_container_t *ret = NULL;
flags = enter_critical_section();
if (fbuf->vbuf_top != NULL && fbuf->vbuf_top != fbuf->vbuf_next_dma)
if (fbuf->vbuf_top != NULL && fbuf->vbuf_top != fbuf->vbuf_next)
{
ret = dequeue_vbuf_unsafe(fbuf);
}
@ -225,25 +225,26 @@ vbuf_container_t *video_framebuff_dq_valid_container(video_framebuff_t *fbuf)
return ret;
}
vbuf_container_t *video_framebuff_get_dma_container(video_framebuff_t *fbuf)
vbuf_container_t *video_framebuff_get_vacant_container
(video_framebuff_t *fbuf)
{
irqstate_t flags;
vbuf_container_t *ret;
flags = enter_critical_section();
ret = fbuf->vbuf_dma = fbuf->vbuf_next_dma;
ret = fbuf->vbuf_curr = fbuf->vbuf_next;
leave_critical_section(flags);
return ret;
}
void video_framebuff_dma_done(video_framebuff_t *fbuf)
void video_framebuff_capture_done(video_framebuff_t *fbuf)
{
fbuf->vbuf_dma = NULL;
if (fbuf->vbuf_next_dma)
fbuf->vbuf_curr = NULL;
if (fbuf->vbuf_next)
{
fbuf->vbuf_next_dma = fbuf->vbuf_next_dma->next;
if (fbuf->vbuf_next_dma == fbuf->vbuf_top) /* RING mode case. */
fbuf->vbuf_next = fbuf->vbuf_next->next;
if (fbuf->vbuf_next == fbuf->vbuf_top) /* RING mode case. */
{
fbuf->vbuf_top = fbuf->vbuf_top->next;
fbuf->vbuf_tail = fbuf->vbuf_tail->next;
@ -264,12 +265,12 @@ void video_framebuff_change_mode(video_framebuff_t *fbuf,
if (mode == V4L2_BUF_MODE_RING)
{
fbuf->vbuf_tail->next = fbuf->vbuf_top;
fbuf->vbuf_next_dma = fbuf->vbuf_top;
fbuf->vbuf_next = fbuf->vbuf_top;
}
else
{
fbuf->vbuf_tail->next = NULL;
fbuf->vbuf_next_dma = fbuf->vbuf_top;
fbuf->vbuf_next = fbuf->vbuf_top;
}
}

View file

@ -29,7 +29,7 @@
#include <nuttx/semaphore.h>
/****************************************************************************
* Public Functions Definistions
* Public Types
****************************************************************************/
struct vbuf_container_s
@ -49,12 +49,16 @@ struct video_framebuff_s
vbuf_container_t *vbuf_empty;
vbuf_container_t *vbuf_top;
vbuf_container_t *vbuf_tail;
vbuf_container_t *vbuf_dma;
vbuf_container_t *vbuf_next_dma;
vbuf_container_t *vbuf_curr;
vbuf_container_t *vbuf_next;
};
typedef struct video_framebuff_s video_framebuff_t;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* Buffer access interface. */
void video_framebuff_init
@ -71,13 +75,13 @@ void video_framebuff_queue_container
(video_framebuff_t *fbuf, vbuf_container_t *tgt);
vbuf_container_t *video_framebuff_dq_valid_container
(video_framebuff_t *fbuf);
vbuf_container_t *video_framebuff_get_dma_container
vbuf_container_t *video_framebuff_get_vacant_container
(video_framebuff_t *fbuf);
vbuf_container_t *video_framebuff_pop_curr_container
(video_framebuff_t *fbuf);
void video_framebuff_dma_done
void video_framebuff_capture_done
(video_framebuff_t *fbuf);
void video_framebuff_change_mode
(video_framebuff_t *fbuf, enum v4l2_buf_mode mode);
#endif // __VIDEO_VIDEO_FRAMEBUFF_H__
#endif // __VIDEO_VIDEO_FRAMEBUFF_H__

View file

@ -0,0 +1,108 @@
/****************************************************************************
* include/nuttx/video/imgdata.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_VIDEO_IMGDATA_H
#define __INCLUDE_NUTTX_VIDEO_IMGDATA_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/types.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Format definition for start_capture() and validate_frame_setting */
#define IMGDATA_FMT_MAX (2)
#define IMGDATA_FMT_MAIN (0)
#define IMGDATA_FMT_SUB (1)
#define IMGDATA_PIX_FMT_UYVY (0)
#define IMGDATA_PIX_FMT_RGB565 (1)
#define IMGDATA_PIX_FMT_JPEG (2)
#define IMGDATA_PIX_FMT_JPEG_WITH_SUBIMG (3)
#define IMGDATA_PIX_FMT_SUBIMG_UYVY (4)
#define IMGDATA_PIX_FMT_SUBIMG_RGB565 (5)
/****************************************************************************
* Public Types
****************************************************************************/
/* structure for validate_frame_setting() and start_capture() */
typedef struct imgdata_format_s
{
uint16_t width;
uint16_t height;
uint32_t pixelformat;
} imgdata_format_t;
typedef struct imgdata_interval_s
{
uint32_t numerator;
uint32_t denominator;
} imgdata_interval_t;
typedef int (*imgdata_capture_t)(uint8_t result, uint32_t size);
/* Structure for Data Control I/F */
struct imgdata_ops_s
{
CODE int (*init)(void);
CODE int (*uninit)(void);
CODE int (*validate_buf)(uint8_t *addr, uint32_t size);
CODE int (*set_buf)(uint8_t *addr, uint32_t size);
CODE int (*validate_frame_setting)(uint8_t nr_datafmts,
FAR imgdata_format_t *datafmts,
FAR imgdata_interval_t *interval);
CODE int (*start_capture)(uint8_t nr_datafmts,
FAR imgdata_format_t *datafmts,
FAR imgdata_interval_t *interval,
FAR imgdata_capture_t callback);
CODE int (*stop_capture)(void);
};
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* Register image data operations. */
void imgdata_register(const FAR struct imgdata_ops_s *ops);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_VIDEO_IMGDATA_H */

View file

@ -0,0 +1,350 @@
/****************************************************************************
* include/nuttx/video/imgsensor.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_VIDEO_IMGSENSOR_H
#define __INCLUDE_NUTTX_VIDEO_IMGSENSOR_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <sys/types.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* 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_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)
/* bit definition for IMGSENSOR_ID_3A_LOCK */
#define IMGSENSOR_LOCK_EXPOSURE (1 << 0)
#define IMGSENSOR_LOCK_WHITE_BALANCE (1 << 1)
#define IMGSENSOR_LOCK_FOCUS (1 << 2)
/* Status bit definition for IMGSENSOR_ID_3A_STATUS */
#define IMGSENSOR_3A_STATUS_STABLE (0)
#define IMGSENSOR_3A_STATUS_AE_OPERATING (1 << 0)
#define IMGSENSOR_3A_STATUS_AWB_OPERATING (1 << 1)
#define IMGSENSOR_3A_STATUS_AF_OPERATING (1 << 2)
/* Format definition for start_capture() and validate_frame_setting */
#define IMGSENSOR_FMT_MAX (2)
#define IMGSENSOR_FMT_MAIN (0)
#define IMGSENSOR_FMT_SUB (1)
#define IMGSENSOR_PIX_FMT_UYVY (0)
#define IMGSENSOR_PIX_FMT_RGB565 (1)
#define IMGSENSOR_PIX_FMT_JPEG (2)
#define IMGSENSOR_PIX_FMT_JPEG_WITH_SUBIMG (3)
#define IMGSENSOR_PIX_FMT_SUBIMG_UYVY (4)
#define IMGSENSOR_PIX_FMT_SUBIMG_RGB565 (5)
/****************************************************************************
* Public Types
****************************************************************************/
/* enumeration for VIDEO_ID_COLORFX */
typedef enum imgsensor_colorfx_e
{
IMGSENSOR_COLORFX_NONE = 0,
IMGSENSOR_COLORFX_BW = 1,
IMGSENSOR_COLORFX_SEPIA = 2,
IMGSENSOR_COLORFX_NEGATIVE = 3,
IMGSENSOR_COLORFX_EMBOSS = 4,
IMGSENSOR_COLORFX_SKETCH = 5,
IMGSENSOR_COLORFX_SKY_BLUE = 6,
IMGSENSOR_COLORFX_GRASS_GREEN = 7,
IMGSENSOR_COLORFX_SKIN_WHITEN = 8,
IMGSENSOR_COLORFX_VIVID = 9,
IMGSENSOR_COLORFX_AQUA = 10,
IMGSENSOR_COLORFX_ART_FREEZE = 11,
IMGSENSOR_COLORFX_SILHOUETTE = 12,
IMGSENSOR_COLORFX_SOLARIZATION = 13,
IMGSENSOR_COLORFX_ANTIQUE = 14,
IMGSENSOR_COLORFX_SET_CBCR = 15,
IMGSENSOR_COLORFX_PASTEL = 16,
} imgsensor_colorfx_t;
/* enumeration for IMGSENSOR_ID_EXPOSURE_AUTO */
typedef enum imgsensor_exposure_auto_type_e
{
/* exposure time:auto, iris aperture:auto */
IMGSENSOR_EXPOSURE_AUTO = 0,
/* exposure time:manual, iris aperture:manual */
IMGSENSOR_EXPOSURE_MANUAL = 1,
/* exposure time:manual, iris aperture:auto */
IMGSENSOR_EXPOSURE_SHUTTER_PRIORITY = 2,
/* exposure time:auto, iris aperture:manual */
IMGSENSOR_EXPOSURE_APERTURE_PRIORITY = 3
} imgsensor_exposure_auto_type_t;
/* enumeration for IMGSENSOR_ID_AUTO_N_PRESET_WHITE_BALANCE */
typedef enum imgsensor_white_balance_e
{
IMGSENSOR_WHITE_BALANCE_MANUAL = 0,
IMGSENSOR_WHITE_BALANCE_AUTO = 1,
IMGSENSOR_WHITE_BALANCE_INCANDESCENT = 2,
IMGSENSOR_WHITE_BALANCE_FLUORESCENT = 3,
IMGSENSOR_WHITE_BALANCE_FLUORESCENT_H = 4,
IMGSENSOR_WHITE_BALANCE_HORIZON = 5,
IMGSENSOR_WHITE_BALANCE_DAYLIGHT = 6,
IMGSENSOR_WHITE_BALANCE_FLASH = 7,
IMGSENSOR_WHITE_BALANCE_CLOUDY = 8,
IMGSENSOR_WHITE_BALANCE_SHADE = 9,
} imgsensor_white_balance_t;
/* enumeration for IMGSENSOR_ID_ISO_SENSITIVITY_AUTO */
typedef enum imgsensor_iso_sensitivity_auto_type_e
{
IMGSENSOR_ISO_SENSITIVITY_MANUAL = 0,
IMGSENSOR_ISO_SENSITIVITY_AUTO = 1,
} imgsensor_iso_sensitivity_auto_type_t;
/* enumeration for IMGSENSOR_ID_EXPOSURE_METERING */
typedef enum imgsensor_exposure_metering_e
{
IMGSENSOR_EXPOSURE_METERING_AVERAGE = 0,
IMGSENSOR_EXPOSURE_METERING_CENTER_WEIGHTED = 1,
IMGSENSOR_EXPOSURE_METERING_SPOT = 2,
IMGSENSOR_EXPOSURE_METERING_MATRIX = 3,
} imgsensor_exposure_metering_t;
/* enumeration for IMGSENSOR_ID_FLASH_LED_MODE */
typedef enum imgsensor_flash_led_mode_e
{
IMGSENSOR_FLASH_LED_MODE_NONE = 0,
IMGSENSOR_FLASH_LED_MODE_FLASH = 1,
IMGSENSOR_FLASH_LED_MODE_TORCH = 2,
} imgsensor_flash_led_mode_t;
/* enumeration for get_supported_value() */
typedef enum imgsensor_ctrl_type_e
{
IMGSENSOR_CTRL_TYPE_INTEGER = 1,
IMGSENSOR_CTRL_TYPE_BOOLEAN = 2,
IMGSENSOR_CTRL_TYPE_INTEGER64 = 5,
IMGSENSOR_CTRL_TYPE_BITMASK = 8,
IMGSENSOR_CTRL_TYPE_INTEGER_MENU = 9,
IMGSENSOR_CTRL_TYPE_U8FIXEDPOINT_Q7 = 10,
IMGSENSOR_CTRL_TYPE_U16FIXEDPOINT_Q8 = 11,
IMGSENSOR_CTRL_TYPE_INTEGER_TIMES_3 = 12,
IMGSENSOR_CTRL_TYPE_U8 = 0x0100,
IMGSENSOR_CTRL_TYPE_U16 = 0x0101,
IMGSENSOR_CTRL_TYPE_U32 = 0x0102,
} imgsensor_ctrl_type_t;
/* enumeration for stream */
typedef enum imgsensor_stream_type_e
{
IMGSENSOR_STREAM_TYPE_VIDEO = 0,
IMGSENSOR_STREAM_TYPE_STILL = 1,
} imgsensor_stream_type_t;
/* structure for validate_frame_setting() and start_capture() */
typedef struct imgsensor_format_s
{
uint16_t width;
uint16_t height;
uint32_t pixelformat;
} imgsensor_format_t;
typedef struct imgsensor_interval_s
{
uint32_t numerator;
uint32_t denominator;
} imgsensor_interval_t;
/* structure for get_supported_value() */
typedef struct imgsensor_capability_range_s
{
int64_t minimum;
int64_t maximum;
uint64_t step;
int64_t default_value;
} imgsensor_capability_range_t;
typedef struct imgsensor_capability_discrete_s
{
int8_t nr_values;
int32_t *values;
int32_t default_value;
} imgsensor_capability_discrete_t;
typedef struct imgsensor_capability_elems_s
{
uint32_t nr_elems;
int64_t minimum;
int64_t maximum;
uint64_t step;
} imgsensor_capability_elems_t;
typedef struct imgsensor_supported_value_s
{
imgsensor_ctrl_type_t type; /* control type */
union
{
/* Use 'range' member in the following types cases.
* IMGSENSOR_CTRL_TYPE_INTEGER
* IMGSENSOR_CTRL_TYPE_BOOLEAN
* IMGSENSOR_CTRL_TYPE_INTEGER64
* IMGSENSOR_CTRL_TYPE_BITMASK
* IMGSENSOR_CTRL_TYPE_U8FIXEDPOINT_Q7
* IMGSENSOR_CTRL_TYPE_U16FIXEDPOINT_Q8
* IMGSENSOR_CTRL_TYPE_INTEGER_TIMES_3
*/
imgsensor_capability_range_t range;
/* Use 'discrete' member in the following type case.
* IMGSENSOR_CTRL_TYPE_INTEGER_MENU
*/
imgsensor_capability_discrete_t discrete;
/* Use 'elems' member in the following types cases.
* IMGSENSOR_CTRL_TYPE_U8
* IMGSENSOR_CTRL_TYPE_U16
* IMGSENSOR_CTRL_TYPE_U32
*/
imgsensor_capability_elems_t elems;
} u;
} imgsensor_supported_value_t;
typedef union imgsensor_value_u
{
int32_t value32;
int64_t value64;
uint8_t *p_u8;
uint16_t *p_u16;
uint32_t *p_u32;
} imgsensor_value_t;
/* Structure for Image Sensor I/F */
struct imgsensor_ops_s
{
CODE int (*init)(void);
CODE int (*uninit)(void);
CODE int (*validate_frame_setting)(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,
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_supported_value)(uint32_t id,
FAR imgsensor_supported_value_t *value);
CODE int (*get_value)(uint32_t id,
uint32_t size,
FAR imgsensor_value_t *value);
CODE int (*set_value)(uint32_t id,
uint32_t size,
imgsensor_value_t value);
};
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* Register image sensor operations. */
void imgsensor_register(const FAR struct imgsensor_ops_s *ops);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_VIDEO_HALIF_H */

View file

@ -49,7 +49,7 @@ extern "C"
* Public Function Prototypes
****************************************************************************/
FAR struct video_devops_s *isx012_initialize(void);
int isx012_initialize(FAR struct i2c_master_s *i2c);
int isx012_uninitialize(void);
#undef EXTERN

View file

@ -25,10 +25,8 @@
* Included Files
****************************************************************************/
#include <nuttx/compiler.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <sys/ioctl.h>
#include "video_controls.h"
#ifdef __cplusplus
@ -150,6 +148,30 @@ extern "C"
#define VIDIOC_CANCEL_DQBUF _VIDIOC(0x0016)
/* Query control for scene parameter
* Address pointing to struct v4s_query_ext_ctrl_scene
*/
#define V4SIOC_QUERY_EXT_CTRL_SCENE _VIDIOC(0x0017)
/* Query menu for scene parameter
* Address pointing to struct v4s_querymenu_scene
*/
#define V4SIOC_QUERYMENU_SCENE _VIDIOC(0x0018)
/* Get current control value
* Address pointing to struct v4s_ext_controls_scene
*/
#define V4SIOC_G_EXT_CTRLS_SCENE _VIDIOC(0x0019)
/* Set control value
* Address pointing to struct v4s_ext_controls_scene
*/
#define V4SIOC_S_EXT_CTRLS_SCENE _VIDIOC(0x001a)
#define VIDEO_HSIZE_QVGA (320) /* QVGA horizontal size */
#define VIDEO_VSIZE_QVGA (240) /* QVGA vertical size */
#define VIDEO_HSIZE_VGA (640) /* VGA horizontal size */
@ -188,6 +210,14 @@ extern "C"
#define V4L2_PIX_FMT_JPEG_WITH_SUBIMG v4l2_fourcc('J', 'S', 'U', 'B')
/* YUV 4:2:2 for sub image */
#define V4L2_PIX_FMT_SUBIMG_UYVY v4l2_fourcc('S', 'Y', 'U', 'V')
/* RGB565 for sub image */
#define V4L2_PIX_FMT_SUBIMG_RGB565 v4l2_fourcc('S', 'R', 'G', 'B')
/* MAX length of v4l2_fmtdesc description string */
#define V4L2_FMT_DSC_MAX (32)
@ -343,14 +373,13 @@ struct v4l2_fmtdesc
uint32_t flags;
char description[V4L2_FMT_DSC_MAX]; /* Description string */
uint32_t pixelformat; /* Format fourcc */
uint32_t subimg_pixelformat; /* Format fourcc */
};
enum v4l2_frmsizetypes
{
V4L2_FRMSIZE_TYPE_DISCRETE = 1, /* Discrete value */
V4L2_FRMSIZE_TYPE_DISCRETE = 1, /* Discrete value */
V4L2_FRMSIZE_TYPE_CONTINUOUS = 2, /* Continuous value */
V4L2_FRMSIZE_TYPE_STEPWISE = 3, /* Step value */
V4L2_FRMSIZE_TYPE_STEPWISE = 3, /* Step value */
};
struct v4l2_frmsize_discrete
@ -375,33 +404,16 @@ struct v4l2_frmsizeenum
uint32_t buf_type; /* enum #v4l2_buf_type */
uint32_t pixel_format; /* Pixel format */
uint32_t type; /* Frame size type the device supports. */
union
{ /* Frame size */
struct v4l2_frmsize_discrete discrete; /* Use in type =
* V4L2_FRMSIZE_TYPE_DISCRETE
* case
*/
struct v4l2_frmsize_stepwise stepwise; /* Use in type =
* V4L2_FRMSIZE_TYPE_CONTINUOUS
* or V4L2_FRMSIZE_TYPE_STEPWISE
* case
*/
};
uint32_t subimg_pixel_format; /* Pixel format of sub image */
uint32_t subimg_type; /* Frame size type of subimage. */
/* In type == V4L2_FRMSIZE_TYPE_DISCRETE case, use discrete.
* Otherwise, use stepwise.
*/
union
{ /* Frame size of subimage */
struct v4l2_frmsize_discrete discrete; /* Use in subimg_type =
* V4L2_FRMSIZE_TYPE_DISCRETE
* case
*/
struct v4l2_frmsize_stepwise stepwise; /* Use in subimg_type =
* V4L2_FRMSIZE_TYPE_CONTINUOUS
* or V4L2_FRMSIZE_TYPE_STEPWISE
* case
*/
} subimg;
{
struct v4l2_frmsize_discrete discrete;
struct v4l2_frmsize_stepwise stepwise;
};
};
/* type of frame interval enumeration */
@ -437,9 +449,6 @@ struct v4l2_frmivalenum
uint32_t pixel_format; /* Pixel format */
uint16_t width; /* Frame width */
uint16_t height; /* Frame height */
uint32_t subimg_pixel_format; /* Pixel format for sub image */
uint16_t subimg_width; /* Frame width for sub image */
uint16_t subimg_height; /* Frame height for sub image */
uint32_t type; /* Frame interval type */
union
{ /* Frame interval */
@ -455,9 +464,6 @@ struct v4l2_pix_format
uint16_t width; /* Image width in pixels */
uint16_t height; /* Image height in pixels */
uint32_t pixelformat; /* The pixel format or type of compression. */
uint16_t subimg_width; /* sub image width in pixels in case of pixelformat = V4L2_PIX_FMT_JPEG_WITH_SUBIMG */
uint16_t subimg_height; /* sub image height in pixels in case of pixelformat = V4L2_PIX_FMT_JPEG_WITH_SUBIMG */
uint32_t subimg_pixelformat; /* The pixel format of sub image in case of pixelformat = V4L2_PIX_FMT_JPEG_WITH_SUBIMG */
uint32_t field; /* enum #v4l2_field */
uint32_t bytesperline; /* for padding, zero if unused */
uint32_t sizeimage; /* Size in bytes of the buffer to hold a complete image */
@ -556,7 +562,7 @@ struct v4l2_query_ext_ctrl
uint32_t dims[V4L2_CTRL_MAX_DIMS]; /* Dimensions */
};
begin_packed_struct struct v4l2_querymenu
struct v4l2_querymenu
{
uint16_t ctrl_class; /* camera control class */
uint16_t id; /* camera control id */
@ -566,7 +572,7 @@ begin_packed_struct struct v4l2_querymenu
char name[32]; /* name of menu */
int64_t value; /* value of menu */
};
} end_packed_struct;
};
struct v4l2_control
{
@ -578,7 +584,7 @@ struct v4l2_control
* ioctl(VIDIOC_G_EXT_CTRLS / VIDIOC_S_EXT_CTRLS)
*/
begin_packed_struct struct v4l2_ext_control
struct v4l2_ext_control
{
uint16_t id; /* camera control id */
uint16_t size; /* size of value(not use) */
@ -592,7 +598,7 @@ begin_packed_struct struct v4l2_ext_control
uint32_t *p_u32; /* QUERY_EXT_CTRL type = U32 */
void *ptr;
};
} end_packed_struct;
};
struct v4l2_ext_controls
{
@ -606,9 +612,29 @@ struct v4l2_ext_controls
struct v4l2_ext_control *controls; /* each control information */
};
/****************************************************************************
* Public Data
****************************************************************************/
/* Structure for V4SIOC_S_EXT_CTRLS and V4SIOC_G_EXT_CTRLS */
struct v4s_ext_controls_scene
{
enum v4l2_scene_mode mode; /* scene mode to be controled */
struct v4l2_ext_controls control; /* same as VIDIOC_S_EXT_CTRLS */
};
/* Structure for V4SIOC_QUERY_EXT_CTRL */
struct v4s_query_ext_ctrl_scene
{
enum v4l2_scene_mode mode; /* scene mode to be queried */
struct v4l2_query_ext_ctrl control; /* same as VIDIOC_QUERY_EXT_CTRL */
};
/* Structure for V4SIOC_QUERYMENU */
struct v4s_querymenu_scene
{
enum v4l2_scene_mode mode; /* scene mode to be queried */
struct v4l2_querymenu menu; /* same as VIDIOC_QUERYMENU */
};
/****************************************************************************
* Public Function Prototypes
@ -622,8 +648,7 @@ struct v4l2_ext_controls
* negative value is returned.
*/
int video_initialize(FAR const char *devpath,
FAR const struct video_devops_s *devops);
int video_initialize(FAR const char *devpath);
/* Uninitialize video driver.
*

View file

@ -1,84 +0,0 @@
/****************************************************************************
* include/nuttx/video/video_halif.h
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership. The
* ASF licenses this file to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance with the
* License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations
* under the License.
*
****************************************************************************/
#ifndef __INCLUDE_NUTTX_VIDEO_HALIF_H
#define __INCLUDE_NUTTX_VIDEO_HALIF_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/video/video.h>
/****************************************************************************
* Public Types
****************************************************************************/
struct video_devops_s
{
CODE int (*open)(FAR void *video_priv);
CODE int (*close)(void);
CODE int (*do_halfpush)(bool enable);
CODE int (*set_buftype)(enum v4l2_buf_type type);
CODE int (*set_buf)(uint32_t bufaddr, uint32_t bufsize);
CODE int (*cancel_dma)(void);
CODE int (*get_range_of_fmt)(FAR struct v4l2_fmtdesc *format);
CODE int (*get_range_of_framesize)(FAR struct v4l2_frmsizeenum *frmsize);
CODE int (*try_format)(FAR struct v4l2_format *format);
CODE int (*set_format)(FAR struct v4l2_format *format);
CODE int (*get_range_of_frameinterval)
(FAR struct v4l2_frmivalenum *frmival);
CODE int (*set_frameinterval)(FAR struct v4l2_streamparm *parm);
CODE int (*get_range_of_ctrlvalue)(FAR struct v4l2_query_ext_ctrl *range);
CODE int (*get_menu_of_ctrlvalue)(FAR struct v4l2_querymenu *menu);
CODE int (*get_ctrlvalue)(uint16_t ctrl_class,
FAR struct v4l2_ext_control *control);
CODE int (*set_ctrlvalue)(uint16_t ctrl_class,
FAR struct v4l2_ext_control *control);
CODE int (*refresh)(void);
};
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Functions Definitions
****************************************************************************/
int video_common_notify_dma_done(uint8_t err_code,
uint32_t buf_type,
uint32_t datasize,
FAR void *priv);
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif /* __INCLUDE_NUTTX_VIDEO_HALIF_H */