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 24 #include "dss.h" 25 #include "omapdss.h" 26 27 int omapdss_device_init_output(struct omap_dss_device *out) 28 { 29 out->next = omapdss_of_find_connected_device(out->dev->of_node, 0); 30 if (IS_ERR(out->next)) { 31 if (PTR_ERR(out->next) != -EPROBE_DEFER) 32 dev_err(out->dev, "failed to find video sink\n"); 33 return PTR_ERR(out->next); 34 } 35 36 if (out->next && out->type != out->next->type) { 37 dev_err(out->dev, "output type and display type don't match\n"); 38 return -EINVAL; 39 } 40 41 return 0; 42 } 43 EXPORT_SYMBOL(omapdss_device_init_output); 44 45 void omapdss_device_cleanup_output(struct omap_dss_device *out) 46 { 47 if (out->next) 48 omapdss_device_put(out->next); 49 } 50 EXPORT_SYMBOL(omapdss_device_cleanup_output); 51 52 int dss_install_mgr_ops(struct dss_device *dss, 53 const struct dss_mgr_ops *mgr_ops, 54 struct omap_drm_private *priv) 55 { 56 if (dss->mgr_ops) 57 return -EBUSY; 58 59 dss->mgr_ops = mgr_ops; 60 dss->mgr_ops_priv = priv; 61 62 return 0; 63 } 64 EXPORT_SYMBOL(dss_install_mgr_ops); 65 66 void dss_uninstall_mgr_ops(struct dss_device *dss) 67 { 68 dss->mgr_ops = NULL; 69 dss->mgr_ops_priv = NULL; 70 } 71 EXPORT_SYMBOL(dss_uninstall_mgr_ops); 72 73 void dss_mgr_set_timings(struct omap_dss_device *dssdev, 74 const struct videomode *vm) 75 { 76 dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv, 77 dssdev->dispc_channel, vm); 78 } 79 EXPORT_SYMBOL(dss_mgr_set_timings); 80 81 void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev, 82 const struct dss_lcd_mgr_config *config) 83 { 84 dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv, 85 dssdev->dispc_channel, config); 86 } 87 EXPORT_SYMBOL(dss_mgr_set_lcd_config); 88 89 int dss_mgr_enable(struct omap_dss_device *dssdev) 90 { 91 return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv, 92 dssdev->dispc_channel); 93 } 94 EXPORT_SYMBOL(dss_mgr_enable); 95 96 void dss_mgr_disable(struct omap_dss_device *dssdev) 97 { 98 dssdev->dss->mgr_ops->disable(dssdev->dss->mgr_ops_priv, 99 dssdev->dispc_channel); 100 } 101 EXPORT_SYMBOL(dss_mgr_disable); 102 103 void dss_mgr_start_update(struct omap_dss_device *dssdev) 104 { 105 dssdev->dss->mgr_ops->start_update(dssdev->dss->mgr_ops_priv, 106 dssdev->dispc_channel); 107 } 108 EXPORT_SYMBOL(dss_mgr_start_update); 109 110 int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev, 111 void (*handler)(void *), void *data) 112 { 113 struct dss_device *dss = dssdev->dss; 114 115 return dss->mgr_ops->register_framedone_handler(dss->mgr_ops_priv, 116 dssdev->dispc_channel, 117 handler, data); 118 } 119 EXPORT_SYMBOL(dss_mgr_register_framedone_handler); 120 121 void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev, 122 void (*handler)(void *), void *data) 123 { 124 struct dss_device *dss = dssdev->dss; 125 126 dss->mgr_ops->unregister_framedone_handler(dss->mgr_ops_priv, 127 dssdev->dispc_channel, 128 handler, data); 129 } 130 EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler); 131