++ xtime = hcd->frame_usecs[i];
++ for (j = i + 1; j < 8; j++) {
++ /*
++ * if we add this frame remaining time to xtime we may
++ * be OK, if not we need to test j for a complete frame.
++ */
++ if ((xtime + hcd->frame_usecs[j]) < utime) {
++ if (hcd->frame_usecs[j] < max_uframe_usecs[j]) {
++ j = 8;
++ ret = -1;
++ continue;
++ }
++ }
++ if (xtime >= utime) {
++ ret = i;
++ j = 8; /* stop loop with a good value ret */
++ continue;
++ }
++ /* add the frame time to x time */
++ xtime += hcd->frame_usecs[j];
++ /* we must have a fully available next frame or break */
++ if ((xtime < utime) &&
++ (hcd->frame_usecs[j] == max_uframe_usecs[j])) {
++ ret = -1;
++ j = 8; /* stop loop with a bad value ret */
++ continue;
++ }
++ }
++ if (ret >= 0) {
++ t_left = utime;
++ for (j = i; (t_left > 0) && (j < 8); j++) {
++ t_left -= hcd->frame_usecs[j];
++ if (t_left <= 0) {
++ qh->frame_usecs[j] +=
++ hcd->frame_usecs[j] + t_left;
++ hcd->frame_usecs[j] = -t_left;
++ ret = i;
++ done = 1;
++ } else {
++ qh->frame_usecs[j] +=
++ hcd->frame_usecs[j];
++ hcd->frame_usecs[j] = 0;
++ }
++ }
++ } else {
++ i++;
++ if (i == 8) {
++ done = 1;
++ ret = -1;
++ }
++ }