\doxysection{libusb.\+h}
\label{libusb_8h_source}\index{include/osmocom/usb/libusb.h@{include/osmocom/usb/libusb.h}}
\textbf{ Go to the documentation of this file.}
\begin{DoxyCode}{0}
\DoxyCodeLine{1 \textcolor{preprocessor}{\#pragma once}}
\DoxyCodeLine{2 \textcolor{comment}{/* libusb utilities}}
\DoxyCodeLine{3 \textcolor{comment}{ *}}
\DoxyCodeLine{4 \textcolor{comment}{ * (C) 2010-\/2019 by Harald Welte <hwelte@hmw-\/consulting.de>}}
\DoxyCodeLine{5 \textcolor{comment}{ *}}
\DoxyCodeLine{6 \textcolor{comment}{ * This program is free software; you can redistribute it and/or}}
\DoxyCodeLine{7 \textcolor{comment}{ * modify it under the terms of the GNU General Public License}}
\DoxyCodeLine{8 \textcolor{comment}{ * as published by the Free Software Foundation; either version 2}}
\DoxyCodeLine{9 \textcolor{comment}{ * of the License, or (at your option) any later version.}}
\DoxyCodeLine{10 \textcolor{comment}{ *}}
\DoxyCodeLine{11 \textcolor{comment}{ * This program is distributed in the hope that it will be useful,}}
\DoxyCodeLine{12 \textcolor{comment}{ * but WITHOUT ANY WARRANTY; without even the implied warranty of}}
\DoxyCodeLine{13 \textcolor{comment}{ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the}}
\DoxyCodeLine{14 \textcolor{comment}{ * GNU General Public License for more details.}}
\DoxyCodeLine{15 \textcolor{comment}{ */}}
\DoxyCodeLine{16 }
\DoxyCodeLine{17 \textcolor{preprocessor}{\#include <libusb.h>}}
\DoxyCodeLine{18 }
\DoxyCodeLine{19 \textcolor{preprocessor}{\#define USB\_MAX\_PATH\_LEN 20}}
\DoxyCodeLine{20 }
\DoxyCodeLine{21 \textcolor{keyword}{struct }dev\_id \{}
\DoxyCodeLine{22         uint16\_t vendor\_id;}
\DoxyCodeLine{23         uint16\_t product\_id;}
\DoxyCodeLine{24 \};}
\DoxyCodeLine{25 }
\DoxyCodeLine{26 \textcolor{comment}{/* structure describing a single matching interface found */}}
\DoxyCodeLine{27 \textcolor{keyword}{struct }usb\_interface\_match \{}
\DoxyCodeLine{28         \textcolor{comment}{/* libusb device E*/}}
\DoxyCodeLine{29         libusb\_device *usb\_dev;}
\DoxyCodeLine{30         \textcolor{comment}{/* Vendor ID of the device running matching interface */}}
\DoxyCodeLine{31         uint16\_t vendor;}
\DoxyCodeLine{32         \textcolor{comment}{/* Product ID of the device running matching interface */}}
\DoxyCodeLine{33         uint16\_t product;}
\DoxyCodeLine{34         \textcolor{comment}{/* USB Bus Address */}}
\DoxyCodeLine{35         uint8\_t addr;}
\DoxyCodeLine{36         \textcolor{comment}{/* physical path */}}
\DoxyCodeLine{37         \textcolor{keywordtype}{char} path[USB\_MAX\_PATH\_LEN];}
\DoxyCodeLine{38         \textcolor{comment}{/* configuration of matching interface */}}
\DoxyCodeLine{39         uint8\_t configuration;}
\DoxyCodeLine{40         \textcolor{comment}{/* interface number of matching interface */}}
\DoxyCodeLine{41         uint8\_t interface;}
\DoxyCodeLine{42         \textcolor{comment}{/* altsetting of matching interface */}}
\DoxyCodeLine{43         uint8\_t altsetting;}
\DoxyCodeLine{44         \textcolor{comment}{/* bInterfaceClass of matching interface */}}
\DoxyCodeLine{45         uint8\_t \textcolor{keyword}{class};}
\DoxyCodeLine{46         \textcolor{comment}{/* bInterfaceSubClass of matching interface */}}
\DoxyCodeLine{47         uint8\_t sub\_class;}
\DoxyCodeLine{48         \textcolor{comment}{/* bInterfaceProtocol of matching interface */}}
\DoxyCodeLine{49         uint8\_t protocol;}
\DoxyCodeLine{50         \textcolor{comment}{/* index of string descriptor of matching interface */}}
\DoxyCodeLine{51         uint8\_t string\_idx;}
\DoxyCodeLine{52 \};}
\DoxyCodeLine{53 }
\DoxyCodeLine{55 \textcolor{keyword}{struct }osmo\_usb\_matchspec \{}
\DoxyCodeLine{57         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{58                 \textcolor{keywordtype}{int} vendor\_id; }
\DoxyCodeLine{59                 \textcolor{keywordtype}{int} product\_id;       }
\DoxyCodeLine{60                 \textcolor{keywordtype}{char} *path; }
\DoxyCodeLine{61         \} dev;}
\DoxyCodeLine{62 }
\DoxyCodeLine{64         \textcolor{keywordtype}{int} config\_id;         }
\DoxyCodeLine{67         \textcolor{keyword}{struct }\{}
\DoxyCodeLine{68                 \textcolor{comment}{/* typically those three are set to application defaults */}}
\DoxyCodeLine{69                 \textcolor{keywordtype}{int} \textcolor{keyword}{class};      }
\DoxyCodeLine{70                 \textcolor{keywordtype}{int} subclass;   }
\DoxyCodeLine{71                 \textcolor{keywordtype}{int} proto; }
\DoxyCodeLine{73                 \textcolor{comment}{/* typically those two are -\/1; but user can override them */}}
\DoxyCodeLine{74                 \textcolor{keywordtype}{int} num;}
\DoxyCodeLine{75                 \textcolor{keywordtype}{int} altsetting;}
\DoxyCodeLine{76         \} intf;}
\DoxyCodeLine{77 \};}
\DoxyCodeLine{78 }
\DoxyCodeLine{79 }
\DoxyCodeLine{80 \textcolor{keywordtype}{char} *osmo\_libusb\_dev\_get\_path\_buf(\textcolor{keywordtype}{char} *buf, \textcolor{keywordtype}{size\_t} bufsize, libusb\_device *dev);}
\DoxyCodeLine{81 \textcolor{keywordtype}{char} *osmo\_libusb\_dev\_get\_path\_c(\textcolor{keywordtype}{void} *ctx, libusb\_device *dev);}
\DoxyCodeLine{82 }
\DoxyCodeLine{83 libusb\_device **osmo\_libusb\_find\_matching\_usb\_devs(\textcolor{keywordtype}{void} *ctx, \textcolor{keyword}{struct} libusb\_context *luctx,}
\DoxyCodeLine{84                                                    \textcolor{keyword}{const} \textcolor{keyword}{struct} dev\_id *dev\_ids);}
\DoxyCodeLine{85 }
\DoxyCodeLine{86 libusb\_device *osmo\_libusb\_find\_matching\_dev\_path(\textcolor{keyword}{struct} libusb\_context *luctx,}
\DoxyCodeLine{87                                                   \textcolor{keyword}{const} \textcolor{keyword}{struct} dev\_id *dev\_ids,}
\DoxyCodeLine{88                                                   \textcolor{keyword}{const} \textcolor{keywordtype}{char} *path);}
\DoxyCodeLine{89 }
\DoxyCodeLine{90 libusb\_device *osmo\_libusb\_find\_matching\_dev\_serial(\textcolor{keyword}{struct} libusb\_context *luctx,}
\DoxyCodeLine{91                                                     \textcolor{keyword}{const} \textcolor{keyword}{struct} dev\_id *dev\_ids,}
\DoxyCodeLine{92                                                     \textcolor{keyword}{const} \textcolor{keywordtype}{char} *serial);}
\DoxyCodeLine{93 }
\DoxyCodeLine{94 \textcolor{keywordtype}{int} osmo\_libusb\_dev\_find\_matching\_interfaces(libusb\_device *dev, \textcolor{keywordtype}{int} \textcolor{keyword}{class}, \textcolor{keywordtype}{int} sub\_class,}
\DoxyCodeLine{95                                              \textcolor{keywordtype}{int} protocol, \textcolor{keyword}{struct} usb\_interface\_match *out,}
\DoxyCodeLine{96                                              \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} out\_len);}
\DoxyCodeLine{97 }
\DoxyCodeLine{98 \textcolor{keywordtype}{int} osmo\_libusb\_find\_matching\_interfaces(libusb\_context *luctx, \textcolor{keyword}{const} \textcolor{keyword}{struct} dev\_id *dev\_ids,}
\DoxyCodeLine{99                                          \textcolor{keywordtype}{int} \textcolor{keyword}{class}, \textcolor{keywordtype}{int} sub\_class, \textcolor{keywordtype}{int} protocol,}
\DoxyCodeLine{100                                          \textcolor{keyword}{struct} usb\_interface\_match *out, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} out\_len);}
\DoxyCodeLine{101 }
\DoxyCodeLine{102 libusb\_device\_handle *osmo\_libusb\_open\_claim\_interface(\textcolor{keywordtype}{void} *ctx, libusb\_context *luctx,}
\DoxyCodeLine{103                                                         \textcolor{keyword}{const} \textcolor{keyword}{struct} usb\_interface\_match *ifm);}
\DoxyCodeLine{104 }
\DoxyCodeLine{105 \textcolor{keywordtype}{void} osmo\_libusb\_match\_init(\textcolor{keyword}{struct} osmo\_usb\_matchspec *cfg, \textcolor{keywordtype}{int} if\_class, \textcolor{keywordtype}{int} if\_subclass, \textcolor{keywordtype}{int} if\_proto);}
\DoxyCodeLine{106 }
\DoxyCodeLine{107 libusb\_device\_handle *osmo\_libusb\_find\_open\_claim(\textcolor{keyword}{const} \textcolor{keyword}{struct} osmo\_usb\_matchspec *cfg,}
\DoxyCodeLine{108                                                   \textcolor{keyword}{const} \textcolor{keyword}{struct} dev\_id *default\_dev\_ids);}
\DoxyCodeLine{109 }
\DoxyCodeLine{110 \textcolor{keywordtype}{int} osmo\_libusb\_get\_ep\_addrs(libusb\_device\_handle *devh, \textcolor{keywordtype}{unsigned} \textcolor{keywordtype}{int} if\_num,}
\DoxyCodeLine{111                              uint8\_t *out, uint8\_t *in, uint8\_t *irq);}
\DoxyCodeLine{112 }
\DoxyCodeLine{113 }
\DoxyCodeLine{114 \textcolor{keywordtype}{int} osmo\_libusb\_init(libusb\_context **luctx);}
\DoxyCodeLine{115 \textcolor{keywordtype}{void} osmo\_libusb\_exit(libusb\_context *luctx);}

\end{DoxyCode}
