Created
May 26, 2012 12:58
-
-
Save amery/2793851 to your computer and use it in GitHub Desktop.
android gadget lost changes in 3.3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 2e14a78d5f0d2e85117fe1dfca9667693ab31da8 | |
Author: javen <javen@MServer.allwinnertech.com> | |
Date: Mon Nov 28 20:41:11 2011 +0800 | |
fixed bug for android | |
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c | |
index bff6c84..3b4e281 100644 | |
--- a/drivers/usb/gadget/android.c | |
+++ b/drivers/usb/gadget/android.c | |
@@ -789,7 +789,11 @@ static int mass_storage_function_init(struct android_usb_function *f, | |
memset(name, 0, 32); | |
- snprintf(name, 5, "lun%d\n", i); | |
+ if(i){ | |
+ snprintf(name, 5, "lun%d\n", i); | |
+ }else{ | |
+ strcpy(name, "lun"); | |
+ } | |
printk("lun name: %s\n", name); | |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c | |
index dc06da6..da1b795 100644 | |
--- a/drivers/usb/gadget/composite.c | |
+++ b/drivers/usb/gadget/composite.c | |
@@ -585,6 +585,9 @@ static int remove_config(struct usb_composite_dev *cdev, | |
config->unbind(config); | |
/* may free memory for "c" */ | |
} | |
+ | |
+ usb_ep_autoconfig_reset(cdev->gadget); | |
+ | |
return 0; | |
} | |
diff --git a/drivers/usb/gadget/f_adb.c b/drivers/usb/gadget/f_adb.c | |
index 1c0166c..94290db 100644 | |
--- a/drivers/usb/gadget/f_adb.c | |
+++ b/drivers/usb/gadget/f_adb.c | |
@@ -466,15 +466,19 @@ adb_function_bind(struct usb_configuration *c, struct usb_function *f) | |
/* allocate interface ID(s) */ | |
id = usb_interface_id(c, f); | |
- if (id < 0) | |
+ if (id < 0) { | |
+ printk(KERN_ERR "usb_interface_id failed\n"); | |
return id; | |
+ } | |
adb_interface_desc.bInterfaceNumber = id; | |
/* allocate endpoints */ | |
ret = adb_create_bulk_endpoints(dev, &adb_fullspeed_in_desc, | |
&adb_fullspeed_out_desc); | |
- if (ret) | |
+ if (ret) { | |
+ printk(KERN_ERR "adb_create_bulk_endpoints failed\n"); | |
return ret; | |
+ } | |
/* support high speed hardware */ | |
if (gadget_is_dualspeed(c->cdev->gadget)) { | |
diff --git a/drivers/usb/host/ehci_sun4i.c b/drivers/usb/host/ehci_sun4i.c | |
index 6c9c6bb..e5f7623 100644 | |
--- a/drivers/usb/host/ehci_sun4i.c | |
+++ b/drivers/usb/host/ehci_sun4i.c | |
@@ -645,9 +645,10 @@ static int sw_ehci_hcd_suspend(struct device *dev) | |
clear_bit(HCD_FLAG_HW_ACCESSIBLE, &hcd->flags); | |
- sw_stop_ehci(sw_ehci); | |
spin_unlock_irqrestore(&ehci->lock, flags); | |
+ sw_stop_ehci(sw_ehci); | |
+ | |
return 0; | |
} | |
diff --git a/drivers/usb/sun4i_usb/udc/sw_udc.c b/drivers/usb/sun4i_usb/udc/sw_udc.c | |
index b211fcd..205e815 100644 | |
--- a/drivers/usb/sun4i_usb/udc/sw_udc.c | |
+++ b/drivers/usb/sun4i_usb/udc/sw_udc.c | |
@@ -2700,13 +2700,13 @@ static int sw_udc_set_pullup(struct sw_udc *udc, int is_on) | |
{ | |
DMSG_DBG_UDC("sw_udc_set_pullup\n"); | |
+ is_udc_enable = is_on; | |
+ | |
if(!is_peripheral_active()){ | |
DMSG_PANIC("ERR: usb device is not active\n"); | |
return 0; | |
} | |
- is_udc_enable = is_on; | |
- | |
if(is_on){ | |
sw_udc_enable(udc); | |
}else{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 66c8b364a43fd7b7b98c3434429ff5b5c07f0c1d | |
Author: Javen <javen@allwinnertech.com> | |
Date: Fri Nov 25 14:02:28 2011 +0800 | |
usb: add sys_config support | |
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c | |
index 3abc53a..bff6c84 100644 | |
--- a/drivers/usb/gadget/android.c | |
+++ b/drivers/usb/gadget/android.c | |
@@ -45,7 +45,6 @@ | |
#include "epautoconf.c" | |
#include "composite.c" | |
-#include "f_audio_source.c" | |
#include "f_mass_storage.c" | |
#include "u_serial.c" | |
#include "f_acm.c" | |
@@ -218,6 +217,135 @@ static void android_disable(struct android_dev *dev) | |
} | |
/*-------------------------------------------------------------------------*/ | |
+ | |
+struct g_android_usb_config{ | |
+ /* usb feature */ | |
+ u32 vendor_id; | |
+ u32 mass_storage_id; | |
+ u32 adb_id; | |
+ | |
+ char usb_manufacturer_name[64]; | |
+ char usb_product_name[64]; | |
+ char usb_serial_number[64]; | |
+ | |
+ /* usb_mass_storage feature */ | |
+ char msc_vendor_name[64]; | |
+ char msc_product_name[64]; | |
+ u32 msc_release; | |
+ u32 luns; | |
+}; | |
+ | |
+#include <mach/sys_config.h> | |
+ | |
+static s32 get_msc_config(struct g_android_usb_config *config) | |
+{ | |
+ s32 ret = 0; | |
+ | |
+ //---------------------------------------- | |
+ // usb_feature | |
+ //---------------------------------------- | |
+ | |
+ /* vendor_id */ | |
+ ret = script_parser_fetch("usb_feature", "vendor_id", (int *)&(config->vendor_id), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature vendor_id failed\n"); | |
+ } | |
+ | |
+ /* mass_storage_id */ | |
+ ret = script_parser_fetch("usb_feature", "mass_storage_id", (int *)&(config->mass_storage_id), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature mass_storage_id failed\n"); | |
+ } | |
+ | |
+ /* adb_id */ | |
+ ret = script_parser_fetch("usb_feature", "adb_id", (int *)&(config->adb_id), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature adb_id failed\n"); | |
+ } | |
+ | |
+ /* manufacturer_name */ | |
+ ret = script_parser_fetch("usb_feature", "manufacturer_name", (int *)config->usb_manufacturer_name, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature manufacturer_name failed\n"); | |
+ } | |
+ | |
+ /* product_name */ | |
+ ret = script_parser_fetch("usb_feature", "product_name", (int *)config->usb_product_name, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature product_name failed\n"); | |
+ } | |
+ | |
+ /* serial_number */ | |
+ ret = script_parser_fetch("usb_feature", "serial_number", (int *)config->usb_serial_number, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature serial_number failed\n"); | |
+ } | |
+ | |
+ //---------------------------------------- | |
+ // msc_feature | |
+ //---------------------------------------- | |
+ | |
+ /* vendor_name */ | |
+ ret = script_parser_fetch("msc_feature", "vendor_name", (int *)config->msc_vendor_name, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get msc_feature vendor_name failed\n"); | |
+ } | |
+ | |
+ /* product_name */ | |
+ ret = script_parser_fetch("msc_feature", "product_name", (int *)config->msc_product_name, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get msc_feature product_name failed\n"); | |
+ } | |
+ | |
+ /* release */ | |
+ ret = script_parser_fetch("msc_feature", "release", (int *)&(config->msc_release), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get msc_feature release failed\n"); | |
+ } | |
+ | |
+ /* luns */ | |
+ ret = script_parser_fetch("msc_feature", "luns", (int *)&(config->luns), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get msc_feature luns failed\n"); | |
+ } | |
+ | |
+ return 0; | |
+} | |
+ | |
+static void print_msc_config(struct g_android_usb_config *config) | |
+{ | |
+ printk("------print_msc_config-----\n"); | |
+ printk("vendor_id = 0x%x\n", config->vendor_id); | |
+ printk("mass_storage_id = 0x%x\n", config->mass_storage_id); | |
+ printk("adb_id = 0x%x\n", config->adb_id); | |
+ | |
+ printk("usb_manufacturer_name = %s\n", config->usb_manufacturer_name); | |
+ printk("usb_product_name = %s\n", config->usb_product_name); | |
+ printk("usb_serial_number = %s\n", config->usb_serial_number); | |
+ | |
+ printk("msc_vendor_name = %s\n", config->msc_vendor_name); | |
+ printk("msc_product_name = %s\n", config->msc_product_name); | |
+ printk("msc_release = %d\n", config->msc_release); | |
+ printk("luns = %d\n", config->luns); | |
+ printk("---------------------------\n"); | |
+} | |
+ | |
+static struct g_android_usb_config g_android_usb_config; | |
+ | |
+static s32 modify_device_data(void) | |
+{ | |
+ struct g_android_usb_config *config = &g_android_usb_config; | |
+ | |
+ memset(config, 0, sizeof(struct g_android_usb_config)); | |
+ | |
+ get_msc_config(config); | |
+ | |
+ print_msc_config(config); | |
+ | |
+ return 0; | |
+} | |
+ | |
+/*-------------------------------------------------------------------------*/ | |
/* Supported functions initialization */ | |
struct adb_data { | |
@@ -630,14 +758,25 @@ static int mass_storage_function_init(struct android_usb_function *f, | |
struct mass_storage_function_config *config; | |
struct fsg_common *common; | |
int err; | |
+ int i = 0; | |
config = kzalloc(sizeof(struct mass_storage_function_config), | |
GFP_KERNEL); | |
if (!config) | |
return -ENOMEM; | |
- config->fsg.nluns = 1; | |
- config->fsg.luns[0].removable = 1; | |
+ if(g_android_usb_config.luns <= FSG_MAX_LUNS){ | |
+ config->fsg.nluns = g_android_usb_config.luns; | |
+ }else{ | |
+ printk("err: g_android_usb_config.luns is too big, (%d, 8)\n", g_android_usb_config.luns); | |
+ } | |
+ | |
+ for(i = 0; i < config->fsg.nluns; i++){ | |
+ config->fsg.luns[i].removable = 1; | |
+ config->fsg.luns[i].ro = 0; | |
+ config->fsg.luns[i].cdrom = 0; | |
+ config->fsg.luns[i].nofua = 0; | |
+ } | |
common = fsg_common_init(NULL, cdev, &config->fsg); | |
if (IS_ERR(common)) { | |
@@ -645,13 +784,23 @@ static int mass_storage_function_init(struct android_usb_function *f, | |
return PTR_ERR(common); | |
} | |
- err = sysfs_create_link(&f->dev->kobj, | |
- &common->luns[0].dev.kobj, | |
- "lun"); | |
- if (err) { | |
- kfree(config); | |
- return err; | |
- } | |
+ for(i = 0; i < config->fsg.nluns; i++){ | |
+ char name[32]; | |
+ | |
+ memset(name, 0, 32); | |
+ | |
+ snprintf(name, 5, "lun%d\n", i); | |
+ | |
+ printk("lun name: %s\n", name); | |
+ | |
+ err = sysfs_create_link(&f->dev->kobj, | |
+ &common->luns[i].dev.kobj, | |
+ name); | |
+ if (err) { | |
+ kfree(config); | |
+ return err; | |
+ } | |
+ } | |
config->common = common; | |
f->config = config; | |
@@ -741,67 +890,6 @@ static struct android_usb_function accessory_function = { | |
.ctrlrequest = accessory_function_ctrlrequest, | |
}; | |
-static int audio_source_function_init(struct android_usb_function *f, | |
- struct usb_composite_dev *cdev) | |
-{ | |
- struct audio_source_config *config; | |
- | |
- config = kzalloc(sizeof(struct audio_source_config), GFP_KERNEL); | |
- if (!config) | |
- return -ENOMEM; | |
- config->card = -1; | |
- config->device = -1; | |
- f->config = config; | |
- return 0; | |
-} | |
- | |
-static void audio_source_function_cleanup(struct android_usb_function *f) | |
-{ | |
- kfree(f->config); | |
-} | |
- | |
-static int audio_source_function_bind_config(struct android_usb_function *f, | |
- struct usb_configuration *c) | |
-{ | |
- struct audio_source_config *config = f->config; | |
- | |
- return audio_source_bind_config(c, config); | |
-} | |
- | |
-static void audio_source_function_unbind_config(struct android_usb_function *f, | |
- struct usb_configuration *c) | |
-{ | |
- struct audio_source_config *config = f->config; | |
- | |
- config->card = -1; | |
- config->device = -1; | |
-} | |
- | |
-static ssize_t audio_source_pcm_show(struct device *dev, | |
- struct device_attribute *attr, char *buf) | |
-{ | |
- struct android_usb_function *f = dev_get_drvdata(dev); | |
- struct audio_source_config *config = f->config; | |
- | |
- /* print PCM card and device numbers */ | |
- return sprintf(buf, "%d %d\n", config->card, config->device); | |
-} | |
- | |
-static DEVICE_ATTR(pcm, S_IRUGO | S_IWUSR, audio_source_pcm_show, NULL); | |
- | |
-static struct device_attribute *audio_source_function_attributes[] = { | |
- &dev_attr_pcm, | |
- NULL | |
-}; | |
- | |
-static struct android_usb_function audio_source_function = { | |
- .name = "audio_source", | |
- .init = audio_source_function_init, | |
- .cleanup = audio_source_function_cleanup, | |
- .bind_config = audio_source_function_bind_config, | |
- .unbind_config = audio_source_function_unbind_config, | |
- .attributes = audio_source_function_attributes, | |
-}; | |
static struct android_usb_function *supported_functions[] = { | |
&adb_function, | |
@@ -811,7 +899,6 @@ static struct android_usb_function *supported_functions[] = { | |
&rndis_function, | |
&mass_storage_function, | |
&accessory_function, | |
- &audio_source_function, | |
NULL | |
}; | |
@@ -1270,11 +1357,6 @@ static void android_disconnect(struct usb_gadget *gadget) | |
unsigned long flags; | |
composite_disconnect(gadget); | |
- /* accessory HID support can be active while the | |
- accessory function is not actually enabled, | |
- so we need to inform it when we are disconnected. | |
- */ | |
- acc_disconnect(); | |
spin_lock_irqsave(&cdev->lock, flags); | |
dev->connected = 0; | |
@@ -1311,6 +1393,8 @@ static int __init init(void) | |
struct android_dev *dev; | |
int err; | |
+ modify_device_data(); | |
+ | |
android_class = class_create(THIS_MODULE, "android_usb"); | |
if (IS_ERR(android_class)) | |
return PTR_ERR(android_class); | |
diff --git a/drivers/usb/gadget/file_storage.c b/drivers/usb/gadget/file_storage.c | |
index e358130..5b9c491 100644 | |
--- a/drivers/usb/gadget/file_storage.c | |
+++ b/drivers/usb/gadget/file_storage.c | |
@@ -3520,6 +3520,9 @@ static int __init fsg_bind(struct usb_gadget *gadget) | |
/* Tell the thread to start working */ | |
wake_up_process(fsg->thread_task); | |
+ | |
+ usb_gadget_connect(gadget); | |
+ | |
return 0; | |
autoconf_fail: | |
diff --git a/drivers/usb/sun4i_usb/udc/sw_udc.c b/drivers/usb/sun4i_usb/udc/sw_udc.c | |
index 5589f8f..b211fcd 100644 | |
--- a/drivers/usb/sun4i_usb/udc/sw_udc.c | |
+++ b/drivers/usb/sun4i_usb/udc/sw_udc.c | |
@@ -67,6 +67,7 @@ static u32 usbd_port_no = 0; | |
static sw_udc_io_t g_sw_udc_io; | |
static u32 usb_connect = 0; | |
static u32 is_controller_alive = 0; | |
+static u8 is_udc_enable = 0; /* is udc enable by gadget? */ | |
#ifdef CONFIG_USB_SW_SUN4I_USB0_OTG | |
static struct platform_device *g_udc_pdev = NULL; | |
@@ -2704,6 +2705,8 @@ static int sw_udc_set_pullup(struct sw_udc *udc, int is_on) | |
return 0; | |
} | |
+ is_udc_enable = is_on; | |
+ | |
if(is_on){ | |
sw_udc_enable(udc); | |
}else{ | |
@@ -3041,7 +3044,7 @@ int usb_gadget_probe_driver(struct usb_gadget_driver *driver, | |
} | |
/* Enable udc */ | |
- sw_udc_enable(udc); | |
+ //sw_udc_enable(udc); //remove by 2011.11.25 | |
return 0; | |
@@ -3228,7 +3231,7 @@ int sw_usb_device_enable(void) | |
goto err; | |
} | |
- if(udc->driver){ | |
+ if(udc->driver && is_udc_enable){ | |
sw_udc_enable(udc); | |
cfg_udc_command(SW_UDC_P_ENABLE); | |
} | |
@@ -3642,11 +3645,13 @@ static int sw_udc_resume(struct platform_device *pdev) | |
/* open USB clock */ | |
open_usb_clock(&g_sw_udc_io); | |
- /* enable usb controller */ | |
- sw_udc_enable(udc); | |
+ if(is_udc_enable){ | |
+ /* enable usb controller */ | |
+ sw_udc_enable(udc); | |
- /* soft connect */ | |
- cfg_udc_command(SW_UDC_P_ENABLE); | |
+ /* soft connect */ | |
+ cfg_udc_command(SW_UDC_P_ENABLE); | |
+ } | |
DMSG_INFO_UDC("sw_udc_resume end\n"); | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
commit 77521727e8f062e553c13c6ae842789c546f28e8 | |
Author: xiongtie <xiongtie@Exdroid3.(none)> | |
Date: Mon Dec 26 23:06:07 2011 +0800 | |
merge from tag exdroid4.0.1r1-v0.4 | |
diff --git a/drivers/usb/gadget/android.c b/drivers/usb/gadget/android.c | |
index 3b4e281..0d8abdb 100644 | |
--- a/drivers/usb/gadget/android.c | |
+++ b/drivers/usb/gadget/android.c | |
@@ -217,135 +217,6 @@ static void android_disable(struct android_dev *dev) | |
} | |
/*-------------------------------------------------------------------------*/ | |
- | |
-struct g_android_usb_config{ | |
- /* usb feature */ | |
- u32 vendor_id; | |
- u32 mass_storage_id; | |
- u32 adb_id; | |
- | |
- char usb_manufacturer_name[64]; | |
- char usb_product_name[64]; | |
- char usb_serial_number[64]; | |
- | |
- /* usb_mass_storage feature */ | |
- char msc_vendor_name[64]; | |
- char msc_product_name[64]; | |
- u32 msc_release; | |
- u32 luns; | |
-}; | |
- | |
-#include <mach/sys_config.h> | |
- | |
-static s32 get_msc_config(struct g_android_usb_config *config) | |
-{ | |
- s32 ret = 0; | |
- | |
- //---------------------------------------- | |
- // usb_feature | |
- //---------------------------------------- | |
- | |
- /* vendor_id */ | |
- ret = script_parser_fetch("usb_feature", "vendor_id", (int *)&(config->vendor_id), 64); | |
- if(ret != 0){ | |
- printk("ERR: get usb_feature vendor_id failed\n"); | |
- } | |
- | |
- /* mass_storage_id */ | |
- ret = script_parser_fetch("usb_feature", "mass_storage_id", (int *)&(config->mass_storage_id), 64); | |
- if(ret != 0){ | |
- printk("ERR: get usb_feature mass_storage_id failed\n"); | |
- } | |
- | |
- /* adb_id */ | |
- ret = script_parser_fetch("usb_feature", "adb_id", (int *)&(config->adb_id), 64); | |
- if(ret != 0){ | |
- printk("ERR: get usb_feature adb_id failed\n"); | |
- } | |
- | |
- /* manufacturer_name */ | |
- ret = script_parser_fetch("usb_feature", "manufacturer_name", (int *)config->usb_manufacturer_name, 64); | |
- if(ret != 0){ | |
- printk("ERR: get usb_feature manufacturer_name failed\n"); | |
- } | |
- | |
- /* product_name */ | |
- ret = script_parser_fetch("usb_feature", "product_name", (int *)config->usb_product_name, 64); | |
- if(ret != 0){ | |
- printk("ERR: get usb_feature product_name failed\n"); | |
- } | |
- | |
- /* serial_number */ | |
- ret = script_parser_fetch("usb_feature", "serial_number", (int *)config->usb_serial_number, 64); | |
- if(ret != 0){ | |
- printk("ERR: get usb_feature serial_number failed\n"); | |
- } | |
- | |
- //---------------------------------------- | |
- // msc_feature | |
- //---------------------------------------- | |
- | |
- /* vendor_name */ | |
- ret = script_parser_fetch("msc_feature", "vendor_name", (int *)config->msc_vendor_name, 64); | |
- if(ret != 0){ | |
- printk("ERR: get msc_feature vendor_name failed\n"); | |
- } | |
- | |
- /* product_name */ | |
- ret = script_parser_fetch("msc_feature", "product_name", (int *)config->msc_product_name, 64); | |
- if(ret != 0){ | |
- printk("ERR: get msc_feature product_name failed\n"); | |
- } | |
- | |
- /* release */ | |
- ret = script_parser_fetch("msc_feature", "release", (int *)&(config->msc_release), 64); | |
- if(ret != 0){ | |
- printk("ERR: get msc_feature release failed\n"); | |
- } | |
- | |
- /* luns */ | |
- ret = script_parser_fetch("msc_feature", "luns", (int *)&(config->luns), 64); | |
- if(ret != 0){ | |
- printk("ERR: get msc_feature luns failed\n"); | |
- } | |
- | |
- return 0; | |
-} | |
- | |
-static void print_msc_config(struct g_android_usb_config *config) | |
-{ | |
- printk("------print_msc_config-----\n"); | |
- printk("vendor_id = 0x%x\n", config->vendor_id); | |
- printk("mass_storage_id = 0x%x\n", config->mass_storage_id); | |
- printk("adb_id = 0x%x\n", config->adb_id); | |
- | |
- printk("usb_manufacturer_name = %s\n", config->usb_manufacturer_name); | |
- printk("usb_product_name = %s\n", config->usb_product_name); | |
- printk("usb_serial_number = %s\n", config->usb_serial_number); | |
- | |
- printk("msc_vendor_name = %s\n", config->msc_vendor_name); | |
- printk("msc_product_name = %s\n", config->msc_product_name); | |
- printk("msc_release = %d\n", config->msc_release); | |
- printk("luns = %d\n", config->luns); | |
- printk("---------------------------\n"); | |
-} | |
- | |
-static struct g_android_usb_config g_android_usb_config; | |
- | |
-static s32 modify_device_data(void) | |
-{ | |
- struct g_android_usb_config *config = &g_android_usb_config; | |
- | |
- memset(config, 0, sizeof(struct g_android_usb_config)); | |
- | |
- get_msc_config(config); | |
- | |
- print_msc_config(config); | |
- | |
- return 0; | |
-} | |
- | |
-/*-------------------------------------------------------------------------*/ | |
/* Supported functions initialization */ | |
struct adb_data { | |
@@ -1099,11 +970,10 @@ static ssize_t enable_store(struct device *pdev, struct device_attribute *attr, | |
cdev->desc.bDeviceClass = device_desc.bDeviceClass; | |
cdev->desc.bDeviceSubClass = device_desc.bDeviceSubClass; | |
cdev->desc.bDeviceProtocol = device_desc.bDeviceProtocol; | |
- list_for_each_entry(f, &dev->enabled_functions, enabled_list) { | |
- if (f->enable) | |
- f->enable(f); | |
- } | |
- android_enable(dev); | |
+ | |
+ usb_add_config(cdev, &android_config_driver, | |
+ android_bind_config); | |
+ usb_gadget_connect(cdev->gadget); | |
dev->enabled = true; | |
} else if (!enabled && dev->enabled) { | |
android_disable(dev); | |
@@ -1261,10 +1131,23 @@ static int android_bind(struct usb_composite_dev *cdev) | |
strings_dev[STRING_PRODUCT_IDX].id = id; | |
device_desc.iProduct = id; | |
+/* Modified by javen */ | |
+#if 0 | |
/* Default strings - should be updated by userspace */ | |
strncpy(manufacturer_string, "Android", sizeof(manufacturer_string) - 1); | |
strncpy(product_string, "Android", sizeof(product_string) - 1); | |
strncpy(serial_string, "0123456789ABCDEF", sizeof(serial_string) - 1); | |
+#else | |
+{ | |
+ struct android_usb_config usb_config; | |
+ | |
+ get_android_usb_config(&usb_config); | |
+ | |
+ strncpy(manufacturer_string, usb_config.usb_manufacturer_name, sizeof(manufacturer_string) - 1); | |
+ strncpy(product_string, usb_config.usb_product_name, sizeof(product_string) - 1); | |
+ strncpy(serial_string, usb_config.usb_serial_number, sizeof(serial_string) - 1); | |
+} | |
+#endif | |
id = usb_string_id(cdev); | |
if (id < 0) | |
@@ -1397,7 +1280,16 @@ static int __init init(void) | |
struct android_dev *dev; | |
int err; | |
- modify_device_data(); | |
+/* modified by javen */ | |
+{ | |
+ struct android_usb_config usb_config; | |
+ | |
+ parse_android_usb_config(); | |
+ get_android_usb_config(&usb_config); | |
+ | |
+ device_desc.idVendor = usb_config.vendor_id; | |
+ device_desc.idProduct = usb_config.mass_storage_id; | |
+} | |
android_class = class_create(THIS_MODULE, "android_usb"); | |
if (IS_ERR(android_class)) | |
diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c | |
index da1b795..c2fb149 100644 | |
--- a/drivers/usb/gadget/composite.c | |
+++ b/drivers/usb/gadget/composite.c | |
@@ -1374,3 +1374,127 @@ void usb_composite_setup_continue(struct usb_composite_dev *cdev) | |
spin_unlock_irqrestore(&cdev->lock, flags); | |
} | |
+ | |
+//------------------------------------------------------------------------- | |
+// | |
+// add by javen | |
+// | |
+//------------------------------------------------------------------------- | |
+ | |
+#include <mach/sys_config.h> | |
+ | |
+static s32 get_android_config(struct android_usb_config *config) | |
+{ | |
+ s32 ret = 0; | |
+ | |
+ //---------------------------------------- | |
+ // usb_feature | |
+ //---------------------------------------- | |
+ | |
+ /* vendor_id */ | |
+ ret = script_parser_fetch("usb_feature", "vendor_id", (int *)&(config->vendor_id), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature vendor_id failed\n"); | |
+ } | |
+ | |
+ /* mass_storage_id */ | |
+ ret = script_parser_fetch("usb_feature", "mass_storage_id", (int *)&(config->mass_storage_id), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature mass_storage_id failed\n"); | |
+ } | |
+ | |
+ /* adb_id */ | |
+ ret = script_parser_fetch("usb_feature", "adb_id", (int *)&(config->adb_id), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature adb_id failed\n"); | |
+ } | |
+ | |
+ /* manufacturer_name */ | |
+ ret = script_parser_fetch("usb_feature", "manufacturer_name", (int *)config->usb_manufacturer_name, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature manufacturer_name failed\n"); | |
+ } | |
+ | |
+ /* product_name */ | |
+ ret = script_parser_fetch("usb_feature", "product_name", (int *)config->usb_product_name, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature product_name failed\n"); | |
+ } | |
+ | |
+ /* serial_number */ | |
+ ret = script_parser_fetch("usb_feature", "serial_number", (int *)config->usb_serial_number, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get usb_feature serial_number failed\n"); | |
+ } | |
+ | |
+ //---------------------------------------- | |
+ // msc_feature | |
+ //---------------------------------------- | |
+ | |
+ /* vendor_name */ | |
+ ret = script_parser_fetch("msc_feature", "vendor_name", (int *)config->msc_vendor_name, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get msc_feature vendor_name failed\n"); | |
+ } | |
+ | |
+ /* product_name */ | |
+ ret = script_parser_fetch("msc_feature", "product_name", (int *)config->msc_product_name, 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get msc_feature product_name failed\n"); | |
+ } | |
+ | |
+ /* release */ | |
+ ret = script_parser_fetch("msc_feature", "release", (int *)&(config->msc_release), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get msc_feature release failed\n"); | |
+ } | |
+ | |
+ /* luns */ | |
+ ret = script_parser_fetch("msc_feature", "luns", (int *)&(config->luns), 64); | |
+ if(ret != 0){ | |
+ printk("ERR: get msc_feature luns failed\n"); | |
+ } | |
+ | |
+ return 0; | |
+} | |
+ | |
+static void print_android_config(struct android_usb_config *config) | |
+{ | |
+ printk("------print_msc_config-----\n"); | |
+ printk("vendor_id = 0x%x\n", config->vendor_id); | |
+ printk("mass_storage_id = 0x%x\n", config->mass_storage_id); | |
+ printk("adb_id = 0x%x\n", config->adb_id); | |
+ | |
+ printk("usb_manufacturer_name = %s\n", config->usb_manufacturer_name); | |
+ printk("usb_product_name = %s\n", config->usb_product_name); | |
+ printk("usb_serial_number = %s\n", config->usb_serial_number); | |
+ | |
+ printk("msc_vendor_name = %s\n", config->msc_vendor_name); | |
+ printk("msc_product_name = %s\n", config->msc_product_name); | |
+ printk("msc_release = %d\n", config->msc_release); | |
+ printk("luns = %d\n", config->luns); | |
+ printk("---------------------------\n"); | |
+} | |
+ | |
+static struct android_usb_config g_android_usb_config; | |
+ | |
+s32 parse_android_usb_config(void) | |
+{ | |
+ struct android_usb_config *config = &g_android_usb_config; | |
+ | |
+ memset(config, 0, sizeof(struct android_usb_config)); | |
+ | |
+ get_android_config(config); | |
+ | |
+ print_android_config(config); | |
+ | |
+ return 0; | |
+} | |
+ | |
+s32 get_android_usb_config(struct android_usb_config *config) | |
+{ | |
+ memcpy(config, &g_android_usb_config, sizeof(struct android_usb_config)); | |
+ | |
+ return 0; | |
+} | |
+ | |
diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c | |
index 9b7360f..10532db 100644 | |
--- a/drivers/usb/gadget/epautoconf.c | |
+++ b/drivers/usb/gadget/epautoconf.c | |
@@ -71,8 +71,11 @@ ep_matches ( | |
u16 max; | |
/* endpoint already claimed? */ | |
- if (NULL != ep->driver_data) | |
+ if (NULL != ep->driver_data) { | |
+ printk("%s, wrn: endpoint already claimed, ep(0x%p, 0x%p, %s)\n", __func__, | |
+ ep, ep->driver_data, ep->name); | |
return 0; | |
+ } | |
/* only support ep0 for portable CONTROL traffic */ | |
type = desc->bmAttributes & USB_ENDPOINT_XFERTYPE_MASK; | |
@@ -94,14 +97,26 @@ ep_matches ( | |
/* bulk endpoints handle interrupt transfers, | |
* except the toggle-quirky iso-synch kind | |
*/ | |
- if ('s' == tmp[2]) // == "-iso" | |
+ if ('s' == tmp[2]){ // == "-iso" | |
+ printk("-iso\n"); | |
return 0; | |
+ } | |
+ | |
/* for now, avoid PXA "interrupt-in"; | |
* it's documented as never using DATA1. | |
*/ | |
- if (gadget_is_pxa (gadget) | |
- && 'i' == tmp [1]) | |
+ if (gadget_is_pxa (gadget) && 'i' == tmp [1]){ | |
+ printk("11111\n"); | |
return 0; | |
+ } | |
+ | |
+ | |
+ /* softwinner otg support -int */ | |
+ if(gadget_is_softwinner_otg(gadget) && 'n' != tmp [2]){ | |
+ printk("3333333\n"); | |
+ return 0; | |
+ } | |
+ | |
break; | |
case USB_ENDPOINT_XFER_BULK: | |
if ('b' != tmp[1]) // != "-bulk" | |
diff --git a/drivers/usb/gadget/f_mass_storage.c b/drivers/usb/gadget/f_mass_storage.c | |
index bc2f624..4d589da 100644 | |
--- a/drivers/usb/gadget/f_mass_storage.c | |
+++ b/drivers/usb/gadget/f_mass_storage.c | |
@@ -764,19 +764,24 @@ static int do_read(struct fsg_common *common) | |
*/ | |
if ((common->cmnd[1] & ~0x18) != 0) { | |
curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | |
+ printk("err: do_read, We allow DPO and FUA, but we don't implement them.\n"); | |
return -EINVAL; | |
} | |
} | |
+ | |
if (lba >= curlun->num_sectors) { | |
curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; | |
+ printk("err: do_read, lba is too big. (%d, %d)\n", lba, (u32)curlun->num_sectors); | |
return -EINVAL; | |
} | |
file_offset = ((loff_t) lba) << 9; | |
/* Carry out the file reads */ | |
amount_left = common->data_size_from_cmnd; | |
- if (unlikely(amount_left == 0)) | |
+ if (unlikely(amount_left == 0)) { | |
+ printk("err: do_read, common->data_size_from_cmnd is zero.\n"); | |
return -EIO; /* No default reply */ | |
+ } | |
for (;;) { | |
/* | |
@@ -801,8 +806,10 @@ static int do_read(struct fsg_common *common) | |
bh = common->next_buffhd_to_fill; | |
while (bh->state != BUF_STATE_EMPTY) { | |
rc = sleep_thread(common); | |
- if (rc) | |
+ if (rc) { | |
+ printk("err: do_read, sleep_thread failed.\n"); | |
return rc; | |
+ } | |
} | |
/* | |
@@ -826,17 +833,21 @@ static int do_read(struct fsg_common *common) | |
amount, &file_offset_tmp); | |
VLDBG(curlun, "file read %u @ %llu -> %d\n", amount, | |
(unsigned long long)file_offset, (int)nread); | |
- if (signal_pending(current)) | |
+ if (signal_pending(current)) { | |
+ printk("err: do_read, signal_pending(current).(0x%x)\n", signal_pending(current)); | |
return -EINTR; | |
+ } | |
if (nread < 0) { | |
- LDBG(curlun, "error in file read: %d\n", (int)nread); | |
+ //LDBG(curlun, "error in file read: %d\n", (int)nread); | |
+ printk("err: do_read, error in file read: %d\n", (int)nread); | |
nread = 0; | |
} else if (nread < amount) { | |
- LDBG(curlun, "partial file read: %d/%u\n", | |
- (int)nread, amount); | |
+ //LDBG(curlun, "partial file read: %d/%u\n", (int)nread, amount); | |
+ printk("err: do_read, partial file read: %d/%u\n", (int)nread, amount); | |
nread -= (nread & 511); /* Round down to a block */ | |
} | |
+ | |
file_offset += nread; | |
amount_left -= nread; | |
common->residue -= nread; | |
@@ -856,9 +867,12 @@ static int do_read(struct fsg_common *common) | |
/* Send this buffer and go read some more */ | |
bh->inreq->zero = 0; | |
- if (!start_in_transfer(common, bh)) | |
+ if (!start_in_transfer(common, bh)) { | |
/* Don't know what to do if common->fsg is NULL */ | |
+ printk("err: do_read, start_in_transfer failed\n"); | |
return -EIO; | |
+ } | |
+ | |
common->next_buffhd_to_fill = bh->next; | |
} | |
@@ -883,8 +897,10 @@ static int do_write(struct fsg_common *common) | |
if (curlun->ro) { | |
curlun->sense_data = SS_WRITE_PROTECTED; | |
+ printk("err: do_write, file is read only, can not write\n"); | |
return -EINVAL; | |
} | |
+ | |
spin_lock(&curlun->filp->f_lock); | |
curlun->filp->f_flags &= ~O_SYNC; /* Default is not to wait */ | |
spin_unlock(&curlun->filp->f_lock); | |
@@ -906,8 +922,10 @@ static int do_write(struct fsg_common *common) | |
*/ | |
if (common->cmnd[1] & ~0x18) { | |
curlun->sense_data = SS_INVALID_FIELD_IN_CDB; | |
+ printk("err: do_write, We allow DPO and FUA, We don't implement DPO.\n"); | |
return -EINVAL; | |
} | |
+ | |
if (!curlun->nofua && (common->cmnd[1] & 0x08)) { /* FUA */ | |
spin_lock(&curlun->filp->f_lock); | |
curlun->filp->f_flags |= O_SYNC; | |
@@ -916,6 +934,7 @@ static int do_write(struct fsg_common *common) | |
} | |
if (lba >= curlun->num_sectors) { | |
curlun->sense_data = SS_LOGICAL_BLOCK_ADDRESS_OUT_OF_RANGE; | |
+ printk("err: do_write, lba is overwrite. (%d, %d)\n", (u32)lba, (u32)curlun->num_sectors); | |
return -EINVAL; | |
} | |
@@ -983,9 +1002,12 @@ static int do_write(struct fsg_common *common) | |
bh->outreq->length = amount; | |
bh->bulk_out_intended_length = amount; | |
bh->outreq->short_not_ok = 1; | |
- if (!start_out_transfer(common, bh)) | |
+ if (!start_out_transfer(common, bh)) { | |
/* Dunno what to do if common->fsg is NULL */ | |
+ printk("err: do_write, start_out_transfer failed\n"); | |
return -EIO; | |
+ } | |
+ | |
common->next_buffhd_to_fill = bh->next; | |
continue; | |
} | |
@@ -1018,21 +1040,25 @@ static int do_write(struct fsg_common *common) | |
/* Perform the write */ | |
file_offset_tmp = file_offset; | |
+ | |
nwritten = vfs_write(curlun->filp, | |
(char __user *)bh->buf, | |
amount, &file_offset_tmp); | |
+ | |
VLDBG(curlun, "file write %u @ %llu -> %d\n", amount, | |
(unsigned long long)file_offset, (int)nwritten); | |
- if (signal_pending(current)) | |
+ if (signal_pending(current)) { | |
+ printk("err: do_write, signal_pending(current).(0x%x)\n", signal_pending(current)); | |
return -EINTR; /* Interrupted! */ | |
+ } | |
if (nwritten < 0) { | |
- LDBG(curlun, "error in file write: %d\n", | |
- (int)nwritten); | |
+ //LDBG(curlun, "error in file write: %d\n", (int)nwritten); | |
+ printk("err: do_write, error in file write: %d\n", (int)nwritten); | |
nwritten = 0; | |
} else if (nwritten < amount) { | |
- LDBG(curlun, "partial file write: %d/%u\n", | |
- (int)nwritten, amount); | |
+ //LDBG(curlun, "partial file write: %d/%u\n", (int)nwritten, amount); | |
+ printk("err: do_write, partial file write: %d/%u\n", (int)nwritten, amount); | |
nwritten -= (nwritten & 511); | |
/* Round down to a block */ | |
} | |
@@ -1058,8 +1084,10 @@ static int do_write(struct fsg_common *common) | |
/* Wait for something to happen */ | |
rc = sleep_thread(common); | |
- if (rc) | |
+ if (rc) { | |
+ printk("err: do_write, sleep_thread failed\n"); | |
return rc; | |
+ } | |
} | |
return -EIO; /* No default reply */ | |
@@ -2848,6 +2876,9 @@ buffhds_first_it: | |
i = 0x0399; | |
} | |
} | |
+ | |
+/* Modified by javen */ | |
+#if 0 | |
snprintf(common->inquiry_string, sizeof common->inquiry_string, | |
"%-8s%-16s%04x", cfg->vendor_name ?: "Linux", | |
/* Assume product name dependent on the first LUN */ | |
@@ -2855,6 +2886,18 @@ buffhds_first_it: | |
? "File-Stor Gadget" | |
: "File-CD Gadget"), | |
i); | |
+#else | |
+{ | |
+ struct android_usb_config config; | |
+ | |
+ memset(&config, 0, sizeof(struct android_usb_config)); | |
+ get_android_usb_config(&config); | |
+ | |
+ snprintf(common->inquiry_string, sizeof common->inquiry_string, | |
+ "%-8s%-16s%04d", | |
+ config.msc_vendor_name, config.msc_product_name, config.msc_release); | |
+} | |
+#endif | |
/* | |
* Some peripheral controllers are known not to be able to | |
diff --git a/drivers/usb/gadget/f_mtp.c b/drivers/usb/gadget/f_mtp.c | |
index 2829231..368ddb0 100644 | |
--- a/drivers/usb/gadget/f_mtp.c | |
+++ b/drivers/usb/gadget/f_mtp.c | |
@@ -410,6 +410,7 @@ static int mtp_create_bulk_endpoints(struct mtp_dev *dev, | |
ep->driver_data = dev; /* claim the endpoint */ | |
dev->ep_out = ep; | |
+#if 0 | |
ep = usb_ep_autoconfig(cdev->gadget, out_desc); | |
if (!ep) { | |
DBG(cdev, "usb_ep_autoconfig for ep_out failed\n"); | |
@@ -418,6 +419,7 @@ static int mtp_create_bulk_endpoints(struct mtp_dev *dev, | |
DBG(cdev, "usb_ep_autoconfig for mtp ep_out got %s\n", ep->name); | |
ep->driver_data = dev; /* claim the endpoint */ | |
dev->ep_out = ep; | |
+#endif | |
ep = usb_ep_autoconfig(cdev->gadget, intr_desc); | |
if (!ep) { | |
@@ -945,14 +947,18 @@ out: | |
static int mtp_open(struct inode *ip, struct file *fp) | |
{ | |
printk(KERN_INFO "mtp_open\n"); | |
- if (mtp_lock(&_mtp_dev->open_excl)) | |
+ | |
+ if (mtp_lock(&_mtp_dev->open_excl)){ | |
+ printk("err: mtp is busy\n"); | |
return -EBUSY; | |
+ } | |
/* clear any error condition */ | |
if (_mtp_dev->state != STATE_OFFLINE) | |
_mtp_dev->state = STATE_READY; | |
fp->private_data = _mtp_dev; | |
+ | |
return 0; | |
} | |
@@ -961,6 +967,7 @@ static int mtp_release(struct inode *ip, struct file *fp) | |
printk(KERN_INFO "mtp_release\n"); | |
mtp_unlock(&_mtp_dev->open_excl); | |
+ | |
return 0; | |
} | |
diff --git a/drivers/usb/gadget/gadget_chips.h b/drivers/usb/gadget/gadget_chips.h | |
index bcdac7c..7a7f117 100644 | |
--- a/drivers/usb/gadget/gadget_chips.h | |
+++ b/drivers/usb/gadget/gadget_chips.h | |
@@ -160,6 +160,12 @@ | |
#define gadget_is_renesas_usbhs(g) 0 | |
#endif | |
+#if defined(CONFIG_USB_SW_SUN3I_UDC0) || defined(CONFIG_USB_SW_SUN4I_UDC0) | |
+#define gadget_is_softwinner_otg(g) (!strcmp("sw_usb_udc", (g)->name)) | |
+#else | |
+#define gadget_is_softwinner_otg(g) 0 | |
+#endif | |
+ | |
/** | |
* usb_gadget_controller_number - support bcdDevice id convention | |
* @gadget: the controller being driven | |
@@ -223,6 +229,8 @@ static inline int usb_gadget_controller_number(struct usb_gadget *gadget) | |
return 0x29; | |
else if (gadget_is_s3c_hsudc(gadget)) | |
return 0x30; | |
+ else if (gadget_is_softwinner_otg(gadget)) | |
+ return 0x30; | |
return -ENOENT; | |
} | |
diff --git a/drivers/usb/gadget/storage_common.c b/drivers/usb/gadget/storage_common.c | |
index a872248..31bfafd 100644 | |
--- a/drivers/usb/gadget/storage_common.c | |
+++ b/drivers/usb/gadget/storage_common.c | |
@@ -603,7 +603,10 @@ static int fsg_lun_open(struct fsg_lun *curlun, const char *filename) | |
curlun->filp = filp; | |
curlun->file_length = size; | |
curlun->num_sectors = num_sectors; | |
+ | |
LDBG(curlun, "open backing file: %s\n", filename); | |
+ printk("usb open backing file: %s, 0x%p\n", filename, curlun); | |
+ | |
rc = 0; | |
out: | |
@@ -616,6 +619,9 @@ static void fsg_lun_close(struct fsg_lun *curlun) | |
{ | |
if (curlun->filp) { | |
LDBG(curlun, "close backing file\n"); | |
+ | |
+ printk("usb close backing file: 0x%p\n", curlun); | |
+ | |
fput(curlun->filp); | |
curlun->filp = NULL; | |
} | |
@@ -770,6 +776,7 @@ static ssize_t fsg_store_file(struct device *dev, struct device_attribute *attr, | |
*/ | |
if (curlun->prevent_medium_removal && fsg_lun_is_open(curlun)) { | |
LDBG(curlun, "eject attempt prevented\n"); | |
+ printk("media is prevented, can not eject\n"); | |
return -EBUSY; /* "Door is locked" */ | |
} | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment