-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathgc_generic.h
68 lines (52 loc) · 1.48 KB
/
gc_generic.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
// SPDX-License-Identifier: GPL-2.0-only
/*
* Copyright (C) 2021-2022 HandsomeMod Project
*
* Handsomeyingyan <[email protected]>
*
* GC(Gadget Controller) is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
*/
#ifndef GC_GENERIC_H
#define GC_GENERIC_H
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <linux/usb/ch9.h>
#include <usbg/usbg.h>
#define GC_SUCCESS 0
#define GC_FAILED -1
#define GC_CONFIG_PATH "/sys/kernel/config"
typedef enum {
USB_HOST,
USB_GADGET
}gc_usb_mode;
// generic info passed by cmake
typedef struct {
char *serial_number;
char *manufacturer;
char *product;
unsigned int id_vendor;
unsigned int id_product;
}gc_generic_info;
usbg_gadget * gc_init(gc_generic_info info);
/* 获取usb模式 */
gc_usb_mode gc_get_mode();
/* 生成id */
char *gc_generate_id(usbg_function_type type);
/* 删除特定的function */
int gc_delete_function(gc_generic_info info,char *target);
/* 清除所有的gadget */
int gc_remove_all_gadgets(gc_generic_info info);
/* 销毁usb gadget */
void gc_clean();
/* 手动开启gadget */
int gc_enable_gadget(gc_generic_info info);
/* 手动关闭gadget */
int gc_disable_gadget(gc_generic_info info);
/* 得到config */
usbg_config *gc_get_config(usbg_gadget *gadget);
#endif //GC_GENERIC_H