Skip to content

Commit b3c6c8b

Browse files
committed
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
1 parent 4644453 commit b3c6c8b

5 files changed

Lines changed: 97 additions & 61 deletions

File tree

‎drivers/gpu/drm/drm_connector.c‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,40 @@ static const struct drm_prop_enum_list drm_dpms_enum_list[] = {
506506
};
507507
DRM_ENUM_NAME_FN(drm_get_dpms_name, drm_dpms_enum_list)
508508

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+
509543
/* Optional connector properties. */
510544
static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = {
511545
{ DRM_MODE_SCALE_NONE, "None" },

‎drivers/gpu/drm/drm_crtc.c‎

Lines changed: 0 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -419,40 +419,6 @@ void drm_crtc_cleanup(struct drm_crtc *crtc)
419419
}
420420
EXPORT_SYMBOL(drm_crtc_cleanup);
421421

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-
456422
static int drm_encoder_register_all(struct drm_device *dev)
457423
{
458424
struct drm_encoder *encoder;

‎drivers/gpu/drm/drm_edid.c‎

Lines changed: 4 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3721,14 +3721,7 @@ bool drm_rgb_quant_range_selectable(struct edid *edid)
37213721
}
37223722
EXPORT_SYMBOL(drm_rgb_quant_range_selectable);
37233723

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+
/*
37323725
* Parse the CEA extension according to CEA-861-B.
37333726
* Return true if HDMI deep color supported, false if not or unknown.
37343727
*/
@@ -3822,16 +3815,6 @@ static bool drm_assign_hdmi_deep_color_info(struct edid *edid,
38223815
return false;
38233816
}
38243817

3825-
/**
3826-
* drm_add_display_info - pull display info out if present
3827-
* @edid: EDID data
3828-
* @info: display info (attached to connector)
3829-
* @connector: connector whose edid is used to build display info
3830-
*
3831-
* Grab any available display info and stuff it into the drm_display_info
3832-
* structure that's part of the connector. Useful for tracking bpp and
3833-
* color spaces.
3834-
*/
38353818
static void drm_add_display_info(struct edid *edid,
38363819
struct drm_display_info *info,
38373820
struct drm_connector *connector)
@@ -4052,7 +4035,9 @@ static int add_displayid_detailed_modes(struct drm_connector *connector,
40524035
* @connector: connector we're probing
40534036
* @edid: EDID data
40544037
*
4055-
* Add the specified modes to the connector's mode list.
4038+
* Add the specified modes to the connector's mode list. Also fills out the
4039+
* &drm_display_info structure in @connector with any information which can be
4040+
* derived from the edid.
40564041
*
40574042
* Return: The number of modes added or 0 if we couldn't find any.
40584043
*/

‎include/drm/drm_connector.h‎

Lines changed: 59 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,28 +84,69 @@ enum subpixel_order {
8484
SubPixelNone,
8585
};
8686

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().
8997
*/
9098
struct drm_display_info {
99+
/**
100+
* @name: Name of the display.
101+
*/
91102
char name[DRM_DISPLAY_INFO_LEN];
92103

93-
/* Physical size */
104+
/**
105+
* @width_mm: Physical width in mm.
106+
*/
94107
unsigned int width_mm;
108+
/**
109+
* @height_mm: Physical height in mm.
110+
*/
95111
unsigned int height_mm;
96112

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+
*/
97118
unsigned int pixel_clock;
119+
/**
120+
* @bpc: Maximum bits per color channel. Used by HDMI and DP outputs.
121+
*/
98122
unsigned int bpc;
99123

124+
/**
125+
* @subpixel_order: Subpixel order of LCD panels.
126+
*/
100127
enum subpixel_order subpixel_order;
101128

102129
#define DRM_COLOR_FORMAT_RGB444 (1<<0)
103130
#define DRM_COLOR_FORMAT_YCRCB444 (1<<1)
104131
#define DRM_COLOR_FORMAT_YCRCB422 (1<<2)
105132

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+
*/
106139
u32 color_formats;
107140

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+
*/
108146
const u32 *bus_formats;
147+
/**
148+
* @num_bus_formats: Size of @bus_formats array.
149+
*/
109150
unsigned int num_bus_formats;
110151

111152
#define DRM_BUS_FLAG_DE_LOW (1<<0)
@@ -115,14 +156,28 @@ struct drm_display_info {
115156
/* drive data on neg. edge */
116157
#define DRM_BUS_FLAG_PIXDATA_NEGEDGE (1<<3)
117158

159+
/**
160+
* @bus_flags: Additional information (like pixel signal polarity) for
161+
* the pixel data on the bus, using DRM_BUS_FLAGS\_ defines.
162+
*/
118163
u32 bus_flags;
119164

120-
/* Mask of supported hdmi deep color modes */
165+
/**
166+
* @edid_hdmi_dc_modes: Mask of supported hdmi deep color modes. Even
167+
* more stuff redundant with @bus_formats.
168+
*/
121169
u8 edid_hdmi_dc_modes;
122170

171+
/**
172+
* @cea_rev: CEA revision of the HDMI sink.
173+
*/
123174
u8 cea_rev;
124175
};
125176

177+
int drm_display_info_set_bus_formats(struct drm_display_info *info,
178+
const u32 *formats,
179+
unsigned int num_formats);
180+
126181
/**
127182
* struct drm_connector_state - mutable connector state
128183
* @connector: backpointer to the connector

‎include/drm/drm_crtc.h‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,10 +2208,6 @@ extern void drm_mode_config_init(struct drm_device *dev);
22082208
extern void drm_mode_config_reset(struct drm_device *dev);
22092209
extern void drm_mode_config_cleanup(struct drm_device *dev);
22102210

2211-
extern int drm_display_info_set_bus_formats(struct drm_display_info *info,
2212-
const u32 *formats,
2213-
unsigned int num_formats);
2214-
22152211
static inline bool drm_property_type_is(struct drm_property *property,
22162212
uint32_t type)
22172213
{

0 commit comments

Comments
 (0)