AG903ライブラリリファレンス
内容インデックスホーム
前へ上へ次へ
pgpmgr.c

PGP Manager

PGP Manager Layer.

none

AXELL CORPORATION

2017_02_22 初版 

2017_10_26 Ver2.0 

2018_01_24 [SDK2.1] 画像前処理の制限項目によるエラーチェックと説明文の追加 (#1773) 

2018_01_24 [SDK2.1] パイプライン入力ポートに指定するデジタルビデオ入力ポートハンドルの型に誤り (#1757) 

2019_12_27 [SDK3.0] PGPのラベリング解析関数が確保したリソースを解放する関数を追加 (#1951) 

2024_03_22 [SDK3.6] PGPのソースがVIDであることを確認するときの型キャストの不具合を修正 (#4940)

1: 13: 14: 18: 19: 20: #include <stdio.h> 21: #include "pgpmgr_common.h" 22: #include "pgp/pgpprm.h" 23: #include "via/viamgr.h" 24: #include "vid/vidmgr.h" 25: 26: 34: false, 0, 35: 0, {{0}}, 36: 0, {{0}}, 37: 0, {{0}}, 38: 0, {{0}}, 39: {NULL}, {NULL}, {NULL}, {NULL}, 40: {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, {NULL}, 41: {0}, 42: }; 43: 44: 50: PgpMgrContext *PgpGetContext(void) 51: { 52: return &PgpContext; 53: } 54: 55: 56: 57: #define CSC_MUL_MASK 0xFFF 58: #define CSC_ADD_MASK 0xFFFFF 59: 60: #define SPF1_COEFF_MASK 0xFF 61: #define SPF1_OFFSET_MASK 0x1FF 62: 63: #define THR_MSK_L_MASK 0x1 64: #define THR_MSK_H_MASK 0x1 65: #define THR_MSK_X_MASK 0x1 66: #define THR_MSK_HMAX_MASK 0xFF 67: #define THR_MSK_HMIN_MASK 0xFF 68: #define THR_MSK_LMAX_MASK 0xFF 69: #define THR_MSK_LMIN_MASK 0xFF 70: 71: #define THR_8THR_MAXV_MASK 0xFF 72: #define THR_8THR_MAXTH_MASK 0xFF 73: #define THR_8THR_MINTH_MASK 0xFF 74: 75: #define THR_SPF1_COEFF_MASK 0x1 76: #define THR_SPF1_THR_MASK 0x3F 77: 78: #define IFC_GAIN_MASK 0xFF 79: 80: #ifndef AG903_PGP_MGR_TS_FORCE_DISABLE 81: 82: 93: int32_t AG903_PgpMgrEnableTimeSharingPipeline(_Bool enable) 94: { 95: if ((PgpContext.num_pipeline_handles != 0) || 96: (PgpContext.num_vram_input_handles != 0) || 97: (PgpContext.num_frame_calc_handles != 0) || 98: (PgpContext.num_dgc_lut != 0)) { 99: return -AG903_EINVAL; 100: } 101: 102: PgpContext.pipeline_time_sharing_enable = enable; 103: 104: return AG903_ENONE; 105: } 106: #endif 107: 108: 109: 119: int32_t AG903_PgpMgrGetPipelineHandle(int32_t num, AG903_PgpMgrPipelineHandle **handles) 120: { 121: int i, j; 122: 123: 124: if (PgpContext.pipeline_time_sharing_enable == true) { 125: if ((num + PgpContext.num_pipeline_handles) > AG903_PGP_MGR_MAX_PIPELINE_HANDLE) { 126: return -AG903_EINVAL; 127: } 128: } else { 129: if ((num + PgpContext.num_pipeline_handles) > AG903_PGP_MGR_PIPELINE_NUM) { 130: return -AG903_EINVAL; 131: } 132: } 133: 134: if (handles == NULL) { 135: return -AG903_EINVAL; 136: } 137: 138: 139: for (i = 0; i < num; i++) { 140: for (j = 0; j < AG903_PGP_MGR_MAX_PIPELINE_HANDLE; j++) { 141: if (PgpContext.pipeline_handles[j].is_used == false) { 142: 143: PgpMgrInitPipelineHandle(&PgpContext.pipeline_handles[j]); 144: 145: PgpContext.pipeline_handles[j].is_used = true; 146: PgpContext.pipeline_handles[j].id = AG903_PGP_MGR_PIPELINE_HANDLE_ID; 147: handles[i] = &PgpContext.pipeline_handles[j]; 148: break; 149: } 150: } 151: } 152: 153: 154: if (PgpContext.num_pipeline_handles == 0) { 155: PgpMgrSetIntr(); 156: } 157: PgpContext.num_pipeline_handles += num; 158: return AG903_ENONE; 159: } 160: 161: 162: 171: int32_t AG903_PgpMgrReleasePipelineHandle(AG903_PgpMgrPipelineHandle *handle) 172: { 173: 174: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 175: return -AG903_EINVAL; 176: } 177: 178: if (handle->is_used_frame_calc == true) { 179: return -AG903_EINVAL; 180: } 181: 182: 183: if (handle->pipeline_no != -1) { 184: 185: if (PgpContext.exec_pipeline[handle->pipeline_no] == handle) { 186: PGPPrmParamPGPnSTATE state; 187: AG903_PgpPrmGetPGPnSTATE(handle->pipeline_no, &state); 188: if (state.st != AG903_PGP_MGR_STATE_IDLE) { 189: return -AG903_EBUSY; 190: } 191: PgpContext.exec_pipeline[handle->pipeline_no] = NULL; 192: } 193: if (PgpContext.assign_pipeline[handle->pipeline_no] == handle) { 194: PgpContext.assign_pipeline[handle->pipeline_no] = NULL; 195: } 196: } 197: if (handle->input_handle != NULL) { 198: AG903_PgpMgrVRAMInputHandle *vram_handle = (AG903_PgpMgrVRAMInputHandle *)handle->input_handle; 199: 200: if (vram_handle->id == AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID) { 201: vram_handle->ref_cnt--; 202: 203: if (PgpContext.pipeline_time_sharing_enable == false) { 204: if ((vram_handle->ref_cnt == 0) && (vram_handle->port_no != -1)) { 205: if (PgpContext.assign_vram[vram_handle->port_no] == vram_handle) { 206: PgpContext.assign_vram[vram_handle->port_no] = NULL; 207: } 208: } 209: } 210: } 211: } 212: 213: if (handle->dgc_lut != NULL) { 214: handle->dgc_lut->ref_cnt--; 215: } 216: handle->is_used = false; 217: handle->id = 0; 218: PgpContext.num_pipeline_handles--; 219: 220: 221: if (PgpContext.num_pipeline_handles == 0) { 222: PgpMgrResetIntr(); 223: } 224: return AG903_ENONE; 225: } 226: 227: 228: 245: int32_t AG903_PgpMgrAssignPipeline(void *handle) 246: { 247: uint32_t id; 248: 249: if (handle == NULL) { 250: return -AG903_EINVAL; 251: } 252: 253: 254: id = ((AG903_PgpMgrPipelineHandle *)handle)->id; 255: if ((id != AG903_PGP_MGR_PIPELINE_HANDLE_ID) && (id != AG903_PGP_MGR_FRAME_CALC_HANDLE_ID)) { 256: return -AG903_EINVAL; 257: } 258: 259: if (id == AG903_PGP_MGR_PIPELINE_HANDLE_ID) { 260: AG903_PgpMgrPipelineHandle *p = (AG903_PgpMgrPipelineHandle *)handle; 261: 262: if (p->is_assign == true) { 263: return -AG903_EINVAL; 264: } 265: 266: if (p->input_handle == NULL) { 267: return -AG903_EINVAL; 268: } 269: 270: return PgpMgrAssignPipelineHandle(p); 271: } else { 272: AG903_PgpMgrFrameCalcHandle *f = (AG903_PgpMgrFrameCalcHandle *)handle; 273: 274: if (f->master_handle->is_assign == true) { 275: return -AG903_EINVAL; 276: } 277: 278: if (f->master_handle->input_handle == NULL) { 279: return -AG903_EINVAL; 280: } 281: 282: if (f->slave_pipeline == true) { 283: AG903_PgpMgrPipelineHandle *slave = (AG903_PgpMgrPipelineHandle *)f->slave_handle; 284: if (slave->input_handle == NULL) { 285: return -AG903_EINVAL; 286: } 287: } 288: 289: return PgpMgrAssignFrameCalcHandle(f); 290: } 291: } 292: 293: 294: 306: int32_t AG903_PgpMgrForceAssignPipeline(void *handle, uint32_t pipeline) 307: { 308: uint32_t id; 309: 310: if (handle == NULL) { 311: return -AG903_EINVAL; 312: } 313: 314: id = ((AG903_PgpMgrPipelineHandle *)handle)->id; 315: if ((id != AG903_PGP_MGR_PIPELINE_HANDLE_ID) && (id != AG903_PGP_MGR_FRAME_CALC_HANDLE_ID)) { 316: return -AG903_EINVAL; 317: } 318: switch (pipeline) { 319: case AG903_PGP_MGR_CALC_PIPELINE0: 320: case AG903_PGP_MGR_CALC_PIPELINE1: 321: case AG903_PGP_MGR_INPUT_PIPELINE0: 322: case AG903_PGP_MGR_INPUT_PIPELINE1: 323: case AG903_PGP_MGR_FRAME_PIPELINE0: 324: case AG903_PGP_MGR_FRAME_PIPELINE1: 325: break; 326: default: 327: return -AG903_EINVAL; 328: } 329: 330: if (id == AG903_PGP_MGR_PIPELINE_HANDLE_ID) { 331: AG903_PgpMgrPipelineHandle *p = (AG903_PgpMgrPipelineHandle *)handle; 332: 333: if (p->is_assign == true) { 334: return -AG903_EINVAL; 335: } 336: 337: if (p->input_handle == NULL) { 338: return -AG903_EINVAL; 339: } 340: 341: if (p->is_used_frame_calc == true) { 342: return -AG903_EINVAL; 343: } 344: 345: return PgpMgrForceAssignPipelineHandle(p, pipeline); 346: } else { 347: AG903_PgpMgrFrameCalcHandle *f = (AG903_PgpMgrFrameCalcHandle *)handle; 348: 349: if (f->master_handle->is_assign == true) { 350: return -AG903_EINVAL; 351: } 352: 353: if (f->master_handle->input_handle == NULL) { 354: return -AG903_EINVAL; 355: } 356: 357: if (f->slave_pipeline == true) { 358: AG903_PgpMgrPipelineHandle *slave = (AG903_PgpMgrPipelineHandle *)f->slave_handle; 359: if (slave->input_handle == NULL) { 360: return -AG903_EINVAL; 361: } 362: } 363: 364: return PgpMgrForceAssignFrameCalcHandle(f, pipeline); 365: } 366: } 367: 368: 369: 379: int32_t AG903_PgpMgrReleaseAssignment(void *handle) 380: { 381: uint32_t id; 382: AG903_PgpMgrVRAMInputHandle *vram_handle; 383: 384: if (handle == NULL) { 385: return -AG903_EINVAL; 386: } 387: 388: id = ((AG903_PgpMgrPipelineHandle *)handle)->id; 389: if ((id != AG903_PGP_MGR_PIPELINE_HANDLE_ID) && (id != AG903_PGP_MGR_FRAME_CALC_HANDLE_ID)) { 390: return -AG903_EINVAL; 391: } 392: 393: if (id == AG903_PGP_MGR_PIPELINE_HANDLE_ID) { 394: AG903_PgpMgrPipelineHandle *p = (AG903_PgpMgrPipelineHandle *)handle; 395: 396: if (p->is_assign == false) { 397: return -AG903_EINVAL; 398: } 399: if (PgpContext.exec_pipeline[p->pipeline_no] == p) { 400: 401: PGPPrmParamPGPnSTATE state; 402: AG903_PgpPrmGetPGPnSTATE(p->pipeline_no, &state); 403: if (state.st != AG903_PGP_MGR_STATE_IDLE) { 404: return -AG903_EBUSY; 405: } 406: PgpContext.exec_pipeline[p->pipeline_no] = NULL; 407: } 408: 409: if (PgpContext.assign_pipeline[p->pipeline_no] == handle) { 410: PgpContext.assign_pipeline[p->pipeline_no] = NULL; 411: } 412: 413: vram_handle = (AG903_PgpMgrVRAMInputHandle *)p->input_handle; 414: if ((vram_handle != NULL) && (vram_handle->id == AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 415: vram_handle->ref_cnt--; 416: } 417: p->is_assign = false; 418: p->pipeline_no = -1; 419: p->input_handle = NULL; 420: } else { 421: AG903_PgpMgrFrameCalcHandle *f = (AG903_PgpMgrFrameCalcHandle *)handle; 422: AG903_PgpMgrPipelineHandle *master = (AG903_PgpMgrPipelineHandle *)f->master_handle; 423: AG903_PgpMgrPipelineHandle *slave = (AG903_PgpMgrPipelineHandle *)f->slave_handle; 424: 425: if (master->is_assign == false) { 426: return -AG903_EINVAL; 427: } 428: if (PgpContext.exec_pipeline[master->pipeline_no] == master) { 429: 430: PGPPrmParamPGPnSTATE state; 431: AG903_PgpPrmGetPGPnSTATE(master->pipeline_no, &state); 432: if (state.st != AG903_PGP_MGR_STATE_IDLE) { 433: return -AG903_EBUSY; 434: } 435: PgpContext.exec_pipeline[master->pipeline_no] = NULL; 436: } 437: 438: if (PgpContext.assign_pipeline[master->pipeline_no] == master) { 439: PgpContext.assign_pipeline[master->pipeline_no] = NULL; 440: } 441: 442: vram_handle = (AG903_PgpMgrVRAMInputHandle *)master->input_handle; 443: if ((vram_handle != NULL) && (vram_handle->id == AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 444: vram_handle->ref_cnt--; 445: } 446: master->is_assign = false; 447: master->pipeline_no = -1; 448: master->input_handle = NULL; 449: 450: if (slave->id == AG903_PGP_MGR_PIPELINE_HANDLE_ID) { 451: if (PgpContext.assign_pipeline[slave->pipeline_no] == slave) { 452: PgpContext.assign_pipeline[slave->pipeline_no] = NULL; 453: } 454: if (PgpContext.exec_pipeline[slave->pipeline_no] == slave) { 455: PgpContext.exec_pipeline[slave->pipeline_no] = NULL; 456: } 457: 458: vram_handle = (AG903_PgpMgrVRAMInputHandle *)slave->input_handle; 459: if ((vram_handle != NULL) && (vram_handle->id == AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 460: vram_handle->ref_cnt--; 461: } 462: slave->is_assign = false; 463: slave->pipeline_no = -1; 464: slave->input_handle = NULL; 465: } 466: } 467: 468: return AG903_ENONE; 469: } 470: 471: 472: 481: int32_t AG903_PgpMgrCheckFunctionValidation(AG903_PgpMgrPipelineHandle *handle, uint32_t pipeline) 482: { 483: 484: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 485: return -AG903_EINVAL; 486: } 487: 488: 489: switch (pipeline) { 490: case AG903_PGP_MGR_CALC_PIPELINE0: 491: case AG903_PGP_MGR_CALC_PIPELINE1: 492: case AG903_PGP_MGR_INPUT_PIPELINE0: 493: case AG903_PGP_MGR_INPUT_PIPELINE1: 494: case AG903_PGP_MGR_FRAME_PIPELINE0: 495: case AG903_PGP_MGR_FRAME_PIPELINE1: 496: break; 497: default: 498: return -AG903_EINVAL; 499: } 500: 501: return PgpMgrCheckAssignPipelineHandle(handle, pipeline); 502: } 503: 504: 505: 523: int32_t AG903_PgpMgrExecPipeline(void *handle, uint32_t cmd) 524: { 525: uint32_t id; 526: 527: if (handle == NULL) { 528: return -AG903_EINVAL; 529: } 530: 531: 532: id = ((AG903_PgpMgrPipelineHandle *)handle)->id; 533: if ((id != AG903_PGP_MGR_PIPELINE_HANDLE_ID) && (id != AG903_PGP_MGR_FRAME_CALC_HANDLE_ID)) { 534: return -AG903_EINVAL; 535: } 536: 537: switch (cmd) { 538: case AG903_PGP_MGR_CMD_NONE: 539: case AG903_PGP_MGR_CMD_EXEC: 540: case AG903_PGP_MGR_CMD_EXEC_CONTINUE: 541: case AG903_PGP_MGR_CMD_TRIG: 542: case AG903_PGP_MGR_CMD_TRIG_CONTINUE: 543: case AG903_PGP_MGR_CMD_IDLE: 544: case AG903_PGP_MGR_CMD_RESET_TIMESTAMP_CNT: 545: case AG903_PGP_MGR_CMD_RESET_FRAME_CNT: 546: case AG903_PGP_MGR_CMD_RESET_INTR_CNT: 547: case AG903_PGP_MGR_CMD_FORCE_QUIT: 548: break; 549: default: 550: return -AG903_EINVAL; 551: } 552: 553: if (id == AG903_PGP_MGR_PIPELINE_HANDLE_ID) { 554: AG903_PgpMgrPipelineHandle *p = (AG903_PgpMgrPipelineHandle *)handle; 555: 556: if (p->is_assign == false) { 557: return -AG903_EINVAL; 558: } 559: 560: return PgpMgrExecPipelineHandle(p, cmd); 561: } else { 562: AG903_PgpMgrFrameCalcHandle *f = (AG903_PgpMgrFrameCalcHandle *)handle; 563: AG903_PgpMgrPipelineHandle *master = (AG903_PgpMgrPipelineHandle *)f->master_handle; 564: 565: if (master->is_assign == false) { 566: return -AG903_EINVAL; 567: } 568: 569: return PgpMgrExecFrameCalcHandle(f, cmd); 570: } 571: } 572: 573: 574: 585: int32_t AG903_PgpMgrSetIntrCallbackFunc(AG903_PgpMgrPipelineHandle *handle, uint32_t type, void (*func)(int32_t id, void *handle)) 586: { 587: 588: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 589: return -AG903_EINVAL; 590: } 591: 592: switch (type) { 593: case AG903_PGP_MGR_INTR_INPUT: 594: handle->intr_vsynci_enable = (func == NULL) ? false : true; 595: handle->intr_input_func = func; 596: break; 597: case AG903_PGP_MGR_INTR_OUTPUT: 598: handle->intr_vsynco_enable = (func == NULL) ? false : true; 599: handle->intr_output_func = func; 600: break; 601: case AG903_PGP_MGR_INTR_DONE: 602: handle->intr_vsynco_enable = (func == NULL) ? false : true; 603: handle->intr_done_func = func; 604: break; 605: case AG903_PGP_MGR_INTR_VRAM_ERROR: 606: handle->intr_voicpl_enable = handle->intr_vooflw_enable = (func == NULL) ? false : true; 607: handle->intr_vram_error_func = func; 608: break; 609: case AG903_PGP_MGR_INTR_LBL_ERROR: 610: handle->intr_lblcrpt_enable = (func == NULL) ? false : true; 611: handle->intr_lbl_error_func = func; 612: break; 613: case AG903_PGP_MGR_INTR_HGM_ERROR: 614: handle->intr_hgmicpl_enable = (func == NULL) ? false : true; 615: handle->intr_hgm_error_func = func; 616: break; 617: case AG903_PGP_MGR_INTR_ND: 618: handle->intr_nd_enable = (func == NULL) ? false : true; 619: handle->intr_nd_func = func; 620: break; 621: case AG903_PGP_MGR_INTR_IFC_OVF: 622: handle->intr_ifcofs_enable = handle->intr_ifcofm_enable = (func == NULL) ? false : true; 623: handle->intr_ifc_ovf_func = func; 624: break; 625: case AG903_PGP_MGR_INTR_INPUT_LINE: 626: handle->intr_vlinei_enable = (func == NULL) ? false : true; 627: handle->intr_input_line_func = func; 628: break; 629: case AG903_PGP_MGR_INTR_OUTPUT_LINE: 630: handle->intr_vlineo_enable = (func == NULL) ? false : true; 631: handle->intr_output_line_func = func; 632: break; 633: case AG903_PGP_MGR_INTR_LBL_DONE: 634: handle->intr_lblcpl_enable = (func == NULL) ? false : true; 635: handle->intr_lbl_done_func = func; 636: break; 637: case AG903_PGP_MGR_INTR_HGM_DONE: 638: handle->intr_hgmcpl_enable = (func == NULL) ? false : true; 639: handle->intr_hgm_done_func = func; 640: break; 641: default: 642: return -AG903_EINVAL; 643: } 644: 645: handle->is_dirty = true; 646: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_INTR_ENABLE] = true; 647: return AG903_ENONE; 648: } 649: 650: 651: 677: int32_t AG903_PgpMgrSetConfigIntrCtrl(AG903_PgpMgrPipelineHandle *handle, uint32_t input_field, uint32_t input_fcnt, uint32_t input_line, uint32_t output_field, uint32_t output_fcnt, uint32_t output_line) 678: { 679: 680: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 681: return -AG903_EINVAL; 682: } 683: 684: 685: switch (input_field) { 686: case AG903_PGP_MGR_INTR_CTRL_FIELD_ODD: 687: case AG903_PGP_MGR_INTR_CTRL_FIELD_EVEN: 688: case AG903_PGP_MGR_INTR_CTRL_FIELD_ODD_EVEN: 689: break; 690: default: 691: return -AG903_EINVAL; 692: } 693: if ((input_fcnt == 0) || (input_fcnt > AG903_PGP_MGR_INTR_CTRL_MAX_FRAME_CNT)) { 694: return -AG903_EINVAL; 695: } 696: if (input_line > AG903_PGP_MGR_INTR_CTRL_MAX_INPUT_LINE) { 697: return -AG903_EINVAL; 698: } 699: switch (output_field) { 700: case AG903_PGP_MGR_INTR_CTRL_FIELD_ODD: 701: case AG903_PGP_MGR_INTR_CTRL_FIELD_EVEN: 702: case AG903_PGP_MGR_INTR_CTRL_FIELD_ODD_EVEN: 703: break; 704: default: 705: return -AG903_EINVAL; 706: } 707: if ((output_fcnt == 0) || (output_fcnt > AG903_PGP_MGR_INTR_CTRL_MAX_FRAME_CNT)) { 708: return -AG903_EINVAL; 709: } 710: if (output_line > AG903_PGP_MGR_INTR_CTRL_MAX_OUTPUT_LINE) { 711: return -AG903_EINVAL; 712: } 713: 714: 715: handle->input_intr_field = input_field; 716: handle->input_intr_fcnt = input_fcnt; 717: handle->input_intr_line = input_line; 718: handle->output_intr_field = output_field; 719: handle->output_intr_fcnt = output_fcnt; 720: handle->output_intr_line = output_line; 721: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_INTR_CTRL] = true; 722: handle->is_dirty = true; 723: return AG903_ENONE; 724: } 725: 726: 727: 742: int32_t AG903_PgpMgrGetPipelineStatus(AG903_PgpMgrPipelineHandle *handle, uint32_t *blank, _Bool *is_vram_out, uint32_t *queue_cnt, uint32_t *sub_status, uint32_t *status) 743: { 744: PGPPrmParamPGPnSTATE state; 745: 746: 747: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 748: return -AG903_EINVAL; 749: } 750: 751: if (handle->is_assign != true) { 752: return -AG903_EINVAL; 753: } 754: 755: 756: AG903_PgpPrmGetPGPnSTATE(handle->pipeline_no, &state); 757: 758: 759: if ((PgpContext.exec_pipeline[handle->pipeline_no] != handle) && (state.st != AG903_PGP_MGR_STATE_IDLE)) { 760: return -AG903_EINVAL; 761: } 762: 763: if (blank != NULL) { 764: *blank = state.blank; 765: } 766: if (is_vram_out != NULL) { 767: *is_vram_out = state.vrmacc; 768: } 769: if (queue_cnt != NULL) { 770: *queue_cnt = state.queue; 771: } 772: if (sub_status != NULL) { 773: *sub_status = state.sst; 774: } 775: if (status != NULL) { 776: *status = state.st; 777: } 778: return AG903_ENONE; 779: } 780: 781: 782: 796: int32_t AG903_PgpMgrEnableParamTrigCtrl(AG903_PgpMgrPipelineHandle *handle, _Bool vlinei_enable, _Bool vsynci_enable, _Bool vlineo_enable, _Bool vsynco_enable) 797: { 798: 799: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 800: return -AG903_EINVAL; 801: } 802: 803: 804: if (handle->is_assign == true) { 805: return -AG903_EBUSY; 806: } 807: 808: 809: handle->trig_vlinei_enable = vlinei_enable; 810: handle->trig_vsynci_enable = vsynci_enable; 811: handle->trig_vlineo_enable = vlineo_enable; 812: handle->trig_vsynco_enable = vsynco_enable; 813: handle->is_dirty = true; 814: return AG903_ENONE; 815: } 816: 817: 818: 844: int32_t AG903_PgpMgrSetConfigTrigCtrl(AG903_PgpMgrPipelineHandle *handle, uint32_t input_field, uint32_t input_fcnt, uint32_t input_line, uint32_t output_field, uint32_t output_fcnt, uint32_t output_line) 845: { 846: 847: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 848: return -AG903_EINVAL; 849: } 850: 851: 852: switch (input_field) { 853: case AG903_PGP_MGR_TRIG_CTRL_FIELD_ODD: 854: case AG903_PGP_MGR_TRIG_CTRL_FIELD_EVEN: 855: case AG903_PGP_MGR_TRIG_CTRL_FIELD_ODD_EVEN: 856: break; 857: default: 858: return -AG903_EINVAL; 859: } 860: if ((input_fcnt == 0) || (input_fcnt > AG903_PGP_MGR_TRIG_CTRL_MAX_FRAME_CNT)) { 861: return -AG903_EINVAL; 862: } 863: if (input_line > AG903_PGP_MGR_TRIG_CTRL_MAX_INPUT_LINE) { 864: return -AG903_EINVAL; 865: } 866: switch (output_field) { 867: case AG903_PGP_MGR_TRIG_CTRL_FIELD_ODD: 868: case AG903_PGP_MGR_TRIG_CTRL_FIELD_EVEN: 869: case AG903_PGP_MGR_TRIG_CTRL_FIELD_ODD_EVEN: 870: break; 871: default: 872: return -AG903_EINVAL; 873: } 874: if ((output_fcnt == 0) || (output_fcnt > AG903_PGP_MGR_TRIG_CTRL_MAX_FRAME_CNT)) { 875: return -AG903_EINVAL; 876: } 877: if (output_line > AG903_PGP_MGR_TRIG_CTRL_MAX_OUTPUT_LINE) { 878: return -AG903_EINVAL; 879: } 880: 881: 882: handle->input_trig_field = input_field; 883: handle->input_trig_fcnt = input_fcnt; 884: handle->input_trig_line = input_line; 885: handle->output_trig_field = output_field; 886: handle->output_trig_fcnt = output_fcnt; 887: handle->output_trig_line = output_line; 888: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_TRIG_CTRL] = true; 889: handle->is_dirty = true; 890: return AG903_ENONE; 891: } 892: 893: 894: 910: int32_t AG903_PgpMgrSetParamInputHSyncDelay(AG903_PgpMgrPipelineHandle *handle, uint32_t h_delay) 911: { 912: 913: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 914: return -AG903_EINVAL; 915: } 916: 917: 918: if (h_delay > AG903_PGP_MGR_MAX_INPUT_HSYNC_DELAY) { 919: return -AG903_EINVAL; 920: } 921: 922: 923: if (handle->is_assign == true) { 924: return -AG903_EBUSY; 925: } 926: 927: 928: handle->input_hsync_delay = h_delay; 929: handle->is_dirty = true; 930: return AG903_ENONE; 931: } 932: 933: 934: 946: int32_t AG903_PgpMgrSetParamInputMode(AG903_PgpMgrPipelineHandle *handle, uint32_t md) 947: { 948: 949: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 950: return -AG903_EINVAL; 951: } 952: 953: 954: switch (md) { 955: case AG903_PGP_MGR_INPUT_MD_VSYNC: 956: case AG903_PGP_MGR_INPUT_MD_ODD_VSYNC: 957: break; 958: default: 959: return -AG903_EINVAL; 960: } 961: 962: 963: if (handle->is_assign == true) { 964: return -AG903_EBUSY; 965: } 966: 967: 968: handle->input_mode = md; 969: handle->is_dirty = true; 970: return AG903_ENONE; 971: } 972: 973: 974: 986: int32_t AG903_PgpMgrSetParamInputTimeCLK(AG903_PgpMgrPipelineHandle *handle, uint32_t tick) 987: { 988: 989: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 990: return -AG903_EINVAL; 991: } 992: 993: 994: switch (tick) { 995: case AG903_PGP_MGR_INPUT_TIME_CLK0: 996: case AG903_PGP_MGR_INPUT_TIME_CLK1: 997: break; 998: default: 999: return -AG903_EINVAL; 1000: } 1001: 1002: 1003: if (handle->is_assign == true) { 1004: return -AG903_EBUSY; 1005: } 1006: 1007: 1008: handle->input_timer_clk = tick; 1009: handle->is_dirty = true; 1010: return AG903_ENONE; 1011: } 1012: 1013: 1014: 1028: int32_t AG903_PgpMgrSetConfigInputTrigChannel(AG903_PgpMgrPipelineHandle *handle, uint32_t timer_ch) 1029: { 1030: 1031: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1032: return -AG903_EINVAL; 1033: } 1034: 1035: 1036: if (timer_ch > AG903_PGP_MGR_MAX_TRIG_TIMER_CHANNEL) { 1037: return -AG903_EINVAL; 1038: } 1039: 1040: 1041: handle->input_trig_timer_ch = timer_ch; 1042: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_INPUT_TRIG_CH] = true; 1043: handle->is_dirty = true; 1044: return AG903_ENONE; 1045: } 1046: 1047: 1048: 1066: int32_t AG903_PgpMgrSetInputPort(AG903_PgpMgrPipelineHandle *handle, void *src) 1067: { 1068: const uint32_t via_port[4] = { 1069: AG903_PGP_MGR_INPUT_PORT_VIA_0, 1070: AG903_PGP_MGR_INPUT_PORT_VIA_1, 1071: AG903_PGP_MGR_INPUT_PORT_VIA_2, 1072: AG903_PGP_MGR_INPUT_PORT_VIA_3, 1073: }; 1074: const uint32_t vid_port[4] = { 1075: AG903_PGP_MGR_INPUT_PORT_VID_0, 1076: AG903_PGP_MGR_INPUT_PORT_VID_1, 1077: AG903_PGP_MGR_INPUT_PORT_VID_2, 1078: AG903_PGP_MGR_INPUT_PORT_VID_3, 1079: }; 1080: 1081: AG903_ViaMgrInputHandle *via_h = (AG903_ViaMgrInputHandle *)src; 1082: AG903_VidMgrOutputHandle *vid_h = (AG903_VidMgrOutputHandle *)src; 1083: AG903_PgpMgrVRAMInputHandle *vram_h = (AG903_PgpMgrVRAMInputHandle *)src; 1084: 1085: 1086: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1087: return -AG903_EINVAL; 1088: } 1089: 1090: if (src != NULL) { 1091: if (via_h->id == AG903_VIA_MGR_INPUT_HANDLE_ID) { 1092: handle->input_port = via_port[via_h->port_no]; 1093: } else if (vid_h->id == AG903_VID_MGR_OUTPUT_HANDLE_ID) { 1094: handle->input_port = vid_port[vid_h->port_no]; 1095: } else if (vram_h->id == AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID) { 1096: 1097: vram_h->ref_cnt++; 1098: } else { 1099: return -AG903_EINVAL; 1100: } 1101: } 1102: 1103: 1104: vram_h = (AG903_PgpMgrVRAMInputHandle *)handle->input_handle; 1105: if ((vram_h != NULL) && (vram_h->id == AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 1106: vram_h->ref_cnt--; 1107: } 1108: 1109: 1110: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_INPUT_TRIG_CH] = true; 1111: handle->input_handle = src; 1112: return AG903_ENONE; 1113: } 1114: 1115: 1116: 1128: int32_t AG903_PgpMgrSetParamInputFormat(AG903_PgpMgrPipelineHandle *handle, uint32_t format) 1129: { 1130: 1131: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1132: return -AG903_EINVAL; 1133: } 1134: 1135: 1136: switch (format) { 1137: case AG903_PGP_MGR_INPUT_FMT_RGB888: 1138: case AG903_PGP_MGR_INPUT_FMT_RGB565: 1139: case AG903_PGP_MGR_INPUT_FMT_YCBCR444: 1140: case AG903_PGP_MGR_INPUT_FMT_YCBCR422_WO_IP: 1141: case AG903_PGP_MGR_INPUT_FMT_YCBCR422_W_IP: 1142: case AG903_PGP_MGR_INPUT_FMT_CLUT8: 1143: case AG903_PGP_MGR_INPUT_FMT_CLUT1: 1144: break; 1145: default: 1146: return -AG903_EINVAL; 1147: } 1148: 1149: 1150: if (handle->is_assign == true) { 1151: return -AG903_EBUSY; 1152: } 1153: 1154: 1155: handle->input_format = format; 1156: handle->is_dirty = true; 1157: return AG903_ENONE; 1158: } 1159: 1160: 1161: 1179: int32_t AG903_PgpMgrSetParamInputSize(AG903_PgpMgrPipelineHandle *handle, uint32_t vsize, uint32_t hsize) 1180: { 1181: 1182: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1183: return -AG903_EINVAL; 1184: } 1185: 1186: 1187: if ((vsize == 0) || (vsize > AG903_PGP_MGR_MAX_INPUT_SIZE)) { 1188: return -AG903_EINVAL; 1189: } 1190: if ((hsize == 0) || (hsize > AG903_PGP_MGR_MAX_INPUT_SIZE)) { 1191: return -AG903_EINVAL; 1192: } 1193: 1194: 1195: if (handle->is_assign == true) { 1196: return -AG903_EBUSY; 1197: } 1198: 1199: 1200: handle->input_vsize = vsize; 1201: handle->input_hsize = hsize; 1202: handle->is_dirty = true; 1203: return AG903_ENONE; 1204: } 1205: 1206: 1207: 1225: int32_t AG903_PgpMgrSetParamInputPosition(AG903_PgpMgrPipelineHandle *handle, uint32_t vpos, uint32_t hpos) 1226: { 1227: 1228: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1229: return -AG903_EINVAL; 1230: } 1231: 1232: 1233: if (vpos > AG903_PGP_MGR_MAX_INPUT_POS) { 1234: return -AG903_EINVAL; 1235: } 1236: if (hpos > AG903_PGP_MGR_MAX_INPUT_POS) { 1237: return -AG903_EINVAL; 1238: } 1239: 1240: 1241: if (handle->is_assign == true) { 1242: return -AG903_EBUSY; 1243: } 1244: 1245: 1246: handle->input_vpos = vpos; 1247: handle->input_hpos = hpos; 1248: handle->is_dirty = true; 1249: return AG903_ENONE; 1250: } 1251: 1252: 1253: 1267: int32_t AG903_PgpMgrSetParamInputScan(AG903_PgpMgrPipelineHandle *handle, uint32_t scan, _Bool epos, _Bool opos) 1268: { 1269: 1270: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1271: return -AG903_EINVAL; 1272: } 1273: 1274: 1275: switch (scan) { 1276: case AG903_PGP_MGR_SCAN_PROGRESSIVE: 1277: case AG903_PGP_MGR_SCAN_INTERLACE: 1278: break; 1279: default: 1280: return -AG903_EINVAL; 1281: } 1282: 1283: 1284: if (handle->is_assign == true) { 1285: return -AG903_EBUSY; 1286: } 1287: 1288: 1289: handle->input_scan = scan; 1290: handle->input_epos = epos; 1291: handle->input_opos = opos; 1292: handle->is_dirty = true; 1293: return AG903_ENONE; 1294: } 1295: 1296: 1297: 1311: int32_t AG903_PgpMgrSetConfigOutputFramePadding(AG903_PgpMgrPipelineHandle *handle, uint32_t pad) 1312: { 1313: 1314: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1315: return -AG903_EINVAL; 1316: } 1317: 1318: 1319: if (pad > AG903_PGP_MGR_MAX_OUTPUT_PAD) { 1320: return -AG903_EINVAL; 1321: } 1322: 1323: 1324: handle->output_pad = pad; 1325: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_OUTPUT_CTRL] = true; 1326: handle->is_dirty = true; 1327: return AG903_ENONE; 1328: } 1329: 1330: 1331: 1342: int32_t AG903_PgpMgrSetConfigOutputLimit(AG903_PgpMgrPipelineHandle *handle, uint32_t limit) 1343: { 1344: 1345: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1346: return -AG903_EINVAL; 1347: } 1348: 1349: 1350: switch (limit) { 1351: case AG903_PGP_MGR_LIMIT_0_255: 1352: case AG903_PGP_MGR_LIMIT_16_235_AND_240: 1353: break; 1354: default: 1355: return -AG903_EINVAL; 1356: } 1357: 1358: 1359: handle->output_limit = limit; 1360: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_OUTPUT_CTRL] = true; 1361: handle->is_dirty = true; 1362: return AG903_ENONE; 1363: } 1364: 1365: 1366: 1375: int32_t AG903_PgpMgrEnableConfigOutputFrameInfo(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 1376: { 1377: 1378: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1379: return -AG903_EINVAL; 1380: } 1381: 1382: 1383: handle->output_fai_enable = enable; 1384: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_OUTPUT_CTRL] = true; 1385: handle->is_dirty = true; 1386: return AG903_ENONE; 1387: } 1388: 1389: 1390: 1399: int32_t AG903_PgpMgrEnableConfigOutputDither(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 1400: { 1401: 1402: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1403: return -AG903_EINVAL; 1404: } 1405: 1406: 1407: handle->output_dither_enable = enable; 1408: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_OUTPUT_CTRL] = true; 1409: handle->is_dirty = true; 1410: return AG903_ENONE; 1411: } 1412: 1413: 1414: 1426: int32_t AG903_PgpMgrSetParamOutputScan(AG903_PgpMgrPipelineHandle *handle, uint32_t scan) 1427: { 1428: 1429: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1430: return -AG903_EINVAL; 1431: } 1432: 1433: 1434: switch (scan) { 1435: case AG903_PGP_MGR_SCAN_PROGRESSIVE: 1436: case AG903_PGP_MGR_SCAN_INTERLACE: 1437: break; 1438: default: 1439: return -AG903_EINVAL; 1440: } 1441: 1442: 1443: if (handle->is_assign == true) { 1444: return -AG903_EBUSY; 1445: } 1446: 1447: 1448: handle->output_scan = scan; 1449: handle->is_dirty = true; 1450: return AG903_ENONE; 1451: } 1452: 1453: 1454: 1465: int32_t AG903_PgpMgrSetParamOutputAddrDim(AG903_PgpMgrPipelineHandle *handle, uint32_t dim) 1466: { 1467: 1468: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1469: return -AG903_EINVAL; 1470: } 1471: 1472: 1473: switch (dim) { 1474: case AG903_PGP_MGR_ADDR_DIMENTION_1: 1475: case AG903_PGP_MGR_ADDR_DIMENTION_2: 1476: break; 1477: default: 1478: return -AG903_EINVAL; 1479: } 1480: 1481: 1482: if (handle->is_assign == true) { 1483: return -AG903_EBUSY; 1484: } 1485: 1486: 1487: handle->output_dim = dim; 1488: handle->is_dirty = true; 1489: return AG903_ENONE; 1490: } 1491: 1492: 1493: 1505: int32_t AG903_PgpMgrSetConfigOutputDataSwap(AG903_PgpMgrPipelineHandle *handle, _Bool word, _Bool hword, _Bool four_bit, _Bool one_bit) 1506: { 1507: 1508: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1509: return -AG903_EINVAL; 1510: } 1511: 1512: 1513: handle->output_word_swap_enable = word; 1514: handle->output_hword_swap_enable = hword; 1515: handle->output_4bit_swap_enable = four_bit; 1516: handle->output_1bit_swap_enable = one_bit; 1517: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_OUTPUT_CTRL] = true; 1518: handle->is_dirty = true; 1519: return AG903_ENONE; 1520: } 1521: 1522: 1523: 1533: int32_t AG903_PgpMgrSetConfigOutputInterlaceFrame(AG903_PgpMgrPipelineHandle *handle, uint32_t frame_save) 1534: { 1535: 1536: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1537: return -AG903_EINVAL; 1538: } 1539: 1540: 1541: switch (frame_save) { 1542: case AG903_PGP_MGR_OUTPUT_FRAME_SAVE_ODD: 1543: case AG903_PGP_MGR_OUTPUT_FRAME_SAVE_EVEN: 1544: case AG903_PGP_MGR_OUTPUT_FRAME_SAVE_IGNORE_FIELD: 1545: case AG903_PGP_MGR_OUTPUT_FRAME_SAVE_FIELD: 1546: case AG903_PGP_MGR_OUTPUT_FRAME_SAVE_WEAVE: 1547: break; 1548: default: 1549: return -AG903_EINVAL; 1550: } 1551: 1552: 1553: handle->output_md = frame_save; 1554: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_OUTPUT_CTRL] = true; 1555: handle->is_dirty = true; 1556: return AG903_ENONE; 1557: } 1558: 1559: 1560: 1574: int32_t AG903_PgpMgrSetParamOutputBMU(AG903_PgpMgrPipelineHandle *handle, uint32_t bmu) 1575: { 1576: 1577: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1578: return -AG903_EINVAL; 1579: } 1580: 1581: 1582: switch (bmu) { 1583: case AG903_PGP_MGR_OUTPUT_BMU_NONE: 1584: case AG903_PGP_MGR_OUTPUT_BMU_ENABLE: 1585: case AG903_PGP_MGR_OUTPUT_BMU_ENABLE_EVEN: 1586: break; 1587: default: 1588: return -AG903_EINVAL; 1589: } 1590: 1591: 1592: if (handle->is_assign == true) { 1593: return -AG903_EBUSY; 1594: } 1595: 1596: 1597: handle->output_bmu = bmu; 1598: handle->is_dirty = true; 1599: return AG903_ENONE; 1600: } 1601: 1602: 1603: 1615: int32_t AG903_PgpMgrSetParamOutputFormat(AG903_PgpMgrPipelineHandle *handle, uint32_t format) 1616: { 1617: 1618: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1619: return -AG903_EINVAL; 1620: } 1621: 1622: 1623: switch (format) { 1624: case AG903_PGP_MGR_OUTPUT_FMT_RGB888_TO_RGB888_32BIT: 1625: case AG903_PGP_MGR_OUTPUT_FMT_RGB888_TO_RGB888_24BIT: 1626: case AG903_PGP_MGR_OUTPUT_FMT_RGB888_TO_RGB565: 1627: case AG903_PGP_MGR_OUTPUT_FMT_RGB888_TO_ARGB1555: 1628: case AG903_PGP_MGR_OUTPUT_FMT_RGB888_TO_ARGB4444: 1629: case AG903_PGP_MGR_OUTPUT_FMT_RGB888_TO_RGB888_SEP: 1630: case AG903_PGP_MGR_OUTPUT_FMT_YCBCR444_TO_YCBCR444_32BIT: 1631: case AG903_PGP_MGR_OUTPUT_FMT_YCBCR444_TO_YCBCR444_24BIT: 1632: case AG903_PGP_MGR_OUTPUT_FMT_YCBCR444_TO_YCBCR422: 1633: case AG903_PGP_MGR_OUTPUT_FMT_YCBCR444_TO_YCBCR444_SEP: 1634: case AG903_PGP_MGR_OUTPUT_FMT_CLUT8_TO_CLUT8: 1635: case AG903_PGP_MGR_OUTPUT_FMT_CLUT1_TO_CLUT1: 1636: break; 1637: default: 1638: return -AG903_EINVAL; 1639: } 1640: 1641: 1642: if (handle->is_assign == true) { 1643: return -AG903_EBUSY; 1644: } 1645: 1646: 1647: handle->output_format = format; 1648: handle->is_dirty = true; 1649: return AG903_ENONE; 1650: } 1651: 1652: 1653: 1665: int32_t AG903_PgpMgrEnableConfigOutputColorMask(AG903_PgpMgrPipelineHandle *handle, _Bool red, _Bool green, _Bool blue) 1666: { 1667: 1668: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID) || ((red == false) && (green == false) && (blue == false))) { 1669: return -AG903_EINVAL; 1670: } 1671: 1672: 1673: handle->output_red_enable = red; 1674: handle->output_green_enable = green; 1675: handle->output_blue_enable = blue; 1676: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_OUTPUT_COLOR_MASK] = true; 1677: handle->is_dirty = true; 1678: return AG903_ENONE; 1679: } 1680: 1681: 1682: 1691: int32_t AG903_PgpMgrSetConfigOutputBaseAddr(AG903_PgpMgrPipelineHandle *handle, void *addr) 1692: { 1693: 1694: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1695: return -AG903_EINVAL; 1696: } 1697: 1698: 1699: if (addr == NULL) { 1700: return -AG903_EINVAL; 1701: } 1702: 1703: 1704: handle->output_base_addr = (uint32_t)addr; 1705: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_OUTPUT_BASE_ADDR] = true; 1706: handle->is_dirty = true; 1707: return AG903_ENONE; 1708: } 1709: 1710: 1711: 1728: int32_t AG903_PgpMgrSetParamOutputStride(AG903_PgpMgrPipelineHandle *handle, uint32_t stride) 1729: { 1730: 1731: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1732: return -AG903_EINVAL; 1733: } 1734: 1735: 1736: if ((stride == 0) || (stride > AG903_PGP_MGR_OUTPUT_MAX_STRIDE_BYTE)) { 1737: return -AG903_EINVAL; 1738: } 1739: 1740: 1741: if (handle->is_assign == true) { 1742: return -AG903_EBUSY; 1743: } 1744: 1745: 1746: handle->output_vram_stride = stride; 1747: handle->is_dirty = true; 1748: return AG903_ENONE; 1749: } 1750: 1751: 1752: 1773: int32_t AG903_PgpMgrGetFrameInfo(AG903_PgpMgrPipelineHandle *handle, uint32_t *tmstmp, uint32_t *field, uint32_t *port, uint32_t *fnum) 1774: { 1775: 1776: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1777: return -AG903_EINVAL; 1778: } 1779: 1780: 1781: if (handle->is_assign == false) { 1782: return -AG903_EINVAL; 1783: } 1784: 1785: if (PgpContext.exec_pipeline[handle->pipeline_no] != handle) { 1786: return -AG903_EINVAL; 1787: } 1788: 1789: 1790: if (tmstmp != NULL) { 1791: AG903_PgpPrmGetPGPnFAIVAL0(handle->pipeline_no, tmstmp); 1792: } 1793: if (field != NULL || port != NULL || fnum != NULL) { 1794: uint32_t tmp_field, tmp_port, tmp_fnum; 1795: AG903_PgpPrmGetPGPnFAIVAL1(handle->pipeline_no, &tmp_field, &tmp_port, &tmp_fnum); 1796: if (field != NULL) { 1797: *field = tmp_field; 1798: } 1799: if (port != NULL) { 1800: *port = tmp_port; 1801: } 1802: if (fnum != NULL) { 1803: *fnum = tmp_fnum; 1804: } 1805: } 1806: return AG903_ENONE; 1807: } 1808: 1809: 1810: 1822: int32_t AG903_PgpMgrSetParamFrameCalcOrder(AG903_PgpMgrPipelineHandle *handle, uint32_t order) 1823: { 1824: 1825: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1826: return -AG903_EINVAL; 1827: } 1828: 1829: 1830: switch (order) { 1831: case AG903_PGP_MGR_IFCODR_FRAME_TO_OTHER: 1832: case AG903_PGP_MGR_IFCODR_OTHER_TO_FRAME: 1833: break; 1834: default: 1835: return -AG903_EINVAL; 1836: } 1837: 1838: 1839: if (handle->is_assign == true) { 1840: return -AG903_EBUSY; 1841: } 1842: 1843: 1844: handle->ifc_order = order; 1845: handle->is_dirty = true; 1846: return AG903_ENONE; 1847: } 1848: 1849: 1850: 1861: int32_t AG903_PgpMgrEnableParamThresholdOp(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 1862: { 1863: 1864: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1865: return -AG903_EINVAL; 1866: } 1867: 1868: 1869: if (handle->is_assign == true) { 1870: return -AG903_EBUSY; 1871: } 1872: 1873: 1874: handle->thr_enable = enable; 1875: handle->is_dirty = true; 1876: return AG903_ENONE; 1877: } 1878: 1879: 1880: 1891: int32_t AG903_PgpMgrEnableParamDGC(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 1892: { 1893: 1894: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1895: return -AG903_EINVAL; 1896: } 1897: 1898: 1899: if (handle->is_assign == true) { 1900: return -AG903_EBUSY; 1901: } 1902: 1903: 1904: handle->dgc_enable = enable; 1905: handle->is_dirty = true; 1906: return AG903_ENONE; 1907: } 1908: 1909: 1910: 1921: int32_t AG903_PgpMgrEnableParamHSV(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 1922: { 1923: 1924: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1925: return -AG903_EINVAL; 1926: } 1927: 1928: 1929: if (handle->is_assign == true) { 1930: return -AG903_EBUSY; 1931: } 1932: 1933: 1934: handle->hsv1_enable = enable; 1935: handle->is_dirty = true; 1936: return AG903_ENONE; 1937: } 1938: 1939: 1940: 1951: int32_t AG903_PgpMgrEnableParamSpatialFilter(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 1952: { 1953: 1954: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1955: return -AG903_EINVAL; 1956: } 1957: 1958: 1959: if (handle->is_assign == true) { 1960: return -AG903_EBUSY; 1961: } 1962: 1963: 1964: handle->spf_enable = enable; 1965: handle->is_dirty = true; 1966: return AG903_ENONE; 1967: } 1968: 1969: 1970: 1981: int32_t AG903_PgpMgrEnableParamScaling(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 1982: { 1983: 1984: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 1985: return -AG903_EINVAL; 1986: } 1987: 1988: 1989: if (handle->is_assign == true) { 1990: return -AG903_EBUSY; 1991: } 1992: 1993: 1994: handle->scale_enable = enable; 1995: handle->is_dirty = true; 1996: return AG903_ENONE; 1997: } 1998: 1999: 2000: 2011: int32_t AG903_PgpMgrEnableParamColorSpace(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 2012: { 2013: 2014: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2015: return -AG903_EINVAL; 2016: } 2017: 2018: 2019: if (handle->is_assign == true) { 2020: return -AG903_EBUSY; 2021: } 2022: 2023: 2024: handle->csc1_enable = enable; 2025: handle->is_dirty = true; 2026: return AG903_ENONE; 2027: } 2028: 2029: 2030: 2041: int32_t AG903_PgpMgrEnableParamNRF(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 2042: { 2043: 2044: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2045: return -AG903_EINVAL; 2046: } 2047: 2048: 2049: if (handle->is_assign == true) { 2050: return -AG903_EBUSY; 2051: } 2052: 2053: 2054: handle->nrf_enable = enable; 2055: handle->is_dirty = true; 2056: return AG903_ENONE; 2057: } 2058: 2059: 2060: 2073: int32_t AG903_PgpMgrEnableParamHistogram(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 2074: { 2075: 2076: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2077: return -AG903_EINVAL; 2078: } 2079: 2080: 2081: if (handle->is_assign == true) { 2082: return -AG903_EBUSY; 2083: } 2084: 2085: 2086: handle->hgm_enable = enable; 2087: handle->is_dirty = true; 2088: return AG903_ENONE; 2089: } 2090: 2091: 2092: 2105: int32_t AG903_PgpMgrEnableParamLabeling(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 2106: { 2107: 2108: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2109: return -AG903_EINVAL; 2110: } 2111: 2112: 2113: if (handle->is_assign == true) { 2114: return -AG903_EBUSY; 2115: } 2116: 2117: 2118: handle->lbl_enable = enable; 2119: handle->is_dirty = true; 2120: return AG903_ENONE; 2121: } 2122: 2123: 2124: 2144: int32_t AG903_PgpMgrSetConfigIPConversion(AG903_PgpMgrPipelineHandle *handle, uint32_t limit, uint32_t blky, uint32_t blkc) 2145: { 2146: 2147: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2148: return -AG903_EINVAL; 2149: } 2150: 2151: 2152: switch (limit) { 2153: case AG903_PGP_MGR_LIMIT_0_255: 2154: case AG903_PGP_MGR_LIMIT_16_235_AND_240: 2155: break; 2156: default: 2157: return -AG903_EINVAL; 2158: } 2159: if (blky > AG903_PGP_MGR_MAX_IP_BLANK) { 2160: return -AG903_EINVAL; 2161: } 2162: if (blkc > AG903_PGP_MGR_MAX_IP_BLANK) { 2163: return -AG903_EINVAL; 2164: } 2165: 2166: 2167: handle->ipc_limit = limit; 2168: handle->ipc_blk_y = blky; 2169: handle->ipc_blk_c = blkc; 2170: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_IP_CONV] = true; 2171: handle->is_dirty = true; 2172: return AG903_ENONE; 2173: } 2174: 2175: 2176: 2196: int32_t AG903_PgpMgrSetConfigColorSpace(AG903_PgpMgrPipelineHandle *handle, uint32_t limit, uint32_t shift, int32_t mtx[3][4]) 2197: { 2198: int32_t i; 2199: 2200: 2201: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2202: return -AG903_EINVAL; 2203: } 2204: 2205: 2206: switch (limit) { 2207: case AG903_PGP_MGR_LIMIT_0_255: 2208: case AG903_PGP_MGR_LIMIT_16_235_AND_240: 2209: break; 2210: default: 2211: return -AG903_EINVAL; 2212: } 2213: if (shift > AG903_PGP_MGR_MAX_COLOR_SPACE_SHIFT) { 2214: return -AG903_EINVAL; 2215: } 2216: if (mtx == NULL) { 2217: return -AG903_EINVAL; 2218: } 2219: 2220: 2221: handle->csc1_limit = limit; 2222: handle->csc1_shift = shift; 2223: for (i = 0; i < 3; i++) { 2224: handle->csc1_matrix[i][0] = mtx[i][0] & CSC_MUL_MASK; 2225: handle->csc1_matrix[i][1] = mtx[i][1] & CSC_MUL_MASK; 2226: handle->csc1_matrix[i][2] = mtx[i][2] & CSC_MUL_MASK; 2227: handle->csc1_matrix[i][3] = mtx[i][3] & CSC_ADD_MASK; 2228: } 2229: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_COLOR_SPACE] = true; 2230: handle->is_dirty = true; 2231: return AG903_ENONE; 2232: } 2233: 2234: 2235: 2245: int32_t AG903_PgpMgrSetConfigPresetColorSpace(AG903_PgpMgrPipelineHandle *handle, uint32_t format) 2246: { 2247: 2248: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2249: return -AG903_EINVAL; 2250: } 2251: 2252: 2253: switch (format) { 2254: case AG903_PGP_MGR_CSC_YUV_BT_601_FULL_TO_RGB: 2255: case AG903_PGP_MGR_CSC_RGB_TO_YUV_BT_601_FULL: 2256: case AG903_PGP_MGR_CSC_YUV_BT_601_LIMIT_TO_RGB: 2257: case AG903_PGP_MGR_CSC_RGB_TO_YUV_BT_601_LIMIT: 2258: case AG903_PGP_MGR_CSC_YUV_BT_709_FULL_TO_RGB: 2259: case AG903_PGP_MGR_CSC_RGB_TO_YUV_BT_709_FULL: 2260: case AG903_PGP_MGR_CSC_YUV_BT_709_LIMIT_TO_RGB: 2261: case AG903_PGP_MGR_CSC_RGB_TO_YUV_BT_709_LIMIT: 2262: break; 2263: default: 2264: return -AG903_EINVAL; 2265: } 2266: 2267: 2268: PgpMgrGetPresetColorSpaceParameter(format, &handle->csc1_limit, &handle->csc1_shift, &handle->csc1_matrix[0][0]); 2269: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_COLOR_SPACE] = true; 2270: handle->is_dirty = true; 2271: return AG903_ENONE; 2272: } 2273: 2274: 2275: 2301: int32_t AG903_PgpMgrSetConfigScaling(AG903_PgpMgrPipelineHandle *handle, uint32_t limit, uint32_t filter, uint32_t nmr_v, uint32_t dnm_v, uint32_t nmr_h, uint32_t dnm_h) 2302: { 2303: 2304: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2305: return -AG903_EINVAL; 2306: } 2307: 2308: 2309: switch (limit) { 2310: case AG903_PGP_MGR_LIMIT_0_255: 2311: case AG903_PGP_MGR_LIMIT_16_235_AND_240: 2312: break; 2313: default: 2314: return -AG903_EINVAL; 2315: } 2316: switch (filter) { 2317: case AG903_PGP_MGR_FILTER_NEAREST: 2318: case AG903_PGP_MGR_FILTER_LINEAR: 2319: break; 2320: default: 2321: return -AG903_EINVAL; 2322: } 2323: if ((nmr_v == 0) || (nmr_v > AG903_PGP_MGR_MAX_SCALING_VALUE)) { 2324: return -AG903_EINVAL; 2325: } 2326: if ((dnm_v == 0) || (dnm_v > AG903_PGP_MGR_MAX_SCALING_VALUE)) { 2327: return -AG903_EINVAL; 2328: } 2329: if ((nmr_h == 0) || (nmr_h > AG903_PGP_MGR_MAX_SCALING_VALUE)) { 2330: return -AG903_EINVAL; 2331: } 2332: if ((dnm_h == 0) || (dnm_h > AG903_PGP_MGR_MAX_SCALING_VALUE)) { 2333: return -AG903_EINVAL; 2334: } 2335: 2336: 2337: handle->scale_limit = limit; 2338: handle->scale_mtd = filter; 2339: handle->scale_v_nmr = nmr_v; 2340: handle->scale_v_dnm = dnm_v; 2341: handle->scale_h_nmr = nmr_h; 2342: handle->scale_h_dnm = dnm_h; 2343: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_SCALING] = true; 2344: handle->is_dirty = true; 2345: return AG903_ENONE; 2346: } 2347: 2348: 2374: int32_t AG903_PgpMgrSetConfigSpatialFilter(AG903_PgpMgrPipelineHandle *handle, uint32_t shift, uint32_t border, uint32_t border_red, uint32_t border_green, uint32_t border_blue, int32_t coeff[9], int32_t offset) 2375: { 2376: int32_t i; 2377: 2378: 2379: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2380: return -AG903_EINVAL; 2381: } 2382: 2383: 2384: if (shift > AG903_PGP_MGR_MAX_SPF_SHIFT) { 2385: return -AG903_EINVAL; 2386: } 2387: switch (border) { 2388: case AG903_PGP_MGR_SPF_BORDER_COLOR: 2389: case AG903_PGP_MGR_SPF_BORDER_NEIGHBOR: 2390: break; 2391: default: 2392: return -AG903_EINVAL; 2393: } 2394: if (coeff == NULL) { 2395: return -AG903_EINVAL; 2396: } 2397: 2398: 2399: handle->spf_shift = shift; 2400: handle->spf_border_sel = border; 2401: handle->spf_border_red = border_red; 2402: handle->spf_border_green = border_green; 2403: handle->spf_border_blue = border_blue; 2404: for (i = 0; i < 9; i++) { 2405: handle->spf_coeff[i] = coeff[i] & SPF1_COEFF_MASK; 2406: } 2407: handle->spf_offset = offset & SPF1_OFFSET_MASK; 2408: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_SP_FILTER] = true; 2409: handle->is_dirty = true; 2410: return AG903_ENONE; 2411: } 2412: 2413: 2414: 2424: int32_t AG903_PgpMgrSetConfigHSVHLSConversion(AG903_PgpMgrPipelineHandle *handle, uint32_t sel) 2425: { 2426: 2427: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2428: return -AG903_EINVAL; 2429: } 2430: 2431: 2432: switch (sel) { 2433: case AG903_PGP_MGR_CONVERT_HSV: 2434: case AG903_PGP_MGR_CONVERT_HLS: 2435: break; 2436: default: 2437: return -AG903_EINVAL; 2438: } 2439: 2440: 2441: handle->hsv_hls_sel = sel; 2442: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_HSVHSL_CONV] = true; 2443: handle->is_dirty = true; 2444: return AG903_ENONE; 2445: } 2446: 2447: 2459: int32_t AG903_PgpMgrExecHistogram(AG903_PgpMgrPipelineHandle *handle, uint32_t cmd) 2460: { 2461: PGPPrmParamPGPnSTATE state; 2462: PGPPrmParamPGPnHGMSTAT hgmstat; 2463: 2464: 2465: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2466: return -AG903_EINVAL; 2467: } 2468: 2469: 2470: if (handle->is_assign == false) { 2471: return -AG903_EINVAL; 2472: } 2473: 2474: AG903_PgpPrmGetPGPnSTATE(handle->pipeline_no, &state); 2475: 2476: if ((PgpContext.exec_pipeline[handle->pipeline_no] != handle ) && (state.st != AG903_PGP_MGR_STATE_IDLE)) { 2477: return -AG903_EBUSY; 2478: } 2479: AG903_PgpPrmGetPGPnHGMSTAT(handle->pipeline_no, &hgmstat); 2480: 2481: switch (cmd) { 2482: case AG903_PGP_MGR_HGM_CMD_EXEC: 2483: case AG903_PGP_MGR_HGM_CMD_EXEC_WO_VRAM: 2484: 2485: if ((hgmstat.queue == (AG903_PGP_MGR_HGM_CMD_MAX_QUEUE - 1)) || ((hgmstat.cmd != 0) && (cmd != hgmstat.cmd))) { 2486: return -AG903_EBUSY; 2487: } 2488: break; 2489: case AG903_PGP_MGR_HGM_CMD_NONE: 2490: case AG903_PGP_MGR_HGM_CMD_DELETE: 2491: case AG903_PGP_MGR_HGM_CMD_RESET: 2492: break; 2493: default: 2494: return -AG903_EINVAL; 2495: } 2496: 2497: 2498: 2499: AG903_PgpPrmSetPGPnHGMCMD(handle->pipeline_no, cmd); 2500: 2501: return AG903_ENONE; 2502: } 2503: 2504: 2530: int32_t AG903_PgpMgrSetConfigHistogramParameter(AG903_PgpMgrPipelineHandle *handle, uint32_t inv, uint32_t exc, uint32_t thr, uint32_t shift, uint32_t v_inc, uint32_t h_inc) 2531: { 2532: 2533: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2534: return -AG903_EINVAL; 2535: } 2536: 2537: 2538: if (inv > AG903_PGP_MGR_MAX_HGM_OUTPUT_INVALIDATE) { 2539: return -AG903_EINVAL; 2540: } 2541: switch (exc) { 2542: case AG903_PGP_MGR_HGM_EXC_NONE: 2543: case AG903_PGP_MGR_HGM_EXC_0: 2544: case AG903_PGP_MGR_HGM_EXC_0_16: 2545: case AG903_PGP_MGR_HGM_EXC_0_WO_R: 2546: break; 2547: default: 2548: return -AG903_EINVAL; 2549: } 2550: if (thr > AG903_PGP_MGR_MAX_HGM_THR) { 2551: return -AG903_EINVAL; 2552: } 2553: if (shift > AG903_PGP_MGR_MAX_HGM_SHIFT) { 2554: return -AG903_EINVAL; 2555: } 2556: if (v_inc > AG903_PGP_MGR_MAX_HGM_INC) { 2557: return -AG903_EINVAL; 2558: } 2559: if (h_inc > AG903_PGP_MGR_MAX_HGM_INC) { 2560: return -AG903_EINVAL; 2561: } 2562: 2563: 2564: handle->hgm_invalidate = inv; 2565: handle->hgm_exc = exc; 2566: handle->hgm_thr = thr; 2567: handle->hgm_shift = shift; 2568: handle->hgm_vinc = v_inc; 2569: handle->hgm_hinc = h_inc; 2570: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_HGM_PARAM] = true; 2571: handle->is_dirty = true; 2572: return AG903_ENONE; 2573: } 2574: 2575: 2591: int32_t AG903_PgpMgrSetConfigHistogramSize(AG903_PgpMgrPipelineHandle *handle, uint32_t vsize, uint32_t hsize) 2592: { 2593: 2594: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2595: return -AG903_EINVAL; 2596: } 2597: 2598: 2599: if ((vsize == 0) || (vsize > AG903_PGP_MGR_MAX_HGM_SIZE)) { 2600: return -AG903_EINVAL; 2601: } 2602: if ((hsize == 0) || (hsize > AG903_PGP_MGR_MAX_HGM_SIZE)) { 2603: return -AG903_EINVAL; 2604: } 2605: 2606: 2607: handle->hgm_vsize = vsize; 2608: handle->hgm_hsize = hsize; 2609: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_HGM_SIZE] = true; 2610: handle->is_dirty = true; 2611: return AG903_ENONE; 2612: } 2613: 2614: 2630: int32_t AG903_PgpMgrSetConfigHistogramPosition(AG903_PgpMgrPipelineHandle *handle, uint32_t vpos, uint32_t hpos) 2631: { 2632: 2633: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2634: return -AG903_EINVAL; 2635: } 2636: 2637: 2638: if (vpos > AG903_PGP_MGR_MAX_HGM_POS) { 2639: return -AG903_EINVAL; 2640: } 2641: if (hpos > AG903_PGP_MGR_MAX_HGM_POS) { 2642: return -AG903_EINVAL; 2643: } 2644: 2645: 2646: handle->hgm_vpos = vpos; 2647: handle->hgm_hpos = hpos; 2648: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_HGM_POS] = true; 2649: handle->is_dirty = true; 2650: return AG903_ENONE; 2651: } 2652: 2653: 2662: int32_t AG903_PgpMgrSetConfigHistogramBaseAddr(AG903_PgpMgrPipelineHandle *handle, void *addr) 2663: { 2664: 2665: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2666: return -AG903_EINVAL; 2667: } 2668: 2669: 2670: if (addr == NULL) { 2671: return -AG903_EINVAL; 2672: } 2673: 2674: 2675: handle->hgm_addr = (uint32_t)addr; 2676: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_HGM_BASE_ADDR] = true; 2677: handle->is_dirty = true; 2678: return AG903_ENONE; 2679: } 2680: 2681: 2682: 2693: int32_t AG903_PgpMgrEnableParamHistogramBMU(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 2694: { 2695: 2696: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2697: return -AG903_EINVAL; 2698: } 2699: 2700: 2701: if (handle->is_assign == true) { 2702: return -AG903_EBUSY; 2703: } 2704: 2705: 2706: handle->hgm_bmu = enable; 2707: handle->is_dirty = true; 2708: return AG903_ENONE; 2709: } 2710: 2711: 2712: 2730: int32_t AG903_PgpMgrGetHistogramParameter(AG903_PgpMgrPipelineHandle *handle, uint32_t *most_r, uint32_t *max_r, uint32_t *min_r, uint32_t *most_g, uint32_t *max_g, uint32_t *min_g, uint32_t *most_b, uint32_t *max_b, uint32_t *min_b) 2731: { 2732: uint32_t dummy, tmp_max, tmp_min; 2733: 2734: 2735: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2736: return -AG903_EINVAL; 2737: } 2738: 2739: 2740: if (handle->is_assign == false) { 2741: return -AG903_EINVAL; 2742: } 2743: 2744: if (PgpContext.exec_pipeline[handle->pipeline_no] != handle) { 2745: return -AG903_EINVAL; 2746: } 2747: 2748: 2749: if (most_r != NULL) { 2750: AG903_PgpPrmGetPGPnHGMMOD2(handle->pipeline_no, &dummy, most_r, &dummy); 2751: } 2752: AG903_PgpPrmGetPGPnHGMRNG2(handle->pipeline_no, &tmp_max, &tmp_min); 2753: if (max_r != NULL) { 2754: *max_r = tmp_max; 2755: } 2756: if (min_r != NULL) { 2757: *min_r = tmp_min; 2758: } 2759: if (most_g != NULL) { 2760: AG903_PgpPrmGetPGPnHGMMOD1(handle->pipeline_no, &dummy, most_g, &dummy); 2761: } 2762: AG903_PgpPrmGetPGPnHGMRNG1(handle->pipeline_no, &tmp_max, &tmp_min); 2763: if (max_g != NULL) { 2764: *max_g = tmp_max; 2765: } 2766: if (min_g != NULL) { 2767: *min_g = tmp_min; 2768: } 2769: if (most_b != NULL) { 2770: AG903_PgpPrmGetPGPnHGMMOD0(handle->pipeline_no, &dummy, most_b, &dummy); 2771: } 2772: AG903_PgpPrmGetPGPnHGMRNG0(handle->pipeline_no, &tmp_max, &tmp_min); 2773: if (max_b != NULL) { 2774: *max_b = tmp_max; 2775: } 2776: if (min_b != NULL) { 2777: *min_b = tmp_min; 2778: } 2779: return AG903_ENONE; 2780: } 2781: 2782: 2783: 2797: int32_t AG903_PgpMgrGetHistogramStatus(AG903_PgpMgrPipelineHandle *handle, _Bool *is_init, _Bool *is_vram_out, _Bool *is_act, uint32_t *queue_cnt, uint32_t *exec_cmd) 2798: { 2799: PGPPrmParamPGPnHGMSTAT hgmstat; 2800: 2801: 2802: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2803: return -AG903_EINVAL; 2804: } 2805: 2806: 2807: if (handle->is_assign == false) { 2808: return -AG903_EINVAL; 2809: } 2810: 2811: AG903_PgpPrmGetPGPnHGMSTAT(handle->pipeline_no, &hgmstat); 2812: 2813: 2814: if ((PgpContext.exec_pipeline[handle->pipeline_no] != handle) && (hgmstat.cmd != AG903_PGP_MGR_HGM_CMD_NONE)) { 2815: return -AG903_EINVAL; 2816: } 2817: if (is_init != NULL) { 2818: *is_init = hgmstat.init; 2819: } 2820: if (is_vram_out != NULL) { 2821: *is_vram_out = hgmstat.vrmacc; 2822: } 2823: if (is_act != NULL) { 2824: *is_act = hgmstat.act; 2825: } 2826: if (queue_cnt != NULL) { 2827: *queue_cnt = hgmstat.queue; 2828: } 2829: if (exec_cmd != NULL) { 2830: *exec_cmd = hgmstat.cmd; 2831: } 2832: return AG903_ENONE; 2833: } 2834: 2835: 2836: 2860: int32_t AG903_PgpMgrSetConfigThreshold(AG903_PgpMgrPipelineHandle *handle, uint32_t limit, _Bool spf, _Bool mask, _Bool csc, _Bool hsv_hls, _Bool thr8, uint32_t sel_out, uint32_t sel_clut8) 2861: { 2862: 2863: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2864: return -AG903_EINVAL; 2865: } 2866: 2867: 2868: switch (limit) { 2869: case AG903_PGP_MGR_LIMIT_NONE: 2870: case AG903_PGP_MGR_LIMIT_16_235_AND_240: 2871: break; 2872: default: 2873: return -AG903_EINVAL; 2874: } 2875: switch (sel_out) { 2876: case AG903_PGP_MGR_THR_OUT_SEL_RGB: 2877: case AG903_PGP_MGR_THR_OUT_SEL_MUX8: 2878: case AG903_PGP_MGR_THR_OUT_SEL_SPF1: 2879: case AG903_PGP_MGR_THR_OUT_SEL_LBL: 2880: break; 2881: default: 2882: return -AG903_EINVAL; 2883: } 2884: switch (sel_clut8) { 2885: case AG903_PGP_MGR_THR_CLUT8_OUT_B: 2886: case AG903_PGP_MGR_THR_CLUT8_OUT_G: 2887: case AG903_PGP_MGR_THR_CLUT8_OUT_R: 2888: break; 2889: default: 2890: return -AG903_EINVAL; 2891: } 2892: 2893: 2894: handle->thr_limit = limit; 2895: handle->thr_spf1_enable = spf; 2896: handle->thr_msk_enable = mask; 2897: handle->thr_csc2_enable = csc; 2898: handle->thr_hsv2_enable = hsv_hls; 2899: handle->thr_thr8bit_enable = thr8; 2900: handle->thr_out_sel = sel_out; 2901: handle->thr_clut8_sel = sel_clut8; 2902: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_THR] = true; 2903: handle->is_dirty = true; 2904: return AG903_ENONE; 2905: } 2906: 2907: 2908: 2918: int32_t AG903_PgpMgrSetConfigThresholdHSVHLSConversion(AG903_PgpMgrPipelineHandle *handle, uint32_t sel) 2919: { 2920: 2921: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2922: return -AG903_EINVAL; 2923: } 2924: 2925: 2926: switch (sel) { 2927: case AG903_PGP_MGR_CONVERT_HSV: 2928: case AG903_PGP_MGR_CONVERT_HLS: 2929: break; 2930: default: 2931: return -AG903_EINVAL; 2932: } 2933: 2934: 2935: handle->thr_hsv_hls_sel = sel; 2936: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_THR_HSCHLS_CONV] = true; 2937: handle->is_dirty = true; 2938: return AG903_ENONE; 2939: } 2940: 2941: 2942: 2962: int32_t AG903_PgpMgrSetConfigThresholdColorSpace(AG903_PgpMgrPipelineHandle *handle, uint32_t limit, uint32_t shift, int32_t mtx[3][4]) 2963: { 2964: int32_t i; 2965: 2966: 2967: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 2968: return -AG903_EINVAL; 2969: } 2970: 2971: 2972: switch (limit) { 2973: case AG903_PGP_MGR_LIMIT_0_255: 2974: case AG903_PGP_MGR_LIMIT_16_235_AND_240: 2975: break; 2976: default: 2977: return -AG903_EINVAL; 2978: } 2979: if (shift > AG903_PGP_MGR_MAX_COLOR_SPACE_SHIFT) { 2980: return -AG903_EINVAL; 2981: } 2982: if (mtx == NULL) { 2983: return -AG903_EINVAL; 2984: } 2985: 2986: 2987: handle->thr_csc2_limit = limit; 2988: handle->thr_csc2_shift = shift; 2989: for (i = 0; i < 3; i++) { 2990: handle->thr_csc2_matrix[i][0] = mtx[i][0] & CSC_MUL_MASK; 2991: handle->thr_csc2_matrix[i][1] = mtx[i][1] & CSC_MUL_MASK; 2992: handle->thr_csc2_matrix[i][2] = mtx[i][2] & CSC_MUL_MASK; 2993: handle->thr_csc2_matrix[i][3] = mtx[i][3] & CSC_ADD_MASK; 2994: } 2995: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_THR_COLOR_SPACE] = true; 2996: handle->is_dirty = true; 2997: return AG903_ENONE; 2998: } 2999: 3000: 3001: 3011: int32_t AG903_PgpMgrSetConfigThresholdPresetColorSpace(AG903_PgpMgrPipelineHandle *handle, uint32_t format) 3012: { 3013: 3014: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3015: return -AG903_EINVAL; 3016: } 3017: 3018: 3019: switch (format) { 3020: case AG903_PGP_MGR_CSC_YUV_BT_601_FULL_TO_RGB: 3021: case AG903_PGP_MGR_CSC_RGB_TO_YUV_BT_601_FULL: 3022: case AG903_PGP_MGR_CSC_YUV_BT_601_LIMIT_TO_RGB: 3023: case AG903_PGP_MGR_CSC_RGB_TO_YUV_BT_601_LIMIT: 3024: case AG903_PGP_MGR_CSC_YUV_BT_709_FULL_TO_RGB: 3025: case AG903_PGP_MGR_CSC_RGB_TO_YUV_BT_709_FULL: 3026: case AG903_PGP_MGR_CSC_YUV_BT_709_LIMIT_TO_RGB: 3027: case AG903_PGP_MGR_CSC_RGB_TO_YUV_BT_709_LIMIT: 3028: break; 3029: default: 3030: return -AG903_EINVAL; 3031: } 3032: 3033: 3034: PgpMgrGetPresetColorSpaceParameter(format, &handle->thr_csc2_limit, &handle->thr_csc2_shift, &handle->thr_csc2_matrix[0][0]); 3035: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_THR_COLOR_SPACE] = true; 3036: handle->is_dirty = true; 3037: return AG903_ENONE; 3038: } 3039: 3040: 3041: 3064: int32_t AG903_PgpMgrSetConfigThresholdMask(AG903_PgpMgrPipelineHandle *handle, uint32_t ch, uint32_t h, uint32_t l, uint32_t x, uint32_t hmax, uint32_t hmin, uint32_t lmax, uint32_t lmin) 3065: { 3066: 3067: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3068: return -AG903_EINVAL; 3069: } 3070: 3071: 3072: switch (ch) { 3073: case AG903_PGP_MGR_THR_CHANNEL_B: 3074: case AG903_PGP_MGR_THR_CHANNEL_G: 3075: case AG903_PGP_MGR_THR_CHANNEL_R: 3076: break; 3077: default: 3078: return -AG903_EINVAL; 3079: } 3080: 3081: 3082: handle->thr_msk_h[ch] = h & THR_MSK_L_MASK; 3083: handle->thr_msk_l[ch] = l & THR_MSK_H_MASK; 3084: handle->thr_msk_x[ch] = x & THR_MSK_X_MASK; 3085: handle->thr_msk_hmax[ch] = hmax & THR_MSK_HMAX_MASK; 3086: handle->thr_msk_hmin[ch] = hmin & THR_MSK_HMIN_MASK; 3087: handle->thr_msk_lmax[ch] = lmax & THR_MSK_LMAX_MASK; 3088: handle->thr_msk_lmin[ch] = lmin & THR_MSK_LMIN_MASK; 3089: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_THR_MASK] = true; 3090: handle->is_dirty = true; 3091: return AG903_ENONE; 3092: } 3093: 3094: 3095: 3115: int32_t AG903_PgpMgrSetConfigThreshold8Bit(AG903_PgpMgrPipelineHandle *handle, uint32_t ch, uint32_t type, uint32_t maxval, uint32_t maxthr, uint32_t minthr) 3116: { 3117: 3118: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3119: return -AG903_EINVAL; 3120: } 3121: 3122: 3123: switch (ch) { 3124: case AG903_PGP_MGR_THR_CHANNEL_B: 3125: case AG903_PGP_MGR_THR_CHANNEL_G: 3126: case AG903_PGP_MGR_THR_CHANNEL_R: 3127: break; 3128: default: 3129: return -AG903_EINVAL; 3130: } 3131: switch (type) { 3132: case AG903_PGP_MGR_THR_8BIT_TYPE_THR_BIN: 3133: case AG903_PGP_MGR_THR_8BIT_TYPE_THR_BIN_INV: 3134: case AG903_PGP_MGR_THR_8BIT_TYPE_TRU: 3135: case AG903_PGP_MGR_THR_8BIT_TYPE_THR_ZERO: 3136: case AG903_PGP_MGR_THR_8BIT_TYPE_THR_ZERO_INV: 3137: break; 3138: case AG903_PGP_MGR_THR_8BIT_TYPE_THR_BIN_EXT: 3139: case AG903_PGP_MGR_THR_8BIT_TYPE_THR_BIN_INV_EXT: 3140: case AG903_PGP_MGR_THR_8BIT_TYPE_TRU_EXT: 3141: case AG903_PGP_MGR_THR_8BIT_TYPE_THR_ZERO_EXT: 3142: case AG903_PGP_MGR_THR_8BIT_TYPE_THR_ZERO_INV_EXT: 3143: if (minthr > maxthr) { 3144: return -AG903_EINVAL; 3145: } 3146: break; 3147: default: 3148: return -AG903_EINVAL; 3149: } 3150: 3151: 3152: handle->thr_thr8_prm_type[ch] = type; 3153: handle->thr_thr8_prm_maxval[ch] = maxval & THR_8THR_MAXV_MASK; 3154: handle->thr_thr8_prm_maxthr[ch] = maxthr & THR_8THR_MAXTH_MASK; 3155: handle->thr_thr8_prm_minthr[ch] = minthr & THR_8THR_MINTH_MASK; 3156: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_THR_8BIT] = true; 3157: handle->is_dirty = true; 3158: return AG903_ENONE; 3159: } 3160: 3161: 3162: 3183: int32_t AG903_PgpMgrSetConfigThreshold1Bit(AG903_PgpMgrPipelineHandle *handle, uint32_t h, uint32_t l, uint32_t x, uint32_t hmax, uint32_t hmin, uint32_t lmax, uint32_t lmin) 3184: { 3185: 3186: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3187: return -AG903_EINVAL; 3188: } 3189: 3190: 3191: handle->thr_thr1_h = h & THR_MSK_L_MASK; 3192: handle->thr_thr1_l = l & THR_MSK_H_MASK; 3193: handle->thr_thr1_x = x & THR_MSK_X_MASK; 3194: handle->thr_thr1_hmax = hmax & THR_MSK_HMAX_MASK; 3195: handle->thr_thr1_hmin = hmin & THR_MSK_HMIN_MASK; 3196: handle->thr_thr1_lmax = lmax & THR_MSK_LMAX_MASK; 3197: handle->thr_thr1_lmin = lmin & THR_MSK_LMIN_MASK; 3198: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_THR_1BIT] = true; 3199: handle->is_dirty = true; 3200: return AG903_ENONE; 3201: } 3202: 3203: 3204: 3220: int32_t AG903_PgpMgrSetConfigThresholdSpatialFilter1Bit(AG903_PgpMgrPipelineHandle *handle, int32_t coeff[9], int32_t thr) 3221: { 3222: int32_t i; 3223: 3224: 3225: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3226: return -AG903_EINVAL; 3227: } 3228: 3229: 3230: if (coeff == NULL) { 3231: return -AG903_EINVAL; 3232: } 3233: 3234: 3235: for (i = 0; i < 9; i++) { 3236: handle->thr_spf1_coeff[i] = coeff[i] & THR_SPF1_COEFF_MASK; 3237: } 3238: handle->thr_spf1_thr = thr & THR_SPF1_THR_MASK; 3239: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_THR_SP_FILTER_1BIT] = true; 3240: handle->is_dirty = true; 3241: return AG903_ENONE; 3242: } 3243: 3244: 3245: 3256: int32_t AG903_PgpMgrExecLabeling(AG903_PgpMgrPipelineHandle *handle, uint32_t cmd) 3257: { 3258: PGPPrmParamPGPnSTATE state; 3259: 3260: 3261: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3262: return -AG903_EINVAL; 3263: } 3264: 3265: switch (cmd) { 3266: case AG903_PGP_MGR_LBL_CMD_NONE: 3267: case AG903_PGP_MGR_LBL_CMD_EXEC: 3268: case AG903_PGP_MGR_LBL_CMD_DELETE: 3269: case AG903_PGP_MGR_LBL_CMD_RESET: 3270: break; 3271: default: 3272: return -AG903_EINVAL; 3273: } 3274: 3275: 3276: if (handle->is_assign == false) { 3277: return -AG903_EINVAL; 3278: } 3279: 3280: AG903_PgpPrmGetPGPnSTATE(handle->pipeline_no, &state); 3281: 3282: if ((PgpContext.exec_pipeline[handle->pipeline_no] != handle ) && (state.st != AG903_PGP_MGR_STATE_IDLE)) { 3283: return -AG903_EBUSY; 3284: } 3285: 3286: PGPPrmParamPGPnLBLSTAT lblstat; 3287: AG903_PgpPrmGetPGPnLBLSTAT(handle->pipeline_no, &lblstat); 3288: 3289: if ((cmd == AG903_PGP_MGR_LBL_CMD_EXEC) && (lblstat.queue == (AG903_PGP_MGR_LBL_CMD_MAX_QUEUE - 1))) { 3290: return -AG903_EBUSY; 3291: } 3292: 3293: 3294: AG903_PgpPrmSetPGPnLBLCMD(handle->pipeline_no, cmd); 3295: 3296: return AG903_ENONE; 3297: } 3298: 3299: 3300: 3316: int32_t AG903_PgpMgrSetConfigLabelingValidTime(AG903_PgpMgrPipelineHandle *handle, uint32_t vld, uint32_t inv) 3317: { 3318: 3319: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3320: return -AG903_EINVAL; 3321: } 3322: 3323: 3324: if ((vld == 0) || (vld > AG903_PGP_MGR_MAX_LBL_OUTPUT_VALIDATE)) { 3325: return -AG903_EINVAL; 3326: } 3327: if (inv > AG903_PGP_MGR_MAX_LBL_OUTPUT_INVALIDATE) { 3328: return -AG903_EINVAL; 3329: } 3330: 3331: 3332: handle->lbl_valid = vld; 3333: handle->lbl_invalid = inv; 3334: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_LBL_PARAM] = true; 3335: handle->is_dirty = true; 3336: return AG903_ENONE; 3337: } 3338: 3339: 3340: 3358: int32_t AG903_PgpMgrSetConfigLabelingParameter(AG903_PgpMgrPipelineHandle *handle, uint32_t connect, uint32_t flush_thr, uint32_t max_id) 3359: { 3360: 3361: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3362: return -AG903_EINVAL; 3363: } 3364: 3365: 3366: switch (connect) { 3367: case AG903_PGP_MGR_LBL_CNCT_8: 3368: case AG903_PGP_MGR_LBL_CNCT_4: 3369: break; 3370: default: 3371: return -AG903_EINVAL; 3372: } 3373: if (flush_thr > AG903_PGP_MGR_MAX_LBL_FLUSH_THR) { 3374: return -AG903_EINVAL; 3375: } 3376: if (max_id > AG903_PGP_MGR_MAX_LBL_ID) { 3377: return -AG903_EINVAL; 3378: } 3379: 3380: 3381: handle->lbl_connect = connect; 3382: handle->lbl_flush_thr = flush_thr; 3383: handle->lbl_maxid = max_id; 3384: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_LBL_PARAM] = true; 3385: handle->is_dirty = true; 3386: return AG903_ENONE; 3387: } 3388: 3389: 3390: 3406: int32_t AG903_PgpMgrSetConfigLabelingSize(AG903_PgpMgrPipelineHandle *handle, uint32_t vsize, uint32_t hsize) 3407: { 3408: 3409: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3410: return -AG903_EINVAL; 3411: } 3412: 3413: 3414: if ((vsize == 0) || (vsize > AG903_PGP_MGR_MAX_LBL_VSIZE)) { 3415: return -AG903_EINVAL; 3416: } 3417: if ((hsize == 0) || (hsize > AG903_PGP_MGR_MAX_LBL_HSIZE)) { 3418: return -AG903_EINVAL; 3419: } 3420: 3421: 3422: handle->lbl_vsize = vsize; 3423: handle->lbl_hsize = hsize; 3424: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_LBL_SIZE] = true; 3425: handle->is_dirty = true; 3426: return AG903_ENONE; 3427: } 3428: 3429: 3430: 3446: int32_t AG903_PgpMgrSetConfigLabelingPosition(AG903_PgpMgrPipelineHandle *handle, uint32_t vpos, uint32_t hpos) 3447: { 3448: 3449: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3450: return -AG903_EINVAL; 3451: } 3452: 3453: 3454: if (vpos > AG903_PGP_MGR_MAX_LBL_POS) { 3455: return -AG903_EINVAL; 3456: } 3457: if (hpos > AG903_PGP_MGR_MAX_LBL_POS) { 3458: return -AG903_EINVAL; 3459: } 3460: 3461: 3462: handle->lbl_vpos = vpos; 3463: handle->lbl_hpos = hpos; 3464: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_LBL_POS] = true; 3465: handle->is_dirty = true; 3466: return AG903_ENONE; 3467: } 3468: 3469: 3470: 3479: int32_t AG903_PgpMgrSetConfigLabelingBaseAddr(AG903_PgpMgrPipelineHandle *handle, void *addr) 3480: { 3481: 3482: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3483: return -AG903_EINVAL; 3484: } 3485: 3486: 3487: if (addr == NULL) { 3488: return -AG903_EINVAL; 3489: } 3490: 3491: 3492: handle->lbl_addr = (uint32_t)addr; 3493: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_LBL_BASE_ADDR] = true; 3494: handle->is_dirty = true; 3495: return AG903_ENONE; 3496: } 3497: 3498: 3499: 3510: int32_t AG903_PgpMgrEnableParamLabelingBMU(AG903_PgpMgrPipelineHandle *handle, _Bool enable) 3511: { 3512: 3513: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3514: return -AG903_EINVAL; 3515: } 3516: 3517: 3518: if (handle->is_assign == true) { 3519: return -AG903_EBUSY; 3520: } 3521: 3522: 3523: handle->lbl_bmu = enable; 3524: handle->is_dirty = true; 3525: return AG903_ENONE; 3526: } 3527: 3528: 3529: 3543: int32_t AG903_PgpMgrGetLabelingStatus(AG903_PgpMgrPipelineHandle *handle, uint32_t *id, _Bool *is_vram_out, _Bool *is_act, uint32_t *queue_cnt, uint32_t *exec_cmd) 3544: { 3545: 3546: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 3547: return -AG903_EINVAL; 3548: } 3549: 3550: 3551: if (handle->is_assign == false) { 3552: return -AG903_EINVAL; 3553: } 3554: 3555: 3556: PGPPrmParamPGPnLBLSTAT lblstat; 3557: AG903_PgpPrmGetPGPnLBLSTAT(handle->pipeline_no, &lblstat); 3558: 3559: 3560: if ((PgpContext.exec_pipeline[handle->pipeline_no] != handle) && (lblstat.cmd != AG903_PGP_MGR_LBL_CMD_NONE)) { 3561: return -AG903_EINVAL; 3562: } 3563: if (id != NULL) { 3564: *id = lblstat.l_id; 3565: } 3566: if (is_vram_out != NULL) { 3567: *is_vram_out = lblstat.vrmacc; 3568: } 3569: if (is_act != NULL) { 3570: *is_act = lblstat.act; 3571: } 3572: if (queue_cnt != NULL) { 3573: *queue_cnt = lblstat.queue; 3574: } 3575: if (exec_cmd != NULL) { 3576: *exec_cmd = lblstat.cmd; 3577: } 3578: return AG903_ENONE; 3579: } 3580: 3581: 3582: 3596: int32_t AG903_PgpMgrAnalyzeLabelingTable(void *src, uint32_t tbl_num, void **dst) 3597: { 3598: uint32_t dst_num; 3599: 3600: 3601: if (src == NULL) { 3602: return -AG903_EINVAL; 3603: } 3604: if (tbl_num < 1) { 3605: return -AG903_EINVAL; 3606: } 3607: 3608: 3609: *dst = PgpMgrAnalyzeLabelingTable(src, tbl_num, &dst_num); 3610: 3611: 3612: if (dst_num == 0) { 3613: return 0; 3614: } 3615: 3616: 3617: if (*dst == NULL) { 3618: return -AG903_ENOMEM; 3619: } 3620: 3621: return dst_num; 3622: } 3623: 3624: 3625: 3633: int32_t AG903_PgpMgrReleaseLabelingTable(void *tbl) 3634: { 3635: if (tbl == NULL) { 3636: return -AG903_EINVAL; 3637: } 3638: PgpMgrReleaseLabelingTable(tbl); 3639: return AG903_ENONE; 3640: } 3641: 3642: 3643: 3658: int32_t AG903_PgpMgrGetFrameCalcHandle(AG903_PgpMgrFrameCalcHandle **handle, AG903_PgpMgrPipelineHandle *master, void *slave) 3659: { 3660: int32_t i; 3661: AG903_PgpMgrPipelineHandle *slave_pipeline = (AG903_PgpMgrPipelineHandle *)slave; 3662: AG903_PgpMgrVRAMInputHandle *slave_vram = (AG903_PgpMgrVRAMInputHandle *)slave; 3663: 3664: 3665: if (PgpContext.pipeline_time_sharing_enable == true) { 3666: if ((PgpContext.num_frame_calc_handles + 1) > AG903_PGP_MGR_MAX_FRAME_CALC_HANDLE) { 3667: return -AG903_ENOMEM; 3668: } 3669: } else { 3670: if ((PgpContext.num_frame_calc_handles + 1) > AG903_PGP_MGR_CALC_PIPELINE_NUM) { 3671: return -AG903_ENOMEM; 3672: } 3673: } 3674: 3675: if ((handle == NULL) || (master == NULL) || (slave == NULL)) { 3676: return -AG903_EINVAL; 3677: } 3678: 3679: 3680: if (master->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID) { 3681: return -AG903_EINVAL; 3682: } 3683: if ((master->is_assign == true) || (master->is_used_frame_calc == true)) { 3684: return -AG903_EBUSY; 3685: } 3686: 3687: if (slave_pipeline->id == AG903_PGP_MGR_PIPELINE_HANDLE_ID) { 3688: if ((slave_pipeline->is_assign == true) || (slave_pipeline->is_used_frame_calc == true)) { 3689: return -AG903_EBUSY; 3690: } 3691: slave_pipeline->frame_out_enable = false; 3692: slave_pipeline->is_used_frame_calc = true; 3693: slave_pipeline->is_dirty = true; 3694: } else if (slave_vram->id == AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID) { 3695: slave_vram->ref_cnt++; 3696: } else { 3697: return -AG903_EINVAL; 3698: } 3699: master->ifc_enable = true; 3700: master->is_used_frame_calc = true; 3701: master->is_dirty = true; 3702: 3703: 3704: for (i = 0; i < AG903_PGP_MGR_MAX_FRAME_CALC_HANDLE; i++) { 3705: if (PgpContext.frame_calc_handles[i].is_used == false) { 3706: PgpContext.frame_calc_handles[i].is_used = true; 3707: PgpContext.frame_calc_handles[i].master_handle = master; 3708: PgpContext.frame_calc_handles[i].slave_handle = slave; 3709: PgpContext.frame_calc_handles[i].id = AG903_PGP_MGR_FRAME_CALC_HANDLE_ID; 3710: PgpContext.frame_calc_handles[i].slave_pipeline = (slave_pipeline->id == AG903_PGP_MGR_PIPELINE_HANDLE_ID) ? true : false; 3711: *handle = &PgpContext.frame_calc_handles[i]; 3712: break; 3713: } 3714: } 3715: PgpContext.num_frame_calc_handles++; 3716: return AG903_ENONE; 3717: } 3718: 3719: 3720: 3729: int32_t AG903_PgpMgrReleaseFrameCalcHandle(AG903_PgpMgrFrameCalcHandle *handle) 3730: { 3731: AG903_PgpMgrPipelineHandle *slave_pipeline; 3732: 3733: 3734: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_FRAME_CALC_HANDLE_ID)) { 3735: return -AG903_EINVAL; 3736: } 3737: 3738: 3739: if (handle->master_handle->pipeline_no != -1) { 3740: 3741: if (PgpContext.exec_pipeline[handle->master_handle->pipeline_no] == handle->master_handle) { 3742: PGPPrmParamPGPnSTATE state; 3743: AG903_PgpPrmGetPGPnSTATE(handle->master_handle->pipeline_no, &state); 3744: if (state.st != AG903_PGP_MGR_STATE_IDLE) { 3745: return -AG903_EBUSY; 3746: } 3747: PgpContext.exec_pipeline[handle->master_handle->pipeline_no] = NULL; 3748: } 3749: 3750: if (PgpContext.assign_pipeline[handle->master_handle->pipeline_no] == handle->master_handle) { 3751: PgpContext.assign_pipeline[handle->master_handle->pipeline_no] = NULL; 3752: } 3753: if (handle->slave_pipeline == true) { 3754: slave_pipeline = (AG903_PgpMgrPipelineHandle *)handle->slave_handle; 3755: if (PgpContext.assign_pipeline[slave_pipeline->pipeline_no] == slave_pipeline) { 3756: PgpContext.assign_pipeline[slave_pipeline->pipeline_no] = NULL; 3757: } 3758: } 3759: } 3760: 3761: 3762: handle->master_handle->ifc_enable = false; 3763: handle->master_handle->is_used_frame_calc = false; 3764: handle->master_handle->is_assign = false; 3765: handle->master_handle->pipeline_no = -1; 3766: handle->master_handle->is_dirty = true; 3767: if (handle->slave_pipeline == true) { 3768: slave_pipeline = (AG903_PgpMgrPipelineHandle *)handle->slave_handle; 3769: if ((slave_pipeline->pipeline_no != -1) && (PgpContext.exec_pipeline[slave_pipeline->pipeline_no] == slave_pipeline)) { 3770: PgpContext.exec_pipeline[slave_pipeline->pipeline_no] = NULL; 3771: } 3772: slave_pipeline->frame_out_enable = true; 3773: slave_pipeline->is_used_frame_calc = false; 3774: slave_pipeline->is_assign = false; 3775: slave_pipeline->pipeline_no = -1; 3776: slave_pipeline->is_dirty = true; 3777: } else { 3778: AG903_PgpMgrVRAMInputHandle *slave_vram = (AG903_PgpMgrVRAMInputHandle *)handle->slave_handle; 3779: slave_vram->ref_cnt--; 3780: } 3781: 3782: handle->is_used = false; 3783: handle->id = 0; 3784: PgpContext.num_frame_calc_handles--; 3785: return AG903_ENONE; 3786: } 3787: 3788: 3789: 3811: int32_t AG903_PgpMgrSetConfigFrameCalcParameter(AG903_PgpMgrFrameCalcHandle *handle, uint32_t scan, uint32_t limit, uint32_t slave_src, uint32_t operation) 3812: { 3813: 3814: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_FRAME_CALC_HANDLE_ID)) { 3815: return -AG903_EINVAL; 3816: } 3817: 3818: switch (scan) { 3819: case AG903_PGP_MGR_SCAN_PROGRESSIVE: 3820: case AG903_PGP_MGR_SCAN_INTERLACE: 3821: break; 3822: default: 3823: return -AG903_EINVAL; 3824: } 3825: switch (limit) { 3826: case AG903_PGP_MGR_IFC_LIMIT_0_255: 3827: case AG903_PGP_MGR_IFC_LIMIT_16_235_AND_240: 3828: case AG903_PGP_MGR_IFC_LIMIT_M128_127: 3829: break; 3830: default: 3831: return -AG903_EINVAL; 3832: } 3833: switch (slave_src) { 3834: case AG903_PGP_MGR_IFC_SLAVE_VRAM_UI: 3835: case AG903_PGP_MGR_IFC_SLAVE_VRAM_I: 3836: case AG903_PGP_MGR_IFC_SLAVE_PIPELINE: 3837: break; 3838: default: 3839: return -AG903_EINVAL; 3840: } 3841: switch (operation) { 3842: case AG903_PGP_MGR_IFC_OP_AND: 3843: case AG903_PGP_MGR_IFC_OP_OR: 3844: case AG903_PGP_MGR_IFC_OP_XOR: 3845: case AG903_PGP_MGR_IFC_OP_ADD: 3846: case AG903_PGP_MGR_IFC_OP_ABS: 3847: break; 3848: default: 3849: return -AG903_EINVAL; 3850: } 3851: 3852: handle->master_handle->ifc_scan = scan; 3853: handle->master_handle->ifc_limit = limit; 3854: handle->master_handle->ifc_slave_src = (handle->slave_pipeline == true) ? AG903_PGP_MGR_IFC_SLAVE_PIPELINE : slave_src; 3855: handle->master_handle->ifc_operation = operation; 3856: handle->master_handle->is_config_dirty[AG903_PGP_MGR_CONFIG_IFC_PARAM] = true; 3857: handle->master_handle->is_dirty = true; 3858: return AG903_ENONE; 3859: } 3860: 3861: 3862: 3882: int32_t AG903_PgpMgrSetConfigFrameCalcGain(AG903_PgpMgrFrameCalcHandle *handle, int32_t master_gain, int32_t slave_gain, uint32_t master_shift, uint32_t slave_shift) 3883: { 3884: 3885: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_FRAME_CALC_HANDLE_ID)) { 3886: return -AG903_EINVAL; 3887: } 3888: 3889: 3890: if (master_shift > AG903_PGP_MGR_MAX_IFC_GAIN_SHIFT) { 3891: return -AG903_EINVAL; 3892: } 3893: if (slave_shift > AG903_PGP_MGR_MAX_IFC_GAIN_SHIFT) { 3894: return -AG903_EINVAL; 3895: } 3896: 3897: 3898: handle->master_handle->ifc_master_gain = master_gain & IFC_GAIN_MASK; 3899: handle->master_handle->ifc_slave_gain = slave_gain & IFC_GAIN_MASK; 3900: handle->master_handle->ifc_master_shift = master_shift; 3901: handle->master_handle->ifc_slave_shift = slave_shift; 3902: handle->master_handle->is_config_dirty[AG903_PGP_MGR_CONFIG_IFC_PARAM] = true; 3903: handle->master_handle->is_config_dirty[AG903_PGP_MGR_CONFIG_IFC_GAIN] = true; 3904: handle->master_handle->is_dirty = true; 3905: return AG903_ENONE; 3906: } 3907: 3908: 3909: 3922: int32_t AG903_PgpMgrGetVRAMInputHandle(int32_t num, AG903_PgpMgrVRAMInputHandle **handles) 3923: { 3924: int i, j; 3925: 3926: 3927: if (PgpContext.pipeline_time_sharing_enable == true) { 3928: if ((num + PgpContext.num_vram_input_handles) > AG903_PGP_MGR_MAX_VRAMI_HANDLE) { 3929: return -AG903_EINVAL; 3930: } 3931: } else { 3932: if ((num + PgpContext.num_vram_input_handles) > AG903_PGP_MGR_VRAMI_NUM) { 3933: return -AG903_EINVAL; 3934: } 3935: } 3936: 3937: if (handles == NULL) { 3938: return -AG903_EINVAL; 3939: } 3940: 3941: 3942: for (i = 0; i < num; i++) { 3943: for (j = 0; j < AG903_PGP_MGR_MAX_VRAMI_HANDLE; j++) { 3944: if (PgpContext.vram_input_handles[j].is_used == false) { 3945: 3946: PgpMgrInitVRAMInputHandle(&PgpContext.vram_input_handles[j]); 3947: 3948: PgpContext.vram_input_handles[j].is_used = true; 3949: PgpContext.vram_input_handles[j].id = AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID; 3950: handles[i] = &PgpContext.vram_input_handles[j]; 3951: break; 3952: } 3953: } 3954: } 3955: 3956: PgpContext.num_vram_input_handles += num; 3957: 3958: return AG903_ENONE; 3959: } 3960: 3961: 3962: 3971: int32_t AG903_PgpMgrReleaseVRAMInputHandle(AG903_PgpMgrVRAMInputHandle *handle) 3972: { 3973: 3974: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 3975: return -AG903_EINVAL; 3976: } 3977: 3978: 3979: if (handle->ref_cnt != 0) { 3980: return -AG903_EBUSY; 3981: } 3982: 3983: if (PgpContext.assign_vram[handle->port_no] == handle) { 3984: PgpContext.assign_vram[handle->port_no] = NULL; 3985: } 3986: if (PgpContext.exec_vram[handle->port_no] == handle) { 3987: PgpContext.exec_vram[handle->port_no] = NULL; 3988: } 3989: 3990: handle->is_used = false; 3991: handle->id = 0; 3992: PgpContext.num_vram_input_handles--; 3993: return AG903_ENONE; 3994: } 3995: 3996: 3997: 4008: int32_t AG903_PgpMgrExecVRAMInput(AG903_PgpMgrVRAMInputHandle *handle, uint32_t cmd) 4009: { 4010: uint32_t dummy, queue, st; 4011: 4012: 4013: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4014: return -AG903_EINVAL; 4015: } 4016: 4017: 4018: if (handle->port_no == -1) { 4019: return -AG903_EINVAL; 4020: } 4021: 4022: AG903_PgpPrmGetPGPVInSTATE(handle->port_no, &dummy, &queue, &st); 4023: 4024: if ((PgpContext.exec_vram[handle->port_no] != handle ) && (st != AG903_PGP_MGR_VI_CMD_NONE)) { 4025: return -AG903_EBUSY; 4026: } 4027: 4028: switch (cmd) { 4029: case AG903_PGP_MGR_VI_CMD_EXEC: 4030: 4031: if ((queue == (AG903_PGP_MGR_VI_CMD_MAX_QUEUE - 1)) || ((st != 0) && (cmd != st))) { 4032: return -AG903_EBUSY; 4033: } 4034: break; 4035: case AG903_PGP_MGR_VI_CMD_EXEC_CONTINUE: 4036: 4037: if (st != 0) { 4038: return -AG903_EBUSY; 4039: } 4040: break; 4041: case AG903_PGP_MGR_VI_CMD_NONE: 4042: case AG903_PGP_MGR_VI_CMD_IDLE: 4043: case AG903_PGP_MGR_VI_CMD_RESET: 4044: break; 4045: default: 4046: return -AG903_EINVAL; 4047: } 4048: 4049: PgpMgrExecVRAMInputHandle(handle, cmd); 4050: return AG903_ENONE; 4051: } 4052: 4053: 4054: 4066: int32_t AG903_PgpMgrGetVRAMStatus(AG903_PgpMgrVRAMInputHandle *handle, _Bool *is_vram_out, uint32_t *queue_cnt, uint32_t *exec_cmd) 4067: { 4068: uint32_t tmp_vram, tmp_queue, tmp_st; 4069: 4070: 4071: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4072: return -AG903_EINVAL; 4073: } 4074: 4075: 4076: if (handle->port_no == -1) { 4077: return -AG903_EINVAL; 4078: } 4079: 4080: 4081: AG903_PgpPrmGetPGPVInSTATE(handle->port_no, &tmp_vram, &tmp_queue, &tmp_st); 4082: 4083: 4084: if ((PgpContext.exec_vram[handle->port_no] != handle) && (tmp_st != AG903_PGP_MGR_VI_CMD_NONE)) { 4085: return -AG903_EINVAL; 4086: } 4087: if (is_vram_out != NULL) { 4088: *is_vram_out = tmp_vram; 4089: } 4090: if (queue_cnt != NULL) { 4091: *queue_cnt = tmp_queue; 4092: } 4093: if (exec_cmd != NULL) { 4094: *exec_cmd = tmp_st; 4095: } 4096: return AG903_ENONE; 4097: } 4098: 4099: 4100: 4112: int32_t AG903_PgpMgrSetParamVRAMInputBMU(AG903_PgpMgrVRAMInputHandle *handle, uint32_t bmu) 4113: { 4114: 4115: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4116: return -AG903_EINVAL; 4117: } 4118: 4119: 4120: switch (bmu) { 4121: case AG903_PGP_MGR_VI_BMU_NONE: 4122: case AG903_PGP_MGR_VI_BMU_ENABLE: 4123: case AG903_PGP_MGR_VI_BMU_ENABLE_ODD: 4124: break; 4125: default: 4126: return -AG903_EINVAL; 4127: } 4128: 4129: 4130: if (handle->port_no != -1) { 4131: return -AG903_EBUSY; 4132: } 4133: 4134: 4135: handle->bmu = bmu; 4136: handle->is_dirty = true; 4137: return AG903_ENONE; 4138: } 4139: 4140: 4141: 4153: int32_t AG903_PgpMgrSetParamVRAMInputScan(AG903_PgpMgrVRAMInputHandle *handle, uint32_t scan) 4154: { 4155: 4156: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4157: return -AG903_EINVAL; 4158: } 4159: 4160: 4161: switch (scan) { 4162: case AG903_PGP_MGR_SCAN_PROGRESSIVE: 4163: case AG903_PGP_MGR_SCAN_INTERLACE: 4164: break; 4165: default: 4166: return -AG903_EINVAL; 4167: } 4168: 4169: 4170: if (handle->port_no != -1) { 4171: return -AG903_EBUSY; 4172: } 4173: 4174: 4175: handle->scan = scan; 4176: handle->is_dirty = true; 4177: return AG903_ENONE; 4178: } 4179: 4180: 4181: 4193: int32_t AG903_PgpMgrSetParamVRAMInputAddrDim(AG903_PgpMgrVRAMInputHandle *handle, uint32_t dim) 4194: { 4195: 4196: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4197: return -AG903_EINVAL; 4198: } 4199: 4200: 4201: switch (dim) { 4202: case AG903_PGP_MGR_ADDR_DIMENTION_1: 4203: case AG903_PGP_MGR_ADDR_DIMENTION_2: 4204: break; 4205: default: 4206: return -AG903_EINVAL; 4207: } 4208: 4209: 4210: if (handle->port_no != -1) { 4211: return -AG903_EBUSY; 4212: } 4213: 4214: 4215: handle->dim = dim; 4216: handle->is_dirty = true; 4217: return AG903_ENONE; 4218: } 4219: 4220: 4221: 4233: int32_t AG903_PgpMgrSetConfigVRAMDataSwap(AG903_PgpMgrVRAMInputHandle *handle, _Bool word, _Bool hword, _Bool four_bit, _Bool one_bit) 4234: { 4235: 4236: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4237: return -AG903_EINVAL; 4238: } 4239: 4240: 4241: handle->vram_word_swap_enable = word; 4242: handle->vram_hword_swap_enable = hword; 4243: handle->vram_4bit_swap_enable = four_bit; 4244: handle->vram_1bit_swap_enable = one_bit; 4245: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_VI_CTRL] = true; 4246: handle->is_dirty = true; 4247: return AG903_ENONE; 4248: } 4249: 4250: 4251: 4262: int32_t AG903_PgpMgrSetConfigVRAMInterlaceFrame(AG903_PgpMgrVRAMInputHandle *handle, uint32_t frame_read, _Bool fai) 4263: { 4264: 4265: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4266: return -AG903_EINVAL; 4267: } 4268: 4269: 4270: switch (frame_read) { 4271: case AG903_PGP_MGR_VI_FRAME_READ_ODD: 4272: case AG903_PGP_MGR_VI_FRAME_READ_EVEN: 4273: case AG903_PGP_MGR_VI_FRAME_READ_FIELD: 4274: case AG903_PGP_MGR_VI_FRAME_READ_WEAVE: 4275: break; 4276: default: 4277: return -AG903_EINVAL; 4278: } 4279: 4280: 4281: handle->md = frame_read; 4282: handle->fai_enable = fai; 4283: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_VI_CTRL] = true; 4284: handle->is_dirty = true; 4285: return AG903_ENONE; 4286: } 4287: 4288: 4289: 4307: int32_t AG903_PgpMgrSetConfigVRAMValidTime(AG903_PgpMgrVRAMInputHandle *handle, uint32_t div, uint32_t vld, uint32_t inv) 4308: { 4309: 4310: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4311: return -AG903_EINVAL; 4312: } 4313: 4314: 4315: if ((div == 0) || (div > AG903_PGP_MGR_MAX_VI_DIV)) { 4316: return -AG903_EINVAL; 4317: } 4318: if ((vld == 0) || (vld > AG903_PGP_MGR_MAX_VI_VALIDATE)) { 4319: return -AG903_EINVAL; 4320: } 4321: if (inv > AG903_PGP_MGR_MAX_VI_INVALIDATE) { 4322: return -AG903_EINVAL; 4323: } 4324: 4325: 4326: handle->div = div; 4327: handle->valid = vld; 4328: handle->invalid = inv; 4329: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_VI_CTRL1] = true; 4330: handle->is_dirty = true; 4331: return AG903_ENONE; 4332: } 4333: 4334: 4335: 4347: int32_t AG903_PgpMgrSetParamVRAMFormat(AG903_PgpMgrVRAMInputHandle *handle, uint32_t format) 4348: { 4349: 4350: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4351: return -AG903_EINVAL; 4352: } 4353: 4354: 4355: switch (format) { 4356: case AG903_PGP_MGR_VI_FMT_RGB888_32: 4357: case AG903_PGP_MGR_VI_FMT_RGB888_24: 4358: case AG903_PGP_MGR_VI_FMT_RGB565: 4359: case AG903_PGP_MGR_VI_FMT_YCBCR444_32: 4360: case AG903_PGP_MGR_VI_FMT_YCBCR444_24: 4361: case AG903_PGP_MGR_VI_FMT_YCBCR422: 4362: case AG903_PGP_MGR_VI_FMT_CLUT8: 4363: case AG903_PGP_MGR_VI_FMT_CLUT1: 4364: break; 4365: default: 4366: return -AG903_EINVAL; 4367: } 4368: 4369: 4370: if (handle->port_no != -1) { 4371: return -AG903_EBUSY; 4372: } 4373: 4374: 4375: handle->format = format; 4376: handle->is_dirty = true; 4377: return AG903_ENONE; 4378: } 4379: 4380: 4381: 4390: int32_t AG903_PgpMgrSetConfigVRAMBaseAddr(AG903_PgpMgrVRAMInputHandle *handle, void *addr) 4391: { 4392: 4393: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4394: return -AG903_EINVAL; 4395: } 4396: 4397: 4398: if (addr == NULL) { 4399: return -AG903_EINVAL; 4400: } 4401: 4402: 4403: handle->addr = (uint32_t)addr; 4404: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_VI_BASE] = true; 4405: handle->is_dirty = true; 4406: return AG903_ENONE; 4407: } 4408: 4409: 4410: 4426: int32_t AG903_PgpMgrSetParamVRAMStride(AG903_PgpMgrVRAMInputHandle *handle, uint32_t stride) 4427: { 4428: 4429: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4430: return -AG903_EINVAL; 4431: } 4432: 4433: 4434: if ((stride == 0) || (stride > AG903_PGP_MGR_VI_MAX_STRIDE_BYTE)) { 4435: return -AG903_EINVAL; 4436: } 4437: 4438: 4439: if (handle->port_no != -1) { 4440: return -AG903_EBUSY; 4441: } 4442: 4443: 4444: handle->stride = stride; 4445: handle->is_dirty = true; 4446: return AG903_ENONE; 4447: } 4448: 4449: 4450: 4477: int32_t AG903_PgpMgrSetParamVRAMSyncSignal(AG903_PgpMgrVRAMInputHandle *handle, uint32_t h_pw, uint32_t h_fp, uint32_t h_bp, uint32_t v_pw, uint32_t v_fp, uint32_t v_bp) 4478: { 4479: 4480: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4481: return -AG903_EINVAL; 4482: } 4483: 4484: 4485: if ((h_pw == 0) || (h_pw > AG903_PGP_MGR_MAX_VI_H_PULES_WIDTH)) { 4486: return -AG903_EINVAL; 4487: } 4488: if ((h_fp == 0) || (h_fp > AG903_PGP_MGR_MAX_VI_H_FRONT_PORCH)) { 4489: return -AG903_EINVAL; 4490: } 4491: if ((h_bp == 0) || (h_bp > AG903_PGP_MGR_MAX_VI_H_BACK_PORCH)) { 4492: return -AG903_EINVAL; 4493: } 4494: if ((v_pw == 0) || (v_pw > AG903_PGP_MGR_MAX_VI_V_PULES_WIDTH)) { 4495: return -AG903_EINVAL; 4496: } 4497: if ((v_fp == 0) || (v_fp > AG903_PGP_MGR_MAX_VI_V_FRONT_PORCH)) { 4498: return -AG903_EINVAL; 4499: } 4500: if ((v_bp == 0) || (v_bp > AG903_PGP_MGR_MAX_VI_V_BACK_PORCH)) { 4501: return -AG903_EINVAL; 4502: } 4503: 4504: 4505: if (handle->port_no != -1) { 4506: return -AG903_EBUSY; 4507: } 4508: 4509: 4510: handle->h_pulse_width = h_pw; 4511: handle->h_front_porch = h_fp; 4512: handle->h_back_porch = h_bp; 4513: handle->v_pulse_width = v_pw; 4514: handle->v_front_porch = v_fp; 4515: handle->v_back_porch = v_bp; 4516: handle->is_dirty = true; 4517: return AG903_ENONE; 4518: } 4519: 4520: 4521: 4539: int32_t AG903_PgpMgrSetParamVRAMSize(AG903_PgpMgrVRAMInputHandle *handle, uint32_t h_size, uint32_t v_size) 4540: { 4541: 4542: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4543: return -AG903_EINVAL; 4544: } 4545: 4546: 4547: if ((h_size == 0) || (h_size > AG903_PGP_MGR_MAX_VI_H_SIZE)) { 4548: return -AG903_EINVAL; 4549: } 4550: if ((v_size == 0) || (v_size > AG903_PGP_MGR_MAX_VI_V_SIZE)) { 4551: return -AG903_EINVAL; 4552: } 4553: 4554: 4555: if (handle->port_no != -1) { 4556: return -AG903_EBUSY; 4557: } 4558: 4559: 4560: handle->h_frame_size = h_size; 4561: handle->v_frame_size = v_size; 4562: handle->is_dirty = true; 4563: return AG903_ENONE; 4564: } 4565: 4566: 4567: 4580: int32_t AG903_PgpMgrAdjustVRAMFrame(AG903_PgpMgrVRAMInputHandle *handle, _Bool e_vbp, _Bool e_vfp, _Bool o_vbp, _Bool o_vfp, _Bool o_vsize) 4581: { 4582: 4583: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4584: return -AG903_EINVAL; 4585: } 4586: 4587: 4588: handle->adjust_even_vbp = e_vbp; 4589: handle->adjust_even_vfp = e_vfp; 4590: handle->adjust_odd_vbp = o_vbp; 4591: handle->adjust_odd_vfp = o_vfp; 4592: handle->adjust_odd_vsize = o_vsize; 4593: handle->is_config_dirty[AG903_PGP_MGR_CONFIG_VI_ADJUST_FRAME] = true; 4594: handle->is_dirty = true; 4595: return AG903_ENONE; 4596: } 4597: 4598: 4599: 4608: int32_t AG903_PgpMgrCheckVRAMParameter(AG903_PgpMgrVRAMInputHandle *vram, AG903_PgpMgrPipelineHandle *pipeline) 4609: { 4610: 4611: if ((vram == NULL) || (vram->id != AG903_PGP_MGR_VRAM_INPUT_HANDLE_ID)) { 4612: return -AG903_EINVAL; 4613: } 4614: if ((pipeline == NULL) || (pipeline->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 4615: return -AG903_EINVAL; 4616: } 4617: 4618: 4619: if ((vram->h_pulse_width + vram->h_back_porch) != pipeline->input_hpos) { 4620: return -AG903_EINVAL; 4621: } 4622: 4623: if ((vram->v_pulse_width + vram->v_back_porch) != pipeline->input_vpos) { 4624: return -AG903_EINVAL; 4625: } 4626: 4627: return AG903_ENONE; 4628: } 4629: 4630: 4631: 4642: int32_t AG903_PgpMgrSetJPEG(AG903_PgpMgrPipelineHandle *handle) 4643: { 4644: 4645: if ((handle == NULL) || (handle->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 4646: return -AG903_EINVAL; 4647: } 4648: 4649: 4650: if (handle->is_assign == false) { 4651: return -AG903_EINVAL; 4652: } 4653: 4654: PgpContext.jpeg_output_pipeline = handle->pipeline_no; 4655: 4656: return AG903_ENONE; 4657: } 4658: 4659: 4660: 4671: int32_t AG903_PgpMgrEnableJPEG(_Bool enable) 4672: { 4673: if ((enable == true) && (PgpContext.jpeg_output_enable == true)) { 4674: return -AG903_EBUSY; 4675: } 4676: 4677: PgpContext.jpeg_output_enable = enable; 4678: 4679: 4680: AG903_PgpPrmSetPGPJPGOUTSEL(PgpContext.jpeg_output_enable, PgpContext.jpeg_output_pipeline); 4681: 4682: return AG903_ENONE; 4683: } 4684: 4685: 4686: #define PACK_LUT(d0, d1, d2, d3) (((d0) << 0) | ((d1) << 8) | ((d2) << 16) | ((d3) << 24)) 4687: 4700: int32_t AG903_PgpMgrGetDGCLUT(uint8_t red[256], uint8_t green[256], uint8_t blue[256], AG903_PgpMgrDGCLookupTable **table) 4701: { 4702: int i, j; 4703: 4704: 4705: if ((red == NULL) || (green == NULL) || (blue == NULL) || (table == NULL)) { 4706: return -AG903_EINVAL; 4707: } 4708: 4709: if ((PgpContext.num_dgc_lut + 1) > AG903_PGP_MGR_MAX_DGC_LUT) { 4710: return -AG903_ENOMEM; 4711: } 4712: 4713: 4714: for (i = 0; i < AG903_PGP_MGR_MAX_DGC_LUT; i++) { 4715: if (PgpContext.dgc_lut[i].is_used == false) { 4716: PgpContext.dgc_lut[i].is_used = true; 4717: PgpContext.dgc_lut[i].id = AG903_PGP_MGR_DGC_LUT_ID; 4718: PgpContext.dgc_lut[i].ref_cnt = 0; 4719: 4720: for (j = 0; j < 256; j++) { 4721: PgpContext.dgc_lut[i].lut_data[0][j] = blue[j]; 4722: PgpContext.dgc_lut[i].lut_data[1][j] = green[j]; 4723: PgpContext.dgc_lut[i].lut_data[2][j] = red[j]; 4724: } 4725: *table = &PgpContext.dgc_lut[i]; 4726: break; 4727: } 4728: } 4729: 4730: PgpContext.num_dgc_lut++; 4731: 4732: return AG903_ENONE; 4733: } 4734: 4735: 4736: 4744: int32_t AG903_PgpMgrReleaseDGCLUT(AG903_PgpMgrDGCLookupTable *table) 4745: { 4746: 4747: if ((table == NULL) || (table->id != AG903_PGP_MGR_DGC_LUT_ID)) { 4748: return -AG903_EINVAL; 4749: } 4750: 4751: 4752: if (table->ref_cnt != 0) { 4753: return -AG903_EINVAL; 4754: } 4755: 4756: 4757: table->is_used = false; 4758: table->id = 0; 4759: PgpContext.num_dgc_lut--; 4760: 4761: return AG903_ENONE; 4762: } 4763: 4764: 4765: 4775: int32_t AG903_PgpMgrSetConfigDGCLUT(AG903_PgpMgrPipelineHandle *pipeline, AG903_PgpMgrDGCLookupTable *dgc_lut) 4776: { 4777: 4778: if ((pipeline == NULL) || (pipeline->id != AG903_PGP_MGR_PIPELINE_HANDLE_ID)) { 4779: return -AG903_EINVAL; 4780: } 4781: if ((dgc_lut != NULL) && (dgc_lut->id != AG903_PGP_MGR_DGC_LUT_ID)) { 4782: return -AG903_EINVAL; 4783: } 4784: 4785: 4786: if (pipeline->dgc_lut == dgc_lut) { 4787: return AG903_ENONE; 4788: } 4789: 4790: if (pipeline->dgc_lut != NULL) { 4791: pipeline->dgc_lut->ref_cnt--; 4792: pipeline->dgc_lut = NULL; 4793: } 4794: 4795: pipeline->dgc_lut = dgc_lut; 4796: if (dgc_lut != NULL) { 4797: pipeline->dgc_lut_dirty = true; 4798: dgc_lut->ref_cnt++; 4799: } 4800: 4801: return AG903_ENONE; 4802: }
 
名前 
説明 
 
VRAM入力のインタレースモードでのEVEN/ODDフレーム調整 
 
ラベリング付加情報テーブルの解析 
 
パイプラインハンドルまたはフレーム間演算ハンドルを物理的なパイプラインに割り当て 
 
パイプラインハンドルが指定した物理パイプラインへの割り当て可否チェック 
 
指定されたVRAM入力ハンドルとパイプラインハンドルの映像パラメータの互換性確認 
 
RGB分離出力によるパイプライン出力時のカラーマスク設定 
 
減色処理時のディザリングの有効/無効設定 
 
フレーム付加情報出力の有効/無効設定 
 
JPEG出力の有効/無効設定 
 
色空間変換処理の有効/無効設定 
 
濃度変換処理の有効/無効設定 
 
ヒストグラム処理の有効/無効設定 
 
ヒストグラム計測時のバッファ管理ユニット設定 
 
HSV、HLS変換処理の有効/無効設定 
 
ラベリング処理の有効/無効設定 
 
ラベリング処理時のバッファ管理ユニット使用有無設定 
 
3タップノイズフィルタ処理の有効/無効設定 
 
スケーリング処理の有効/無効設定 
 
空間フィルタ処理の有効/無効設定 
 
閾値処理の有効/無効設定 
 
ビデオ入力、フレーム出力トリガの有効/無効設定 
 
前処理の時分割動作の有効無効指定 
 
ヒストグラムの実行制御 
 
ラベリング処理の実行制御 
 
パイプラインの実行制御 
 
VRAM入力の実行制御 
 
パイプラインハンドルまたはフレーム間演算ハンドルを指定したパイプラインに強制割り当て 
 
濃度変換テーブルハンドル取得 
 
フレーム間演算ハンドル取得 
 
パイプラインのフレーム付加情報の値取得 
 
ヒストグラム計測時の最頻値、最大値、最小値取得 
 
ヒストグラム計測時のステータス取得 
 
ラベリング処理時のステータス取得 
 
指定数のパイプラインハンドル取得 
 
パイプラインのステータス取得 
 
指定した数のVRAM入力ハンドル取得 
 
VRAM入力のステータス取得 
 
パイプラインハンドルの物理パイプラインに対する割り当て解放 
 
濃度変換テーブル解放 
 
フレーム間演算ハンドル解放 
 
ラベリング付加情報テーブルの開放 
 
パイプラインハンドルの解放 
 
VRAM入力ハンドル解放 
 
色空間変換を制御するパラメータ設定 
 
パイプラインハンドルへの濃度変換テーブル関連付け 
 
フレーム間演算のゲインパラメータ設定 
 
フレーム間演算パラメータ設定 
 
ヒストグラム計測出力先ベースアドレス設定 
 
ヒストグラム制御のパラメータ設定 
 
ヒストグラム計測開始座標設定 
 
ヒストグラム制御のパラメータ設定 
 
HSV、HLS変換回路の出力フォーマット設定 
 
トリガ起動のタイマモジュールのチャンネル番号設定 
 
パイプラインの入出力割り込み設定 
 
I/P変換回路のパラメータ設定 
 
ラベリング付加情報出力先のベースアドレス設定 
 
ラベリングの制御パラメータ設定 
 
ラベリング処理開始座標設定 
 
ラベリング処理サイズ設定 
 
ラベリングの出力有効/無効期間パラメータ設定 
 
パイプラインの出力先ベースアドレス設定 
 
パイプライン出力時のデータスワップ設定 
 
フレーム保存時のパディング値設定 
 
インタレース入力のフレーム保存方法設定 
 
24bit入力値のリミット動作設定 
 
色空間変換のプリセット設定 
 
スケーリングのパラメータ設定 
 
空間フィルタを制御するパラメータ設定 
 
閾値処理の機能設定 
 
閾値処理の 1bit 閾値処理設定 
 
閾値処理の 8bit 閾値処理のパラメータ設定 
 
閾値処理の色空間変換を制御するパラメータ設定 
 
閾値処理の HSV、HLS 変換回路の出力フォーマット機能設定 
 
閾値処理のマスク生成設定 
 
色空間変換のプリセット設定 
 
閾値処理の 1bit 空間フィルタ設定 
 
ビデオ入力、フレーム出力トリガ設定 
 
VRAM入力の出力先ベースアドレス設定 
 
VRAM入力のデータスワップ設定 
 
VRAM入力のインタレースフレームの読みだし方法設定 
 
VRAM入力の出力有効/無効期間パラメータ設定 
 
パイプラインの入力ポート設定 
 
割り込みのコールバック関数登録 
 
指定されたパイプラインハンドルのJPEG出力設定 
 
フレーム間演算とその他の演算の処理順序設定 
 
パイプラインの入力フォーマット設定 
 
キャプチャ入力のHSYNCに対する遅延設定 
 
キャプチャ入力の動作モード設定 
 
パイプラインのキャプチャ開始座標設定 
 
パイプラインのキャプチャ時のフレーム走査方法設定 
 
パイプラインのキャプチャサイズ設定 
 
キャプチャ入力のタイプスタンプ生成に使用するクロックソース設定 
 
パイプライン出力時のアドレス指定方法設定 
 
バッファ管理ユニット設定 
 
パイプライン出力時のフォーマット設定 
 
パイプライン出力時のフレーム走査方法設定 
 
パイプラインの出力先が2次元の場合のストライドバイト設定 
 
VRAM入力のフォーマット設定 
 
VRAM入力のアドレス指定方法設定 
 
VRAM入力のバッファ管理ユニット設定 
 
VRAM入力のフレーム走査方法設定 
 
VRAM入力のフレームサイズ設定 
 
VRAM入力が二次元アドレスの場合のストライドバイト設定 
 
VRAM入力の同期信号出力パラメータ設定 
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.