Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm: polish function kerneldoc for drm_modes.[hc]

- Tune down yelling RETURNS.
- OCD align all the parameters the same.
- Add missing kerneldoc, which also means that we need to include the
kerneldoc from the drm_modes.h header now.
- Add missing Returns: sections.
- General polish and clarification - especially the kerneldoc for the
mode creation helpers seems to have been some good specimen of
copypasta gone wrong.

All actual code changes have all been extracted into prep patches
since there was simply too much to polish.

v2: More polish for the command line modeline functions.

Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>

+115 -65
+1
Documentation/DocBook/drm.tmpl
··· 965 965 </itemizedlist> 966 966 <sect2> 967 967 <title>Display Modes Function Reference</title> 968 + !Iinclude/drm/drm_modes.h 968 969 !Edrivers/gpu/drm/drm_modes.c 969 970 </sect2> 970 971 <sect2>
+106 -65
drivers/gpu/drm/drm_modes.c
··· 63 63 * drm_mode_create - create a new display mode 64 64 * @dev: DRM device 65 65 * 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. 67 68 * 68 - * RETURNS: 69 + * Returns: 69 70 * Pointer to new mode on success, NULL on error. 70 71 */ 71 72 struct drm_display_mode *drm_mode_create(struct drm_device *dev) ··· 91 90 * @dev: DRM device 92 91 * @mode: mode to remove 93 92 * 94 - * Free @mode's unique identifier, then free it. 93 + * Release @mode's unique ID, then free it @mode structure itself using kfree. 95 94 */ 96 95 void drm_mode_destroy(struct drm_device *dev, struct drm_display_mode *mode) 97 96 { ··· 105 104 EXPORT_SYMBOL(drm_mode_destroy); 106 105 107 106 /** 108 - * drm_mode_probed_add - add a mode to a connector's probed mode list 107 + * drm_mode_probed_add - add a mode to a connector's probed_mode list 109 108 * @connector: connector the new mode 110 109 * @mode: mode data 111 110 * 112 - * Add @mode to @connector's mode list for later use. 111 + * Add @mode to @connector's probed_mode list for later use. This list should 112 + * then in a second step get filtered and all the modes actually supported by 113 + * the hardware moved to the @connector's modes list. 113 114 */ 114 115 void drm_mode_probed_add(struct drm_connector *connector, 115 116 struct drm_display_mode *mode) ··· 123 120 EXPORT_SYMBOL(drm_mode_probed_add); 124 121 125 122 /** 126 - * drm_cvt_mode -create a modeline based on CVT algorithm 127 - * @dev: DRM device 123 + * drm_cvt_mode -create a modeline based on the CVT algorithm 124 + * @dev: drm device 128 125 * @hdisplay: hdisplay size 129 126 * @vdisplay: vdisplay size 130 - * @vrefresh : vrefresh rate 131 - * @reduced : Whether the GTF calculation is simplified 132 - * @interlaced:Whether the interlace is supported 133 - * @margins: whether to add margins or not 134 - * 135 - * return the modeline based on CVT algorithm 127 + * @vrefresh: vrefresh rate 128 + * @reduced: whether to use reduced blanking 129 + * @interlaced: whether to compute an interlaced mode 130 + * @margins: whether to add margins (borders) 136 131 * 137 132 * This function is called to generate the modeline based on CVT algorithm 138 133 * according to the hdisplay, vdisplay, vrefresh. ··· 140 139 * 141 140 * And it is copied from xf86CVTmode in xserver/hw/xfree86/modes/xf86cvt.c. 142 141 * What I have done is to translate it by using integer calculation. 142 + * 143 + * Returns: 144 + * The modeline based on the CVT algorithm stored in a drm_display_mode object. 145 + * The display mode object is allocated with drm_mode_create(). Returns NULL 146 + * when no mode could be allocated. 143 147 */ 144 148 struct drm_display_mode *drm_cvt_mode(struct drm_device *dev, int hdisplay, 145 149 int vdisplay, int vrefresh, ··· 344 338 EXPORT_SYMBOL(drm_cvt_mode); 345 339 346 340 /** 347 - * drm_gtf_mode_complex - create the modeline based on full GTF algorithm 348 - * 349 - * @dev :drm device 350 - * @hdisplay :hdisplay size 351 - * @vdisplay :vdisplay size 352 - * @vrefresh :vrefresh rate. 353 - * @interlaced :whether the interlace is supported 354 - * @margins :desired margin size 341 + * drm_gtf_mode_complex - create the modeline based on the full GTF algorithm 342 + * @dev: drm device 343 + * @hdisplay: hdisplay size 344 + * @vdisplay: vdisplay size 345 + * @vrefresh: vrefresh rate. 346 + * @interlaced: whether to compute an interlaced mode 347 + * @margins: desired margin (borders) size 355 348 * @GTF_M: extended GTF formula parameters 356 349 * @GTF_2C: extended GTF formula parameters 357 350 * @GTF_K: extended GTF formula parameters 358 351 * @GTF_2J: extended GTF formula parameters 359 352 * 360 - * return the modeline based on full GTF algorithm. 361 - * 362 353 * GTF feature blocks specify C and J in multiples of 0.5, so we pass them 363 354 * in here multiplied by two. For a C of 40, pass in 80. 355 + * 356 + * Returns: 357 + * The modeline based on the full GTF algorithm stored in a drm_display_mode object. 358 + * The display mode object is allocated with drm_mode_create(). Returns NULL 359 + * when no mode could be allocated. 364 360 */ 365 361 struct drm_display_mode * 366 362 drm_gtf_mode_complex(struct drm_device *dev, int hdisplay, int vdisplay, ··· 532 524 EXPORT_SYMBOL(drm_gtf_mode_complex); 533 525 534 526 /** 535 - * drm_gtf_mode - create the modeline based on GTF algorithm 536 - * 537 - * @dev :drm device 538 - * @hdisplay :hdisplay size 539 - * @vdisplay :vdisplay size 540 - * @vrefresh :vrefresh rate. 541 - * @interlaced :whether the interlace is supported 542 - * @margins :whether the margin is supported 527 + * drm_gtf_mode - create the modeline based on the GTF algorithm 528 + * @dev: drm device 529 + * @hdisplay: hdisplay size 530 + * @vdisplay: vdisplay size 531 + * @vrefresh: vrefresh rate. 532 + * @interlaced: whether to compute an interlaced mode 533 + * @margins: desired margin (borders) size 543 534 * 544 535 * return the modeline based on GTF algorithm 545 536 * ··· 557 550 * C = 40 558 551 * K = 128 559 552 * J = 20 553 + * 554 + * Returns: 555 + * The modeline based on the GTF algorithm stored in a drm_display_mode object. 556 + * The display mode object is allocated with drm_mode_create(). Returns NULL 557 + * when no mode could be allocated. 560 558 */ 561 559 struct drm_display_mode * 562 560 drm_gtf_mode(struct drm_device *dev, int hdisplay, int vdisplay, int vrefresh, ··· 574 562 EXPORT_SYMBOL(drm_gtf_mode); 575 563 576 564 #ifdef CONFIG_VIDEOMODE_HELPERS 565 + /** 566 + * drm_display_mode_from_videomode - fill in @dmode using @vm, 567 + * @vm: videomode structure to use as source 568 + * @dmode: drm_display_mode structure to use as destination 569 + * 570 + * Fills out @dmode using the display mode specified in @vm. 571 + */ 577 572 void drm_display_mode_from_videomode(const struct videomode *vm, 578 573 struct drm_display_mode *dmode) 579 574 { ··· 625 606 * This function is expensive and should only be used, if only one mode is to be 626 607 * read from DT. To get multiple modes start with of_get_display_timings and 627 608 * work with that instead. 609 + * 610 + * Returns: 611 + * 0 on success, a negative errno code when no of videomode node was found. 628 612 */ 629 613 int of_get_drm_display_mode(struct device_node *np, 630 614 struct drm_display_mode *dmode, int index) ··· 655 633 * drm_mode_set_name - set the name on a mode 656 634 * @mode: name will be set in this mode 657 635 * 658 - * Set the name of @mode to a standard format. 636 + * Set the name of @mode to a standard format which is <hdisplay>x<vdisplay> 637 + * with an optional 'i' suffix for interlaced modes. 659 638 */ 660 639 void drm_mode_set_name(struct drm_display_mode *mode) 661 640 { ··· 671 648 /** drm_mode_hsync - get the hsync of a mode 672 649 * @mode: mode 673 650 * 674 - * Return @modes's hsync rate in kHz, rounded to the nearest int. 651 + * Returns: 652 + * @modes's hsync rate in kHz, rounded to the nearest integer. Calculates the 653 + * value first if it is not yet set. 675 654 */ 676 655 int drm_mode_hsync(const struct drm_display_mode *mode) 677 656 { ··· 697 672 * drm_mode_vrefresh - get the vrefresh of a mode 698 673 * @mode: mode 699 674 * 700 - * Return @mode's vrefresh rate in Hz or calculate it if necessary. 701 - * 702 - * FIXME: why is this needed? shouldn't vrefresh be set already? 703 - * 704 - * RETURNS: 705 - * Vertical refresh rate. It will be the result of actual value plus 0.5. 706 - * If it is 70.288, it will return 70Hz. 707 - * If it is 59.6, it will return 60Hz. 675 + * Returns: 676 + * @modes's vrefresh rate in Hz, rounded to the nearest integer. Calculates the 677 + * value first if it is not yet set. 708 678 */ 709 679 int drm_mode_vrefresh(const struct drm_display_mode *mode) 710 680 { ··· 728 708 EXPORT_SYMBOL(drm_mode_vrefresh); 729 709 730 710 /** 731 - * drm_mode_set_crtcinfo - set CRTC modesetting parameters 711 + * drm_mode_set_crtcinfo - set CRTC modesetting timing parameters 732 712 * @p: mode 733 713 * @adjust_flags: a combination of adjustment flags 734 714 * 735 - * Setup the CRTC modesetting parameters for @p, adjusting if necessary. 715 + * Setup the CRTC modesetting timing parameters for @p, adjusting if necessary. 736 716 * 737 717 * - The CRTC_INTERLACE_HALVE_V flag can be used to halve vertical timings of 738 718 * interlaced modes. ··· 800 780 } 801 781 EXPORT_SYMBOL(drm_mode_set_crtcinfo); 802 782 803 - 804 783 /** 805 784 * drm_mode_copy - copy the mode 806 785 * @dst: mode to overwrite ··· 826 807 * 827 808 * Just allocate a new mode, copy the existing mode into it, and return 828 809 * a pointer to it. Used to create new instances of established modes. 810 + * 811 + * Returns: 812 + * Pointer to duplicated mode on success, NULL on error. 829 813 */ 830 814 struct drm_display_mode *drm_mode_duplicate(struct drm_device *dev, 831 815 const struct drm_display_mode *mode) ··· 852 830 * 853 831 * Check to see if @mode1 and @mode2 are equivalent. 854 832 * 855 - * RETURNS: 833 + * Returns: 856 834 * True if the modes are equal, false otherwise. 857 835 */ 858 836 bool drm_mode_equal(const struct drm_display_mode *mode1, const struct drm_display_mode *mode2) ··· 881 859 * Check to see if @mode1 and @mode2 are equivalent, but 882 860 * don't check the pixel clocks nor the stereo layout. 883 861 * 884 - * RETURNS: 862 + * Returns: 885 863 * True if the modes are equal, false otherwise. 886 864 */ 887 865 bool drm_mode_equal_no_clocks_no_stereo(const struct drm_display_mode *mode1, ··· 912 890 * @maxX: maximum width 913 891 * @maxY: maximum height 914 892 * 915 - * The DRM device (@dev) has size and pitch limits. Here we validate the 916 - * modes we probed for @dev against those limits and set their status as 917 - * necessary. 893 + * This function is a helper which can be used to validate modes against size 894 + * limitations of the DRM device/connector. If a mode is too big its status 895 + * memeber is updated with the appropriate validation failure code. The list 896 + * itself is not changed. 918 897 */ 919 898 void drm_mode_validate_size(struct drm_device *dev, 920 899 struct list_head *mode_list, ··· 939 916 * @mode_list: list of modes to check 940 917 * @verbose: be verbose about it 941 918 * 942 - * Once mode list generation is complete, a caller can use this routine to 943 - * remove invalid modes from a mode list. If any of the modes have a 944 - * status other than %MODE_OK, they are removed from @mode_list and freed. 919 + * This helper function can be used to prune a display mode list after 920 + * validation has been completed. All modes who's status is not MODE_OK will be 921 + * removed from the list, and if @verbose the status code and mode name is also 922 + * printed to dmesg. 945 923 */ 946 924 void drm_mode_prune_invalid(struct drm_device *dev, 947 925 struct list_head *mode_list, bool verbose) ··· 972 948 * Compare two modes, given by @lh_a and @lh_b, returning a value indicating 973 949 * which is better. 974 950 * 975 - * RETURNS: 951 + * Returns: 976 952 * Negative if @lh_a is better than @lh_b, zero if they're equivalent, or 977 953 * positive if @lh_b is better than @lh_a. 978 954 */ ··· 1000 976 1001 977 /** 1002 978 * drm_mode_sort - sort mode list 1003 - * @mode_list: list to sort 979 + * @mode_list: list of drm_display_mode structures to sort 1004 980 * 1005 - * Sort @mode_list by favorability, putting good modes first. 981 + * Sort @mode_list by favorability, moving good modes to the head of the list. 1006 982 */ 1007 983 void drm_mode_sort(struct list_head *mode_list) 1008 984 { ··· 1016 992 * 1017 993 * This moves the modes from the @connector probed_modes list 1018 994 * to the actual mode list. It compares the probed mode against the current 1019 - * list and only adds different modes. All modes unverified after this point 1020 - * will be removed by the prune invalid modes. 995 + * list and only adds different/new modes. 996 + * 997 + * This is just a helper functions doesn't validate any modes itself and also 998 + * doesn't prune any invalid modes. Callers need to do that themselves. 1021 999 */ 1022 1000 void drm_mode_connector_list_update(struct drm_connector *connector) 1023 1001 { ··· 1054 1028 EXPORT_SYMBOL(drm_mode_connector_list_update); 1055 1029 1056 1030 /** 1057 - * drm_mode_parse_command_line_for_connector - parse command line for connector 1058 - * @mode_option: per connector mode option 1059 - * @connector: connector to parse line for 1060 - * @mode: preallocated mode structure to fill out 1031 + * drm_mode_parse_command_line_for_connector - parse command line modeline for connector 1032 + * @mode_option: optional per connector mode option 1033 + * @connector: connector to parse modeline for 1034 + * @mode: preallocated drm_cmdline_mode structure to fill out 1061 1035 * 1062 - * This parses the connector specific then generic command lines for 1063 - * modes and options to configure the connector. 1036 + * This parses @mode_option command line modeline for modes and options to 1037 + * configure the connector. If @mode_option is NULL the default command line 1038 + * modeline in fb_mode_option will be parsed instead. 1064 1039 * 1065 - * This uses the same parameters as the fb modedb.c, except for extra 1040 + * This uses the same parameters as the fb modedb.c, except for an extra 1041 + * force-enable, force-enable-digital and force-disable bit at the end: 1042 + * 1066 1043 * <xres>x<yres>[M][R][-<bpp>][@<refresh>][i][m][eDd] 1067 1044 * 1068 - * enable/enable Digital/disable bit at the end 1045 + * The intermediate drm_cmdline_mode structure is required to store additional 1046 + * options from the command line modline like the force-enabel/disable flag. 1047 + * 1048 + * Returns: 1049 + * True if a valid modeline has been parsed, false otherwise. 1069 1050 */ 1070 1051 bool drm_mode_parse_command_line_for_connector(const char *mode_option, 1071 1052 struct drm_connector *connector, ··· 1225 1192 } 1226 1193 EXPORT_SYMBOL(drm_mode_parse_command_line_for_connector); 1227 1194 1195 + /** 1196 + * drm_mode_create_from_cmdline_mode - convert a command line modeline into a DRM display mode 1197 + * @dev: DRM device to create the new mode for 1198 + * @cmd: input command line modeline 1199 + * 1200 + * Returns: 1201 + * Pointer to converted mode on success, NULL on error. 1202 + */ 1228 1203 struct drm_display_mode * 1229 1204 drm_mode_create_from_cmdline_mode(struct drm_device *dev, 1230 1205 struct drm_cmdline_mode *cmd)
+8
include/drm/drm_modes.h
··· 162 162 enum drm_connector_force force; 163 163 }; 164 164 165 + /** 166 + * drm_mode_is_stereo - check for stereo mode flags 167 + * @mode: drm_display_mode to check 168 + * 169 + * Returns: 170 + * True if the mode is one of the stereo modes (like side-by-side), false if 171 + * not. 172 + */ 165 173 static inline bool drm_mode_is_stereo(const struct drm_display_mode *mode) 166 174 { 167 175 return mode->flags & DRM_MODE_FLAG_3D_MASK;