19960aa7cSTomi Valkeinen /* 2bb5cdf8dSAndrew F. Davis * Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/ 39960aa7cSTomi Valkeinen * Author: Archit Taneja <archit@ti.com> 49960aa7cSTomi Valkeinen * 59960aa7cSTomi Valkeinen * This program is free software; you can redistribute it and/or modify it 69960aa7cSTomi Valkeinen * under the terms of the GNU General Public License version 2 as published by 79960aa7cSTomi Valkeinen * the Free Software Foundation. 89960aa7cSTomi Valkeinen * 99960aa7cSTomi Valkeinen * This program is distributed in the hope that it will be useful, but WITHOUT 109960aa7cSTomi Valkeinen * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 119960aa7cSTomi Valkeinen * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for 129960aa7cSTomi Valkeinen * more details. 139960aa7cSTomi Valkeinen * 149960aa7cSTomi Valkeinen * You should have received a copy of the GNU General Public License along with 159960aa7cSTomi Valkeinen * this program. If not, see <http://www.gnu.org/licenses/>. 169960aa7cSTomi Valkeinen */ 179960aa7cSTomi Valkeinen 189960aa7cSTomi Valkeinen #include <linux/kernel.h> 199960aa7cSTomi Valkeinen #include <linux/module.h> 209960aa7cSTomi Valkeinen #include <linux/platform_device.h> 219960aa7cSTomi Valkeinen #include <linux/slab.h> 229960aa7cSTomi Valkeinen #include <linux/of.h> 239960aa7cSTomi Valkeinen 24845417b3SLaurent Pinchart #include "dss.h" 2532043da7SPeter Ujfalusi #include "omapdss.h" 269960aa7cSTomi Valkeinen 279960aa7cSTomi Valkeinen static DEFINE_MUTEX(output_lock); 289960aa7cSTomi Valkeinen 29*71316556SLaurent Pinchart int omapdss_output_validate(struct omap_dss_device *out) 309960aa7cSTomi Valkeinen { 31*71316556SLaurent Pinchart if (out->next && out->output_type != out->next->type) { 3239637e10STomi Valkeinen dev_err(out->dev, "output type and display type don't match\n"); 33*71316556SLaurent Pinchart return -EINVAL; 349960aa7cSTomi Valkeinen } 359960aa7cSTomi Valkeinen 36*71316556SLaurent Pinchart return 0; 379960aa7cSTomi Valkeinen } 38*71316556SLaurent Pinchart EXPORT_SYMBOL(omapdss_output_validate); 399960aa7cSTomi Valkeinen 409960aa7cSTomi Valkeinen int omapdss_output_unset_device(struct omap_dss_device *out) 419960aa7cSTomi Valkeinen { 4279ddb2f0SLaurent Pinchart int r = 0; 439960aa7cSTomi Valkeinen 449960aa7cSTomi Valkeinen mutex_lock(&output_lock); 459960aa7cSTomi Valkeinen 469960aa7cSTomi Valkeinen if (out->dst->state != OMAP_DSS_DISPLAY_DISABLED) { 4739637e10STomi Valkeinen dev_err(out->dev, 4839637e10STomi Valkeinen "device %s is not disabled, cannot unset device\n", 499960aa7cSTomi Valkeinen out->dst->name); 509960aa7cSTomi Valkeinen r = -EINVAL; 519960aa7cSTomi Valkeinen } 529960aa7cSTomi Valkeinen 539960aa7cSTomi Valkeinen mutex_unlock(&output_lock); 549960aa7cSTomi Valkeinen 559960aa7cSTomi Valkeinen return r; 569960aa7cSTomi Valkeinen } 579960aa7cSTomi Valkeinen EXPORT_SYMBOL(omapdss_output_unset_device); 589960aa7cSTomi Valkeinen 59845417b3SLaurent Pinchart int dss_install_mgr_ops(struct dss_device *dss, 60845417b3SLaurent Pinchart const struct dss_mgr_ops *mgr_ops, 6164cb8179SLaurent Pinchart struct omap_drm_private *priv) 629960aa7cSTomi Valkeinen { 63845417b3SLaurent Pinchart if (dss->mgr_ops) 649960aa7cSTomi Valkeinen return -EBUSY; 659960aa7cSTomi Valkeinen 66845417b3SLaurent Pinchart dss->mgr_ops = mgr_ops; 67845417b3SLaurent Pinchart dss->mgr_ops_priv = priv; 689960aa7cSTomi Valkeinen 699960aa7cSTomi Valkeinen return 0; 709960aa7cSTomi Valkeinen } 719960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_install_mgr_ops); 729960aa7cSTomi Valkeinen 73845417b3SLaurent Pinchart void dss_uninstall_mgr_ops(struct dss_device *dss) 749960aa7cSTomi Valkeinen { 75845417b3SLaurent Pinchart dss->mgr_ops = NULL; 76845417b3SLaurent Pinchart dss->mgr_ops_priv = NULL; 779960aa7cSTomi Valkeinen } 789960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_uninstall_mgr_ops); 799960aa7cSTomi Valkeinen 80a48bc6acSLaurent Pinchart int dss_mgr_connect(struct omap_dss_device *dssdev) 819960aa7cSTomi Valkeinen { 82845417b3SLaurent Pinchart return dssdev->dss->mgr_ops->connect(dssdev->dss->mgr_ops_priv, 83a48bc6acSLaurent Pinchart dssdev->dispc_channel, dssdev); 849960aa7cSTomi Valkeinen } 859960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_mgr_connect); 869960aa7cSTomi Valkeinen 87a48bc6acSLaurent Pinchart void dss_mgr_disconnect(struct omap_dss_device *dssdev) 889960aa7cSTomi Valkeinen { 89845417b3SLaurent Pinchart dssdev->dss->mgr_ops->disconnect(dssdev->dss->mgr_ops_priv, 90a48bc6acSLaurent Pinchart dssdev->dispc_channel, dssdev); 919960aa7cSTomi Valkeinen } 929960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_mgr_disconnect); 939960aa7cSTomi Valkeinen 9428d79f3eSLaurent Pinchart void dss_mgr_set_timings(struct omap_dss_device *dssdev, 9528d79f3eSLaurent Pinchart const struct videomode *vm) 969960aa7cSTomi Valkeinen { 97845417b3SLaurent Pinchart dssdev->dss->mgr_ops->set_timings(dssdev->dss->mgr_ops_priv, 98845417b3SLaurent Pinchart dssdev->dispc_channel, vm); 999960aa7cSTomi Valkeinen } 1009960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_mgr_set_timings); 1019960aa7cSTomi Valkeinen 10228d79f3eSLaurent Pinchart void dss_mgr_set_lcd_config(struct omap_dss_device *dssdev, 1039960aa7cSTomi Valkeinen const struct dss_lcd_mgr_config *config) 1049960aa7cSTomi Valkeinen { 105845417b3SLaurent Pinchart dssdev->dss->mgr_ops->set_lcd_config(dssdev->dss->mgr_ops_priv, 10664cb8179SLaurent Pinchart dssdev->dispc_channel, config); 1079960aa7cSTomi Valkeinen } 1089960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_mgr_set_lcd_config); 1099960aa7cSTomi Valkeinen 11028d79f3eSLaurent Pinchart int dss_mgr_enable(struct omap_dss_device *dssdev) 1119960aa7cSTomi Valkeinen { 112845417b3SLaurent Pinchart return dssdev->dss->mgr_ops->enable(dssdev->dss->mgr_ops_priv, 113845417b3SLaurent Pinchart dssdev->dispc_channel); 1149960aa7cSTomi Valkeinen } 1159960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_mgr_enable); 1169960aa7cSTomi Valkeinen 11728d79f3eSLaurent Pinchart void dss_mgr_disable(struct omap_dss_device *dssdev) 1189960aa7cSTomi Valkeinen { 119845417b3SLaurent Pinchart dssdev->dss->mgr_ops->disable(dssdev->dss->mgr_ops_priv, 120845417b3SLaurent Pinchart dssdev->dispc_channel); 1219960aa7cSTomi Valkeinen } 1229960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_mgr_disable); 1239960aa7cSTomi Valkeinen 12428d79f3eSLaurent Pinchart void dss_mgr_start_update(struct omap_dss_device *dssdev) 1259960aa7cSTomi Valkeinen { 126845417b3SLaurent Pinchart dssdev->dss->mgr_ops->start_update(dssdev->dss->mgr_ops_priv, 127845417b3SLaurent Pinchart dssdev->dispc_channel); 1289960aa7cSTomi Valkeinen } 1299960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_mgr_start_update); 1309960aa7cSTomi Valkeinen 13128d79f3eSLaurent Pinchart int dss_mgr_register_framedone_handler(struct omap_dss_device *dssdev, 1329960aa7cSTomi Valkeinen void (*handler)(void *), void *data) 1339960aa7cSTomi Valkeinen { 134845417b3SLaurent Pinchart struct dss_device *dss = dssdev->dss; 135845417b3SLaurent Pinchart 136845417b3SLaurent Pinchart return dss->mgr_ops->register_framedone_handler(dss->mgr_ops_priv, 13764cb8179SLaurent Pinchart dssdev->dispc_channel, 13828d79f3eSLaurent Pinchart handler, data); 1399960aa7cSTomi Valkeinen } 1409960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_mgr_register_framedone_handler); 1419960aa7cSTomi Valkeinen 14228d79f3eSLaurent Pinchart void dss_mgr_unregister_framedone_handler(struct omap_dss_device *dssdev, 1439960aa7cSTomi Valkeinen void (*handler)(void *), void *data) 1449960aa7cSTomi Valkeinen { 145845417b3SLaurent Pinchart struct dss_device *dss = dssdev->dss; 146845417b3SLaurent Pinchart 147845417b3SLaurent Pinchart dss->mgr_ops->unregister_framedone_handler(dss->mgr_ops_priv, 14864cb8179SLaurent Pinchart dssdev->dispc_channel, 14928d79f3eSLaurent Pinchart handler, data); 1509960aa7cSTomi Valkeinen } 1519960aa7cSTomi Valkeinen EXPORT_SYMBOL(dss_mgr_unregister_framedone_handler); 152