1 /**************************************************************************/ 2 /* */ 3 /* Copyright (c) Microsoft Corporation. All rights reserved. */ 4 /* */ 5 /* This software is licensed under the Microsoft Software License */ 6 /* Terms for Microsoft Azure RTOS. Full text of the license can be */ 7 /* found in the LICENSE file at https://aka.ms/AzureRTOS_EULA */ 8 /* and in the root directory of this software. */ 9 /* */ 10 /**************************************************************************/ 11 12 /**************************************************************************/ 13 /**************************************************************************/ 14 /** */ 15 /** USBX Component */ 16 /** */ 17 /** Device Video Class */ 18 /** */ 19 /**************************************************************************/ 20 /**************************************************************************/ 21 22 #define UX_SOURCE_CODE 23 24 25 /* Include necessary system files. */ 26 27 #include "ux_api.h" 28 #include "ux_device_class_video.h" 29 #include "ux_device_stack.h" 30 31 32 #if defined(UX_DEVICE_STANDALONE) 33 /**************************************************************************/ 34 /* */ 35 /* FUNCTION RELEASE */ 36 /* */ 37 /* _ux_device_class_video_tasks_run PORTABLE C */ 38 /* 6.2.0 */ 39 /* AUTHOR */ 40 /* */ 41 /* Chaoqiong Xiao, Microsoft Corporation */ 42 /* */ 43 /* DESCRIPTION */ 44 /* */ 45 /* This function is the background task of the video. */ 46 /* */ 47 /* It's for standalone mode. */ 48 /* */ 49 /* INPUT */ 50 /* */ 51 /* instance Pointer to video class */ 52 /* */ 53 /* OUTPUT */ 54 /* */ 55 /* State machine status */ 56 /* UX_STATE_EXIT Device not configured */ 57 /* UX_STATE_IDLE No streaming transfer running */ 58 /* UX_STATE_WAIT Streaming transfer running */ 59 /* */ 60 /* CALLS */ 61 /* */ 62 /* (ux_device_class_video_stream_task_function) */ 63 /* Run stream task */ 64 /* */ 65 /* CALLED BY */ 66 /* */ 67 /* USBX Device Stack */ 68 /* */ 69 /* RELEASE HISTORY */ 70 /* */ 71 /* DATE NAME DESCRIPTION */ 72 /* */ 73 /* 10-31-2022 Chaoqiong Xiao Initial Version 6.2.0 */ 74 /* */ 75 /**************************************************************************/ _ux_device_class_video_tasks_run(VOID * instance)76UINT _ux_device_class_video_tasks_run(VOID *instance) 77 { 78 UX_SLAVE_DEVICE *device; 79 UX_DEVICE_CLASS_VIDEO *video; 80 UX_DEVICE_CLASS_VIDEO_STREAM *stream; 81 ULONG stream_index; 82 UINT status; 83 ULONG running_count; 84 85 86 /* Get Video instance. */ 87 video = (UX_DEVICE_CLASS_VIDEO *) instance; 88 89 /* Get the pointer to the device. */ 90 device = &_ux_system_slave -> ux_system_slave_device; 91 92 /* Check if the device is configured. */ 93 if (device -> ux_slave_device_state != UX_DEVICE_CONFIGURED) 94 return(UX_STATE_EXIT); 95 96 /* Run video streaming tasks. */ 97 running_count = 0; 98 for (stream_index = 0; 99 stream_index < video -> ux_device_class_video_streams_nb; 100 stream_index ++) 101 { 102 stream = &video -> ux_device_class_video_streams[stream_index]; 103 status = stream -> ux_device_class_video_stream_task_function(stream); 104 if (status == UX_STATE_EXIT) 105 return(status); 106 if (status == UX_STATE_WAIT) 107 running_count ++; 108 } 109 110 /* Return state running. */ 111 return (running_count > 0) ? (UX_STATE_WAIT) : (UX_STATE_IDLE); 112 } 113 #endif 114