/*! \brief configure the CEC peripheral \param[in] none \param[out] none \retval none */ void cec_config(void) { /* enable clocks */ rcu_periph_clock_enable(RCU_GPIOB); rcu_periph_clock_enable(RCU_CEC); /* configure CEC_LINE_GPIO as output open drain */ gpio_mode_set(GPIOB,GPIO_MODE_AF,GPIO_PUPD_NONE,GPIO_PIN_8); gpio_output_options_set(GPIOB,GPIO_OTYPE_OD,GPIO_OSPEED_50MHZ,GPIO_PIN_8); gpio_af_set(GPIOB,GPIO_AF_0,GPIO_PIN_8); /* configure priority group */ nvic_priority_group_set(NVIC_PRIGROUP_PRE1_SUB3); /* enable the CEC global interrupt (with higher priority) */ nvic_irq_enable(CEC_IRQn,0,0); /* configure CEC */ cec_init(CEC_SFT_START_SOM,CEC_SFT_1POINT5_PERIOD,CEC_OWN_ADDRESS2); cec_error_config(CEC_BROADCAST_ERROR_BIT_OFF,CEC_LONG_PERIOD_ERROR_BIT_OFF,CEC_RISING_PERIOD_ERROR_BIT_OFF,CEC_STOP_RISING_ERROR_BIT_OFF); cec_reception_tolerance_disable(); /* activate CEC interrupts associated to the set of TX and RX flags */ cec_interrupt_enable(CEC_INTEN_TENDIE | CEC_INTEN_TBRIE | CEC_INTEN_RENDIE | CEC_INTEN_RBRIE); /* activate CEC interrupts associated to the set of TX and RX error */ cec_interrupt_enable(CEC_INTEN_ROIE | CEC_INTEN_RBREIE | CEC_INTEN_RSBPEIE | CEC_INTEN_RLBPEIE | CEC_INTEN_RAEIE | CEC_INTEN_LSTARBIE | CEC_INTEN_TUIE | CEC_INTEN_TERRIE | CEC_INTEN_TAERRIE ); /* enable CEC */ cec_enable(); }
void hdmirx_hw_config(void) { hdmirx_print("%s %d\n", __func__, rx.port); WRITE_CBUS_REG(RESET0_REGISTER, 0x8); //reset HDMIRX module mdelay(10); clk_init(); hdmirx_wr_top(HDMIRX_TOP_INTR_MASKN, 0); //disable top interrupt gate control_reset(0); hdmirx_wr_top( HDMIRX_TOP_PORT_SEL, (1<<rx.port)); //EDID port select hdmirx_interrupts_cfg(false); //disable dwc interrupt if(hdcp_enable){ hdmi_rx_ctrl_hdcp_config(&rx.hdcp); } else { hdmirx_wr_bits_dwc( RA_HDCP_CTRL, HDCP_ENABLE, 0); } /*phy config*/ //hdmirx_phy_restart(); //hdmi_rx_phy_fast_switching(1); phy_init(rx.port, 0); //port, dcm /**/ /* control config */ control_init(rx.port); audio_init(); packet_init(); hdmirx_audio_fifo_rst(); hdmirx_packet_fifo_rst(); /**/ control_reset(1); /*enable irq */ hdmirx_wr_top(HDMIRX_TOP_INTR_STAT_CLR, ~0); hdmirx_wr_top(HDMIRX_TOP_INTR_MASKN, 0x00001fff); hdmirx_interrupts_hpd(true); /**/ #ifndef USE_GPIO_FOR_HPD hdmi_rx_ctrl_hpd(true); hdmirx_wr_top( HDMIRX_TOP_HPD_PWR5V, (1<<5)|(1<<4)); //invert HDP output #endif /* wait at least 4 video frames (at 24Hz) : 167ms for the mode detection recover the video mode */ mdelay(200); /* Check If HDCP engine is in Idle state, if not wait for authentication time. 200ms is enough if no Ri errors */ if (hdmirx_rd_dwc(0xe0) != 0) { mdelay(200); } #if CEC_FUNC_ENABLE cec_init(); #endif }
int main(int argc, char* argv[]) { CONFIGURATION config; config_parse(argc, argv, &config); if (config.action == NULL || strcmp("help", config.action) == 0) help(); enum platform system = platform_check(config.platform); if (system == 0) { fprintf(stderr, "Platform '%s' not found\n", config.platform); exit(-1); } if (strcmp("map", config.action) == 0) { if (config.address == NULL) { perror("No filename for mapping"); exit(-1); } udev_init(!inputAdded, config.mapping); for (int i=0;i<config.inputsCount;i++) evdev_create(config.inputs[i].path, config.inputs[i].mapping); evdev_map(config.address); exit(0); } if (config.address == NULL) { config.address = malloc(MAX_ADDRESS_SIZE); if (config.address == NULL) { perror("Not enough memory"); exit(-1); } config.address[0] = 0; gs_discover_server(config.address); if (config.address[0] == 0) { fprintf(stderr, "Autodiscovery failed. Specify an IP address next time.\n"); exit(-1); } } char host_config_file[128]; sprintf(host_config_file, "hosts/%s.conf", config.address); config_file_parse(host_config_file, &config); SERVER_DATA server; server.address = config.address; int ret; if ((ret = gs_init(&server, config.key_dir)) == GS_OUT_OF_MEMORY) { fprintf(stderr, "Not enough memory\n"); exit(-1); } else if (ret == GS_INVALID) { fprintf(stderr, "Invalid data received from server: %s\n", config.address, gs_error); exit(-1); } else if (ret != GS_OK) { fprintf(stderr, "Can't connect to server %s\n", config.address); exit(-1); } if (strcmp("list", config.action) == 0) { pair_check(&server); applist(&server); } else if (strcmp("stream", config.action) == 0) { pair_check(&server); if (IS_EMBEDDED(system)) { for (int i=0;i<config.inputsCount;i++) evdev_create(config.inputs[i].path, config.inputs[i].mapping); udev_init(!inputAdded, config.mapping); evdev_init(); #ifdef HAVE_LIBCEC cec_init(); #endif /* HAVE_LIBCEC */ } #ifdef HAVE_SDL else if (system == SDL) sdl_init(config.stream.width, config.stream.height); #endif stream(&server, &config, system); } else if (strcmp("pair", config.action) == 0) { char pin[5]; sprintf(pin, "%d%d%d%d", (int)random() % 10, (int)random() % 10, (int)random() % 10, (int)random() % 10); printf("Please enter the following PIN on the target PC: %s\n", pin); if (gs_pair(&server, &pin[0]) != GS_OK) { fprintf(stderr, "Failed to pair to server: %s\n", gs_error); } else { printf("Succesfully paired\n"); } } else if (strcmp("quit", config.action) == 0) { pair_check(&server); gs_quit_app(&server); } else fprintf(stderr, "%s is not a valid action\n", config.action); }
int main(int argc, char* argv[]) { printf("Moonlight Embedded %d.%d.%d (%s)\n", VERSION_MAJOR, VERSION_MINOR, VERSION_PATCH, COMPILE_OPTIONS); CONFIGURATION config; config_parse(argc, argv, &config); if (config.action == NULL || strcmp("help", config.action) == 0) help(); enum platform system = platform_check(config.platform); if (system == 0) { fprintf(stderr, "Platform '%s' not found\n", config.platform); exit(-1); } config.stream.supportsHevc = config.stream.supportsHevc || platform_supports_hevc(system); if (strcmp("map", config.action) == 0) { if (config.address == NULL) { perror("No filename for mapping"); exit(-1); } udev_init(!inputAdded, config.mapping); for (int i=0;i<config.inputsCount;i++) evdev_create(config.inputs[i].path, config.inputs[i].mapping); evdev_map(config.address); exit(0); } if (config.address == NULL) { config.address = malloc(MAX_ADDRESS_SIZE); if (config.address == NULL) { perror("Not enough memory"); exit(-1); } config.address[0] = 0; printf("Searching for server...\n"); gs_discover_server(config.address); if (config.address[0] == 0) { fprintf(stderr, "Autodiscovery failed. Specify an IP address next time.\n"); exit(-1); } } char host_config_file[128]; sprintf(host_config_file, "hosts/%s.conf", config.address); if (access(host_config_file, R_OK) != -1) config_file_parse(host_config_file, &config); SERVER_DATA server; server.address = config.address; printf("Connect to %s...\n", server.address); int ret; if ((ret = gs_init(&server, config.key_dir)) == GS_OUT_OF_MEMORY) { fprintf(stderr, "Not enough memory\n"); exit(-1); } else if (ret == GS_INVALID) { fprintf(stderr, "Invalid data received from server: %s\n", config.address, gs_error); exit(-1); } else if (ret == GS_UNSUPPORTED_VERSION) { if (!config.unsupported_version) { fprintf(stderr, "Unsupported version: %s\n", gs_error); exit(-1); } } else if (ret != GS_OK) { fprintf(stderr, "Can't connect to server %s\n", config.address); exit(-1); } printf("NVIDIA %s, GFE %s (protocol version %d)\n", server.gpuType, server.gfeVersion, server.serverMajorVersion); if (strcmp("list", config.action) == 0) { pair_check(&server); applist(&server); } else if (strcmp("stream", config.action) == 0) { pair_check(&server); if (IS_EMBEDDED(system)) { for (int i=0;i<config.inputsCount;i++) { printf("Add input %s (mapping %s)...\n", config.inputs[i].path, config.inputs[i].mapping); evdev_create(config.inputs[i].path, config.inputs[i].mapping); } udev_init(!inputAdded, config.mapping); evdev_init(); #ifdef HAVE_LIBCEC cec_init(); #endif /* HAVE_LIBCEC */ } #ifdef HAVE_SDL else if (system == SDL) sdl_init(config.stream.width, config.stream.height, config.fullscreen); #endif stream(&server, &config, system); } else if (strcmp("pair", config.action) == 0) { char pin[5]; sprintf(pin, "%d%d%d%d", (int)random() % 10, (int)random() % 10, (int)random() % 10, (int)random() % 10); printf("Please enter the following PIN on the target PC: %s\n", pin); if (gs_pair(&server, &pin[0]) != GS_OK) { fprintf(stderr, "Failed to pair to server: %s\n", gs_error); } else { printf("Succesfully paired\n"); } } else if (strcmp("unpair", config.action) == 0) { if (gs_unpair(&server) != GS_OK) { fprintf(stderr, "Failed to unpair to server: %s\n", gs_error); } else { printf("Succesfully unpaired\n"); } } else if (strcmp("quit", config.action) == 0) { pair_check(&server); gs_quit_app(&server); } else fprintf(stderr, "%s is not a valid action\n", config.action); }