initial Raspberry Vanilla AOSP 12 commit

* Audio
  - Based on AOSP hikey audio HAL:
    https://android.googlesource.com/device/linaro/hikey/+/refs/heads/master/audio/
  - ALSA based on Android-x86
  - ALSA loop is used to support HDMI audio on Pi 4 because VC4 HDMI
    audio devices use SNDRV_PCM_FORMAT_IEC958_SUBFRAME_LE that is not
    supported on Android
    https://github.com/raspberrypi/linux/issues/4651
    https://github.com/raspberrypi/linux/issues/4654

* Bluetooth
  - AOSP Broadcom vendor stack with some additional fixes from android-rpi

* Camera
  - libcamera for official Raspberry Pi CSI camera modules based on GloDroid
  - AOSP external camera HAL for UVC USB webcams:
    https://source.android.com/docs/core/camera/external-usb-cameras

* Graphics
  - OpenGL & Vulkan: upstream Mesa with GloDroid patches
  - Upstream drm_hwcomposer with force resolution patch from Android-x86 and
    my additional fixes
  - minigbm based on GloDroid

* Health
  - Based on AOSP cuttlefish health HAL

* Kernel
  - Merge of Raspberry Pi and AOSP common kernel with my additional fixes
    and configurations
    https://github.com/raspberrypi/linux
    https://android.googlesource.com/kernel/common/

* Lights
  - Based on LineageOS Xiaomi msm8996-common lights HAL

* suspend_blocker
  - Based on AOSP cuttlefish

* v4l2_codec2
  - Based on AOSP with my Raspberry Pi 4 specific fixes

* Wifi
  - AOSP Broadcom vendor stack with my additional fixes
This commit is contained in:
Konsta
2022-09-14 15:06:12 +03:00
commit bbdbc45eea
85 changed files with 3127 additions and 0 deletions

6
Android.bp Normal file
View File

@@ -0,0 +1,6 @@
// Copyright (C) 2021-2022 KonstaKANG
//
// SPDX-License-Identifier: Apache-2.0
soong_namespace {
}

11
AndroidProducts.mk Normal file
View File

@@ -0,0 +1,11 @@
#
# Copyright (C) 2021-2022 KonstaKANG
#
# SPDX-License-Identifier: Apache-2.0
#
PRODUCT_MAKEFILES := \
$(LOCAL_DIR)/aosp_rpi4.mk
COMMON_LUNCH_CHOICES := \
aosp_rpi4-userdebug

88
BoardConfig.mk Normal file
View File

@@ -0,0 +1,88 @@
#
# Copyright (C) 2021-2022 KonstaKANG
#
# SPDX-License-Identifier: Apache-2.0
#
DEVICE_PATH := device/brcm/rpi4
# Platform
TARGET_NO_BOOTLOADER := true
TARGET_NO_RECOVERY := true
TARGET_BOARD_PLATFORM := rpi
TARGET_ARCH := arm64
TARGET_ARCH_VARIANT := armv8-a
TARGET_CPU_ABI := arm64-v8a
TARGET_CPU_ABI2 :=
TARGET_CPU_VARIANT := cortex-a72
TARGET_2ND_ARCH := arm
TARGET_2ND_ARCH_VARIANT := armv7-a-neon
TARGET_2ND_CPU_ABI := armeabi-v7a
TARGET_2ND_CPU_ABI2 := armeabi
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_USES_MESON_BUILD := true
# Display
TARGET_SCREEN_DENSITY := 240
# Graphics
BOARD_MESA3D_USES_MESON_BUILD := true
BOARD_MESA3D_GALLIUM_DRIVERS := vc4 v3d
BOARD_MESA3D_VULKAN_DRIVERS := broadcom
# Kernel
BOARD_CUSTOM_BOOTIMG := true
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_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
BOARD_SYSTEMIMAGE_PARTITION_SIZE := 2147483648 # 2048M
BOARD_USERDATAIMAGE_PARTITION_SIZE := 134217728 # 128M
BOARD_VENDORIMAGE_PARTITION_SIZE := 268435456 # 256M
BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE := ext4
TARGET_USERIMAGES_SPARSE_EXT_DISABLED := true
TARGET_USERIMAGES_USE_EXT4 := true
# Properties
TARGET_VENDOR_PROP += $(DEVICE_PATH)/vendor.prop
# SELinux
BOARD_SEPOLICY_DIRS += device/brcm/rpi4/sepolicy
BOARD_KERNEL_CMDLINE += androidboot.selinux=permissive
# Treble
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED := true
BOARD_VNDK_VERSION := current
PRODUCT_FULL_TREBLE_OVERRIDE := true
TARGET_COPY_OUT_VENDOR := vendor
# Wifi
BOARD_WLAN_DEVICE := bcmdhd
BOARD_HOSTAPD_DRIVER := NL80211
BOARD_HOSTAPD_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
BOARD_WPA_SUPPLICANT_DRIVER := NL80211
BOARD_WPA_SUPPLICANT_PRIVATE_LIB := lib_driver_cmd_$(BOARD_WLAN_DEVICE)
WIFI_HIDL_UNIFIED_SUPPLICANT_SERVICE_RC_ENTRY := true
WPA_SUPPLICANT_VERSION := VER_0_8_X

1
README.md Normal file
View File

@@ -0,0 +1 @@
Raspberry Vanilla AOSP 12 device configuration for Raspberry Pi 4.

16
aosp_rpi4.mk Normal file
View File

@@ -0,0 +1,16 @@
#
# Copyright (C) 2021-2022 KonstaKANG
#
# SPDX-License-Identifier: Apache-2.0
#
# Inherit device configuration
$(call inherit-product, device/brcm/rpi4/device.mk)
# Device identifier. This must come after all inclusions.
PRODUCT_DEVICE := rpi4
PRODUCT_NAME := aosp_rpi4
PRODUCT_BRAND := Raspberry
PRODUCT_MODEL := Raspberry Pi 4
PRODUCT_MANUFACTURER := Raspberry
PRODUCT_RELEASE_NAME := Raspberry Pi 4

24
audio/Android.bp Normal file
View File

@@ -0,0 +1,24 @@
// Copyright (C) 2015 The Android Open Source Project
// Copyright (C) 2021-2022 KonstaKANG
//
// SPDX-License-Identifier: Apache-2.0
cc_library_shared {
name: "audio.primary.rpi",
relative_install_path: "hw",
proprietary: true,
srcs: ["audio_hw.c"],
include_dirs: [
"external/expat/lib",
"external/tinyalsa/include",
"system/media/audio_effects/include",
"system/media/audio_utils/include",
],
header_libs: ["libhardware_headers"],
shared_libs: [
"libcutils",
"liblog",
"libtinyalsa",
],
cflags: ["-Wno-unused-parameter"],
}

708
audio/audio_hw.c Normal file
View File

