fix video payload head toggle
This commit is contained in:
@@ -24,6 +24,8 @@ struct usbd_video_cfg_priv {
|
|||||||
.info[2] = { .bDescriptorSubtype = VIDEO_VC_PROCESSING_UNIT_DESCRIPTOR_SUBTYPE, .bEntityId = 0x02, .wTerminalType = 0x00 },
|
.info[2] = { .bDescriptorSubtype = VIDEO_VC_PROCESSING_UNIT_DESCRIPTOR_SUBTYPE, .bEntityId = 0x02, .wTerminalType = 0x00 },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static bool head_toggle = false;
|
||||||
|
|
||||||
static int usbd_video_control_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
static int usbd_video_control_request_handler(struct usb_setup_packet *setup, uint8_t **data, uint32_t *len)
|
||||||
{
|
{
|
||||||
uint8_t control_selector = (uint8_t)(setup->wValue >> 8);
|
uint8_t control_selector = (uint8_t)(setup->wValue >> 8);
|
||||||
@@ -694,6 +696,7 @@ static void video_notify_handler(uint8_t event, void *arg)
|
|||||||
usbd_video_open(intf->bInterfaceNumber);
|
usbd_video_open(intf->bInterfaceNumber);
|
||||||
} else {
|
} else {
|
||||||
usbd_video_close(intf->bInterfaceNumber);
|
usbd_video_close(intf->bInterfaceNumber);
|
||||||
|
head_toggle = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -770,7 +773,7 @@ uint32_t usbd_video_mjpeg_payload_fill(uint8_t *input, uint32_t input_len, uint8
|
|||||||
|
|
||||||
for (size_t i = 0; i < packets; i++) {
|
for (size_t i = 0; i < packets; i++) {
|
||||||
output[usbd_video_cfg.probe.dwMaxPayloadTransferSize * i] = 0x02;
|
output[usbd_video_cfg.probe.dwMaxPayloadTransferSize * i] = 0x02;
|
||||||
output[usbd_video_cfg.probe.dwMaxPayloadTransferSize * i + 1] ^= 0x01;
|
output[usbd_video_cfg.probe.dwMaxPayloadTransferSize * i + 1] = head_toggle;
|
||||||
if (i == (packets - 1)) {
|
if (i == (packets - 1)) {
|
||||||
memcpy(&output[2 + usbd_video_cfg.probe.dwMaxPayloadTransferSize * i], &input[picture_pos], last_packet_size - 2);
|
memcpy(&output[2 + usbd_video_cfg.probe.dwMaxPayloadTransferSize * i], &input[picture_pos], last_packet_size - 2);
|
||||||
} else {
|
} else {
|
||||||
@@ -778,7 +781,7 @@ uint32_t usbd_video_mjpeg_payload_fill(uint8_t *input, uint32_t input_len, uint8
|
|||||||
picture_pos += usbd_video_cfg.probe.dwMaxPayloadTransferSize - 2;
|
picture_pos += usbd_video_cfg.probe.dwMaxPayloadTransferSize - 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
head_toggle ^= 1;
|
||||||
*out_len = (input_len + 2 * packets);
|
*out_len = (input_len + 2 * packets);
|
||||||
return packets;
|
return packets;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user