1 // Copyright (C) 2022 Beken Corporation 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 #pragma once 16 #include "driver/dvp_camera_types.h" 17 18 19 #ifdef __cplusplus 20 extern "C" { 21 #endif 22 23 24 typedef struct 25 { 26 media_ppi_t ppi; 27 dvp_mode_t mode; 28 int (*frame_set_ppi)(media_ppi_t ppi, frame_type_t type); 29 void (*frame_complete)(frame_buffer_t* buffer); 30 frame_buffer_t* (*frame_alloc)(void); 31 } dvp_camera_config_t; 32 33 typedef struct 34 { 35 int (*read_uint8) (uint8_t addr, uint8_t reg, uint8_t *value); 36 int (*read_uint16) (uint8_t addr, uint16_t reg, uint8_t *value); 37 int (*write_uint8) (uint8_t addr, uint8_t reg, uint8_t value); 38 int (*write_uint16) (uint8_t addr, uint16_t reg, uint8_t value); 39 } dvp_camera_i2c_callback_t; 40 41 42 typedef struct 43 { 44 char *name; 45 media_ppi_t def_ppi; 46 sensor_fps_t def_fps; 47 uint16 id; 48 uint8 clk; 49 uint16 address; 50 uint16 fps_cap; 51 uint16 ppi_cap; 52 bool (*detect)(const dvp_camera_i2c_callback_t *cb); 53 int (*init)(const dvp_camera_i2c_callback_t *cb); 54 int (*set_ppi)(const dvp_camera_i2c_callback_t *cb, media_ppi_t ppi); 55 int (*set_fps)(const dvp_camera_i2c_callback_t *cb, sensor_fps_t fps); 56 } dvp_sensor_config_t; 57 58 #define GC_QVGA_USE_SUBSAMPLE 1 59 60 typedef struct 61 { 62 media_ppi_t ppi; 63 sensor_fps_t fps; 64 char *name; 65 uint16 id; 66 uint16 fps_cap; 67 uint16 ppi_cap; 68 uint32 pixel_size; 69 dvp_mode_t mode; 70 } dvp_camera_device_t; 71 72 73 bk_err_t bk_dvp_camera_driver_init(dvp_camera_config_t *config); 74 bk_err_t bk_dvp_camera_driver_deinit(void); 75 dvp_camera_device_t *bk_dvp_camera_get_device(void); 76 77 int dvp_camera_i2c_read_uint8(uint8_t addr, uint8_t reg, uint8_t *value); 78 int dvp_camera_i2c_read_uint16(uint8_t addr, uint16_t reg, uint8_t *value); 79 int dvp_camera_i2c_write_uint8(uint8_t addr, uint8_t reg, uint8_t value); 80 int dvp_camera_i2c_write_uint16(uint8_t addr, uint16_t reg, uint8_t value); 81 82 bk_err_t bk_dvp_camera_encode_config(uint8_t auto_ctrl, uint32_t up_size, uint32_t low_size); 83 84 #ifdef __cplusplus 85 } 86 #endif 87