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
@@ -44,6 +44,7 @@ subdirs = [ | |||
44 | "tests/pointer/1.0/default/lib", | 44 | "tests/pointer/1.0/default/lib", |
45 | "thermal/1.0", | 45 | "thermal/1.0", |
46 | "thermal/1.0/default", | 46 | "thermal/1.0/default", |
47 | "tv/input/1.0", | ||
47 | "vehicle/2.0", | 48 | "vehicle/2.0", |
48 | "vibrator/1.0", | 49 | "vibrator/1.0", |
49 | "vibrator/1.0/default", | 50 | "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 00000000..5acb9373 --- /dev/null +++ b/tv/input/1.0/Android.bp | |||
@@ -0,0 +1,55 @@ | |||
1 | // This file is autogenerated by hidl-gen. Do not edit manually. | ||
2 | |||
3 | genrule { | ||
4 | name: "android.hardware.tv.input@1.0_genc++", | ||
5 | tool: "hidl-gen", | ||
6 | cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.tv.input@1.0", | ||
7 | srcs: [ | ||
8 | "types.hal", | ||
9 | "ITvInput.hal", | ||
10 | "ITvInputCallback.hal", | ||
11 | ], | ||
12 | out: [ | ||
13 | "android/hardware/tv/input/1.0/types.cpp", | ||
14 | "android/hardware/tv/input/1.0/TvInputAll.cpp", | ||
15 | "android/hardware/tv/input/1.0/TvInputCallbackAll.cpp", | ||
16 | ], | ||
17 | } | ||
18 | |||
19 | genrule { | ||
20 | name: "android.hardware.tv.input@1.0_genc++_headers", | ||
21 | tool: "hidl-gen", | ||
22 | cmd: "$tool -o $genDir -Lc++ -randroid.hardware:hardware/interfaces android.hardware.tv.input@1.0", | ||
23 | srcs: [ | ||
24 | "types.hal", | ||
25 | "ITvInput.hal", | ||
26 | "ITvInputCallback.hal", | ||
27 | ], | ||
28 | out: [ | ||
29 | "android/hardware/tv/input/1.0/types.h", | ||
30 | "android/hardware/tv/input/1.0/ITvInput.h", | ||
31 | "android/hardware/tv/input/1.0/IHwTvInput.h", | ||
32 | "android/hardware/tv/input/1.0/BnTvInput.h", | ||
33 | "android/hardware/tv/input/1.0/BpTvInput.h", | ||
34 | "android/hardware/tv/input/1.0/BsTvInput.h", | ||
35 | "android/hardware/tv/input/1.0/ITvInputCallback.h", | ||
36 | "android/hardware/tv/input/1.0/IHwTvInputCallback.h", | ||
37 | "android/hardware/tv/input/1.0/BnTvInputCallback.h", | ||
38 | "android/hardware/tv/input/1.0/BpTvInputCallback.h", | ||
39 | "android/hardware/tv/input/1.0/BsTvInputCallback.h", | ||
40 | ], | ||
41 | } | ||
42 | |||
43 | cc_library_shared { | ||
44 | name: "android.hardware.tv.input@1.0", | ||
45 | generated_sources: ["android.hardware.tv.input@1.0_genc++"], | ||
46 | generated_headers: ["android.hardware.tv.input@1.0_genc++_headers"], | ||
47 | export_generated_headers: ["android.hardware.tv.input@1.0_genc++_headers"], | ||
48 | shared_libs: [ | ||
49 | "libhidl", | ||
50 | "libhwbinder", | ||
51 | "libutils", | ||
52 | "libcutils", | ||
53 | "android.hardware.audio.common@2.0", | ||
54 | ], | ||
55 | } | ||
diff --git a/tv/input/1.0/ITvInput.hal b/tv/input/1.0/ITvInput.hal new file mode 100644 index 00000000..43de276f --- /dev/null +++ b/tv/input/1.0/ITvInput.hal | |||
@@ -0,0 +1,79 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | package android.hardware.tv.input@1.0; | ||
18 | |||
19 | import ITvInputCallback; | ||
20 | |||
21 | interface ITvInput { | ||
22 | /* | ||
23 | * Sets a callback for events. | ||
24 | * | ||
25 | * Note that initially no device is available in the client side, so the | ||
26 | * implementation must notify all the currently available devices including | ||
27 | * static devices via callback once callback is set. | ||
28 | * | ||
29 | * @param callback Callback object to pass events. | ||
30 | */ | ||
31 | @entry | ||
32 | @exit | ||
33 | @callflow(next={"getStreamConfigurations"}) | ||
34 | setCallback(ITvInputCallback callback); | ||
35 | |||
36 | /* | ||
37 | * Gets stream configurations for a specific device. | ||
38 | * | ||
39 | * The configs object is valid only until the next | ||
40 | * STREAM_CONFIGURATIONS_CHANGED event. | ||
41 | * | ||
42 | * @param deviceId Device ID for the configurations. | ||
43 | * @return result OK upon success. Otherwise, | ||
44 | * INVALID_ARGUMENTS if the given device ID is not valid. | ||
45 | * @return configurations An array of available configurations. | ||
46 | */ | ||
47 | @callflow(next={"openStream", "getStreamConfigurations", "closeStream"}) | ||
48 | getStreamConfigurations(int32_t deviceId) | ||
49 | generates (Result result, vec<TvStreamConfig> configurations); | ||
50 | |||
51 | /* | ||
52 | * Opens a specific stream in a device. | ||
53 | * | ||
54 | * @param deviceId Device ID for the steam to open. | ||
55 | * @param streamId Steam ID for the steam to open. Must be one of the | ||
56 | * stream IDs returned from getStreamConfigurations(). | ||
57 | * @return result OK upon success. Otherwise, | ||
58 | * INVALID_ARGUMENTS if any of given IDs are not valid; | ||
59 | * INVALID_STATE if the stream with the given ID is already open; | ||
60 | * NO_RESOURCE if the client must close other streams to open the | ||
61 | * stream. | ||
62 | * @return sidebandStream handle for sideband stream. | ||
63 | */ | ||
64 | @callflow(next={"closeStream", "getStreamConfigurations", "openStream"}) | ||
65 | openStream(int32_t deviceId, int32_t streamId) | ||
66 | generates (Result result, handle sidebandStream); | ||
67 | |||
68 | /* | ||
69 | * Closes a specific stream in a device. | ||
70 | * | ||
71 | * @param deviceId Device ID for the steam to open. | ||
72 | * @param streamId Steam ID for the steam to open. | ||
73 | * @return result OK upon success. Otherwise, | ||
74 | * INVALID_ARGUMENTS if any of given IDs are not valid; | ||
75 | * INVALID_STATE if the stream with the given ID is not open. | ||
76 | */ | ||
77 | @callflow(next={"getStreamConfigurations", "openStream", "closeStream"}) | ||
78 | closeStream(int32_t deviceId, int32_t streamId) generates (Result result); | ||
79 | }; | ||
diff --git a/tv/input/1.0/ITvInputCallback.hal b/tv/input/1.0/ITvInputCallback.hal new file mode 100644 index 00000000..f2f07a03 --- /dev/null +++ b/tv/input/1.0/ITvInputCallback.hal | |||
@@ -0,0 +1,27 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | package android.hardware.tv.input@1.0; | ||
18 | |||
19 | interface ITvInputCallback { | ||
20 | /* | ||
21 | * Notifies the client that an event has occured. For possible event types, | ||
22 | * check TvInputEventType. | ||
23 | * | ||
24 | * @param event Event passed to the client. | ||
25 | */ | ||
26 | notify(TvInputEvent event); | ||
27 | }; | ||
diff --git a/tv/input/1.0/default/Android.mk b/tv/input/1.0/default/Android.mk new file mode 100644 index 00000000..520b0bf6 --- /dev/null +++ b/tv/input/1.0/default/Android.mk | |||
@@ -0,0 +1,44 @@ | |||
1 | LOCAL_PATH := $(call my-dir) | ||
2 | |||
3 | include $(CLEAR_VARS) | ||
4 | LOCAL_MODULE := android.hardware.tv.input@1.0-impl | ||
5 | LOCAL_MODULE_RELATIVE_PATH := hw | ||
6 | LOCAL_SRC_FILES := \ | ||
7 | TvInput.cpp \ | ||
8 | |||
9 | LOCAL_SHARED_LIBRARIES := \ | ||
10 | libbase \ | ||
11 | liblog \ | ||
12 | libhardware \ | ||
13 | libhidl \ | ||
14 | libhwbinder \ | ||
15 | libutils \ | ||
16 | android.hardware.audio.common@2.0 \ | ||
17 | android.hardware.tv.input@1.0 \ | ||
18 | |||
19 | include $(BUILD_SHARED_LIBRARY) | ||
20 | |||
21 | include $(CLEAR_VARS) | ||
22 | LOCAL_MODULE_RELATIVE_PATH := hw | ||
23 | LOCAL_MODULE := android.hardware.tv.input@1.0-service | ||
24 | LOCAL_INIT_RC := android.hardware.tv.input@1.0-service.rc | ||
25 | LOCAL_SRC_FILES := \ | ||
26 | service.cpp \ | ||
27 | |||
28 | LOCAL_SHARED_LIBRARIES := \ | ||
29 | liblog \ | ||
30 | libcutils \ | ||
31 | libdl \ | ||
32 | libbase \ | ||
33 | libutils \ | ||
34 | libhardware_legacy \ | ||
35 | libhardware \ | ||
36 | |||
37 | LOCAL_SHARED_LIBRARIES += \ | ||
38 | libhwbinder \ | ||
39 | libhidl \ | ||
40 | android.hardware.audio.common@2.0 \ | ||
41 | android.hardware.tv.input@1.0 \ | ||
42 | |||
43 | include $(BUILD_EXECUTABLE) | ||
44 | |||
diff --git a/tv/input/1.0/default/TvInput.cpp b/tv/input/1.0/default/TvInput.cpp new file mode 100644 index 00000000..6181ffb8 --- /dev/null +++ b/tv/input/1.0/default/TvInput.cpp | |||
@@ -0,0 +1,226 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "android.hardware.tv.input@1.0-service" | ||
18 | #include <android-base/logging.h> | ||
19 | |||
20 | #include "TvInput.h" | ||
21 | |||
22 | const native_handle_t kNullNativeHandle{sizeof(native_handle_t), 0, 0, {}}; | ||
23 | |||
24 | namespace android { | ||
25 | namespace hardware { | ||
26 | namespace tv { | ||
27 | namespace input { | ||
28 | namespace V1_0 { | ||
29 | namespace implementation { | ||
30 | |||
31 | static_assert(TV_INPUT_TYPE_OTHER_HARDWARE == static_cast<int>(TvInputType::OTHER), | ||
32 | "TvInputType::OTHER must match legacy value."); | ||
33 | static_assert(TV_INPUT_TYPE_TUNER == static_cast<int>(TvInputType::TUNER), | ||
34 | "TvInputType::TUNER must match legacy value."); | ||
35 | static_assert(TV_INPUT_TYPE_COMPOSITE == static_cast<int>(TvInputType::COMPOSITE), | ||
36 | "TvInputType::COMPOSITE must match legacy value."); | ||
37 | static_assert(TV_INPUT_TYPE_SVIDEO == static_cast<int>(TvInputType::SVIDEO), | ||
38 | "TvInputType::SVIDEO must match legacy value."); | ||
39 | static_assert(TV_INPUT_TYPE_SCART == static_cast<int>(TvInputType::SCART), | ||
40 | "TvInputType::SCART must match legacy value."); | ||
41 | static_assert(TV_INPUT_TYPE_COMPONENT == static_cast<int>(TvInputType::COMPONENT), | ||
42 | "TvInputType::COMPONENT must match legacy value."); | ||
43 | static_assert(TV_INPUT_TYPE_VGA == static_cast<int>(TvInputType::VGA), | ||
44 | "TvInputType::VGA must match legacy value."); | ||
45 | static_assert(TV_INPUT_TYPE_DVI == static_cast<int>(TvInputType::DVI), | ||
46 | "TvInputType::DVI must match legacy value."); | ||
47 | static_assert(TV_INPUT_TYPE_HDMI == static_cast<int>(TvInputType::HDMI), | ||
48 | "TvInputType::HDMI must match legacy value."); | ||
49 | static_assert(TV_INPUT_TYPE_DISPLAY_PORT == static_cast<int>(TvInputType::DISPLAY_PORT), | ||
50 | "TvInputType::DISPLAY_PORT must match legacy value."); | ||
51 | |||
52 | static_assert(TV_INPUT_EVENT_DEVICE_AVAILABLE == static_cast<int>( | ||
53 | TvInputEventType::DEVICE_AVAILABLE), | ||
54 | "TvInputEventType::DEVICE_AVAILABLE must match legacy value."); | ||
55 | static_assert(TV_INPUT_EVENT_DEVICE_UNAVAILABLE == static_cast<int>( | ||
56 | TvInputEventType::DEVICE_UNAVAILABLE), | ||
57 | "TvInputEventType::DEVICE_UNAVAILABLE must match legacy value."); | ||
58 | static_assert(TV_INPUT_EVENT_STREAM_CONFIGURATIONS_CHANGED == static_cast<int>( | ||
59 | TvInputEventType::STREAM_CONFIGURATIONS_CHANGED), | ||
60 | "TvInputEventType::STREAM_CONFIGURATIONS_CHANGED must match legacy value."); | ||
61 | |||
62 | sp<ITvInputCallback> TvInput::mCallback = nullptr; | ||
63 | |||
64 | TvInput::TvInput(tv_input_device_t* device) : mDevice(device) { | ||
65 | mCallbackOps.notify = &TvInput::notify; | ||
66 | } | ||
67 | |||
68 | TvInput::~TvInput() { | ||
69 | if (mDevice != nullptr) { | ||
70 | free(mDevice); | ||
71 | } | ||
72 | } | ||
73 | |||
74 | // Methods from ::android::hardware::tv_input::V1_0::ITvInput follow. | ||
75 | Return<void> TvInput::setCallback(const sp<ITvInputCallback>& callback) { | ||
76 | mCallback = callback; | ||
77 | if (mCallback != nullptr) { | ||
78 | mDevice->initialize(mDevice, &mCallbackOps, nullptr); | ||
79 | } | ||
80 | return Void(); | ||
81 | } | ||
82 | |||
83 | Return<void> TvInput::getStreamConfigurations(int32_t deviceId, getStreamConfigurations_cb cb) { | ||
84 | int32_t configCount = 0; | ||
85 | const tv_stream_config_t* configs = nullptr; | ||
86 | int ret = mDevice->get_stream_configurations(mDevice, deviceId, &configCount, &configs); | ||
87 | Result res = Result::UNKNOWN; | ||
88 | hidl_vec<TvStreamConfig> tvStreamConfigs; | ||
89 | if (ret == 0) { | ||
90 | res = Result::OK; | ||
91 | tvStreamConfigs.resize(getSupportedConfigCount(configCount, configs)); | ||
92 | int32_t pos = 0; | ||
93 | for (int32_t i = 0; i < configCount; ++i) { | ||
94 | if (isSupportedStreamType(configs[i].type)) { | ||
95 | tvStreamConfigs[pos].streamId = configs[i].stream_id; | ||
96 | tvStreamConfigs[pos].maxVideoWidth = configs[i].max_video_width; | ||
97 | tvStreamConfigs[pos].maxVideoHeight = configs[i].max_video_height; | ||
98 | ++pos; | ||
99 | } | ||
100 | } | ||
101 | } | ||
102 | cb(res, tvStreamConfigs); | ||
103 | return Void(); | ||
104 | } | ||
105 | |||
106 | Return<void> TvInput::openStream(int32_t deviceId, int32_t streamId, openStream_cb cb) { | ||
107 | tv_stream_t stream; | ||
108 | stream.stream_id = streamId; | ||
109 | int ret = mDevice->open_stream(mDevice, deviceId, &stream); | ||
110 | Result res = Result::UNKNOWN; | ||
111 | native_handle_t* sidebandStream = nullptr; | ||
112 | if (ret == 0) { | ||
113 | if (isSupportedStreamType(stream.type)) { | ||
114 | res = Result::OK; | ||
115 | sidebandStream = stream.sideband_stream_source_handle; | ||
116 | } | ||
117 | } else { | ||
118 | // TODO(b/30814137) | ||
119 | sidebandStream = const_cast<native_handle_t*>(&kNullNativeHandle); | ||
120 | if (ret == -EBUSY) { | ||
121 | res = Result::NO_RESOURCE; | ||
122 | } else if (ret == -EEXIST) { | ||
123 | res = Result::INVALID_STATE; | ||
124 | } else if (ret == -EINVAL) { | ||
125 | res = Result::INVALID_ARGUMENTS; | ||
126 | } | ||
127 | } | ||
128 | cb(res, sidebandStream); | ||
129 | return Void(); | ||
130 | } | ||
131 | |||
132 | Return<Result> TvInput::closeStream(int32_t deviceId, int32_t streamId) { | ||
133 | int ret = mDevice->close_stream(mDevice, deviceId, streamId); | ||
134 | Result res = Result::UNKNOWN; | ||
135 | if (ret == 0) { | ||
136 | res = Result::OK; | ||
137 | } else if (ret == -ENOENT) { | ||
138 | res = Result::INVALID_STATE; | ||
139 | } else if (ret == -EINVAL) { | ||
140 | res = Result::INVALID_ARGUMENTS; | ||
141 | } | ||
142 | return res; | ||
143 | } | ||
144 | |||
145 | // static | ||
146 | void TvInput::notify(struct tv_input_device* __unused, tv_input_event_t* event, | ||
147 | void* __unused) { | ||
148 | if (mCallback != nullptr && event != nullptr) { | ||
149 | // Capturing is no longer supported. | ||
150 | if (event->type >= TV_INPUT_EVENT_CAPTURE_SUCCEEDED) { | ||
151 | return; | ||
152 | } | ||
153 | TvInputEvent tvInputEvent; | ||
154 | tvInputEvent.type = static_cast<TvInputEventType>(event->type); | ||
155 | tvInputEvent.deviceInfo.deviceId = event->device_info.device_id; | ||
156 | tvInputEvent.deviceInfo.type = static_cast<TvInputType>( | ||
157 | event->device_info.type); | ||
158 | tvInputEvent.deviceInfo.portId = event->device_info.hdmi.port_id; | ||
159 | // TODO: Ensure the legacy audio type code is the same once audio HAL default | ||
160 | // implementation is ready. | ||
161 | tvInputEvent.deviceInfo.audioType = static_cast<AudioDevice>( | ||
162 | event->device_info.audio_type); | ||
163 | memset(tvInputEvent.deviceInfo.audioAddress.data(), 0, | ||
164 | tvInputEvent.deviceInfo.audioAddress.size()); | ||
165 | const char* address = event->device_info.audio_address; | ||
166 | if (address != nullptr) { | ||
167 | size_t size = strlen(address); | ||
168 | if (size > tvInputEvent.deviceInfo.audioAddress.size()) { | ||
169 | LOG(ERROR) << "Audio address is too long. Address:" << address << ""; | ||
170 | return; | ||
171 | } | ||
172 | for (size_t i = 0; i < size; ++i) { | ||
173 | tvInputEvent.deviceInfo.audioAddress[i] = | ||
174 | static_cast<uint8_t>(event->device_info.audio_address[i]); | ||
175 | } | ||
176 | } | ||
177 | mCallback->notify(tvInputEvent); | ||
178 | } | ||
179 | } | ||
180 | |||
181 | // static | ||
182 | uint32_t TvInput::getSupportedConfigCount(uint32_t configCount, | ||
183 | const tv_stream_config_t* configs) { | ||
184 | uint32_t supportedConfigCount = 0; | ||
185 | for (uint32_t i = 0; i < configCount; ++i) { | ||
186 | if (isSupportedStreamType(configs[i].type)) { | ||
187 | supportedConfigCount++; | ||
188 | } | ||
189 | } | ||
190 | return supportedConfigCount; | ||
191 | } | ||
192 | |||
193 | // static | ||
194 | bool TvInput::isSupportedStreamType(int type) { | ||
195 | // Buffer producer type is no longer supported. | ||
196 | return type != TV_STREAM_TYPE_BUFFER_PRODUCER; | ||
197 | } | ||
198 | |||
199 | ITvInput* HIDL_FETCH_ITvInput(const char* name) { | ||
200 | int ret = 0; | ||
201 | const hw_module_t* hw_module = nullptr; | ||
202 | tv_input_device_t* input_device; | ||
203 | ret = hw_get_module(TV_INPUT_HARDWARE_MODULE_ID, &hw_module); | ||
204 | if (ret == 0 && hw_module->methods->open != nullptr) { | ||
205 | ret = hw_module->methods->open(hw_module, TV_INPUT_DEFAULT_DEVICE, | ||
206 | reinterpret_cast<hw_device_t**>(&input_device)); | ||
207 | if (ret == 0) { | ||
208 | return new TvInput(input_device); | ||
209 | } | ||
210 | else { | ||
211 | LOG(ERROR) << "Passthrough failed to load legacy HAL."; | ||
212 | return nullptr; | ||
213 | } | ||
214 | } | ||
215 | else { | ||
216 | LOG(ERROR) << "hw_get_module " << name << " failed: " << ret; | ||
217 | return nullptr; | ||
218 | } | ||
219 | } | ||
220 | |||
221 | } // namespace implementation | ||
222 | } // namespace V1_0 | ||
223 | } // namespace input | ||
224 | } // namespace tv | ||
225 | } // namespace hardware | ||
226 | } // 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 00000000..81cbb208 --- /dev/null +++ b/tv/input/1.0/default/TvInput.h | |||
@@ -0,0 +1,75 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | #ifndef HIDL_GENERATED_android_hardware_tv_input_V1_0_TvInput_H_ | ||
17 | #define HIDL_GENERATED_android_hardware_tv_input_V1_0_TvInput_H_ | ||
18 | |||
19 | #include <android/hardware/tv/input/1.0/ITvInput.h> | ||
20 | #include <hidl/Status.h> | ||
21 | #include <hardware/tv_input.h> | ||
22 | |||
23 | #include <hidl/MQDescriptor.h> | ||
24 | |||
25 | namespace android { | ||
26 | namespace hardware { | ||
27 | namespace tv { | ||
28 | namespace input { | ||
29 | namespace V1_0 { | ||
30 | namespace implementation { | ||
31 | |||
32 | using ::android::hardware::audio::common::V2_0::AudioDevice; | ||
33 | using ::android::hardware::tv::input::V1_0::ITvInput; | ||
34 | using ::android::hardware::tv::input::V1_0::ITvInputCallback; | ||
35 | using ::android::hardware::tv::input::V1_0::Result; | ||
36 | using ::android::hardware::tv::input::V1_0::TvInputEvent; | ||
37 | using ::android::hardware::tv::input::V1_0::TvStreamConfig; | ||
38 | using ::android::hardware::Return; | ||
39 | using ::android::hardware::Void; | ||
40 | using ::android::hardware::hidl_vec; | ||
41 | using ::android::hardware::hidl_string; | ||
42 | using ::android::sp; | ||
43 | |||
44 | struct TvInput : public ITvInput { | ||
45 | TvInput(tv_input_device_t* device); | ||
46 | ~TvInput(); | ||
47 | Return<void> setCallback(const sp<ITvInputCallback>& callback) override; | ||
48 | Return<void> getStreamConfigurations(int32_t deviceId, | ||
49 | getStreamConfigurations_cb _hidl_cb) override; | ||
50 | Return<void> openStream(int32_t deviceId, int32_t streamId, | ||
51 | openStream_cb _hidl_cb) override; | ||
52 | Return<Result> closeStream(int32_t deviceId, int32_t streamId) override; | ||
53 | |||
54 | static void notify(struct tv_input_device* __unused, tv_input_event_t* event, | ||
55 | void* __unused); | ||
56 | static uint32_t getSupportedConfigCount(uint32_t configCount, | ||
57 | const tv_stream_config_t* configs); | ||
58 | static bool isSupportedStreamType(int type); | ||
59 | |||
60 | private: | ||
61 | static sp<ITvInputCallback> mCallback; | ||
62 | tv_input_callback_ops_t mCallbackOps; | ||
63 | tv_input_device_t* mDevice; | ||
64 | }; | ||
65 | |||
66 | extern "C" ITvInput* HIDL_FETCH_ITvInput(const char* name); | ||
67 | |||
68 | } // namespace implementation | ||
69 | } // namespace V1_0 | ||
70 | } // namespace input | ||
71 | } // namespace tv | ||
72 | } // namespace hardware | ||
73 | } // namespace android | ||
74 | |||
75 | #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 00000000..c5bc0b7c --- /dev/null +++ b/tv/input/1.0/default/android.hardware.tv.input@1.0-service.rc | |||
@@ -0,0 +1,4 @@ | |||
1 | service tv-input-1-0 /system/bin/hw/android.hardware.tv.input@1.0-service | ||
2 | class hal | ||
3 | user system | ||
4 | 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 00000000..d59c848b --- /dev/null +++ b/tv/input/1.0/default/service.cpp | |||
@@ -0,0 +1,31 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | #define LOG_TAG "android.hardware.tv_input@1.0-service" | ||
18 | |||
19 | #include <android/hardware/tv/input/1.0/ITvInput.h> | ||
20 | |||
21 | #include <hidl/LegacySupport.h> | ||
22 | |||
23 | using android::sp; | ||
24 | |||
25 | // Generated HIDL files | ||
26 | using android::hardware::tv::input::V1_0::ITvInput; | ||
27 | using android::hardware::defaultPassthroughServiceImplementation; | ||
28 | |||
29 | int main() { | ||
30 | return defaultPassthroughServiceImplementation<ITvInput>("tv.input"); | ||
31 | } | ||
diff --git a/tv/input/1.0/types.hal b/tv/input/1.0/types.hal new file mode 100644 index 00000000..89a7acc0 --- /dev/null +++ b/tv/input/1.0/types.hal | |||
@@ -0,0 +1,125 @@ | |||
1 | /* | ||
2 | * Copyright (C) 2016 The Android Open Source Project | ||
3 | * | ||
4 | * Licensed under the Apache License, Version 2.0 (the "License"); | ||
5 | * you may not use this file except in compliance with the License. | ||
6 | * You may obtain a copy of the License at | ||
7 | * | ||
8 | * http://www.apache.org/licenses/LICENSE-2.0 | ||
9 | * | ||
10 | * Unless required by applicable law or agreed to in writing, software | ||
11 | * distributed under the License is distributed on an "AS IS" BASIS, | ||
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
13 | * See the License for the specific language governing permissions and | ||
14 | * limitations under the License. | ||
15 | */ | ||
16 | |||
17 | package android.hardware.tv.input@1.0; | ||
18 | |||
19 | import android.hardware.audio.common@2.0; | ||
20 | |||
21 | enum Result { | ||
22 | OK, | ||
23 | UNKNOWN, | ||
24 | NO_RESOURCE, | ||
25 | INVALID_ARGUMENTS, | ||
26 | INVALID_STATE, | ||
27 | }; | ||
28 | |||
29 | /* Type of physical TV input. */ | ||
30 | enum TvInputType { | ||
31 | OTHER = 1, // Generic hardware. | ||
32 | TUNER = 2, // Tuner. e.g. built-in terrestrial tuner | ||
33 | COMPOSITE = 3, | ||
34 | SVIDEO = 4, | ||
35 | SCART = 5, | ||
36 | COMPONENT = 6, | ||
37 | VGA = 7, | ||
38 | DVI = 8, | ||
39 | HDMI = 9, // Physical HDMI port. e.g. HDMI 1 | ||
40 | DISPLAY_PORT = 10, | ||
41 | }; | ||
42 | |||
43 | struct TvInputDeviceInfo { | ||
44 | int32_t deviceId; | ||
45 | TvInputType type; | ||
46 | uint32_t portId; // HDMI port ID number. e.g. 2 for HDMI 2 | ||
47 | AudioDevice audioType; // Audio device type. e.g AudioDevice::IN_HDMI | ||
48 | uint8_t[32] audioAddress; // Audio device address. "" if N/A. If the text | ||
49 | // length is less than 32, the remaining part | ||
50 | // must be filled with 0s. | ||
51 | }; | ||
52 | |||
53 | enum TvInputEventType { | ||
54 | /* | ||
55 | * Hardware notifies the framework that a device is available. | ||
56 | * | ||
57 | * Note that DEVICE_AVAILABLE and DEVICE_UNAVAILABLE events do not represent | ||
58 | * hotplug events (i.e. plugging cable into or out of the physical port). | ||
59 | * These events notify the framework whether the port is available or not. | ||
60 | * For a concrete example, when a user plugs in or pulls out the HDMI cable | ||
61 | * from a HDMI port, it does not generate DEVICE_AVAILABLE and/or | ||
62 | * DEVICE_UNAVAILABLE events. However, if a user inserts a pluggable USB | ||
63 | * tuner into the Android device, it must generate a DEVICE_AVAILABLE event | ||
64 | * and when the port is removed, it must generate a DEVICE_UNAVAILABLE | ||
65 | * event. | ||
66 | * | ||
67 | * For hotplug events, please see STREAM_CONFIGURATION_CHANGED for more | ||
68 | * details. | ||
69 | * | ||
70 | * HAL implementation must register devices by using this event when the | ||
71 | * device boots up. The framework must recognize device reported via this | ||
72 | * event only. | ||
73 | */ | ||
74 | DEVICE_AVAILABLE = 1, | ||
75 | |||
76 | /* | ||
77 | * Hardware notifies the framework that a device is unavailable. | ||
78 | * | ||
79 | * HAL implementation must generate this event when a device registered | ||
80 | * by DEVICE_AVAILABLE is no longer available. For example, | ||
81 | * the event can indicate that a USB tuner is plugged out from the Android | ||
82 | * device. | ||
83 | * | ||
84 | * Note that this event is not for indicating cable plugged out of the port; | ||
85 | * for that purpose, the implementation must use | ||
86 | * STREAM_CONFIGURATION_CHANGED event. This event represents the port itself | ||
87 | * being no longer available. | ||
88 | */ | ||
89 | DEVICE_UNAVAILABLE = 2, | ||
90 | |||
91 | /* | ||
92 | * Stream configurations are changed. Client must regard all open streams | ||
93 | * at the specific device are closed, and must call | ||
94 | * getStreamConfigurations() again, opening some of them if necessary. | ||
95 | * | ||
96 | * HAL implementation must generate this event when the available stream | ||
97 | * configurations change for any reason. A typical use case of this event | ||
98 | * is to notify the framework that the input signal has changed resolution, | ||
99 | * or that the cable is plugged out so that the number of available streams | ||
100 | * is 0. | ||
101 | * | ||
102 | * The implementation must use this event to indicate hotplug status of the | ||
103 | * port. the framework regards input devices with no available streams as | ||
104 | * disconnected, so the implementation can generate this event with no | ||
105 | * available streams to indicate that this device is disconnected, and vice | ||
106 | * versa. | ||
107 | */ | ||
108 | STREAM_CONFIGURATIONS_CHANGED = 3, | ||
109 | }; | ||
110 | |||
111 | struct TvInputEvent { | ||
112 | TvInputEventType type; | ||
113 | /* | ||
114 | * DEVICE_AVAILABLE: all fields are relevant. | ||
115 | * DEVICE_UNAVAILABLE: only deviceId is relevant. | ||
116 | * STREAM_CONFIGURATIONS_CHANGED: only deviceId is relevant. | ||
117 | */ | ||
118 | TvInputDeviceInfo deviceInfo; | ||
119 | }; | ||
120 | |||
121 | struct TvStreamConfig { | ||
122 | int32_t streamId; | ||
123 | uint32_t maxVideoWidth; // Max width of the stream. | ||
124 | uint32_t maxVideoHeight; // Max height of the stream. | ||
125 | }; | ||