rk3188-5.1 USB摄像头默认改成前置

说明:后置摄像头改成前置,预览和拍照都为前置。

一、把后置和前置互换一下,默认成前置:

diff --git a/hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp b/hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp

index 238eccc..bc47e48 100755

--- a/hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp

+++ b/hardware/rockchip/camera/CameraHal/CameraHal_Module.cpp

@@ -764,9 +764,9 @@ int camera_get_number_of_cameras(void)

memcpy(camInfoTmp[cam_cnt&0x01].driver,capability.driver, sizeof(camInfoTmp[cam_cnt&0x01].driver));

camInfoTmp[cam_cnt&0x01].version = capability.version;

if (strstr((char*)&capability.card[0], "front") != NULL) {

- camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;

- } else {

camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_BACK;

+ } else {

+ camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;

}

二:摄像头虽然改成了前置,但是预览和照片的方向还是反的。修改预览方向,改成前置预览

diff --git a/hardware/rockchip/camera/CameraHal/AppMsgNotifier.cpp b/hardware/rockchip/camera/CameraHal/AppMsgNotifier.cpp

old mode 100644

new mode 100755

index d483bbc..113c083

--- a/hardware/rockchip/camera/CameraHal/AppMsgNotifier.cpp

+++ b/hardware/rockchip/camera/CameraHal/AppMsgNotifier.cpp

@@ -1033,6 +1033,15 @@ int AppMsgNotifier::captureEncProcessPicture(FramInfo_s* frame){

mNotifyCb(CAMERA_MSG_SHUTTER, 0, 0, mCallbackCookie);

LOGD("captureEncProcessPicture,rotation = %d,jpeg_w = %d,jpeg_h = %d",rotation,jpeg_w,jpeg_h);

+

+ //mirror

+ if(1) //(mDataCbFrontMirror)

+ {

+ char *dbuf = (char*)malloc(frame->frame_width*frame->frame_height*3/2);

+ YuvData_Mirror(V4L2_PIX_FMT_NV12, (char*)frame->vir_addr,(char*)dbuf, frame->frame_width, frame->frame_height);

+ memcpy((void*)frame->vir_addr,dbuf,frame->frame_width*frame->frame_height*3/2);

+ free(dbuf);

+ }

//2. copy to output buffer for mirro and flip

/*[email protected]: v0.4.7*/

diff --git a/hardware/rockchip/camera/CameraHal/CameraHal.h b/hardware/rockchip/camera/CameraHal/CameraHal.h

old mode 100644

new mode 100755

index 004b745..e7d9578

--- a/hardware/rockchip/camera/CameraHal/CameraHal.h

+++ b/hardware/rockchip/camera/CameraHal/CameraHal.h

@@ -105,6 +105,7 @@ extern "C" int rk_camera_yuv_scale_crop_ipp(int v4l2_fmt_src, int v4l2_fmt_dst,

extern "C" int YData_Mirror_Line(int v4l2_fmt_src, int *psrc, int *pdst, int w);

extern "C" int UVData_Mirror_Line(int v4l2_fmt_src, int *psrc, int *pdst, int w);

extern "C" int YuvData_Mirror_Flip(int v4l2_fmt_src, char *pdata, char *pline_tmp, int w, int h);

+extern "C" int YuvData_Mirror(int v4l2_fmt_src, char *pdata, char *pline_tmp, int w, int h);

extern "C" int YUV420_rotate(const unsigned char* srcy, int src_stride, unsigned char* srcuv,

unsigned char* dsty, int dst_stride, unsigned char* dstuv,

int width, int height,int rotate_angle);

diff --git a/hardware/rockchip/camera/CameraHal/CameraHalUtil.cpp b/hardware/rockchip/camera/CameraHal/CameraHalUtil.cpp

index f7d8075..d03371e 100755

--- a/hardware/rockchip/camera/CameraHal/CameraHalUtil.cpp

+++ b/hardware/rockchip/camera/CameraHal/CameraHalUtil.cpp

@@ -1018,6 +1018,40 @@ extern "C" int YuvData_Mirror_Flip(int v4l2_fmt_src, char *pdata, char *pline_t

YuvData_Mirror_Flip_end:

return err;

}

+

+

+extern "C" int YuvData_Mirror(int v4l2_fmt_src, char *pdata, char *pline_tmp, int w, int h)

+{

+ int err = 0,i,j;

+

+ //420sp

+ int *pdst = NULL;

+ int *psrc;

+

+ pdst = (int*)pline_tmp;

+

+ psrc = (int*)pdata;

+ for (j=0; j

+ YData_Mirror_Line(v4l2_fmt_src, psrc, pdst+((w>>2)-1),w);

+ psrc += (w>>2);

+ pdst += (w>>2);

+ }

+

+ // UV mirror

+ psrc = (int*)(pdata+w*h);

+ pdst = (int*)(pline_tmp+w*h);

+ for (j=0; j<(h>>1); j++) {

+ UVData_Mirror_Line(v4l2_fmt_src, psrc, pdst+((w>>2)-1),w);

+ psrc += (w>>2);

+ pdst += (w>>2);

+ }

+

+

+YuvData_Mirror_end:

+ return err;

+}

+

extern "C" int YUV420_rotate(const unsigned char* srcy, int src_stride, unsigned char* srcuv,

unsigned char* dsty, int dst_stride, unsigned char* dstuv,

int width, int height,int rotate_angle){

注:该方法在rk3288平台效果一样。

你可能感兴趣的:(rk3288)