LCOV - code coverage report
Current view: top level - drivers/gpu/drm - drm_bridge.c (source / functions) Hit Total Coverage
Test: combined.info Lines: 0 131 0.0 %
Date: 2022-04-01 14:35:51 Functions: 0 15 0.0 %
Branches: 0 110 0.0 %

           Branch data     Line data    Source code
       1                 :            : /*
       2                 :            :  * Copyright (c) 2014 Samsung Electronics Co., Ltd
       3                 :            :  *
       4                 :            :  * Permission is hereby granted, free of charge, to any person obtaining a
       5                 :            :  * copy of this software and associated documentation files (the "Software"),
       6                 :            :  * to deal in the Software without restriction, including without limitation
       7                 :            :  * the rights to use, copy, modify, merge, publish, distribute, sub license,
       8                 :            :  * and/or sell copies of the Software, and to permit persons to whom the
       9                 :            :  * Software is furnished to do so, subject to the following conditions:
      10                 :            :  *
      11                 :            :  * The above copyright notice and this permission notice (including the
      12                 :            :  * next paragraph) shall be included in all copies or substantial portions
      13                 :            :  * of the Software.
      14                 :            :  *
      15                 :            :  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
      16                 :            :  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
      17                 :            :  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
      18                 :            :  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
      19                 :            :  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
      20                 :            :  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
      21                 :            :  * DEALINGS IN THE SOFTWARE.
      22                 :            :  */
      23                 :            : 
      24                 :            : #include <linux/err.h>
      25                 :            : #include <linux/module.h>
      26                 :            : #include <linux/mutex.h>
      27                 :            : 
      28                 :            : #include <drm/drm_bridge.h>
      29                 :            : #include <drm/drm_encoder.h>
      30                 :            : 
      31                 :            : #include "drm_crtc_internal.h"
      32                 :            : 
      33                 :            : /**
      34                 :            :  * DOC: overview
      35                 :            :  *
      36                 :            :  * &struct drm_bridge represents a device that hangs on to an encoder. These are
      37                 :            :  * handy when a regular &drm_encoder entity isn't enough to represent the entire
      38                 :            :  * encoder chain.
      39                 :            :  *
      40                 :            :  * A bridge is always attached to a single &drm_encoder at a time, but can be
      41                 :            :  * either connected to it directly, or through an intermediate bridge::
      42                 :            :  *
      43                 :            :  *     encoder ---> bridge B ---> bridge A
      44                 :            :  *
      45                 :            :  * Here, the output of the encoder feeds to bridge B, and that furthers feeds to
      46                 :            :  * bridge A.
      47                 :            :  *
      48                 :            :  * The driver using the bridge is responsible to make the associations between
      49                 :            :  * the encoder and bridges. Once these links are made, the bridges will
      50                 :            :  * participate along with encoder functions to perform mode_set/enable/disable
      51                 :            :  * through the ops provided in &drm_bridge_funcs.
      52                 :            :  *
      53                 :            :  * drm_bridge, like drm_panel, aren't drm_mode_object entities like planes,
      54                 :            :  * CRTCs, encoders or connectors and hence are not visible to userspace. They
      55                 :            :  * just provide additional hooks to get the desired output at the end of the
      56                 :            :  * encoder chain.
      57                 :            :  *
      58                 :            :  * Bridges can also be chained up using the &drm_bridge.chain_node field.
      59                 :            :  *
      60                 :            :  * Both legacy CRTC helpers and the new atomic modeset helpers support bridges.
      61                 :            :  */
      62                 :            : 
      63                 :            : static DEFINE_MUTEX(bridge_lock);
      64                 :            : static LIST_HEAD(bridge_list);
      65                 :            : 
      66                 :            : /**
      67                 :            :  * drm_bridge_add - add the given bridge to the global bridge list
      68                 :            :  *
      69                 :            :  * @bridge: bridge control structure
      70                 :            :  */
      71                 :          0 : void drm_bridge_add(struct drm_bridge *bridge)
      72                 :            : {
      73                 :          0 :         mutex_lock(&bridge_lock);
      74                 :          0 :         list_add_tail(&bridge->list, &bridge_list);
      75                 :          0 :         mutex_unlock(&bridge_lock);
      76                 :          0 : }
      77                 :            : EXPORT_SYMBOL(drm_bridge_add);
      78                 :            : 
      79                 :            : /**
      80                 :            :  * drm_bridge_remove - remove the given bridge from the global bridge list
      81                 :            :  *
      82                 :            :  * @bridge: bridge control structure
      83                 :            :  */
      84                 :          0 : void drm_bridge_remove(struct drm_bridge *bridge)
      85                 :            : {
      86                 :          0 :         mutex_lock(&bridge_lock);
      87                 :          0 :         list_del_init(&bridge->list);
      88                 :          0 :         mutex_unlock(&bridge_lock);
      89                 :          0 : }
      90                 :            : EXPORT_SYMBOL(drm_bridge_remove);
      91                 :            : 
      92                 :            : /**
      93                 :            :  * drm_bridge_attach - attach the bridge to an encoder's chain
      94                 :            :  *
      95                 :            :  * @encoder: DRM encoder
      96                 :            :  * @bridge: bridge to attach
      97                 :            :  * @previous: previous bridge in the chain (optional)
      98                 :            :  *
      99                 :            :  * Called by a kms driver to link the bridge to an encoder's chain. The previous
     100                 :            :  * argument specifies the previous bridge in the chain. If NULL, the bridge is
     101                 :            :  * linked directly at the encoder's output. Otherwise it is linked at the
     102                 :            :  * previous bridge's output.
     103                 :            :  *
     104                 :            :  * If non-NULL the previous bridge must be already attached by a call to this
     105                 :            :  * function.
     106                 :            :  *
     107                 :            :  * Note that bridges attached to encoders are auto-detached during encoder
     108                 :            :  * cleanup in drm_encoder_cleanup(), so drm_bridge_attach() should generally
     109                 :            :  * *not* be balanced with a drm_bridge_detach() in driver code.
     110                 :            :  *
     111                 :            :  * RETURNS:
     112                 :            :  * Zero on success, error code on failure
     113                 :            :  */
     114                 :          0 : int drm_bridge_attach(struct drm_encoder *encoder, struct drm_bridge *bridge,
     115                 :            :                       struct drm_bridge *previous)
     116                 :            : {
     117                 :          0 :         int ret;
     118                 :            : 
     119         [ #  # ]:          0 :         if (!encoder || !bridge)
     120                 :            :                 return -EINVAL;
     121                 :            : 
     122   [ #  #  #  #  :          0 :         if (previous && (!previous->dev || previous->encoder != encoder))
                   #  # ]
     123                 :            :                 return -EINVAL;
     124                 :            : 
     125         [ #  # ]:          0 :         if (bridge->dev)
     126                 :            :                 return -EBUSY;
     127                 :            : 
     128                 :          0 :         bridge->dev = encoder->dev;
     129                 :          0 :         bridge->encoder = encoder;
     130                 :            : 
     131         [ #  # ]:          0 :         if (previous)
     132                 :          0 :                 list_add(&bridge->chain_node, &previous->chain_node);
     133                 :            :         else
     134                 :          0 :                 list_add(&bridge->chain_node, &encoder->bridge_chain);
     135                 :            : 
     136         [ #  # ]:          0 :         if (bridge->funcs->attach) {
     137                 :          0 :                 ret = bridge->funcs->attach(bridge);
     138         [ #  # ]:          0 :                 if (ret < 0) {
     139                 :          0 :                         list_del(&bridge->chain_node);
     140                 :          0 :                         bridge->dev = NULL;
     141                 :          0 :                         bridge->encoder = NULL;
     142                 :          0 :                         return ret;
     143                 :            :                 }
     144                 :            :         }
     145                 :            : 
     146                 :            :         return 0;
     147                 :            : }
     148                 :            : EXPORT_SYMBOL(drm_bridge_attach);
     149                 :            : 
     150                 :          0 : void drm_bridge_detach(struct drm_bridge *bridge)
     151                 :            : {
     152   [ #  #  #  # ]:          0 :         if (WARN_ON(!bridge))
     153                 :            :                 return;
     154                 :            : 
     155   [ #  #  #  # ]:          0 :         if (WARN_ON(!bridge->dev))
     156                 :            :                 return;
     157                 :            : 
     158         [ #  # ]:          0 :         if (bridge->funcs->detach)
     159                 :          0 :                 bridge->funcs->detach(bridge);
     160                 :            : 
     161                 :          0 :         list_del(&bridge->chain_node);
     162                 :          0 :         bridge->dev = NULL;
     163                 :            : }
     164                 :            : 
     165                 :            : /**
     166                 :            :  * DOC: bridge callbacks
     167                 :            :  *
     168                 :            :  * The &drm_bridge_funcs ops are populated by the bridge driver. The DRM
     169                 :            :  * internals (atomic and CRTC helpers) use the helpers defined in drm_bridge.c
     170                 :            :  * These helpers call a specific &drm_bridge_funcs op for all the bridges
     171                 :            :  * during encoder configuration.
     172                 :            :  *
     173                 :            :  * For detailed specification of the bridge callbacks see &drm_bridge_funcs.
     174                 :            :  */
     175                 :            : 
     176                 :            : /**
     177                 :            :  * drm_bridge_chain_mode_fixup - fixup proposed mode for all bridges in the
     178                 :            :  *                               encoder chain
     179                 :            :  * @bridge: bridge control structure
     180                 :            :  * @mode: desired mode to be set for the bridge
     181                 :            :  * @adjusted_mode: updated mode that works for this bridge
     182                 :            :  *
     183                 :            :  * Calls &drm_bridge_funcs.mode_fixup for all the bridges in the
     184                 :            :  * encoder chain, starting from the first bridge to the last.
     185                 :            :  *
     186                 :            :  * Note: the bridge passed should be the one closest to the encoder
     187                 :            :  *
     188                 :            :  * RETURNS:
     189                 :            :  * true on success, false on failure
     190                 :            :  */
     191                 :          0 : bool drm_bridge_chain_mode_fixup(struct drm_bridge *bridge,
     192                 :            :                                  const struct drm_display_mode *mode,
     193                 :            :                                  struct drm_display_mode *adjusted_mode)
     194                 :            : {
     195                 :          0 :         struct drm_encoder *encoder;
     196                 :            : 
     197         [ #  # ]:          0 :         if (!bridge)
     198                 :            :                 return true;
     199                 :            : 
     200                 :          0 :         encoder = bridge->encoder;
     201         [ #  # ]:          0 :         list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
     202         [ #  # ]:          0 :                 if (!bridge->funcs->mode_fixup)
     203                 :          0 :                         continue;
     204                 :            : 
     205         [ #  # ]:          0 :                 if (!bridge->funcs->mode_fixup(bridge, mode, adjusted_mode))
     206                 :            :                         return false;
     207                 :            :         }
     208                 :            : 
     209                 :            :         return true;
     210                 :            : }
     211                 :            : EXPORT_SYMBOL(drm_bridge_chain_mode_fixup);
     212                 :            : 
     213                 :            : /**
     214                 :            :  * drm_bridge_chain_mode_valid - validate the mode against all bridges in the
     215                 :            :  *                               encoder chain.
     216                 :            :  * @bridge: bridge control structure
     217                 :            :  * @mode: desired mode to be validated
     218                 :            :  *
     219                 :            :  * Calls &drm_bridge_funcs.mode_valid for all the bridges in the encoder
     220                 :            :  * chain, starting from the first bridge to the last. If at least one bridge
     221                 :            :  * does not accept the mode the function returns the error code.
     222                 :            :  *
     223                 :            :  * Note: the bridge passed should be the one closest to the encoder.
     224                 :            :  *
     225                 :            :  * RETURNS:
     226                 :            :  * MODE_OK on success, drm_mode_status Enum error code on failure
     227                 :            :  */
     228                 :            : enum drm_mode_status
     229                 :          0 : drm_bridge_chain_mode_valid(struct drm_bridge *bridge,
     230                 :            :                             const struct drm_display_mode *mode)
     231                 :            : {
     232                 :          0 :         struct drm_encoder *encoder;
     233                 :            : 
     234         [ #  # ]:          0 :         if (!bridge)
     235                 :            :                 return MODE_OK;
     236                 :            : 
     237                 :          0 :         encoder = bridge->encoder;
     238         [ #  # ]:          0 :         list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
     239                 :          0 :                 enum drm_mode_status ret;
     240                 :            : 
     241         [ #  # ]:          0 :                 if (!bridge->funcs->mode_valid)
     242                 :          0 :                         continue;
     243                 :            : 
     244                 :          0 :                 ret = bridge->funcs->mode_valid(bridge, mode);
     245         [ #  # ]:          0 :                 if (ret != MODE_OK)
     246                 :          0 :                         return ret;
     247                 :            :         }
     248                 :            : 
     249                 :            :         return MODE_OK;
     250                 :            : }
     251                 :            : EXPORT_SYMBOL(drm_bridge_chain_mode_valid);
     252                 :            : 
     253                 :            : /**
     254                 :            :  * drm_bridge_chain_disable - disables all bridges in the encoder chain
     255                 :            :  * @bridge: bridge control structure
     256                 :            :  *
     257                 :            :  * Calls &drm_bridge_funcs.disable op for all the bridges in the encoder
     258                 :            :  * chain, starting from the last bridge to the first. These are called before
     259                 :            :  * calling the encoder's prepare op.
     260                 :            :  *
     261                 :            :  * Note: the bridge passed should be the one closest to the encoder
     262                 :            :  */
     263                 :          0 : void drm_bridge_chain_disable(struct drm_bridge *bridge)
     264                 :            : {
     265                 :          0 :         struct drm_encoder *encoder;
     266                 :          0 :         struct drm_bridge *iter;
     267                 :            : 
     268         [ #  # ]:          0 :         if (!bridge)
     269                 :            :                 return;
     270                 :            : 
     271                 :          0 :         encoder = bridge->encoder;
     272         [ #  # ]:          0 :         list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
     273         [ #  # ]:          0 :                 if (iter->funcs->disable)
     274                 :          0 :                         iter->funcs->disable(iter);
     275                 :            : 
     276         [ #  # ]:          0 :                 if (iter == bridge)
     277                 :            :                         break;
     278                 :            :         }
     279                 :            : }
     280                 :            : EXPORT_SYMBOL(drm_bridge_chain_disable);
     281                 :            : 
     282                 :            : /**
     283                 :            :  * drm_bridge_chain_post_disable - cleans up after disabling all bridges in the
     284                 :            :  *                                 encoder chain
     285                 :            :  * @bridge: bridge control structure
     286                 :            :  *
     287                 :            :  * Calls &drm_bridge_funcs.post_disable op for all the bridges in the
     288                 :            :  * encoder chain, starting from the first bridge to the last. These are called
     289                 :            :  * after completing the encoder's prepare op.
     290                 :            :  *
     291                 :            :  * Note: the bridge passed should be the one closest to the encoder
     292                 :            :  */
     293                 :          0 : void drm_bridge_chain_post_disable(struct drm_bridge *bridge)
     294                 :            : {
     295                 :          0 :         struct drm_encoder *encoder;
     296                 :            : 
     297         [ #  # ]:          0 :         if (!bridge)
     298                 :            :                 return;
     299                 :            : 
     300                 :          0 :         encoder = bridge->encoder;
     301         [ #  # ]:          0 :         list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
     302         [ #  # ]:          0 :                 if (bridge->funcs->post_disable)
     303                 :          0 :                         bridge->funcs->post_disable(bridge);
     304                 :            :         }
     305                 :            : }
     306                 :            : EXPORT_SYMBOL(drm_bridge_chain_post_disable);
     307                 :            : 
     308                 :            : /**
     309                 :            :  * drm_bridge_chain_mode_set - set proposed mode for all bridges in the
     310                 :            :  *                             encoder chain
     311                 :            :  * @bridge: bridge control structure
     312                 :            :  * @mode: desired mode to be set for the encoder chain
     313                 :            :  * @adjusted_mode: updated mode that works for this encoder chain
     314                 :            :  *
     315                 :            :  * Calls &drm_bridge_funcs.mode_set op for all the bridges in the
     316                 :            :  * encoder chain, starting from the first bridge to the last.
     317                 :            :  *
     318                 :            :  * Note: the bridge passed should be the one closest to the encoder
     319                 :            :  */
     320                 :          0 : void drm_bridge_chain_mode_set(struct drm_bridge *bridge,
     321                 :            :                                const struct drm_display_mode *mode,
     322                 :            :                                const struct drm_display_mode *adjusted_mode)
     323                 :            : {
     324                 :          0 :         struct drm_encoder *encoder;
     325                 :            : 
     326         [ #  # ]:          0 :         if (!bridge)
     327                 :            :                 return;
     328                 :            : 
     329                 :          0 :         encoder = bridge->encoder;
     330         [ #  # ]:          0 :         list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
     331         [ #  # ]:          0 :                 if (bridge->funcs->mode_set)
     332                 :          0 :                         bridge->funcs->mode_set(bridge, mode, adjusted_mode);
     333                 :            :         }
     334                 :            : }
     335                 :            : EXPORT_SYMBOL(drm_bridge_chain_mode_set);
     336                 :            : 
     337                 :            : /**
     338                 :            :  * drm_bridge_chain_pre_enable - prepares for enabling all bridges in the
     339                 :            :  *                               encoder chain
     340                 :            :  * @bridge: bridge control structure
     341                 :            :  *
     342                 :            :  * Calls &drm_bridge_funcs.pre_enable op for all the bridges in the encoder
     343                 :            :  * chain, starting from the last bridge to the first. These are called
     344                 :            :  * before calling the encoder's commit op.
     345                 :            :  *
     346                 :            :  * Note: the bridge passed should be the one closest to the encoder
     347                 :            :  */
     348                 :          0 : void drm_bridge_chain_pre_enable(struct drm_bridge *bridge)
     349                 :            : {
     350                 :          0 :         struct drm_encoder *encoder;
     351                 :          0 :         struct drm_bridge *iter;
     352                 :            : 
     353         [ #  # ]:          0 :         if (!bridge)
     354                 :            :                 return;
     355                 :            : 
     356                 :          0 :         encoder = bridge->encoder;
     357         [ #  # ]:          0 :         list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
     358         [ #  # ]:          0 :                 if (iter->funcs->pre_enable)
     359                 :          0 :                         iter->funcs->pre_enable(iter);
     360                 :            :         }
     361                 :            : }
     362                 :            : EXPORT_SYMBOL(drm_bridge_chain_pre_enable);
     363                 :            : 
     364                 :            : /**
     365                 :            :  * drm_bridge_chain_enable - enables all bridges in the encoder chain
     366                 :            :  * @bridge: bridge control structure
     367                 :            :  *
     368                 :            :  * Calls &drm_bridge_funcs.enable op for all the bridges in the encoder
     369                 :            :  * chain, starting from the first bridge to the last. These are called
     370                 :            :  * after completing the encoder's commit op.
     371                 :            :  *
     372                 :            :  * Note that the bridge passed should be the one closest to the encoder
     373                 :            :  */
     374                 :          0 : void drm_bridge_chain_enable(struct drm_bridge *bridge)
     375                 :            : {
     376                 :          0 :         struct drm_encoder *encoder;
     377                 :            : 
     378         [ #  # ]:          0 :         if (!bridge)
     379                 :            :                 return;
     380                 :            : 
     381                 :          0 :         encoder = bridge->encoder;
     382         [ #  # ]:          0 :         list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
     383         [ #  # ]:          0 :                 if (bridge->funcs->enable)
     384                 :          0 :                         bridge->funcs->enable(bridge);
     385                 :            :         }
     386                 :            : }
     387                 :            : EXPORT_SYMBOL(drm_bridge_chain_enable);
     388                 :            : 
     389                 :            : /**
     390                 :            :  * drm_atomic_bridge_chain_disable - disables all bridges in the encoder chain
     391                 :            :  * @bridge: bridge control structure
     392                 :            :  * @old_state: old atomic state
     393                 :            :  *
     394                 :            :  * Calls &drm_bridge_funcs.atomic_disable (falls back on
     395                 :            :  * &drm_bridge_funcs.disable) op for all the bridges in the encoder chain,
     396                 :            :  * starting from the last bridge to the first. These are called before calling
     397                 :            :  * &drm_encoder_helper_funcs.atomic_disable
     398                 :            :  *
     399                 :            :  * Note: the bridge passed should be the one closest to the encoder
     400                 :            :  */
     401                 :          0 : void drm_atomic_bridge_chain_disable(struct drm_bridge *bridge,
     402                 :            :                                      struct drm_atomic_state *old_state)
     403                 :            : {
     404                 :          0 :         struct drm_encoder *encoder;
     405                 :          0 :         struct drm_bridge *iter;
     406                 :            : 
     407         [ #  # ]:          0 :         if (!bridge)
     408                 :            :                 return;
     409                 :            : 
     410                 :          0 :         encoder = bridge->encoder;
     411         [ #  # ]:          0 :         list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
     412         [ #  # ]:          0 :                 if (iter->funcs->atomic_disable)
     413                 :          0 :                         iter->funcs->atomic_disable(iter, old_state);
     414         [ #  # ]:          0 :                 else if (iter->funcs->disable)
     415                 :          0 :                         iter->funcs->disable(iter);
     416                 :            : 
     417         [ #  # ]:          0 :                 if (iter == bridge)
     418                 :            :                         break;
     419                 :            :         }
     420                 :            : }
     421                 :            : EXPORT_SYMBOL(drm_atomic_bridge_chain_disable);
     422                 :            : 
     423                 :            : /**
     424                 :            :  * drm_atomic_bridge_chain_post_disable - cleans up after disabling all bridges
     425                 :            :  *                                        in the encoder chain
     426                 :            :  * @bridge: bridge control structure
     427                 :            :  * @old_state: old atomic state
     428                 :            :  *
     429                 :            :  * Calls &drm_bridge_funcs.atomic_post_disable (falls back on
     430                 :            :  * &drm_bridge_funcs.post_disable) op for all the bridges in the encoder chain,
     431                 :            :  * starting from the first bridge to the last. These are called after completing
     432                 :            :  * &drm_encoder_helper_funcs.atomic_disable
     433                 :            :  *
     434                 :            :  * Note: the bridge passed should be the one closest to the encoder
     435                 :            :  */
     436                 :          0 : void drm_atomic_bridge_chain_post_disable(struct drm_bridge *bridge,
     437                 :            :                                           struct drm_atomic_state *old_state)
     438                 :            : {
     439                 :          0 :         struct drm_encoder *encoder;
     440                 :            : 
     441         [ #  # ]:          0 :         if (!bridge)
     442                 :            :                 return;
     443                 :            : 
     444                 :          0 :         encoder = bridge->encoder;
     445         [ #  # ]:          0 :         list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
     446         [ #  # ]:          0 :                 if (bridge->funcs->atomic_post_disable)
     447                 :          0 :                         bridge->funcs->atomic_post_disable(bridge, old_state);
     448         [ #  # ]:          0 :                 else if (bridge->funcs->post_disable)
     449                 :          0 :                         bridge->funcs->post_disable(bridge);
     450                 :            :         }
     451                 :            : }
     452                 :            : EXPORT_SYMBOL(drm_atomic_bridge_chain_post_disable);
     453                 :            : 
     454                 :            : /**
     455                 :            :  * drm_atomic_bridge_chain_pre_enable - prepares for enabling all bridges in
     456                 :            :  *                                      the encoder chain
     457                 :            :  * @bridge: bridge control structure
     458                 :            :  * @old_state: old atomic state
     459                 :            :  *
     460                 :            :  * Calls &drm_bridge_funcs.atomic_pre_enable (falls back on
     461                 :            :  * &drm_bridge_funcs.pre_enable) op for all the bridges in the encoder chain,
     462                 :            :  * starting from the last bridge to the first. These are called before calling
     463                 :            :  * &drm_encoder_helper_funcs.atomic_enable
     464                 :            :  *
     465                 :            :  * Note: the bridge passed should be the one closest to the encoder
     466                 :            :  */
     467                 :          0 : void drm_atomic_bridge_chain_pre_enable(struct drm_bridge *bridge,
     468                 :            :                                         struct drm_atomic_state *old_state)
     469                 :            : {
     470                 :          0 :         struct drm_encoder *encoder;
     471                 :          0 :         struct drm_bridge *iter;
     472                 :            : 
     473         [ #  # ]:          0 :         if (!bridge)
     474                 :            :                 return;
     475                 :            : 
     476                 :          0 :         encoder = bridge->encoder;
     477         [ #  # ]:          0 :         list_for_each_entry_reverse(iter, &encoder->bridge_chain, chain_node) {
     478         [ #  # ]:          0 :                 if (iter->funcs->atomic_pre_enable)
     479                 :          0 :                         iter->funcs->atomic_pre_enable(iter, old_state);
     480         [ #  # ]:          0 :                 else if (iter->funcs->pre_enable)
     481                 :          0 :                         iter->funcs->pre_enable(iter);
     482                 :            : 
     483         [ #  # ]:          0 :                 if (iter == bridge)
     484                 :            :                         break;
     485                 :            :         }
     486                 :            : }
     487                 :            : EXPORT_SYMBOL(drm_atomic_bridge_chain_pre_enable);
     488                 :            : 
     489                 :            : /**
     490                 :            :  * drm_atomic_bridge_chain_enable - enables all bridges in the encoder chain
     491                 :            :  * @bridge: bridge control structure
     492                 :            :  * @old_state: old atomic state
     493                 :            :  *
     494                 :            :  * Calls &drm_bridge_funcs.atomic_enable (falls back on
     495                 :            :  * &drm_bridge_funcs.enable) op for all the bridges in the encoder chain,
     496                 :            :  * starting from the first bridge to the last. These are called after completing
     497                 :            :  * &drm_encoder_helper_funcs.atomic_enable
     498                 :            :  *
     499                 :            :  * Note: the bridge passed should be the one closest to the encoder
     500                 :            :  */
     501                 :          0 : void drm_atomic_bridge_chain_enable(struct drm_bridge *bridge,
     502                 :            :                                     struct drm_atomic_state *old_state)
     503                 :            : {
     504                 :          0 :         struct drm_encoder *encoder;
     505                 :            : 
     506         [ #  # ]:          0 :         if (!bridge)
     507                 :            :                 return;
     508                 :            : 
     509                 :          0 :         encoder = bridge->encoder;
     510         [ #  # ]:          0 :         list_for_each_entry_from(bridge, &encoder->bridge_chain, chain_node) {
     511         [ #  # ]:          0 :                 if (bridge->funcs->atomic_enable)
     512                 :          0 :                         bridge->funcs->atomic_enable(bridge, old_state);
     513         [ #  # ]:          0 :                 else if (bridge->funcs->enable)
     514                 :          0 :                         bridge->funcs->enable(bridge);
     515                 :            :         }
     516                 :            : }
     517                 :            : EXPORT_SYMBOL(drm_atomic_bridge_chain_enable);
     518                 :            : 
     519                 :            : #ifdef CONFIG_OF
     520                 :            : /**
     521                 :            :  * of_drm_find_bridge - find the bridge corresponding to the device node in
     522                 :            :  *                      the global bridge list
     523                 :            :  *
     524                 :            :  * @np: device node
     525                 :            :  *
     526                 :            :  * RETURNS:
     527                 :            :  * drm_bridge control struct on success, NULL on failure
     528                 :            :  */
     529                 :            : struct drm_bridge *of_drm_find_bridge(struct device_node *np)
     530                 :            : {
     531                 :            :         struct drm_bridge *bridge;
     532                 :            : 
     533                 :            :         mutex_lock(&bridge_lock);
     534                 :            : 
     535                 :            :         list_for_each_entry(bridge, &bridge_list, list) {
     536                 :            :                 if (bridge->of_node == np) {
     537                 :            :                         mutex_unlock(&bridge_lock);
     538                 :            :                         return bridge;
     539                 :            :                 }
     540                 :            :         }
     541                 :            : 
     542                 :            :         mutex_unlock(&bridge_lock);
     543                 :            :         return NULL;
     544                 :            : }
     545                 :            : EXPORT_SYMBOL(of_drm_find_bridge);
     546                 :            : #endif
     547                 :            : 
     548                 :            : MODULE_AUTHOR("Ajay Kumar <ajaykumar.rs@samsung.com>");
     549                 :            : MODULE_DESCRIPTION("DRM bridge infrastructure");
     550                 :            : MODULE_LICENSE("GPL and additional rights");

Generated by: LCOV version 1.14