Home | History | Annotate | Download | only in uim_rfkill
      1 /*
      2  *  User Mode Init manager - For shared transport
      3  *
      4  *  This program is free software; you can redistribute it and/or modify
      5  *  it under the terms of the GNU General Public License as published by
      6  *  the Free Software Foundation; either version 2 of the License, or
      7  *  (at your option) any later version.
      8  *
      9  *  This program is distributed in the hope that it will be useful,
     10  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     11  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     12  *  GNU General Public License for more details.
     13  *
     14  *  You should have received a copy of the GNU General Public License
     15  *  along with this program;if not, write to the Free Software
     16  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
     17  */
     18 
     19 #ifndef UIM_H
     20 #define UIM_H
     21 
     22 /* Paramaters to set the baud rate*/
     23 #define  FLOW_CTL       0x0001
     24 #define  BOTHER         0x00001000
     25 #define  ARM_NCCS       19
     26 
     27 #define TCGETS2      _IOR('T',0x2A, struct termios2)
     28 #define TCSETS2      _IOW('T',0x2B, struct termios2)
     29 
     30 /*HCI Command and Event information*/
     31 #define HCI_HDR_OPCODE          0xff36
     32 #define WRITE_BD_ADDR_OPCODE    0xFC06
     33 #define RESP_PREFIX             0x04
     34 #define MAX_TRY                 10
     35 
     36 /* HCI Packet types */
     37 #define HCI_COMMAND_PKT         0x01
     38 #define HCI_EVENT_PKT           0x04
     39 
     40 /* HCI command macros*/
     41 #define HCI_EVENT_HDR_SIZE              2
     42 #define HCI_COMMAND_HDR_SIZE            3
     43 #define UIM_WRITE_BD_ADDR_CP_SIZE       6
     44 
     45 
     46 /* HCI event macros*/
     47 #define EVT_CMD_COMPLETE_SIZE   3
     48 #define EVT_CMD_STATUS_SIZE     4
     49 #define EVT_CMD_COMPLETE        0x0E
     50 #define EVT_CMD_STATUS          0x0F
     51 
     52 
     53 #define VERBOSE
     54 #ifndef ANDROID
     55 #define ALOGE printf
     56 #endif /* ANDROID */
     57 #define LOG_TAG "uim-rfkill: "
     58 #define UIM_ERR(fmt, arg...)  ALOGE("uim:"fmt"\n" , ##arg)
     59 #if defined(UIM_DEBUG)          /* limited debug messages */
     60 #define UIM_START_FUNC()      ALOGE("uim: Inside %s\n", __FUNCTION__)
     61 #define UIM_DBG(fmt, arg...)  ALOGE("uim:"fmt"\n" , ## arg)
     62 #define UIM_VER(fmt, arg...)
     63 #elif defined(VERBOSE)          /* very verbose */
     64 #define UIM_START_FUNC()      ALOGE("uim: Inside %s\n", __FUNCTION__)
     65 #define UIM_DBG(fmt, arg...)  ALOGE("uim:"fmt"\n" , ## arg)
     66 #define UIM_VER(fmt, arg...)  ALOGE("uim:"fmt"\n" , ## arg)
     67 #else /* error msgs only */
     68 #define UIM_START_FUNC()
     69 #define UIM_DBG(fmt, arg...)
     70 #define UIM_VER(fmt, arg...)
     71 #endif
     72 
     73 /*Termios2 structure for setting the Custom baud rate*/
     74 struct termios2 {
     75     tcflag_t c_iflag;       /* input mode flags */
     76     tcflag_t c_oflag;       /* output mode flags */
     77     tcflag_t c_cflag;       /* control mode flags */
     78     tcflag_t c_lflag;       /* local mode flags */
     79     cc_t c_line;            /* line discipline */
     80     cc_t c_cc[ARM_NCCS];    /* control characters */
     81     speed_t c_ispeed;       /* input speed */
     82     speed_t c_ospeed;       /* output speed */
     83 };
     84 
     85 /* HCI command header*/
     86 typedef struct {
     87     uint16_t        opcode;         /* OCF & OGF */
     88     uint8_t         plen;
     89 } __attribute__ ((packed))      hci_command_hdr;
     90 
     91 /* HCI event header*/
     92 typedef struct {
     93     uint8_t         evt;
     94     uint8_t         plen;
     95 } __attribute__ ((packed))      hci_event_hdr;
     96 
     97 /* HCI command complete event*/
     98 typedef struct {
     99     uint8_t         ncmd;
    100     uint16_t        opcode;
    101 } __attribute__ ((packed)) evt_cmd_complete;
    102 
    103 /* HCI event status*/
    104 typedef struct {
    105     uint8_t         status;
    106     uint8_t         ncmd;
    107     uint16_t        opcode;
    108 } __attribute__ ((packed)) evt_cmd_status;
    109 
    110 /* HCI Event structure to set the cusrom baud rate*/
    111 typedef struct {
    112     uint8_t uart_prefix;
    113     hci_event_hdr hci_hdr;
    114     evt_cmd_complete cmd_complete;
    115     uint8_t status;
    116     uint8_t data[16];
    117 } __attribute__ ((packed)) command_complete_t;
    118 
    119 /* HCI Command structure to set the cusrom baud rate*/
    120 typedef struct {
    121     uint8_t uart_prefix;
    122     hci_command_hdr hci_hdr;
    123     uint32_t speed;
    124 } __attribute__ ((packed)) uim_speed_change_cmd;
    125 
    126 /* BD address structure to set the uim BD address*/
    127 typedef struct {
    128     unsigned char b[6];
    129 } __attribute__((packed)) bdaddr_t;
    130 
    131 /* HCI Command structure to set the uim BD address*/
    132 typedef struct {
    133     uint8_t uart_prefix;
    134     hci_command_hdr hci_hdr;
    135     bdaddr_t addr;
    136 } __attribute__ ((packed)) uim_bdaddr_change_cmd;
    137 
    138 /* Signal received from KIM will install line discipline at first,
    139  * the next signal received from KIM will un-install the
    140  * line discipline*/
    141 enum {
    142     /* expecting signal from KIM to setup uart fd for ST */
    143     INSTALL_N_TI_WL,
    144 
    145     /* expecting signal from KIM to close uart fd */
    146     UNINSTALL_N_TI_WL,
    147 };
    148 
    149 /* Functions to insert and remove the kernel modules from the system*/
    150 extern int init_module(void *, unsigned int, const char *);
    151 extern int delete_module(const char *, unsigned int);
    152 extern int load_file(const char *, unsigned int *);
    153 
    154 #endif /* UIM_H */
    155