方法1:
修改文件:
hardware\rockchip\camera\CameraHal\CameraHal_Module.cpp
//默认前置置摄像头 camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT ;//默认后置置摄像头 camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_BACK;
所以将CAMERA_FACING_BACK
和CAMERA_FACING_FRONT
对换即可
源代码:
#ifdef LAPTOP} else if (strstr((char*)&capability.card[0], "HP HD") != NULL|| strstr((char*)&capability.card[0], "HP IR")) {camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT;if (strstr((char*)&capability.card[0], "HP IR"))gCamerasUnavailabled++;gUsbCameraNames[cam_cnt&0x01] = String8((char*)&capability.card[0]);LOGD("Camera %d name: %s", (cam_cnt&0x01), gUsbCameraNames[cam_cnt&0x01].string()); #endif} else {camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_BACK;} if ((cam_cnt&0x01) == 0)//默认前置摄像头camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_FRONT ;else//默认后置置摄像头camInfoTmp[cam_cnt&0x01].facing_info.facing = CAMERA_FACING_BACK;:::::
方法2修改驱动:
将capability card改为"facing-orientation".
例如facing(1), orientation(180)就是"front-180",android的CameraHal会根据命名规则来解析是前置摄像头还是后置摄像头,以及摄像头的方向.如果要做多个摄像头兼容可以加上VID与PID匹配.
diff --git a/drivers/media/usb/uvc/uvc_v4l2.c b/drivers/media/usb/uvc/uvc_v4l2.c index 196198f..d81586f 100644 --- a/drivers/media/usb/uvc/uvc_v4l2.c +++ b/drivers/media/usb/uvc/uvc_v4l2.c @@ -564,6 +564,14 @@ static long uvc_v4l2_do_ioctl(struct file *file, unsigned int cmd, void *arg)memset(cap, 0, sizeof *cap);strlcpy(cap->driver, "uvcvideo", sizeof cap->driver);strlcpy(cap->card, vdev->name, sizeof cap->card); + + if(le16_to_cpu(stream->dev->udev->descriptor.idVendor)==0x058f && + le16_to_cpu(stream->dev->udev->descriptor.idProduct)==0x3841){//058f:3841 + pr_info("uvc vendor product matched\n"); + memset(cap->card, 0, sizeof cap->card); + strlcpy(cap->card, "front-180", sizeof cap->card); + } +usb_make_path(stream->dev->udev,cap->bus_info, sizeof(cap->bus_info));cap->version = LINUX_VERSION_CODE;
方法3:
rk3399/hardware/interfaces$ git diff . diff --git a/camera/device/3.4/default/ExternalCameraDevice.cpp b/camera/device/3.4/default/ExternalCameraDevice.cpp old mode 100644 new mode 100755 index 6dfe9d7..577f793 --- a/camera/device/3.4/default/ExternalCameraDevice.cpp +++ b/camera/device/3.4/default/ExternalCameraDevice.cpp @@ -309,7 +309,7 @@ status_t ExternalCameraDevice::initDefaultCharsKeys(UPDATE(ANDROID_LENS_INFO_AVAILABLE_OPTICAL_STABILIZATION,&opticalStabilizationMode, 1); - const uint8_t facing = ANDROID_LENS_FACING_BACK; + const uint8_t facing = ANDROID_LENS_FACING_FRONT; UPDATE(ANDROID_LENS_FACING, &facing, 1);// android.noiseReductionUSB前后置摄像头切换 (ngui.cc) 标签:card,FACING,cnt,USB,cap,facing,切换,uvc,摄像头 From: https://www.cnblogs.com/wanglongjiang/p/17605868.html