Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-only
0002 /*
0003  * Copyright (C) 2012 Texas Instruments Incorporated - https://www.ti.com/
0004  * Author: Archit Taneja <archit@ti.com>
0005  */
0006 
0007 #include <linux/kernel.h>
0008 #include <linux/module.h>
0009 #include <linux/platform_device.h>
0010 #include <linux/slab.h>
0011 #include <linux/of.h>
0012 #include <linux/of_graph.h>
0013 
0014 #include <drm/drm_bridge.h>
0015 #include <drm/drm_panel.h>
0016 
0017 #include "dss.h"
0018 #include "omapdss.h"
0019 
0020 int omapdss_device_init_output(struct omap_dss_device *out,
0021                    struct drm_bridge *local_bridge)
0022 {
0023     struct device_node *remote_node;
0024     int ret;
0025 
0026     remote_node = of_graph_get_remote_node(out->dev->of_node,
0027                            out->of_port, 0);
0028     if (!remote_node) {
0029         dev_dbg(out->dev, "failed to find video sink\n");
0030         return 0;
0031     }
0032 
0033     out->bridge = of_drm_find_bridge(remote_node);
0034     out->panel = of_drm_find_panel(remote_node);
0035     if (IS_ERR(out->panel))
0036         out->panel = NULL;
0037 
0038     of_node_put(remote_node);
0039 
0040     if (out->panel) {
0041         struct drm_bridge *bridge;
0042 
0043         bridge = drm_panel_bridge_add(out->panel);
0044         if (IS_ERR(bridge)) {
0045             dev_err(out->dev,
0046                 "unable to create panel bridge (%ld)\n",
0047                 PTR_ERR(bridge));
0048             ret = PTR_ERR(bridge);
0049             goto error;
0050         }
0051 
0052         out->bridge = bridge;
0053     }
0054 
0055     if (local_bridge) {
0056         if (!out->bridge) {
0057             ret = -EPROBE_DEFER;
0058             goto error;
0059         }
0060 
0061         out->next_bridge = out->bridge;
0062         out->bridge = local_bridge;
0063     }
0064 
0065     if (!out->bridge) {
0066         ret = -EPROBE_DEFER;
0067         goto error;
0068     }
0069 
0070     return 0;
0071 
0072 error:
0073     omapdss_device_cleanup_output(out);
0074     return ret;
0075 }
0076 
0077 void omapdss_device_cleanup_output(struct omap_dss_device *out)
0078 {
0079     if (out->bridge && out->panel)
0080         drm_panel_bridge_remove(out->next_bridge ?
0081                     out->next_bridge : out->bridge);
0082 }
0083 
0084 void dss_mgr_set_timings(struct omap_dss_device *dssdev,
0085              const struct videomode *vm)
0086 {
0087     omap_crtc_dss_set_timings(dssdev->dss->mgr_ops_priv,
0088                       dssdev->dispc_channel, vm);
0089 }
0090 
0091 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev,
0092         const struct dss_lcd_mgr_config *config)
0093 {
0094     omap_crtc_dss_set_lcd_config(dssdev->dss->mgr_ops_priv,
0095                          dssdev->dispc_channel, config);
0096 }
0097 
0098 int dss_mgr_enable(struct omap_dss_device *dssdev)
0099 {
0100     return omap_crtc_dss_enable(dssdev->dss->mgr_ops_priv,
0101                         dssdev->dispc_channel);
0102 }
0103 
0104 void dss_mgr_disable(struct omap_dss_device *dssdev)
0105 {
0106     omap_crtc_dss_disable(dssdev->dss->mgr_ops_priv,
0107                       dssdev->dispc_channel);
0108 }
0109 
0110 void dss_mgr_start_update(struct omap_dss_device *dssdev)
0111 {
0112     omap_crtc_dss_start_update(dssdev->dss->mgr_ops_priv,
0113                        dssdev->dispc_channel);
0114 }
0115 
0116 int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev,
0117         void (*handler)(void *), void *data)
0118 {
0119     struct dss_device *dss = dssdev->dss;
0120 
0121     return omap_crtc_dss_register_framedone(dss->mgr_ops_priv,
0122                             dssdev->dispc_channel,
0123                             handler, data);
0124 }
0125 
0126 void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev,
0127         void (*handler)(void *), void *data)
0128 {
0129     struct dss_device *dss = dssdev->dss;
0130 
0131     omap_crtc_dss_unregister_framedone(dss->mgr_ops_priv,
0132                            dssdev->dispc_channel,
0133                            handler, data);
0134 }