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

VIA Manager

VIA Manager Layer.

none

AXELL CORPORATION

2017_02_22 初版 

2017_10_26 Ver2.0 

2019_03_08 [SDK2.2] VIAにビデオ入力の信号が有効であることを検出する関数を追加 (#2454)

1: 10: 11: 15: 16: 17: #include <stdio.h> 18: #include "via/viaprm.h" 19: #include "via/viamgr.h" 20: #include "pgp/pgpprm.h" 21: #include "sys/spcprm.h" 22: #include "sys/sscprm.h" 23: 24: 25: #define PGP_IDLE (0) 26: 27: 28: #define GCAT (0x1) 29: #define NSNS (0x1) 30: #define NONS (0x1) 31: #define TRAP (0x0) 32: #define AGCEN (0x1) 33: #define ACCOV (0x30) 34: #define ACCTC (0x1) 35: #define CBPLLULTH (0x12) 36: #define CBPLLULSV (0x0) 37: #define AGCGAINSPD (0x3) 38: #define AGCOFSTSPD (0x3) 39: #define AGCPOS (0x0) 40: #define AGCGAINEN (0x1) 41: #define AGCOFSTEN (0x1) 42: #define CLAMPOFS (0x10) 43: 44: 45: static _Bool init_check = false; 46: 47: 48: static struct { 49: _Bool used_ports[AG903_VIA_MGR_MAX_PORTS]; 50: AG903_ViaMgrInputHandle ports[AG903_VIA_MGR_MAX_PORTS]; 51: } ViaContext = { 52: {false, false, false, false}, 53: {{0}} 54: }; 55: 56: 57: static struct { 58: uint16_t fmt; 59: uint16_t hcycle; 60: uint16_t hvalid; 61: uint16_t hdelay; 62: uint16_t vcycle; 63: uint16_t vvalid; 64: uint16_t vdelay; 65: uint16_t frm; 66: uint16_t accmark; 67: uint16_t agcpal; 68: } ViaFormat[AG903_VIA_MGR_FORMAT_MAX] = { 69: { 0x0000, 0x06B4, 0x05A0, 0x001A, 0x020D, 0x01E0, 0x000A, 0x0000, 0x003E, 0x0000 }, 70: { 0x0008, 0x0618, 0x0500, 0x0014, 0x020D, 0x01E0, 0x000A, 0x0000, 0x0039, 0x0000 }, 71: { 0x0007, 0x071C, 0x0600, 0x0094, 0x020D, 0x01E0, 0x000A, 0x0000, 0x003E, 0x0000 }, 72: { 0x0001, 0x06C0, 0x05A0, 0x0014, 0x0271, 0x0240, 0x000A, 0x0001, 0x003E, 0x0001 }, 73: { 0x0009, 0x0760, 0x0600, 0x0014, 0x0271, 0x0240, 0x000A, 0x0001, 0x0032, 0x0001 }, 74: }; 75: 76: 77: static struct { 78: uint16_t nsck; 79: uint16_t mono; 80: } ViaMode[AG903_VIA_MGR_MODE_MAX] = { 81: { 0x0001, 0x0000 }, 82: { 0x0000, 0x0001 }, 83: }; 84: 85: 86: 94: int32_t AG903_ViaMgrInit(void) 95: { 96: 97: { 98: AG903_SSCPrmVideoAdcParam param = {0}; 99: 100: param.acq_clr = 0x0; 101: param.acq_en = 0x0; 102: param.dat_en = 0xF; 103: param.clmp_tmg = 0x0; 104: param.clmp_lv = 0xF; 105: param.pga_ctl = 0xF; 106: 107: AG903_SSCPrmSetVideoAdcSetup(&param); 108: } 109: 110: 111: 112: 113: 114: { 115: AG903_SPCPrmVideoAdcParam param = {0}; 116: AG903_SPCPrmVideoAdcEnable enable = {0}; 117: 118: param.clmp_en0 = 0x0; 119: param.clmp_en1 = 0x0; 120: param.clmp_en2 = 0x0; 121: param.clmp_en3 = 0x0; 122: param.clmp_lv0 = 0xA5; 123: param.clmp_lv1 = 0xA5; 124: param.clmp_lv2 = 0xA5; 125: param.clmp_lv3 = 0xA5; 126: param.clmp_imp = 0x3; 127: param.gain0 = 0x7; 128: param.gain1 = 0x7; 129: param.gain2 = 0x7; 130: param.gain3 = 0x7; 131: param.aaf_ctrl = 0x20; 132: param.qntzr_bias_up = 0x2; 133: param.input_range = 0x1; 134: param.ref_bias_up = 0x1; 135: enable.adc = 0x1; 136: enable.ch0 = 0x1; 137: enable.ch1 = 0x1; 138: enable.ch2 = 0x1; 139: enable.ch3 = 0x1; 140: 141: AG903_SPCPrmSetVideoAdcCtrl(&param, &enable); 142: } 143: 144: init_check = true; 145: 146: return AG903_ENONE; 147: } 148: 149: 150: 164: int32_t AG903_ViaMgrGetInputHandle(int32_t *ports, int32_t num_ports, AG903_ViaMgrInputHandle **handles) 165: { 166: int32_t i; 167: _Bool num_check[AG903_VIA_MGR_MAX_PORTS] = {false}; 168: 169: if (init_check != true) { 170: return -AG903_EINVAL; 171: } 172: if (num_ports > AG903_VIA_MGR_MAX_PORTS) { 173: return -AG903_EINVAL; 174: } 175: if ((ports == NULL) || (handles == NULL)) { 176: return -AG903_EINVAL; 177: } 178: for (i = 0; i < num_ports; i++) { 179: if ((ports[i] < 0) || (ports[i] >= AG903_VIA_MGR_MAX_PORTS)) { 180: return -AG903_EINVAL; 181: } 182: if (ViaContext.used_ports[ports[i]] != false) { 183: return -AG903_ENOMEM; 184: } 185: 186: if (num_check[ports[i]] == true) { 187: return -AG903_EINVAL; 188: } 189: num_check[ports[i]] = true; 190: } 191: 192: for (i = 0; i < num_ports; i++) { 193: 194: handles[i] = (AG903_ViaMgrInputHandle *)&ViaContext.ports[ports[i]]; 195: handles[i]->id = AG903_VIA_MGR_INPUT_HANDLE_ID; 196: handles[i]->port_no = ports[i]; 197: 198: ViaContext.used_ports[ports[i]] = true; 199: } 200: return AG903_ENONE; 201: } 202: 203: 204: 213: int32_t AG903_ViaMgrReleaseInputHandle(AG903_ViaMgrInputHandle *handle) 214: { 215: 216: if ((handle == NULL) || (handle->id != AG903_VIA_MGR_INPUT_HANDLE_ID)) { 217: return -AG903_EINVAL; 218: } 219: 220: 221: ViaContext.used_ports[handle->port_no] = false; 222: 223: 224: handle->id = 0; 225: 226: return AG903_ENONE; 227: } 228: 229: 230: 242: int32_t AG903_ViaMgrSetInputParameter(AG903_ViaMgrInputHandle *handle, uint32_t format, uint32_t mode) 243: { 244: 245: if ((handle == NULL) || (handle->id != AG903_VIA_MGR_INPUT_HANDLE_ID)) { 246: return -AG903_EINVAL; 247: } 248: 249: 250: switch (format) { 251: case AG903_VIA_MGR_FORMAT_NTSC_BT: 252: case AG903_VIA_MGR_FORMAT_NTSC_SQ: 253: case AG903_VIA_MGR_FORMAT_NTSC_4F: 254: case AG903_VIA_MGR_FORMAT_PAL_BT: 255: case AG903_VIA_MGR_FORMAT_PAL_SQ: 256: break; 257: default: 258: return -AG903_EINVAL; 259: } 260: 261: 262: switch (mode) { 263: case AG903_VIA_MGR_MODE_COLOR: 264: case AG903_VIA_MGR_MODE_MONOCHROME: 265: break; 266: default: 267: return -AG903_EINVAL; 268: } 269: 270: VIAPrmParamVIASRCSELECT select; 271: select.gcat = GCAT; 272: select.nsck = ViaMode[mode].nsck; 273: select.nsns = NSNS; 274: select.nons = NONS; 275: AG903_ViaPrmSetVIASRCSELECT(handle->port_no, &select); 276: 277: AG903_ViaPrmSetVIASRCFORMAT(handle->port_no, ViaFormat[format].fmt); 278: AG903_ViaPrmSetVIASRCHCYCLE(handle->port_no, ViaFormat[format].hcycle); 279: AG903_ViaPrmSetVIASRCHVALID(handle->port_no, ViaFormat[format].hvalid); 280: AG903_ViaPrmSetVIASRCHDELAY(handle->port_no, ViaFormat[format].hdelay); 281: AG903_ViaPrmSetVIASRCVCYCLE(handle->port_no, ViaFormat[format].vcycle); 282: AG903_ViaPrmSetVIASRCVVALID(handle->port_no, ViaFormat[format].vvalid); 283: AG903_ViaPrmSetVIASRCVDELAY(handle->port_no, ViaFormat[format].vdelay); 284: AG903_ViaPrmSetVIASRCFRMFREQ(handle->port_no, ViaFormat[format].frm); 285: AG903_ViaPrmSetVIASIGYCS(handle->port_no, TRAP, ViaMode[mode].mono); 286: 287: VIAPrmParamVIACHDSETUP3 setup3; 288: setup3.agcen = AGCEN; 289: setup3.accov = ACCOV; 290: setup3.acctc = ACCTC; 291: setup3.accmark = ViaFormat[format].accmark; 292: AG903_ViaPrmSetVIACHDSETUP3(handle->port_no, &setup3); 293: 294: VIAPrmParamVIACHDSETUP5 setup5; 295: setup5.cbpllulth = CBPLLULTH; 296: setup5.cbpllulsv = CBPLLULSV; 297: setup5.agcgainspd = AGCGAINSPD; 298: setup5.agcofstspd = AGCOFSTSPD; 299: setup5.agcpos = AGCPOS; 300: setup5.agcpal = ViaFormat[format].agcpal; 301: setup5.agcgainen = AGCGAINEN; 302: setup5.agcofsten = AGCOFSTEN; 303: AG903_ViaPrmSetVIACHDSETUP5(handle->port_no, &setup5); 304: 305: AG903_ViaPrmSetVIACLAMPLEVEL(handle->port_no, CLAMPOFS); 306: 307: return AG903_ENONE; 308: } 309: 310: 311: 320: int32_t AG903_ViaMgrIsInputValid(AG903_ViaMgrInputHandle *handle) 321: { 322: VIAPrmParamVIADETSTATUS vdst = { 323: .normal = 0, 324: .nosync = 1, 325: }; 326: AG903_ViaPrmGetVIADETSTATUS(handle->port_no, &vdst); 327: if (!vdst.nosync && vdst.normal) { 328: return 1; 329: } 330: return 0; 331: }
 
名前 
説明 
 
VIA ハンドル取得 
 
VIA 初期化 
 
ビデオ入力信号の状態取得 
 
VIA ハンドル解放 
 
フォーマット/カラーモード設定 
Copyright (c) 2017-2025 Axell Corporation. All rights reserved.