summaryrefslogtreecommitdiffstats
path: root/Src/Network/base/.svn/text-base/DriverConfiguration.h.svn-base
blob: f79ce8f3901398258e8b86f402df7790bd1659e3 (plain)
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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
/*
 * Video On Demand Samples
 *
 * Copyright (C) 2015 Microchip Technology Germany II GmbH & Co. KG
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 2 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 * You may also obtain this software under a propriety license from Microchip.
 * Please contact Microchip for further information.
 *
 */

/*----------------------------------------------------------*/
/*! \file
 * \brief This component provides helper tools to deal with USB endpoints.
 */
/*----------------------------------------------------------*/
#ifndef DRIVERCONFIGURATION_H
#define DRIVERCONFIGURATION_H

#include <stdint.h>
#include <stdbool.h>
#include "Types.h"

#ifdef __cplusplus
extern "C"
{
#endif

    /*----------------------------------------------------------*/
    /*! \brief Checks if the given USB device instance exists.
     *
     * \param deviceInstance    - The device instance of the USB INIC, starting at 0 for the first instance.
     *
     * \return true: Device exists.
     * \return false: Device does not exist.
     */
    /*----------------------------------------------------------*/
    bool ExistsUsbDeviceInstance( uint8_t deviceInstance );

    /*----------------------------------------------------------*/
    /*! \brief Checks if the given MLB device instance exists.
     *
     * \param deviceInstance    - The device instance of the MLB INIC, starting at 0 for the first instance.
     *
     * \return true: Device exists.
     * \return false: Device does not exist.
     */
    /*----------------------------------------------------------*/
    bool ExistsMlbDeviceInstance( uint8_t deviceInstance );

    /*----------------------------------------------------------*/
    /*! \brief Checks if the given I2C device instance exists.
     *
     * \param deviceInstance    - The device instance of the I2C INIC, starting at 0 for the first instance.
     *
     * \return true: Device exists.
     * \return false: Device does not exist.
     */
    /*----------------------------------------------------------*/
    bool ExistsI2CDeviceInstance( uint8_t deviceInstance );

    /*----------------------------------------------------------*/
    /*! \brief Retreives the Linux character device names for the given USB device instance and the endpoint address.
     *
     * \note If the given buffer is too small to hold the whole path, the string is truncated and not useable!
     *
     * \param deviceInstance    - The device instance of the USB INIC, starting at 0 for the first instance.
     * \param endpointAddress   - The USB endpoint address, RX endpoints starting with upper bit set (0x8X).
     * \param deviceName        - [in,out] Given buffer will be filled with device name (starting with /dev/).
     * \param deviceNameLength  - The length of the given deviceName buffer in bytes.
     * \param systemName        - [in,out] Given buffer will be filled with system name (starting with /sys/).
     * \param systemNameLength  - The length of the given systemName buffer in bytes.
     * \param linkName          - [in,out] Given buffer will be filled with the string needed to register this device to an AIM
     * \param linkNameLength    - The length of the given linkName buffer in bytes.
     *
     * \return true: Operation was successful.
     * \return false: Operation failed, device or endpoint does not exist.
     */
    /*----------------------------------------------------------*/
    bool GetUsbDeviceNames( uint8_t deviceInstance, uint8_t endpointAddress, char *deviceName,
        uint16_t deviceNameLength, char *systemName, uint16_t systemNameLength, char *linkName,
        uint16_t linkNameLength );


    /*----------------------------------------------------------*/
    /*! \brief Retreives the Linux character device names for the given MLB device instance and the endpoint address.
     *
     * \note If the given buffer is too small to hold the whole path, the string is truncated and not useable!
     *
     * \param deviceInstance    - The device instance of the USB INIC, starting at 0 for the first instance.
     * \param mlbChannelAddress - The MLB channel address
     * \param deviceName        - [in,out] Given buffer will be filled with device name (starting with /dev/).
     * \param deviceNameLength  - The length of the given deviceName buffer in bytes.
     * \param systemName        - [in,out] Given buffer will be filled with system name (starting with /sys/).
     * \param systemNameLength  - The length of the given systemName buffer in bytes.
     * \param linkName          - [in,out] Given buffer will be filled with the string needed to register this device to an AIM
     * \param linkNameLength    - The length of the given linkName buffer in bytes.
     *
     * \return true: Operation was successful.
     * \return false: Operation failed, device or endpoint does not exist.
     */
    /*----------------------------------------------------------*/
    bool GetMlbDeviceNames( uint8_t deviceInstance, uint8_t mlbChannelAddress, char *deviceName,
        uint16_t deviceNameLength, char *systemName, uint16_t systemNameLength, char *linkName,
        uint16_t linkNameLength );


    /*----------------------------------------------------------*/
    /*! \brief Retreives the Linux character device names for the given I2C device instance and the endpoint address.
     *
     * \note If the given buffer is too small to hold the whole path, the string is truncated and not useable!
     *
     * \param deviceInstance    - The device instance of the I2C INIC, starting at 0 for the first instance.
     * \param isTx              - true, if the names for transmission path should be retrieved, otherwise for the reception path.
     * \param deviceName        - [in,out] Given buffer will be filled with device name (starting with /dev/).
     * \param deviceNameLength  - The length of the given deviceName buffer in bytes.
     * \param systemName        - [in,out] Given buffer will be filled with system name (starting with /sys/).
     * \param systemNameLength  - The length of the given systemName buffer in bytes.
     * \param linkName          - [in,out] Given buffer will be filled with the string needed to register this device to an AIM
     * \param linkNameLength    - The length of the given linkName buffer in bytes.
     *
     * \return true: Operation was successful.
     * \return false: Operation failed, device or endpoint does not exist.
     */
    /*----------------------------------------------------------*/
    bool GetI2CDeviceNames( uint8_t deviceInstance, bool isTx, char *deviceName, uint16_t deviceNameLength,
        char *systemName, uint16_t systemNameLength, char *linkName, uint16_t linkNameLength );

    /*----------------------------------------------------------*/
    /*! \brief Closes the MOST channel.
     *
     * \param device    - The system path to configure the MOST device (starting with "/sys/").
     *
     * \return True if no error
     */
    /*----------------------------------------------------------*/
    bool CloseMostChannel( const char *device );

    /*----------------------------------------------------------*/
    /*! \brief Configures the MOST channel.
     *
     * \param device    - The system path to configure the MOST device (starting with "/sys/").
     * \param mostType  - The MOST data type (control, asynchron, synchron, isochron).
     * \param direction - The direction of the stream (directionRX, directionTX).
     * \param numBuf    - The amount of buffers.
     * \param bufSize   - The size of each buffer in bytes.
     *
     * \return True if no error
     */
    /*----------------------------------------------------------*/
    bool ConfigureMostChannel( const char *device, EPDataType_t mostType, EPDirection_t direction, uint32_t numBuf,
        uint32_t bufSize );

    /*----------------------------------------------------------*/
    /*! \brief Configures the isochronous channel of a device.
     *  \note This function has to be called before ConfigureMostChannel!
     *
     * \param device    - The system path to configure the MOST device (starting with "/sys/").
     * \param subbufferSize - The amount of bytes for a single subbuffer (eg. 188 or 196 bytes).
     * \param packetsPerTransaction - The amount of ischronous packets per transaction.
     *
     * \return True if no error
     */
    /*----------------------------------------------------------*/
    bool ConfigureIsocChannel( const char *device, uint32_t subbufferSize, uint32_t packetsPerTransaction );

    /*----------------------------------------------------------*/
    /*! \brief Configures the Synchronous channel of a device.
     *  \note This function has to be called before ConfigureMostChannel!
     *
     * \param device    - The system path to configure the MOST device (starting with "/sys/").
     * \param syncBlockWidth - The bandwidth of a single synchronous frame. Ignored if not sync channel.
     * \param amounOfSyncFrames - The amount of synchronous frames per USB packet. Ignored if not sync channel.
     *
     * \return True if no error
     */
    /*----------------------------------------------------------*/
    bool ConfigureSyncChannel( const char *device, uint32_t syncBlockWidth, uint32_t amounOfSyncFrames );


    /*----------------------------------------------------------*/
    /*! \brief Creates a character device for the given device's link name.
     *
     * \param linkName          - [in] Link name, which is needed to register this device to an AIM.
     * \param deviceName        - [in,out] Device name (starting with /dev/).
     *
     * \return True if no error
     */
    /*----------------------------------------------------------*/
    bool LinkToCharacterDevice( const char *linkName, const char *deviceName );


    /*----------------------------------------------------------*/
    /*! \brief Creates a audio device (ALSA) for the given device's link name.
     *
     * \param linkName          - [in] Link name, which is needed to register this device to an AIM.
     * \param subBufferSize     - [in] The amount of bytes for all channels of this connection on the MOST.
     *
     * \return True if no error
     */
    /*----------------------------------------------------------*/
    bool LinkToAudioDevice( const char *linkName, uint16_t subBufferSize );

    /*----------------------------------------------------------*/
    /*! \brief Creates a Video for Linux device (V4L) for the given device's link name.
     *
     * \param linkName          - [in] Link name, which is needed to register this device to an AIM.
     *
     * \return True if no error
     */
    /*----------------------------------------------------------*/
    bool LinkToVideoForLinuxDevice( const char *linkName );


    /*----------------------------------------------------------*/
    /*! \brief Parsed the global errno variable and generate a human readable error description out of it.
     *
     * \return Zero terminated error description string.
     */
    /*----------------------------------------------------------*/
    const char *GetErrnoString();

#ifdef __cplusplus
}
#endif

#endif //DRIVERCONFIGURATION_H