本文主要是介绍【Mtk Camera开发学习】06 MTK 和 Qcom 平台支持通过 Camera 标准API 打开 USBCamera,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
一、MTK平台支持通过标准接口打开USB Camera
---
mediatek/mt***/device.mk | 4 ++++
.../hal/camera/external_camera_config.xml | 20 +++++++++++++++++++
mediatek/mt***/init.mt***.rc | 5 +++++
mediatek/mt***/manifest.xml | 1 +
mediatek/mt***/ueventd.mt**.rc | 2 ++
5 files changed, 32 insertions(+)
create mode 100644 mediatek/mt***/hal/camera/external_camera_config.xml
diff --git a/mediatek/mt***/device.mk b/mediatek/mt***/device.mk
index 00e67370..f1db63b6 100644
--- a/mediatek/mt**/device.mk
+++ b/mediatek/mt**/device.mk
@@ -226,6 +226,10 @@ PRODUCT_PACKAGES +=
vendor.mediatek.hardware.camera.isphal@1.0-impl
PRODUCT_PACKAGES += camerahalserver
PRODUCT_PACKAGES += android.hardware.camera.provider@2.6-service-mediatek
PRODUCT_PACKAGES += android.hardware.camera.provider@2.6-impl-mediatek
+PRODUCT_PACKAGES += android.hardware.camera.provider@2.4-impl
+PRODUCT_PACKAGES += android.hardware.camera.provider@2.4-external-service
+PRODUCT_COPY_FILES += \
+
device/mediatek/mt***/hal/camera/external_camera_config.xml:$(TARGET_COPY_OUT_VE
NDOR)/etc/external_camera_config.xml
PRODUCT_PACKAGES += libmtkcam_device1
PRODUCT_PACKAGES += libmtkcam_device3
PRODUCT_PACKAGES += camera.mt**
diff --git a/mediatek/mt6877/hal/camera/external_camera_config.xml
b/mediatek/mt6877/hal/camera/external_camera_config.xml
new file mode 100644
index 00000000..2884e131--- /dev/null
+++ b/mediatek/mt***/hal/camera/external_camera_config.xml
@@ -0,0 +1,20 @@
+<ExternalCamera>
+ <Provider>
+ <ignore> <!-- Internal video devices to be ignored by external camera
HAL -->
+ <id>0</id>
+ <id>1</id>
+ <id>2</id>
+ <id>3</id>
+ </ignore>
+ </Provider>
+ <Device>
+ <MaxJpegBufferSize bytes="3145728"/>
+ <NumVideoBuffers count="4"/>
+ <NumStillBuffers count="2"/>
+ <FpsList>
+ <Limit width="640" height="480" fpsBound="30.0"/>
+ <Limit width="1280" height="720" fpsBound="30.0"/>
+ <Limit width="1920" height="1080" fpsBound="30.0"/>
+ </FpsList>
+ </Device>
+</ExternalCamera>diff --git a/mediatek/mt***/init.mt***.rc b/mediatek/mt***/init.mt***.rc
index 415bc50e..9b401e5f 100644
--- a/mediatek/mt***/init.mt***.rc
+++ b/mediatek/mt***/init.mt***.rc
@@ -415,6 +415,11 @@ on post-fs-data
chown media system /dev/video0
chmod 0660 /dev/video1
chown media system /dev/video1
+ chmod 0660 /dev/video5
+ chown media system /dev/video5
+ chmod 0660 /dev/video4
+ chown media system /dev/video4
+
mkdir /data/vendor/vcodec 0777 media system
mkdir /data/vendor/vcodec/log 0770 media system
mkdir /data/vendor/vcodec/in 0770 media system
diff --git a/mediatek/mt***/manifest.xml b/mediatek/mt***/manifest.xml
index 455924cb..badea3ec 100644
--- a/mediatek/mt***/manifest.xml
+++ b/mediatek/mt***/manifest.xml
@@ -27,6 +27,7 @@
<name>ICameraProvider</name>
<instance>internal/0</instance>
</interface>
+ <fqname>@2.4::ICameraProvider/external/0</fqname>
</hal>
<hal format="hidl">
<name>android.hardware.gatekeeper</name>diff --git a/mediatek/mt***/ueventd.mt***.rc b/mediatek/mt***/ueventd.mt***.rc
index 9b71ee5d..efcf2599 100644
--- a/mediatek/mt***/ueventd.mt***.rc
+++ b/mediatek/mt***/ueventd.mt***.rc
@@ -89,6 +89,8 @@
#v4l2 device
/dev/video* 0660 camera system
+/dev/video4 0666 media system
+/dev/video5 0666 media system
/dev/media* 0660 camera system
/dev/v4l-subdev* 0660 camera system
--
---
sepolicy/prebuilts/api/31.0/public/cameraserver.te | 5 +++++
sepolicy/public/cameraserver.te | 5 +++++
2 files changed, 10 insertions(+)
diff --git a/sepolicy/prebuilts/api/31.0/public/cameraserver.te
b/sepolicy/prebuilts/api/31.0/public/cameraserver.te
index 7a29240c..f08dbc7b 100644
--- a/sepolicy/prebuilts/api/31.0/public/cameraserver.te
+++ b/sepolicy/prebuilts/api/31.0/public/cameraserver.te
@@ -74,3 +74,8 @@ userdebug_or_eng(`
allow cameraserver su:fifo_file { read write };
allow cameraserver su:unix_stream_socket { read write };
')
+
+
+allow cameraserver device:dir r_dir_perms;
+allow cameraserver video_device:dir r_dir_perms;
+allow cameraserver video_device:chr_file rw_file_perms;
diff --git a/sepolicy/public/cameraserver.te b/sepolicy/public/cameraserver.te
index 7a29240c..f08dbc7b 100644
--- a/sepolicy/public/cameraserver.te
+++ b/sepolicy/public/cameraserver.te@@ -74,3 +74,8 @@ userdebug_or_eng(`
allow cameraserver su:fifo_file { read write };
allow cameraserver su:unix_stream_socket { read write };
')
+
+
+allow cameraserver device:dir r_dir_perms;
+allow cameraserver video_device:dir r_dir_perms;
+allow cameraserver video_device:chr_file rw_file_perms;
--
CONFIG_USB_VIDEO_CLASS=y
CONFIG_MEDIA_USB_SUPPORT=y
allow hal_camera_default hal_graphics_mapper_hwservice:hwservice_manager find;
11-07 15:01:26.314 D/hwcomposer( 632): (0:3) Layer+
(mva=0x0/sec=0/prot=0/fmt=1/alpha=1:0xff/blend=0002/dim=0/range=20000000/x=0 y=0
w=480 h=52 s=480 -> x=0 y=0 w=480 h=52/ext_layer=2 ds=0 fbdc=1 is_mml=0) =
11-07 15:01:26.322 E/SELinux ( 482): avc: denied { find } for
interface=android.hardware.graphics.mapper::IMapper sid=u:r:hal_camera_default:s0
pid=5451 scontext=u:r:hal_camera_default:s0
tcontext=u:object_r:hal_graphics_mapper_hwservice:s0 tclass=hwservice_manager
permissive=0
11-07 15:01:26.323 E/SELinux ( 482): avc: denied { find } for
interface=android.hardware.graphics.mapper::IMapper sid=u:r:hal_camera_default:s0
pid=5451 scontext=u:r:hal_camera_default:s0
tcontext=u:object_r:hal_graphics_mapper_hwservice:s0 tclass=hwservice_manager
permissive=0
11-07 15:01:26.323 E/SELinux ( 482): avc: denied { find } for
interface=android.hardware.graphics.mapper::IMapper sid=u:r:hal_camera_default:s0
pid=5451 scontext=u:r:hal_camera_default:s0
tcontext=u:object_r:hal_graphics_mapper_hwservice:s0 tclass=hwservice_manager
permissive=0
11-07 15:01:26.323 E/HandleImporter( 5451): initializeLocked: cannnot acccess
graphics mapper HAL!
二、Qcom 平台
<ExternalCamera>
<Provider>
<ignore> <!-- Internal video devices to be ignored by external camera HAL
-->
<id>0</id> <!-- No leading/trailing spaces -->
<id>1</id>
</ignore>
</Provider>
<!-- See ExternalCameraUtils.cpp for default values of Device configurations
below -->
<Device>
<!-- Max JPEG buffer size in bytes-->
<MaxJpegBufferSize bytes="3145728"/> <!-- 3MB (~= 1080p YUV420) -->
<!-- Size of v4l2 buffer queue when streaming >= 30fps -->
<!-- Larger value: more request can be cached pipeline (less janky) -->
<!-- Smaller value: use less memory -->
<NumVideoBuffers count="4"/>
<!-- Size of v4l2 buffer queue when streaming < 30fps -->
<NumStillBuffers count="2"/>
<!-- List of maximum fps for various output sizes -->
<!-- Any image size smaller than the size listed in Limit row will
report
fps (as minimum frame duration) up to the fpsBound value. -->
<FpsList>
<!-- width/height must be increasing, fpsBound must be decreasing-->
<Limit width="640" height="480" fpsBound="30.0"/>
<Limit width="1280" height="720" fpsBound="30.0"/>
<!-- image size larger than the last entry will not be supported-->
</FpsList>
</Device>
</ExternalCamera>
PRODUCT_PACKAGES += android.hardware.camera.provider@2.4-external-service
PRODUCT_COPY_FILES += \
device/qcom/holi/external_camera_config.xml:$(TARGET_COPY_OUT_VENDOR)/etc/extern
al_camera_config.xml
<hal format="hidl">
<name>android.hardware.camera.provider</name>
<transport>hwbinder</transport>
<version>2.4</version>
<interface>
<name>ICameraProvider</name>
<instance>legacy/0</instance>
<instance>external/0</instance> <!-- new add for usb camera-->
</interface>
</hal>
CONFIG_USB_VIDEO_CLASS=y
-----------------------------------------------------------------------------------------
文章内容所有权归@公众号:小驰行动派,禁止宣传转载,谢谢~
这篇关于【Mtk Camera开发学习】06 MTK 和 Qcom 平台支持通过 Camera 标准API 打开 USBCamera的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!