Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b9392d99 authored by Gregory Herrero's avatar Gregory Herrero Committed by Felipe Balbi
Browse files

usb: dwc2: host: add function to compare frame index



This function allow comparing frame index used for
descriptor list which has 64 entries.

Acked-by: default avatarJohn Youn <johnyoun@synopsys.com>
Signed-off-by: default avatarGregory Herrero <gregory.herrero@intel.com>
Signed-off-by: default avatarFelipe Balbi <balbi@ti.com>
parent 2b046bc5
Loading
Loading
Loading
Loading
+13 −0
Original line number Diff line number Diff line
@@ -534,6 +534,19 @@ static inline bool dbg_perio(void) { return false; }
/* Packet size for any kind of endpoint descriptor */
#define dwc2_max_packet(wmaxpacketsize) ((wmaxpacketsize) & 0x07ff)

/*
 * Returns true if frame1 index is greater than frame2 index. The comparison
 * is done modulo FRLISTEN_64_SIZE. This accounts for the rollover of the
 * frame number when the max index frame number is reached.
 */
static inline bool dwc2_frame_idx_num_gt(u16 fr_idx1, u16 fr_idx2)
{
	u16 diff = fr_idx1 - fr_idx2;
	u16 sign = diff & (FRLISTEN_64_SIZE >> 1);

	return diff && !sign;
}

/*
 * Returns true if frame1 is less than or equal to frame2. The comparison is
 * done modulo HFNUM_MAX_FRNUM. This accounts for the rollover of the