mirror of
https://github.com/hardkernel/linux.git
synced 2026-06-07 03:15:31 +09:00
ANDROID: usb: gadget: Add support for MTP OS desc
Windows requires OS specific descriptors for automatic install of drivers for MTP devices. https://msdn.microsoft.com/en-us/library/windows/ hardware/gg463179.aspx BUG=24583401 BUG=chrome-os-partner:43409 Change-Id: I9397072ca3d183efbc9571c6cde3790f10d8851e Signed-off-by: Badhri Jagan Sridharan <Badhri@google.com> Reviewed-on: https://chromium-review.googlesource.com/304346 Commit-Ready: Andrew Bresticker <abrestic@chromium.org> Tested-by: Andrew Bresticker <abrestic@chromium.org> Reviewed-by: Andrew Bresticker <abrestic@chromium.org> Signed-off-by: Amit Pundir <amit.pundir@linaro.org>
This commit is contained in:
@@ -346,6 +346,8 @@ struct mtp_instance {
|
||||
struct usb_function_instance func_inst;
|
||||
const char *name;
|
||||
struct mtp_dev *dev;
|
||||
char mtp_ext_compat_id[16];
|
||||
struct usb_os_desc mtp_os_desc;
|
||||
};
|
||||
|
||||
/* temporary variable used between mtp_open() and mtp_gadget_bind() */
|
||||
@@ -1157,6 +1159,7 @@ mtp_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
struct mtp_dev *dev = func_to_mtp(f);
|
||||
int id;
|
||||
int ret;
|
||||
struct mtp_instance *fi_mtp;
|
||||
|
||||
dev->cdev = cdev;
|
||||
DBG(cdev, "mtp_function_bind dev: %p\n", dev);
|
||||
@@ -1174,6 +1177,18 @@ mtp_function_bind(struct usb_configuration *c, struct usb_function *f)
|
||||
mtp_string_defs[INTERFACE_STRING_INDEX].id = ret;
|
||||
mtp_interface_desc.iInterface = ret;
|
||||
}
|
||||
|
||||
fi_mtp = container_of(f->fi, struct mtp_instance, func_inst);
|
||||
|
||||
if (cdev->use_os_string) {
|
||||
f->os_desc_table = kzalloc(sizeof(*f->os_desc_table),
|
||||
GFP_KERNEL);
|
||||
if (!f->os_desc_table)
|
||||
return -ENOMEM;
|
||||
f->os_desc_n = 1;
|
||||
f->os_desc_table[0].os_desc = &fi_mtp->mtp_os_desc;
|
||||
}
|
||||
|
||||
/* allocate endpoints */
|
||||
ret = mtp_create_bulk_endpoints(dev, &mtp_fullspeed_in_desc,
|
||||
&mtp_fullspeed_out_desc, &mtp_intr_desc);
|
||||
@@ -1223,6 +1238,8 @@ mtp_function_unbind(struct usb_configuration *c, struct usb_function *f)
|
||||
while ((req = mtp_req_get(dev, &dev->intr_idle)))
|
||||
mtp_request_free(req, dev->ep_intr);
|
||||
dev->state = STATE_OFFLINE;
|
||||
kfree(f->os_desc_table);
|
||||
f->os_desc_n = 0;
|
||||
}
|
||||
|
||||
static int mtp_function_set_alt(struct usb_function *f,
|
||||
@@ -1406,6 +1423,7 @@ static void mtp_free_inst(struct usb_function_instance *fi)
|
||||
fi_mtp = to_fi_mtp(fi);
|
||||
kfree(fi_mtp->name);
|
||||
mtp_cleanup();
|
||||
kfree(fi_mtp->mtp_os_desc.group.default_groups);
|
||||
kfree(fi_mtp);
|
||||
}
|
||||
|
||||
@@ -1413,6 +1431,8 @@ struct usb_function_instance *alloc_inst_mtp_ptp(bool mtp_config)
|
||||
{
|
||||
struct mtp_instance *fi_mtp;
|
||||
int ret = 0;
|
||||
struct usb_os_desc *descs[1];
|
||||
char *names[1];
|
||||
|
||||
fi_mtp = kzalloc(sizeof(*fi_mtp), GFP_KERNEL);
|
||||
if (!fi_mtp)
|
||||
@@ -1420,6 +1440,13 @@ struct usb_function_instance *alloc_inst_mtp_ptp(bool mtp_config)
|
||||
fi_mtp->func_inst.set_inst_name = mtp_set_inst_name;
|
||||
fi_mtp->func_inst.free_func_inst = mtp_free_inst;
|
||||
|
||||
fi_mtp->mtp_os_desc.ext_compat_id = fi_mtp->mtp_ext_compat_id;
|
||||
INIT_LIST_HEAD(&fi_mtp->mtp_os_desc.ext_prop);
|
||||
descs[0] = &fi_mtp->mtp_os_desc;
|
||||
names[0] = "MTP";
|
||||
usb_os_desc_prepare_interf_dir(&fi_mtp->func_inst.group, 1,
|
||||
descs, names, THIS_MODULE);
|
||||
|
||||
if (mtp_config) {
|
||||
ret = mtp_setup_configfs(fi_mtp);
|
||||
if (ret) {
|
||||
|
||||
Reference in New Issue
Block a user