Lines Matching refs:mode
53 * drm_mode_debug_printmodeline - print a mode to dmesg
54 * @mode: mode to print
56 * Describe @mode using DRM_DEBUG.
58 void drm_mode_debug_printmodeline(const struct drm_display_mode *mode)
60 DRM_DEBUG_KMS("Modeline " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode));
65 * drm_mode_create - create a new display mode
72 * Pointer to new mode on success, NULL on error.
87 * drm_mode_destroy - remove a mode
89 * @mode: mode to remove
91 * Release @mode's unique ID, then free it @mode structure itself using kfree.
93 void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
95 if (!mode)
98 kfree(mode);
103 * drm_mode_probed_add - add a mode to a connector's probed_mode list
104 * @connector: connector the new mode
105 * @mode: mode data
107 * Add @mode to @connector's probed_mode list for later use. This list should
112 struct drm_display_mode *mode)
116 list_add_tail(&mode->head, &connector->probed_modes);
326 struct drm_display_mode *mode,
349 "Generating a %ux%u%c, %u-line mode with a %lu kHz clock\n",
357 drm_dbg_kms(dev, "Trying to generate a BT.601 mode. Disabling checks.\n");
455 mode->clock = pixel_clock_hz / 1000;
456 mode->hdisplay = hactive;
457 mode->hsync_start = mode->hdisplay + hfp;
458 mode->hsync_end = mode->hsync_start + hslen;
459 mode->htotal = mode->hsync_end + hbp;
474 * Moreover, if we want to create a progressive mode for
504 mode->vdisplay = vactive;
505 mode->vsync_start = mode->vdisplay + vfp;
506 mode->vsync_end = mode->vsync_start + vslen;
507 mode->vtotal = mode->vsync_end + vbp;
509 if (mode->vtotal != params->num_lines)
512 mode->type = DRM_MODE_TYPE_DRIVER;
513 mode->flags = DRM_MODE_FLAG_NVSYNC | DRM_MODE_FLAG_NHSYNC;
515 mode->flags |= DRM_MODE_FLAG_INTERLACE;
517 drm_mode_set_name(mode);
519 drm_dbg_kms(dev, "Generated mode " DRM_MODE_FMT "\n", DRM_MODE_ARG(mode));
525 * drm_analog_tv_mode - create a display mode for an analog TV
527 * @tv_mode: TV Mode standard to create a mode for. See DRM_MODE_TV_MODE_*.
531 * @interlace: whether to compute an interlaced mode
535 * this is DRM_MODE_TV_MODE_MONOCHROME, a 625-line mode will be created.
542 * A pointer to the mode, allocated with drm_mode_create(). Returns NULL
552 struct drm_display_mode *mode;
581 mode = drm_mode_create(dev);
582 if (!mode)
585 ret = fill_analog_mode(dev, mode,
591 return mode;
594 drm_mode_destroy(dev, mode);
606 * @interlaced: whether to compute an interlaced mode
620 * The display mode object is allocated with drm_mode_create(). Returns NULL
621 * when no mode could be allocated.
809 /* ignore - just set the mode flag for interlaced */
814 /* Fill the mode line name */
833 * @interlaced: whether to compute an interlaced mode
845 * The display mode object is allocated with drm_mode_create(). Returns NULL
846 * when no mode could be allocated.
992 /* finally, pack the results in the mode struct */
1025 * @interlaced: whether to compute an interlaced mode
1050 * The display mode object is allocated with drm_mode_create(). Returns NULL
1051 * when no mode could be allocated.
1069 * Fills out @dmode using the display mode specified in @vm.
1110 * Fills out @vm using the display mode specified in @dmode.
1184 * This function is expensive and should only be used, if only one mode is to be
1206 pr_debug("%pOF: got %dx%d display mode: " DRM_MODE_FMT "\n",
1220 * are read and set on the display mode.
1264 * drm_mode_set_name - set the name on a mode
1265 * @mode: name will be set in this mode
1267 * Set the name of @mode to a standard format which is <hdisplay>x<vdisplay>
1270 void drm_mode_set_name(struct drm_display_mode *mode)
1272 bool interlaced = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
1274 snprintf(mode->name, DRM_DISPLAY_MODE_LEN, "%dx%d%s",
1275 mode->hdisplay, mode->vdisplay,
1281 * drm_mode_vrefresh - get the vrefresh of a mode
1282 * @mode: mode
1287 int drm_mode_vrefresh(const struct drm_display_mode *mode)
1291 if (mode->htotal == 0 || mode->vtotal == 0)
1294 if (mode->flags & DRM_MODE_FLAG_INTERLACE)
1296 if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
1298 if (mode->vscan > 1)
1299 den *= mode->vscan;
1301 if (check_mul_overflow(mode->clock, num, &num))
1304 if (check_mul_overflow(mode->htotal * mode->vtotal, den, &den))
1312 * drm_mode_get_hv_timing - Fetches hdisplay/vdisplay for given mode
1313 * @mode: mode to query
1317 * The vdisplay value will be doubled if the specified mode is a stereo mode of
1320 void drm_mode_get_hv_timing(const struct drm_display_mode *mode,
1325 drm_mode_init(&adjusted, mode);
1335 * @p: mode
1413 * drm_mode_copy - copy the mode
1414 * @dst: mode to overwrite
1415 * @src: mode to copy
1417 * Copy an existing mode into another mode, preserving the
1418 * list head of the destination mode.
1430 * drm_mode_init - initialize the mode from another mode
1431 * @dst: mode to overwrite
1432 * @src: mode to copy
1434 * Copy an existing mode into another mode, zeroing the
1435 * list head of the destination mode. Typically used
1447 * drm_mode_duplicate - allocate and duplicate an existing mode
1448 * @dev: drm_device to allocate the duplicated mode for
1449 * @mode: mode to duplicate
1451 * Just allocate a new mode, copy the existing mode into it, and return
1455 * Pointer to duplicated mode on success, NULL on error.
1458 const struct drm_display_mode *mode)
1466 drm_mode_copy(nmode, mode);
1522 * @mode1: first mode
1523 * @mode2: second mode
1567 * @mode1: first mode
1568 * @mode2: second mode
1589 * @mode1: first mode
1590 * @mode2: second mode
1610 * @mode1: first mode
1611 * @mode2: second mode
1629 drm_mode_validate_basic(const struct drm_display_mode *mode)
1631 if (mode->type & ~DRM_MODE_TYPE_ALL)
1634 if (mode->flags & ~DRM_MODE_FLAG_ALL)
1637 if ((mode->flags & DRM_MODE_FLAG_3D_MASK) > DRM_MODE_FLAG_3D_MAX)
1640 if (mode->clock == 0)
1643 if (mode->hdisplay == 0 ||
1644 mode->hsync_start < mode->hdisplay ||
1645 mode->hsync_end < mode->hsync_start ||
1646 mode->htotal < mode->hsync_end)
1649 if (mode->vdisplay == 0 ||
1650 mode->vsync_start < mode->vdisplay ||
1651 mode->vsync_end < mode->vsync_start ||
1652 mode->vtotal < mode->vsync_end)
1659 * drm_mode_validate_driver - make sure the mode is somewhat sane
1661 * @mode: mode to check
1663 * First do basic validation on the mode, and then allow the driver
1668 * The mode status
1672 const struct drm_display_mode *mode)
1676 status = drm_mode_validate_basic(mode);
1681 return dev->mode_config.funcs->mode_valid(dev, mode);
1689 * @mode: mode to check
1694 * limitations of the DRM device/connector. If a mode is too big its status
1699 * The mode status
1702 drm_mode_validate_size(const struct drm_display_mode *mode,
1705 if (maxX > 0 && mode->hdisplay > maxX)
1708 if (maxY > 0 && mode->vdisplay > maxY)
1717 * @mode: mode to check
1721 * only mode, when the source doesn't support it.
1724 * The mode status
1727 drm_mode_validate_ycbcr420(const struct drm_display_mode *mode,
1731 drm_mode_is_420_only(&connector->display_info, mode))
1796 * drm_mode_prune_invalid - remove invalid modes from mode list
1801 * This helper function can be used to prune a display mode list after
1803 * removed from the list, and if @verbose the status code and mode name is also
1809 struct drm_display_mode *mode, *t;
1811 list_for_each_entry_safe(mode, t, mode_list, head) {
1812 if (mode->status != MODE_OK) {
1813 list_del(&mode->head);
1814 if (mode->type & DRM_MODE_TYPE_USERDEF) {
1815 drm_warn(dev, "User-defined mode not supported: "
1816 DRM_MODE_FMT "\n", DRM_MODE_ARG(mode));
1819 drm_dbg_kms(dev, "Rejected mode: " DRM_MODE_FMT " (%s)\n",
1820 DRM_MODE_ARG(mode), drm_get_mode_status_name(mode->status));
1822 drm_mode_destroy(dev, mode);
1831 * @lh_a: list_head for first mode
1832 * @lh_b: list_head for second mode
1865 * drm_mode_sort - sort mode list
1877 * drm_connector_list_update - update the mode list for the connector
1881 * to the actual mode list. It compares the probed mode against the current
1894 struct drm_display_mode *mode;
1897 /* go through current modes checking for the new probed mode */
1898 list_for_each_entry(mode, &connector->modes, head) {
1899 if (!drm_mode_equal(pmode, mode))
1905 * If the old matching mode is stale (ie. left over
1914 * the mode added to the probed_modes list first.
1916 if (mode->status == MODE_STALE) {
1917 drm_mode_copy(mode, pmode);
1918 } else if ((mode->type & DRM_MODE_TYPE_PREFERRED) == 0 &&
1920 pmode->type |= mode->type;
1921 drm_mode_copy(mode, pmode);
1923 mode->type |= pmode->type;
1939 struct drm_cmdline_mode *mode)
1951 mode->bpp = bpp;
1952 mode->bpp_specified = true;
1958 struct drm_cmdline_mode *mode)
1970 mode->refresh = refresh;
1971 mode->refresh_specified = true;
1979 struct drm_cmdline_mode *mode)
1989 mode->interlace = true;
1995 mode->margins = true;
1998 if (mode->force != DRM_FORCE_UNSPECIFIED)
2003 mode->force = DRM_FORCE_ON;
2005 mode->force = DRM_FORCE_ON_DIGITAL;
2008 if (mode->force != DRM_FORCE_UNSPECIFIED)
2011 mode->force = DRM_FORCE_OFF;
2014 if (mode->force != DRM_FORCE_UNSPECIFIED)
2017 mode->force = DRM_FORCE_ON;
2030 struct drm_cmdline_mode *mode)
2074 mode);
2083 mode->xres = xres;
2084 mode->yres = yres;
2085 mode->cvt = cvt;
2086 mode->rb = rb;
2115 struct drm_cmdline_mode *mode)
2128 mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
2130 mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP;
2132 mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP;
2134 mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP;
2142 struct drm_cmdline_mode *mode)
2159 mode->tv_mode_specified = true;
2160 mode->tv_mode = ret;
2168 struct drm_cmdline_mode *mode)
2215 mode->tv_margins.right = margin;
2220 mode->tv_margins.left = margin;
2225 mode->tv_margins.top = margin;
2230 mode->tv_margins.bottom = margin;
2232 if (drm_mode_parse_panel_orientation(delim, mode))
2235 if (drm_mode_parse_tv_mode(delim, mode))
2254 mode->rotation_reflection = rotation;
2294 /* If the name starts with a digit, it's not a named mode */
2300 * contains only an option and no mode.
2305 /* The connection status extras can be set without a mode. */
2311 * We're sure we're a named mode at this point, iterate over the
2315 const struct drm_named_mode *mode = &drm_named_modes[i];
2318 ret = str_has_prefix(name, mode->name);
2322 strscpy(cmdline_mode->name, mode->name, sizeof(cmdline_mode->name));
2323 cmdline_mode->pixel_clock = mode->pixel_clock_khz;
2324 cmdline_mode->xres = mode->xres;
2325 cmdline_mode->yres = mode->yres;
2326 cmdline_mode->interlace = !!(mode->flags & DRM_MODE_FLAG_INTERLACE);
2327 cmdline_mode->tv_mode = mode->tv_mode;
2339 * @mode_option: optional per connector mode option
2341 * @mode: preallocated drm_cmdline_mode structure to fill out
2351 * Additionals options can be provided following the mode, using a comma to
2363 struct drm_cmdline_mode *mode)
2374 memset(mode, 0, sizeof(*mode));
2375 mode->panel_orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
2416 ret = drm_mode_parse_cmdline_named_mode(name, mode_end, mode);
2421 * Having a mode that starts by a letter (and thus is named) and
2427 /* No named mode? Check for a normal mode argument, e.g. 1024x768 */
2428 if (!mode->specified && isdigit(name[0])) {
2432 mode);
2436 mode->specified = true;
2439 /* No mode? Check for freestanding extras and/or options */
2440 if (!mode->specified) {
2455 ret = drm_mode_parse_cmdline_bpp(bpp_ptr, &bpp_end_ptr, mode);
2459 mode->bpp_specified = true;
2464 &refresh_end_ptr, mode);
2468 mode->refresh_specified = true;
2489 connector, mode);
2497 connector, mode);
2532 * drm_mode_create_from_cmdline_mode - convert a command line modeline into a DRM display mode
2533 * @dev: DRM device to create the new mode for
2537 * Pointer to converted mode on success, NULL on error.
2543 struct drm_display_mode *mode;
2549 mode = drm_named_mode(dev, cmd);
2551 mode = drm_cvt_mode(dev,
2557 mode = drm_gtf_mode(dev,
2562 if (!mode)
2565 mode->type |= DRM_MODE_TYPE_USERDEF;
2568 drm_mode_fixup_1366x768(mode);
2569 drm_mode_set_crtcinfo(mode, CRTC_INTERLACE_HALVE_V);
2570 return mode;
2614 WARN(1, "Invalid aspect ratio (0%x) on mode\n",
2667 * flags for kernel-mode, but in picture_aspect_ratio.
2705 * @mode: video mode to be tested.
2708 * true if the mode can be supported in YCBCR420 format
2712 const struct drm_display_mode *mode)
2714 u8 vic = drm_match_cea_mode(mode);
2725 * @mode: video mode to be tested.
2728 * true if the mode can be support YCBCR420 format
2732 const struct drm_display_mode *mode)
2734 u8 vic = drm_match_cea_mode(mode);
2744 * @mode: video mode to be tested.
2747 * true if the mode can be supported in YCBCR420 format
2751 const struct drm_display_mode *mode)
2753 return drm_mode_is_420_only(display, mode) ||
2754 drm_mode_is_420_also(display, mode);
2759 * drm_set_preferred_mode - Sets the preferred mode of a connector
2760 * @connector: connector whose mode list should be processed
2761 * @hpref: horizontal resolution of preferred mode
2762 * @vpref: vertical resolution of preferred mode
2764 * Marks a mode as preferred if it matches the resolution specified by @hpref
2770 struct drm_display_mode *mode;
2772 list_for_each_entry(mode, &connector->probed_modes, head) {
2773 if (mode->hdisplay == hpref &&
2774 mode->vdisplay == vpref)
2775 mode->type |= DRM_MODE_TYPE_PREFERRED;