@@ -63,9 +63,10 @@ EXPORT_SYMBOL(drm_mode_debug_printmodeline);
6363 * drm_mode_create - create a new display mode
6464 * @dev: DRM device
6565 *
66- * Create a new drm_display_mode, give it an ID, and return it.
66+ * Create a new, cleared drm_display_mode with kzalloc, allocate an ID for it
67+ * and return it.
6768 *
68- * RETURNS :
69+ * Returns :
6970 * Pointer to new mode on success, NULL on error.
7071 */
7172struct drm_display_mode * drm_mode_create (struct drm_device * dev )
@@ -90,7 +91,7 @@ EXPORT_SYMBOL(drm_mode_create);
9091 * @dev: DRM device
9192 * @mode: mode to remove
9293 *
93- * Free @mode's unique identifier , then free it.
94+ * Release @mode's unique ID , then free it @mode structure itself using kfree .
9495 */
9596void drm_mode_destroy (struct drm_device * dev , struct drm_display_mode * mode )
9697{
@@ -104,11 +105,13 @@ void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode)
104105EXPORT_SYMBOL (drm_mode_destroy );
105106
106107/**
107- * drm_mode_probed_add - add a mode to a connector's probed mode list
108+ * drm_mode_probed_add - add a mode to a connector's probed_mode list
108109 * @connector: connector the new mode
109110 * @mode: mode data
110111 *
111- * Add @mode to @connector's mode list for later use.
112+ * Add @mode to @connector's probed_mode list for later use. This list should
113+ * then in a second step get filtered and all the modes actually supported by
114+ * the hardware moved to the @connector's modes list.
112115 */
113116void drm_mode_probed_add (struct drm_connector * connector ,
114117 struct drm_display_mode * mode )
@@ -120,16 +123,14 @@ void drm_mode_probed_add(struct drm_connector *connector,
120123EXPORT_SYMBOL (drm_mode_probed_add );
121124
122125/**
123- * drm_cvt_mode -create a modeline based on CVT algorithm
124- * @dev: DRM device
126+ * drm_cvt_mode -create a modeline based on the CVT algorithm
127+ * @dev: drm device
125128 * @hdisplay: hdisplay size
126129 * @vdisplay: vdisplay size
127- * @vrefresh : vrefresh rate
128- * @reduced : Whether the GTF calculation is simplified
129- * @interlaced:Whether the interlace is supported
130- * @margins: whether to add margins or not
131- *
132- * return the modeline based on CVT algorithm
130+ * @vrefresh: vrefresh rate
131+ * @reduced: whether to use reduced blanking
132+ * @interlaced: whether to compute an interlaced mode
133+ * @margins: whether to add margins (borders)
133134 *
134135 * This function is called to generate the modeline based on CVT algorithm
135136 * according to the hdisplay, vdisplay, vrefresh.
@@ -139,6 +140,11 @@ EXPORT_SYMBOL(drm_mode_probed_add);
139140 *
140141 * And it is copied from xf86CVTmode in xserver/hw/xfree86/modes/xf86cvt.c.
141142 * What I have done is to translate it by using integer calculation.
143+ *
144+ * Returns:
145+ * The modeline based on the CVT algorithm stored in a drm_display_mode object.
146+ * The display mode object is allocated with drm_mode_create(). Returns NULL
147+ * when no mode could be allocated.
142148 */
143149struct drm_display_mode * drm_cvt_mode (struct drm_device * dev , int hdisplay ,
144150 int vdisplay , int vrefresh ,
@@ -338,23 +344,25 @@ struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay,
338344EXPORT_SYMBOL (drm_cvt_mode );
339345
340346/**
341- * drm_gtf_mode_complex - create the modeline based on full GTF algorithm
342- *
343- * @dev :drm device
344- * @hdisplay :hdisplay size
345- * @vdisplay :vdisplay size
346- * @vrefresh :vrefresh rate.
347- * @interlaced :whether the interlace is supported
348- * @margins :desired margin size
347+ * drm_gtf_mode_complex - create the modeline based on the full GTF algorithm
348+ * @dev: drm device
349+ * @hdisplay: hdisplay size
350+ * @vdisplay: vdisplay size
351+ * @vrefresh: vrefresh rate.
352+ * @interlaced: whether to compute an interlaced mode
353+ * @margins: desired margin (borders) size
349354 * @GTF_M: extended GTF formula parameters
350355 * @GTF_2C: extended GTF formula parameters
351356 * @GTF_K: extended GTF formula parameters
352357 * @GTF_2J: extended GTF formula parameters
353358 *
354- * return the modeline based on full GTF algorithm.
355- *
356359 * GTF feature blocks specify C and J in multiples of 0.5, so we pass them
357360 * in here multiplied by two. For a C of 40, pass in 80.
361+ *
362+ * Returns:
363+ * The modeline based on the full GTF algorithm stored in a drm_display_mode object.
364+ * The display mode object is allocated with drm_mode_create(). Returns NULL
365+ * when no mode could be allocated.
358366 */
359367struct drm_display_mode *
360368drm_gtf_mode_complex (struct drm_device * dev , int hdisplay , int vdisplay ,
@@ -524,14 +532,13 @@ drm_gtf_mode_complex(struct drm_device *dev, int hdisplay, int vdisplay,
524532EXPORT_SYMBOL (drm_gtf_mode_complex );
525533
526534/**
527- * drm_gtf_mode - create the modeline based on GTF algorithm
528- *
529- * @dev :drm device
530- * @hdisplay :hdisplay size
531- * @vdisplay :vdisplay size
532- * @vrefresh :vrefresh rate.
533- * @interlaced :whether the interlace is supported
534- * @margins :whether the margin is supported
535+ * drm_gtf_mode - create the modeline based on the GTF algorithm
536+ * @dev: drm device
537+ * @hdisplay: hdisplay size
538+ * @vdisplay: vdisplay size
539+ * @vrefresh: vrefresh rate.
540+ * @interlaced: whether to compute an interlaced mode
541+ * @margins: desired margin (borders) size
535542 *
536543 * return the modeline based on GTF algorithm
537544 *
@@ -550,6 +557,11 @@ EXPORT_SYMBOL(drm_gtf_mode_complex);
550557 * C = 40
551558 * K = 128
552559 * J = 20
560+ *
561+ * Returns:
562+ * The modeline based on the GTF algorithm stored in a drm_display_mode object.
563+ * The display mode object is allocated with drm_mode_create(). Returns NULL
564+ * when no mode could be allocated.
553565 */
554566struct drm_display_mode *
555567drm_gtf_mode (struct drm_device * dev , int hdisplay , int vdisplay , int vrefresh ,
@@ -562,6 +574,13 @@ drm_gtf_mode(struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh,
562574EXPORT_SYMBOL (drm_gtf_mode );
563575
564576#ifdef CONFIG_VIDEOMODE_HELPERS
577+ /**
578+ * drm_display_mode_from_videomode - fill in @dmode using @vm,
579+ * @vm: videomode structure to use as source
580+ * @dmode: drm_display_mode structure to use as destination
581+ *
582+ * Fills out @dmode using the display mode specified in @vm.
583+ */
565584void drm_display_mode_from_videomode (const struct videomode * vm ,
566585 struct drm_display_mode * dmode )
567586{
@@ -606,6 +625,9 @@ EXPORT_SYMBOL_GPL(drm_display_mode_from_videomode);
606625 * This function is expensive and should only be used, if only one mode is to be
607626 * read from DT. To get multiple modes start with of_get_display_timings and
608627 * work with that instead.
628+ *
629+ * Returns:
630+ * 0 on success, a negative errno code when no of videomode node was found.
609631 */
610632int of_get_drm_display_mode (struct device_node * np ,
611633 struct drm_display_mode * dmode , int index )
@@ -633,7 +655,8 @@ EXPORT_SYMBOL_GPL(of_get_drm_display_mode);
633655 * drm_mode_set_name - set the name on a mode
634656 * @mode: name will be set in this mode
635657 *
636- * Set the name of @mode to a standard format.
658+ * Set the name of @mode to a standard format which is <hdisplay>x<vdisplay>
659+ * with an optional 'i' suffix for interlaced modes.
637660 */
638661void drm_mode_set_name (struct drm_display_mode * mode )
639662{
@@ -648,7 +671,9 @@ EXPORT_SYMBOL(drm_mode_set_name);
648671/** drm_mode_hsync - get the hsync of a mode
649672 * @mode: mode
650673 *
651- * Return @modes's hsync rate in kHz, rounded to the nearest int.
674+ * Returns:
675+ * @modes's hsync rate in kHz, rounded to the nearest integer. Calculates the
676+ * value first if it is not yet set.
652677 */
653678int drm_mode_hsync (const struct drm_display_mode * mode )
654679{
@@ -672,14 +697,9 @@ EXPORT_SYMBOL(drm_mode_hsync);
672697 * drm_mode_vrefresh - get the vrefresh of a mode
673698 * @mode: mode
674699 *
675- * Return @mode's vrefresh rate in Hz or calculate it if necessary.
676- *
677- * FIXME: why is this needed? shouldn't vrefresh be set already?
678- *
679- * RETURNS:
680- * Vertical refresh rate. It will be the result of actual value plus 0.5.
681- * If it is 70.288, it will return 70Hz.
682- * If it is 59.6, it will return 60Hz.
700+ * Returns:
701+ * @modes's vrefresh rate in Hz, rounded to the nearest integer. Calculates the
702+ * value first if it is not yet set.
683703 */
684704int drm_mode_vrefresh (const struct drm_display_mode * mode )
685705{
@@ -708,11 +728,11 @@ int drm_mode_vrefresh(const struct drm_display_mode *mode)
708728EXPORT_SYMBOL (drm_mode_vrefresh );
709729
710730/**
711- * drm_mode_set_crtcinfo - set CRTC modesetting parameters
731+ * drm_mode_set_crtcinfo - set CRTC modesetting timing parameters
712732 * @p: mode
713733 * @adjust_flags: a combination of adjustment flags
714734 *
715- * Setup the CRTC modesetting parameters for @p, adjusting if necessary.
735+ * Setup the CRTC modesetting timing parameters for @p, adjusting if necessary.
716736 *
717737 * - The CRTC_INTERLACE_HALVE_V flag can be used to halve vertical timings of
718738 * interlaced modes.
@@ -780,7 +800,6 @@ void drm_mode_set_crtcinfo(struct drm_display_mode *p, int adjust_flags)
780800}
781801EXPORT_SYMBOL (drm_mode_set_crtcinfo );
782802
783-
784803/**
785804 * drm_mode_copy - copy the mode
786805 * @dst: mode to overwrite
@@ -807,6 +826,9 @@ EXPORT_SYMBOL(drm_mode_copy);
807826 *
808827 * Just allocate a new mode, copy the existing mode into it, and return
809828 * a pointer to it. Used to create new instances of established modes.
829+ *
830+ * Returns:
831+ * Pointer to duplicated mode on success, NULL on error.
810832 */
811833struct drm_display_mode * drm_mode_duplicate (struct drm_device * dev ,
812834 const struct drm_display_mode * mode )
@@ -830,7 +852,7 @@ EXPORT_SYMBOL(drm_mode_duplicate);
830852 *
831853 * Check to see if @mode1 and @mode2 are equivalent.
832854 *
833- * RETURNS :
855+ * Returns :
834856 * True if the modes are equal, false otherwise.
835857 */
836858bool drm_mode_equal (const struct drm_display_mode * mode1 , const struct drm_display_mode * mode2 )
@@ -859,7 +881,7 @@ EXPORT_SYMBOL(drm_mode_equal);
859881 * Check to see if @mode1 and @mode2 are equivalent, but
860882 * don't check the pixel clocks nor the stereo layout.
861883 *
862- * RETURNS :
884+ * Returns :
863885 * True if the modes are equal, false otherwise.
864886 */
865887bool drm_mode_equal_no_clocks_no_stereo (const struct drm_display_mode * mode1 ,
@@ -890,9 +912,10 @@ EXPORT_SYMBOL(drm_mode_equal_no_clocks_no_stereo);
890912 * @maxX: maximum width
891913 * @maxY: maximum height
892914 *
893- * The DRM device (@dev) has size and pitch limits. Here we validate the
894- * modes we probed for @dev against those limits and set their status as
895- * necessary.
915+ * This function is a helper which can be used to validate modes against size
916+ * limitations of the DRM device/connector. If a mode is too big its status
917+ * memeber is updated with the appropriate validation failure code. The list
918+ * itself is not changed.
896919 */
897920void drm_mode_validate_size (struct drm_device * dev ,
898921 struct list_head * mode_list ,
@@ -916,9 +939,10 @@ EXPORT_SYMBOL(drm_mode_validate_size);
916939 * @mode_list: list of modes to check
917940 * @verbose: be verbose about it
918941 *
919- * Once mode list generation is complete, a caller can use this routine to
920- * remove invalid modes from a mode list. If any of the modes have a
921- * status other than %MODE_OK, they are removed from @mode_list and freed.
942+ * This helper function can be used to prune a display mode list after
943+ * validation has been completed. All modes who's status is not MODE_OK will be
944+ * removed from the list, and if @verbose the status code and mode name is also
945+ * printed to dmesg.
922946 */
923947void drm_mode_prune_invalid (struct drm_device * dev ,
924948 struct list_head * mode_list , bool verbose )
@@ -948,7 +972,7 @@ EXPORT_SYMBOL(drm_mode_prune_invalid);
948972 * Compare two modes, given by @lh_a and @lh_b, returning a value indicating
949973 * which is better.
950974 *
951- * RETURNS :
975+ * Returns :
952976 * Negative if @lh_a is better than @lh_b, zero if they're equivalent, or
953977 * positive if @lh_b is better than @lh_a.
954978 */
@@ -976,9 +1000,9 @@ static int drm_mode_compare(void *priv, struct list_head *lh_a, struct list_head
9761000
9771001/**
9781002 * drm_mode_sort - sort mode list
979- * @mode_list: list to sort
1003+ * @mode_list: list of drm_display_mode structures to sort
9801004 *
981- * Sort @mode_list by favorability, putting good modes first .
1005+ * Sort @mode_list by favorability, moving good modes to the head of the list .
9821006 */
9831007void drm_mode_sort (struct list_head * mode_list )
9841008{
@@ -992,8 +1016,10 @@ EXPORT_SYMBOL(drm_mode_sort);
9921016 *
9931017 * This moves the modes from the @connector probed_modes list
9941018 * to the actual mode list. It compares the probed mode against the current
995- * list and only adds different modes. All modes unverified after this point
996- * will be removed by the prune invalid modes.
1019+ * list and only adds different/new modes.
1020+ *
1021+ * This is just a helper functions doesn't validate any modes itself and also
1022+ * doesn't prune any invalid modes. Callers need to do that themselves.
9971023 */
9981024void drm_mode_connector_list_update (struct drm_connector * connector )
9991025{
@@ -1028,18 +1054,25 @@ void drm_mode_connector_list_update(struct drm_connector *connector)
10281054EXPORT_SYMBOL (drm_mode_connector_list_update );
10291055
10301056/**
1031- * drm_mode_parse_command_line_for_connector - parse command line for connector
1032- * @mode_option: per connector mode option
1033- * @connector: connector to parse line for
1034- * @mode: preallocated mode structure to fill out
1057+ * drm_mode_parse_command_line_for_connector - parse command line modeline for connector
1058+ * @mode_option: optional per connector mode option
1059+ * @connector: connector to parse modeline for
1060+ * @mode: preallocated drm_cmdline_mode structure to fill out
1061+ *
1062+ * This parses @mode_option command line modeline for modes and options to
1063+ * configure the connector. If @mode_option is NULL the default command line
1064+ * modeline in fb_mode_option will be parsed instead.
10351065 *
1036- * This parses the connector specific then generic command lines for
1037- * modes and options to configure the connector.
1066+ * This uses the same parameters as the fb modedb.c, except for an extra
1067+ * force-enable, force-enable-digital and force-disable bit at the end:
10381068 *
1039- * This uses the same parameters as the fb modedb.c, except for extra
10401069 * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m][eDd]
10411070 *
1042- * enable/enable Digital/disable bit at the end
1071+ * The intermediate drm_cmdline_mode structure is required to store additional
1072+ * options from the command line modline like the force-enabel/disable flag.
1073+ *
1074+ * Returns:
1075+ * True if a valid modeline has been parsed, false otherwise.
10431076 */
10441077bool drm_mode_parse_command_line_for_connector (const char * mode_option ,
10451078 struct drm_connector * connector ,
@@ -1192,6 +1225,14 @@ bool drm_mode_parse_command_line_for_connector(const char *mode_option,
11921225}
11931226EXPORT_SYMBOL (drm_mode_parse_command_line_for_connector );
11941227
1228+ /**
1229+ * drm_mode_create_from_cmdline_mode - convert a command line modeline into a DRM display mode
1230+ * @dev: DRM device to create the new mode for
1231+ * @cmd: input command line modeline
1232+ *
1233+ * Returns:
1234+ * Pointer to converted mode on success, NULL on error.
1235+ */
11951236struct drm_display_mode *
11961237drm_mode_create_from_cmdline_mode (struct drm_device * dev ,
11971238 struct drm_cmdline_mode * cmd )
0 commit comments