/* * Copyright (C) 2013, NVIDIA Corporation. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sub license, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice (including the * next paragraph) shall be included in all copies or substantial portions * of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. */ #include <linux/backlight.h> #include <linux/err.h> #include <linux/module.h> #include <drm/drm_crtc.h> #include <drm/drm_panel.h> #include <drm/drm_print.h> static DEFINE_MUTEX(panel_lock); static LIST_HEAD(panel_list); /** * DOC: drm panel * * The DRM panel helpers allow drivers to register panel objects with a * central registry and provide functions to retrieve those panels in display * drivers. * * For easy integration into drivers using the &drm_bridge infrastructure please * take look at drm_panel_bridge_add() and devm_drm_panel_bridge_add(). */ /** * drm_panel_init - initialize a panel * @panel: DRM panel * @dev: parent device of the panel * @funcs: panel operations * @connector_type: the connector type (DRM_MODE_CONNECTOR_*) corresponding to * the panel interface * * Initialize the panel structure for subsequent registration with * drm_panel_add(). */ void drm_panel_init(struct drm_panel *panel, struct device *dev, const struct drm_panel_funcs *funcs, int connector_type) { … } EXPORT_SYMBOL(…); /** * drm_panel_add - add a panel to the global registry * @panel: panel to add * * Add a panel to the global registry so that it can be looked up by display * drivers. */ void drm_panel_add(struct drm_panel *panel) { … } EXPORT_SYMBOL(…); /** * drm_panel_remove - remove a panel from the global registry * @panel: DRM panel * * Removes a panel from the global registry. */ void drm_panel_remove(struct drm_panel *panel) { … } EXPORT_SYMBOL(…); /** * drm_panel_prepare - power on a panel * @panel: DRM panel * * Calling this function will enable power and deassert any reset signals to * the panel. After this has completed it is possible to communicate with any * integrated circuitry via a command bus. * * Return: 0 on success or a negative error code on failure. */ int drm_panel_prepare(struct drm_panel *panel) { … } EXPORT_SYMBOL(…); /** * drm_panel_unprepare - power off a panel * @panel: DRM panel * * Calling this function will completely power off a panel (assert the panel's * reset, turn off power supplies, ...). After this function has completed, it * is usually no longer possible to communicate with the panel until another * call to drm_panel_prepare(). * * Return: 0 on success or a negative error code on failure. */ int drm_panel_unprepare(struct drm_panel *panel) { … } EXPORT_SYMBOL(…); /** * drm_panel_enable - enable a panel * @panel: DRM panel * * Calling this function will cause the panel display drivers to be turned on * and the backlight to be enabled. Content will be visible on screen after * this call completes. * * Return: 0 on success or a negative error code on failure. */ int drm_panel_enable(struct drm_panel *panel) { … } EXPORT_SYMBOL(…); /** * drm_panel_disable - disable a panel * @panel: DRM panel * * This will typically turn off the panel's backlight or disable the display * drivers. For smart panels it should still be possible to communicate with * the integrated circuitry via any command bus after this call. * * Return: 0 on success or a negative error code on failure. */ int drm_panel_disable(struct drm_panel *panel) { … } EXPORT_SYMBOL(…); /** * drm_panel_get_modes - probe the available display modes of a panel * @panel: DRM panel * @connector: DRM connector * * The modes probed from the panel are automatically added to the connector * that the panel is attached to. * * Return: The number of modes available from the panel on success, or 0 on * failure (no modes). */ int drm_panel_get_modes(struct drm_panel *panel, struct drm_connector *connector) { … } EXPORT_SYMBOL(…); #ifdef CONFIG_OF /** * of_drm_find_panel - look up a panel using a device tree node * @np: device tree node of the panel * * Searches the set of registered panels for one that matches the given device * tree node. If a matching panel is found, return a pointer to it. * * Return: A pointer to the panel registered for the specified device tree * node or an ERR_PTR() if no panel matching the device tree node can be found. * * Possible error codes returned by this function: * * - EPROBE_DEFER: the panel device has not been probed yet, and the caller * should retry later * - ENODEV: the device is not available (status != "okay" or "ok") */ struct drm_panel *of_drm_find_panel(const struct device_node *np) { … } EXPORT_SYMBOL(…); /** * of_drm_get_panel_orientation - look up the orientation of the panel through * the "rotation" binding from a device tree node * @np: device tree node of the panel * @orientation: orientation enum to be filled in * * Looks up the rotation of a panel in the device tree. The orientation of the * panel is expressed as a property name "rotation" in the device tree. The * rotation in the device tree is counter clockwise. * * Return: 0 when a valid rotation value (0, 90, 180, or 270) is read or the * rotation property doesn't exist. Return a negative error code on failure. */ int of_drm_get_panel_orientation(const struct device_node *np, enum drm_panel_orientation *orientation) { … } EXPORT_SYMBOL(…); #endif /** * drm_is_panel_follower() - Check if the device is a panel follower * @dev: The 'struct device' to check * * This checks to see if a device needs to be power sequenced together with * a panel using the panel follower API. * At the moment panels can only be followed on device tree enabled systems. * The "panel" property of the follower points to the panel to be followed. * * Return: true if we should be power sequenced with a panel; false otherwise. */ bool drm_is_panel_follower(struct device *dev) { … } EXPORT_SYMBOL(…); /** * drm_panel_add_follower() - Register something to follow panel state. * @follower_dev: The 'struct device' for the follower. * @follower: The panel follower descriptor for the follower. * * A panel follower is called right after preparing the panel and right before * unpreparing the panel. It's primary intention is to power on an associated * touchscreen, though it could be used for any similar devices. Multiple * devices are allowed the follow the same panel. * * If a follower is added to a panel that's already been turned on, the * follower's prepare callback is called right away. * * At the moment panels can only be followed on device tree enabled systems. * The "panel" property of the follower points to the panel to be followed. * * Return: 0 or an error code. Note that -ENODEV means that we detected that * follower_dev is not actually following a panel. The caller may * choose to ignore this return value if following a panel is optional. */ int drm_panel_add_follower(struct device *follower_dev, struct drm_panel_follower *follower) { … } EXPORT_SYMBOL(…); /** * drm_panel_remove_follower() - Reverse drm_panel_add_follower(). * @follower: The panel follower descriptor for the follower. * * Undo drm_panel_add_follower(). This includes calling the follower's * unprepare function if we're removed from a panel that's currently prepared. * * Return: 0 or an error code. */ void drm_panel_remove_follower(struct drm_panel_follower *follower) { … } EXPORT_SYMBOL(…); static void drm_panel_remove_follower_void(void *follower) { … } /** * devm_drm_panel_add_follower() - devm version of drm_panel_add_follower() * @follower_dev: The 'struct device' for the follower. * @follower: The panel follower descriptor for the follower. * * Handles calling drm_panel_remove_follower() using devm on the follower_dev. * * Return: 0 or an error code. */ int devm_drm_panel_add_follower(struct device *follower_dev, struct drm_panel_follower *follower) { … } EXPORT_SYMBOL(…); #if IS_REACHABLE(CONFIG_BACKLIGHT_CLASS_DEVICE) /** * drm_panel_of_backlight - use backlight device node for backlight * @panel: DRM panel * * Use this function to enable backlight handling if your panel * uses device tree and has a backlight phandle. * * When the panel is enabled backlight will be enabled after a * successful call to &drm_panel_funcs.enable() * * When the panel is disabled backlight will be disabled before the * call to &drm_panel_funcs.disable(). * * A typical implementation for a panel driver supporting device tree * will call this function at probe time. Backlight will then be handled * transparently without requiring any intervention from the driver. * drm_panel_of_backlight() must be called after the call to drm_panel_init(). * * Return: 0 on success or a negative error code on failure. */ int drm_panel_of_backlight(struct drm_panel *panel) { … } EXPORT_SYMBOL(…); #endif MODULE_AUTHOR(…) …; MODULE_DESCRIPTION(…) …; MODULE_LICENSE(…) …;