summaryrefslogtreecommitdiff
path: root/common/usbx_host_classes/src/ux_host_class_video_transfer_request_callback.c
blob: b056be7f7d04f8e3fe91fd08a8dcd4695021ab18 (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
/***************************************************************************
 * 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                                                        */
/**                                                                       */
/**   Video Class                                                         */
/**                                                                       */
/**************************************************************************/
/**************************************************************************/


/* Include necessary system files.  */

#define UX_SOURCE_CODE

#include "ux_api.h"
#include "ux_host_class_video.h"
#include "ux_host_stack.h"


/**************************************************************************/
/*                                                                        */
/*  FUNCTION                                               RELEASE        */
/*                                                                        */
/*    _ux_host_class_video_transfer_request_callback      PORTABLE C      */
/*                                                           6.1.12       */
/*  AUTHOR                                                                */
/*                                                                        */
/*    Chaoqiong Xiao, Microsoft Corporation                               */
/*                                                                        */
/*  DESCRIPTION                                                           */
/*                                                                        */
/*    This function receives a completion call back on an isoch transfer  */
/*    request.                                                            */
/*                                                                        */
/*  INPUT                                                                 */
/*                                                                        */
/*    transfer_request                      Pointer to transfer request   */
/*                                                                        */
/*  OUTPUT                                                                */
/*                                                                        */
/*    None                                                                */
/*                                                                        */
/*  CALLS                                                                 */
/*                                                                        */
/*    (ux_host_class_video_transfer_completion_function)                  */
/*                                          Transfer request completion   */
/*                                                                        */
/*  CALLED BY                                                             */
/*                                                                        */
/*    Video Class                                                         */
/*                                                                        */
/**************************************************************************/
VOID  _ux_host_class_video_transfer_request_callback(UX_TRANSFER *transfer_request)
{

UX_HOST_CLASS_VIDEO *video;
UX_ENDPOINT         *endpoint;
ULONG               transfer_index;


    /* Get the pointer to the video instance.  */
    video =  (UX_HOST_CLASS_VIDEO *) transfer_request -> ux_transfer_request_class_instance;

    /* Do a sanity check on the transfer request, if NULL something is wrong.  */
    if (video == UX_NULL)
        return;

    /* Check endpoint status.  */
    endpoint = video -> ux_host_class_video_isochronous_endpoint;
    if (endpoint -> ux_endpoint_transfer_request.ux_transfer_request_completion_code != UX_TRANSFER_STATUS_PENDING)
        return;

    /* The caller's transfer request needs to be updated.  */
    transfer_index = video -> ux_host_class_video_transfer_request_end_index;
    transfer_index++;
    if (transfer_index == UX_HOST_CLASS_VIDEO_TRANSFER_REQUEST_COUNT)
        transfer_index = 0;

    /* Update the transfer index.  */
    video -> ux_host_class_video_transfer_request_end_index = transfer_index;

    /* Call the completion routine.  */
    if (video -> ux_host_class_video_transfer_completion_function)
        video -> ux_host_class_video_transfer_completion_function(transfer_request);

    /* Return to caller.  */
    return;
}