411aca7362
Pull in raspberry-vanilla's AOSP17 device tree changes for rpi5 while keeping all PawletOS customizations (A/B partition layout, sepolicy, zram, TWRP recovery scaffolding, ALSA HDMI pre-warm, product/overlay structure) intact on top. Upstream changes absorbed: - AOSP17 audio HAL refactor (StreamAlsa split into StreamAlsaBase/ StreamAlsaMonoPipe, Utils.cpp -> UtilsAlsa.cpp, new Bluetooth/stub helper classes, libeffects AIDL rebuild via *_ndk_shared defaults) - API level 36 -> 37, FCM matrix level 202504 -> 202604 - QuickSettings tile default split (SystemUIRpiOverlay, ported into pawlet_rpi_common where this overlay now lives) - vendor_tracing_descriptors added to enforce-product-packages-exist - misc AOSP17 logging header switch (android-base/logging.h -> Log.h) Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
77 lines
2.9 KiB
C++
77 lines
2.9 KiB
C++
/*
|
|
* Copyright (C) 2023 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.
|
|
*/
|
|
|
|
#define LOG_TAG "AHAL_ModuleAlsa"
|
|
|
|
#include <vector>
|
|
|
|
#include <Log.h>
|
|
|
|
#include "UtilsAlsa.h"
|
|
#include "core-impl/ModuleAlsa.h"
|
|
|
|
extern "C" {
|
|
#include "alsa_device_profile.h"
|
|
}
|
|
|
|
using aidl::android::media::audio::common::AudioChannelLayout;
|
|
using aidl::android::media::audio::common::AudioFormatType;
|
|
using aidl::android::media::audio::common::AudioPort;
|
|
using aidl::android::media::audio::common::AudioProfile;
|
|
|
|
namespace aidl::android::hardware::audio::core {
|
|
|
|
ndk::ScopedAStatus ModuleAlsa::populateConnectedDevicePort(AudioPort* audioPort, int32_t) {
|
|
auto deviceProfile = alsa::getDeviceProfile(*audioPort);
|
|
if (!deviceProfile.has_value()) {
|
|
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_ARGUMENT);
|
|
}
|
|
auto proxy = alsa::readAlsaDeviceInfo(*deviceProfile);
|
|
if (proxy.get() == nullptr) {
|
|
return ndk::ScopedAStatus::fromExceptionCode(EX_ILLEGAL_STATE);
|
|
}
|
|
|
|
alsa_device_profile* profile = proxy.getProfile();
|
|
std::vector<AudioChannelLayout> channels =
|
|
alsa::getChannelMasksFromProfile(profile, isDevicePortSupportAmbisonics(*audioPort));
|
|
std::vector<int> sampleRates = alsa::getSampleRatesFromProfile(profile);
|
|
|
|
for (size_t i = 0; i < std::min(MAX_PROFILE_FORMATS, AUDIO_PORT_MAX_AUDIO_PROFILES) &&
|
|
profile->formats[i] != PCM_FORMAT_INVALID;
|
|
++i) {
|
|
auto audioFormatDescription =
|
|
alsa::c2aidl_pcm_format_AudioFormatDescription(profile->formats[i]);
|
|
if (audioFormatDescription.type == AudioFormatType::DEFAULT) {
|
|
LOG(WARNING) << __func__ << ": unknown pcm type=" << profile->formats[i];
|
|
continue;
|
|
}
|
|
AudioProfile audioProfile = {.format = audioFormatDescription,
|
|
.channelMasks = channels,
|
|
.sampleRates = sampleRates};
|
|
audioPort->profiles.push_back(std::move(audioProfile));
|
|
}
|
|
return ndk::ScopedAStatus::ok();
|
|
}
|
|
|
|
bool ModuleAlsa::isDevicePortSupportAmbisonics(const AudioPort&) {
|
|
// The default implementation always returns 'false'. Vendor implementations
|
|
// may supply logic which is based on the knowledge of SoC capabilities,
|
|
// or based on USB device ID.
|
|
return false;
|
|
}
|
|
|
|
} // namespace aidl::android::hardware::audio::core
|