am 215b682b: MTP: changes to use new usb_request support in libusbhost
* commit '215b682b8a02ac51d820b8e301d50431bdd09b3d': MTP: changes to use new usb_request support in libusbhost
This commit is contained in:
@@ -29,12 +29,8 @@
|
||||
#include <errno.h>
|
||||
|
||||
#include <usbhost/usbhost.h>
|
||||
#include <linux/version.h>
|
||||
#if LINUX_VERSION_CODE > KERNEL_VERSION(2, 6, 20)
|
||||
#include <linux/usb/ch9.h>
|
||||
#else
|
||||
#include <linux/usb_ch9.h>
|
||||
#endif
|
||||
|
||||
struct usb_device;
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -194,20 +190,13 @@ bool MtpClient::usbDeviceAdded(const char *devname) {
|
||||
return mDone;
|
||||
}
|
||||
|
||||
struct usb_endpoint *ep_in = usb_endpoint_open(device, ep_in_desc);
|
||||
struct usb_endpoint *ep_out = usb_endpoint_open(device, ep_out_desc);
|
||||
struct usb_endpoint *ep_intr = usb_endpoint_open(device, ep_intr_desc);
|
||||
|
||||
if (usb_device_claim_interface(device, interface->bInterfaceNumber)) {
|
||||
LOGE("usb_device_claim_interface failed errno: %d\n", errno);
|
||||
usb_endpoint_close(ep_in);
|
||||
usb_endpoint_close(ep_out);
|
||||
usb_endpoint_close(ep_intr);
|
||||
return mDone;
|
||||
}
|
||||
|
||||
MtpDevice* mtpDevice = new MtpDevice(device, interface->bInterfaceNumber,
|
||||
ep_in, ep_out, ep_intr);
|
||||
ep_in_desc, ep_out_desc, ep_intr_desc);
|
||||
mDeviceList.add(mtpDevice);
|
||||
mtpDevice->initialize();
|
||||
deviceAdded(mtpDevice);
|
||||
|
||||
@@ -391,15 +391,19 @@ int MtpDataPacket::writeDataHeader(int fd, uint32_t length) {
|
||||
#endif // MTP_DEVICE
|
||||
|
||||
#ifdef MTP_HOST
|
||||
int MtpDataPacket::read(struct usb_endpoint *ep) {
|
||||
int MtpDataPacket::read(struct usb_request *request) {
|
||||
// first read the header
|
||||
int length = transfer(ep, mBuffer, mBufferSize);
|
||||
request->buffer = mBuffer;
|
||||
request->buffer_length = mBufferSize;
|
||||
int length = transfer(request);
|
||||
if (length >= MTP_CONTAINER_HEADER_SIZE) {
|
||||
// look at the length field to see if the data spans multiple packets
|
||||
uint32_t totalLength = MtpPacket::getUInt32(MTP_CONTAINER_LENGTH_OFFSET);
|
||||
while (totalLength > length) {
|
||||
allocate(length + mAllocationIncrement);
|
||||
int ret = transfer(ep, mBuffer + length, mAllocationIncrement);
|
||||
request->buffer = mBuffer + length;
|
||||
request->buffer_length = mAllocationIncrement;
|
||||
int ret = transfer(request);
|
||||
if (ret >= 0)
|
||||
length += ret;
|
||||
else {
|
||||
@@ -413,10 +417,12 @@ int MtpDataPacket::read(struct usb_endpoint *ep) {
|
||||
return length;
|
||||
}
|
||||
|
||||
int MtpDataPacket::readData(struct usb_endpoint *ep, void* buffer, int length) {
|
||||
int MtpDataPacket::readData(struct usb_request *request, void* buffer, int length) {
|
||||
int read = 0;
|
||||
while (read < length) {
|
||||
int ret = transfer(ep, (char *)buffer + read, length - read);
|
||||
request->buffer = (char *)buffer + read;
|
||||
request->buffer_length = length - read;
|
||||
int ret = transfer(request);
|
||||
if (ret < 0) {
|
||||
return ret;
|
||||
}
|
||||
@@ -426,8 +432,8 @@ int MtpDataPacket::readData(struct usb_endpoint *ep, void* buffer, int length) {
|
||||
}
|
||||
|
||||
// Queue a read request. Call readDataWait to wait for result
|
||||
int MtpDataPacket::readDataAsync(struct usb_endpoint *ep, void* buffer, int length) {
|
||||
if (usb_endpoint_queue(ep, buffer, length)) {
|
||||
int MtpDataPacket::readDataAsync(struct usb_request *req) {
|
||||
if (usb_request_queue(req)) {
|
||||
LOGE("usb_endpoint_queue failed, errno: %d", errno);
|
||||
return -1;
|
||||
}
|
||||
@@ -435,39 +441,49 @@ int MtpDataPacket::readDataAsync(struct usb_endpoint *ep, void* buffer, int leng
|
||||
}
|
||||
|
||||
// Wait for result of readDataAsync
|
||||
int MtpDataPacket::readDataWait(struct usb_endpoint *ep) {
|
||||
int ep_num;
|
||||
return usb_endpoint_wait(usb_endpoint_get_device(ep), &ep_num);
|
||||
int MtpDataPacket::readDataWait(struct usb_device *device) {
|
||||
struct usb_request *req = usb_request_wait(device);
|
||||
return (req ? req->actual_length : -1);
|
||||
}
|
||||
|
||||
int MtpDataPacket::readDataHeader(struct usb_endpoint *ep) {
|
||||
int length = transfer(ep, mBuffer, usb_endpoint_max_packet(ep));
|
||||
int MtpDataPacket::readDataHeader(struct usb_request *request) {
|
||||
request->buffer = mBuffer;
|
||||
request->buffer_length = request->max_packet_size;
|
||||
int length = transfer(request);
|
||||
if (length >= 0)
|
||||
mPacketSize = length;
|
||||
return length;
|
||||
}
|
||||
|
||||
int MtpDataPacket::writeDataHeader(struct usb_endpoint *ep, uint32_t length) {
|
||||
int MtpDataPacket::writeDataHeader(struct usb_request *request, uint32_t length) {
|
||||
MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, length);
|
||||
MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA);
|
||||
int ret = transfer(ep, mBuffer, MTP_CONTAINER_HEADER_SIZE);
|
||||
request->buffer = mBuffer;
|
||||
request->buffer_length = MTP_CONTAINER_HEADER_SIZE;
|
||||
int ret = transfer(request);
|
||||
return (ret < 0 ? ret : 0);
|
||||
}
|
||||
|
||||
int MtpDataPacket::write(struct usb_endpoint *ep) {
|
||||
int MtpDataPacket::write(struct usb_request *request) {
|
||||
MtpPacket::putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
|
||||
MtpPacket::putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_DATA);
|
||||
|
||||
// send header separately from data
|
||||
int ret = transfer(ep, mBuffer, MTP_CONTAINER_HEADER_SIZE);
|
||||
if (ret == MTP_CONTAINER_HEADER_SIZE)
|
||||
ret = transfer(ep, mBuffer + MTP_CONTAINER_HEADER_SIZE,
|
||||
mPacketSize - MTP_CONTAINER_HEADER_SIZE);
|
||||
request->buffer = mBuffer;
|
||||
request->buffer_length = MTP_CONTAINER_HEADER_SIZE;
|
||||
int ret = transfer(request);
|
||||
if (ret == MTP_CONTAINER_HEADER_SIZE) {
|
||||
request->buffer = mBuffer + MTP_CONTAINER_HEADER_SIZE;
|
||||
request->buffer_length = mPacketSize - MTP_CONTAINER_HEADER_SIZE;
|
||||
ret = transfer(request);
|
||||
}
|
||||
return (ret < 0 ? ret : 0);
|
||||
}
|
||||
|
||||
int MtpDataPacket::write(struct usb_endpoint *ep, void* buffer, uint32_t length) {
|
||||
int ret = transfer(ep, buffer, length);
|
||||
int MtpDataPacket::write(struct usb_request *request, void* buffer, uint32_t length) {
|
||||
request->buffer = buffer;
|
||||
request->buffer_length = length;
|
||||
int ret = transfer(request);
|
||||
return (ret < 0 ? ret : 0);
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,9 @@
|
||||
#include "MtpPacket.h"
|
||||
#include "mtp.h"
|
||||
|
||||
struct usb_device;
|
||||
struct usb_request;
|
||||
|
||||
namespace android {
|
||||
|
||||
class MtpStringBuffer;
|
||||
@@ -100,15 +103,15 @@ public:
|
||||
#endif
|
||||
|
||||
#ifdef MTP_HOST
|
||||
int read(struct usb_endpoint *ep);
|
||||
int readData(struct usb_endpoint *ep, void* buffer, int length);
|
||||
int readDataAsync(struct usb_endpoint *ep, void* buffer, int length);
|
||||
int readDataWait(struct usb_endpoint *ep);
|
||||
int readDataHeader(struct usb_endpoint *ep);
|
||||
int read(struct usb_request *request);
|
||||
int readData(struct usb_request *request, void* buffer, int length);
|
||||
int readDataAsync(struct usb_request *req);
|
||||
int readDataWait(struct usb_device *device);
|
||||
int readDataHeader(struct usb_request *ep);
|
||||
|
||||
int writeDataHeader(struct usb_endpoint *ep, uint32_t length);
|
||||
int write(struct usb_endpoint *ep);
|
||||
int write(struct usb_endpoint *ep, void* buffer, uint32_t length);
|
||||
int writeDataHeader(struct usb_request *ep, uint32_t length);
|
||||
int write(struct usb_request *ep);
|
||||
int write(struct usb_request *ep, void* buffer, uint32_t length);
|
||||
#endif
|
||||
|
||||
inline bool hasData() const { return mPacketSize > MTP_CONTAINER_HEADER_SIZE; }
|
||||
|
||||
@@ -39,25 +39,35 @@
|
||||
namespace android {
|
||||
|
||||
MtpDevice::MtpDevice(struct usb_device* device, int interface,
|
||||
struct usb_endpoint *ep_in, struct usb_endpoint *ep_out,
|
||||
struct usb_endpoint *ep_intr)
|
||||
const struct usb_endpoint_descriptor *ep_in,
|
||||
const struct usb_endpoint_descriptor *ep_out,
|
||||
const struct usb_endpoint_descriptor *ep_intr)
|
||||
: mDevice(device),
|
||||
mInterface(interface),
|
||||
mEndpointIn(ep_in),
|
||||
mEndpointOut(ep_out),
|
||||
mEndpointIntr(ep_intr),
|
||||
mRequestIn1(NULL),
|
||||
mRequestIn2(NULL),
|
||||
mRequestOut(NULL),
|
||||
mRequestIntr(NULL),
|
||||
mDeviceInfo(NULL),
|
||||
mID(usb_device_get_unique_id(device)),
|
||||
mSessionID(0),
|
||||
mTransactionID(0),
|
||||
mReceivedResponse(false)
|
||||
{
|
||||
mRequestIn1 = usb_request_new(device, ep_in);
|
||||
mRequestIn2 = usb_request_new(device, ep_in);
|
||||
mRequestOut = usb_request_new(device, ep_out);
|
||||
mRequestIntr = usb_request_new(device, ep_intr);
|
||||
}
|
||||
|
||||
MtpDevice::~MtpDevice() {
|
||||
close();
|
||||
for (int i = 0; i < mDeviceProperties.size(); i++)
|
||||
delete mDeviceProperties[i];
|
||||
usb_request_free(mRequestIn1);
|
||||
usb_request_free(mRequestIn2);
|
||||
usb_request_free(mRequestOut);
|
||||
usb_request_free(mRequestIntr);
|
||||
}
|
||||
|
||||
void MtpDevice::initialize() {
|
||||
@@ -325,7 +335,7 @@ bool MtpDevice::sendObject(MtpObjectInfo* info, int srcFD) {
|
||||
while (remaining > 0) {
|
||||
int count = read(srcFD, buffer, sizeof(buffer));
|
||||
if (count > 0) {
|
||||
int written = mData.write(mEndpointOut, buffer, count);
|
||||
int written = mData.write(mRequestOut, buffer, count);
|
||||
// FIXME check error
|
||||
remaining -= count;
|
||||
} else {
|
||||
@@ -441,7 +451,7 @@ bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int gro
|
||||
mRequest.reset();
|
||||
mRequest.setParameter(1, handle);
|
||||
if (sendRequest(MTP_OPERATION_GET_OBJECT)
|
||||
&& mData.readDataHeader(mEndpointIn)) {
|
||||
&& mData.readDataHeader(mRequestIn1)) {
|
||||
uint32_t length = mData.getContainerLength();
|
||||
if (length < MTP_CONTAINER_HEADER_SIZE)
|
||||
goto fail;
|
||||
@@ -461,20 +471,22 @@ bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int gro
|
||||
|
||||
// USB reads greater than 16K don't work
|
||||
char buffer1[16384], buffer2[16384];
|
||||
char* readBuffer = buffer1;
|
||||
char* writeBuffer = NULL;
|
||||
mRequestIn1->buffer = buffer1;
|
||||
mRequestIn2->buffer = buffer2;
|
||||
struct usb_request* req = mRequestIn1;
|
||||
void* writeBuffer = NULL;
|
||||
int writeLength = 0;
|
||||
|
||||
while (remaining > 0 || writeBuffer) {
|
||||
if (remaining > 0) {
|
||||
// queue up a read request
|
||||
int readSize = (remaining > sizeof(buffer1) ? sizeof(buffer1) : remaining);
|
||||
if (mData.readDataAsync(mEndpointIn, readBuffer, readSize)) {
|
||||
req->buffer_length = (remaining > sizeof(buffer1) ? sizeof(buffer1) : remaining);
|
||||
if (mData.readDataAsync(req)) {
|
||||
LOGE("readDataAsync failed");
|
||||
goto fail;
|
||||
}
|
||||
} else {
|
||||
readBuffer = NULL;
|
||||
req = NULL;
|
||||
}
|
||||
|
||||
if (writeBuffer) {
|
||||
@@ -482,23 +494,23 @@ bool MtpDevice::readObject(MtpObjectHandle handle, const char* destPath, int gro
|
||||
if (write(fd, writeBuffer, writeLength) != writeLength) {
|
||||
LOGE("write failed");
|
||||
// wait for pending read before failing
|
||||
if (readBuffer)
|
||||
mData.readDataWait(mEndpointIn);
|
||||
if (req)
|
||||
mData.readDataWait(mDevice);
|
||||
goto fail;
|
||||
}
|
||||
writeBuffer = NULL;
|
||||
}
|
||||
|
||||
// wait for read to complete
|
||||
if (readBuffer) {
|
||||
int read = mData.readDataWait(mEndpointIn);
|
||||
if (req) {
|
||||
int read = mData.readDataWait(mDevice);
|
||||
if (read < 0)
|
||||
goto fail;
|
||||
|
||||
writeBuffer = readBuffer;
|
||||
writeBuffer = req->buffer;
|
||||
writeLength = read;
|
||||
remaining -= read;
|
||||
readBuffer = (readBuffer == buffer1 ? buffer2 : buffer1);
|
||||
req = (req == mRequestIn1 ? mRequestIn2 : mRequestIn1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -518,7 +530,7 @@ bool MtpDevice::sendRequest(MtpOperationCode operation) {
|
||||
mRequest.setOperationCode(operation);
|
||||
if (mTransactionID > 0)
|
||||
mRequest.setTransactionID(mTransactionID++);
|
||||
int ret = mRequest.write(mEndpointOut);
|
||||
int ret = mRequest.write(mRequestOut);
|
||||
mRequest.dump();
|
||||
return (ret > 0);
|
||||
}
|
||||
@@ -527,14 +539,14 @@ bool MtpDevice::sendData() {
|
||||
LOGV("sendData\n");
|
||||
mData.setOperationCode(mRequest.getOperationCode());
|
||||
mData.setTransactionID(mRequest.getTransactionID());
|
||||
int ret = mData.write(mEndpointOut);
|
||||
int ret = mData.write(mRequestOut);
|
||||
mData.dump();
|
||||
return (ret > 0);
|
||||
}
|
||||
|
||||
bool MtpDevice::readData() {
|
||||
mData.reset();
|
||||
int ret = mData.read(mEndpointIn);
|
||||
int ret = mData.read(mRequestIn1);
|
||||
LOGV("readData returned %d\n", ret);
|
||||
if (ret >= MTP_CONTAINER_HEADER_SIZE) {
|
||||
if (mData.getContainerType() == MTP_CONTAINER_TYPE_RESPONSE) {
|
||||
@@ -557,7 +569,7 @@ bool MtpDevice::readData() {
|
||||
bool MtpDevice::writeDataHeader(MtpOperationCode operation, int dataLength) {
|
||||
mData.setOperationCode(operation);
|
||||
mData.setTransactionID(mRequest.getTransactionID());
|
||||
return (!mData.writeDataHeader(mEndpointOut, dataLength));
|
||||
return (!mData.writeDataHeader(mRequestOut, dataLength));
|
||||
}
|
||||
|
||||
MtpResponseCode MtpDevice::readResponse() {
|
||||
@@ -566,7 +578,7 @@ MtpResponseCode MtpDevice::readResponse() {
|
||||
mReceivedResponse = false;
|
||||
return mResponse.getResponseCode();
|
||||
}
|
||||
int ret = mResponse.read(mEndpointIn);
|
||||
int ret = mResponse.read(mRequestIn1);
|
||||
if (ret >= MTP_CONTAINER_HEADER_SIZE) {
|
||||
mResponse.dump();
|
||||
return mResponse.getResponseCode();
|
||||
|
||||
@@ -25,6 +25,8 @@
|
||||
#include <utils/threads.h>
|
||||
|
||||
struct usb_device;
|
||||
struct usb_request;
|
||||
struct usb_endpoint_descriptor;
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -36,9 +38,10 @@ class MtpDevice {
|
||||
private:
|
||||
struct usb_device* mDevice;
|
||||
int mInterface;
|
||||
struct usb_endpoint* mEndpointIn;
|
||||
struct usb_endpoint* mEndpointOut;
|
||||
struct usb_endpoint* mEndpointIntr;
|
||||
struct usb_request* mRequestIn1;
|
||||
struct usb_request* mRequestIn2;
|
||||
struct usb_request* mRequestOut;
|
||||
struct usb_request* mRequestIntr;
|
||||
MtpDeviceInfo* mDeviceInfo;
|
||||
MtpPropertyList mDeviceProperties;
|
||||
|
||||
@@ -61,8 +64,9 @@ private:
|
||||
|
||||
public:
|
||||
MtpDevice(struct usb_device* device, int interface,
|
||||
struct usb_endpoint *ep_in, struct usb_endpoint *ep_out,
|
||||
struct usb_endpoint *ep_intr);
|
||||
const struct usb_endpoint_descriptor *ep_in,
|
||||
const struct usb_endpoint_descriptor *ep_out,
|
||||
const struct usb_endpoint_descriptor *ep_intr);
|
||||
virtual ~MtpDevice();
|
||||
|
||||
inline int getID() const { return mID; }
|
||||
|
||||
@@ -27,6 +27,8 @@
|
||||
|
||||
#include "MtpEventPacket.h"
|
||||
|
||||
#include <usbhost/usbhost.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
MtpEventPacket::MtpEventPacket()
|
||||
@@ -52,9 +54,10 @@ int MtpEventPacket::write(int fd) {
|
||||
#endif
|
||||
|
||||
#ifdef MTP_HOST
|
||||
// read our buffer from the given endpoint
|
||||
int MtpEventPacket::read(struct usb_endpoint *ep) {
|
||||
int ret = transfer(ep, mBuffer, mBufferSize);
|
||||
int MtpEventPacket::read(struct usb_request *request) {
|
||||
request->buffer = mBuffer;
|
||||
request->buffer_length = mBufferSize;
|
||||
int ret = transfer(request);
|
||||
if (ret >= 0)
|
||||
mPacketSize = ret;
|
||||
else
|
||||
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
#endif
|
||||
|
||||
#ifdef MTP_HOST
|
||||
// read our buffer from the given endpoint
|
||||
int read(struct usb_endpoint *ep);
|
||||
// read our buffer with the given request
|
||||
int read(struct usb_request *request);
|
||||
#endif
|
||||
|
||||
inline MtpEventCode getEventCode() const { return getContainerCode(); }
|
||||
|
||||
@@ -152,13 +152,13 @@ void MtpPacket::setParameter(int index, uint32_t value) {
|
||||
}
|
||||
|
||||
#ifdef MTP_HOST
|
||||
int MtpPacket::transfer(struct usb_endpoint *ep, void* buffer, int length) {
|
||||
if (usb_endpoint_queue(ep, buffer, length)) {
|
||||
int MtpPacket::transfer(struct usb_request* request) {
|
||||
if (usb_request_queue(request)) {
|
||||
LOGE("usb_endpoint_queue failed, errno: %d", errno);
|
||||
return -1;
|
||||
}
|
||||
int ep_num;
|
||||
return usb_endpoint_wait(usb_endpoint_get_device(ep), &ep_num);
|
||||
request = usb_request_wait(request->dev);
|
||||
return (request ? request->actual_length : -1);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
#include "MtpTypes.h"
|
||||
|
||||
struct usb_endpoint;
|
||||
struct usb_request;
|
||||
|
||||
namespace android {
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
void setParameter(int index, uint32_t value);
|
||||
|
||||
#ifdef MTP_HOST
|
||||
int transfer(struct usb_endpoint *ep, void* buffer, int length);
|
||||
int transfer(struct usb_request* request);
|
||||
#endif
|
||||
|
||||
protected:
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "MtpRequestPacket.h"
|
||||
|
||||
#include <usbhost/usbhost.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
MtpRequestPacket::MtpRequestPacket()
|
||||
@@ -45,11 +47,13 @@ int MtpRequestPacket::read(int fd) {
|
||||
|
||||
#ifdef MTP_HOST
|
||||
// write our buffer to the given endpoint (host mode)
|
||||
int MtpRequestPacket::write(struct usb_endpoint *ep)
|
||||
int MtpRequestPacket::write(struct usb_request *request)
|
||||
{
|
||||
putUInt32(MTP_CONTAINER_LENGTH_OFFSET, mPacketSize);
|
||||
putUInt16(MTP_CONTAINER_TYPE_OFFSET, MTP_CONTAINER_TYPE_COMMAND);
|
||||
return transfer(ep, mBuffer, mPacketSize);
|
||||
request->buffer = mBuffer;
|
||||
request->buffer_length = mPacketSize;
|
||||
return transfer(request);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
#include "MtpPacket.h"
|
||||
#include "mtp.h"
|
||||
|
||||
struct usb_request;
|
||||
|
||||
namespace android {
|
||||
|
||||
class MtpRequestPacket : public MtpPacket {
|
||||
@@ -35,7 +37,7 @@ public:
|
||||
|
||||
#ifdef MTP_HOST
|
||||
// write our buffer to the given endpoint
|
||||
int write(struct usb_endpoint *ep);
|
||||
int write(struct usb_request *request);
|
||||
#endif
|
||||
|
||||
inline MtpOperationCode getOperationCode() const { return getContainerCode(); }
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "MtpResponsePacket.h"
|
||||
|
||||
#include <usbhost/usbhost.h>
|
||||
|
||||
namespace android {
|
||||
|
||||
MtpResponsePacket::MtpResponsePacket()
|
||||
@@ -42,9 +44,10 @@ int MtpResponsePacket::write(int fd) {
|
||||
#endif
|
||||
|
||||
#ifdef MTP_HOST
|
||||
// read our buffer from the given endpoint
|
||||
int MtpResponsePacket::read(struct usb_endpoint *ep) {
|
||||
int ret = transfer(ep, mBuffer, mBufferSize);
|
||||
int MtpResponsePacket::read(struct usb_request *request) {
|
||||
request->buffer = mBuffer;
|
||||
request->buffer_length = mBufferSize;
|
||||
int ret = transfer(request);
|
||||
if (ret >= 0)
|
||||
mPacketSize = ret;
|
||||
else
|
||||
|
||||
@@ -34,8 +34,8 @@ public:
|
||||
#endif
|
||||
|
||||
#ifdef MTP_HOST
|
||||
// read our buffer from the given endpoint
|
||||
int read(struct usb_endpoint *ep);
|
||||
// read our buffer with the given request
|
||||
int read(struct usb_request *request);
|
||||
#endif
|
||||
|
||||
inline MtpResponseCode getResponseCode() const { return getContainerCode(); }
|
||||
|
||||
Reference in New Issue
Block a user