/* Build the language ID table for string descriptors. */
EFI_STATUS UsbBuildLangTable(IN USB_DEVICE *UsbDev)
/* Build the language ID table for string descriptors. */
EFI_STATUS UsbBuildLangTable(IN USB_DEVICE *UsbDev)
{
  EFI_USB_STRING_DESCRIPTOR  *Desc;
  EFI_STATUS                 Status;
  UINTN                      Index;
  UINTN                      Max;
  UINT16                     *Point;
  Desc = UsbGetOneString (UsbDev, 0, 0);
  if (Desc == NULL) {
    return EFI_UNSUPPORTED;
  }
  if (Desc->Length < 4) {
    Status = EFI_UNSUPPORTED;
    goto ON_EXIT;
  }
  Status = EFI_SUCCESS;
  Max = (Desc->Length - 2) / 2;
  Max = MIN (Max, USB_MAX_LANG_ID);
  Point = Desc->String;
  for (Index = 0; Index < Max; Index++) {
    UsbDev->LangId[Index] = *Point;
    Point++;
  }
  UsbDev->TotalLangId = (UINT16)Max;
ON_EXIT:
  gBS->FreePool (Desc);
  return Status;
}