Changeset 92574f4 in mainline for uspace/app/usbinfo/info.c


Ignore:
Timestamp:
2011-02-24T12:03:27Z (13 years ago)
Author:
Lubos Slovak <lubos.slovak@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
e7b7ebd5
Parents:
4837092 (diff), a80849c (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merged development (changes in DDF, etc.).

Conflicts in uspace/drv/usbkbd/main.c

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/usbinfo/info.c

    r4837092 r92574f4  
    3737#include <str_error.h>
    3838#include <errno.h>
    39 #include <usb/usbdrv.h>
    4039#include <usb/pipes.h>
     40#include <usb/recognise.h>
    4141#include <usb/request.h>
    4242#include "usbinfo.h"
     
    4747        usb_device_connection_t wire;
    4848        usb_endpoint_pipe_t ctrl_pipe;
    49         ctrl_pipe.hc_phone = -1;
    50 
    51         int hc_phone = devman_device_connect(hc_handle, 0);
    52         if (hc_phone < 0) {
    53                 fprintf(stderr,
    54                     NAME ": failed to connect to host controller (%zu): %s.\n",
    55                         (size_t) hc_handle, str_error(hc_phone));
    56                 return hc_phone;
     49
     50        /*
     51         * Initialize pipes.
     52         */
     53        rc = usb_device_connection_initialize(&wire, hc_handle, address);
     54        if (rc != EOK) {
     55                fprintf(stderr,
     56                    NAME ": failed to create connection to the device: %s.\n",
     57                    str_error(rc));
     58                goto leave;
     59        }
     60        rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe, &wire);
     61        if (rc != EOK) {
     62                fprintf(stderr,
     63                    NAME ": failed to create default control pipe: %s.\n",
     64                    str_error(rc));
     65                goto leave;
     66        }
     67        rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
     68        if (rc != EOK) {
     69                fprintf(stderr,
     70                    NAME ": failed to start session on control pipe: %s.\n",
     71                    str_error(rc));
     72                goto leave;
    5773        }
    5874
     
    6278        match_id_list_t match_id_list;
    6379        init_match_ids(&match_id_list);
    64         rc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address);
     80        rc = usb_device_create_match_ids(&ctrl_pipe, &match_id_list);
    6581        if (rc != EOK) {
    6682                fprintf(stderr,
     
    7086        }
    7187        dump_match_ids(&match_id_list);
    72 
    73         /*
    74          * Initialize pipes.
    75          */
    76         rc = usb_device_connection_initialize(&wire, hc_handle, address);
    77         if (rc != EOK) {
    78                 fprintf(stderr,
    79                     NAME ": failed to create connection to the device: %s.\n",
    80                     str_error(rc));
    81                 goto leave;
    82         }
    83         rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe, &wire);
    84         if (rc != EOK) {
    85                 fprintf(stderr,
    86                     NAME ": failed to create default control pipe: %s.\n",
    87                     str_error(rc));
    88                 goto leave;
    89         }
    90         rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
    91         if (rc != EOK) {
    92                 fprintf(stderr,
    93                     NAME ": failed to start session on control pipe: %s.\n",
    94                     str_error(rc));
    95                 goto leave;
    96         }
    9788
    9889        /*
     
    138129            config_descriptor.total_length);
    139130
     131        /*
     132         * Get supported languages of STRING descriptors.
     133         */
     134        l18_win_locales_t *langs;
     135        size_t langs_count;
     136        rc = usb_request_get_supported_languages(&ctrl_pipe,
     137            &langs, &langs_count);
     138        if (rc != EOK) {
     139                fprintf(stderr,
     140                    NAME ": failed to get list of supported languages: %s.\n",
     141                    str_error(rc));
     142                goto skip_strings;
     143        }
     144
     145        printf("String languages (%zu):", langs_count);
     146        size_t i;
     147        for (i = 0; i < langs_count; i++) {
     148                printf(" 0x%04x", (int) langs[i]);
     149        }
     150        printf(".\n");
     151
     152        /*
     153         * Dump all strings in all available langages;
     154         */
     155        for (i = 0; i < langs_count; i++) {
     156                l18_win_locales_t lang = langs[i];
     157
     158                printf("%sStrings for language 0x%04x:\n", get_indent(0),
     159                    (int) lang);
     160
     161                /*
     162                 * Try all indexes - we will see what pops-up ;-).
     163                 * However, to speed things up, we will stop after
     164                 * encountering several broken (or nonexistent ones)
     165                 * descriptors in line.
     166                 */
     167                size_t idx;
     168                size_t failed_count = 0;
     169                for (idx = 1; idx < 0xFF; idx++) {
     170                        char *string;
     171                        rc = usb_request_get_string(&ctrl_pipe, idx, lang,
     172                            &string);
     173                        if (rc != EOK) {
     174                                failed_count++;
     175                                if (failed_count > 3) {
     176                                        break;
     177                                }
     178                                continue;
     179                        }
     180                        printf("%sString #%zu: \"%s\"\n", get_indent(1),
     181                            idx, string);
     182                        free(string);
     183                        failed_count = 0; /* Reset failed counter. */
     184                }
     185        }
     186
     187
     188skip_strings:
     189
    140190        rc = EOK;
     191
    141192leave:
    142193        /* Ignoring errors here. */
    143         ipc_hangup(hc_phone);
    144194        usb_endpoint_pipe_end_session(&ctrl_pipe);
    145195
Note: See TracChangeset for help on using the changeset viewer.