Skip to content

Commit 50525c3

Browse files
StanFox1984vsyrjala
authored andcommitted
drm: content-type property for HDMI connector
Added content_type property to drm_connector_state in order to properly handle external HDMI TV content-type setting. v2: * Moved helper function which attaches content type property to the drm core, as was suggested. Removed redundant connector state initialization. v3: * Removed caps in drm_content_type_enum_list. After some discussion it turned out that HDMI Spec 1.4 was wrongly assuming that IT Content(itc) bit doesn't affect Content type states, however itc bit needs to be manupulated as well. In order to not expose additional property for itc, for sake of simplicity it was decided to bind those together in same "content type" property. v4: * Added it_content checking in intel_digital_connector_atomic_check. Fixed documentation for new content type enum. v5: * Moved patch revision's description to commit messages. v6: * Minor naming fix for the content type enumeration string. v7: * Fix parameter name for documentation and parameter alignment in order not to get warning. Added Content Type description to new HDMI connector properties section. v8: * Thrown away unneeded numbers from HDMI content-type property description. Switch to strings desription instead of plain definitions. v9: * Moved away hdmi specific content-type enum from drm_connector_state. Content type property should probably not be bound to any specific connector interface in drm_connector_state. Same probably should be done to hdmi_picture_aspect_ration enum which is also contained in drm_connector_state. Added special helper function to get derive hdmi specific relevant infoframe fields. v10: * Added usage description to HDMI properties kernel doc. v11: * Created centralized function for filling HDMI AVI infoframe, based on correspondent DRM property value. Acked-by: Hans Verkuil <hans.verkuil@cisco.com> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch> Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20180515135928.31092-2-stanislav.lisovskiy@intel.com [vsyrjala: clean up checkpatch multiple blank lines warnings] Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
1 parent 5d435b4 commit 50525c3

File tree

8 files changed

+157
-0
lines changed

8 files changed

+157
-0
lines changed

Documentation/gpu/drm-kms.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,12 @@ Standard Connector Properties
517517
.. kernel-doc:: drivers/gpu/drm/drm_connector.c
518518
:doc: standard connector properties
519519

520+
HDMI Specific Connector Properties
521+
-----------------------------
522+
523+
.. kernel-doc:: drivers/gpu/drm/drm_connector.c
524+
:doc: HDMI connector properties
525+
520526
Plane Composition Properties
521527
----------------------------
522528

Documentation/gpu/kms-properties.csv

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Owner Module/Drivers,Group,Property Name,Type,Property Values,Object attached,De
1717
,Virtual GPU,“suggested X”,RANGE,"Min=0, Max=0xffffffff",Connector,property to suggest an X offset for a connector
1818
,,“suggested Y”,RANGE,"Min=0, Max=0xffffffff",Connector,property to suggest an Y offset for a connector
1919
,Optional,"""aspect ratio""",ENUM,"{ ""None"", ""4:3"", ""16:9"" }",Connector,TDB
20+
,Optional,"""content type""",ENUM,"{ ""No Data"", ""Graphics"", ""Photo"", ""Cinema"", ""Game"" }",Connector,TBD
2021
i915,Generic,"""Broadcast RGB""",ENUM,"{ ""Automatic"", ""Full"", ""Limited 16:235"" }",Connector,"When this property is set to Limited 16:235 and CTM is set, the hardware will be programmed with the result of the multiplication of CTM by the limited range matrix to ensure the pixels normaly in the range 0..1.0 are remapped to the range 16/255..235/255."
2122
,,“audio”,ENUM,"{ ""force-dvi"", ""off"", ""auto"", ""on"" }",Connector,TBD
2223
,SDVO-TV,“mode”,ENUM,"{ ""NTSC_M"", ""NTSC_J"", ""NTSC_443"", ""PAL_B"" } etc.",Connector,TBD

