Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 96619acd authored by Edwin Moquete's avatar Edwin Moquete Committed by Michael Bestas
Browse files

Revert "usb: f_mtp: Don't handle OS descriptors from MTP driver"

Breaks MTP on Windows.

This reverts commit 5d93fbb5.

Change-Id: Ifbfee3e9911e9dfdff21f11ec73fde715adb1ab6
parent d230856d
Loading
Loading
Loading
Loading
+28 −5
Original line number Diff line number Diff line
@@ -354,6 +354,20 @@ struct mtp_ext_config_desc {
	struct mtp_ext_config_desc_function    function;
};

static struct mtp_ext_config_desc mtp_ext_config_desc = {
	.header = {
		.dwLength = __constant_cpu_to_le32(sizeof(mtp_ext_config_desc)),
		.bcdVersion = __constant_cpu_to_le16(0x0100),
		.wIndex = __constant_cpu_to_le16(4),
		.bCount = 1,
	},
	.function = {
		.bFirstInterfaceNumber = 0,
		.bInterfaceCount = 1,
		.compatibleID = { 'M', 'T', 'P' },
	},
};

struct mtp_device_status {
	__le16	wLength;
	__le16	wCode;
@@ -1324,7 +1338,20 @@ static int mtp_ctrlrequest(struct usb_composite_dev *cdev,
		mtp_log("vendor request: %d index: %d value: %d length: %d\n",
			ctrl->bRequest, w_index, w_value, w_length);

		value = -EOPNOTSUPP;
		if (ctrl->bRequest == 1
				&& (ctrl->bRequestType & USB_DIR_IN)
				&& (w_index == 4 || w_index == 5)) {
			value = (w_length < sizeof(mtp_ext_config_desc) ?
					w_length : sizeof(mtp_ext_config_desc));
			memcpy(cdev->req->buf, &mtp_ext_config_desc, value);

			/* update compatibleID if PTP */
			if (dev->function.fs_descriptors == fs_ptp_descs) {
				struct mtp_ext_config_desc *d = cdev->req->buf;

				d->function.compatibleID[0] = 'P';
			}
		}
	} else if ((ctrl->bRequestType & USB_TYPE_MASK) == USB_TYPE_CLASS) {
		mtp_log("class request: %d index: %d value: %d length: %d\n",
			ctrl->bRequest, w_index, w_value, w_length);
@@ -1803,10 +1830,6 @@ struct usb_function_instance *alloc_inst_mtp_ptp(bool mtp_config)
		return ERR_PTR(-ENOMEM);
	fi_mtp->func_inst.set_inst_name = mtp_set_inst_name;
	fi_mtp->func_inst.free_func_inst = mtp_free_inst;
	if (mtp_config)
		memcpy(fi_mtp->mtp_ext_compat_id, "MTP", 3);
	else
		memcpy(fi_mtp->mtp_ext_compat_id, "PTP", 3);

	fi_mtp->mtp_os_desc.ext_compat_id = fi_mtp->mtp_ext_compat_id;
	INIT_LIST_HEAD(&fi_mtp->mtp_os_desc.ext_prop);