Re: [PATCH 1/1] lsusb: Added support for Billboard Capability descriptor

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Felipe,

Thanks for your inputs.
I have incorporated your comments and added few more validation.

Regards,
Muthu

On Sat, Oct 10, 2015 at 9:11 PM, Felipe Balbi <balbi@xxxxxx> wrote:
>
> Hi,
>
> Muthu M <muthu.lnx@xxxxxxxxx> writes:
>> Added support for Billboard Capability descriptor as per Universal
>> Serial Bus Device Class Definition for Billboard Devices Revision 1.1
>>
>> Signed-off-by: Muthu M <muthu.lnx@xxxxxxxxx>
>
> I didn't confirm with the billboard class to make sure all details are
> correct (will do that on Monday, hopefully), but great work :-) A few
> minor nits below
>
>> ---
>>  lsusb.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
>>  1 file changed, 82 insertions(+)
>>
>> diff --git a/lsusb.c b/lsusb.c
>> index 774caed..dae7c6c 100644
>> --- a/lsusb.c
>> +++ b/lsusb.c
>> @@ -70,6 +70,7 @@
>>  #define USB_DC_SUPERSPEED            0x03
>>  #define USB_DC_CONTAINER_ID          0x04
>>  #define USB_DC_SUPERSPEEDPLUS                0x0a
>> +#define USB_DC_BILLBOARD             0x0d
>>
>>  /* Conventional codes for class-specific descriptors.  The convention is
>>   * defined in the USB "Common Class" Spec (3.11).  Individual class specs
>> @@ -118,6 +119,22 @@ static const char * const encryption_type[] = {
>>       "RSA_1",
>>       "RESERVED"
>>  };
>
> add a blank line here
>
>> +static const char * const vconn_power[] = {
>> +     "1W",
>> +     "1.5W",
>> +     "2W",
>> +     "3W",
>> +     "4W",
>> +     "5W",
>> +     "6W",
>> +     "reserved"
>> +};
>
> and here
>
>> +static const char * const alt_mode_state[] = {
>> +     "Unspecified Error",
>> +     "Alternate Mode configuration not attempted",
>> +     "Alternate Mode configuration attempted but unsuccessful",
>> +     "Alternate Mode configuration successful"
>> +};
>>
>>  static void dump_interface(libusb_device_handle *dev, const struct libusb_interface *interface);
>>  static void dump_endpoint(libusb_device_handle *dev, const struct libusb_interface_descriptor *interface, const struct libusb_endpoint_descriptor *endpoint);
>> @@ -3771,6 +3788,68 @@ static void dump_container_id_device_capability_desc(unsigned char *buf)
>>                       get_guid(&buf[4]));
>>  }
>>
>> +static void dump_billboard_device_capability_desc(libusb_device_handle *dev, unsigned char *buf)
>
> most other dump functions define a prototype above, you might wanna do
> the same to keep consistency.
>
>> +{
>> +     char *url, *alt_mode_str;
>> +     int w_vconn_power, alt_mode, i, svid, state;
>> +     const char *vconn;
>> +     unsigned char *bmConfigured;
>> +
>> +     if (buf[0] < 40) {
>> +             printf("  Bad Billboard Capability descriptor.\n");
>
> this should probably be printed to stderr.
>
>> +             return;
>> +     }
>
> another blank line here
>
>> +     url = get_dev_string(dev, buf[3]);
>> +     w_vconn_power = buf[6] | (buf[7] << 8);
>> +     vconn = (w_vconn_power & (1 << 15)) ? "VCONN power not required" : vconn_power[w_vconn_power & 0x7];
>> +     printf("  Billboard Capability:\n"
>> +                     "    bLength                 %5u\n"
>> +                     "    bDescriptorType         %5u\n"
>> +                     "    bDevCapabilityType      %5u\n"
>> +                     "    iAddtionalInfoURL       %5u %s\n"
>> +                     "    bNumberOfAlternateModes %5u\n"
>> +                     "    bPreferredAlternateMode %5u\n"
>> +                     "    VCONN Power             %5u %s\n",
>> +                     buf[0], buf[1], buf[2],
>> +                     buf[3], url,
>> +                     buf[4], buf[5],
>> +                     w_vconn_power, vconn);
>
> add a blank line here
>
>> +     bmConfigured = &buf[8];
>
> and here
>
>> +     printf(
>> +                     "    bmConfigured               "
>> +                     );
>
> and here
>
>> +     dump_bytes(bmConfigured, 32);
>
> and here
>
>> +     printf(
>> +                     "    bcdVersion              %2x.%02x\n"
>> +                     "    bAdditionalFailureInfo  %5u\n"
>> +                     "    bReserved               %5u\n",
>> +                     (buf[41] == 0) ? 1 : buf[41], buf[40],
>> +                     buf[42], buf[43]);
>> +
>> +     printf(
>> +                     "    Alternate Modes supported by Device Container:\n"
>> +                     );
>> +     i = 44; /* Alternate mode 0 starts at index 44 */
>> +     for (alt_mode = 0; alt_mode < buf[4]; alt_mode++) {
>> +             svid = buf[i] | (buf[i+1] << 8);
>> +             alt_mode_str = get_dev_string(dev, buf[i+3]);
>> +             state = ((bmConfigured[alt_mode >> 2]) >> ((alt_mode & 0x3) << 1)) & 0x3;
>> +             printf(
>> +                     "    Alternate Mode %d : %s\n"
>> +                     "      wSVID[%d]                    0x%04X\n"
>> +                     "      bAlternateMode[%d]       %5u\n"
>> +                     "      iAlternateModeString[%d] %5u %s\n",
>> +                     alt_mode, alt_mode_state[state],
>> +                     alt_mode, svid,
>> +                     alt_mode, buf[i+2],
>> +                     alt_mode, buf[i+3], alt_mode_str);
>> +             free(alt_mode_str);
>> +             i += 4;
>> +     }
>> +
>> +     free (url);
>> +}
>> +
>>  static void dump_bos_descriptor(libusb_device_handle *fd)
>>  {
>>       /* Total length of BOS descriptors varies.
>> @@ -3849,6 +3928,9 @@ static void dump_bos_descriptor(libusb_device_handle *fd)
>>               case USB_DC_CONTAINER_ID:
>>                       dump_container_id_device_capability_desc(buf);
>>                       break;
>> +             case USB_DC_BILLBOARD:
>> +                     dump_billboard_device_capability_desc(fd, buf);
>> +                     break;
>>               default:
>>                       printf("  ** UNRECOGNIZED: ");
>>                       dump_bytes(buf, buf[0]);
>> --
>> 1.8.3.2
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-usb" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
> --
> balbi
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux