Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit d82c3be1 authored by Eric Laurent's avatar Eric Laurent Committed by Android (Google) Code Review
Browse files

Merge "Revert "Initial implementation of broadcast radio HAL.""

parents 44338473 2c2df013
Loading
Loading
Loading
Loading
+0 −1
Original line number Diff line number Diff line
@@ -66,7 +66,6 @@ LOCAL_SHARED_LIBRARIES := \
    android.hardware.audio.common@2.0 \
    android.hardware.audio.effect@2.0 \
    android.hardware.soundtrigger@2.0 \
    android.hardware.broadcastradio@1.0

ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
LOCAL_MULTILIB := 32
+0 −3
Original line number Diff line number Diff line
@@ -20,7 +20,6 @@
#include <android/hardware/audio/2.0/IDevicesFactory.h>
#include <android/hardware/audio/effect/2.0/IEffectsFactory.h>
#include <android/hardware/soundtrigger/2.0/ISoundTriggerHw.h>
#include <android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h>

using android::hardware::IPCThreadState;
using android::hardware::ProcessState;
@@ -28,12 +27,10 @@ using android::hardware::audio::effect::V2_0::IEffectsFactory;
using android::hardware::audio::V2_0::IDevicesFactory;
using android::hardware::soundtrigger::V2_0::ISoundTriggerHw;
using android::hardware::registerPassthroughServiceImplementation;
using android::hardware::broadcastradio::V1_0::IBroadcastRadioFactory;

int main(int /* argc */, char* /* argv */ []) {
    registerPassthroughServiceImplementation<IDevicesFactory>("audio_devices_factory");
    registerPassthroughServiceImplementation<IEffectsFactory>("audio_effects_factory");
    registerPassthroughServiceImplementation<ISoundTriggerHw>("sound_trigger.primary");
    registerPassthroughServiceImplementation<IBroadcastRadioFactory>("broadcastradio");
    return android::hardware::launchRpcServer(16);
}
+2 −4
Original line number Diff line number Diff line
@@ -72,9 +72,7 @@ interface ITunerCallback {
    /*
     * Method called by the HAL when metadata for current station
     * are updated.
     * @param channel The channel the metadata is associated with.
     * @param subChannel The sub channel the metadata is associated with.
     * @param metadata A list of all updated metada.
     * @param metadatas A list of all updated metada.
     */
    oneway newMetadata(uint32_t channel, uint32_t subChannel, vec<MetaData>  metadata);
    oneway newMetadata(vec<MetaData>  metadatas);
};
 No newline at end of file
+0 −27
Original line number Diff line number Diff line
LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)
LOCAL_MODULE := android.hardware.broadcastradio@1.0-impl
LOCAL_MODULE_RELATIVE_PATH := hw
LOCAL_SRC_FILES := \
    BroadcastRadio.cpp \
    BroadcastRadioFactory.cpp \
    Tuner.cpp \
    Utils.cpp

LOCAL_SHARED_LIBRARIES := \
    libhidl \
    libhwbinder \
    libutils \
    liblog \
    libhardware \
    android.hardware.broadcastradio@1.0 \
    libradio_metadata

ifeq ($(strip $(AUDIOSERVER_MULTILIB)),)
LOCAL_MULTILIB := 32
else
LOCAL_MULTILIB := $(AUDIOSERVER_MULTILIB)
endif

include $(BUILD_SHARED_LIBRARY)
+0 −141
Original line number Diff line number Diff line
/*
 * Copyright (C) 2016 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 "BroadcastRadio"
//#define LOG_NDEBUG 0

#include <utils/Log.h>
#include <hardware/radio.h>

#include "BroadcastRadio.h"
#include "Tuner.h"
#include "Utils.h"

namespace android {
namespace hardware {
namespace broadcastradio {
namespace V1_0 {
namespace implementation {

BroadcastRadio::BroadcastRadio(Class classId)
    : mStatus(Result::NOT_INITIALIZED), mClassId(classId), mHwDevice(NULL)
{
}

BroadcastRadio::~BroadcastRadio()
{
    if (mHwDevice != NULL) {
        radio_hw_device_close(mHwDevice);
    }
}

void BroadcastRadio::onFirstRef()
{
    const hw_module_t *mod;
    int rc;
    ALOGI("%s mClassId %d", __FUNCTION__, mClassId);

    mHwDevice = NULL;
    const char *classString = Utils::getClassString(mClassId);
    if (classString == NULL) {
        ALOGE("invalid class ID %d", mClassId);
        mStatus = Result::INVALID_ARGUMENTS;
        return;
    }

    ALOGI("%s RADIO_HARDWARE_MODULE_ID %s %s",
          __FUNCTION__, RADIO_HARDWARE_MODULE_ID, classString);

    rc = hw_get_module_by_class(RADIO_HARDWARE_MODULE_ID, classString, &mod);
    if (rc != 0) {
        ALOGE("couldn't load radio module %s.%s (%s)",
              RADIO_HARDWARE_MODULE_ID, classString, strerror(-rc));
        return;
    }
    rc = radio_hw_device_open(mod, &mHwDevice);
    if (rc != 0) {
        ALOGE("couldn't open radio hw device in %s.%s (%s)",
              RADIO_HARDWARE_MODULE_ID, "primary", strerror(-rc));
        mHwDevice = NULL;
        return;
    }
    if (mHwDevice->common.version != RADIO_DEVICE_API_VERSION_CURRENT) {
        ALOGE("wrong radio hw device version %04x", mHwDevice->common.version);
        radio_hw_device_close(mHwDevice);
        mHwDevice = NULL;
    } else {
        mStatus = Result::OK;
    }
}

int BroadcastRadio::closeHalTuner(const struct radio_tuner *halTuner)
{
    ALOGV("%s", __FUNCTION__);
    if (mHwDevice == NULL) {
        return -ENODEV;
    }
    if (halTuner == 0) {
        return -EINVAL;
    }
    return mHwDevice->close_tuner(mHwDevice, halTuner);
}


// Methods from ::android::hardware::broadcastradio::V1_0::IBroadcastRadio follow.
Return<void> BroadcastRadio::getProperties(getProperties_cb _hidl_cb)
{
    int rc;
    radio_hal_properties_t halProperties;
    Properties properties;

    if (mHwDevice == NULL) {
        rc = -ENODEV;
        goto exit;
    }
    rc = mHwDevice->get_properties(mHwDevice, &halProperties);
    if (rc == 0) {
        Utils::convertPropertiesFromHal(&properties, &halProperties);
    }

exit:
    _hidl_cb(Utils::convertHalResult(rc), properties);
    return Void();
}

Return<void> BroadcastRadio::openTuner(const BandConfig& config, bool audio,
                                       const sp<ITunerCallback>& callback, openTuner_cb _hidl_cb)
{
    sp<Tuner> tunerImpl = new Tuner(callback, this);

    radio_hal_band_config_t halConfig;
    const struct radio_tuner *halTuner;
    Utils::convertBandConfigToHal(&halConfig, &config);
    int rc = mHwDevice->open_tuner(mHwDevice, &halConfig, audio,
                                   Tuner::callback, tunerImpl.get(),
                                   &halTuner);
    if (rc == 0) {
        tunerImpl->setHalTuner(halTuner);
    }

    _hidl_cb(Utils::convertHalResult(rc), tunerImpl);
    return Void();
}


} // namespace implementation
}  // namespace V1_0
}  // namespace broadcastradio
}  // namespace hardware
}  // namespace android
Loading