summaryrefslogtreecommitdiff
path: root/common/usbx_pictbridge/src/ux_pictbridge_dpsclient_api_capability.c
blob: a70a959f76566792cbbc3473b84e97456c590c3b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/***************************************************************************
 * Copyright (c) 2024 Microsoft Corporation
 * Copyright (c) 2026-present Eclipse ThreadX contributors
 *
 * This program and the accompanying materials are made available under the
 * terms of the MIT License which is available at
 * https://opensource.org/licenses/MIT.
 *
 * SPDX-License-Identifier: MIT
 **************************************************************************/


/**************************************************************************/
/**************************************************************************/
/**                                                                       */
/** USBX Component                                                        */
/**                                                                       */
/**   Pictbridge Application                                              */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/


/* Include necessary system files.  */

#define UX_SOURCE_CODE

#include "ux_api.h"
#include "ux_pictbridge.h"
#include "ux_device_class_pima.h"


/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _ux_pictbridge_dpsclient_api_capability             PORTABLE C      */
/*                                                           6.1.12       */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Chaoqiong Xiao, Microsoft Corporation                               */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This function creates the tag lines of the configure_print_service  */
/*    request and then output the request to the printer.                 */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    pictbridge                            Pictbridge instance           */
/*    capability_code                       What capability to get        */
/*    capability_parameter                  Optional parameter            */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    Completion Status                                                   */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*    _ux_utility_delay_ms                  Delay ms                      */
/*    _ux_pictbridge_dps_client_input_object_prepare                      */
/*    _ux_system_event_flags_get                                         */
/*                                                                        */
/*  CALLED BY                                                             */
/*                                                                        */
/*    _ux_pictbridge_dpshost_object_get                                   */
/*                                                                        */
/**************************************************************************/
UINT _ux_pictbridge_dpsclient_api_capability(UX_PICTBRIDGE *pictbridge, ULONG capability_code,
                                             ULONG capability_parameter)
{
UINT                                status;
ULONG                               actual_flags;

    /* Wait for 100 ms to give a chance to the host to send a request before the client can post a Object Added event.  */
    _ux_utility_delay_ms(100);

    /* Prepare the object for capability. */
    status = _ux_pictbridge_dpsclient_input_object_prepare(pictbridge, UX_PICTBRIDGE_OR_GET_CAPABILITY,
                                                            capability_code, capability_parameter);

    /* Check status.  */
    if (status != UX_SUCCESS)
        return(status);

    /* We should wait for the host to send a script with the response.  */
    status =  _ux_system_event_flags_get(&pictbridge -> ux_pictbridge_event_flags_group, UX_PICTBRIDGE_EVENT_FLAG_CAPABILITY,
                                        UX_AND_CLEAR, &actual_flags, UX_PICTBRIDGE_EVENT_TIMEOUT);

    /* Check status.  */
    if (status != UX_SUCCESS)
        return(UX_EVENT_ERROR);

    /* Ensure the flag was set.  */
    if (actual_flags & UX_PICTBRIDGE_EVENT_FLAG_CAPABILITY)

        /* Return completion status.  */
        return(UX_SUCCESS);

    else

        /* Return completion status.  */
        return(UX_ERROR);
}