pi-usb.h

Go to the documentation of this file.
00001 /*
00002  * $Id: pi-usb.h,v 1.21 2007-02-09 16:11:37 desrod Exp $
00003  *
00004  * pi-usb.h: Support for USB-connected Palm devices
00005  *
00006  * This library is free software; you can redistribute it and/or modify it
00007  * under the terms of the GNU Library General Public License as published by
00008  * the Free Software Foundation; either version 2 of the License, or (at
00009  * your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful, but
00012  * WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library
00014  * General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Library General Public License
00017  * along with this library; if not, write to the Free Software Foundation,
00018  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00019  */
00020 
00021 #ifndef _PILOT_USB_H_
00022 #define _PILOT_USB_H_
00023 
00024 #include "pi-args.h"
00025 #include "pi-buffer.h"
00026 
00027 #ifdef __cplusplus
00028 extern "C" {
00029 #endif
00030 
00031 #if defined(sun) && defined(__SVR4)
00032 #define u_int8_t uint8_t
00033 #define u_int16_t uint16_t
00034 #define u_int32_t uint32_t
00035 #endif
00036 
00037 #define PI_USB_DEV     1
00038 
00039         struct pi_usb_data;
00040 
00041         typedef struct pi_usb_impl {
00042                 int (*open) PI_ARGS((pi_socket_t *ps,
00043                         struct pi_sockaddr *addr, size_t addrlen));
00044                 int (*close) PI_ARGS((pi_socket_t *ps));
00045 
00046                 ssize_t (*write) PI_ARGS((pi_socket_t *ps,
00047                         PI_CONST unsigned char *buf, size_t len, int flags));
00048                 ssize_t (*read) PI_ARGS((pi_socket_t *ps,
00049                          pi_buffer_t *buf, size_t expect, int flags));
00050                 int (*flush) PI_ARGS((pi_socket_t *ps, int flags));
00051                 int (*poll) PI_ARGS((pi_socket_t *ps, int timeout));
00052 
00053                 int (*wait_for_device) PI_ARGS((pi_socket_t *ps, int *timeout));
00054                 int (*changebaud) PI_ARGS((pi_socket_t *ps));
00055                 int (*control_request) PI_ARGS((struct pi_usb_data *usb_data,
00056                         int request_type, int request, int value, int reqindex,
00057                         void *data, int size, int timeout));
00058         } pi_usb_impl_t;
00059 
00060 #define USB_INIT_NONE           (1<<0)
00061 #define USB_INIT_TAPWAVE        (1<<1)
00062 #define USB_INIT_VISOR          (1<<2)
00063 #define USB_INIT_SONY_CLIE      (1<<3)
00064 
00065         typedef struct pi_usb_dev {
00066                 u_int16_t       vendor, product;
00067                 u_int32_t       flags;
00068                 char            *idstr;
00069         } pi_usb_dev_t;
00070 
00071         typedef struct pi_usb_data {
00072                 struct pi_usb_impl impl;        
00073                 struct pi_usb_dev dev;          
00075                 unsigned char buf[256];         
00076                 size_t buf_size;
00077 
00078                 /* IO options */
00079                 void *ref;                      
00081                 /* Baud rate info (for USB serial adapters on platforms
00082                    where they connect through the USB layer, like Darwin) */
00083                 int rate;                       
00084                 int establishrate;              
00085                 int establishhighrate;          
00087                 int timeout;
00088         } pi_usb_data_t;
00089 
00090         extern pi_device_t *pi_usb_device PI_ARGS((int type));
00091         extern void pi_usb_impl_init PI_ARGS((struct pi_usb_impl *impl));
00092         extern int USB_check_device PI_ARGS((pi_usb_data_t *dev, u_int16_t vendor, u_int16_t product));
00093         extern int USB_configure_device PI_ARGS((pi_usb_data_t *dev, u_int8_t *input_pipe, u_int8_t *output_pipe));
00094 
00095         /* Start of the new generic USB pilot init stuff. */
00096 
00097         /*
00098          * USB control requests we send to the devices From
00099          * linux/drivers/usb/serial/visor.h
00100          */
00101         #define GENERIC_REQUEST_BYTES_AVAILABLE         0x01
00102         #define GENERIC_CLOSE_NOTIFICATION              0x02
00103         #define VISOR_GET_CONNECTION_INFORMATION        0x03
00104         #define PALM_GET_EXT_CONNECTION_INFORMATION     0x04
00105 
00106         /*
00107          * Reply struct and defines for VISOR_GET_CONNECTION_INFORMATION
00108          */
00109         typedef struct
00110         {
00111                 u_int16_t num_ports;
00112                 struct
00113                 {
00114                         u_int8_t port_function_id;
00115                         u_int8_t port;
00116                 } connections[2];
00117         } visor_connection_info_t;
00118 
00119         /* struct visor_connection_info.connection[x].port defines: */
00120         #define VISOR_ENDPOINT_1        0x01
00121         #define VISOR_ENDPOINT_2        0x02
00122 
00123         /* struct visor_connection_info.connection[x].port_function_id defines: */
00124         #define VISOR_FUNCTION_GENERIC              0x00
00125         #define VISOR_FUNCTION_DEBUGGER             0x01
00126         #define VISOR_FUNCTION_HOTSYNC              0x02
00127         #define VISOR_FUNCTION_CONSOLE              0x03
00128         #define VISOR_FUNCTION_REMOTE_FILE_SYS      0x04
00129 
00130         /*
00131          * Reply struct for PALM_GET_EXT_CONNECTION_INFORMATION
00132          */
00133         typedef struct
00134         {
00135                 u_int8_t num_ports;
00136                 u_int8_t endpoint_numbers_different;
00137                 u_int16_t reserved1;
00138                 struct
00139                 {
00140                         char port_function_id[4];
00141                         u_int8_t port;
00142                         u_int8_t endpoint_info;
00143                         u_int16_t reserved;
00144                 } connections[2];
00145         } palm_ext_connection_info_t;
00146 
00147 
00148 #ifdef __cplusplus
00149 }
00150 #endif
00151 #endif

© 1996-2007 by pilot-link.org. All rights reserved.