summaryrefslogtreecommitdiff
authorWei Wang <wei.wang@amlogic.com>2016-03-17 02:04:24 (GMT)
committer Wei Wang <wei.wang@amlogic.com>2016-04-06 08:00:26 (GMT)
commit418cdd63c60f062293fda99e3857893b530c8d57 (patch)
tree1af996d04eda754392cea47b90271bca9b33fca8
parent81f8be29107ff46632483a812fb0dc97e83b208f (diff)
downloadscreen_source-418cdd63c60f062293fda99e3857893b530c8d57.zip
screen_source-418cdd63c60f062293fda99e3857893b530c8d57.tar.gz
screen_source-418cdd63c60f062293fda99e3857893b530c8d57.tar.bz2
pd#121354:support capture video buffer
Change-Id: I10693716394f1dcebdc56f933369d2e26391d7dc
Diffstat
-rw-r--r--aml_screen.cpp25
-rw-r--r--v4l2_vdin.cpp41
-rw-r--r--v4l2_vdin.h4
3 files changed, 65 insertions, 5 deletions
diff --git a/aml_screen.cpp b/aml_screen.cpp
index b35be42..560ff65 100644
--- a/aml_screen.cpp
+++ b/aml_screen.cpp
@@ -126,7 +126,9 @@ int screen_source_set_format(struct aml_screen_device* dev, int width, int heigh
{
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
- if ((width > 0) && (height > 0) && ((pix_format == V4L2_PIX_FMT_NV21) || (pix_format == V4L2_PIX_FMT_YUV420))) {
+ if ((width > 0) && (height > 0) && ((pix_format == V4L2_PIX_FMT_NV21) || (pix_format == V4L2_PIX_FMT_YUV420)
+ || (pix_format == V4L2_PIX_FMT_RGB24)
+ || (pix_format == V4L2_PIX_FMT_RGB565X) )) {
return source->set_format(width, height, pix_format);
} else {
return source->set_format();
@@ -208,6 +210,24 @@ int screen_source_get_source_type(struct aml_screen_device* dev)
return source->get_source_type();
}
+int screen_source_start_v4l2_device(struct aml_screen_device* dev)
+{
+ android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
+ return source->start_v4l2_device();
+}
+
+int screen_source_stop_v4l2_device(struct aml_screen_device* dev)
+{
+ android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
+ return source->stop_v4l2_device();
+}
+
+int screen_source_set_port_type(struct aml_screen_device* dev,int sourceType)
+{
+ android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
+ return source->set_port_type(sourceType);
+}
+
/* int screen_source_inc_buffer_refcount(struct aml_screen_device* dev, int* ptr)
{
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
@@ -279,6 +299,9 @@ static int aml_screen_device_open(const struct hw_module_t* module, const char*
dev->ops.set_source_type = screen_source_set_source_type;
dev->ops.get_source_type = screen_source_get_source_type;
// dev->ops.inc_buffer_refcount = screen_source_inc_buffer_refcount;
+ dev->ops.start_v4l2_device = screen_source_start_v4l2_device;
+ dev->ops.stop_v4l2_device = screen_source_stop_v4l2_device;
+ dev->ops.set_port_type = screen_source_set_port_type;
*device = &dev->common;
status = 0;
gAmlScreenOpen++;
diff --git a/v4l2_vdin.cpp b/v4l2_vdin.cpp
index f42e2cc..772154c 100644
--- a/v4l2_vdin.cpp
+++ b/v4l2_vdin.cpp
@@ -227,6 +227,23 @@ int vdin_screen_source::start_v4l2_device()
return ret;
}
+int vdin_screen_source::stop_v4l2_device()
+{
+ ALOGE("%s %d", __FUNCTION__, __LINE__);
+ int ret;
+ enum v4l2_buf_type bufType = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+ ret = ioctl (mCameraHandle, VIDIOC_STREAMOFF, &bufType);
+ if (ret < 0) {
+ ALOGE("StopStreaming: Unable to stop capture: %s", strerror(errno));
+ }
+ for (int i = 0; i < mBufferCount; i++) {
+ if (munmap(mVideoInfo->mem[i], mVideoInfo->buf.length) < 0) {
+ ALOGE("Unmap failed");
+ }
+ }
+ return ret;
+}
int vdin_screen_source::start()
{
ALOGV("%s %d", __FUNCTION__, __LINE__);
@@ -270,7 +287,7 @@ int vdin_screen_source::pause()
}
int vdin_screen_source::stop()
{
- ALOGV("%s %d", __FUNCTION__, __LINE__);
+ ALOGE("!!!!!!!!!%s %d", __FUNCTION__, __LINE__);
int ret;
mState = STOPING;
@@ -473,6 +490,18 @@ int vdin_screen_source::set_source_type(int sourceType)
return ret;
}
+int vdin_screen_source::set_port_type(int sourceType)
+ {
+ ALOGD("[%s %d]", __FUNCTION__, __LINE__);
+ int ret = 0;
+ unsigned int portType = (unsigned int)sourceType;
+ ALOGE("portType:%d",portType);
+ ret = ioctl(mCameraHandle, VIDIOC_S_INPUT, &portType);
+ if (ret < 0) {
+ ALOGE("Set port type fail: %s. ret:%d", strerror(errno),ret);
+ }
+ return ret;
+ }
int vdin_screen_source::get_source_type()
{
ALOGV("[%s %d]", __FUNCTION__, __LINE__);
@@ -489,7 +518,7 @@ int vdin_screen_source::get_source_type()
int vdin_screen_source::aquire_buffer(aml_screen_buffer_info_t *buff_info)
{
- ALOGV("%s %d", __FUNCTION__, __LINE__);
+ ALOGE("%s %d", __FUNCTION__, __LINE__);
int ret = -1;
mVideoInfo->buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
mVideoInfo->buf.memory = V4L2_MEMORY_MMAP;
@@ -503,8 +532,14 @@ int vdin_screen_source::aquire_buffer(aml_screen_buffer_info_t *buff_info)
}
buff_info->buffer_mem = 0;
buff_info->buffer_canvas = 0;
- return ret;
+ ALOGE("aquire_buffer %d %d", ret ,__LINE__);
+ return ret;
}
+
+ if (!(mFrameType & NATIVE_WINDOW_DATA || mFrameType & CALL_BACK_DATA))
+ mVideoInfo->refcount[mVideoInfo->buf.index] += 1;
+
+ ALOGE("%s finish %d ", __FUNCTION__, __LINE__);
buff_info->buffer_mem = mVideoInfo->mem[mVideoInfo->buf.index];
buff_info->buffer_canvas = mVideoInfo->canvas[mVideoInfo->buf.index];
buff_info->tv_sec = mVideoInfo->buf.timestamp.tv_sec;
diff --git a/v4l2_vdin.h b/v4l2_vdin.h
index 1a01955..9794078 100644
--- a/v4l2_vdin.h
+++ b/v4l2_vdin.h
@@ -97,9 +97,11 @@ class vdin_screen_source {
int set_frame_rate(int frameRate);
int set_source_type(int sourceType);
int get_source_type();
+ int start_v4l2_device();
+ int stop_v4l2_device();
+ int set_port_type(int sourceType);
private:
int init_native_window();
- int start_v4l2_device();
int workThread();
private:
class WorkThread : public Thread {