author | jiyu.yang <jiyu.yang@amlogic.com> | 2014-11-28 07:12:47 (GMT) |
---|---|---|
committer | jiyu.yang <jiyu.yang@amlogic.com> | 2014-11-28 07:14:02 (GMT) |
commit | 4eea29c30bd122628397d0ea6a97b0cc874d7361 (patch) | |
tree | 22a0a574c1bac22291402fef739751f1350963a0 | |
parent | 09763434a3e2aa2e13a73f6cc2c747075207d9df (diff) | |
download | camera-4eea29c30bd122628397d0ea6a97b0cc874d7361.zip camera-4eea29c30bd122628397d0ea6a97b0cc874d7361.tar.gz camera-4eea29c30bd122628397d0ea6a97b0cc874d7361.tar.bz2 |
multi stream
Change-Id: I70a3f0b713e67611cfaaf1e4ab53e39aba5d92ff
-rwxr-xr-x | v3/Android.mk | 1 | ||||
-rwxr-xr-x | v3/EmulatedFakeCamera3.cpp | 24 | ||||
-rwxr-xr-x | v3/fake-pipeline2/Base.h | 1 | ||||
-rwxr-xr-x | v3/fake-pipeline2/Sensor.cpp | 114 | ||||
-rwxr-xr-x | v3/fake-pipeline2/Sensor.h | 21 | ||||
-rwxr-xr-x | v3/fake-pipeline2/camera_hw.cpp | 27 | ||||
-rwxr-xr-x | v3/fake-pipeline2/camera_hw.h | 9 | ||||
-rwxr-xr-x | v3/fake-pipeline2/ge2d.h | 559 | ||||
-rwxr-xr-x | v3/fake-pipeline2/ge2d_main.h | 62 | ||||
-rwxr-xr-x | v3/fake-pipeline2/ge2d_stream.cpp | 207 | ||||
-rw-r--r-- | v3/fake-pipeline2/ge2d_stream.h | 27 | ||||
-rwxr-xr-x | v3/fake-pipeline2/ge2d_wq.h | 310 |
12 files changed, 1316 insertions, 46 deletions
diff --git a/v3/Android.mk b/v3/Android.mk index 5fd8344..e10495f 100755 --- a/v3/Android.mk +++ b/v3/Android.mk @@ -94,6 +94,7 @@ LOCAL_SRC_FILES := \ JpegCompressor.cpp \ fake-pipeline2/Scene.cpp \ fake-pipeline2/Sensor.cpp \ + fake-pipeline2/ge2d_stream.cpp \ fake-pipeline2/JpegCompressor.cpp \ fake-pipeline2/NV12_resize.c\ EmulatedCamera3.cpp \ diff --git a/v3/EmulatedFakeCamera3.cpp b/v3/EmulatedFakeCamera3.cpp index 03c0403..0d6fedd 100755 --- a/v3/EmulatedFakeCamera3.cpp +++ b/v3/EmulatedFakeCamera3.cpp @@ -509,26 +509,9 @@ status_t EmulatedFakeCamera3::configureStreams( privStream->alive = true; privStream->registered = false; - switch (newStream->stream_type) { - case CAMERA3_STREAM_OUTPUT: - if (newStream->usage & GRALLOC_USAGE_HW_VIDEO_ENCODER) { - newStream->usage = (GRALLOC_USAGE_HW_TEXTURE - | GRALLOC_USAGE_HW_RENDER - | GRALLOC_USAGE_SW_READ_RARELY - | GRALLOC_USAGE_SW_WRITE_NEVER - | GRALLOC_USAGE_HW_CAMERA_WRITE); - } else { - newStream->usage = GRALLOC_USAGE_HW_CAMERA_WRITE; - } - break; - case CAMERA3_STREAM_INPUT: - newStream->usage = GRALLOC_USAGE_HW_CAMERA_READ; - break; - case CAMERA3_STREAM_BIDIRECTIONAL: - newStream->usage = GRALLOC_USAGE_HW_CAMERA_READ | - GRALLOC_USAGE_HW_CAMERA_WRITE; - break; - } + newStream->usage = + mSensor->getStreamUsage(newStream->stream_type); + DBG_LOGB("stream_type=%d\n", newStream->stream_type); newStream->max_buffers = kMaxBufferCount; newStream->priv = privStream; @@ -1187,6 +1170,7 @@ status_t EmulatedFakeCamera3::processCaptureRequest( destBuf.format = privBuffer->format; // Use real private format destBuf.stride = srcBuf.stream->width; // TODO: query from gralloc destBuf.buffer = srcBuf.buffer; + destBuf.share_fd = privBuffer->share_fd; //ALOGI("%s, i:%d format for this usage: %d x %d, usage %x, format=%x, returned\n", // __FUNCTION__, i, destBuf.width, destBuf.height, privBuffer->usage, privBuffer->format); diff --git a/v3/fake-pipeline2/Base.h b/v3/fake-pipeline2/Base.h index f17c336..1f27ca6 100755 --- a/v3/fake-pipeline2/Base.h +++ b/v3/fake-pipeline2/Base.h @@ -40,6 +40,7 @@ struct StreamBuffer { uint32_t stride; buffer_handle_t *buffer; uint8_t *img; + int share_fd; }; typedef Vector<StreamBuffer> Buffers; diff --git a/v3/fake-pipeline2/Sensor.cpp b/v3/fake-pipeline2/Sensor.cpp index 9090c26..3c37494 100755 --- a/v3/fake-pipeline2/Sensor.cpp +++ b/v3/fake-pipeline2/Sensor.cpp @@ -31,10 +31,12 @@ #include "Sensor.h" #include <cmath> #include <cstdlib> +#include <hardware/camera3.h> #include "system/camera_metadata.h" #include "libyuv.h" #include "NV12_resize.h" #include "libyuv/scale.h" +#include "ge2d_stream.h" #define ARRAY_SIZE(x) (sizeof((x))/sizeof(((x)[0]))) @@ -160,8 +162,41 @@ status_t Sensor::startUp(int idx) { ALOGE("Unable to open sensor %d, errno=%d\n", vinfo->idx, res); } + mSensorType = SENSOR_MMAP; + if (strstr((const char *)vinfo->cap.driver, "uvcvideo")) { + mSensorType = SENSOR_USB; + } + + if (strstr((const char *)vinfo->cap.card, "share_fd")) { + mSensorType = SENSOR_SHARE_FD; + } + return res; } +uint32_t Sensor::getStreamUsage(int stream_type) +{ + uint32_t usage = GRALLOC_USAGE_HW_CAMERA_WRITE; + + switch (stream_type) { + case CAMERA3_STREAM_OUTPUT: + usage = GRALLOC_USAGE_HW_CAMERA_WRITE; + break; + case CAMERA3_STREAM_INPUT: + usage = GRALLOC_USAGE_HW_CAMERA_READ; + break; + case CAMERA3_STREAM_BIDIRECTIONAL: + usage = GRALLOC_USAGE_HW_CAMERA_READ | + GRALLOC_USAGE_HW_CAMERA_WRITE; + break; + } + if ((mSensorType == SENSOR_MMAP) + || (mSensorType == SENSOR_USB)) { + usage = (GRALLOC_USAGE_HW_TEXTURE + | GRALLOC_USAGE_HW_RENDER); + } + + return usage; +} status_t Sensor::setOutputFormat(int width, int height, int pixelformat) { @@ -908,16 +943,71 @@ bool Sensor::threadLoop() { mNextCapturedBuffers = nextBuffers; if (mNextCapturedBuffers != NULL) { - mKernelBuffer = NULL; if (listener != NULL) { listener->onSensorEvent(frameNumber, SensorListener::EXPOSURE_START, mNextCaptureTime); } + ALOGVV("Starting next capture: Exposure: %f ms, gain: %d", (float)exposureDuration/1e6, gain); mScene.setExposureDuration((float)exposureDuration/1e9); mScene.calculateScene(mNextCaptureTime); + if ( mSensorType == SENSOR_SHARE_FD) { + captureNewImageWithGe2d(); + } else { + captureNewImage(); + } + ////// + } + ALOGVV("Sensor vertical blanking interval"); + nsecs_t workDoneRealTime = systemTime(); + const nsecs_t timeAccuracy = 2e6; // 2 ms of imprecision is ok + if (workDoneRealTime < frameEndRealTime - timeAccuracy) { + timespec t; + t.tv_sec = (frameEndRealTime - workDoneRealTime) / 1000000000L; + t.tv_nsec = (frameEndRealTime - workDoneRealTime) % 1000000000L; + + int ret; + do { + ret = nanosleep(&t, &t); + } while (ret != 0); + } + nsecs_t endRealTime = systemTime(); + ALOGVV("Frame cycle took %d ms, target %d ms", + (int)((endRealTime - startRealTime)/1000000), + (int)(frameDuration / 1000000)); + return true; +}; + +int Sensor::captureNewImageWithGe2d() { + + uint32_t gain = mGainFactor; + mKernelPhysAddr = 0; + + + while (mKernelPhysAddr == 0) { + mKernelPhysAddr = get_frame_phys(vinfo); + usleep(5000); + } + + // Might be adding more buffers, so size isn't constant + for (size_t i = 0; i < mNextCapturedBuffers->size(); i++) { + const StreamBuffer &b = (*mNextCapturedBuffers)[i]; + fillStream(vinfo, mKernelPhysAddr, b); + } + putback_frame(vinfo); + mKernelPhysAddr = 0; + + return 0; + +} + +int Sensor::captureNewImage() { + + uint32_t gain = mGainFactor; + mKernelBuffer = NULL; + // Might be adding more buffers, so size isn't constant for (size_t i = 0; i < mNextCapturedBuffers->size(); i++) { const StreamBuffer &b = (*mNextCapturedBuffers)[i]; @@ -979,27 +1069,9 @@ bool Sensor::threadLoop() { } putback_frame(vinfo); mKernelBuffer = NULL; - } - - ALOGVV("Sensor vertical blanking interval"); - nsecs_t workDoneRealTime = systemTime(); - const nsecs_t timeAccuracy = 2e6; // 2 ms of imprecision is ok - if (workDoneRealTime < frameEndRealTime - timeAccuracy) { - timespec t; - t.tv_sec = (frameEndRealTime - workDoneRealTime) / 1000000000L; - t.tv_nsec = (frameEndRealTime - workDoneRealTime) % 1000000000L; - int ret; - do { - ret = nanosleep(&t, &t); - } while (ret != 0); - } - nsecs_t endRealTime = systemTime(); - ALOGVV("Frame cycle took %d ms, target %d ms", - (int)((endRealTime - startRealTime)/1000000), - (int)(frameDuration / 1000000)); - return true; -}; + return 0; +} int Sensor::getStreamConfigurations(uint32_t picSizes[], const int32_t kAvailableFormats[], int size) { int res; diff --git a/v3/fake-pipeline2/Sensor.h b/v3/fake-pipeline2/Sensor.h index 2c7e0ad..2c4be1a 100755 --- a/v3/fake-pipeline2/Sensor.h +++ b/v3/fake-pipeline2/Sensor.h @@ -81,7 +81,7 @@ #include <utils/String8.h> #include "Scene.h" -#include "Base.h" +//#include "Base.h" #include "camera_hw.h" #include <cstdlib> @@ -149,7 +149,6 @@ typedef enum camera_focus_mode_e { CAM_FOCUS_MODE_CONTI_PIC, }camera_focus_mode_t; - class Sensor: private Thread, public virtual RefBase { public: @@ -168,6 +167,7 @@ class Sensor: private Thread, public virtual RefBase { status_t setOutputFormat(int width, int height, int pixelformat); void setPictureRotate(int rotate); int getPictureRotate(); + uint32_t getStreamUsage(int stream_type); status_t streamOn(); status_t streamOff(); @@ -291,6 +291,7 @@ class Sensor: private Thread, public virtual RefBase { uint32_t mGainFactor; Buffers *mNextBuffers; uint8_t *mKernelBuffer; + uintptr_t mKernelPhysAddr; uint32_t mFrameNumber; int mRotateValue; @@ -312,6 +313,20 @@ class Sensor: private Thread, public virtual RefBase { //store the v4l2 info struct VideoInfo *vinfo; + + + typedef enum sensor_type_e{ + SENSOR_MMAP = 0, + SENSOR_ION, + SENSOR_ION_MPLANE, + SENSOR_DMA, + SENSOR_CANVAS_MODE, + SENSOR_USB, + SENSOR_SHARE_FD, + }sensor_type_t; + + enum sensor_type_e mSensorType; + /** * Inherited Thread virtual overrides, and members only used by the * processing thread @@ -326,6 +341,8 @@ class Sensor: private Thread, public virtual RefBase { Scene mScene; + int captureNewImageWithGe2d(); + int captureNewImage(); void captureRaw(uint8_t *img, uint32_t gain, uint32_t stride); void captureRGBA(uint8_t *img, uint32_t gain, uint32_t stride); void captureRGB(uint8_t *img, uint32_t gain, uint32_t stride); diff --git a/v3/fake-pipeline2/camera_hw.cpp b/v3/fake-pipeline2/camera_hw.cpp index 5d9dd38..68f4ee9 100755 --- a/v3/fake-pipeline2/camera_hw.cpp +++ b/v3/fake-pipeline2/camera_hw.cpp @@ -182,6 +182,33 @@ int stop_capturing(struct VideoInfo *vinfo) return res; } +uintptr_t get_frame_phys(struct VideoInfo *vinfo) +{ + CLEAR(vinfo->preview.buf); + + vinfo->preview.buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + vinfo->preview.buf.memory = V4L2_MEMORY_MMAP; + + if (-1 == ioctl(vinfo->fd, VIDIOC_DQBUF, &vinfo->preview.buf)) { + switch (errno) { + case EAGAIN: + return 0; + + case EIO: + /* Could ignore EIO, see spec. */ + + /* fall through */ + + default: + DBG_LOGB("VIDIOC_DQBUF failed, errno=%d\n", errno); + exit(1); + } + DBG_LOGB("VIDIOC_DQBUF failed, errno=%d\n", errno); + } + + return (uintptr_t)vinfo->preview.buf.m.userptr; +} + void *get_frame(struct VideoInfo *vinfo) { CLEAR(vinfo->preview.buf); diff --git a/v3/fake-pipeline2/camera_hw.h b/v3/fake-pipeline2/camera_hw.h index fe8dee8..f4cb349 100755 --- a/v3/fake-pipeline2/camera_hw.h +++ b/v3/fake-pipeline2/camera_hw.h @@ -1,5 +1,5 @@ -//#ifndef __CAMERA_HW__ -//#define __CAMERA_HW__ +#ifndef __HW_CAMERA_HW_H__ +#define __HW_CAMERA_HW_H__ #include <linux/videodev2.h> #include <stdio.h> @@ -61,7 +61,10 @@ extern int start_capturing(struct VideoInfo *vinfo); extern int start_picture(struct VideoInfo *vinfo,int rotate); extern void stop_picture(struct VideoInfo *vinfo); extern int stop_capturing(struct VideoInfo *vinfo); + +extern uintptr_t get_frame_phys(struct VideoInfo *vinfo); + extern void *get_frame(struct VideoInfo *vinfo); extern void *get_picture(struct VideoInfo *vinfo); extern int putback_frame(struct VideoInfo *vinfo); -//#endif +#endif diff --git a/v3/fake-pipeline2/ge2d.h b/v3/fake-pipeline2/ge2d.h new file mode 100755 index 0000000..bd74d02 --- a/dev/null +++ b/v3/fake-pipeline2/ge2d.h @@ -0,0 +1,559 @@ +#ifndef _GE2D_H_ +#define _GE2D_H_ +#ifdef __KERNEL__ +#include <mach/am_regs.h> +#include <linux/module.h> +#endif +#define AVMem_kmalloc(x) kmalloc(x,GFP_KERNEL) +#define AVMem_calloc(a,b) kcalloc(a,b,GFP_KERNEL) +#define AVMem_free kfree + + +#define MAX_BITBLT_WORK_CONFIG 4 +#define MAX_GE2D_CMD 32 //64 + +#define GE2D_STATE_IDLE 0 +#define GE2D_STATE_RUNNING 1 +#define GE2D_STATE_CLEANUP 2 +#define GE2D_STATE_REMOVING_WQ 3 +#define GE2D_PROCESS_QUEUE_START 0 +#define GE2D_PROCESS_QUEUE_STOP 1 + +#define RELEASE_SRC1_CANVAS 0x01 +#define RELEASE_SRC2_CANVAS 0x02 +#define RELEASE_SRC1_BUFFER 0x04 +#define RELEASE_SRC2_BUFFER 0x08 +#define RELEASE_CB 0x10 +#define RELEASE_REQUIRED 0x1f + +#define START_FLAG 0x20 +#define RELEASE_FLAG 0x40 +#define FINISH_FLAG 0x80 + +#define FORMAT_8BIT_COMPONENT 0 + #define COMPONENT_Y_OR_R 0 + #define COMPONENT_Cb_OR_G 1 + #define COMPONENT_Cr_OR_B 2 + #define COMPONENT_ALPHA 3 +#define FORMAT_422_YUV 1 +#define FORMAT_444_YUV_OR_RGB 2 +#define FORMAT_YUVA_OR_RGBA 3 + +#define FILL_MODE_BOUNDARY_PIXEL 0 +#define FILL_MODE_DEFAULT_COLOR 1 + +#define OPERATION_ADD 0 //Cd = Cs*Fs+Cd*Fd +#define OPERATION_SUB 1 //Cd = Cs*Fs-Cd*Fd +#define OPERATION_REVERSE_SUB 2 //Cd = Cd*Fd-Cs*Fs +#define OPERATION_MIN 3 //Cd = Min(Cd*Fd,Cs*Fs) +#define OPERATION_MAX 4 //Cd = Max(Cd*Fd,Cs*Fs) +#define OPERATION_LOGIC 5 + +#define COLOR_FACTOR_ZERO 0 +#define COLOR_FACTOR_ONE 1 +#define COLOR_FACTOR_SRC_COLOR 2 +#define COLOR_FACTOR_ONE_MINUS_SRC_COLOR 3 +#define COLOR_FACTOR_DST_COLOR 4 +#define COLOR_FACTOR_ONE_MINUS_DST_COLOR 5 +#define COLOR_FACTOR_SRC_ALPHA 6 +#define COLOR_FACTOR_ONE_MINUS_SRC_ALPHA 7 +#define COLOR_FACTOR_DST_ALPHA 8 +#define COLOR_FACTOR_ONE_MINUS_DST_ALPHA 9 +#define COLOR_FACTOR_CONST_COLOR 10 +#define COLOR_FACTOR_ONE_MINUS_CONST_COLOR 11 +#define COLOR_FACTOR_CONST_ALPHA 12 +#define COLOR_FACTOR_ONE_MINUS_CONST_ALPHA 13 +#define COLOR_FACTOR_SRC_ALPHA_SATURATE 14 + +#define ALPHA_FACTOR_ZERO 0 +#define ALPHA_FACTOR_ONE 1 +#define ALPHA_FACTOR_SRC_ALPHA 2 +#define ALPHA_FACTOR_ONE_MINUS_SRC_ALPHA 3 +#define ALPHA_FACTOR_DST_ALPHA 4 +#define ALPHA_FACTOR_ONE_MINUS_DST_ALPHA 5 +#define ALPHA_FACTOR_CONST_ALPHA 6 +#define ALPHA_FACTOR_ONE_MINUS_CONST_ALPHA 7 + +#define LOGIC_OPERATION_CLEAR 0 +#define LOGIC_OPERATION_COPY 1 +#define LOGIC_OPERATION_NOOP 2 +#define LOGIC_OPERATION_SET 3 +#define LOGIC_OPERATION_COPY_INVERT 4 +#define LOGIC_OPERATION_INVERT 5 +#define LOGIC_OPERATION_AND_REVERSE 6 +#define LOGIC_OPERATION_OR_REVERSE 7 +#define LOGIC_OPERATION_AND 8 +#define LOGIC_OPERATION_OR 9 +#define LOGIC_OPERATION_NAND 10 +#define LOGIC_OPERATION_NOR 11 +#define LOGIC_OPERATION_XOR 12 +#define LOGIC_OPERATION_EQUIV 13 +#define LOGIC_OPERATION_AND_INVERT 14 +#define LOGIC_OPERATION_OR_INVERT 15 + +#define DST_CLIP_MODE_INSIDE 0 +#define DST_CLIP_MODE_OUTSIDE 1 + +#define FILTER_TYPE_BICUBIC 1 +#define FILTER_TYPE_BILINEAR 2 +#define FILTER_TYPE_TRIANGLE 3 + +#define MATRIX_YCC_TO_RGB 1 +#define MATRIX_RGB_TO_YCC 2 +#define MATRIX_FULL_RANGE_YCC_TO_RGB 3 + + +#define GE2D_ENDIAN_SHIFT 24 +#define GE2D_ENDIAN_MASK (0x1 << GE2D_ENDIAN_SHIFT) +#define GE2D_BIG_ENDIAN (0 << GE2D_ENDIAN_SHIFT) +#define GE2D_LITTLE_ENDIAN (1 << GE2D_ENDIAN_SHIFT) + +#define GE2D_COLOR_MAP_SHIFT 20 +#define GE2D_COLOR_MAP_MASK (0xf << GE2D_COLOR_MAP_SHIFT) +/* nv12 &nv21, only works on m6*/ +#define GE2D_COLOR_MAP_NV12 (15 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_NV21 (14 << GE2D_COLOR_MAP_SHIFT) +/* 16 bit */ +#define GE2D_COLOR_MAP_YUV422 (0 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_RGB655 (1 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUV655 (1 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_RGB844 (2 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUV844 (2 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_RGBA6442 (3 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUVA6442 (3 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_RGBA4444 (4 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUVA4444 (4 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_RGB565 (5 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUV565 (5 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_ARGB4444 (6 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_AYUV4444 (6 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_ARGB1555 (7 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_AYUV1555 (7 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_RGBA4642 (8 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUVA4642 (8 << GE2D_COLOR_MAP_SHIFT) +/* 24 bit */ +#define GE2D_COLOR_MAP_RGB888 (0 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUV444 (0 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_RGBA5658 (1 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUVA5658 (1 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_ARGB8565 (2 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_AYUV8565 (2 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_RGBA6666 (3 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUVA6666 (3 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_ARGB6666 (4 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_AYUV6666 (4 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_BGR888 (5 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_VUY888 (5 << GE2D_COLOR_MAP_SHIFT) +/* 32 bit */ +#define GE2D_COLOR_MAP_RGBA8888 (0 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_YUVA8888 (0 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_ARGB8888 (1 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_AYUV8888 (1 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_ABGR8888 (2 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_AVUY8888 (2 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_BGRA8888 (3 << GE2D_COLOR_MAP_SHIFT) +#define GE2D_COLOR_MAP_VUYA8888 (3 << GE2D_COLOR_MAP_SHIFT) + +/* format code is defined as: +[11] : 1-YUV color space, 0-RGB color space +[10] : compress_range +[9:8]: format +[7:6]: 8bit_mode_sel +[5] : LUT_EN +[4:3]: PIC_STRUCT +[2] : SEP_EN +[1:0]: X_YC_RATIO, SRC1_Y_YC_RATIO +*/ +#define GE2D_FORMAT_MASK 0x0ffff +#define GE2D_BPP_MASK 0x00300 +#define GE2D_BPP_8BIT 0x00000 +#define GE2D_BPP_16BIT 0x00100 +#define GE2D_BPP_24BIT 0x00200 +#define GE2D_BPP_32BIT 0x00300 +#define GE2D_FORMAT_YUV 0x20000 +#define GE2D_FORMAT_COMP_RANGE 0x10000 +/*bit8(2) format bi6(2) mode_8b_sel bit5(1)lut_en bit2 sep_en*/ +/*M seperate block S one block.*/ + +#define GE2D_FMT_S8_Y 0x00000 /* 00_00_0_00_0_00 */ +#define GE2D_FMT_S8_CB 0x00040 /* 00_01_0_00_0_00 */ +#define GE2D_FMT_S8_CR 0x00080 /* 00_10_0_00_0_00 */ +#define GE2D_FMT_S8_R 0x00000 /* 00_00_0_00_0_00 */ +#define GE2D_FMT_S8_G 0x00040 /* 00_01_0_00_0_00 */ +#define GE2D_FMT_S8_B 0x00080 /* 00_10_0_00_0_00 */ +#define GE2D_FMT_S8_A 0x000c0 /* 00_11_0_00_0_00 */ +#define GE2D_FMT_S8_LUT 0x00020 /* 00_00_1_00_0_00 */ +#define GE2D_FMT_S16_YUV422 0x20102 /* 01_00_0_00_0_00 */ +#define GE2D_FMT_S16_RGB (GE2D_LITTLE_ENDIAN|0x00100) /* 01_00_0_00_0_00 */ +#define GE2D_FMT_S24_YUV444 0x20200 /* 10_00_0_00_0_00 */ +#define GE2D_FMT_S24_RGB (GE2D_LITTLE_ENDIAN|0x00200) /* 10_00_0_00_0_00 */ +#define GE2D_FMT_S32_YUVA444 0x20300 /* 11_00_0_00_0_00 */ +#define GE2D_FMT_S32_RGBA (GE2D_LITTLE_ENDIAN|0x00300) /* 11_00_0_00_0_00 */ +#define GE2D_FMT_M24_YUV420 0x20007 /* 00_00_0_00_1_11 */ +#define GE2D_FMT_M24_YUV422 0x20006 /* 00_00_0_00_1_10 */ +#define GE2D_FMT_M24_YUV444 0x20004 /* 00_00_0_00_1_00 */ +#define GE2D_FMT_M24_RGB 0x00004 /* 00_00_0_00_1_00 */ +#define GE2D_FMT_M24_YUV420T 0x20017 /* 00_00_0_10_1_11 */ +#define GE2D_FMT_M24_YUV420B 0x2001f /* 00_00_0_11_1_11 */ + +#define GE2D_FMT_M24_YUV420SP 0x20207 +#define GE2D_FMT_M24_YUV420SPT 0x20217 /* 01_00_0_00_1_11 nv12 &nv21, only works on m6. */ +#define GE2D_FMT_M24_YUV420SPB 0x2021f /* 01_00_0_00_1_11 nv12 &nv21, only works on m6. */ + +#define GE2D_FMT_S16_YUV422T 0x20110 /* 01_00_0_10_0_00 */ +#define GE2D_FMT_S16_YUV422B 0x20138 /* 01_00_0_11_0_00 */ +#define GE2D_FMT_S24_YUV444T 0x20210 /* 10_00_0_10_0_00 */ +#define GE2D_FMT_S24_YUV444B 0x20218 /* 10_00_0_11_0_00 */ + +/* back compatible defines */ +#define GE2D_FORMAT_S8_Y (GE2D_FORMAT_YUV|GE2D_FMT_S8_Y) +#define GE2D_FORMAT_S8_CB (GE2D_FORMAT_YUV|GE2D_FMT_S8_CB) +#define GE2D_FORMAT_S8_CR (GE2D_FORMAT_YUV|GE2D_FMT_S8_CR) +#define GE2D_FORMAT_S8_R GE2D_FMT_S8_R +#define GE2D_FORMAT_S8_G GE2D_FMT_S8_G +#define GE2D_FORMAT_S8_B GE2D_FMT_S8_B +#define GE2D_FORMAT_S8_A GE2D_FMT_S8_A +#define GE2D_FORMAT_S8_LUT GE2D_FMT_S8_LUT +/* nv12 &nv21, only works on m6. */ +#define GE2D_FORMAT_M24_NV12 (GE2D_FMT_M24_YUV420SP| GE2D_COLOR_MAP_NV12) +#define GE2D_FORMAT_M24_NV12T (GE2D_FMT_M24_YUV420SPT| GE2D_COLOR_MAP_NV12) +#define GE2D_FORMAT_M24_NV12B (GE2D_FMT_M24_YUV420SPB| GE2D_COLOR_MAP_NV12) +#define GE2D_FORMAT_M24_NV21 (GE2D_FMT_M24_YUV420SP| GE2D_COLOR_MAP_NV21) +#define GE2D_FORMAT_M24_NV21T (GE2D_FMT_M24_YUV420SPT| GE2D_COLOR_MAP_NV21) +#define GE2D_FORMAT_M24_NV21B (GE2D_FMT_M24_YUV420SPB| GE2D_COLOR_MAP_NV21) + + + +#define GE2D_FORMAT_S12_RGB_655 (GE2D_FMT_S16_RGB | GE2D_COLOR_MAP_RGB655) +#define GE2D_FORMAT_S16_YUV422 (GE2D_FMT_S16_YUV422 | GE2D_COLOR_MAP_YUV422) +#define GE2D_FORMAT_S16_RGB_655 (GE2D_FMT_S16_RGB | GE2D_COLOR_MAP_RGB655) +#define GE2D_FORMAT_S24_YUV444 (GE2D_FMT_S24_YUV444 | GE2D_COLOR_MAP_YUV444) +#define GE2D_FORMAT_S24_RGB (GE2D_FMT_S24_RGB | GE2D_COLOR_MAP_RGB888) +#define GE2D_FORMAT_S32_YUVA444 (GE2D_FMT_S32_YUVA444 | GE2D_COLOR_MAP_YUVA4444) +#define GE2D_FORMAT_S32_RGBA (GE2D_FMT_S32_RGBA | GE2D_COLOR_MAP_RGBA8888) +#define GE2D_FORMAT_M24_YUV420 GE2D_FMT_M24_YUV420 +#define GE2D_FORMAT_M24_YUV422 GE2D_FMT_M24_YUV422 +#define GE2D_FORMAT_M24_YUV444 GE2D_FMT_M24_YUV444 +#define GE2D_FORMAT_M24_RGB GE2D_FMT_M24_RGB +#define GE2D_FORMAT_M24_YUV420T GE2D_FMT_M24_YUV420T +#define GE2D_FORMAT_M24_YUV420B GE2D_FMT_M24_YUV420B +#define GE2D_FORMAT_S16_YUV422T (GE2D_FMT_S16_YUV422T | GE2D_COLOR_MAP_YUV422) +#define GE2D_FORMAT_S16_YUV422B (GE2D_FMT_S16_YUV422B | GE2D_COLOR_MAP_YUV422) +#define GE2D_FORMAT_S24_YUV444T (GE2D_FMT_S24_YUV444T | GE2D_COLOR_MAP_YUV444) +#define GE2D_FORMAT_S24_YUV444B (GE2D_FMT_S24_YUV444B | GE2D_COLOR_MAP_YUV444) +//format added in A1H +/*16 bit*/ +#define GE2D_FORMAT_S16_RGB_565 (GE2D_FMT_S16_RGB | GE2D_COLOR_MAP_RGB565) +#define GE2D_FORMAT_S16_RGB_844 (GE2D_FMT_S16_RGB | GE2D_COLOR_MAP_RGB844) +#define GE2D_FORMAT_S16_RGBA_6442 (GE2D_FMT_S16_RGB | GE2D_COLOR_MAP_RGBA6442) +#define GE2D_FORMAT_S16_RGBA_4444 (GE2D_FMT_S16_RGB | GE2D_COLOR_MAP_RGBA4444) +#define GE2D_FORMAT_S16_ARGB_4444 (GE2D_FMT_S16_RGB | GE2D_COLOR_MAP_ARGB4444) +#define GE2D_FORMAT_S16_ARGB_1555 (GE2D_FMT_S16_RGB | GE2D_COLOR_MAP_ARGB1555) +#define GE2D_FORMAT_S16_RGBA_4642 (GE2D_FMT_S16_RGB | GE2D_COLOR_MAP_RGBA4642) +/*24 bit*/ +#define GE2D_FORMAT_S24_RGBA_5658 (GE2D_FMT_S24_RGB | GE2D_COLOR_MAP_RGBA5658) +#define GE2D_FORMAT_S24_ARGB_8565 (GE2D_FMT_S24_RGB | GE2D_COLOR_MAP_ARGB8565) +#define GE2D_FORMAT_S24_RGBA_6666 (GE2D_FMT_S24_RGB | GE2D_COLOR_MAP_RGBA6666) +#define GE2D_FORMAT_S24_ARGB_6666 (GE2D_FMT_S24_RGB | GE2D_COLOR_MAP_ARGB6666) +#define GE2D_FORMAT_S24_BGR (GE2D_FMT_S24_RGB | GE2D_COLOR_MAP_BGR888) +/*32 bit*/ +#define GE2D_FORMAT_S32_ARGB (GE2D_FMT_S32_RGBA | GE2D_COLOR_MAP_ARGB8888) +#define GE2D_FORMAT_S32_ABGR (GE2D_FMT_S32_RGBA | GE2D_COLOR_MAP_ABGR8888) +#define GE2D_FORMAT_S32_BGRA (GE2D_FMT_S32_RGBA | GE2D_COLOR_MAP_BGRA8888) + + + +#define OSD0 0 +#define OSD1 1 +#define VID0 2 +#define VID1 3 +typedef struct { + int x; /* X coordinate of its top-left point */ + int y; /* Y coordinate of its top-left point */ + int w; /* width of it */ + int h; /* height of it */ +} rectangle_t; +typedef struct { + unsigned int color ; + rectangle_t src1_rect; + rectangle_t src2_rect; + rectangle_t dst_rect; + int op; +}ge2d_para_t ; + +typedef struct { + int config_index ;//possible index OSD0 OSD1 VID0 VID1 + int handle[MAX_BITBLT_WORK_CONFIG] ; +}ge2d_config_handle_t ; + + +typedef struct { + unsigned char interrupt_ctrl; + + unsigned char dp_onoff_mode; + unsigned char vfmt_onoff_en; + unsigned int dp_on_cnt; + unsigned int dp_off_cnt; +} ge2d_gen_t; + + +typedef struct { + unsigned char urgent_en; + unsigned char ddr_burst_size_y; + unsigned char ddr_burst_size_cb; + unsigned char ddr_burst_size_cr; + unsigned int canaddr; + unsigned char x_yc_ratio; + unsigned char y_yc_ratio; + unsigned char sep_en; + unsigned char format; + + unsigned char endian; + unsigned char color_map; + + unsigned char mode_8b_sel; + unsigned char lut_en; + unsigned int def_color; + unsigned int format_all; +} ge2d_src1_data_t; + +typedef struct { + int clipx_start; + int clipx_end; + int clipy_start; + int clipy_end; + unsigned char clipx_start_ex; + unsigned char clipx_end_ex; + unsigned char clipy_start_ex; + unsigned char clipy_end_ex; + unsigned char pic_struct; + unsigned char fill_mode; //bit1 for outside alpha , bit0 for color data + unsigned int outside_alpha; + unsigned char chfmt_rpt_pix; + unsigned char cvfmt_rpt_pix; +} ge2d_src1_gen_t; + +typedef struct { + unsigned char urgent_en; + unsigned char ddr_burst_size; + unsigned char src2_canaddr; + unsigned char src2_format; + + unsigned char src2_endian; + unsigned char src2_color_map; + + unsigned char src2_mode_8b_sel; + unsigned int src2_def_color; + + unsigned int dst_canaddr; + unsigned char dst_format; + + unsigned char dst_endian; + unsigned char dst_color_map; + + unsigned char dst_mode_8b_sel; + + unsigned int src2_format_all; + unsigned int dst_format_all; + + /* only for m6 */ + unsigned char dst2_pixel_byte_width; + unsigned char dst2_color_map; + unsigned char dst2_discard_mode; + unsigned char dst2_enable; + +} ge2d_src2_dst_data_t; + + +typedef struct { + int src2_clipx_start; + int src2_clipx_end; + int src2_clipy_start; + int src2_clipy_end; + unsigned char src2_pic_struct; + unsigned char src2_fill_mode; //bit1 for outside alpha , bit0 for color data + unsigned int src2_outside_alpha; + + int dst_clipx_start; + int dst_clipx_end; + int dst_clipy_start; + int dst_clipy_end; + unsigned char dst_clip_mode; + unsigned char dst_pic_struct; +} ge2d_src2_dst_gen_t; + +typedef struct { + //scaler related + unsigned char src1_vsc_bank_length; + unsigned char src1_vsc_phase0_always_en; + unsigned char src1_hsc_bank_length; + unsigned char src1_hsc_phase0_always_en; + unsigned char src1_hsc_rpt_ctrl; //1bit, 0: using minus, 1: using repeat data + unsigned char src1_vsc_rpt_ctrl; //1bit, 0: using minus 1: using repeat data + unsigned char src1_hsc_nearest_en; + unsigned char src1_vsc_nearest_en; + + unsigned char antiflick_en; + unsigned char antiflick_ycbcr_rgb_sel; + unsigned char antiflick_cbcr_en; + unsigned int antiflick_r_coef; //Y= (R * r_coef + G * g_coef + B * b_coef)/256 + unsigned int antiflick_g_coef; + unsigned int antiflick_b_coef; + unsigned int antiflick_color_filter_n1[4]; + unsigned int antiflick_color_filter_n2[4]; + unsigned int antiflick_color_filter_n3[4]; + unsigned int antiflick_color_filter_th[3]; + unsigned int antiflick_alpha_filter_n1[4]; + unsigned int antiflick_alpha_filter_n2[4]; + unsigned int antiflick_alpha_filter_n3[4]; + unsigned int antiflick_alpha_filter_th[3]; + //matrix related + unsigned char use_matrix_default; + unsigned char conv_matrix_en; + unsigned char matrix_sat_in_en; + unsigned char matrix_minus_16_ctrl; //3bit + unsigned char matrix_sign_ctrl; //3bit + int matrix_offset[3]; + int matrix_coef[9]; + + unsigned char src1_gb_alpha; + unsigned int alu_const_color; + + unsigned char src1_key_en; + unsigned char src2_key_en; + unsigned char src1_key_mode; + unsigned char src2_key_mode; + unsigned int src1_key; + unsigned int src2_key; + unsigned int src1_key_mask; + unsigned int src2_key_mask; + unsigned char bitmask_en; + unsigned char bytemask_only; + unsigned int bitmask; + +} ge2d_dp_gen_t; + +typedef struct { + int src1_x_start; + int src1_y_start; + int src1_x_end; + int src1_y_end; + //unsigned char src1_x_start_ex; + //unsigned char src1_y_start_ex; + //unsigned char src1_x_end_ex; + //unsigned char src1_y_end_ex; + + unsigned char src1_x_rev; + unsigned char src1_y_rev; + //unsigned char src1_x_chr_phase; + //unsigned char src1_y_chr_phase; + unsigned char src1_fill_color_en; + + int src2_x_start; + int src2_y_start; + int src2_x_end; + int src2_y_end; + unsigned char src2_x_rev; + unsigned char src2_y_rev; + unsigned char src2_fill_color_en; + + int dst_x_start; + int dst_y_start; + int dst_x_end; + int dst_y_end; + unsigned char dst_xy_swap; + unsigned char dst_x_rev; + unsigned char dst_y_rev; + + int sc_prehsc_en; + int sc_prevsc_en; + int sc_hsc_en; + int sc_vsc_en; + int vsc_phase_step; + int vsc_phase_slope; + unsigned char vsc_rpt_l0_num; + int vsc_ini_phase; + int hsc_phase_step; + int hsc_phase_slope; + unsigned char hsc_rpt_p0_num; + int hsc_ini_phase; + unsigned char hsc_div_en; + unsigned int hsc_div_length; + int hsc_adv_num; + int hsc_adv_phase; + + unsigned char src1_cmult_asel; + unsigned char src2_cmult_asel; + + unsigned char color_blend_mode; + unsigned char color_src_blend_factor; + unsigned char color_dst_blend_factor; + unsigned char color_logic_op; + + unsigned char alpha_blend_mode; + unsigned char alpha_src_blend_factor; + unsigned char alpha_dst_blend_factor; + unsigned char alpha_logic_op; + + int (*cmd_cb)(unsigned); + unsigned int cmd_cb_param; + unsigned int src1_buffer; + unsigned int src2_buffer; + unsigned char release_flag; + unsigned char wait_done_flag; +} ge2d_cmd_t; + +typedef struct { + ge2d_gen_t gen; + ge2d_src1_data_t src1_data; + ge2d_src1_gen_t src1_gen; + ge2d_src2_dst_data_t src2_dst_data; + ge2d_src2_dst_gen_t src2_dst_gen; + ge2d_dp_gen_t dp_gen; + unsigned v_scale_coef_type; + unsigned h_scale_coef_type; + unsigned update_flag; +} ge2d_config_t; +typedef struct tasklet_struct tasklet_struct_t; +#ifdef __KERNEL__ +extern void ge2d_set_src1_data(ge2d_src1_data_t *cfg); + +extern void ge2d_set_src1_gen(ge2d_src1_gen_t *cfg); + +extern void ge2d_set_src2_dst_data(ge2d_src2_dst_data_t *cfg); + +extern void ge2d_set_src2_dst_gen(ge2d_src2_dst_gen_t *cfg); + +extern void ge2d_set_dp_gen(ge2d_dp_gen_t *cfg); + +extern void ge2d_set_cmd(ge2d_cmd_t *cfg); + +extern void ge2d_wait_done(void); + +extern void ge2d_set_src1_scale_coef(unsigned v_filt_type, unsigned h_filt_type); + +extern void ge2d_set_gen(ge2d_gen_t * cfg); + +extern void ge2d_soft_rst(void); + +extern int ge2d_is_busy (void); + +extern int ge2d_cmd_fifo_full(void); +#endif +#define INT32S signed int +#define INT32U unsigned int +#define INT16U unsigned short +#define INT8U unsigned char +#define INT8S signed char +#include "ge2d_wq.h" +#include "ge2d_main.h" +#ifdef __KERNEL__ +#include "ge2dgen.h" +#include "bitblt.h" +#include <linux/fb.h> +#endif + + + +#endif + diff --git a/v3/fake-pipeline2/ge2d_main.h b/v3/fake-pipeline2/ge2d_main.h new file mode 100755 index 0000000..bd0e4bb --- a/dev/null +++ b/v3/fake-pipeline2/ge2d_main.h @@ -0,0 +1,62 @@ +#ifndef _GE2D_MAIN_H +#define _GE2D_MAIN_H +#ifdef __KERNEL__ +#include "ge2d.h" +#include <linux/interrupt.h> +#include <linux/compat.h> +#include <mach/am_regs.h> +#include <linux/amlogic/amports/canvas.h> +#include <linux/fb.h> +#include <linux/list.h> +#include <asm/uaccess.h> +#include <linux/sysfs.h> +#include <linux/spinlock.h> +#include <linux/kthread.h> +#include <linux/ion.h> +#endif + +/************************************************************** +** ** +** macro define ** +** ** +***************************************************************/ + +#define GE2D_CLASS_NAME "ge2d" + +#define GE2D_STRETCHBLIT_NOALPHA_NOBLOCK 0x4708 +#define GE2D_BLIT_NOALPHA_NOBLOCK 0x4707 +#define GE2D_BLEND_NOBLOCK 0x4706 +#define GE2D_BLIT_NOBLOCK 0x4705 +#define GE2D_STRETCHBLIT_NOBLOCK 0x4704 +#define GE2D_FILLRECTANGLE_NOBLOCK 0x4703 + + +#define GE2D_STRETCHBLIT_NOALPHA 0x4702 +#define GE2D_BLIT_NOALPHA 0x4701 +#define GE2D_BLEND 0x4700 +#define GE2D_BLIT 0x46ff +#define GE2D_STRETCHBLIT 0x46fe +#define GE2D_FILLRECTANGLE 0x46fd +#define GE2D_SRCCOLORKEY 0x46fc +#define GE2D_SET_COEF 0x46fb +#define GE2D_CONFIG_EX 0x46fa +#define GE2D_CONFIG 0x46f9 +#define GE2D_ANTIFLICKER_ENABLE 0x46f8 + +/************************************************************** +** ** +** type define ** +** ** +***************************************************************/ +#ifdef __KERNEL__ +typedef struct { + char name[20]; + unsigned int open_count; + int major; + unsigned int dbg_enable; + struct class *cla; + struct device *dev; + struct ion_client *ion_client; +}ge2d_device_t; +#endif +#endif diff --git a/v3/fake-pipeline2/ge2d_stream.cpp b/v3/fake-pipeline2/ge2d_stream.cpp new file mode 100755 index 0000000..7ff0432 --- a/dev/null +++ b/v3/fake-pipeline2/ge2d_stream.cpp @@ -0,0 +1,207 @@ +/* + * Copyright (C) 2014 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_NNDEBUG 0 + +#define LOG_TAG "Camera_Stream" +#include <hardware/camera3.h> +#include <DebugUtils.h> +#include "ge2d_stream.h" + +//namespace android { + +#ifdef __cplusplus +//extern "C"{ +#endif +int cameraConfigureStreams(struct VideoInfo *vinfo, camera3_stream_configuration *streamList) { +#if 0 + + int src_width = vinfo->preview.format.fmt.pix.width; + int src_height = vinfo->preview.format.fmt.pix.height; + int src_top = 0; + int src_left = 0; + + //TODO check the pointers + if (vinfo->num_configs == 0) { + vinfo->ge2d_config = (config_para_ex_t *) malloc (sizeof(config_para_ex_t) + *streamList->num_streams); + vinfo->num_configs = streamList->num_streams; + } else if (vinfo->num_configs <= streamList->num_streams) { + vinfo->ge2d_config = (config_para_ex_t *) realloc (sizeof(config_para_ex_t) + *streamList->num_streams); + vinfo->num_configs = streamList->num_streams; + } + + config_para_ex_t *cfg = vinfo->ge2d_config; + + for (size_t i = 0; i < streamList->num_streams; i++) { + camera3_stream_t *newStream = streamList->streams[i]; + + /* data operating. */ + cfg->alu_const_color= 0;//0x000000ff; + cfg->bitmask_en = 0; + cfg->src1_gb_alpha = 0;//0xff; + cfg->dst_xy_swap = 0; + + cfg->src_planes[0].addr = 0 + cfg->src_planes[0].w = src_width; + cfg->src_planes[0].h = src_height; + cfg->src_planes[1].addr = 0; + cfg->src_planes[1].w = src_width/2; + cfg->src_planes[1].h = src_height/2; + cfg->src_planes[2].addr = 0; + cfg->src_planes[2].w = src_width/2; + cfg->src_planes[2].h = src_height/2; + //canvas_read(output_para.index&0xff,&cd); + cfg->dst_planes[0].addr = 0;//cd.addr; + cfg->dst_planes[0].w = newStream->width; + cfg->dst_planes[0].h = newStream->height; + cfg->src_key.key_enable = 0; + cfg->src_key.key_mask = 0; + cfg->src_key.key_mode = 0; + cfg->src_para.canvas_index=0;//TODO vf->canvas0Addr; + cfg->src_para.mem_type = CANVAS_ALLOC; + cfg->src_para.format = GE2D_FORMAT_S16_YUV422; + //get_input_format(vf); + cfg->src_para.fill_color_en = 0; + cfg->src_para.fill_mode = 0; + cfg->src_para.x_rev = 0; + cfg->src_para.y_rev = 0; + cfg->src_para.color = 0xffffffff; + cfg->src_para.top = 0; + cfg->src_para.left = 0; + cfg->src_para.width = src_width; + cfg->src_para.height = src_height; + /* printk("vf_width is %d , vf_height is %d \n",vf->width ,vf->height); */ + //cfg->dst_para.canvas_index = output_para.index&0xff; + + cfg.dst_para.mem_type = CANVAS_ALLOC; + cfg.dst_para.fill_color_en = 0; + cfg.dst_para.fill_mode = 0; + cfg.dst_para.format = GE2D_FORMAT_M24_NV21|GE2D_LITTLE_ENDIAN; + cfg.dst_para.x_rev = 0; + cfg.dst_para.y_rev = 0; + cfg.dst_para.color = 0; + cfg.dst_para.top = 0; + cfg.dst_para.left = 0; + cfg.dst_para.width = newStream->width; + cfg.dst_para.height = newStream->height; + + cfg ++; + } + CAMHAL_LOGDB("numcfgs = %d, num streams=%d\n", + vinfo->num_configs, streamList->num_streams); +#endif + return 0; +} + +int fillStream(struct VideoInfo *src, uintptr_t physAddr, const android::StreamBuffer &dst) { + /* data operating. */ + int ge2d_fd; + config_para_ex_t cfg; + ge2d_para_t para; + + int32_t src_width = src->preview.format.fmt.pix.width; + int32_t src_height = src->preview.format.fmt.pix.height; + + ge2d_fd = open("/dev/ge2d", O_RDWR); + if (ge2d_fd < 0) { + CAMHAL_LOGEA("open ge2d failed\n"); + return -1; + } + + //ioctl(ge2d_fd, GE2D_ANTIFLICKER_ENABLE,0); + memset(&cfg, 0, sizeof(cfg)); + cfg.alu_const_color= 0; + cfg.bitmask_en = 0; + cfg.src1_gb_alpha = 0; //0xff; + cfg.dst_xy_swap = 0; + + cfg.src_planes[0].addr = physAddr; + cfg.src_planes[0].w = src_width; + cfg.src_planes[0].h = src_height; + //NV21, YV12 need to add + cfg.src_planes[1].addr = physAddr + src_width *src_height; + cfg.src_planes[1].w = src_width; + cfg.src_planes[1].h = src_height/2; + //cfg.src_planes[2].addr = 0; + //cfg.src_planes[2].w = src_width/2; + //cfg.src_planes[2].h = src_height/2; + //canvas_read(output_para.index&0xff,&cd); + cfg.dst_planes[0].addr = dst.share_fd;//cd.addr; + cfg.dst_planes[0].w = dst.width; + cfg.dst_planes[0].h = dst.height; + + cfg.dst_planes[1].addr = dst.share_fd;//cd.addr; + cfg.dst_planes[1].w = dst.width; + cfg.dst_planes[1].h = dst.height/2; + cfg.src_key.key_enable = 0; + cfg.src_key.key_mask = 0; + cfg.src_key.key_mode = 0; + cfg.src_para.mem_type = CANVAS_ALLOC; + cfg.src_para.format = GE2D_FORMAT_M24_NV21|GE2D_LITTLE_ENDIAN; + cfg.src_para.fill_color_en = 0; + cfg.src_para.fill_mode = 0; + cfg.src_para.x_rev = 0; + cfg.src_para.y_rev = 0; + cfg.src_para.color = 0xffffffff;// 0xffff; + cfg.src_para.top = 0; + cfg.src_para.left = 0; + cfg.src_para.width = src_width; + cfg.src_para.height = src_height; + cfg.src2_para.mem_type = CANVAS_TYPE_INVALID; + /* printk("vf_width is %d , vf_height is %d \n",vf.width ,vf.height); */ + //cfg.dst_para.canvas_index = output_para.index&0xff; + + cfg.dst_para.mem_type = CANVAS_ALLOC; + cfg.dst_para.fill_color_en = 0; + cfg.dst_para.fill_mode = 0; + cfg.dst_para.format = GE2D_FORMAT_M24_NV21|GE2D_LITTLE_ENDIAN; + cfg.dst_para.x_rev = 0; + cfg.dst_para.y_rev = 0; + cfg.dst_para.color = 0; + cfg.dst_para.top = 0; + cfg.dst_para.left = 0; + cfg.dst_para.width = dst.width; + cfg.dst_para.height = dst.height; + cfg.src_addr_type = GE2D_ADDR_TYPE_PHY_ADDR; + cfg.dst_addr_type = GE2D_ADDR_TYPE_SHARE_FD; + + ioctl(ge2d_fd, GE2D_CONFIG_EX, &cfg); + + para.src1_rect.x = 0; + para.src1_rect.y = 0; + para.src1_rect.w = src_width; + para.src1_rect.h = src_height; + para.dst_rect.x = 0; + para.dst_rect.y = 0; + para.dst_rect.w = dst.width; + para.dst_rect.h = dst.height; + //Y + ioctl(ge2d_fd, GE2D_STRETCHBLIT_NOALPHA, ¶); + //Cb + //Cr + + close (ge2d_fd); + ge2d_fd = -1; + + return 0; +} +#ifdef __cplusplus +//} +#endif +//}// namespace android diff --git a/v3/fake-pipeline2/ge2d_stream.h b/v3/fake-pipeline2/ge2d_stream.h new file mode 100644 index 0000000..d056c10 --- a/dev/null +++ b/v3/fake-pipeline2/ge2d_stream.h @@ -0,0 +1,27 @@ +/* + * Copyright (C) 2014 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. + */ + +#ifndef __GE2D_STREAM_H__ +#define __GE2D_STREAM_H__ + +#include <linux/videodev2.h> +#include "Base.h" +#include "camera_hw.h" +#include "ge2d.h" + +int fillStream(struct VideoInfo *src, uintptr_t physAddr, const android::StreamBuffer &dst); + +#endif diff --git a/v3/fake-pipeline2/ge2d_wq.h b/v3/fake-pipeline2/ge2d_wq.h new file mode 100755 index 0000000..9bcfba3 --- a/dev/null +++ b/v3/fake-pipeline2/ge2d_wq.h @@ -0,0 +1,310 @@ +#ifndef BITBLT_H_ +#define BITBLT_H_ + +#ifdef __KERNEL__ +#include <linux/mutex.h> +#include <linux/semaphore.h> +#include <linux/list.h> +#include <linux/amlogic/osd/osd.h> +#include <linux/interrupt.h> +#include <linux/sched.h> +#include <linux/spinlock.h> +#include <linux/wait.h> +#include <linux/slab.h> +#endif +#define GE2D_HIGHEST_PRIORITY 0 +#define GE2D_LOWEST_PRIORITY 255 + +#define FLAG_CONFIG_UPDATE_ONLY 0 +#define FLAG_CONFIG_ALL 1 + +#define UPDATE_SRC_DATA 0x01 +#define UPDATE_SRC_GEN 0x02 +#define UPDATE_DST_DATA 0x04 +#define UPDATE_DST_GEN 0x08 +#define UPDATE_DP_GEN 0x10 +#define UPDATE_SCALE_COEF 0x20 +#define UPDATE_ALL 0x3f +#define GE2D_ATTR_MAX 2 +#define GE2D_MAX_WORK_QUEUE_NUM 4 +#define GE2D_IRQ_NO INT_GE2D +#define FILE_NAME "[GE2D_WQ]" +typedef enum +{ + OSD0_OSD0 =0, + OSD0_OSD1, + OSD1_OSD1, + OSD1_OSD0, + ALLOC_OSD0, + ALLOC_OSD1, + ALLOC_ALLOC, + TYPE_INVALID, +}ge2d_src_dst_t; +typedef enum +{ + CANVAS_OSD0 =0, + CANVAS_OSD1, + CANVAS_ALLOC, + CANVAS_TYPE_INVALID, +}ge2d_src_canvas_type; +#ifdef __KERNEL__ +typedef struct { + struct list_head list; + ge2d_cmd_t cmd ; + ge2d_config_t config; + +}ge2d_queue_item_t; + +typedef struct{ + struct list_head list; //connect all process in one queue for RR process. + ge2d_config_t config; //current wq configuration + ge2d_cmd_t cmd; + struct list_head work_queue; + struct list_head free_queue; + wait_queue_head_t cmd_complete; + int queue_dirty; + int queue_need_recycle; + spinlock_t lock; // for get and release item. +} ge2d_context_t; + +typedef struct { + wait_queue_head_t cmd_complete; + struct completion process_complete; + spinlock_t sem_lock; //for queue switch and create destroy queue. + struct semaphore cmd_in_sem; +}ge2d_event_t; + + + +typedef struct { + struct list_head process_queue; + ge2d_context_t* current_wq; + ge2d_context_t* last_wq; + struct task_struct* ge2d_thread; + ge2d_event_t event ; + int irq_num; + int ge2d_state; + int process_queue_state; +}ge2d_manager_t ; +#endif +typedef struct { + int xres; + int yres ; + int canvas_index; + int bpp; + int ge2d_color_index; +}src_dst_para_t ; + +typedef enum { + COLOR_INDEX_02_PAL4 = 2, // 0 + COLOR_INDEX_04_PAL16 = 4, // 0 + COLOR_INDEX_08_PAL256=8, + COLOR_INDEX_16_655 =9, + COLOR_INDEX_16_844 =10, + COLOR_INDEX_16_6442 =11 , + COLOR_INDEX_16_4444_R = 12, + COLOR_INDEX_16_4642_R = 13, + COLOR_INDEX_16_1555_A=14, + COLOR_INDEX_16_4444_A = 15, + COLOR_INDEX_16_565 =16, + + COLOR_INDEX_24_6666_A=19, + COLOR_INDEX_24_6666_R=20, + COLOR_INDEX_24_8565 =21, + COLOR_INDEX_24_5658 = 22, + COLOR_INDEX_24_888_B = 23, + COLOR_INDEX_24_RGB = 24, + + COLOR_INDEX_32_BGRA=29, + COLOR_INDEX_32_ABGR = 30, + COLOR_INDEX_32_RGBA=31, + COLOR_INDEX_32_ARGB=32, + + COLOR_INDEX_YUV_422=33, + +}color_index_t; + +static const int bpp_type_lut[]={ + //16bit + COLOR_INDEX_16_655, // 0 + COLOR_INDEX_16_844, // 1 + COLOR_INDEX_16_6442, // 2 + COLOR_INDEX_16_4444_R, // 3 + COLOR_INDEX_16_565, // 4 + COLOR_INDEX_16_4444_A, // 5 + COLOR_INDEX_16_1555_A, // 6 + COLOR_INDEX_16_4642_R, // 7 + //24bit + COLOR_INDEX_24_RGB, // 0 + COLOR_INDEX_24_5658, // 1 + COLOR_INDEX_24_8565, // 2 + COLOR_INDEX_24_6666_R, // 3 + COLOR_INDEX_24_6666_A, // 4 + COLOR_INDEX_24_888_B, // 5 + 0, + 0, + //32bit + COLOR_INDEX_32_RGBA, // 0 + COLOR_INDEX_32_ARGB, // 1 + COLOR_INDEX_32_ABGR, // 2 + COLOR_INDEX_32_BGRA, // 3 + 0,0,0,0 +}; + +static const int default_ge2d_color_lut[]={ + 0, + 0, + 0,//BPP_TYPE_02_PAL4 = 2, + 0, + 0,//BPP_TYPE_04_PAL16 = 4, + 0, + 0, + 0, + 0,//BPP_TYPE_08_PAL256=8, + GE2D_FORMAT_S16_RGB_655,//BPP_TYPE_16_655 =9, + GE2D_FORMAT_S16_RGB_844,//BPP_TYPE_16_844 =10, + GE2D_FORMAT_S16_RGBA_6442,//BPP_TYPE_16_6442 =11 , + GE2D_FORMAT_S16_RGBA_4444,//BPP_TYPE_16_4444_R = 12, + GE2D_FORMAT_S16_RGBA_4642,//BPP_TYPE_16_4642_R = 13, + GE2D_FORMAT_S16_ARGB_1555,//BPP_TYPE_16_1555_A=14, + GE2D_FORMAT_S16_ARGB_4444,//BPP_TYPE_16_4444_A = 15, + GE2D_FORMAT_S16_RGB_565,//BPP_TYPE_16_565 =16, + 0, + 0, + GE2D_FORMAT_S24_ARGB_6666,//BPP_TYPE_24_6666_A=19, + GE2D_FORMAT_S24_RGBA_6666,//BPP_TYPE_24_6666_R=20, + GE2D_FORMAT_S24_ARGB_8565,//BPP_TYPE_24_8565 =21, + GE2D_FORMAT_S24_RGBA_5658,//BPP_TYPE_24_5658 = 22, + GE2D_FORMAT_S24_BGR,//BPP_TYPE_24_888_B = 23, + GE2D_FORMAT_S24_RGB,//BPP_TYPE_24_RGB = 24, + 0, + 0, + 0, + 0, + GE2D_FORMAT_S32_BGRA,//BPP_TYPE_32_BGRA=29, + GE2D_FORMAT_S32_ABGR,//BPP_TYPE_32_ABGR = 30, + GE2D_FORMAT_S32_RGBA,//BPP_TYPE_32_RGBA=31, + GE2D_FORMAT_S32_ARGB,//BPP_TYPE_32_ARGB=32, +}; +typedef enum{ + GE2D_OP_DEFAULT=0, + GE2D_OP_FILLRECT, + GE2D_OP_BLIT, + GE2D_OP_STRETCHBLIT, + GE2D_OP_BLEND, + GE2D_OP_MAXNUM +}ge2d_op_type_t; + +//the same as config_planes_t's member addr +typedef unsigned long ge2d_phys_addr_t; + +typedef struct { + unsigned long addr; + unsigned int w; + unsigned int h; +}config_planes_t; + +typedef struct{ + int key_enable; + int key_color; + int key_mask; + int key_mode; +}src_key_ctrl_t; +typedef struct { + int src_dst_type; + int alu_const_color; + unsigned int src_format; + unsigned int dst_format ; //add for src&dst all in user space. + + config_planes_t src_planes[4]; + config_planes_t dst_planes[4]; + src_key_ctrl_t src_key; +}config_para_t; + +typedef struct { + int canvas_index; + int top; + int left; + int width; + int height; + int format; + int mem_type; + int color; + unsigned char x_rev; + unsigned char y_rev; + unsigned char fill_color_en; + unsigned char fill_mode; +}src_dst_para_ex_t ; + + +typedef enum ge2d_addr_type_e { + GE2D_ADDR_TYPE_NONE, + GE2D_ADDR_TYPE_PHY_ADDR, + GE2D_ADDR_TYPE_SHARE_FD, +}ge2d_addr_type_t; + +typedef struct { + src_dst_para_ex_t src_para; + src_dst_para_ex_t src2_para; + src_dst_para_ex_t dst_para; + +//key mask + src_key_ctrl_t src_key; + src_key_ctrl_t src2_key; + + int alu_const_color; + unsigned src1_gb_alpha; + unsigned op_mode; + unsigned char bitmask_en; + unsigned char bytemask_only; + unsigned int bitmask; + unsigned char dst_xy_swap; + +// scaler and phase releated + unsigned hf_init_phase; + int hf_rpt_num; + unsigned hsc_start_phase_step; + int hsc_phase_slope; + unsigned vf_init_phase; + int vf_rpt_num; + unsigned vsc_start_phase_step; + int vsc_phase_slope; + unsigned char src1_vsc_phase0_always_en; + unsigned char src1_hsc_phase0_always_en; + unsigned char src1_hsc_rpt_ctrl; //1bit, 0: using minus, 1: using repeat data + unsigned char src1_vsc_rpt_ctrl; //1bit, 0: using minus 1: using repeat data + +//canvas info + config_planes_t src_planes[4]; + config_planes_t src2_planes[4]; + config_planes_t dst_planes[4]; + + enum ge2d_addr_type_e src_addr_type; + enum ge2d_addr_type_e dst_addr_type; +}config_para_ex_t; +#ifdef __KERNEL__ +extern int ge2d_setup(void); +extern int ge2d_deinit(void); +extern int ge2d_context_config(ge2d_context_t *context, config_para_t *ge2d_config); +extern int ge2d_context_config_ex(ge2d_context_t *context, config_para_ex_t *ge2d_config); + +extern int ge2d_wq_init(void); +extern int destroy_ge2d_work_queue(ge2d_context_t* ) ; +extern ge2d_context_t* create_ge2d_work_queue(void) ; + +extern int ge2d_wq_remove_config(ge2d_context_t *wq); + +extern void ge2d_wq_set_scale_coef(ge2d_context_t *wq, unsigned v_scale_coef, unsigned h_scale_coef); +extern int ge2d_antiflicker_enable(ge2d_context_t *context,unsigned long enable); +extern ge2d_src1_data_t * ge2d_wq_get_src_data(ge2d_context_t *wq); +extern ge2d_src1_gen_t * ge2d_wq_get_src_gen(ge2d_context_t *wq); +extern ge2d_src2_dst_data_t * ge2d_wq_get_dst_data(ge2d_context_t *wq); +extern ge2d_src2_dst_gen_t * ge2d_wq_get_dst_gen(ge2d_context_t *wq); +extern ge2d_dp_gen_t * ge2d_wq_get_dp_gen(ge2d_context_t *wq); +extern ge2d_cmd_t * ge2d_wq_get_cmd(ge2d_context_t *wq); + +extern int ge2d_wq_add_work(ge2d_context_t *wq); +#endif + + +#endif // BITBLT_H |