Kiran Kelageri | dee0c78 | 2015-07-13 12:12:18 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (c) 2013-2015, The Linux Foundation. All rights reserved. |
| 3 | * |
| 4 | * Redistribution and use in source and binary forms, with or without |
| 5 | * modification, are permitted provided that the following conditions are |
| 6 | * met: |
| 7 | * * Redistributions of source code must retain the above copyright |
| 8 | * notice, this list of conditions and the following disclaimer. |
| 9 | * * Redistributions in binary form must reproduce the above |
| 10 | * copyright notice, this list of conditions and the following |
| 11 | * disclaimer in the documentation and/or other materials provided |
| 12 | * with the distribution. |
| 13 | * * Neither the name of The Linux Foundation nor the names of its |
| 14 | * contributors may be used to endorse or promote products derived |
| 15 | * from this software without specific prior written permission. |
| 16 | * |
| 17 | * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED |
| 18 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF |
| 19 | * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT |
| 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS |
| 21 | * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR |
| 22 | * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF |
| 23 | * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR |
| 24 | * BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, |
| 25 | * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE |
| 26 | * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN |
| 27 | * IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 28 | */ |
| 29 | |
| 30 | #ifndef ANDROID_INCLUDE_WIPOWER_H |
| 31 | #define ANDROID_INCLUDE_WIPOWER_H |
| 32 | |
| 33 | #include <stdint.h> |
| 34 | #include <sys/cdefs.h> |
| 35 | #include <sys/types.h> |
| 36 | #include <stdbool.h> |
| 37 | |
| 38 | #include <hardware/hardware.h> |
| 39 | #include <hardware/bluetooth.h> |
| 40 | |
| 41 | __BEGIN_DECLS |
| 42 | |
| 43 | typedef enum { |
| 44 | OFF =0, |
| 45 | ON |
| 46 | } wipower_state_t; |
| 47 | |
| 48 | |
| 49 | typedef struct { |
| 50 | |
| 51 | unsigned char optional; |
| 52 | unsigned short rect_voltage; |
| 53 | unsigned short rect_current; |
| 54 | unsigned short out_voltage; |
| 55 | unsigned short out_current; |
| 56 | unsigned char temp; |
| 57 | unsigned short rect_voltage_min; |
| 58 | unsigned short rect_voltage_set; |
| 59 | unsigned short rect_voltage_max; |
| 60 | unsigned char alert; |
| 61 | unsigned short rfu1; |
| 62 | unsigned char rfu2; |
| 63 | |
| 64 | }__attribute__((packed)) wipower_dyn_data_t; |
| 65 | |
| 66 | /** Bluetooth Enable/Disable Callback. */ |
| 67 | typedef void (*wipower_state_changed_callback)(wipower_state_t state); |
| 68 | |
| 69 | |
| 70 | typedef void (*wipower_alerts)(unsigned char alert); |
| 71 | |
| 72 | |
| 73 | typedef void (*wipower_dynamic_data)(wipower_dyn_data_t* alert_data); |
| 74 | |
| 75 | |
| 76 | typedef void (*wipower_power_apply)(unsigned char power_flag); |
| 77 | |
| 78 | typedef void (*callback_thread_event)(bt_cb_thread_evt evt); |
| 79 | |
| 80 | /** Bluetooth DM callback structure. */ |
| 81 | typedef struct { |
| 82 | /** set to sizeof(wipower_callbacks_t) */ |
| 83 | size_t size; |
| 84 | wipower_state_changed_callback wipower_state_changed_cb; |
| 85 | wipower_alerts wipower_alert; |
| 86 | wipower_dynamic_data wipower_data; |
| 87 | wipower_power_apply wipower_power_event; |
| 88 | callback_thread_event callback_thread_event; |
| 89 | } wipower_callbacks_t; |
| 90 | |
| 91 | |
| 92 | /** Represents the standard Wipower interface. */ |
| 93 | typedef struct { |
| 94 | /** set to sizeof(wipower_interface_t) */ |
| 95 | size_t size; |
| 96 | |
| 97 | /** Initialize Wipower modules*/ |
| 98 | int (*init)(wipower_callbacks_t *wp_callbacks); |
| 99 | |
| 100 | /** Enable/Disable Wipower charging */ |
| 101 | int (*enable)(bool enable); |
| 102 | |
| 103 | int (*set_current_limit)(short value); |
| 104 | |
| 105 | unsigned char (*get_current_limit)(void); |
| 106 | |
| 107 | wipower_state_t (*get_state)(void); |
| 108 | |
| 109 | /** Enable/Disable Wipower charging */ |
| 110 | int (*enable_alerts)(bool enable); |
| 111 | |
| 112 | int (*enable_data_notify)(bool enable); |
| 113 | int (*enable_power_apply)(bool enable, bool on, bool time_flag); |
| 114 | } wipower_interface_t; |
| 115 | |
| 116 | |
| 117 | __END_DECLS |
| 118 | |
| 119 | #endif /* ANDROID_INCLUDE_WIPOWER_H */ |