@@ -0,0 +1,708 @@
/*
* Copyright (C) 2016 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.
*/
#define LOG_TAG "audio_hw_rpi"
//#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 <sound/asound.h>
#include <tinyalsa/asoundlib.h>
#include <audio_utils/resampler.h>
#include <audio_utils/echo_reference.h>
#include <hardware/audio_effect.h>
#include <hardware/audio_alsaops.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;
pthread_mutex_t lock; /* see note below on mutex acquisition order */
struct pcm_config config;
struct pcm *pcm;
bool unavailable;
int standby;
struct alsa_audio_device *dev;
int write_threshold;
unsigned int written;
};
static int get_pcm_card()
{
char card[PROPERTY_VALUE_MAX];
property_get("persist.audio.pcm.card", card, "0");
return atoi(card);
}
static int get_pcm_device()
{
char device[PROPERTY_VALUE_MAX];
property_get("persist.audio.pcm.device", device, "0");
return atoi(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;
/* default to low power: will be corrected in out_write if necessary before first write to
* tinyalsa.
*/
out->write_threshold = PLAYBACK_PERIOD_COUNT * PERIOD_SIZE;
out->config.start_threshold = PLAYBACK_PERIOD_START_THRESHOLD * PERIOD_SIZE;
out->config.avail_min = PERIOD_SIZE;
out->pcm = pcm_open(get_pcm_card(), get_pcm_device(), PCM_OUT | PCM_MMAP | PCM_NOIRQ | PCM_MONOTONIC, &out->config);
if (!pcm_is_ready(out->pcm)) {
ALOGE("cannot open pcm_out driver: %s", pcm_get_error(out->pcm));
pcm_close(out->pcm);
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)
{
struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
return out->config.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)
{
ALOGV("out_get_buffer_size: %d", 4096);
/* return the closest majoring multiple of 16 frames, as
* audioflinger expects audio buffers to be a multiple of 16 frames */
size_t size = PERIOD_SIZE;
size = ((size + 15) / 16) * 16;
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");
struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
return audio_channel_out_mask_from_count(out->config.channels);
}
static audio_format_t out_get_format(const struct audio_stream *stream)
{
ALOGV("out_get_format");
struct alsa_stream_out *out = (struct alsa_stream_out *)stream;
return audio_format_from_pcm_format(out->config.format);
}
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) {
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;
return (PERIOD_SIZE * PLAYBACK_PERIOD_COUNT * 1000) / out->config.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);
size_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);
ret = pcm_mmap_write(out->pcm, buffer, out_frames * frame_size);
if (ret == 0) {
out->written += out_frames;
}
exit:
pthread_mutex_unlock(&out->lock);
if (ret != 0) {
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) {
unsigned int avail;
if (pcm_get_htimestamp(out->pcm, &avail, timestamp) == 0) {
size_t kernel_buffer_size = out->config.period_size * out->config.period_count;
int64_t signed_frames = out->written - kernel_buffer_size + avail;
if (signed_frames >= 0) {
*frames = signed_frames;
ret = 0;
}
}
}
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;
struct pcm_params *params;
int ret = 0;
params = pcm_params_get(get_pcm_card(), get_pcm_device(), PCM_OUT);
if (!params)
return -ENOSYS;
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->config.channels = CHANNEL_STEREO;
out->config.rate = CODEC_SAMPLING_RATE;
out->config.format = PCM_FORMAT_S16_LE;
out->config.period_size = PERIOD_SIZE;
out->config.period_count = PLAYBACK_PERIOD_COUNT;
if (out->config.rate != config->sample_rate ||
audio_channel_count_from_out_mask(config->channel_mask) != CHANNEL_STEREO ||
out->config.format != pcm_format_from_audio_format(config->format) ) {
config->sample_rate = out->config.rate;
config->format = audio_format_from_pcm_format(out->config.format);
config->channel_mask = audio_channel_out_mask_from_count(CHANNEL_STEREO);
ret = -EINVAL;
}
ALOGI("adev_open_output_stream selects channels=%d rate=%d format=%d",
out->config.channels, out->config.rate, out->config.format);
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 HW HAL",
.author = "The Android Open Source Project",
.methods = &hal_module_methods,
},
};

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<!-- Copyright (C) 2015 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.
-->
<audioPolicyConfiguration version="7.0" xmlns:xi="http://www.w3.org/2001/XInclude">
<modules>
<module name="primary" halVersion="2.0">
<attachedDevices>
<item>Speaker</item>
<item>Built-In Mic</item>
</attachedDevices>
<defaultOutputDevice>Speaker</defaultOutputDevice>
<mixPorts>
<mixPort name="primary output" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000"
channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</mixPort>
<mixPort name="primary input" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000 11025 12000 16000 22050 24000 32000 44100 48000"
channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/>
</mixPort>
</mixPorts>
<devicePorts>
<devicePort tagName="Speaker" type="AUDIO_DEVICE_OUT_SPEAKER" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000"
channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="Wired Headset" type="AUDIO_DEVICE_OUT_WIRED_HEADSET" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000"
channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="Wired Headphones" type="AUDIO_DEVICE_OUT_WIRED_HEADPHONE" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000"
channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
</devicePort>
<devicePort tagName="BT SCO" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000 16000"
channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
</devicePort>
<devicePort tagName="BT SCO Headset" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000 16000"
channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
</devicePort>
<devicePort tagName="BT SCO Car Kit" type="AUDIO_DEVICE_OUT_BLUETOOTH_SCO_CARKIT" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000 16000"
channelMasks="AUDIO_CHANNEL_OUT_MONO"/>
</devicePort>
<devicePort tagName="Built-In Mic" type="AUDIO_DEVICE_IN_BUILTIN_MIC" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000 11025 12000 16000 22050 24000 32000 44100 48000"
channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/>
</devicePort>
<devicePort tagName="Wired Headset Mic" type="AUDIO_DEVICE_IN_WIRED_HEADSET" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000 11025 12000 16000 22050 24000 32000 44100 48000"
channelMasks="AUDIO_CHANNEL_IN_MONO AUDIO_CHANNEL_IN_STEREO"/>
</devicePort>
<devicePort tagName="BT SCO Headset Mic" type="AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET" role="source">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="8000 16000"
channelMasks="AUDIO_CHANNEL_IN_MONO"/>
</devicePort>
</devicePorts>
<routes>
<route type="mix" sink="Speaker"
sources="primary output"/>
<route type="mix" sink="Wired Headset"
sources="primary output"/>
<route type="mix" sink="Wired Headphones"
sources="primary output"/>
<route type="mix" sink="BT SCO"
sources="primary output"/>
<route type="mix" sink="BT SCO Headset"
sources="primary output"/>
<route type="mix" sink="BT SCO Car Kit"
sources="primary output"/>
<route type="mix" sink="primary input"
sources="Built-In Mic,Wired Headset Mic,BT SCO Headset Mic"/>
</routes>
</module>
<xi:include href="a2dp_in_audio_policy_configuration_7_0.xml"/>
<xi:include href="usb_audio_policy_configuration.xml"/>
<xi:include href="r_submix_audio_policy_configuration.xml"/>
<xi:include href="bluetooth_audio_policy_configuration_7_0.xml"/>
</modules>
<xi:include href="audio_policy_volumes.xml"/>
<xi:include href="default_volume_tables.xml"/>
</audioPolicyConfiguration>

68
audio/vc4-hdmi.conf Normal file
View File

@@ -0,0 +1,68 @@
# 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
}
}
}

View File

@@ -0,0 +1,12 @@
/*
* Copyright (C) 2021-2022 KonstaKANG
*
* SPDX-License-Identifier: Apache-2.0
*/
#ifndef _BDROID_BUILDCFG_H
#define _BDROID_BUILDCFG_H
#define BTM_DEF_LOCAL_NAME "Raspberry Pi 4"
#endif

