summaryrefslogtreecommitdiff
authorJunliang Zhou <junliang.zhou@amlogic.com>2015-08-05 08:18:40 (GMT)
committer junliang.zhou <junliang.zhou@amlogic.com>2015-08-10 08:47:18 (GMT)
commit7f391a443597f078d7614e0aa9472481c90b2611 (patch)
tree2c92395710390a39652860051eee72cee17b711f
parent5c1b3d432baeabc6df04e89cd2554ea30d57441c (diff)
downloadscreen_source-7f391a443597f078d7614e0aa9472481c90b2611.zip
screen_source-7f391a443597f078d7614e0aa9472481c90b2611.tar.gz
screen_source-7f391a443597f078d7614e0aa9472481c90b2611.tar.bz2
PD#110605 add screencatch for l-amlogic
Change-Id: I1a1f7670e6e764e37ceb71e02c5d5c59d13e3b5a
Diffstat
-rw-r--r--aml_screen.cpp50
-rwxr-xr-xtest/Android.mk16
-rwxr-xr-xtest/screen_source_test.cpp91
-rw-r--r--v4l2_vdin.cpp39
-rw-r--r--v4l2_vdin.h1
5 files changed, 62 insertions, 135 deletions
diff --git a/aml_screen.cpp b/aml_screen.cpp
index 5baee05..640389e 100644
--- a/aml_screen.cpp
+++ b/aml_screen.cpp
@@ -55,7 +55,6 @@
static unsigned int gAmlScreenOpen = 0;
static android::Mutex gAmlScreenLock;
-
/*****************************************************************************/
static int aml_screen_device_open(const struct hw_module_t* module, const char* name,
@@ -104,11 +103,13 @@ int screen_source_start(struct aml_screen_device* dev)
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
return source->start();
}
+
int screen_source_stop(struct aml_screen_device* dev)
{
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
return source->stop();
}
+
int screen_source_pause(struct aml_screen_device* dev)
{
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
@@ -120,16 +121,14 @@ int screen_source_get_format(struct aml_screen_device* dev)
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
return source->get_format();
}
+
int screen_source_set_format(struct aml_screen_device* dev, int width, int height, int pix_format)
{
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))) {
return source->set_format(width, height, pix_format);
- }
- else
- {
+ } else {
return source->set_format();
}
}
@@ -150,6 +149,16 @@ int screen_source_set_crop(struct aml_screen_device* dev, int x, int y, int widt
return android::BAD_VALUE;
}
+int screen_source_set_amlvideo2_crop(struct aml_screen_device* dev, int x, int y, int width, int height)
+{
+ android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
+
+ if ((x >= 0) && (y >= 0) && (width > 0) && (height > 0))
+ return source->set_amlvideo2_crop(x, y, width, height);
+
+ return android::BAD_VALUE;
+}
+
int screen_source_aquire_buffer(struct aml_screen_device* dev, aml_screen_buffer_info_t* buff_info)
{
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
@@ -162,16 +171,19 @@ int screen_source_release_buffer(struct aml_screen_device* dev, void* ptr)
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
return source->release_buffer(ptr);
}
+
int screen_source_set_state_callback(struct aml_screen_device* dev, olStateCB callback)
{
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
return source->set_state_callback(callback);
}
+
int screen_source_set_preview_window(struct aml_screen_device* dev, ANativeWindow* window)
{
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
return source->set_preview_window(window);
}
+
int screen_source_set_data_callback(struct aml_screen_device* dev, app_data_callback callback, void* user)
{
android::vdin_screen_source* source = (android::vdin_screen_source*)dev->priv;
@@ -202,7 +214,6 @@ int screen_source_get_source_type(struct aml_screen_device* dev)
return source->inc_buffer_refcount(ptr);
} */
-
/*****************************************************************************/
static int aml_screen_device_open(const struct hw_module_t* module, const char* name,
@@ -211,46 +222,46 @@ static int aml_screen_device_open(const struct hw_module_t* module, const char*
int status = -EINVAL;
android::vdin_screen_source* source = NULL;
android::Mutex::Autolock lock(gAmlScreenLock);
-
+
LOGV("aml_screen_device_open");
-
+
if (!strcmp(name, AML_SCREEN_SOURCE)) {
if(gAmlScreenOpen > 1){
ALOGD("aml screen device already open");
*device = NULL;
return -EINVAL;
}
-
+
aml_screen_device_t *dev = (aml_screen_device_t*)malloc(sizeof(aml_screen_device_t));
-
- if (!dev){
+
+ if (!dev) {
LOGE("no memory for the screen source device");
return -ENOMEM;
}
/* initialize handle here */
memset(dev, 0, sizeof(*dev));
-
+
source = new android::vdin_screen_source;
- if (!source){
+ if (!source) {
LOGE("no memory for class of vdin_screen_source");
free (dev);
return -ENOMEM;
}
- if(source->init()!=0){
+ if (source->init()!= 0) {
LOGE("open vdin_screen_source failed!");
- free (dev);
+ free (dev);
return -1;
}
dev->priv = (void*)source;
-
+
/* initialize the procs */
dev->common.tag = HARDWARE_DEVICE_TAG;
dev->common.version = 0;
dev->common.module = const_cast<hw_module_t*>(module);
dev->common.close = aml_screen_device_close;
-
+
dev->ops.start = screen_source_start;
dev->ops.stop = screen_source_stop;
dev->ops.pause = screen_source_pause;
@@ -258,6 +269,7 @@ static int aml_screen_device_open(const struct hw_module_t* module, const char*
dev->ops.set_format = screen_source_set_format;
dev->ops.set_rotation = screen_source_set_rotation;
dev->ops.set_crop = screen_source_set_crop;
+ dev->ops.set_amlvideo2_crop = screen_source_set_amlvideo2_crop;
dev->ops.aquire_buffer = screen_source_aquire_buffer;
dev->ops.release_buffer = screen_source_release_buffer;
dev->ops.setStateCallBack = screen_source_set_state_callback;
diff --git a/test/Android.mk b/test/Android.mk
deleted file mode 100755
index a17fdd5..0000000
--- a/test/Android.mk
+++ b/dev/null
@@ -1,16 +0,0 @@
-# Build the unit tests.
-LOCAL_PATH:= $(call my-dir)
-include $(CLEAR_VARS)
-
-LOCAL_MODULE := screen_source_test
-
-LOCAL_MODULE_TAGS := tests
-
-LOCAL_SRC_FILES := screen_source_test.cpp
-
-LOCAL_SHARED_LIBRARIES := libutils\
- libhardware
-
-#LOCAL_C_INCLUDES :=
-
-include $(BUILD_EXECUTABLE) \ No newline at end of file
diff --git a/test/screen_source_test.cpp b/test/screen_source_test.cpp
deleted file mode 100755
index fa38337..0000000
--- a/test/screen_source_test.cpp
+++ b/dev/null
@@ -1,91 +0,0 @@
-/*
- * Copyright (C) 2013 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#define LOG_NDEBUG 0
-#define LOG_TAG "screen_source_test"
-#include <hardware/hardware.h>
-#include <hardware/aml_screen.h>
-
-#include <errno.h>
-#include <cutils/log.h>
-#include <cutils/atomic.h>
-
-#include <stdio.h>
-#include <assert.h>
-#include <limits.h>
-#include <unistd.h>
-#include <fcntl.h>
-#include <sched.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-
-
-#ifndef LOGD
-#define LOGD ALOGD
-#endif
-#ifndef LOGV
-#define LOGV ALOGV
-#endif
-#ifndef LOGE
-#define LOGE ALOGE
-#endif
-#ifndef LOGI
-#define LOGI ALOGI
-#endif
-/*****************************************************************************/
-int main(int argc, char **argv) {
- aml_screen_module_t* mModule;
- aml_screen_device_t* mDev;
- int ret = 0;
- int dumpfd;
- char * pSrcBufffer;
- int i = 100;
-
- if (hw_get_module(AML_SCREEN_HARDWARE_MODULE_ID,
- (const hw_module_t **)&mModule) < 0)
- {
- LOGE("can not get screen source module");
- ret = -1;
- }
- else
- {
- LOGV("succeed to get screen source module");
- mModule->common.methods->open((const hw_module_t *)mModule,
- AML_SCREEN_SOURCE, (struct hw_device_t**)&mDev);
- //do test here, we can use ops of mDev to operate vdin source
- }
-
- mDev->ops.start(mDev);
-
- dumpfd = open("/tmp/yuvsource", O_CREAT | O_RDWR | O_TRUNC, 0644);
- LOGV("dumpfd:%d\n");
-
- while(i--)
- {
- pSrcBufffer = mDev->ops.aquire_buffer(mDev);
-
- write(dumpfd, pSrcBufffer, 640*480*3/2);
-
- //usleep(100000);
- LOGV("release_buffer %x pSrcBufffer:%x", mDev->ops.release_buffer, pSrcBufffer);
- mDev->ops.release_buffer(mDev);
- }
-
- mDev->ops.stop(mDev);
-
- return ret;
-}
-/*****************************************************************************/
diff --git a/v4l2_vdin.cpp b/v4l2_vdin.cpp
index 9e2283f..fbbe6e2 100644
--- a/v4l2_vdin.cpp
+++ b/v4l2_vdin.cpp
@@ -423,23 +423,44 @@ int vdin_screen_source::set_frame_rate(int frameRate)
ALOGV("[%s %d]", __FUNCTION__, __LINE__);
int ret = 0;
struct v4l2_control ctl;
-
+
if(mCameraHandle<0)
return -1;
-
- struct v4l2_streamparm sparm;
- memset(&sparm, 0, sizeof( sparm ));
- sparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;//stream_flag;
- sparm.parm.output.timeperframe.denominator = frameRate;
- sparm.parm.output.timeperframe.numerator = 1;
-
- ret = ioctl(mCameraHandle, VIDIOC_S_PARM, &sparm);
+
+ struct v4l2_streamparm sparm;
+ memset(&sparm, 0, sizeof( sparm ));
+ sparm.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;//stream_flag;
+ sparm.parm.output.timeperframe.denominator = frameRate;
+ sparm.parm.output.timeperframe.numerator = 1;
+
+ ret = ioctl(mCameraHandle, VIDIOC_S_PARM, &sparm);
if(ret < 0){
ALOGE("Set frame rate fail: %s. ret=%d", strerror(errno),ret);
}
return ret ;
}
+int vdin_screen_source::set_amlvideo2_crop(int x, int y, int width, int height)
+{
+ ALOGV("[%s %d]", __FUNCTION__, __LINE__);
+ int ret = 0;
+
+ struct v4l2_crop crop;
+ memset(&crop, 0, sizeof(struct v4l2_crop));
+
+ crop.type = V4L2_BUF_TYPE_VIDEO_OVERLAY;
+ crop.c.left = x;
+ crop.c.top = y;
+ crop.c.width = width;
+ crop.c.height = height;
+ ret = ioctl(mCameraHandle, VIDIOC_S_CROP, &crop);
+ if (ret) {
+ ALOGE("Set frame rate fail: %s. ret=%d", strerror(errno),ret);
+ }
+
+ return ret ;
+}
+
int vdin_screen_source::set_source_type(int sourceType)
{
ALOGV("[%s %d]", __FUNCTION__, __LINE__);
diff --git a/v4l2_vdin.h b/v4l2_vdin.h
index 0db756e..e299d8e 100644
--- a/v4l2_vdin.h
+++ b/v4l2_vdin.h
@@ -87,6 +87,7 @@ class vdin_screen_source {
int set_format(int width = 640, int height = 480, int color_format = V4L2_PIX_FMT_NV21);
int set_rotation(int degree);
int set_crop(int x, int y, int width, int height);
+ int set_amlvideo2_crop(int x, int y, int width, int height);
int aquire_buffer(aml_screen_buffer_info_t *buff_info);
// int inc_buffer_refcount(int* ptr);
int release_buffer(void* ptr);