static int sunxi_hdmi_ddc_do_command(u32 cmnd, int offset, int n) { struct sunxi_hdmi_reg * const hdmi = (struct sunxi_hdmi_reg *)SUNXI_HDMI_BASE; setbits_le32(&hdmi->ddc_fifo_ctrl, SUNXI_HDMI_DDC_FIFO_CTRL_CLEAR); writel(SUNXI_HMDI_DDC_ADDR_EDDC_SEGMENT(offset >> 8) | SUNXI_HMDI_DDC_ADDR_EDDC_ADDR | SUNXI_HMDI_DDC_ADDR_OFFSET(offset) | SUNXI_HMDI_DDC_ADDR_SLAVE_ADDR, &hdmi->ddc_addr); #ifndef CONFIG_MACH_SUN6I writel(n, &hdmi->ddc_byte_count); writel(cmnd, &hdmi->ddc_cmnd); #else writel(n << 16 | cmnd, &hdmi->ddc_cmnd); #endif setbits_le32(&hdmi->ddc_ctrl, SUNXI_HMDI_DDC_CTRL_START); return await_completion(&hdmi->ddc_ctrl, SUNXI_HMDI_DDC_CTRL_START, 0); }
static int dramc_scan_readpipe(void) { struct sunxi_dram_reg *dram = (struct sunxi_dram_reg *)SUNXI_DRAMC_BASE; u32 reg_val; /* data training trigger */ #ifdef CONFIG_SUN7I clrbits_le32(&dram->csr, DRAM_CSR_FAILED); #endif setbits_le32(&dram->ccr, DRAM_CCR_DATA_TRAINING); /* check whether data training process has completed */ await_completion(&dram->ccr, DRAM_CCR_DATA_TRAINING); /* check data training result */ reg_val = readl(&dram->csr); if (reg_val & DRAM_CSR_FAILED) return -1; return 0; }
int main() { int COMportNum; char COMportName[256]="COM5", tmpChar; portstream_fd COMstream; #ifdef _UNIX char COMportPrefix[10] = "/dev/cua"; #else char COMportPrefix[10] = "COM"; #endif int UID_index; unsigned char UID; int command_count; signed short int ppos, tpos; unsigned short int uval; int status; /* parse the input arguments */ printf("\n\n\n****** PAN-TILT BINARY NETWORKING TEST PROGRAM, %s\n", NET_TEST_CODE_VERSION); printf("****** Serial Port Interface Driver, %s\n", SERIAL_CODE_VERSION); printf("****** (c)1999, Directed Perception, Inc. All Rights Reserved.\n"); COMportName[0] = ' '; while (COMportName[0] == ' ') { printf("\nEnter the %s port number the PTU is attached to: ", COMportPrefix); scanf("%d", &COMportNum); printf("You selected %s%d. Is this OK? (enter 'y' or 'n'): ", COMportPrefix, COMportNum); tmpChar = 'f'; while ( (tmpChar != 'y') && (tmpChar != 'n') ) tmpChar = ((char) tolower(getchar())); if ( tmpChar == 'y' ) sprintf(COMportName, "%s%d", COMportPrefix, COMportNum); } /* initialize the serial port */ COMstream = open_host_port(COMportName); if ( COMstream == PORT_NOT_OPENED ) { printf("\nSerial Port setup error.\n"); goto abnormal_exit; } printf("\nSerial port %s initialized\n", COMportName); /* now initialize the parse state of all the networked PTUs */ printf("\n\n\nBEGINNING: INITIALIZING NETWORKED PTU PARSE STATES\n\n"); for (UID_index=0; UID_index < NUMBER_OF_NETWORKED_PTUs; UID_index++) { UID = PTU_units_list[UID_index]; if (select_unit(UID)) { printf("\n\n<<< selected UID=%d... ", UID); if ( (status=reset_PTU_parser(5000)) != PTU_OK ) { printf("\nError: reset_PTU_parser returned %d\n", status); goto abnormal_exit; } uval = 2500; set_desired(PAN, SPEED, (PTU_PARM_PTR *) &uval, ABSOLUTE); set_desired(TILT, SPEED, (PTU_PARM_PTR *) &uval, ABSOLUTE); printf(">>>\n\n"); } } printf("\n\nENDED: INITIALIZING NETWORKED PTU PARSE STATES\n\n\n"); /* now command each of the networked PTUs in sequence to test network functionality */ printf("\n\n\nBEGINNING: EXERCISING NETWORKED PTUS\n\n"); for (command_count=0, ppos=3000, tpos=600; command_count<5; command_count++, ppos=-ppos, tpos=-tpos) { printf("\n***\n"); for (UID_index=0; UID_index < NUMBER_OF_NETWORKED_PTUs; UID_index++) { UID = PTU_units_list[UID_index]; if (select_unit(UID)) { printf("\nselected UID=%d... ", UID); set_desired(PAN, POSITION, (PTU_PARM_PTR *) &ppos, ABSOLUTE); set_desired(TILT, POSITION, (PTU_PARM_PTR *) &tpos, ABSOLUTE); await_completion(); printf(" %d ", command_count); } } } for (UID_index=0, ppos=0, tpos=0; UID_index < NUMBER_OF_NETWORKED_PTUs; UID_index++, ppos=-ppos, tpos=-tpos) { UID = PTU_units_list[UID_index]; if (select_unit(UID)) { set_desired(PAN, POSITION, (PTU_PARM_PTR *) &ppos, ABSOLUTE); set_desired(TILT, POSITION, (PTU_PARM_PTR *) &tpos, ABSOLUTE); await_completion(); }} printf("\n\nENDED: EXERCISING NETWORKED PTUS\n\n\n"); /* now command each of the networked PTUs to test network functionality */ printf("\n\n\nBEGINNING: EXERCISING NETWORKED PTUS\n\n"); for (UID_index=0; UID_index < NUMBER_OF_NETWORKED_PTUs; UID_index++) { UID = PTU_units_list[UID_index]; if (select_unit(UID)) { printf("\n\n<<< selected UID=%d... ", UID); for (command_count=0, ppos=3000, tpos=1000; command_count<NUMBER_OF_COMMANDS; command_count++, ppos=-ppos, tpos=-tpos) { set_desired(PAN, POSITION, (PTU_PARM_PTR *) &ppos, ABSOLUTE); set_desired(TILT, POSITION, (PTU_PARM_PTR *) &tpos, ABSOLUTE); await_completion(); printf(" %d ", command_count); } ppos=0; tpos=0; set_desired(PAN, POSITION, (PTU_PARM_PTR *) &ppos, ABSOLUTE); set_desired(TILT, POSITION, (PTU_PARM_PTR *) &tpos, ABSOLUTE); await_completion(); printf("\n>>>\n\n"); }} printf("\n\nENDED: EXERCISING NETWORKED PTUS\n\n\n"); /* rehome the PTU */ set_mode(DEFAULTS, RESTORE_SAVED_SETTINGS); await_completion(); goto exit; abnormal_exit: printf("\nABNORMAL EXIT: test failed\n\n"); exit: /* FlushInputBuffer(); */ close_host_port(COMstream); printf("(Enter any key to exit): "); getchar(); return(TRUE); }
static int sunxi_hdmi_edid_get_mode(struct ctfb_res_modes *mode) { struct edid1_info edid1; struct edid_cea861_info cea681[4]; struct edid_detailed_timing *t = (struct edid_detailed_timing *)edid1.monitor_details.timing; struct sunxi_hdmi_reg * const hdmi = (struct sunxi_hdmi_reg *)SUNXI_HDMI_BASE; struct sunxi_ccm_reg * const ccm = (struct sunxi_ccm_reg *)SUNXI_CCM_BASE; int i, r, ext_blocks = 0; /* SUNXI_HDMI_CTRL_ENABLE & PAD_CTRL0 are already set by hpd_detect */ writel(SUNXI_HDMI_PAD_CTRL1 | SUNXI_HDMI_PAD_CTRL1_HALVE, &hdmi->pad_ctrl1); writel(SUNXI_HDMI_PLL_CTRL | SUNXI_HDMI_PLL_CTRL_DIV(15), &hdmi->pll_ctrl); writel(SUNXI_HDMI_PLL_DBG0_PLL3, &hdmi->pll_dbg0); /* Reset i2c controller */ setbits_le32(&ccm->hdmi_clk_cfg, CCM_HDMI_CTRL_DDC_GATE); writel(SUNXI_HMDI_DDC_CTRL_ENABLE | SUNXI_HMDI_DDC_CTRL_SDA_ENABLE | SUNXI_HMDI_DDC_CTRL_SCL_ENABLE | SUNXI_HMDI_DDC_CTRL_RESET, &hdmi->ddc_ctrl); if (await_completion(&hdmi->ddc_ctrl, SUNXI_HMDI_DDC_CTRL_RESET, 0)) return -EIO; writel(SUNXI_HDMI_DDC_CLOCK, &hdmi->ddc_clock); #ifndef CONFIG_MACH_SUN6I writel(SUNXI_HMDI_DDC_LINE_CTRL_SDA_ENABLE | SUNXI_HMDI_DDC_LINE_CTRL_SCL_ENABLE, &hdmi->ddc_line_ctrl); #endif r = sunxi_hdmi_edid_get_block(0, (u8 *)&edid1); if (r == 0) { r = edid_check_info(&edid1); if (r) { printf("EDID: invalid EDID data\n"); r = -EINVAL; } } if (r == 0) { ext_blocks = edid1.extension_flag; if (ext_blocks > 4) ext_blocks = 4; for (i = 0; i < ext_blocks; i++) { if (sunxi_hdmi_edid_get_block(1 + i, (u8 *)&cea681[i]) != 0) { ext_blocks = i; break; } } } /* Disable DDC engine, no longer needed */ clrbits_le32(&hdmi->ddc_ctrl, SUNXI_HMDI_DDC_CTRL_ENABLE); clrbits_le32(&ccm->hdmi_clk_cfg, CCM_HDMI_CTRL_DDC_GATE); if (r) return r; /* We want version 1.3 or 1.2 with detailed timing info */ if (edid1.version != 1 || (edid1.revision < 3 && !EDID1_INFO_FEATURE_PREFERRED_TIMING_MODE(edid1))) { printf("EDID: unsupported version %d.%d\n", edid1.version, edid1.revision); return -EINVAL; } /* Take the first usable detailed timing */ for (i = 0; i < 4; i++, t++) { r = video_edid_dtd_to_ctfb_res_modes(t, mode); if (r == 0) break; } if (i == 4) { printf("EDID: no usable detailed timing found\n"); return -ENOENT; } /* Check for basic audio support, if found enable hdmi output */ sunxi_display.monitor = sunxi_monitor_dvi; for (i = 0; i < ext_blocks; i++) { if (cea681[i].extension_tag != EDID_CEA861_EXTENSION_TAG || cea681[i].revision < 2) continue; if (EDID_CEA861_SUPPORTS_BASIC_AUDIO(cea681[i])) sunxi_display.monitor = sunxi_monitor_hdmi; } return 0; }