2016-08-31 19:09:05 +03:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2016 Intel Corporation
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
* documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
* the above copyright notice appear in all copies and that both that copyright
|
|
|
|
* notice and this permission notice appear in supporting documentation, and
|
|
|
|
* that the name of the copyright holders not be used in advertising or
|
|
|
|
* publicity pertaining to distribution of the software without specific,
|
|
|
|
* written prior permission. The copyright holders make no representations
|
|
|
|
* about the suitability of this software for any purpose. It is provided "as
|
|
|
|
* is" without express or implied warranty.
|
|
|
|
*
|
|
|
|
* THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
|
|
|
|
* INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
|
|
|
|
* EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
|
|
|
|
* CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
|
|
|
|
* DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
|
|
|
* TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
|
|
|
|
* OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __DRM_BRIDGE_H__
|
|
|
|
#define __DRM_BRIDGE_H__
|
|
|
|
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/ctype.h>
|
2020-01-06 17:34:06 +03:00
|
|
|
|
|
|
|
#include <drm/drm_atomic.h>
|
2019-12-03 17:15:07 +03:00
|
|
|
#include <drm/drm_encoder.h>
|
2016-08-31 19:09:05 +03:00
|
|
|
#include <drm/drm_mode_object.h>
|
|
|
|
#include <drm/drm_modes.h>
|
|
|
|
|
|
|
|
struct drm_bridge;
|
2018-01-12 10:48:52 +03:00
|
|
|
struct drm_bridge_timings;
|
2017-06-02 23:25:14 +03:00
|
|
|
struct drm_panel;
|
2016-08-31 19:09:05 +03:00
|
|
|
|
2020-01-06 17:34:06 +03:00
|
|
|
/**
|
|
|
|
* struct drm_bridge_state - Atomic bridge state object
|
|
|
|
* @base: inherit from &drm_private_state
|
|
|
|
* @bridge: the bridge this state refers to
|
|
|
|
*/
|
|
|
|
struct drm_bridge_state {
|
|
|
|
struct drm_private_state base;
|
|
|
|
|
|
|
|
struct drm_bridge *bridge;
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline struct drm_bridge_state *
|
|
|
|
drm_priv_to_bridge_state(struct drm_private_state *priv)
|
|
|
|
{
|
|
|
|
return container_of(priv, struct drm_bridge_state, base);
|
|
|
|
}
|
|
|
|
|
2016-08-31 19:09:05 +03:00
|
|
|
/**
|
|
|
|
* struct drm_bridge_funcs - drm_bridge control functions
|
|
|
|
*/
|
|
|
|
struct drm_bridge_funcs {
|
|
|
|
/**
|
|
|
|
* @attach:
|
|
|
|
*
|
|
|
|
* This callback is invoked whenever our bridge is being attached to a
|
|
|
|
* &drm_encoder.
|
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @attach callback is optional.
|
2016-08-31 19:09:05 +03:00
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* Zero on success, error code on failure.
|
|
|
|
*/
|
|
|
|
int (*attach)(struct drm_bridge *bridge);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @detach:
|
|
|
|
*
|
|
|
|
* This callback is invoked whenever our bridge is being detached from a
|
|
|
|
* &drm_encoder.
|
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @detach callback is optional.
|
2016-08-31 19:09:05 +03:00
|
|
|
*/
|
|
|
|
void (*detach)(struct drm_bridge *bridge);
|
|
|
|
|
2017-05-15 12:33:47 +03:00
|
|
|
/**
|
|
|
|
* @mode_valid:
|
|
|
|
*
|
|
|
|
* This callback is used to check if a specific mode is valid in this
|
|
|
|
* bridge. This should be implemented if the bridge has some sort of
|
|
|
|
* restriction in the modes it can display. For example, a given bridge
|
|
|
|
* may be responsible to set a clock value. If the clock can not
|
|
|
|
* produce all the values for the available modes then this callback
|
|
|
|
* can be used to restrict the number of modes to only the ones that
|
|
|
|
* can be displayed.
|
|
|
|
*
|
|
|
|
* This hook is used by the probe helpers to filter the mode list in
|
|
|
|
* drm_helper_probe_single_connector_modes(), and it is used by the
|
|
|
|
* atomic helpers to validate modes supplied by userspace in
|
|
|
|
* drm_atomic_helper_check_modeset().
|
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @mode_valid callback is optional.
|
2017-05-15 12:33:47 +03:00
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* Since this function is both called from the check phase of an atomic
|
|
|
|
* commit, and the mode validation in the probe paths it is not allowed
|
|
|
|
* to look at anything else but the passed-in mode, and validate it
|
|
|
|
* against configuration-invariant hardward constraints. Any further
|
|
|
|
* limits which depend upon the configuration can only be checked in
|
|
|
|
* @mode_fixup.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* drm_mode_status Enum
|
|
|
|
*/
|
2018-01-29 12:55:31 +03:00
|
|
|
enum drm_mode_status (*mode_valid)(struct drm_bridge *bridge,
|
2017-05-15 12:33:47 +03:00
|
|
|
const struct drm_display_mode *mode);
|
|
|
|
|
2016-08-31 19:09:05 +03:00
|
|
|
/**
|
|
|
|
* @mode_fixup:
|
|
|
|
*
|
2018-05-15 23:37:36 +03:00
|
|
|
* This callback is used to validate and adjust a mode. The parameter
|
2016-08-31 19:09:05 +03:00
|
|
|
* mode is the display mode that should be fed to the next element in
|
|
|
|
* the display chain, either the final &drm_connector or the next
|
|
|
|
* &drm_bridge. The parameter adjusted_mode is the input mode the bridge
|
|
|
|
* requires. It can be modified by this callback and does not need to
|
2017-05-15 12:11:35 +03:00
|
|
|
* match mode. See also &drm_crtc_state.adjusted_mode for more details.
|
2016-08-31 19:09:05 +03:00
|
|
|
*
|
|
|
|
* This is the only hook that allows a bridge to reject a modeset. If
|
|
|
|
* this function passes all other callbacks must succeed for this
|
|
|
|
* configuration.
|
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @mode_fixup callback is optional.
|
2016-08-31 19:09:05 +03:00
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* This function is called in the check phase of atomic modesets, which
|
|
|
|
* can be aborted for any reason (including on userspace's request to
|
|
|
|
* just check whether a configuration would be possible). Drivers MUST
|
|
|
|
* NOT touch any persistent state (hardware or software) or data
|
|
|
|
* structures except the passed in @state parameter.
|
|
|
|
*
|
2017-05-15 12:33:47 +03:00
|
|
|
* Also beware that userspace can request its own custom modes, neither
|
|
|
|
* core nor helpers filter modes to the list of probe modes reported by
|
|
|
|
* the GETCONNECTOR IOCTL and stored in &drm_connector.modes. To ensure
|
|
|
|
* that modes are filtered consistently put any bridge constraints and
|
|
|
|
* limits checks into @mode_valid.
|
|
|
|
*
|
2016-08-31 19:09:05 +03:00
|
|
|
* RETURNS:
|
|
|
|
*
|
|
|
|
* True if an acceptable configuration is possible, false if the modeset
|
|
|
|
* operation should be rejected.
|
|
|
|
*/
|
|
|
|
bool (*mode_fixup)(struct drm_bridge *bridge,
|
|
|
|
const struct drm_display_mode *mode,
|
|
|
|
struct drm_display_mode *adjusted_mode);
|
|
|
|
/**
|
|
|
|
* @disable:
|
|
|
|
*
|
|
|
|
* This callback should disable the bridge. It is called right before
|
|
|
|
* the preceding element in the display pipe is disabled. If the
|
|
|
|
* preceding element is a bridge this means it's called before that
|
2017-01-02 11:17:26 +03:00
|
|
|
* bridge's @disable vfunc. If the preceding element is a &drm_encoder
|
|
|
|
* it's called right before the &drm_encoder_helper_funcs.disable,
|
|
|
|
* &drm_encoder_helper_funcs.prepare or &drm_encoder_helper_funcs.dpms
|
|
|
|
* hook.
|
2016-08-31 19:09:05 +03:00
|
|
|
*
|
|
|
|
* The bridge can assume that the display pipe (i.e. clocks and timing
|
|
|
|
* signals) feeding it is still running when this callback is called.
|
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @disable callback is optional.
|
2016-08-31 19:09:05 +03:00
|
|
|
*/
|
|
|
|
void (*disable)(struct drm_bridge *bridge);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @post_disable:
|
|
|
|
*
|
2017-01-02 11:17:26 +03:00
|
|
|
* This callback should disable the bridge. It is called right after the
|
|
|
|
* preceding element in the display pipe is disabled. If the preceding
|
|
|
|
* element is a bridge this means it's called after that bridge's
|
|
|
|
* @post_disable function. If the preceding element is a &drm_encoder
|
|
|
|
* it's called right after the encoder's
|
|
|
|
* &drm_encoder_helper_funcs.disable, &drm_encoder_helper_funcs.prepare
|
|
|
|
* or &drm_encoder_helper_funcs.dpms hook.
|
2016-08-31 19:09:05 +03:00
|
|
|
*
|
|
|
|
* The bridge must assume that the display pipe (i.e. clocks and timing
|
|
|
|
* singals) feeding it is no longer running when this callback is
|
|
|
|
* called.
|
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @post_disable callback is optional.
|
2016-08-31 19:09:05 +03:00
|
|
|
*/
|
|
|
|
void (*post_disable)(struct drm_bridge *bridge);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @mode_set:
|
|
|
|
*
|
|
|
|
* This callback should set the given mode on the bridge. It is called
|
2017-01-02 11:17:26 +03:00
|
|
|
* after the @mode_set callback for the preceding element in the display
|
|
|
|
* pipeline has been called already. If the bridge is the first element
|
|
|
|
* then this would be &drm_encoder_helper_funcs.mode_set. The display
|
|
|
|
* pipe (i.e. clocks and timing signals) is off when this function is
|
|
|
|
* called.
|
2018-04-09 18:24:27 +03:00
|
|
|
*
|
|
|
|
* The adjusted_mode parameter is the mode output by the CRTC for the
|
|
|
|
* first bridge in the chain. It can be different from the mode
|
|
|
|
* parameter that contains the desired mode for the connector at the end
|
|
|
|
* of the bridges chain, for instance when the first bridge in the chain
|
|
|
|
* performs scaling. The adjusted mode is mostly useful for the first
|
|
|
|
* bridge in the chain and is likely irrelevant for the other bridges.
|
|
|
|
*
|
|
|
|
* For atomic drivers the adjusted_mode is the mode stored in
|
|
|
|
* &drm_crtc_state.adjusted_mode.
|
|
|
|
*
|
|
|
|
* NOTE:
|
|
|
|
*
|
|
|
|
* If a need arises to store and access modes adjusted for other
|
|
|
|
* locations than the connection between the CRTC and the first bridge,
|
|
|
|
* the DRM framework will have to be extended with DRM bridge states.
|
2016-08-31 19:09:05 +03:00
|
|
|
*/
|
|
|
|
void (*mode_set)(struct drm_bridge *bridge,
|
2018-04-06 17:39:01 +03:00
|
|
|
const struct drm_display_mode *mode,
|
|
|
|
const struct drm_display_mode *adjusted_mode);
|
2016-08-31 19:09:05 +03:00
|
|
|
/**
|
|
|
|
* @pre_enable:
|
|
|
|
*
|
|
|
|
* This callback should enable the bridge. It is called right before
|
|
|
|
* the preceding element in the display pipe is enabled. If the
|
|
|
|
* preceding element is a bridge this means it's called before that
|
2017-01-02 11:17:26 +03:00
|
|
|
* bridge's @pre_enable function. If the preceding element is a
|
|
|
|
* &drm_encoder it's called right before the encoder's
|
|
|
|
* &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or
|
|
|
|
* &drm_encoder_helper_funcs.dpms hook.
|
2016-08-31 19:09:05 +03:00
|
|
|
*
|
|
|
|
* The display pipe (i.e. clocks and timing signals) feeding this bridge
|
|
|
|
* will not yet be running when this callback is called. The bridge must
|
|
|
|
* not enable the display link feeding the next bridge in the chain (if
|
|
|
|
* there is one) when this callback is called.
|
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @pre_enable callback is optional.
|
2016-08-31 19:09:05 +03:00
|
|
|
*/
|
|
|
|
void (*pre_enable)(struct drm_bridge *bridge);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @enable:
|
|
|
|
*
|
|
|
|
* This callback should enable the bridge. It is called right after
|
|
|
|
* the preceding element in the display pipe is enabled. If the
|
|
|
|
* preceding element is a bridge this means it's called after that
|
2017-01-02 11:17:26 +03:00
|
|
|
* bridge's @enable function. If the preceding element is a
|
|
|
|
* &drm_encoder it's called right after the encoder's
|
|
|
|
* &drm_encoder_helper_funcs.enable, &drm_encoder_helper_funcs.commit or
|
|
|
|
* &drm_encoder_helper_funcs.dpms hook.
|
2016-08-31 19:09:05 +03:00
|
|
|
*
|
|
|
|
* The bridge can assume that the display pipe (i.e. clocks and timing
|
|
|
|
* signals) feeding it is running when this callback is called. This
|
|
|
|
* callback must enable the display link feeding the next bridge in the
|
|
|
|
* chain if there is one.
|
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @enable callback is optional.
|
2016-08-31 19:09:05 +03:00
|
|
|
*/
|
|
|
|
void (*enable)(struct drm_bridge *bridge);
|
2019-06-11 19:08:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_pre_enable:
|
|
|
|
*
|
|
|
|
* This callback should enable the bridge. It is called right before
|
|
|
|
* the preceding element in the display pipe is enabled. If the
|
|
|
|
* preceding element is a bridge this means it's called before that
|
|
|
|
* bridge's @atomic_pre_enable or @pre_enable function. If the preceding
|
|
|
|
* element is a &drm_encoder it's called right before the encoder's
|
|
|
|
* &drm_encoder_helper_funcs.atomic_enable hook.
|
|
|
|
*
|
|
|
|
* The display pipe (i.e. clocks and timing signals) feeding this bridge
|
|
|
|
* will not yet be running when this callback is called. The bridge must
|
|
|
|
* not enable the display link feeding the next bridge in the chain (if
|
|
|
|
* there is one) when this callback is called.
|
|
|
|
*
|
|
|
|
* Note that this function will only be invoked in the context of an
|
2019-12-03 17:15:05 +03:00
|
|
|
* atomic commit. It will not be invoked from
|
|
|
|
* &drm_bridge_chain_pre_enable. It would be prudent to also provide an
|
|
|
|
* implementation of @pre_enable if you are expecting driver calls into
|
|
|
|
* &drm_bridge_chain_pre_enable.
|
2019-06-11 19:08:17 +03:00
|
|
|
*
|
|
|
|
* The @atomic_pre_enable callback is optional.
|
|
|
|
*/
|
|
|
|
void (*atomic_pre_enable)(struct drm_bridge *bridge,
|
2019-12-03 17:15:11 +03:00
|
|
|
struct drm_atomic_state *old_state);
|
2019-06-11 19:08:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_enable:
|
|
|
|
*
|
|
|
|
* This callback should enable the bridge. It is called right after
|
|
|
|
* the preceding element in the display pipe is enabled. If the
|
|
|
|
* preceding element is a bridge this means it's called after that
|
|
|
|
* bridge's @atomic_enable or @enable function. If the preceding element
|
|
|
|
* is a &drm_encoder it's called right after the encoder's
|
|
|
|
* &drm_encoder_helper_funcs.atomic_enable hook.
|
|
|
|
*
|
|
|
|
* The bridge can assume that the display pipe (i.e. clocks and timing
|
|
|
|
* signals) feeding it is running when this callback is called. This
|
|
|
|
* callback must enable the display link feeding the next bridge in the
|
|
|
|
* chain if there is one.
|
|
|
|
*
|
|
|
|
* Note that this function will only be invoked in the context of an
|
2019-12-03 17:15:05 +03:00
|
|
|
* atomic commit. It will not be invoked from &drm_bridge_chain_enable.
|
|
|
|
* It would be prudent to also provide an implementation of @enable if
|
|
|
|
* you are expecting driver calls into &drm_bridge_chain_enable.
|
2019-06-11 19:08:17 +03:00
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @atomic_enable callback is optional.
|
2019-06-11 19:08:17 +03:00
|
|
|
*/
|
|
|
|
void (*atomic_enable)(struct drm_bridge *bridge,
|
2019-12-03 17:15:11 +03:00
|
|
|
struct drm_atomic_state *old_state);
|
2019-06-11 19:08:17 +03:00
|
|
|
/**
|
|
|
|
* @atomic_disable:
|
|
|
|
*
|
|
|
|
* This callback should disable the bridge. It is called right before
|
|
|
|
* the preceding element in the display pipe is disabled. If the
|
|
|
|
* preceding element is a bridge this means it's called before that
|
|
|
|
* bridge's @atomic_disable or @disable vfunc. If the preceding element
|
|
|
|
* is a &drm_encoder it's called right before the
|
|
|
|
* &drm_encoder_helper_funcs.atomic_disable hook.
|
|
|
|
*
|
|
|
|
* The bridge can assume that the display pipe (i.e. clocks and timing
|
|
|
|
* signals) feeding it is still running when this callback is called.
|
|
|
|
*
|
|
|
|
* Note that this function will only be invoked in the context of an
|
2019-12-03 17:15:05 +03:00
|
|
|
* atomic commit. It will not be invoked from
|
|
|
|
* &drm_bridge_chain_disable. It would be prudent to also provide an
|
|
|
|
* implementation of @disable if you are expecting driver calls into
|
|
|
|
* &drm_bridge_chain_disable.
|
2019-06-11 19:08:17 +03:00
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @atomic_disable callback is optional.
|
2019-06-11 19:08:17 +03:00
|
|
|
*/
|
|
|
|
void (*atomic_disable)(struct drm_bridge *bridge,
|
2019-12-03 17:15:11 +03:00
|
|
|
struct drm_atomic_state *old_state);
|
2019-06-11 19:08:17 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_post_disable:
|
|
|
|
*
|
|
|
|
* This callback should disable the bridge. It is called right after the
|
|
|
|
* preceding element in the display pipe is disabled. If the preceding
|
|
|
|
* element is a bridge this means it's called after that bridge's
|
|
|
|
* @atomic_post_disable or @post_disable function. If the preceding
|
|
|
|
* element is a &drm_encoder it's called right after the encoder's
|
|
|
|
* &drm_encoder_helper_funcs.atomic_disable hook.
|
|
|
|
*
|
|
|
|
* The bridge must assume that the display pipe (i.e. clocks and timing
|
|
|
|
* signals) feeding it is no longer running when this callback is
|
|
|
|
* called.
|
|
|
|
*
|
|
|
|
* Note that this function will only be invoked in the context of an
|
2019-12-03 17:15:05 +03:00
|
|
|
* atomic commit. It will not be invoked from
|
|
|
|
* &drm_bridge_chain_post_disable.
|
2019-06-11 19:08:17 +03:00
|
|
|
* It would be prudent to also provide an implementation of
|
|
|
|
* @post_disable if you are expecting driver calls into
|
2019-12-03 17:15:05 +03:00
|
|
|
* &drm_bridge_chain_post_disable.
|
2019-06-11 19:08:17 +03:00
|
|
|
*
|
2019-08-22 02:55:02 +03:00
|
|
|
* The @atomic_post_disable callback is optional.
|
2019-06-11 19:08:17 +03:00
|
|
|
*/
|
|
|
|
void (*atomic_post_disable)(struct drm_bridge *bridge,
|
2019-12-03 17:15:11 +03:00
|
|
|
struct drm_atomic_state *old_state);
|
2020-01-06 17:34:06 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_duplicate_state:
|
|
|
|
*
|
|
|
|
* Duplicate the current bridge state object (which is guaranteed to be
|
|
|
|
* non-NULL).
|
|
|
|
*
|
|
|
|
* The atomic_duplicate_state() is optional. When not implemented the
|
|
|
|
* core allocates a drm_bridge_state object and calls
|
|
|
|
* &__drm_atomic_helper_bridge_duplicate_state() to initialize it.
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
* A valid drm_bridge_state object or NULL if the allocation fails.
|
|
|
|
*/
|
|
|
|
struct drm_bridge_state *(*atomic_duplicate_state)(struct drm_bridge *bridge);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_destroy_state:
|
|
|
|
*
|
|
|
|
* Destroy a bridge state object previously allocated by
|
|
|
|
* &drm_bridge_funcs.atomic_duplicate_state().
|
|
|
|
*
|
|
|
|
* The atomic_destroy_state hook is optional. When not implemented the
|
|
|
|
* core calls kfree() on the state.
|
|
|
|
*/
|
|
|
|
void (*atomic_destroy_state)(struct drm_bridge *bridge,
|
|
|
|
struct drm_bridge_state *state);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @atomic_reset:
|
|
|
|
*
|
|
|
|
* Reset the bridge to a predefined state (or retrieve its current
|
|
|
|
* state) and return a &drm_bridge_state object matching this state.
|
|
|
|
* This function is called at attach time.
|
|
|
|
*
|
|
|
|
* The atomic_reset hook is optional. When not implemented the core
|
|
|
|
* allocates a new state and calls &__drm_atomic_helper_bridge_reset().
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
* A valid drm_bridge_state object in case of success, an ERR_PTR()
|
|
|
|
* giving the reason of the failure otherwise.
|
|
|
|
*/
|
|
|
|
struct drm_bridge_state *(*atomic_reset)(struct drm_bridge *bridge);
|
2016-08-31 19:09:05 +03:00
|
|
|
};
|
|
|
|
|
2018-01-12 10:48:52 +03:00
|
|
|
/**
|
|
|
|
* struct drm_bridge_timings - timing information for the bridge
|
|
|
|
*/
|
|
|
|
struct drm_bridge_timings {
|
|
|
|
/**
|
2018-09-05 08:21:08 +03:00
|
|
|
* @input_bus_flags:
|
2018-01-12 10:48:52 +03:00
|
|
|
*
|
2018-09-05 08:21:08 +03:00
|
|
|
* Tells what additional settings for the pixel data on the bus
|
|
|
|
* this bridge requires (like pixel signal polarity). See also
|
|
|
|
* &drm_display_info->bus_flags.
|
2018-01-12 10:48:52 +03:00
|
|
|
*/
|
2018-09-05 08:21:08 +03:00
|
|
|
u32 input_bus_flags;
|
2018-01-12 10:48:52 +03:00
|
|
|
/**
|
|
|
|
* @setup_time_ps:
|
|
|
|
*
|
|
|
|
* Defines the time in picoseconds the input data lines must be
|
|
|
|
* stable before the clock edge.
|
|
|
|
*/
|
|
|
|
u32 setup_time_ps;
|
|
|
|
/**
|
|
|
|
* @hold_time_ps:
|
|
|
|
*
|
|
|
|
* Defines the time in picoseconds taken for the bridge to sample the
|
|
|
|
* input signal after the clock edge.
|
|
|
|
*/
|
|
|
|
u32 hold_time_ps;
|
2019-03-05 00:05:34 +03:00
|
|
|
/**
|
|
|
|
* @dual_link:
|
|
|
|
*
|
|
|
|
* True if the bus operates in dual-link mode. The exact meaning is
|
|
|
|
* dependent on the bus type. For LVDS buses, this indicates that even-
|
|
|
|
* and odd-numbered pixels are received on separate links.
|
|
|
|
*/
|
|
|
|
bool dual_link;
|
2018-01-12 10:48:52 +03:00
|
|
|
};
|
|
|
|
|
2016-08-31 19:09:05 +03:00
|
|
|
/**
|
|
|
|
* struct drm_bridge - central DRM bridge control structure
|
|
|
|
*/
|
|
|
|
struct drm_bridge {
|
2020-01-06 17:34:06 +03:00
|
|
|
/** @base: inherit from &drm_private_object */
|
|
|
|
struct drm_private_obj base;
|
2018-06-06 22:04:29 +03:00
|
|
|
/** @dev: DRM device this bridge belongs to */
|
2016-08-31 19:09:05 +03:00
|
|
|
struct drm_device *dev;
|
2018-06-06 22:04:29 +03:00
|
|
|
/** @encoder: encoder to which this bridge is connected */
|
2016-08-31 19:09:05 +03:00
|
|
|
struct drm_encoder *encoder;
|
2019-12-03 17:15:08 +03:00
|
|
|
/** @chain_node: used to form a bridge chain */
|
|
|
|
struct list_head chain_node;
|
2016-08-31 19:09:05 +03:00
|
|
|
#ifdef CONFIG_OF
|
2018-06-06 22:04:29 +03:00
|
|
|
/** @of_node: device node pointer to the bridge */
|
2016-08-31 19:09:05 +03:00
|
|
|
struct device_node *of_node;
|
|
|
|
#endif
|
2018-06-06 22:04:29 +03:00
|
|
|
/** @list: to keep track of all added bridges */
|
2016-08-31 19:09:05 +03:00
|
|
|
struct list_head list;
|
2018-06-06 22:04:29 +03:00
|
|
|
/**
|
|
|
|
* @timings:
|
|
|
|
*
|
|
|
|
* the timing specification for the bridge, if any (may be NULL)
|
|
|
|
*/
|
2018-01-12 10:48:52 +03:00
|
|
|
const struct drm_bridge_timings *timings;
|
2018-06-06 22:04:29 +03:00
|
|
|
/** @funcs: control functions */
|
2016-08-31 19:09:05 +03:00
|
|
|
const struct drm_bridge_funcs *funcs;
|
2018-06-06 22:04:29 +03:00
|
|
|
/** @driver_private: pointer to the bridge driver's internal context */
|
2016-08-31 19:09:05 +03:00
|
|
|
void *driver_private;
|
|
|
|
};
|
|
|
|
|
2020-01-06 17:34:06 +03:00
|
|
|
static inline struct drm_bridge *
|
|
|
|
drm_priv_to_bridge(struct drm_private_obj *priv)
|
|
|
|
{
|
|
|
|
return container_of(priv, struct drm_bridge, base);
|
|
|
|
}
|
|
|
|
|
2017-07-03 11:42:17 +03:00
|
|
|
void drm_bridge_add(struct drm_bridge *bridge);
|
2016-08-31 19:09:05 +03:00
|
|
|
void drm_bridge_remove(struct drm_bridge *bridge);
|
|
|
|
struct drm_bridge *of_drm_find_bridge(struct device_node *np);
|
2016-11-28 18:59:08 +03:00
|
|
|
int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
|
|
|
|
struct drm_bridge *previous);
|
2016-08-31 19:09:05 +03:00
|
|
|
|
2019-12-03 17:15:06 +03:00
|
|
|
/**
|
|
|
|
* drm_bridge_get_next_bridge() - Get the next bridge in the chain
|
|
|
|
* @bridge: bridge object
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
* the next bridge in the chain after @bridge, or NULL if @bridge is the last.
|
|
|
|
*/
|
|
|
|
static inline struct drm_bridge *
|
|
|
|
drm_bridge_get_next_bridge(struct drm_bridge *bridge)
|
|
|
|
{
|
2019-12-03 17:15:08 +03:00
|
|
|
if (list_is_last(&bridge->chain_node, &bridge->encoder->bridge_chain))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return list_next_entry(bridge, chain_node);
|
2019-12-03 17:15:06 +03:00
|
|
|
}
|
|
|
|
|
2019-12-03 17:15:10 +03:00
|
|
|
/**
|
|
|
|
* drm_bridge_get_prev_bridge() - Get the previous bridge in the chain
|
|
|
|
* @bridge: bridge object
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
* the previous bridge in the chain, or NULL if @bridge is the first.
|
|
|
|
*/
|
|
|
|
static inline struct drm_bridge *
|
|
|
|
drm_bridge_get_prev_bridge(struct drm_bridge *bridge)
|
|
|
|
{
|
|
|
|
if (list_is_first(&bridge->chain_node, &bridge->encoder->bridge_chain))
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return list_prev_entry(bridge, chain_node);
|
|
|
|
}
|
|
|
|
|
2019-12-03 17:15:07 +03:00
|
|
|
/**
|
|
|
|
* drm_bridge_chain_get_first_bridge() - Get the first bridge in the chain
|
|
|
|
* @encoder: encoder object
|
|
|
|
*
|
|
|
|
* RETURNS:
|
|
|
|
* the first bridge in the chain, or NULL if @encoder has no bridge attached
|
|
|
|
* to it.
|
|
|
|
*/
|
|
|
|
static inline struct drm_bridge *
|
|
|
|
drm_bridge_chain_get_first_bridge(struct drm_encoder *encoder)
|
|
|
|
{
|
2019-12-03 17:15:08 +03:00
|
|
|
return list_first_entry_or_null(&encoder->bridge_chain,
|
|
|
|
struct drm_bridge, chain_node);
|
2019-12-03 17:15:07 +03:00
|
|
|
}
|
|
|
|
|
2019-12-03 17:15:09 +03:00
|
|
|
/**
|
|
|
|
* drm_for_each_bridge_in_chain() - Iterate over all bridges present in a chain
|
|
|
|
* @encoder: the encoder to iterate bridges on
|
|
|
|
* @bridge: a bridge pointer updated to point to the current bridge at each
|
|
|
|
* iteration
|
|
|
|
*
|
|
|
|
* Iterate over all bridges present in the bridge chain attached to @encoder.
|
|
|
|
*/
|
|
|
|
#define drm_for_each_bridge_in_chain(encoder, bridge) \
|
|
|
|
list_for_each_entry(bridge, &(encoder)->bridge_chain, chain_node)
|
|
|
|
|
2019-12-03 17:15:05 +03:00
|
|
|
bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge,
|
|
|
|
const struct drm_display_mode *mode,
|
|
|
|
struct drm_display_mode *adjusted_mode);
|
|
|
|
enum drm_mode_status
|
|
|
|
drm_bridge_chain_mode_valid(struct drm_bridge *bridge,
|
|
|
|
const struct drm_display_mode *mode);
|
|
|
|
void drm_bridge_chain_disable(struct drm_bridge *bridge);
|
|
|
|
void drm_bridge_chain_post_disable(struct drm_bridge *bridge);
|
|
|
|
void drm_bridge_chain_mode_set(struct drm_bridge *bridge,
|
|
|
|
const struct drm_display_mode *mode,
|
|
|
|
const struct drm_display_mode *adjusted_mode);
|
|
|
|
void drm_bridge_chain_pre_enable(struct drm_bridge *bridge);
|
|
|
|
void drm_bridge_chain_enable(struct drm_bridge *bridge);
|
2016-08-31 19:09:05 +03:00
|
|
|
|
2019-12-03 17:15:05 +03:00
|
|
|
void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge,
|
|
|
|
struct drm_atomic_state *state);
|
|
|
|
void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
|
|
|
|
struct drm_atomic_state *state);
|
|
|
|
void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,
|
|
|
|
struct drm_atomic_state *state);
|
|
|
|
void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge,
|
2019-06-11 19:08:17 +03:00
|
|
|
struct drm_atomic_state *state);
|
|
|
|
|
2020-01-06 17:34:06 +03:00
|
|
|
void __drm_atomic_helper_bridge_reset(struct drm_bridge *bridge,
|
|
|
|
struct drm_bridge_state *state);
|
|
|
|
void __drm_atomic_helper_bridge_duplicate_state(struct drm_bridge *bridge,
|
|
|
|
struct drm_bridge_state *new);
|
|
|
|
|
|
|
|
static inline struct drm_bridge_state *
|
|
|
|
drm_atomic_get_bridge_state(struct drm_atomic_state *state,
|
|
|
|
struct drm_bridge *bridge)
|
|
|
|
{
|
|
|
|
struct drm_private_state *obj_state;
|
|
|
|
|
|
|
|
obj_state = drm_atomic_get_private_obj_state(state, &bridge->base);
|
|
|
|
if (IS_ERR(obj_state))
|
|
|
|
return ERR_CAST(obj_state);
|
|
|
|
|
|
|
|
return drm_priv_to_bridge_state(obj_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct drm_bridge_state *
|
|
|
|
drm_atomic_get_old_bridge_state(struct drm_atomic_state *state,
|
|
|
|
struct drm_bridge *bridge)
|
|
|
|
{
|
|
|
|
struct drm_private_state *obj_state;
|
|
|
|
|
|
|
|
obj_state = drm_atomic_get_old_private_obj_state(state, &bridge->base);
|
|
|
|
if (!obj_state)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return drm_priv_to_bridge_state(obj_state);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline struct drm_bridge_state *
|
|
|
|
drm_atomic_get_new_bridge_state(struct drm_atomic_state *state,
|
|
|
|
struct drm_bridge *bridge)
|
|
|
|
{
|
|
|
|
struct drm_private_state *obj_state;
|
|
|
|
|
|
|
|
obj_state = drm_atomic_get_new_private_obj_state(state, &bridge->base);
|
|
|
|
if (!obj_state)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
return drm_priv_to_bridge_state(obj_state);
|
|
|
|
}
|
|
|
|
|
2017-06-02 23:25:14 +03:00
|
|
|
#ifdef CONFIG_DRM_PANEL_BRIDGE
|
drm/bridge: panel: Infer connector type from panel by default
The drm panel bridge creates a connector using a connector type
explicitly passed by the display controller or bridge driver that
instantiates the panel bridge. Now that drm_panel reports its connector
type, we can use it to avoid passing an explicit (and often incorrect)
connector type to drm_panel_bridge_add() and
devm_drm_panel_bridge_add().
Several drivers report incorrect or unknown connector types to
userspace. Reporting a different type may result in a breakage. For that
reason, rename (devm_)drm_panel_bridge_add() to
(devm_)drm_panel_bridge_add_typed(), and add new
(devm_)drm_panel_bridge_add() functions that use the panel connector
type. Update all callers of (devm_)drm_panel_bridge_add() to the _typed
function, they will be converted one by one after testing.
The panel drivers have been updated with the following Coccinelle
semantic patch, with manual inspection and fixes to indentation.
@@
expression bridge;
expression dev;
expression panel;
identifier type;
@@
(
-bridge = drm_panel_bridge_add(panel, type);
+bridge = drm_panel_bridge_add_typed(panel, type);
|
-bridge = devm_drm_panel_bridge_add(dev, panel, type);
+bridge = devm_drm_panel_bridge_add_typed(dev, panel, type);
)
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190904132804.29680-3-laurent.pinchart@ideasonboard.com
2019-09-04 16:28:04 +03:00
|
|
|
struct drm_bridge *drm_panel_bridge_add(struct drm_panel *panel);
|
|
|
|
struct drm_bridge *drm_panel_bridge_add_typed(struct drm_panel *panel,
|
|
|
|
u32 connector_type);
|
2017-06-02 23:25:14 +03:00
|
|
|
void drm_panel_bridge_remove(struct drm_bridge *bridge);
|
2017-07-19 00:05:06 +03:00
|
|
|
struct drm_bridge *devm_drm_panel_bridge_add(struct device *dev,
|
drm/bridge: panel: Infer connector type from panel by default
The drm panel bridge creates a connector using a connector type
explicitly passed by the display controller or bridge driver that
instantiates the panel bridge. Now that drm_panel reports its connector
type, we can use it to avoid passing an explicit (and often incorrect)
connector type to drm_panel_bridge_add() and
devm_drm_panel_bridge_add().
Several drivers report incorrect or unknown connector types to
userspace. Reporting a different type may result in a breakage. For that
reason, rename (devm_)drm_panel_bridge_add() to
(devm_)drm_panel_bridge_add_typed(), and add new
(devm_)drm_panel_bridge_add() functions that use the panel connector
type. Update all callers of (devm_)drm_panel_bridge_add() to the _typed
function, they will be converted one by one after testing.
The panel drivers have been updated with the following Coccinelle
semantic patch, with manual inspection and fixes to indentation.
@@
expression bridge;
expression dev;
expression panel;
identifier type;
@@
(
-bridge = drm_panel_bridge_add(panel, type);
+bridge = drm_panel_bridge_add_typed(panel, type);
|
-bridge = devm_drm_panel_bridge_add(dev, panel, type);
+bridge = devm_drm_panel_bridge_add_typed(dev, panel, type);
)
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>
Link: https://patchwork.freedesktop.org/patch/msgid/20190904132804.29680-3-laurent.pinchart@ideasonboard.com
2019-09-04 16:28:04 +03:00
|
|
|
struct drm_panel *panel);
|
|
|
|
struct drm_bridge *devm_drm_panel_bridge_add_typed(struct device *dev,
|
|
|
|
struct drm_panel *panel,
|
|
|
|
u32 connector_type);
|
2019-12-07 17:03:32 +03:00
|
|
|
struct drm_connector *drm_panel_bridge_connector(struct drm_bridge *bridge);
|
2017-06-02 23:25:14 +03:00
|
|
|
#endif
|
|
|
|
|
2016-08-31 19:09:05 +03:00
|
|
|
#endif
|