initial HAL definition for bradcast radio (e.g FM radio)
Bug: 31973526
Change-Id: Ibdc3f2558104eb56bcb744c431d1213ce3459ed8
diff --git a/Android.bp b/Android.bp
index b475d56..dc22b14 100644
--- a/Android.bp
+++ b/Android.bp
@@ -8,6 +8,7 @@
"biometrics/fingerprint/2.1",
"bluetooth/1.0",
"boot/1.0",
+ "broadcastradio/1.0",
"example/extension/light/2.0",
"gnss/1.0",
"graphics/allocator/2.0",
diff --git a/broadcastradio/1.0/Android.bp b/broadcastradio/1.0/Android.bp
new file mode 100644
index 0000000..44af4aa
--- /dev/null
+++ b/broadcastradio/1.0/Android.bp
@@ -0,0 +1,70 @@
+// This file is autogenerated by hidl-gen. Do not edit manually.
+
+genrule {
+ name: "android.hardware.broadcastradio@1.0_genc++",
+ tool: "hidl-gen",
+ cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.broadcastradio@1.0",
+ srcs: [
+ "types.hal",
+ "IBroadcastRadio.hal",
+ "IBroadcastRadioFactory.hal",
+ "ITuner.hal",
+ "ITunerCallback.hal",
+ ],
+ out: [
+ "android/hardware/broadcastradio/1.0/types.cpp",
+ "android/hardware/broadcastradio/1.0/BroadcastRadioAll.cpp",
+ "android/hardware/broadcastradio/1.0/BroadcastRadioFactoryAll.cpp",
+ "android/hardware/broadcastradio/1.0/TunerAll.cpp",
+ "android/hardware/broadcastradio/1.0/TunerCallbackAll.cpp",
+ ],
+}
+
+genrule {
+ name: "android.hardware.broadcastradio@1.0_genc++_headers",
+ tool: "hidl-gen",
+ cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.broadcastradio@1.0",
+ srcs: [
+ "types.hal",
+ "IBroadcastRadio.hal",
+ "IBroadcastRadioFactory.hal",
+ "ITuner.hal",
+ "ITunerCallback.hal",
+ ],
+ out: [
+ "android/hardware/broadcastradio/1.0/types.h",
+ "android/hardware/broadcastradio/1.0/IBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/IHwBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/BnBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/BpBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/BsBroadcastRadio.h",
+ "android/hardware/broadcastradio/1.0/IBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/IHwBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/BnBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/BpBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/BsBroadcastRadioFactory.h",
+ "android/hardware/broadcastradio/1.0/ITuner.h",
+ "android/hardware/broadcastradio/1.0/IHwTuner.h",
+ "android/hardware/broadcastradio/1.0/BnTuner.h",
+ "android/hardware/broadcastradio/1.0/BpTuner.h",
+ "android/hardware/broadcastradio/1.0/BsTuner.h",
+ "android/hardware/broadcastradio/1.0/ITunerCallback.h",
+ "android/hardware/broadcastradio/1.0/IHwTunerCallback.h",
+ "android/hardware/broadcastradio/1.0/BnTunerCallback.h",
+ "android/hardware/broadcastradio/1.0/BpTunerCallback.h",
+ "android/hardware/broadcastradio/1.0/BsTunerCallback.h",
+ ],
+}
+
+cc_library_shared {
+ name: "android.hardware.broadcastradio@1.0",
+ generated_sources: ["android.hardware.broadcastradio@1.0_genc++"],
+ generated_headers: ["android.hardware.broadcastradio@1.0_genc++_headers"],
+ export_generated_headers: ["android.hardware.broadcastradio@1.0_genc++_headers"],
+ shared_libs: [
+ "libhidl",
+ "libhwbinder",
+ "libutils",
+ "libcutils",
+ ],
+}
diff --git a/broadcastradio/1.0/IBroadcastRadio.hal b/broadcastradio/1.0/IBroadcastRadio.hal
new file mode 100644
index 0000000..c7fe62d
--- /dev/null
+++ b/broadcastradio/1.0/IBroadcastRadio.hal
@@ -0,0 +1,51 @@
+/*
+ * 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.
+ */
+
+package android.hardware.broadcastradio@1.0;
+
+import ITunerCallback;
+import ITuner;
+
+interface IBroadcastRadio {
+
+ /*
+ * Retrieve implementation properties.
+ * @return result Operation completion status: OK in case of success,
+ * NOT_INITIALIZED in case of initialization error.
+ * @return properties A Properties structure containing implementation
+ * description and capabilities.
+ */
+ getProperties() generates (Result result, Properties properties);
+
+ /*
+ * Open a tuner interface for the requested configuration.
+ * If no other tuner is opened, this will power on the radio hardware.
+ * The hardware must be powered down when all tuner interface are released.
+ * @param config A BandConfig struct containing the band configuration to apply
+ * @param audio True if this tuner must be used for live radio listening and
+ * should be connected to the radio audio source.
+ * @param callback the callback interface
+ * @return result Operation completion status: OK in case of success,
+ * INVALID_ARGUMENTS if configuration requested is invalid,
+ * INVALID_STATE if called out of sequence
+ * @return tuner The interface to control the tuner
+ *
+ * Callback ITunerCallback.ConfigChanged MUST be called once the
+ * configuration is applied or a failure occurs or after a time out.
+ */
+ openTuner(BandConfig config, bool audio, ITunerCallback callback)
+ generates (Result result, ITuner tuner);
+};
diff --git a/broadcastradio/1.0/IBroadcastRadioFactory.hal b/broadcastradio/1.0/IBroadcastRadioFactory.hal
new file mode 100644
index 0000000..82a97c4
--- /dev/null
+++ b/broadcastradio/1.0/IBroadcastRadioFactory.hal
@@ -0,0 +1,36 @@
+/*
+ * 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.
+ */
+
+package android.hardware.broadcastradio@1.0;
+
+import IBroadcastRadio;
+
+interface IBroadcastRadioFactory {
+
+ /*
+ * Connects to a broadcast radio HAL module for a given class
+ * (AM/FM, Satellite, DAB).
+ *
+ * @param classId Class of the module to connect to .
+ * @return retval operation completion status. Returns INVALID_ARGUMENTS
+ * if there is no corresponding hardware module found,
+ * NOT_INITIALIZED if an error occurred while opening the hardware
+ * module.
+ * @return result the interface for the created module.
+ */
+ connectModule(Class classId)
+ generates (Result retval, IBroadcastRadio result);
+};
diff --git a/broadcastradio/1.0/ITuner.hal b/broadcastradio/1.0/ITuner.hal
new file mode 100644
index 0000000..5e2bffe
--- /dev/null
+++ b/broadcastradio/1.0/ITuner.hal
@@ -0,0 +1,113 @@
+/*
+ * 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.
+ */
+
+package android.hardware.broadcastradio@1.0;
+
+import ITunerCallback;
+
+interface ITuner {
+
+ /*
+ * Apply current radio band configuration (band, range, channel spacing...).
+ * Automatically cancels pending scan, step or tune.
+ * ITunerCallback.configChange() method MUST be called once the
+ * configuration is applied or a failure occurs or after a time out.
+ * @param config The band configuration to apply.
+ * @return result OK if configuration could be applied
+ * NOT_INITIALIZED in case of initialization error.
+ * INVALID_ARGUMENTS if configuration requested is invalid
+ *
+ */
+ setConfiguration(BandConfig config) generates(Result result);
+
+ /*
+ * Retrieve current radio band configuration.
+ * @return result OK if valid configuration is returned,
+ * NOT_INITIALIZED in case of initialization error.
+ * @param config Current band configuration
+ */
+ getConfiguration() generates(Result result, BandConfig config);
+
+ /*
+ * Start scanning up to next valid station.
+ * Shall be called only when a valid configuration has been applied.
+ * Automatically cancels pending scan, step or tune.
+ * ITunerCallback.tuneComplete() MUST be called once locked on a station
+ * or after a time out or full band scan if no station found.
+ * The status should indicate if a valid station is tuned or not.
+ * @param direction UP or DOWN.
+ * @param skipSubChannel valid for HD radio or digital radios only:
+ * ignore sub channels (e.g SPS for HD radio).
+ * @return result OK if scan successfully started
+ * INVALID_STATE if called out of sequence
+ * NOT_INITIALIZED if another error occurs
+ */
+ scan(Direction direction, bool skipSubChannel) generates(Result result);
+
+ /*
+ * Move one channel spacing up or down.
+ * Must be called when a valid configuration has been applied.
+ * Automatically cancels pending scan, step or tune.
+ * ITunerCallback.tuneComplete() MUST be called once locked on a station
+ * or after a time out or full band scan if no station found.
+ * The status should indicate if a valid station is tuned or not.
+ * @param direction UP or DOWN.
+ * @param skipSubChannel valid for HD radio or digital radios only:
+ * ignore sub channels (e.g SPS for HD radio).
+ * @return result OK if scan successfully started
+ * INVALID_STATE if called out of sequence
+ * NOT_INITIALIZED if another error occurs
+ */
+ step(Direction direction, bool skipSubChannel) generates(Result result);
+
+ /*
+ * Tune to specified channel.
+ * Must be called when a valid configuration has been applied.
+ * Automatically cancels pending scan, step or tune.
+ * ITunerCallback.tuneComplete() MUST be called once locked on a station
+ * or after a time out or full band scan if no station found.
+ * The status should indicate if a valid station is tuned or not.
+ * @param channel Channel to tune to. A frequency in kHz for AM/FM/HD Radio
+ * bands.
+ * @param subChannel Valid for HD radio or digital radios only
+ * (e.g SPS number for HD radio)..
+ * @return result OK if scan successfully started
+ * INVALID_ARGUMENTS if invalid arguments are passed
+ * INVALID_STATE if called out of sequence
+ * NOT_INITIALIZED if another error occurs
+ */
+ tune(uint32_t channel, uint32_t subChannel) generates(Result result);
+
+ /*
+ * Cancel a scan, step or tune operation.
+ * Shall be called only while a scan, step or tune operation is pending.
+ * ITunerCallback.tuneComplete() MUST NOT be sent by the HAL.
+ * @return result OK if scan successfully started
+ * INVALID_STATE if called out of sequence
+ * NOT_INITIALIZED if another error occurs
+ */
+ cancel() generates(Result result);
+
+ /*
+ * Retrieve current station information.
+ * @param withMetadata True if Metadata should be returned, false otherwise.
+ * @return result OK if scan successfully started
+ * NOT_INITIALIZED if another error occurs
+ * @return info Current program information.
+ */
+ getProgramInformation(bool withMetadata)
+ generates(Result result, ProgramInfo info);
+};
diff --git a/broadcastradio/1.0/ITunerCallback.hal b/broadcastradio/1.0/ITunerCallback.hal
new file mode 100644
index 0000000..f805472
--- /dev/null
+++ b/broadcastradio/1.0/ITunerCallback.hal
@@ -0,0 +1,78 @@
+/*
+ * 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.
+ */
+
+package android.hardware.broadcastradio@1.0;
+
+
+interface ITunerCallback {
+
+ /*
+ * Method called by the HAL when a HW failure occurs.
+ * The framework MUST close the ITuner interface and open a new one.
+ */
+ oneway hardwareFailure();
+
+ /*
+ * Method called by the HAL when a new configuration is applied
+ * in response to IDevice.openTuner() or ITuner.setConfiguration().
+ * @param result OK if the configuration has been applied,
+ * INVALID_ARGUMENTS if not or TIMEOUT in case of time out.
+ * @param config A BandConfig structure describing the new configuration
+ * applied.
+ */
+ oneway configChange(Result result, BandConfig config);
+
+ /*
+ * Method called by the HAL when a tuning operation completes
+ * following a step(), scan() or tune() command.
+ * @param result OK if tune succeeded or TIMEOUT in case of time out.
+ * @param info A ProgramInfo structure describing the tuned station.
+ */
+ oneway tuneComplete(Result result, ProgramInfo info);
+
+ /*
+ * Method called by the HAL when a frequency switch occurs.
+ * @param info A ProgramInfo structure describing the new tuned station.
+ */
+ oneway afSwitch(ProgramInfo info);
+
+ /*
+ * Method called by the HAL when the antenna connection state changes.
+ * @param connected True if the antenna is connected, false otherwise.
+ */
+ oneway antennaStateChange(bool connected);
+
+ /*
+ * Method called by the HAL when a traffic announcement starts or
+ * stops.
+ * @param active True if the announcement starts, false if it stops.
+ */
+ oneway trafficAnnouncement(bool active);
+
+ /*
+ * Method called by the HAL when an emergency announcement starts
+ * or stops.
+ * @param active True if the announcement starts, false if it stops.
+ */
+ oneway emergencyAnnouncement(bool active);
+
+ /*
+ * Method called by the HAL when metadata for current station
+ * are updated.
+ * @param metadatas A list of all updated metada.
+ */
+ oneway newMetadata(vec<MetaData> metadatas);
+};
\ No newline at end of file
diff --git a/broadcastradio/1.0/types.hal b/broadcastradio/1.0/types.hal
new file mode 100644
index 0000000..c5b4411
--- /dev/null
+++ b/broadcastradio/1.0/types.hal
@@ -0,0 +1,216 @@
+/*
+ * Copyright 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.
+ */
+
+package android.hardware.broadcastradio@1.0;
+
+enum Result {
+ OK,
+ NOT_INITIALIZED,
+ INVALID_ARGUMENTS,
+ INVALID_STATE,
+ TIMEOUT,
+};
+
+/*
+ * Radio hardware module class. A given radio hardware module HAL is of one
+ * class only. The platform can not have more than one hardware module of
+ * each class. Current version of the framework only supports RADIO_CLASS_AM_FM.
+ */
+enum Class : uint32_t {
+ /* FM (including HD radio) and AM */
+ AM_FM = 0,
+ /* Satellite Radio */
+ SAT = 1,
+ /* Digital Radio (DAB) */
+ DT = 2,
+};
+
+/* value for field "type" of radio band described in struct radio_hal_band_config */
+enum Band : uint32_t {
+ /* Amplitude Modulation band: LW, MW, SW */
+ AM = 0,
+ /* Frequency Modulation band: FM */
+ FM = 1,
+ /* FM HD Radio / DRM (IBOC) */
+ FM_HD = 2,
+ /* AM HD Radio / DRM (IBOC) */
+ AM_HD = 3,
+};
+
+/* RDS variant implemented. A struct FmBandConfig can list none or several. */
+enum Rds : uint32_t {
+ NONE = 0,
+ WORLD = (1<<0),
+ RDS_US = (1<<1),
+};
+
+
+/* FM deemphasis variant implemented.
+ * A struct FmBandConfig can list one or more. */
+enum Deemphasis : uint32_t {
+ D50 = (1<<0),
+ D75 = (1<<1),
+};
+
+/* Scanning direction for scan() and step() tuner APIs */
+enum Direction : uint32_t {
+ UP,
+ DOWN
+};
+
+/* Unique handle allocated to a radio module */
+typedef uint32_t Handle;
+
+
+/* Additional attributes for an FM band configuration */
+struct FmBandConfig {
+ /* deemphasis variant */
+ Deemphasis deemphasis;
+ /* stereo supported */
+ bool stereo;
+ /* RDS variants supported */
+ Rds rds;
+ /* Traffic Announcement supported */
+ bool ta;
+ /* Alternate Frequency supported */
+ bool af;
+ /* Emergency announcements supported */
+ bool ea;
+};
+
+/* Additional attributes for an AM band configuration */
+struct AmBandConfig {
+ /* Stereo supported */
+ bool stereo;
+};
+
+/* Radio band configuration. Describes a given band supported by the radio
+ * module. The HAL can expose only one band per type with the the maximum range
+ * supported and all options. The framework will derive the actual regions were
+ * this module can operate and expose separate band configurations for
+ * applications to chose from. */
+struct BandConfig {
+ Band type;
+ bool antennaConnected;
+ uint32_t lowerLimit;
+ uint32_t upperLimit;
+ vec<uint32_t> spacings;
+ union Ext {
+ FmBandConfig fm;
+ AmBandConfig am;
+ };
+};
+
+/* Exposes properties of a given hardware radio module.
+ * NOTE: current framework implementation supports only one audio source
+ * (num_audio_sources = 1). The source corresponds to AUDIO_DEVICE_IN_FM_TUNER.
+ * If more than one tuner is supported (num_tuners > 1), only one can be
+ * connected to the audio source. */
+struct Properties {
+ /* Class of this module. E.g AM_FM */
+ Class classId;
+ /* implementor name */
+ string implementor;
+ /* product name */
+ string product;
+ /* product version */
+ string version;
+ /* serial number (for subscription services) */
+ string serial;
+ /* number of tuners controllable independently */
+ uint32_t numTuners;
+ /* number of audio sources driven simultaneously */
+ uint32_t numAudioSources;
+ /* the hardware supports capture of audio source from audio HAL */
+ bool supportsCapture;
+ vec<BandConfig> bands; /* band descriptors */
+};
+
+enum MetadataType {
+ INVALID = -1,
+ /* Signed 32 bit integer */
+ INT = 0,
+ /* String */
+ TEXT = 1,
+ /* Raw binary data (icon or art)
+ This data must be transparent to the android framework */
+ RAW = 2,
+ /* clock data, see MetaDataClock */
+ CLOCK = 3,
+};
+
+enum MetadataKey {
+ INVALID = -1,
+ /* RDS PI - string */
+ RDS_PI = 0,
+ /* RDS PS - string */
+ RDS_PS = 1,
+ /* RDS PTY - int32_t */
+ RDS_PTY = 2,
+ /* RBDS PTY - int32_t */
+ RBDS_PTY = 3,
+ /* RDS RT - string */
+ RDS_RT = 4,
+ /* Song title - string */
+ TITLE = 5,
+ /* Artist name - string */
+ ARTIST = 6,
+ /* Album name - string */
+ ALBUM = 7,
+ /* Musical genre - string */
+ GENRE = 8,
+ /* Station icon - raw */
+ ICON = 9,
+ /* Album art - raw */
+ ART = 10,
+ /* Clock - MetaDataClock */
+ CLOCK = 11,
+};
+
+struct MetaDataClock {
+ /* Seconds since epoch at GMT + 0. */
+ uint64_t utcSecondsSinceEpoch;
+ /* Minutes offset from the GMT. */
+ int32_t timezoneOffsetInMinutes;
+};
+
+struct MetaData {
+ MetadataType type;
+ MetadataKey key;
+ /* Value used for type MetadataType.INT */
+ int32_t intValue;
+ /* Value used for type MetadataType.CLOCK */
+ MetaDataClock clockValue;
+ /* Value used for type MetadataType.TEXT */
+ string stringValue;
+ /* Value used for type MetadataType.RAW */
+ vec<uint8_t> rawValue;
+};
+
+
+/* Radio program information. Returned by the HAL with event RADIO_EVENT_TUNED.
+ * Contains information on currently tuned channel.
+ */
+struct ProgramInfo {
+ uint32_t channel; /* current channel. (e.g kHz for band type AM_FM) */
+ uint32_t subChannel; /* current sub channel. (FM_HD) */
+ bool tuned; /* tuned to a program or not */
+ bool stereo; /* program is stereo or not */
+ bool digital; /* digital program or not (e.g HD Radio program) */
+ uint32_t signalStrength; /* signal strength from 0 to 100 */
+ vec<MetaData> metadata; /* non empty if meta data are present (e.g PTY, song title ...) */
+};
+