14
bluetooth/vnd_rpi4.txt Normal file
View File

@@ -0,0 +1,14 @@
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

45
boot/config.txt Normal file
View File

@@ -0,0 +1,45 @@
# Kernel
arm_64bit=1
kernel=Image
# Ramdisk
initramfs ramdisk.img followkernel
# Audio
dtparam=audio=on
# Camera
camera_auto_detect=1
start_x=1
# Display
disable_overscan=1
# Display panel
#dtoverlay=vc4-kms-dsi-7inch
#dtoverlay=rpi-backlight
# Graphics acceleration
dtoverlay=vc4-kms-v3d
dtoverlay=cma,cma-384
# I2C
#dtparam=i2c_arm=on
# I2S
#dtparam=i2s=on
# Serial console
enable_uart=1
# SPI
#dtparam=spi=on
# USB
dtoverlay=dwc2,dr_mode=peripheral
[cm4]
dtoverlay=dwc2,dr_mode=otg
[all]
# V4L2
#dtoverlay=rpivid-v4l2

10
camera/camera_hal.yaml Normal file
View File

@@ -0,0 +1,10 @@
cameras:
"/base/soc/i2c0mux/i2c@1/imx219@10":
location: back
rotation: 0
"/base/soc/i2c0mux/i2c@1/imx477@1a":
location: back
rotation: 0
"/base/soc/i2c0mux/i2c@1/ov5647@36":
location: back
rotation: 0

View File

@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 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.
-->
<ExternalCamera>
<Provider>
<ignore> <!-- Internal video devices to be ignored by external camera HAL -->
<id>10</id> <!-- No leading/trailing spaces -->
<id>11</id>
<id>12</id>
<id>13</id>
<id>14</id>
<id>15</id>
<id>16</id>
<id>18</id>
<id>19</id>
<id>20</id>
<id>21</id>
<id>22</id>
<id>23</id>
</ignore>
</Provider>
<!-- See ExternalCameraUtils.cpp for default values of Device configurations below -->
<Device>
<!-- Max JPEG buffer size in bytes-->
<MaxJpegBufferSize bytes="3145728"/> <!-- 3MB (~= 1080p YUV420) -->
<!-- Size of v4l2 buffer queue when streaming >= 30fps -->
<!-- Larger value: more request can be cached pipeline (less janky) -->
<!-- Smaller value: use less memory -->
<NumVideoBuffers count="4"/>
<!-- Size of v4l2 buffer queue when streaming < 30fps -->
<NumStillBuffers count="2"/>
<!-- List of maximum fps for various output sizes -->
<!-- Any image size smaller than the size listed in Limit row will report
fps (as minimum frame duration) up to the fpsBound value. -->
<FpsList>
<!-- width/height must be increasing, fpsBound must be decreasing-->
<Limit width="640" height="480" fpsBound="30.0"/>
<Limit width="1280" height="720" fpsBound="15.0"/>
<Limit width="1920" height="1080" fpsBound="10.0"/>
<!-- image size larger than the last entry will not be supported-->
</FpsList>
</Device>
</ExternalCamera>

View File

@@ -0,0 +1,190 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Copyright (C) 2016 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.
-->
<!DOCTYPE MediaSettings SYSTEM "/system/etc/media_profiles_V1_0.dtd">
<!--
This file is used to declare the multimedia profiles and capabilities
on an android-powered device.
-->
<MediaSettings>
<!-- Each camcorder profile defines a set of predefined configuration parameters -->
<CamcorderProfiles cameraId="0">
<EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
<Video codec="h264"
bitRate="128000"
width="320"
height="240"
frameRate="30" />
<Audio codec="amrnb"
bitRate="12200"
sampleRate="8000"
channels="1" />
</EncoderProfile>
<EncoderProfile quality="480p" fileFormat="mp4" duration="60">
<Video codec="h264"
bitRate="12000000"
width="640"
height="480"
frameRate="30" />
<Audio codec="amrnb"
bitRate="12200"
sampleRate="8000"
channels="1" />
</EncoderProfile>
<EncoderProfile quality="720p " fileFormat="mp4" duration="60">
<Video codec="h264"
bitRate="12000000"
width="1280"
height="720"
frameRate="30" />
<Audio codec="amrnb"
bitRate="12200"
sampleRate="8000"
channels="1" />
</EncoderProfile>
<EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
<Video codec="h264"
bitRate="192000"
width="176"
height="144"
frameRate="30" />
<!-- audio setting is ignored -->
<Audio codec="amrnb"
bitRate="12200"
sampleRate="8000"
channels="1" />
</EncoderProfile>
<ImageEncoding quality="95" />
<ImageEncoding quality="80" />
<ImageEncoding quality="70" />
<ImageDecoding memCap="20000000" />
</CamcorderProfiles>
<CamcorderProfiles cameraId="1">
<EncoderProfile quality="qvga" fileFormat="mp4" duration="60">
<Video codec="h264"
bitRate="128000"
width="320"
height="240"
frameRate="30" />
<Audio codec="amrnb"
bitRate="12200"
sampleRate="8000"
channels="1" />
</EncoderProfile>
<EncoderProfile quality="480p" fileFormat="mp4" duration="60">
<Video codec="h264"
bitRate="12000000"
width="640"
height="480"
frameRate="30" />
<Audio codec="amrnb"
bitRate="12200"
sampleRate="8000"
channels="1" />
</EncoderProfile>
<EncoderProfile quality="720p " fileFormat="mp4" duration="60">
<Video codec="h264"
bitRate="12000000"
width="1280"
height="720"
frameRate="30" />
<Audio codec="amrnb"
bitRate="12200"
sampleRate="8000"
channels="1" />
</EncoderProfile>
<EncoderProfile quality="timelapseqcif" fileFormat="mp4" duration="30">
<Video codec="h264"
bitRate="192000"
width="176"
height="144"
frameRate="30" />
<!-- audio setting is ignored -->
<Audio codec="amrnb"
bitRate="12200"
sampleRate="8000"
channels="1" />
</EncoderProfile>
<ImageEncoding quality="95" />
<ImageEncoding quality="80" />
<ImageEncoding quality="70" />
<ImageDecoding memCap="20000000" />
</CamcorderProfiles>
<EncoderOutputFileFormat name="3gp" />
<EncoderOutputFileFormat name="mp4" />
<!--
If a codec is not enabled, it is invisible to the applications
In other words, the applications won't be able to use the codec
or query the capabilities of the codec at all if it is disabled
-->
<VideoEncoderCap name="h264" enabled="true"
minBitRate="64000" maxBitRate="12000000"
minFrameWidth="176" maxFrameWidth="1280"
minFrameHeight="144" maxFrameHeight="720"
minFrameRate="15" maxFrameRate="30" />
<VideoEncoderCap name="h263" enabled="true"
minBitRate="64000" maxBitRate="12000000"
minFrameWidth="176" maxFrameWidth="1280"
minFrameHeight="144" maxFrameHeight="720"
minFrameRate="15" maxFrameRate="30" />
<VideoEncoderCap name="m4v" enabled="true"
minBitRate="64000" maxBitRate="12000000"
minFrameWidth="176" maxFrameWidth="1280"
minFrameHeight="144" maxFrameHeight="720"
minFrameRate="15" maxFrameRate="30" />
<AudioEncoderCap name="aac" enabled="true"
minBitRate="8000" maxBitRate="96000"
minSampleRate="8000" maxSampleRate="48000"
minChannels="1" maxChannels="1" />
<AudioEncoderCap name="amrwb" enabled="true"
minBitRate="6600" maxBitRate="23050"
minSampleRate="16000" maxSampleRate="16000"
minChannels="1" maxChannels="1" />
<AudioEncoderCap name="amrnb" enabled="true"
minBitRate="5525" maxBitRate="12200"
minSampleRate="8000" maxSampleRate="8000"
minChannels="1" maxChannels="1" />
<!--
FIXME:
We do not check decoder capabilities at present
At present, we only check whether windows media is visible
for TEST applications. For other applications, we do
not perform any checks at all.
-->
<VideoDecoderCap name="wmv" enabled="false"/>
<AudioDecoderCap name="wma" enabled="false"/>
</MediaSettings>

