Refactoring usb function variable in usb gadget
[platform/core/system/libdevice-node.git] / hw / usb_gadget.h
index ad53d0e..c0ac3dc 100644 (file)
 #ifndef __HW_USB_GADGET_H__
 #define __HW_USB_GADGET_H__
 
-#include <hw/common.h>
+#include <stdint.h>
 
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-#include <errno.h>
+#include <hw/common.h>
 
-/**
- * The id of this device
- */
+/* The id of this device */
 #define USB_GADGET_DEVICE_ID   "usb_gadget"
 
-/**
- * The version of this device
- */
+/*The version of this device */
 #define USB_GADGET_DEVICE_VERSION      MAKE_VERSION(0,1)
 
+/*The default USB configuration */
+#define DEFAULT_VID 0x04e8
+#define DEFAULT_PID 0x6860
+#define DEFAULT_BCD_DEVICE 0x0100
+
+#define DEFAULT_LANG 0x409 /* US_en */
+#define DEFAULT_MANUFACTURER "Samsung"
+#define DEFAULT_PRODUCT "TIZEN"
+#define DEFAULT_SERIAL "01234TEST"
+
+#define DEFAULT_BMATTRIBUTES ((1 << 7) | (1 << 6))
+#define DEFAULT_MAX_POWER 500
+
 typedef enum {
        USB_FUNCTION_IDX_MTP         = 0,
        USB_FUNCTION_IDX_ACM         = 1,
@@ -83,9 +89,6 @@ struct usb_function {
        const char *service;
 
        void (*handler)(int enable);
-
-       int (*clone)(struct usb_function *func, struct usb_function **_clone);
-       void (*free_func)(struct usb_function *func);
 };
 
 struct usb_configuration_attributes {
@@ -100,7 +103,7 @@ struct usb_configuration_strings {
 
 struct usb_configuration {
        struct usb_configuration_attributes attrs;
-       struct usb_configuration_strings *strs;
+       struct usb_configuration_strings strs;
        struct usb_function **funcs;
 };
 
@@ -122,8 +125,7 @@ struct usb_gadget_strings {
 
 struct usb_gadget {
        struct usb_gadget_attrs attrs;
-       struct usb_gadget_strings *strs;
-       struct usb_function **funcs;
+       struct usb_gadget_strings strs;
        struct usb_configuration **configs;
 };
 
@@ -134,16 +136,15 @@ struct usb_gadget_id {
 struct usb_gadget_translator {
        struct hw_common common;
 
-       int (*id_to_gadget)(struct usb_gadget_id *gadget_id,
-                        struct usb_gadget **gadget);
-
+       int (*id_to_gadget)(struct usb_gadget_id *gadget_id,  struct usb_gadget **gadget);
        void (*cleanup_gadget)(struct usb_gadget *gadget);
 };
 
-int simple_translator_open(struct hw_info *info,
-               const char *id, struct hw_common **common);
+int simple_translator_open(struct hw_info *info, const char *id, struct hw_common **common);
 int simple_translator_close(struct hw_common *common);
 
-extern struct usb_function *_available_funcs[];
+struct usb_function *find_usb_function_by_id(int id);
+struct usb_function *find_usb_function_by_name(const char *name);
+struct usb_function *find_usb_function_by_name_instance(const char *name, const char *instance);
 
 #endif