Coverage Report

Created: 2026-10-17 06:38

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/barebox/drivers/video/drm/drm_modes.c
Line
Count
Source
1
/*
2
 * Copyright © 1997-2003 by The XFree86 Project, Inc.
3
 * Copyright © 2007 Dave Airlie
4
 * Copyright © 2007-2008 Intel Corporation
5
 *   Jesse Barnes <jesse.barnes@intel.com>
6
 * Copyright 2005-2006 Luc Verhaegen
7
 * Copyright (c) 2001, Andy Ritger  aritger@nvidia.com
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a
10
 * copy of this software and associated documentation files (the "Software"),
11
 * to deal in the Software without restriction, including without limitation
12
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13
 * and/or sell copies of the Software, and to permit persons to whom the
14
 * Software is furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in
17
 * all copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22
 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
23
 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24
 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
 * OTHER DEALINGS IN THE SOFTWARE.
26
 *
27
 * Except as contained in this notice, the name of the copyright holder(s)
28
 * and author(s) shall not be used in advertising or otherwise to promote
29
 * the sale, use or other dealings in this Software without prior written
30
 * authorization from the copyright holder(s) and author(s).
31
 */
32
33
#include <linux/ctype.h>
34
#include <linux/export.h>
35
#include <linux/list.h>
36
#include <of.h>
37
38
#include <video/drm/drm_modes.h>
39
40
/**
41
 * drm_mode_vrefresh - get the vrefresh of a mode
42
 * @mode: mode
43
 *
44
 * Returns:
45
 * @modes's vrefresh rate in Hz, rounded to the nearest integer. Calculates the
46
 * value first if it is not yet set.
47
 */
48
int drm_mode_vrefresh(const struct drm_display_mode *mode)
49
0
{
50
0
  unsigned int num, den;
51
52
0
  if (mode->htotal == 0 || mode->vtotal == 0)
53
0
    return 0;
54
55
0
  num = mode->clock;
56
0
  den = mode->htotal * mode->vtotal;
57
58
0
  if (mode->flags & DRM_MODE_FLAG_INTERLACE)
59
0
    num *= 2;
60
0
  if (mode->flags & DRM_MODE_FLAG_DBLSCAN)
61
0
    den *= 2;
62
0
  if (mode->vscan > 1)
63
0
    den *= mode->vscan;
64
65
0
  return DIV_ROUND_CLOSEST_ULL(mul_u32_u32(num, 1000), den);
66
0
}
67
EXPORT_SYMBOL(drm_mode_vrefresh);