/***************************************************************************
 * 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_completed     PORTABLE C      */
/*                                                           6.1          */
/*  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_request_completion_function)          */
/*                                          Transfer request completion   */
/*                                                                        */
/*  CALLED BY                                                             */
/*                                                                        */
/*    Video Class                                                         */
/*                                                                        */
/**************************************************************************/
VOID  _ux_host_class_video_transfer_request_completed(UX_TRANSFER *transfer_request)
{

UX_HOST_CLASS_VIDEO_TRANSFER_REQUEST     *video_transfer_request;


    /* Get the pointer to the video specific transfer request, by nature of the lined transfer requests,
       the corresponding transfer request has to be the head transfer request in the video instance.  */
    video_transfer_request =  (UX_HOST_CLASS_VIDEO_TRANSFER_REQUEST *) transfer_request -> ux_transfer_request_user_specific;

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

    /* The caller's transfer request needs to be updated.  */
    video_transfer_request -> ux_host_class_video_transfer_request_actual_length =    transfer_request -> ux_transfer_request_actual_length;
    video_transfer_request -> ux_host_class_video_transfer_request_completion_code =  transfer_request -> ux_transfer_request_completion_code;

    /* Call the completion routine.  */
    video_transfer_request -> ux_host_class_video_transfer_request_completion_function(video_transfer_request);

    /* Return to caller.  */
    return;
}