58
compatibility_matrix.xml Normal file
View File

@@ -0,0 +1,58 @@
<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>
<interface>
<name>ISensorManager</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.manager</name>
<version>1.2</version>
<interface>
<name>IServiceManager</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl" optional="true">
<name>android.hidl.memory</name>
<version>1.0</version>
<interface>
<name>IMapper</name>
<instance>ashmem</instance>
</interface>
</hal>
<hal format="hidl" optional="false">
<name>android.hidl.token</name>
<version>1.0</version>
<interface>
<name>ITokenManager</name>
<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>

266
device.mk Normal file
View File

@@ -0,0 +1,266 @@
#
# Copyright (C) 2021-2022 KonstaKANG
#
# SPDX-License-Identifier: Apache-2.0
#
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
# API level
PRODUCT_SHIPPING_API_LEVEL := 32
# Audio
PRODUCT_PACKAGES += \
android.hardware.audio.service \
android.hardware.audio@7.0-impl \
android.hardware.audio.effect@7.0-impl \
audio.primary.rpi \
audio.r_submix.default \
audio.usb.default
PRODUCT_PACKAGES += \
tinycap \
tinyhostless \
tinymix \
tinypcminfo \
tinyplay
PRODUCT_COPY_FILES += \
$(DEVICE_PATH)/audio/audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_configuration.xml \
frameworks/av/media/libeffects/data/audio_effects.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_effects.xml \
frameworks/av/services/audiopolicy/config/audio_policy_volumes.xml:$(TARGET_COPY_OUT_VENDOR)/etc/audio_policy_volumes.xml \
frameworks/av/services/audiopolicy/config/default_volume_tables.xml:$(TARGET_COPY_OUT_VENDOR)/etc/default_volume_tables.xml \
frameworks/av/services/audiopolicy/config/r_submix_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/r_submix_audio_policy_configuration.xml \
frameworks/av/services/audiopolicy/config/usb_audio_policy_configuration.xml:$(TARGET_COPY_OUT_VENDOR)/etc/usb_audio_policy_configuration.xml
PRODUCT_PACKAGES += \
alsa_amixer \
alsa_aplay \
alsa_arecord \
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/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 \
external/alsa-lib/src/conf/pcm/dmix.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/dmix.conf \
external/alsa-lib/src/conf/pcm/dpl.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/dpl.conf \
external/alsa-lib/src/conf/pcm/dsnoop.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/dsnoop.conf \
external/alsa-lib/src/conf/pcm/front.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/front.conf \
external/alsa-lib/src/conf/pcm/hdmi.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/hdmi.conf \
external/alsa-lib/src/conf/pcm/iec958.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/iec958.conf \
external/alsa-lib/src/conf/pcm/modem.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/modem.conf \
external/alsa-lib/src/conf/pcm/rear.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/rear.conf \
external/alsa-lib/src/conf/pcm/side.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/side.conf \
external/alsa-lib/src/conf/pcm/surround21.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/surround21.conf \
external/alsa-lib/src/conf/pcm/surround40.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/surround40.conf \
external/alsa-lib/src/conf/pcm/surround41.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/surround41.conf \
external/alsa-lib/src/conf/pcm/surround50.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/surround50.conf \
external/alsa-lib/src/conf/pcm/surround51.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/surround51.conf \
external/alsa-lib/src/conf/pcm/surround71.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/pcm/surround71.conf \
external/alsa-lib/src/conf/smixer.conf:$(TARGET_COPY_OUT_VENDOR)/etc/alsa/smixer.conf
# Bluetooth
PRODUCT_PACKAGES += \
android.hardware.bluetooth@1.0-impl \
android.hardware.bluetooth@1.0-service \
libbt-vendor
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 \
audio.bluetooth.default
PRODUCT_COPY_FILES += \
frameworks/av/services/audiopolicy/config/a2dp_in_audio_policy_configuration_7_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/a2dp_in_audio_policy_configuration_7_0.xml \
frameworks/av/services/audiopolicy/config/bluetooth_audio_policy_configuration_7_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/bluetooth_audio_policy_configuration_7_0.xml
# Camera
PRODUCT_PACKAGES += \
android.hardware.camera.provider@2.5-external-service
PRODUCT_COPY_FILES += \
$(DEVICE_PATH)/camera/external_camera_config.xml:$(TARGET_COPY_OUT_VENDOR)/etc/external_camera_config.xml
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.camera.external.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.external.xml
PRODUCT_PACKAGES += \
android.hardware.camera.provider@2.5-service_64 \
camera.libcamera \
ipa_rpi
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
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.camera.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.camera.xml
PRODUCT_COPY_FILES += \
$(DEVICE_PATH)/camera/media_profiles_V1_0.xml:$(TARGET_COPY_OUT_VENDOR)/etc/media_profiles_V1_0.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
# Ethernet
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.ethernet.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.ethernet.xml
# Gatekeeper
PRODUCT_PACKAGES += \
android.hardware.gatekeeper@1.0-service.software
# Graphics
PRODUCT_PACKAGES += \
android.hardware.graphics.allocator@4.0-service.minigbm_gbm_mesa \
android.hardware.graphics.mapper@4.0-impl.minigbm_gbm_mesa
PRODUCT_PACKAGES += \
android.hardware.graphics.composer@2.4-service \
hwcomposer.drm
PRODUCT_PACKAGES += \
libEGL_mesa \
libGLESv1_CM_mesa \
libGLESv2_mesa \
libgallium_dri \
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
PRODUCT_PACKAGES += \
vulkan.broadcom
PRODUCT_COPY_FILES += \
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
# Health
PRODUCT_PACKAGES += \
android.hardware.health@2.0-service.rpi
# Kernel
PRODUCT_COPY_FILES += \
$(DEVICE_PATH)-kernel/Image:$(PRODUCT_OUT)/kernel
# Keymaster
PRODUCT_PACKAGES += \
android.hardware.keymaster@3.0-impl \
android.hardware.keymaster@3.0-service
# Lights
PRODUCT_PACKAGES += \
android.hardware.light@2.0-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
# Ramdisk
PRODUCT_COPY_FILES += \
$(DEVICE_PATH)/ramdisk/fstab.rpi4:$(TARGET_COPY_OUT_RAMDISK)/fstab.rpi4 \
$(DEVICE_PATH)/ramdisk/fstab.rpi4:$(TARGET_COPY_OUT_VENDOR)/etc/fstab.rpi4 \
$(DEVICE_PATH)/ramdisk/init.rpi4.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.rpi4.rc \
$(DEVICE_PATH)/ramdisk/init.rpi4.usb.rc:$(TARGET_COPY_OUT_VENDOR)/etc/init/hw/init.rpi4.usb.rc \
$(DEVICE_PATH)/ramdisk/ueventd.rpi4.rc:$(TARGET_COPY_OUT_VENDOR)/etc/ueventd.rc
# Seccomp
PRODUCT_COPY_FILES += \
$(DEVICE_PATH)/seccomp_policy/codec2.vendor.ext.policy:$(TARGET_COPY_OUT_VENDOR)/etc/seccomp_policy/codec2.vendor.ext.policy \
$(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)
# Suspend
PRODUCT_PACKAGES += \
suspend_blocker_rpi
# USB
PRODUCT_PACKAGES += \
android.hardware.usb@1.0-service
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.usb.accessory.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.accessory.xml \
frameworks/native/data/etc/android.hardware.usb.host.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.usb.host.xml \
frameworks/native/data/etc/android.software.midi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.software.midi.xml
# V4L2
PRODUCT_SOONG_NAMESPACES += external/v4l2_codec2
PRODUCT_PACKAGES += \
android.hardware.media.c2@1.0-service-v4l2 \
libc2plugin_store
# Wifi
PRODUCT_PACKAGES += \
android.hardware.wifi@1.0-service \
hostapd \
hostapd_cli \
libwpa_client \
wificond \
wpa_cli \
wpa_supplicant \
wpa_supplicant.conf
PRODUCT_COPY_FILES += \
hardware/broadcom/wlan/bcmdhd/config/wpa_supplicant_overlay.conf:$(TARGET_COPY_OUT_VENDOR)/etc/wifi/wpa_supplicant_overlay.conf
PRODUCT_COPY_FILES += \
frameworks/native/data/etc/android.hardware.wifi.xml:$(TARGET_COPY_OUT_VENDOR)/etc/permissions/android.hardware.wifi.xml

