平台:全志的Android6 ,使用的是全志A40I
出现的问题: 打开摄像头的时候,内核层没有提示任何的错误,但是在ADB里面 使用 logcat |grep V4L2 查看摄像头打印出来的信息
提示以下两句话:
返回源代码找到对应的文件是在:V4L2CameraDevice2.cpp 里面获取摄像头传感器类型出现了错误:便是一下函数的ioctl()出现了错误。
int V4L2CameraDevice::getSensorType()
{
........
ctrl.id = V4L2_CID_SENSOR_TYPE; // 是这个宏有问题 匹配不上
qc_ctrl.id = V4L2_CID_SENSOR_TYPE; //
if (-1 == ioctl (mCameraFd, VIDIOC_QUERYCTRL, &qc_ctrl))
{
LOGE("query sensor type ctrl failed");
return -1;
}
ret = ioctl(mCameraFd, VIDIOC_G_CTRL, &ctrl);
return ctrl.value;
}
经过内核打印和对比之后发现是 V4L2_CID_SENSOR_TYPE这个宏有问题,进一步查看HAL的这个宏的定义在对应的videodev2_34.h里面发现
#define V4L2_CID_PRIVATE_BASE 0x08000000
V4L2_CID_SENSOR_TYPE (V4L2_CID_PRIVATE_BASE+16)
但是在内核层查看比较对应的宏之后发现;这个宏又是这样定义的,真是醉了。
#define V4L2_CTRL_CLASS_USER 0x00980000 /* Old-style 'user' controls */
#define V4L2_CID_BASE (V4L2_CTRL_CLASS_USER | 0x900)
#define V4L2_CID_USER_BASE (V4L2_CID_BASE)
#define V4L2_CID_USER_SUNXI_CAMERA_BASE (V4L2_CID_USER_BASE + 0x1050)
#define V4L2_CID_SENSOR_TYPE (V4L2_CID_USER_SUNXI_CAMERA_BASE+13)
但是在HAL层的videodev2_34.h 文件里面也有内核上面的定义但是并没有用。
有遇到这个问题的大神麻烦帮小弟看一下,究竟是修改内核的参数来配合HAL的宏好 ,还是修改HAL层的宏来匹配内核的。
查找内核层的头文件里面也有这个定义:
#define V4L2_CID_PRIVATE_BASE 0x08000000
但是,但是,但是居然没有定义这个宏 V4L2_CID_SENSOR_TYPE 。给的SDK都是这么不严谨的么。
在这里请教一下大家了,谢谢
离线
没看出来, 帮你顶一下吧。
晕哥 在 V4L2CameraDevice2.cpp文件里面发现这个有头文件定义。#include <sunxi_camera.h>头文件里面定义的就符合内核ioctl命令。
会不会是我选择的平台有关啊。 但是我这个是A40I不是A64。疑惑的是这里的A64是他的芯片还是说对应的的arm64
#ifdef __PLATFORM_A64__
#include <sunxi_camera.h>
#else
#include <videodev2_34.h>
#endif
离线
https://linux-sunxi.org/A40i
https://linux-sunxi.org/A64感觉应该 A40I不是A64
不确定的话就这样:
#ifdef __PLATFORM_A64__
#include <sunxi_camera.h>
#error "----------error A64----------"
#else
#include <videodev2_34.h>
#error "----------error A40i----------"
#endif看编译的时候, 输出什么信息。
编译过后启动的#include <videodev2_34.h>这个头文件。 但是使用这个头文件会出现一个错误,就是访问内核VFE.C的ioctl函数的命令会出错
比较之后,VFE.C文件适配的头文件应该是#include <sunxi_camera.h>。 做了两套改变
①、试图将#ifdef __PLATFORM_A64__ 全部调换成#ifdef __PLATFORM_A40__是可以编译成功的。也没有提示说因为ioctl函数的调用错误的提示
了。 但是开机点击开机应用只有MCLK引脚有信号,其他引脚都没有信号
②、将videodev2_34.h里面的ioctl命令替换成sunxi_camera.h里面的,仅仅是替换几个命令,其他东西没有改变,图像不出但是各个引脚出现一些电平
信号了,这个就很奇怪。
离线
使用①方案的时候,没有出现图像仅仅就是CSI的MCLK引脚时钟有信号。
在ADB下面使用: logcat |grep Camera 打印出以下内容。(由于对安卓懂得不多,这个命令查看一下,有知道其他的朋友希望不啬赐教。 谢谢)
30|root@azalea-m2ultra:/ # logcat |grep Camera
1-02 14:10:34.577 1758 1758 I CameraService: CameraService started (pid=1758)
1-02 14:10:34.577 1758 1758 I CameraService: CameraService process starting
1-02 14:10:35.204 1758 1758 D HALCameraFactory: camera hal version: 3000130327_V1.0
1-02 14:10:35.211 1758 1758 D HALCameraFactory: There is 1 attached cameras and 0 removable cameras
1-02 14:10:35.211 1758 1758 I CameraService: Loaded "V4L2Camera Module" camera module
1-02 14:10:35.211 1758 1758 D HALCameraFactory: There is 1 attached cameras and 0 removable cameras
1-02 14:10:35.211 1758 1758 D HALCameraFactory: There is 1 attached cameras and 0 removable cameras
1-02 14:10:35.211 1758 1758 I CameraFlashlight: Opening camera 0
1-02 14:10:35.211 1758 1758 D HALCameraFactory: Calling process is: /system/bin/mediaserver
1-02 14:10:35.211 1758 1758 E V4L2CameraDevice: USE_ION_MEM_ALLOCATOR
1-02 14:10:35.242 1758 1758 E V4L2CameraDevice: open HAL_info_name = /dev/video0
1-02 14:10:35.487 1758 1758 E V4L2CameraDevice: openCameraDev ok
1-02 14:10:35.488 1758 1758 D HALCameraFactory: Calling process is: /system/bin/mediaserver
1-02 14:10:35.512 1758 2243 W CameraHardware: CMD_QUEUE_STOP_FACE_DETECTE failed, mFaceDetection not opened.
1-02 14:10:35.664 1758 1758 I CameraFlashlight: Destroying camera 0
1-02 14:10:35.765 1758 1758 D HALCameraFactory: Calling process is: /system/bin/mediaserver
1-02 14:10:41.866 2516 2516 I SystemServer: Camera Service
1-02 14:10:41.867 2516 2516 I SystemServiceManager: Starting com.android.server.camera.CameraService
1-02 14:10:45.475 3364 3364 I CameraManagerGlobal: Connecting to camera service
1-02 14:10:45.483 1758 1758 I CameraService: getCameraCharacteristics: Switching to HAL1 shim implementation...
1-02 14:10:45.484 1758 1758 D HALCameraFactory: Calling process is: com.android.systemui
1-02 14:10:45.484 1758 1758 I CameraService: CameraService::connect call (PID 1758 "media", camera ID 0) for HAL version default and Camera API version 1
1-02 14:10:45.485 1758 1758 E CameraService: getCameraPriorityFromProcState: Received invalid process state -1 from ActivityManagerService!
1-02 14:10:45.485 1758 1758 D HALCameraFactory: There is 1 attached cameras and 0 removable cameras
1-02 14:10:45.485 1758 1758 D HALCameraFactory: Calling process is: /system/bin/mediaserver
1-02 14:10:45.551 1758 1758 I CameraClient: Opening camera 0
1-02 14:10:45.551 1758 1758 D HALCameraFactory: Calling process is: /system/bin/mediaserver
1-02 14:10:45.582 1758 1758 E V4L2CameraDevice: open HAL_info_name = /dev/video0
1-02 14:10:45.818 1758 1758 E V4L2CameraDevice: openCameraDev ok
1-02 14:10:45.819 1758 1758 D HALCameraFactory: Calling process is: /system/bin/mediaserver
1-02 14:10:45.821 1758 2243 W CameraHardware: CMD_QUEUE_STOP_FACE_DETECTE failed, mFaceDetection not opened.
1-02 14:10:45.997 1758 1758 I CameraFlashlight: Destroying camera 0
1-02 14:10:46.105 1758 1758 D HALCameraFactory: There is 1 attached cameras and 0 removable cameras
1-02 14:10:46.112 1758 1758 I CameraService: disconnect: Disconnected client for camera 0 for PID 1758
1-02 14:10:46.119 1758 3939 D HALCameraFactory: Calling process is: com.android.systemui
1-02 14:10:46.130 1758 3292 D HALCameraFactory: Calling process is: com.android.systemui
1-02 16:45:40.749 2516 2574 I ActivityManager: START u0 {act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.android.camera2/com.android.camera.CameraLauncher bnds=[186,659][319,747] (ha
extras)} from uid 10006 on display 0
1-02 16:45:40.812 2516 2575 I ActivityManager: Start proc 9109:com.android.camera2/u0a21 for activity com.android.camera2/com.android.camera.CameraLauncher
1-02 16:45:41.001 9109 9109 V CAM_Profiler: [ 0.000ms][ui] GUARD: CameraApp onCreate() - START
1-02 16:45:41.012 9109 9109 I CAM_Profiler: [ 21.770ms][ui] GUARD: CameraApp onCreate() - [21.770ms] initializeTimeOfFirstRun
1-02 16:45:41.013 9109 9109 V CAM_Profiler: [ 22.674ms][ui] GUARD: CameraApp onCreate() - [ 0.904ms] UsageStatistics.initialize
1-02 16:45:41.018 9109 9109 V CAM_Profiler: [ 27.353ms][ui] GUARD: CameraApp onCreate() - [ 4.678ms] clearNotifications
1-02 16:45:41.018 9109 9109 I CAM_Profiler: [ 27.353ms][ui] GUARD: CameraApp onCreate() - STOP
1-02 16:45:41.038 9109 9109 V CAM_QuickActivity: START onCreate: Activity = com.android.camera.CameraActivity@7b9f38e
1-02 16:45:41.038 9109 9109 V CAM_Profiler: [ 0.000ms][ui] GUARD: CameraActivity.onCreateTasks - START
1-02 16:45:41.156 9109 9109 I CAM_Profiler: [116.961ms][ui] GUARD: CameraActivity.onCreateTasks - [44.646ms] Glide.setup
1-02 16:45:41.159 9109 9109 V CAM_Profiler: [120.970ms][ui] GUARD: CameraActivity.onCreateTasks - [ 4.009ms] OneCameraManager.get
1-02 16:45:41.175 9109 9109 I CameraManagerGlobal: Connecting to camera service
1-02 16:45:41.182 1758 3139 I CameraService: getCameraCharacteristics: Switching to HAL1 shim implementation...
1-02 16:45:41.182 1758 3139 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.189 1758 1758 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.199 1758 3139 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.209 9109 9109 V CAM_Profiler: [170.227ms][ui] GUARD: CameraActivity.onCreateTasks - [10.681ms] computePictureSizes
1-02 16:45:41.452 9109 9109 I CAM_Profiler: [413.129ms][ui] GUARD: CameraActivity.onCreateTasks - [239.571ms] setContentView()
1-02 16:45:41.479 9109 9109 I CAM_Profiler: [440.704ms][ui] GUARD: CameraActivity.onCreateTasks - [27.576ms] Configure Camera UI
1-02 16:45:41.497 9109 9109 V CAM_CameraController: Closing camera
1-02 16:45:41.506 9109 9109 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@e6c2f2b]
1-02 16:45:41.515 9109 9109 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@e6c2f2b, com.android.camera.ButtonManager@dc0ec34]
1-02 16:45:41.515 9109 9109 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@e6c2f2b, com.android.camera.ButtonManager@dc0ec34, com.android.camera.widget.IndicatorIconController@6fc3fd2]
1-02 16:45:41.516 9109 9109 V CAM_Profiler: [477.669ms][ui] GUARD: CameraActivity.onCreateTasks - [10.549ms] Init Current Module UI
1-02 16:45:41.521 9109 9109 D CAM_Camera2OneCamMgr: Getting First BACK Camera
1-02 16:45:41.521 1758 1758 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.523 1758 3139 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.537 1758 3982 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.538 1758 3981 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.554 9109 9109 I CAM_Profiler: [515.696ms][ui] GUARD: CameraActivity.onCreateTasks - [38.028ms] Init CurrentModule
1-02 16:45:41.566 9109 9109 I CAM_Profiler: [527.757ms][ui] GUARD: CameraActivity.onCreateTasks - STOP
1-02 16:45:41.566 9109 9109 V CAM_QuickActivity: END onCreate: Activity = com.android.camera.CameraActivity@7b9f38e
1-02 16:45:41.571 9109 9109 V CAM_QuickActivity: START onStart: Activity = com.android.camera.CameraActivity@7b9f38e
1-02 16:45:41.581 9109 9109 V CAM_QuickActivity: END onStart: Activity = com.android.camera.CameraActivity@7b9f38e
1-02 16:45:41.581 9109 9109 V CAM_QuickActivity: START onResume: Activity = com.android.camera.CameraActivity@7b9f38e
1-02 16:45:41.585 9109 9109 V CAM_Profiler: [ 0.000ms][ui] GUARD: CameraActivity.resume - START
1-02 16:45:41.586 9109 9109 V CAM_CameraActivity: Build info: azalea_m2ultra-eng 6.0.1 MOB30R 20191107 test-keys
1-02 16:45:41.627 9109 9187 V CAM_CameraDataAdapter: retrieved photo metadata, number of items: 0
1-02 16:45:41.627 9109 9187 V CAM_CameraDataAdapter: retrieved video metadata, number of items: 0
1-02 16:45:41.627 9109 9187 V CAM_CameraDataAdapter: sorting video/photo metadata
1-02 16:45:41.630 9109 9187 V CAM_CameraDataAdapter: sorted video/photo metadata
1-02 16:45:41.631 9109 9109 I CAM_Profiler: [ 45.793ms][ui] GUARD: CameraActivity.resume - [35.718ms] mCurrentModule.resume
1-02 16:45:41.633 9109 9109 V CAM_Profiler: [ 48.248ms][ui] GUARD: CameraActivity.resume - [ 0.083ms] mPanoramaViewHelper.onResume()
1-02 16:45:41.634 9109 9109 I CAM_Profiler: [ 48.767ms][ui] GUARD: CameraActivity.resume - STOP
1-02 16:45:41.634 9109 9109 V CAM_QuickActivity: END onResume: Activity = com.android.camera.CameraActivity@7b9f38e
1-02 16:45:41.669 9109 9109 V CAM_CameraActivity: ignoring storage callback after activity pause
1-02 16:45:41.929 9109 9109 V CAM_CameraAppUI: SurfaceTexture is available
1-02 16:45:41.933 9109 9229 V CAM_Profiler: [ 0.000ms] GUARD: CaptureModule.closeCamera() - START
1-02 16:45:41.933 9109 9229 V CAM_Profiler: [ 0.683ms] GUARD: CaptureModule.closeCamera() - [ 0.683ms] mCameraOpenCloseLock.acquire()
1-02 16:45:41.934 9109 9229 V CAM_Profiler: [ 0.997ms] GUARD: CaptureModule.closeCamera() - STOP
1-02 16:45:41.934 9109 9229 V CAM_Profiler: [ 0.000ms] GUARD: CaptureModule.openCameraAndStartPreview() - START
1-02 16:45:41.934 9109 9229 V CAM_Profiler: [ 0.233ms] GUARD: CaptureModule.openCameraAndStartPreview() - [ 0.233ms] Acquired mCameraOpenCloseLock
1-02 16:45:41.935 9109 9229 D CAM_Camera2OneCamMgr: Getting First BACK Camera
1-02 16:45:41.936 1758 3939 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.938 1758 3292 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.945 9109 9229 I CAM_OneCamera1Opnr: Opening Camera: CameraId{Api2='0',Api1:0}
1-02 16:45:41.948 1758 3139 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.949 9109 9109 V CAM_CameraDataAdapter: new photos query return num items: 0
1-02 16:45:41.953 1758 3982 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.954 2516 2910 I ActivityManager: Displayed com.android.camera2/com.android.camera.CameraLauncher: +1s167ms
1-02 16:45:41.964 1758 9195 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:41.967 9109 9229 I CameraManager: Using legacy camera HAL.
1-02 16:45:41.975 1758 3939 I CameraService: CameraService::connect call (PID 9109 "com.android.camera2", camera ID 0) for HAL version default and Camera API version 1
1-02 16:45:41.977 1758 3939 D HALCameraFactory: There is 1 attached cameras and 0 removable cameras
1-02 16:45:41.977 1758 3939 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:42.036 1758 3939 I CameraClient: Opening camera 0
1-02 16:45:42.036 1758 3939 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:42.067 1758 3939 E V4L2CameraDevice: open HAL_info_name = /dev/video0
1-02 16:45:42.318 1758 3939 E V4L2CameraDevice: openCameraDev ok
1-02 16:45:42.319 1758 3939 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:42.334 1758 3139 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:42.371 9109 9229 I CAM_Profiler: [436.960ms] GUARD: CaptureModule.openCameraAndStartPreview() - [436.727ms] mOneCameraOpener.open()
1-02 16:45:42.372 1758 3982 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:42.372 9109 9229 I CAM_Profiler: [436.960ms] GUARD: CaptureModule.openCameraAndStartPreview() - STOP
1-02 16:45:42.382 1758 3939 D HALCameraFactory: Calling process is: com.android.camera2
1-02 16:45:42.393 9109 9180 I CAM_OneCamCreator: Camera support level: LEGACY_JPEG
1-02 16:45:42.434 9109 9180 D CAM_CaptureModule: onCameraOpened: com.android.camera.one.v2.initialization.GenericOneCameraImpl@11360fb
1-02 16:45:42.443 9109 9180 I CameraDeviceState: Legacy camera service transitioning to state CONFIGURING
1-02 16:45:42.447 9109 9269 D Camera : app passed NULL surface
1-02 16:45:42.479 9109 9180 I CameraDeviceState: Legacy camera service transitioning to state IDLE
1-02 16:45:42.496 9109 9180 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@e6c2f2b, com.android.camera.ButtonManager@dc0ec34, com.android.camera.widget.IndicatorIconController@6fc3fd2, com.android.camera.
ettings.SettingObserver$Listener@a15d448]
1-02 16:45:42.496 9109 9180 V CAM_SettingsManager: listeners: [com.android.camera.app.CameraAppUI@e6c2f2b, com.android.camera.ButtonManager@dc0ec34, com.android.camera.widget.IndicatorIconController@6fc3fd2, com.android.camera.
ettings.SettingObserver$Listener@a15d448, com.android.camera.settings.SettingObserver$Listener@e137806]
1-02 16:45:42.505 9109 9109 V CAM_CameraAppUI: onPreviewStarted
1-02 16:45:42.523 1758 9195 D CameraHardware: Starting camera, Size:640x480 , picture format:yuv420sp
1-02 16:45:42.523 1758 9195 D V4L2CameraDevice: startDevice, wxh: 640x480, fmt: 825382478
1-02 16:45:44.774 1758 2238 E V4L2CameraDevice: select timeout
2238 W V4L2CameraDevice: wait v4l2 buffer time out
1-02238 W V4L2CameraDevice: preview queue has 0 items.
1-02 16:45:46.776 1758 2238 E V4L2CameraDevice: select timeout
1-02 16:45:46.776 1758 2238 W V4L2CameraDevice: wait v4l2 buffer time out
1-02 16:45:46.776 1758 2238 W V4L2CameraDevice: preview queue has 0 items.
1-02 16:45:46.778 9109 9269 I CameraDeviceState: Legacy camera service transitioning to state CAPTURING
1-02 16:45:48.776 1758 2238 E V4L2CameraDevice: select timeout
1-02 16:45:48.776 1758 2238 W V4L2CameraDevice: wait v4l2 buffer time out
最近编辑记录 2505300733 (2019-11-21 14:23:03)
离线
顶一下 看看有没有大佬 路过
离线