libmegapixels.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  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. EXPORT int
  9. libmegapixels_find_config_verbose(char *configfile, int print);
  10. #define LIBMEGAPIXELS_CMD_LINK 1
  11. #define LIBMEGAPIXELS_CMD_MODE 2
  12. #define LIBMEGAPIXELS_CMD_CROP 3
  13. #define LIBMEGAPIXELS_CMD_INTERVAL 4
  14. #define LIBMEGAPIXELS_CFA_NONE 0
  15. #define LIBMEGAPIXELS_CFA_BGGR 1
  16. #define LIBMEGAPIXELS_CFA_GBRG 2
  17. #define LIBMEGAPIXELS_CFA_GRBG 3
  18. #define LIBMEGAPIXELS_CFA_RGGB 4
  19. #define LIBMEGAPIXELS_XFER_RAW 0
  20. #define LIBMEGAPIXELS_XFER_SRGB 8
  21. #define LIBMEGAPIXELS_FLASH_SCREEN 0
  22. #define LIBMEGAPIXELS_FLASH_V4L 1
  23. #define LIBMEGAPIXELS_FLASH_LED 2
  24. struct _lmp_cmd {
  25. int type;
  26. const char *entity_from;
  27. const char *entity_to;
  28. int pad_from;
  29. int pad_to;
  30. int width;
  31. int height;
  32. int top;
  33. int left;
  34. int format;
  35. int rate;
  36. uint32_t entity_from_id;
  37. int pad_from_id;
  38. uint32_t entity_to_id;
  39. int pad_to_id;
  40. };
  41. typedef struct _lmp_cmd libmegapixels_cmd;
  42. struct _lmp_mode {
  43. int width;
  44. int height;
  45. int rate;
  46. int format;
  47. int rotation;
  48. int mirrored;
  49. int xfer;
  50. double focal_length;
  51. double f_number;
  52. uint32_t v4l_pixfmt;
  53. uint32_t media_busfmt;
  54. int num_cmds;
  55. libmegapixels_cmd **cmds;
  56. };
  57. typedef struct _lmp_mode libmegapixels_mode;
  58. struct _lmp_subdev {
  59. char *path;
  60. int fd;
  61. uint32_t entity_id;
  62. };
  63. typedef struct _lmp_subdev libmegapixels_subdev;
  64. struct _lmp_camera {
  65. int index;
  66. char *name;
  67. char *sensor_name;
  68. char *bridge_name;
  69. char *media_path;
  70. char *sensor_path;
  71. char *video_path;
  72. char *flash_path;
  73. char *lens_path;
  74. int flash_type;
  75. int media_fd;
  76. int sensor_fd;
  77. int video_fd;
  78. int flash_fd;
  79. int lens_fd;
  80. int num_modes;
  81. libmegapixels_mode **modes;
  82. libmegapixels_mode *current_mode;
  83. int num_handles;
  84. libmegapixels_subdev **handles;
  85. };
  86. typedef struct _lmp_camera libmegapixels_camera;
  87. struct _lmp_device_config {
  88. char *path;
  89. const char *make;
  90. const char *model;
  91. int count;
  92. int loaded_config;
  93. int loaded_uvc;
  94. libmegapixels_camera **cameras;
  95. };
  96. typedef struct _lmp_device_config libmegapixels_devconfig;
  97. typedef struct _lmp_aaa {
  98. float matrix1[9];
  99. float matrix2[9];
  100. float avg_r;
  101. float avg_g;
  102. float avg_b;
  103. int exposure;
  104. float temp;
  105. float tint;
  106. int focus;
  107. int blacklevel;
  108. } libmegapixels_aaa_stats;
  109. EXPORT int
  110. libmegapixels_init(libmegapixels_devconfig **config);
  111. EXPORT void
  112. libmegapixels_loglevel(int loglevel);
  113. EXPORT int
  114. libmegapixels_load_file(libmegapixels_devconfig *config, const char *file);
  115. EXPORT int
  116. libmegapixels_load_file_lint(libmegapixels_devconfig *config, const char *file, int linting);
  117. EXPORT int
  118. libmegapixels_load_uvc(libmegapixels_devconfig *config);
  119. EXPORT int
  120. libmegapixels_open(libmegapixels_camera *camera);
  121. EXPORT void
  122. libmegapixels_close(libmegapixels_camera *camera);
  123. EXPORT unsigned int
  124. libmegapixels_select_mode(libmegapixels_camera *camera, libmegapixels_mode *mode, struct v4l2_format *format);
  125. EXPORT char *
  126. libmegapixels_v4l_pixfmt_to_string(uint32_t pixfmt);
  127. EXPORT char *
  128. libmegapixels_format_name(int format);
  129. EXPORT const char *
  130. libmegapixels_format_cfa(int format);
  131. EXPORT const char *
  132. libmegapixels_format_cfa_pattern(int format);
  133. EXPORT uint32_t
  134. libmegapixels_mode_raw_width_to_width(int index, uint32_t width);
  135. EXPORT uint32_t
  136. libmegapixels_mode_width_to_padding(int index, uint32_t width);
  137. EXPORT uint32_t
  138. libmegapixels_mode_width_to_bytes(int index, uint32_t width);
  139. EXPORT uint32_t
  140. libmegapixels_format_to_v4l_pixfmt(int index);
  141. EXPORT uint32_t
  142. libmegapixels_format_to_media_busfmt(int index);
  143. EXPORT uint32_t
  144. libmegapixels_format_bits_per_pixel(int format);
  145. EXPORT int
  146. libmegapixels_mode_equals(libmegapixels_mode *a, libmegapixels_mode *b);
  147. // The AAA API is considered completely unstable and shouldn't be used yet
  148. EXPORT void
  149. libmegapixels_aaa_init(libmegapixels_aaa_stats *stats);
  150. EXPORT void
  151. libmegapixels_aaa_set_matrix(libmegapixels_aaa_stats *stats, const float matrix1[9], const float matrix2[9]);
  152. EXPORT void
  153. libmegapixels_aaa_software_statistics(libmegapixels_aaa_stats *stats, const unsigned int *frame, int width, int height);
  154. #endif