/* * Configure PORT_1C as data with PORT_1D as the valid signal. Test receiving * two different words of data and check they are the correct values. */ void port_test_input(chanend c) { port p = port_enable(XS1_PORT_1C); port_set_buffered(p); port_set_transfer_width(p, 32); port p_ready = port_enable(XS1_PORT_1D); clock clk = clock_enable(XS1_CLKBLK_2); clock_start(clk); port_configure_in_strobed_slave(p, p_ready, clk); chan_output_word(c, 0); // Send ack unsigned int x = port_input(p); if (x != 0xfeedbeef) { debug_printf("Error %x received instead of 0xfeedbeef\n", x); } x = port_input(p); if (x != 0x12345678) { debug_printf("Error %x received instead of 0x12345678\n", x); } chan_output_word(c, 0); // Send ack port_disable(p); port_disable(p_ready); clock_disable(clk); // Get information about the tile/core running the server for debug messages unsigned tile_id = get_local_tile_id(); unsigned core_id = get_logical_core_id(); debug_printf("%x:%d: input done\n", tile_id, core_id); }
/* * Configure PORT_1A as data with PORT_1B as the valid signal. Ensure that the * receiver is ready using a channel end. Send a word of data, delay for a while * and send another word to ensure the valid signals are functioning. */ void port_test_output(chanend c) { port p = port_enable(XS1_PORT_1A); port_set_buffered(p); port_set_transfer_width(p, 32); port p_ready = port_enable(XS1_PORT_1B); clock clk = clock_enable(XS1_CLKBLK_1); clock_start(clk); port_configure_out_strobed_master(p, p_ready, clk, 0); chan_input_word(c); // Wait for ack port_output(p, 0xfeedbeef); timer tmr = timer_alloc(); timer_delay(tmr, 1000); timer_free(tmr); port_output(p, 0x12345678); chan_input_word(c); // Wait for ack port_disable(p); port_disable(p_ready); clock_disable(clk); // Get information about the tile/core running the server for debug messages unsigned tile_id = get_local_tile_id(); unsigned core_id = get_logical_core_id(); debug_printf("%x:%d: output done\n", tile_id, core_id); }
OMX_ERRORTYPE process_event(HTEST *hTest, MSG *pMsg) { OMX_EVENTTYPE event = pMsg->data.event.eEvent; OMX_U32 nPortIndex = pMsg->data.event.nData1; if(event == OMX_EventPortSettingsChanged) { port_disable(hTest, nPortIndex); port_enable(hTest, nPortIndex); OMX_STATETYPE eState = OMX_StateInvalid; OMX_GetState(hTest->hComponent, &eState); if(eState == OMX_StateExecuting) { /* Send output buffers */ OMX_S32 i; for(i=0; i<hTest->nBufferHdr[1]; i++) { hTest->pBufferHdr[1][i]->nFilledLen = 0; hTest->pBufferHdr[1][i]->nOffset = 0; OMX_FillThisBuffer(hTest->hComponent, hTest->pBufferHdr[1][i]); } } } return OMX_ErrorNone; }
int main(int argc, char * const *argv) { int power_up = 0; int power_down = 0; int action_taken = 0; int ret; struct state st; int ch; struct option longopts[] = { { "list-ports", no_argument, NULL, 'l' }, { "port-enable",required_argument, &power_up, 'e' }, { "port-disable",required_argument, &power_down, 'd' }, { "help", no_argument, NULL, 'h' }, { NULL, 0, NULL, 0 } }; memset(&st, 0, sizeof(st)); st.progname = argv[0]; ret = novena_hub_init(&st); if (ret) return ret; while ((ch = getopt_long(argc, argv, "le:d:h", longopts, NULL)) != -1) { switch (ch) { case 'h': print_help(&st); action_taken = 1; break; case 'e': port_enable(&st, optarg); action_taken = 1; break; case 'd': port_disable(&st, optarg); action_taken = 1; break; case 'l': list_ports(&st); action_taken = 1; break; default: break; } } if (!action_taken) print_help(&st); novena_hub_deinit(&st); return 0; }
/* !DO NOT ALTER FUNCTION SIGNATURE! */ int callback_ofc_capable_switch_ofc_resources_ofc_port_ofc_configuration_ofc_admin_state (void ** data, XMLDIFF_OP op, xmlNodePtr node, struct nc_err** error) { nc_verb_verbose("%s: data=%p, op=%d\n", __PRETTY_FUNCTION__, data, op); print_element_names(node, 0); int rv = EXIT_SUCCESS; int down = 0; // default is up if ((XMLDIFF_ADD|XMLDIFF_MOD) & op) { if (xmlStrEqual(XML_GET_CONTENT(node->children), BAD_CAST "down")) { down = 1; } // sanity check... if the content is not "down", it has to be "up" assert(down || xmlStrEqual(XML_GET_CONTENT(node->children), BAD_CAST "up")); // currently the resource-id is the port name (even if the name is not set xmlNodePtr tmp = find_element(BAD_CAST "resource-id", node->parent->parent->children); assert(tmp); if (down) { // set interface down nc_verb_verbose("set interface %s down\n", tmp->children->content); if (port_disable(ofc_state.xmp_client_handle, tmp->children->content)) { rv = EXIT_FAILURE; } } else { // set interface up nc_verb_verbose("set interface %s up\n", tmp->children->content); if (port_enable(ofc_state.xmp_client_handle, tmp->children->content)) { rv = EXIT_FAILURE; } } } else if (XMLDIFF_REM & op) { // setting interface up } else { nc_verb_error("unsupported op"); assert(0); } return rv; }
OMX_ERRORTYPE parser_process_port_setting_changed(HTEST *hTest,OMX_U32 nPortIndex) { OMX_ERRORTYPE ret = OMX_ErrorNone; port_disable(hTest,nPortIndex); OMX_PARAM_U32TYPE sU32; OMX_INIT_STRUCT(&sU32, OMX_PARAM_U32TYPE); sU32.nPortIndex = nPortIndex; ret = OMX_GetParameter(hTest->hComponent,OMX_IndexParamNumAvailableStreams,&sU32); if (ret != OMX_ErrorNone) return ret; printf("%s,%d,track %d, number of available stream is %d.\n",__FUNCTION__,__LINE__,sU32.nPortIndex,sU32.nU32); /*active strem number should be from 0 to NumAvailable - 1*/ sU32.nU32 = sU32.nU32 - 1; ret = OMX_SetParameter(hTest->hComponent,OMX_IndexParamActiveStream,&sU32); if (ret != OMX_ErrorNone) return ret; printf("%s,%d,track %d, set active stream number %d.\n",__FUNCTION__,__LINE__,sU32.nPortIndex,sU32.nU32); OMX_PARAM_PORTDEFINITIONTYPE sPortDef; OMX_INIT_STRUCT(&sPortDef, OMX_PARAM_PORTDEFINITIONTYPE); sPortDef.nPortIndex = nPortIndex; ret = OMX_GetParameter(hTest->hComponent, OMX_IndexParamPortDefinition, &sPortDef); if (ret != OMX_ErrorNone) return ret; if (nPortIndex == hTest->nAudioTrackNum) printf("%s,%d,audio track %d, compress format %d.\n",__FUNCTION__,__LINE__,sPortDef.nPortIndex,sPortDef.format.audio.eEncoding); else printf("%s,%d,video track %d, compress format %d.\n",__FUNCTION__,__LINE__,sPortDef.nPortIndex,sPortDef.format.video.eCompressionFormat); port_enable(hTest,nPortIndex); return ret; }
OMX_ERRORTYPE cmd_process(HTEST *hTest) { char rep[10]; OMX_BOOL bExit = OMX_FALSE; while(bExit == OMX_FALSE) { printf("Input test cmd:\n"); printf("[f]flush\n"); printf("[x]exit\n"); scanf("%s", rep); if(rep[0] == 'l') load_component(hTest); else if(rep[0] == 's') { OMX_U32 state = 0; printf("State trans to:\n"); printf("0 -- Invalid\n"); printf("1 -- Loaded\n"); printf("2 -- Idle\n"); printf("3 -- Executing\n"); printf("4 -- Pause\n"); printf("5 -- WaitForResources\n"); scanf("%d", &state); StateTrans(hTest, (OMX_STATETYPE)state); } else if(rep[0] == 'f') { OMX_U32 nPortIndex = 0; printf("Want to flush port number:\n"); scanf("%d", &nPortIndex); port_flush(hTest, nPortIndex); } else if(rep[0] == 'd') { OMX_U32 nPortIndex = 0; printf("Want to disbale port number:\n"); scanf("%d", &nPortIndex); port_disable(hTest, nPortIndex); } else if(rep[0] == 'e') { OMX_U32 nPortIndex = 0; printf("Want to enable port number:\n"); scanf("%d", &nPortIndex); port_enable(hTest, nPortIndex); } else if(rep[0] == 'k') { OMX_U32 nSeekPos = 0; printf("seek to second:\n"); scanf("%d", &nSeekPos); OMX_U32 nSeekMode = 0; printf("seek mode [0:Fast,1:Accurate]:\n"); scanf("%d", &nSeekMode); do_seek(hTest, nSeekPos, (OMX_TIME_SEEKMODETYPE)nSeekMode); } else if(rep[0] == 'x') { MSG sMsg; sMsg.type = EXIT; hTest->pMsgQ->Add(&sMsg); hTest->bStop = OMX_TRUE; bExit = OMX_TRUE; StateTrans(hTest, (OMX_STATETYPE)2); StateTrans(hTest, (OMX_STATETYPE)1); unload_component(hTest); } } return OMX_ErrorNone; }
void bridge_open_2() { port_enable(&port_b); }
void bridge_open_1() { port_enable(&port_a); }