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 ANDROID_HARDWARE_RADIO_HAL_LEGACY_H 18 #define ANDROID_HARDWARE_RADIO_HAL_LEGACY_H 19 20 #include <utils/RefBase.h> 21 #include <hardware/radio.h> 22 #include "RadioInterface.h" 23 #include "TunerInterface.h" 24 #include "TunerCallbackInterface.h" 25 26 namespace android { 27 28 class RadioHalLegacy : public RadioInterface 29 { 30 public: 31 RadioHalLegacy(radio_class_t classId); 32 33 // RadioInterface 34 virtual int getProperties(radio_hal_properties_t *properties); 35 virtual int openTuner(const radio_hal_band_config_t *config, 36 bool audio, 37 sp<TunerCallbackInterface> callback, 38 sp<TunerInterface>& tuner); 39 virtual int closeTuner(sp<TunerInterface>& tuner); 40 41 // RefBase 42 virtual void onFirstRef(); 43 44 class Tuner : public TunerInterface 45 { 46 public: 47 Tuner(sp<TunerCallbackInterface> callback); 48 49 virtual int setConfiguration(const radio_hal_band_config_t *config); 50 virtual int getConfiguration(radio_hal_band_config_t *config); 51 virtual int scan(radio_direction_t direction, bool skip_sub_channel); 52 virtual int step(radio_direction_t direction, bool skip_sub_channel); 53 virtual int tune(unsigned int channel, unsigned int sub_channel); 54 virtual int cancel(); 55 virtual int getProgramInformation(radio_program_info_t *info); 56 57 static void callback(radio_hal_event_t *halEvent, void *cookie); 58 void onCallback(radio_hal_event_t *halEvent); 59 setHalTuner(const struct radio_tuner * halTuner)60 void setHalTuner(const struct radio_tuner *halTuner) { mHalTuner = halTuner; } getHalTuner()61 const struct radio_tuner *getHalTuner() { return mHalTuner; } 62 63 private: 64 virtual ~Tuner(); 65 66 const struct radio_tuner *mHalTuner; 67 sp<TunerCallbackInterface> mCallback; 68 }; 69 70 protected: 71 virtual ~RadioHalLegacy(); 72 73 private: 74 static const char * sClassModuleNames[]; 75 76 radio_class_t mClassId; 77 struct radio_hw_device *mHwDevice; 78 }; 79 80 } // namespace android 81 82 #endif // ANDROID_HARDWARE_RADIO_HAL_LEGACY_H 83