int edid_get_ranges(struct edid1_info *edid, unsigned int *hmin, unsigned int *hmax, unsigned int *vmin, unsigned int *vmax) { int i; struct edid_monitor_descriptor *monitor; *hmin = *hmax = *vmin = *vmax = 0; if (edid_check_info(edid)) return -1; for (i = 0; i < ARRAY_SIZE(edid->monitor_details.descriptor); i++) { monitor = &edid->monitor_details.descriptor[i]; if (monitor->type == EDID_MONITOR_DESCRIPTOR_RANGE) { *hmin = monitor->data.range_data.horizontal_min; *hmax = monitor->data.range_data.horizontal_max; *vmin = monitor->data.range_data.vertical_min; *vmax = monitor->data.range_data.vertical_max; return 0; } } return -1; }
void edid_print_info(struct edid1_info *edid_info) { int i; char manufacturer[4]; unsigned int have_timing = 0; uint32_t serial_number; if (edid_check_info(edid_info)) { printf("Not a valid EDID\n"); return; } printf("EDID version: %d.%d\n", edid_info->version, edid_info->revision); printf("Product ID code: %04x\n", EDID1_INFO_PRODUCT_CODE(*edid_info)); edid_get_manufacturer_name(edid_info, manufacturer); printf("Manufacturer: %s\n", manufacturer); serial_number = EDID1_INFO_SERIAL_NUMBER(*edid_info); if (serial_number != 0xffffffff) { if (strcmp(manufacturer, "MAG") == 0) serial_number -= 0x7000000; if (strcmp(manufacturer, "OQI") == 0) serial_number -= 456150000; if (strcmp(manufacturer, "VSC") == 0) serial_number -= 640000000; } printf("Serial number: %08x\n", serial_number); printf("Manufactured in week: %d year: %d\n", edid_info->week, edid_info->year + 1990); printf("Video input definition: %svoltage level %d%s%s%s%s%s\n", EDID1_INFO_VIDEO_INPUT_DIGITAL(*edid_info) ? "digital signal, " : "analog signal, ", EDID1_INFO_VIDEO_INPUT_VOLTAGE_LEVEL(*edid_info), EDID1_INFO_VIDEO_INPUT_BLANK_TO_BLACK(*edid_info) ? ", blank to black" : "", EDID1_INFO_VIDEO_INPUT_SEPARATE_SYNC(*edid_info) ? ", separate sync" : "", EDID1_INFO_VIDEO_INPUT_COMPOSITE_SYNC(*edid_info) ? ", composite sync" : "", EDID1_INFO_VIDEO_INPUT_SYNC_ON_GREEN(*edid_info) ? ", sync on green" : "", EDID1_INFO_VIDEO_INPUT_SERRATION_V(*edid_info) ? ", serration v" : ""); printf("Monitor is %s\n", EDID1_INFO_FEATURE_RGB(*edid_info) ? "RGB" : "non-RGB"); printf("Maximum visible display size: %d cm x %d cm\n", edid_info->max_size_horizontal, edid_info->max_size_vertical); printf("Power management features: %s%s, %s%s, %s%s\n", EDID1_INFO_FEATURE_ACTIVE_OFF(*edid_info) ? "" : "no ", "active off", EDID1_INFO_FEATURE_SUSPEND(*edid_info) ? "" : "no ", "suspend", EDID1_INFO_FEATURE_STANDBY(*edid_info) ? "" : "no ", "standby"); printf("Estabilished timings:\n"); if (EDID1_INFO_ESTABLISHED_TIMING_720X400_70(*edid_info)) printf("\t720x400\t\t70 Hz (VGA 640x400, IBM)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_720X400_88(*edid_info)) printf("\t720x400\t\t88 Hz (XGA2)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_640X480_60(*edid_info)) printf("\t640x480\t\t60 Hz (VGA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_640X480_67(*edid_info)) printf("\t640x480\t\t67 Hz (Mac II, Apple)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_640X480_72(*edid_info)) printf("\t640x480\t\t72 Hz (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_640X480_75(*edid_info)) printf("\t640x480\t\t75 Hz (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_800X600_56(*edid_info)) printf("\t800x600\t\t56 Hz (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_800X600_60(*edid_info)) printf("\t800x600\t\t60 Hz (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_800X600_72(*edid_info)) printf("\t800x600\t\t72 Hz (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_800X600_75(*edid_info)) printf("\t800x600\t\t75 Hz (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_832X624_75(*edid_info)) printf("\t832x624\t\t75 Hz (Mac II)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_1024X768_87I(*edid_info)) printf("\t1024x768\t87 Hz Interlaced (8514A)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_1024X768_60(*edid_info)) printf("\t1024x768\t60 Hz (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_1024X768_70(*edid_info)) printf("\t1024x768\t70 Hz (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_1024X768_75(*edid_info)) printf("\t1024x768\t75 Hz (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_1280X1024_75(*edid_info)) printf("\t1280x1024\t75 (VESA)\n"); if (EDID1_INFO_ESTABLISHED_TIMING_1152X870_75(*edid_info)) printf("\t1152x870\t75 (Mac II)\n"); /* Standard timings. */ printf("Standard timings:\n"); for (i = 0; i < ARRAY_SIZE(edid_info->standard_timings); i++) { unsigned int aspect = 10000; unsigned int x, y; unsigned char xres, vfreq; xres = EDID1_INFO_STANDARD_TIMING_XRESOLUTION(*edid_info, i); vfreq = EDID1_INFO_STANDARD_TIMING_VFREQ(*edid_info, i); if ((xres != vfreq) || ((xres != 0) && (xres != 1)) || ((vfreq != 0) && (vfreq != 1))) { switch (EDID1_INFO_STANDARD_TIMING_ASPECT(*edid_info, i)) { case ASPECT_625: aspect = 6250; break; case ASPECT_75: aspect = 7500; break; case ASPECT_8: aspect = 8000; break; case ASPECT_5625: aspect = 5625; break; } x = (xres + 31) * 8; y = x * aspect / 10000; printf("\t%dx%d%c\t%d Hz\n", x, y, x > 1000 ? ' ' : '\t', (vfreq & 0x3f) + 60); have_timing = 1; } } /* Detailed timing information. */ for (i = 0; i < ARRAY_SIZE(edid_info->monitor_details.descriptor); i++) { edid_print_dtd(&edid_info->monitor_details.descriptor[i], &have_timing); } if (!have_timing) printf("\tNone\n"); }
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; }