4 * Copyright (c) 2012 - 2013 Samsung Electronics Co., Ltd.
6 * Licensed under the Apache License, Version 2.0 (the License);
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
19 #ifndef __USB_CLIENT_H__
20 #define __USB_CLIENT_H__
23 #include <device-node.h>
26 #include "core/devices.h"
27 #include "display/poll.h"
28 #include "core/udev.h"
29 #include "core/common.h"
30 #include "core/list.h"
31 #include "apps/apps.h"
32 #include "usb-common.h"
35 #define UDEV_PROP_KEY_SWITCH_NAME "SWITCH_NAME"
36 #define UDEV_PROP_VALUE_USB_CABLE "usb_cable"
38 #define UDEV_PROP_KEY_SWITCH_STATE "SWITCH_STATE"
39 #define UDEV_PROP_VALUE_DISCON "0"
40 #define UDEV_PROP_VALUE_CON "1"
43 #define USBMODE_SUBSYSTEM "usb_mode"
44 #define UDEV_PROP_KEY_USB_STATE "USB_STATE"
45 #define UDEV_PROP_VALUE_CONFIGURED "CONFIGURED"
48 #define UDEV_PROP_KEY_CHGDET "CHGDET"
49 #define UDEV_PROP_VALUE_USB "usb"
51 #define USB_CON_START "start"
52 #define USB_CON_STOP "stop"
54 #define USB_RESTRICT "restrict"
55 #define USB_ERROR "error"
57 #define USB_BUF_LEN 64
59 #ifndef VCONFKEY_USB_CONFIGURATION_ENABLED
60 #define VCONFKEY_USB_CONFIGURATION_ENABLED "memory/private/usb/conf_enabled"
63 enum internal_usb_mode {
64 SET_USB_DIAG_RMNET = 11,
67 enum usbclient_setting_option {
68 SET_CONFIGURATION = 0x01,
70 SET_NOTIFICATION = 0x04,
78 struct usb_configuration {
79 char name[USB_BUF_LEN];
80 char value[USB_BUF_LEN];
83 struct usb_operation {
84 char name[USB_BUF_LEN];
85 char oper[USB_BUF_LEN];
89 int make_configuration_list(int usb_mode);
90 void release_configuration_list(void);
91 int make_operation_list(int usb_mode, char *action);
92 void release_operations_list(void);
94 int get_root_path(char **path);
95 int get_operations_list(dd_list **list);
96 int get_configurations_list(dd_list **list);
99 void client_mode_changed(keynode_t* key, void *data);
100 void prev_client_mode_changed(keynode_t* key, void *data);
101 void debug_mode_changed(keynode_t* key, void *data);
102 void tethering_status_changed(keynode_t* key, void *data);
104 /* Check usb state */
105 int get_default_mode(void);
106 int get_current_usb_physical_state(void);
107 int get_current_usb_logical_state(void);
108 int get_current_usb_mode(void);
109 int get_selected_usb_mode(void);
110 int get_debug_mode(void);
111 int change_selected_usb_mode(int mode);
112 int update_current_usb_mode(int mode);
113 int update_usb_state(int state);
114 unsigned int get_current_usb_gadget_info(int mode);
117 void unset_client_mode(int mode, bool change);
120 int control_start(enum device_flags flags);
121 int control_stop(enum device_flags flags);
122 int control_status(void);
123 void wait_until_booting_done(void);
124 void usbclient_init_booting_done(void);
125 void act_usb_connected(void);
126 int register_usbclient_dbus_methods(void);
127 void send_msg_usb_state_changed(void);
128 void send_msg_usb_mode_changed(void);
131 void launch_syspopup(char *str);
133 /* Change usb mode */
134 void change_client_setting(int options);
135 bool get_wait_configured(void);
138 void usb_state_changed(int state);
140 #endif /* __USB_CLIENT_H__ */