int exynos_gsc_free_and_close(void *handle) { Exynos_gsc_In(); struct v4l2_requestbuffers reqbuf; struct v4l2_buffer buf; struct v4l2_plane planes[NUM_OF_GSC_PLANES]; int ret = 0; CGscaler* gsc = GetGscaler(handle); if (gsc == NULL) { ALOGE("%s::handle == NULL() fail", __func__); return -1; } #ifdef USES_SCALER if (gsc->gsc_id >= HW_SCAL0) { ret = exynos_sc_free_and_close(gsc->scaler); Exynos_gsc_Out(); return ret; } #endif memset(&reqbuf, 0, sizeof(struct v4l2_requestbuffers)); reqbuf.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; reqbuf.memory = V4L2_MEMORY_DMABUF; reqbuf.count = 0; if (exynos_v4l2_reqbufs(gsc->mdev.gsc_vd_entity->fd, &reqbuf) < 0) { ALOGE("%s::request buffers failed", __func__); return -1; } close(gsc->mdev.gsc_sd_entity->fd); close(gsc->mdev.gsc_vd_entity->fd); gsc->mdev.gsc_sd_entity->fd = -1; gsc->mdev.gsc_vd_entity->fd = -1; exynos_gsc_destroy(gsc); Exynos_gsc_Out(); return 0; }
static bool m_exynos_rotator_set_format( int fd, struct rotator_info *info, bool force) { struct v4l2_requestbuffers req_buf; int plane_count; plane_count = m_rotator_get_plane_count(info->v4l2_colorformat); if (plane_count < 0) { ALOGE("%s::not supported v4l2_colorformat", __func__); return false; } if (force == false) { // format info->format.type = info->buf_type; if (exynos_v4l2_g_fmt(fd, &info->format) < 0) { ALOGE("%s::exynos_v4l2_g_fmt() fail type=%d", __func__, info->buf_type); return false; } if (info->width != info->format.fmt.pix_mp.width || info->height != info->format.fmt.pix_mp.height || info->v4l2_colorformat != info->format.fmt.pix_mp.pixelformat) { ALOGV("%s::info is different..)", __func__); goto set_hw; } // crop if (info->buf_type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { info->crop.type = info->buf_type; if (exynos_v4l2_g_crop(fd, &info->crop) < 0) { ALOGE("%s::exynos_v4l2_g_crop() fail", __func__); return false; } if (info->crop_left != info->crop.c.left || info->crop_top != info->crop.c.top || info->crop_width != info->crop.c.width || info->crop_height != info->crop.c.height) { ALOGV("%s::crop is different..", __func__); goto set_hw; } } // rotation value; int value = 0; if (exynos_v4l2_g_ctrl(fd, V4L2_CID_ROTATE, &value) < 0) { ALOGE("%s::exynos_v4l2_g_ctrl(V4L2_CID_ROTATE) fail"); return false; } if (info->rotation != value) { ALOGV("%s::rotation is different..", __func__); goto set_hw; } // skip s_fmt ALOGV("%s::fmt, crop is same with old-one, so skip s_fmt crop..", __func__); return true; } set_hw: if (info->stream_on == true) { if (exynos_v4l2_streamoff(fd, info->buf_type) < 0) { ALOGE("%s::exynos_v4l2_streamoff() fail", __func__); return false; } info->stream_on = false; } if (exynos_v4l2_s_ctrl(fd, V4L2_CID_ROTATE, info->rotation) < 0) { ALOGE("%s::exynos_v4l2_s_ctrl(V4L2_CID_ROTATE) fail", __func__); return false; } info->format.fmt.pix_mp.width = info->width; info->format.fmt.pix_mp.height = info->height; info->format.fmt.pix_mp.pixelformat = info->v4l2_colorformat; info->format.fmt.pix_mp.field = V4L2_FIELD_ANY; info->format.fmt.pix_mp.num_planes = plane_count; if (exynos_v4l2_s_fmt(fd, &info->format) < 0) { ALOGE("%s::exynos_v4l2_s_fmt() fail", __func__); return false; } if (info->buf_type == V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE) { info->crop.type = info->buf_type; info->crop.c.left = info->crop_left; info->crop.c.top = info->crop_top; info->crop.c.width = info->crop_width; info->crop.c.height = info->crop_height; if (exynos_v4l2_s_crop(fd, &info->crop) < 0) { ALOGE("%s::exynos_v4l2_s_crop() fail", __func__); return false; } } if (exynos_v4l2_s_ctrl(fd, V4L2_CID_CACHEABLE, info->cacheable) < 0) { ALOGE("%s::exynos_v4l2_s_ctrl() fail", __func__); return false; } req_buf.count = 1; req_buf.type = info->buf_type; req_buf.memory = V4L2_MEMORY_USERPTR; if (exynos_v4l2_reqbufs(fd, &req_buf) < 0) { ALOGE("%s::exynos_v4l2_reqbufs() fail", __func__); return false; } return true; }