From 1b1a81a5f2319049c50098a8186fdf214383c54e Mon Sep 17 00:00:00 2001 From: John Stultz Date: Tue, 27 Jul 2021 05:38:32 +0000 Subject: db845c: Enabling usb camera Following: https://source.android.com/devices/camera/external-usb-cameras With a number of additions (like sepolicy, and permissions), in order to get it going. This patch also adds a very simple media_profiles.xml implementation which works for video recording, but adds an iffy vga (640x480) entry calling it 480p. We will likely need to tweak all this quite a bit when we add real hwcodec support or onboard camera support. Change-Id: I9db300d9eadd9246d5f1fbab40d1fcbe33336961 Signed-off-by: John Stultz --- device-common.mk | 11 ++++ etc/external_camera_config.xml | 28 ++++++++++ etc/media_profiles.xml | 118 +++++++++++++++++++++++++++++++++++++++++ manifest.xml | 10 ++++ sepolicy/hal_camera.te | 15 ++++++ ueventd.common.rc | 4 ++ 6 files changed, 186 insertions(+) create mode 100644 etc/external_camera_config.xml create mode 100644 etc/media_profiles.xml create mode 100644 sepolicy/hal_camera.te diff --git a/device-common.mk b/device-common.mk index 718d398..82d4b25 100644 --- a/device-common.mk +++ b/device-common.mk @@ -167,6 +167,17 @@ PRODUCT_COPY_FILES += \ PRODUCT_COPY_FILES += \ device/linaro/dragonboard/etc/permissions/android.software.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.xml + +# External Web Cam support +PRODUCT_PACKAGES += \ + android.hardware.camera.provider@2.4-impl \ + android.hardware.camera.provider@2.4-external-service + +PRODUCT_COPY_FILES += \ + frameworks/native/data/etc/android.hardware.camera.front.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.front.xml \ + $(LOCAL_PATH)/etc/media_profiles.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles_V1_0.xml \ + $(LOCAL_PATH)/etc/external_camera_config.xml:$(TARGET_COPY_OUT_VENDOR)/etc/external_camera_config.xml + # Keymaster PRODUCT_PACKAGES += \ android.hardware.keymaster@3.0-impl \ diff --git a/etc/external_camera_config.xml b/etc/external_camera_config.xml new file mode 100644 index 0000000..991ff40 --- /dev/null +++ b/etc/external_camera_config.xml @@ -0,0 +1,28 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/etc/media_profiles.xml b/etc/media_profiles.xml new file mode 100644 index 0000000..2ffb7a3 --- /dev/null +++ b/etc/media_profiles.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/manifest.xml b/manifest.xml index 910ec90..5f62e28 100644 --- a/manifest.xml +++ b/manifest.xml @@ -35,6 +35,16 @@ default + + android.hardware.camera.provider + hwbinder + + 2.4 + + ICameraProvider + external/0 + + android.hardware.drm hwbinder diff --git a/sepolicy/hal_camera.te b/sepolicy/hal_camera.te new file mode 100644 index 0000000..6bbc346 --- /dev/null +++ b/sepolicy/hal_camera.te @@ -0,0 +1,15 @@ +vndbinder_use(hal_camera_default); + +allow hal_camera_default hal_graphics_mapper_hwservice:hwservice_manager find; +hal_client_domain(hal_camera_default, hal_graphics_allocator); +hal_client_domain(hal_camera_default, hal_graphics_composer); + +# for external camera +allow cameraserver device:dir r_dir_perms; +allow cameraserver video_device:dir r_dir_perms; +allow cameraserver video_device:chr_file rw_file_perms; + +allow hal_camera_default gpu_device:chr_file { open read write ioctl map getattr }; +allow hal_camera_default dri_device:dir { open read search }; +allow cameraserver dri_device:dir { open read write search getattr }; +allow cameraserver gpu_device:chr_file { open read write ioctl map getattr }; diff --git a/ueventd.common.rc b/ueventd.common.rc index c0ba022..3e396f6 100644 --- a/ueventd.common.rc +++ b/ueventd.common.rc @@ -11,3 +11,7 @@ subsystem usbmisc # media.codec2 /dev/ion 0664 system system + +# usb webcam? +/dev/video0 0660 system camera +/dev/video1 0660 system camera -- cgit v1.2.3