hpm_camera_config.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*
  2. * Copyright (c) 2021 HPMicro
  3. *
  4. * SPDX-License-Identifier: BSD-3-Clause
  5. *
  6. */
  7. #ifndef HPM_CAMERA_CONFIG_H
  8. #define HPM_CAMERA_CONFIG_H
  9. #include "hpm_common.h"
  10. #include "hpm_display_common.h"
  11. #include "hpm_i2c_drv.h"
  12. /* Macro to define video resolution. */
  13. #define HPM_CAMERA_RESOLUTION(width, height) ((uint32_t)(width) | ((uint32_t)(height) << 16U))
  14. typedef struct {
  15. I2C_Type *ptr;
  16. void (*delay_ms)(uint32_t ms);
  17. void (*write_rst)(uint8_t state);
  18. void (*write_pwdn)(uint8_t state);
  19. uint16_t i2c_device_addr;
  20. } camera_context_t;
  21. typedef struct {
  22. bool hsync_active_low;
  23. bool vsync_active_low;
  24. } camera_param_dvp_t;
  25. typedef struct {
  26. bool de_active_low;
  27. bool hsync_active_low;
  28. bool vsync_active_low;
  29. } camera_param_mipi_t;
  30. typedef enum {
  31. camera_interface_dvp,
  32. camera_interface_mipi,
  33. } camera_interface_t;
  34. typedef struct {
  35. uint32_t width;
  36. uint32_t height;
  37. display_pixel_format_t pixel_format;
  38. camera_interface_t interface;
  39. void *interface_param;
  40. } camera_config_t;
  41. /* Video Resolution definition. */
  42. typedef enum {
  43. video_resolution_5mp = HPM_CAMERA_RESOLUTION(2592, 1944), /* 5MP, 2592 * 1944 */
  44. video_resolution_sxga = HPM_CAMERA_RESOLUTION(1280, 800), /* SXGA, 1280 * 800 */
  45. video_resolution_1080p = HPM_CAMERA_RESOLUTION(1920, 1080), /* 1080P, 1920 * 1280*/
  46. video_resolution_720p = HPM_CAMERA_RESOLUTION(1280, 720), /* 720P, 1280 * 720 */
  47. video_resolution_800_480 = HPM_CAMERA_RESOLUTION(800, 480), /* 640 * 480 */
  48. video_resolution_vga = HPM_CAMERA_RESOLUTION(640, 480), /* VGA, 640 * 480 */
  49. video_resolution_480_272 = HPM_CAMERA_RESOLUTION(480, 272), /* 480 * 272 */
  50. video_resolution_qvga = HPM_CAMERA_RESOLUTION(320, 240), /* QVGA, 320 * 240 */
  51. } camera_resolution_t;
  52. /* Camera light mode type. */
  53. typedef enum {
  54. camera_light_mode_auto = 0,
  55. camera_light_mode_sunny,
  56. camera_light_mode_cloudy,
  57. camera_light_mode_office,
  58. camera_light_mode_home,
  59. camera_light_mode_night,
  60. } camera_light_mode_t;
  61. /* Camera special effect type. */
  62. typedef enum {
  63. camera_special_effect_normal = 0, /* Normal. */
  64. camera_special_effect_bw, /* B & W */
  65. camera_special_effect_sepia, /* Sepia. */
  66. camera_special_effect_bluish, /* Bluish. */
  67. camera_special_effect_redish, /* Redish. */
  68. camera_special_effect_greenish, /* Greenish. */
  69. camera_special_effect_negtive, /* Negtive. */
  70. camera_special_effect_over_exposure, /* OverExposure. */
  71. camera_special_effect_solarize, /* Solarize. */
  72. } camera_special_effect_t;
  73. #ifdef __cplusplus
  74. extern "C" {
  75. #endif
  76. /*
  77. * camera device initialization
  78. */
  79. hpm_stat_t camera_device_init(camera_context_t *camera_context, camera_config_t *camera_config);
  80. hpm_stat_t camera_device_get_dvp_param(camera_context_t *camera_context, camera_config_t *camera_config);
  81. hpm_stat_t camera_device_get_mipi_param(camera_context_t *camera_context, camera_config_t *camera_config);
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif /* HPM_CAMERA_CONFIG_H */