Compare commits

...

2 Commits

Author SHA1 Message Date
129b508123 uvc: ack SET_CUR after data 2026-01-09 17:55:36 -03:00
efa261ba48 core: skip reset when gadget bound 2026-01-09 17:55:25 -03:00
2 changed files with 20 additions and 5 deletions

View File

@ -96,7 +96,13 @@ case "${1:-}" in
;;
esac
cleanup() { echo "" >"$G/UDC" 2>/dev/null || true; }
cleanup() {
if [[ -n ${LESAVKA_ALLOW_GADGET_RESET:-} ]]; then
LESAVKA_DETACH_CLEAR_UDC=1 detach_gadget
else
detach_gadget
fi
}
DISABLE_UAC=${LESAVKA_DISABLE_UAC:-}
DISABLE_UVC=${LESAVKA_DISABLE_UVC:-}
@ -186,6 +192,17 @@ fi
[[ -n $UDC ]] || { log "❌ UDC not present after manual bind"; exit 1; }
log "✅ UDC detected: $UDC"
# Guard against lockups: if the gadget is already bound, don't reset unless forced.
BOUND_UDC=""
if [[ -r $G/UDC ]]; then
BOUND_UDC=$(cat "$G/UDC" 2>/dev/null || true)
fi
if [[ -n $BOUND_UDC && -z ${LESAVKA_ALLOW_GADGET_RESET:-} ]]; then
log "🔒 gadget already bound to '$BOUND_UDC' - refusing reset."
log " Set LESAVKA_ALLOW_GADGET_RESET=1 to force."
exit 0
fi
# Guard against lockups: don't reset gadget while host is attached unless forced.
UDC_STATE="$(udc_state "$UDC")"
if [[ -z ${LESAVKA_ALLOW_GADGET_RESET:-} ]] && is_attached_state "$UDC_STATE"; then

View File

@ -384,9 +384,6 @@ fn handle_setup(
return;
}
*pending = Some(PendingRequest { interface, selector });
let len = req.w_length as usize;
let payload = vec![0u8; len.min(UVC_DATA_SIZE)];
let _ = send_response(fd, uvc_send_response, &payload);
if debug {
eprintln!(
"[lesavka-uvc] SET_CUR queued len={} iface={} sel={}",
@ -525,7 +522,8 @@ fn handle_data(
);
}
}
// No extra response required; ep0 data stage completion ends the control transfer.
// ACK the OUT transfer after we've processed the payload.
let _ = send_response(fd, uvc_send_response, &[]);
}
}