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