Skip to content

Commit

Permalink
Merge pull request #209 from tsundre/improve-usb2-extension-devcap
Browse files Browse the repository at this point in the history
lsusb: improve usb2 device capability descriptor
  • Loading branch information
gregkh authored Nov 16, 2024
2 parents dd312ac + 5c02e04 commit 807d0cc
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lsusb.c
Original file line number Diff line number Diff line change
Expand Up @@ -3217,7 +3217,10 @@ dump_device_status(libusb_device_handle *fd, int otg, int super_speed)

static void dump_usb2_device_capability_desc(unsigned char *buf, bool lpm_required)
{
static const uint16_t besl_us[16] = { 125, 150, 200, 300, 400, 500, 1000, 2000,
3000, 4000, 5000, 6000, 7000, 8000, 9000, 10000 };
unsigned int wide;
unsigned int besl;

wide = buf[3] + (buf[4] << 8) +
(buf[5] << 16) + (buf[6] << 24);
Expand All @@ -3232,16 +3235,17 @@ static void dump_usb2_device_capability_desc(unsigned char *buf, bool lpm_requir
else if (!lpm_required && !(wide & 0x02))
printf(" Link Power Management (LPM) not supported\n");
else if (!(wide & 0x04))
printf(" HIRD Link Power Management (LPM)"
" Supported\n");
printf(" HIRD Link Power Management (LPM) Supported\n");
else {
printf(" BESL Link Power Management (LPM)"
" Supported\n");
if (wide & 0x08)
printf(" BESL value %5u us \n", wide & 0xf00);
if (wide & 0x10)
printf(" Deep BESL value %5u us \n",
wide & 0xf000);
printf(" BESL Link Power Management (LPM) Supported\n");
if (wide & 0x08) {
besl = (wide & 0xf00) >> 8;
printf(" Baseline BESL value %5hu us \n", besl_us[besl]);
}
if (wide & 0x10) {
besl = (wide & 0xf000) >> 12;
printf(" Deep BESL value %5hu us \n", besl_us[besl]);
}
}
}

Expand Down

0 comments on commit 807d0cc

Please sign in to comment.