GCC Code Coverage Report
Directory: ./ Exec Total Coverage
File: usbx_host_classes/src/ux_host_class_hid_report_decompress.c Lines: 10 10 100.0 %
Date: 2026-03-06 18:57:10 Branches: 4 4 100.0 %

Line Branch Exec Source
1
/***************************************************************************
2
 * Copyright (c) 2024 Microsoft Corporation
3
 * Copyright (c) 2026-present Eclipse ThreadX contributors
4
 *
5
 * This program and the accompanying materials are made available under the
6
 * terms of the MIT License which is available at
7
 * https://opensource.org/licenses/MIT.
8
 *
9
 * SPDX-License-Identifier: MIT
10
 **************************************************************************/
11
12
13
/**************************************************************************/
14
/**************************************************************************/
15
/**                                                                       */
16
/** USBX Component                                                        */
17
/**                                                                       */
18
/**   HID Class                                                           */
19
/**                                                                       */
20
/**************************************************************************/
21
/**************************************************************************/
22
23
24
/* Include necessary system files.  */
25
26
#define UX_SOURCE_CODE
27
28
#include "ux_api.h"
29
#include "ux_host_class_hid.h"
30
#include "ux_host_stack.h"
31
32
33
/**************************************************************************/
34
/*                                                                        */
35
/*  FUNCTION                                               RELEASE        */
36
/*                                                                        */
37
/*    _ux_host_class_hid_report_decompress                PORTABLE C      */
38
/*                                                           6.1          */
39
/*  AUTHOR                                                                */
40
/*                                                                        */
41
/*    Chaoqiong Xiao, Microsoft Corporation                               */
42
/*                                                                        */
43
/*  DESCRIPTION                                                           */
44
/*                                                                        */
45
/*    This function will decompress a raw report into a client buffer.    */
46
/*                                                                        */
47
/*  INPUT                                                                 */
48
/*                                                                        */
49
/*    hid                                   Pointer to HID class          */
50
/*    client_report                         Pointer to client report      */
51
/*    report_buffer                         Pointer to report buffer      */
52
/*    report_length                         Length of report              */
53
/*                                                                        */
54
/*  OUTPUT                                                                */
55
/*                                                                        */
56
/*    Completion Status                                                   */
57
/*                                                                        */
58
/*  CALLS                                                                 */
59
/*                                                                        */
60
/*    _ux_host_class_hid_field_decompress   Decompress field              */
61
/*                                                                        */
62
/*  CALLED BY                                                             */
63
/*                                                                        */
64
/*    HID Class                                                           */
65
/*                                                                        */
66
/**************************************************************************/
67
1187
UINT  _ux_host_class_hid_report_decompress(UX_HOST_CLASS_HID *hid, UX_HOST_CLASS_HID_CLIENT_REPORT *client_report,
68
                                           UCHAR  *report_buffer, ULONG report_length)
69
{
70
71
UX_HOST_CLASS_HID_REPORT     *hid_report;
72
UX_HOST_CLASS_HID_FIELD      *hid_field;
73
74
    UX_PARAMETER_NOT_USED(hid);
75
76
    /* Get the report pointer from the caller.  */
77
1187
    hid_report =  client_report -> ux_host_class_hid_client_report;
78
79
    /* Check if this report has a ID field in the front. An ID field is required
80
       if report ID is non null.  */
81
1187
    if (hid_report -> ux_host_class_hid_report_id != 0)
82
    {
83
84
        /* We have an ID tag in the report. The ID tag is the first byte of the report. Skip the
85
           ID tag and adjust the length.  */
86
7
        report_buffer++;
87
7
        report_length--;
88
    }
89
90
    /* Get the first field associated with the report.  */
91
1187
    hid_field =  hid_report -> ux_host_class_hid_report_field;
92
93
    /* We need to decompress each field defined in the report.  */
94
4351
    while (hid_field != UX_NULL)
95
    {
96
97
        /* Decompress a field.  */
98
3164
        _ux_host_class_hid_field_decompress(hid_field, report_buffer, client_report);
99
100
        /* Move to the next field.  */
101
3164
        hid_field =  hid_field -> ux_host_class_hid_field_next_field;
102
    }
103
104
    /* Return successful completion.  */
105
1187
    return(UX_SUCCESS);
106
}
107