diff options
| -rw-r--r-- | Android.bp | 1 | ||||
| -rw-r--r-- | tv/input/1.0/Android.bp | 55 | ||||
| -rw-r--r-- | tv/input/1.0/ITvInput.hal | 79 | ||||
| -rw-r--r-- | tv/input/1.0/ITvInputCallback.hal | 27 | ||||
| -rw-r--r-- | tv/input/1.0/default/Android.mk | 44 | ||||
| -rw-r--r-- | tv/input/1.0/default/TvInput.cpp | 226 | ||||
| -rw-r--r-- | tv/input/1.0/default/TvInput.h | 75 | ||||
| -rw-r--r-- | tv/input/1.0/default/android.hardware.tv.input@1.0-service.rc | 4 | ||||
| -rw-r--r-- | tv/input/1.0/default/service.cpp | 31 | ||||
| -rw-r--r-- | tv/input/1.0/types.hal | 125 |
10 files changed, 667 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp index 3c441bb8f..d0278e7c0 100644 --- a/Android.bp +++ b/Android.bp @@ -43,6 +43,7 @@ subdirs = [ "tests/pointer/1.0/default/lib", "thermal/1.0", "thermal/1.0/default", + "tv/input/1.0", "vehicle/2.0", "vibrator/1.0", "vibrator/1.0/default", diff --git a/tv/input/1.0/Android.bp b/tv/input/1.0/Android.bp new file mode 100644 index 000000000..5acb9373b --- /dev/null +++ b/tv/input/1.0/Android.bp @@ -0,0 +1,55 @@ +// This file is autogenerated by hidl-gen. Do not edit manually. + +genrule { + name: "android.hardware.tv.input@1.0_genc++", + tool: "hidl-gen", + cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.tv.input@1.0", + srcs: [ + "types.hal", + "ITvInput.hal", + "ITvInputCallback.hal", + ], + out: [ + "android/hardware/tv/input/1.0/types.cpp", + "android/hardware/tv/input/1.0/TvInputAll.cpp", + "android/hardware/tv/input/1.0/TvInputCallbackAll.cpp", + ], +} + +genrule { + name: "android.hardware.tv.input@1.0_genc++_headers", + tool: "hidl-gen", + cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.tv.input@1.0", + srcs: [ + "types.hal", + "ITvInput.hal", + "ITvInputCallback.hal", + ], + out: [ + "android/hardware/tv/input/1.0/types.h", + "android/hardware/tv/input/1.0/ITvInput.h", + "android/hardware/tv/input/1.0/IHwTvInput.h", + "android/hardware/tv/input/1.0/BnTvInput.h", + "android/hardware/tv/input/1.0/BpTvInput.h", + "android/hardware/tv/input/1.0/BsTvInput.h", + "android/hardware/tv/input/1.0/ITvInputCallback.h", + "android/hardware/tv/input/1.0/IHwTvInputCallback.h", + "android/hardware/tv/input/1.0/BnTvInputCallback.h", + "android/hardware/tv/input/1.0/BpTvInputCallback.h", + "android/hardware/tv/input/1.0/BsTvInputCallback.h", + ], +} + +cc_library_shared { + name: "android.hardware.tv.input@1.0", + generated_sources: ["android.hardware.tv.input@1.0_genc++"], + generated_headers: ["android.hardware.tv.input@1.0_genc++_headers"], + export_generated_headers: ["android.hardware.tv.input@1.0_genc++_headers"], + shared_libs: [ + "libhidl", + "libhwbinder", + "libutils", + "libcutils", + "android.hardware.audio.common@2.0", + ], +} diff --git a/tv/input/1.0/ITvInput.hal b/tv/input/1.0/ITvInput.hal new file mode 100644 index 000000000..43de276f0 --- /dev/null +++ b/tv/input/1.0/ITvInput.hal @@ -0,0 +1,79 @@ +/* + * 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.tv.input@1.0; + +import ITvInputCallback; + +interface ITvInput { + /* + * Sets a callback for events. + * + * Note that initially no device is available in the client side, so the + * implementation must notify all the currently available devices including + * static devices via callback once callback is set. + * + * @param callback Callback object to pass events. + */ + @entry + @exit + @callflow(next={"getStreamConfigurations"}) + setCallback(ITvInputCallback callback); + + /* + * Gets stream configurations for a specific device. + * + * The configs object is valid only until the next + * STREAM_CONFIGURATIONS_CHANGED event. + * + * @param deviceId Device ID for the configurations. + * @return result OK upon success. Otherwise, + * INVALID_ARGUMENTS if the given device ID is not valid. + * @return configurations An array of available configurations. + */ + @callflow(next={"openStream", "getStreamConfigurations", "closeStream"}) + getStreamConfigurations(int32_t deviceId) + generates (Result result, vec<TvStreamConfig> configurations); + + /* + * Opens a specific stream in a device. + * + * @param deviceId Device ID for the steam to open. + * @param streamId Steam ID for the steam to open. Must be one of the + * stream IDs returned from getStreamConfigurations(). + * @return result OK upon success. Otherwise, + * INVALID_ARGUMENTS if any of given IDs are not valid; + * INVALID_STATE if the stream with the given ID is already open; + * NO_RESOURCE if the client must close other streams to open the + * stream. + * @return sidebandStream handle for sideband stream. + */ + @callflow(next={"closeStream", "getStreamConfigurations", "openStream"}) + openStream(int32_t deviceId, int32_t streamId) + generates (Result result, handle sidebandStream); + + /* + * Closes a specific stream in a device. + * + * @param deviceId Device ID for the steam to open. + * @param streamId Steam ID for the steam to open. + * @return result OK upon success. Otherwise, + * INVALID_ARGUMENTS if any of given IDs are not valid; + * INVALID_STATE if the stream with the given ID is not open. + */ + @callflow(next={"getStreamConfigurations", "openStream", "closeStream"}) + closeStream(int32_t deviceId, int32_t streamId) generates (Result result); +}; diff --git a/tv/input/1.0/ITvInputCallback.hal b/tv/input/1.0/ITvInputCallback.hal new file mode 100644 index 000000000..f2f07a039 --- /dev/null +++ b/tv/input/1.0/ITvInputCallback.hal @@ -0,0 +1,27 @@ +/* + * 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.tv.input@1.0; + +interface ITvInputCallback { + /* + * Notifies the client that an event has occured. For possible event types, + * check TvInputEventType. + * + * @param event Event passed to the client. + */ + notify(TvInputEvent event); +}; diff --git a/tv/input/1.0/default/Android.mk b/tv/input/1.0/default/Android.mk new file mode 100644 index 000000000..520b0bf6c --- /dev/null +++ b/tv/input/1.0/default/Android.mk @@ -0,0 +1,44 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) +LOCAL_MODULE := android.hardware.tv.input@1.0-impl +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_SRC_FILES := \ + TvInput.cpp \ + +LOCAL_SHARED_LIBRARIES := \ + libbase \ + liblog \ + libhardware \ + libhidl \ + libhwbinder \ + libutils \ + android.hardware.audio.common@2.0 \ + android.hardware.tv.input@1.0 \ + +include $(BUILD_SHARED_LIBRARY) + +include $(CLEAR_VARS) +LOCAL_MODULE_RELATIVE_PATH := hw +LOCAL_MODULE := android.hardware.tv.input@1.0-service +LOCAL_INIT_RC := android.hardware.tv.input@1.0-service.rc +LOCAL_SRC_FILES := \ + service.cpp \ + +LOCAL_SHARED_LIBRARIES := \ + liblog \ + libcutils \ + libdl \ + libbase \ + libutils \ + libhardware_legacy \ + libhardware \ + +LOCAL_SHARED_LIBRARIES += \ + libhwbinder \ + libhidl \ + android.hardware.audio.common@2.0 \ + android.hardware.tv.input@1.0 \ + +include $(BUILD_EXECUTABLE) + diff --git a/tv/input/1.0/default/TvInput.cpp b/tv/input/1.0/default/TvInput.cpp new file mode 100644 index 000000000..6181ffb81 --- /dev/null +++ b/tv/input/1.0/default/TvInput.cpp @@ -0,0 +1,226 @@ +/* + * 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 "android.hardware.tv.input@1.0-service" +#include <android-base/logging.h> + +#include "TvInput.h" + +const native_handle_t kNullNativeHandle{sizeof(native_handle_t), 0, 0, {}}; + +namespace android { +namespace hardware { +namespace tv { +namespace input { +namespace V1_0 { +namespace implementation { + +static_assert(TV_INPUT_TYPE_OTHER_HARDWARE == static_cast<int>(TvInputType::OTHER), + "TvInputType::OTHER must match legacy value."); +static_assert(TV_INPUT_TYPE_TUNER == static_cast<int>(TvInputType::TUNER), + "TvInputType::TUNER must match legacy value."); +static_assert(TV_INPUT_TYPE_COMPOSITE == static_cast<int>(TvInputType::COMPOSITE), + "TvInputType::COMPOSITE must match legacy value."); +static_assert(TV_INPUT_TYPE_SVIDEO == static_cast<int>(TvInputType::SVIDEO), + "TvInputType::SVIDEO must match legacy value."); +static_assert(TV_INPUT_TYPE_SCART == static_cast<int>(TvInputType::SCART), + "TvInputType::SCART must match legacy value."); +static_assert(TV_INPUT_TYPE_COMPONENT == static_cast<int>(TvInputType::COMPONENT), + "TvInputType::COMPONENT must match legacy value."); +static_assert(TV_INPUT_TYPE_VGA == static_cast<int>(TvInputType::VGA), + "TvInputType::VGA must match legacy value."); +static_assert(TV_INPUT_TYPE_DVI == static_cast<int>(TvInputType::DVI), + "TvInputType::DVI must match legacy value."); +static_assert(TV_INPUT_TYPE_HDMI == static_cast<int>(TvInputType::HDMI), + "TvInputType::HDMI must match legacy value."); +static_assert(TV_INPUT_TYPE_DISPLAY_PORT == static_cast<int>(TvInputType::DISPLAY_PORT), + "TvInputType::DISPLAY_PORT must match legacy value."); + +static_assert(TV_INPUT_EVENT_DEVICE_AVAILABLE == static_cast<int>( + TvInputEventType::DEVICE_AVAILABLE), + "TvInputEventType::DEVICE_AVAILABLE must match legacy value."); +static_assert(TV_INPUT_EVENT_DEVICE_UNAVAILABLE == static_cast<int>( + TvInputEventType::DEVICE_UNAVAILABLE), + "TvInputEventType::DEVICE_UNAVAILABLE must match legacy value."); +static_assert(TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED == static_cast<int>( + TvInputEventType::STREAM_CONFIGURATIONS_CHANGED), + "TvInputEventType::STREAM_CONFIGURATIONS_CHANGED must match legacy value."); + +sp<ITvInputCallback> TvInput::mCallback = nullptr; + +TvInput::TvInput(tv_input_device_t* device) : mDevice(device) { + mCallbackOps.notify = &TvInput::notify; +} + +TvInput::~TvInput() { + if (mDevice != nullptr) { + free(mDevice); + } +} + +// Methods from ::android::hardware::tv_input::V1_0::ITvInput follow. +Return<void> TvInput::setCallback(const sp<ITvInputCallback>& callback) { + mCallback = callback; + if (mCallback != nullptr) { + mDevice->initialize(mDevice, &mCallbackOps, nullptr); + } + return Void(); +} + +Return<void> TvInput::getStreamConfigurations(int32_t deviceId, getStreamConfigurations_cb cb) { + int32_t configCount = 0; + const tv_stream_config_t* configs = nullptr; + int ret = mDevice->get_stream_configurations(mDevice, deviceId, &configCount, &configs); + Result res = Result::UNKNOWN; + hidl_vec<TvStreamConfig> tvStreamConfigs; + if (ret == 0) { + res = Result::OK; + tvStreamConfigs.resize(getSupportedConfigCount(configCount, configs)); + int32_t pos = 0; + for (int32_t i = 0; i < configCount; ++i) { + if (isSupportedStreamType(configs[i].type)) { + tvStreamConfigs[pos].streamId = configs[i].stream_id; + tvStreamConfigs[pos].maxVideoWidth = configs[i].max_video_width; + tvStreamConfigs[pos].maxVideoHeight = configs[i].max_video_height; + ++pos; + } + } + } + cb(res, tvStreamConfigs); + return Void(); +} + +Return<void> TvInput::openStream(int32_t deviceId, int32_t streamId, openStream_cb cb) { + tv_stream_t stream; + stream.stream_id = streamId; + int ret = mDevice->open_stream(mDevice, deviceId, &stream); + Result res = Result::UNKNOWN; + native_handle_t* sidebandStream = nullptr; + if (ret == 0) { + if (isSupportedStreamType(stream.type)) { + res = Result::OK; + sidebandStream = stream.sideband_stream_source_handle; + } + } else { + // TODO(b/30814137) + sidebandStream = const_cast<native_handle_t*>(&kNullNativeHandle); + if (ret == -EBUSY) { + res = Result::NO_RESOURCE; + } else if (ret == -EEXIST) { + res = Result::INVALID_STATE; + } else if (ret == -EINVAL) { + res = Result::INVALID_ARGUMENTS; + } + } + cb(res, sidebandStream); + return Void(); +} + +Return<Result> TvInput::closeStream(int32_t deviceId, int32_t streamId) { + int ret = mDevice->close_stream(mDevice, deviceId, streamId); + Result res = Result::UNKNOWN; + if (ret == 0) { + res = Result::OK; + } else if (ret == -ENOENT) { + res = Result::INVALID_STATE; + } else if (ret == -EINVAL) { + res = Result::INVALID_ARGUMENTS; + } + return res; +} + +// static +void TvInput::notify(struct tv_input_device* __unused, tv_input_event_t* event, + void* __unused) { + if (mCallback != nullptr && event != nullptr) { + // Capturing is no longer supported. + if (event->type >= TV_INPUT_EVENT_CAPTURE_SUCCEEDED) { + return; + } + TvInputEvent tvInputEvent; + tvInputEvent.type = static_cast<TvInputEventType>(event->type); + tvInputEvent.deviceInfo.deviceId = event->device_info.device_id; + tvInputEvent.deviceInfo.type = static_cast<TvInputType>( + event->device_info.type); + tvInputEvent.deviceInfo.portId = event->device_info.hdmi.port_id; + // TODO: Ensure the legacy audio type code is the same once audio HAL default + // implementation is ready. + tvInputEvent.deviceInfo.audioType = static_cast<AudioDevice>( + event->device_info.audio_type); + memset(tvInputEvent.deviceInfo.audioAddress.data(), 0, + tvInputEvent.deviceInfo.audioAddress.size()); + const char* address = event->device_info.audio_address; + if (address != nullptr) { + size_t size = strlen(address); + if (size > tvInputEvent.deviceInfo.audioAddress.size()) { + LOG(ERROR) << "Audio address is too long. Address:" << address << ""; + return; + } + for (size_t i = 0; i < size; ++i) { + tvInputEvent.deviceInfo.audioAddress[i] = + static_cast<uint8_t>(event->device_info.audio_address[i]); + } + } + mCallback->notify(tvInputEvent); + } +} + +// static +uint32_t TvInput::getSupportedConfigCount(uint32_t configCount, + const tv_stream_config_t* configs) { + uint32_t supportedConfigCount = 0; + for (uint32_t i = 0; i < configCount; ++i) { + if (isSupportedStreamType(configs[i].type)) { + supportedConfigCount++; + } + } + return supportedConfigCount; +} + +// static +bool TvInput::isSupportedStreamType(int type) { + // Buffer producer type is no longer supported. + return type != TV_STREAM_TYPE_BUFFER_PRODUCER; +} + +ITvInput* HIDL_FETCH_ITvInput(const char* name) { + int ret = 0; + const hw_module_t* hw_module = nullptr; + tv_input_device_t* input_device; + ret = hw_get_module(TV_INPUT_HARDWARE_MODULE_ID, &hw_module); + if (ret == 0 && hw_module->methods->open != nullptr) { + ret = hw_module->methods->open(hw_module, TV_INPUT_DEFAULT_DEVICE, + reinterpret_cast<hw_device_t**>(&input_device)); + if (ret == 0) { + return new TvInput(input_device); + } + else { + LOG(ERROR) << "Passthrough failed to load legacy HAL."; + return nullptr; + } + } + else { + LOG(ERROR) << "hw_get_module " << name << " failed: " << ret; + return nullptr; + } +} + +} // namespace implementation +} // namespace V1_0 +} // namespace input +} // namespace tv +} // namespace hardware +} // namespace android diff --git a/tv/input/1.0/default/TvInput.h b/tv/input/1.0/default/TvInput.h new file mode 100644 index 000000000..81cbb208f --- /dev/null +++ b/tv/input/1.0/default/TvInput.h @@ -0,0 +1,75 @@ +/* + * 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. + */ +#ifndef HIDL_GENERATED_android_hardware_tv_input_V1_0_TvInput_H_ +#define HIDL_GENERATED_android_hardware_tv_input_V1_0_TvInput_H_ + +#include <android/hardware/tv/input/1.0/ITvInput.h> +#include <hidl/Status.h> +#include <hardware/tv_input.h> + +#include <hidl/MQDescriptor.h> + +namespace android { +namespace hardware { +namespace tv { +namespace input { +namespace V1_0 { +namespace implementation { + +using ::android::hardware::audio::common::V2_0::AudioDevice; +using ::android::hardware::tv::input::V1_0::ITvInput; +using ::android::hardware::tv::input::V1_0::ITvInputCallback; +using ::android::hardware::tv::input::V1_0::Result; +using ::android::hardware::tv::input::V1_0::TvInputEvent; +using ::android::hardware::tv::input::V1_0::TvStreamConfig; +using ::android::hardware::Return; +using ::android::hardware::Void; +using ::android::hardware::hidl_vec; +using ::android::hardware::hidl_string; +using ::android::sp; + +struct TvInput : public ITvInput { + TvInput(tv_input_device_t* device); + ~TvInput(); + Return<void> setCallback(const sp<ITvInputCallback>& callback) override; + Return<void> getStreamConfigurations(int32_t deviceId, + getStreamConfigurations_cb _hidl_cb) override; + Return<void> openStream(int32_t deviceId, int32_t streamId, + openStream_cb _hidl_cb) override; + Return<Result> closeStream(int32_t deviceId, int32_t streamId) override; + + static void notify(struct tv_input_device* __unused, tv_input_event_t* event, + void* __unused); + static uint32_t getSupportedConfigCount(uint32_t configCount, + const tv_stream_config_t* configs); + static bool isSupportedStreamType(int type); + + private: + static sp<ITvInputCallback> mCallback; + tv_input_callback_ops_t mCallbackOps; + tv_input_device_t* mDevice; +}; + +extern "C" ITvInput* HIDL_FETCH_ITvInput(const char* name); + +} // namespace implementation +} // namespace V1_0 +} // namespace input +} // namespace tv +} // namespace hardware +} // namespace android + +#endif // HIDL_GENERATED_android_hardware_tv_input_V1_0_TvInput_H_ diff --git a/tv/input/1.0/default/android.hardware.tv.input@1.0-service.rc b/tv/input/1.0/default/android.hardware.tv.input@1.0-service.rc new file mode 100644 index 000000000..c5bc0b7c8 --- /dev/null +++ b/tv/input/1.0/default/android.hardware.tv.input@1.0-service.rc @@ -0,0 +1,4 @@ +service tv-input-1-0 /system/bin/hw/android.hardware.tv.input@1.0-service + class hal + user system + group system readproc diff --git a/tv/input/1.0/default/service.cpp b/tv/input/1.0/default/service.cpp new file mode 100644 index 000000000..d59c848b4 --- /dev/null +++ b/tv/input/1.0/default/service.cpp @@ -0,0 +1,31 @@ +/* + * 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 "android.hardware.tv_input@1.0-service" + +#include <android/hardware/tv/input/1.0/ITvInput.h> + +#include <hidl/LegacySupport.h> + +using android::sp; + +// Generated HIDL files +using android::hardware::tv::input::V1_0::ITvInput; +using android::hardware::defaultPassthroughServiceImplementation; + +int main() { + return defaultPassthroughServiceImplementation<ITvInput>("tv.input"); +} diff --git a/tv/input/1.0/types.hal b/tv/input/1.0/types.hal new file mode 100644 index 000000000..89a7acc0c --- /dev/null +++ b/tv/input/1.0/types.hal @@ -0,0 +1,125 @@ +/* + * 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.tv.input@1.0; + +import android.hardware.audio.common@2.0; + +enum Result { + OK, + UNKNOWN, + NO_RESOURCE, + INVALID_ARGUMENTS, + INVALID_STATE, +}; + +/* Type of physical TV input. */ +enum TvInputType { + OTHER = 1, // Generic hardware. + TUNER = 2, // Tuner. e.g. built-in terrestrial tuner + COMPOSITE = 3, + SVIDEO = 4, + SCART = 5, + COMPONENT = 6, + VGA = 7, + DVI = 8, + HDMI = 9, // Physical HDMI port. e.g. HDMI 1 + DISPLAY_PORT = 10, +}; + +struct TvInputDeviceInfo { + int32_t deviceId; + TvInputType type; + uint32_t portId; // HDMI port ID number. e.g. 2 for HDMI 2 + AudioDevice audioType; // Audio device type. e.g AudioDevice::IN_HDMI + uint8_t[32] audioAddress; // Audio device address. "" if N/A. If the text + // length is less than 32, the remaining part + // must be filled with 0s. +}; + +enum TvInputEventType { + /* + * Hardware notifies the framework that a device is available. + * + * Note that DEVICE_AVAILABLE and DEVICE_UNAVAILABLE events do not represent + * hotplug events (i.e. plugging cable into or out of the physical port). + * These events notify the framework whether the port is available or not. + * For a concrete example, when a user plugs in or pulls out the HDMI cable + * from a HDMI port, it does not generate DEVICE_AVAILABLE and/or + * DEVICE_UNAVAILABLE events. However, if a user inserts a pluggable USB + * tuner into the Android device, it must generate a DEVICE_AVAILABLE event + * and when the port is removed, it must generate a DEVICE_UNAVAILABLE + * event. + * + * For hotplug events, please see STREAM_CONFIGURATION_CHANGED for more + * details. + * + * HAL implementation must register devices by using this event when the + * device boots up. The framework must recognize device reported via this + * event only. + */ + DEVICE_AVAILABLE = 1, + + /* + * Hardware notifies the framework that a device is unavailable. + * + * HAL implementation must generate this event when a device registered + * by DEVICE_AVAILABLE is no longer available. For example, + * the event can indicate that a USB tuner is plugged out from the Android + * device. + * + * Note that this event is not for indicating cable plugged out of the port; + * for that purpose, the implementation must use + * STREAM_CONFIGURATION_CHANGED event. This event represents the port itself + * being no longer available. + */ + DEVICE_UNAVAILABLE = 2, + + /* + * Stream configurations are changed. Client must regard all open streams + * at the specific device are closed, and must call + * getStreamConfigurations() again, opening some of them if necessary. + * + * HAL implementation must generate this event when the available stream + * configurations change for any reason. A typical use case of this event + * is to notify the framework that the input signal has changed resolution, + * or that the cable is plugged out so that the number of available streams + * is 0. + * + * The implementation must use this event to indicate hotplug status of the + * port. the framework regards input devices with no available streams as + * disconnected, so the implementation can generate this event with no + * available streams to indicate that this device is disconnected, and vice + * versa. + */ + STREAM_CONFIGURATIONS_CHANGED = 3, +}; + +struct TvInputEvent { + TvInputEventType type; + /* + * DEVICE_AVAILABLE: all fields are relevant. + * DEVICE_UNAVAILABLE: only deviceId is relevant. + * STREAM_CONFIGURATIONS_CHANGED: only deviceId is relevant. + */ + TvInputDeviceInfo deviceInfo; +}; + +struct TvStreamConfig { + int32_t streamId; + uint32_t maxVideoWidth; // Max width of the stream. + uint32_t maxVideoHeight; // Max height of the stream. +}; |
