drm/panel: Add and initialise an orientation field to drm_panel

Current usage of drm_connector_set_panel_orientation is from a panel's
get_modes call. However if the panel orientation property doesn't
exist on the connector at this point, then drm_mode_object triggers
WARNs as the connector is already registered.

Add an orientation variable to struct drm_panel and initialise it from
drm_panel_init.
panel_bridge_attach can then create the property before the connector
is registered.

Signed-off-by: Dave Stevenson <dave.stevenson@raspberrypi.com>
This commit is contained in:
Dave Stevenson
2022-02-01 12:20:20 +00:00
committed by Phil Elwell
parent 4fa195dbe1
commit 194052920b
3 changed files with 22 additions and 5 deletions

View File

@@ -79,6 +79,10 @@ static int panel_bridge_attach(struct drm_bridge *bridge,
return ret; return ret;
} }
/* set up connector's "panel orientation" property */
drm_connector_set_panel_orientation(&panel_bridge->connector,
panel_bridge->panel->orientation);
drm_connector_attach_encoder(&panel_bridge->connector, drm_connector_attach_encoder(&panel_bridge->connector,
bridge->encoder); bridge->encoder);

View File

@@ -61,6 +61,9 @@ void drm_panel_init(struct drm_panel *panel, struct device *dev,
panel->dev = dev; panel->dev = dev;
panel->funcs = funcs; panel->funcs = funcs;
panel->connector_type = connector_type; panel->connector_type = connector_type;
panel->orientation = DRM_MODE_PANEL_ORIENTATION_UNKNOWN;
of_drm_get_panel_orientation(dev->of_node, &panel->orientation);
} }
EXPORT_SYMBOL(drm_panel_init); EXPORT_SYMBOL(drm_panel_init);
@@ -289,16 +292,18 @@ int of_drm_get_panel_orientation(const struct device_node *np,
if (ret < 0) if (ret < 0)
return ret; return ret;
if (rotation == 0) if (rotation == 0) {
*orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL; *orientation = DRM_MODE_PANEL_ORIENTATION_NORMAL;
else if (rotation == 90) } else if (rotation == 90) {
*orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP; *orientation = DRM_MODE_PANEL_ORIENTATION_RIGHT_UP;
else if (rotation == 180) } else if (rotation == 180) {
*orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP; *orientation = DRM_MODE_PANEL_ORIENTATION_BOTTOM_UP;
else if (rotation == 270) } else if (rotation == 270) {
*orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP; *orientation = DRM_MODE_PANEL_ORIENTATION_LEFT_UP;
else } else {
DRM_ERROR("%pOF: invalid orientation %d\n", np, ret);
return -EINVAL; return -EINVAL;
}
return 0; return 0;
} }

View File

@@ -165,6 +165,14 @@ struct drm_panel {
*/ */
int connector_type; int connector_type;
/**
* @orientation:
*
* Panel orientation at initialisation. This is used to initialise the
* drm_connector property for panel orientation.
*/
enum drm_panel_orientation orientation;
/** /**
* @list: * @list:
* *