libmegapixels.h 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. #ifndef LIBMEGAPIXELS_HEADER
  2. #define LIBMEGAPIXELS_HEADER
  3. #include <stdint.h>
  4. #include <linux/videodev2.h>
  5. #define EXPORT __attribute__((__visibility__("default")))
  6. EXPORT int
  7. libmegapixels_find_config(char *configfile);
  8. #define LIBMEGAPIXELS_CMD_LINK 1
  9. #define LIBMEGAPIXELS_CMD_MODE 2
  10. #define LIBMEGAPIXELS_CMD_CROP 3
  11. #define LIBMEGAPIXELS_CMD_INTERVAL 4
  12. #define LIBMEGAPIXELS_CFA_NONE 0
  13. #define LIBMEGAPIXELS_CFA_BGGR 1
  14. #define LIBMEGAPIXELS_CFA_GBRG 2
  15. #define LIBMEGAPIXELS_CFA_GRBG 3
  16. #define LIBMEGAPIXELS_CFA_RGGB 4
  17. #define LIBMEGAPIXELS_XFER_RAW 0;
  18. #define LIBMEGAPIXELS_XFER_SRGB 8;
  19. struct _lmp_cmd {
  20. int type;
  21. const char *entity_from;
  22. const char *entity_to;
  23. int pad_from;
  24. int pad_to;
  25. int width;
  26. int height;
  27. int top;
  28. int left;
  29. int format;
  30. int rate;
  31. uint32_t entity_from_id;
  32. int pad_from_id;
  33. uint32_t entity_to_id;
  34. int pad_to_id;
  35. };
  36. typedef struct _lmp_cmd libmegapixels_cmd;
  37. struct _lmp_mode {
  38. int width;
  39. int height;
  40. int rate;
  41. int format;
  42. int rotation;
  43. int mirrored;
  44. int xfer;
  45. double focal_length;
  46. double f_number;
  47. uint32_t v4l_pixfmt;
  48. uint32_t media_busfmt;
  49. int num_cmds;
  50. libmegapixels_cmd **cmds;
  51. };
  52. typedef struct _lmp_mode libmegapixels_mode;
  53. struct _lmp_subdev {
  54. char *path;
  55. int fd;
  56. uint32_t entity_id;
  57. };
  58. typedef struct _lmp_subdev libmegapixels_subdev;
  59. struct _lmp_camera {
  60. int index;
  61. char *name;
  62. char *sensor_name;
  63. char *bridge_name;
  64. char *media_path;
  65. char *sensor_path;
  66. char *video_path;
  67. int media_fd;
  68. int sensor_fd;
  69. int video_fd;
  70. int num_modes;
  71. libmegapixels_mode **modes;
  72. libmegapixels_mode *current_mode;
  73. int num_handles;
  74. libmegapixels_subdev **handles;
  75. };
  76. typedef struct _lmp_camera libmegapixels_camera;
  77. struct _lmp_device_config {
  78. char *path;
  79. const char *make;
  80. const char *model;
  81. int count;
  82. int loaded_config;
  83. int loaded_uvc;
  84. libmegapixels_camera **cameras;
  85. };
  86. typedef struct _lmp_device_config libmegapixels_devconfig;
  87. typedef struct _lmp_aaa {
  88. int exposure;
  89. float temp;
  90. float tint;
  91. int focus;
  92. int blacklevel;
  93. } libmegapixels_aaa_stats;
  94. EXPORT int
  95. libmegapixels_init(libmegapixels_devconfig **config);
  96. EXPORT int
  97. libmegapixels_load_file(libmegapixels_devconfig *config, const char *file);
  98. EXPORT int
  99. libmegapixels_load_uvc(libmegapixels_devconfig *config);
  100. EXPORT int
  101. libmegapixels_open(libmegapixels_camera *camera);
  102. EXPORT void
  103. libmegapixels_close(libmegapixels_camera *camera);
  104. EXPORT unsigned int
  105. libmegapixels_select_mode(libmegapixels_camera *camera, libmegapixels_mode *mode, struct v4l2_format *format);
  106. EXPORT char *
  107. libmegapixels_v4l_pixfmt_to_string(uint32_t pixfmt);
  108. EXPORT char *
  109. libmegapixels_format_name(int format);
  110. EXPORT const char *
  111. libmegapixels_format_cfa(int format);
  112. EXPORT const char *
  113. libmegapixels_format_cfa_pattern(int format);
  114. EXPORT uint32_t
  115. libmegapixels_mode_raw_width_to_width(int index, uint32_t width);
  116. EXPORT uint32_t
  117. libmegapixels_mode_width_to_padding(int index, uint32_t width);
  118. EXPORT uint32_t
  119. libmegapixels_mode_width_to_bytes(int index, uint32_t width);
  120. EXPORT uint32_t
  121. libmegapixels_format_to_v4l_pixfmt(int index);
  122. EXPORT uint32_t
  123. libmegapixels_format_to_media_busfmt(int index);
  124. EXPORT uint32_t
  125. libmegapixels_format_bits_per_pixel(int format);
  126. EXPORT int
  127. libmegapixels_mode_equals(libmegapixels_mode *a, libmegapixels_mode *b);
  128. EXPORT void
  129. libmegapixels_aaa_software_statistics(unsigned int *frame, int width, int height,
  130. libmegapixels_aaa_stats *stats);
  131. #endif