gpu_sysfs_header.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. #ifndef __GPU_SYSFS_HEADER_H__
  2. #define __GPU_SYSFS_HEADER_H__
  3. /* Linux kernel header. */
  4. #include <linux/kobject.h>
  5. #include <linux/string.h>
  6. #include <linux/sysfs.h>
  7. #include <linux/module.h>
  8. #include <linux/init.h>
  9. #include <linux/platform_device.h>
  10. #include <linux/slab.h>
  11. /* File handling related headers. */
  12. #include <linux/fs.h>
  13. #include <asm/segment.h>
  14. #include <asm/uaccess.h>
  15. #include <linux/buffer_head.h>
  16. #include <linux/string.h>
  17. /* Some necessary defines and typedefs. */
  18. #define GPU_SYSFS_MODULE_NAME "gpusysfs"
  19. #define DEVNAME_SIZE 32
  20. #define SRUK_FALSE 1
  21. #define SRUK_TRUE 0
  22. #define SRUK_DRV_NAME "sruk"
  23. typedef unsigned int sruk_bool;
  24. static const char sruk_drv_name[] = SRUK_DRV_NAME;
  25. /* Device and attribute data structure. */
  26. typedef struct sruk_os_device
  27. {
  28. struct list_head entry;
  29. struct device *dev;
  30. char devname[DEVNAME_SIZE];
  31. } sruk_os_device;
  32. typedef struct sruk_attribute
  33. {
  34. int id;
  35. uintptr_t data;
  36. } sruk_attribute;
  37. typedef struct sruk_device
  38. {
  39. sruk_os_device osdev;
  40. } sruk_device;
  41. /* *
  42. * *********************************************************************
  43. * Function prototypes for sysfs.
  44. * *********************************************************************
  45. * */
  46. ssize_t gpu_min_clock_show(struct device *dev, struct device_attribute *attr, char *buf);
  47. ssize_t gpu_max_clock_show(struct device *dev, struct device_attribute *attr, char *buf);
  48. ssize_t gpu_busy_show(struct device *dev, struct device_attribute *attr, char *buf);
  49. ssize_t gpu_vol_show(struct device *dev, struct device_attribute *attr, char *buf);
  50. ssize_t gpu_freq_show(struct device *dev, struct device_attribute *attr, char *buf);
  51. ssize_t gpu_freq_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
  52. ssize_t gpu_freq_table_show(struct device *dev, struct device_attribute *attr, char *buf);
  53. ssize_t gpu_governor_show(struct device *dev, struct device_attribute *attr, char *buf);
  54. ssize_t gpu_governor_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
  55. ssize_t gpu_available_governor_show(struct device *dev, struct device_attribute *attr, char *buf);
  56. ssize_t gpu_cores_config_show(struct device *dev, struct device_attribute *attr, char *buf);
  57. ssize_t gpu_tmu_show(struct device *dev, struct device_attribute *attr, char *buf);
  58. ssize_t gpu_model_show(struct device *dev, struct device_attribute *attr, char *buf);
  59. ssize_t gpu_version_show(struct device *dev, struct device_attribute *attr, char *buf);
  60. ssize_t gpu_mem_show(struct device *dev, struct device_attribute *attr, char *buf);
  61. ssize_t fps_show(struct device *dev, struct device_attribute *attr, char *buf);
  62. ssize_t fps_write(struct device *dev, struct device_attribute *attr, const char *buf, size_t count);
  63. /* *
  64. * *********************************************************************
  65. * File handling related function prototypes..
  66. * *********************************************************************
  67. * */
  68. struct file* file_open(const char* path, int flags, int rights) ;
  69. void file_close(struct file *file_ptr);
  70. int file_read(struct file *file_ptr, unsigned long long offset, unsigned char* data, unsigned int size);
  71. int file_write(struct file *file_ptr, unsigned long long offset, unsigned char* data, unsigned int size);
  72. int file_sync(struct file* file_ptr);
  73. int open_file_and_read_buffer(char *filename_and_path, char *input_buffer, int input_buffer_size);
  74. int open_file_and_write_buffer(char *filename_and_path, const char *buffer, int buffer_size);
  75. /* *
  76. * *********************************************************************
  77. * Buffer size for reading from sysfs files.
  78. * *********************************************************************
  79. * */
  80. #define INPUT_BUFFER_SIZE_16 16
  81. #define INPUT_BUFFER_SIZE_32 32
  82. #define INPUT_BUFFER_SIZE_64 64
  83. #define INPUT_BUFFER_SIZE_128 128
  84. #define INPUT_BUFFER_SIZE_256 256
  85. #define INPUT_BUFFER_SIZE_512 512
  86. #endif /* __GPU_SYSFS_HEADER_H__ */