diff options
author | Jeongmo Yang <jm80.yang@samsung.com> | 2017-05-24 14:40:15 +0900 |
---|---|---|
committer | Sylwester Nawrocki <s.nawrocki@samsung.com> | 2017-11-17 12:51:14 +0100 |
commit | 09fdfed765434c92e1881b97afcf59ab0337a05e (patch) | |
tree | 6a887e17735ca31afb2f94bb72f0746bb40f9dfc | |
parent | 8045622ac9422154b44afb931d0a9fdfca3ec814 (diff) | |
download | gst-plugins-camera-n4-09fdfed765434c92e1881b97afcf59ab0337a05e.tar.gz gst-plugins-camera-n4-09fdfed765434c92e1881b97afcf59ab0337a05e.tar.bz2 gst-plugins-camera-n4-09fdfed765434c92e1881b97afcf59ab0337a05e.zip |
Support rear camera for test
[Version] 0.0.2
[Profile] Common
[Issue Type] Update
[Dependency module] N/A
[Test] [M(T) - Boot=(OK), sdb=(OK), Home=(OK), Touch=(OK), Version=tizen-unified_20170515.1]
Change-Id: I62d41d1886426a201fae294e103ca2b718420fa5
Signed-off-by: Jeongmo Yang <jm80.yang@samsung.com>
-rw-r--r-- | camerasrc/src/camerasrc-internal.c | 8 | ||||
-rw-r--r-- | camerasrc/src/camerasrc.c | 1870 | ||||
-rw-r--r-- | camerasrc/src/gstcamerasrc.c | 30 | ||||
-rw-r--r-- | camerasrc/src/include/camerasrc-common.h | 22 | ||||
-rw-r--r-- | camerasrc/src/include/camerasrc.h | 3 |
5 files changed, 1398 insertions, 535 deletions
diff --git a/camerasrc/src/camerasrc-internal.c b/camerasrc/src/camerasrc-internal.c index ff528bd..622790c 100644 --- a/camerasrc/src/camerasrc-internal.c +++ b/camerasrc/src/camerasrc-internal.c @@ -817,10 +817,10 @@ static int _camerasrc_set_cmd(camerasrc_handle_t *handle, _camsrc_cmd_t cmd, voi break; case _CAMERASRC_CMD_AF_CONTROL: /* WRITEME */ - camsrc_info("[_CAMERASRC_CMD_AF_CONTROL] cmd set(value=%d)", (int)value); + camsrc_info("[_CAMERASRC_CMD_AF_CONTROL] cmd set(value=%d)", (int)(long)value); /* FIXME : Please fix whole AF implementation!!! */ - switch ((int)value) { + switch ((int)(long)value) { case _CAMERASRC_AF_START: _camerasrc_start_autofocusing(handle); break; @@ -933,12 +933,12 @@ static int _camerasrc_get_cmd(camerasrc_handle_t *handle, _camsrc_cmd_t cmd, voi break; case _CAMERASRC_CMD_AF_CONTROL: camsrc_log("[_CAMERASRC_CMD_AF_CONTROL] cmd get"); - switch ((int)value) { + switch ((int)(long)value) { case _CAMERASRC_AF_RESULT: _camerasrc_get_autofocusing_result(handle); break; default: - camsrc_info("Not support : GET AF CONTROL [%d]", (int)value); + camsrc_info("Not support : GET AF CONTROL [%d]", (int)(long)value); break; } break; diff --git a/camerasrc/src/camerasrc.c b/camerasrc/src/camerasrc.c index 1cd578b..2b0926a 100644 --- a/camerasrc/src/camerasrc.c +++ b/camerasrc/src/camerasrc.c @@ -35,6 +35,7 @@ #define S_FMT_COUNT 2 #define BUF_LEN 64 +#define META_PLANE_SIZE 32768 /* * LOCAL DEFINITIONS @@ -79,6 +80,8 @@ /* FIMC IS NUM */ +#define FIMC_IS_VIDEO_3A0_NUM 10 +#define FIMC_IS_VIDEO_3A0P_NUM 12 #define FIMC_IS_VIDEO_3A1_NUM 14 #define FIMC_IS_VIDEO_3A1P_NUM 16 #define FIMC_IS_VIDEO_ISP_NUM 30 @@ -97,6 +100,18 @@ #define GRP_SCC 0x06 #define GRP_SCP 0x07 +/* struct camera2_internal_udm */ +/* #define FIMC_IS_ISP_VS2_INIT 0x003F8CE4 */ +#define FIMC_IS_ISP_VS2_INIT_R 0x0044BC0C +/* #define FIMC_IS_ISP_VS2_INIT_R 0x004438BC */ +/* #define FIMC_IS_ISP_VS2_INIT_R 0x00453F5C */ + +#define FIMC_IS_ISP_VS2_STEP 0x8350 +#define FIMC_IS_ISP_VS2_RANGE 40 + +#define PRIMARY_SENSOR_WIDTH_1 5328 +#define PRIMARY_SENSOR_WIDTH_2 4000 +#define PRIMARY_SENSOR_HEIGHT 3000 extern const CAMERASRC_DEV_DEPENDENT_MISC_FUNC *dev_misc_func; @@ -115,6 +130,9 @@ int _camerasrc_ioctl_reqbufs(camerasrc_handle_t *p, int fd, guint count, int typ int _camerasrc_ioctl_qbuf(camerasrc_handle_t *p, int fd, int type, int memory, int idx, camerasrc_buffer_t *buffer); int _camerasrc_ioctl_dqbuf(camerasrc_handle_t *p, int fd, int type, int memory, int *idx, int num_planes); int _camerasrc_ioctl_stream(camerasrc_handle_t *p, int fd, int type, int on); +static int _camerasrc_allocate_device_buffer(camsrc_handle_t handle, camerasrc_buffer_t **device_buffer, + camerasrc_format_t *device_format, int buffer_size[], int num_planes); +static void _camerasrc_release_device_buffer(camerasrc_buffer_t *device_buffer, int num_buffers); /**** A U T O F O C U S I N G F U N C T I O N S ****/ @@ -132,13 +150,19 @@ int _camerasrc_get_exif_info(camerasrc_handle_t *handle, camerasrc_buffer_t *exi static int _camerasrc_set_shot_meta(camerasrc_handle_t *p, unsigned int grpid, int fcount, unsigned long long timestamp, struct camera2_shot_ext *shot_ext); +static int _camerasrc_set_shot_meta2(camerasrc_handle_t *p, unsigned int grpid, int fcount, + unsigned long long timestamp, struct camera2_shot_ext *shot_ext); + +static int _camerasrc_get_device_type_string(camerasrc_handle_t *p, int fd, int type, char **device_string, char **type_string); /* media definitions */ -#define VIDEO_DEVICE_NODE_PRIMARY "/dev/video1" +#define VIDEO_DEVICE_NODE_PRIMARY "/dev/video100" #define VIDEO_DEVICE_NODE_SECONDARY "/dev/video101" #define VIDEO_DEVICE_NODE_COMPANION "/dev/video109" #define VIDEO_DEVICE_NODE_ISP "/dev/video130" +#define VIDEO_DEVICE_NODE_3AA0 "/dev/video110" +#define VIDEO_DEVICE_NODE_3AA0C "/dev/video111" #define VIDEO_DEVICE_NODE_3AA1 "/dev/video114" #define VIDEO_DEVICE_NODE_3AA1C "/dev/video115" #define VIDEO_DEVICE_NODE_SCC "/dev/video134" @@ -173,6 +197,43 @@ static int buf_4k_align(unsigned int buf_size) } +static int _camerasrc_get_device_type_string(camerasrc_handle_t *p, int fd, int type, char **device_string, char **type_string) +{ + if (!p || !device_string || !type_string) { + camsrc_error("NULL ptr %p %p %p", p, device_string, type_string); + return CAMERASRC_ERR_INVALID_PARAMETER; + } + + if (fd == p->fd_sensor) + *device_string = "SENSOR"; + else if (fd == p->fd_isp) + *device_string = "ISP"; + else if (fd == p->fd_3aa0) + *device_string = "3AA0"; + else if (fd == p->fd_3aa0c) + *device_string = "3AA0C"; + else if (fd == p->fd_3aa1) + *device_string = "3AA1"; + else if (fd == p->fd_3aa1c) + *device_string = "3AA1C"; + else if (fd == p->fd_scc) + *device_string = "SCC"; + else if (fd == p->fd_scp) + *device_string = "SCP"; + else + *device_string = "Unknown"; + + if (type == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) + *type_string = "CAPTURE_MPLANE"; + else if (type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) + *type_string = "OUTPUT_MPLANE"; + else + *type_string = "Unknown"; + + return CAMERASRC_SUCCESS; +} + + static int _camerasrc_set_cmd(camsrc_handle_t handle, _camsrc_cmd_t cmd, void *value) { camerasrc_handle_t *p = NULL; @@ -476,21 +537,28 @@ int _camerasrc_ioctl_s_fmt(camerasrc_handle_t *p, int fd, int type, camerasrc_fo int i = 0; int width = 0; int height = 0; - struct v4l2_format vformat; + char *device_string = NULL; + char *type_string = NULL; char err_msg[CAMERASRC_ERRMSG_MAX_LEN] = {'\0',}; + struct v4l2_format vformat; if (p == NULL || fd < 0 || format ==NULL) { camsrc_error("INVALID parameter %p %d %p", p, fd, format); return CAMERASRC_ERR_INVALID_PARAMETER; } + if (_camerasrc_get_device_type_string(p, fd, type, &device_string, &type_string) != CAMERASRC_SUCCESS) { + camsrc_error("get device and type string failed"); + return CAMERASRC_ERR_INVALID_PARAMETER; + } + memset(&vformat, 0x0, sizeof(struct v4l2_format)); width = format->img_size.width; height = format->img_size.height; - camsrc_info("ENTER - type %d, format %d, %dx%d", - type, format->pix_format, width, height); + camsrc_info("ENTER - device %s, type %s [%d], format %d, %dx%d", + device_string, type_string, type, format->pix_format, width, height); vformat.type = type; vformat.fmt.pix_mp.width = width; @@ -572,6 +640,8 @@ int _camerasrc_ioctl_s_fmt(camerasrc_handle_t *p, int fd, int type, camerasrc_fo int _camerasrc_ioctl_reqbufs(camerasrc_handle_t *p, int fd, guint count, int type, int memory, guint *ret_count) { int ret = CAMERASRC_SUCCESS; + char *device_string = NULL; + char *type_string = NULL; struct v4l2_requestbuffers vreq_bufs; if (p == NULL) { @@ -579,13 +649,19 @@ int _camerasrc_ioctl_reqbufs(camerasrc_handle_t *p, int fd, guint count, int typ return CAMERASRC_ERR_NULL_POINTER; } + if (_camerasrc_get_device_type_string(p, fd, type, &device_string, &type_string) != CAMERASRC_SUCCESS) { + camsrc_error("get device and type string failed"); + return CAMERASRC_ERR_INVALID_PARAMETER; + } + CLEAR(vreq_bufs); vreq_bufs.count = count; vreq_bufs.type = type; vreq_bufs.memory = memory; - camsrc_info("VIDIOC_REQBUFS : count %d, type %d, memory %d", count, type, memory); + camsrc_info("VIDIOC_REQBUFS : device %s, count %d, type %s %d, memory %d", + device_string, count, type_string, type, memory); ret = _camerasrc_ioctl(p, fd, VIDIOC_REQBUFS, &vreq_bufs); @@ -628,6 +704,7 @@ int _camerasrc_ioctl_qbuf(camerasrc_handle_t *p, int fd, int type, int memory, i if (buffer->planes[i].bo) { lvbuf.m.planes[i].m.fd = buffer->planes[i].fd; lvbuf.m.planes[i].length = buffer->planes[i].length; + lvbuf.m.planes[i].bytesused = buffer->planes[i].length; camsrc_debug("[index %d] [plane %d] fd %d, length %d", idx, i, lvbuf.m.planes[i].m.fd, lvbuf.m.planes[i].length); @@ -788,17 +865,113 @@ static int __camerasrc_open_device(camerasrc_handle_t *p, camerasrc_dev_id_t cam p->cur_dev_id = camera_id; + /* open device nodes and VIDIOC_S_INPUT */ + p->fd_companion = open(VIDEO_DEVICE_NODE_COMPANION, O_RDWR, 0); + if (p->fd_companion < 0) { + camsrc_error("open failed [%s] : COMPANION", VIDEO_DEVICE_NODE_COMPANION); + goto OPEN_FAILED; + } + if (camera_id == CAMERASRC_DEV_ID_PRIMARY) { - /* TODO : secondary camera is only enabled now */ - } else { - /* open device nodes and VIDIOC_S_INPUT */ - /* SENSOR */ - p->fd_companion = open(VIDEO_DEVICE_NODE_COMPANION, O_RDWR, 0); - if (p->fd_companion < 0) { - camsrc_error("open failed [%s] : COMPANION", VIDEO_DEVICE_NODE_COMPANION); + /* sensor */ + p->fd_sensor = open(VIDEO_DEVICE_NODE_PRIMARY, O_RDWR, 0); + if (p->fd_sensor < 0) { + camsrc_error("open failed [%s] : SENSOR", VIDEO_DEVICE_NODE_PRIMARY); + goto OPEN_FAILED; + } + + input = 0x68; + camsrc_info("[SENSOR] VIDIOC_S_INPUT 0x%x", input); + ret_ioctl = ioctl(p->fd_sensor, VIDIOC_S_INPUT, &input); + if (ret_ioctl < 0) { + camsrc_error("[SENSOR] VIDIOC_S_INPUT failed. SENSOR - input 0x%x", input); + goto OPEN_FAILED; + } + + /* ISP */ + p->fd_isp = open(VIDEO_DEVICE_NODE_ISP, O_RDWR, 0); + if (p->fd_isp < 0) { + camsrc_error("open failed [%s] : ISP", VIDEO_DEVICE_NODE_ISP); + goto OPEN_FAILED; + } + + input = 0xC68; + camsrc_info("[ISP] VIDIOC_S_INPUT 0x%x", input); + ret_ioctl = ioctl(p->fd_isp, VIDIOC_S_INPUT, &input); + if (ret_ioctl < 0) { + camsrc_error("[ISP] VIDIOC_S_INPUT failed. ISP - input 0x%x", input); + goto OPEN_FAILED; + } + + /* 3AA0 */ + p->fd_3aa0 = open(VIDEO_DEVICE_NODE_3AA0, O_RDWR, 0); + if (p->fd_3aa0 < 0) { + camsrc_error("open failed [%s] : 3AA0", VIDEO_DEVICE_NODE_3AA0); + goto OPEN_FAILED; + } + + input = 0x01000068; + camsrc_info("[3AA0] VIDIOC_S_INPUT 0x%x", input); + ret_ioctl = ioctl(p->fd_3aa0, VIDIOC_S_INPUT, &input); + if (ret_ioctl < 0) { + camsrc_error("[3AA0] VIDIOC_S_INPUT failed. 3AA0 - input 0x%x", input); + goto OPEN_FAILED; + } + + input = 0x01000068; + camsrc_info("[3AA0] VIDIOC_S_INPUT 0x%x", input); + ret_ioctl = ioctl(p->fd_3aa0, VIDIOC_S_INPUT, &input); + if (ret_ioctl < 0) { + camsrc_error("[3AA0] VIDIOC_S_INPUT failed. 3AA0 - input 0x%x", input); + goto OPEN_FAILED; + } + + /* 3AA0C */ + p->fd_3aa0c = open(VIDEO_DEVICE_NODE_3AA0C, O_RDWR, 0); + if (p->fd_3aa0c < 0) { + camsrc_error("open failed [%s] : 3AA0C", VIDEO_DEVICE_NODE_3AA0C); + goto OPEN_FAILED; + } + + input = 104; + camsrc_info("[3AA0C] VIDIOC_S_INPUT 0x%x", input); + ret_ioctl = ioctl(p->fd_3aa0c, VIDIOC_S_INPUT, &input); + if (ret_ioctl < 0) { + camsrc_error("[3AA0C] VIDIOC_S_INPUT failed. 3AA0C - input 0x%x", input); + goto OPEN_FAILED; + } + + /* SCC */ + p->fd_scc = open(VIDEO_DEVICE_NODE_SCC, O_RDWR, 0); + if (p->fd_scc < 0) { + camsrc_error("open failed [%s] : SCC", VIDEO_DEVICE_NODE_SCC); + goto OPEN_FAILED; + } + + input = 8808; + camsrc_info("[SCC] VIDIOC_S_INPUT 0x%x", input); + ret_ioctl = ioctl(p->fd_scc, VIDIOC_S_INPUT, &input); + if (ret_ioctl < 0) { + camsrc_error("[SCC] VIDIOC_S_INPUT failed. SCC - input 0x%x", input); goto OPEN_FAILED; } + /* SCP */ + p->fd_scp = open(VIDEO_DEVICE_NODE_SCP, O_RDWR, 0); + if (p->fd_scp < 0) { + camsrc_error("open failed [%s] : SCP", VIDEO_DEVICE_NODE_SCP); + goto OPEN_FAILED; + } + + input = 9576; + camsrc_info("[SCP] VIDIOC_S_INPUT 0x%x", input); + ret_ioctl = ioctl(p->fd_scp, VIDIOC_S_INPUT, &input); + if (ret_ioctl < 0) { + camsrc_error("[SCP] VIDIOC_S_INPUT failed. SCP - input 0x%x", input); + goto OPEN_FAILED; + } + } else { + /* sensor */ p->fd_sensor = open(VIDEO_DEVICE_NODE_SECONDARY, O_RDWR, 0); if (p->fd_sensor < 0) { camsrc_error("open failed [%s] : SENSOR", VIDEO_DEVICE_NODE_SECONDARY); @@ -926,46 +1099,51 @@ static void __camerasrc_close_device(camerasrc_handle_t *p) camsrc_info("start"); - /* Disable link media */ - if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { - /* TODO : secondary camera is only enabled now */ - } else { - if (p->fd_companion > -1) { - camsrc_info("close fd_companion : %d", p->fd_companion); - close(p->fd_companion); - p->fd_companion = -1; - } + if (p->fd_companion > -1) { + camsrc_info("close fd_companion : %d", p->fd_companion); + close(p->fd_companion); + p->fd_companion = -1; + } - if (p->fd_sensor > -1) { - camsrc_info("close fd_sensor : %d", p->fd_sensor); - close(p->fd_sensor); - p->fd_sensor = -1; - } - if (p->fd_isp > -1) { - camsrc_info("close fd_isp : %d", p->fd_isp); - close(p->fd_isp); - p->fd_isp = -1; - } - if (p->fd_3aa1 > -1) { - camsrc_info("close fd_3aa1 : %d", p->fd_3aa1); - close(p->fd_3aa1); - p->fd_3aa1 = -1; - } - if (p->fd_3aa1c > -1) { - camsrc_info("close fd_3aa1c : %d", p->fd_3aa1c); - close(p->fd_3aa1c); - p->fd_3aa1c = -1; - } - if (p->fd_scc > -1) { - camsrc_info("close fd_scc : %d", p->fd_scc); - close(p->fd_scc); - p->fd_scc = -1; - } - if (p->fd_scp > -1) { - camsrc_info("close fd_scp : %d", p->fd_scp); - close(p->fd_scp); - p->fd_scp = -1; - } + if (p->fd_sensor > -1) { + camsrc_info("close fd_sensor : %d", p->fd_sensor); + close(p->fd_sensor); + p->fd_sensor = -1; + } + if (p->fd_isp > -1) { + camsrc_info("close fd_isp : %d", p->fd_isp); + close(p->fd_isp); + p->fd_isp = -1; + } + if (p->fd_3aa0 > -1) { + camsrc_info("close fd_3aa0 : %d", p->fd_3aa0); + close(p->fd_3aa0); + p->fd_3aa0 = -1; + } + if (p->fd_3aa0c > -1) { + camsrc_info("close fd_3aa0c : %d", p->fd_3aa0c); + close(p->fd_3aa0c); + p->fd_3aa0c = -1; + } + if (p->fd_3aa1 > -1) { + camsrc_info("close fd_3aa1 : %d", p->fd_3aa1); + close(p->fd_3aa1); + p->fd_3aa1 = -1; + } + if (p->fd_3aa1c > -1) { + camsrc_info("close fd_3aa1c : %d", p->fd_3aa1c); + close(p->fd_3aa1c); + p->fd_3aa1c = -1; + } + if (p->fd_scc > -1) { + camsrc_info("close fd_scc : %d", p->fd_scc); + close(p->fd_scc); + p->fd_scc = -1; + } + if (p->fd_scp > -1) { + camsrc_info("close fd_scp : %d", p->fd_scp); + close(p->fd_scp); + p->fd_scp = -1; } camsrc_info("done"); @@ -1006,6 +1184,7 @@ static int _camerasrc_initialize_handle(camerasrc_handle_t *handle) handle->af_usr_data = NULL; handle->af_cb = NULL; handle->first_frame = 1; + handle->frame_count = 0; handle->request_count = 0; CLEAR(handle->queued_buf_list); @@ -1065,11 +1244,11 @@ static int _camerasrc_queue_buffer(camerasrc_handle_t *handle, int buf_index) } ret = _camerasrc_ioctl_qbuf(p, - p->fd_scp, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - buf_index, - &p->buffer_scp[buf_index]); + p->fd_scp, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + buf_index, + &p->buffer_scp[buf_index]); if (ret != CAMERASRC_SUCCESS) { camsrc_error("_camerasrc_ioctl_qbuf failed"); return CAMERASRC_ERR_IO_CONTROL; @@ -1084,180 +1263,271 @@ static int _camerasrc_dequeue_buffer(camerasrc_handle_t *handle, int *buf_index, camerasrc_handle_t *p = handle; int ret = CAMERASRC_ERR_UNKNOWN; int buf_index_sensor = 0; - int buf_index_3aa1cap = 0; - int buf_index_3aa1out = 0; + int buf_index_3aa_cap = 0; + int buf_index_3aa_out = 0; int buf_index_isp = 0; int buf_index_scc = 0; int buf_index_scp = 0; - unsigned long long timestamp; + unsigned long long timestamp = 0; struct camera2_shot_ext *shot_sensor = NULL; struct camera2_shot_ext *shot_isp = NULL; struct camera2_shot_ext *shot_scc = NULL; + struct camera2_shot_ext *shot_3aa = NULL; if (p->buffer_scp == NULL) { camsrc_error("buffer is not allocated"); return CAMERASRC_ERR_ALLOCATION; } +_DQ_AGAIN: /* SENSOR - DQBUF */ ret = _camerasrc_ioctl_dqbuf(p, - p->fd_sensor, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - &buf_index_sensor, - p->buffer_sensor[0].num_planes); + p->fd_sensor, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + &buf_index_sensor, + p->buffer_sensor[0].num_planes); if (ret != CAMERASRC_SUCCESS) { camsrc_error("[SENSOR] _camerasrc_ioctl_dqbuf failed"); return CAMERASRC_ERR_IO_CONTROL; } - camsrc_debug("[SENSOR] DQBUF index %d", buf_index_sensor); - shot_sensor = (struct camera2_shot_ext *)p->buffer_sensor[buf_index_sensor].planes[1].start; timestamp = shot_sensor->shot.dm.sensor.timeStamp; - handle->request_count++; + p->frame_count = shot_sensor->shot.dm.request.frameCount; - /* SENSOR set shot meta */ - _camerasrc_set_shot_meta(p, GRP_3AA, handle->request_count, timestamp, shot_sensor); + camsrc_debug("[SENSOR] DQBUF index %d, frame count %d", buf_index_sensor, p->frame_count); - /* 3AA1 CAPTURE - QBUF */ - ret = _camerasrc_ioctl_qbuf(p, - p->fd_3aa1, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - buf_index_sensor, - &p->buffer_isp[buf_index_sensor]); - if (ret != CAMERASRC_SUCCESS) { - camsrc_error("[3AA1 - CAPTURE] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_sensor, ret); - return CAMERASRC_ERR_IO_CONTROL; - } + p->request_count++; - /* 3AA1 OUTPUT - QBUF */ - ret = _camerasrc_ioctl_qbuf(p, - p->fd_3aa1, - V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, - V4L2_MEMORY_DMABUF, - buf_index_sensor, - &p->buffer_sensor[buf_index_sensor]); - if (ret != CAMERASRC_SUCCESS) { - camsrc_error("[3AA1 - OUTPUT] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_sensor, ret); - return CAMERASRC_ERR_IO_CONTROL; - } + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { + /* 3AA0 CAPTURE - DQBUF */ + ret = _camerasrc_ioctl_dqbuf(p, + p->fd_3aa0, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + &buf_index_3aa_cap, + p->buffer_isp[0].num_planes); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[3AA0 CAPTURE] _camerasrc_ioctl_dqbuf failed"); + return CAMERASRC_ERR_IO_CONTROL; + } - /* 3AA1 CAPTURE - DQBUF */ - ret = _camerasrc_ioctl_dqbuf(p, - p->fd_3aa1, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - &buf_index_3aa1cap, - p->buffer_sensor[0].num_planes); - if (ret != CAMERASRC_SUCCESS) { - camsrc_error("[3AA1 CAPTURE] _camerasrc_ioctl_dqbuf failed"); - return CAMERASRC_ERR_IO_CONTROL; + camsrc_debug("[3AA0 - CAPTURE] DQBUF index %d", buf_index_3aa_cap); + + /* 3AA0 OUTPUT - DQBUF */ + ret = _camerasrc_ioctl_dqbuf(p, + p->fd_3aa0, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + V4L2_MEMORY_DMABUF, + &buf_index_3aa_out, + p->buffer_ta[0].num_planes); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[3AA0 OUTPUT] _camerasrc_ioctl_dqbuf failed"); + return CAMERASRC_ERR_IO_CONTROL; + } + + camsrc_debug("[3AA0 - OUTPUT] DQBUF index %d", buf_index_3aa_out); + } else { + /* SENSOR set shot meta */ + _camerasrc_set_shot_meta(p, GRP_3AA, p->request_count, timestamp, shot_sensor); + + /* 3AA1 CAPTURE - QBUF */ + ret = _camerasrc_ioctl_qbuf(p, + p->fd_3aa1, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + buf_index_sensor, + &p->buffer_isp[buf_index_sensor]); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[3AA1 - CAPTURE] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_sensor, ret); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* 3AA1 OUTPUT - QBUF */ + ret = _camerasrc_ioctl_qbuf(p, + p->fd_3aa1, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + V4L2_MEMORY_DMABUF, + buf_index_sensor, + &p->buffer_sensor[buf_index_sensor]); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[3AA1 - OUTPUT] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_sensor, ret); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* 3AA1 CAPTURE - DQBUF */ + ret = _camerasrc_ioctl_dqbuf(p, + p->fd_3aa1, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + &buf_index_3aa_cap, + p->buffer_sensor[0].num_planes); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[3AA1 CAPTURE] _camerasrc_ioctl_dqbuf failed"); + return CAMERASRC_ERR_IO_CONTROL; + } + + camsrc_debug("[3AA1 - CAPTURE] DQBUF index %d", buf_index_3aa_cap); + + /* 3AA1 OUTPUT - DQBUF */ + ret = _camerasrc_ioctl_dqbuf(p, + p->fd_3aa1, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + V4L2_MEMORY_DMABUF, + &buf_index_3aa_out, + p->buffer_sensor[0].num_planes); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[3AA1 OUTPUT] _camerasrc_ioctl_dqbuf failed"); + return CAMERASRC_ERR_IO_CONTROL; + } + + camsrc_debug("[3AA1 - OUTPUT] DQBUF index %d", buf_index_3aa_out); + + /* SENSOR set shot meta */ + _camerasrc_set_shot_meta(p, GRP_SENSOR, 0, 0, shot_sensor); } - camsrc_debug("[3AA1 - CAPTURE] DQBUF index %d", buf_index_3aa1cap); + shot_isp = (struct camera2_shot_ext *)p->buffer_isp[buf_index_3aa_cap].planes[1].start; - /* 3AA1 OUTPUT - DQBUF */ - ret = _camerasrc_ioctl_dqbuf(p, - p->fd_3aa1, - V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, - V4L2_MEMORY_DMABUF, - &buf_index_3aa1out, - p->buffer_sensor[0].num_planes); + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) + _camerasrc_set_shot_meta2(p, GRP_ISP, p->frame_count, timestamp, shot_isp); + else + _camerasrc_set_shot_meta(p, GRP_ISP, p->request_count, timestamp, shot_isp); + + if (p->cur_dev_id != CAMERASRC_DEV_ID_PRIMARY || !p->first_frame) { + /* ISP - DQBUF */ + ret = _camerasrc_ioctl_dqbuf(p, + p->fd_isp, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + V4L2_MEMORY_DMABUF, + &buf_index_isp, + p->buffer_isp[0].num_planes); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[3AA1 OUTPUT] _camerasrc_ioctl_dqbuf failed"); + return CAMERASRC_ERR_IO_CONTROL; + } + + camsrc_debug("[ISP] DQBUF index %d", buf_index_isp); + } else { + camsrc_warning("primary camera first frame"); + } + + /* ISP - QBUF */ + ret = _camerasrc_ioctl_qbuf(p, + p->fd_isp, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + V4L2_MEMORY_DMABUF, + buf_index_3aa_cap, + &p->buffer_isp[buf_index_3aa_cap]); if (ret != CAMERASRC_SUCCESS) { - camsrc_error("[3AA1 OUTPUT] _camerasrc_ioctl_dqbuf failed"); + camsrc_error("[ISP] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_3aa_cap, ret); return CAMERASRC_ERR_IO_CONTROL; } - camsrc_debug("[3AA1 - OUTPUT] DQBUF index %d", buf_index_3aa1out); + camsrc_debug("[ISP] QBUF index %d", buf_index_3aa_cap); /* SENSOR set shot meta */ - _camerasrc_set_shot_meta(p, GRP_SENSOR, 0, 0, shot_sensor); + _camerasrc_set_shot_meta2(p, GRP_SENSOR, 0, 0, shot_sensor); /* SENSOR - QBUF */ ret = _camerasrc_ioctl_qbuf(p, - p->fd_sensor, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - buf_index_sensor, - &p->buffer_sensor[buf_index_sensor]); + p->fd_sensor, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + buf_index_sensor, + &p->buffer_sensor[buf_index_sensor]); if (ret != CAMERASRC_SUCCESS) { camsrc_error("[SENSOR] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_sensor, ret); return CAMERASRC_ERR_IO_CONTROL; } - shot_isp = (struct camera2_shot_ext *)p->buffer_isp[buf_index_sensor].planes[1].start; - _camerasrc_set_shot_meta(p, GRP_ISP, handle->request_count, timestamp, shot_isp); + camsrc_debug("[SENSOR] QBUF index %d", buf_index_sensor); - /* ISP - QBUF */ - ret = _camerasrc_ioctl_qbuf(p, - p->fd_isp, - V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, - V4L2_MEMORY_DMABUF, - buf_index_sensor, - &p->buffer_isp[buf_index_sensor]); - if (ret != CAMERASRC_SUCCESS) { - camsrc_error("[ISP] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_sensor, ret); - return CAMERASRC_ERR_IO_CONTROL; - } + //_camerasrc_wait_frame_available(p, 2000); - /* ISP - DQBUF */ - ret = _camerasrc_ioctl_dqbuf(p, - p->fd_isp, - V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, - V4L2_MEMORY_DMABUF, - &buf_index_isp, - p->buffer_isp[0].num_planes); - if (ret != CAMERASRC_SUCCESS) { - camsrc_error("[3AA1 OUTPUT] _camerasrc_ioctl_dqbuf failed"); - return CAMERASRC_ERR_IO_CONTROL; - } + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { + shot_3aa = (struct camera2_shot_ext *)p->buffer_ta[buf_index_3aa_out].planes[1].start; + + /* set 3AA0 meta */ + _camerasrc_set_shot_meta2(p, GRP_3AA, p->frame_count, 0, shot_3aa); + + /* 3AA0 OUTPUT - QBUF */ + ret = _camerasrc_ioctl_qbuf(p, + p->fd_3aa0, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + V4L2_MEMORY_DMABUF, + buf_index_3aa_out, + &p->buffer_ta[buf_index_3aa_out]); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[3AA0 - OUTPUT] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_3aa_cap, ret); + return CAMERASRC_ERR_IO_CONTROL; + } - camsrc_debug("[ISP] DQBUF index %d", buf_index_isp); + camsrc_debug("[3AA - OUTPUT] QBUF index %d", buf_index_3aa_out); - //_camerasrc_wait_frame_available(p, 2000); + /* 3AA0 CAPTURE - QBUF */ + ret = _camerasrc_ioctl_qbuf(p, + p->fd_3aa0, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + buf_index_3aa_cap, + &p->buffer_isp[buf_index_3aa_cap]); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[3AA0 - CAPTURE] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_3aa_cap, ret); + return CAMERASRC_ERR_IO_CONTROL; + } - /* SCC - DQBUF */ - ret = _camerasrc_ioctl_dqbuf(p, - p->fd_scc, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - &buf_index_scc, - p->buffer_scc[0].num_planes); - if (ret != CAMERASRC_SUCCESS) { - camsrc_error("[SCC] _camerasrc_ioctl_dqbuf failed"); - return CAMERASRC_ERR_IO_CONTROL; - } + camsrc_debug("[3AA - CAPTURE] QBUF index %d", buf_index_3aa_cap); + } else { + /* SCC - DQBUF */ + ret = _camerasrc_ioctl_dqbuf(p, + p->fd_scc, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + &buf_index_scc, + p->buffer_scc[0].num_planes); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[SCC] _camerasrc_ioctl_dqbuf failed"); + return CAMERASRC_ERR_IO_CONTROL; + } - shot_scc = (struct camera2_shot_ext *)p->buffer_scc[buf_index_scc].planes[1].start; - shot_scc->shot.dm.request.frameCount = handle->request_count; + shot_scc = (struct camera2_shot_ext *)p->buffer_scc[buf_index_scc].planes[1].start; + shot_scc->shot.dm.request.frameCount = p->request_count; - /* SCC - QBUF */ - ret = _camerasrc_ioctl_qbuf(p, - p->fd_scc, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - buf_index_scc, - &p->buffer_scc[buf_index_scc]); - if (ret != CAMERASRC_SUCCESS) { - camsrc_error("[SCC] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_scc, ret); - return CAMERASRC_ERR_IO_CONTROL; + /* SCC - QBUF */ + ret = _camerasrc_ioctl_qbuf(p, + p->fd_scc, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + buf_index_scc, + &p->buffer_scc[buf_index_scc]); + if (ret != CAMERASRC_SUCCESS) { + camsrc_error("[SCC] _camerasrc_ioctl_qbuf index %d, failed[%x]", buf_index_scc, ret); + return CAMERASRC_ERR_IO_CONTROL; + } + } + + if (p->first_frame) { + p->first_frame = 0; + camsrc_warning("DQ again..."); + goto _DQ_AGAIN; } /* SCP */ ret = _camerasrc_ioctl_dqbuf(p, - p->fd_scp, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - &buf_index_scp, - p->buffer_scp[0].num_planes); + p->fd_scp, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + &buf_index_scp, + p->buffer_scp[0].num_planes); if (ret != CAMERASRC_SUCCESS) { camsrc_error("[SCC] _camerasrc_ioctl_dqbuf failed"); return CAMERASRC_ERR_IO_CONTROL; } - camsrc_debug("SCP DQBUF index : %d", buf_index_scp); + + camsrc_debug("[SCP] DQBUF index : %d", buf_index_scp); memcpy(buffer, &p->buffer_scp[buf_index_scp], sizeof(camerasrc_buffer_t)); @@ -1549,13 +1819,110 @@ int camerasrc_get_num_buffer(camsrc_handle_t handle, unsigned int *num_buffer) } +static int _camerasrc_allocate_device_buffer(camsrc_handle_t handle, camerasrc_buffer_t **device_buffer, + camerasrc_format_t *device_format, int buffer_size[], int num_planes) +{ + int buffer_struct_size = 0; + int buffer_index = 0; + int plane_index = 0; + camerasrc_buffer_t *device_buffer_new = NULL; + + if (!handle || !device_buffer || !device_format) { + camsrc_error("NULL ptr %p %p %p", handle, device_buffer, device_format); + return CAMERASRC_ERR_INVALID_PARAMETER; + } + + camsrc_info("num buffers %d", device_format->num_buffers); + + buffer_struct_size = sizeof(camerasrc_buffer_t) * device_format->num_buffers; + + device_buffer_new = (camerasrc_buffer_t *)malloc(buffer_struct_size); + if (!device_buffer_new) { + camsrc_error("failed to alloc device buffer"); + return CAMERASRC_ERR_ALLOCATION; + } + + memset(device_buffer_new, 0x0, buffer_struct_size); + + for (buffer_index = 0 ; buffer_index < device_format->num_buffers ; buffer_index++) { + device_buffer_new[buffer_index].num_planes = num_planes; + for (plane_index = 0 ; plane_index < num_planes ; plane_index++) { + if (!camerasrc_tbm_alloc_buffer(handle, buffer_size[plane_index], + &(device_buffer_new[buffer_index].planes[plane_index].bo), + &(device_buffer_new[buffer_index].planes[plane_index].fd), + &(device_buffer_new[buffer_index].planes[plane_index].start))) { + camsrc_error("camerasrc_tbm_alloc_buffer failed[%d:%d] : size %d", + buffer_index, plane_index, buffer_size[plane_index]); + goto _ALLOC_FAILED; + } + + device_buffer_new[buffer_index].planes[plane_index].length = buffer_size[plane_index]; + + camsrc_info("buffer [%d][%d] BUF: bo[%p] fd[%d] addr[%p] size[%d]", + buffer_index, plane_index, + device_buffer_new[buffer_index].planes[plane_index].bo, + device_buffer_new[buffer_index].planes[plane_index].fd, + device_buffer_new[buffer_index].planes[plane_index].start, + device_buffer_new[buffer_index].planes[plane_index].length); + } + } + + *device_buffer = device_buffer_new; + + camsrc_info("done - %p", *device_buffer); + + return CAMERASRC_SUCCESS; + +_ALLOC_FAILED: + _camerasrc_release_device_buffer(device_buffer_new, device_format->num_buffers); + device_buffer_new = NULL; + + return CAMERASRC_ERR_ALLOCATION; +} + + +static void _camerasrc_release_device_buffer(camerasrc_buffer_t *device_buffer, int num_buffers) +{ + int buffer_index = 0; + int plane_index = 0; + + if (!device_buffer) { + camsrc_warning("NULL device buffer"); + return; + } + + camsrc_warning("num buffers : %d", num_buffers); + + for (buffer_index = 0 ; buffer_index < num_buffers ; buffer_index++) { + for (plane_index = 0 ; plane_index < MAX_PLANE_NUM ; plane_index++) { + if (device_buffer[buffer_index].planes[plane_index].bo) { + camsrc_info("[device buffer %p] release buffer[%d:%d] unref bo %p", + device_buffer, buffer_index, plane_index, device_buffer[buffer_index].planes[plane_index].bo); + + tbm_bo_unref(device_buffer[buffer_index].planes[plane_index].bo); + + device_buffer[buffer_index].planes[plane_index].bo = NULL; + device_buffer[buffer_index].planes[plane_index].fd = 0; + device_buffer[buffer_index].planes[plane_index].start = NULL; + device_buffer[buffer_index].planes[plane_index].length = 0; + } else { + camsrc_info("[device buffer %p] skip release buffer[%d] plane[%d]", + device_buffer, buffer_index, plane_index); + } + } + } + + free(device_buffer); + device_buffer = NULL; + + return; +} + + int camerasrc_create_buffer(camsrc_handle_t handle) { camerasrc_handle_t *p = NULL; - int ret = CAMERASRC_SUCCESS; - int count = 0; - int plane_index = 0; - int plane_num = 0; + int num_planes = 0; int buffer_size[MAX_PLANE_NUM] = {0,}; int preview_width = 0; int preview_height = 0; @@ -1573,213 +1940,157 @@ int camerasrc_create_buffer(camsrc_handle_t handle) p = CAMERASRC_HANDLE(handle); - if (p->buffer_sensor || p->buffer_isp || p->buffer_scc || p->buffer_scp) { + if (p->buffer_sensor || p->buffer_ta || p->buffer_isp || p->buffer_scc || p->buffer_scp) { + camsrc_warning("release remained buffer"); camerasrc_destroy_buffer(handle); } preview_width = p->format_scp.img_size.width; preview_height = p->format_scp.img_size.height; - memset(&p->format_sensor, 0x0, sizeof(camerasrc_format_t)); - memset(&p->format_isp, 0x0, sizeof(camerasrc_format_t)); - memset(&p->format_scc, 0x0, sizeof(camerasrc_format_t)); - - p->format_sensor.num_buffers = p->format_scp.num_buffers - 6; p->format_3aa1.num_buffers = p->format_scp.num_buffers - 6; - p->format_isp.num_buffers = p->format_scp.num_buffers - 6; - p->format_scc.num_buffers = p->format_scp.num_buffers - 6; - - /* set sensor resolution */ - sensor_width = FRONT_SENSOR_SIZE_WIDTH + SENSOR_MARGIN_WIDTH; - sensor_height = FRONT_SENSOR_SIZE_HEIGHT + SENSOR_MARGIN_HEIGHT; /** * buffer allocation */ - /* sensor */ - p->buffer_sensor = (camerasrc_buffer_t *)malloc(sizeof(camerasrc_buffer_t) * p->format_sensor.num_buffers); - if (p->buffer_sensor == NULL) { - camsrc_error("failed to buffer_sensor"); - return CAMERASRC_ERR_ALLOCATION; - } + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { + /* SENSOR */ + camsrc_warning("buffer_sensor allocation"); - memset(p->buffer_sensor, 0x0, sizeof(camerasrc_buffer_t) * p->format_sensor.num_buffers); + buffer_size[0] = 25584000; /* for 5328x3000 */ + buffer_size[1] = META_PLANE_SIZE; + buffer_size[2] = 0; + buffer_size[3] = 0; - aligned_width = ((sensor_width + 9) / 10) * 10; - bytes_per_line = (aligned_width * 8) / 5; + p->format_sensor.num_buffers = 5; - buffer_size[0] = bytes_per_line * sensor_height; - buffer_size[1] = SPARE_SIZE; - buffer_size[2] = 0; - buffer_size[3] = 0; + if (_camerasrc_allocate_device_buffer(handle, &p->buffer_sensor, &p->format_sensor, buffer_size, 2) != CAMERASRC_SUCCESS) { + camsrc_error("alloc buffer_sensor failed"); + goto CREATE_BUFFER_FAILED; + } - for (count = 0 ; count < p->format_sensor.num_buffers ; count++) { - p->buffer_sensor[count].num_planes = BAYER_PLANE_COUNT; - for (plane_index = 0 ; plane_index < MAX_PLANE_NUM ; plane_index++) { - if (buffer_size[plane_index] > 0) { - ret = camerasrc_tbm_alloc_buffer(handle, buffer_size[plane_index], - &(p->buffer_sensor[count].planes[plane_index].bo), - &(p->buffer_sensor[count].planes[plane_index].fd), - &(p->buffer_sensor[count].planes[plane_index].start)); - if (ret == FALSE) { - camsrc_error("[sensor] camerasrc_tbm_alloc_buffer failed[%d:%d] : size %d", - count, plane_index, buffer_size[plane_index]); - goto CREATE_BUFFER_FAILED; - } + /* TA */ + camsrc_warning("buffer_ta allocation"); - p->buffer_sensor[count].planes[plane_index].length = buffer_size[plane_index]; + buffer_size[0] = 4096; //(64 + 9) / 10 * 16 * 32;; + buffer_size[1] = META_PLANE_SIZE; + buffer_size[2] = 0; + buffer_size[3] = 0; - camsrc_info("sensor [%d][%d] BUF: bo[%p] fd[%d] addr[%p] size[%d]", - count, plane_index, - p->buffer_sensor[count].planes[plane_index].bo, - p->buffer_sensor[count].planes[plane_index].fd, - p->buffer_sensor[count].planes[plane_index].start, - p->buffer_sensor[count].planes[plane_index].length); - } - } - } + p->format_ta.num_buffers = 5; - /* ISP */ - p->buffer_isp = (camerasrc_buffer_t *)malloc(sizeof(camerasrc_buffer_t) * p->format_isp.num_buffers); - if (p->buffer_isp == NULL) { - camsrc_error("failed to buffer_isp"); - goto CREATE_BUFFER_FAILED; - } + if (_camerasrc_allocate_device_buffer(handle, &p->buffer_ta, &p->format_ta, buffer_size, 2) != CAMERASRC_SUCCESS) { + camsrc_error("alloc buffer_ta failed"); + goto CREATE_BUFFER_FAILED; + } - memset(p->buffer_isp, 0x0, sizeof(camerasrc_buffer_t) * p->format_isp.num_buffers); + /* ISP */ + camsrc_warning("buffer_isp allocation"); - for (count = 0 ; count < p->format_isp.num_buffers ; count++) { - p->buffer_isp[count].num_planes = ISP_PLANE_COUNT; - for (plane_index = 0 ; plane_index < MAX_PLANE_NUM ; plane_index++) { - if (buffer_size[plane_index] > 0) { - ret = camerasrc_tbm_alloc_buffer(handle, buffer_size[plane_index], - &(p->buffer_isp[count].planes[plane_index].bo), - &(p->buffer_isp[count].planes[plane_index].fd), - &(p->buffer_isp[count].planes[plane_index].start)); - if (ret == FALSE) { - camsrc_error("[isp] camerasrc_tbm_alloc_buffer failed[%d:%d] : size %d", - count, plane_index, buffer_size[plane_index]); - goto CREATE_BUFFER_FAILED; - } + buffer_size[0] = 6010368; + buffer_size[1] = META_PLANE_SIZE; + buffer_size[2] = 0; + buffer_size[3] = 0; - p->buffer_isp[count].planes[plane_index].length = buffer_size[plane_index]; + p->format_isp.num_buffers = 5; - camsrc_info("isp [%d][%d] BUF: bo[%p] fd[%d] addr[%p] size[%d]", - count, plane_index, - p->buffer_isp[count].planes[plane_index].bo, - p->buffer_isp[count].planes[plane_index].fd, - p->buffer_isp[count].planes[plane_index].start, - p->buffer_isp[count].planes[plane_index].length); - } + if (_camerasrc_allocate_device_buffer(handle, &p->buffer_isp, &p->format_isp, buffer_size, 2) != CAMERASRC_SUCCESS) { + camsrc_error("alloc buffer_isp failed"); + goto CREATE_BUFFER_FAILED; } - } - /* SCC */ - p->buffer_scc = (camerasrc_buffer_t *)malloc(sizeof(camerasrc_buffer_t) * p->format_scc.num_buffers); - if (p->buffer_scc == NULL) { - camsrc_error("failed to buffer_scc"); - goto CREATE_BUFFER_FAILED; - } + /* SCP */ + camsrc_warning("buffer_scp allocation"); + + buffer_size[0] = preview_width * preview_height;//2089216; + buffer_size[1] = buffer_size[0] >> 1;//1044736; + buffer_size[2] = META_PLANE_SIZE; + buffer_size[3] = 0; - memset(p->buffer_scc, 0x0, sizeof(camerasrc_buffer_t) * p->format_scc.num_buffers); + if (_camerasrc_allocate_device_buffer(handle, &p->buffer_scp, &p->format_scp, buffer_size, 3) != CAMERASRC_SUCCESS) { + camsrc_error("alloc buffer_scp failed"); + goto CREATE_BUFFER_FAILED; + } + } else { + /* set sensor resolution */ + sensor_width = FRONT_SENSOR_SIZE_WIDTH + SENSOR_MARGIN_WIDTH; + sensor_height = FRONT_SENSOR_SIZE_HEIGHT + SENSOR_MARGIN_HEIGHT; - for (count = 0 ; count < p->format_scc.num_buffers ; count++) { - p->buffer_scc[count].num_planes = SCC_PLANE_COUNT; - for (plane_index = 0 ; plane_index < MAX_PLANE_NUM ; plane_index++) { - if (buffer_size[plane_index] > 0) { - ret = camerasrc_tbm_alloc_buffer(handle, buffer_size[plane_index], - &(p->buffer_scc[count].planes[plane_index].bo), - &(p->buffer_scc[count].planes[plane_index].fd), - &(p->buffer_scc[count].planes[plane_index].start)); - if (ret == FALSE) { - camsrc_error("[scc] camerasrc_tbm_alloc_buffer failed[%d:%d] : size %d", - count, plane_index, buffer_size[plane_index]); - goto CREATE_BUFFER_FAILED; - } + /* sensor */ + aligned_width = ((sensor_width + 9) / 10) * 10; + bytes_per_line = (aligned_width * 8) / 5; - p->buffer_scc[count].planes[plane_index].length = buffer_size[plane_index]; + buffer_size[0] = bytes_per_line * sensor_height; + buffer_size[1] = SPARE_SIZE; + buffer_size[2] = 0; + buffer_size[3] = 0; - camsrc_info("scc [%d][%d] BUF: bo[%p] fd[%d] addr[%p] size[%d]", - count, plane_index, - p->buffer_scc[count].planes[plane_index].bo, - p->buffer_scc[count].planes[plane_index].fd, - p->buffer_scc[count].planes[plane_index].start, - p->buffer_scc[count].planes[plane_index].length); - } + p->format_sensor.num_buffers = p->format_scp.num_buffers - 6; + + if (_camerasrc_allocate_device_buffer(handle, &p->buffer_sensor, &p->format_sensor, buffer_size, 2) != CAMERASRC_SUCCESS) { + camsrc_error("alloc buffer_sensor failed"); + goto CREATE_BUFFER_FAILED; } - } - /* SCP */ - p->buffer_scp = (camerasrc_buffer_t *)malloc(sizeof(camerasrc_buffer_t) * p->format_scp.num_buffers); - if (p->buffer_scp == NULL) { - camsrc_error("failed to buffer_scp"); - goto CREATE_BUFFER_FAILED; - } + /* ISP */ + p->format_isp.num_buffers = p->format_scp.num_buffers - 6; - memset(p->buffer_scp, 0x0, sizeof(camerasrc_buffer_t) * p->format_scp.num_buffers); + if (_camerasrc_allocate_device_buffer(handle, &p->buffer_isp, &p->format_isp, buffer_size, 2) != CAMERASRC_SUCCESS) { + camsrc_error("alloc buffer_isp failed"); + goto CREATE_BUFFER_FAILED; + } - switch (p->format_scp.pix_format) { - case CAMERASRC_PIX_YUY2: - buffer_size[0] = buf_4k_align((preview_width * preview_height) << 1); - buffer_size[1] = buf_4k_align(SPARE_SIZE); - buffer_size[2] = 0; - buffer_size[3] = 0; - plane_num = 2; - break; - case CAMERASRC_PIX_YUV420P: - buffer_size[0] = buf_4k_align(preview_width * preview_height); - buffer_size[1] = buf_4k_align((preview_width * preview_height) >> 2); - buffer_size[2] = buffer_size[1]; - buffer_size[3] = buf_4k_align(SPARE_SIZE); - plane_num = 4; - break; - case CAMERASRC_PIX_NV12: - buffer_size[0] = buf_4k_align((preview_width * preview_height * 3) >> 1); - buffer_size[1] = buf_4k_align(SPARE_SIZE); - buffer_size[2] = 0; - buffer_size[3] = 0; - plane_num = 2; - break; - case CAMERASRC_PIX_SN12: - buffer_size[0] = buf_4k_align(preview_width * preview_height); - buffer_size[1] = buf_4k_align((preview_width * preview_height) >> 1); - buffer_size[2] = buf_4k_align(SPARE_SIZE); - buffer_size[3] = 0; - plane_num = 3; - break; - default: - camsrc_warning("invalid output format = %d, set size as NV12M(SN12)", p->format_scp.pix_format); - buffer_size[0] = buf_4k_align(preview_width * preview_height); - buffer_size[1] = buf_4k_align((preview_width * preview_height) >> 1); - buffer_size[2] = buf_4k_align(SPARE_SIZE); - buffer_size[3] = 0; - plane_num = 3; - break; - } + /* SCC */ + p->format_scc.num_buffers = p->format_scp.num_buffers - 6; - for (count = 0 ; count < p->format_scp.num_buffers ; count++) { - p->buffer_scp[count].num_planes = plane_num; - for (plane_index = 0 ; plane_index < MAX_PLANE_NUM ; plane_index++) { - if (buffer_size[plane_index] > 0) { - ret = camerasrc_tbm_alloc_buffer(handle, buffer_size[plane_index], - &(p->buffer_scp[count].planes[plane_index].bo), - &(p->buffer_scp[count].planes[plane_index].fd), - &(p->buffer_scp[count].planes[plane_index].start)); - if (ret == FALSE) { - camsrc_error("[scp] camerasrc_tbm_alloc_buffer failed[%d:%d] : size %d", - count, plane_index, buffer_size[plane_index]); - goto CREATE_BUFFER_FAILED; - } + if (_camerasrc_allocate_device_buffer(handle, &p->buffer_scc, &p->format_scc, buffer_size, 2) != CAMERASRC_SUCCESS) { + camsrc_error("alloc buffer_scc failed"); + goto CREATE_BUFFER_FAILED; + } - p->buffer_scp[count].planes[plane_index].length = buffer_size[plane_index]; + /* SCP */ + switch (p->format_scp.pix_format) { + case CAMERASRC_PIX_YUY2: + buffer_size[0] = buf_4k_align((preview_width * preview_height) << 1); + buffer_size[1] = buf_4k_align(SPARE_SIZE); + buffer_size[2] = 0; + buffer_size[3] = 0; + num_planes = 2; + break; + case CAMERASRC_PIX_YUV420P: + buffer_size[0] = buf_4k_align(preview_width * preview_height); + buffer_size[1] = buf_4k_align((preview_width * preview_height) >> 2); + buffer_size[2] = buffer_size[1]; + buffer_size[3] = buf_4k_align(SPARE_SIZE); + num_planes = 4; + break; + case CAMERASRC_PIX_NV12: + buffer_size[0] = buf_4k_align((preview_width * preview_height * 3) >> 1); + buffer_size[1] = buf_4k_align(SPARE_SIZE); + buffer_size[2] = 0; + buffer_size[3] = 0; + num_planes = 2; + break; + case CAMERASRC_PIX_SN12: + buffer_size[0] = buf_4k_align(preview_width * preview_height); + buffer_size[1] = buf_4k_align((preview_width * preview_height) >> 1); + buffer_size[2] = buf_4k_align(SPARE_SIZE); + buffer_size[3] = 0; + num_planes = 3; + break; + default: + camsrc_warning("invalid output format = %d, set size as NV12M(SN12)", p->format_scp.pix_format); + buffer_size[0] = buf_4k_align(preview_width * preview_height); + buffer_size[1] = buf_4k_align((preview_width * preview_height) >> 1); + buffer_size[2] = buf_4k_align(SPARE_SIZE); + buffer_size[3] = 0; + num_planes = 3; + break; + } - camsrc_info("scp [%d][%d] BUF: bo[%p] fd[%d] addr[%p] size[%d]", - count, plane_index, - p->buffer_scp[count].planes[plane_index].bo, - p->buffer_scp[count].planes[plane_index].fd, - p->buffer_scp[count].planes[plane_index].start, - p->buffer_scp[count].planes[plane_index].length); - } + if (_camerasrc_allocate_device_buffer(handle, &p->buffer_scp, &p->format_scp, buffer_size, num_planes) != CAMERASRC_SUCCESS) { + camsrc_error("alloc buffer_scp failed"); + goto CREATE_BUFFER_FAILED; } } @@ -1795,8 +2106,6 @@ CREATE_BUFFER_FAILED: int camerasrc_destroy_buffer(camsrc_handle_t handle) { camerasrc_handle_t *p = NULL; - int count = 0; - int plane_index = 0; camsrc_info("enter"); @@ -1808,96 +2117,29 @@ int camerasrc_destroy_buffer(camsrc_handle_t handle) p = CAMERASRC_HANDLE(handle); /* buffer - sensor */ - if (p->buffer_sensor) { - for (count = 0 ; count < p->format_sensor.num_buffers ; count++) { - for (plane_index = 0 ; plane_index < MAX_PLANE_NUM ; plane_index++) { - if (p->buffer_sensor[count].planes[plane_index].bo) { - camsrc_info("[sensor] unref bo %p", p->buffer_sensor[count].planes[plane_index].bo); - tbm_bo_unref(p->buffer_sensor[count].planes[plane_index].bo); - p->buffer_sensor[count].planes[plane_index].bo = NULL; - p->buffer_sensor[count].planes[plane_index].fd = 0; - p->buffer_sensor[count].planes[plane_index].start = NULL; - p->buffer_sensor[count].planes[plane_index].length = 0; - } else { - camsrc_info("[sensor] skip release buffer[%d] plane[%d]", count, plane_index); - } - } - } + camsrc_warning("sensor"); + _camerasrc_release_device_buffer(p->buffer_sensor, p->format_sensor.num_buffers); + p->buffer_sensor = NULL; - free(p->buffer_sensor); - p->buffer_sensor = NULL; - } else { - camsrc_warning("buffer_sensor is already NULL"); - } + /* buffer - ta */ + camsrc_warning("ta"); + _camerasrc_release_device_buffer(p->buffer_ta, p->format_ta.num_buffers); + p->buffer_ta = NULL; /* buffer - isp */ - if (p->buffer_isp) { - for (count = 0 ; count < p->format_isp.num_buffers ; count++) { - for (plane_index = 0 ; plane_index < MAX_PLANE_NUM ; plane_index++) { - if (p->buffer_isp[count].planes[plane_index].bo) { - camsrc_info("[isp] unref bo %p", p->buffer_isp[count].planes[plane_index].bo); - tbm_bo_unref(p->buffer_isp[count].planes[plane_index].bo); - p->buffer_isp[count].planes[plane_index].bo = NULL; - p->buffer_isp[count].planes[plane_index].fd = 0; - p->buffer_isp[count].planes[plane_index].start = NULL; - p->buffer_isp[count].planes[plane_index].length = 0; - } else { - camsrc_info("[isp] skip release buffer[%d] plane[%d]", count, plane_index); - } - } - } - - free(p->buffer_isp); - p->buffer_isp = NULL; - } else { - camsrc_warning("buffer_isp is already NULL"); - } + camsrc_warning("isp"); + _camerasrc_release_device_buffer(p->buffer_isp, p->format_isp.num_buffers); + p->buffer_isp = NULL; /* buffer - scc */ - if (p->buffer_scc) { - for (count = 0 ; count < p->format_scc.num_buffers ; count++) { - for (plane_index = 0 ; plane_index < MAX_PLANE_NUM ; plane_index++) { - if (p->buffer_scc[count].planes[plane_index].bo) { - camsrc_info("[scc] unref bo %p", p->buffer_scc[count].planes[plane_index].bo); - tbm_bo_unref(p->buffer_scc[count].planes[plane_index].bo); - p->buffer_scc[count].planes[plane_index].bo = NULL; - p->buffer_scc[count].planes[plane_index].fd = 0; - p->buffer_scc[count].planes[plane_index].start = NULL; - p->buffer_scc[count].planes[plane_index].length = 0; - } else { - camsrc_info("[scc] skip release buffer[%d] plane[%d]", count, plane_index); - } - } - } - - free(p->buffer_scc); - p->buffer_scc = NULL; - } else { - camsrc_warning("buffer_scc is already NULL"); - } + camsrc_warning("scc"); + _camerasrc_release_device_buffer(p->buffer_scc, p->format_scc.num_buffers); + p->buffer_scc = NULL; /* buffer - scp */ - if (p->buffer_scp) { - for (count = 0 ; count < p->format_scp.num_buffers ; count++) { - for (plane_index = 0 ; plane_index < MAX_PLANE_NUM ; plane_index++) { - if (p->buffer_scp[count].planes[plane_index].bo) { - camsrc_info("[scp] unref bo %p", p->buffer_scp[count].planes[plane_index].bo); - tbm_bo_unref(p->buffer_scp[count].planes[plane_index].bo); - p->buffer_scp[count].planes[plane_index].bo = NULL; - p->buffer_scp[count].planes[plane_index].fd = 0; - p->buffer_scp[count].planes[plane_index].start = NULL; - p->buffer_scp[count].planes[plane_index].length = 0; - } else { - camsrc_info("[scp] skip release buffer[%d] plane[%d]", count, plane_index); - } - } - } - - free(p->buffer_scp); - p->buffer_scp = NULL; - } else { - camsrc_warning("buffer_scp is already NULL"); - } + camsrc_warning("scp"); + _camerasrc_release_device_buffer(p->buffer_scp, p->format_scp.num_buffers); + p->buffer_scp = NULL; camsrc_info("done"); @@ -1909,6 +2151,8 @@ int camerasrc_start_preview_stream(camsrc_handle_t handle) { camerasrc_handle_t *p = NULL; int i = 0; + int type = 0; + int input = 0; int err = CAMERASRC_ERR_UNKNOWN; char err_msg[CAMERASRC_ERRMSG_MAX_LEN] = {'\0',}; @@ -1930,12 +2174,6 @@ int camerasrc_start_preview_stream(camsrc_handle_t handle) camsrc_warning("Invalid state transition"); } - /* check buffer */ - if (p->buffer_sensor == NULL || p->buffer_isp == NULL || p->buffer_scc == NULL || p->buffer_scp == NULL) { - camsrc_error("buffer is NULL %p %p %p %p", p->buffer_sensor, p->buffer_isp, p->buffer_scc, p->buffer_scp); - return CAMERASRC_ERR_INVALID_STATE; - } - /* P R E V I E W F O R M A T S E T T I N G */ if (!(p->format_scp.pix_format == CAMERASRC_PIX_YUV422P || p->format_scp.pix_format == CAMERASRC_PIX_YUV420P || p->format_scp.pix_format == CAMERASRC_PIX_YV12 || @@ -1958,11 +2196,182 @@ int camerasrc_start_preview_stream(camsrc_handle_t handle) } if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { - /* TODO */ - } else { - int type = 0; - int input = 0; + /* FPS */ + err = _camerasrc_ioctl_s_parm(p, p->fd_sensor, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, 1, 30); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("_camerasrc_ioctl_s_parm failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* sensor format */ + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + p->format_sensor.pix_format = CAMERASRC_PIX_SBGGR12; + + err = _camerasrc_ioctl_s_fmt(p, p->fd_sensor, type, &p->format_sensor); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[SENSOR] _camerasrc_ioctl_s_fmt failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* sensor reqbufs */ + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + err = _camerasrc_ioctl_reqbufs(p, p->fd_sensor, p->format_sensor.num_buffers, + type, V4L2_MEMORY_DMABUF, &p->format_sensor.num_buffers); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[SENSOR] _camerasrc_ioctl_reqbufs failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->reqbuf_sensor = TRUE; + + /* sensor s_ctrl */ + err = _camerasrc_ioctl_s_ctrl(p, p->fd_sensor, 0x9a1034, 2000); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[SENSOR] S_CTRL 0x9a1034 -> 2000 failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* ISP format */ + type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + p->format_isp.pix_format = CAMERASRC_PIX_SBGGR12; + + err = _camerasrc_ioctl_s_fmt(p, p->fd_isp, type, &p->format_isp); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[ISP] _camerasrc_ioctl_s_fmt failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* ISP reqbufs */ + type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + err = _camerasrc_ioctl_reqbufs(p, p->fd_isp, p->format_isp.num_buffers, + type, V4L2_MEMORY_DMABUF, &p->format_isp.num_buffers); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[ISP] _camerasrc_ioctl_reqbufs failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->reqbuf_isp = TRUE; + + /* 3AA0_OUTPUT format */ + type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + p->format_3aa0.img_size.width = 32; + p->format_3aa0.img_size.height = 64; + p->format_3aa0.pix_format = CAMERASRC_PIX_SBGGR12; + + err = _camerasrc_ioctl_s_fmt(p, p->fd_3aa0, type, &p->format_3aa0); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0_OUTPUT] _camerasrc_ioctl_s_fmt failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* 3AA0_OUTPUT reqbufs */ + p->format_3aa0.num_buffers = 5; + type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; + err = _camerasrc_ioctl_reqbufs(p, p->fd_3aa0, p->format_3aa0.num_buffers, + type, V4L2_MEMORY_DMABUF, &p->format_3aa0.num_buffers); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0_OUTPUT] _camerasrc_ioctl_reqbufs failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->reqbuf_3aa0_output = TRUE; + + /* 3AA0_CAPTURE format */ + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + p->format_3aa0.img_size.width = p->format_isp.img_size.width; + p->format_3aa0.img_size.height = p->format_isp.img_size.height; + p->format_3aa0.pix_format = CAMERASRC_PIX_SBGGR12; + + err = _camerasrc_ioctl_s_fmt(p, p->fd_3aa0, type, &p->format_3aa0); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0_CAPTURE] _camerasrc_ioctl_s_fmt failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* 3AA0_CAPTURE reqbufs */ + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + err = _camerasrc_ioctl_reqbufs(p, p->fd_3aa0, p->format_3aa0.num_buffers, + type, V4L2_MEMORY_DMABUF, &p->format_3aa0.num_buffers); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0_CAPTURE] _camerasrc_ioctl_reqbufs failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->reqbuf_3aa0_capture = TRUE; + /* ISP s_ctrl */ + err = _camerasrc_ioctl_s_ctrl(p, p->fd_isp, 0x9a1033, 0); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[ISP] S_CTRL 0x9a1033 -> 0 failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* 3AA0C format */ + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + p->format_3aa0c.img_size.width = PRIMARY_SENSOR_WIDTH_1; /* capture size should be set */ + p->format_3aa0c.img_size.height = PRIMARY_SENSOR_HEIGHT; + p->format_3aa0c.pix_format = CAMERASRC_PIX_SBGGR12; + + err = _camerasrc_ioctl_s_fmt(p, p->fd_3aa0c, type, &p->format_3aa0c); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0C] _camerasrc_ioctl_s_fmt failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* 3AA0C reqbufs */ + p->format_3aa0c.num_buffers = 5; + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + err = _camerasrc_ioctl_reqbufs(p, p->fd_3aa0c, p->format_3aa0c.num_buffers, + type, V4L2_MEMORY_DMABUF, &p->format_3aa0c.num_buffers); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0C] _camerasrc_ioctl_reqbufs failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->reqbuf_3aa0c_capture = TRUE; + + /* SCP format */ + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + p->format_scp.pix_format = CAMERASRC_PIX_SN21; + + err = _camerasrc_ioctl_s_fmt(p, p->fd_scp, type, &p->format_scp); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[SCP] _camerasrc_ioctl_s_fmt failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* SCP reqbufs */ + type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; + err = _camerasrc_ioctl_reqbufs(p, p->fd_scp, p->format_scp.num_buffers, + type, V4L2_MEMORY_DMABUF, &p->format_scp.num_buffers); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[SCP] _camerasrc_ioctl_reqbufs failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + /* ISP s_ctrl */ + err = _camerasrc_ioctl_s_ctrl(p, p->fd_isp, 0x9a1036, 0); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[ISP] S_CTRL 0x9a1036 -> 0 failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + } else { /* sensor */ err = _camerasrc_ioctl_s_ctrl(p, p->fd_sensor, V4L2_CID_IS_MIN_TARGET_FPS, 15); if (err != CAMERASRC_SUCCESS) { @@ -2180,50 +2589,59 @@ int camerasrc_start_preview_stream(camsrc_handle_t handle) } /* QBUF */ - if (p->buffer_sensor) { - err = _camerasrc_set_shot_meta(p, GRP_SENSOR, 0, 0, (struct camera2_shot_ext *)p->buffer_sensor[0].planes[1].start); - if (err != CAMERASRC_SUCCESS) { - camsrc_error("[SENSOR] _camerasrc_set_shot_meta index %d, failed[%x]", i, err); - return err; - } + if (p->buffer_scp) { + for (i = 0 ; i < p->format_scp.num_buffers ; i++) { + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { + err = _camerasrc_set_shot_meta2(p, GRP_SCP, i, 0, (struct camera2_shot_ext *)p->buffer_scp[i].planes[2].start); + } else { + err = _camerasrc_set_shot_meta(p, GRP_SCP, i, 0, (struct camera2_shot_ext *)p->buffer_scp[i].planes[2].start); + } + if (err != CAMERASRC_SUCCESS) { + camsrc_error("[SCP] _camerasrc_set_shot_meta index %d, failed[%x]", i, err); + return err; + } - for (i = 0 ; i < p->format_sensor.num_buffers ; i++) { err = _camerasrc_ioctl_qbuf(p, - p->fd_sensor, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - i, - &p->buffer_sensor[i]); + p->fd_scp, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + i, + &p->buffer_scp[i]); if (err != CAMERASRC_SUCCESS) { - camsrc_error("[SENSOR] _camerasrc_ioctl_qbuf index %d, failed[%x]", i, err); + camsrc_error("[SCP] _camerasrc_ioctl_qbuf index %d, failed[%x]", i, err); return CAMERASRC_ERR_IO_CONTROL; } } - camsrc_info("[SENSOR] QBUF done - %d", p->format_sensor.num_buffers); + camsrc_info("[SCP] QBUF done - %d", p->format_scp.num_buffers); } - if (p->buffer_scp) { - for (i = 0 ; i < p->format_scp.num_buffers ; i++) { - err = _camerasrc_set_shot_meta(p, GRP_SCP, i, 0, (struct camera2_shot_ext *)p->buffer_scp[i].planes[2].start); - if (err != CAMERASRC_SUCCESS) { - camsrc_error("[SCP] _camerasrc_set_shot_meta index %d, failed[%x]", i, err); - return err; - } + if (p->buffer_sensor) { + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { + err = _camerasrc_set_shot_meta2(p, GRP_SENSOR, 0, 0, (struct camera2_shot_ext *)p->buffer_sensor[0].planes[1].start); + } else { + err = _camerasrc_set_shot_meta(p, GRP_SENSOR, 0, 0, (struct camera2_shot_ext *)p->buffer_sensor[0].planes[1].start); + } + if (err != CAMERASRC_SUCCESS) { + camsrc_error("[SENSOR] _camerasrc_set_shot_meta index %d, failed[%x]", i, err); + return err; + } + + for (i = 0 ; i < p->format_sensor.num_buffers ; i++) { err = _camerasrc_ioctl_qbuf(p, - p->fd_scp, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - i, - &p->buffer_scp[i]); + p->fd_sensor, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + i, + &p->buffer_sensor[i]); if (err != CAMERASRC_SUCCESS) { - camsrc_error("[SCP] _camerasrc_ioctl_qbuf index %d, failed[%x]", i, err); + camsrc_error("[SENSOR] _camerasrc_ioctl_qbuf index %d, failed[%x]", i, err); return CAMERASRC_ERR_IO_CONTROL; } } - camsrc_info("[SCP] QBUF done - %d", p->format_scp.num_buffers); + camsrc_info("[SENSOR] QBUF done - %d", p->format_sensor.num_buffers); } /* STREAM ON */ @@ -2238,38 +2656,40 @@ int camerasrc_start_preview_stream(camsrc_handle_t handle) camsrc_info("[SENSOR] STREAMON done"); - err = _camerasrc_ioctl_stream(p, p->fd_3aa1, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, TRUE); - if (err != CAMERASRC_SUCCESS) { - strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); - camsrc_error("[3AA1 - CAPTURE] _camerasrc_ioctl_stream failed[%x] : %s", err, err_msg); - return CAMERASRC_ERR_IO_CONTROL; - } + if (p->cur_dev_id == CAMERASRC_DEV_ID_SECONDARY) { + err = _camerasrc_ioctl_stream(p, p->fd_3aa1, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, TRUE); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA1 - CAPTURE] _camerasrc_ioctl_stream failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } - p->streamon_3aa1_capture = TRUE; + p->streamon_3aa1_capture = TRUE; - camsrc_info("[3AA1 - CAPTURE] STREAMON done"); + camsrc_info("[3AA1 - CAPTURE] STREAMON done"); - err = _camerasrc_ioctl_stream(p, p->fd_3aa1, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, TRUE); - if (err != CAMERASRC_SUCCESS) { - strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); - camsrc_error("[3AA1 - OUTPUT] _camerasrc_ioctl_stream failed[%x] : %s", err, err_msg); - return CAMERASRC_ERR_IO_CONTROL; - } + err = _camerasrc_ioctl_stream(p, p->fd_3aa1, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, TRUE); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA1 - OUTPUT] _camerasrc_ioctl_stream failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } - p->streamon_3aa1_output = TRUE; + p->streamon_3aa1_output = TRUE; - camsrc_info("[3AA1 - OUTPUT] STREAMON done"); + camsrc_info("[3AA1 - OUTPUT] STREAMON done"); - err = _camerasrc_ioctl_stream(p, p->fd_scc, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, TRUE); - if (err != CAMERASRC_SUCCESS) { - strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); - camsrc_error("[SCC] _camerasrc_ioctl_stream failed[%x] : %s", err, err_msg); - return CAMERASRC_ERR_IO_CONTROL; - } + err = _camerasrc_ioctl_stream(p, p->fd_scc, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, TRUE); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[SCC] _camerasrc_ioctl_stream failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } - p->streamon_scc = TRUE; + p->streamon_scc = TRUE; - camsrc_info("[SCC] STREAMON done"); + camsrc_info("[SCC] STREAMON done"); + } err = _camerasrc_ioctl_stream(p, p->fd_scp, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, TRUE); if (err != CAMERASRC_SUCCESS) { @@ -2282,6 +2702,30 @@ int camerasrc_start_preview_stream(camsrc_handle_t handle) camsrc_info("[SCP] STREAMON done"); + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { + err = _camerasrc_ioctl_stream(p, p->fd_3aa0, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, TRUE); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0_CAPTURE] _camerasrc_ioctl_stream failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->streamon_3aa0_capture = TRUE; + + camsrc_info("[3AA0_CAPTURE] STREAMON done"); + + err = _camerasrc_ioctl_stream(p, p->fd_3aa0, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, TRUE); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0_OUTPUT] _camerasrc_ioctl_stream failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->streamon_3aa0_output = TRUE; + + camsrc_info("[3AA0_OUTPUT] STREAMON done"); + } + err = _camerasrc_ioctl_stream(p, p->fd_isp, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, TRUE); if (err != CAMERASRC_SUCCESS) { strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); @@ -2293,7 +2737,46 @@ int camerasrc_start_preview_stream(camsrc_handle_t handle) camsrc_info("[ISP] STREAMON done"); - if (p->cur_dev_id == CAMERASRC_DEV_ID_SECONDARY) { + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { + /* 3AA buffers qbuf */ + for (i = 0 ; i < p->format_3aa0.num_buffers ; i++) { + err = _camerasrc_set_shot_meta2(p, GRP_3AA, 0, 0, (struct camera2_shot_ext *)p->buffer_ta[i].planes[1].start); + if (err != CAMERASRC_SUCCESS) { + camsrc_error("[TA] _camerasrc_set_shot_meta index %d, failed[%x]", i, err); + return err; + } + + err = _camerasrc_ioctl_qbuf(p, + p->fd_3aa0, + V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, + V4L2_MEMORY_DMABUF, + i, + &p->buffer_ta[i]); + if (err != CAMERASRC_SUCCESS) { + camsrc_error("[3AA0_OUTPUT - TA] _camerasrc_ioctl_qbuf index %d, failed[%x]", i, err); + return CAMERASRC_ERR_IO_CONTROL; + } + + err = _camerasrc_ioctl_qbuf(p, + p->fd_3aa0, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + i, + &p->buffer_isp[i]); + if (err != CAMERASRC_SUCCESS) { + camsrc_error("[3AA0_CAPTURE - ISP] _camerasrc_ioctl_qbuf index %d, failed[%x]", i, err); + return CAMERASRC_ERR_IO_CONTROL; + } + } + + /* sensor s_ctrl */ + err = _camerasrc_ioctl_s_ctrl(p, p->fd_sensor, 0x9a100e, 1); + if (err != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[SENSOR] S_CTRL 0x9a100e -> 1 failed[%x] : %s", err, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + } else { err = _camerasrc_ioctl_s_ctrl(p, p->fd_sensor, V4L2_CID_IS_S_STREAM, TRUE); if (err != CAMERASRC_SUCCESS) { strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); @@ -2304,29 +2787,29 @@ int camerasrc_start_preview_stream(camsrc_handle_t handle) p->streamon_sensor_sub = TRUE; camsrc_info("[SENSOR] IS_S_STREAM 1 done"); - } - if (p->buffer_scc) { - for (i = 0 ; i < p->format_scc.num_buffers ; i++) { - err = _camerasrc_set_shot_meta(p, GRP_SCC, i, 0, (struct camera2_shot_ext *)p->buffer_scc[i].planes[1].start); - if (err != CAMERASRC_SUCCESS) { - camsrc_error("[SCC] _camerasrc_set_shot_meta index %d, failed[%x]", i, err); - return err; - } + if (p->buffer_scc) { + for (i = 0 ; i < p->format_scc.num_buffers ; i++) { + err = _camerasrc_set_shot_meta(p, GRP_SCC, i, 0, (struct camera2_shot_ext *)p->buffer_scc[i].planes[1].start); + if (err != CAMERASRC_SUCCESS) { + camsrc_error("[SCC] _camerasrc_set_shot_meta index %d, failed[%x]", i, err); + return err; + } - err = _camerasrc_ioctl_qbuf(p, - p->fd_scc, - V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, - V4L2_MEMORY_DMABUF, - i, - &p->buffer_scc[i]); - if (err != CAMERASRC_SUCCESS) { - camsrc_error("[SCC] _camerasrc_ioctl_qbuf index %d, failed[%x]", i, err); - return CAMERASRC_ERR_IO_CONTROL; + err = _camerasrc_ioctl_qbuf(p, + p->fd_scc, + V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, + V4L2_MEMORY_DMABUF, + i, + &p->buffer_scc[i]); + if (err != CAMERASRC_SUCCESS) { + camsrc_error("[SCC] _camerasrc_ioctl_qbuf index %d, failed[%x]", i, err); + return CAMERASRC_ERR_IO_CONTROL; + } } - } - camsrc_info("[SCC] QBUF done - %d", p->format_scc.num_buffers); + camsrc_info("[SCC] QBUF done - %d", p->format_scc.num_buffers); + } } CAMERASRC_SET_STATE(p, CAMERASRC_STATE_PREVIEW); @@ -2367,7 +2850,15 @@ int camerasrc_stop_stream(camsrc_handle_t handle) UNLOCK(p); /* STREAM OFF */ - if (p->cur_dev_id == CAMERASRC_DEV_ID_SECONDARY && + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { + /* sensor s_ctrl */ + ret = _camerasrc_ioctl_s_ctrl(p, p->fd_sensor, 0x9a100e, 15); + if (ret != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[SENSOR] S_CTRL 0x9a100e -> 15 failed[%x] : %s", ret, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + } else if (p->cur_dev_id == CAMERASRC_DEV_ID_SECONDARY && p->streamon_sensor_sub) { ret = _camerasrc_ioctl_s_ctrl(p, p->fd_sensor, V4L2_CID_IS_S_STREAM, 0); if (ret != CAMERASRC_SUCCESS) { @@ -2394,6 +2885,34 @@ int camerasrc_stop_stream(camsrc_handle_t handle) camsrc_info("[SENSOR] STREAMOFF done"); } + if (p->streamon_3aa0_output) { +#if 0 + ret = _camerasrc_ioctl_stream(p, p->fd_3aa0, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, FALSE); + if (ret != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0 - OUTPUT] _camerasrc_ioctl_stream failed[%x] : %s", ret, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } +#endif + p->streamon_3aa0_output = FALSE; + + camsrc_info("[3AA0 - OUTPUT] STREAMOFF done"); + } + + if (p->streamon_3aa0_capture) { +#if 0 + ret = _camerasrc_ioctl_stream(p, p->fd_3aa0, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, FALSE); + if (ret != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0 - CAPTURE] _camerasrc_ioctl_stream failed[%x] : %s", ret, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } +#endif + p->streamon_3aa0_capture = FALSE; + + camsrc_info("[3AA0 - CAPTURE] STREAMOFF done"); + } + if (p->streamon_3aa1_output) { ret = _camerasrc_ioctl_stream(p, p->fd_3aa1, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, FALSE); if (ret != CAMERASRC_SUCCESS) { @@ -2490,6 +3009,34 @@ int camerasrc_stop_stream(camsrc_handle_t handle) camsrc_info("[3AA1 - OUTPUT] REQBUF 0 done"); } + /* 3AA0 - CAPTURE */ + if (p->reqbuf_3aa0_capture) { + ret = _camerasrc_ioctl_reqbufs(p, p->fd_3aa0, 0, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, V4L2_MEMORY_DMABUF, NULL); + if (ret != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0 - CAPTURE] _camerasrc_ioctl_reqbufs failed[%x] : %s", ret, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->reqbuf_3aa0_capture = FALSE; + + camsrc_info("[3AA0 - CAPTURE] REQBUF 0 done"); + } + + /* 3AA0 - OUTPUT */ + if (p->reqbuf_3aa0_output) { + ret = _camerasrc_ioctl_reqbufs(p, p->fd_3aa0, 0, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, V4L2_MEMORY_DMABUF, NULL); + if (ret != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0 - OUTPUT] _camerasrc_ioctl_reqbufs failed[%x] : %s", ret, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->reqbuf_3aa0_output = FALSE; + + camsrc_info("[3AA0 - OUTPUT] REQBUF 0 done"); + } + /* 3AA1 - CAPTURE */ if (p->reqbuf_3aa1_capture) { ret = _camerasrc_ioctl_reqbufs(p, p->fd_3aa1, 0, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, V4L2_MEMORY_DMABUF, NULL); @@ -2532,6 +3079,20 @@ int camerasrc_stop_stream(camsrc_handle_t handle) camsrc_info("[SCC] REQBUF 0 done"); } + /* 3AA0C */ + if (p->reqbuf_3aa0c_capture) { + ret = _camerasrc_ioctl_reqbufs(p, p->fd_3aa0c, 0, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, V4L2_MEMORY_DMABUF, NULL); + if (ret != CAMERASRC_SUCCESS) { + strerror_r(p->errnum, err_msg, CAMERASRC_ERRMSG_MAX_LEN); + camsrc_error("[3AA0C - CAPTURE] _camerasrc_ioctl_reqbufs failed[%x] : %s", ret, err_msg); + return CAMERASRC_ERR_IO_CONTROL; + } + + p->reqbuf_3aa0c_capture = FALSE; + + camsrc_info("[3AA0C] REQBUF 0 done"); + } + /* SCP */ if (p->reqbuf_scp) { ret = _camerasrc_ioctl_reqbufs(p, p->fd_isp, 0, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, V4L2_MEMORY_DMABUF, NULL); @@ -3021,7 +3582,24 @@ int camerasrc_set_format(camsrc_handle_t handle, camerasrc_format_t *fmt) p->format_scp.quality = fmt->quality; p->format_scp.sizeimage = fmt->sizeimage; p->format_scp.rotation = fmt->rotation; - p->format_scp.num_buffers = CAMERASRC_PREVIEW_BUFFER_NUM; + + p->format_isp.img_size.width = fmt->img_size.width; + p->format_isp.img_size.height = fmt->img_size.height; + + if (p->cur_dev_id == CAMERASRC_DEV_ID_PRIMARY) { + if (fmt->img_size.width == fmt->img_size.height) + p->format_sensor.img_size.width = PRIMARY_SENSOR_HEIGHT; + else if (fmt->img_size.width / 4 == fmt->img_size.height / 3) + p->format_sensor.img_size.width = PRIMARY_SENSOR_WIDTH_2; + else + p->format_sensor.img_size.width = PRIMARY_SENSOR_WIDTH_1; + + p->format_sensor.img_size.height = PRIMARY_SENSOR_HEIGHT; + + p->format_scp.num_buffers = CAMERASRC_PREVIEW_BUFFER_NUM_PRIMARY; + } else { + p->format_scp.num_buffers = CAMERASRC_PREVIEW_BUFFER_NUM_SECONDARY; + } switch (fmt->pix_format) { case CAMERASRC_PIX_YUV420: @@ -3126,6 +3704,8 @@ static int _camerasrc_dump_format(camsrc_handle_t handle) p = CAMERASRC_HANDLE(handle); camsrc_info("---------FORMAT SETTING DUMP--------"); + camsrc_info("- Sensor set : %d x %d", p->format_sensor.img_size.width, p->format_sensor.img_size.height); + camsrc_info("- ISP set : %d x %d", p->format_isp.img_size.width, p->format_isp.img_size.height); camsrc_info("- Image size : %d x %d", p->format_scp.img_size.width, p->format_scp.img_size.height); camsrc_info("- Capture size : %d x %d", p->format_scp.capture_size.width, p->format_scp.capture_size.height); camsrc_info("- Thumbnail size : %d x %d", p->format_scp.thumb_size.width, p->format_scp.thumb_size.height); @@ -3323,6 +3903,8 @@ int camerasrc_tbm_alloc_buffer(camsrc_handle_t handle, int size, tbm_bo *bo, int *dma_buf_fd = bo_handle_fd.u32; *vaddr = bo_handle_vaddr.ptr; + memset(bo_handle_vaddr.ptr, 0x0, size); + camsrc_warning("bo %p, dmabuf fd %u, vaddr %p, size %d", *bo, *dma_buf_fd, *vaddr, size); @@ -3355,7 +3937,7 @@ int camerasrc_read_basic_dev_info(camerasrc_dev_id_t dev_id, camerasrc_caps_info { fseek(fp, 0, SEEK_SET); nread = fread(caps_info, 1, sizeof(camerasrc_caps_info_t), fp); - camsrc_info("Need to be read : %d / Actual read : %d", sizeof(camerasrc_caps_info_t), nread); + camsrc_info("Need to be read : %d / Actual read : %d", (int)sizeof(camerasrc_caps_info_t), nread); fclose(fp); } else @@ -3391,7 +3973,7 @@ int camerasrc_read_misc_dev_info(camerasrc_dev_id_t dev_id, camerasrc_ctrl_list_ { fseek(fp, 0, SEEK_SET); nread = fread(ctrl_info, 1, sizeof(camerasrc_ctrl_list_info_t), fp); - camsrc_info("Need to be read : %d / Actual read : %d", sizeof(camerasrc_ctrl_list_info_t), nread); + camsrc_info("Need to be read : %d / Actual read : %d", (int)sizeof(camerasrc_ctrl_list_info_t), nread); fclose(fp); } else @@ -3427,7 +4009,7 @@ int camerasrc_read_extra_dev_info(camerasrc_dev_id_t dev_id, camerasrc_extra_inf { fseek(fp, 0, SEEK_SET); nread = fread(extra_info, 1, sizeof(camerasrc_extra_info_t), fp); - camsrc_info("Need to be read : %d / Actual read : %d", sizeof(camerasrc_extra_info_t), nread); + camsrc_info("Need to be read : %d / Actual read : %d", (int)sizeof(camerasrc_extra_info_t), nread); fclose(fp); } else @@ -3478,7 +4060,7 @@ int camerasrc_write_basic_dev_info(camsrc_handle_t handle, camerasrc_caps_info_t { fseek(fp, 0, SEEK_SET); nwrite = fwrite(caps_info, 1, sizeof(camerasrc_caps_info_t), fp); - camsrc_info("Need to be written : %d / Actual written : %d", sizeof(camerasrc_caps_info_t), nwrite); + camsrc_info("Need to be written : %d / Actual written : %d", (int)sizeof(camerasrc_caps_info_t), nwrite); fclose(fp); } else @@ -3528,7 +4110,7 @@ int camerasrc_write_misc_dev_info(camsrc_handle_t handle, camerasrc_ctrl_list_in { fseek(fp, 0, SEEK_SET); nwrite = fwrite(ctrl_info, 1, sizeof(camerasrc_ctrl_list_info_t), fp); - camsrc_info("Need to be written : %d / Actual written : %d", sizeof(camerasrc_ctrl_list_info_t), nwrite); + camsrc_info("Need to be written : %d / Actual written : %d", (int)sizeof(camerasrc_ctrl_list_info_t), nwrite); fclose(fp); } else @@ -3578,7 +4160,7 @@ int camerasrc_write_extra_dev_info(camsrc_handle_t handle, camerasrc_extra_info_ { fseek(fp, 0, SEEK_SET); nwrite = fwrite(extra_info, 1, sizeof(camerasrc_extra_info_t), fp); - camsrc_info("Need to be written : %d / Actual written : %d", sizeof(camerasrc_extra_info_t), nwrite); + camsrc_info("Need to be written : %d / Actual written : %d", (int)sizeof(camerasrc_extra_info_t), nwrite); fclose(fp); } else @@ -3589,6 +4171,248 @@ int camerasrc_write_extra_dev_info(camsrc_handle_t handle, camerasrc_extra_info_ } +static int _camerasrc_set_shot_meta2(camerasrc_handle_t *p, unsigned int grpid, int fcount, + unsigned long long timestamp, struct camera2_shot_ext *shot_ext) +{ + const unsigned int width = 2560; + const unsigned int height = 1440; + + if (!p || !shot_ext) { + camsrc_error("NULL handle %p %p", p, shot_ext); + return CAMERASRC_ERR_NULL_POINTER; + } + + if (grpid != GRP_ISP) + memset(shot_ext, 0, sizeof(struct camera2_shot_ext)); + + shot_ext->drc_bypass = 1; + shot_ext->dis_bypass = 1; + shot_ext->dnr_bypass = 1; + shot_ext->fd_bypass = 1; + + shot_ext->setfile = 0; + /* shot_ext->free_cnt = 5; */ + + shot_ext->shot.ctl.request.metadataMode = METADATA_MODE_FULL; + shot_ext->shot.ctl.lens.aperture = 2.26999998; + shot_ext->shot.ctl.lens.focalLength = 4.80000019; + shot_ext->shot.ctl.lens.opticalStabilizationMode = OPTICAL_STABILIZATION_MODE_STILL; + shot_ext->shot.ctl.sensor.frameDuration = 33333333; + shot_ext->shot.ctl.flash.flashMode = CAM2_FLASH_MODE_OFF; + shot_ext->shot.ctl.noise.mode = PROCESSING_MODE_OFF; + + shot_ext->shot.ctl.tonemap.mode = TONEMAP_MODE_FAST; + shot_ext->shot.ctl.tonemap.curveGreen[1] = 1; + shot_ext->shot.ctl.tonemap.curveGreen[2] = 1; + shot_ext->shot.ctl.tonemap.curveBlue[1] = 1; + shot_ext->shot.ctl.tonemap.curveBlue[2] = 1; + + shot_ext->shot.ctl.color.mode = COLORCORRECTION_MODE_FAST; + shot_ext->shot.ctl.color.transform [0] = 1; + shot_ext->shot.ctl.color.transform [4] = 1; + shot_ext->shot.ctl.color.transform [8] = 1; + shot_ext->shot.ctl.color.hue = 3; + shot_ext->shot.ctl.color.saturation = 3; + shot_ext->shot.ctl.color.brightness = 3; + shot_ext->shot.ctl.color.contrast = 3; + + shot_ext->shot.ctl.stats.faceDetectMode = FACEDETECT_MODE_OFF; + shot_ext->shot.ctl.stats.histogramMode = STATS_MODE_OFF; + shot_ext->shot.ctl.stats.sharpnessMapMode = STATS_MODE_OFF; + + /* AA */ + shot_ext->shot.ctl.aa.captureIntent = AA_CAPTURE_INTENT_CUSTOM; + shot_ext->shot.ctl.aa.mode = AA_CONTROL_USE_SCENE_MODE; + shot_ext->shot.ctl.aa.sceneMode = AA_SCENE_MODE_LLS; + shot_ext->shot.ctl.aa.aeMode = AA_AEMODE_CENTER; + shot_ext->shot.ctl.aa.aeExpCompensation = 5; + shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 10; + shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30; + shot_ext->shot.ctl.aa.aeAntibandingMode = AA_AE_ANTIBANDING_AUTO_50HZ; + shot_ext->shot.ctl.aa.awbMode = AA_AWBMODE_WB_AUTO; + shot_ext->shot.ctl.aa.aeflashMode = AA_FLASHMODE_OFF; + shot_ext->shot.ctl.aa.afMode = AA_AFMODE_CONTINUOUS_PICTURE; + shot_ext->shot.ctl.aa.afRegions[4] = 1000; + shot_ext->shot.ctl.aa.isoMode = AA_ISOMODE_AUTO; + shot_ext->shot.ctl.aa.isoValue = 0; + shot_ext->shot.ctl.aa.awbValue = 4; + + /* JPEG */ + shot_ext->shot.ctl.jpeg.quality = 0x60; + shot_ext->shot.ctl.jpeg.thumbnailSize[0] = 0x200; + shot_ext->shot.ctl.jpeg.thumbnailSize[1] = 0x180; + shot_ext->shot.ctl.jpeg.thumbnailQuality = 0x64; + + shot_ext->shot.dm.edge.mode = PROCESSING_MODE_OFF; + + if (grpid == GRP_3AA) { + shot_ext->setfile = 0; + + shot_ext->node_group.leader.vid = FIMC_IS_VIDEO_3A0_NUM; + shot_ext->node_group.leader.request = 1; + shot_ext->node_group.leader.input.cropRegion[0] = 4; + shot_ext->node_group.leader.input.cropRegion[1] = 2; + shot_ext->node_group.leader.input.cropRegion[2] = width + 88; /* 2648 */ + shot_ext->node_group.leader.input.cropRegion[3] = height + 50; /* 1490 */ + shot_ext->node_group.leader.output.cropRegion[0] = 4; + shot_ext->node_group.leader.output.cropRegion[1] = 2; + shot_ext->node_group.leader.output.cropRegion[2] = width + 88; /* 2648 */ + shot_ext->node_group.leader.output.cropRegion[3] = height + 50; /* 1490 */ + + shot_ext->node_group.capture[1].vid = FIMC_IS_VIDEO_3A0P_NUM; + shot_ext->node_group.capture[1].request = 1; + shot_ext->node_group.capture[1].input.cropRegion[0] = 0; + shot_ext->node_group.capture[1].input.cropRegion[1] = 0; + shot_ext->node_group.capture[1].input.cropRegion[2] = width + 88; /* 2648 */ + shot_ext->node_group.capture[1].input.cropRegion[3] = height + 50; /* 1490 */ + shot_ext->node_group.capture[1].output.cropRegion[0] = 0; + shot_ext->node_group.capture[1].output.cropRegion[1] = 0; + shot_ext->node_group.capture[1].output.cropRegion[2] = width; + shot_ext->node_group.capture[1].output.cropRegion[3] = height; +#if 0 + /* FIXME: is this needed? */ + shot_ext->shot.ctl.scaler.cropRegion[0] = 0x3f800000; + shot_ext->shot.ctl.scaler.cropRegion[1] = 0; + shot_ext->shot.ctl.scaler.cropRegion[2] = width; + shot_ext->shot.ctl.scaler.cropRegion[3] = height; +#endif + shot_ext->shot.ctl.aa.aeTargetFpsRange[0] = 10; + shot_ext->shot.ctl.aa.aeTargetFpsRange[1] = 30; + + } else if (grpid == GRP_ISP) { + shot_ext->setfile = 0; + + shot_ext->node_group.leader.vid = FIMC_IS_VIDEO_ISP_NUM; + shot_ext->node_group.leader.request = 1; + shot_ext->node_group.leader.input.cropRegion[0] = 0; + shot_ext->node_group.leader.input.cropRegion[1] = 0; + shot_ext->node_group.leader.input.cropRegion[2] = width; + shot_ext->node_group.leader.input.cropRegion[3] = height; + + shot_ext->node_group.leader.output.cropRegion[0] = 0; + shot_ext->node_group.leader.output.cropRegion[1] = 0; + shot_ext->node_group.leader.output.cropRegion[2] = width; + shot_ext->node_group.leader.output.cropRegion[3] = height; +#if 0 + /* SCC */ + shot_ext->node_group.capture[0].vid = FIMC_IS_VIDEO_SCC_NUM; + shot_ext->node_group.capture[0].request = 1; + shot_ext->node_group.capture[0].input.cropRegion[0] = 0; + shot_ext->node_group.capture[0].input.cropRegion[1] = 0; + shot_ext->node_group.capture[0].input.cropRegion[2] = 2560; + shot_ext->node_group.capture[0].input.cropRegion[3] = 1440; + shot_ext->node_group.capture[0].output.cropRegion[0] = 0; + shot_ext->node_group.capture[0].output.cropRegion[1] = 0; + shot_ext->node_group.capture[0].output.cropRegion[2] = 1920; + shot_ext->node_group.capture[0].output.cropRegion[3] = 1080; +#endif + /* SCP */ + shot_ext->node_group.capture[0].vid = FIMC_IS_VIDEO_SCP_NUM; + shot_ext->node_group.capture[0].request = 1; + shot_ext->node_group.capture[0].input.cropRegion[0] = 0; + shot_ext->node_group.capture[0].input.cropRegion[1] = 0; + shot_ext->node_group.capture[0].input.cropRegion[2] = 1920; + shot_ext->node_group.capture[0].input.cropRegion[3] = 1080; + + shot_ext->node_group.capture[0].output.cropRegion[0] = 0; + shot_ext->node_group.capture[0].output.cropRegion[1] = 0; + shot_ext->node_group.capture[0].output.cropRegion[2] = 1920; + shot_ext->node_group.capture[0].output.cropRegion[3] = 1080; + /* + * First entry needs to be non-zero - if it's not errors for + * SCC/SCP/DIS are being reported (no target address). + * Same rule (first item non-zero) applies to vendorSpecific2[]. + */ + shot_ext->shot.udm.internal.vendorSpecific1[0] = 2; + shot_ext->shot.udm.internal.vendorSpecific1[1] = 0x000b0c00; + //shot_ext->shot.udm.internal.vendorSpecific1[2] = 0x52ae3000; + + shot_ext->shot.udm.internal.vendorSpecific2[0] = + (FIMC_IS_ISP_VS2_INIT_R + + ((fcount - 1) % FIMC_IS_ISP_VS2_RANGE) * FIMC_IS_ISP_VS2_STEP); + + shot_ext->shot.udm.bayer.width = width; + shot_ext->shot.udm.bayer.height = height; + + shot_ext->shot.udm.companion.drc_mode = COMPANION_DRC_ON; + shot_ext->shot.udm.companion.wdr_mode = COMPANION_WDR_OFF; + shot_ext->shot.udm.companion.paf_mode = COMPANION_PAF_ON; + + shot_ext->shot.udm.companion.pdaf.lensPosResolution = 0x3ff; + + shot_ext->shot.dm.hotpixel.mode = PROCESSING_MODE_FAST; + shot_ext->shot.dm.demosaic.mode = PROCESSING_MODE_FAST; + shot_ext->shot.dm.noise.mode = PROCESSING_MODE_OFF; + shot_ext->shot.dm.shading.mode = PROCESSING_MODE_FAST; + + shot_ext->shot.dm.color.mode = COLORCORRECTION_MODE_FAST; +#if 0 + shot_ext->shot.dm.color.transform[0] = 1.95095313; + shot_ext->shot.dm.color.transform[1] = -0.973571777; + shot_ext->shot.dm.color.transform[2] = 0.0226186104; + shot_ext->shot.dm.color.transform[3] = -0.257125854; + shot_ext->shot.dm.color.transform[4] = 1.34063721; + shot_ext->shot.dm.color.transform[5] = -0.0835113525; + shot_ext->shot.dm.color.transform[6] = 0.0106252059; + shot_ext->shot.dm.color.transform[7] = -0.997131407; + shot_ext->shot.dm.color.transform[8] = 1.98650622; +#endif + shot_ext->shot.dm.color.hue = 3; + shot_ext->shot.dm.color.saturation = 3; + shot_ext->shot.dm.color.brightness = 3; + shot_ext->shot.dm.color.contrast = 3; + + shot_ext->shot.dm.edge.mode = PROCESSING_MODE_OFF; + + shot_ext->shot.dm.aa.mode = AA_CONTROL_USE_SCENE_MODE; + shot_ext->shot.dm.aa.sceneMode = AA_SCENE_MODE_LLS; + shot_ext->shot.dm.aa.aeMode = AA_AEMODE_CENTER; + shot_ext->shot.dm.aa.aeState = AE_STATE_CONVERGED; + shot_ext->shot.dm.aa.aeflashMode = AA_FLASHMODE_OFF; + shot_ext->shot.dm.aa.awbMode = AA_AWBMODE_WB_AUTO; + shot_ext->shot.dm.aa.awbRegions[2] = 2647; + shot_ext->shot.dm.aa.awbRegions[3] = 1489; + shot_ext->shot.dm.aa.awbRegions[4] = 100; + shot_ext->shot.dm.aa.afState = AA_AFSTATE_INACTIVE; + shot_ext->shot.dm.aa.isoMode = AA_ISOMODE_AUTO; + shot_ext->shot.dm.aa.isoValue = 320; + + shot_ext->shot.uctl.companionUd.wdr_mode = COMPANION_WDR_OFF; +#if 0 + // scpTargetAddress = {0x56100000, 0x80200000, 0xa0000000, 0x0} + unsigned int adr[] = { + 0x51b3c000, + 0x51835000, + 0x5152e000, + }; + + shot_ext->shot.uctl.scalerUd.scpTargetAddress[0] = adr[fcount % 2]; + //shot_ext->shot.uctl.scalerUd.scpTargetAddress[1] = 0x80200000; + //shot_ext->shot.uctl.scalerUd.scpTargetAddress[2] = 0xa0000000; + //shot_ext->shot.uctl.scalerUd.scpTargetAddress[3] = 0; +#endif + shot_ext->shot.uctl.scalerUd.orientation = 0x5d; + + shot_ext->shot.dm.entry.lowIndexParam = 0; + shot_ext->shot.dm.entry.highIndexParam = 0; + shot_ext->shot.ctl.entry.lowIndexParam = 0; + shot_ext->shot.ctl.entry.highIndexParam = 0; + } + + if (grpid != GRP_SENSOR) { + shot_ext->shot.dm.request.metadataMode = METADATA_MODE_NONE; + shot_ext->shot.dm.request.frameCount = fcount; + shot_ext->shot.dm.sensor.timeStamp = timestamp; + } + + camsrc_debug("grpid: %d fcount: %d", grpid, fcount); + + shot_ext->shot.magicNumber = METADATA_MAGIC_NUMBER; + + return CAMERASRC_SUCCESS; +} + + static int _camerasrc_set_shot_meta(camerasrc_handle_t *p, unsigned int grpid, int fcount, unsigned long long timestamp, struct camera2_shot_ext *shot_ext) { diff --git a/camerasrc/src/gstcamerasrc.c b/camerasrc/src/gstcamerasrc.c index f3b897b..a814b30 100644 --- a/camerasrc/src/gstcamerasrc.c +++ b/camerasrc/src/gstcamerasrc.c @@ -694,7 +694,7 @@ static gboolean gst_camerasrc_start(GstCameraSrc *camerasrc) _READY_DONE: camerasrc->mode = VIDEO_IN_MODE_PREVIEW; - camerasrc->current_buffer_data_index = (camerasrc->current_buffer_data_index + 1)%10; + camerasrc->current_buffer_data_index = (camerasrc->current_buffer_data_index + 1) % 10; camerasrc->buffer_running = TRUE; GST_DEBUG_OBJECT(camerasrc, "LEAVED"); @@ -1093,7 +1093,7 @@ static GstFlowReturn gst_camerasrc_read_preview(GstCameraSrc *camerasrc, GstBuff /* check restart preview command */ if (!g_queue_is_empty(camerasrc->restart_cmd_list)) { - int restart_cmd = (int)g_queue_pop_head(camerasrc->restart_cmd_list); + int restart_cmd = GPOINTER_TO_INT(g_queue_pop_head(camerasrc->restart_cmd_list)); GST_INFO("popped cmd : %d", restart_cmd); @@ -1305,7 +1305,7 @@ static GstFlowReturn gst_camerasrc_read_capture(GstCameraSrc *camerasrc, GstBuff if (get_stop_command == FALSE) { if (!g_queue_is_empty(camerasrc->capture_cmd_list)) { - command = (int)g_queue_pop_head(camerasrc->capture_cmd_list); + command = GPOINTER_TO_INT(g_queue_pop_head(camerasrc->capture_cmd_list)); GST_INFO_OBJECT(camerasrc, "Pop command [%d]", command); if (command == GST_CAMERA_CONTROL_CAPTURE_COMMAND_STOP) { get_stop_command = TRUE; @@ -1564,8 +1564,8 @@ CHECK_CAPTURE_INTERVAL: *buffer = buf->buffer; gst_buffer_map(*buffer, &buf_info, GST_MAP_READ); GST_INFO_OBJECT(camerasrc, "BUF for PREVIEW: addr %p size %d, format %c%c%c%c", - buf_info.data, buf_info.maxsize, - camerasrc->cap_fourcc, camerasrc->cap_fourcc>>8, camerasrc->cap_fourcc>>16, camerasrc->cap_fourcc>>24); + buf_info.data, (int)buf_info.maxsize, camerasrc->cap_fourcc, + camerasrc->cap_fourcc>>8, camerasrc->cap_fourcc>>16, camerasrc->cap_fourcc>>24); gst_buffer_unmap(*buffer, &buf_info); } @@ -1687,7 +1687,7 @@ static GstFlowReturn gst_camerasrc_read(GstCameraSrc *camerasrc, GstBuffer **buf g_mutex_lock(&camerasrc->mutex); if (!g_queue_is_empty(camerasrc->capture_cmd_list)) { - command = (int)g_queue_pop_head(camerasrc->capture_cmd_list); + command = GPOINTER_TO_INT(g_queue_pop_head(camerasrc->capture_cmd_list)); GST_INFO_OBJECT(camerasrc, "popped cmd : %d", command); } @@ -2199,6 +2199,24 @@ static GstMemory *gst_camerasrc_get_zero_copy_data(GstCameraSrc *camerasrc, guin mm_buf, free); +#if 0 + { + FILE *fp = fopen("/home/owner/media/test.yuv", "a"); + if (fp) { + g_print("write %d + %d\n", + mm_buf->width[0] * mm_buf->height[0], + mm_buf->width[1] * mm_buf->height[1]); + fwrite(mm_buf->data[0], 1, mm_buf->width[0] * mm_buf->height[0], fp); + fwrite(mm_buf->data[1], 1, mm_buf->width[1] * mm_buf->height[1], fp); + fflush(fp); + fclose(fp); + fp = NULL; + } else { + g_print("failed to open file : errno %d\n", errno); + } + } +#endif + return meta; } diff --git a/camerasrc/src/include/camerasrc-common.h b/camerasrc/src/include/camerasrc-common.h index 39da122..4204b54 100644 --- a/camerasrc/src/include/camerasrc-common.h +++ b/camerasrc/src/include/camerasrc-common.h @@ -100,13 +100,21 @@ GST_DEBUG_CATEGORY_EXTERN(camerasrc_debug); #define GST_CAT_DEFAULT camerasrc_debug #endif /* GST_CAT_DEFAULT */ - +#if 1 #define camsrc_log(msg, args...) GST_LOG(msg, ##args) #define camsrc_debug(msg, args...) GST_DEBUG(msg, ##args) #define camsrc_info(msg, args...) GST_INFO(msg, ##args) #define camsrc_warning(msg, args...) GST_WARNING(msg, ##args) #define camsrc_error(msg, args...) GST_ERROR(msg, ##args) #define camsrc_critical(msg, args...) GST_ERROR(msg, ##args) +#else +#define camsrc_log(msg, args...) g_print("[%4d][%s] "msg"\n", __LINE__, __func__, ##args) +#define camsrc_debug(msg, args...) g_print("[%4d][%s] "msg"\n", __LINE__, __func__, ##args) +#define camsrc_info(msg, args...) g_print("[%4d][%s] "msg"\n", __LINE__, __func__, ##args) +#define camsrc_warning(msg, args...) g_print("[%4d][%s] "msg"\n", __LINE__, __func__, ##args) +#define camsrc_error(msg, args...) g_print("[%4d][%s] "msg"\n", __LINE__, __func__, ##args) +#define camsrc_critical(msg, args...) g_print("[%4d][%s] "msg"\n", __LINE__, __func__, ##args) +#endif #define camsrc_assert(condition) { \ if (!(condition)) { \ GST_ERROR("failed [%s]", #condition); \ @@ -359,12 +367,16 @@ typedef struct _camerasrc_handle_t { int fd_companion; int fd_sensor; int fd_isp; + int fd_3aa0; + int fd_3aa0c; int fd_3aa1; int fd_3aa1c; int fd_scc; int fd_scp; int streamon_sensor; + int streamon_3aa0_output; + int streamon_3aa0_capture; int streamon_3aa1_output; int streamon_3aa1_capture; int streamon_isp; @@ -373,12 +385,16 @@ typedef struct _camerasrc_handle_t { int streamon_sensor_sub; int reqbuf_sensor; + int reqbuf_3aa0_output; + int reqbuf_3aa0_capture; + int reqbuf_3aa0c_capture; int reqbuf_3aa1_output; int reqbuf_3aa1_capture; int reqbuf_isp; int reqbuf_scc; int reqbuf_scp; + int frame_count; int request_count; /* state information */ @@ -390,6 +406,9 @@ typedef struct _camerasrc_handle_t { /* image format information */ int is_highquality; camerasrc_format_t format_sensor; + camerasrc_format_t format_ta; + camerasrc_format_t format_3aa0; + camerasrc_format_t format_3aa0c; camerasrc_format_t format_3aa1; camerasrc_format_t format_isp; camerasrc_format_t format_scc; @@ -401,6 +420,7 @@ typedef struct _camerasrc_handle_t { int first_frame; struct v4l2_buffer queued_buf_list[CAMERASRC_USRPTR_MAX_BUFFER_NUM]; camerasrc_buffer_t *buffer_sensor; + camerasrc_buffer_t *buffer_ta; camerasrc_buffer_t *buffer_isp; camerasrc_buffer_t *buffer_scc; camerasrc_buffer_t *buffer_scp; diff --git a/camerasrc/src/include/camerasrc.h b/camerasrc/src/include/camerasrc.h index 6608193..18cf766 100644 --- a/camerasrc/src/include/camerasrc.h +++ b/camerasrc/src/include/camerasrc.h @@ -38,7 +38,8 @@ extern "C" { #define MAX_FACE_NUM 16 #define MAX_PLANE_NUM 4 -#define CAMERASRC_PREVIEW_BUFFER_NUM 12 /* number of request buffer when preview */ +#define CAMERASRC_PREVIEW_BUFFER_NUM_PRIMARY 9 /* number of request buffer when preview */ +#define CAMERASRC_PREVIEW_BUFFER_NUM_SECONDARY 12 /* number of request buffer when preview */ #define CAMERASRC_VIDEO_BUFFER_NUM 7 #define CAMERASRC_STILL_BUFFER_NUM 1 |