msm_fb_panel.c 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196
  1. /* Copyright (c) 2008-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/module.h>
  14. #include <linux/moduleparam.h>
  15. #include <linux/kernel.h>
  16. #include <linux/slab.h>
  17. #include <linux/delay.h>
  18. #include <linux/mm.h>
  19. #include <linux/fb.h>
  20. #include <linux/init.h>
  21. #include <linux/ioport.h>
  22. #include <linux/device.h>
  23. #include <linux/dma-mapping.h>
  24. #include <linux/uaccess.h>
  25. #include <linux/workqueue.h>
  26. #include <linux/string.h>
  27. #include <linux/version.h>
  28. #include <linux/proc_fs.h>
  29. #include <linux/vmalloc.h>
  30. #include <linux/debugfs.h>
  31. #include "msm_fb_panel.h"
  32. int panel_next_on(struct platform_device *pdev)
  33. {
  34. int ret = 0;
  35. struct msm_fb_panel_data *pdata;
  36. struct msm_fb_panel_data *next_pdata;
  37. struct platform_device *next_pdev;
  38. pdata = (struct msm_fb_panel_data *)pdev->dev.platform_data;
  39. if (pdata) {
  40. next_pdev = pdata->next;
  41. if (next_pdev) {
  42. next_pdata =
  43. (struct msm_fb_panel_data *)next_pdev->dev.
  44. platform_data;
  45. if ((next_pdata) && (next_pdata->on))
  46. ret = next_pdata->on(next_pdev);
  47. }
  48. }
  49. return ret;
  50. }
  51. int panel_next_off(struct platform_device *pdev)
  52. {
  53. int ret = 0;
  54. struct msm_fb_panel_data *pdata;
  55. struct msm_fb_panel_data *next_pdata;
  56. struct platform_device *next_pdev;
  57. pdata = (struct msm_fb_panel_data *)pdev->dev.platform_data;
  58. if (pdata) {
  59. next_pdev = pdata->next;
  60. if (next_pdev) {
  61. next_pdata =
  62. (struct msm_fb_panel_data *)next_pdev->dev.
  63. platform_data;
  64. if ((next_pdata) && (next_pdata->on))
  65. ret = next_pdata->off(next_pdev);
  66. }
  67. }
  68. return ret;
  69. }
  70. int panel_next_fps_level_change(struct platform_device *pdev,
  71. u32 fps_level)
  72. {
  73. int ret = 0;
  74. struct msm_fb_panel_data *pdata;
  75. struct msm_fb_panel_data *next_pdata;
  76. struct platform_device *next_pdev;
  77. pdata = (struct msm_fb_panel_data *)pdev->dev.platform_data;
  78. if (pdata) {
  79. next_pdev = pdata->next;
  80. if (next_pdev) {
  81. next_pdata =
  82. (struct msm_fb_panel_data *)next_pdev->dev.
  83. platform_data;
  84. if ((next_pdata) && (next_pdata->fps_level_change))
  85. ret = next_pdata->fps_level_change(next_pdev,
  86. fps_level);
  87. }
  88. }
  89. return ret;
  90. }
  91. int panel_next_late_init(struct platform_device *pdev)
  92. {
  93. int ret = 0;
  94. struct msm_fb_panel_data *pdata;
  95. struct msm_fb_panel_data *next_pdata;
  96. struct platform_device *next_pdev;
  97. pdata = (struct msm_fb_panel_data *)pdev->dev.platform_data;
  98. if (pdata) {
  99. next_pdev = pdata->next;
  100. if (next_pdev) {
  101. next_pdata = (struct msm_fb_panel_data *)
  102. next_pdev->dev.platform_data;
  103. if ((next_pdata) && (next_pdata->late_init))
  104. ret = next_pdata->late_init(next_pdev);
  105. }
  106. }
  107. return ret;
  108. }
  109. struct platform_device *msm_fb_device_alloc(struct msm_fb_panel_data *pdata,
  110. u32 type, u32 id)
  111. {
  112. struct platform_device *this_dev = NULL;
  113. char dev_name[16];
  114. switch (type) {
  115. case EBI2_PANEL:
  116. snprintf(dev_name, sizeof(dev_name), "ebi2_lcd");
  117. break;
  118. case MDDI_PANEL:
  119. snprintf(dev_name, sizeof(dev_name), "mddi");
  120. break;
  121. case EXT_MDDI_PANEL:
  122. snprintf(dev_name, sizeof(dev_name), "mddi_ext");
  123. break;
  124. case TV_PANEL:
  125. snprintf(dev_name, sizeof(dev_name), "tvenc");
  126. break;
  127. case HDMI_PANEL:
  128. case LCDC_PANEL:
  129. snprintf(dev_name, sizeof(dev_name), "lcdc");
  130. break;
  131. case LVDS_PANEL:
  132. snprintf(dev_name, sizeof(dev_name), "lvds");
  133. break;
  134. case DTV_PANEL:
  135. snprintf(dev_name, sizeof(dev_name), "dtv");
  136. break;
  137. case MIPI_VIDEO_PANEL:
  138. case MIPI_CMD_PANEL:
  139. snprintf(dev_name, sizeof(dev_name), "mipi_dsi");
  140. break;
  141. case WRITEBACK_PANEL:
  142. snprintf(dev_name, sizeof(dev_name), "writeback");
  143. break;
  144. default:
  145. return NULL;
  146. }
  147. if (pdata != NULL)
  148. pdata->next = NULL;
  149. else
  150. return NULL;
  151. this_dev =
  152. platform_device_alloc(dev_name, ((u32) type << 16) | (u32) id);
  153. if (this_dev) {
  154. if (platform_device_add_data
  155. (this_dev, pdata, sizeof(struct msm_fb_panel_data))) {
  156. printk
  157. ("msm_fb_device_alloc: platform_device_add_data failed!\n");
  158. platform_device_put(this_dev);
  159. return NULL;
  160. }
  161. }
  162. return this_dev;
  163. }