/* * Cleanup the connector if we know it was initialized. * * FIXME: This wouldn't be needed if the panel_bridge structure was * allocated with drmm_kzalloc(). This might be tricky since the * drm_device pointer can only be retrieved when the bridge is attached.
*/ if (connector->dev)
drm_connector_cleanup(connector);
}
/** * drm_bridge_is_panel - Checks if a drm_bridge is a panel_bridge. * * @bridge: The drm_bridge to be checked. * * Returns true if the bridge is a panel bridge, or false otherwise.
*/ bool drm_bridge_is_panel(conststruct drm_bridge *bridge)
{ return bridge->funcs == &panel_bridge_bridge_funcs;
}
EXPORT_SYMBOL(drm_bridge_is_panel);
/** * drm_panel_bridge_add - Creates a &drm_bridge and &drm_connector that * just calls the appropriate functions from &drm_panel. * * @panel: The drm_panel being wrapped. Must be non-NULL. * * For drivers converting from directly using drm_panel: The expected * usage pattern is that during either encoder module probe or DSI * host attach, a drm_panel will be looked up through * drm_of_find_panel_or_bridge(). drm_panel_bridge_add() is used to * wrap that panel in the new bridge, and the result can then be * passed to drm_bridge_attach(). The drm_panel_prepare() and related * functions can be dropped from the encoder driver (they're now * called by the KMS helpers before calling into the encoder), along * with connector creation. When done with the bridge (after * drm_mode_config_cleanup() if the bridge has already been attached), then * drm_panel_bridge_remove() to free it. * * The connector type is set to @panel->connector_type, which must be set to a * known type. Calling this function with a panel whose connector type is * DRM_MODE_CONNECTOR_Unknown will return ERR_PTR(-EINVAL). * * See devm_drm_panel_bridge_add() for an automatically managed version of this * function.
*/ struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel)
{ if (WARN_ON(panel->connector_type == DRM_MODE_CONNECTOR_Unknown)) return ERR_PTR(-EINVAL);
/** * drm_panel_bridge_add_typed - Creates a &drm_bridge and &drm_connector with * an explicit connector type. * @panel: The drm_panel being wrapped. Must be non-NULL. * @connector_type: The connector type (DRM_MODE_CONNECTOR_*) * * This is just like drm_panel_bridge_add(), but forces the connector type to * @connector_type instead of infering it from the panel. * * This function is deprecated and should not be used in new drivers. Use * drm_panel_bridge_add() instead, and fix panel drivers as necessary if they * don't report a connector type.
*/ struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel,
u32 connector_type)
{ struct panel_bridge *panel_bridge;
/** * drm_panel_bridge_remove - Unregisters and frees a drm_bridge * created by drm_panel_bridge_add(). * * @bridge: The drm_bridge being freed.
*/ void drm_panel_bridge_remove(struct drm_bridge *bridge)
{ struct panel_bridge *panel_bridge;
if (!bridge) return;
if (!drm_bridge_is_panel(bridge)) {
drm_warn(bridge->dev, "%s: called on non-panel bridge!\n", __func__); return;
}
drm_bridge_remove(bridge); /* TODO remove this after reworking panel_bridge lifetime */
devm_drm_put_bridge(panel_bridge->panel->dev, bridge);
}
EXPORT_SYMBOL(drm_panel_bridge_remove);
/** * drm_panel_bridge_set_orientation - Set the connector's panel orientation * from the bridge that can be transformed to panel bridge. * * @connector: The connector to be set panel orientation. * @bridge: The drm_bridge to be transformed to panel bridge. * * Returns 0 on success, negative errno on failure.
*/ int drm_panel_bridge_set_orientation(struct drm_connector *connector, struct drm_bridge *bridge)
{ struct panel_bridge *panel_bridge;
/** * devm_drm_panel_bridge_add - Creates a managed &drm_bridge and &drm_connector * that just calls the appropriate functions from &drm_panel. * @dev: device to tie the bridge lifetime to * @panel: The drm_panel being wrapped. Must be non-NULL. * * This is the managed version of drm_panel_bridge_add() which automatically * calls drm_panel_bridge_remove() when @dev is unbound.
*/ struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev, struct drm_panel *panel)
{ if (WARN_ON(panel->connector_type == DRM_MODE_CONNECTOR_Unknown)) return ERR_PTR(-EINVAL);
/** * devm_drm_panel_bridge_add_typed - Creates a managed &drm_bridge and * &drm_connector with an explicit connector type. * @dev: device to tie the bridge lifetime to * @panel: The drm_panel being wrapped. Must be non-NULL. * @connector_type: The connector type (DRM_MODE_CONNECTOR_*) * * This is just like devm_drm_panel_bridge_add(), but forces the connector type * to @connector_type instead of infering it from the panel. * * This function is deprecated and should not be used in new drivers. Use * devm_drm_panel_bridge_add() instead, and fix panel drivers as necessary if * they don't report a connector type.
*/ struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev, struct drm_panel *panel,
u32 connector_type)
{ struct drm_bridge **ptr, *bridge;
ptr = devres_alloc(devm_drm_panel_bridge_release, sizeof(*ptr),
GFP_KERNEL); if (!ptr) return ERR_PTR(-ENOMEM);
/** * drmm_panel_bridge_add - Creates a DRM-managed &drm_bridge and * &drm_connector that just calls the * appropriate functions from &drm_panel. * * @drm: DRM device to tie the bridge lifetime to * @panel: The drm_panel being wrapped. Must be non-NULL. * * This is the DRM-managed version of drm_panel_bridge_add() which * automatically calls drm_panel_bridge_remove() when @dev is cleaned * up.
*/ struct drm_bridge *drmm_panel_bridge_add(struct drm_device *drm, struct drm_panel *panel)
{ struct drm_bridge *bridge; int ret;
bridge = drm_panel_bridge_add_typed(panel, panel->connector_type); if (IS_ERR(bridge)) return bridge;
ret = drmm_add_action_or_reset(drm, drmm_drm_panel_bridge_release,
bridge); if (ret) return ERR_PTR(ret);
/** * drm_panel_bridge_connector - return the connector for the panel bridge * @bridge: The drm_bridge. * * drm_panel_bridge creates the connector. * This function gives external access to the connector. * * Returns: Pointer to drm_connector
*/ struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge)
{ struct panel_bridge *panel_bridge;
#ifdef CONFIG_OF /** * devm_drm_of_get_bridge - Return next bridge in the chain * @dev: device to tie the bridge lifetime to * @np: device tree node containing encoder output ports * @port: port in the device tree node * @endpoint: endpoint in the device tree node * * Given a DT node's port and endpoint number, finds the connected node * and returns the associated bridge if any, or creates and returns a * drm panel bridge instance if a panel is connected. * * Returns a pointer to the bridge if successful, or an error pointer * otherwise.
*/ struct drm_bridge *devm_drm_of_get_bridge(struct device *dev, struct device_node *np,
u32 port, u32 endpoint)
{ struct drm_bridge *bridge; struct drm_panel *panel; int ret;
ret = drm_of_find_panel_or_bridge(np, port, endpoint,
&panel, &bridge); if (ret) return ERR_PTR(ret);
if (panel)
bridge = devm_drm_panel_bridge_add(dev, panel);
/** * drmm_of_get_bridge - Return next bridge in the chain * @drm: device to tie the bridge lifetime to * @np: device tree node containing encoder output ports * @port: port in the device tree node * @endpoint: endpoint in the device tree node * * Given a DT node's port and endpoint number, finds the connected node * and returns the associated bridge if any, or creates and returns a * drm panel bridge instance if a panel is connected. * * Returns a drmm managed pointer to the bridge if successful, or an error * pointer otherwise.
*/ struct drm_bridge *drmm_of_get_bridge(struct drm_device *drm, struct device_node *np,
u32 port, u32 endpoint)
{ struct drm_bridge *bridge; struct drm_panel *panel; int ret;
ret = drm_of_find_panel_or_bridge(np, port, endpoint,
&panel, &bridge); if (ret) return ERR_PTR(ret);
if (panel)
bridge = drmm_panel_bridge_add(drm, panel);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.