connector-analog-tv.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. /*
  2. * Analog TV Connector driver
  3. *
  4. * Copyright (C) 2013 Texas Instruments Incorporated - http://www.ti.com/
  5. * Author: Tomi Valkeinen <tomi.valkeinen@ti.com>
  6. *
  7. * This program is free software; you can redistribute it and/or modify it
  8. * under the terms of the GNU General Public License version 2 as published by
  9. * the Free Software Foundation.
  10. */
  11. #include <linux/slab.h>
  12. #include <linux/module.h>
  13. #include <linux/platform_device.h>
  14. #include <linux/of.h>
  15. #include "../dss/omapdss.h"
  16. struct panel_drv_data {
  17. struct omap_dss_device dssdev;
  18. struct device *dev;
  19. };
  20. #define to_panel_data(x) container_of(x, struct panel_drv_data, dssdev)
  21. static int tvc_connect(struct omap_dss_device *src,
  22. struct omap_dss_device *dst)
  23. {
  24. return 0;
  25. }
  26. static void tvc_disconnect(struct omap_dss_device *src,
  27. struct omap_dss_device *dst)
  28. {
  29. }
  30. static int tvc_enable(struct omap_dss_device *dssdev)
  31. {
  32. struct panel_drv_data *ddata = to_panel_data(dssdev);
  33. struct omap_dss_device *src = dssdev->src;
  34. int r;
  35. dev_dbg(ddata->dev, "enable\n");
  36. if (!omapdss_device_is_connected(dssdev))
  37. return -ENODEV;
  38. if (omapdss_device_is_enabled(dssdev))
  39. return 0;
  40. r = src->ops->enable(src);
  41. if (r)
  42. return r;
  43. dssdev->state = OMAP_DSS_DISPLAY_ACTIVE;
  44. return r;
  45. }
  46. static void tvc_disable(struct omap_dss_device *dssdev)
  47. {
  48. struct panel_drv_data *ddata = to_panel_data(dssdev);
  49. struct omap_dss_device *src = dssdev->src;
  50. dev_dbg(ddata->dev, "disable\n");
  51. if (!omapdss_device_is_enabled(dssdev))
  52. return;
  53. src->ops->disable(src);
  54. dssdev->state = OMAP_DSS_DISPLAY_DISABLED;
  55. }
  56. static const struct omap_dss_device_ops tvc_ops = {
  57. .connect = tvc_connect,
  58. .disconnect = tvc_disconnect,
  59. .enable = tvc_enable,
  60. .disable = tvc_disable,
  61. };
  62. static int tvc_probe(struct platform_device *pdev)
  63. {
  64. struct panel_drv_data *ddata;
  65. struct omap_dss_device *dssdev;
  66. ddata = devm_kzalloc(&pdev->dev, sizeof(*ddata), GFP_KERNEL);
  67. if (!ddata)
  68. return -ENOMEM;
  69. platform_set_drvdata(pdev, ddata);
  70. ddata->dev = &pdev->dev;
  71. dssdev = &ddata->dssdev;
  72. dssdev->ops = &tvc_ops;
  73. dssdev->dev = &pdev->dev;
  74. dssdev->type = OMAP_DISPLAY_TYPE_VENC;
  75. dssdev->owner = THIS_MODULE;
  76. dssdev->of_ports = BIT(0);
  77. omapdss_display_init(dssdev);
  78. omapdss_device_register(dssdev);
  79. return 0;
  80. }
  81. static int __exit tvc_remove(struct platform_device *pdev)
  82. {
  83. struct panel_drv_data *ddata = platform_get_drvdata(pdev);
  84. struct omap_dss_device *dssdev = &ddata->dssdev;
  85. omapdss_device_unregister(&ddata->dssdev);
  86. tvc_disable(dssdev);
  87. return 0;
  88. }
  89. static const struct of_device_id tvc_of_match[] = {
  90. { .compatible = "omapdss,svideo-connector", },
  91. { .compatible = "omapdss,composite-video-connector", },
  92. {},
  93. };
  94. MODULE_DEVICE_TABLE(of, tvc_of_match);
  95. static struct platform_driver tvc_connector_driver = {
  96. .probe = tvc_probe,
  97. .remove = __exit_p(tvc_remove),
  98. .driver = {
  99. .name = "connector-analog-tv",
  100. .of_match_table = tvc_of_match,
  101. .suppress_bind_attrs = true,
  102. },
  103. };
  104. module_platform_driver(tvc_connector_driver);
  105. MODULE_AUTHOR("Tomi Valkeinen <tomi.valkeinen@ti.com>");
  106. MODULE_DESCRIPTION("Analog TV Connector driver");
  107. MODULE_LICENSE("GPL");