Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 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 | #ifndef WIFI_CHIP_H_ |
| 18 | #define WIFI_CHIP_H_ |
| 19 | |
| 20 | #include <set> |
| 21 | |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 22 | #include <android-base/macros.h> |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 23 | #include <android/hardware/wifi/1.0/IWifiChip.h> |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 24 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 25 | #include "wifi_legacy_hal.h" |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 26 | |
| 27 | namespace android { |
| 28 | namespace hardware { |
| 29 | namespace wifi { |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 30 | namespace V1_0 { |
| 31 | namespace implementation { |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 32 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 33 | /** |
| 34 | * HIDL interface object used to control a Wifi HAL chip instance. |
| 35 | * Since there is only a single chip instance used today, there is no |
| 36 | * identifying handle information stored here. |
| 37 | */ |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 38 | class WifiChip : public IWifiChip { |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 39 | public: |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 40 | WifiChip(ChipId chip_id, const std::weak_ptr<WifiLegacyHal> legacy_hal); |
Roshan Pius | 3e2d671 | 2016-10-06 13:16:23 -0700 | [diff] [blame^] | 41 | // HIDL does not provide a built-in mechanism to let the server invalidate |
| 42 | // a HIDL interface object after creation. If any client process holds onto |
| 43 | // a reference to the object in their context, any method calls on that |
| 44 | // reference will continue to be directed to the server. |
| 45 | // |
| 46 | // However Wifi HAL needs to control the lifetime of these objects. So, add |
| 47 | // a public |invalidate| method to |WifiChip| and it's child objects. This |
| 48 | // will be used to mark an object invalid when either: |
| 49 | // a) Wifi HAL is stopped, or |
| 50 | // b) Wifi Chip is reconfigured. |
| 51 | // |
| 52 | // All HIDL method implementations should check if the object is still marked |
| 53 | // valid before processing them. |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 54 | void invalidate(); |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 55 | |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 56 | // HIDL methods exposed. |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 57 | Return<ChipId> getId() override; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 58 | Return<void> registerEventCallback( |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 59 | const sp<IWifiChipEventCallback>& callback) override; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 60 | Return<void> getAvailableModes(getAvailableModes_cb cb) override; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 61 | Return<void> configureChip(uint32_t mode_id) override; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 62 | Return<uint32_t> getMode() override; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 63 | Return<void> requestChipDebugInfo() override; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 64 | Return<void> requestDriverDebugDump() override; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 65 | Return<void> requestFirmwareDebugDump() override; |
| 66 | |
| 67 | private: |
Roshan Pius | cd566bd | 2016-10-10 08:03:42 -0700 | [diff] [blame] | 68 | ChipId chip_id_; |
Roshan Pius | aabe575 | 2016-09-29 09:03:59 -0700 | [diff] [blame] | 69 | std::weak_ptr<WifiLegacyHal> legacy_hal_; |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 70 | std::set<sp<IWifiChipEventCallback>> callbacks_; |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 71 | |
| 72 | DISALLOW_COPY_AND_ASSIGN(WifiChip); |
| 73 | }; |
| 74 | |
Roshan Pius | 79a9975 | 2016-10-04 13:03:58 -0700 | [diff] [blame] | 75 | } // namespace implementation |
| 76 | } // namespace V1_0 |
Roshan Pius | 3c4e8a3 | 2016-10-03 14:53:58 -0700 | [diff] [blame] | 77 | } // namespace wifi |
| 78 | } // namespace hardware |
| 79 | } // namespace android |
| 80 | |
| 81 | #endif // WIFI_CHIP_H_ |