Workaround for receiving Voice Calls using the E1750 dongle from

Huawei. It might appear as if the firmware is allocating memory blocks
according to the USB transfer size and if there is initially a lot of
data, like at the answering machine prompt, it simply dies without any
apparent reason. The simple workaround for this is to force a zero
length packet at hardware level after every 512 bytes of data. This
will force the other side to use smaller memory blocks aswell.

MFC after:	1 week
This commit is contained in:
Hans Petter Selasky 2014-09-12 22:40:12 +00:00
parent 53bdd39b8a
commit b75ac2ba76

View File

@ -75,6 +75,8 @@ SYSCTL_INT(_hw_usb_u3g, OID_AUTO, debug, CTLFLAG_RW,
#define U3G_MAXPORTS 12
#define U3G_CONFIG_INDEX 0
#define U3G_BSIZE 2048
#define U3G_TXSIZE (U3G_BSIZE / U3G_TXFRAMES)
#define U3G_TXFRAMES 4
/* Eject methods; See also usb_quirks.h:UQ_MSC_EJECT_* */
#define U3GINIT_HUAWEI 1 /* Requires Huawei init command */
@ -145,6 +147,7 @@ static const struct usb_config u3g_config[U3G_N_TRANSFER] = {
.endpoint = UE_ADDR_ANY,
.direction = UE_DIR_OUT,
.bufsize = U3G_BSIZE,/* bytes */
.frames = U3G_TXFRAMES,
.flags = {.pipe_bof = 1,.force_short_xfer = 1,},
.callback = &u3g_write_callback,
},
@ -1011,14 +1014,22 @@ u3g_write_callback(struct usb_xfer *xfer, usb_error_t error)
struct ucom_softc *ucom = usbd_xfer_softc(xfer);
struct usb_page_cache *pc;
uint32_t actlen;
uint32_t frame;
switch (USB_GET_STATE(xfer)) {
case USB_ST_TRANSFERRED:
case USB_ST_SETUP:
tr_setup:
pc = usbd_xfer_get_frame(xfer, 0);
if (ucom_get_data(ucom, pc, 0, U3G_BSIZE, &actlen)) {
usbd_xfer_set_frame_len(xfer, 0, actlen);
for (frame = 0; frame != U3G_TXFRAMES; frame++) {
usbd_xfer_set_frame_offset(xfer, frame * U3G_TXSIZE, frame);
pc = usbd_xfer_get_frame(xfer, frame);
if (ucom_get_data(ucom, pc, 0, U3G_TXSIZE, &actlen) == 0)
break;
usbd_xfer_set_frame_len(xfer, frame, actlen);
}
if (frame != 0) {
usbd_xfer_set_frames(xfer, frame);
usbd_transfer_submit(xfer);
}
break;