int ExynosJpegBase::updateConfig(enum MODE eMode, int iInBufs, int iOutBufs, int iInBufPlanes, int iOutBufPlanes) { if (t_bFlagCreate == false) { return ERROR_JPEG_DEVICE_NOT_CREATE_YET; } int iRet = ERROR_NONE; if (eMode == MODE_ENCODE) { iRet = t_v4l2SetJpegcomp(t_iJpegFd, t_stJpegConfig.enc_qual); if (iRet < 0) { JPEG_ERROR_LOG("[%s,%d]: S_JPEGCOMP failed\n", __func__,iRet); return ERROR_INVALID_JPEG_CONFIG; } } t_stJpegConfig.numOfPlanes = iInBufPlanes; t_stJpegConfig.mode = eMode; iRet = t_v4l2SetFmt(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, &t_stJpegConfig); if (iRet < 0) { JPEG_ERROR_LOG("[%s,%d]: jpeg input S_FMT failed\n", __func__,iRet); return ERROR_INVALID_JPEG_CONFIG; } struct BUF_INFO stBufInfo; stBufInfo.numOfPlanes = iInBufs; stBufInfo.buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; stBufInfo.memory = V4L2_MEMORY_DMABUF; iRet = t_v4l2Reqbufs(t_iJpegFd, iInBufs, &stBufInfo); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Input REQBUFS failed\n", __func__, iRet); return ERROR_EXCUTE_FAIL; } t_stJpegConfig.numOfPlanes = iOutBufPlanes; iRet = t_v4l2SetFmt(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, &t_stJpegConfig); if (iRet < 0) { JPEG_ERROR_LOG("[%s,%d]: jpeg output S_FMT failed\n", __func__,iRet); return ERROR_INVALID_JPEG_CONFIG; } stBufInfo.numOfPlanes = iOutBufs; stBufInfo.buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; iRet = t_v4l2Reqbufs(t_iJpegFd, iOutBufs, &stBufInfo); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Output REQBUFS failed\n", __func__, iRet); return ERROR_REQBUF_FAIL; } return ERROR_NONE; }
int ExynosJpegBase::create(enum MODE eMode) { if (t_bFlagCreate == true) { return ERROR_JPEG_DEVICE_ALREADY_CREATE; } int iRet = ERROR_NONE; switch (eMode) { case MODE_ENCODE: t_iJpegFd = open(JPEG_ENC_NODE, O_RDWR, 0); break; case MODE_DECODE: t_iJpegFd = open(JPEG_DEC_NODE, O_RDWR, 0); break; default: t_iJpegFd = -1; return ERROR_INVALID_JPEG_MODE; break; } if (t_iJpegFd < 0) { t_iJpegFd = -1; JPEG_ERROR_LOG("[%s]: JPEG_NODE open failed\n", __func__); return ERROR_CANNOT_OPEN_JPEG_DEVICE; } if (t_iJpegFd <= 0) { t_iJpegFd = -1; JPEG_ERROR_LOG("ERR(%s):JPEG device was closed\n", __func__); return ERROR_JPEG_DEVICE_ALREADY_CLOSED; } iRet = t_v4l2Querycap(t_iJpegFd); if (iRet < 0) { JPEG_ERROR_LOG("[%s]: QUERYCAP failed\n", __func__); close(t_iJpegFd); return ERROR_CANNOT_OPEN_JPEG_DEVICE; } memset(&t_stJpegConfig, 0, sizeof(struct CONFIG)); memset(&t_stJpegInbuf, 0, sizeof(struct BUFFER)); memset(&t_stJpegOutbuf, 0, sizeof(struct BUFFER)); t_stJpegConfig.mode = eMode; t_bFlagCreate = true; t_bFlagCreateInBuf = false; t_bFlagCreateOutBuf = false; t_bFlagExcute = false; t_iPlaneNum = 0; return ERROR_NONE; }
int SecJpegEncoderHal::updateConfig(void) { if (t_bFlagCreate == false) { return ERROR_JPEG_DEVICE_NOT_CREATE_YET; } int iRet = ERROR_NONE; iRet = t_v4l2SetJpegcomp(t_iJpegFd, t_stJpegConfig.enc_qual); if (iRet < 0) { JPEG_ERROR_LOG("[%s,%d]: S_JPEGCOMP failed", __func__,iRet); return ERROR_INVALID_JPEG_CONFIG; } t_stJpegConfig.numOfPlanes = t_iPlaneNum; t_stJpegConfig.mode = MODE_ENCODE; iRet = t_v4l2SetFmt(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, &t_stJpegConfig); if (iRet < 0) { JPEG_ERROR_LOG("[%s,%d]: jpeg input S_FMT failed", __func__,iRet); return ERROR_INVALID_JPEG_CONFIG; } struct BUF_INFO stBufInfo; stBufInfo.numOfPlanes = t_iPlaneNum; stBufInfo.buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; stBufInfo.memory = V4L2_MEMORY_USERPTR; iRet = t_v4l2Reqbufs(t_iJpegFd, NUM_BUFFERS, &stBufInfo); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Input REQBUFS failed", __func__, iRet); return ERROR_EXCUTE_FAIL; } t_stJpegConfig.numOfPlanes = NUM_PLANES; iRet = t_v4l2SetFmt(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, &t_stJpegConfig); if (iRet < 0) { JPEG_ERROR_LOG("[%s,%d]: jpeg output S_FMT failed", __func__,iRet); return ERROR_INVALID_JPEG_CONFIG; } stBufInfo.numOfPlanes = NUM_PLANES; stBufInfo.buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; iRet = t_v4l2Reqbufs(t_iJpegFd, NUM_BUFFERS, &stBufInfo); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Output REQBUFS failed", __func__, iRet); return ERROR_REQBUF_FAIL; } return ERROR_NONE; }
int ExynosJpegBase::setJpegConfig(enum MODE eMode, void *pConfig) { if (t_bFlagCreate == false) { return ERROR_JPEG_DEVICE_NOT_CREATE_YET; } if (pConfig == NULL) { return ERROR_JPEG_CONFIG_POINTER_NULL; } memcpy(&t_stJpegConfig, pConfig, sizeof(struct CONFIG)); switch (eMode) { case MODE_ENCODE: switch (t_stJpegConfig.pix.enc_fmt.in_fmt) { case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_RGB565X: case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_RGB32: t_iPlaneNum = 1; break; default: JPEG_ERROR_LOG("%s::Invalid input color format(%d) fail\n", __func__, t_stJpegConfig.pix.enc_fmt.in_fmt); t_iPlaneNum = 0; return ERROR_INVALID_COLOR_FORMAT; } break; case MODE_DECODE: switch (t_stJpegConfig.pix.dec_fmt.out_fmt) { case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_RGB565X: case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_RGB32: t_iPlaneNum = 1; break; default: JPEG_ERROR_LOG("%s::Invalid input color format(%d) fail\n", __func__, t_stJpegConfig.pix.dec_fmt.out_fmt); t_iPlaneNum = 0; return ERROR_INVALID_COLOR_FORMAT; } break; default: t_iPlaneNum = 0; return ERROR_INVALID_JPEG_MODE; break; } return ERROR_NONE; }
int ExynosJpegBase::setColorFormat(enum MODE eMode, int iV4l2ColorFormat) { if (t_bFlagCreate == false) { return ERROR_JPEG_DEVICE_NOT_CREATE_YET; } switch(iV4l2ColorFormat) { case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_RGB565X: case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_RGB32: switch (eMode) { case MODE_ENCODE: t_stJpegConfig.pix.enc_fmt.in_fmt = iV4l2ColorFormat; break; case MODE_DECODE: t_stJpegConfig.pix.dec_fmt.out_fmt = iV4l2ColorFormat; break; default: return ERROR_INVALID_JPEG_MODE; break; } break; default: JPEG_ERROR_LOG("%s::Invalid input color format(%d) fail\n", __func__, iV4l2ColorFormat); t_iPlaneNum = 0; return ERROR_INVALID_COLOR_FORMAT; break; } switch (iV4l2ColorFormat) { case V4L2_PIX_FMT_YUV420: case V4L2_PIX_FMT_NV16: case V4L2_PIX_FMT_YUYV: case V4L2_PIX_FMT_RGB565X: case V4L2_PIX_FMT_BGR32: case V4L2_PIX_FMT_RGB32: t_iPlaneNum = 1; break; default: JPEG_ERROR_LOG("%s::Invalid input color format(%d) fail\n", __func__, iV4l2ColorFormat); t_iPlaneNum = 0; return ERROR_INVALID_COLOR_FORMAT; } return ERROR_NONE; }
int ExynosJpegBase::t_v4l2Dqbuf(int iFd, enum v4l2_buf_type eType, enum v4l2_memory eMemory, int iNumPlanes) { struct v4l2_buffer buf; struct v4l2_plane planes[3]; int iRet = ERROR_NONE; memset(&buf, 0, sizeof(struct v4l2_buffer)); memset(planes, 0, sizeof(struct v4l2_plane)*3); buf.type = eType; buf.memory = eMemory; buf.length = iNumPlanes; buf.m.planes = planes; iRet = ioctl(iFd, VIDIOC_DQBUF, &buf); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d] VIDIOC_DQBUF failed\n", __func__, iRet); return iRet; } #ifdef KERNEL_33_JPEG_API if ((eType == V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) && \ (t_stJpegConfig.mode == MODE_ENCODE)) { t_stJpegConfig.sizeJpeg = buf.m.planes[0].bytesused; } #endif return iRet; }
int ExynosJpegBase::t_v4l2Qbuf(int iFd, struct BUF_INFO *pstBufInfo, struct BUFFER *pstBuf) { struct v4l2_buffer v4l2_buf; struct v4l2_plane plane[JPEG_MAX_PLANE_CNT]; int i; int iRet = ERROR_NONE; memset(&v4l2_buf, 0, sizeof(struct v4l2_buffer)); memset(plane, 0, (int)JPEG_MAX_PLANE_CNT * sizeof(struct v4l2_plane)); v4l2_buf.index = 0; v4l2_buf.type = pstBufInfo->buf_type; v4l2_buf.memory = pstBufInfo->memory; v4l2_buf.field = V4L2_FIELD_ANY; v4l2_buf.length = pstBufInfo->numOfPlanes; v4l2_buf.m.planes = plane; if (pstBufInfo->memory == V4L2_MEMORY_DMABUF) { for (i = 0; i < pstBufInfo->numOfPlanes; i++) { v4l2_buf.m.planes[i].m.fd = (unsigned long)pstBuf->addr[i]; v4l2_buf.m.planes[i].length = pstBuf->size[i]; } } iRet = ioctl(iFd, VIDIOC_QBUF, &v4l2_buf); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d] VIDIOC_QBUF failed\n", __func__, iRet); pstBuf->numOfPlanes = 0; return iRet; } return iRet; }
int SecJpegEncoderHal::create(void) { if (t_bFlagCreate == true) { return ERROR_JPEG_DEVICE_ALREADY_CREATE; } int iRet = ERROR_NONE; t_iJpegFd = open(JPEG_ENC_NODE, O_RDWR, 0); if (t_iJpegFd < 0) { t_iJpegFd = -1; JPEG_ERROR_LOG("[%s]: JPEG_ENC_NODE open failed", __func__); return ERROR_CANNOT_OPEN_JPEG_DEVICE; } if (t_iJpegFd <= 0) { t_iJpegFd = -1; JPEG_ERROR_LOG("ERR(%s):JPEG device was closed\n", __func__); return ERROR_JPEG_DEVICE_ALREADY_CLOSED; } iRet = t_v4l2Querycap(t_iJpegFd); if (iRet < 0) { JPEG_ERROR_LOG("[%s]: QUERYCAP failed", __func__); close(t_iJpegFd); return ERROR_CANNOT_OPEN_JPEG_DEVICE; } memset(&t_stJpegConfig, 0, sizeof(struct CONFIG)); memset(&t_stJpegInbuf, 0, sizeof(struct BUFFER)); memset(&t_stJpegOutbuf, 0, sizeof(struct BUFFER)); t_stJpegConfig.mode = MODE_ENCODE; t_bFlagCreate = true; t_bFlagCreateInBuf = false; t_bFlagCreateOutBuf = false; t_bFlagExcute = false; t_iPlaneNum = 0; return ERROR_NONE; }
int ExynosJpegBase::t_v4l2StreamOff(int iFd, enum v4l2_buf_type eType) { int iRet = ERROR_NONE; iRet = ioctl(iFd, VIDIOC_STREAMOFF, &eType); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d] VIDIOC_STREAMOFF failed\n", __func__, iRet); return iRet; } return iRet; }
int ExynosJpegBase::setCache(int iValue) { if (t_bFlagCreate == false) { return ERROR_JPEG_DEVICE_NOT_CREATE_YET; } if (t_v4l2SetCtrl(t_iJpegFd, V4L2_CID_CACHEABLE, iValue)<0) { JPEG_ERROR_LOG("%s::cache setting failed\n", __func__); return ERROR_CANNOT_CHANGE_CACHE_SETTING; } return ERROR_NONE; }
int ExynosJpegBase::t_v4l2Querycap(int iFd) { struct v4l2_capability cap; int iRet = ERROR_NONE; iRet = ioctl(iFd, VIDIOC_QUERYCAP, &cap); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: VIDIOC_QUERYCAP failed\n", __func__, iRet); return iRet; } return iRet; }
int SecJpegEncoderHal::encode(void) { if (t_bFlagCreate == false) { return ERROR_JPEG_DEVICE_NOT_CREATE_YET; } struct BUF_INFO stBufInfo; int iRet = ERROR_NONE; t_bFlagExcute = true; stBufInfo.numOfPlanes = t_iPlaneNum; stBufInfo.buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; stBufInfo.memory = V4L2_MEMORY_USERPTR; iRet = t_v4l2Qbuf(t_iJpegFd, &stBufInfo, &t_stJpegInbuf); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Input QBUF failed", __func__, iRet); return ERROR_EXCUTE_FAIL; } stBufInfo.numOfPlanes = NUM_PLANES; stBufInfo.buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; iRet = t_v4l2Qbuf(t_iJpegFd, &stBufInfo, &t_stJpegOutbuf); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Output QBUF failed", __func__, iRet); return ERROR_EXCUTE_FAIL; } stBufInfo.numOfPlanes = t_iPlaneNum; iRet = t_v4l2StreamOn(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: input stream on failed", __func__, iRet); return ERROR_EXCUTE_FAIL; } stBufInfo.numOfPlanes = NUM_PLANES; iRet = t_v4l2StreamOn(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: output stream on failed", __func__, iRet); return ERROR_EXCUTE_FAIL; } stBufInfo.numOfPlanes = t_iPlaneNum; iRet = t_v4l2Dqbuf(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, V4L2_MEMORY_MMAP); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Intput DQBUF failed", __func__, iRet); return ERROR_EXCUTE_FAIL; } stBufInfo.numOfPlanes = NUM_PLANES; iRet = t_v4l2Dqbuf(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, V4L2_MEMORY_MMAP); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Output DQBUF failed", __func__, iRet); return ERROR_EXCUTE_FAIL; } return ERROR_NONE; }
int ExynosJpegBase::t_v4l2GetCtrl(int iFd, int iCid) { struct v4l2_control ctrl; int iRet = ERROR_NONE; ctrl.id = iCid; iRet = ioctl(iFd, VIDIOC_G_CTRL, &ctrl); if (iRet < 0) { JPEG_ERROR_LOG("[%s] VIDIOC_G_CTRL failed : cid(%d)\n", __func__, ctrl.id); return iRet; } return ctrl.value; }
int ExynosJpegBase::t_v4l2SetJpegcomp(int iFd, int iQuality) { struct v4l2_jpegcompression arg; int iRet = ERROR_NONE; arg.quality = iQuality; iRet = ioctl(iFd, VIDIOC_S_JPEGCOMP, &arg); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: VIDIOC_S_JPEGCOMP failed\n", __func__, iRet); return iRet; } return iRet; }
int SecJpegEncoderHal::getJpegSize(void) { if (t_bFlagCreate == false) { return 0; } int iSize = t_v4l2GetCtrl(t_iJpegFd, V4L2_CID_CAM_JPEG_ENCODEDSIZE); if (iSize < 0) { JPEG_ERROR_LOG("%s::Fail to JPEG output buffer!!\n", __func__); return 0; } return iSize; }
int ExynosJpegBase::t_v4l2SetFmt(int iFd, enum v4l2_buf_type eType, struct CONFIG *pstConfig) { struct v4l2_format fmt; int iRet = ERROR_NONE; fmt.type = eType; fmt.fmt.pix_mp.width = pstConfig->width; fmt.fmt.pix_mp.height = pstConfig->height; fmt.fmt.pix_mp.field = V4L2_FIELD_ANY; fmt.fmt.pix_mp.num_planes = pstConfig->numOfPlanes; if (pstConfig->mode == MODE_ENCODE) fmt.fmt.pix_mp.colorspace = V4L2_COLORSPACE_JPEG; switch (fmt.type) { case V4L2_BUF_TYPE_VIDEO_OUTPUT: // fall through case V4L2_BUF_TYPE_VIDEO_CAPTURE: break; case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: if (pstConfig->mode == MODE_ENCODE) { fmt.fmt.pix_mp.pixelformat = pstConfig->pix.enc_fmt.in_fmt; } else { fmt.fmt.pix_mp.pixelformat = pstConfig->pix.dec_fmt.in_fmt; fmt.fmt.pix_mp.plane_fmt[0].sizeimage = pstConfig->sizeJpeg; } break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: if (pstConfig->mode == MODE_ENCODE) { fmt.fmt.pix_mp.pixelformat = pstConfig->pix.enc_fmt.out_fmt; } else { fmt.fmt.pix_mp.pixelformat = pstConfig->pix.dec_fmt.out_fmt; fmt.fmt.pix_mp.width = pstConfig->scaled_width; fmt.fmt.pix_mp.height = pstConfig->scaled_height; } break; default: return ERROR_INVALID_V4l2_BUF_TYPE; break; } iRet = ioctl(iFd, VIDIOC_S_FMT, &fmt); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: VIDIOC_S_FMT failed\n", __func__, iRet); return iRet; } return iRet; }
int ExynosJpegBase::t_v4l2SetCtrl(int iFd, int iCid, int iValue) { struct v4l2_control vc; int iRet = ERROR_NONE; vc.id = iCid; vc.value = iValue; iRet = ioctl(iFd, VIDIOC_S_CTRL, &vc); if (iRet < 0) { JPEG_ERROR_LOG("[%s] VIDIOC_S_CTRL failed : cid(%d), value(%d)\n", __func__, iCid, iValue); return iRet; } return iRet; }
int ExynosJpegDecoder::getSize(int *piW, int *piH) { if (t_bFlagCreate == false) return ERROR_JPEG_DEVICE_NOT_CREATE_YET; int iRet = t_v4l2GetFmt(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, &t_stJpegConfig); if (iRet < 0) { JPEG_ERROR_LOG("[%s,%d]: get image size failed\n", __func__,iRet); return ERROR_GET_SIZE_FAIL; } *piW = t_stJpegConfig.width; *piH = t_stJpegConfig.height; return ERROR_NONE; }
int ExynosJpegBase::execute(int iInBufPlanes, int iOutBufPlanes) { if (t_bFlagCreate == false) { return ERROR_JPEG_DEVICE_NOT_CREATE_YET; } struct BUF_INFO stBufInfo; int iRet = ERROR_NONE; t_bFlagExcute = true; stBufInfo.numOfPlanes = iInBufPlanes; stBufInfo.buf_type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; stBufInfo.memory = V4L2_MEMORY_DMABUF; iRet = t_v4l2Qbuf(t_iJpegFd, &stBufInfo, &t_stJpegInbuf); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Input QBUF failed\n", __func__, iRet); return ERROR_EXCUTE_FAIL; } stBufInfo.numOfPlanes = iOutBufPlanes; stBufInfo.buf_type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; iRet = t_v4l2Qbuf(t_iJpegFd, &stBufInfo, &t_stJpegOutbuf); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Output QBUF failed\n", __func__, iRet); return ERROR_EXCUTE_FAIL; } iRet = t_v4l2StreamOn(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: input stream on failed\n", __func__, iRet); return ERROR_EXCUTE_FAIL; } iRet = t_v4l2StreamOn(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: output stream on failed\n", __func__, iRet); return ERROR_EXCUTE_FAIL; } iRet = t_v4l2Dqbuf(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE, V4L2_MEMORY_MMAP, iInBufPlanes); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Intput DQBUF failed\n", __func__, iRet); return ERROR_EXCUTE_FAIL; } iRet = t_v4l2Dqbuf(t_iJpegFd, V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE, V4L2_MEMORY_MMAP, iOutBufPlanes); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: Output DQBUF failed\n", __func__, iRet); return ERROR_EXCUTE_FAIL; } return ERROR_NONE; }
int ExynosJpegBase::t_v4l2Reqbufs(int iFd, int iBufCount, struct BUF_INFO *pstBufInfo) { struct v4l2_requestbuffers req; int iRet = ERROR_NONE; memset(&req, 0, sizeof(v4l2_requestbuffers)); req.type = pstBufInfo->buf_type; req.memory = pstBufInfo->memory; //if (pstBufInfo->memory == V4L2_MEMORY_MMAP) req.count = iBufCount; iRet = ioctl(iFd, VIDIOC_REQBUFS, &req); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: VIDIOC_REQBUFS failed\n", __func__, iRet); return iRet; } return iRet; }
int ExynosJpegBase::t_v4l2GetFmt(int iFd, enum v4l2_buf_type eType, struct CONFIG *pstConfig) { struct v4l2_format fmt; int iRet = ERROR_NONE; fmt.type = eType; iRet = ioctl(iFd, VIDIOC_G_FMT, &fmt); if (iRet < 0) { JPEG_ERROR_LOG("[%s:%d]: VIDIOC_G_FMT failed\n", __func__, iRet); return iRet; } switch (fmt.type) { case V4L2_BUF_TYPE_VIDEO_OUTPUT: // fall through case V4L2_BUF_TYPE_VIDEO_CAPTURE: pstConfig->width = fmt.fmt.pix.width; pstConfig->height = fmt.fmt.pix.height; break; case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: pstConfig->width = fmt.fmt.pix_mp.width; pstConfig->height = fmt.fmt.pix_mp.height; if (pstConfig->mode == MODE_ENCODE) pstConfig->pix.enc_fmt.in_fmt = fmt.fmt.pix_mp.pixelformat; else pstConfig->pix.dec_fmt.in_fmt = fmt.fmt.pix_mp.pixelformat; break; case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: pstConfig->width = fmt.fmt.pix_mp.width; pstConfig->height = fmt.fmt.pix_mp.height; if (pstConfig->mode == MODE_ENCODE) pstConfig->pix.enc_fmt.out_fmt = fmt.fmt.pix_mp.pixelformat; else pstConfig->pix.dec_fmt.out_fmt = fmt.fmt.pix_mp.pixelformat; break; default: return ERROR_INVALID_V4l2_BUF_TYPE; } return iRet; }