video_sysfs.c 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #if 0
  18. static ssize_t n_lanes_store(struct device *dev, struct device_attribute *attr,
  19. const char *buf, size_t count)
  20. {
  21. int ret;
  22. unsigned long lanes;
  23. struct platform_device *pdev = to_platform_device(dev);
  24. struct bm_csi_drvdata *drvdata = platform_get_drvdata(pdev);
  25. struct dw_csi *csi_dev = &drvdata->csi_dev;
  26. ret = kstrtoul(buf, 10, &lanes);
  27. if (ret < 0)
  28. return ret;
  29. if (lanes > 8) {
  30. dev_err(dev, "Invalid number of lanes %lu\n", lanes);
  31. return count;
  32. }
  33. dev_info(dev, "Lanes %lu\n", lanes);
  34. csi_dev->hw.num_lanes = lanes;
  35. return count;
  36. }
  37. static ssize_t n_lanes_show(struct device *dev,
  38. struct device_attribute *attr,
  39. char *buf)
  40. {
  41. struct platform_device *pdev = to_platform_device(dev);
  42. struct video_drvdata *drvdata = platform_get_drvdata(pdev);
  43. char buffer[10];
  44. snprintf(buffer, 10, "%d\n", csi_dev->hw.num_lanes);
  45. return strlcpy(buf, buffer, PAGE_SIZE);
  46. }
  47. #endif
  48. static void show_subdev(pipline_t *pipline)
  49. {
  50. int i = 0;
  51. sub_dev_info_t *sub_dev;
  52. sub_dev = pipline->sub_dev;
  53. while(i < pipline->sub_dev_num) {
  54. video_info("dev[%d]: %s%d\n", i, sub_dev->name, sub_dev->idx);
  55. sub_dev++;
  56. i++;
  57. }
  58. }
  59. static ssize_t piplines_show(struct device *dev,
  60. struct device_attribute *attr,
  61. char *buf)
  62. {
  63. int i = 0;
  64. struct platform_device *pdev = to_platform_device(dev);
  65. struct video_drvdata *drvdata = platform_get_drvdata(pdev);
  66. pipline_t *pipline = drvdata->piplines;
  67. while(i < drvdata->pipline_num) {
  68. video_info("/*pipline[%d]*******/\n", i);
  69. show_subdev(pipline);
  70. video_info("\n\n");
  71. pipline++;
  72. i++;
  73. }
  74. return 0;
  75. }
  76. //static DEVICE_ATTR_RW(n_lanes);
  77. static DEVICE_ATTR_RO(piplines);
  78. int video_create_capabilities_sysfs(struct platform_device *pdev)
  79. {
  80. device_create_file(&pdev->dev, &dev_attr_piplines);
  81. return 0;
  82. }
  83. int video_remove_capabilities_sysfs(struct platform_device *pdev)
  84. {
  85. device_remove_file(&pdev->dev, &dev_attr_piplines);
  86. return 0;
  87. }