video_hw_info.c 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. #include <linux/delay.h>
  2. #include <linux/kernel.h>
  3. #include <linux/module.h>
  4. #include <linux/io.h>
  5. #include <linux/phy/phy.h>
  6. #include <linux/delay.h>
  7. #include <linux/interrupt.h>
  8. #include <linux/of.h>
  9. #include <linux/of_graph.h>
  10. #include <linux/platform_device.h>
  11. #include <linux/ratelimit.h>
  12. #include <linux/reset.h>
  13. #include <linux/videodev2.h>
  14. #include <linux/wait.h>
  15. #include "video.h"
  16. #include "video_kernel_defs.h"
  17. #include "video.h"
  18. typedef struct describe_comm{
  19. unsigned id;
  20. char *desc;
  21. }describe_comm_t;
  22. static int get_id_by_desc( describe_comm_t *,const char* );
  23. #define ENUM_DESC_MAPS_DECLATR(type) static describe_comm_t describe_map_##type[]={
  24. #define ENUM_DESC_MAPS_ADD(str) {str,#str},
  25. #define ENUM_DESC_MAPS_END {-1,"end"}};
  26. #define GET_ENUM_BY_DESC(type,str) get_id_by_desc(describe_map_##type,str)
  27. /****vedio_ip_type_e string to enum map*/
  28. ENUM_DESC_MAPS_DECLATR(subdev)
  29. {SENSOR, "vivcam"},
  30. {VIPRE, "vipre"},
  31. {ISP, "isp"},
  32. {DW, "dw"},
  33. {DSP, "dsp"},
  34. {RY, "ry"},
  35. ENUM_DESC_MAPS_END
  36. /****sensor_path_type_e string to enum map*/
  37. ENUM_DESC_MAPS_DECLATR(sensor)
  38. ENUM_DESC_MAPS_ADD(SENSOR_VGA_RAW12_LINER)
  39. ENUM_DESC_MAPS_ADD(SENSOR_1080P_RAW12_LINER)
  40. ENUM_DESC_MAPS_ADD(SENSOR_4K_RAW12_LINER)
  41. ENUM_DESC_MAPS_ADD(SENSOR_VGA_RAW10_LINER)
  42. ENUM_DESC_MAPS_ADD(SENSOR_1080P_RAW10_LINER)
  43. ENUM_DESC_MAPS_ADD(SENSOR_4K_RAW10_LINER)
  44. ENUM_DESC_MAPS_ADD(SENSOR_1296x972_RAW10_LINER)
  45. ENUM_DESC_MAPS_ADD(SENSOR_2592x1944_RAW10_LINER)
  46. ENUM_DESC_MAPS_ADD(SENSOR_1280x720_RAW10_LINER)
  47. ENUM_DESC_MAPS_ADD(SENSOR_1600x1200_RAW10_LINER)
  48. ENUM_DESC_MAPS_ADD(SENSOR_3280x2464_RAW10_LINER)
  49. ENUM_DESC_MAPS_ADD(SENSOR_1640x1232_RAW10_LINER)
  50. ENUM_DESC_MAPS_ADD(SENSOR_VGA_RAW12_HDR_2DOL)
  51. ENUM_DESC_MAPS_ADD(SENSOR_VGA_RAW12_HDR_3DOL)
  52. ENUM_DESC_MAPS_END
  53. /****isp_path_type_e string to enum map*/
  54. ENUM_DESC_MAPS_DECLATR(isp)
  55. ENUM_DESC_MAPS_ADD(ISP_MI_PATH_MP)
  56. ENUM_DESC_MAPS_ADD(ISP_MI_PATH_SP)
  57. ENUM_DESC_MAPS_ADD(ISP_MI_PATH_SP2_BP)
  58. #ifdef ISP_MI_MCM_WR
  59. ENUM_DESC_MAPS_ADD(ISP_MI_MCM_WR0)
  60. ENUM_DESC_MAPS_ADD(ISP_MI_MCM_WR1)
  61. #endif
  62. ENUM_DESC_MAPS_ADD(ISP_MI_PATH_PP)
  63. ENUM_DESC_MAPS_ADD(ISP_MI_HDR_L)
  64. ENUM_DESC_MAPS_ADD(ISP_MI_HDR_S)
  65. ENUM_DESC_MAPS_ADD(ISP_MI_HDR_VS)
  66. ENUM_DESC_MAPS_END
  67. /****vipre_path_type_e string to enum map*/
  68. ENUM_DESC_MAPS_DECLATR(vipre)
  69. ENUM_DESC_MAPS_ADD(VIPRE_CSI0_DSP)
  70. ENUM_DESC_MAPS_ADD(VIPRE_CSI1_DSP)
  71. ENUM_DESC_MAPS_ADD(VIPRE_CSI2_DSP)
  72. ENUM_DESC_MAPS_ADD(VIPRE_CSI0_DDR)
  73. ENUM_DESC_MAPS_ADD(VIPRE_CSI1_DDR)
  74. ENUM_DESC_MAPS_ADD(VIPRE_CSI2_DDR)
  75. ENUM_DESC_MAPS_ADD(VIPRE_CSI0_ISP0)
  76. ENUM_DESC_MAPS_ADD(VIPRE_CSI1_ISP0)
  77. ENUM_DESC_MAPS_ADD(VIPRE_CSI2_ISP0)
  78. ENUM_DESC_MAPS_ADD(VIPRE_CSI0_ISP1)
  79. ENUM_DESC_MAPS_ADD(VIPRE_CSI1_ISP1)
  80. ENUM_DESC_MAPS_ADD(VIPRE_CSI2_ISP1)
  81. ENUM_DESC_MAPS_ADD(VIPRE_CSI0_LOW_COAST_HDR_ISP0)
  82. ENUM_DESC_MAPS_ADD(VIPRE_CSI1_LOW_COAST_HDR_ISP0)
  83. ENUM_DESC_MAPS_ADD(VIPRE_CSI2_LOW_COAST_HDR_ISP0)
  84. ENUM_DESC_MAPS_END
  85. /****ry_path_type_e string to enum map*/
  86. ENUM_DESC_MAPS_DECLATR(ry)
  87. ENUM_DESC_MAPS_ADD(ISP_RY_MI_PATH_MP)
  88. ENUM_DESC_MAPS_ADD(ISP_RY_MI_PATH_SP)
  89. ENUM_DESC_MAPS_ADD(ISP_RY_MI_PATH_SP2_BP)
  90. ENUM_DESC_MAPS_END
  91. /****dsp_path_type_e string to enum map*/
  92. ENUM_DESC_MAPS_DECLATR(dsp)
  93. ENUM_DESC_MAPS_ADD(DSP_PATH_ISP_RY)
  94. ENUM_DESC_MAPS_ADD(DSP_PATH_ISP_CPU)
  95. ENUM_DESC_MAPS_ADD(DSP_PATH_VIPRE_DDR)
  96. ENUM_DESC_MAPS_ADD(DSP_PATH_VIPRE_EVEN)
  97. ENUM_DESC_MAPS_ADD(DSP_PATH_VIPRE_ODD)
  98. ENUM_DESC_MAPS_ADD(DSP_PATH_VIPRE_RY)
  99. ENUM_DESC_MAPS_END
  100. ENUM_DESC_MAPS_DECLATR(dw)
  101. ENUM_DESC_MAPS_ADD(DW_DWE_VSE0)
  102. ENUM_DESC_MAPS_ADD(DW_DWE_VSE1)
  103. ENUM_DESC_MAPS_ADD(DW_DWE_VSE2)
  104. ENUM_DESC_MAPS_END
  105. static int get_id_by_desc(describe_comm_t* desc_list,const char* str)
  106. {
  107. int i=0;
  108. while(0!=strcmp(desc_list[i].desc,"end") )
  109. {
  110. if(0==strcmp(desc_list[i].desc,str))
  111. {
  112. return desc_list[i].id;
  113. }
  114. i++;
  115. }
  116. return -1;
  117. }
  118. vedio_ip_type_e convert_subdev_name_to_id(const char* name)
  119. {
  120. return GET_ENUM_BY_DESC(subdev,name);
  121. }
  122. int vedio_get_path_type(const char*subdev_name,const char* path_name)
  123. {
  124. vedio_ip_type_e ip_type = GET_ENUM_BY_DESC(subdev,subdev_name);
  125. switch(ip_type)
  126. {
  127. case SENSOR:
  128. return 0;//GET_ENUM_BY_DESC(sensor,path_name);
  129. case VIPRE:
  130. return GET_ENUM_BY_DESC(vipre,path_name);
  131. case ISP:
  132. return GET_ENUM_BY_DESC(isp,path_name);
  133. case DW:
  134. return GET_ENUM_BY_DESC(dw,path_name);
  135. case DSP:
  136. return GET_ENUM_BY_DESC(dsp,path_name);
  137. case RY:
  138. return GET_ENUM_BY_DESC(ry,path_name);
  139. default:
  140. // printk("No match sub device name\n");
  141. return -1;
  142. }
  143. }