-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathqtiDevInf.h
158 lines (135 loc) · 5.48 KB
/
qtiDevInf.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
// Copyright (c) 2024, Qualcomm Innovation Center, Inc. All rights reserved.
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*===========================================================================
FILE:
qtiDevInf.h
DESCRIPTION:
Linux Serial USB driver Implementation for QTI hardwar
==========================================================================*/
#ifndef QTIDEVINF_H
#define QTIDEVINF_H
#include <linux/kernel.h>
#include <linux/slab.h>
#include <linux/module.h>
#include <linux/usb.h>
#include <linux/string.h>
#include <linux/ctype.h>
#include <linux/uaccess.h>
#include <linux/version.h>
#define QTIDEV_INF_DEFAULT_VENDOR "QTI" /**< Default Vendor */
#define QTIDEV_INF_CLASS_STR "Class" /**< INF 'class' Section */
#define QTIDEV_INF_VERSION_STR "Version" /**< INF 'version' Section */
#define QTIDEV_INF_STRING_STR "String" /**< INF 'string' Section */
#define QTIDEV_INF_MANUFACTURER_STR "Manufacturer"/**< INF Manufacturer sec */
#define QTIDEV_INF_MAX_KEY_SIZE 64 /**< Maximum key size */
#define QTIDEV_INF_MAX_LINE_SIZE (512) /**< Maximum INF Line size */
#define QTIDEV_INF_DICT_OPERATOR ":=" /**< Possible dict operators */
#define QTIDEV_INF_START_SECTION "[" /**< Possible start operators */
#define QTIDEV_INF_END_SECTION "]" /**< Possible end operators */
#define QTIDEV_INF_START_COMMENT_PREFIXES ";#" /**< Possible comments */
#define QTIDEV_INF_CLASS_NET_STR "Net" /**< For WWan entry */
#define QTIDEV_INF_CLASS_MODEM_STR "Modem" /**< For Dun entry */
#define QTIDEV_INF_CLASS_PORTS_STR "Ports" /**< For Ports entry */
#define QTIDEV_INF_CLASS_USB_STR "USB" /**< For QDSS entry */
#define LOGGING
#ifndef DBG
#ifdef LOGGING
#define DBG(format, args...) printk( KERN_INFO "%s:%d " format, __FUNCTION__, __LINE__, ##args)
#else
#define DBG(args...) do {} while (0)
#endif
#endif
/**
* @brief QTIdev device type Info
*/
typedef enum {
QTIDEV_INF_TYPE_TRACE_IN, /**< Type QDSS Trace/ Bulk in */
QTIDEV_INF_TYPE_DPL, /**< Type QDSS DPL/ Bulk in */
QTIDEV_INF_TYPE_BULK, /**< Type QDSS Bulk */
/* @note : After extracting data from INF file
* we only get the info whether the device is 'DPL (or) Bulk'
* need to extract further for 'Bulk in/out'/ 'Trace', based
* on number of endpoints
*/
QTIDEV_INF_TYPE_BULK_IN_OUT, /**< Type QDSS Bulk In Out */
QTIDEV_INF_TYPE_LPC, /**< Type LPC Bulk In Out */
QTIDEV_INF_TYPE_UNKNOWN /**< Unknown QDSS Type */
} QTIdevtype;
/**
* @brief device Class Info (ex: Net, Modem ..etc)
*/
typedef enum {
QTIDEV_INF_CLASS_NET = 0, /**< For WWan entry */
QTIDEV_INF_CLASS_MODEM, /**< For Dun entry */
QTIDEV_INF_CLASS_PORTS, /**< For Ports entry */
QTIDEV_INF_CLASS_USB, /**< For QDSS entry */
QTIDEV_INF_CLASS_UNKNOWN /**< Unknown Class Type */
} deviceClass;
typedef enum {
QTIDEV_INF_VERSION = 0, /**< Inf 'version' info */
QTIDEV_INF_MANUFACTURER, /**< Inf 'manufacturer' info*/
QTIDEV_INF_DEVICE_INFO, /**< Inf 'device info' info */
QTIDEV_INF_STRING, /**< Inf 'string' info */
QTIDEV_INF_UNKNOWN /**< Unknown Section */
} sectionInfo_t;
typedef struct _devInfo {
QTIdevtype mDevType; /**< Device type */
char mpKey[QTIDEV_INF_MAX_KEY_SIZE]; /**< device friendly name */
int mVid_pid_iface[3]; /**< VID/PID/INT */
} devInfo_t;
typedef struct _fileInfo {
deviceClass mClass; /**< INF/Config file class */
unsigned int mLength; /**< Number of devices can occupy */
unsigned int mNumResp; /**< Number of devices present */
struct _devInfo mDevInfo[0];
}fileInfo_t;
/**
* @brief To extract the device info from the stored data
*
* Returns the device info, which is been extracted from
* INF file and strored in pFileInfo
*
* @param pIface usb_interface info
* @param pFileInfo global Ctx, contains INF info
*
* @returns devInfo on Success / NULL on Failure
*/
void* QTIDevInfGetDevInfo(struct usb_interface *pIface, fileInfo_t *pFileInfo);
/**
* @brief To verify whether the INF/config file is modified
*
* Returns the file status
*
* @param pFileInfo global Ctx, contains INF info
* @param pFilePath INF/Config file path
*
* @returns true - If no change in config file
* false - Config file got modified
* negative error - If file got corrupted/removed
*/
int QTIDevInfCheckFileStatus(fileInfo_t *pFileInfo, char *pFilePath);
/**
* @brief To get number of entries present in INF/config file
*
* Returns the count of device entries
*
* @param pFileInfo global Ctx, contains INF info
* @param pFilePath INF/Config file path
*
* @returns count - number of devices present
* negative error - If file got corrupted/removed
*/
int QTIDevInfEntrySize(void *pFilePath);
/**
* @brief To extract the device info and store in ctx
*
* extracts the device info from file 'pFilePath', and stores in pFileInfo
*
* @param pFilePath INF/Config file path
* @param pFileInfo global Ctx, contains INF info
*
* @returns 0 on Success
* negative error - If file got corrupted/removed/invalid
*/
int QTIDevInfParse(void *pFilePath, fileInfo_t *pFileInfo);
#endif