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

drm: document drm_display_info

We seem to have a bit a mess in how to describe the bus formats, with
a multitude of competing ways. Might be best to consolidate it all and
use MEDIA_BUS_FMT_ also for the hdmi color formats and high color
modes.

Also move all the display_info related functions into drm_connector.c
(there's only one) to group it all together. I did decided against
also moving the edid related display info functions, they seem to fit
better in drm_edid.c. Instead sprinkle a few cross references around.
While at that reduce the kerneldoc for static functions, there's not
point in documenting internals with that much detail really.

v2: Fix typo and move misplaced hunk (Sean).

Cc: Sean Paul <seanpaul@chromium.org>
Reviewed-by: Sean Paul <seanpaul@chromium.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/1471034937-651-19-git-send-email-daniel.vetter@ffwll.ch

+97 -61
+34
drivers/gpu/drm/drm_connector.c
··· 506 506 }; 507 507 DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list) 508 508 509 + /** 510 + * drm_display_info_set_bus_formats - set the supported bus formats 511 + * @info: display info to store bus formats in 512 + * @formats: array containing the supported bus formats 513 + * @num_formats: the number of entries in the fmts array 514 + * 515 + * Store the supported bus formats in display info structure. 516 + * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for 517 + * a full list of available formats. 518 + */ 519 + int drm_display_info_set_bus_formats(struct drm_display_info *info, 520 + const u32 *formats, 521 + unsigned int num_formats) 522 + { 523 + u32 *fmts = NULL; 524 + 525 + if (!formats && num_formats) 526 + return -EINVAL; 527 + 528 + if (formats && num_formats) { 529 + fmts = kmemdup(formats, sizeof(*formats) * num_formats, 530 + GFP_KERNEL); 531 + if (!fmts) 532 + return -ENOMEM; 533 + } 534 + 535 + kfree(info->bus_formats); 536 + info->bus_formats = fmts; 537 + info->num_bus_formats = num_formats; 538 + 539 + return 0; 540 + } 541 + EXPORT_SYMBOL(drm_display_info_set_bus_formats); 542 + 509 543 /* Optional connector properties. */ 510 544 static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = { 511 545 { DRM_MODE_SCALE_NONE, "None" },
-34
drivers/gpu/drm/drm_crtc.c
··· 419 419 } 420 420 EXPORT_SYMBOL(drm_crtc_cleanup); 421 421 422 - /** 423 - * drm_display_info_set_bus_formats - set the supported bus formats 424 - * @info: display info to store bus formats in 425 - * @formats: array containing the supported bus formats 426 - * @num_formats: the number of entries in the fmts array 427 - * 428 - * Store the supported bus formats in display info structure. 429 - * See MEDIA_BUS_FMT_* definitions in include/uapi/linux/media-bus-format.h for 430 - * a full list of available formats. 431 - */ 432 - int drm_display_info_set_bus_formats(struct drm_display_info *info, 433 - const u32 *formats, 434 - unsigned int num_formats) 435 - { 436 - u32 *fmts = NULL; 437 - 438 - if (!formats && num_formats) 439 - return -EINVAL; 440 - 441 - if (formats && num_formats) { 442 - fmts = kmemdup(formats, sizeof(*formats) * num_formats, 443 - GFP_KERNEL); 444 - if (!fmts) 445 - return -ENOMEM; 446 - } 447 - 448 - kfree(info->bus_formats); 449 - info->bus_formats = fmts; 450 - info->num_bus_formats = num_formats; 451 - 452 - return 0; 453 - } 454 - EXPORT_SYMBOL(drm_display_info_set_bus_formats); 455 - 456 422 static int drm_encoder_register_all(struct drm_device *dev) 457 423 { 458 424 struct drm_encoder *encoder;
+4 -19
drivers/gpu/drm/drm_edid.c
··· 3721 3721 } 3722 3722 EXPORT_SYMBOL(drm_rgb_quant_range_selectable); 3723 3723 3724 - /** 3725 - * drm_assign_hdmi_deep_color_info - detect whether monitor supports 3726 - * hdmi deep color modes and update drm_display_info if so. 3727 - * @edid: monitor EDID information 3728 - * @info: Updated with maximum supported deep color bpc and color format 3729 - * if deep color supported. 3730 - * @connector: DRM connector, used only for debug output 3731 - * 3724 + /* 3732 3725 * Parse the CEA extension according to CEA-861-B. 3733 3726 * Return true if HDMI deep color supported, false if not or unknown. 3734 3727 */ ··· 3815 3822 return false; 3816 3823 } 3817 3824 3818 - /** 3819 - * drm_add_display_info - pull display info out if present 3820 - * @edid: EDID data 3821 - * @info: display info (attached to connector) 3822 - * @connector: connector whose edid is used to build display info 3823 - * 3824 - * Grab any available display info and stuff it into the drm_display_info 3825 - * structure that's part of the connector. Useful for tracking bpp and 3826 - * color spaces. 3827 - */ 3828 3825 static void drm_add_display_info(struct edid *edid, 3829 3826 struct drm_display_info *info, 3830 3827 struct drm_connector *connector) ··· 4035 4052 * @connector: connector we're probing 4036 4053 * @edid: EDID data 4037 4054 * 4038 - * Add the specified modes to the connector's mode list. 4055 + * Add the specified modes to the connector's mode list. Also fills out the 4056 + * &drm_display_info structure in @connector with any information which can be 4057 + * derived from the edid. 4039 4058 * 4040 4059 * Return: The number of modes added or 0 if we couldn't find any. 4041 4060 */
+59 -4
include/drm/drm_connector.h
··· 84 84 SubPixelNone, 85 85 }; 86 86 87 - /* 88 - * Describes a given display (e.g. CRT or flat panel) and its limitations. 87 + /** 88 + * struct drm_display_info - runtime data about the connected sink 89 + * 90 + * Describes a given display (e.g. CRT or flat panel) and its limitations. For 91 + * fixed display sinks like built-in panels there's not much difference between 92 + * this and struct &drm_connector. But for sinks with a real cable this 93 + * structure is meant to describe all the things at the other end of the cable. 94 + * 95 + * For sinks which provide an EDID this can be filled out by calling 96 + * drm_add_edid_modes(). 89 97 */ 90 98 struct drm_display_info { 99 + /** 100 + * @name: Name of the display. 101 + */ 91 102 char name[DRM_DISPLAY_INFO_LEN]; 92 103 93 - /* Physical size */ 104 + /** 105 + * @width_mm: Physical width in mm. 106 + */ 94 107 unsigned int width_mm; 108 + /** 109 + * @height_mm: Physical height in mm. 110 + */ 95 111 unsigned int height_mm; 96 112 113 + /** 114 + * @pixel_clock: Maximum pixel clock supported by the sink, in units of 115 + * 100Hz. This mismatches the clok in &drm_display_mode (which is in 116 + * kHZ), because that's what the EDID uses as base unit. 117 + */ 97 118 unsigned int pixel_clock; 119 + /** 120 + * @bpc: Maximum bits per color channel. Used by HDMI and DP outputs. 121 + */ 98 122 unsigned int bpc; 99 123 124 + /** 125 + * @subpixel_order: Subpixel order of LCD panels. 126 + */ 100 127 enum subpixel_order subpixel_order; 101 128 102 129 #define DRM_COLOR_FORMAT_RGB444 (1<<0) 103 130 #define DRM_COLOR_FORMAT_YCRCB444 (1<<1) 104 131 #define DRM_COLOR_FORMAT_YCRCB422 (1<<2) 105 132 133 + /** 134 + * @color_formats: HDMI Color formats, selects between RGB and YCrCb 135 + * modes. Used DRM_COLOR_FORMAT\_ defines, which are _not_ the same ones 136 + * as used to describe the pixel format in framebuffers, and also don't 137 + * match the formats in @bus_formats which are shared with v4l. 138 + */ 106 139 u32 color_formats; 107 140 141 + /** 142 + * @bus_formats: Pixel data format on the wire, somewhat redundant with 143 + * @color_formats. Array of size @num_bus_formats encoded using 144 + * MEDIA_BUS_FMT\_ defines shared with v4l and media drivers. 145 + */ 108 146 const u32 *bus_formats; 147 + /** 148 + * @num_bus_formats: Size of @bus_formats array. 149 + */ 109 150 unsigned int num_bus_formats; 110 151 111 152 #define DRM_BUS_FLAG_DE_LOW (1<<0) ··· 156 115 /* drive data on neg. edge */ 157 116 #define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3) 158 117 118 + /** 119 + * @bus_flags: Additional information (like pixel signal polarity) for 120 + * the pixel data on the bus, using DRM_BUS_FLAGS\_ defines. 121 + */ 159 122 u32 bus_flags; 160 123 161 - /* Mask of supported hdmi deep color modes */ 124 + /** 125 + * @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even 126 + * more stuff redundant with @bus_formats. 127 + */ 162 128 u8 edid_hdmi_dc_modes; 163 129 130 + /** 131 + * @cea_rev: CEA revision of the HDMI sink. 132 + */ 164 133 u8 cea_rev; 165 134 }; 135 + 136 + int drm_display_info_set_bus_formats(struct drm_display_info *info, 137 + const u32 *formats, 138 + unsigned int num_formats); 166 139 167 140 /** 168 141 * struct drm_connector_state - mutable connector state
-4
include/drm/drm_crtc.h
··· 2208 2208 extern void drm_mode_config_reset(struct drm_device *dev); 2209 2209 extern void drm_mode_config_cleanup(struct drm_device *dev); 2210 2210 2211 - extern int drm_display_info_set_bus_formats(struct drm_display_info *info, 2212 - const u32 *formats, 2213 - unsigned int num_formats); 2214 - 2215 2211 static inline bool drm_property_type_is(struct drm_property *property, 2216 2212 uint32_t type) 2217 2213 {