drivers/gpu/drm/drm_atomic.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1270,6 +1270,8 @@ static int drm_atomic_connector_set_property(struct drm_connector *connector,
12701270
state->link_status = val;
12711271
} else if (property == config->aspect_ratio_property) {
12721272
state->picture_aspect_ratio = val;
1273+
} else if (property == config->content_type_property) {
1274+
state->content_type = val;
12731275
} else if (property == connector->scaling_mode_property) {
12741276
state->scaling_mode = val;
12751277
} else if (property == connector->content_protection_property) {
@@ -1355,6 +1357,8 @@ drm_atomic_connector_get_property(struct drm_connector *connector,
13551357
*val = state->link_status;
13561358
} else if (property == config->aspect_ratio_property) {
13571359
*val = state->picture_aspect_ratio;
1360+
} else if (property == config->content_type_property) {
1361+
*val = state->content_type;
13581362
} else if (property == connector->scaling_mode_property) {
13591363
*val = state->scaling_mode;
13601364
} else if (property == connector->content_protection_property) {

drivers/gpu/drm/drm_connector.c

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -720,6 +720,14 @@ static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = {
720720
{ DRM_MODE_PICTURE_ASPECT_16_9, "16:9" },
721721
};
722722

723+
static const struct drm_prop_enum_list drm_content_type_enum_list[] = {
724+
{ DRM_MODE_CONTENT_TYPE_NO_DATA, "No Data" },
725+
{ DRM_MODE_CONTENT_TYPE_GRAPHICS, "Graphics" },
726+
{ DRM_MODE_CONTENT_TYPE_PHOTO, "Photo" },
727+
{ DRM_MODE_CONTENT_TYPE_CINEMA, "Cinema" },
728+
{ DRM_MODE_CONTENT_TYPE_GAME, "Game" },
729+
};
730+
723731
static const struct drm_prop_enum_list drm_panel_orientation_enum_list[] = {
724732
{ DRM_MODE_PANEL_ORIENTATION_NORMAL, "Normal" },
725733
{ DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP, "Upside Down" },
@@ -996,6 +1004,84 @@ int drm_mode_create_dvi_i_properties(struct drm_device *dev)
9961004
}
9971005
EXPORT_SYMBOL(drm_mode_create_dvi_i_properties);
9981006

1007+
/**
1008+
* DOC: HDMI connector properties
1009+
*
1010+
* content type (HDMI specific):
1011+
* Indicates content type setting to be used in HDMI infoframes to indicate
1012+
* content type for the external device, so that it adjusts it's display
1013+
* settings accordingly.
1014+
*
1015+
* The value of this property can be one of the following:
1016+
*
1017+
* No Data:
1018+
* Content type is unknown
1019+
* Graphics:
1020+
* Content type is graphics
1021+
* Photo:
1022+
* Content type is photo
1023+
* Cinema:
1024+
* Content type is cinema
1025+
* Game:
1026+
* Content type is game
1027+
*
1028+
* Drivers can set up this property by calling
1029+
* drm_connector_attach_content_type_property(). Decoding to
1030+
* infoframe values is done through
1031+
* drm_hdmi_get_content_type_from_property() and
1032+
* drm_hdmi_get_itc_bit_from_property().
1033+
*/
1034+
1035+
/**
1036+
* drm_connector_attach_content_type_property - attach content-type property
1037+
* @connector: connector to attach content type property on.
1038+
*
1039+
* Called by a driver the first time a HDMI connector is made.
1040+
*/
1041+
int drm_connector_attach_content_type_property(struct drm_connector *connector)
1042+
{
1043+
if (!drm_mode_create_content_type_property(connector->dev))
1044+
drm_object_attach_property(&connector->base,
1045+
connector->dev->mode_config.content_type_property,
1046+
DRM_MODE_CONTENT_TYPE_NO_DATA);
1047+
return 0;
1048+
}
1049+
EXPORT_SYMBOL(drm_connector_attach_content_type_property);
1050+
1051+
1052+
/**
1053+
* drm_hdmi_avi_infoframe_content_type() - fill the HDMI AVI infoframe
1054+
* content type information, based
1055+
* on correspondent DRM property.
1056+
* @frame: HDMI AVI infoframe
1057+
* @conn_state: DRM display connector state
1058+
*
1059+
*/
1060+
void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe *frame,
1061+
const struct drm_connector_state *conn_state)
1062+
{
1063+
switch (conn_state->content_type) {
1064+
case DRM_MODE_CONTENT_TYPE_GRAPHICS:
1065+
frame->content_type = HDMI_CONTENT_TYPE_GRAPHICS;
1066+
break;
1067+
case DRM_MODE_CONTENT_TYPE_CINEMA:
1068+
frame->content_type = HDMI_CONTENT_TYPE_CINEMA;
1069+
break;
1070+
case DRM_MODE_CONTENT_TYPE_GAME:
1071+
frame->content_type = HDMI_CONTENT_TYPE_GAME;
1072+
break;
1073+
case DRM_MODE_CONTENT_TYPE_PHOTO:
1074+
frame->content_type = HDMI_CONTENT_TYPE_PHOTO;
1075+
break;
1076+
default:
1077+
/* Graphics is the default(0) */
1078+
frame->content_type = HDMI_CONTENT_TYPE_GRAPHICS;
1079+
}
1080+
1081+
frame->itc = conn_state->content_type != DRM_MODE_CONTENT_TYPE_NO_DATA;
1082+
}
1083+
EXPORT_SYMBOL(drm_hdmi_avi_infoframe_content_type);
1084+
9991085
/**
10001086
* drm_create_tv_properties - create TV specific connector properties
10011087
* @dev: DRM device
@@ -1260,6 +1346,33 @@ int drm_mode_create_aspect_ratio_property(struct drm_device *dev)
12601346
}
12611347
EXPORT_SYMBOL(drm_mode_create_aspect_ratio_property);
12621348

1349+
/**
1350+
* drm_mode_create_content_type_property - create content type property
1351+
* @dev: DRM device
1352+
*
1353+
* Called by a driver the first time it's needed, must be attached to desired
1354+
* connectors.
1355+
*
1356+
* Returns:
1357+
* Zero on success, negative errno on failure.
1358+
*/
1359+
int drm_mode_create_content_type_property(struct drm_device *dev)
1360+
{
1361+
if (dev->mode_config.content_type_property)
1362+
return 0;
1363+
1364+
dev->mode_config.content_type_property =
1365+
drm_property_create_enum(dev, 0, "content type",
1366+
drm_content_type_enum_list,
1367+
ARRAY_SIZE(drm_content_type_enum_list));
1368+
1369+
if (dev->mode_config.content_type_property == NULL)
1370+
return -ENOMEM;
1371+
1372+
return 0;
1373+
}
1374+
EXPORT_SYMBOL(drm_mode_create_content_type_property);
1375+
12631376
/**
12641377
* drm_mode_create_suggested_offset_properties - create suggests offset properties
12651378
* @dev: DRM device

drivers/gpu/drm/drm_edid.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4872,6 +4872,14 @@ drm_hdmi_avi_infoframe_from_display_mode(struct hdmi_avi_infoframe *frame,
48724872

48734873
frame->picture_aspect = HDMI_PICTURE_ASPECT_NONE;
48744874

4875+
/*
4876+
* As some drivers don't support atomic, we can't use connector state.
4877+
* So just initialize the frame with default values, just the same way
4878+
* as it's done with other properties here.
4879+
*/
4880+
frame->content_type = HDMI_CONTENT_TYPE_GRAPHICS;
4881+
frame->itc = 0;
4882+
48754883
/*
48764884
* Populate picture aspect ratio from either
48774885
* user input (if specified) or from the CEA mode list.

include/drm/drm_connector.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -418,6 +418,14 @@ struct drm_connector_state {
418418
*/
419419
enum hdmi_picture_aspect picture_aspect_ratio;
420420

421+
/**
422+
* @content_type: Connector property to control the
423+
* HDMI infoframe content type setting.
424+
* The %DRM_MODE_CONTENT_TYPE_\* values much
425+
* match the values.
426+
*/
427+
unsigned int content_type;
428+
421429
/**
422430
* @scaling_mode: Connector property to control the
423431
* upscaling, mostly used for built-in panels.
@@ -1089,11 +1097,16 @@ int drm_mode_create_tv_properties(struct drm_device *dev,
10891097
unsigned int num_modes,
10901098
const char * const modes[]);
10911099
int drm_mode_create_scaling_mode_property(struct drm_device *dev);
1100+
int drm_connector_attach_content_type_property(struct drm_connector *dev);
10921101
int drm_connector_attach_scaling_mode_property(struct drm_connector *connector,
10931102
u32 scaling_mode_mask);
10941103
int drm_connector_attach_content_protection_property(
10951104
struct drm_connector *connector);
10961105
int drm_mode_create_aspect_ratio_property(struct drm_device *dev);
1106+
int drm_mode_create_content_type_property(struct drm_device *dev);
1107+
void drm_hdmi_avi_infoframe_content_type(struct hdmi_avi_infoframe *frame,
1108+
const struct drm_connector_state *conn_state);
1109+
10971110
int drm_mode_create_suggested_offset_properties(struct drm_device *dev);
10981111

10991112
int drm_mode_connector_set_path_property(struct drm_connector *connector,

include/drm/drm_mode_config.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,11 @@ struct drm_mode_config {
726726
* HDMI infoframe aspect ratio setting.
727727
*/
728728
struct drm_property *aspect_ratio_property;
729+
/**
730+
* @content_type_property: Optional connector property to control the
731+
* HDMI infoframe content type setting.
732+
*/
733+
struct drm_property *content_type_property;
729734
/**
730735
* @degamma_lut_property: Optional CRTC property to set the LUT used to
731736
* convert the framebuffer's colors to linear gamma.

include/uapi/drm/drm_mode.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ extern "C" {
9696
#define DRM_MODE_PICTURE_ASPECT_64_27 3
9797
#define DRM_MODE_PICTURE_ASPECT_256_135 4
9898

99+
/* Content type options */
100+
#define DRM_MODE_CONTENT_TYPE_NO_DATA 0
101+
#define DRM_MODE_CONTENT_TYPE_GRAPHICS 1
102+
#define DRM_MODE_CONTENT_TYPE_PHOTO 2
103+
#define DRM_MODE_CONTENT_TYPE_CINEMA 3
104+
#define DRM_MODE_CONTENT_TYPE_GAME 4
105+
99106
/* Aspect ratio flag bitmask (4 bits 22:19) */
100107
#define DRM_MODE_FLAG_PIC_AR_MASK (0x0F<<19)
101108
#define DRM_MODE_FLAG_PIC_AR_NONE \

0 commit comments

Comments
 (0)