Compare commits
88 Commits
android-12
...
android-14
Author | SHA1 | Date | |
---|---|---|---|
|
57cdc04899 | ||
|
073f50878f | ||
|
973797e543 | ||
|
b7ac80d55f | ||
|
eef70eed76 | ||
|
49655668d2 | ||
|
e47485495e | ||
|
d9457507d1 | ||
|
9dd0d06c97 | ||
|
810864227d | ||
|
77d8091ba1 | ||
|
f5db2884d7 | ||
|
38a5c9ff94 | ||
|
0205059ddb | ||
|
ef056e1f91 | ||
|
51d93e9116 | ||
|
54a1d67860 | ||
|
cafac234ff | ||
|
c1f7f3e677 | ||
|
c4a082a910 | ||
|
8a64b0130c | ||
|
58de1fd5f1 | ||
|
3f4462dd77 | ||
|
1ac293a581 | ||
|
99f26e997f | ||
|
2632bb5db3 | ||
|
eeeab1fb7e | ||
|
2dc938adef | ||
|
a1b1670f1c | ||
|
31b0958771 | ||
|
d1476ec29f | ||
|
c9cb165c19 | ||
|
2df5bd40b4 | ||
|
003d08a615 | ||
|
29e89ed615 | ||
|
7e2e50fdb5 | ||
|
68d59d4e59 | ||
|
5193e6ce38 | ||
|
f396cbd7cd | ||
|
f40e2e0b3f | ||
|
8ed26e6ce0 | ||
|
b194bfeb50 | ||
|
f973ec3b27 | ||
|
d2d71de351 | ||
|
91e679f985 | ||
|
a44c8a0e42 | ||
|
b11baea4dd | ||
|
cc4df73839 | ||
|
18cc1bd154 | ||
|
8c2871ed29 | ||
|
1c8d67b68d | ||
|
1273c5706f | ||
|
441fee39c8 | ||
|
c0a8378d8b | ||
|
6dd65fa73f | ||
|
9d97214096 | ||
|
2c74170885 | ||
|
fa4e05caab | ||
|
aa699b1415 | ||
|
30b46be80b | ||
|
7e49f1dadb | ||
|
5aefdbab09 | ||
|
4c17ea10df | ||
|
cac7486609 | ||
|
6f2c07f589 | ||
|
cccd7a63ec | ||
|
c6ecc0a1dd | ||
|
f74ee1fc3d | ||
|
53a5d230cc | ||
|
1b30e93a6a | ||
|
e0a401b461 | ||
|
526eb3759b | ||
|
2207df9355 | ||
|
a6453efdef | ||
|
dc1fc3a6e3 | ||
|
4bb647b2d6 | ||
|
523369cab2 | ||
|
9b826f72b8 | ||
|
8150438454 | ||
|
5ca6214215 | ||
|
203db632fa | ||
|
1e8030c243 | ||
|
3ca55b2c31 | ||
|
1951d76f1e | ||
|
7c245cd045 | ||
|
cc22a51844 | ||
|
8c709130cd | ||
|
c76b23f21e |
@@ -1,11 +1,15 @@
|
||||
#
|
||||
# Copyright (C) 2021-2022 KonstaKANG
|
||||
# Copyright (C) 2021-2023 KonstaKANG
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
PRODUCT_MAKEFILES := \
|
||||
$(LOCAL_DIR)/aosp_rpi4.mk
|
||||
$(LOCAL_DIR)/aosp_rpi4.mk \
|
||||
$(LOCAL_DIR)/aosp_rpi4_car.mk \
|
||||
$(LOCAL_DIR)/aosp_rpi4_tv.mk
|
||||
|
||||
COMMON_LUNCH_CHOICES := \
|
||||
aosp_rpi4-userdebug
|
||||
aosp_rpi4-userdebug \
|
||||
aosp_rpi4_car-userdebug \
|
||||
aosp_rpi4_tv-userdebug
|
||||
|
@@ -26,19 +26,18 @@ TARGET_2ND_CPU_VARIANT := cortex-a72
|
||||
|
||||
# Bluetooth
|
||||
BOARD_BLUETOOTH_BDROID_BUILDCFG_INCLUDE_DIR := $(DEVICE_PATH)/bluetooth
|
||||
BOARD_CUSTOM_BT_CONFIG := $(DEVICE_PATH)/bluetooth/vnd_rpi4.txt
|
||||
BOARD_HAVE_BLUETOOTH := true
|
||||
BOARD_HAVE_BLUETOOTH_BCM := true
|
||||
|
||||
# Camera
|
||||
BOARD_LIBCAMERA_IPAS := raspberrypi
|
||||
BOARD_LIBCAMERA_PIPELINES := raspberrypi
|
||||
BOARD_LIBCAMERA_IPAS := rpi/vc4
|
||||
BOARD_LIBCAMERA_PIPELINES := rpi/vc4
|
||||
BOARD_LIBCAMERA_USES_MESON_BUILD := true
|
||||
|
||||
# Display
|
||||
TARGET_SCREEN_DENSITY := 240
|
||||
|
||||
# Graphics
|
||||
BOARD_MESA3D_BUILD_LIBGBM := true
|
||||
BOARD_MESA3D_USES_MESON_BUILD := true
|
||||
BOARD_MESA3D_GALLIUM_DRIVERS := vc4 v3d
|
||||
BOARD_MESA3D_VULKAN_DRIVERS := broadcom
|
||||
@@ -49,12 +48,10 @@ BOARD_CUSTOM_BOOTIMG_MK := $(DEVICE_PATH)/mkbootimg.mk
|
||||
BOARD_KERNEL_CMDLINE := console=ttyS0,115200 no_console_suspend root=/dev/ram0 rootwait androidboot.hardware=rpi4
|
||||
|
||||
# Manifest
|
||||
DEVICE_FRAMEWORK_COMPATIBILITY_MATRIX_FILE := $(DEVICE_PATH)/framework_compatibility_matrix.xml
|
||||
DEVICE_MANIFEST_FILE := $(DEVICE_PATH)/manifest.xml
|
||||
DEVICE_MATRIX_FILE := $(DEVICE_PATH)/compatibility_matrix.xml
|
||||
|
||||
# Media
|
||||
TARGET_ENABLE_MEDIADRM_64 := true
|
||||
|
||||
# Partition sizes
|
||||
BOARD_FLASH_BLOCK_SIZE := 4096
|
||||
BOARD_BOOTIMAGE_PARTITION_SIZE := 134217728 # 128M
|
||||
|
@@ -1 +1 @@
|
||||
Raspberry Vanilla AOSP 12 device configuration for Raspberry Pi 4.
|
||||
Raspberry Vanilla AOSP 14 device configuration for Raspberry Pi 4.
|
||||
|
19
aosp_rpi4.mk
19
aosp_rpi4.mk
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2021-2022 KonstaKANG
|
||||
# Copyright (C) 2021-2023 KonstaKANG
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@@ -7,6 +7,23 @@
|
||||
# Inherit device configuration
|
||||
$(call inherit-product, device/brcm/rpi4/device.mk)
|
||||
|
||||
PRODUCT_AAPT_CONFIG := normal mdpi hdpi
|
||||
PRODUCT_AAPT_PREF_CONFIG := hdpi
|
||||
PRODUCT_CHARACTERISTICS := tablet,nosdcard
|
||||
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
|
||||
|
||||
# Overlays
|
||||
PRODUCT_PACKAGES += \
|
||||
AndroidRpiOverlay \
|
||||
SettingsRpiOverlay \
|
||||
SettingsProviderRpiOverlay \
|
||||
SystemUIRpiOverlay \
|
||||
WifiRpiOverlay
|
||||
|
||||
# Permissions
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/tablet_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/tablet_core_hardware.xml
|
||||
|
||||
# Device identifier. This must come after all inclusions.
|
||||
PRODUCT_DEVICE := rpi4
|
||||
PRODUCT_NAME := aosp_rpi4
|
||||
|
79
aosp_rpi4_car.mk
Normal file
79
aosp_rpi4_car.mk
Normal file
@@ -0,0 +1,79 @@
|
||||
#
|
||||
# Copyright (C) 2021-2023 KonstaKANG
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
# Inherit device configuration
|
||||
$(call inherit-product, device/brcm/rpi4/device.mk)
|
||||
|
||||
PRODUCT_AAPT_CONFIG := normal mdpi hdpi
|
||||
PRODUCT_AAPT_PREF_CONFIG := hdpi
|
||||
PRODUCT_CHARACTERISTICS := automotive,nosdcard
|
||||
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
|
||||
$(call inherit-product, packages/services/Car/car_product/build/car.mk)
|
||||
|
||||
# Bluetooth
|
||||
PRODUCT_VENDOR_PROPERTIES += \
|
||||
bluetooth.device.class_of_device=38,4,8 \
|
||||
bluetooth.profile.a2dp.source.enabled=false \
|
||||
bluetooth.profile.asha.central.enabled=false \
|
||||
bluetooth.profile.bap.broadcast.assist.enabled=false \
|
||||
bluetooth.profile.bap.unicast.client.enabled=false \
|
||||
bluetooth.profile.bas.client.enabled=false \
|
||||
bluetooth.profile.ccp.server.enabled=false \
|
||||
bluetooth.profile.csip.set_coordinator.enabled=false \
|
||||
bluetooth.profile.hap.client.enabled=false \
|
||||
bluetooth.profile.hfp.ag.enabled=false \
|
||||
bluetooth.profile.hid.device.enabled=false \
|
||||
bluetooth.profile.hid.host.enabled=false \
|
||||
bluetooth.profile.map.client.enabled=false \
|
||||
bluetooth.profile.map.server.enabled=false \
|
||||
bluetooth.profile.mcp.server.enabled=false \
|
||||
bluetooth.profile.opp.enabled=false \
|
||||
bluetooth.profile.pbap.server.enabled=false \
|
||||
bluetooth.profile.sap.server.enabled=false \
|
||||
bluetooth.profile.vcp.controller.enabled=false
|
||||
|
||||
# Broadcast radio
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.broadcastradio-service.default
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.hardware.broadcastradio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.broadcastradio.xml
|
||||
|
||||
# Camera
|
||||
ENABLE_CAMERA_SERVICE := true
|
||||
|
||||
# EVS
|
||||
ENABLE_CAREVSSERVICE_SAMPLE := true
|
||||
ENABLE_EVS_SAMPLE := true
|
||||
ENABLE_EVS_SERVICE := true
|
||||
ENABLE_REAR_VIEW_CAMERA_SAMPLE := true
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/brcm/rpi4/camera/evs_config_override.json:${TARGET_COPY_OUT_VENDOR}/etc/automotive/evs/config_override.json
|
||||
|
||||
# Overlays
|
||||
PRODUCT_PACKAGES += \
|
||||
AndroidRpiOverlay \
|
||||
CarServiceRpiOverlay \
|
||||
SettingsProviderRpiOverlay \
|
||||
WifiRpiOverlay
|
||||
|
||||
# Permissions
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.software.activities_on_secondary_displays.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.activities_on_secondary_displays.xml \
|
||||
frameworks/native/data/etc/car_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/car_core_hardware.xml
|
||||
|
||||
# Vehicle
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.automotive.vehicle@2.0-default-service
|
||||
|
||||
# Device identifier. This must come after all inclusions.
|
||||
PRODUCT_DEVICE := rpi4
|
||||
PRODUCT_NAME := aosp_rpi4_car
|
||||
PRODUCT_BRAND := Raspberry
|
||||
PRODUCT_MODEL := Raspberry Pi 4
|
||||
PRODUCT_MANUFACTURER := Raspberry
|
||||
PRODUCT_RELEASE_NAME := Raspberry Pi 4
|
42
aosp_rpi4_tv.mk
Normal file
42
aosp_rpi4_tv.mk
Normal file
@@ -0,0 +1,42 @@
|
||||
#
|
||||
# Copyright (C) 2021-2023 KonstaKANG
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
# Inherit device configuration
|
||||
$(call inherit-product, device/brcm/rpi4/device.mk)
|
||||
|
||||
PRODUCT_AAPT_PREF_CONFIG := tvdpi
|
||||
PRODUCT_CHARACTERISTICS := tv
|
||||
$(call inherit-product, device/google/atv/products/atv_base.mk)
|
||||
|
||||
# Android TV
|
||||
PRODUCT_PACKAGES += \
|
||||
DocumentsUI \
|
||||
LeanbackIME \
|
||||
TvProvision \
|
||||
TvSampleLeanbackLauncher \
|
||||
TvSettingsTwoPanel
|
||||
|
||||
# Bluetooth
|
||||
PRODUCT_VENDOR_PROPERTIES += \
|
||||
bluetooth.device.class_of_device=34,4,36
|
||||
|
||||
# Boot animation
|
||||
PRODUCT_COPY_FILES += \
|
||||
device/google/atv/products/bootanimations/bootanimation.zip:$(TARGET_COPY_OUT_SYSTEM)/media/bootanimation.zip
|
||||
|
||||
# Overlays
|
||||
PRODUCT_PACKAGES += \
|
||||
AndroidTvRpiOverlay \
|
||||
SettingsProviderTvRpiOverlay \
|
||||
WifiRpiOverlay
|
||||
|
||||
# Device identifier. This must come after all inclusions.
|
||||
PRODUCT_DEVICE := rpi4
|
||||
PRODUCT_NAME := aosp_rpi4_tv
|
||||
PRODUCT_BRAND := Raspberry
|
||||
PRODUCT_MODEL := Raspberry Pi 4
|
||||
PRODUCT_MANUFACTURER := Raspberry
|
||||
PRODUCT_RELEASE_NAME := Raspberry Pi 4
|
@@ -1,5 +1,5 @@
|
||||
// Copyright (C) 2015 The Android Open Source Project
|
||||
// Copyright (C) 2021-2022 KonstaKANG
|
||||
// Copyright (C) 2021-2023 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
@@ -22,3 +22,22 @@ cc_library_shared {
|
||||
],
|
||||
cflags: ["-Wno-unused-parameter"],
|
||||
}
|
||||
|
||||
cc_library_shared {
|
||||
name: "audio.primary.rpi_hdmi",
|
||||
relative_install_path: "hw",
|
||||
proprietary: true,
|
||||
srcs: ["audio_hw_hdmi.c"],
|
||||
include_dirs: [
|
||||
"external/expat/lib",
|
||||
"system/media/audio_effects/include",
|
||||
"system/media/audio_utils/include",
|
||||
],
|
||||
header_libs: ["libhardware_headers"],
|
||||
shared_libs: [
|
||||
"libcutils",
|
||||
"liblog",
|
||||
"libasound",
|
||||
],
|
||||
cflags: ["-Wno-unused-parameter"],
|
||||
}
|
||||
|
@@ -84,9 +84,44 @@ struct alsa_stream_out {
|
||||
unsigned int written;
|
||||
};
|
||||
|
||||
static int probe_pcm_out_card() {
|
||||
FILE *fp;
|
||||
char card_node[] = "/proc/asound/card0/id";
|
||||
char card_id[64];
|
||||
|
||||
char card_prop[PROPERTY_VALUE_MAX];
|
||||
property_get("persist.audio.device", card_prop, "");
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
card_node[17] = i + '0';
|
||||
if ((fp = fopen(card_node, "r")) != NULL) {
|
||||
fgets(card_id, sizeof(card_id), fp);
|
||||
ALOGV("%s: %s", card_node, card_id);
|
||||
if (!strcmp(card_prop, "jack") && !strncmp(card_id, "Headphones", 10)) {
|
||||
fclose(fp);
|
||||
ALOGI("Using PCM card %d for 3.5mm audio jack", i);
|
||||
return i;
|
||||
} else if (!strcmp(card_prop, "dac") && strncmp(card_id, "Headphones", 10)
|
||||
&& strncmp(card_id, "vc4hdmi", 7)) {
|
||||
fclose(fp);
|
||||
ALOGI("Using PCM card %d for audio DAC %s", i, card_id);
|
||||
return i;
|
||||
}
|
||||
fclose(fp);
|
||||
}
|
||||
}
|
||||
|
||||
ALOGE("Could not probe PCM card for %s, using PCM card 0", card_prop);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int get_pcm_card()
|
||||
{
|
||||
char card[PROPERTY_VALUE_MAX];
|
||||
property_get("persist.audio.pcm.card.auto", card, "false");
|
||||
if (!strcmp(card, "true"))
|
||||
return probe_pcm_out_card();
|
||||
|
||||
property_get("persist.audio.pcm.card", card, "0");
|
||||
return atoi(card);
|
||||
}
|
||||
|
770
audio/audio_hw_hdmi.c
Normal file
770
audio/audio_hw_hdmi.c
Normal file
@@ -0,0 +1,770 @@
|
||||
/*
|
||||
* Copyright (C) 2016 The Android Open Source Project
|
||||
* Copyright (C) 2021-2023 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "audio_hw_rpi_hdmi"
|
||||
//#define LOG_NDEBUG 0
|
||||
|
||||
#include <errno.h>
|
||||
#include <malloc.h>
|
||||
#include <pthread.h>
|
||||
#include <stdint.h>
|
||||
#include <sys/time.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include <log/log.h>
|
||||
#include <cutils/str_parms.h>
|
||||
#include <cutils/properties.h>
|
||||
|
||||
#include <hardware/hardware.h>
|
||||
#include <system/audio.h>
|
||||
#include <hardware/audio.h>
|
||||
|
||||
#include <alsa/asoundlib.h>
|
||||
#include <audio_utils/resampler.h>
|
||||
#include <audio_utils/echo_reference.h>
|
||||
#include <hardware/audio_effect.h>
|
||||
#include <audio_effects/effect_aec.h>
|
||||
|
||||
|
||||
/* Minimum granularity - Arbitrary but small value */
|
||||
#define CODEC_BASE_FRAME_COUNT 32
|
||||
|
||||
/* number of base blocks in a short period (low latency) */
|
||||
#define PERIOD_MULTIPLIER 32 /* 21 ms */
|
||||
/* number of frames per short period (low latency) */
|
||||
#define PERIOD_SIZE (CODEC_BASE_FRAME_COUNT * PERIOD_MULTIPLIER)
|
||||
/* number of pseudo periods for low latency playback */
|
||||
#define PLAYBACK_PERIOD_COUNT 4
|
||||
#define PLAYBACK_PERIOD_START_THRESHOLD 2
|
||||
#define CODEC_SAMPLING_RATE 48000
|
||||
#define CHANNEL_STEREO 2
|
||||
#define MIN_WRITE_SLEEP_US 5000
|
||||
|
||||
struct stub_stream_in {
|
||||
struct audio_stream_in stream;
|
||||
};
|
||||
|
||||
struct alsa_audio_device {
|
||||
struct audio_hw_device hw_device;
|
||||
|
||||
pthread_mutex_t lock; /* see note below on mutex acquisition order */
|
||||
int devices;
|
||||
struct alsa_stream_in *active_input;
|
||||
struct alsa_stream_out *active_output;
|
||||
bool mic_mute;
|
||||
};
|
||||
|
||||
struct alsa_stream_out {
|
||||
struct audio_stream_out stream;
|
||||
struct alsa_audio_device *dev;
|
||||
|
||||
pthread_mutex_t lock; /* see note below on mutex acquisition order */
|
||||
snd_pcm_t *pcm;
|
||||
|
||||
snd_pcm_uframes_t period_size;
|
||||
unsigned int periods;
|
||||
snd_pcm_uframes_t buffer_size;
|
||||
|
||||
bool unavailable;
|
||||
int standby;
|
||||
snd_pcm_uframes_t written;
|
||||
};
|
||||
|
||||
static void get_alsa_device_name(char *name) {
|
||||
char hdmi_device[PROPERTY_VALUE_MAX];
|
||||
property_get("persist.audio.hdmi.device", hdmi_device, "vc4hdmi0");
|
||||
|
||||
// use card configured in vc4-hdmi.conf to get IEC958 subframe conversion
|
||||
sprintf(name, "default:CARD=%s", hdmi_device);
|
||||
}
|
||||
|
||||
/* must be called with hw device and output stream mutexes locked */
|
||||
static int start_output_stream(struct alsa_stream_out *out)
|
||||
{
|
||||
struct alsa_audio_device *adev = out->dev;
|
||||
|
||||
if (out->unavailable)
|
||||
return -ENODEV;
|
||||
|
||||
char device_name[PROPERTY_VALUE_MAX];
|
||||
get_alsa_device_name(device_name);
|
||||
ALOGI("start_output_stream: %s", device_name);
|
||||
|
||||
int r;
|
||||
snd_pcm_t *pcm;
|
||||
|
||||
if ((r = snd_pcm_open(&pcm, device_name, SND_PCM_STREAM_PLAYBACK, 0) < 0)) {
|
||||
ALOGE("cannot open pcm_out driver: %s", snd_strerror(r));
|
||||
adev->active_output = NULL;
|
||||
out->unavailable = true;
|
||||
return -ENODEV;
|
||||
}
|
||||
out->pcm = pcm;
|
||||
|
||||
snd_pcm_hw_params_t *hwp;
|
||||
snd_pcm_hw_params_alloca(&hwp);
|
||||
snd_pcm_hw_params_any(pcm, hwp);
|
||||
snd_pcm_hw_params_set_access(pcm, hwp, SND_PCM_ACCESS_RW_INTERLEAVED);
|
||||
snd_pcm_hw_params_set_format(pcm, hwp, SND_PCM_FORMAT_S16_LE);
|
||||
snd_pcm_hw_params_set_rate(pcm, hwp, CODEC_SAMPLING_RATE, 0);
|
||||
snd_pcm_hw_params_set_channels(pcm, hwp, CHANNEL_STEREO);
|
||||
|
||||
// Configurue period_size, periods and buffer_size
|
||||
int dir = 0;
|
||||
out->period_size = PERIOD_SIZE;
|
||||
if ((r = snd_pcm_hw_params_set_period_size_near(pcm, hwp, &out->period_size, &dir)) < 0) {
|
||||
ALOGE("cannot snd_pcm_hw_params_set_period_size_near: %s", snd_strerror(r));
|
||||
adev->active_output = NULL;
|
||||
out->unavailable = true;
|
||||
return -ENODEV;
|
||||
}
|
||||
dir = 0;
|
||||
out->periods = PLAYBACK_PERIOD_COUNT;
|
||||
if ((r = snd_pcm_hw_params_set_periods_near(pcm, hwp, &out->periods, &dir)) < 0) {
|
||||
ALOGE("cannot snd_pcm_hw_params_set_periods_near: %s", snd_strerror(r));
|
||||
adev->active_output = NULL;
|
||||
out->unavailable = true;
|
||||
return -ENODEV;
|
||||
}
|
||||
out->buffer_size = out->period_size * out->periods;
|
||||
if ((r = snd_pcm_hw_params_set_buffer_size_near(pcm, hwp, &out->buffer_size)) < 0) {
|
||||
ALOGE("cannot snd_pcm_hw_params_set_buffer_size_near: %s", snd_strerror(r));
|
||||
adev->active_output = NULL;
|
||||
out->unavailable = true;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
//write the hw params
|
||||
if ((r = snd_pcm_hw_params(pcm, hwp)) < 0) {
|
||||
ALOGE("cannot snd_pcm_hw_params: %s", snd_strerror(r));
|
||||
adev->active_output = NULL;
|
||||
out->unavailable = true;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
//Software parameters
|
||||
snd_pcm_sw_params_t *swp;
|
||||
snd_pcm_sw_params_alloca(&swp);
|
||||
snd_pcm_sw_params_current(pcm, swp);
|
||||
|
||||
// set avail_min to period_size
|
||||
if ((r = snd_pcm_sw_params_set_avail_min(pcm, swp, out->period_size)) < 0) {
|
||||
ALOGE("cannot snd_pcm_sw_params_set_avail_min: %s", snd_strerror(r));
|
||||
adev->active_output = NULL;
|
||||
out->unavailable = true;
|
||||
return -ENODEV;
|
||||
}
|
||||
// set start_threshold to period_size * PLAYBACK_PERIOD_START_THRESHOLD
|
||||
if ((r = snd_pcm_sw_params_set_start_threshold(pcm, swp, out->period_size * PLAYBACK_PERIOD_START_THRESHOLD)) < 0) {
|
||||
ALOGE("cannot snd_pcm_sw_params_set_start_threshold: %s", snd_strerror(r));
|
||||
adev->active_output = NULL;
|
||||
out->unavailable = true;
|
||||
return -ENODEV;
|
||||
}
|
||||
//write the sw params
|
||||
if ((r = snd_pcm_sw_params(pcm, swp)) < 0) {
|
||||
ALOGE("cannot snd_pcm_sw_params: %s", snd_strerror(r));
|
||||
adev->active_output = NULL;
|
||||
out->unavailable = true;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
// prepare
|
||||
if ((r = snd_pcm_prepare(pcm)) < 0) {
|
||||
ALOGE("cannot snd_pcm_prepare: %s", snd_strerror(r));
|
||||
adev->active_output = NULL;
|
||||
out->unavailable = true;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
adev->active_output = out;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static uint32_t out_get_sample_rate(const struct audio_stream *stream)
|
||||
{
|
||||
ALOGV("out_get_sample_rate: %d", CODEC_SAMPLING_RATE);
|
||||
return CODEC_SAMPLING_RATE;
|
||||
}
|
||||
|
||||
static int out_set_sample_rate(struct audio_stream *stream, uint32_t rate)
|
||||
{
|
||||
ALOGV("out_set_sample_rate: %d", 0);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static size_t out_get_buffer_size(const struct audio_stream *stream)
|
||||
{
|
||||
struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
|
||||
|
||||
/* return the closest majoring multiple of 16 frames, as
|
||||
* audioflinger expects audio buffers to be a multiple of 16 frames */
|
||||
size_t size = out->period_size;
|
||||
size = ((size + 15) / 16) * 16;
|
||||
ALOGV("out_get_buffer_size: %ld", (long int)size);
|
||||
return size * audio_stream_out_frame_size((struct audio_stream_out *)stream);
|
||||
}
|
||||
|
||||
static audio_channel_mask_t out_get_channels(const struct audio_stream *stream)
|
||||
{
|
||||
ALOGV("out_get_channels: %d", CHANNEL_STEREO);
|
||||
return audio_channel_out_mask_from_count(CHANNEL_STEREO);
|
||||
}
|
||||
|
||||
static audio_format_t out_get_format(const struct audio_stream *stream)
|
||||
{
|
||||
ALOGV("out_get_format: %d", AUDIO_FORMAT_PCM_16_BIT);
|
||||
return AUDIO_FORMAT_PCM_16_BIT;
|
||||
}
|
||||
|
||||
static int out_set_format(struct audio_stream *stream, audio_format_t format)
|
||||
{
|
||||
ALOGV("out_set_format: %d",format);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int do_output_standby(struct alsa_stream_out *out)
|
||||
{
|
||||
struct alsa_audio_device *adev = out->dev;
|
||||
|
||||
if (!out->standby) {
|
||||
snd_pcm_close(out->pcm);
|
||||
out->pcm = NULL;
|
||||
adev->active_output = NULL;
|
||||
out->standby = 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int out_standby(struct audio_stream *stream)
|
||||
{
|
||||
ALOGV("out_standby");
|
||||
struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
|
||||
int status;
|
||||
|
||||
pthread_mutex_lock(&out->dev->lock);
|
||||
pthread_mutex_lock(&out->lock);
|
||||
status = do_output_standby(out);
|
||||
pthread_mutex_unlock(&out->lock);
|
||||
pthread_mutex_unlock(&out->dev->lock);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int out_dump(const struct audio_stream *stream, int fd)
|
||||
{
|
||||
ALOGV("out_dump");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int out_set_parameters(struct audio_stream *stream, const char *kvpairs)
|
||||
{
|
||||
ALOGV("out_set_parameters");
|
||||
struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
|
||||
struct alsa_audio_device *adev = out->dev;
|
||||
struct str_parms *parms;
|
||||
char value[32];
|
||||
int val = 0;
|
||||
int ret = -EINVAL;
|
||||
|
||||
if (kvpairs == NULL || kvpairs[0] == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
parms = str_parms_create_str(kvpairs);
|
||||
|
||||
if (str_parms_get_str(parms, AUDIO_PARAMETER_STREAM_ROUTING, value, sizeof(value)) >= 0) {
|
||||
val = atoi(value);
|
||||
pthread_mutex_lock(&adev->lock);
|
||||
pthread_mutex_lock(&out->lock);
|
||||
if (((adev->devices & AUDIO_DEVICE_OUT_ALL) != val) && (val != 0)) {
|
||||
adev->devices &= ~AUDIO_DEVICE_OUT_ALL;
|
||||
adev->devices |= val;
|
||||
}
|
||||
pthread_mutex_unlock(&out->lock);
|
||||
pthread_mutex_unlock(&adev->lock);
|
||||
ret = 0;
|
||||
}
|
||||
|
||||
str_parms_destroy(parms);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static char * out_get_parameters(const struct audio_stream *stream, const char *keys)
|
||||
{
|
||||
ALOGV("out_get_parameters");
|
||||
return strdup("");
|
||||
}
|
||||
|
||||
static uint32_t out_get_latency(const struct audio_stream_out *stream)
|
||||
{
|
||||
ALOGV("out_get_latency");
|
||||
struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
|
||||
// latency = buffer_size / rate
|
||||
return (out->buffer_size * 1000) / CODEC_SAMPLING_RATE;
|
||||
}
|
||||
|
||||
static int out_set_volume(struct audio_stream_out *stream, float left,
|
||||
float right)
|
||||
{
|
||||
ALOGV("out_set_volume: Left:%f Right:%f", left, right);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t out_write(struct audio_stream_out *stream, const void* buffer,
|
||||
size_t bytes)
|
||||
{
|
||||
int ret;
|
||||
struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
|
||||
struct alsa_audio_device *adev = out->dev;
|
||||
size_t frame_size = audio_stream_out_frame_size(stream);
|
||||
snd_pcm_uframes_t out_frames = bytes / frame_size;
|
||||
|
||||
/* acquiring hw device mutex systematically is useful if a low priority thread is waiting
|
||||
* on the output stream mutex - e.g. executing select_mode() while holding the hw device
|
||||
* mutex
|
||||
*/
|
||||
pthread_mutex_lock(&adev->lock);
|
||||
pthread_mutex_lock(&out->lock);
|
||||
if (out->standby) {
|
||||
ret = start_output_stream(out);
|
||||
if (ret != 0) {
|
||||
pthread_mutex_unlock(&adev->lock);
|
||||
goto exit;
|
||||
}
|
||||
out->standby = 0;
|
||||
}
|
||||
|
||||
pthread_mutex_unlock(&adev->lock);
|
||||
|
||||
ALOGV("out_write: out_frames:%ld", (long int)out_frames);
|
||||
|
||||
ret = snd_pcm_writei(out->pcm, buffer, out_frames);
|
||||
if (ret == out_frames) {
|
||||
out->written += out_frames;
|
||||
}
|
||||
exit:
|
||||
pthread_mutex_unlock(&out->lock);
|
||||
|
||||
if (ret != out_frames) {
|
||||
if (ret == -EPIPE) {
|
||||
ALOGE("underrun deteced -> redo snd_pcm_prepare");
|
||||
snd_pcm_prepare(out->pcm);
|
||||
} else {
|
||||
ALOGE("out_write err: %s", snd_strerror(ret));
|
||||
usleep((int64_t)bytes * 1000000 / audio_stream_out_frame_size(stream) /
|
||||
out_get_sample_rate(&stream->common));
|
||||
}
|
||||
}
|
||||
|
||||
return bytes;
|
||||
}
|
||||
|
||||
static int out_get_render_position(const struct audio_stream_out *stream,
|
||||
uint32_t *dsp_frames)
|
||||
{
|
||||
*dsp_frames = 0;
|
||||
ALOGV("out_get_render_position: dsp_frames: %p", dsp_frames);
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
static int out_get_presentation_position(const struct audio_stream_out *stream,
|
||||
uint64_t *frames, struct timespec *timestamp)
|
||||
{
|
||||
struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
|
||||
int ret = -1;
|
||||
|
||||
if (out->pcm) {
|
||||
snd_pcm_uframes_t avail;
|
||||
int r;
|
||||
if ((r = snd_pcm_htimestamp(out->pcm, &avail, timestamp)) == 0) {
|
||||
int64_t signed_frames = (int64_t)(out->written) - out->buffer_size + avail;
|
||||
if (signed_frames >= 0) {
|
||||
*frames = signed_frames;
|
||||
ret = 0;
|
||||
}
|
||||
ALOGV("out_get_presentation_position: %ld", (long int)(*frames));
|
||||
} else {
|
||||
ALOGE("out_get_presentation_position: err: %s", snd_strerror(r));
|
||||
}
|
||||
} else {
|
||||
ALOGV("out_get_presentation_position: stream in standby");
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
static int out_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
|
||||
{
|
||||
ALOGV("out_add_audio_effect: %p", effect);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int out_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
|
||||
{
|
||||
ALOGV("out_remove_audio_effect: %p", effect);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int out_get_next_write_timestamp(const struct audio_stream_out *stream,
|
||||
int64_t *timestamp)
|
||||
{
|
||||
*timestamp = 0;
|
||||
ALOGV("out_get_next_write_timestamp: %ld", (long int)(*timestamp));
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/** audio_stream_in implementation **/
|
||||
static uint32_t in_get_sample_rate(const struct audio_stream *stream)
|
||||
{
|
||||
ALOGV("in_get_sample_rate");
|
||||
return 8000;
|
||||
}
|
||||
|
||||
static int in_set_sample_rate(struct audio_stream *stream, uint32_t rate)
|
||||
{
|
||||
ALOGV("in_set_sample_rate: %d", rate);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static size_t in_get_buffer_size(const struct audio_stream *stream)
|
||||
{
|
||||
ALOGV("in_get_buffer_size: %d", 320);
|
||||
return 320;
|
||||
}
|
||||
|
||||
static audio_channel_mask_t in_get_channels(const struct audio_stream *stream)
|
||||
{
|
||||
ALOGV("in_get_channels: %d", AUDIO_CHANNEL_IN_MONO);
|
||||
return AUDIO_CHANNEL_IN_MONO;
|
||||
}
|
||||
|
||||
static audio_format_t in_get_format(const struct audio_stream *stream)
|
||||
{
|
||||
return AUDIO_FORMAT_PCM_16_BIT;
|
||||
}
|
||||
|
||||
static int in_set_format(struct audio_stream *stream, audio_format_t format)
|
||||
{
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int in_standby(struct audio_stream *stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int in_dump(const struct audio_stream *stream, int fd)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int in_set_parameters(struct audio_stream *stream, const char *kvpairs)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static char * in_get_parameters(const struct audio_stream *stream,
|
||||
const char *keys)
|
||||
{
|
||||
return strdup("");
|
||||
}
|
||||
|
||||
static int in_set_gain(struct audio_stream_in *stream, float gain)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static ssize_t in_read(struct audio_stream_in *stream, void* buffer,
|
||||
size_t bytes)
|
||||
{
|
||||
ALOGV("in_read: bytes %zu", bytes);
|
||||
/* XXX: fake timing for audio input */
|
||||
usleep((int64_t)bytes * 1000000 / audio_stream_in_frame_size(stream) /
|
||||
in_get_sample_rate(&stream->common));
|
||||
memset(buffer, 0, bytes);
|
||||
return bytes;
|
||||
}
|
||||
|
||||
static uint32_t in_get_input_frames_lost(struct audio_stream_in *stream)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int in_add_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int in_remove_audio_effect(const struct audio_stream *stream, effect_handle_t effect)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int adev_open_output_stream(struct audio_hw_device *dev,
|
||||
audio_io_handle_t handle,
|
||||
audio_devices_t devices,
|
||||
audio_output_flags_t flags,
|
||||
struct audio_config *config,
|
||||
struct audio_stream_out **stream_out,
|
||||
const char *address __unused)
|
||||
{
|
||||
ALOGV("adev_open_output_stream...");
|
||||
|
||||
struct alsa_audio_device *ladev = (struct alsa_audio_device *)dev;
|
||||
struct alsa_stream_out *out;
|
||||
int ret = 0;
|
||||
|
||||
out = (struct alsa_stream_out *)calloc(1, sizeof(struct alsa_stream_out));
|
||||
if (!out)
|
||||
return -ENOMEM;
|
||||
|
||||
out->stream.common.get_sample_rate = out_get_sample_rate;
|
||||
out->stream.common.set_sample_rate = out_set_sample_rate;
|
||||
out->stream.common.get_buffer_size = out_get_buffer_size;
|
||||
out->stream.common.get_channels = out_get_channels;
|
||||
out->stream.common.get_format = out_get_format;
|
||||
out->stream.common.set_format = out_set_format;
|
||||
out->stream.common.standby = out_standby;
|
||||
out->stream.common.dump = out_dump;
|
||||
out->stream.common.set_parameters = out_set_parameters;
|
||||
out->stream.common.get_parameters = out_get_parameters;
|
||||
out->stream.common.add_audio_effect = out_add_audio_effect;
|
||||
out->stream.common.remove_audio_effect = out_remove_audio_effect;
|
||||
out->stream.get_latency = out_get_latency;
|
||||
out->stream.set_volume = out_set_volume;
|
||||
out->stream.write = out_write;
|
||||
out->stream.get_render_position = out_get_render_position;
|
||||
out->stream.get_next_write_timestamp = out_get_next_write_timestamp;
|
||||
out->stream.get_presentation_position = out_get_presentation_position;
|
||||
|
||||
out->period_size = PERIOD_SIZE;
|
||||
out->periods = PLAYBACK_PERIOD_COUNT;
|
||||
out->buffer_size = out->period_size * out->periods;
|
||||
|
||||
out->dev = ladev;
|
||||
out->standby = 1;
|
||||
out->unavailable = false;
|
||||
|
||||
config->format = out_get_format(&out->stream.common);
|
||||
config->channel_mask = out_get_channels(&out->stream.common);
|
||||
config->sample_rate = out_get_sample_rate(&out->stream.common);
|
||||
|
||||
*stream_out = &out->stream;
|
||||
|
||||
/* TODO The retry mechanism isn't implemented in AudioPolicyManager/AudioFlinger. */
|
||||
ret = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void adev_close_output_stream(struct audio_hw_device *dev,
|
||||
struct audio_stream_out *stream)
|
||||
{
|
||||
ALOGV("adev_close_output_stream...");
|
||||
free(stream);
|
||||
}
|
||||
|
||||
static int adev_set_parameters(struct audio_hw_device *dev, const char *kvpairs)
|
||||
{
|
||||
ALOGV("adev_set_parameters");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static char * adev_get_parameters(const struct audio_hw_device *dev,
|
||||
const char *keys)
|
||||
{
|
||||
ALOGV("adev_get_parameters");
|
||||
return strdup("");
|
||||
}
|
||||
|
||||
static int adev_init_check(const struct audio_hw_device *dev)
|
||||
{
|
||||
ALOGV("adev_init_check");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int adev_set_voice_volume(struct audio_hw_device *dev, float volume)
|
||||
{
|
||||
ALOGV("adev_set_voice_volume: %f", volume);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int adev_set_master_volume(struct audio_hw_device *dev, float volume)
|
||||
{
|
||||
ALOGV("adev_set_master_volume: %f", volume);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int adev_get_master_volume(struct audio_hw_device *dev, float *volume)
|
||||
{
|
||||
ALOGV("adev_get_master_volume: %f", *volume);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int adev_set_master_mute(struct audio_hw_device *dev, bool muted)
|
||||
{
|
||||
ALOGV("adev_set_master_mute: %d", muted);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int adev_get_master_mute(struct audio_hw_device *dev, bool *muted)
|
||||
{
|
||||
ALOGV("adev_get_master_mute: %d", *muted);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int adev_set_mode(struct audio_hw_device *dev, audio_mode_t mode)
|
||||
{
|
||||
ALOGV("adev_set_mode: %d", mode);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int adev_set_mic_mute(struct audio_hw_device *dev, bool state)
|
||||
{
|
||||
ALOGV("adev_set_mic_mute: %d",state);
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static int adev_get_mic_mute(const struct audio_hw_device *dev, bool *state)
|
||||
{
|
||||
ALOGV("adev_get_mic_mute");
|
||||
return -ENOSYS;
|
||||
}
|
||||
|
||||
static size_t adev_get_input_buffer_size(const struct audio_hw_device *dev,
|
||||
const struct audio_config *config)
|
||||
{
|
||||
ALOGV("adev_get_input_buffer_size: %d", 320);
|
||||
return 320;
|
||||
}
|
||||
|
||||
static int adev_open_input_stream(struct audio_hw_device __unused *dev,
|
||||
audio_io_handle_t handle,
|
||||
audio_devices_t devices,
|
||||
struct audio_config *config,
|
||||
struct audio_stream_in **stream_in,
|
||||
audio_input_flags_t flags __unused,
|
||||
const char *address __unused,
|
||||
audio_source_t source __unused)
|
||||
{
|
||||
struct stub_stream_in *in;
|
||||
|
||||
ALOGV("adev_open_input_stream...");
|
||||
|
||||
in = (struct stub_stream_in *)calloc(1, sizeof(struct stub_stream_in));
|
||||
if (!in)
|
||||
return -ENOMEM;
|
||||
|
||||
in->stream.common.get_sample_rate = in_get_sample_rate;
|
||||
in->stream.common.set_sample_rate = in_set_sample_rate;
|
||||
in->stream.common.get_buffer_size = in_get_buffer_size;
|
||||
in->stream.common.get_channels = in_get_channels;
|
||||
in->stream.common.get_format = in_get_format;
|
||||
in->stream.common.set_format = in_set_format;
|
||||
in->stream.common.standby = in_standby;
|
||||
in->stream.common.dump = in_dump;
|
||||
in->stream.common.set_parameters = in_set_parameters;
|
||||
in->stream.common.get_parameters = in_get_parameters;
|
||||
in->stream.common.add_audio_effect = in_add_audio_effect;
|
||||
in->stream.common.remove_audio_effect = in_remove_audio_effect;
|
||||
in->stream.set_gain = in_set_gain;
|
||||
in->stream.read = in_read;
|
||||
in->stream.get_input_frames_lost = in_get_input_frames_lost;
|
||||
|
||||
*stream_in = &in->stream;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void adev_close_input_stream(struct audio_hw_device *dev,
|
||||
struct audio_stream_in *in)
|
||||
{
|
||||
ALOGV("adev_close_input_stream...");
|
||||
return;
|
||||
}
|
||||
|
||||
static int adev_dump(const audio_hw_device_t *device, int fd)
|
||||
{
|
||||
ALOGV("adev_dump");
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int adev_close(hw_device_t *device)
|
||||
{
|
||||
ALOGV("adev_close");
|
||||
free(device);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int adev_open(const hw_module_t* module, const char* name,
|
||||
hw_device_t** device)
|
||||
{
|
||||
struct alsa_audio_device *adev;
|
||||
|
||||
ALOGV("adev_open: %s", name);
|
||||
|
||||
if (strcmp(name, AUDIO_HARDWARE_INTERFACE) != 0)
|
||||
return -EINVAL;
|
||||
|
||||
adev = calloc(1, sizeof(struct alsa_audio_device));
|
||||
if (!adev)
|
||||
return -ENOMEM;
|
||||
|
||||
adev->hw_device.common.tag = HARDWARE_DEVICE_TAG;
|
||||
adev->hw_device.common.version = AUDIO_DEVICE_API_VERSION_2_0;
|
||||
adev->hw_device.common.module = (struct hw_module_t *) module;
|
||||
adev->hw_device.common.close = adev_close;
|
||||
adev->hw_device.init_check = adev_init_check;
|
||||
adev->hw_device.set_voice_volume = adev_set_voice_volume;
|
||||
adev->hw_device.set_master_volume = adev_set_master_volume;
|
||||
adev->hw_device.get_master_volume = adev_get_master_volume;
|
||||
adev->hw_device.set_master_mute = adev_set_master_mute;
|
||||
adev->hw_device.get_master_mute = adev_get_master_mute;
|
||||
adev->hw_device.set_mode = adev_set_mode;
|
||||
adev->hw_device.set_mic_mute = adev_set_mic_mute;
|
||||
adev->hw_device.get_mic_mute = adev_get_mic_mute;
|
||||
adev->hw_device.set_parameters = adev_set_parameters;
|
||||
adev->hw_device.get_parameters = adev_get_parameters;
|
||||
adev->hw_device.get_input_buffer_size = adev_get_input_buffer_size;
|
||||
adev->hw_device.open_output_stream = adev_open_output_stream;
|
||||
adev->hw_device.close_output_stream = adev_close_output_stream;
|
||||
adev->hw_device.open_input_stream = adev_open_input_stream;
|
||||
adev->hw_device.close_input_stream = adev_close_input_stream;
|
||||
adev->hw_device.dump = adev_dump;
|
||||
|
||||
adev->devices = AUDIO_DEVICE_NONE;
|
||||
|
||||
*device = &adev->hw_device.common;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct hw_module_methods_t hal_module_methods = {
|
||||
.open = adev_open,
|
||||
};
|
||||
|
||||
struct audio_module HAL_MODULE_INFO_SYM = {
|
||||
.common = {
|
||||
.tag = HARDWARE_MODULE_TAG,
|
||||
.module_api_version = AUDIO_MODULE_API_VERSION_0_1,
|
||||
.hal_api_version = HARDWARE_HAL_API_VERSION,
|
||||
.id = AUDIO_HARDWARE_MODULE_ID,
|
||||
.name = "Raspberry Pi audio hdmi HW HAL",
|
||||
.author = "The Android Open Source Project",
|
||||
.methods = &hal_module_methods,
|
||||
},
|
||||
};
|
@@ -1,68 +0,0 @@
|
||||
# Configuration for the VC4-HDMI sound card using software IEC958
|
||||
# subframe conversion
|
||||
|
||||
<confdir:pcm/hdmi.conf>
|
||||
vc4-hdmi.pcm.hdmi.0 {
|
||||
@args [ CARD AES0 AES1 AES2 AES3 ]
|
||||
@args.CARD {
|
||||
type string
|
||||
}
|
||||
@args.AES0 {
|
||||
type integer
|
||||
}
|
||||
@args.AES1 {
|
||||
type integer
|
||||
}
|
||||
@args.AES2 {
|
||||
type integer
|
||||
}
|
||||
@args.AES3 {
|
||||
type integer
|
||||
}
|
||||
type iec958
|
||||
slave {
|
||||
format IEC958_SUBFRAME_LE
|
||||
pcm {
|
||||
type hooks
|
||||
slave.pcm {
|
||||
type hw
|
||||
card $CARD
|
||||
device 0
|
||||
}
|
||||
hooks.0 {
|
||||
type ctl_elems
|
||||
hook_args [
|
||||
{
|
||||
name "IEC958 Playback Default"
|
||||
interface PCM
|
||||
optional true
|
||||
lock true
|
||||
preserve true
|
||||
value [ $AES0 $AES1 $AES2 $AES3 ]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
status [ $AES0 $AES1 $AES2 $AES3 ]
|
||||
}
|
||||
|
||||
# default with plug
|
||||
vc4-hdmi.pcm.default {
|
||||
@args [ CARD ]
|
||||
@args.CARD {
|
||||
type string
|
||||
}
|
||||
type plug
|
||||
slave.pcm {
|
||||
type softvol
|
||||
slave.pcm {
|
||||
@func concat
|
||||
strings [ "hdmi:" $CARD ]
|
||||
}
|
||||
control {
|
||||
name "PCM Playback Volume"
|
||||
card $CARD
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,14 +0,0 @@
|
||||
BLUETOOTH_UART_DEVICE_PORT = "/dev/ttyAMA0"
|
||||
FW_PATCHFILE_LOCATION = "/vendor/firmware/brcm/"
|
||||
FW_PATCH_SETTLEMENT_DELAY_MS = 200
|
||||
BT_WAKE_VIA_PROC = FALSE
|
||||
BT_WAKE_VIA_USERIAL_IOCTL = FALSE
|
||||
LPM_IDLE_TIMEOUT_MULTIPLE = 5
|
||||
SCO_CFG_INCLUDED = FALSE
|
||||
SCO_PCM_IF_CLOCK_RATE = 2
|
||||
BTVND_DBG = FALSE
|
||||
BTHW_DBG = FALSE
|
||||
VNDUSERIAL_DBG = FALSE
|
||||
UPIO_DBG = FALSE
|
||||
UART_TARGET_BAUD_RATE = 3000000
|
||||
USE_CONTROLLER_BDADDR = FALSE
|
@@ -12,6 +12,9 @@ dtparam=audio=on
|
||||
camera_auto_detect=1
|
||||
start_x=1
|
||||
|
||||
# CPU
|
||||
arm_boost=1
|
||||
|
||||
# Display
|
||||
disable_overscan=1
|
||||
|
||||
@@ -20,8 +23,8 @@ disable_overscan=1
|
||||
#dtoverlay=rpi-backlight
|
||||
|
||||
# Graphics acceleration
|
||||
disable_fw_kms_setup=1
|
||||
dtoverlay=vc4-kms-v3d
|
||||
dtoverlay=cma,cma-384
|
||||
|
||||
# I2C
|
||||
#dtparam=i2c_arm=on
|
||||
@@ -40,6 +43,3 @@ dtoverlay=dwc2,dr_mode=peripheral
|
||||
[cm4]
|
||||
dtoverlay=dwc2,dr_mode=otg
|
||||
[all]
|
||||
|
||||
# V4L2
|
||||
#dtoverlay=rpivid-v4l2
|
||||
|
@@ -0,0 +1,10 @@
|
||||
service vendor.camera-provider-2-5 /vendor/bin/hw/android.hardware.camera.provider@2.5-service_64
|
||||
class hal
|
||||
user cameraserver
|
||||
group audio camera input drmrpc
|
||||
ioprio rt 4
|
||||
capabilities SYS_NICE
|
||||
task_profiles CameraServiceCapacity MaxPerformance
|
||||
override
|
||||
setenv LIBCAMERA_LOG_LEVELS *:WARN
|
||||
setenv LIBCAMERA_LOG_FILE syslog
|
@@ -2,9 +2,15 @@ cameras:
|
||||
"/base/soc/i2c0mux/i2c@1/imx219@10":
|
||||
location: back
|
||||
rotation: 0
|
||||
"/base/soc/i2c0mux/i2c@1/imx296@1a":
|
||||
location: back
|
||||
rotation: 0
|
||||
"/base/soc/i2c0mux/i2c@1/imx477@1a":
|
||||
location: back
|
||||
rotation: 0
|
||||
"/base/soc/i2c0mux/i2c@1/imx708@1a":
|
||||
location: back
|
||||
rotation: 0
|
||||
"/base/soc/i2c0mux/i2c@1/ov5647@36":
|
||||
location: back
|
||||
rotation: 0
|
||||
|
85
camera/evs_config_override.json
Normal file
85
camera/evs_config_override.json
Normal file
@@ -0,0 +1,85 @@
|
||||
|
||||
{
|
||||
"car" : {
|
||||
"width" : 76.7,
|
||||
"wheelBase" : 117.9,
|
||||
"frontExtent" : 44.7,
|
||||
"rearExtent" : 40
|
||||
},
|
||||
"displays" : [
|
||||
{
|
||||
"_comment": "Display0",
|
||||
"displayPort" : 0,
|
||||
"frontRange" : 100,
|
||||
"rearRange" : 100
|
||||
},
|
||||
{
|
||||
"_comment": "Display1",
|
||||
"displayPort" : 1,
|
||||
"frontRange" : 100,
|
||||
"rearRange" : 100
|
||||
}
|
||||
],
|
||||
"graphic" : {
|
||||
"frontPixel" : -20,
|
||||
"rearPixel" : 260
|
||||
},
|
||||
"cameras" : [
|
||||
{
|
||||
"cameraId" : "/dev/video0",
|
||||
"function" : "reverse",
|
||||
"x" : 0.0,
|
||||
"y" : 20.0,
|
||||
"z" : 48,
|
||||
"yaw" : 180,
|
||||
"pitch" : -10,
|
||||
"roll" : 0,
|
||||
"hfov" : 115,
|
||||
"vfov" : 80,
|
||||
"hflip" : true,
|
||||
"vflip" : false
|
||||
},
|
||||
{
|
||||
"cameraId" : "1",
|
||||
"function" : "front",
|
||||
"x" : 0.0,
|
||||
"y" : 100.0,
|
||||
"z" : 48,
|
||||
"yaw" : 0,
|
||||
"pitch" : -10,
|
||||
"roll" : 0,
|
||||
"hfov" : 115,
|
||||
"vfov" : 80,
|
||||
"hflip" : false,
|
||||
"vflip" : false
|
||||
},
|
||||
{
|
||||
"cameraId" : "2",
|
||||
"function" : "right",
|
||||
"x" : -25.0,
|
||||
"y" : 60.0,
|
||||
"z" : 88,
|
||||
"yaw" : -90,
|
||||
"pitch" : -10,
|
||||
"roll" : 0,
|
||||
"hfov" : 60,
|
||||
"vfov" : 62,
|
||||
"hflip" : false,
|
||||
"vflip" : false
|
||||
},
|
||||
{
|
||||
"cameraId" : "3",
|
||||
"function" : "left",
|
||||
"x" : 20.0,
|
||||
"y" : 60.0,
|
||||
"z" : 88,
|
||||
"yaw" : 90,
|
||||
"pitch" : -10,
|
||||
"roll" : 0,
|
||||
"hfov" : 60,
|
||||
"vfov" : 62,
|
||||
"hflip" : false,
|
||||
"vflip" : false
|
||||
}
|
||||
]
|
||||
}
|
@@ -32,6 +32,7 @@
|
||||
<id>21</id>
|
||||
<id>22</id>
|
||||
<id>23</id>
|
||||
<id>31</id>
|
||||
</ignore>
|
||||
</Provider>
|
||||
<!-- See ExternalCameraUtils.cpp for default values of Device configurations below -->
|
||||
|
17
cec/Android.bp
Normal file
17
cec/Android.bp
Normal file
@@ -0,0 +1,17 @@
|
||||
// Copyright (C) 2019 The Android Open-Source Project
|
||||
// Copyright (C) 2021-2022 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cc_library_shared {
|
||||
name: "hdmi_cec.rpi",
|
||||
relative_install_path: "hw",
|
||||
proprietary: true,
|
||||
srcs: ["hdmi_cec.c"],
|
||||
cflags: ["-Werror"],
|
||||
shared_libs: [
|
||||
"liblog",
|
||||
"libcutils",
|
||||
"libhardware",
|
||||
],
|
||||
}
|
618
cec/hdmi_cec.c
Normal file
618
cec/hdmi_cec.c
Normal file
@@ -0,0 +1,618 @@
|
||||
/*
|
||||
* Copyright (C) 2019 BayLibre, SAS.
|
||||
* Copyright (C) 2021-2022 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "hdmi_cec"
|
||||
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <stdlib.h>
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <poll.h>
|
||||
#include <sys/socket.h>
|
||||
#include <linux/netlink.h>
|
||||
#include <linux/cec.h>
|
||||
#include <sys/eventfd.h>
|
||||
|
||||
#include <log/log.h>
|
||||
#include <cutils/properties.h>
|
||||
#include <hardware/hdmi_cec.h>
|
||||
|
||||
typedef struct hdmicec_context
|
||||
{
|
||||
hdmi_cec_device_t device; /* must be first */
|
||||
int cec_fd;
|
||||
unsigned int vendor_id;
|
||||
unsigned int type;
|
||||
unsigned int version;
|
||||
struct hdmi_port_info port_info;
|
||||
event_callback_t p_event_cb;
|
||||
void *cb_arg;
|
||||
pthread_t thread;
|
||||
int exit_fd;
|
||||
pthread_mutex_t options_lock;
|
||||
bool cec_enabled;
|
||||
bool cec_control_enabled;
|
||||
} hdmicec_context_t;
|
||||
|
||||
static int hdmicec_add_logical_address(const struct hdmi_cec_device *dev, cec_logical_address_t addr)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
unsigned int la_type = CEC_LOG_ADDR_TYPE_UNREGISTERED;
|
||||
unsigned int all_dev_types = 0;
|
||||
unsigned int prim_type = 0xff;
|
||||
struct cec_log_addrs laddrs;
|
||||
int ret;
|
||||
|
||||
ALOGD("%s: addr:%x\n", __func__, addr);
|
||||
|
||||
if (addr >= CEC_ADDR_BROADCAST)
|
||||
return -1;
|
||||
|
||||
ret = ioctl(ctx->cec_fd, CEC_ADAP_G_LOG_ADDRS, &laddrs);
|
||||
if (ret)
|
||||
return ret;
|
||||
memset(&laddrs, 0, sizeof(laddrs));
|
||||
|
||||
laddrs.cec_version = ctx->version;
|
||||
laddrs.vendor_id = ctx->vendor_id;
|
||||
|
||||
switch (addr) {
|
||||
case CEC_LOG_ADDR_TV:
|
||||
prim_type = CEC_OP_PRIM_DEVTYPE_TV;
|
||||
la_type = CEC_LOG_ADDR_TYPE_TV;
|
||||
all_dev_types = CEC_OP_ALL_DEVTYPE_TV;
|
||||
break;
|
||||
case CEC_LOG_ADDR_RECORD_1:
|
||||
case CEC_LOG_ADDR_RECORD_2:
|
||||
case CEC_LOG_ADDR_RECORD_3:
|
||||
prim_type = CEC_OP_PRIM_DEVTYPE_RECORD;
|
||||
la_type = CEC_LOG_ADDR_TYPE_RECORD;
|
||||
all_dev_types = CEC_OP_ALL_DEVTYPE_RECORD;
|
||||
break;
|
||||
case CEC_LOG_ADDR_TUNER_1:
|
||||
case CEC_LOG_ADDR_TUNER_2:
|
||||
case CEC_LOG_ADDR_TUNER_3:
|
||||
case CEC_LOG_ADDR_TUNER_4:
|
||||
prim_type = CEC_OP_PRIM_DEVTYPE_TUNER;
|
||||
la_type = CEC_LOG_ADDR_TYPE_TUNER;
|
||||
all_dev_types = CEC_OP_ALL_DEVTYPE_TUNER;
|
||||
break;
|
||||
case CEC_LOG_ADDR_PLAYBACK_1:
|
||||
case CEC_LOG_ADDR_PLAYBACK_2:
|
||||
case CEC_LOG_ADDR_PLAYBACK_3:
|
||||
prim_type = CEC_OP_PRIM_DEVTYPE_PLAYBACK;
|
||||
la_type = CEC_LOG_ADDR_TYPE_PLAYBACK;
|
||||
all_dev_types = CEC_OP_ALL_DEVTYPE_PLAYBACK;
|
||||
laddrs.flags = CEC_LOG_ADDRS_FL_ALLOW_RC_PASSTHRU;
|
||||
break;
|
||||
case CEC_LOG_ADDR_AUDIOSYSTEM:
|
||||
prim_type = CEC_OP_PRIM_DEVTYPE_AUDIOSYSTEM;
|
||||
la_type = CEC_LOG_ADDR_TYPE_AUDIOSYSTEM;
|
||||
all_dev_types = CEC_OP_ALL_DEVTYPE_AUDIOSYSTEM;
|
||||
break;
|
||||
case CEC_LOG_ADDR_SPECIFIC:
|
||||
prim_type = CEC_OP_PRIM_DEVTYPE_PROCESSOR;
|
||||
la_type = CEC_LOG_ADDR_TYPE_SPECIFIC;
|
||||
all_dev_types = CEC_OP_ALL_DEVTYPE_SWITCH;
|
||||
break;
|
||||
case CEC_ADDR_RESERVED_1:
|
||||
case CEC_ADDR_RESERVED_2:
|
||||
case CEC_ADDR_UNREGISTERED:
|
||||
laddrs.flags = CEC_LOG_ADDRS_FL_ALLOW_UNREG_FALLBACK;
|
||||
break;
|
||||
}
|
||||
|
||||
laddrs.num_log_addrs = 1;
|
||||
laddrs.log_addr[0] = addr;
|
||||
laddrs.log_addr_type[0] = la_type;
|
||||
laddrs.primary_device_type[0] = prim_type;
|
||||
laddrs.all_device_types[0] = all_dev_types;
|
||||
laddrs.features[0][0] = 0;
|
||||
laddrs.features[0][1] = 0;
|
||||
|
||||
ret = ioctl(ctx->cec_fd, CEC_ADAP_S_LOG_ADDRS, &laddrs);
|
||||
if (ret) {
|
||||
ALOGD("%s: %m\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ALOGD("%s: log_addr_mask=%x\n", __func__, laddrs.log_addr_mask);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void hdmicec_clear_logical_address(const struct hdmi_cec_device *dev)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
struct cec_log_addrs laddrs;
|
||||
int ret;
|
||||
|
||||
memset(&laddrs, 0, sizeof(laddrs));
|
||||
ret = ioctl(ctx->cec_fd, CEC_ADAP_S_LOG_ADDRS, &laddrs);
|
||||
if (ret)
|
||||
ALOGD("%s: %m\n", __func__);
|
||||
}
|
||||
|
||||
static int hdmicec_get_physical_address(const struct hdmi_cec_device *dev, uint16_t *addr)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
int ret = ioctl(ctx->cec_fd, CEC_ADAP_G_PHYS_ADDR, addr);
|
||||
if (ret)
|
||||
ALOGD("%s: %m\n", __func__);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int hdmicec_send_message(const struct hdmi_cec_device *dev, const cec_message_t *msg)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
struct cec_msg cec_msg;
|
||||
int ret;
|
||||
|
||||
pthread_mutex_lock(&ctx->options_lock);
|
||||
bool cec_enabled = ctx->cec_enabled;
|
||||
pthread_mutex_unlock(&ctx->options_lock);
|
||||
if (!cec_enabled) {
|
||||
return HDMI_RESULT_FAIL;
|
||||
}
|
||||
|
||||
ALOGD("%s: len=%u\n", __func__, (unsigned int)msg->length);
|
||||
|
||||
memset(&cec_msg, 0, sizeof(cec_msg));
|
||||
cec_msg.msg[0] = (msg->initiator << 4) | msg->destination;
|
||||
|
||||
memcpy(&cec_msg.msg[1], msg->body, msg->length);
|
||||
cec_msg.len = msg->length + 1;
|
||||
|
||||
ret = ioctl(ctx->cec_fd, CEC_TRANSMIT, &cec_msg);
|
||||
if (ret) {
|
||||
ALOGD("%s: %m\n", __func__);
|
||||
return HDMI_RESULT_FAIL;
|
||||
}
|
||||
|
||||
if (cec_msg.tx_status != CEC_TX_STATUS_OK)
|
||||
ALOGD("%s: tx_status=%d\n", __func__, cec_msg.tx_status);
|
||||
|
||||
switch (cec_msg.tx_status) {
|
||||
case CEC_TX_STATUS_OK:
|
||||
return HDMI_RESULT_SUCCESS;
|
||||
case CEC_TX_STATUS_ARB_LOST:
|
||||
return HDMI_RESULT_BUSY;
|
||||
case CEC_TX_STATUS_NACK:
|
||||
return HDMI_RESULT_NACK;
|
||||
default:
|
||||
if (cec_msg.tx_status & CEC_TX_STATUS_NACK)
|
||||
return HDMI_RESULT_NACK;
|
||||
return HDMI_RESULT_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
static void hdmicec_register_event_callback(const struct hdmi_cec_device *dev,
|
||||
event_callback_t callback, void *arg)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
|
||||
ctx->p_event_cb = callback;
|
||||
ctx->cb_arg = arg;
|
||||
}
|
||||
|
||||
static void hdmicec_get_version(const struct hdmi_cec_device *dev, int *version)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
|
||||
*version = ctx->version;
|
||||
}
|
||||
|
||||
static void hdmicec_get_vendor_id(const struct hdmi_cec_device *dev, uint32_t *vendor_id)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
|
||||
*vendor_id = ctx->vendor_id;
|
||||
}
|
||||
|
||||
static void hdmicec_get_port_info(const struct hdmi_cec_device *dev,
|
||||
struct hdmi_port_info *list[], int *total)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
int ret;
|
||||
|
||||
ret = ioctl(ctx->cec_fd, CEC_ADAP_G_PHYS_ADDR, &ctx->port_info.physical_address);
|
||||
if (ret)
|
||||
ALOGD("%s: %m\n", __func__);
|
||||
|
||||
ALOGD("type:%s, id:%d, cec support:%d, arc support:%d, physical address:%x",
|
||||
ctx->port_info.type ? "output" : "input",
|
||||
ctx->port_info.port_id,
|
||||
ctx->port_info.cec_supported,
|
||||
ctx->port_info.arc_supported,
|
||||
ctx->port_info.physical_address);
|
||||
|
||||
if (ctx->port_info.physical_address != CEC_PHYS_ADDR_INVALID) {
|
||||
*list = &ctx->port_info;
|
||||
*total = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void hdmicec_set_option(const struct hdmi_cec_device *dev, int flag, int value)
|
||||
{
|
||||
struct hdmicec_context* ctx = (struct hdmicec_context*)dev;
|
||||
ALOGD("%s: flag=%d, value=%d", __func__, flag, value);
|
||||
switch (flag) {
|
||||
case HDMI_OPTION_ENABLE_CEC:
|
||||
pthread_mutex_lock(&ctx->options_lock);
|
||||
ctx->cec_enabled = (value == 1 ? true : false);
|
||||
pthread_mutex_unlock(&ctx->options_lock);
|
||||
break;
|
||||
case HDMI_OPTION_WAKEUP:
|
||||
// Not valid for playback devices
|
||||
break;
|
||||
case HDMI_OPTION_SYSTEM_CEC_CONTROL:
|
||||
pthread_mutex_lock(&ctx->options_lock);
|
||||
ctx->cec_control_enabled = (value == 1 ? true : false);
|
||||
pthread_mutex_unlock(&ctx->options_lock);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static int hdmicec_is_connected(const struct hdmi_cec_device *dev, int port_id)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
int ret;
|
||||
|
||||
(void)port_id;
|
||||
|
||||
ret = ioctl(ctx->cec_fd, CEC_ADAP_G_PHYS_ADDR,
|
||||
&ctx->port_info.physical_address);
|
||||
if (ret) {
|
||||
ALOGD("%s: %m\n", __func__);
|
||||
return ret;
|
||||
}
|
||||
|
||||
if (ctx->port_info.physical_address == CEC_PHYS_ADDR_INVALID)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
static int get_opcode(struct cec_msg* message) {
|
||||
return (((uint8_t)message->msg[1]) & 0xff);
|
||||
}
|
||||
|
||||
static int get_first_param(struct cec_msg* message) {
|
||||
return (((uint8_t)message->msg[2]) & 0xff);
|
||||
}
|
||||
|
||||
static bool is_power_ui_command(struct cec_msg* message) {
|
||||
int ui_command = get_first_param(message);
|
||||
switch (ui_command) {
|
||||
case CEC_OP_UI_CMD_POWER:
|
||||
case CEC_OP_UI_CMD_DEVICE_ROOT_MENU:
|
||||
case CEC_OP_UI_CMD_POWER_ON_FUNCTION:
|
||||
return true;
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static bool is_transferable_in_sleep(struct cec_msg* message) {
|
||||
int opcode = get_opcode(message);
|
||||
switch (opcode) {
|
||||
case CEC_MESSAGE_ABORT:
|
||||
case CEC_MESSAGE_DEVICE_VENDOR_ID:
|
||||
case CEC_MESSAGE_GET_CEC_VERSION:
|
||||
case CEC_MESSAGE_GET_MENU_LANGUAGE:
|
||||
case CEC_MESSAGE_GIVE_DEVICE_POWER_STATUS:
|
||||
case CEC_MESSAGE_GIVE_DEVICE_VENDOR_ID:
|
||||
case CEC_MESSAGE_GIVE_OSD_NAME:
|
||||
case CEC_MESSAGE_GIVE_PHYSICAL_ADDRESS:
|
||||
case CEC_MESSAGE_REPORT_PHYSICAL_ADDRESS:
|
||||
case CEC_MESSAGE_REPORT_POWER_STATUS:
|
||||
case CEC_MESSAGE_SET_OSD_NAME:
|
||||
case CEC_MESSAGE_DECK_CONTROL:
|
||||
case CEC_MESSAGE_PLAY:
|
||||
return true;
|
||||
case CEC_MESSAGE_USER_CONTROL_PRESSED:
|
||||
return is_power_ui_command(message);
|
||||
default:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
static void *event_thread(void *arg)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)arg;
|
||||
int ret;
|
||||
struct pollfd ufds[3] = {
|
||||
{ ctx->cec_fd, POLLIN, 0 },
|
||||
{ ctx->cec_fd, POLLERR, 0 },
|
||||
{ ctx->exit_fd, POLLIN, 0 },
|
||||
};
|
||||
|
||||
ALOGI("%s start!", __func__);
|
||||
|
||||
while (1) {
|
||||
ufds[0].revents = 0;
|
||||
ufds[1].revents = 0;
|
||||
ufds[2].revents = 0;
|
||||
|
||||
ret = poll(ufds, 3, -1);
|
||||
|
||||
if (ret <= 0)
|
||||
continue;
|
||||
|
||||
if (ufds[2].revents == POLLIN) /* Exit */
|
||||
break;
|
||||
|
||||
if (ufds[1].revents == POLLERR) { /* CEC Event */
|
||||
hdmi_event_t event = { };
|
||||
struct cec_event ev;
|
||||
|
||||
ret = ioctl(ctx->cec_fd, CEC_DQEVENT, &ev);
|
||||
if (ret)
|
||||
continue;
|
||||
|
||||
pthread_mutex_lock(&ctx->options_lock);
|
||||
bool cec_enabled = ctx->cec_enabled;
|
||||
pthread_mutex_unlock(&ctx->options_lock);
|
||||
if (!cec_enabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ev.event == CEC_EVENT_STATE_CHANGE) {
|
||||
event.type = HDMI_EVENT_HOT_PLUG;
|
||||
event.dev = &ctx->device;
|
||||
event.hotplug.port_id = 1;
|
||||
if (ev.state_change.phys_addr == CEC_PHYS_ADDR_INVALID)
|
||||
event.hotplug.connected = false;
|
||||
else
|
||||
event.hotplug.connected = true;
|
||||
|
||||
if (ctx->p_event_cb != NULL) {
|
||||
ctx->p_event_cb(&event, ctx->cb_arg);
|
||||
} else {
|
||||
ALOGE("no event callback for hotplug\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ufds[0].revents == POLLIN) { /* CEC Driver */
|
||||
struct cec_msg msg = { };
|
||||
hdmi_event_t event = { };
|
||||
|
||||
ret = ioctl(ctx->cec_fd, CEC_RECEIVE, &msg);
|
||||
if (ret) {
|
||||
ALOGE("%s: CEC_RECEIVE error (%m)\n", __func__);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (msg.rx_status != CEC_RX_STATUS_OK) {
|
||||
ALOGD("%s: rx_status=%d\n", __func__, msg.rx_status);
|
||||
continue;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&ctx->options_lock);
|
||||
bool cec_enabled = ctx->cec_enabled;
|
||||
pthread_mutex_unlock(&ctx->options_lock);
|
||||
if (!cec_enabled) {
|
||||
continue;
|
||||
}
|
||||
|
||||
pthread_mutex_lock(&ctx->options_lock);
|
||||
bool cec_control_enabled = ctx->cec_control_enabled;
|
||||
pthread_mutex_unlock(&ctx->options_lock);
|
||||
if (!cec_control_enabled && !is_transferable_in_sleep(&msg)) {
|
||||
ALOGD("%s: filter message in standby mode\n", __func__);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (ctx->p_event_cb != NULL) {
|
||||
event.type = HDMI_EVENT_CEC_MESSAGE;
|
||||
event.dev = &ctx->device;
|
||||
event.cec.initiator = msg.msg[0] >> 4;
|
||||
event.cec.destination = msg.msg[0] & 0xf;
|
||||
event.cec.length = msg.len - 1;
|
||||
memcpy(event.cec.body, &msg.msg[1], msg.len - 1);
|
||||
|
||||
ctx->p_event_cb(&event, ctx->cb_arg);
|
||||
} else {
|
||||
ALOGE("no event callback for msg\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ALOGI("%s exit!", __func__);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void hdmicec_set_arc(const struct hdmi_cec_device *dev, int port_id, int flag)
|
||||
{
|
||||
(void)dev;
|
||||
(void)port_id;
|
||||
(void)flag;
|
||||
/* Not supported */
|
||||
}
|
||||
|
||||
static int hdmicec_close(struct hdmi_cec_device *dev)
|
||||
{
|
||||
struct hdmicec_context *ctx = (struct hdmicec_context *)dev;
|
||||
uint64_t tmp = 1;
|
||||
|
||||
ALOGD("%s\n", __func__);
|
||||
|
||||
if (ctx->exit_fd > 0) {
|
||||
write(ctx->exit_fd, &tmp, sizeof(tmp));
|
||||
pthread_join(ctx->thread, NULL);
|
||||
}
|
||||
|
||||
if (ctx->cec_fd > 0)
|
||||
close(ctx->cec_fd);
|
||||
if (ctx->exit_fd > 0)
|
||||
close(ctx->exit_fd);
|
||||
free(ctx);
|
||||
|
||||
ctx->cec_enabled = false;
|
||||
ctx->cec_control_enabled = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cec_init(struct hdmicec_context *ctx)
|
||||
{
|
||||
struct cec_log_addrs laddrs = {};
|
||||
struct cec_caps caps = {};
|
||||
uint32_t mode;
|
||||
int ret;
|
||||
|
||||
// Ensure the CEC device supports required capabilities
|
||||
ret = ioctl(ctx->cec_fd, CEC_ADAP_G_CAPS, &caps);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
if (!(caps.capabilities & (CEC_CAP_LOG_ADDRS |
|
||||
CEC_CAP_TRANSMIT |
|
||||
CEC_CAP_PASSTHROUGH))) {
|
||||
ALOGE("%s: wrong cec adapter capabilities %x\n",
|
||||
__func__, caps.capabilities);
|
||||
return -1;
|
||||
}
|
||||
|
||||
// This is an exclusive follower, in addition put the CEC device into passthrough mode
|
||||
mode = CEC_MODE_INITIATOR | CEC_MODE_EXCL_FOLLOWER_PASSTHRU;
|
||||
ret = ioctl(ctx->cec_fd, CEC_S_MODE, &mode);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ctx->type = property_get_int32("ro.hdmi.device_type", CEC_DEVICE_PLAYBACK);
|
||||
|
||||
ctx->vendor_id = property_get_int32("ro.hdmi.vendor_id",
|
||||
0x000c03 /* HDMI LLC vendor ID */);
|
||||
|
||||
ctx->version = property_get_bool("ro.hdmi.cec_version",
|
||||
CEC_OP_CEC_VERSION_1_4);
|
||||
|
||||
ctx->port_info.type = ctx->type == CEC_DEVICE_TV ? HDMI_INPUT : HDMI_OUTPUT;
|
||||
ctx->port_info.port_id = 1;
|
||||
ctx->port_info.cec_supported = 1;
|
||||
ctx->port_info.arc_supported = 0;
|
||||
|
||||
ALOGD("%s: type=%d\n", __func__, ctx->type);
|
||||
ALOGD("%s: vendor_id=%04x\n", __func__, ctx->vendor_id);
|
||||
ALOGD("%s: version=%d\n", __func__, ctx->version);
|
||||
|
||||
memset(&laddrs, 0, sizeof(laddrs));
|
||||
ret = ioctl(ctx->cec_fd, CEC_ADAP_S_LOG_ADDRS, &laddrs);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
pthread_mutex_init(&ctx->options_lock, NULL);
|
||||
|
||||
ALOGD("%s: initialized CEC controller\n", __func__);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int open_hdmi_cec(const struct hw_module_t *module, const char *id,
|
||||
struct hw_device_t **device)
|
||||
{
|
||||
char path[32];
|
||||
char prop[PROPERTY_VALUE_MAX];
|
||||
hdmicec_context_t *ctx;
|
||||
int ret;
|
||||
|
||||
ALOGD("%s: id=%s\n", __func__, id);
|
||||
|
||||
ctx = malloc(sizeof(struct hdmicec_context));
|
||||
if (!ctx)
|
||||
return -ENOMEM;
|
||||
|
||||
memset(ctx, 0, sizeof(*ctx));
|
||||
|
||||
property_get("ro.hdmi.cec_device", prop, "cec0");
|
||||
snprintf(path, sizeof(path), "/dev/%s", prop);
|
||||
|
||||
ctx->cec_fd = open(path, O_RDWR);
|
||||
if (ctx->cec_fd < 0) {
|
||||
ALOGE("faild to open %s, ret=%s\n", path, strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ctx->exit_fd = eventfd(0, EFD_NONBLOCK);
|
||||
if (ctx->exit_fd < 0) {
|
||||
ALOGE("faild to open eventfd, ret = %d\n", errno);
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ctx->device.common.tag = HARDWARE_DEVICE_TAG;
|
||||
ctx->device.common.version = HDMI_CEC_DEVICE_API_VERSION_1_0;
|
||||
ctx->device.common.module = (struct hw_module_t *)module;
|
||||
ctx->device.common.close = (int (*)(struct hw_device_t* device))hdmicec_close;
|
||||
|
||||
ctx->device.add_logical_address = hdmicec_add_logical_address;
|
||||
ctx->device.clear_logical_address = hdmicec_clear_logical_address;
|
||||
ctx->device.get_physical_address = hdmicec_get_physical_address;
|
||||
ctx->device.send_message = hdmicec_send_message;
|
||||
ctx->device.register_event_callback = hdmicec_register_event_callback;
|
||||
ctx->device.get_version = hdmicec_get_version;
|
||||
ctx->device.get_vendor_id = hdmicec_get_vendor_id;
|
||||
ctx->device.get_port_info = hdmicec_get_port_info;
|
||||
ctx->device.set_option = hdmicec_set_option;
|
||||
ctx->device.set_audio_return_channel = hdmicec_set_arc;
|
||||
ctx->device.is_connected = hdmicec_is_connected;
|
||||
|
||||
/* init status */
|
||||
ret = cec_init(ctx);
|
||||
if (ret)
|
||||
goto fail;
|
||||
|
||||
*device = &ctx->device.common;
|
||||
|
||||
/* thread loop for receiving cec msg */
|
||||
if (pthread_create(&ctx->thread, NULL, event_thread, ctx)) {
|
||||
ALOGE("Can't create event thread: %s\n", strerror(errno));
|
||||
goto fail;
|
||||
}
|
||||
|
||||
ctx->cec_enabled = true;
|
||||
ctx->cec_control_enabled = true;
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
hdmicec_close((struct hdmi_cec_device *)ctx);
|
||||
return -errno;
|
||||
}
|
||||
|
||||
/* module method */
|
||||
static struct hw_module_methods_t hdmi_cec_module_methods = {
|
||||
.open = open_hdmi_cec,
|
||||
};
|
||||
|
||||
/* hdmi_cec module */
|
||||
struct hw_module_t HAL_MODULE_INFO_SYM = {
|
||||
.tag = HARDWARE_MODULE_TAG,
|
||||
.version_major = 1,
|
||||
.version_minor = 0,
|
||||
.id = HDMI_CEC_HARDWARE_MODULE_ID,
|
||||
.name = "Raspberry Pi HDMI CEC HAL",
|
||||
.author = "The Android Open Source Project",
|
||||
.methods = &hdmi_cec_module_methods,
|
||||
};
|
@@ -1,12 +1,4 @@
|
||||
<compatibility-matrix version="1.0" type="device">
|
||||
<hal format="hidl" optional="false">
|
||||
<name>android.frameworks.displayservice</name>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IDisplayService</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl" optional="false">
|
||||
<name>android.frameworks.sensorservice</name>
|
||||
<version>1.0</version>
|
||||
@@ -39,20 +31,4 @@
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl" optional="false">
|
||||
<name>android.system.net.netd</name>
|
||||
<version>1.1</version>
|
||||
<interface>
|
||||
<name>INetd</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl" optional="false">
|
||||
<name>android.system.wifi.keystore</name>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IKeystore</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</compatibility-matrix>
|
||||
|
131
device.mk
131
device.mk
@@ -1,5 +1,5 @@
|
||||
#
|
||||
# Copyright (C) 2021-2022 KonstaKANG
|
||||
# Copyright (C) 2021-2023 KonstaKANG
|
||||
#
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
@@ -8,23 +8,22 @@ DEVICE_PATH := device/brcm/rpi4
|
||||
PRODUCT_SOONG_NAMESPACES += $(DEVICE_PATH)
|
||||
|
||||
$(call inherit-product, $(SRC_TARGET_DIR)/product/core_64_bit.mk)
|
||||
$(call inherit-product, $(SRC_TARGET_DIR)/product/full_base.mk)
|
||||
$(call inherit-product, frameworks/native/build/tablet-7in-xhdpi-2048-dalvik-heap.mk)
|
||||
$(call inherit-product, vendor/brcm/rpi4/rpi4-vendor.mk)
|
||||
|
||||
PRODUCT_AAPT_CONFIG := normal mdpi hdpi
|
||||
PRODUCT_AAPT_PREF_CONFIG := hdpi
|
||||
PRODUCT_CHARACTERISTICS := tablet,nosdcard
|
||||
# APEX
|
||||
$(call inherit-product, $(SRC_TARGET_DIR)/product/updatable_apex.mk)
|
||||
|
||||
# API level
|
||||
PRODUCT_SHIPPING_API_LEVEL := 32
|
||||
PRODUCT_SHIPPING_API_LEVEL := 34
|
||||
|
||||
# Audio
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.audio.service \
|
||||
android.hardware.audio@7.0-impl \
|
||||
android.hardware.audio@7.1-impl \
|
||||
android.hardware.audio.effect@7.0-impl \
|
||||
audio.primary.rpi \
|
||||
audio.primary.rpi_hdmi \
|
||||
audio.r_submix.default \
|
||||
audio.usb.default
|
||||
|
||||
@@ -50,9 +49,9 @@ PRODUCT_PACKAGES += \
|
||||
alsa_loop
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/audio/vc4-hdmi.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/cards/vc4-hdmi.conf \
|
||||
external/alsa-lib/src/conf/alsa.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/alsa.conf \
|
||||
external/alsa-lib/src/conf/cards/aliases.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/cards/aliases.conf \
|
||||
external/alsa-lib/src/conf/cards/vc4-hdmi.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/cards/vc4-hdmi.conf \
|
||||
external/alsa-lib/src/conf/ctl/default.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/ctl/default.conf \
|
||||
external/alsa-lib/src/conf/pcm/center_lfe.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/center_lfe.conf \
|
||||
external/alsa-lib/src/conf/pcm/default.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/default.conf \
|
||||
@@ -75,17 +74,14 @@ PRODUCT_COPY_FILES += \
|
||||
|
||||
# Bluetooth
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.bluetooth@1.0-impl \
|
||||
android.hardware.bluetooth@1.0-service \
|
||||
libbt-vendor
|
||||
android.hardware.bluetooth@1.1-service.btlinux
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.hardware.bluetooth.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth.xml \
|
||||
frameworks/native/data/etc/android.hardware.bluetooth_le.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.bluetooth_le.xml
|
||||
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.bluetooth.audio@2.0-impl \
|
||||
audio.a2dp.default \
|
||||
android.hardware.bluetooth.audio-impl \
|
||||
audio.bluetooth.default
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
@@ -94,7 +90,7 @@ PRODUCT_COPY_FILES += \
|
||||
|
||||
# Camera
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.camera.provider@2.5-external-service
|
||||
android.hardware.camera.provider-V1-external-service
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/camera/external_camera_config.xml:$(TARGET_COPY_OUT_VENDOR)/etc/external_camera_config.xml
|
||||
@@ -105,36 +101,66 @@ PRODUCT_COPY_FILES += \
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.camera.provider@2.5-service_64 \
|
||||
camera.libcamera \
|
||||
ipa_rpi
|
||||
ipa_rpi_vc4
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/camera/android.hardware.camera.provider@2.5-service_64.rpi.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/android.hardware.camera.provider@2.5-service_64.rpi.rc
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/camera/camera_hal.yaml:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/camera_hal.yaml \
|
||||
external/libcamera/src/ipa/raspberrypi/data/imx219.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/raspberrypi/imx219.json \
|
||||
external/libcamera/src/ipa/raspberrypi/data/imx219_noir.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/raspberrypi/imx219_noir.json \
|
||||
external/libcamera/src/ipa/raspberrypi/data/imx477.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/raspberrypi/imx477.json \
|
||||
external/libcamera/src/ipa/raspberrypi/data/imx477_noir.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/raspberrypi/imx477_noir.json \
|
||||
external/libcamera/src/ipa/raspberrypi/data/ov5647.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/raspberrypi/ov5647.json \
|
||||
external/libcamera/src/ipa/raspberrypi/data/ov5647_noir.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/raspberrypi/ov5647_noir.json
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx219.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx219.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx219_noir.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx219_noir.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx296.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx296.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx296_mono.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx296_mono.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx477.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx477.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx477_noir.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx477_noir.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx477_scientific.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx477_scientific.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx708.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx708.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx708_noir.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx708_noir.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx708_wide.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx708_wide.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/imx708_wide_noir.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/imx708_wide_noir.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/ov5647.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/ov5647.json \
|
||||
external/libcamera/src/ipa/rpi/vc4/data/ov5647_noir.json:$(TARGET_COPY_OUT_VENDOR)/etc/libcamera/ipa/rpi/vc4/ov5647_noir.json
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.hardware.camera.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.xml
|
||||
frameworks/native/data/etc/android.hardware.camera.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.xml \
|
||||
frameworks/native/data/etc/android.hardware.camera.concurrent.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.concurrent.xml \
|
||||
frameworks/native/data/etc/android.hardware.camera.flash-autofocus.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.flash-autofocus.xml \
|
||||
frameworks/native/data/etc/android.hardware.camera.front.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.front.xml \
|
||||
frameworks/native/data/etc/android.hardware.camera.full.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.full.xml \
|
||||
frameworks/native/data/etc/android.hardware.camera.raw.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.raw.xml
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/camera/media_profiles_V1_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles_V1_0.xml
|
||||
|
||||
# CEC
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.tv.cec@1.0-impl \
|
||||
android.hardware.tv.cec@1.0-service \
|
||||
hdmi_cec.rpi
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.hardware.hdmi.cec.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.hdmi.cec.xml
|
||||
|
||||
# Debugfs
|
||||
PRODUCT_SET_DEBUGFS_RESTRICTIONS := false
|
||||
|
||||
# DRM
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.drm@1.0-impl \
|
||||
android.hardware.drm@1.0-service \
|
||||
android.hardware.drm@1.4-service.clearkey
|
||||
android.hardware.drm-service.clearkey
|
||||
|
||||
# Emergency info
|
||||
PRODUCT_PACKAGES += \
|
||||
EmergencyInfo
|
||||
|
||||
# Ethernet
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.hardware.ethernet.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.ethernet.xml
|
||||
|
||||
# FFmpeg
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.media.c2@1.2-service-ffmpeg
|
||||
|
||||
# Gatekeeper
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.gatekeeper@1.0-service.software
|
||||
@@ -142,7 +168,8 @@ PRODUCT_PACKAGES += \
|
||||
# Graphics
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.graphics.allocator@4.0-service.minigbm_gbm_mesa \
|
||||
android.hardware.graphics.mapper@4.0-impl.minigbm_gbm_mesa
|
||||
android.hardware.graphics.mapper@4.0-impl.minigbm_gbm_mesa \
|
||||
libgbm_mesa_wrapper
|
||||
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.graphics.composer@2.4-service \
|
||||
@@ -156,53 +183,43 @@ PRODUCT_PACKAGES += \
|
||||
libglapi
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.software.opengles.deqp.level-2021-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.opengles.deqp.level.xml
|
||||
frameworks/native/data/etc/android.software.opengles.deqp.level-2023-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.opengles.deqp.level.xml
|
||||
|
||||
PRODUCT_PACKAGES += \
|
||||
vulkan.broadcom
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/vulkan/android.hardware.vulkan.version-1_2.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \
|
||||
frameworks/native/data/etc/android.hardware.vulkan.level-0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.level.xml \
|
||||
frameworks/native/data/etc/android.hardware.vulkan.version-1_0_3.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.vulkan.version.xml \
|
||||
frameworks/native/data/etc/android.software.vulkan.deqp.level-2021-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml
|
||||
frameworks/native/data/etc/android.software.vulkan.deqp.level-2023-03-01.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.vulkan.deqp.level.xml
|
||||
|
||||
# Health
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.health@2.0-service.rpi
|
||||
android.hardware.health-service.rpi
|
||||
|
||||
# Kernel
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)-kernel/Image:$(PRODUCT_OUT)/kernel
|
||||
|
||||
# Keylayout
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/keylayout/Generic.kl:$(TARGET_COPY_OUT_VENDOR)/usr/keylayout/Generic.kl
|
||||
|
||||
# Keymaster
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.keymaster@3.0-impl \
|
||||
android.hardware.keymaster@3.0-service
|
||||
android.hardware.keymaster@4.1-service
|
||||
|
||||
# Lights
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.light@2.0-service.rpi
|
||||
android.hardware.light-service.rpi
|
||||
|
||||
# Media
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/media/media_codecs.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs.xml \
|
||||
$(DEVICE_PATH)/media/media_codecs_v4l2_c2_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_v4l2_c2_video.xml \
|
||||
frameworks/av/media/libstagefright/data/media_codecs_google_c2_audio.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_c2_audio.xml \
|
||||
frameworks/av/media/libstagefright/data/media_codecs_google_c2_tv.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_c2_tv.xml \
|
||||
frameworks/av/media/libstagefright/data/media_codecs_google_c2_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_google_c2_video.xml
|
||||
|
||||
# Overlays
|
||||
PRODUCT_PACKAGES += \
|
||||
AndroidRpiOverlay \
|
||||
SettingsRpiOverlay \
|
||||
SettingsProviderRpiOverlay \
|
||||
SystemUIRpiOverlay \
|
||||
WifiRpiOverlay
|
||||
|
||||
# Permissions
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/tablet_core_hardware.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/tablet_core_hardware.xml
|
||||
|
||||
# Power
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.power-service.example
|
||||
@@ -221,10 +238,6 @@ PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/seccomp_policy/mediacodec.policy:$(TARGET_COPY_OUT_VENDOR)/etc/seccomp_policy/mediacodec.policy \
|
||||
$(DEVICE_PATH)/seccomp_policy/mediaswcodec.policy:$(TARGET_COPY_OUT_VENDOR)/etc/seccomp_policy/mediaswcodec.policy
|
||||
|
||||
# Settings
|
||||
PRODUCT_PACKAGES += \
|
||||
androidx.window.extensions
|
||||
|
||||
# Storage
|
||||
$(call inherit-product, $(SRC_TARGET_DIR)/product/emulated_storage.mk)
|
||||
|
||||
@@ -232,9 +245,14 @@ $(call inherit-product, $(SRC_TARGET_DIR)/product/emulated_storage.mk)
|
||||
PRODUCT_PACKAGES += \
|
||||
suspend_blocker_rpi
|
||||
|
||||
# Thermal
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.thermal-service.example
|
||||
|
||||
# USB
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.usb@1.0-service
|
||||
android.hardware.usb-service.example \
|
||||
android.hardware.usb.gadget@1.2-service.rpi
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.hardware.usb.accessory.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.accessory.xml \
|
||||
@@ -248,9 +266,15 @@ PRODUCT_PACKAGES += \
|
||||
android.hardware.media.c2@1.0-service-v4l2 \
|
||||
libc2plugin_store
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
$(DEVICE_PATH)/media/media_codecs_v4l2_c2_video.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_codecs_v4l2_c2_video.xml
|
||||
|
||||
# Virtualization
|
||||
$(call inherit-product, packages/modules/Virtualization/apex/product_packages.mk)
|
||||
|
||||
# Wifi
|
||||
PRODUCT_PACKAGES += \
|
||||
android.hardware.wifi@1.0-service \
|
||||
android.hardware.wifi-service \
|
||||
hostapd \
|
||||
hostapd_cli \
|
||||
libwpa_client \
|
||||
@@ -264,3 +288,6 @@ PRODUCT_COPY_FILES += \
|
||||
|
||||
PRODUCT_COPY_FILES += \
|
||||
frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml
|
||||
|
||||
# Window extensions
|
||||
$(call inherit-product, $(SRC_TARGET_DIR)/product/window_extensions.mk)
|
||||
|
12
framework_compatibility_matrix.xml
Normal file
12
framework_compatibility_matrix.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<compatibility-matrix version="1.0" type="framework">
|
||||
<hal format="hidl" optional="true">
|
||||
<name>android.hardware.media.c2</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0-2</version>
|
||||
<interface>
|
||||
<name>IComponentStore</name>
|
||||
<instance>ffmpeg</instance>
|
||||
<instance>v4l2</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</compatibility-matrix>
|
@@ -1,33 +1,32 @@
|
||||
// Copyright (C) 2021-2022 KonstaKANG
|
||||
// Copyright (C) 2018 The Android Open Source Project
|
||||
// Copyright (C) 2023 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.health@2.0-service.rpi",
|
||||
init_rc: ["android.hardware.health@2.0-service.rpi.rc"],
|
||||
vintf_fragments: ["android.hardware.health@2.0-service.rpi.xml"],
|
||||
proprietary: true,
|
||||
name: "android.hardware.health-service.rpi",
|
||||
relative_install_path: "hw",
|
||||
vendor: true,
|
||||
init_rc: ["android.hardware.health-service.rpi.rc"],
|
||||
vintf_fragments: ["android.hardware.health-service.rpi.xml"],
|
||||
srcs: [
|
||||
"HealthService.cpp",
|
||||
],
|
||||
cflags: [
|
||||
"-Wall",
|
||||
"-Werror",
|
||||
"HealthImpl.cpp",
|
||||
"main.cpp",
|
||||
],
|
||||
static_libs: [
|
||||
"android.hardware.health@2.0-impl",
|
||||
"android.hardware.health@1.0-convert",
|
||||
"libhealthservice",
|
||||
"android.hardware.health-translate-ndk",
|
||||
"libbatterymonitor",
|
||||
"libhealthstoragedefault",
|
||||
"libhealthloop",
|
||||
"libhealth_aidl_impl",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libbinder_ndk",
|
||||
"libcutils",
|
||||
"libhidlbase",
|
||||
"liblog",
|
||||
"libutils",
|
||||
"android.hardware.health@2.0",
|
||||
"android.hardware.health-V2-ndk",
|
||||
],
|
||||
header_libs: ["libhealthd_headers"],
|
||||
overrides: ["charger"],
|
||||
}
|
||||
|
38
health/HealthImpl.cpp
Normal file
38
health/HealthImpl.cpp
Normal file
@@ -0,0 +1,38 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "HealthImpl.h"
|
||||
|
||||
using ::aidl::android::hardware::health::BatteryHealth;
|
||||
using ::aidl::android::hardware::health::BatteryStatus;
|
||||
using ::aidl::android::hardware::health::HealthInfo;
|
||||
|
||||
namespace aidl::android::hardware::health {
|
||||
|
||||
void HealthImpl::UpdateHealthInfo(HealthInfo* health_info) {
|
||||
health_info->chargerAcOnline = true;
|
||||
health_info->batteryLevel = 100;
|
||||
health_info->batteryStatus = BatteryStatus::CHARGING;
|
||||
health_info->batteryHealth = BatteryHealth::GOOD;
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus HealthImpl::getChargeStatus(BatteryStatus* out) {
|
||||
*out = BatteryStatus::CHARGING;
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
} // namespace aidl::android::hardware::health
|
37
health/HealthImpl.h
Normal file
37
health/HealthImpl.h
Normal file
@@ -0,0 +1,37 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <health-impl/Health.h>
|
||||
|
||||
using ::aidl::android::hardware::health::Health;
|
||||
|
||||
namespace aidl::android::hardware::health {
|
||||
|
||||
class HealthImpl : public Health {
|
||||
public:
|
||||
using Health::Health;
|
||||
virtual ~HealthImpl() {}
|
||||
|
||||
ndk::ScopedAStatus getChargeStatus(BatteryStatus* out) override;
|
||||
|
||||
protected:
|
||||
void UpdateHealthInfo(HealthInfo* health_info) override;
|
||||
};
|
||||
|
||||
} // namespace aidl::android::hardware::health
|
@@ -1,20 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2021-2022 KonstaKANG
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
|
||||
#include <health2/service.h>
|
||||
#include <healthd/healthd.h>
|
||||
|
||||
int main() {
|
||||
return health_service_main();
|
||||
}
|
||||
|
||||
void healthd_board_init(struct healthd_config*) {}
|
||||
|
||||
int healthd_board_battery_update(struct android::BatteryProperties* battery_props) {
|
||||
battery_props->chargerAcOnline = true;
|
||||
battery_props->batteryLevel = 100;
|
||||
return 0;
|
||||
}
|
6
health/android.hardware.health-service.rpi.rc
Normal file
6
health/android.hardware.health-service.rpi.rc
Normal file
@@ -0,0 +1,6 @@
|
||||
service vendor.health-default /vendor/bin/hw/android.hardware.health-service.rpi
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
capabilities WAKE_ALARM BLOCK_SUSPEND
|
||||
file /dev/kmsg w
|
7
health/android.hardware.health-service.rpi.xml
Normal file
7
health/android.hardware.health-service.rpi.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.health</name>
|
||||
<version>2</version>
|
||||
<fqname>IHealth/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
@@ -1,5 +0,0 @@
|
||||
service vendor.health-hal-2-0 /vendor/bin/hw/android.hardware.health@2.0-service.rpi
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
file /dev/kmsg w
|
32
health/main.cpp
Normal file
32
health/main.cpp
Normal file
@@ -0,0 +1,32 @@
|
||||
/*
|
||||
* Copyright (C) 2021 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "HealthImpl.h"
|
||||
|
||||
#include <android/binder_interface_utils.h>
|
||||
#include <health/utils.h>
|
||||
|
||||
using ::aidl::android::hardware::health::HalHealthLoop;
|
||||
using ::aidl::android::hardware::health::HealthImpl;
|
||||
|
||||
int main() {
|
||||
auto config = std::make_unique<healthd_config>();
|
||||
android::hardware::health::InitHealthdConfig(config.get());
|
||||
auto binder = ndk::SharedRefBase::make<HealthImpl>("default", std::move(config));
|
||||
auto hal_health_loop = std::make_shared<HalHealthLoop>(binder, binder);
|
||||
return hal_health_loop->StartLoop();
|
||||
}
|
486
keylayout/Generic.kl
Normal file
486
keylayout/Generic.kl
Normal file
@@ -0,0 +1,486 @@
|
||||
# Copyright (C) 2010 The Android Open Source Project
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
#
|
||||
# Generic key layout file for full alphabetic US English PC style external keyboards.
|
||||
#
|
||||
# This file is intentionally very generic and is intended to support a broad range of keyboards.
|
||||
# Do not edit the generic key layout to support a specific keyboard; instead, create
|
||||
# a new key layout file with the required keyboard configuration.
|
||||
#
|
||||
|
||||
key 1 ESCAPE
|
||||
key 2 1
|
||||
key 3 2
|
||||
key 4 3
|
||||
key 5 4
|
||||
key 6 5
|
||||
key 7 6
|
||||
key 8 7
|
||||
key 9 8
|
||||
key 10 9
|
||||
key 11 0
|
||||
key 12 MINUS
|
||||
key 13 EQUALS
|
||||
key 14 DEL
|
||||
key 15 TAB
|
||||
key 16 Q
|
||||
key 17 W
|
||||
key 18 E
|
||||
key 19 R
|
||||
key 20 T
|
||||
key 21 Y
|
||||
key 22 U
|
||||
key 23 I
|
||||
key 24 O
|
||||
key 25 P
|
||||
key 26 LEFT_BRACKET
|
||||
key 27 RIGHT_BRACKET
|
||||
key 28 ENTER
|
||||
key 29 CTRL_LEFT
|
||||
key 30 A
|
||||
key 31 S
|
||||
key 32 D
|
||||
key 33 F
|
||||
key 34 G
|
||||
key 35 H
|
||||
key 36 J
|
||||
key 37 K
|
||||
key 38 L
|
||||
key 39 SEMICOLON
|
||||
key 40 APOSTROPHE
|
||||
key 41 GRAVE
|
||||
key 42 SHIFT_LEFT
|
||||
key 43 BACKSLASH
|
||||
key 44 Z
|
||||
key 45 X
|
||||
key 46 C
|
||||
key 47 V
|
||||
key 48 B
|
||||
key 49 N
|
||||
key 50 M
|
||||
key 51 COMMA
|
||||
key 52 PERIOD
|
||||
key 53 SLASH
|
||||
key 54 SHIFT_RIGHT
|
||||
key 55 NUMPAD_MULTIPLY
|
||||
key 56 ALT_LEFT
|
||||
key 57 SPACE
|
||||
key 58 CAPS_LOCK
|
||||
key 59 F1
|
||||
key 60 F2
|
||||
key 61 F3
|
||||
key 62 F4
|
||||
key 63 F5
|
||||
key 64 F6
|
||||
key 65 F7
|
||||
key 66 F8
|
||||
key 67 F9
|
||||
key 68 F10
|
||||
key 69 NUM_LOCK
|
||||
key 70 SCROLL_LOCK
|
||||
key 71 NUMPAD_7
|
||||
key 72 NUMPAD_8
|
||||
key 73 NUMPAD_9
|
||||
key 74 NUMPAD_SUBTRACT
|
||||
key 75 NUMPAD_4
|
||||
key 76 NUMPAD_5
|
||||
key 77 NUMPAD_6
|
||||
key 78 NUMPAD_ADD
|
||||
key 79 NUMPAD_1
|
||||
key 80 NUMPAD_2
|
||||
key 81 NUMPAD_3
|
||||
key 82 NUMPAD_0
|
||||
key 83 NUMPAD_DOT
|
||||
# key 84 (undefined)
|
||||
key 85 ZENKAKU_HANKAKU
|
||||
key 86 BACKSLASH
|
||||
key 87 F11
|
||||
key 88 F12
|
||||
key 89 RO
|
||||
# key 90 "KEY_KATAKANA"
|
||||
# key 91 "KEY_HIRAGANA"
|
||||
key 92 HENKAN
|
||||
key 93 KATAKANA_HIRAGANA
|
||||
key 94 MUHENKAN
|
||||
key 95 NUMPAD_COMMA
|
||||
key 96 NUMPAD_ENTER
|
||||
key 97 CTRL_RIGHT
|
||||
key 98 NUMPAD_DIVIDE
|
||||
key 99 SYSRQ
|
||||
key 100 ALT_RIGHT
|
||||
# key 101 "KEY_LINEFEED"
|
||||
key 102 MOVE_HOME
|
||||
key 103 DPAD_UP
|
||||
key 104 PAGE_UP
|
||||
key 105 DPAD_LEFT
|
||||
key 106 DPAD_RIGHT
|
||||
key 107 MOVE_END
|
||||
key 108 DPAD_DOWN
|
||||
key 109 PAGE_DOWN
|
||||
key 110 INSERT
|
||||
key 111 FORWARD_DEL
|
||||
# key 112 "KEY_MACRO"
|
||||
key 113 VOLUME_MUTE
|
||||
key 114 VOLUME_DOWN
|
||||
key 115 VOLUME_UP
|
||||
key 116 POWER
|
||||
key 117 NUMPAD_EQUALS
|
||||
# key 118 "KEY_KPPLUSMINUS"
|
||||
key 119 BREAK
|
||||
key 120 RECENT_APPS
|
||||
key 121 NUMPAD_COMMA
|
||||
key 122 KANA
|
||||
key 123 EISU
|
||||
key 124 YEN
|
||||
key 125 META_LEFT
|
||||
key 126 META_RIGHT
|
||||
key 127 MENU
|
||||
key 128 MEDIA_STOP
|
||||
# key 129 "KEY_AGAIN"
|
||||
# key 130 "KEY_PROPS"
|
||||
# key 131 "KEY_UNDO"
|
||||
# key 132 "KEY_FRONT"
|
||||
key 133 COPY
|
||||
# key 134 "KEY_OPEN"
|
||||
key 135 PASTE
|
||||
# key 136 "KEY_FIND"
|
||||
key 137 CUT
|
||||
# key 138 "KEY_HELP"
|
||||
key 139 MENU
|
||||
key 140 CALCULATOR
|
||||
# key 141 "KEY_SETUP"
|
||||
key 142 SLEEP
|
||||
key 143 WAKEUP
|
||||
# key 144 "KEY_FILE"
|
||||
# key 145 "KEY_SENDFILE"
|
||||
# key 146 "KEY_DELETEFILE"
|
||||
# key 147 "KEY_XFER"
|
||||
# key 148 "KEY_PROG1"
|
||||
# key 149 "KEY_PROG2"
|
||||
key 150 EXPLORER
|
||||
# key 151 "KEY_MSDOS"
|
||||
key 152 POWER
|
||||
# key 153 "KEY_DIRECTION"
|
||||
# key 154 "KEY_CYCLEWINDOWS"
|
||||
key 155 ENVELOPE
|
||||
key 156 BOOKMARK
|
||||
# key 157 "KEY_COMPUTER"
|
||||
key 158 BACK
|
||||
key 159 FORWARD
|
||||
key 160 MEDIA_CLOSE
|
||||
key 161 MEDIA_EJECT
|
||||
key 162 MEDIA_EJECT
|
||||
key 163 MEDIA_NEXT
|
||||
key 164 MEDIA_PLAY_PAUSE
|
||||
key 165 MEDIA_PREVIOUS
|
||||
key 166 MEDIA_STOP
|
||||
key 167 MEDIA_RECORD
|
||||
key 168 MEDIA_REWIND
|
||||
key 169 CALL
|
||||
# key 170 "KEY_ISO"
|
||||
key 171 MUSIC
|
||||
key 172 HOME
|
||||
key 173 REFRESH
|
||||
# key 174 "KEY_EXIT"
|
||||
# key 175 "KEY_MOVE"
|
||||
# key 176 "KEY_EDIT"
|
||||
key 177 PAGE_UP
|
||||
key 178 PAGE_DOWN
|
||||
key 179 NUMPAD_LEFT_PAREN
|
||||
key 180 NUMPAD_RIGHT_PAREN
|
||||
# key 181 "KEY_NEW"
|
||||
# key 182 "KEY_REDO"
|
||||
# key 183 F13
|
||||
# key 184 F14
|
||||
# key 185 F15
|
||||
# key 186 F16
|
||||
# key 187 F17
|
||||
# key 188 F18
|
||||
# key 189 F19
|
||||
# key 190 F20
|
||||
# key 191 F21
|
||||
# key 192 F22
|
||||
# key 193 F23
|
||||
# key 194 F24
|
||||
# key 195 (undefined)
|
||||
# key 196 (undefined)
|
||||
# key 197 (undefined)
|
||||
# key 198 (undefined)
|
||||
# key 199 (undefined)
|
||||
key 200 MEDIA_PLAY
|
||||
key 201 MEDIA_PAUSE
|
||||
# key 202 "KEY_PROG3"
|
||||
# key 203 "KEY_PROG4"
|
||||
key 204 NOTIFICATION
|
||||
# key 205 "KEY_SUSPEND"
|
||||
# key 206 "KEY_CLOSE"
|
||||
key 207 MEDIA_PLAY
|
||||
key 208 MEDIA_FAST_FORWARD
|
||||
# key 209 "KEY_BASSBOOST"
|
||||
# key 210 "KEY_PRINT"
|
||||
# key 211 "KEY_HP"
|
||||
key 212 CAMERA
|
||||
key 213 MUSIC
|
||||
# key 214 "KEY_QUESTION"
|
||||
key 215 ENVELOPE
|
||||
# key 216 "KEY_CHAT"
|
||||
key 217 SEARCH
|
||||
# key 218 "KEY_CONNECT"
|
||||
# key 219 "KEY_FINANCE"
|
||||
# key 220 "KEY_SPORT"
|
||||
# key 221 "KEY_SHOP"
|
||||
# key 222 "KEY_ALTERASE"
|
||||
# key 223 "KEY_CANCEL"
|
||||
key 224 BRIGHTNESS_DOWN
|
||||
key 225 BRIGHTNESS_UP
|
||||
key 226 HEADSETHOOK
|
||||
key 228 KEYBOARD_BACKLIGHT_TOGGLE
|
||||
key 229 KEYBOARD_BACKLIGHT_DOWN
|
||||
key 230 KEYBOARD_BACKLIGHT_UP
|
||||
key 248 MUTE
|
||||
|
||||
key 256 BUTTON_1
|
||||
key 257 BUTTON_2
|
||||
key 258 BUTTON_3
|
||||
key 259 BUTTON_4
|
||||
key 260 BUTTON_5
|
||||
key 261 BUTTON_6
|
||||
key 262 BUTTON_7
|
||||
key 263 BUTTON_8
|
||||
key 264 BUTTON_9
|
||||
key 265 BUTTON_10
|
||||
key 266 BUTTON_11
|
||||
key 267 BUTTON_12
|
||||
key 268 BUTTON_13
|
||||
key 269 BUTTON_14
|
||||
key 270 BUTTON_15
|
||||
key 271 BUTTON_16
|
||||
|
||||
key 288 BUTTON_1
|
||||
key 289 BUTTON_2
|
||||
key 290 BUTTON_3
|
||||
key 291 BUTTON_4
|
||||
key 292 BUTTON_5
|
||||
key 293 BUTTON_6
|
||||
key 294 BUTTON_7
|
||||
key 295 BUTTON_8
|
||||
key 296 BUTTON_9
|
||||
key 297 BUTTON_10
|
||||
key 298 BUTTON_11
|
||||
key 299 BUTTON_12
|
||||
key 300 BUTTON_13
|
||||
key 301 BUTTON_14
|
||||
key 302 BUTTON_15
|
||||
key 303 BUTTON_16
|
||||
|
||||
|
||||
key 304 BUTTON_A
|
||||
key 305 BUTTON_B
|
||||
key 306 BUTTON_C
|
||||
key 307 BUTTON_X
|
||||
key 308 BUTTON_Y
|
||||
key 309 BUTTON_Z
|
||||
key 310 BUTTON_L1
|
||||
key 311 BUTTON_R1
|
||||
key 312 BUTTON_L2
|
||||
key 313 BUTTON_R2
|
||||
key 314 BUTTON_SELECT
|
||||
key 315 BUTTON_START
|
||||
key 316 BUTTON_MODE
|
||||
key 317 BUTTON_THUMBL
|
||||
key 318 BUTTON_THUMBR
|
||||
|
||||
|
||||
key 329 STYLUS_BUTTON_TERTIARY
|
||||
key 331 STYLUS_BUTTON_PRIMARY
|
||||
key 332 STYLUS_BUTTON_SECONDARY
|
||||
|
||||
|
||||
# key 352 "KEY_OK"
|
||||
key 353 DPAD_CENTER
|
||||
# key 354 "KEY_GOTO"
|
||||
# key 355 "KEY_CLEAR"
|
||||
# key 356 "KEY_POWER2"
|
||||
# key 357 "KEY_OPTION"
|
||||
# key 358 "KEY_INFO"
|
||||
# key 359 "KEY_TIME"
|
||||
# key 360 "KEY_VENDOR"
|
||||
# key 361 "KEY_ARCHIVE"
|
||||
key 362 GUIDE
|
||||
# key 363 "KEY_CHANNEL"
|
||||
# key 364 "KEY_FAVORITES"
|
||||
# key 365 "KEY_EPG"
|
||||
key 366 DVR
|
||||
# key 367 "KEY_MHP"
|
||||
# key 368 "KEY_LANGUAGE"
|
||||
# key 369 "KEY_TITLE"
|
||||
key 370 CAPTIONS
|
||||
# key 371 "KEY_ANGLE"
|
||||
# key 372 "KEY_ZOOM"
|
||||
# key 373 "KEY_MODE"
|
||||
# key 374 "KEY_KEYBOARD"
|
||||
# key 375 "KEY_SCREEN"
|
||||
# key 376 "KEY_PC"
|
||||
key 377 TV
|
||||
# key 378 "KEY_TV2"
|
||||
# key 379 "KEY_VCR"
|
||||
# key 380 "KEY_VCR2"
|
||||
# key 381 "KEY_SAT"
|
||||
# key 382 "KEY_SAT2"
|
||||
# key 383 "KEY_CD"
|
||||
# key 384 "KEY_TAPE"
|
||||
# key 385 "KEY_RADIO"
|
||||
# key 386 "KEY_TUNER"
|
||||
# key 387 "KEY_PLAYER"
|
||||
# key 388 "KEY_TEXT"
|
||||
# key 389 "KEY_DVD"
|
||||
# key 390 "KEY_AUX"
|
||||
# key 391 "KEY_MP3"
|
||||
# key 392 "KEY_AUDIO"
|
||||
# key 393 "KEY_VIDEO"
|
||||
# key 394 "KEY_DIRECTORY"
|
||||
# key 395 "KEY_LIST"
|
||||
# key 396 "KEY_MEMO"
|
||||
key 397 CALENDAR
|
||||
key 398 PROG_RED
|
||||
key 399 PROG_GREEN
|
||||
key 400 PROG_YELLOW
|
||||
key 401 PROG_BLUE
|
||||
key 402 CHANNEL_UP
|
||||
key 403 CHANNEL_DOWN
|
||||
# key 404 "KEY_FIRST"
|
||||
key 405 LAST_CHANNEL
|
||||
# key 406 "KEY_AB"
|
||||
# key 407 "KEY_NEXT"
|
||||
# key 408 "KEY_RESTART"
|
||||
# key 409 "KEY_SLOW"
|
||||
# key 410 "KEY_SHUFFLE"
|
||||
# key 411 "KEY_BREAK"
|
||||
# key 412 "KEY_PREVIOUS"
|
||||
# key 413 "KEY_DIGITS"
|
||||
# key 414 "KEY_TEEN"
|
||||
# key 415 "KEY_TWEN"
|
||||
# key 418 "KEY_ZOOM_IN"
|
||||
key 418 ZOOM_IN
|
||||
# key 419 "KEY_ZOOM_OUT"
|
||||
key 419 ZOOM_OUT
|
||||
key 528 FOCUS
|
||||
|
||||
key 429 CONTACTS
|
||||
|
||||
# key 448 "KEY_DEL_EOL"
|
||||
# key 449 "KEY_DEL_EOS"
|
||||
# key 450 "KEY_INS_LINE"
|
||||
# key 451 "KEY_DEL_LINE"
|
||||
|
||||
|
||||
key 464 FUNCTION
|
||||
key 465 ESCAPE FUNCTION
|
||||
key 466 F1 FUNCTION
|
||||
key 467 F2 FUNCTION
|
||||
key 468 F3 FUNCTION
|
||||
key 469 F4 FUNCTION
|
||||
key 470 F5 FUNCTION
|
||||
key 471 F6 FUNCTION
|
||||
key 472 F7 FUNCTION
|
||||
key 473 F8 FUNCTION
|
||||
key 474 F9 FUNCTION
|
||||
key 475 F10 FUNCTION
|
||||
key 476 F11 FUNCTION
|
||||
key 477 F12 FUNCTION
|
||||
key 478 1 FUNCTION
|
||||
key 479 2 FUNCTION
|
||||
key 480 D FUNCTION
|
||||
key 481 E FUNCTION
|
||||
key 482 F FUNCTION
|
||||
key 483 S FUNCTION
|
||||
key 484 B FUNCTION
|
||||
|
||||
|
||||
# key 497 KEY_BRL_DOT1
|
||||
# key 498 KEY_BRL_DOT2
|
||||
# key 499 KEY_BRL_DOT3
|
||||
# key 500 KEY_BRL_DOT4
|
||||
# key 501 KEY_BRL_DOT5
|
||||
# key 502 KEY_BRL_DOT6
|
||||
# key 503 KEY_BRL_DOT7
|
||||
# key 504 KEY_BRL_DOT8
|
||||
|
||||
key 522 STAR
|
||||
key 523 POUND
|
||||
key 580 APP_SWITCH
|
||||
key 582 VOICE_ASSIST
|
||||
# Linux KEY_ASSISTANT
|
||||
key 583 ASSIST
|
||||
key 656 MACRO_1
|
||||
key 657 MACRO_2
|
||||
key 658 MACRO_3
|
||||
key 659 MACRO_4
|
||||
|
||||
# CEC
|
||||
key 352 ENTER
|
||||
key 618 HOME
|
||||
key 141 POWER
|
||||
key 174 BACK
|
||||
|
||||
# Keys defined by HID usages
|
||||
key usage 0x0c0067 WINDOW
|
||||
key usage 0x0c006F BRIGHTNESS_UP
|
||||
key usage 0x0c0070 BRIGHTNESS_DOWN
|
||||
key usage 0x0c0079 KEYBOARD_BACKLIGHT_UP
|
||||
key usage 0x0c007A KEYBOARD_BACKLIGHT_DOWN
|
||||
key usage 0x0c007C KEYBOARD_BACKLIGHT_TOGGLE
|
||||
key usage 0x0c0173 MEDIA_AUDIO_TRACK
|
||||
key usage 0x0c019C PROFILE_SWITCH
|
||||
key usage 0x0c01A2 ALL_APPS
|
||||
key usage 0x0d0044 STYLUS_BUTTON_PRIMARY
|
||||
key usage 0x0d005a STYLUS_BUTTON_SECONDARY
|
||||
|
||||
# Joystick and game controller axes.
|
||||
# Axes that are not mapped will be assigned generic axis numbers by the input subsystem.
|
||||
axis 0x00 X
|
||||
axis 0x01 Y
|
||||
axis 0x02 Z
|
||||
axis 0x03 RX
|
||||
axis 0x04 RY
|
||||
axis 0x05 RZ
|
||||
axis 0x06 THROTTLE
|
||||
axis 0x07 RUDDER
|
||||
axis 0x08 WHEEL
|
||||
axis 0x09 RTRIGGER
|
||||
axis 0x0a LTRIGGER
|
||||
axis 0x10 HAT_X
|
||||
axis 0x11 HAT_Y
|
||||
|
||||
# LEDs
|
||||
led 0x00 NUM_LOCK
|
||||
led 0x01 CAPS_LOCK
|
||||
led 0x02 SCROLL_LOCK
|
||||
led 0x03 COMPOSE
|
||||
led 0x04 KANA
|
||||
led 0x05 SLEEP
|
||||
led 0x06 SUSPEND
|
||||
led 0x07 MUTE
|
||||
led 0x08 MISC
|
||||
led 0x09 MAIL
|
||||
led 0x0a CHARGING
|
||||
|
||||
# SENSORs
|
||||
sensor 0x00 ACCELEROMETER X
|
||||
sensor 0x01 ACCELEROMETER Y
|
||||
sensor 0x02 ACCELEROMETER Z
|
||||
sensor 0x03 GYROSCOPE X
|
||||
sensor 0x04 GYROSCOPE Y
|
||||
sensor 0x05 GYROSCOPE Z
|
@@ -1,24 +1,21 @@
|
||||
// Copyright (C) 2018 The LineageOS Project
|
||||
// Copyright (C) 2021-2022 KonstaKANG
|
||||
// Copyright (C) 2020 The Android Open Source Project
|
||||
// Copyright (C) 2023 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.light@2.0-service.rpi",
|
||||
init_rc: ["android.hardware.light@2.0-service.rpi.rc"],
|
||||
vintf_fragments: ["android.hardware.light@2.0-service.rpi.xml"],
|
||||
proprietary: true,
|
||||
name: "android.hardware.light-service.rpi",
|
||||
relative_install_path: "hw",
|
||||
vendor: true,
|
||||
init_rc: ["android.hardware.light-service.rpi.rc"],
|
||||
vintf_fragments: ["android.hardware.light-service.rpi.xml"],
|
||||
srcs: [
|
||||
"Light.cpp",
|
||||
"service.cpp",
|
||||
"Lights.cpp",
|
||||
"main.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"libutils",
|
||||
"android.hardware.light@2.0",
|
||||
"libbinder_ndk",
|
||||
"android.hardware.light-V2-ndk",
|
||||
],
|
||||
}
|
||||
|
@@ -1,93 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The LineageOS Project
|
||||
* Copyright (C) 2021-2022 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "LightService"
|
||||
|
||||
#include "Light.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
|
||||
namespace {
|
||||
using android::hardware::light::V2_0::LightState;
|
||||
|
||||
static constexpr int DEFAULT_MAX_BRIGHTNESS = 255;
|
||||
|
||||
static uint32_t rgbToBrightness(const LightState& state) {
|
||||
uint32_t color = state.color & 0x00ffffff;
|
||||
return ((77 * ((color >> 16) & 0xff)) + (150 * ((color >> 8) & 0xff)) +
|
||||
(29 * (color & 0xff))) >> 8;
|
||||
}
|
||||
} // anonymous namespace
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace light {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
Light::Light(std::pair<std::ofstream, uint32_t>&& lcd_backlight)
|
||||
: mLcdBacklight(std::move(lcd_backlight)) {
|
||||
auto backlightFn(std::bind(&Light::setLcdBacklight, this, std::placeholders::_1));
|
||||
mLights.emplace(std::make_pair(Type::BACKLIGHT, backlightFn));
|
||||
}
|
||||
|
||||
// Methods from ::android::hardware::light::V2_0::ILight follow.
|
||||
Return<Status> Light::setLight(Type type, const LightState& state) {
|
||||
auto it = mLights.find(type);
|
||||
|
||||
if (it == mLights.end()) {
|
||||
return Status::LIGHT_NOT_SUPPORTED;
|
||||
}
|
||||
|
||||
it->second(state);
|
||||
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
Return<void> Light::getSupportedTypes(getSupportedTypes_cb _hidl_cb) {
|
||||
std::vector<Type> types;
|
||||
|
||||
for (auto const& light : mLights) {
|
||||
types.push_back(light.first);
|
||||
}
|
||||
|
||||
_hidl_cb(types);
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
void Light::setLcdBacklight(const LightState& state) {
|
||||
std::lock_guard<std::mutex> lock(mLock);
|
||||
|
||||
uint32_t brightness = rgbToBrightness(state);
|
||||
|
||||
// If max panel brightness is not the default (255),
|
||||
// apply linear scaling across the accepted range.
|
||||
if (mLcdBacklight.second != DEFAULT_MAX_BRIGHTNESS) {
|
||||
int old_brightness = brightness;
|
||||
brightness = brightness * mLcdBacklight.second / DEFAULT_MAX_BRIGHTNESS;
|
||||
LOG(VERBOSE) << "scaling brightness " << old_brightness << " => " << brightness;
|
||||
}
|
||||
|
||||
mLcdBacklight.first << brightness << std::endl;
|
||||
}
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
@@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The LineageOS Project
|
||||
* Copyright (C) 2021-2022 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
|
||||
#define ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
|
||||
|
||||
#include <android/hardware/light/2.0/ILight.h>
|
||||
#include <hidl/Status.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <mutex>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace light {
|
||||
namespace V2_0 {
|
||||
namespace implementation {
|
||||
|
||||
struct Light : public ILight {
|
||||
Light(std::pair<std::ofstream, uint32_t>&& lcd_backlight);
|
||||
|
||||
// Methods from ::android::hardware::light::V2_0::ILight follow.
|
||||
Return<Status> setLight(Type type, const LightState& state) override;
|
||||
Return<void> getSupportedTypes(getSupportedTypes_cb _hidl_cb) override;
|
||||
|
||||
private:
|
||||
void setLcdBacklight(const LightState& state);
|
||||
|
||||
std::pair<std::ofstream, uint32_t> mLcdBacklight;
|
||||
|
||||
std::unordered_map<Type, std::function<void(const LightState&)>> mLights;
|
||||
std::mutex mLock;
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V2_0
|
||||
} // namespace light
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_LIGHT_V2_0_LIGHT_H
|
67
light/Lights.cpp
Normal file
67
light/Lights.cpp
Normal file
@@ -0,0 +1,67 @@
|
||||
/*
|
||||
* Copyright (C) 2019 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Lights.h"
|
||||
|
||||
#include <android-base/file.h>
|
||||
|
||||
using ::android::base::WriteStringToFile;
|
||||
|
||||
namespace aidl::android::hardware::light {
|
||||
|
||||
static const std::string backlightFiles[] = {
|
||||
"/sys/class/backlight/rpi_backlight/brightness"
|
||||
};
|
||||
|
||||
const static std::vector<HwLight> availableLights = {
|
||||
{.id = (int)LightType::BACKLIGHT, .type = LightType::BACKLIGHT, .ordinal = 0}
|
||||
};
|
||||
|
||||
ndk::ScopedAStatus Lights::setLightState(int id, const HwLightState& state) {
|
||||
HwLight const& light = availableLights[id];
|
||||
std::string const brightness = std::to_string(rgbToBrightness(state));
|
||||
|
||||
switch (light.type) {
|
||||
case LightType::BACKLIGHT:
|
||||
for (auto &file : backlightFiles) {
|
||||
if (!access(file.c_str(), W_OK)) {
|
||||
WriteStringToFile(brightness, file);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
return ndk::ScopedAStatus::fromExceptionCode(EX_UNSUPPORTED_OPERATION);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
ndk::ScopedAStatus Lights::getLights(std::vector<HwLight>* lights) {
|
||||
for (auto i = availableLights.begin(); i != availableLights.end(); i++) {
|
||||
lights->push_back(*i);
|
||||
}
|
||||
|
||||
return ndk::ScopedAStatus::ok();
|
||||
}
|
||||
|
||||
uint32_t Lights::rgbToBrightness(const HwLightState& state) {
|
||||
uint32_t color = state.color & 0x00ffffff;
|
||||
return ((77 * ((color >> 16) & 0xff)) + (150 * ((color >> 8) & 0xff)) +
|
||||
(29 * (color & 0xff))) >> 8;
|
||||
}
|
||||
|
||||
} // aidl::android::hardware::light
|
33
light/Lights.h
Normal file
33
light/Lights.h
Normal file
@@ -0,0 +1,33 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <aidl/android/hardware/light/BnLights.h>
|
||||
|
||||
namespace aidl::android::hardware::light {
|
||||
|
||||
class Lights : public BnLights {
|
||||
public:
|
||||
ndk::ScopedAStatus setLightState(int id, const HwLightState& state) override;
|
||||
ndk::ScopedAStatus getLights(std::vector<HwLight>* types) override;
|
||||
|
||||
private:
|
||||
uint32_t rgbToBrightness(const HwLightState& state);
|
||||
};
|
||||
|
||||
} // aidl::android::hardware::light
|
@@ -1,11 +1,9 @@
|
||||
on init
|
||||
on early-boot
|
||||
chown system system /sys/class/backlight/rpi_backlight/brightness
|
||||
chmod 660 /sys/class/backlight/rpi_backlight/brightness
|
||||
|
||||
service vendor.light-hal-2-0 /vendor/bin/hw/android.hardware.light@2.0-service.rpi
|
||||
interface android.hardware.light@2.0::ILight default
|
||||
service vendor.light-default /vendor/bin/hw/android.hardware.light-service.rpi
|
||||
class hal
|
||||
user system
|
||||
group system
|
||||
# shutting off lights while powering-off
|
||||
shutdown critical
|
7
light/android.hardware.light-service.rpi.xml
Normal file
7
light/android.hardware.light-service.rpi.xml
Normal file
@@ -0,0 +1,7 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.light</name>
|
||||
<version>2</version>
|
||||
<fqname>ILights/default</fqname>
|
||||
</hal>
|
||||
</manifest>
|
@@ -1,11 +0,0 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.light</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>2.0</version>
|
||||
<interface>
|
||||
<name>ILight</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
</manifest>
|
35
light/main.cpp
Normal file
35
light/main.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "Lights.h"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <android/binder_manager.h>
|
||||
#include <android/binder_process.h>
|
||||
|
||||
using ::aidl::android::hardware::light::Lights;
|
||||
|
||||
int main() {
|
||||
ABinderProcess_setThreadPoolMaxThreadCount(0);
|
||||
std::shared_ptr<Lights> lights = ndk::SharedRefBase::make<Lights>();
|
||||
|
||||
const std::string instance = std::string() + Lights::descriptor + "/default";
|
||||
binder_status_t status = AServiceManager_addService(lights->asBinder().get(), instance.c_str());
|
||||
CHECK(status == STATUS_OK);
|
||||
|
||||
ABinderProcess_joinThreadPool();
|
||||
return EXIT_FAILURE; // should not reached
|
||||
}
|
@@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2018 The LineageOS Project
|
||||
* Copyright (C) 2021-2022 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.light@2.0-service.rpi"
|
||||
|
||||
#include <android-base/logging.h>
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include <utils/Errors.h>
|
||||
|
||||
#include "Light.h"
|
||||
|
||||
// libhwbinder:
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
// Generated HIDL files
|
||||
using android::hardware::light::V2_0::ILight;
|
||||
using android::hardware::light::V2_0::implementation::Light;
|
||||
|
||||
const static std::string kLcdBacklightPath = "/sys/class/backlight/rpi_backlight/brightness";
|
||||
|
||||
int main() {
|
||||
uint32_t lcdMaxBrightness = 255;
|
||||
|
||||
std::ofstream lcdBacklight(kLcdBacklightPath);
|
||||
if (!lcdBacklight) {
|
||||
LOG(ERROR) << "Failed to open " << kLcdBacklightPath << ", error=" << errno
|
||||
<< " (" << strerror(errno) << ")";
|
||||
//return -errno;
|
||||
}
|
||||
|
||||
android::sp<ILight> service = new Light(
|
||||
{std::move(lcdBacklight), lcdMaxBrightness});
|
||||
|
||||
configureRpcThreadpool(1, true);
|
||||
|
||||
android::status_t status = service->registerAsService();
|
||||
|
||||
if (status != android::OK) {
|
||||
LOG(ERROR) << "Cannot register Light HAL service";
|
||||
//return 1;
|
||||
}
|
||||
|
||||
LOG(INFO) << "Light HAL Ready.";
|
||||
joinRpcThreadpool();
|
||||
// Under normal cases, execution will not reach this line.
|
||||
LOG(ERROR) << "Light HAL failed to join thread pool.";
|
||||
return 1;
|
||||
}
|
57
manifest.xml
57
manifest.xml
@@ -1,8 +1,8 @@
|
||||
<manifest version="1.0" type="device" target-level="6">
|
||||
<manifest version="1.0" type="device" target-level="8">
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.audio</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>7.0</version>
|
||||
<version>7.1</version>
|
||||
<interface>
|
||||
<name>IDevicesFactory</name>
|
||||
<instance>default</instance>
|
||||
@@ -20,19 +20,18 @@
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.bluetooth</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<version>1.1</version>
|
||||
<interface>
|
||||
<name>IBluetoothHci</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.bluetooth.audio</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>2.0</version>
|
||||
<hal format="aidl">
|
||||
<name>android.hardware.camera.provider</name>
|
||||
<version>1</version>
|
||||
<interface>
|
||||
<name>IBluetoothAudioProvidersFactory</name>
|
||||
<instance>default</instance>
|
||||
<name>ICameraProvider</name>
|
||||
<instance>external/0</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
@@ -41,23 +40,9 @@
|
||||
<version>2.5</version>
|
||||
<interface>
|
||||
<name>ICameraProvider</name>
|
||||
<instance>external/0</instance>
|
||||
<instance>legacy/0</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.drm</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>ICryptoFactory</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
<interface>
|
||||
<name>IDrmFactory</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.graphics.composer</name>
|
||||
<transport>hwbinder</transport>
|
||||
@@ -68,33 +53,11 @@
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.keymaster</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>3.0</version>
|
||||
<interface>
|
||||
<name>IKeymasterDevice</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.media.c2</name>
|
||||
<name>android.hardware.tv.cec</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IComponentStore</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.media.omx</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>1.0</version>
|
||||
<interface>
|
||||
<name>IOmx</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
<interface>
|
||||
<name>IOmxStore</name>
|
||||
<name>IHdmiCec</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
||||
|
@@ -17,7 +17,8 @@
|
||||
-->
|
||||
|
||||
<MediaCodecs>
|
||||
<!-- <Include href="media_codecs_v4l2_c2_video.xml" /> -->
|
||||
<Include href="media_codecs_ffmpeg_c2.xml" />
|
||||
<Include href="media_codecs_v4l2_c2_video.xml" />
|
||||
<Include href="media_codecs_google_c2_audio.xml" />
|
||||
<Include href="media_codecs_google_c2_tv.xml" />
|
||||
<Include href="media_codecs_google_c2_video.xml" />
|
||||
|
@@ -17,7 +17,6 @@
|
||||
-->
|
||||
|
||||
<Included>
|
||||
<!--
|
||||
<Encoders>
|
||||
<MediaCodec name="c2.v4l2.avc.encoder" type="video/avc">
|
||||
<Limit name="size" min="32x32" max="4096x4096" />
|
||||
@@ -29,10 +28,9 @@
|
||||
<Limit name="performance-point-1280x720" range="30-30" />
|
||||
</MediaCodec>
|
||||
</Encoders>
|
||||
-->
|
||||
|
||||
<Decoders>
|
||||
<MediaCodec name="c2.v4l2.avc.decoder" type="video/avc" >
|
||||
<MediaCodec name="c2.v4l2.avc.decoder" type="video/avc">
|
||||
<Limit name="size" min="16x16" max="4096x4096" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
@@ -42,65 +40,5 @@
|
||||
<Limit name="performance-point-3840x2160" range="30-30" />
|
||||
<Feature name="adaptive-playback" />
|
||||
</MediaCodec>
|
||||
|
||||
<!--
|
||||
<MediaCodec name="c2.v4l2.vp8.decoder" type="video/x-vnd.on2.vp8" >
|
||||
<Limit name="size" min="16x16" max="4096x4096" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="1984500" />
|
||||
<Limit name="bitrate" range="1-62500000" />
|
||||
<Limit name="concurrent-instances" max="8" />
|
||||
<Limit name="performance-point-3840x2160" range="30-30" />
|
||||
<Feature name="adaptive-playback" />
|
||||
</MediaCodec>
|
||||
|
||||
<MediaCodec name="c2.v4l2.vp9.decoder" type="video/x-vnd.on2.vp9" >
|
||||
<Limit name="size" min="16x16" max="4096x4096" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="2073600" />
|
||||
<Limit name="bitrate" range="1-62500000" />
|
||||
<Limit name="concurrent-instances" max="8" />
|
||||
<Limit name="performance-point-3840x2160" range="30-30" />
|
||||
<Feature name="adaptive-playback" />
|
||||
</MediaCodec>
|
||||
|
||||
<MediaCodec name="c2.v4l2.avc.decoder.secure" type="video/avc" >
|
||||
<Limit name="size" min="16x16" max="4096x4096" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="1879200" />
|
||||
<Limit name="bitrate" range="1-62500000" />
|
||||
<Limit name="concurrent-instances" max="8" />
|
||||
<Limit name="performance-point-3840x2160" range="30-30" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Feature name="secure-playback" required="true" />
|
||||
</MediaCodec>
|
||||
|
||||
<MediaCodec name="c2.v4l2.vp8.decoder.secure" type="video/x-vnd.on2.vp8" >
|
||||
<Limit name="size" min="16x16" max="4096x4096" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="1984500" />
|
||||
<Limit name="bitrate" range="1-62500000" />
|
||||
<Limit name="concurrent-instances" max="8" />
|
||||
<Limit name="performance-point-3840x2160" range="30-30" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Feature name="secure-playback" required="true" />
|
||||
</MediaCodec>
|
||||
|
||||
<MediaCodec name="c2.v4l2.vp9.decoder.secure" type="video/x-vnd.on2.vp9" >
|
||||
<Limit name="size" min="16x16" max="4096x4096" />
|
||||
<Limit name="alignment" value="2x2" />
|
||||
<Limit name="block-size" value="16x16" />
|
||||
<Limit name="blocks-per-second" min="1" max="2073600" />
|
||||
<Limit name="bitrate" range="1-62500000" />
|
||||
<Limit name="concurrent-instances" max="8" />
|
||||
<Limit name="performance-point-3840x2160" range="30-30" />
|
||||
<Feature name="adaptive-playback" />
|
||||
<Feature name="secure-playback" required="true" />
|
||||
</MediaCodec>
|
||||
-->
|
||||
</Decoders>
|
||||
</Included>
|
||||
|
3
mkimg.sh
3
mkimg.sh
@@ -6,7 +6,7 @@
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
#
|
||||
|
||||
VERSION=RaspberryVanillaAOSP12
|
||||
VERSION=RaspberryVanillaAOSP14
|
||||
DATE=$(date +%Y%m%d)
|
||||
IMGNAME=${VERSION}-${DATE}-rpi4.img
|
||||
IMGSIZE=7
|
||||
@@ -63,7 +63,6 @@ echo "Copying vendor..."
|
||||
sudo dd if=${OUTDIR}/vendor.img of=/dev/mapper/${LOOPDEV}p3 bs=1M
|
||||
echo "Creating userdata..."
|
||||
sudo mkfs.ext4 /dev/mapper/${LOOPDEV}p4 -I 512 -L userdata
|
||||
sudo resize2fs /dev/mapper/${LOOPDEV}p4 1212156
|
||||
sync
|
||||
|
||||
sudo kpartx -d "/dev/${LOOPDEV}"
|
||||
|
@@ -46,6 +46,12 @@
|
||||
cell broadcasting sms, and MMS. -->
|
||||
<bool name="config_sms_capable">false</bool>
|
||||
|
||||
<!-- Flag indicating whether the current device allows data.
|
||||
If true, this means that the device supports data connectivity through
|
||||
the telephony network.
|
||||
This can be overridden to false for devices that support voice and/or sms . -->
|
||||
<bool name="config_mobile_data_capable">false</bool>
|
||||
|
||||
<!-- Whether a software navigation bar should be shown. NOTE: in the future this may be
|
||||
autodetected from the Configuration. -->
|
||||
<bool name="config_showNavigationBar">true</bool>
|
||||
@@ -111,4 +117,8 @@
|
||||
-->
|
||||
<integer name="config_defaultNightMode">2</integer>
|
||||
|
||||
<!-- CEC Configuration -->
|
||||
<bool name="config_cecTvSendStandbyOnSleepEnabled_default">false</bool>
|
||||
<bool name="config_cecTvSendStandbyOnSleepDisabled_default">true</bool>
|
||||
|
||||
</resources>
|
||||
|
10
overlay/AndroidTvRpiOverlay/Android.bp
Normal file
10
overlay/AndroidTvRpiOverlay/Android.bp
Normal file
@@ -0,0 +1,10 @@
|
||||
// Copyright (C) 2021-2022 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
runtime_resource_overlay {
|
||||
name: "AndroidTvRpiOverlay",
|
||||
resource_dirs: ["res"],
|
||||
sdk_version: "current",
|
||||
proprietary: true
|
||||
}
|
19
overlay/AndroidTvRpiOverlay/AndroidManifest.xml
Normal file
19
overlay/AndroidTvRpiOverlay/AndroidManifest.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright (C) 2021-2022 KonstaKANG
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="android.rpi.tv"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
<application android:hasCode="false" />
|
||||
<overlay
|
||||
android:targetPackage="android"
|
||||
android:isStatic="true"
|
||||
android:priority="0" />
|
||||
</manifest>
|
62
overlay/AndroidTvRpiOverlay/res/values/config.xml
Normal file
62
overlay/AndroidTvRpiOverlay/res/values/config.xml
Normal file
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2009 The Android Open Source Project
|
||||
Copyright (C) 2021-2022 KonstaKANG
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
<!-- User activity timeout: Minimum screen off timeout in milliseconds.
|
||||
|
||||
Sets a lower bound for the {@link Settings.System#SCREEN_OFF_TIMEOUT} setting
|
||||
which determines how soon the device will go to sleep when there is no
|
||||
user activity.
|
||||
|
||||
This value must be greater than zero, otherwise the device will immediately
|
||||
fall asleep again as soon as it is awoken.
|
||||
-->
|
||||
<integer name="config_minimumScreenOffTimeout">86400000</integer>
|
||||
|
||||
<!-- Default screen brightness setting.
|
||||
Must be in the range specified by minimum and maximum. -->
|
||||
<integer name="config_screenBrightnessSettingDefault">128</integer>
|
||||
|
||||
<!-- Minimum screen brightness setting allowed by the power manager.
|
||||
The user is forbidden from setting the brightness below this level. -->
|
||||
<integer name="config_screenBrightnessSettingMinimum">20</integer>
|
||||
|
||||
<!-- Screen brightness used to dim the screen when the user activity
|
||||
timeout expires. May be less than the minimum allowed brightness setting
|
||||
that can be set by the user. -->
|
||||
<integer name="config_screenBrightnessDim">20</integer>
|
||||
|
||||
<!-- If true, then we do not ask user for permission for apps to connect to USB devices.
|
||||
Do not set this to true for production devices. Doing so will cause you to fail CTS. -->
|
||||
<bool name="config_disableUsbPermissionDialogs">true</bool>
|
||||
|
||||
<!-- Control the behavior when the user long presses the power button.
|
||||
0 - Nothing
|
||||
1 - Global actions menu
|
||||
2 - Power off (with confirmation)
|
||||
3 - Power off (without confirmation)
|
||||
4 - Go to voice assist
|
||||
5 - Go to assistant (Settings.Secure.ASSISTANT)
|
||||
-->
|
||||
<integer name="config_longPressOnPowerBehavior">1</integer>
|
||||
|
||||
<!-- CEC Configuration -->
|
||||
<bool name="config_cecTvSendStandbyOnSleepEnabled_default">false</bool>
|
||||
<bool name="config_cecTvSendStandbyOnSleepDisabled_default">true</bool>
|
||||
|
||||
</resources>
|
10
overlay/CarServiceRpiOverlay/Android.bp
Normal file
10
overlay/CarServiceRpiOverlay/Android.bp
Normal file
@@ -0,0 +1,10 @@
|
||||
// Copyright (C) 2021-2023 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
runtime_resource_overlay {
|
||||
name: "CarServiceRpiOverlay",
|
||||
resource_dirs: ["res"],
|
||||
sdk_version: "current",
|
||||
proprietary: true
|
||||
}
|
20
overlay/CarServiceRpiOverlay/AndroidManifest.xml
Normal file
20
overlay/CarServiceRpiOverlay/AndroidManifest.xml
Normal file
@@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright (C) 2021-2023 KonstaKANG
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.car.resources.rpi"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
<application android:hasCode="false" />
|
||||
<overlay
|
||||
android:targetPackage="com.android.car.updatable"
|
||||
android:targetName="CarServiceCustomization"
|
||||
android:isStatic="true"
|
||||
android:priority="0" />
|
||||
</manifest>
|
38
overlay/CarServiceRpiOverlay/res/values/config.xml
Normal file
38
overlay/CarServiceRpiOverlay/res/values/config.xml
Normal file
@@ -0,0 +1,38 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2015 The Android Open Source Project
|
||||
Copyright (C) 2021-2023 KonstaKANG
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
|
||||
|
||||
<!-- Specifies notice UI that will be launched when user starts a car or do user
|
||||
switching. It is recommended to use dialog with at least TYPE_APPLICATION_OVERLAY window
|
||||
type to show the UI regardless of activity launches. Target package will be auto-granted
|
||||
necessary permission for TYPE_APPLICATION_OVERLAY window type. The UI package should
|
||||
resolve permission by itself to use any higher priority window type.
|
||||
Setting this string to empty will disable the feature. -->
|
||||
<string name="config_userNoticeUiService" translatable="false"></string>
|
||||
|
||||
<!-- A name of a camera device that provides the rearview through EVS service -->
|
||||
<string name="config_evsRearviewCameraId" translatable="false">/dev/video0</string>
|
||||
|
||||
<!-- The camera Activity name for EVS, if defined, the Activity will be launched by
|
||||
CarEvsService. -->
|
||||
<string name="config_evsCameraActivity" translatable="false">
|
||||
com.google.android.car.evs/com.google.android.car.evs.CarEvsCameraPreviewActivity
|
||||
</string>
|
||||
|
||||
</resources>
|
10
overlay/SettingsProviderTvRpiOverlay/Android.bp
Normal file
10
overlay/SettingsProviderTvRpiOverlay/Android.bp
Normal file
@@ -0,0 +1,10 @@
|
||||
// Copyright (C) 2021-2022 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
runtime_resource_overlay {
|
||||
name: "SettingsProviderTvRpiOverlay",
|
||||
resource_dirs: ["res"],
|
||||
sdk_version: "current",
|
||||
proprietary: true
|
||||
}
|
19
overlay/SettingsProviderTvRpiOverlay/AndroidManifest.xml
Normal file
19
overlay/SettingsProviderTvRpiOverlay/AndroidManifest.xml
Normal file
@@ -0,0 +1,19 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
/*
|
||||
** Copyright (C) 2021-2022 KonstaKANG
|
||||
**
|
||||
** SPDX-License-Identifier: Apache-2.0
|
||||
*/
|
||||
-->
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.android.providers.settings.rpi.tv"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
<application android:hasCode="false" />
|
||||
<overlay
|
||||
android:targetPackage="com.android.providers.settings"
|
||||
android:isStatic="true"
|
||||
android:priority="0" />
|
||||
</manifest>
|
31
overlay/SettingsProviderTvRpiOverlay/res/values/defaults.xml
Normal file
31
overlay/SettingsProviderTvRpiOverlay/res/values/defaults.xml
Normal file
@@ -0,0 +1,31 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Copyright (C) 2009 The Android Open Source Project
|
||||
Copyright (C) 2021-2022 KonstaKANG
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<resources>
|
||||
|
||||
<!-- Default screen brightness -->
|
||||
<integer name="def_screen_brightness">128</integer>
|
||||
|
||||
<!-- Disable location by default -->
|
||||
<integer name="def_location_mode">0</integer>
|
||||
|
||||
<!-- No setup wizard -->
|
||||
<bool name="def_device_provisioned">true</bool>
|
||||
<bool name="def_user_setup_complete">true</bool>
|
||||
|
||||
</resources>
|
@@ -24,7 +24,16 @@
|
||||
<!-- Whether charging_sounds should be shown or not. -->
|
||||
<bool name="config_show_charging_sounds">false</bool>
|
||||
|
||||
<!-- Whether data_saver should be shown or not. -->
|
||||
<bool name="config_show_data_saver">false</bool>
|
||||
|
||||
<!-- Whether battery from app_info_settings is available or not. -->
|
||||
<bool name="config_show_app_info_settings_battery">false</bool>
|
||||
|
||||
<!-- Whether top_level_battery should be shown or not. -->
|
||||
<bool name="config_show_top_level_battery">false</bool>
|
||||
|
||||
<!-- Whether sim related information is visible to the end user. -->
|
||||
<bool name="config_show_sim_info">false</bool>
|
||||
|
||||
</resources>
|
||||
|
@@ -5,6 +5,6 @@
|
||||
#<src> <mnt_point> <type> <mnt_flags and options> <fs_mgr_flags>
|
||||
/dev/block/mmcblk0p2 /system ext4 ro,barrier=1 wait,first_stage_mount
|
||||
/dev/block/mmcblk0p3 /vendor ext4 ro,barrier=1 wait,first_stage_mount
|
||||
/dev/block/mmcblk0p4 /data ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check,formattable,encryptable=footer,quota
|
||||
/dev/block/mmcblk0p4 /data ext4 noatime,nosuid,nodev,nomblk_io_submit,errors=panic wait,check,formattable,quota
|
||||
/devices/platform/scb/*.pcie/*/*/*/usb* auto auto defaults voldmanaged=usb:auto
|
||||
/devices/platform/soc/*.usb/usb* auto auto defaults voldmanaged=usb:auto
|
||||
|
@@ -19,20 +19,6 @@ on property:sys.boot_completed=1
|
||||
# Reinit lmkd to reconfigure lmkd properties
|
||||
setprop lmkd.reinit 1
|
||||
|
||||
on property:sys.boot_completed=1 && property:persist.audio.hdmi.device=*
|
||||
stop alsa_loop
|
||||
start alsa_loop
|
||||
|
||||
on property:persist.audio.hdmi.device=
|
||||
stop alsa_loop
|
||||
|
||||
service alsa_loop /vendor/bin/alsa_loop --cdevice=hw:${persist.audio.pcm.card},1 --pdevice=default:CARD=${persist.audio.hdmi.device}
|
||||
user root
|
||||
group system
|
||||
priority 10
|
||||
ioprio rt 4
|
||||
disabled
|
||||
|
||||
service suspend_blocker_rpi /vendor/bin/suspend_blocker_rpi
|
||||
class early_hal # Start together with system_suspend HAL
|
||||
group system
|
||||
|
@@ -1,8 +1,8 @@
|
||||
on boot
|
||||
mount configfs none /config
|
||||
mkdir /config/usb_gadget/g1 0770 shell shell
|
||||
mkdir /config/usb_gadget/g1/strings/0x409 0770 shell shell
|
||||
write /config/usb_gadget/g1/bcdDevice 0x0223
|
||||
mkdir /config/usb_gadget/g1 0770
|
||||
mkdir /config/usb_gadget/g1/strings/0x409 0770
|
||||
write /config/usb_gadget/g1/bcdDevice 0x0440
|
||||
write /config/usb_gadget/g1/bcdUSB 0x0200
|
||||
write /config/usb_gadget/g1/idVendor 0x18d1
|
||||
write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
|
||||
@@ -15,8 +15,8 @@ on boot
|
||||
mkdir /config/usb_gadget/g1/functions/audio_source.gs3
|
||||
mkdir /config/usb_gadget/g1/functions/rndis.gs4
|
||||
mkdir /config/usb_gadget/g1/functions/midi.gs5
|
||||
mkdir /config/usb_gadget/g1/configs/b.1 0770 shell shell
|
||||
mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770 shell shell
|
||||
mkdir /config/usb_gadget/g1/configs/b.1 0770
|
||||
mkdir /config/usb_gadget/g1/configs/b.1/strings/0x409 0770
|
||||
write /config/usb_gadget/g1/configs/b.1/MaxPower 500
|
||||
write /config/usb_gadget/g1/os_desc/b_vendor_code 0x1
|
||||
write /config/usb_gadget/g1/os_desc/qw_sign "MSFT100"
|
||||
@@ -25,66 +25,65 @@ on boot
|
||||
mkdir /dev/usb-ffs/mtp 0770 mtp mtp
|
||||
mkdir /dev/usb-ffs/ptp 0770 mtp mtp
|
||||
setprop sys.usb.mtp.device_type 3
|
||||
setprop sys.usb.mtp.batchcancel true
|
||||
setprop vendor.usb.rndis.config rndis.gs4
|
||||
symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
|
||||
|
||||
chown system system /config/usb_gadget/
|
||||
chown system system /config/usb_gadget/g1
|
||||
chown system system /config/usb_gadget/g1/UDC
|
||||
chown system system /config/usb_gadget/g1/bDeviceClass
|
||||
chown system system /config/usb_gadget/g1/bDeviceProtocol
|
||||
chown system system /config/usb_gadget/g1/bDeviceSubClass
|
||||
chown system system /config/usb_gadget/g1/bMaxPacketSize0
|
||||
chown system system /config/usb_gadget/g1/bcdDevice
|
||||
chown system system /config/usb_gadget/g1/bcdUSB
|
||||
chown system system /config/usb_gadget/g1/configs
|
||||
chown system system /config/usb_gadget/g1/configs/b.1
|
||||
chown system system /config/usb_gadget/g1/configs/b.1/MaxPower
|
||||
chown system system /config/usb_gadget/g1/configs/b.1/bmAttributes
|
||||
chown system system /config/usb_gadget/g1/configs/b.1/strings
|
||||
chown system system /config/usb_gadget/g1/functions
|
||||
chown system system /config/usb_gadget/g1/functions/accessory.gs2
|
||||
chown system system /config/usb_gadget/g1/functions/audio_source.gs3
|
||||
chown system system /config/usb_gadget/g1/functions/ffs.adb
|
||||
chown system system /config/usb_gadget/g1/functions/ffs.mtp
|
||||
chown system system /config/usb_gadget/g1/functions/ffs.ptp
|
||||
chown system system /config/usb_gadget/g1/functions/midi.gs5
|
||||
chown system system /config/usb_gadget/g1/functions/midi.gs5/buflen
|
||||
chown system system /config/usb_gadget/g1/functions/midi.gs5/id
|
||||
chown system system /config/usb_gadget/g1/functions/midi.gs5/in_ports
|
||||
chown system system /config/usb_gadget/g1/functions/midi.gs5/index
|
||||
chown system system /config/usb_gadget/g1/functions/midi.gs5/out_ports
|
||||
chown system system /config/usb_gadget/g1/functions/midi.gs5/qlen
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/class
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/dev_addr
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/host_addr
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/ifname
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.rndis
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.rndis/compatible_id
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/os_desc/interface.rndis/sub_compatible_id
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/protocol
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/qmult
|
||||
chown system system /config/usb_gadget/g1/functions/rndis.gs4/subclass
|
||||
chown system system /config/usb_gadget/g1/idProduct
|
||||
chown system system /config/usb_gadget/g1/idVendor
|
||||
chown system system /config/usb_gadget/g1/max_speed
|
||||
chown system system /config/usb_gadget/g1/os_desc
|
||||
chown system system /config/usb_gadget/g1/os_desc/b.1
|
||||
chown system system /config/usb_gadget/g1/os_desc/b_vendor_code
|
||||
chown system system /config/usb_gadget/g1/os_desc/qw_sign
|
||||
chown system system /config/usb_gadget/g1/os_desc/use
|
||||
chown system system /config/usb_gadget/g1/strings
|
||||
chown system system /config/usb_gadget/g1/strings/0x409
|
||||
chown system system /config/usb_gadget/g1/strings/0x409/manufacturer
|
||||
chown system system /config/usb_gadget/g1/strings/0x409/product
|
||||
chown system system /config/usb_gadget/g1/strings/0x409/serialnumber
|
||||
|
||||
on property:sys.usb.controller=*
|
||||
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
|
||||
mount functionfs adb /dev/usb-ffs/adb rmode=0770,fmode=0660,uid=2000,gid=2000,no_disconnect=1
|
||||
mount functionfs mtp /dev/usb-ffs/mtp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
|
||||
mount functionfs ptp /dev/usb-ffs/ptp rmode=0770,fmode=0660,uid=1024,gid=1024,no_disconnect=1
|
||||
setprop sys.usb.configfs 1
|
||||
|
||||
on property:sys.usb.config=none && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/os_desc/use 0
|
||||
|
||||
on property:sys.usb.config=mtp && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x4ee1
|
||||
write /config/usb_gadget/g1/os_desc/use 1
|
||||
symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1
|
||||
|
||||
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=mtp,adb && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x4ee2
|
||||
write /config/usb_gadget/g1/os_desc/use 1
|
||||
symlink /config/usb_gadget/g1/functions/ffs.mtp /config/usb_gadget/g1/configs/b.1/f1
|
||||
|
||||
on property:sys.usb.config=rndis && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x4ee3
|
||||
|
||||
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=rndis,adb && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x4ee4
|
||||
|
||||
on property:sys.usb.config=ptp && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x4ee5
|
||||
write /config/usb_gadget/g1/os_desc/use 1
|
||||
symlink /config/usb_gadget/g1/functions/ffs.ptp /config/usb_gadget/g1/configs/b.1/f1
|
||||
|
||||
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=ptp,adb && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x4ee6
|
||||
write /config/usb_gadget/g1/os_desc/use 1
|
||||
symlink /config/usb_gadget/g1/functions/ffs.ptp /config/usb_gadget/g1/configs/b.1/f1
|
||||
|
||||
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=adb && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x4ee7
|
||||
|
||||
on property:sys.usb.config=midi && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x4ee8
|
||||
|
||||
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=midi,adb && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x4ee9
|
||||
|
||||
on property:sys.usb.config=accessory && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x2d00
|
||||
|
||||
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=accessory,adb && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x2d01
|
||||
|
||||
on property:sys.usb.config=audio_source && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x2d02
|
||||
|
||||
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=audio_source,adb && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x2d03
|
||||
|
||||
on property:sys.usb.config=accessory,audio_source && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x2d04
|
||||
|
||||
on property:sys.usb.ffs.ready=1 && property:sys.usb.config=accessory,audio_source,adb && property:sys.usb.configfs=1
|
||||
write /config/usb_gadget/g1/idProduct 0x2d05
|
||||
setprop sys.usb.configfs 2
|
||||
|
@@ -1,23 +1,30 @@
|
||||
# Bluetooth
|
||||
/dev/ttyAMA0 0660 bluetooth bluetooth
|
||||
/dev/rfkill 0660 bluetooth bluetooth
|
||||
/dev/vcio 0660 system bluetooth
|
||||
|
||||
# Camera
|
||||
/dev/media* 0660 system camera
|
||||
/dev/v4l-subdev* 0660 system camera
|
||||
/dev/video* 0660 system camera
|
||||
|
||||
# CEC
|
||||
/dev/cec0 0660 system graphics
|
||||
/dev/cec1 0660 system graphics
|
||||
|
||||
# DMA
|
||||
/dev/dma_heap/linux,cma 0666 system graphics
|
||||
|
||||
# ION
|
||||
/dev/ion 0664 system system
|
||||
|
||||
# USB
|
||||
/sys/class/udc/fe980000.usb current_speed 0664 system system
|
||||
|
||||
# V4L2
|
||||
/dev/media0 0660 media media
|
||||
/dev/media1 0660 media media
|
||||
/dev/video10 0660 media media
|
||||
/dev/video11 0660 media media
|
||||
/dev/video12 0660 media media
|
||||
/dev/video18 0660 media media
|
||||
/dev/video19 0660 media media
|
||||
/dev/video31 0660 media media
|
||||
|
@@ -1,7 +0,0 @@
|
||||
type alsa_loop, domain;
|
||||
type alsa_loop_exec, exec_type, vendor_file_type, file_type;
|
||||
|
||||
init_daemon_domain(alsa_loop)
|
||||
|
||||
allow alsa_loop audio_device:dir r_dir_perms;
|
||||
allow alsa_loop audio_device:chr_file rw_file_perms;
|
@@ -1 +0,0 @@
|
||||
allow bluetooth vcio_device:chr_file rw_file_perms;
|
@@ -1 +1 @@
|
||||
type vcio_device, dev_type, mlstrustedobject;
|
||||
type cec_device, dev_type;
|
||||
|
@@ -1 +0,0 @@
|
||||
type sysfs_gpu, fs_type, sysfs_type;
|
@@ -1,17 +1,19 @@
|
||||
# Audio
|
||||
/vendor/bin/alsa_loop u:object_r:alsa_loop_exec:s0
|
||||
|
||||
# Bluetooth
|
||||
/dev/ttyAMA0 u:object_r:hci_attach_dev:s0
|
||||
/dev/vcio u:object_r:vcio_device:s0
|
||||
/sys/class/rfkill/rfkill[0-9]/state u:object_r:sysfs_bluetooth_writable:s0
|
||||
|
||||
# CEC
|
||||
/dev/cec0 u:object_r:cec_device:s0
|
||||
/dev/cec1 u:object_r:cec_device:s0
|
||||
|
||||
# DRM
|
||||
/vendor/bin/hw/android\.hardware\.drm@1\.4-service\.clearkey u:object_r:hal_drm_clearkey_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.drm@1\.4-service\.widevine u:object_r:hal_drm_widevine_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.drm-service\.clearkey u:object_r:hal_drm_clearkey_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.drm-service\.widevine(.*)? u:object_r:hal_drm_widevine_exec:s0
|
||||
|
||||
# FFmpeg
|
||||
/vendor/bin/hw/android\.hardware\.media\.c2@1\.2-service-ffmpeg u:object_r:mediacodec_exec:s0
|
||||
|
||||
# Gatekeeper
|
||||
/vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service.software u:object_r:hal_gatekeeper_default_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.gatekeeper@1\.0-service\.software u:object_r:hal_gatekeeper_default_exec:s0
|
||||
|
||||
# Graphics
|
||||
/dev/dri u:object_r:gpu_device:s0
|
||||
@@ -29,12 +31,12 @@
|
||||
/vendor/lib(64)?/libminigbm_gralloc_gbm_mesa\.so u:object_r:same_process_hal_file:s0
|
||||
|
||||
# Health
|
||||
/vendor/bin/hw/android\.hardware\.health@2\.0-service.rpi u:object_r:hal_health_default_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.health-service\.rpi u:object_r:hal_health_default_exec:s0
|
||||
|
||||
# Lights
|
||||
/sys/class/backlight/rpi_backlight/brightness u:object_r:sysfs_leds:s0
|
||||
/sys/devices/platform/rpi_backlight/backlight/rpi_backlight/brightness u:object_r:sysfs_leds:s0
|
||||
/vendor/bin/hw/android\.hardware\.light@2\.0-service.rpi u:object_r:hal_light_default_exec:s0
|
||||
/vendor/bin/hw/android\.hardware\.light-service\.rpi u:object_r:hal_light_default_exec:s0
|
||||
|
||||
# Partitions
|
||||
/dev/block/mmcblk0p1 u:object_r:boot_block_device:s0
|
||||
@@ -45,5 +47,8 @@
|
||||
# Suspend
|
||||
/vendor/bin/suspend_blocker_rpi u:object_r:suspend_blocker_exec:s0
|
||||
|
||||
# USB
|
||||
/vendor/bin/hw/android\.hardware\.usb\.gadget@1\.2-service\.rpi u:object_r:hal_usb_gadget_default_exec:s0
|
||||
|
||||
# V4L2
|
||||
/vendor/bin/hw/android\.hardware\.media\.c2@1\.0-service-v4l2(.*)? u:object_r:mediacodec_exec:s0
|
||||
|
1
sepolicy/hal_tv_cec_default.te
Normal file
1
sepolicy/hal_tv_cec_default.te
Normal file
@@ -0,0 +1 @@
|
||||
allow hal_tv_cec_default cec_device:chr_file rw_file_perms;
|
1
sepolicy/service_contexts
Normal file
1
sepolicy/service_contexts
Normal file
@@ -0,0 +1 @@
|
||||
android.hardware.drm.IDrmFactory/widevine u:object_r:hal_drm_service:s0
|
29
usb/Android.bp
Normal file
29
usb/Android.bp
Normal file
@@ -0,0 +1,29 @@
|
||||
// Copyright (C) 2020 The Android Open Source Project
|
||||
// Copyright (C) 2023 KonstaKANG
|
||||
//
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
cc_binary {
|
||||
name: "android.hardware.usb.gadget@1.2-service.rpi",
|
||||
defaults: ["hidl_defaults"],
|
||||
relative_install_path: "hw",
|
||||
init_rc: ["android.hardware.usb.gadget@1.2-service.rpi.rc"],
|
||||
vintf_fragments: ["android.hardware.usb.gadget@1.2-service.rpi.xml"],
|
||||
vendor: true,
|
||||
srcs: [
|
||||
"service.cpp",
|
||||
"UsbGadget.cpp",
|
||||
],
|
||||
shared_libs: [
|
||||
"android.hardware.usb.gadget@1.0",
|
||||
"android.hardware.usb.gadget@1.1",
|
||||
"android.hardware.usb.gadget@1.2",
|
||||
"libbase",
|
||||
"libcutils",
|
||||
"libhardware",
|
||||
"libhidlbase",
|
||||
"liblog",
|
||||
"libutils",
|
||||
],
|
||||
static_libs: ["libusbconfigfs-2"],
|
||||
}
|
287
usb/UsbGadget.cpp
Normal file
287
usb/UsbGadget.cpp
Normal file
@@ -0,0 +1,287 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.usb.gadget@1.2-service.rpi"
|
||||
|
||||
#include "UsbGadget.h"
|
||||
#include <dirent.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <sys/inotify.h>
|
||||
#include <sys/mount.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
#include <unistd.h>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace usb {
|
||||
namespace gadget {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
UsbGadget::UsbGadget() {
|
||||
if (access(OS_DESC_PATH, R_OK) != 0) {
|
||||
ALOGE("configfs setup not done yet");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
void currentFunctionsAppliedCallback(bool functionsApplied, void* payload) {
|
||||
UsbGadget* gadget = (UsbGadget*)payload;
|
||||
gadget->mCurrentUsbFunctionsApplied = functionsApplied;
|
||||
}
|
||||
|
||||
Return<void> UsbGadget::getCurrentUsbFunctions(const sp<V1_0::IUsbGadgetCallback>& callback) {
|
||||
Return<void> ret = callback->getCurrentUsbFunctionsCb(
|
||||
mCurrentUsbFunctions, mCurrentUsbFunctionsApplied ? Status::FUNCTIONS_APPLIED
|
||||
: Status::FUNCTIONS_NOT_APPLIED);
|
||||
if (!ret.isOk()) ALOGE("Call to getCurrentUsbFunctionsCb failed %s", ret.description().c_str());
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
Return<void> UsbGadget::getUsbSpeed(const sp<V1_2::IUsbGadgetCallback>& callback) {
|
||||
std::string current_speed;
|
||||
if (ReadFileToString(SPEED_PATH, ¤t_speed)) {
|
||||
current_speed = Trim(current_speed);
|
||||
ALOGI("current USB speed is %s", current_speed.c_str());
|
||||
if (current_speed == "low-speed")
|
||||
mUsbSpeed = UsbSpeed::LOWSPEED;
|
||||
else if (current_speed == "full-speed")
|
||||
mUsbSpeed = UsbSpeed::FULLSPEED;
|
||||
else if (current_speed == "high-speed")
|
||||
mUsbSpeed = UsbSpeed::HIGHSPEED;
|
||||
else if (current_speed == "super-speed")
|
||||
mUsbSpeed = UsbSpeed::SUPERSPEED;
|
||||
else if (current_speed == "super-speed-plus")
|
||||
mUsbSpeed = UsbSpeed::SUPERSPEED_10Gb;
|
||||
else if (current_speed == "UNKNOWN")
|
||||
mUsbSpeed = UsbSpeed::UNKNOWN;
|
||||
else {
|
||||
/**
|
||||
* This part is used for USB4 or reserved speed.
|
||||
*
|
||||
* If reserved speed is detected, it needs to convert to other speeds.
|
||||
* For example:
|
||||
* If the bandwidth of new speed is 7G, adding new if
|
||||
* statement and set mUsbSpeed to SUPERSPEED.
|
||||
* If the bandwidth of new speed is 80G, adding new if
|
||||
* statement and set mUsbSpeed to USB4_GEN3_40Gb.
|
||||
*/
|
||||
mUsbSpeed = UsbSpeed::RESERVED_SPEED;
|
||||
}
|
||||
} else {
|
||||
ALOGE("Fail to read current speed");
|
||||
mUsbSpeed = UsbSpeed::UNKNOWN;
|
||||
}
|
||||
|
||||
if (callback) {
|
||||
Return<void> ret = callback->getUsbSpeedCb(mUsbSpeed);
|
||||
|
||||
if (!ret.isOk()) ALOGE("Call to getUsbSpeedCb failed %s", ret.description().c_str());
|
||||
}
|
||||
|
||||
return Void();
|
||||
}
|
||||
|
||||
V1_0::Status UsbGadget::tearDownGadget() {
|
||||
if (resetGadget() != V1_0::Status::SUCCESS) return V1_0::Status::ERROR;
|
||||
|
||||
if (monitorFfs.isMonitorRunning()) {
|
||||
monitorFfs.reset();
|
||||
} else {
|
||||
ALOGI("mMonitor not running");
|
||||
}
|
||||
return V1_0::Status::SUCCESS;
|
||||
}
|
||||
|
||||
Return<Status> UsbGadget::reset() {
|
||||
if (!WriteStringToFile("none", PULLUP_PATH)) {
|
||||
ALOGI("Gadget cannot be pulled down");
|
||||
return Status::ERROR;
|
||||
}
|
||||
|
||||
usleep(kDisconnectWaitUs);
|
||||
|
||||
if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) {
|
||||
ALOGI("Gadget cannot be pulled up");
|
||||
return Status::ERROR;
|
||||
}
|
||||
|
||||
return Status::SUCCESS;
|
||||
}
|
||||
|
||||
static V1_0::Status validateAndSetVidPid(uint64_t functions) {
|
||||
V1_0::Status ret = V1_0::Status::SUCCESS;
|
||||
|
||||
switch (functions) {
|
||||
case static_cast<uint64_t>(V1_2::GadgetFunction::MTP):
|
||||
ret = setVidPid("0x18d1", "0x4ee1");
|
||||
break;
|
||||
case V1_2::GadgetFunction::ADB | V1_2::GadgetFunction::MTP:
|
||||
ret = setVidPid("0x18d1", "0x4ee2");
|
||||
break;
|
||||
case static_cast<uint64_t>(V1_2::GadgetFunction::RNDIS):
|
||||
ret = setVidPid("0x18d1", "0x4ee3");
|
||||
break;
|
||||
case V1_2::GadgetFunction::ADB | V1_2::GadgetFunction::RNDIS:
|
||||
ret = setVidPid("0x18d1", "0x4ee4");
|
||||
break;
|
||||
case static_cast<uint64_t>(V1_2::GadgetFunction::PTP):
|
||||
ret = setVidPid("0x18d1", "0x4ee5");
|
||||
break;
|
||||
case V1_2::GadgetFunction::ADB | V1_2::GadgetFunction::PTP:
|
||||
ret = setVidPid("0x18d1", "0x4ee6");
|
||||
break;
|
||||
case static_cast<uint64_t>(V1_2::GadgetFunction::ADB):
|
||||
ret = setVidPid("0x18d1", "0x4ee7");
|
||||
break;
|
||||
case static_cast<uint64_t>(V1_2::GadgetFunction::MIDI):
|
||||
ret = setVidPid("0x18d1", "0x4ee8");
|
||||
break;
|
||||
case V1_2::GadgetFunction::ADB | V1_2::GadgetFunction::MIDI:
|
||||
ret = setVidPid("0x18d1", "0x4ee9");
|
||||
break;
|
||||
case static_cast<uint64_t>(V1_2::GadgetFunction::NCM):
|
||||
ret = setVidPid("0x18d1", "0x4eeb");
|
||||
break;
|
||||
case V1_2::GadgetFunction::ADB | V1_2::GadgetFunction::NCM:
|
||||
ret = setVidPid("0x18d1", "0x4eec");
|
||||
break;
|
||||
case static_cast<uint64_t>(V1_2::GadgetFunction::ACCESSORY):
|
||||
ret = setVidPid("0x18d1", "0x2d00");
|
||||
break;
|
||||
case V1_2::GadgetFunction::ADB | V1_2::GadgetFunction::ACCESSORY:
|
||||
ret = setVidPid("0x18d1", "0x2d01");
|
||||
break;
|
||||
case static_cast<uint64_t>(V1_2::GadgetFunction::AUDIO_SOURCE):
|
||||
ret = setVidPid("0x18d1", "0x2d02");
|
||||
break;
|
||||
case V1_2::GadgetFunction::ADB | V1_2::GadgetFunction::AUDIO_SOURCE:
|
||||
ret = setVidPid("0x18d1", "0x2d03");
|
||||
break;
|
||||
case V1_2::GadgetFunction::ACCESSORY | V1_2::GadgetFunction::AUDIO_SOURCE:
|
||||
ret = setVidPid("0x18d1", "0x2d04");
|
||||
break;
|
||||
case V1_2::GadgetFunction::ADB | V1_2::GadgetFunction::ACCESSORY |
|
||||
V1_2::GadgetFunction::AUDIO_SOURCE:
|
||||
ret = setVidPid("0x18d1", "0x2d05");
|
||||
break;
|
||||
default:
|
||||
ALOGE("Combination not supported");
|
||||
ret = V1_0::Status::CONFIGURATION_NOT_SUPPORTED;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
V1_0::Status UsbGadget::setupFunctions(uint64_t functions,
|
||||
const sp<V1_0::IUsbGadgetCallback>& callback,
|
||||
uint64_t timeout) {
|
||||
bool ffsEnabled = false;
|
||||
int i = 0;
|
||||
|
||||
if (addGenericAndroidFunctions(&monitorFfs, functions, &ffsEnabled, &i) !=
|
||||
V1_0::Status::SUCCESS)
|
||||
return V1_0::Status::ERROR;
|
||||
|
||||
if ((functions & V1_2::GadgetFunction::ADB) != 0) {
|
||||
ffsEnabled = true;
|
||||
if (addAdb(&monitorFfs, &i) != V1_0::Status::SUCCESS) return V1_0::Status::ERROR;
|
||||
}
|
||||
|
||||
// Pull up the gadget right away when there are no ffs functions.
|
||||
if (!ffsEnabled) {
|
||||
if (!WriteStringToFile(kGadgetName, PULLUP_PATH)) return V1_0::Status::ERROR;
|
||||
mCurrentUsbFunctionsApplied = true;
|
||||
if (callback) callback->setCurrentUsbFunctionsCb(functions, V1_0::Status::SUCCESS);
|
||||
return V1_0::Status::SUCCESS;
|
||||
}
|
||||
|
||||
monitorFfs.registerFunctionsAppliedCallback(¤tFunctionsAppliedCallback, this);
|
||||
// Monitors the ffs paths to pull up the gadget when descriptors are written.
|
||||
// Also takes of the pulling up the gadget again if the userspace process
|
||||
// dies and restarts.
|
||||
monitorFfs.startMonitor();
|
||||
|
||||
if (kDebug) ALOGI("Mainthread in Cv");
|
||||
|
||||
if (callback) {
|
||||
bool pullup = monitorFfs.waitForPullUp(timeout);
|
||||
Return<void> ret = callback->setCurrentUsbFunctionsCb(
|
||||
functions, pullup ? V1_0::Status::SUCCESS : V1_0::Status::ERROR);
|
||||
if (!ret.isOk()) ALOGE("setCurrentUsbFunctionsCb error %s", ret.description().c_str());
|
||||
}
|
||||
|
||||
return V1_0::Status::SUCCESS;
|
||||
}
|
||||
|
||||
Return<void> UsbGadget::setCurrentUsbFunctions(uint64_t functions,
|
||||
const sp<V1_0::IUsbGadgetCallback>& callback,
|
||||
uint64_t timeout) {
|
||||
std::unique_lock<std::mutex> lk(mLockSetCurrentFunction);
|
||||
|
||||
mCurrentUsbFunctions = functions;
|
||||
mCurrentUsbFunctionsApplied = false;
|
||||
|
||||
// Unlink the gadget and stop the monitor if running.
|
||||
V1_0::Status status = tearDownGadget();
|
||||
if (status != V1_0::Status::SUCCESS) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
ALOGI("Returned from tearDown gadget");
|
||||
|
||||
// Leave the gadget pulled down to give time for the host to sense disconnect.
|
||||
usleep(kDisconnectWaitUs);
|
||||
|
||||
if (functions == static_cast<uint64_t>(V1_2::GadgetFunction::NONE)) {
|
||||
if (callback == NULL) return Void();
|
||||
Return<void> ret = callback->setCurrentUsbFunctionsCb(functions, V1_0::Status::SUCCESS);
|
||||
if (!ret.isOk())
|
||||
ALOGE("Error while calling setCurrentUsbFunctionsCb %s", ret.description().c_str());
|
||||
return Void();
|
||||
}
|
||||
|
||||
status = validateAndSetVidPid(functions);
|
||||
|
||||
if (status != V1_0::Status::SUCCESS) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = setupFunctions(functions, callback, timeout);
|
||||
if (status != V1_0::Status::SUCCESS) {
|
||||
goto error;
|
||||
}
|
||||
|
||||
ALOGI("Usb Gadget setcurrent functions called successfully");
|
||||
return Void();
|
||||
|
||||
error:
|
||||
ALOGI("Usb Gadget setcurrent functions failed");
|
||||
if (callback == NULL) return Void();
|
||||
Return<void> ret = callback->setCurrentUsbFunctionsCb(functions, status);
|
||||
if (!ret.isOk())
|
||||
ALOGE("Error while calling setCurrentUsbFunctionsCb %s", ret.description().c_str());
|
||||
return Void();
|
||||
}
|
||||
} // namespace implementation
|
||||
} // namespace V1_2
|
||||
} // namespace gadget
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
109
usb/UsbGadget.h
Normal file
109
usb/UsbGadget.h
Normal file
@@ -0,0 +1,109 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef ANDROID_HARDWARE_USB_GADGET_V1_2_USBGADGET_H
|
||||
#define ANDROID_HARDWARE_USB_GADGET_V1_2_USBGADGET_H
|
||||
|
||||
#include <UsbGadgetCommon.h>
|
||||
#include <android-base/file.h>
|
||||
#include <android-base/properties.h>
|
||||
#include <android-base/strings.h>
|
||||
#include <android-base/unique_fd.h>
|
||||
#include <android/hardware/usb/gadget/1.2/IUsbGadget.h>
|
||||
#include <android/hardware/usb/gadget/1.2/types.h>
|
||||
#include <hidl/MQDescriptor.h>
|
||||
#include <hidl/Status.h>
|
||||
#include <sys/epoll.h>
|
||||
#include <sys/eventfd.h>
|
||||
#include <utils/Log.h>
|
||||
#include <chrono>
|
||||
#include <condition_variable>
|
||||
#include <mutex>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
|
||||
namespace android {
|
||||
namespace hardware {
|
||||
namespace usb {
|
||||
namespace gadget {
|
||||
namespace V1_2 {
|
||||
namespace implementation {
|
||||
|
||||
using ::android::sp;
|
||||
using ::android::base::GetProperty;
|
||||
using ::android::base::ReadFileToString;
|
||||
using ::android::base::SetProperty;
|
||||
using ::android::base::Trim;
|
||||
using ::android::base::unique_fd;
|
||||
using ::android::base::WriteStringToFile;
|
||||
using ::android::hardware::hidl_array;
|
||||
using ::android::hardware::hidl_memory;
|
||||
using ::android::hardware::hidl_string;
|
||||
using ::android::hardware::hidl_vec;
|
||||
using ::android::hardware::Return;
|
||||
using ::android::hardware::Void;
|
||||
using ::android::hardware::usb::gadget::addAdb;
|
||||
using ::android::hardware::usb::gadget::addEpollFd;
|
||||
using ::android::hardware::usb::gadget::getVendorFunctions;
|
||||
using ::android::hardware::usb::gadget::kDebug;
|
||||
using ::android::hardware::usb::gadget::kDisconnectWaitUs;
|
||||
using ::android::hardware::usb::gadget::linkFunction;
|
||||
using ::android::hardware::usb::gadget::MonitorFfs;
|
||||
using ::android::hardware::usb::gadget::resetGadget;
|
||||
using ::android::hardware::usb::gadget::setVidPid;
|
||||
using ::android::hardware::usb::gadget::unlinkFunctions;
|
||||
using ::std::string;
|
||||
|
||||
constexpr char kGadgetName[] = "fe980000.usb";
|
||||
static MonitorFfs monitorFfs(kGadgetName);
|
||||
|
||||
#define UDC_PATH "/sys/class/udc/fe980000.usb/"
|
||||
#define SPEED_PATH UDC_PATH "current_speed"
|
||||
|
||||
struct UsbGadget : public IUsbGadget {
|
||||
UsbGadget();
|
||||
|
||||
// Makes sure that only one request is processed at a time.
|
||||
std::mutex mLockSetCurrentFunction;
|
||||
uint64_t mCurrentUsbFunctions;
|
||||
bool mCurrentUsbFunctionsApplied;
|
||||
UsbSpeed mUsbSpeed;
|
||||
|
||||
Return<void> setCurrentUsbFunctions(uint64_t functions,
|
||||
const sp<V1_0::IUsbGadgetCallback>& callback,
|
||||
uint64_t timeout) override;
|
||||
|
||||
Return<void> getCurrentUsbFunctions(const sp<V1_0::IUsbGadgetCallback>& callback) override;
|
||||
|
||||
Return<Status> reset() override;
|
||||
|
||||
Return<void> getUsbSpeed(const sp<V1_2::IUsbGadgetCallback>& callback) override;
|
||||
|
||||
private:
|
||||
V1_0::Status tearDownGadget();
|
||||
V1_0::Status setupFunctions(uint64_t functions, const sp<V1_0::IUsbGadgetCallback>& callback,
|
||||
uint64_t timeout);
|
||||
};
|
||||
|
||||
} // namespace implementation
|
||||
} // namespace V1_2
|
||||
} // namespace gadget
|
||||
} // namespace usb
|
||||
} // namespace hardware
|
||||
} // namespace android
|
||||
|
||||
#endif // ANDROID_HARDWARE_USB_V1_2_USBGADGET_H
|
7
usb/android.hardware.usb.gadget@1.2-service.rpi.rc
Normal file
7
usb/android.hardware.usb.gadget@1.2-service.rpi.rc
Normal file
@@ -0,0 +1,7 @@
|
||||
service vendor.usb-gadget-hal-1-2 /vendor/bin/hw/android.hardware.usb.gadget@1.2-service.rpi
|
||||
interface android.hardware.usb.gadget@1.0::IUsbGadget default
|
||||
interface android.hardware.usb.gadget@1.1::IUsbGadget default
|
||||
interface android.hardware.usb.gadget@1.2::IUsbGadget default
|
||||
class hal
|
||||
user system
|
||||
group system shell mtp
|
@@ -1,10 +1,10 @@
|
||||
<manifest version="1.0" type="device">
|
||||
<hal format="hidl">
|
||||
<name>android.hardware.health</name>
|
||||
<name>android.hardware.usb.gadget</name>
|
||||
<transport>hwbinder</transport>
|
||||
<version>2.0</version>
|
||||
<version>1.2</version>
|
||||
<interface>
|
||||
<name>IHealth</name>
|
||||
<name>IUsbGadget</name>
|
||||
<instance>default</instance>
|
||||
</interface>
|
||||
</hal>
|
53
usb/service.cpp
Normal file
53
usb/service.cpp
Normal file
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright (C) 2020 The Android Open Source Project
|
||||
* Copyright (C) 2023 KonstaKANG
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#define LOG_TAG "android.hardware.usb.gadget@1.2-service.rpi"
|
||||
|
||||
#include <hidl/HidlTransportSupport.h>
|
||||
#include "UsbGadget.h"
|
||||
|
||||
using android::sp;
|
||||
|
||||
// libhwbinder:
|
||||
using android::hardware::configureRpcThreadpool;
|
||||
using android::hardware::joinRpcThreadpool;
|
||||
|
||||
// Generated HIDL files
|
||||
using android::hardware::usb::gadget::V1_2::IUsbGadget;
|
||||
using android::hardware::usb::gadget::V1_2::implementation::UsbGadget;
|
||||
|
||||
using android::OK;
|
||||
using android::status_t;
|
||||
|
||||
int main() {
|
||||
configureRpcThreadpool(1, true /*callerWillJoin*/);
|
||||
|
||||
android::sp<IUsbGadget> service = new UsbGadget();
|
||||
|
||||
status_t status = service->registerAsService();
|
||||
|
||||
if (status != OK) {
|
||||
ALOGE("Cannot register USB Gadget HAL service");
|
||||
return 1;
|
||||
}
|
||||
|
||||
ALOGI("USB Gadget HAL Ready.");
|
||||
joinRpcThreadpool();
|
||||
// Under noraml cases, execution will not reach this line.
|
||||
ALOGI("USB Gadget HAL failed to join thread pool.");
|
||||
return 1;
|
||||
}
|
49
vendor.prop
49
vendor.prop
@@ -1,24 +1,60 @@
|
||||
|
||||
# Audio
|
||||
persist.audio.hdmi.device=vc4hdmi0
|
||||
persist.audio.pcm.card=0
|
||||
persist.audio.pcm.device=0
|
||||
ro.config.media_vol_default=20
|
||||
ro.config.media_vol_steps=25
|
||||
ro.hardware.audio.primary=rpi
|
||||
|
||||
# Bluetooth
|
||||
ro.rfkilldisabled=1
|
||||
bluetooth.device.class_of_device?=90,2,12
|
||||
bluetooth.profile.a2dp.source.enabled?=true
|
||||
bluetooth.profile.asha.central.enabled?=true
|
||||
bluetooth.profile.avrcp.target.enabled?=true
|
||||
bluetooth.profile.bap.broadcast.assist.enabled?=true
|
||||
bluetooth.profile.bap.unicast.client.enabled?=true
|
||||
bluetooth.profile.bas.client.enabled?=true
|
||||
bluetooth.profile.ccp.server.enabled?=true
|
||||
bluetooth.profile.csip.set_coordinator.enabled?=true
|
||||
bluetooth.profile.gatt.enabled?=true
|
||||
bluetooth.profile.hap.client.enabled?=true
|
||||
bluetooth.profile.hfp.ag.enabled?=true
|
||||
bluetooth.profile.hid.device.enabled?=true
|
||||
bluetooth.profile.hid.host.enabled?=true
|
||||
bluetooth.profile.map.server.enabled?=true
|
||||
bluetooth.profile.mcp.server.enabled?=true
|
||||
bluetooth.profile.opp.enabled?=true
|
||||
bluetooth.profile.pan.nap.enabled?=true
|
||||
bluetooth.profile.pan.panu.enabled?=true
|
||||
bluetooth.profile.pbap.server.enabled?=true
|
||||
bluetooth.profile.sap.server.enabled?=true
|
||||
bluetooth.profile.vcp.controller.enabled?=true
|
||||
persist.bluetooth.a2dp_aac.vbr_supported=true
|
||||
|
||||
# Camera
|
||||
media.settings.xml=/vendor/etc/media_profiles_V1_0.xml
|
||||
ro.hardware.camera=libcamera
|
||||
|
||||
# CEC
|
||||
ro.hdmi.cec_device=cec0
|
||||
ro.hdmi.device_type=4
|
||||
|
||||
# Display
|
||||
debug.drm.mode.force=1920x1080
|
||||
|
||||
# FFmpeg
|
||||
persist.ffmpeg_codec2.rank.audio=16
|
||||
persist.ffmpeg_codec2.rank.video=256
|
||||
persist.ffmpeg_codec2.v4l2.h264=false
|
||||
persist.ffmpeg_codec2.v4l2.h265=true
|
||||
|
||||
# Graphics
|
||||
ro.hardware.egl=mesa
|
||||
ro.hardware.hwcomposer=drm
|
||||
ro.hardware.vulkan=broadcom
|
||||
ro.opengles.version=196609
|
||||
vendor.hwc.drm.ctm=DRM_OR_IGNORE
|
||||
|
||||
# LMKD
|
||||
ro.lmk.critical=0
|
||||
@@ -32,8 +68,19 @@ ro.lmk.medium=800
|
||||
ro.lmk.upgrade_pressure=100
|
||||
ro.lmk.use_minfree_levels=true
|
||||
|
||||
# Lockscreen
|
||||
ro.lockscreen.disable.default=true
|
||||
|
||||
# Media
|
||||
debug.stagefright.c2inputsurface=-1
|
||||
|
||||
# MGLRU
|
||||
persist.device_config.mglru_native.lru_gen_config=core
|
||||
|
||||
# V4L2
|
||||
debug.stagefright.c2-poolmask=0xf50000
|
||||
persist.v4l2_codec2.rank.decoder=128
|
||||
persist.v4l2_codec2.rank.encoder=128
|
||||
ro.vendor.v4l2_codec2.decode_concurrent_instances=8
|
||||
ro.vendor.v4l2_codec2.encode_concurrent_instances=8
|
||||
|
||||
|
21
vulkan/android.hardware.vulkan.version-1_2.xml
Normal file
21
vulkan/android.hardware.vulkan.version-1_2.xml
Normal file
@@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Copyright 2022 The Android Open Source Project
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
-->
|
||||
|
||||
<!-- This is the standard feature indicating that the device has a Vulkan
|
||||
driver that supports API version 1.2 (0x00402000) -->
|
||||
<permissions>
|
||||
<feature name="android.hardware.vulkan.version" version="4202496" />
|
||||
</permissions>
|
Reference in New Issue
Block a user