Lines Matching refs:edid
55 #define version_greater(edid, maj, min) \
56 (((edid)->version > (maj)) || \
57 ((edid)->version == (maj) && (edid)->revision > (min)))
64 * EDID blocks out in the wild have a variety of bugs, try to collect
99 struct edid *edid;
176 /* Rotel RSX-1058 forwards sink's EDID but only does HDMI 1.1*/
590 * modes are old-school Mac modes. The EDID spec says the 1152x864@75 mode
1570 * drm_edid_header_is_valid - sanity check the header of the base EDID block
1571 * @raw_edid: pointer to raw base EDID block
1573 * Sanity check the header of the base EDID block.
1592 "Minimum number of valid EDID header bytes (0-8, default 6)");
1595 struct edid *edid);
1617 * drm_edid_block_valid - Sanity check the EDID block (base or extension)
1618 * @raw_edid: pointer to raw EDID block
1620 * @print_bad_edid: if true, dump bad EDID blocks to the console
1623 * Validate a base or extension EDID block and optionally dump bad blocks to
1632 struct edid *edid = (struct edid *)raw_edid;
1653 DRM_DEBUG("Fixing EDID header, your hardware may be failing\n");
1669 DRM_DEBUG("EDID checksum is invalid, remainder is %d\n", csum);
1673 DRM_NOTE("EDID checksum is invalid, remainder is %d\n", csum);
1682 if (edid->version != 1) {
1683 DRM_NOTE("EDID has major version %d, instead of 1\n", edid->version);
1687 if (edid->revision > 4)
1688 DRM_DEBUG("EDID minor > 4, assuming backward compatibility\n");
1700 pr_notice("EDID block is all zeroes\n");
1702 pr_notice("Raw EDID:\n");
1713 * drm_edid_is_valid - sanity check EDID data
1714 * @edid: EDID data
1716 * Sanity-check an entire EDID record (including extensions)
1718 * Return: True if the EDID data is valid, false otherwise.
1720 bool drm_edid_is_valid(struct edid *edid)
1723 u8 *raw = (u8 *)edid;
1725 if (!edid)
1728 for (i = 0; i <= edid->extensions; i++)
1738 * drm_do_probe_ddc_edid() - get EDID information via I2C
1740 * @buf: EDID data buffer to be filled
1741 * @block: 128 byte EDID block to start fetching from
1742 * @len: EDID data buffer length to fetch
1744 * Try to fetch EDID information by calling I2C driver functions.
1801 u8 *edid, int num_blocks)
1809 "%s: EDID is invalid:\n",
1812 u8 *block = edid + i * EDID_LENGTH;
1828 /* Get override or firmware EDID */
1829 static struct edid *drm_get_override_edid(struct drm_connector *connector)
1831 struct edid *override = NULL;
1843 * drm_add_override_edid_modes - add modes from override/firmware EDID
1846 * Add modes from the override/firmware EDID, if available. Only to be used from
1848 * failed during drm_get_edid() and caused the override/firmware EDID to be
1855 struct edid *override;
1864 DRM_DEBUG_KMS("[CONNECTOR:%d:%s] adding %d modes via fallback override/firmware EDID\n",
1873 * drm_do_get_edid - get EDID data using a custom EDID block read function
1875 * @get_edid_block: EDID block read function
1879 * exposes a different interface to read EDID blocks this function can be used
1880 * to get EDID data using a custom block read function.
1886 * The EDID may be overridden using debugfs override_edid or firmare EDID
1888 * order. Having either of them bypasses actual EDID reads.
1890 * Return: Pointer to valid EDID or NULL if we couldn't find any.
1892 struct edid *drm_do_get_edid(struct drm_connector *connector,
1898 u8 *edid, *new;
1899 struct edid *override;
1905 if ((edid = kmalloc(EDID_LENGTH, GFP_KERNEL)) == NULL)
1910 if (get_edid_block(data, edid, 0, EDID_LENGTH))
1912 if (drm_edid_block_valid(edid, 0, false,
1915 if (i == 0 && drm_edid_is_zero(edid, EDID_LENGTH)) {
1924 valid_extensions = edid[0x7e];
1926 return (struct edid *)edid;
1928 new = krealloc(edid, (valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL);
1931 edid = new;
1933 for (j = 1; j <= edid[0x7e]; j++) {
1934 u8 *block = edid + j * EDID_LENGTH;
1947 if (valid_extensions != edid[0x7e]) {
1950 connector_bad_edid(connector, edid, edid[0x7e] + 1);
1952 edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions;
1953 edid[0x7e] = valid_extensions;
1961 for (i = 0; i <= edid[0x7e]; i++) {
1962 u8 *block = edid + i * EDID_LENGTH;
1971 kfree(edid);
1972 edid = new;
1975 return (struct edid *)edid;
1978 connector_bad_edid(connector, edid, 1);
1980 kfree(edid);
2001 * drm_get_edid - get EDID data, if available
2005 * Poke the given I2C channel to grab EDID data if possible. If found,
2008 * Return: Pointer to valid EDID or NULL if we couldn't find any.
2010 struct edid *drm_get_edid(struct drm_connector *connector,
2013 struct edid *edid;
2021 edid = drm_do_get_edid(connector, drm_do_probe_ddc_edid, adapter);
2022 if (edid)
2023 drm_get_displayid(connector, edid);
2024 return edid;
2029 * drm_get_edid_switcheroo - get EDID data for a vga_switcheroo output
2035 * switch DDC to the GPU which is retrieving EDID.
2037 * Return: Pointer to valid EDID or %NULL if we couldn't find any.
2039 struct edid *drm_get_edid_switcheroo(struct drm_connector *connector,
2045 struct edid *edid;
2050 edid = drm_get_edid(connector, adapter);
2055 return edid;
2060 * drm_edid_duplicate - duplicate an EDID and the extensions
2061 * @edid: EDID to duplicate
2063 * Return: Pointer to duplicated EDID or NULL on allocation failure.
2065 struct edid *drm_edid_duplicate(const struct edid *edid)
2067 return kmemdup(edid, (edid->extensions + 1) * EDID_LENGTH, GFP_KERNEL);
2071 /*** EDID parsing ***/
2074 * edid_vendor - match a string against EDID's obfuscated vendor field
2075 * @edid: EDID to match
2078 * Returns true if @vendor is in @edid, false otherwise
2080 static bool edid_vendor(const struct edid *edid, const char *vendor)
2084 edid_vendor[0] = ((edid->mfg_id[0] & 0x7c) >> 2) + '@';
2085 edid_vendor[1] = (((edid->mfg_id[0] & 0x3) << 3) |
2086 ((edid->mfg_id[1] & 0xe0) >> 5)) + '@';
2087 edid_vendor[2] = (edid->mfg_id[1] & 0x1f) + '@';
2093 * edid_get_quirks - return quirk flags for a given EDID
2094 * @edid: EDID to process
2098 static u32 edid_get_quirks(const struct edid *edid)
2106 if (edid_vendor(edid, quirk->vendor) &&
2107 (EDID_PRODUCT_ID(edid) == quirk->product_id))
2244 struct edid *edid = (struct edid *)raw_edid;
2246 if (edid == NULL)
2250 cb(&(edid->detailed_timings[i]), closure);
2276 /* EDID 1.4 defines this explicitly. For EDID 1.3, we guess, badly. */
2278 drm_monitor_supports_rb(struct edid *edid)
2280 if (edid->revision >= 4) {
2282 drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
2286 return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);
2299 drm_gtf2_hbreak(struct edid *edid)
2302 drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
2307 drm_gtf2_2c(struct edid *edid)
2310 drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
2315 drm_gtf2_m(struct edid *edid)
2318 drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
2323 drm_gtf2_k(struct edid *edid)
2326 drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
2331 drm_gtf2_2j(struct edid *edid)
2334 drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
2340 * @edid: EDID block to scan
2342 static int standard_timing_level(struct edid *edid)
2344 if (edid->revision >= 2) {
2345 if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF))
2347 if (drm_gtf2_hbreak(edid))
2349 if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)
2369 * @connector: connector of for the EDID block
2370 * @edid: EDID block to scan
2377 drm_mode_std(struct drm_connector *connector, struct edid *edid,
2388 int timing_level = standard_timing_level(edid);
2393 /* According to the EDID spec, the hdisplay = hsize * 8 + 248 */
2399 if (edid->revision < 3)
2442 if (drm_monitor_supports_rb(edid)) {
2468 if (drm_mode_hsync(mode) > drm_gtf2_hbreak(edid)) {
2472 drm_gtf2_m(edid),
2473 drm_gtf2_2c(edid),
2474 drm_gtf2_k(edid),
2475 drm_gtf2_2j(edid));
2487 * EDID is delightfully ambiguous about how interlaced modes are to be
2529 * drm_mode_detailed - create a new mode from an EDID detailed timing section
2531 * @edid: EDID block
2532 * @timing: EDID detailed timing info
2535 * An EDID detailed timing block contains enough info for us to create and
2539 struct edid *edid,
2627 mode->width_mm = edid->width_cm * 10;
2628 mode->height_mm = edid->height_cm * 10;
2640 struct edid *edid, u8 *t)
2645 if (edid->revision >= 4)
2648 if (edid->revision >= 4)
2657 struct edid *edid, u8 *t)
2662 if (edid->revision >= 4)
2665 if (edid->revision >= 4)
2673 range_pixel_clock(struct edid *edid, u8 *t)
2680 if (edid->revision >= 4 && t[10] == 0x04)
2688 mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
2694 if (!mode_in_hsync_range(mode, edid, t))
2697 if (!mode_in_vsync_range(mode, edid, t))
2700 if ((max_clock = range_pixel_clock(edid, t)))
2705 if (edid->revision >= 4 && t[10] == 0x04)
2709 if (mode_is_rb(mode) && !drm_monitor_supports_rb(edid))
2734 drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid,
2742 if (mode_in_range(drm_dmt_modes + i, edid, timing) &&
2769 drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
2783 if (!mode_in_range(newmode, edid, timing) ||
2797 drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
2803 bool rb = drm_monitor_supports_rb(edid);
2812 if (!mode_in_range(newmode, edid, timing) ||
2836 closure->edid,
2839 if (!version_greater(closure->edid, 1, 1))
2846 closure->edid,
2850 if (!version_greater(closure->edid, 1, 3))
2854 closure->edid,
2864 add_inferred_modes(struct drm_connector *connector, struct edid *edid)
2868 .edid = edid,
2871 if (version_greater(edid, 1, 0))
2872 drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
2918 * add_established_modes - get est. modes from EDID and add them
2920 * @edid: EDID block to scan
2922 * Each EDID block contains a bitmap of the supported "established modes" list
2926 add_established_modes(struct drm_connector *connector, struct edid *edid)
2929 unsigned long est_bits = edid->established_timings.t1 |
2930 (edid->established_timings.t2 << 8) |
2931 ((edid->established_timings.mfg_rsvd & 0x80) << 9);
2935 .edid = edid,
2949 if (version_greater(edid, 1, 0))
2950 drm_for_each_detailed_block((u8 *)edid,
2962 struct edid *edid = closure->edid;
2971 newmode = drm_mode_std(connector, edid, std);
2981 * add_standard_modes - get std. modes from EDID and add them
2983 * @edid: EDID block to scan
2986 * GTF or CVT. Grab them from @edid and add them to the list.
2989 add_standard_modes(struct drm_connector *connector, struct edid *edid)
2994 .edid = edid,
3000 newmode = drm_mode_std(connector, edid,
3001 &edid->standard_timings[i]);
3008 if (version_greater(edid, 1, 0))
3009 drm_for_each_detailed_block((u8 *)edid, do_standard_modes,
3077 add_cvt_modes(struct drm_connector *connector, struct edid *edid)
3081 .edid = edid,
3084 if (version_greater(edid, 1, 2))
3085 drm_for_each_detailed_block((u8 *)edid, do_cvt_mode, &closure);
3102 closure->edid, timing,
3126 * @edid: EDID block to scan
3130 add_detailed_modes(struct drm_connector *connector, struct edid *edid,
3135 .edid = edid,
3140 if (closure.preferred && !version_greater(edid, 1, 3))
3142 (edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING);
3144 drm_for_each_detailed_block((u8 *)edid, do_detailed_mode, &closure);
3164 * Search EDID for CEA extension block.
3166 static const u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
3171 /* No EDID or EDID extensions */
3172 if (edid == NULL || edid->extensions == 0)
3176 for (i = 0; i < edid->extensions; i++) {
3177 edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
3182 if (i == edid->extensions)
3189 static const u8 *drm_find_displayid_extension(const struct edid *edid)
3191 return drm_find_edid_extension(edid, DISPLAYID_EXT);
3194 static const u8 *drm_find_cea_extension(const struct edid *edid)
3204 cea = drm_find_edid_extension(edid, CEA_EXT);
3209 displayid = drm_find_displayid_extension(edid);
3487 add_alternate_cea_modes(struct drm_connector *connector, struct edid *edid)
3495 if (!drm_find_cea_extension(edid))
3976 /* DisplayID CTA extension blocks and top-level CEA EDID
3986 * CEA EDID block defines byte 2 as:
4127 add_cea_modes(struct drm_connector *connector, struct edid *edid)
4129 const u8 *cea = drm_find_cea_extension(edid);
4154 /* Add 4:2:0(only) modes present in EDID */
4306 static int get_monitor_name(struct edid *edid, char name[13])
4311 if (!edid || !name)
4314 drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
4326 * drm_edid_get_monitor_name - fetch the monitor name from the edid
4327 * @edid: monitor EDID information
4332 void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize)
4340 name_length = min(get_monitor_name(edid, buf), bufsize - 1);
4359 * drm_edid_to_eld - build ELD from EDID
4361 * @edid: EDID to parse
4363 * Fill the ELD (EDID-Like Data) buffer for passing to the audio driver. The
4366 static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
4377 if (!edid)
4380 cea = drm_find_cea_extension(edid);
4386 mnl = get_monitor_name(edid, &eld[DRM_ELD_MONITOR_NAME_STRING]);
4394 eld[DRM_ELD_MANUFACTURER_NAME0] = edid->mfg_id[0];
4395 eld[DRM_ELD_MANUFACTURER_NAME1] = edid->mfg_id[1];
4396 eld[DRM_ELD_PRODUCT_CODE0] = edid->prod_code[0];
4397 eld[DRM_ELD_PRODUCT_CODE1] = edid->prod_code[1];
4453 * drm_edid_to_sad - extracts SADs from EDID
4454 * @edid: EDID to parse
4457 * Looks for CEA EDID block and extracts SADs (Short Audio Descriptors) from it.
4463 int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
4469 cea = drm_find_cea_extension(edid);
4513 * drm_edid_to_speaker_allocation - extracts Speaker Allocation Data Blocks from EDID
4514 * @edid: EDID to parse
4517 * Looks for CEA EDID block and extracts the Speaker Allocation Data Block from it.
4524 int drm_edid_to_speaker_allocation(struct edid *edid, u8 **sadb)
4530 cea = drm_find_cea_extension(edid);
4596 * Convert raw EDID values to millisecond.
4610 * @edid: monitor EDID information
4616 bool drm_detect_hdmi_monitor(struct edid *edid)
4622 edid_ext = drm_find_cea_extension(edid);
4644 * @edid: EDID block to scan
4650 * audio' is not defined in EDID.
4654 bool drm_detect_monitor_audio(struct edid *edid)
4661 edid_ext = drm_find_cea_extension(edid);
4746 * * Availability of a HF-VSDB block in EDID (check)
4862 const struct edid *edid)
4868 edid_ext = drm_find_cea_extension(edid);
4900 /* A connector has no EDID information, so we've got no EDID to compute quirks from. Reset
4901 * all of the values which would have been set from EDID
4923 u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edid)
4927 u32 quirks = edid_get_quirks(edid);
4931 info->width_mm = edid->width_cm * 10;
4932 info->height_mm = edid->height_cm * 10;
4938 if (edid->revision < 3)
4941 if (!(edid->input & DRM_EDID_INPUT_DIGITAL))
4944 drm_parse_cea_ext(connector, edid);
4947 * Digital sink with "DFP 1.x compliant TMDS" according to EDID 1.3?
4949 * For such displays, the DFP spec 1.0, section 3.10 "EDID support"
4950 * tells us to assume 8 bpc color depth if the EDID doesn't have
4953 if (info->bpc == 0 && edid->revision == 3 &&
4954 edid->input & DRM_EDID_DIGITAL_DFP_1_X) {
4961 if (edid->revision < 4)
4964 switch (edid->input & DRM_EDID_DIGITAL_DEPTH_MASK) {
4989 DRM_DEBUG("%s: Assigning EDID-1.4 digital sink color depth as %d bpc.\n",
4993 if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB444)
4995 if (edid->features & DRM_EDID_FEATURE_RGB_YCRCB422)
5095 struct edid *edid)
5104 displayid = drm_find_displayid_extension(edid);
5124 * drm_add_edid_modes - add modes from EDID data, if available
5126 * @edid: EDID data
5130 * can be derived from the edid.
5134 int drm_add_edid_modes(struct drm_connector *connector, struct edid *edid)
5139 if (edid == NULL) {
5143 if (!drm_edid_is_valid(edid)) {
5145 dev_warn(connector->dev->dev, "%s: EDID invalid.\n",
5150 drm_edid_to_eld(connector, edid);
5157 quirks = drm_add_display_info(connector, edid);
5160 * EDID spec says modes should be preferred in this order:
5173 num_modes += add_detailed_modes(connector, edid, quirks);
5174 num_modes += add_cvt_modes(connector, edid);
5175 num_modes += add_standard_modes(connector, edid);
5176 num_modes += add_established_modes(connector, edid);
5177 num_modes += add_cea_modes(connector, edid);
5178 num_modes += add_alternate_cea_modes(connector, edid);
5179 num_modes += add_displayid_detailed_modes(connector, edid);
5180 if (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF)
5181 num_modes += add_inferred_modes(connector, edid);
5203 * drm_add_modes_noedid - add modes for the connectors without EDID
5760 /* if this is an EDID extension the first byte will be 0x70 */
5798 struct edid *edid)
5803 displayid = drm_find_displayid_extension(edid);