33
health/Android.bp Normal file
View File

@@ -0,0 +1,33 @@
// Copyright (C) 2021-2022 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,
relative_install_path: "hw",
srcs: [
"HealthService.cpp",
],
cflags: [
"-Wall",
"-Werror",
],
static_libs: [
"android.hardware.health@2.0-impl",
"android.hardware.health@1.0-convert",
"libhealthservice",
"libbatterymonitor",
"libhealthstoragedefault",
],
shared_libs: [
"libbase",
"libcutils",
"libhidlbase",
"libutils",
"android.hardware.health@2.0",
],
header_libs: ["libhealthd_headers"],
}

20
health/HealthService.cpp Normal file
View File

@@ -0,0 +1,20 @@
/*
* 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;
}

View File

@@ -0,0 +1,5 @@
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

View File

@@ -0,0 +1,11 @@
<manifest version="1.0" type="device">
<hal format="hidl">
<name>android.hardware.health</name>
<transport>hwbinder</transport>
<version>2.0</version>
<interface>
<name>IHealth</name>
<instance>default</instance>
</interface>
</hal>
</manifest>

24
light/Android.bp Normal file
View File

@@ -0,0 +1,24 @@
// Copyright (C) 2018 The LineageOS Project
// Copyright (C) 2021-2022 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,
relative_install_path: "hw",
srcs: [
"Light.cpp",
"service.cpp",
],
shared_libs: [
"libbase",
"libcutils",
"libhardware",
"libhidlbase",
"libutils",
"android.hardware.light@2.0",
],
}

93
light/Light.cpp Normal file
View File

@@ -0,0 +1,93 @@
/*
* 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

56
light/Light.h Normal file
View File

@@ -0,0 +1,56 @@
/*
* 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

View File

@@ -0,0 +1,11 @@
on init
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
class hal
user system
group system
# shutting off lights while powering-off
shutdown critical

View File

@@ -0,0 +1,11 @@
<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>

63
light/service.cpp Normal file
View File

@@ -0,0 +1,63 @@
/*
* 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;
}

101
manifest.xml Normal file
View File

@@ -0,0 +1,101 @@
<manifest version="1.0" type="device" target-level="6">
<hal format="hidl">
<name>android.hardware.audio</name>
<transport>hwbinder</transport>
<version>7.0</version>
<interface>
<name>IDevicesFactory</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>android.hardware.audio.effect</name>
<transport>hwbinder</transport>
<version>7.0</version>
<interface>
<name>IEffectsFactory</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>android.hardware.bluetooth</name>
<transport>hwbinder</transport>
<version>1.0</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>
<interface>
<name>IBluetoothAudioProvidersFactory</name>
<instance>default</instance>
</interface>
</hal>
<hal format="hidl">
<name>android.hardware.camera.provider</name>
<transport>hwbinder</transport>
<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>
<version>2.4</version>
<interface>
<name>IComposer</name>
<instance>default</instance>
</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>
<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>
<instance>default</instance>
</interface>
</hal>
</manifest>

24
media/media_codecs.xml Normal file
View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2018 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.
-->
<MediaCodecs>
<!-- <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" />
</MediaCodecs>

View File

@@ -0,0 +1,106 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2021 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.
-->
<Included>
<!--
<Encoders>
<MediaCodec name="c2.v4l2.avc.encoder" type="video/avc">
<Limit name="size" min="32x32" max="4096x4096" />
<Limit name="alignment" value="2x2" />
<Limit name="block-size" value="16x16" />
<Limit name="blocks-per-second" range="1-983040" />
<Limit name="bitrate" range="1-40000000" />
<Limit name="concurrent-instances" max="8" />
<Limit name="performance-point-1280x720" range="30-30" />
</MediaCodec>
</Encoders>
-->
<Decoders>
<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" />
<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" />
</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>

27
mkbootimg.mk Normal file
View File

@@ -0,0 +1,27 @@
#
# Copyright (C) 2021-2022 KonstaKANG
#
# SPDX-License-Identifier: Apache-2.0
#
DEVICE_PATH := device/brcm/rpi4
KERNEL_PATH := device/brcm/rpi4-kernel
VENDOR_PATH := vendor/brcm
RPI_BOOT_OUT := $(PRODUCT_OUT)/rpiboot
$(RPI_BOOT_OUT): $(INSTALLED_RAMDISK_TARGET)
mkdir -p $(RPI_BOOT_OUT)
mkdir -p $(RPI_BOOT_OUT)/overlays
cp $(DEVICE_PATH)/boot/* $(RPI_BOOT_OUT)
cp $(KERNEL_PATH)/Image $(RPI_BOOT_OUT)
cp $(KERNEL_PATH)/bcm2711-rpi-*.dtb $(RPI_BOOT_OUT)
cp $(KERNEL_PATH)/overlays/* $(RPI_BOOT_OUT)/overlays
cp $(PRODUCT_OUT)/ramdisk.img $(RPI_BOOT_OUT)
cp $(VENDOR_PATH)/rpi4/proprietary/boot/* $(RPI_BOOT_OUT)
echo $(BOARD_KERNEL_CMDLINE) > $(RPI_BOOT_OUT)/cmdline.txt
$(INSTALLED_BOOTIMAGE_TARGET): $(RPI_BOOT_OUT)
$(call pretty,"Target boot image: $@")
dd if=/dev/zero of=$@ bs=1M count=128
mkfs.fat -F 32 -n "boot" $@
mcopy -s -i $@ $(RPI_BOOT_OUT)/* ::

72
mkimg.sh Executable file
View File

@@ -0,0 +1,72 @@
#!/bin/bash
#
# Copyright (C) 2021-2022 KonstaKANG
#
# SPDX-License-Identifier: Apache-2.0
#
VERSION=RaspberryVanillaAOSP12
DATE=$(date +%Y%m%d)
IMGNAME=${VERSION}-${DATE}-rpi4.img
IMGSIZE=7
OUTDIR=$(pwd | sed 's/\/device\/brcm\/rpi4$//')/out/target/product/rpi4
echo "Creating image file ${OUTDIR}/${IMGNAME}..."
sudo dd if=/dev/zero of="${OUTDIR}/${IMGNAME}" bs=1M count=$(echo "${IMGSIZE}*1024" | bc)
sync
echo "Creating partitions..."
(
echo o
echo n
echo p
echo 1
echo
echo +128M
echo n
echo p
echo 2
echo
echo +2048M
echo n
echo p
echo 3
echo
echo +256M
echo n
echo p
echo
echo
echo t
echo 1
echo c
echo a
echo 1
echo w
) | sudo fdisk "${OUTDIR}/${IMGNAME}"
sync
LOOPDEV=$(sudo kpartx -av "${OUTDIR}/${IMGNAME}" | awk 'NR==1{ sub(/p[0-9]$/, "", $3); print $3 }')
if [ -z ${LOOPDEV} ]; then
echo "Unable to find loop device!"
exit 1
fi
echo "Image mounted as /dev/${LOOPDEV}"
sleep 1
echo "Copying boot..."
sudo dd if=${OUTDIR}/boot.img of=/dev/mapper/${LOOPDEV}p1 bs=1M
echo "Copying system..."
sudo dd if=${OUTDIR}/system.img of=/dev/mapper/${LOOPDEV}p2 bs=1M
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}"
echo "Done, created ${OUTDIR}/${IMGNAME}!"
exit 0

View File

@@ -0,0 +1,10 @@
// Copyright (C) 2021-2022 KonstaKANG
//
// SPDX-License-Identifier: Apache-2.0
runtime_resource_overlay {
name: "AndroidRpiOverlay",
resource_dirs: ["res"],
sdk_version: "current",
proprietary: true
}

View 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"
android:versionCode="1"
android:versionName="1.0" >
<application android:hasCode="false" />
<overlay
android:targetPackage="android"
android:isStatic="true"
android:priority="0" />
</manifest>

View File

@@ -0,0 +1,114 @@
<?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>
<!-- Flag indicating that the media framework should support playing of sounds on volume
key usage. This adds noticeable additional overhead to volume key processing, so
is disableable for products for which it is irrelevant. -->
<bool name="config_useVolumeKeySounds">false</bool>
<!-- Flag indicating whether the current device is "voice capable".
If true, this means that the device supports circuit-switched
(i.e. voice) phone calls over the telephony network, and is
allowed to display the in-call UI while a cellular voice call is
active. This can be overridden to false for "data only" devices
which can't make voice calls and don't support any in-call UI.
Note: this flag is subtly different from the
PackageManager.FEATURE_TELEPHONY system feature, which is
available on *any* device with a telephony radio, even if the
device is data-only. -->
<bool name="config_voice_capable">false</bool>
<!-- Flag indicating whether the current device allows sms service.
If true, this means that the device supports both sending and
receiving sms via the telephony network.
This can be overridden to false for "data only" devices
which can't send and receive sms message.
Note: Disable SMS also disable voicemail waiting sms,
cell broadcasting sms, and MMS. -->
<bool name="config_sms_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>
<!-- This string array should be overridden by the device to present a list of network
attributes. This is used by the connectivity manager to decide which networks can coexist
based on the hardware -->
<!-- An Array of "[Connection name],[ConnectivityManager.TYPE_xxxx],
[associated radio-type],[priority],[restoral-timer(ms)],[dependencyMet] -->
<!-- the 5th element "resore-time" indicates the number of milliseconds to delay
before automatically restore the default connection. Set -1 if the connection
does not require auto-restore. -->
<!-- the 6th element indicates boot-time dependency-met value. -->
<string-array translatable="false" name="networkAttributes">
<item>"wifi,1,1,1,-1,true"</item>
<item>"bluetooth,7,7,2,-1,true"</item>
<item>"ethernet,9,9,9,-1,true"</item>
</string-array>
<!-- This string array should be overridden by the device to present a list of radio
attributes. This is used by the connectivity manager to decide which networks can coexist
based on the hardware -->
<!-- An Array of "[ConnectivityManager connectionType],
[# simultaneous connection types]" -->
<string-array translatable="false" name="radioAttributes">
<item>"1,1"</item>
<item>"7,1"</item>
<item>"9,1"</item>
</string-array>
<!-- 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>
<!-- Control the default night mode to use when there is no other mode override set.
One of the following values (see UiModeManager.java):
0 - MODE_NIGHT_AUTO
1 - MODE_NIGHT_NO
2 - MODE_NIGHT_YES
-->
<integer name="config_defaultNightMode">2</integer>
</resources>

View File

@@ -0,0 +1,10 @@
// Copyright (C) 2021-2022 KonstaKANG
//
// SPDX-License-Identifier: Apache-2.0
runtime_resource_overlay {
name: "SettingsProviderRpiOverlay",
resource_dirs: ["res"],
sdk_version: "current",
proprietary: true
}

View 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"
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>

View File

@@ -0,0 +1,40 @@
<?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 bluetooth by default -->
<bool name="def_bluetooth_on">false</bool>
<!-- Disable location by default -->
<integer name="def_location_mode">0</integer>
<!-- Disable the lockscreen -->
<bool name="def_lockscreen_disabled">true</bool>
<!-- Keep screen on at all times by default -->
<bool name="def_stay_on_while_plugged_in">true</bool>
<!-- No setup wizard -->
<bool name="def_device_provisioned">true</bool>
<bool name="def_user_setup_complete">true</bool>
</resources>

View File

@@ -0,0 +1,10 @@
// Copyright (C) 2021-2022 KonstaKANG
//
// SPDX-License-Identifier: Apache-2.0
runtime_resource_overlay {
name: "SettingsRpiOverlay",
resource_dirs: ["res"],
sdk_version: "current",
proprietary: true
}

View 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.settings.rpi"
android:versionCode="1"
android:versionName="1.0" >
<application android:hasCode="false" />
<overlay
android:targetPackage="com.android.settings"
android:isStatic="true"
android:priority="0" />
</manifest>

View File

@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2007 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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- Whether call_volume should be shown or not. -->
<bool name="config_show_call_volume">false</bool>
<!-- Whether charging_sounds should be shown or not. -->
<bool name="config_show_charging_sounds">false</bool>
<!-- Whether top_level_battery should be shown or not. -->
<bool name="config_show_top_level_battery">false</bool>
</resources>

View File

@@ -0,0 +1,10 @@
// Copyright (C) 2021-2022 KonstaKANG
//
// SPDX-License-Identifier: Apache-2.0
runtime_resource_overlay {
name: "SystemUIRpiOverlay",
resource_dirs: ["res"],
sdk_version: "current",
proprietary: true
}

View 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.systemui.rpi"
android:versionCode="1"
android:versionName="1.0" >
<application android:hasCode="false" />
<overlay
android:targetPackage="com.android.systemui"
android:isStatic="true"
android:priority="0" />
</manifest>

View File

@@ -0,0 +1,26 @@
<?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>
<!-- The default tiles to display in QuickSettings -->
<string name="quick_settings_tiles_default" translatable="false">
internet,bt,airplane,hotspot,dark,screenrecord
</string>
</resources>

View File

@@ -0,0 +1,10 @@
// Copyright (C) 2021-2022 KonstaKANG
//
// SPDX-License-Identifier: Apache-2.0
runtime_resource_overlay {
name: "WifiRpiOverlay",
resource_dirs: ["res"],
sdk_version: "current",
proprietary: true
}

View File

@@ -0,0 +1,20 @@
<?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.wifi.resources.rpi"
android:versionCode="1"
android:versionName="1.0">
<application android:hasCode="false" />
<overlay
android:targetPackage="com.android.wifi.resources"
android:targetName="WifiCustomization"
android:isStatic="true"
android:priority="0" />
</manifest>

View File

@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright (C) 2019 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 xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<!-- boolean indicating whether the WiFi chipset has 5GHz band support.
Note: This config is replacing the config_wifi_dual_band_support
since more bands may now be supported (such as 6GHz), the naming dual_band
is no longer indicative, and a separate config now exists for each band -->
<bool translatable="false" name ="config_wifi5ghzSupport">true</bool>
</resources>

10
ramdisk/fstab.rpi4 Normal file
View File

@@ -0,0 +1,10 @@
# Android fstab file.
# The filesystem that contains the filesystem checker binary (typically /system) cannot
# specify MF_CHECK, and must come before any filesystems that do specify MF_CHECK
#<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
/devices/platform/scb/*.pcie/*/*/*/usb* auto auto defaults voldmanaged=usb:auto
/devices/platform/soc/*.usb/usb* auto auto defaults voldmanaged=usb:auto

39
ramdisk/init.rpi4.rc Normal file
View File

@@ -0,0 +1,39 @@
import /vendor/etc/init/hw/init.rpi4.usb.rc
on init
symlink /sdcard /storage/sdcard0
on fs
mount_all /vendor/etc/fstab.rpi4
on post-fs-data
# Create the directories used by the Wireless subsystem
mkdir /data/vendor/wifi 0770 wifi wifi
mkdir /data/vendor/wifi/wpa 0770 wifi wifi
mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi
# Set indication (checked by vold) that we have finished this action
setprop vold.post_fs_data_done 1
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
user root

90
ramdisk/init.rpi4.usb.rc Normal file
View File

@@ -0,0 +1,90 @@
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
write /config/usb_gadget/g1/bcdUSB 0x0200
write /config/usb_gadget/g1/idVendor 0x18d1
write /config/usb_gadget/g1/strings/0x409/serialnumber ${ro.serialno}
write /config/usb_gadget/g1/strings/0x409/manufacturer "Raspberry"
write /config/usb_gadget/g1/strings/0x409/product "Pi 4"
mkdir /config/usb_gadget/g1/functions/ffs.adb
mkdir /config/usb_gadget/g1/functions/ffs.mtp
mkdir /config/usb_gadget/g1/functions/ffs.ptp
mkdir /config/usb_gadget/g1/functions/accessory.gs2
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
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"
mkdir /dev/usb-ffs 0775 shell shell
mkdir /dev/usb-ffs/adb 0770 shell shell
mkdir /dev/usb-ffs/mtp 0770 mtp mtp
mkdir /dev/usb-ffs/ptp 0770 mtp mtp
setprop sys.usb.mtp.device_type 3
symlink /config/usb_gadget/g1/configs/b.1 /config/usb_gadget/g1/os_desc/b.1
on property:sys.usb.controller=*
mount functionfs adb /dev/usb-ffs/adb uid=2000,gid=2000
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

23
ramdisk/ueventd.rpi4.rc Normal file
View File

@@ -0,0 +1,23 @@
# 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
# DMA
/dev/dma_heap/linux,cma 0666 system graphics
# ION
/dev/ion 0664 system system
# V4L2
/dev/media0 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

View File

@@ -0,0 +1,20 @@
# device specific syscalls
_llseek: 1
epoll_create1: 1
epoll_ctl: 1
epoll_pwait: 1
eventfd2: 1
fstat64: 1
fstatat64: 1
fstatfs64: 1
getcwd: 1
getdents64: 1
geteuid32: 1
getuid32: 1
mmap2: 1
open: 1
pselect6: 1
sched_getaffinity: 1
statfs64: 1
sysinfo: 1
ugetrlimit: 1

View File

@@ -0,0 +1,9 @@
# device specific syscalls
_llseek: 1
eventfd2: 1
getcwd: 1
pselect6: 1
recvfrom: 1
sched_getaffinity: 1
sendto: 1
sysinfo: 1

View File

@@ -0,0 +1,3 @@
# device specific syscalls
sched_getaffinity: 1
sysinfo: 1

7
sepolicy/alsa_loop.te Normal file
View File

@@ -0,0 +1,7 @@
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
sepolicy/bluetooth.te Normal file
View File

@@ -0,0 +1 @@
allow bluetooth vcio_device:chr_file rw_file_perms;

1
sepolicy/bootanim.te Normal file
View File

@@ -0,0 +1 @@
gpu_access(bootanim)

1
sepolicy/device.te Normal file
View File

@@ -0,0 +1 @@
type vcio_device, dev_type, mlstrustedobject;

1
sepolicy/file.te Normal file
View File

@@ -0,0 +1 @@
type sysfs_gpu, fs_type, sysfs_type;

49
sepolicy/file_contexts Normal file
View File

@@ -0,0 +1,49 @@
# 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
# 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
# Gatekeeper
/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
/dev/dri/card0 u:object_r:gpu_device:s0
/dev/dri/card1 u:object_r:gpu_device:s0
/dev/dri/renderD128 u:object_r:gpu_device:s0
/vendor/bin/hw/android\.hardware\.graphics\.allocator@4\.0-service\.minigbm_gbm_mesa u:object_r:hal_graphics_allocator_default_exec:s0
/vendor/lib(64)?/dri/libgallium_dri\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/hw/android\.hardware\.graphics.mapper@4\.0-impl\.minigbm_gbm_mesa\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/hw/vulkan\.broadcom\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/libdrm\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/libgbm_mesa\.so u:object_r:same_process_hal_file:s0
/vendor/lib{64}?/libgbm_mesa_wrapper\.so u:object_r:same_process_hal_file:s0
/vendor/lib(64)?/libglapi\.so u:object_r:same_process_hal_file:s0
/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
# 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
# Partitions
/dev/block/mmcblk0p1 u:object_r:boot_block_device:s0
/dev/block/mmcblk0p2 u:object_r:system_block_device:s0
/dev/block/mmcblk0p3 u:object_r:system_block_device:s0
/dev/block/mmcblk0p4 u:object_r:userdata_block_device:s0
# Suspend
/vendor/bin/suspend_blocker_rpi u:object_r:suspend_blocker_exec:s0
# V4L2
/vendor/bin/hw/android\.hardware\.media\.c2@1\.0-service-v4l2(.*)? u:object_r:mediacodec_exec:s0

3
sepolicy/genfs_contexts Normal file
View File

@@ -0,0 +1,3 @@
genfscon sysfs /devices/platform/v3dbus/fec00000.v3d/uevent u:object_r:sysfs_gpu:s0
genfscon sysfs /devices/platform/gpu/uevent u:object_r:sysfs_gpu:s0
genfscon sysfs /firmware/devicetree/base/serial-number u:object_r:sysfs_dt_firmware_android:s0

14
sepolicy/hal_camera.te Normal file
View File

@@ -0,0 +1,14 @@
vndbinder_use(hal_camera_default);
allow hal_camera_default hal_graphics_mapper_hwservice:hwservice_manager find;
hal_client_domain(hal_camera_default, hal_graphics_allocator);
hal_client_domain(hal_camera_default, hal_graphics_composer);
allow cameraserver device:dir r_dir_perms;
allow cameraserver video_device:dir r_dir_perms;
allow cameraserver video_device:chr_file rw_file_perms;
allow hal_camera_default gpu_device:dir { open read search };
allow hal_camera_default gpu_device:chr_file { open read write ioctl map getattr };
allow cameraserver gpu_device:dir { open read write search getattr };
allow cameraserver gpu_device:chr_file { open read write ioctl map getattr };

View File

@@ -0,0 +1,10 @@
type hal_drm_clearkey, domain;
type hal_drm_clearkey_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(hal_drm_clearkey)
hal_server_domain(hal_drm_clearkey, hal_drm)
vndbinder_use(hal_drm_clearkey);
allow hal_drm_clearkey hal_allocator_server:fd use;

View File

@@ -0,0 +1,13 @@
type hal_drm_widevine, domain;
type hal_drm_widevine_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(hal_drm_widevine)
hal_server_domain(hal_drm_widevine, hal_drm)
vndbinder_use(hal_drm_widevine);
allow hal_drm_widevine hal_allocator_server:fd use;
allow hal_drm mediacodec:fd use;
hal_client_domain(hal_drm_widevine, hal_graphics_composer);

View File

@@ -0,0 +1 @@
gpu_access(hal_graphics_allocator_default)

View File

@@ -0,0 +1,2 @@
vndbinder_use(hal_graphics_composer_default)
gpu_access(hal_graphics_composer_default)

2
sepolicy/init.te Normal file
View File

@@ -0,0 +1,2 @@
allow init kernel:system module_request;
allow init tmpfs:lnk_file create;

4
sepolicy/kernel.te Normal file
View File

@@ -0,0 +1,4 @@
allow kernel self:capability mknod;
allow kernel self:system module_request;
allow kernel device:dir { create write add_name remove_name rmdir };
allow kernel device:chr_file { create setattr getattr unlink };

1
sepolicy/mediacodec.te Normal file
View File

@@ -0,0 +1 @@
gpu_access(mediacodec)

View File

@@ -0,0 +1 @@
gpu_access(surfaceflinger)

1
sepolicy/mediaserver.te Normal file
View File

@@ -0,0 +1 @@
gpu_access(mediaserver)

2
sepolicy/mediaswcodec.te Normal file
View File

@@ -0,0 +1,2 @@
gpu_access(mediaswcodec)
allow mediaswcodec gpu_device:chr_file { getattr ioctl map open read write };

2
sepolicy/netd.te Normal file
View File

@@ -0,0 +1,2 @@
dontaudit netd self:capability sys_module;
allow netd kernel:system module_request;

1
sepolicy/platform_app.te Normal file
View File

@@ -0,0 +1 @@
gpu_access(platform_app)

1
sepolicy/priv_app.te Normal file
View File

@@ -0,0 +1 @@
gpu_access(priv_app)

1
sepolicy/proc_net.te Normal file
View File

@@ -0,0 +1 @@
allow proc_net proc:filesystem associate;

View File

@@ -0,0 +1 @@
gpu_access(surfaceflinger)

View File

@@ -0,0 +1,6 @@
type suspend_blocker, domain;
type suspend_blocker_exec, exec_type, vendor_file_type, file_type;
init_daemon_domain(suspend_blocker);
wakelock_use(suspend_blocker);

1
sepolicy/system_app.te Normal file
View File

@@ -0,0 +1 @@
gpu_access(system_app)

View File

@@ -0,0 +1,2 @@
gpu_access(system_server)
allow system_server self:capability sys_module;

8
sepolicy/te_macros Normal file
View File

@@ -0,0 +1,8 @@
#####################################
# gpu_access(client_domain)
# Allow client_domain to communicate with the GPU
define(`gpu_access', `
allow $1 gpu_device:dir { open read search getattr };
allow $1 gpu_device:chr_file { open read getattr ioctl map write };
allow $1 sysfs_gpu:file { getattr open read };
')

View File

@@ -0,0 +1 @@
gpu_access(untrusted_app_all)

View File

@@ -0,0 +1,11 @@
// Copyright (C) 2019 The Android Open Source Project
// Copyright (C) 2021-2022 KonstaKANG
//
// SPDX-License-Identifier: Apache-2.0
cc_binary {
name: "suspend_blocker_rpi",
srcs: ["suspend_blocker_rpi.cpp"],
proprietary: true,
shared_libs: ["libpower"],
}

View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2019 The Android Open Source Project
* Copyright (C) 2021-2022 KonstaKANG
*
* SPDX-License-Identifier: Apache-2.0
*/
#include <signal.h>
#include <wakelock/wakelock.h>
int main() {
auto wl = android::wakelock::WakeLock::tryGet("suspend_blocker_rpi"); // RAII object
if (!wl.has_value()) {
return EXIT_FAILURE;
}
sigset_t mask;
sigemptyset(&mask);
return sigsuspend(&mask); // Infinite sleep
}

42
vendor.prop Normal file
View File

@@ -0,0 +1,42 @@
# Audio
persist.audio.pcm.card=0
persist.audio.pcm.device=0
ro.config.media_vol_default=20
ro.config.media_vol_steps=25
# Bluetooth
ro.rfkilldisabled=1
# Camera
media.settings.xml=/vendor/etc/media_profiles_V1_0.xml
ro.hardware.camera=libcamera
# Display
debug.drm.mode.force=1920x1080
# Graphics
ro.hardware.hwcomposer=drm
ro.hardware.vulkan=broadcom
ro.opengles.version=196609
# LMKD
ro.lmk.critical=0
ro.lmk.critical_upgrade=false
ro.lmk.downgrade_pressure=100
ro.lmk.kill_heaviest_task=true
ro.lmk.kill_timeout_ms=100
ro.lmk.log_stats=true
ro.lmk.low=1001
ro.lmk.medium=800
ro.lmk.upgrade_pressure=100
ro.lmk.use_minfree_levels=true
# V4L2
debug.stagefright.c2-poolmask=0xf50000
ro.vendor.v4l2_codec2.decode_concurrent_instances=8
ro.vendor.v4l2_codec2.encode_concurrent_instances=8
# Wifi
wifi.interface=wlan0