Camera hal3 在 android 框架中所处的位置如上图, 对上,主要实现 Framework 一整套 API 接口,响应其 控制命令,返回数据与控制参数结果。 对下, 主要是通 V4l2 框架实现与 kernel 的交互。3a 控制则是通 control loop 接口与 camera_engine_isp 交互。 另外,其中一些组件或功能的实现也会调用到其他一些第三方 库, 如 cameraBuffer 相关,会调用到 Galloc 相关库, jpeg 编码则会调用到 Hwjpeg 相关库。
首先硬件给usb供电,供电后插上usbcamera可以看到新生成的pid vid。
ls /dev/video*
新生成了video1 video2.
media-ctl -d /dev/media0 -p
1|console:/ # media-ctl -d /dev/media0 -p
Opening media device /dev/media0
Enumerating entities
Found 4 entities
Enumerating pads and links
Media controller API version 0.0.189
Media device information
------------------------
driver uvcvideo
model USB2.0 PC CAMERA: USB2.0 PC CAM
serial
bus info usb-fc880000.usb-1.3
hw revision 0x100
driver version 0.0.189
Device topology
- entity 1: USB2.0 PC CAMERA: USB2.0 PC CAM (1 pad, 1 link)
type Node subtype V4L
device node name /dev/video1
pad0: Sink
<- "Processing 2":1 [ENABLED,IMMUTABLE]
- entity 4: USB2.0 PC CAMERA: USB2.0 PC CAM (0 pad, 0 link)
type Node subtype V4L
device node name /dev/video2
- entity 8: Processing 2 (2 pads, 2 links)
type V4L2 subdev subtype Unknown
pad0: Sink
v4l2_subdev_open: Failed to open subdev device node
<- "Input 1":0 [ENABLED,IMMUTABLE]
pad1: Source
v4l2_subdev_open: Failed to open subdev device node
-> "USB2.0 PC CAMERA: USB2.0 PC CAM":0 [ENABLED,IMMUTABLE]
- entity 11: Input 1 (1 pad, 1 link)
type V4L2 subdev subtype Sensor
pad0: Source
v4l2_subdev_open: Failed to open subdev device node
-> "Processing 2":0 [ENABLED,IMMUTABLE]
查看拓扑图,生成新的video1 video2.
dumpsys media.camera
onsole:/ # dumpsys media.camera
== Service global info: ==
Number of camera devices: 1
Number of normal camera devices: 1
Number of public camera devices visible to API1: 1
Device 0 maps to "101"
Active Camera Clients:
[]
Allowed user IDs: 0
== Camera service events log (most recent at top): ==
02-01 18:52:22 : ADD device 101, reason: (Device added)
02-01 18:50:29 : REMOVE device 101, reason: (Device status changed from 1 to 0)
02-01 18:08:37 : DISCONNECT device 101 client for package com.android.camera2 (PID 6195)
02-01 18:08:37 : CONNECT device 101 client for package com.android.camera2 (PID 6195)
02-01 18:06:25 : ADD device 101, reason: (Device added)
02-01 18:06:16 : REMOVE device 101, reason: (Device status changed from 1 to 0)
02-01 18:03:23 : ADD device 101, reason: (Device added)
02-01 18:01:26 : REMOVE device 101, reason: (Device status changed from 1 to 0)
02-01 18:00:53 : DISCONNECT device 101 client for package com.android.camera2 (PID 4701)
02-01 18:00:53 : CONNECT device 101 client for package com.android.camera2 (PID 4701)
02-01 18:00:34 : DISCONNECT device 101 client for package com.android.camera2 (PID 3004)
02-01 18:00:34 : CONNECT device 101 client for package com.android.camera2 (PID 3004)
02-01 18:00:29 : DISCONNECT device 101 client for package com.android.camera2 (PID 3004)
02-01 18:00:29 : CONNECT device 101 client for package com.android.camera2 (PID 3004)
02-01 18:00:04 : ADD device 101, reason: (Device added)
02-01 18:00:01 : USER_SWITCH previous allowed user IDs: , current allowed user IDs: 0
== Camera device 101 dynamic info: ==
Device 101 is closed, no client instance
== Camera Provider HAL external/0-0 (v2.5, remote) static info: 1 devices: ==
== Camera HAL device [email protected]/external/101 (v3.4) static information: ==
Resource cost: 100
Conflicting devices: None
API1 info:
Has a flash unit: false
Facing: Front
Orientation: 0
API2 camera characteristics:
Dumping camera metadata array: 55 / 55 entries, 2048 / 2048 bytes of extra data.
Version: 1, Flags: 00000000
android.info.supportedHardwareLevel (150000): byte[1]
[EXTERNAL ]
android.colorCorrection.availableAberrationModes (00004): byte[1]
[0 ]
android.control.aeAvailableAntibandingModes (10012): byte[1]
[3 ]
android.control.maxRegions (1001c): int32[3]
[0 0 0 ]
android.control.availableVideoStabilizationModes (1001a): byte[1]
[0 ]
android.control.awbAvailableModes (1001b): byte[1]
[1 ]
android.control.aeAvailableModes (10013): byte[1]
[1 ]
android.control.availableEffects (10018): byte[1]
[0 ]
android.control.availableModes (10026): byte[2]
[0 1 ]
android.edge.availableEdgeModes (30002): byte[1]
[0 ]
android.flash.info.available (50000): byte[1]
[FALSE ]
android.hotPixel.availableHotPixelModes (60001): byte[1]
[0 ]
android.jpeg.availableThumbnailSizes (70007): int32[14]
[0 0 176 144 ]
[240 144 256 144 ]
[240 160 256 154 ]
[240 180 ]
android.jpeg.maxSize (70008): int32[1]
[3145728 ]
android.lens.info.focusDistanceCalibration (90007): byte[1]
[UNCALIBRATED ]
android.lens.info.availableOpticalStabilization (90003): byte[1]
[0 ]
android.lens.facing (80005): byte[1]
[FRONT ]
android.noiseReduction.availableNoiseReductionModes (a0002): byte[1]
[0 ]
android.noiseReduction.mode (a0000): byte[1]
[OFF ]
android.request.partialResultCount (c000b): int32[1]
[1 ]
android.request.pipelineMaxDepth (c000a): byte[1]
[4 ]
android.request.maxNumOutputStreams (c0006): int32[3]
[0 2 1 ]
android.request.maxNumInputStreams (c0008): int32[1]
[0 ]
android.scaler.availableMaxDigitalZoom (d0004): float[1]
[4.00000000 ]
android.scaler.croppingType (d000d): byte[1]
[CENTER_ONLY ]
android.sensor.availableTestPatternModes (e0019): int32[2]
[0 1 ]
android.sensor.info.timestampSource (f0008): byte[1]
[UNKNOWN ]
android.sensor.orientation (e000e): int32[1]
[0 ]
android.shading.availableModes (100002): byte[1]
[0 ]
android.statistics.info.availableFaceDetectModes (120000): byte[1]
[0 ]
android.statistics.info.maxFaceCount (120002): int32[1]
[0 ]
android.statistics.info.availableHotPixelMapModes (120006): byte[1]
[0 ]
android.statistics.info.availableLensShadingMapModes (120007): byte[1]
[0 ]
android.sync.maxLatency (170001): int32[1]
[UNKNOWN ]
android.request.availableRequestKeys (c000d): int32[28]
[3 65536 65537 65538 ]
[65539 65542 65541 65543 ]
[65545 65546 65547 65549 ]
[65550 65551 65552 65553 ]
[262146 458755 458756 458757 ]
[458758 524292 655360 851968 ]
[917528 1114112 1114115 65583 ]
android.request.availableResultKeys (c000e): int32[35]
[3 65536 65537 65538 ]
[65539 65542 65567 65541 ]
[65543 65568 65545 65546 ]
[65547 65570 65549 65550 ]
[65551 65552 65553 262146 ]
[262149 458755 458756 458757 ]
[458758 524292 655360 786441 ]
[851968 917520 1114112 1114115 ]
[1114128 1114126 65583 ]
android.request.availableCharacteristicsKeys (c000f): int32[43]
[4 65554 65555 65556 ]
[65557 65558 65572 65559 ]
[65560 65574 65561 65562 ]
[65563 65573 65564 327680 ]
[1376256 458759 524293 589827 ]
[589831 655362 786444 786440 ]
[786438 786443 786442 851972 ]
[851978 851981 983040 983044 ]
[983046 983050 983048 917518 ]
[1048578 1179648 1179654 1179655 ]
[1179650 1507329 65582 ]
android.control.aeCompensationRange (10015): int32[2]
[0 0 ]
android.control.aeCompensationStep (10016): rational[1]
[(0 / 1) ]
android.control.afAvailableModes (10017): byte[2]
[1 0 ]
android.control.availableSceneModes (10019): byte[1]
[0 ]
android.control.aeLockAvailable (10024): byte[1]
[FALSE ]
android.control.awbLockAvailable (10025): byte[1]
[FALSE ]
android.scaler.availableStreamConfigurations (d000a): int32[72]
[33 160 120 OUTPUT ]
[35 160 120 OUTPUT ]
[34 160 120 OUTPUT ]
[33 176 144 OUTPUT ]
[35 176 144 OUTPUT ]
[34 176 144 OUTPUT ]
[33 320 240 OUTPUT ]
[35 320 240 OUTPUT ]
[34 320 240 OUTPUT ]
[33 352 288 OUTPUT ]
[35 352 288 OUTPUT ]
[34 352 288 OUTPUT ]
[33 640 480 OUTPUT ]
[35 640 480 OUTPUT ]
[34 640 480 OUTPUT ]
[33 800 600 OUTPUT ]
[35 800 600 OUTPUT ]
[34 800 600 OUTPUT ]
android.scaler.availableMinFrameDurations (d000b): int64[72]
[33 160 ]
[120 33333333 ]
[35 160 ]
[120 33333333 ]
[34 160 ]
[120 33333333 ]
[33 176 ]
[144 33333333 ]
[35 176 ]
[144 33333333 ]
[34 176 ]
[144 33333333 ]
[33 320 ]
[240 33333333 ]
[35 320 ]
[240 33333333 ]
[34 320 ]
[240 33333333 ]
[33 352 ]
[288 33333333 ]
[35 352 ]
[288 33333333 ]
[34 352 ]
[288 33333333 ]
[33 640 ]
[480 33333333 ]
[35 640 ]
[480 33333333 ]
[34 640 ]
[480 33333333 ]
[33 800 ]
[600 33333333 ]
[35 800 ]
[600 33333333 ]
[34 800 ]
[600 33333333 ]
android.scaler.availableStallDurations (d000c): int64[72]
[33 160 ]
[120 1000000000 ]
[35 160 ]
[120 0 ]
[34 160 ]
[120 0 ]
[33 176 ]
[144 1000000000 ]
[35 176 ]
[144 0 ]
[34 176 ]
[144 0 ]
[33 320 ]
[240 1000000000 ]
dump出来可以看到生成新的cameraid。
Number of camera devices: 1
Number of normal camera devices: 1
v4l2-ctl -d /dev/video1 --all
查看video1信息
130|console:/ # v4l2-ctl -d /dev/video1 --all
Driver Info:
Driver name : uvcvideo
Card type : USB2.0 PC CAMERA: USB2.0 PC CAM
Bus info : usb-fc880000.usb-1.3
Driver version : 5.10.189
Capabilities : 0x84a00001
Video Capture
Metadata Capture
Streaming
Extended Pix Format
Device Capabilities
Device Caps : 0x04200001
Video Capture
Streaming
Extended Pix Format
Media Driver Info:
Driver name : uvcvideo
Model : USB2.0 PC CAMERA: USB2.0 PC CAM
Serial :
Bus info : usb-fc880000.usb-1.3
Media version : 5.10.189
Hardware revision: 0x00000100 (256)
Driver version : 5.10.189
Interface Info:
ID : 0x03000002
Type : V4L Video
Entity Info:
ID : 0x00000001 (1)
Name : USB2.0 PC CAMERA: USB2.0 PC CAM
Function : V4L2 I/O
Pad 0x01000007 : Sink
Link 0x0200000d: from remote pad 0x100000a of entity 'Processing 2': Data, Enabled, Immutable
Priority: 2
Video input : 0 (Input 1: ok)
Format Video Capture:
Width/Height : 640/480
Pixel Format : 'YUYV'
Field : None
Bytes per Line : 1280
Size Image : 614400
Colorspace : Default
Transfer Function : Default (maps to Rec. 709)
YCbCr/HSV Encoding: Default (maps to ITU-R 601)
Quantization : Default (maps to Limited Range)
Flags :
Crop Capability Video Capture:
Bounds : Left 0, Top 0, Width 640, Height 480
Default : Left 0, Top 0, Width 640, Height 480
Pixel Aspect: 1/1
Selection: crop_default, Left 0, Top 0, Width 640, Height 480, Flags:
Selection: crop_bounds, Left 0, Top 0, Width 640, Height 480, Flags:
Streaming Parameters Video Capture:
Capabilities : timeperframe
Frames per second: 30.000 (30/1)
Read buffers : 0
brightness 0x00980900 (int) : min=0 max=255 step=1 default=128 value=128
contrast 0x00980901 (int) : min=0 max=255 step=1 default=135 value=135
saturation 0x00980902 (int) : min=0 max=255 step=1 default=75 value=75
hue 0x00980903 (int) : min=-127 max=127 step=1 default=0 value=0
gamma 0x00980910 (int) : min=1 max=8 step=1 default=4 value=4
power_line_frequency 0x00980918 (menu) : min=0 max=2 default=1 value=1
sharpness 0x0098091b (int) : min=0 max=15 step=1 default=5 value=5
backlight_compensation 0x0098091c (int) : min=1 max=5 step=1 default=1 value=1
v4l2-ctl -d /dev/video1 --list-formats-ext
查看video1支持的格式和分辨率
console:/ # v4l2-ctl -d /dev/video1 --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Size: Discrete 640x480
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 352x288
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 320x240
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 176x144
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
Size: Discrete 160x120
Interval: Discrete 0.033s (30.000 fps)
Interval: Discrete 0.067s (15.000 fps)
分析:此时打开usbcamera的画面是黑屏,查看hal3 camera框架里面适配的分辨率和视频格式是否支持yuvv,最大的分辨率为640*480.
待更新。。。。。。