| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2007 Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bpvrlib_feed.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/4 $ |
|---|
| 12 | * $brcm_Date: 12/13/10 6:59p $ |
|---|
| 13 | * |
|---|
| 14 | * Module Description: |
|---|
| 15 | * |
|---|
| 16 | * PVR library, playback feeder module |
|---|
| 17 | * Revision History: |
|---|
| 18 | * |
|---|
| 19 | * $brcm_Log: /magnum/syslib/pvrlib/bpvrlib_feed.h $ |
|---|
| 20 | * |
|---|
| 21 | * Hydra_Software_Devel/4 12/13/10 6:59p vsilyaev |
|---|
| 22 | * SW7425-39: Added support for MUX input |
|---|
| 23 | * |
|---|
| 24 | * Hydra_Software_Devel/3 4/16/08 6:57p mward |
|---|
| 25 | * PR39994: Use BXPT_Playback_GetIntId() instead of channelNum. |
|---|
| 26 | * |
|---|
| 27 | * Hydra_Software_Devel/2 8/2/07 5:36p vsilyaev |
|---|
| 28 | * PR 33751: Improved documentation of bpvrlib_feed module |
|---|
| 29 | * |
|---|
| 30 | * Hydra_Software_Devel/1 8/2/07 4:18p vsilyaev |
|---|
| 31 | * PR 33751: |
|---|
| 32 | * |
|---|
| 33 | * |
|---|
| 34 | ***************************************************************************/ |
|---|
| 35 | #ifndef BPVRLIB_FEED_H__ |
|---|
| 36 | #define BPVRLIB_FEED_H__ |
|---|
| 37 | #include "bxpt_playback.h" |
|---|
| 38 | #include "bavc_xpt.h" |
|---|
| 39 | |
|---|
| 40 | #ifdef __cplusplus |
|---|
| 41 | extern "C" { |
|---|
| 42 | #endif |
|---|
| 43 | |
|---|
| 44 | /************************************************************************ |
|---|
| 45 | The BPVRlib_Feed is replacement for BPVRlib_Play. And goal of this |
|---|
| 46 | replacement is to improve performance, it's done in several ways: |
|---|
| 47 | o reduce code complexity by removing unused functionality |
|---|
| 48 | o support for batch operations (send multiple blocks at the time), thus spreading cost of function call across multiple data chunks |
|---|
| 49 | o effective use of cached memory to reduce latency of CPU to hardware communications. |
|---|
| 50 | |
|---|
| 51 | |
|---|
| 52 | Purpose of BPVRlib_Feed library is to send data from the memory using the playback block into the transport hardware. |
|---|
| 53 | |
|---|
| 54 | BPVRlib_Feed library provides scalable API that could be used in wide range of application |
|---|
| 55 | o data from circular FIFO |
|---|
| 56 | o data from network buffers |
|---|
| 57 | o synchronous transfer from the user's memory |
|---|
| 58 | o data from the stream parsers library |
|---|
| 59 | o good use of resources at hand (MIPS cache, scatter/gather nature of playback hardware) |
|---|
| 60 | o Asynchronous/non-blocking execution |
|---|
| 61 | |
|---|
| 62 | *************************************************************************/ |
|---|
| 63 | |
|---|
| 64 | |
|---|
| 65 | /* type of BPVRlib_Feed instance */ |
|---|
| 66 | typedef struct BPVRlib_Feed *BPVRlib_Feed_Handle; |
|---|
| 67 | |
|---|
| 68 | /* |
|---|
| 69 | Summary: |
|---|
| 70 | The settings needed for creating instance of BPVRlib_Feed |
|---|
| 71 | */ |
|---|
| 72 | typedef struct BPVRlib_Feed_Settings { |
|---|
| 73 | BXPT_Handle xptHandle; /* XPT handle */ |
|---|
| 74 | BXPT_Playback_Handle xptPlayHandle; /* XPT playback handle */ |
|---|
| 75 | BMEM_Heap_Handle heap; /* Mem heap handle */ |
|---|
| 76 | BINT_Handle intHandle; /* Int handle */ |
|---|
| 77 | bool useExtndedDesc; /* enable use of extended (8 word) descriprots if HW supports it, this allows use of the BPVRlib_Feed_AddExtendedOffsetEntries API */ |
|---|
| 78 | size_t numDesc; /* number of descriptors to use */ |
|---|
| 79 | void *applicationCnxt; /* application specific context */ |
|---|
| 80 | int applicationNumber; /* application specific number passed into the callback */ |
|---|
| 81 | void (*descAvaliable_isr)(void *applicationCnxt, int applicationNumber); /* function that is called when new descriptor becomes avaliable, e.g. when BPVRlib_Feed_AddEntries/BPVRlib_Feed_OffsetAddEntries could be called and it will consume some data */ |
|---|
| 82 | } BPVRlib_Feed_Settings; |
|---|
| 83 | |
|---|
| 84 | /* |
|---|
| 85 | Summary: |
|---|
| 86 | status of BPVRlib_Feed instance |
|---|
| 87 | See also: |
|---|
| 88 | BPVRlib_Feed_GetStatus |
|---|
| 89 | */ |
|---|
| 90 | typedef struct BPVRlib_Feed_Status { |
|---|
| 91 | unsigned freeDesc; /* number of avaliable descriptors, call to BPVRlib_Feed_AddEntries/BPVRlib_Feed_OffsetAddEntries will consume at least that many entries */ |
|---|
| 92 | } BPVRlib_Feed_Status; |
|---|
| 93 | |
|---|
| 94 | /* |
|---|
| 95 | Summary: |
|---|
| 96 | This structure describes single transfer unit for the feeder |
|---|
| 97 | Description: |
|---|
| 98 | This structure is used to describe transfer unit in terms of CPU virtual address |
|---|
| 99 | See also: |
|---|
| 100 | o BPVRlib_Feed_OffsetEntry |
|---|
| 101 | o BPVRlib_Feed_AddEntries |
|---|
| 102 | */ |
|---|
| 103 | typedef struct BPVRlib_Feed_Entry { |
|---|
| 104 | void *addr; /* memory address such BMEM_Heap_ConvertAddressToOffset could be uses convert address to the device offset, for example an address returned by BMEM_Alloc */ |
|---|
| 105 | size_t len; /* length of memory block */ |
|---|
| 106 | } BPVRlib_Feed_Entry; |
|---|
| 107 | |
|---|
| 108 | /* |
|---|
| 109 | Summary: |
|---|
| 110 | This structure describes single transfer unit for the feeder |
|---|
| 111 | Description: |
|---|
| 112 | This structure is used to describe transfer unit it terms of physicall device addresses (also known as device offset) |
|---|
| 113 | See also: |
|---|
| 114 | o BPVRlib_Feed_Entry |
|---|
| 115 | o BPVRlib_Feed_AddOffsetEntries |
|---|
| 116 | */ |
|---|
| 117 | typedef struct BPVRlib_Feed_OffsetEntry { |
|---|
| 118 | uint32_t offset; /* device offset of the memory region */ |
|---|
| 119 | size_t len; /* length of memory block */ |
|---|
| 120 | } BPVRlib_Feed_OffsetEntry; |
|---|
| 121 | |
|---|
| 122 | /* |
|---|
| 123 | Summary: |
|---|
| 124 | This structure describes extended single transfer unit for the feeder |
|---|
| 125 | Description: |
|---|
| 126 | This structure is used to describe transfer unit it terms of physicall device addresses (also known as device offset) |
|---|
| 127 | See also: |
|---|
| 128 | o BPVRlib_Feed_AddExtendedOffsetEntries |
|---|
| 129 | */ |
|---|
| 130 | typedef struct BPVRlib_Feed_ExtendedOffsetEntry { |
|---|
| 131 | BPVRlib_Feed_OffsetEntry baseEntry; |
|---|
| 132 | BAVC_TsMux_DescConfig flags; |
|---|
| 133 | } BPVRlib_Feed_ExtendedOffsetEntry; |
|---|
| 134 | |
|---|
| 135 | /* |
|---|
| 136 | Summary: |
|---|
| 137 | fills-out configuration structure with default values */ |
|---|
| 138 | void BPVRlib_Feed_GetDefaultSettings( |
|---|
| 139 | BPVRlib_Feed_Settings *settings /* pointer to the configuration structure */ |
|---|
| 140 | ); |
|---|
| 141 | /* |
|---|
| 142 | Summary: |
|---|
| 143 | opens new instancne of BPVRlib_Feed_ feeder |
|---|
| 144 | */ |
|---|
| 145 | BERR_Code BPVRlib_Feed_Open( |
|---|
| 146 | BPVRlib_Feed_Handle *feed, /* out pointer to the instance of BPVRlib_Feed */ |
|---|
| 147 | const BPVRlib_Feed_Settings *settings /* pointer to the configuration structure */ |
|---|
| 148 | ); |
|---|
| 149 | |
|---|
| 150 | /* |
|---|
| 151 | Summary: |
|---|
| 152 | releases all resources allocated for the feeder |
|---|
| 153 | */ |
|---|
| 154 | void BPVRlib_Feed_Close( |
|---|
| 155 | BPVRlib_Feed_Handle feed /* instance of BPVRlib_Feed */ |
|---|
| 156 | ); |
|---|
| 157 | |
|---|
| 158 | /* |
|---|
| 159 | Summary: |
|---|
| 160 | Addes new data to the feeder. |
|---|
| 161 | Description: |
|---|
| 162 | This function is used to add new data to the feeder. |
|---|
| 163 | Pointer to BPVRlib_Feed_Entry need to be valid only during duration of the function call . |
|---|
| 164 | */ |
|---|
| 165 | BERR_Code BPVRlib_Feed_AddEntries( |
|---|
| 166 | BPVRlib_Feed_Handle feed, /* instance of BPVRlib_Feed */ |
|---|
| 167 | BMEM_Heap_Handle heap, /* instance of BMEM_Heap_Handle that used to convert entries[i].addr to the device offset */ |
|---|
| 168 | const BPVRlib_Feed_Entry *entries, /* pointer to array of BPVRlib_Feed_Entry */ |
|---|
| 169 | size_t count, /* number of elements in the array */ |
|---|
| 170 | size_t *nconsumed /* out pointer to return number of consumed elements */ |
|---|
| 171 | ); |
|---|
| 172 | |
|---|
| 173 | /* |
|---|
| 174 | Summary: |
|---|
| 175 | Addes new data to the feeder. |
|---|
| 176 | Description: |
|---|
| 177 | This function is used to add new data to the feeder. |
|---|
| 178 | Pointer to BPVRlib_Feed_Entry need to be valid only during duration of the function call. |
|---|
| 179 | This function shall be used if address can't be converted by using BMEM_Heap_Handle or user want's to |
|---|
| 180 | remove overhead of calling BMEM_Heap_ConvertAddressToOffset for each address |
|---|
| 181 | */ |
|---|
| 182 | BERR_Code BPVRlib_Feed_AddOffsetEntries( |
|---|
| 183 | BPVRlib_Feed_Handle feed, /* instance of BPVRlib_Feed */ |
|---|
| 184 | const BPVRlib_Feed_OffsetEntry *entries, /* pointer to array of BPVRlib_Feed_OffsetEntry */ |
|---|
| 185 | size_t count, /* number of elements in the array */ |
|---|
| 186 | size_t *nconsumed/* out pointer to return number of consumed elements */ |
|---|
| 187 | ); |
|---|
| 188 | |
|---|
| 189 | /* |
|---|
| 190 | Summary: |
|---|
| 191 | Addes new data to the feeder. |
|---|
| 192 | Description: |
|---|
| 193 | This function is used to add new data to the feeder. |
|---|
| 194 | Pointer to BPVRlib_Feed_ExtendedOffsetEntry need to be valid only during duration of the function call. |
|---|
| 195 | This function shall be used if address can't be converted by using BMEM_Heap_Handle or user want's to |
|---|
| 196 | remove overhead of calling BMEM_Heap_ConvertAddressToOffset for each address. |
|---|
| 197 | See also: |
|---|
| 198 | o BPVRlib_Feed_AddOffsetEntries |
|---|
| 199 | o BPVRlib_Feed_Settings |
|---|
| 200 | */ |
|---|
| 201 | BERR_Code BPVRlib_Feed_AddExtendedOffsetEntries( |
|---|
| 202 | BPVRlib_Feed_Handle feed, /* instance of BPVRlib_Feed */ |
|---|
| 203 | const BPVRlib_Feed_ExtendedOffsetEntry *entries, /* pointer to array of BPVRlib_Feed_ExtendedOffsetEntries */ |
|---|
| 204 | size_t count, /* number of elements in the array */ |
|---|
| 205 | size_t *nconsumed/* out pointer to return number of consumed elements */ |
|---|
| 206 | ); |
|---|
| 207 | |
|---|
| 208 | /* |
|---|
| 209 | Summary: |
|---|
| 210 | This function is used to monitor progress of transaction |
|---|
| 211 | Description: |
|---|
| 212 | This function returns number of completed entries since last call to BPVRlib_Feed_GetCompleted. Often |
|---|
| 213 | application would use this number recycle memory. |
|---|
| 214 | */ |
|---|
| 215 | BERR_Code BPVRlib_Feed_GetCompleted( |
|---|
| 216 | BPVRlib_Feed_Handle feed, /* instance of BPVRlib_Feed */ |
|---|
| 217 | size_t *ncompleted /* out pointer to return number of completed elements */ |
|---|
| 218 | ); |
|---|
| 219 | /* |
|---|
| 220 | Summary: |
|---|
| 221 | This function activates data feeding |
|---|
| 222 | */ |
|---|
| 223 | BERR_Code BPVRlib_Feed_Start( |
|---|
| 224 | BPVRlib_Feed_Handle feed /* instance of BPVRlib_Feed */ |
|---|
| 225 | ); |
|---|
| 226 | |
|---|
| 227 | /* |
|---|
| 228 | Summary: |
|---|
| 229 | This function deactivates data feeding. |
|---|
| 230 | Description: |
|---|
| 231 | The BPVRlib_Feed_Stop function stops data feeding, all unsent entries are discarded. |
|---|
| 232 | */ |
|---|
| 233 | void BPVRlib_Feed_Stop( |
|---|
| 234 | BPVRlib_Feed_Handle feed /* instance of BPVRlib_Feed */ |
|---|
| 235 | ); |
|---|
| 236 | /* |
|---|
| 237 | Summary: |
|---|
| 238 | This function returms statos of BPVRlib_Feed module |
|---|
| 239 | */ |
|---|
| 240 | void BPVRlib_Feed_GetStatus( |
|---|
| 241 | BPVRlib_Feed_Handle feed, /* instance of BPVRlib_Feed */ |
|---|
| 242 | BPVRlib_Feed_Status *status /* out pointer to the BPVRlib_Feed_Status structure */ |
|---|
| 243 | ); |
|---|
| 244 | #ifdef __cplusplus |
|---|
| 245 | } |
|---|
| 246 | #endif |
|---|
| 247 | |
|---|
| 248 | #endif /* BPVRLIB_FEED_H__ */ |
|---|
| 249 | |
|---|