AG903ライブラリリファレンス
内容インデックスホーム
Body Source
本文ソース
1: 11: 12: 16: 17: 18: #include "AG903_common.h" 19: 20: #include "bmu/bmumgr.h" 21: #include "bmu/bmuprm.h" 22: 23: 24: #define AG903_BMU_BUF_NUM_MAX (8) 25: 26: static AG903_BMUMgrHandle handle_list[AG903_BMU_UNIT_NUM]; 27: static _Bool handle_used_flag[AG903_BMU_UNIT_NUM] = {false}; 28: 29: 34: static void AG903_BMUMgrInit(uint8_t unit) { 35: AG903_BMUPrmSetCTRL(unit, 0); 36: AG903_BMUPrmSetMOD(unit, 0, 0, 0); 37: AG903_BMUPrmSetSINKMODULE(unit, 0); 38: AG903_BMUPrmSetBASEADR(unit, 0); 39: AG903_BMUPrmSetSTRIDE(unit, 0); 40: AG903_BMUPrmSetBUFNUM(unit, 0); 41: } 42: 43: 51: int32_t AG903_BMUMgrGetHandle(AG903_BMUMgrHandle **handle) 52: { 53: int32_t alloc_unit = -1; 54: int32_t i; 55: 56: 57: for(i = 0 ; i < AG903_BMU_UNIT_NUM ; i++) 58: { 59: if(handle_used_flag[i] != true) 60: { 61: alloc_unit = i; 62: break; 63: } 64: } 65: 66: if(alloc_unit == -1) 67: { 68: return -AG903_EBUSY; 69: } 70: 71: 72: AG903_BMUMgrInit(alloc_unit); 73: 74: (*handle) = &handle_list[alloc_unit]; 75: handle_used_flag[i] = true; 76: 77: (*handle)->unit_id = alloc_unit; 78: (*handle)->is_exec = false; 79: 80: return AG903_ENONE; 81: } 82: 83: 92: int32_t AG903_BMUMgrReleaseHandle(AG903_BMUMgrHandle *handle) 93: { 94: uint32_t unit = (handle - handle_list); 95: 96: 97: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 98: { 99: return -AG903_EINVAL; 100: } 101: 102: 103: if(handle->is_exec) 104: { 105: return -AG903_EBUSY; 106: } 107: handle_used_flag[unit] = false; 108: 109: return AG903_ENONE; 110: } 111: 112: 119: int32_t AG903_BMUMgrEnable(AG903_BMUMgrHandle *handle) 120: { 121: uint32_t unit = (handle - handle_list); 122: 123: 124: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 125: { 126: return -AG903_EINVAL; 127: } 128: 129: handle->is_exec = true; 130: AG903_BMUPrmSetCTRL(unit, 1); 131: 132: return AG903_ENONE; 133: } 134: 135: 143: int32_t AG903_BMUMgrDisable(AG903_BMUMgrHandle *handle) 144: { 145: uint32_t unit = (handle - handle_list); 146: 147: 148: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 149: { 150: return -AG903_EINVAL; 151: } 152: 153: handle->is_exec = false; 154: AG903_BMUPrmSetCTRL(unit, 0); 155: 156: return AG903_ENONE; 157: } 158: 159: 170: int32_t AG903_BMUMgrSetMode(AG903_BMUMgrHandle *handle, uint8_t ini, uint8_t mgr) 171: { 172: uint32_t unit = (handle - handle_list); 173: 174: 175: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 176: { 177: return -AG903_EINVAL; 178: } 179: 180: 181: if(handle->is_exec) 182: { 183: return -AG903_EBUSY; 184: } 185: 186: 187: if(ini > AG903_BMU_SINK_WAIT_DISABLE) 188: { 189: return -AG903_EINVAL; 190: } 191: 192: if(mgr > AG903_BMU_BUF_MGR_MODE3) 193: { 194: return -AG903_EINVAL; 195: } 196: 197: uint8_t cini, cmgr, csrc; 198: AG903_BMUPrmGetMOD(unit, &cini, &cmgr, &csrc); 199: AG903_BMUPrmSetMOD(unit, ini, mgr, csrc); 200: 201: return AG903_ENONE; 202: } 203: 204: 214: int32_t AG903_BMUMgrSetSrcModule(AG903_BMUMgrHandle *handle, uint8_t src) 215: { 216: uint32_t unit = (handle - handle_list); 217: 218: 219: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 220: { 221: return -AG903_EINVAL; 222: } 223: 224: 225: if(handle->is_exec) 226: { 227: return -AG903_EBUSY; 228: } 229: 230: 231: if(src > AG903_BMU_SRC_JPG0) 232: { 233: return -AG903_EINVAL; 234: } 235: 236: uint8_t ini, mgr, csrc; 237: AG903_BMUPrmGetMOD(unit, &ini, &mgr, &csrc); 238: AG903_BMUPrmSetMOD(unit, ini, mgr, src); 239: handle->src_id = src; 240: 241: return AG903_ENONE; 242: } 243: 244: 256: int32_t AG903_BMUMgrAddSinkModule(AG903_BMUMgrHandle *handle, uint8_t sink) 257: { 258: uint32_t unit = (handle - handle_list); 259: 260: 261: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 262: { 263: return -AG903_EINVAL; 264: } 265: 266: 267: if(handle->is_exec) 268: { 269: return -AG903_EBUSY; 270: } 271: 272: 273: if(sink > AG903_BMU_SINK_JPG0) 274: { 275: return -AG903_EINVAL; 276: } 277: 278: uint32_t reg; 279: AG903_BMUPrmGetSINKMODULE(unit, &reg); 280: reg |= 1 << sink; 281: AG903_BMUPrmSetSINKMODULE(unit, reg); 282: 283: return AG903_ENONE; 284: } 285: 286: 296: int32_t AG903_BMUMgrRemoveSinkModule(AG903_BMUMgrHandle *handle, uint8_t sink) 297: { 298: uint32_t unit = (handle - handle_list); 299: 300: 301: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 302: { 303: return -AG903_EINVAL; 304: } 305: 306: 307: if(handle->is_exec) 308: { 309: return -AG903_EBUSY; 310: } 311: 312: 313: if(sink > AG903_BMU_SINK_JPG0) 314: { 315: return -AG903_EINVAL; 316: } 317: 318: uint32_t reg; 319: AG903_BMUPrmGetSINKMODULE(unit, &reg); 320: reg &= ~(1 << sink); 321: AG903_BMUPrmSetSINKMODULE(unit, reg); 322: 323: return AG903_ENONE; 324: } 325: 326: 336: int32_t AG903_BMUMgrGetSinkStatus(AG903_BMUMgrHandle *handle, uint8_t sink, uint8_t *status) 337: { 338: uint32_t unit = (handle - handle_list); 339: 340: 341: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 342: { 343: return -AG903_EINVAL; 344: } 345: 346: 347: if(sink > AG903_BMU_SINK_JPG0) 348: { 349: return -AG903_EINVAL; 350: } 351: 352: uint32_t reg; 353: AG903_BMUPrmGetSINKSTAT(unit, &reg); 354: *status = (reg >> sink) & 1; 355: 356: return AG903_ENONE; 357: } 358: 359: 374: int32_t AG903_BMUMgrSetBufferConfig(AG903_BMUMgrHandle *handle, void *buffer, uint32_t stride, uint32_t buf_num) 375: { 376: uint32_t unit = (handle - handle_list); 377: 378: 379: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 380: { 381: return -AG903_EINVAL; 382: } 383: 384: 385: if(handle->is_exec) 386: { 387: return -AG903_EBUSY; 388: } 389: 390: 392: 393: if(stride >= (1<<(24+1)) || (stride & 0x7f)) 394: { 395: return -AG903_EINVAL; 396: } 397: 398: if(buf_num > AG903_BMU_BUF_NUM_MAX) 399: { 400: return -AG903_EINVAL; 401: } 402: 403: if (8 < buf_num) 404: { 405: return -AG903_EINVAL; 406: } 407: 408: if(buf_num == 8) 409: { 410: buf_num = 0; 411: } 412: 413: AG903_BMUPrmSetBASEADR(unit, ((uint32_t)buffer) & AG903_BMUn_BASEADR_ADR_MSK); 414: AG903_BMUPrmSetSTRIDE (unit, stride & AG903_BMUn_STRIDE_STRIDE_MSK); 415: AG903_BMUPrmSetBUFNUM (unit, buf_num); 416: 417: return AG903_ENONE; 418: } 419: 420: 429: int32_t AG903_BMUMgrGetStatus(AG903_BMUMgrHandle *handle, AG903_BMUMgrStatus *status) 430: { 431: uint32_t unit = (handle - handle_list); 432: 433: 434: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 435: { 436: return -AG903_EINVAL; 437: } 438: 439: BMUPrmParamSTAT regstat; 440: AG903_BMUPrmGetSTAT(unit, &regstat); 441: status->is_valid = (uint8_t)regstat.val; 442: status->is_empty = (uint8_t)regstat.empty; 443: status->is_read_wait_appeared = (uint8_t)regstat.rwa; 444: status->is_read_busy = (uint8_t)regstat.rbsy; 445: status->read_module_num = (uint8_t)regstat.rnum; 446: status->is_full = (uint8_t)regstat.full; 447: status->is_write_wait_appeared = (uint8_t)regstat.wwa; 448: status->is_write_busy = (uint8_t)regstat.wbsy; 449: status->write_module_num = (uint8_t)regstat.wnum; 450: 451: return AG903_ENONE; 452: } 453: 454: 465: int32_t AG903_BMUMgrGetBMUSinkAddress(AG903_BMUMgrHandle *handle, uint32_t *addr) 466: { 467: uint32_t unit = (handle - handle_list); 468: 469: 470: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 471: { 472: return -AG903_EINVAL; 473: } 474: 475: 476: (*addr) = (unit<<24) | ((uint32_t)5<<29); 477: 478: return AG903_ENONE; 479: } 480: 481: 492: int32_t AG903_BMUMgrGetBMUSrcAddress(AG903_BMUMgrHandle *handle, uint32_t *addr) 493: { 494: uint8_t src = handle->src_id; 495: uint32_t unit = (handle - handle_list); 496: 497: 498: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 499: { 500: return -AG903_EINVAL; 501: } 502: 503: 504: if(AG903_BMU_SRC_GFX0 <= src && src <= AG903_BMU_SRC_GFX3) 505: { 506: 507: (*addr) = (unit<<24) | ((uint32_t)5<<29) | ((uint32_t)1<<28); 508: }else 509: { 510: 511: (*addr) = (unit<<24) | ((uint32_t)5<<29); 512: } 513: 514: return AG903_ENONE; 515: } 516: 517: 526: int32_t AG903_BMUMgrGetBMUId(AG903_BMUMgrHandle *handle, uint8_t *id) 527: { 528: uint32_t unit = (handle - handle_list); 529: 530: 531: if(unit >= AG903_BMU_UNIT_NUM || &handle_list[unit] != handle) 532: { 533: return -AG903_EINVAL; 534: } 535: 536: (*id) = unit; 537: 538: return AG903_ENONE; 539: } 540:
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.