mdp4_wfd_writeback.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. /* Copyright (c) 2011-2013, The Linux Foundation. All rights reserved.
  2. *
  3. * This program is free software; you can redistribute it and/or modify
  4. * it under the terms of the GNU General Public License version 2 and
  5. * only version 2 as published by the Free Software Foundation.
  6. *
  7. * This program is distributed in the hope that it will be useful,
  8. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. * GNU General Public License for more details.
  11. *
  12. */
  13. #include <linux/types.h>
  14. #include <linux/list.h>
  15. #include <linux/ioctl.h>
  16. #include <linux/spinlock.h>
  17. #include <linux/init.h>
  18. #include <linux/platform_device.h>
  19. #include <linux/version.h>
  20. #include "mdp4_wfd_writeback_util.h"
  21. #include "msm_fb.h"
  22. static int writeback_on(struct platform_device *pdev)
  23. {
  24. return 0;
  25. }
  26. static int writeback_off(struct platform_device *pdev)
  27. {
  28. return 0;
  29. }
  30. static int writeback_probe(struct platform_device *pdev)
  31. {
  32. struct msm_fb_data_type *mfd;
  33. struct platform_device *mdp_dev = NULL;
  34. struct msm_fb_panel_data *pdata = NULL;
  35. int rc = 0;
  36. WRITEBACK_MSG_ERR("Inside writeback_probe\n");
  37. mfd = platform_get_drvdata(pdev);
  38. if (!mfd)
  39. return -ENODEV;
  40. if (mfd->key != MFD_KEY)
  41. return -EINVAL;
  42. mdp_dev = platform_device_alloc("mdp", pdev->id);
  43. if (!mdp_dev)
  44. return -ENOMEM;
  45. /*
  46. * link to the latest pdev
  47. */
  48. mfd->pdev = mdp_dev;
  49. mfd->dest = DISPLAY_LCD;
  50. if (platform_device_add_data
  51. (mdp_dev, pdev->dev.platform_data,
  52. sizeof(struct msm_fb_panel_data))) {
  53. pr_err("writeback_probe: "
  54. "platform_device_add_data failed!\n");
  55. platform_device_put(mdp_dev);
  56. return -ENOMEM;
  57. }
  58. pdata = (struct msm_fb_panel_data *)mdp_dev->dev.platform_data;
  59. pdata->on = writeback_on;
  60. pdata->off = writeback_off;
  61. pdata->next = pdev;
  62. /*
  63. * get/set panel specific fb info
  64. */
  65. mfd->panel_info = pdata->panel_info;
  66. mfd->fb_imgType = MDP_RGB_565;
  67. platform_set_drvdata(mdp_dev, mfd);
  68. mfd->writeback_sdev.name = "wfd";
  69. rc = switch_dev_register(&mfd->writeback_sdev);
  70. if (rc) {
  71. pr_err("Failed to setup switch dev for writeback panel");
  72. return rc;
  73. }
  74. rc = platform_device_add(mdp_dev);
  75. if (rc) {
  76. WRITEBACK_MSG_ERR("failed to add device");
  77. platform_device_put(mdp_dev);
  78. return rc;
  79. }
  80. return rc;
  81. }
  82. static int writeback_remove(struct platform_device *pdev)
  83. {
  84. struct msm_fb_data_type *mfd = platform_get_drvdata(pdev);
  85. switch_dev_unregister(&mfd->writeback_sdev);
  86. return 0;
  87. }
  88. static struct platform_driver writeback_driver = {
  89. .probe = writeback_probe,
  90. .remove = writeback_remove,
  91. .driver = {
  92. .name = "writeback",
  93. },
  94. };
  95. static int __init writeback_driver_init(void)
  96. {
  97. int rc = 0;
  98. WRITEBACK_MSG_ERR("Inside writeback_driver_init\n");
  99. rc = platform_driver_register(&writeback_driver);
  100. return rc;
  101. }
  102. module_init(writeback_driver_init);