libmegapixels.h 3.5 KB

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