aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/gadget/multi_config.h
blob: 792bbaedc15bad26f6694e1a5396e86a0ea0f89a (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
/*
 * File Name : multi_config.h
 *
 * Virtual multi configuration utilities for composite USB gadgets.
 * This utilitie can support variable interface for variable Host PC.
 *
 * Copyright (C) 2011 Samsung Electronics
 * Author: SoonYong, Cho <soonyong.cho@samsung.com>
 *
 * This software is licensed under the terms of the GNU General Public
 * License version 2, as published by the Free Software Foundation, and
 * may be copied, distributed, and modified under those terms.
 *
 * 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.
 *
 */

#ifndef __MULTI_CONFIG_H
#define __MULTI_CONFIG_H

#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/usb/composite.h>

/*
 * Debugging macro and defines
 */
/*#define USB_DEBUG
 *#define USB_MORE_DEBUG
 */
#define USB_DEBUG_ESS

#ifdef USB_DEBUG
#  ifdef USB_MORE_DEBUG
#    define USB_DBG(fmt, args...) \
	printk(KERN_INFO "usb: %s "fmt, __func__, ##args)
#  else
#    define USB_DBG(fmt, args...) \
	printk(KERN_DEBUG "usb: %s "fmt, __func__, ##args)
#  endif
#else /* DO NOT PRINT LOG */
#  define USB_DBG(fmt, args...) do { } while (0)
#endif /* USB_DEBUG */

#ifdef USB_DEBUG_ESS
#  ifdef USB_MORE_DEBUG
#    define USB_DBG_ESS(fmt, args...) \
	printk(KERN_INFO "usb: %s "fmt, __func__, ##args)
#  else
#    define USB_DBG_ESS(fmt, args...) \
	printk(KERN_DEBUG "usb: %s "fmt, __func__, ##args)
#  endif
#else /* DO NOT PRINT LOG */
#  define USB_DBG_ESS(fmt, args...) do { } while (0)
#endif /* USB_DEBUG_ESS */

#define MAIN_FUNCTION "mtp"
#define MULTI_FUNCTION_1 "mtp"
#define MULTI_FUNCTION_2 "acm0"
#define MULTI_EXCEPTION_FUNCTION "adb"

#define MAC_REQUEST	0
#define OTHER_REQUEST	1

/* Description  : Set configuration number
 * Parameter    : unsigned num (host request)
 * Return value : always return 0 (It's virtual multiconfiguration)
 */
unsigned set_config_number(unsigned num);

/* Description  : Get configuration number
 * Return value : virtual multiconfiguration number (zero base)
 */
int get_config_number(void);

/* Description  : Check configuration number
 * Parameter    : unsigned num (host request)
 * Return value : 1 (true  : virtual multi configuraiton)
		  0 (false : normal configuration)
 */
int check_config(unsigned num);

/* Description  : Search number of configuration including virtual configuration
 * Parameter    : usb_configuration *c (referenced configuration)
		  unsigned count (real number of configuration)
 * Return value : virtual or real number of configuration
 */
unsigned count_multi_config(struct usb_configuration *c, unsigned count);

/* Description  : Is multi configuration available ?
 * Return value : 1 (true), 0 (false)
 */
int is_multi_configuration(void);

/* Description  : Check function to skip for multi configuration
 * Parameter    : char* name (function name)
 * Return value : 0 (not available), 1 (available)
 */
int is_available_function(const char *name);

/* Description  : Change configuration using virtual multi configuration.
 * Parameter    : struct usb_funciton f (to be changed function interface)
		  void *next (next means usb req->buf)
		  int len (length for to fill buffer)
		  struct usb_configuration *config
		  (To reference interface array of current config)
		  enum usb_device_speed speed (usb speed)
 * Return value : "ret < 0" means fillbuffer function is failed.
 */
int change_conf(struct usb_function *f,
		void *next, int len,
		struct usb_configuration *config,
		enum usb_device_speed speed);

/* Description  : Set interface count
 * Parameter    : struct usb_configuration *config
		  (To reference interface array of current config)
		  struct usb_config_descriptor *c
		  (number of interfaces)
 * Return value : void
 */
void set_interface_count(struct usb_configuration *config,
	struct usb_config_descriptor *c);

/* Description  : Set string mode
 *		  This mode will be used for deciding other interface.
 * Parameter    : u16 w_length
 *		  - 2 means MAC request.
 *		  - Windows and Linux PC always request 255 size.
 */
void set_string_mode(u16 w_length);
#endif /* __MULTI_CONFIG_H */