1 /* 2 * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 3 * Author: Archit Taneja <archit@ti.com> 4 * 5 * This program is free software; you can redistribute it and/or modify it 6 * under the terms of the GNU General Public License version 2 as published by 7 * the Free Software Foundation. 8 * 9 * This program is distributed in the hope that it will be useful, but WITHOUT 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 12 * more details. 13 * 14 * You should have received a copy of the GNU General Public License along with 15 * this program. If not, see <http://www.gnu.org/licenses/>. 16 */ 17 18 #include <linux/kernel.h> 19 #include <linux/module.h> 20 #include <linux/platform_device.h> 21 #include <linux/slab.h> 22 #include <linux/of.h> 23 #include <linux/of_graph.h> 24 25 #include <drm/drm_panel.h> 26 27 #include "dss.h" 28 #include "omapdss.h" 29 30 int omapdss_device_init_output(struct omap_dss_device *out) 31 { 32 struct device_node *remote_node; 33 34 remote_node = of_graph_get_remote_node(out->dev->of_node, 0, 0); 35 if (!remote_node) { 36 dev_dbg(out->dev, "failed to find video sink\n"); 37 return 0; 38 } 39 40 out->next = omapdss_find_device_by_node(remote_node); 41 out->bridge = of_drm_find_bridge(remote_node); 42 out->panel = of_drm_find_panel(remote_node); 43 if (IS_ERR(out->panel)) 44 out->panel = NULL; 45 46 of_node_put(remote_node); 47 48 if (out->next && out->type != out->next->type) { 49 dev_err(out->dev, "output type and display type don't match\n"); 50 omapdss_device_put(out->next); 51 out->next = NULL; 52 return -EINVAL; 53 } 54 55 return out->next || out->bridge || out->panel ? 0 : -EPROBE_DEFER; 56 } 57 EXPORT_SYMBOL(omapdss_device_init_output); 58 59 void omapdss_device_cleanup_output(struct omap_dss_device *out) 60 { 61 if (out->next) 62 omapdss_device_put(out->next); 63 } 64 EXPORT_SYMBOL(omapdss_device_cleanup_output); 65 66 int dss_install_mgr_ops(struct dss_device *dss, 67 const struct dss_mgr_ops *mgr_ops, 68 struct omap_drm_private *priv) 69 { 70 if (dss->mgr_ops) 71 return -EBUSY; 72 73 dss->mgr_ops = mgr_ops; 74 dss->mgr_ops_priv = priv; 75 76 return 0; 77 } 78 EXPORT_SYMBOL(dss_install_mgr_ops); 79 80 void dss_uninstall_mgr_ops(struct dss_device *dss) 81 { 82 dss->mgr_ops = NULL; 83 dss->mgr_ops_priv = NULL; 84 } 85 EXPORT_SYMBOL(dss_uninstall_mgr_ops); 86 87 void dss_mgr_set_timings(struct omap_dss_device *dssdev, 88 const struct videomode *vm) 89 { 90 dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv, 91 dssdev->dispc_channel, vm); 92 } 93 EXPORT_SYMBOL(dss_mgr_set_timings); 94 95 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev, 96 const struct dss_lcd_mgr_config *config) 97 { 98 dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv, 99 dssdev->dispc_channel, config); 100 } 101 EXPORT_SYMBOL(dss_mgr_set_lcd_config); 102 103 int dss_mgr_enable(struct omap_dss_device *dssdev) 104 { 105 return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv, 106 dssdev->dispc_channel); 107 } 108 EXPORT_SYMBOL(dss_mgr_enable); 109 110 void dss_mgr_disable(struct omap_dss_device *dssdev) 111 { 112 dssdev->dss->mgr_ops->disable(dssdev->dss->mgr_ops_priv, 113 dssdev->dispc_channel); 114 } 115 EXPORT_SYMBOL(dss_mgr_disable); 116 117 void dss_mgr_start_update(struct omap_dss_device *dssdev) 118 { 119 dssdev->dss->mgr_ops->start_update(dssdev->dss->mgr_ops_priv, 120 dssdev->dispc_channel); 121 } 122 EXPORT_SYMBOL(dss_mgr_start_update); 123 124 int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev, 125 void (*handler)(void *), void *data) 126 { 127 struct dss_device *dss = dssdev->dss; 128 129 return dss->mgr_ops->register_framedone_handler(dss->mgr_ops_priv, 130 dssdev->dispc_channel, 131 handler, data); 132 } 133 EXPORT_SYMBOL(dss_mgr_register_framedone_handler); 134 135 void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev, 136 void (*handler)(void *), void *data) 137 { 138 struct dss_device *dss = dssdev->dss; 139 140 dss->mgr_ops->unregister_framedone_handler(dss->mgr_ops_priv, 141 dssdev->dispc_channel, 142 handler, data); 143 } 144 EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler); 145