RK3288 Android5.1 多個品牌USB攝像頭git
同一塊主板和代碼,大部分品牌的USB攝像頭能夠正常使用,只有某一款USB攝像頭不能使用。app
插上攝像頭,底層能夠識別到攝像頭。ide
<6>[ 47.479515] usb 3-1.4: new high-speed USB device number 5 using usb20_host <6>[ 47.696548] usb 3-1.4: New USB device found, idVendor=058f, idProduct=2657 <6>[ 47.696719] usb 3-1.4: New USB device strings: Mfr=1, Product=2, SerialNumber=0 <6>[ 47.696825] usb 3-1.4: Product: PC Camera <6>[ 47.696908] usb 3-1.4: Manufacturer: Alcor Micro, Corp. <6>[ 47.708510] uvcvideo: Found UVC 1.00 device PC Camera (058f:2657) <6>[ 47.718236] input: PC Camera as /devices/ff540000.usb/usb3/3-1/3-1.4/3-1.4:1.0/input/input5
可是每次打開攝像頭app都顯示「沒法鏈接到相機」,上層 log 以下。spa
D/CameraHal( 177): setParameters(583): setParameters(583): Set preview size 800x600 ... ... D/CameraHal( 177): startPreview(177): startPreview177:preview_w = 800,preview_h = 600,drv_w = 800,drv_h = 600 D/CameraHal( 177): cameraSetSize(476): cameraSetSize(476):IN, w = 800,h = 600 ... ... E/CameraHal( 177): getFrame(614): getFrame(614): VIDIOC_DQBUF Failed!!! err[I/O error] E/CameraHal( 177): getFrame(620): getFrame(620): camera driver or device may be error, so notify CAMERA_MSG_ERROR
最後官方的回覆以下:code
USB攝像頭800x600分辨率輸出有問題,強制使用1280x960,同時保留1280x720爲錄像使用,由軟件剪切到1280x720blog
diff --git a/CameraHal/CameraUSBAdapter.cpp b/CameraHal/CameraUSBAdapter.cpp index b88dd17..adb446b 100644 --- a/CameraHal/CameraUSBAdapter.cpp +++ b/CameraHal/CameraUSBAdapter.cpp @@ -134,8 +134,8 @@ void CameraUSBAdapter::initDefaultParameters(int camFd) params.set(KEY_PREVIEW_W_FORCE,"0"); params.set(KEY_PREVIEW_H_FORCE,"0"); - params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, parameterString.string()); - params.setPreviewSize(640,480); + params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, "1280x960,1280x720"); + params.setPreviewSize(1280, 960); /*picture size setting*/ params.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, parameterString.string()); params.setPictureSize(mCamDriverFrmWidthMax, mCamDriverFrmHeightMax);
按照官方的 patch 修改後,攝像頭能夠正常使用。get
若是出現能夠預覽,不能拍照的問題,還須要更改拍照的分辨率input
diff --git a/CameraHal/CameraUSBAdapter.cpp b/CameraHal/CameraUSBAdapter.cpp index b88dd17..adb446b 100644 --- a/CameraHal/CameraUSBAdapter.cpp +++ b/CameraHal/CameraUSBAdapter.cpp @@ -134,8 +134,8 @@ void CameraUSBAdapter::initDefaultParameters(int camFd) params.set(KEY_PREVIEW_W_FORCE,"0"); params.set(KEY_PREVIEW_H_FORCE,"0"); params.set(CameraParameters::KEY_SUPPORTED_PREVIEW_SIZES, "1280x960,1280x720"); params.setPreviewSize(1280, 960); /*picture size setting*/ - params.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, parameterString.string()); - params.setPictureSize(mCamDriverFrmWidthMax, mCamDriverFrmHeightMax); + params.set(CameraParameters::KEY_SUPPORTED_PICTURE_SIZES, "1280x960,1280x720"); + params.setPictureSize(1280, 960);