1 /***************************************************************************
2  * Copyright (c) 2024 Microsoft Corporation
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the MIT License which is available at
6  * https://opensource.org/licenses/MIT.
7  *
8  * SPDX-License-Identifier: MIT
9  **************************************************************************/
10 
11 
12 /**************************************************************************/
13 /**************************************************************************/
14 /**                                                                       */
15 /** USBX Component                                                        */
16 /**                                                                       */
17 /**   Host Stack                                                          */
18 /**                                                                       */
19 /**************************************************************************/
20 /**************************************************************************/
21 
22 
23 /* Include necessary system files.  */
24 
25 #define UX_SOURCE_CODE
26 
27 #include "ux_api.h"
28 #include "ux_host_stack.h"
29 
30 
31 /**************************************************************************/
32 /*                                                                        */
33 /*  FUNCTION                                               RELEASE        */
34 /*                                                                        */
35 /*    _ux_host_stack_class_interface_scan                 PORTABLE C      */
36 /*                                                           6.1.4        */
37 /*  AUTHOR                                                                */
38 /*                                                                        */
39 /*    Chaoqiong Xiao, Microsoft Corporation                               */
40 /*                                                                        */
41 /*  DESCRIPTION                                                           */
42 /*                                                                        */
43 /*    This function will scan all default interfaces for a single         */
44 /*    configuration and call the registered class with the                */
45 /*    Class/SubClass/Protocol of the interface.                           */
46 /*                                                                        */
47 /*    If the device has multiple configurations (like the Apple iPod),    */
48 /*    the first configuration is treated as the default configuration.    */
49 /*    If a device which has multiple configurations wants to control the  */
50 /*    configuration selection, it must ensure that the PID/VID based      */
51 /*    class at the device level claims the entire device.                 */
52 /*                                                                        */
53 /*                                                                        */
54 /*    For the interface, there is no reason to use the PID/VID has a      */
55 /*    binding element as classes that trigger on PID/VID will be called   */
56 /*    by the device descriptor scanning process.                          */
57 /*                                                                        */
58 /*  INPUT                                                                 */
59 /*                                                                        */
60 /*    device                                Device pointer                */
61 /*                                                                        */
62 /*  OUTPUT                                                                */
63 /*                                                                        */
64 /*    Result of operation                                                 */
65 /*                                                                        */
66 /*  CALLS                                                                 */
67 /*                                                                        */
68 /*    _ux_host_stack_class_call             Call class command            */
69 /*    _ux_host_stack_device_configuration_select                          */
70 /*                                          Select configuration          */
71 /*    (ux_host_stack_class_call)            Call class from host stack    */
72 /*    (ux_host_class_entry_function)        Class entry function          */
73 /*                                                                        */
74 /*  CALLED BY                                                             */
75 /*                                                                        */
76 /*    USBX Components                                                     */
77 /*                                                                        */
78 /*  RELEASE HISTORY                                                       */
79 /*                                                                        */
80 /*    DATE              NAME                      DESCRIPTION             */
81 /*                                                                        */
82 /*  05-19-2020     Chaoqiong Xiao           Initial Version 6.0           */
83 /*  09-30-2020     Chaoqiong Xiao           Modified comment(s),          */
84 /*                                            resulting in version 6.1    */
85 /*  02-02-2021     Chaoqiong Xiao           Modified comment(s),          */
86 /*                                            used internal function call */
87 /*                                            to scan interfaces,         */
88 /*                                            resulting in version 6.1.4  */
89 /*                                                                        */
90 /**************************************************************************/
_ux_host_stack_class_interface_scan(UX_DEVICE * device)91 UINT  _ux_host_stack_class_interface_scan(UX_DEVICE *device)
92 {
93 
94 UX_CONFIGURATION        *configuration;
95 UINT                    status;
96 
97 
98     /* Get the 1st and only configuration.  If the device has multiple
99        configurations, we simply use the first one as default. */
100     configuration =  device -> ux_device_first_configuration;
101     if (configuration == UX_NULL)
102         return(UX_ERROR);
103 
104     /* Scan interfaces for this configuration.  */
105     status = _ux_host_stack_configuration_interface_scan(configuration);
106 
107     /* Return operation result.  */
108     return(status);
109 }
110 
111