Home | History | Annotate | Download | only in inc
      1 /*
      2  * Copyright (C) 2015 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 _PHNXPEXTNS_CUSTOM_H_
     18 #define _PHNXPEXTNS_CUSTOM_H_
     19 
     20 #include <nfa_api.h>
     21 #include <sys/types.h>
     22 #include <errno.h>
     23 #include <phNfcStatus.h>
     24 
     25 #ifdef __cplusplus
     26 extern "C" {
     27 #endif
     28 
     29 /*
     30  * TLV structure
     31  * For simple TLV, type[0] == 0x00
     32  * For extended TLV, type[0] == 0xA0
     33  */
     34 typedef struct {
     35     uint8_t type[2];
     36     uint8_t len;
     37     uint8_t *val;
     38 } tlv_t;
     39 
     40 typedef enum {
     41     passive_106 = 0x01,
     42     passive_212 = 0x02,
     43     passive_424 = 0x04,
     44     active_106 = 0x10,
     45     active_212 = 0x20,
     46     active_424 = 0x40,
     47 } p2p_speed_t;
     48 
     49 typedef enum {
     50     NO_SE,
     51     UICC,
     52     eSE,
     53 } SE_t;
     54 
     55 typedef enum {
     56     ReaderMode = 0x01,
     57     P2PMode = 0x02,
     58     CEMode = 0x04,
     59 } PollMode_t;
     60 
     61 /*******************************************************************************
     62  **
     63  ** Function         phNxpExtns_get_version
     64  **
     65  ** Description      Function to get the HW, FW and SW versions.
     66  **
     67  ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED.
     68  **
     69  ** NOTE: Internally this function will use phNxpNciHal_get_version from HAL.
     70  *******************************************************************************/
     71 
     72 NFCSTATUS phNxpExtns_get_version (uint32_t *hw_ver, uint32_t *fw_ver, uint32_t *sw_ver);
     73 
     74 /*******************************************************************************
     75  **
     76  ** Function         phNxpNciHal_read_tlv
     77  **
     78  ** Description      Function to read simple TLV and extended TLV.
     79  **                  Memory for TLV and fields are allocated and freed by calling
     80  **                  function. Input is type and len. Response is provied in *val.
     81  **
     82  ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED.
     83  **
     84  ** NOTE: Internally this function will use NFA_GetConfig for simple TLV.
     85  **       For extended TLV, it will use NFA_SendRawFrame.
     86  *******************************************************************************/
     87 
     88 NFCSTATUS phNxpNciHal_read_tlv (tlv_t *tlv);
     89 
     90 /*******************************************************************************
     91  **
     92  ** Function         phNxpNciHal_write_tlv
     93  **
     94  ** Description      Function to write simple TLV and extended TLV.
     95  **                  Memory for TLV and fields are allocated and freed by calling
     96  **                  function. Input is type, len, *val.
     97  **
     98  ** Returns          NFCSTATUS_SUCCESS if successful,otherwise NFCSTATUS_FAILED.
     99  **
    100  ** NOTE: Internally this function will use NFA_SetConfig for simple TLV.
    101  **       For extended TLV, it will use NFA_SendRawFrame.
    102  *******************************************************************************/
    103 
    104 NFCSTATUS phNxpNciHal_write_tlv (tlv_t *tlv);
    105 
    106 /*******************************************************************************
    107  **
    108  ** Function        phNxpExtns_select_poll_tech
    109  **
    110  ** Description     This function selects the polling technology for starting
    111  **                 polling loop. This function does not start polling loop.
    112  **                 It is just a setting for polling technology.
    113  **
    114  ** Returns         NFCSTATUS_SUCCESS if operation successful,
    115  **                 otherwise NFCSTATUS_FAILED.
    116  **
    117  ** NOTE: Internally this function is using NFA_EnablePolling function.
    118  *******************************************************************************/
    119 
    120 NFCSTATUS phNxpExtns_select_poll_tech (tNFA_TECHNOLOGY_MASK tech_mask);
    121 
    122 /*******************************************************************************
    123  **
    124  ** Function        phNxpExtns_select_ce_listen_tech
    125  **
    126  ** Description     This function set the listen tech for card emulation.
    127  **                 This function does not include routing.
    128  **                 This function does not start polling loop.
    129  **
    130  ** Returns         NFCSTATUS_SUCCESS if operation successful,
    131  **                 otherwise NFCSTATUS_FAILED.
    132  **
    133  ** NOTE: Internally this function is using NFA_CeConfigureUiccListenTech.
    134  **       Not sure which handle to use, from UICC or eSE.
    135  *******************************************************************************/
    136 
    137 NFCSTATUS phNxpExtns_select_ce_listen_tech (tNFA_TECHNOLOGY_MASK tech_mask);
    138 
    139 /*******************************************************************************
    140  **
    141  ** Function        phNxpExtns_select_p2p_poll_speed
    142  **
    143  ** Description     This function will select the P2P polling speed.
    144  **                 phNxpExtns_select_poll_tech overwrite the settings of poll if
    145  **                 reader mode is enabled.
    146  **                 There is only one active poll phase but device can use one
    147  **                 active speed and can move to higher speed if target supports.
    148  **
    149  ** Returns         NFCSTATUS_SUCCESS if operation successful,
    150  **                 otherwise NFCSTATUS_FAILED.
    151  **
    152  ** NOTE: Internally this function will use NFA_EnablePolling and NFA_SetConfig
    153  *******************************************************************************/
    154 
    155 NFCSTATUS phNxpExtns_select_p2p_poll_speed (p2p_speed_t p2p_initiator_speed);
    156 
    157 /*******************************************************************************
    158  **
    159  ** Function        phNxpExtns_select_p2p_listen_speed
    160  **
    161  ** Description     This function will select the listen mode
    162  **                 This function does not include routing.
    163  **                 This function does not start polling loop.
    164  **
    165  ** Returns         NFCSTATUS_SUCCESS if operation successful,
    166  **                 otherwise NFCSTATUS_FAILED.
    167  **
    168  ** NOTE: Internally this function will use NFA_SetP2pListenTech and NFA_SetConfig
    169  *******************************************************************************/
    170 
    171 NFCSTATUS phNxpExtns_select_p2p_listen_speed (p2p_speed_t p2p_target_speed);
    172 
    173 /*******************************************************************************
    174  **
    175  ** Function        phNxpExtns_select_se
    176  **
    177  ** Description     This function will set the routing of the traffic to selected
    178  **                 SE. This function also does not start polling loop.
    179  **
    180  ** Returns         NFCSTATUS_SUCCESS if operation successful,
    181  **                 otherwise NFCSTATUS_FAILED.
    182  **
    183  ** NOTE:
    184  *******************************************************************************/
    185 
    186 NFCSTATUS phNxpExtns_select_se (SE_t se);
    187 
    188 /*******************************************************************************
    189  **
    190  ** Function        phNxpExtns_set_poll_mode
    191  **
    192  ** Description     This function selects which mode to enable for polling loop.
    193  **                 This function do not start polling loop.
    194  **
    195  ** Returns         NFCSTATUS_SUCCESS if operation successful,
    196  **                 otherwise NFCSTATUS_FAILED.
    197  **
    198  ** NOTE:
    199  *******************************************************************************/
    200 
    201 NFCSTATUS phNxpExtns_set_poll_mode (PollMode_t poll_mode);
    202 
    203 /*******************************************************************************
    204  **
    205  ** Function        phNxpExtns_start_poll
    206  **
    207  ** Description     This function starts polling loop based on the configuration
    208  **                 of the previous calls. If no configuration done through other
    209  **                 function call then it uses the default configuration from
    210  **                 configuration files.
    211  **                 This function internally stops the polling loop if it is
    212  **                 already running.
    213  **
    214  ** Returns         NFCSTATUS_SUCCESS if operation successful,
    215  **                 otherwise NFCSTATUS_FAILED.
    216  **
    217  ** NOTE: Internally this function uses NFA_StartRfDiscovery.
    218  *******************************************************************************/
    219 
    220 NFCSTATUS phNxpExtns_start_poll (void);
    221 
    222 /*******************************************************************************
    223  **
    224  ** Function        phNxpExtns_stop_poll
    225  **
    226  ** Description     This function stops the polling loop if it is running.
    227  **
    228  ** Returns          NFCSTATUS_SUCCESS if operation successful,
    229  **                  otherwise NFCSTATUS_FAILED.
    230  **
    231  ** NOTE:Internally this function uses NFA_StopRfDiscovery.
    232  *******************************************************************************/
    233 
    234 NFCSTATUS phNxpExtns_stop_poll (void);
    235 
    236 /*******************************************************************************
    237  **
    238  ** Function        phNxpExtns_enable_Felica_CLT
    239  **
    240  ** Description     This function enables or disable Felica CLT feature.
    241  **
    242  ** Returns         NFCSTATUS_SUCCESS if operation successful,
    243  **                 otherwise NFCSTATUS_FAILED.
    244  **
    245  ** NOTE:
    246  *******************************************************************************/
    247 
    248 NFCSTATUS phNxpExtns_enable_Felica_CLT (bool enable);
    249 
    250 /*******************************************************************************
    251  **
    252  ** Function        phNxpExtns_enable_Mifare_CLT
    253  **
    254  ** Description     This function enables or disable Mifare CLT feature.
    255  **
    256  ** Returns         NFCSTATUS_SUCCESS if operation successful,
    257  **                 otherwise NFCSTATUS_FAILED.
    258  **
    259  ** NOTE:
    260  *******************************************************************************/
    261 
    262 NFCSTATUS phNxpExtns_enable_Mifare_CLT (bool enable);
    263 
    264 #endif /* _PHNXPEXTNS_CUSTOM_H_ */
    265