aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/components/video/camera
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/components/video/camera')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/driver_camera-device-common.cmake31
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/fsl_camera_device.h168
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/driver_camera-device-max9286.cmake19
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/fsl_max9286.c807
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/fsl_max9286.h89
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/driver_camera-device-mt9m114.cmake19
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/fsl_mt9m114.c397
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/fsl_mt9m114.h651
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/driver_camera-device-ov5640.cmake19
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/fsl_ov5640.c1124
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/fsl_ov5640.h58
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov7725/driver_camera-device-ov7725.cmake19
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov7725/fsl_ov7725.c655
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov7725/fsl_ov7725.h217
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/sccb/driver_camera-device-sccb.cmake16
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/sccb/fsl_sccb.c63
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/sccb/fsl_sccb.h117
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/driver_camera-common.cmake30
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/fsl_camera.h52
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/receiver/csi/driver_camera-receiver-csi.cmake28
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/receiver/csi/fsl_csi_camera_adapter.c177
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/receiver/csi/fsl_csi_camera_adapter.h65
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/receiver/driver_camera-receiver-common.cmake16
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/receiver/fsl_camera_receiver.h170
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/receiver/isi/driver_camera-receiver-isi.cmake25
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/receiver/isi/fsl_isi_camera_adapter.c463
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/components/video/camera/receiver/isi/fsl_isi_camera_adapter.h111
27 files changed, 5606 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/driver_camera-device-common.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/driver_camera-device-common.cmake
new file mode 100644
index 000000000..9a95a3491
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/driver_camera-device-common.cmake
@@ -0,0 +1,31 @@
1if(NOT DRIVER_CAMERA-DEVICE-COMMON_INCLUDED)
2
3 set(DRIVER_CAMERA-DEVICE-COMMON_INCLUDED true CACHE BOOL "driver_camera-device-common component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 )
7
8 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
9 ${CMAKE_CURRENT_LIST_DIR}/.
10 )
11
12 #OR Logic component
13 if(${MCUX_DEVICE} STREQUAL "MIMXRT1052")
14 include(driver_camera-common)
15 endif()
16 if(${MCUX_DEVICE} STREQUAL "MIMXRT1064")
17 include(driver_camera-common)
18 endif()
19 if(${MCUX_DEVICE} STREQUAL "MIMX8QM6_cm4_core1")
20 include(driver_camera-common)
21 endif()
22 if(${MCUX_DEVICE} STREQUAL "MIMX8QX6")
23 include(driver_camera-common)
24 endif()
25 if(${MCUX_DEVICE} STREQUAL "MIMXRT1062")
26 include(driver_camera-common)
27 endif()
28
29 include(driver_common)
30
31endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/fsl_camera_device.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/fsl_camera_device.h
new file mode 100644
index 000000000..13c6cd9f2
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/fsl_camera_device.h
@@ -0,0 +1,168 @@
1/*
2 * Copyright 2017 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_CAMERA_DEVICE_H_
10#define _FSL_CAMERA_DEVICE_H_
11
12#include "fsl_common.h"
13#include "fsl_camera.h"
14
15/*******************************************************************************
16 * Definitions
17 ******************************************************************************/
18typedef struct _camera_device_handle camera_device_handle_t;
19
20/*! @brief Camera device control command. */
21typedef enum _camera_device_cmd
22{
23 kCAMERA_DeviceAutoFocus, /*!< Auto focus. */
24#define CAMERA_AUTO_FOCUS_ON 1
25#define CAMERA_AUTO_FOCUS_OFF 0
26
27 kCAMERA_DeviceLightMode, /*!< Light mode. */
28#define CAMERA_LIGHT_MODE_AUTO 0
29#define CAMERA_LIGHT_MODE_SUNNY 1
30#define CAMERA_LIGHT_MODE_CLOUDY 2
31#define CAMERA_LIGHT_MODE_OFFICE 3
32#define CAMERA_LIGHT_MODE_HOME 4
33#define CAMERA_LIGHT_MODE_NIGHT 5
34
35 kCAMERA_DeviceSaturation, /*!< Saturation, pass in adjust value, such as -2, -1, 0, 1, 2... */
36 kCAMERA_DeviceBrightness, /*!< Brightness, pass in adjust value, such as -2, -1, 0, 1, 2... */
37 kCAMERA_DeviceContrast, /*!< Contrast, pass in adjust value, such as -2, -1, 0, 1, 2... */
38
39 kCAMERA_DeviceSpecialEffect, /*!< Special effect. */
40#define CAMERA_SPECIAL_EFFECT_NORMAL 0 /* Normal. */
41#define CAMERA_SPECIAL_EFFECT_BW 1 /* B & W */
42#define CAMERA_SPECIAL_EFFECT_SEPIA 2 /* Sepia. */
43#define CAMERA_SPECIAL_EFFECT_BLUISH 3 /* Bluish. */
44#define CAMERA_SPECIAL_EFFECT_REDISH 4 /* Redish. */
45#define CAMERA_SPECIAL_EFFECT_GREENISH 5 /* Greenish. */
46#define CAMERA_SPECIAL_EFFECT_NEGTIVE 6 /* Negtive. */
47#define CAMERA_SPECIAL_EFFECT_OVER_EXPOSURE 7 /* OverExposure. */
48#define CAMERA_SPECIAL_EFFECT_SOLARIZE 8 /* Solarize. */
49
50 kCAMERA_DeviceNightMode, /*!< Night mode. */
51#define CAMERA_NIGHT_MODE_DISABLED 0 /* Disable. */
52#define CAMERA_NIGHT_MODE_AUTO_FR_DIVBY2 1 /* Use automatic frame rate, max reduction to 1/2 frame rate. */
53#define CAMERA_NIGHT_MODE_AUTO_FR_DIVBY4 4 /* Use automatic frame rate, max reduction to 1/4 frame rate. */
54#define CAMERA_NIGHT_MODE_AUTO_FR_DIVBY8 8 /* Use automatic frame rate, max reduction to 1/8 frame rate. */
55} camera_device_cmd_t;
56
57/*! @brief Camera device operations. */
58typedef struct _camera_device_operations
59{
60 status_t (*init)(camera_device_handle_t *handle, const camera_config_t *config);
61 status_t (*deinit)(camera_device_handle_t *handle);
62 status_t (*start)(camera_device_handle_t *handle);
63 status_t (*stop)(camera_device_handle_t *handle);
64 status_t (*control)(camera_device_handle_t *handle, camera_device_cmd_t cmd, int32_t arg);
65 status_t (*init_ext)(camera_device_handle_t *handle, const camera_config_t *config, const void *specialConfig);
66} camera_device_operations_t;
67
68/*! @brief Camera device handle. */
69struct _camera_device_handle
70{
71 void *resource; /*!< The resource used by the camera device, it is device specific. */
72 const camera_device_operations_t *ops; /*!< The device related operations. */
73};
74
75/*******************************************************************************
76 * API
77 ******************************************************************************/
78
79#if defined(__cplusplus)
80extern "C" {
81#endif
82
83/*!
84 * @brief Initialize the camera device.
85 *
86 * Initialize the camera device with the user defined configuration.
87 *
88 * @param handle Camera device handle.
89 * @param config Pointer to the configuration.
90 * @return Returns @ref kStatus_Success if initialize success, otherwise returns
91 * error code.
92 */
93static inline status_t CAMERA_DEVICE_Init(camera_device_handle_t *handle, const camera_config_t *config)
94{
95 return handle->ops->init(handle, config);
96}
97
98/*!
99 * @brief Initialize the camera device with more specific configuration.
100 *
101 * This is an externed API of @ref CAMERA_DEVICE_Init, it allow upper layer to
102 * pass in device specific configuration. In this case, the
103 * @ref CAMERA_DEVICE_Init uses default specific configuration.
104 *
105 * @param handle Camera device handle.
106 * @param config Pointer to the configuration.
107 * @param specialConfig Pointer to the device specific configuration.
108 * @return Returns @ref kStatus_Success if initialize success, otherwise returns
109 * error code.
110 */
111static inline status_t CAMERA_DEVICE_InitExt(camera_device_handle_t *handle,
112 const camera_config_t *config,
113 const void *specialConfig)
114{
115 return handle->ops->init_ext(handle, config, specialConfig);
116}
117
118/*!
119 * @brief Deinitialize the camera device.
120 *
121 * @param handle Camera device handle.
122 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
123 */
124static inline status_t CAMERA_DEVICE_Deinit(camera_device_handle_t *handle)
125{
126 return handle->ops->deinit(handle);
127}
128
129/*!
130 * @brief Control the camera device.
131 *
132 * @param handle Camera device handle.
133 * @param cmd Camera device command
134 * @param arg Argument for the command.
135 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
136 */
137static inline status_t CAMERA_DEVICE_Control(camera_device_handle_t *handle, camera_device_cmd_t cmd, int32_t arg)
138{
139 return handle->ops->control(handle, cmd, arg);
140}
141
142/*!
143 * @brief Start the camera device to output data.
144 *
145 * @param handle Camera device handle.
146 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
147 */
148static inline status_t CAMERA_DEVICE_Start(camera_device_handle_t *handle)
149{
150 return handle->ops->start(handle);
151}
152
153/*!
154 * @brief Stop the camera device outputing data.
155 *
156 * @param handle Camera device handle.
157 * @return Returns @ref kStatus_Success if success, otherwise returns error code.
158 */
159static inline status_t CAMERA_DEVICE_Stop(camera_device_handle_t *handle)
160{
161 return handle->ops->stop(handle);
162}
163
164#if defined(__cplusplus)
165}
166#endif
167
168#endif /* _FSL_CAMERA_DEVICE_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/driver_camera-device-max9286.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/driver_camera-device-max9286.cmake
new file mode 100644
index 000000000..d872b9e3e
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/driver_camera-device-max9286.cmake
@@ -0,0 +1,19 @@
1if(NOT DRIVER_CAMERA-DEVICE-MAX9286_INCLUDED)
2
3 set(DRIVER_CAMERA-DEVICE-MAX9286_INCLUDED true CACHE BOOL "driver_camera-device-max9286 component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_max9286.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13
14 include(driver_camera-common)
15 include(driver_video-common)
16 include(driver_camera-device-common)
17 include(driver_video-i2c)
18
19endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/fsl_max9286.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/fsl_max9286.c
new file mode 100644
index 000000000..b3fc52c2b
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/fsl_max9286.c
@@ -0,0 +1,807 @@
1/*
2 * Copyright 2018, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#include "fsl_video_common.h"
10#include "fsl_camera.h"
11#include "fsl_camera_device.h"
12#include "fsl_max9286.h"
13
14/*******************************************************************************
15 * Definitions
16 ******************************************************************************/
17#ifndef MAX9271_RETRY
18#define MAX9271_RETRY 20U
19#endif
20
21#ifndef OV10635_RETRY
22#define OV10635_RETRY 20U
23#endif
24
25#define I2C_ADDR_MAX9286 0x6AU
26#define I2C_ADDR_MAX9271 0x40U
27#define I2C_ADDR_OV10635 0x30U
28/*
29 * 0: Initial value
30 * 1-4: Address for each camera
31 * 5: Broadcast address
32 */
33#define I2C_ADDR_MAX9271_N(n) (I2C_ADDR_MAX9271 + (uint8_t)(n))
34
35#define I2C_ADDR_OV10635_N(n) (I2C_ADDR_OV10635 + (uint8_t)(n))
36
37#define MAX9271_MAX_COUNT 4U /* 4 MAX9271 at most. */
38
39#define MAX9286_Write(handle, reg, value) \
40 VIDEO_I2C_WriteReg(I2C_ADDR_MAX9286, kVIDEO_RegAddr8Bit, (reg), kVIDEO_RegWidth8Bit, (value), \
41 ((const max9286_resource_t *)((handle)->resource))->i2cSendFunc)
42
43#define MAX9286_Read(handle, reg, value) \
44 VIDEO_I2C_ReadReg(I2C_ADDR_MAX9286, kVIDEO_RegAddr8Bit, (reg), kVIDEO_RegWidth8Bit, (value), \
45 ((const max9286_resource_t *)((handle)->resource))->i2cReceiveFunc)
46
47#define OV10635_REG_PID 0x300AU
48#define OV10635_REG_VER 0x300BU
49#define OV10635_PID 0xA6U
50#define OV10635_VER 0x35U
51
52#define MAX9286_REG_ID 0x1EU
53#define MAX9286_ID 0x40U
54
55#define OV10635_RESOLUTION_CONFIG_REG_NUM 9U
56
57typedef struct _ov10635_reg
58{
59 uint16_t reg;
60 uint8_t value;
61} ov10635_reg_t;
62
63typedef struct _ov10635_resolution_config
64{
65 uint8_t framePerSec;
66 uint32_t resolution;
67 ov10635_reg_t regs[OV10635_RESOLUTION_CONFIG_REG_NUM];
68} ov10635_resolution_config_t;
69
70/*******************************************************************************
71 * Prototypes
72 ******************************************************************************/
73status_t MAX9286_Init(camera_device_handle_t *handle, const camera_config_t *config);
74status_t MAX9286_Deinit(camera_device_handle_t *handle);
75status_t MAX9286_Start(camera_device_handle_t *handle);
76status_t MAX9286_Stop(camera_device_handle_t *handle);
77status_t MAX9286_Control(camera_device_handle_t *handle, camera_device_cmd_t cmd, int32_t arg);
78status_t MAX9286_InitExt(camera_device_handle_t *handle, const camera_config_t *config, const void *extConfig);
79
80/*******************************************************************************
81 * Variables
82 ******************************************************************************/
83const camera_device_operations_t max9286_ops = {
84 .init = MAX9286_Init,
85 .deinit = MAX9286_Deinit,
86 .start = MAX9286_Start,
87 .stop = MAX9286_Stop,
88 .control = MAX9286_Control,
89 .init_ext = MAX9286_InitExt,
90};
91
92static const ov10635_reg_t ov10635Firmware[] = {
93 {0x0103, 0x01}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61},
94 {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61},
95 {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61},
96 {0x300C, 0x61}, {0x300C, 0x61}, {0x300C, 0x61}, {0x301B, 0xFF}, {0x301C, 0xFF}, {0x301A, 0xFF}, {0x3011, 0x42},
97 {0x6900, 0x0C}, {0x6901, 0x11}, {0x3503, 0x10}, {0x3025, 0x03}, {0x3003, 0x20}, {0x3004, 0x21}, {0x3005, 0x20},
98 {0x3006, 0x91}, {0x3600, 0x74}, {0x3601, 0x2B}, {0x3612, 0x00}, {0x3611, 0x67}, {0x3633, 0xCA}, {0x3602, 0x2F},
99 {0x3603, 0x00}, {0x3630, 0x28}, {0x3631, 0x16}, {0x3714, 0x10}, {0x371D, 0x01}, {0x4300, 0x38}, {0x3007, 0x01},
100 {0x3024, 0x01}, {0x3020, 0x0B}, {0x3702, 0x20}, {0x3703, 0x48}, {0x3704, 0x32}, {0x3709, 0xA8}, {0x3709, 0xA8},
101 {0x370C, 0xC7}, {0x370D, 0x80}, {0x3712, 0x00}, {0x3713, 0x20}, {0x3715, 0x04}, {0x381D, 0x40}, {0x381C, 0x00},
102 {0x3822, 0x50}, {0x3824, 0x50}, {0x3815, 0x8C}, {0x3804, 0x05}, {0x3805, 0x1F}, {0x3800, 0x00}, {0x3801, 0x00},
103 {0x3806, 0x03}, {0x3807, 0x29}, {0x3802, 0x00}, {0x3803, 0x04}, {0x3808, 0x05}, {0x3809, 0x00}, {0x380A, 0x03},
104 {0x380B, 0x20}, {0x380C, 0x07}, {0x380D, 0x71}, {0x6E42, 0x03}, {0x6E43, 0x48}, {0x380E, 0x03}, {0x380F, 0x48},
105 {0x3813, 0x02}, {0x3811, 0x10}, {0x381F, 0x0C}, {0x3828, 0x03}, {0x3829, 0x10}, {0x382A, 0x10}, {0x382B, 0x10},
106 {0x3621, 0x64}, {0x5005, 0x08}, {0x56D5, 0x00}, {0x56D6, 0x80}, {0x56D7, 0x00}, {0x56D8, 0x00}, {0x56D9, 0x00},
107 {0x56DA, 0x80}, {0x56DB, 0x00}, {0x56DC, 0x00}, {0x56E8, 0x00}, {0x56E9, 0x7F}, {0x56EA, 0x00}, {0x56EB, 0x7F},
108 {0x5100, 0x00}, {0x5101, 0x80}, {0x5102, 0x00}, {0x5103, 0x80}, {0x5104, 0x00}, {0x5105, 0x80}, {0x5106, 0x00},
109 {0x5107, 0x80}, {0x5108, 0x00}, {0x5109, 0x00}, {0x510A, 0x00}, {0x510B, 0x00}, {0x510C, 0x00}, {0x510D, 0x00},
110 {0x510E, 0x00}, {0x510F, 0x00}, {0x5110, 0x00}, {0x5111, 0x80}, {0x5112, 0x00}, {0x5113, 0x80}, {0x5114, 0x00},
111 {0x5115, 0x80}, {0x5116, 0x00}, {0x5117, 0x80}, {0x5118, 0x00}, {0x5119, 0x00}, {0x511A, 0x00}, {0x511B, 0x00},
112 {0x511C, 0x00}, {0x511D, 0x00}, {0x511E, 0x00}, {0x511F, 0x00}, {0x56D0, 0x00}, {0x5006, 0x24}, {0x5608, 0x0D},
113 {0x52D7, 0x06}, {0x528D, 0x08}, {0x5293, 0x12}, {0x52D3, 0x12}, {0x5288, 0x06}, {0x5289, 0x20}, {0x52C8, 0x06},
114 {0x52C9, 0x20}, {0x52CD, 0x04}, {0x5381, 0x00}, {0x5382, 0xFF}, {0x5589, 0x76}, {0x558A, 0x47}, {0x558B, 0xEF},
115 {0x558C, 0xC9}, {0x558D, 0x49}, {0x558E, 0x30}, {0x558F, 0x67}, {0x5590, 0x3F}, {0x5591, 0xF0}, {0x5592, 0x10},
116 {0x55A2, 0x6D}, {0x55A3, 0x55}, {0x55A4, 0xC3}, {0x55A5, 0xB5}, {0x55A6, 0x43}, {0x55A7, 0x38}, {0x55A8, 0x5F},
117 {0x55A9, 0x4B}, {0x55AA, 0xF0}, {0x55AB, 0x10}, {0x5581, 0x52}, {0x5300, 0x01}, {0x5301, 0x00}, {0x5302, 0x00},
118 {0x5303, 0x0E}, {0x5304, 0x00}, {0x5305, 0x0E}, {0x5306, 0x00}, {0x5307, 0x36}, {0x5308, 0x00}, {0x5309, 0xD9},
119 {0x530A, 0x00}, {0x530B, 0x0F}, {0x530C, 0x00}, {0x530D, 0x2C}, {0x530E, 0x00}, {0x530F, 0x59}, {0x5310, 0x00},
120 {0x5311, 0x7B}, {0x5312, 0x00}, {0x5313, 0x22}, {0x5314, 0x00}, {0x5315, 0xD5}, {0x5316, 0x00}, {0x5317, 0x13},
121 {0x5318, 0x00}, {0x5319, 0x18}, {0x531A, 0x00}, {0x531B, 0x26}, {0x531C, 0x00}, {0x531D, 0xDC}, {0x531E, 0x00},
122 {0x531F, 0x02}, {0x5320, 0x00}, {0x5321, 0x24}, {0x5322, 0x00}, {0x5323, 0x56}, {0x5324, 0x00}, {0x5325, 0x85},
123 {0x5326, 0x00}, {0x5327, 0x20}, {0x5609, 0x01}, {0x560A, 0x40}, {0x560B, 0x01}, {0x560C, 0x40}, {0x560D, 0x00},
124 {0x560E, 0xFA}, {0x560F, 0x00}, {0x5610, 0xFA}, {0x5611, 0x02}, {0x5612, 0x80}, {0x5613, 0x02}, {0x5614, 0x80},
125 {0x5615, 0x01}, {0x5616, 0x2C}, {0x5617, 0x01}, {0x5618, 0x2C}, {0x563B, 0x01}, {0x563C, 0x01}, {0x563D, 0x01},
126 {0x563E, 0x01}, {0x563F, 0x03}, {0x5640, 0x03}, {0x5641, 0x03}, {0x5642, 0x05}, {0x5643, 0x09}, {0x5644, 0x05},
127 {0x5645, 0x05}, {0x5646, 0x05}, {0x5647, 0x05}, {0x5651, 0x00}, {0x5652, 0x80}, {0x521A, 0x01}, {0x521B, 0x03},
128 {0x521C, 0x06}, {0x521D, 0x0A}, {0x521E, 0x0E}, {0x521F, 0x12}, {0x5220, 0x16}, {0x5223, 0x02}, {0x5225, 0x04},
129 {0x5227, 0x08}, {0x5229, 0x0C}, {0x522B, 0x12}, {0x522D, 0x18}, {0x522F, 0x1E}, {0x5241, 0x04}, {0x5242, 0x01},
130 {0x5243, 0x03}, {0x5244, 0x06}, {0x5245, 0x0A}, {0x5246, 0x0E}, {0x5247, 0x12}, {0x5248, 0x16}, {0x524A, 0x03},
131 {0x524C, 0x04}, {0x524E, 0x08}, {0x5250, 0x0C}, {0x5252, 0x12}, {0x5254, 0x18}, {0x5256, 0x1E}, {0x4606, 0x07},
132 {0x4607, 0x71}, {0x460A, 0x02}, {0x460B, 0x70}, {0x460C, 0x00}, {0x4620, 0x0E}, {0x4700, 0x04}, {0x4701, 0x00},
133 {0x4702, 0x01}, {0x4004, 0x04}, {0x4005, 0x18}, {0x4001, 0x06}, {0x4050, 0x22}, {0x4051, 0x24}, {0x4052, 0x02},
134 {0x4057, 0x9C}, {0x405A, 0x00}, {0x4202, 0x02}, {0x3023, 0x10}, {0x0100, 0x01}, {0x0100, 0x01}, {0x6F10, 0x07},
135 {0x6F11, 0x82}, {0x6F12, 0x04}, {0x6F13, 0x00}, {0x6F14, 0x1F}, {0x6F15, 0xDD}, {0x6F16, 0x04}, {0x6F17, 0x04},
136 {0x6F18, 0x36}, {0x6F19, 0x66}, {0x6F1A, 0x04}, {0x6F1B, 0x08}, {0x6F1C, 0x0C}, {0x6F1D, 0xE7}, {0x6F1E, 0x04},
137 {0x6F1F, 0x0C}, {0xD000, 0x19}, {0xD001, 0xA0}, {0xD002, 0x00}, {0xD003, 0x01}, {0xD004, 0xA9}, {0xD005, 0xAD},
138 {0xD006, 0x10}, {0xD007, 0x40}, {0xD008, 0x44}, {0xD009, 0x00}, {0xD00A, 0x68}, {0xD00B, 0x00}, {0xD00C, 0x15},
139 {0xD00D, 0x00}, {0xD00E, 0x00}, {0xD00F, 0x00}, {0xD010, 0x19}, {0xD011, 0xA0}, {0xD012, 0x00}, {0xD013, 0x01},
140 {0xD014, 0xA9}, {0xD015, 0xAD}, {0xD016, 0x13}, {0xD017, 0xD0}, {0xD018, 0x44}, {0xD019, 0x00}, {0xD01A, 0x68},
141 {0xD01B, 0x00}, {0xD01C, 0x15}, {0xD01D, 0x00}, {0xD01E, 0x00}, {0xD01F, 0x00}, {0xD020, 0x19}, {0xD021, 0xA0},
142 {0xD022, 0x00}, {0xD023, 0x01}, {0xD024, 0xA9}, {0xD025, 0xAD}, {0xD026, 0x14}, {0xD027, 0xB8}, {0xD028, 0x44},
143 {0xD029, 0x00}, {0xD02A, 0x68}, {0xD02B, 0x00}, {0xD02C, 0x15}, {0xD02D, 0x00}, {0xD02E, 0x00}, {0xD02F, 0x00},
144 {0xD030, 0x19}, {0xD031, 0xA0}, {0xD032, 0x00}, {0xD033, 0x01}, {0xD034, 0xA9}, {0xD035, 0xAD}, {0xD036, 0x14},
145 {0xD037, 0xDC}, {0xD038, 0x44}, {0xD039, 0x00}, {0xD03A, 0x68}, {0xD03B, 0x00}, {0xD03C, 0x15}, {0xD03D, 0x00},
146 {0xD03E, 0x00}, {0xD03F, 0x00}, {0xD040, 0x9C}, {0xD041, 0x21}, {0xD042, 0xFF}, {0xD043, 0xE4}, {0xD044, 0xD4},
147 {0xD045, 0x01}, {0xD046, 0x48}, {0xD047, 0x00}, {0xD048, 0xD4}, {0xD049, 0x01}, {0xD04A, 0x50}, {0xD04B, 0x04},
148 {0xD04C, 0xD4}, {0xD04D, 0x01}, {0xD04E, 0x60}, {0xD04F, 0x08}, {0xD050, 0xD4}, {0xD051, 0x01}, {0xD052, 0x70},
149 {0xD053, 0x0C}, {0xD054, 0xD4}, {0xD055, 0x01}, {0xD056, 0x80}, {0xD057, 0x10}, {0xD058, 0x19}, {0xD059, 0xC0},
150 {0xD05A, 0x00}, {0xD05B, 0x01}, {0xD05C, 0xA9}, {0xD05D, 0xCE}, {0xD05E, 0x02}, {0xD05F, 0xA4}, {0xD060, 0x9C},
151 {0xD061, 0xA0}, {0xD062, 0x00}, {0xD063, 0x00}, {0xD064, 0x84}, {0xD065, 0x6E}, {0xD066, 0x00}, {0xD067, 0x00},
152 {0xD068, 0xD8}, {0xD069, 0x03}, {0xD06A, 0x28}, {0xD06B, 0x76}, {0xD06C, 0x1A}, {0xD06D, 0x00}, {0xD06E, 0x00},
153 {0xD06F, 0x01}, {0xD070, 0xAA}, {0xD071, 0x10}, {0xD072, 0x03}, {0xD073, 0xF0}, {0xD074, 0x18}, {0xD075, 0x60},
154 {0xD076, 0x00}, {0xD077, 0x01}, {0xD078, 0xA8}, {0xD079, 0x63}, {0xD07A, 0x07}, {0xD07B, 0x80}, {0xD07C, 0xE0},
155 {0xD07D, 0xA0}, {0xD07E, 0x00}, {0xD07F, 0x04}, {0xD080, 0x18}, {0xD081, 0xC0}, {0xD082, 0x00}, {0xD083, 0x00},
156 {0xD084, 0xA8}, {0xD085, 0xC6}, {0xD086, 0x00}, {0xD087, 0x00}, {0xD088, 0x8C}, {0xD089, 0x63}, {0xD08A, 0x00},
157 {0xD08B, 0x00}, {0xD08C, 0xD4}, {0xD08D, 0x01}, {0xD08E, 0x28}, {0xD08F, 0x14}, {0xD090, 0xD4}, {0xD091, 0x01},
158 {0xD092, 0x30}, {0xD093, 0x18}, {0xD094, 0x07}, {0xD095, 0xFF}, {0xD096, 0xF8}, {0xD097, 0xFD}, {0xD098, 0x9C},
159 {0xD099, 0x80}, {0xD09A, 0x00}, {0xD09B, 0x03}, {0xD09C, 0xA5}, {0xD09D, 0x6B}, {0xD09E, 0x00}, {0xD09F, 0xFF},
160 {0xD0A0, 0x18}, {0xD0A1, 0xC0}, {0xD0A2, 0x00}, {0xD0A3, 0x01}, {0xD0A4, 0xA8}, {0xD0A5, 0xC6}, {0xD0A6, 0x01},
161 {0xD0A7, 0x02}, {0xD0A8, 0xE1}, {0xD0A9, 0x6B}, {0xD0AA, 0x58}, {0xD0AB, 0x00}, {0xD0AC, 0x84}, {0xD0AD, 0x8E},
162 {0xD0AE, 0x00}, {0xD0AF, 0x00}, {0xD0B0, 0xE1}, {0xD0B1, 0x6B}, {0xD0B2, 0x30}, {0xD0B3, 0x00}, {0xD0B4, 0x98},
163 {0xD0B5, 0xB0}, {0xD0B6, 0x00}, {0xD0B7, 0x00}, {0xD0B8, 0x8C}, {0xD0B9, 0x64}, {0xD0BA, 0x00}, {0xD0BB, 0x6E},
164 {0xD0BC, 0xE5}, {0xD0BD, 0xA5}, {0xD0BE, 0x18}, {0xD0BF, 0x00}, {0xD0C0, 0x10}, {0xD0C1, 0x00}, {0xD0C2, 0x00},
165 {0xD0C3, 0x06}, {0xD0C4, 0x95}, {0xD0C5, 0x8B}, {0xD0C6, 0x00}, {0xD0C7, 0x00}, {0xD0C8, 0x94}, {0xD0C9, 0xA4},
166 {0xD0CA, 0x00}, {0xD0CB, 0x70}, {0xD0CC, 0xE5}, {0xD0CD, 0x65}, {0xD0CE, 0x60}, {0xD0CF, 0x00}, {0xD0D0, 0x0C},
167 {0xD0D1, 0x00}, {0xD0D2, 0x00}, {0xD0D3, 0x62}, {0xD0D4, 0x15}, {0xD0D5, 0x00}, {0xD0D6, 0x00}, {0xD0D7, 0x00},
168 {0xD0D8, 0x18}, {0xD0D9, 0x60}, {0xD0DA, 0x80}, {0xD0DB, 0x06}, {0xD0DC, 0xA8}, {0xD0DD, 0x83}, {0xD0DE, 0x38},
169 {0xD0DF, 0x29}, {0xD0E0, 0xA8}, {0xD0E1, 0xE3}, {0xD0E2, 0x40}, {0xD0E3, 0x08}, {0xD0E4, 0x8C}, {0xD0E5, 0x84},
170 {0xD0E6, 0x00}, {0xD0E7, 0x00}, {0xD0E8, 0xA8}, {0xD0E9, 0xA3}, {0xD0EA, 0x40}, {0xD0EB, 0x09}, {0xD0EC, 0xA8},
171 {0xD0ED, 0xC3}, {0xD0EE, 0x38}, {0xD0EF, 0x2A}, {0xD0F0, 0xD8}, {0xD0F1, 0x07}, {0xD0F2, 0x20}, {0xD0F3, 0x00},
172 {0xD0F4, 0x8C}, {0xD0F5, 0x66}, {0xD0F6, 0x00}, {0xD0F7, 0x00}, {0xD0F8, 0xD8}, {0xD0F9, 0x05}, {0xD0FA, 0x18},
173 {0xD0FB, 0x00}, {0xD0FC, 0x18}, {0xD0FD, 0x60}, {0xD0FE, 0x00}, {0xD0FF, 0x01}, {0xD100, 0x98}, {0xD101, 0x90},
174 {0xD102, 0x00}, {0xD103, 0x00}, {0xD104, 0x84}, {0xD105, 0xAE}, {0xD106, 0x00}, {0xD107, 0x00}, {0xD108, 0xA8},
175 {0xD109, 0x63}, {0xD10A, 0x06}, {0xD10B, 0x4C}, {0xD10C, 0x9C}, {0xD10D, 0xC0}, {0xD10E, 0x00}, {0xD10F, 0x00},
176 {0xD110, 0xD8}, {0xD111, 0x03}, {0xD112, 0x30}, {0xD113, 0x00}, {0xD114, 0x8C}, {0xD115, 0x65}, {0xD116, 0x00},
177 {0xD117, 0x6E}, {0xD118, 0xE5}, {0xD119, 0x84}, {0xD11A, 0x18}, {0xD11B, 0x00}, {0xD11C, 0x10}, {0xD11D, 0x00},
178 {0xD11E, 0x00}, {0xD11F, 0x07}, {0xD120, 0x18}, {0xD121, 0x80}, {0xD122, 0x80}, {0xD123, 0x06}, {0xD124, 0x94},
179 {0xD125, 0x65}, {0xD126, 0x00}, {0xD127, 0x70}, {0xD128, 0xE5}, {0xD129, 0x43}, {0xD12A, 0x60}, {0xD12B, 0x00},
180 {0xD12C, 0x0C}, {0xD12D, 0x00}, {0xD12E, 0x00}, {0xD12F, 0x3E}, {0xD130, 0xA8}, {0xD131, 0x64}, {0xD132, 0x38},
181 {0xD133, 0x24}, {0xD134, 0x18}, {0xD135, 0x80}, {0xD136, 0x80}, {0xD137, 0x06}, {0xD138, 0xA8}, {0xD139, 0x64},
182 {0xD13A, 0x38}, {0xD13B, 0x24}, {0xD13C, 0x8C}, {0xD13D, 0x63}, {0xD13E, 0x00}, {0xD13F, 0x00}, {0xD140, 0xA4},
183 {0xD141, 0x63}, {0xD142, 0x00}, {0xD143, 0x40}, {0xD144, 0xBC}, {0xD145, 0x23}, {0xD146, 0x00}, {0xD147, 0x00},
184 {0xD148, 0x0C}, {0xD149, 0x00}, {0xD14A, 0x00}, {0xD14B, 0x2A}, {0xD14C, 0xA8}, {0xD14D, 0x64}, {0xD14E, 0x6E},
185 {0xD14F, 0x44}, {0xD150, 0x19}, {0xD151, 0x00}, {0xD152, 0x80}, {0xD153, 0x06}, {0xD154, 0xA8}, {0xD155, 0xE8},
186 {0xD156, 0x3D}, {0xD157, 0x05}, {0xD158, 0x8C}, {0xD159, 0x67}, {0xD15A, 0x00}, {0xD15B, 0x00}, {0xD15C, 0xB8},
187 {0xD15D, 0x63}, {0xD15E, 0x00}, {0xD15F, 0x18}, {0xD160, 0xB8}, {0xD161, 0x63}, {0xD162, 0x00}, {0xD163, 0x98},
188 {0xD164, 0xBC}, {0xD165, 0x03}, {0xD166, 0x00}, {0xD167, 0x00}, {0xD168, 0x10}, {0xD169, 0x00}, {0xD16A, 0x00},
189 {0xD16B, 0x10}, {0xD16C, 0xA9}, {0xD16D, 0x48}, {0xD16E, 0x67}, {0xD16F, 0x02}, {0xD170, 0xB8}, {0xD171, 0xA3},
190 {0xD172, 0x00}, {0xD173, 0x19}, {0xD174, 0x8C}, {0xD175, 0x8A}, {0xD176, 0x00}, {0xD177, 0x00}, {0xD178, 0xA9},
191 {0xD179, 0x68}, {0xD17A, 0x67}, {0xD17B, 0x03}, {0xD17C, 0xB8}, {0xD17D, 0xC4}, {0xD17E, 0x00}, {0xD17F, 0x08},
192 {0xD180, 0x8C}, {0xD181, 0x6B}, {0xD182, 0x00}, {0xD183, 0x00}, {0xD184, 0xB8}, {0xD185, 0x85}, {0xD186, 0x00},
193 {0xD187, 0x98}, {0xD188, 0xE0}, {0xD189, 0x63}, {0xD18A, 0x30}, {0xD18B, 0x04}, {0xD18C, 0xE0}, {0xD18D, 0x64},
194 {0xD18E, 0x18}, {0xD18F, 0x00}, {0xD190, 0xA4}, {0xD191, 0x83}, {0xD192, 0xFF}, {0xD193, 0xFF}, {0xD194, 0xB8},
195 {0xD195, 0x64}, {0xD196, 0x00}, {0xD197, 0x48}, {0xD198, 0xD8}, {0xD199, 0x0A}, {0xD19A, 0x18}, {0xD19B, 0x00},
196 {0xD19C, 0xD8}, {0xD19D, 0x0B}, {0xD19E, 0x20}, {0xD19F, 0x00}, {0xD1A0, 0x9C}, {0xD1A1, 0x60}, {0xD1A2, 0x00},
197 {0xD1A3, 0x00}, {0xD1A4, 0xD8}, {0xD1A5, 0x07}, {0xD1A6, 0x18}, {0xD1A7, 0x00}, {0xD1A8, 0xA8}, {0xD1A9, 0x68},
198 {0xD1AA, 0x38}, {0xD1AB, 0x22}, {0xD1AC, 0x9C}, {0xD1AD, 0x80}, {0xD1AE, 0x00}, {0xD1AF, 0x70}, {0xD1B0, 0xA8},
199 {0xD1B1, 0xE8}, {0xD1B2, 0x38}, {0xD1B3, 0x43}, {0xD1B4, 0xD8}, {0xD1B5, 0x03}, {0xD1B6, 0x20}, {0xD1B7, 0x00},
200 {0xD1B8, 0x9C}, {0xD1B9, 0xA0}, {0xD1BA, 0x00}, {0xD1BB, 0x00}, {0xD1BC, 0xA8}, {0xD1BD, 0xC8}, {0xD1BE, 0x38},
201 {0xD1BF, 0x42}, {0xD1C0, 0x8C}, {0xD1C1, 0x66}, {0xD1C2, 0x00}, {0xD1C3, 0x00}, {0xD1C4, 0x9C}, {0xD1C5, 0xA5},
202 {0xD1C6, 0x00}, {0xD1C7, 0x01}, {0xD1C8, 0xB8}, {0xD1C9, 0x83}, {0xD1CA, 0x00}, {0xD1CB, 0x08}, {0xD1CC, 0xA4},
203 {0xD1CD, 0xA5}, {0xD1CE, 0x00}, {0xD1CF, 0xFF}, {0xD1D0, 0x8C}, {0xD1D1, 0x67}, {0xD1D2, 0x00}, {0xD1D3, 0x00},
204 {0xD1D4, 0xE0}, {0xD1D5, 0x63}, {0xD1D6, 0x20}, {0xD1D7, 0x00}, {0xD1D8, 0xA4}, {0xD1D9, 0x63}, {0xD1DA, 0xFF},
205 {0xD1DB, 0xFF}, {0xD1DC, 0xBC}, {0xD1DD, 0x43}, {0xD1DE, 0x00}, {0xD1DF, 0x07}, {0xD1E0, 0x0C}, {0xD1E1, 0x00},
206 {0xD1E2, 0x00}, {0xD1E3, 0x5B}, {0xD1E4, 0xBC}, {0xD1E5, 0x05}, {0xD1E6, 0x00}, {0xD1E7, 0x02}, {0xD1E8, 0x03},
207 {0xD1E9, 0xFF}, {0xD1EA, 0xFF}, {0xD1EB, 0xF6}, {0xD1EC, 0x9C}, {0xD1ED, 0xA0}, {0xD1EE, 0x00}, {0xD1EF, 0x00},
208 {0xD1F0, 0xA8}, {0xD1F1, 0xA4}, {0xD1F2, 0x55}, {0xD1F3, 0x86}, {0xD1F4, 0x8C}, {0xD1F5, 0x63}, {0xD1F6, 0x00},
209 {0xD1F7, 0x00}, {0xD1F8, 0xA8}, {0xD1F9, 0xC4}, {0xD1FA, 0x6E}, {0xD1FB, 0x45}, {0xD1FC, 0xA8}, {0xD1FD, 0xE4},
210 {0xD1FE, 0x55}, {0xD1FF, 0x87}, {0xD200, 0xD8}, {0xD201, 0x05}, {0xD202, 0x18}, {0xD203, 0x00}, {0xD204, 0x8C},
211 {0xD205, 0x66}, {0xD206, 0x00}, {0xD207, 0x00}, {0xD208, 0xA8}, {0xD209, 0xA4}, {0xD20A, 0x6E}, {0xD20B, 0x46},
212 {0xD20C, 0xD8}, {0xD20D, 0x07}, {0xD20E, 0x18}, {0xD20F, 0x00}, {0xD210, 0xA8}, {0xD211, 0x84}, {0xD212, 0x55},
213 {0xD213, 0x88}, {0xD214, 0x8C}, {0xD215, 0x65}, {0xD216, 0x00}, {0xD217, 0x00}, {0xD218, 0xD8}, {0xD219, 0x04},
214 {0xD21A, 0x18}, {0xD21B, 0x00}, {0xD21C, 0x03}, {0xD21D, 0xFF}, {0xD21E, 0xFF}, {0xD21F, 0xCE}, {0xD220, 0x19},
215 {0xD221, 0x00}, {0xD222, 0x80}, {0xD223, 0x06}, {0xD224, 0x8C}, {0xD225, 0x63}, {0xD226, 0x00}, {0xD227, 0x00},
216 {0xD228, 0xA4}, {0xD229, 0x63}, {0xD22A, 0x00}, {0xD22B, 0x40}, {0xD22C, 0xBC}, {0xD22D, 0x23}, {0xD22E, 0x00},
217 {0xD22F, 0x00}, {0xD230, 0x13}, {0xD231, 0xFF}, {0xD232, 0xFF}, {0xD233, 0xC8}, {0xD234, 0x9D}, {0xD235, 0x00},
218 {0xD236, 0x00}, {0xD237, 0x40}, {0xD238, 0xA8}, {0xD239, 0x64}, {0xD23A, 0x55}, {0xD23B, 0x86}, {0xD23C, 0xA8},
219 {0xD23D, 0xA4}, {0xD23E, 0x55}, {0xD23F, 0x87}, {0xD240, 0xD8}, {0xD241, 0x03}, {0xD242, 0x40}, {0xD243, 0x00},
220 {0xD244, 0xA8}, {0xD245, 0x64}, {0xD246, 0x55}, {0xD247, 0x88}, {0xD248, 0xD8}, {0xD249, 0x05}, {0xD24A, 0x40},
221 {0xD24B, 0x00}, {0xD24C, 0xD8}, {0xD24D, 0x03}, {0xD24E, 0x40}, {0xD24F, 0x00}, {0xD250, 0x03}, {0xD251, 0xFF},
222 {0xD252, 0xFF}, {0xD253, 0xC1}, {0xD254, 0x19}, {0xD255, 0x00}, {0xD256, 0x80}, {0xD257, 0x06}, {0xD258, 0x94},
223 {0xD259, 0x84}, {0xD25A, 0x00}, {0xD25B, 0x72}, {0xD25C, 0xE5}, {0xD25D, 0xA4}, {0xD25E, 0x60}, {0xD25F, 0x00},
224 {0xD260, 0x0C}, {0xD261, 0x00}, {0xD262, 0x00}, {0xD263, 0x3F}, {0xD264, 0x9D}, {0xD265, 0x60}, {0xD266, 0x01},
225 {0xD267, 0x00}, {0xD268, 0x85}, {0xD269, 0x4E}, {0xD26A, 0x00}, {0xD26B, 0x00}, {0xD26C, 0x98}, {0xD26D, 0x70},
226 {0xD26E, 0x00}, {0xD26F, 0x00}, {0xD270, 0x8C}, {0xD271, 0x8A}, {0xD272, 0x00}, {0xD273, 0x6F}, {0xD274, 0xE5},
227 {0xD275, 0x63}, {0xD276, 0x20}, {0xD277, 0x00}, {0xD278, 0x10}, {0xD279, 0x00}, {0xD27A, 0x00}, {0xD27B, 0x07},
228 {0xD27C, 0x15}, {0xD27D, 0x00}, {0xD27E, 0x00}, {0xD27F, 0x00}, {0xD280, 0x8C}, {0xD281, 0xAA}, {0xD282, 0x00},
229 {0xD283, 0x6E}, {0xD284, 0xE0}, {0xD285, 0x63}, {0xD286, 0x28}, {0xD287, 0x02}, {0xD288, 0xE0}, {0xD289, 0x84},
230 {0xD28A, 0x28}, {0xD28B, 0x02}, {0xD28C, 0x07}, {0xD28D, 0xFF}, {0xD28E, 0xF8}, {0xD28F, 0x66}, {0xD290, 0xE0},
231 {0xD291, 0x63}, {0xD292, 0x5B}, {0xD293, 0x06}, {0xD294, 0x8C}, {0xD295, 0x6A}, {0xD296, 0x00}, {0xD297, 0x77},
232 {0xD298, 0xE0}, {0xD299, 0x63}, {0xD29A, 0x5B}, {0xD29B, 0x06}, {0xD29C, 0xBD}, {0xD29D, 0x63}, {0xD29E, 0x00},
233 {0xD29F, 0x00}, {0xD2A0, 0x0C}, {0xD2A1, 0x00}, {0xD2A2, 0x00}, {0xD2A3, 0x3C}, {0xD2A4, 0x15}, {0xD2A5, 0x00},
234 {0xD2A6, 0x00}, {0xD2A7, 0x00}, {0xD2A8, 0x8C}, {0xD2A9, 0x8A}, {0xD2AA, 0x00}, {0xD2AB, 0x78}, {0xD2AC, 0xB8},
235 {0xD2AD, 0x63}, {0xD2AE, 0x00}, {0xD2AF, 0x88}, {0xD2B0, 0xE1}, {0xD2B1, 0x64}, {0xD2B2, 0x5B}, {0xD2B3, 0x06},
236 {0xD2B4, 0xBD}, {0xD2B5, 0x6B}, {0xD2B6, 0x00}, {0xD2B7, 0x00}, {0xD2B8, 0x0C}, {0xD2B9, 0x00}, {0xD2BA, 0x00},
237 {0xD2BB, 0x34}, {0xD2BC, 0xD4}, {0xD2BD, 0x01}, {0xD2BE, 0x18}, {0xD2BF, 0x14}, {0xD2C0, 0xB9}, {0xD2C1, 0x6B},
238 {0xD2C2, 0x00}, {0xD2C3, 0x88}, {0xD2C4, 0x85}, {0xD2C5, 0x01}, {0xD2C6, 0x00}, {0xD2C7, 0x14}, {0xD2C8, 0xBD},
239 {0xD2C9, 0x68}, {0xD2CA, 0x00}, {0xD2CB, 0x00}, {0xD2CC, 0x0C}, {0xD2CD, 0x00}, {0xD2CE, 0x00}, {0xD2CF, 0x2C},
240 {0xD2D0, 0xD4}, {0xD2D1, 0x01}, {0xD2D2, 0x58}, {0xD2D3, 0x18}, {0xD2D4, 0x84}, {0xD2D5, 0x81}, {0xD2D6, 0x00},
241 {0xD2D7, 0x14}, {0xD2D8, 0xBD}, {0xD2D9, 0xA4}, {0xD2DA, 0x01}, {0xD2DB, 0x00}, {0xD2DC, 0x10}, {0xD2DD, 0x00},
242 {0xD2DE, 0x00}, {0xD2DF, 0x05}, {0xD2E0, 0x84}, {0xD2E1, 0xC1}, {0xD2E2, 0x00}, {0xD2E3, 0x18}, {0xD2E4, 0x9C},
243 {0xD2E5, 0xA0}, {0xD2E6, 0x01}, {0xD2E7, 0x00}, {0xD2E8, 0xD4}, {0xD2E9, 0x01}, {0xD2EA, 0x28}, {0xD2EB, 0x14},
244 {0xD2EC, 0x84}, {0xD2ED, 0xC1}, {0xD2EE, 0x00}, {0xD2EF, 0x18}, {0xD2F0, 0xBD}, {0xD2F1, 0x66}, {0xD2F2, 0x00},
245 {0xD2F3, 0x00}, {0xD2F4, 0x0C}, {0xD2F5, 0x00}, {0xD2F6, 0x00}, {0xD2F7, 0x20}, {0xD2F8, 0x9D}, {0xD2F9, 0x00},
246 {0xD2FA, 0x00}, {0xD2FB, 0x00}, {0xD2FC, 0x84}, {0xD2FD, 0x61}, {0xD2FE, 0x00}, {0xD2FF, 0x18}, {0xD300, 0xBD},
247 {0xD301, 0xA3}, {0xD302, 0x01}, {0xD303, 0x00}, {0xD304, 0x10}, {0xD305, 0x00}, {0xD306, 0x00}, {0xD307, 0x03},
248 {0xD308, 0x9C}, {0xD309, 0x80}, {0xD30A, 0x01}, {0xD30B, 0x00}, {0xD30C, 0xD4}, {0xD30D, 0x01}, {0xD30E, 0x20},
249 {0xD30F, 0x18}, {0xD310, 0x18}, {0xD311, 0x60}, {0xD312, 0x80}, {0xD313, 0x06}, {0xD314, 0x85}, {0xD315, 0x01},
250 {0xD316, 0x00}, {0xD317, 0x14}, {0xD318, 0xA8}, {0xD319, 0x83}, {0xD31A, 0x38}, {0xD31B, 0x29}, {0xD31C, 0xA8},
251 {0xD31D, 0xC3}, {0xD31E, 0x40}, {0xD31F, 0x08}, {0xD320, 0x8C}, {0xD321, 0x84}, {0xD322, 0x00}, {0xD323, 0x00},
252 {0xD324, 0xA8}, {0xD325, 0xA3}, {0xD326, 0x38}, {0xD327, 0x2A}, {0xD328, 0xA8}, {0xD329, 0xE3}, {0xD32A, 0x40},
253 {0xD32B, 0x09}, {0xD32C, 0xE0}, {0xD32D, 0x64}, {0xD32E, 0x40}, {0xD32F, 0x00}, {0xD330, 0xD8}, {0xD331, 0x06},
254 {0xD332, 0x18}, {0xD333, 0x00}, {0xD334, 0x8C}, {0xD335, 0x65}, {0xD336, 0x00}, {0xD337, 0x00}, {0xD338, 0x84},
255 {0xD339, 0x81}, {0xD33A, 0x00}, {0xD33B, 0x18}, {0xD33C, 0xE3}, {0xD33D, 0xE3}, {0xD33E, 0x20}, {0xD33F, 0x00},
256 {0xD340, 0xD8}, {0xD341, 0x07}, {0xD342, 0xF8}, {0xD343, 0x00}, {0xD344, 0x03}, {0xD345, 0xFF}, {0xD346, 0xFF},
257 {0xD347, 0x6F}, {0xD348, 0x18}, {0xD349, 0x60}, {0xD34A, 0x00}, {0xD34B, 0x01}, {0xD34C, 0x0F}, {0xD34D, 0xFF},
258 {0xD34E, 0xFF}, {0xD34F, 0x9D}, {0xD350, 0x18}, {0xD351, 0x60}, {0xD352, 0x80}, {0xD353, 0x06}, {0xD354, 0x00},
259 {0xD355, 0x00}, {0xD356, 0x00}, {0xD357, 0x11}, {0xD358, 0xA8}, {0xD359, 0x83}, {0xD35A, 0x6E}, {0xD35B, 0x43},
260 {0xD35C, 0xE0}, {0xD35D, 0x6C}, {0xD35E, 0x28}, {0xD35F, 0x02}, {0xD360, 0xE0}, {0xD361, 0x84}, {0xD362, 0x28},
261 {0xD363, 0x02}, {0xD364, 0x07}, {0xD365, 0xFF}, {0xD366, 0xF8}, {0xD367, 0x30}, {0xD368, 0xB8}, {0xD369, 0x63},
262 {0xD36A, 0x00}, {0xD36B, 0x08}, {0xD36C, 0x03}, {0xD36D, 0xFF}, {0xD36E, 0xFF}, {0xD36F, 0xC0}, {0xD370, 0x85},
263 {0xD371, 0x4E}, {0xD372, 0x00}, {0xD373, 0x00}, {0xD374, 0x03}, {0xD375, 0xFF}, {0xD376, 0xFF}, {0xD377, 0xE7},
264 {0xD378, 0xD4}, {0xD379, 0x01}, {0xD37A, 0x40}, {0xD37B, 0x18}, {0xD37C, 0x9C}, {0xD37D, 0x60}, {0xD37E, 0x00},
265 {0xD37F, 0x00}, {0xD380, 0x03}, {0xD381, 0xFF}, {0xD382, 0xFF}, {0xD383, 0xDB}, {0xD384, 0xD4}, {0xD385, 0x01},
266 {0xD386, 0x18}, {0xD387, 0x14}, {0xD388, 0x03}, {0xD389, 0xFF}, {0xD38A, 0xFF}, {0xD38B, 0xCE}, {0xD38C, 0x9D},
267 {0xD38D, 0x6B}, {0xD38E, 0x00}, {0xD38F, 0xFF}, {0xD390, 0x03}, {0xD391, 0xFF}, {0xD392, 0xFF}, {0xD393, 0xC6},
268 {0xD394, 0x9C}, {0xD395, 0x63}, {0xD396, 0x00}, {0xD397, 0xFF}, {0xD398, 0xA8}, {0xD399, 0xE3}, {0xD39A, 0x38},
269 {0xD39B, 0x0F}, {0xD39C, 0x8C}, {0xD39D, 0x84}, {0xD39E, 0x00}, {0xD39F, 0x00}, {0xD3A0, 0xA8}, {0xD3A1, 0xA3},
270 {0xD3A2, 0x38}, {0xD3A3, 0x0E}, {0xD3A4, 0xA8}, {0xD3A5, 0xC3}, {0xD3A6, 0x6E}, {0xD3A7, 0x42}, {0xD3A8, 0xD8},
271 {0xD3A9, 0x07}, {0xD3AA, 0x20}, {0xD3AB, 0x00}, {0xD3AC, 0x8C}, {0xD3AD, 0x66}, {0xD3AE, 0x00}, {0xD3AF, 0x00},
272 {0xD3B0, 0xD8}, {0xD3B1, 0x05}, {0xD3B2, 0x18}, {0xD3B3, 0x00}, {0xD3B4, 0x85}, {0xD3B5, 0x21}, {0xD3B6, 0x00},
273 {0xD3B7, 0x00}, {0xD3B8, 0x85}, {0xD3B9, 0x41}, {0xD3BA, 0x00}, {0xD3BB, 0x04}, {0xD3BC, 0x85}, {0xD3BD, 0x81},
274 {0xD3BE, 0x00}, {0xD3BF, 0x08}, {0xD3C0, 0x85}, {0xD3C1, 0xC1}, {0xD3C2, 0x00}, {0xD3C3, 0x0C}, {0xD3C4, 0x86},
275 {0xD3C5, 0x01}, {0xD3C6, 0x00}, {0xD3C7, 0x10}, {0xD3C8, 0x44}, {0xD3C9, 0x00}, {0xD3CA, 0x48}, {0xD3CB, 0x00},
276 {0xD3CC, 0x9C}, {0xD3CD, 0x21}, {0xD3CE, 0x00}, {0xD3CF, 0x1C}, {0xD3D0, 0x9C}, {0xD3D1, 0x21}, {0xD3D2, 0xFF},
277 {0xD3D3, 0xFC}, {0xD3D4, 0xD4}, {0xD3D5, 0x01}, {0xD3D6, 0x48}, {0xD3D7, 0x00}, {0xD3D8, 0x18}, {0xD3D9, 0x60},
278 {0xD3DA, 0x00}, {0xD3DB, 0x01}, {0xD3DC, 0xA8}, {0xD3DD, 0x63}, {0xD3DE, 0x07}, {0xD3DF, 0x80}, {0xD3E0, 0x8C},
279 {0xD3E1, 0x63}, {0xD3E2, 0x00}, {0xD3E3, 0x68}, {0xD3E4, 0xBC}, {0xD3E5, 0x03}, {0xD3E6, 0x00}, {0xD3E7, 0x00},
280 {0xD3E8, 0x10}, {0xD3E9, 0x00}, {0xD3EA, 0x00}, {0xD3EB, 0x0C}, {0xD3EC, 0x15}, {0xD3ED, 0x00}, {0xD3EE, 0x00},
281 {0xD3EF, 0x00}, {0xD3F0, 0x07}, {0xD3F1, 0xFF}, {0xD3F2, 0xD9}, {0xD3F3, 0x98}, {0xD3F4, 0x15}, {0xD3F5, 0x00},
282 {0xD3F6, 0x00}, {0xD3F7, 0x00}, {0xD3F8, 0x18}, {0xD3F9, 0x60}, {0xD3FA, 0x80}, {0xD3FB, 0x06}, {0xD3FC, 0xA8},
283 {0xD3FD, 0x63}, {0xD3FE, 0xC4}, {0xD3FF, 0xB8}, {0xD400, 0x8C}, {0xD401, 0x63}, {0xD402, 0x00}, {0xD403, 0x00},
284 {0xD404, 0xBC}, {0xD405, 0x23}, {0xD406, 0x00}, {0xD407, 0x01}, {0xD408, 0x10}, {0xD409, 0x00}, {0xD40A, 0x00},
285 {0xD40B, 0x25}, {0xD40C, 0x9D}, {0xD40D, 0x00}, {0xD40E, 0x00}, {0xD40F, 0x00}, {0xD410, 0x00}, {0xD411, 0x00},
286 {0xD412, 0x00}, {0xD413, 0x0B}, {0xD414, 0xB8}, {0xD415, 0xE8}, {0xD416, 0x00}, {0xD417, 0x02}, {0xD418, 0x07},
287 {0xD419, 0xFF}, {0xD41A, 0xD6}, {0xD41B, 0x24}, {0xD41C, 0x15}, {0xD41D, 0x00}, {0xD41E, 0x00}, {0xD41F, 0x00},
288 {0xD420, 0x18}, {0xD421, 0x60}, {0xD422, 0x80}, {0xD423, 0x06}, {0xD424, 0xA8}, {0xD425, 0x63}, {0xD426, 0xC4},
289 {0xD427, 0xB8}, {0xD428, 0x8C}, {0xD429, 0x63}, {0xD42A, 0x00}, {0xD42B, 0x00}, {0xD42C, 0xBC}, {0xD42D, 0x23},
290 {0xD42E, 0x00}, {0xD42F, 0x01}, {0xD430, 0x10}, {0xD431, 0x00}, {0xD432, 0x00}, {0xD433, 0x1B}, {0xD434, 0x9D},
291 {0xD435, 0x00}, {0xD436, 0x00}, {0xD437, 0x00}, {0xD438, 0xB8}, {0xD439, 0xE8}, {0xD43A, 0x00}, {0xD43B, 0x02},
292 {0xD43C, 0x9C}, {0xD43D, 0xC0}, {0xD43E, 0x00}, {0xD43F, 0x00}, {0xD440, 0x18}, {0xD441, 0xA0}, {0xD442, 0x80},
293 {0xD443, 0x06}, {0xD444, 0xE0}, {0xD445, 0x67}, {0xD446, 0x30}, {0xD447, 0x00}, {0xD448, 0xA8}, {0xD449, 0xA5},
294 {0xD44A, 0xCE}, {0xD44B, 0xB0}, {0xD44C, 0x19}, {0xD44D, 0x60}, {0xD44E, 0x00}, {0xD44F, 0x01}, {0xD450, 0xA9},
295 {0xD451, 0x6B}, {0xD452, 0x06}, {0xD453, 0x14}, {0xD454, 0xE0}, {0xD455, 0x83}, {0xD456, 0x28}, {0xD457, 0x00},
296 {0xD458, 0x9C}, {0xD459, 0xC6}, {0xD45A, 0x00}, {0xD45B, 0x01}, {0xD45C, 0xE0}, {0xD45D, 0x63}, {0xD45E, 0x18},
297 {0xD45F, 0x00}, {0xD460, 0x8C}, {0xD461, 0x84}, {0xD462, 0x00}, {0xD463, 0x00}, {0xD464, 0xE0}, {0xD465, 0xA3},
298 {0xD466, 0x58}, {0xD467, 0x00}, {0xD468, 0xA4}, {0xD469, 0xC6}, {0xD46A, 0x00}, {0xD46B, 0xFF}, {0xD46C, 0xB8},
299 {0xD46D, 0x64}, {0xD46E, 0x00}, {0xD46F, 0x18}, {0xD470, 0xBC}, {0xD471, 0x46}, {0xD472, 0x00}, {0xD473, 0x03},
300 {0xD474, 0x94}, {0xD475, 0x85}, {0xD476, 0x00}, {0xD477, 0x00}, {0xD478, 0xB8}, {0xD479, 0x63}, {0xD47A, 0x00},
301 {0xD47B, 0x98}, {0xD47C, 0xE0}, {0xD47D, 0x64}, {0xD47E, 0x18}, {0xD47F, 0x00}, {0xD480, 0x0F}, {0xD481, 0xFF},
302 {0xD482, 0xFF}, {0xD483, 0xF0}, {0xD484, 0xDC}, {0xD485, 0x05}, {0xD486, 0x18}, {0xD487, 0x00}, {0xD488, 0x9C},
303 {0xD489, 0x68}, {0xD48A, 0x00}, {0xD48B, 0x01}, {0xD48C, 0xA5}, {0xD48D, 0x03}, {0xD48E, 0x00}, {0xD48F, 0xFF},
304 {0xD490, 0xBC}, {0xD491, 0x48}, {0xD492, 0x00}, {0xD493, 0x01}, {0xD494, 0x0F}, {0xD495, 0xFF}, {0xD496, 0xFF},
305 {0xD497, 0xEA}, {0xD498, 0xB8}, {0xD499, 0xE8}, {0xD49A, 0x00}, {0xD49B, 0x02}, {0xD49C, 0x18}, {0xD49D, 0x60},
306 {0xD49E, 0x00}, {0xD49F, 0x01}, {0xD4A0, 0xA8}, {0xD4A1, 0x63}, {0xD4A2, 0x06}, {0xD4A3, 0x14}, {0xD4A4, 0x07},
307 {0xD4A5, 0xFF}, {0xD4A6, 0xE4}, {0xD4A7, 0x05}, {0xD4A8, 0x9C}, {0xD4A9, 0x83}, {0xD4AA, 0x00}, {0xD4AB, 0x10},
308 {0xD4AC, 0x85}, {0xD4AD, 0x21}, {0xD4AE, 0x00}, {0xD4AF, 0x00}, {0xD4B0, 0x44}, {0xD4B1, 0x00}, {0xD4B2, 0x48},
309 {0xD4B3, 0x00}, {0xD4B4, 0x9C}, {0xD4B5, 0x21}, {0xD4B6, 0x00}, {0xD4B7, 0x04}, {0xD4B8, 0x18}, {0xD4B9, 0x60},
310 {0xD4BA, 0x00}, {0xD4BB, 0x01}, {0xD4BC, 0x9C}, {0xD4BD, 0x80}, {0xD4BE, 0xFF}, {0xD4BF, 0xFF}, {0xD4C0, 0xA8},
311 {0xD4C1, 0x63}, {0xD4C2, 0x09}, {0xD4C3, 0xEF}, {0xD4C4, 0xD8}, {0xD4C5, 0x03}, {0xD4C6, 0x20}, {0xD4C7, 0x00},
312 {0xD4C8, 0x18}, {0xD4C9, 0x60}, {0xD4CA, 0x80}, {0xD4CB, 0x06}, {0xD4CC, 0xA8}, {0xD4CD, 0x63}, {0xD4CE, 0xC9},
313 {0xD4CF, 0xEF}, {0xD4D0, 0xD8}, {0xD4D1, 0x03}, {0xD4D2, 0x20}, {0xD4D3, 0x00}, {0xD4D4, 0x44}, {0xD4D5, 0x00},
314 {0xD4D6, 0x48}, {0xD4D7, 0x00}, {0xD4D8, 0x15}, {0xD4D9, 0x00}, {0xD4DA, 0x00}, {0xD4DB, 0x00}, {0xD4DC, 0x18},
315 {0xD4DD, 0x80}, {0xD4DE, 0x00}, {0xD4DF, 0x01}, {0xD4E0, 0xA8}, {0xD4E1, 0x84}, {0xD4E2, 0x0A}, {0xD4E3, 0x12},
316 {0xD4E4, 0x8C}, {0xD4E5, 0x64}, {0xD4E6, 0x00}, {0xD4E7, 0x00}, {0xD4E8, 0xBC}, {0xD4E9, 0x03}, {0xD4EA, 0x00},
317 {0xD4EB, 0x00}, {0xD4EC, 0x13}, {0xD4ED, 0xFF}, {0xD4EE, 0xFF}, {0xD4EF, 0xFE}, {0xD4F0, 0x15}, {0xD4F1, 0x00},
318 {0xD4F2, 0x00}, {0xD4F3, 0x00}, {0xD4F4, 0x44}, {0xD4F5, 0x00}, {0xD4F6, 0x48}, {0xD4F7, 0x00}, {0xD4F8, 0x15},
319 {0xD4F9, 0x00}, {0xD4FA, 0x00}, {0xD4FB, 0x00}, {0xD4FC, 0x00}, {0xD4FD, 0x00}, {0xD4FE, 0x00}, {0xD4FF, 0x00},
320 {0xD500, 0x00}, {0xD501, 0x00}, {0xD502, 0x00}, {0xD503, 0x00}, {0x6F0E, 0x33}, {0x6F0F, 0x33}, {0x460E, 0x08},
321 {0x460F, 0x01}, {0x4610, 0x00}, {0x4611, 0x01}, {0x4612, 0x00}, {0x4613, 0x01}, {0x4605, 0x08}, {0x4608, 0x00},
322 {0x4609, 0x08}, {0x6804, 0x00}, {0x6805, 0x06}, {0x6806, 0x00}, {0x5120, 0x00}, {0x3510, 0x00}, {0x3504, 0x00},
323 {0x6800, 0x00}, {0x6F0D, 0x0F}, {0x5000, 0xFF}, {0x5001, 0xBF}, {0x5002, 0x7E}, {0x5003, 0x0C}, {0x503D, 0x00},
324 {0xC450, 0x01}, {0xC452, 0x04}, {0xC453, 0x00}, {0xC454, 0x00}, {0xC455, 0x00}, {0xC456, 0x00}, {0xC457, 0x00},
325 {0xC458, 0x00}, {0xC459, 0x00}, {0xC45B, 0x00}, {0xC45C, 0x00}, {0xC45D, 0x00}, {0xC45E, 0x00}, {0xC45F, 0x00},
326 {0xC460, 0x00}, {0xC461, 0x01}, {0xC462, 0x01}, {0xC464, 0x88}, {0xC465, 0x00}, {0xC466, 0x8A}, {0xC467, 0x00},
327 {0xC468, 0x86}, {0xC469, 0x00}, {0xC46A, 0x40}, {0xC46B, 0x50}, {0xC46C, 0x30}, {0xC46D, 0x28}, {0xC46E, 0x60},
328 {0xC46F, 0x40}, {0xC47C, 0x01}, {0xC47D, 0x38}, {0xC47E, 0x00}, {0xC47F, 0x00}, {0xC480, 0x00}, {0xC481, 0xFF},
329 {0xC482, 0x00}, {0xC483, 0x40}, {0xC484, 0x00}, {0xC485, 0x18}, {0xC486, 0x00}, {0xC487, 0x18}, {0xC488, 0x34},
330 {0xC489, 0x00}, {0xC48A, 0x34}, {0xC48B, 0x00}, {0xC48C, 0x00}, {0xC48D, 0x04}, {0xC48E, 0x00}, {0xC48F, 0x04},
331 {0xC490, 0x07}, {0xC492, 0x20}, {0xC493, 0x08}, {0xC498, 0x02}, {0xC499, 0x00}, {0xC49A, 0x02}, {0xC49B, 0x00},
332 {0xC49C, 0x02}, {0xC49D, 0x00}, {0xC49E, 0x02}, {0xC49F, 0x60}, {0xC4A0, 0x03}, {0xC4A1, 0x00}, {0xC4A2, 0x04},
333 {0xC4A3, 0x00}, {0xC4A4, 0x00}, {0xC4A5, 0x10}, {0xC4A6, 0x00}, {0xC4A7, 0x40}, {0xC4A8, 0x00}, {0xC4A9, 0x80},
334 {0xC4AA, 0x0D}, {0xC4AB, 0x00}, {0xC4AC, 0x0F}, {0xC4AD, 0xC0}, {0xC4B4, 0x01}, {0xC4B5, 0x01}, {0xC4B6, 0x00},
335 {0xC4B7, 0x01}, {0xC4B8, 0x00}, {0xC4B9, 0x01}, {0xC4BA, 0x01}, {0xC4BB, 0x00}, {0xC4BC, 0x01}, {0xC4BD, 0x60},
336 {0xC4BE, 0x02}, {0xC4BF, 0x33}, {0xC4C8, 0x03}, {0xC4C9, 0xD0}, {0xC4CA, 0x0E}, {0xC4CB, 0x00}, {0xC4CC, 0x10},
337 {0xC4CD, 0x18}, {0xC4CE, 0x10}, {0xC4CF, 0x18}, {0xC4D0, 0x04}, {0xC4D1, 0x80}, {0xC4E0, 0x04}, {0xC4E1, 0x02},
338 {0xC4E2, 0x01}, {0xC4E4, 0x10}, {0xC4E5, 0x20}, {0xC4E6, 0x30}, {0xC4E7, 0x40}, {0xC4E8, 0x50}, {0xC4E9, 0x60},
339 {0xC4EA, 0x70}, {0xC4EB, 0x80}, {0xC4EC, 0x90}, {0xC4ED, 0xA0}, {0xC4EE, 0xB0}, {0xC4EF, 0xC0}, {0xC4F0, 0xD0},
340 {0xC4F1, 0xE0}, {0xC4F2, 0xF0}, {0xC4F3, 0x80}, {0xC4F4, 0x00}, {0xC4F5, 0x20}, {0xC4F6, 0x02}, {0xC4F7, 0x00},
341 {0xC4F8, 0x04}, {0xC4F9, 0x0B}, {0xC4FA, 0x00}, {0xC4FB, 0x00}, {0xC4FC, 0x01}, {0xC4FD, 0x00}, {0xC4FE, 0x04},
342 {0xC4FF, 0x02}, {0xC500, 0x48}, {0xC501, 0x74}, {0xC502, 0x58}, {0xC503, 0x80}, {0xC504, 0x05}, {0xC505, 0x80},
343 {0xC506, 0x03}, {0xC507, 0x80}, {0xC508, 0x01}, {0xC509, 0xC0}, {0xC50A, 0x01}, {0xC50B, 0xA0}, {0xC50C, 0x01},
344 {0xC50D, 0x2C}, {0xC50E, 0x01}, {0xC50F, 0x0A}, {0xC510, 0x00}, {0xC511, 0x01}, {0xC512, 0x01}, {0xC513, 0x80},
345 {0xC514, 0x04}, {0xC515, 0x00}, {0xC518, 0x03}, {0xC519, 0x48}, {0xC51A, 0x07}, {0xC51B, 0x70}, {0xC2E0, 0x00},
346 {0xC2E1, 0x51}, {0xC2E2, 0x00}, {0xC2E3, 0xD6}, {0xC2E4, 0x01}, {0xC2E5, 0x5E}, {0xC2E9, 0x01}, {0xC2EA, 0x7A},
347 {0xC2EB, 0x90}, {0xC2ED, 0x00}, {0xC2EE, 0x7A}, {0xC2EF, 0x64}, {0xC308, 0x00}, {0xC309, 0x00}, {0xC30A, 0x00},
348 {0xC30C, 0x00}, {0xC30D, 0x01}, {0xC30E, 0x00}, {0xC30F, 0x00}, {0xC310, 0x01}, {0xC311, 0x60}, {0xC312, 0xFF},
349 {0xC313, 0x08}, {0xC314, 0x01}, {0xC315, 0x7F}, {0xC316, 0xFF}, {0xC317, 0x0B}, {0xC318, 0x00}, {0xC319, 0x0C},
350 {0xC31A, 0x00}, {0xC31B, 0xE0}, {0xC31C, 0x00}, {0xC31D, 0x14}, {0xC31E, 0x00}, {0xC31F, 0xC5}, {0xC320, 0xFF},
351 {0xC321, 0x4B}, {0xC322, 0xFF}, {0xC323, 0xF0}, {0xC324, 0xFF}, {0xC325, 0xE8}, {0xC326, 0x00}, {0xC327, 0x46},
352 {0xC328, 0xFF}, {0xC329, 0xD2}, {0xC32A, 0xFF}, {0xC32B, 0xE4}, {0xC32C, 0xFF}, {0xC32D, 0xBB}, {0xC32E, 0x00},
353 {0xC32F, 0x61}, {0xC330, 0xFF}, {0xC331, 0xF9}, {0xC332, 0x00}, {0xC333, 0xD9}, {0xC334, 0x00}, {0xC335, 0x2E},
354 {0xC336, 0x00}, {0xC337, 0xB1}, {0xC338, 0xFF}, {0xC339, 0x64}, {0xC33A, 0xFF}, {0xC33B, 0xEB}, {0xC33C, 0xFF},
355 {0xC33D, 0xE8}, {0xC33E, 0x00}, {0xC33F, 0x48}, {0xC340, 0xFF}, {0xC341, 0xD0}, {0xC342, 0xFF}, {0xC343, 0xED},
356 {0xC344, 0xFF}, {0xC345, 0xAD}, {0xC346, 0x00}, {0xC347, 0x66}, {0xC348, 0x01}, {0xC349, 0x00}, {0x6700, 0x04},
357 {0x6701, 0x7B}, {0x6702, 0xFD}, {0x6703, 0xF9}, {0x6704, 0x3D}, {0x6705, 0x71}, {0x6706, 0x78}, {0x6708, 0x05},
358 {0x6F06, 0x6F}, {0x6F07, 0x00}, {0x6F0A, 0x6F}, {0x6F0B, 0x00}, {0x6F00, 0x03}, {0xC34C, 0x01}, {0xC34D, 0x00},
359 {0xC34E, 0x46}, {0xC34F, 0x55}, {0xC350, 0x00}, {0xC351, 0x40}, {0xC352, 0x00}, {0xC353, 0xFF}, {0xC354, 0x04},
360 {0xC355, 0x08}, {0xC356, 0x01}, {0xC357, 0xEF}, {0xC358, 0x30}, {0xC359, 0x01}, {0xC35A, 0x64}, {0xC35B, 0x46},
361 {0xC35C, 0x00}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0},
362 {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0},
363 {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0},
364 {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x3042, 0xF0}, {0x301B, 0xF0},
365 {0x301C, 0xF0}, {0x301A, 0xF0}, {0xCEB0, 0x00}, {0xCEB1, 0x00}, {0xCEB2, 0x00}, {0xCEB3, 0x00}, {0xCEB4, 0x00},
366 {0xCEB5, 0x00}, {0xCEB6, 0x00}, {0xCEB7, 0x00}, {0xC4BC, 0x01}, {0xC4BD, 0x60}, {0x4709, 0x10}, {0x4300, 0x3A},
367 {0x3832, 0x01}, {0x3833, 0x1A}, {0x3834, 0x03}, {0x3835, 0x48}, {0x302E, 0x01},
368};
369
370static const ov10635_resolution_config_t s_ov10635ResolutionConfigs[] = {{.framePerSec = 30,
371 .resolution = (uint32_t)kVIDEO_ResolutionWXGA,
372 .regs =
373 {
374 {0x3024, 0x01},
375 {0x3003, 0x20},
376 {0x3004, 0x21},
377 {0x3005, 0x20},
378 {0x3006, 0x91},
379 {0x3808, 0x05},
380 {0x3809, 0x00},
381 {0x380a, 0x03},
382 {0x380b, 0x20},
383 }},
384 {.framePerSec = 30,
385 .resolution = (uint32_t)kVIDEO_Resolution720P,
386 .regs = {
387 {0x3024, 0x01},
388 {0x3003, 0x20},
389 {0x3004, 0x21},
390 {0x3005, 0x20},
391 {0x3006, 0x91},
392 {0x3808, 0x05},
393 {0x3809, 0x00},
394 {0x380a, 0x02},
395 {0x380b, 0xD0},
396 }}};
397
398/*******************************************************************************
399 * Code
400 ******************************************************************************/
401
402static status_t MAX9271_Write(camera_device_handle_t *handle, uint8_t i2cAddr, uint32_t reg, uint8_t value)
403{
404 uint32_t retry = MAX9271_RETRY;
405 status_t status = kStatus_Fail;
406
407 while (0U != (retry--))
408 {
409 status = VIDEO_I2C_WriteReg(i2cAddr, kVIDEO_RegAddr8Bit, reg, kVIDEO_RegWidth8Bit, value,
410 ((max9286_resource_t *)(handle->resource))->i2cSendFunc);
411 if (kStatus_Success == status)
412 {
413 break;
414 }
415 VIDEO_DelayMs(1);
416 }
417
418 return status;
419}
420
421static status_t OV10635_Write(camera_device_handle_t *handle, uint8_t i2cAddr, uint32_t reg, uint8_t value)
422{
423 uint32_t retry = OV10635_RETRY;
424 status_t status = kStatus_Fail;
425
426 while (0U != (retry--))
427 {
428 status = VIDEO_I2C_WriteReg(i2cAddr, kVIDEO_RegAddr16Bit, reg, kVIDEO_RegWidth8Bit, value,
429 ((max9286_resource_t *)(handle->resource))->i2cSendFunc);
430 if (kStatus_Success == status)
431 {
432 break;
433 }
434 VIDEO_DelayMs(1);
435 }
436
437 return status;
438}
439
440static status_t OV10635_Read(camera_device_handle_t *handle, uint8_t i2cAddr, uint32_t reg, uint8_t *value)
441{
442 uint32_t retry = OV10635_RETRY;
443 status_t status = kStatus_Fail;
444
445 while (0U != (retry--))
446 {
447 status = VIDEO_I2C_ReadReg(i2cAddr, kVIDEO_RegAddr16Bit, reg, kVIDEO_RegWidth8Bit, value,
448 ((max9286_resource_t *)(handle->resource))->i2cReceiveFunc);
449 if (kStatus_Success == status)
450 {
451 break;
452 }
453 VIDEO_DelayMs(1);
454 }
455
456 return status;
457}
458
459static const ov10635_resolution_config_t *OV10635_GetResolutionConfig(const camera_config_t *cameraConfig)
460{
461 uint8_t i;
462 const ov10635_resolution_config_t *config = NULL;
463
464 for (i = 0; i < ARRAY_SIZE(s_ov10635ResolutionConfigs); i++)
465 {
466 if ((cameraConfig->resolution == s_ov10635ResolutionConfigs[i].resolution) &&
467 (cameraConfig->framePerSec == s_ov10635ResolutionConfigs[i].framePerSec))
468 {
469 config = &s_ov10635ResolutionConfigs[i];
470 break;
471 }
472 }
473
474 return config;
475}
476
477static status_t OV10635_SetResolutionConfig(camera_device_handle_t *handle,
478 uint8_t index,
479 const ov10635_resolution_config_t *config)
480{
481 uint32_t i;
482 status_t status;
483 uint8_t i2cAddr = I2C_ADDR_OV10635_N(index);
484
485 for (i = 0; i < OV10635_RESOLUTION_CONFIG_REG_NUM; i++)
486 {
487 status = OV10635_Write(handle, i2cAddr, config->regs[i].reg, config->regs[i].value);
488 if (status != kStatus_Success)
489 {
490 return status;
491 }
492 }
493
494 return kStatus_Success;
495}
496
497static status_t MAX9286_ReorderVC(camera_device_handle_t *handle, uint8_t linkAvailableMask)
498{
499 uint8_t reg = 0;
500 uint8_t i = 0;
501 uint8_t availableVC = 0;
502 uint8_t unavailableVC = 3;
503
504 for (i = 0; i < MAX9271_MAX_COUNT; i++)
505 {
506 if (0U != (linkAvailableMask & (1U << i)))
507 {
508 /* Link available. */
509 reg |= (availableVC << (2U * i));
510 availableVC++;
511 }
512 else
513 {
514 /* Link not available. */
515 reg |= (unavailableVC << (2U * i));
516 unavailableVC--;
517 }
518 }
519
520 return MAX9286_Write(handle, 0x0B, reg);
521}
522
523static status_t OV10635_Init(camera_device_handle_t *handle, uint8_t index)
524{
525 uint32_t i;
526 status_t status;
527 uint8_t i2cAddr = I2C_ADDR_OV10635_N(index);
528 uint8_t reg = 0U;
529
530 /* Verify the camera ID. */
531 status = OV10635_Read(handle, i2cAddr, OV10635_REG_PID, &reg);
532 if ((status != kStatus_Success) || (reg != OV10635_PID))
533 {
534 return kStatus_Fail;
535 }
536
537 status = OV10635_Read(handle, i2cAddr, OV10635_REG_VER, &reg);
538 if ((status != kStatus_Success) || (reg != OV10635_VER))
539 {
540 return kStatus_Fail;
541 }
542
543 for (i = 0; i < ARRAY_SIZE(ov10635Firmware); i++)
544 {
545 status = OV10635_Write(handle, i2cAddr, ov10635Firmware[i].reg, ov10635Firmware[i].value);
546 if (status != kStatus_Success)
547 {
548 return status;
549 }
550 }
551
552 return kStatus_Success;
553}
554
555static status_t MAX9286_InitHardware(camera_device_handle_t *handle,
556 uint8_t enableCameraMask,
557 const camera_config_t *config)
558{
559 uint32_t i;
560 uint8_t enabledLink = 0;
561 status_t status;
562 const ov10635_resolution_config_t *resolutionConfig;
563
564 resolutionConfig = OV10635_GetResolutionConfig(config);
565
566 if (NULL == resolutionConfig)
567 {
568 return kStatus_InvalidArgument;
569 }
570
571 /* Disable CSI output. */
572 (void)MAX9286_Write(handle, 0x15, 0x03);
573
574 /* Enable PRBS test. */
575 (void)MAX9286_Write(handle, 0x0E, 0x5F);
576 VIDEO_DelayMs(10);
577
578 /* Enable Custom Reverse Channel & First Pulse Length*/
579 (void)MAX9286_Write(handle, 0x3F, 0x4F);
580 VIDEO_DelayMs(2);
581
582 /* First pulse length rise time changed from 300ns to 200ns */
583 (void)MAX9286_Write(handle, 0x3B, 0x1E);
584 VIDEO_DelayMs(2);
585
586 /* Optional - Enable configuration link */
587 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(0), 0x04, 0x43);
588 VIDEO_DelayMs(5);
589
590 /* Enable high threshold for reverse channel input
591 * buffer. This increases immunity to power supply
592 * noise when the coaxial link is used for power as
593 * well as signal.
594 */
595 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(0), 0x08, 0x01);
596 VIDEO_DelayMs(2);
597
598 /* Increase reverse amplitude from 100mV to 170mV. */
599 (void)MAX9286_Write(handle, 0x3B, 0x19);
600 VIDEO_DelayMs(10);
601
602 /*
603 * CSI-2 Output uses YUV 422 8-bit.
604 * Use double input mode.
605 * Enable CSI data lanes D0-D3.
606 */
607 (void)MAX9286_Write(handle, 0x12, 0xF3);
608
609 /* Internal frame sync uses automatic mode */
610 (void)MAX9286_Write(handle, 0x01, 0x02);
611
612 /*
613 * Auto detect link used for CSI clock source.
614 * Disable Internal VSYNC generation.
615 * Enable all input link
616 */
617 (void)MAX9286_Write(handle, 0x00, 0xEF);
618 VIDEO_DelayMs(2);
619
620 /* Frame Sync, Automatic mode. */
621 (void)MAX9286_Write(handle, 0x01, 0x02);
622 VIDEO_DelayMs(200);
623
624 /*
625 * Detect available link.
626 */
627 (void)MAX9286_Read(handle, 0x49, &enabledLink);
628
629 enabledLink = (enabledLink | (enabledLink >> 4)) & 0x0FU;
630
631 enabledLink &= enableCameraMask;
632
633 /* The camera not valid. */
634 if (0U == enabledLink)
635 {
636 /* No valid link. */
637 return kStatus_Fail;
638 }
639
640 /* Disable PRBS test. */
641 (void)MAX9286_Write(handle, 0x0E, 0x50);
642
643 /* Select the first valid. */
644 enabledLink = (~(enabledLink - 1U)) & enabledLink;
645
646 (void)MAX9286_ReorderVC(handle, enabledLink);
647
648 /* Enable available links. */
649 (void)MAX9286_Write(handle, 0x00, 0xE0UL | enabledLink);
650
651 /*
652 * Enable DBL
653 * Set Edge Select 1=Rise / 0=Fall
654 * Enable HS/VS encoding
655 */
656 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(0), 0x07, 0x84);
657
658 /* Setup the links. */
659 for (i = 1; i <= MAX9271_MAX_COUNT; i++)
660 {
661 if ((enabledLink & (1U << (i - 1U))) == 0U)
662 {
663 continue;
664 }
665
666 /* Enable Link i Reverse Channel. */
667 (void)MAX9286_Write(handle, 0x0A, (0x11UL << (i - 1U)));
668 VIDEO_DelayMs(2);
669
670 /* Change serializer slave address. */
671 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(0), 0x00, I2C_ADDR_MAX9271_N(i) << 1);
672 VIDEO_DelayMs(2);
673
674 /* Deserializer device address. */
675 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(0), 0x01, I2C_ADDR_MAX9286 << 1);
676
677 VIDEO_DelayMs(2);
678
679 /* Unique Link i image sensor slave address */
680 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(i), 0x09, I2C_ADDR_OV10635_N(i) << 1);
681
682 /* Link i image sensor slave address */
683 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(i), 0x0A, I2C_ADDR_OV10635_N(0) << 1);
684
685 /* Serializer broadcast address */
686 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(i), 0x0B, I2C_ADDR_MAX9271_N(5) << 1);
687
688 /* Link i serializer address */
689 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(i), 0x0C, I2C_ADDR_MAX9271_N(i) << 1);
690 VIDEO_DelayMs(1);
691 }
692
693 /* Enable Link Reverse Channel. */
694 (void)MAX9286_Write(handle, 0x0A, (uint32_t)enabledLink | ((uint32_t)enabledLink << 4U));
695
696 /* Disable auto acknowledge. */
697 (void)MAX9286_Write(handle, 0x34, 0x36);
698
699 for (i = 1; i <= MAX9271_MAX_COUNT; i++)
700 {
701 if ((enabledLink & (1U << (i - 1U))) == 0U)
702 {
703 continue;
704 }
705
706 status = OV10635_Init(handle, (uint8_t)i);
707
708 if (status != kStatus_Success)
709 {
710 return status;
711 }
712
713 status = OV10635_SetResolutionConfig(handle, (uint8_t)i, resolutionConfig);
714
715 if (status != kStatus_Success)
716 {
717 return status;
718 }
719 }
720
721 /* Enable auto acknowledge. */
722 (void)MAX9286_Write(handle, 0x34, 0xB6);
723
724 /* Enable all serial links */
725 (void)MAX9271_Write(handle, I2C_ADDR_MAX9271_N(5), 0x04, 0x83);
726 VIDEO_DelayMs(5);
727
728 /* Enable CSI output. */
729 (void)MAX9286_Write(handle, 0x15, 0x9B);
730 VIDEO_DelayMs(10);
731
732 return kStatus_Success;
733}
734
735status_t MAX9286_Init(camera_device_handle_t *handle, const camera_config_t *config)
736{
737 /* Any camera could be used. */
738 const max9286_ext_config_t extConfig = {0xFF};
739
740 return MAX9286_InitExt(handle, config, &extConfig);
741}
742
743status_t MAX9286_InitExt(camera_device_handle_t *handle, const camera_config_t *config, const void *extConfig)
744{
745 status_t status;
746 uint8_t reg = 0;
747 uint8_t enableCameraMask;
748
749 const max9286_resource_t *resource = (const max9286_resource_t *)(handle->resource);
750
751 if (NULL != extConfig)
752 {
753 enableCameraMask = ((const max9286_ext_config_t *)extConfig)->enableCameraMask & 0x0FU;
754 }
755 else
756 {
757 enableCameraMask = 0xFFU;
758 }
759
760 if (kCAMERA_InterfaceMIPI != config->interface)
761 {
762 return kStatus_InvalidArgument;
763 }
764
765 /* Only support YUV422 */
766 if (kVIDEO_PixelFormatYUYV != config->pixelFormat)
767 {
768 return kStatus_InvalidArgument;
769 }
770
771 /* Perform hardware reset. */
772 resource->pullPowerDownPin(false);
773 VIDEO_DelayMs(1);
774 resource->pullPowerDownPin(true);
775 VIDEO_DelayMs(10);
776
777 /* Identify the device. */
778 status = MAX9286_Read(handle, MAX9286_REG_ID, &reg);
779 if ((status != kStatus_Success) || (reg != MAX9286_ID))
780 {
781 return kStatus_Fail;
782 }
783
784 return MAX9286_InitHardware(handle, enableCameraMask, config);
785}
786
787status_t MAX9286_Deinit(camera_device_handle_t *handle)
788{
789 ((max9286_resource_t *)(handle->resource))->pullPowerDownPin(false);
790
791 return kStatus_Success;
792}
793
794status_t MAX9286_Start(camera_device_handle_t *handle)
795{
796 return MAX9286_Write(handle, 0x15, 0x1B);
797}
798
799status_t MAX9286_Stop(camera_device_handle_t *handle)
800{
801 return MAX9286_Write(handle, 0x15, 0x03);
802}
803
804status_t MAX9286_Control(camera_device_handle_t *handle, camera_device_cmd_t cmd, int32_t arg)
805{
806 return kStatus_InvalidArgument;
807}
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/fsl_max9286.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/fsl_max9286.h
new file mode 100644
index 000000000..8264b9e4d
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/max9286/fsl_max9286.h
@@ -0,0 +1,89 @@
1/*
2 * Copyright 2018, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_MAX9286_H_
10#define _FSL_MAX9286_H_
11
12#include "fsl_common.h"
13#include "fsl_camera_device.h"
14#include "fsl_video_i2c.h"
15
16/*
17 * Change Log:
18 *
19 * 1.0.2:
20 * - Bug Fixes:
21 * - Fix MISRA 2012 issues.
22 *
23 * 1.0.1:
24 * - Bug Fixes:
25 * - Fixed the bug that camera does not work after warm reset.
26 *
27 * 1.0.0:
28 * - Initial version.
29 *
30 */
31
32/*
33 * The MAX9286 supports 4 camera output. Currently the driver only support
34 * one camera output. User could select which camera to enable by the extended
35 * configuration max9286_ext_config_t. If not specified, the first valid camera
36 * is used.
37 */
38
39/*******************************************************************************
40 * Definitions
41 ******************************************************************************/
42
43/*******************************************************************************
44 * Prototypes
45 ******************************************************************************/
46
47/*!
48 * @brief MAX9286 resource.
49 *
50 * Before initialize the MAX9286, the resource must be initialized that the
51 * Two-Wire-Serial-Interface I2C could start to work.
52 *
53 * The input clock must be 27MHz.
54 */
55typedef struct _max9286_resource
56{
57 video_i2c_send_func_t i2cSendFunc; /*!< I2C send function. */
58 video_i2c_receive_func_t i2cReceiveFunc; /*!< I2C receive function. */
59 void (*pullPowerDownPin)(bool pullUp); /*!< Function to pull power down pin high or low. */
60} max9286_resource_t;
61
62/*!
63 * @brief MAX9286 extended configuration.
64 */
65typedef struct _max9286_ext_config
66{
67 uint8_t enableCameraMask; /*!< Select which camera to enable, there are 4 cameras. For example,
68 use 0x01 to use camera 0, use 0x08 to use camera 3.
69 Currently only support one camera. If multiple cameras are
70 selected, the first available selected camera is used.
71 */
72} max9286_ext_config_t;
73
74/*! @brief MAX9286 operation functions. */
75extern const camera_device_operations_t max9286_ops;
76
77/*******************************************************************************
78 * API
79 ******************************************************************************/
80
81#if defined(__cplusplus)
82extern "C" {
83#endif
84
85#if defined(__cplusplus)
86}
87#endif
88
89#endif /* _FSL_MAX9286_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/driver_camera-device-mt9m114.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/driver_camera-device-mt9m114.cmake
new file mode 100644
index 000000000..8dbbe005a
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/driver_camera-device-mt9m114.cmake
@@ -0,0 +1,19 @@
1if(NOT DRIVER_CAMERA-DEVICE-MT9M114_INCLUDED)
2
3 set(DRIVER_CAMERA-DEVICE-MT9M114_INCLUDED true CACHE BOOL "driver_camera-device-mt9m114 component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_mt9m114.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13
14 include(driver_camera-common)
15 include(driver_video-common)
16 include(driver_camera-device-common)
17 include(driver_video-i2c)
18
19endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/fsl_mt9m114.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/fsl_mt9m114.c
new file mode 100644
index 000000000..c843aff38
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/fsl_mt9m114.c
@@ -0,0 +1,397 @@
1/*
2 * Copyright 2017-2018 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#include "fsl_video_common.h"
10#include "fsl_camera.h"
11#include "fsl_camera_device.h"
12#include "fsl_mt9m114.h"
13
14/*******************************************************************************
15 * Definitions
16 ******************************************************************************/
17
18#define MT9M114_DelayMs(ms) VIDEO_DelayMs(ms)
19#define MT9M114_Write(handle, reg, size, value) \
20 VIDEO_I2C_WriteReg(MT9M114_I2C_ADDR, kVIDEO_RegAddr16Bit, (reg), (video_reg_width_t)(size), (value), \
21 ((mt9m114_resource_t *)((handle)->resource))->i2cSendFunc)
22#define MT9M114_Read(handle, reg, size, value) \
23 VIDEO_I2C_ReadReg(MT9M114_I2C_ADDR, kVIDEO_RegAddr16Bit, (reg), (video_reg_width_t)(size), (value), \
24 ((mt9m114_resource_t *)((handle)->resource))->i2cReceiveFunc)
25#define MT9M114_Modify(handle, reg, size, clrMask, value) \
26 VIDEO_I2C_ModifyReg(MT9M114_I2C_ADDR, kVIDEO_RegAddr16Bit, (reg), (video_reg_width_t)(size), (clrMask), (value), \
27 ((mt9m114_resource_t *)((handle)->resource))->i2cReceiveFunc, \
28 ((mt9m114_resource_t *)((handle)->resource))->i2cSendFunc)
29
30typedef struct _mt9m114_reg
31{
32 uint16_t reg;
33 uint8_t size;
34 uint32_t value;
35} mt9m114_reg_t;
36
37/*******************************************************************************
38 * Prototypes
39 ******************************************************************************/
40status_t MT9M114_Init(camera_device_handle_t *handle, const camera_config_t *config);
41status_t MT9M114_Deinit(camera_device_handle_t *handle);
42status_t MT9M114_Start(camera_device_handle_t *handle);
43status_t MT9M114_Stop(camera_device_handle_t *handle);
44status_t MT9M114_Control(camera_device_handle_t *handle, camera_device_cmd_t cmd, int32_t arg);
45status_t MT9M114_InitExt(camera_device_handle_t *handle, const camera_config_t *config, const void *specialConfig);
46
47/*******************************************************************************
48 * Variables
49 ******************************************************************************/
50const camera_device_operations_t mt9m114_ops = {
51 .init = MT9M114_Init,
52 .deinit = MT9M114_Deinit,
53 .start = MT9M114_Start,
54 .stop = MT9M114_Stop,
55 .control = MT9M114_Control,
56 .init_ext = MT9M114_InitExt,
57};
58
59static const mt9m114_reg_t mt9m114_720p[] = {
60 {MT9M114_VAR_CAM_SENSOR_CFG_Y_ADDR_START, 2, 0x007C}, /* cam_sensor_cfg_y_addr_start = 124 */
61 {MT9M114_VAR_CAM_SENSOR_CFG_X_ADDR_START, 2, 0x0004}, /* cam_sensor_cfg_x_addr_start = 4 */
62 {MT9M114_VAR_CAM_SENSOR_CFG_Y_ADDR_END, 2, 0x0353}, /* cam_sensor_cfg_y_addr_end = 851 */
63 {MT9M114_VAR_CAM_SENSOR_CFG_X_ADDR_END, 2, 0x050B}, /* cam_sensor_cfg_x_addr_end = 1291 */
64 {MT9M114_VAR_CAM_SENSOR_CFG_CPIPE_LAST_ROW, 2, 0x02D3}, /* cam_sensor_cfg_cpipe_last_row = 723 */
65 {MT9M114_VAR_CAM_CROP_WINDOW_WIDTH, 2, 0x0500}, /* cam_crop_window_width = 1280 */
66 {MT9M114_VAR_CAM_CROP_WINDOW_HEIGHT, 2, 0x02D0}, /* cam_crop_window_height = 720 */
67 {MT9M114_VAR_CAM_OUTPUT_WIDTH, 2, 0x0500}, /* cam_output_width = 1280 */
68 {MT9M114_VAR_CAM_OUTPUT_HEIGHT, 2, 0x02D0}, /* cam_output_height = 720 */
69 {MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_XEND, 2, 0x04FF}, /* cam_stat_awb_clip_window_xend = 1279 */
70 {MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_YEND, 2, 0x02CF}, /* cam_stat_awb_clip_window_yend = 719 */
71 {MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_XEND, 2, 0x00FF}, /* cam_stat_ae_initial_window_xend = 255 */
72 {MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_YEND, 2, 0x008F}, /* cam_stat_ae_initial_window_yend = 143 */
73};
74
75static const mt9m114_reg_t mt9m114_480_272[] = {
76 {MT9M114_VAR_CAM_SENSOR_CFG_Y_ADDR_START, 2, 0x00D4}, /* cam_sensor_cfg_y_addr_start = 212 */
77 {MT9M114_VAR_CAM_SENSOR_CFG_X_ADDR_START, 2, 0x00A4}, /* cam_sensor_cfg_x_addr_start = 164 */
78 {MT9M114_VAR_CAM_SENSOR_CFG_Y_ADDR_END, 2, 0x02FB}, /* cam_sensor_cfg_y_addr_end = 763 */
79 {MT9M114_VAR_CAM_SENSOR_CFG_X_ADDR_END, 2, 0x046B}, /* cam_sensor_cfg_x_addr_end = 1131 */
80 {MT9M114_VAR_CAM_SENSOR_CFG_CPIPE_LAST_ROW, 2, 0x0223}, /* cam_sensor_cfg_cpipe_last_row = 547 */
81 {MT9M114_VAR_CAM_CROP_WINDOW_WIDTH, 2, 0x03C0}, /* cam_crop_window_width = 960 */
82 {MT9M114_VAR_CAM_CROP_WINDOW_HEIGHT, 2, 0x0220}, /* cam_crop_window_height = 544 */
83 {MT9M114_VAR_CAM_OUTPUT_WIDTH, 2, 0x01E0}, /* cam_output_width = 480 */
84 {MT9M114_VAR_CAM_OUTPUT_HEIGHT, 2, 0x0110}, /* cam_output_height = 272 */
85 {MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_XEND, 2, 0x01DF}, /* cam_stat_awb_clip_window_xend = 479 */
86 {MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_YEND, 2, 0x010F}, /* cam_stat_awb_clip_window_yend = 271 */
87 {MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_XEND, 2, 0x005F}, /* cam_stat_ae_initial_window_xend = 95 */
88 {MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_YEND, 2, 0x0035}, /* cam_stat_ae_initial_window_yend = 53 */
89};
90
91static const mt9m114_reg_t mt9m114InitConfig[] = {
92 {MT9M114_REG_LOGICAL_ADDRESS_ACCESS, 2u, 0x1000},
93 /* PLL Fout = (Fin * 2 * m) / ((n + 1) * (p + 1)) */
94 {MT9M114_VAR_CAM_SYSCTL_PLL_ENABLE, 1u, 0x01}, /* cam_sysctl_pll_enable = 1 */
95 {MT9M114_VAR_CAM_SYSCTL_PLL_DIVIDER_M_N, 2u, 0x0120}, /* cam_sysctl_pll_divider_m_n = 288 */
96 {MT9M114_VAR_CAM_SYSCTL_PLL_DIVIDER_P, 2u, 0x0700}, /* cam_sysctl_pll_divider_p = 1792 */
97 {MT9M114_VAR_CAM_SENSOR_CFG_PIXCLK, 4u, 0x2DC6C00}, /* cam_sensor_cfg_pixclk = 48000000 */
98 {0x316A, 2, 0x8270}, /* auto txlo_row for hot pixel and linear full well optimization */
99 {0x316C, 2, 0x8270}, /* auto txlo for hot pixel and linear full well optimization */
100 {0x3ED0, 2, 0x2305}, /* eclipse setting, ecl range=1, ecl value=2, ivln=3 */
101 {0x3ED2, 2, 0x77CF}, /* TX_hi=12 */
102 {0x316E, 2, 0x8202}, /* auto ecl , threshold 2x, ecl=0 at high gain, ecl=2 for low gain */
103 {0x3180, 2, 0x87FF}, /* enable delta dark */
104 {0x30D4, 2, 0x6080}, /* disable column correction due to AE oscillation problem */
105 {0xA802, 2, 0x0008}, /* RESERVED_AE_TRACK_02 */
106 {0x3E14, 2, 0xFF39}, /* Enabling pixout clamping to VAA during ADC streaming to solve column band issue */
107 {MT9M114_VAR_CAM_SENSOR_CFG_ROW_SPEED, 2u, 0x0001}, /* cam_sensor_cfg_row_speed = 1 */
108 {MT9M114_VAR_CAM_SENSOR_CFG_FINE_INTEG_TIME_MIN, 2u, 0x00DB}, /* cam_sensor_cfg_fine_integ_time_min = 219 */
109 {MT9M114_VAR_CAM_SENSOR_CFG_FINE_INTEG_TIME_MAX, 2u, 0x07C2}, /* cam_sensor_cfg_fine_integ_time_max = 1986 */
110 {MT9M114_VAR_CAM_SENSOR_CFG_FRAME_LENGTH_LINES, 2u, 0x02FE}, /* cam_sensor_cfg_frame_length_lines = 766 */
111 {MT9M114_VAR_CAM_SENSOR_CFG_LINE_LENGTH_PCK, 2u, 0x0845}, /* cam_sensor_cfg_line_length_pck = 2117 */
112 {MT9M114_VAR_CAM_SENSOR_CFG_FINE_CORRECTION, 2u, 0x0060}, /* cam_sensor_cfg_fine_correction = 96 */
113 {MT9M114_VAR_CAM_SENSOR_CFG_REG_0_DATA, 2u, 0x0020}, /* cam_sensor_cfg_reg_0_data = 32 */
114 {MT9M114_VAR_CAM_SENSOR_CONTROL_READ_MODE, 2u, 0x0000}, /* cam_sensor_control_read_mode = 0 */
115 {MT9M114_VAR_CAM_CROP_WINDOW_XOFFSET, 2u, 0x0000}, /* cam_crop_window_xoffset = 0 */
116 {MT9M114_VAR_CAM_CROP_WINDOW_YOFFSET, 2u, 0x0000}, /* cam_crop_window_yoffset = 0 */
117 {MT9M114_VAR_CAM_CROP_CROPMODE, 1u, 0x03}, /* cam_crop_cropmode = 3 */
118 {MT9M114_VAR_CAM_AET_AEMODE, 1u, 0x00}, /* cam_aet_aemode = 0 */
119 {MT9M114_VAR_CAM_AET_MAX_FRAME_RATE, 2u, 0x1D9A}, /* cam_aet_max_frame_rate = 7578 */
120 {MT9M114_VAR_CAM_AET_MIN_FRAME_RATE, 2u, 0x1D9A}, /* cam_aet_min_frame_rate = 7578 */
121 {MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_XSTART, 2u, 0x0000}, /* cam_stat_awb_clip_window_xstart = 0 */
122 {MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_YSTART, 2u, 0x0000}, /* cam_stat_awb_clip_window_ystart = 0 */
123 {MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_XSTART, 2u, 0x0000}, /* cam_stat_ae_initial_window_xstart = 0 */
124 {MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_YSTART, 2u, 0x0000}, /* cam_stat_ae_initial_window_ystart = 0 */
125 {MT9M114_REG_PAD_SLEW, 2u, 0x0777}, /* Pad slew rate */
126 {MT9M114_VAR_CAM_OUTPUT_FORMAT_YUV, 2u, 0x0038}, /* Must set cam_output_format_yuv_clip for CSI */
127};
128
129/*******************************************************************************
130 * Code
131 ******************************************************************************/
132
133static status_t MT9M114_MultiWrite(camera_device_handle_t *handle, const mt9m114_reg_t regs[], uint32_t num)
134{
135 status_t status = kStatus_Success;
136
137 for (uint32_t i = 0; i < num; i++)
138 {
139 status = MT9M114_Write(handle, regs[i].reg, regs[i].size, regs[i].value);
140
141 if (kStatus_Success != status)
142 {
143 break;
144 }
145 }
146
147 return status;
148}
149
150static status_t MT9M114_SoftwareReset(camera_device_handle_t *handle)
151{
152 status_t status;
153
154 status = MT9M114_Modify(handle, MT9M114_REG_RESET_AND_MISC_CONTROL, 2u, 0x01, 0x01);
155 if (kStatus_Success != status)
156 {
157 return status;
158 }
159
160 MT9M114_DelayMs(1);
161
162 status = MT9M114_Modify(handle, MT9M114_REG_RESET_AND_MISC_CONTROL, 2u, 0x01, 0x00);
163 if (kStatus_Success != status)
164 {
165 return status;
166 }
167
168 MT9M114_DelayMs(45);
169
170 return kStatus_Success;
171}
172
173/*
174 * Set state, the parameter nextState could be
175 *
176 * MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE
177 * MT9M114_SYS_STATE_START_STREAMING
178 * MT9M114_SYS_STATE_ENTER_SUSPEND
179 * MT9M114_SYS_STATE_ENTER_STANDBY
180 * MT9M114_SYS_STATE_LEAVE_STANDBY
181 */
182static status_t MT9M114_SetState(camera_device_handle_t *handle, uint16_t nextState)
183{
184 status_t status;
185 uint16_t value = 0U;
186
187 /* Set the desired next state. */
188 status = MT9M114_Write(handle, MT9M114_VAR_SYSMGR_NEXT_STATE, 1u, nextState);
189 if (kStatus_Success != status)
190 {
191 return status;
192 }
193
194 /* Check that the FW is ready to accept a new command. */
195 while (true)
196 {
197 status = MT9M114_Read(handle, MT9M114_REG_COMMAND_REGISTER, 2u, &value);
198 if (kStatus_Success != status)
199 {
200 return status;
201 }
202
203 if (0U == (value & MT9M114_COMMAND_SET_STATE))
204 {
205 break;
206 }
207 }
208
209 /* Issue the Set State command. */
210 status = MT9M114_Write(handle, MT9M114_REG_COMMAND_REGISTER, 2u, MT9M114_COMMAND_SET_STATE | MT9M114_COMMAND_OK);
211 if (kStatus_Success != status)
212 {
213 return status;
214 }
215
216 /* Wait for the FW to complete the command. */
217 while (true)
218 {
219 MT9M114_DelayMs(1);
220 status = MT9M114_Read(handle, MT9M114_REG_COMMAND_REGISTER, 2u, &value);
221 if (kStatus_Success != status)
222 {
223 return status;
224 }
225
226 if (0U == (value & MT9M114_COMMAND_SET_STATE))
227 {
228 break;
229 }
230 }
231
232 /* Check the 'OK' bit to see if the command was successful. */
233 status = MT9M114_Read(handle, MT9M114_REG_COMMAND_REGISTER, 2u, &value);
234 if (kStatus_Success != status)
235 {
236 return status;
237 }
238
239 if (0U == (value & MT9M114_COMMAND_OK))
240 {
241 return kStatus_Fail;
242 }
243
244 return kStatus_Success;
245}
246
247status_t MT9M114_Init(camera_device_handle_t *handle, const camera_config_t *config)
248{
249 status_t status;
250 uint16_t chip_id = 0;
251 uint16_t outputFormat = 0;
252
253 mt9m114_resource_t *resource = (mt9m114_resource_t *)(handle->resource);
254
255 if ((kCAMERA_InterfaceGatedClock != config->interface) && (kCAMERA_InterfaceNonGatedClock != config->interface) &&
256 (kCAMERA_InterfaceCCIR656 != config->interface))
257 {
258 return kStatus_InvalidArgument;
259 }
260
261 /* Only support 480 * 272 and 720P. */
262 if (((uint32_t)kVIDEO_Resolution720P != config->resolution) &&
263 (FSL_VIDEO_RESOLUTION(480, 272) != config->resolution))
264 {
265 return kStatus_InvalidArgument;
266 }
267
268 /* Only support 30 fps now. */
269 if (30U != config->framePerSec)
270 {
271 return kStatus_InvalidArgument;
272 }
273
274 /* Only support RGB565 and YUV422 */
275 if ((kVIDEO_PixelFormatRGB565 != config->pixelFormat) && (kVIDEO_PixelFormatYUYV != config->pixelFormat))
276 {
277 return kStatus_InvalidArgument;
278 }
279
280 /* The input clock (EXTCLK) must be 24MHz. */
281 if (24000000U != resource->inputClockFreq_Hz)
282 {
283 return kStatus_InvalidArgument;
284 }
285
286 /* Polarity check */
287 if (config->controlFlags !=
288 ((uint32_t)kCAMERA_HrefActiveHigh | (uint32_t)kCAMERA_DataLatchOnRisingEdge | (uint32_t)kCAMERA_VsyncActiveLow))
289 {
290 return kStatus_InvalidArgument;
291 }
292
293 resource->pullResetPin(false); /* Reset pin low. */
294 MT9M114_DelayMs(50); /* Delay at least 50 ms. */
295 resource->pullResetPin(true); /* Reset pin high. */
296 MT9M114_DelayMs(45); /* Delay typically 44.5 ms. */
297
298 /* Identify the device. */
299 status = MT9M114_Read(handle, MT9M114_REG_CHIP_ID, 2u, &chip_id);
300 if (kStatus_Success != status)
301 {
302 return status;
303 }
304 if (MT9M114_CHIP_ID != chip_id)
305 {
306 return kStatus_Fail;
307 }
308
309 /* SW reset. */
310 status = MT9M114_SoftwareReset(handle);
311 if (kStatus_Success != status)
312 {
313 return status;
314 }
315
316 status = MT9M114_MultiWrite(handle, mt9m114InitConfig, ARRAY_SIZE(mt9m114InitConfig));
317 if (kStatus_Success != status)
318 {
319 return status;
320 }
321
322 /* Pixel format. */
323 if (kVIDEO_PixelFormatRGB565 == config->pixelFormat)
324 {
325 outputFormat |= ((1U << 8U) | (1U << 1U));
326 }
327
328 if (kCAMERA_InterfaceCCIR656 == config->interface)
329 {
330 outputFormat |= (1U << 3U);
331 }
332
333 status = MT9M114_Write(handle, MT9M114_VAR_CAM_OUTPUT_FORMAT, 2, outputFormat);
334 if (kStatus_Success != status)
335 {
336 return status;
337 }
338
339 if (kCAMERA_InterfaceNonGatedClock == config->interface)
340 {
341 status = MT9M114_Write(handle, MT9M114_VAR_CAM_PORT_OUTPUT_CONTROL, 2, 0x8020);
342 }
343 else
344 {
345 status = MT9M114_Write(handle, MT9M114_VAR_CAM_PORT_OUTPUT_CONTROL, 2, 0x8000);
346 }
347
348 if (kStatus_Success != status)
349 {
350 return status;
351 }
352
353 /* Resolution */
354 if (config->resolution == FSL_VIDEO_RESOLUTION(480, 272))
355 {
356 status = MT9M114_MultiWrite(handle, mt9m114_480_272, ARRAY_SIZE(mt9m114_480_272));
357 }
358 else
359 {
360 status = MT9M114_MultiWrite(handle, mt9m114_720p, ARRAY_SIZE(mt9m114_720p));
361 }
362
363 if (kStatus_Success != status)
364 {
365 return status;
366 }
367
368 /* Execute Change-Config command. */
369 return MT9M114_SetState(handle, MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE);
370}
371
372status_t MT9M114_Deinit(camera_device_handle_t *handle)
373{
374 ((mt9m114_resource_t *)(handle->resource))->pullResetPin(false);
375
376 return kStatus_Success;
377}
378
379status_t MT9M114_Start(camera_device_handle_t *handle)
380{
381 return MT9M114_SetState(handle, MT9M114_SYS_STATE_START_STREAMING);
382}
383
384status_t MT9M114_Stop(camera_device_handle_t *handle)
385{
386 return MT9M114_SetState(handle, MT9M114_SYS_STATE_ENTER_SUSPEND);
387}
388
389status_t MT9M114_Control(camera_device_handle_t *handle, camera_device_cmd_t cmd, int32_t arg)
390{
391 return kStatus_InvalidArgument;
392}
393
394status_t MT9M114_InitExt(camera_device_handle_t *handle, const camera_config_t *config, const void *specialConfig)
395{
396 return MT9M114_Init(handle, config);
397}
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/fsl_mt9m114.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/fsl_mt9m114.h
new file mode 100644
index 000000000..2e310afe8
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/mt9m114/fsl_mt9m114.h
@@ -0,0 +1,651 @@
1/*
2 * Copyright 2017-2018, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_MT9M114_H_
10#define _FSL_MT9M114_H_
11
12#include "fsl_common.h"
13#include "fsl_camera_device.h"
14#include "fsl_video_i2c.h"
15
16/*
17 * Change log:
18 *
19 * 1.0.1
20 * - Fixed MISRA-C 2012 issues.
21 *
22 * 1.0.0
23 * - Initial version
24 */
25
26/*******************************************************************************
27 * Definitions
28 ******************************************************************************/
29#define MT9M114_I2C_ADDR 0x48U
30#define MT9M114_CHIP_ID 0x2481U
31
32/*! @brief MT9M114 register definitions.*/
33
34/* 1.Core registers */
35#define MT9M114_REG_Y_ADDR_START 0x3002U
36#define MT9M114_REG_X_ADDR_START 0x3004U
37#define MT9M114_REG_Y_ADDR_END 0x3006U
38#define MT9M114_REG_X_ADDR_END 0x3008U
39#define MT9M114_REG_FRAME_LENGTH_LINES 0x300AU
40#define MT9M114_REG_LINE_LENGTH_PCK_ 0x300CU
41#define MT9M114_REG_COARSE_INTEGRATION_TIME 0x3012U
42#define MT9M114_REG_FINE_INTEGRATION_TIME 0x3014U
43#define MT9M114_REG_RESET_REGISTER 0x301AU
44#define MT9M114_REG_FLASH 0x3046U
45#define MT9M114_REG_FLASH_COUNT 0x3048U
46#define MT9M114_REG_GREEN1_GAIN 0x3056U
47#define MT9M114_REG_BLUE_GAIN 0x3058U
48#define MT9M114_REG_RED_GAIN 0x305AU
49#define MT9M114_REG_GREEN2_GAIN 0x305CU
50#define MT9M114_REG_GLOBAL_GAIN 0x305EU
51#define MT9M114_REG_FUSE_ID1 0x31F4U
52#define MT9M114_REG_FUSE_ID2 0x31F6U
53#define MT9M114_REG_FUSE_ID3 0x31F8U
54#define MT9M114_REG_FUSE_ID4 0x31FAU
55#define MT9M114_REG_CHAIN_CONTROL 0x31FCU
56#define MT9M114_REG_CUSTOMER_REV 0x31FEU
57
58/* 2.SOC1 registers */
59#define MT9M114_REG_COLOR_PIPELINE_CONTROL 0x3210U
60
61/* 3.SOC2 registers */
62#define MT9M114_REG_P_G1_P0Q0 0x3640U
63#define MT9M114_REG_P_G1_P0Q1 0x3642U
64#define MT9M114_REG_P_G1_P0Q2 0x3644U
65#define MT9M114_REG_P_G1_P0Q3 0x3646U
66#define MT9M114_REG_P_G1_P0Q4 0x3648U
67#define MT9M114_REG_P_R_P0Q0 0x364AU
68#define MT9M114_REG_P_R_P0Q1 0x364CU
69#define MT9M114_REG_P_R_P0Q2 0x364EU
70#define MT9M114_REG_P_R_P0Q3 0x3650U
71#define MT9M114_REG_P_R_P0Q4 0x3652U
72#define MT9M114_REG_P_B_P0Q0 0x3654U
73#define MT9M114_REG_P_B_P0Q1 0x3656U
74#define MT9M114_REG_P_B_P0Q2 0x3658U
75#define MT9M114_REG_P_B_P0Q3 0x365AU
76#define MT9M114_REG_P_B_P0Q4 0x365CU
77#define MT9M114_REG_P_G2_P0Q0 0x365EU
78#define MT9M114_REG_P_G2_P0Q1 0x3660U
79#define MT9M114_REG_P_G2_P0Q2 0x3662U
80#define MT9M114_REG_P_G2_P0Q3 0x3664U
81#define MT9M114_REG_P_G2_P0Q4 0x3666U
82#define MT9M114_REG_P_G1_P1Q0 0x3680U
83#define MT9M114_REG_P_G1_P1Q1 0x3682U
84#define MT9M114_REG_P_G1_P1Q2 0x3684U
85#define MT9M114_REG_P_G1_P1Q3 0x3686U
86#define MT9M114_REG_P_G1_P1Q4 0x3688U
87#define MT9M114_REG_P_R_P1Q0 0x368AU
88#define MT9M114_REG_P_R_P1Q1 0x368CU
89#define MT9M114_REG_P_R_P1Q2 0x368EU
90#define MT9M114_REG_P_R_P1Q3 0x3690U
91#define MT9M114_REG_P_R_P1Q4 0x3692U
92#define MT9M114_REG_P_B_P1Q0 0x3694U
93#define MT9M114_REG_P_B_P1Q1 0x3696U
94#define MT9M114_REG_P_B_P1Q2 0x3698U
95#define MT9M114_REG_P_B_P1Q3 0x369AU
96#define MT9M114_REG_P_B_P1Q4 0x369CU
97#define MT9M114_REG_P_G2_P1Q0 0x369EU
98#define MT9M114_REG_P_G2_P1Q1 0x36A0U
99#define MT9M114_REG_P_G2_P1Q2 0x36A2U
100#define MT9M114_REG_P_G2_P1Q3 0x36A4U
101#define MT9M114_REG_P_G2_P1Q4 0x36A6U
102#define MT9M114_REG_P_G1_P2Q0 0x36C0U
103#define MT9M114_REG_P_G1_P2Q1 0x36C2U
104#define MT9M114_REG_P_G1_P2Q2 0x36C4U
105#define MT9M114_REG_P_G1_P2Q3 0x36C6U
106#define MT9M114_REG_P_G1_P2Q4 0x36C8U
107#define MT9M114_REG_P_R_P2Q0 0x36CAU
108#define MT9M114_REG_P_R_P2Q1 0x36CCU
109#define MT9M114_REG_P_R_P2Q2 0x36CEU
110#define MT9M114_REG_P_R_P2Q3 0x36D0U
111#define MT9M114_REG_P_R_P2Q4 0x36D2U
112#define MT9M114_REG_P_B_P2Q0 0x36D4U
113#define MT9M114_REG_P_B_P2Q1 0x36D6U
114#define MT9M114_REG_P_B_P2Q2 0x36D8U
115#define MT9M114_REG_P_B_P2Q3 0x36DAU
116#define MT9M114_REG_P_B_P2Q4 0x36DCU
117#define MT9M114_REG_P_G2_P2Q0 0x36DEU
118#define MT9M114_REG_P_G2_P2Q1 0x36E0U
119#define MT9M114_REG_P_G2_P2Q2 0x36E2U
120#define MT9M114_REG_P_G2_P2Q3 0x36E4U
121#define MT9M114_REG_P_G2_P2Q4 0x36E6U
122#define MT9M114_REG_P_G1_P3Q0 0x3700U
123#define MT9M114_REG_P_G1_P3Q1 0x3702U
124#define MT9M114_REG_P_G1_P3Q2 0x3704U
125#define MT9M114_REG_P_G1_P3Q3 0x3706U
126#define MT9M114_REG_P_G1_P3Q4 0x3708U
127#define MT9M114_REG_P_R_P3Q0 0x370AU
128#define MT9M114_REG_P_R_P3Q1 0x370CU
129#define MT9M114_REG_P_R_P3Q2 0x370EU
130#define MT9M114_REG_P_R_P3Q3 0x3710U
131#define MT9M114_REG_P_R_P3Q4 0x3712U
132#define MT9M114_REG_P_B_P3Q0 0x3714U
133#define MT9M114_REG_P_B_P3Q1 0x3716U
134#define MT9M114_REG_P_B_P3Q2 0x3718U
135#define MT9M114_REG_P_B_P3Q3 0x371AU
136#define MT9M114_REG_P_B_P3Q4 0x371CU
137#define MT9M114_REG_P_G2_P3Q0 0x371EU
138#define MT9M114_REG_P_G2_P3Q1 0x3720U
139#define MT9M114_REG_P_G2_P3Q2 0x3722U
140#define MT9M114_REG_P_G2_P3Q3 0x3724U
141#define MT9M114_REG_P_G2_P3Q4 0x3726U
142#define MT9M114_REG_P_G1_P4Q0 0x3740U
143#define MT9M114_REG_P_G1_P4Q1 0x3742U
144#define MT9M114_REG_P_G1_P4Q2 0x3744U
145#define MT9M114_REG_P_G1_P4Q3 0x3746U
146#define MT9M114_REG_P_G1_P4Q4 0x3748U
147#define MT9M114_REG_P_R_P4Q0 0x374AU
148#define MT9M114_REG_P_R_P4Q1 0x374CU
149#define MT9M114_REG_P_R_P4Q2 0x374EU
150#define MT9M114_REG_P_R_P4Q3 0x3750U
151#define MT9M114_REG_P_R_P4Q4 0x3752U
152#define MT9M114_REG_P_B_P4Q0 0x3754U
153#define MT9M114_REG_P_B_P4Q1 0x3756U
154#define MT9M114_REG_P_B_P4Q2 0x3758U
155#define MT9M114_REG_P_B_P4Q3 0x375AU
156#define MT9M114_REG_P_B_P4Q4 0x375CU
157#define MT9M114_REG_P_G2_P4Q0 0x375EU
158#define MT9M114_REG_P_G2_P4Q1 0x3760U
159#define MT9M114_REG_P_G2_P4Q2 0x3762U
160#define MT9M114_REG_P_G2_P4Q3 0x3764U
161#define MT9M114_REG_P_G2_P4Q4 0x3766U
162#define MT9M114_REG_CENTER_ROW 0x3782U
163#define MT9M114_REG_CENTER_COLUMN 0x3784U
164
165/* 4.SYSCTL registers */
166#define MT9M114_REG_CHIP_ID 0x0000U
167#define MT9M114_REG_CLOCKS_CONTROL 0x0016U
168#define MT9M114_REG_RESET_AND_MISC_CONTROL 0x001AU
169#define MT9M114_REG_PAD_SLEW 0x001EU
170#define MT9M114_REG_USER_DEFINED_DEVICE_ADDRESS_ID 0x002EU
171#define MT9M114_REG_PAD_CONTROL 0x0032U
172#define MT9M114_REG_COMMAND_REGISTER 0x0080U
173
174/* 5.XDMA registers */
175#define MT9M114_REG_ACCESS_CTL_STAT 0x0982U
176#define MT9M114_REG_PHYSICAL_ADDRESS_ACCESS 0x098AU
177#define MT9M114_REG_LOGICAL_ADDRESS_ACCESS 0x098EU
178#define MT9M114_REG_MCU_VARIABLE_DATA0 0x0990U
179#define MT9M114_REG_MCU_VARIABLE_DATA1 0x0992U
180#define MT9M114_REG_MCU_VARIABLE_DATA2 0x0994U
181#define MT9M114_REG_MCU_VARIABLE_DATA3 0x0996U
182#define MT9M114_REG_MCU_VARIABLE_DATA4 0x0998U
183#define MT9M114_REG_MCU_VARIABLE_DATA5 0x099AU
184#define MT9M114_REG_MCU_VARIABLE_DATA6 0x099CU
185#define MT9M114_REG_MCU_VARIABLE_DATA7 0x099EU
186
187/*! @brief MT9M114 variables definitions.*/
188
189/* 01.Monitor variables */
190#define MT9M114_VAR_MON_MAJOR_VERSION 0x8000U
191#define MT9M114_VAR_MON_MINOR_VERSION 0x8002U
192#define MT9M114_VAR_MON_RELEASE_VERSION 0x8004U
193#define MT9M114_VAR_MON_HEARTBEAT 0x8006U
194
195/* 02.Sequencer variables */
196#define MT9M114_VAR_SEQ_ERROR_CODE 0x8406U
197
198/* 03.AE_Rule variables */
199#define MT9M114_VAR_AE_RULE_ALGO 0xA404U
200#define MT9M114_VAR_AE_RULE_AVG_Y_FROM_STATS 0xA406U
201#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_0_0 0xA407U
202#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_0_1 0xA408U
203#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_0_2 0xA409U
204#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_0_3 0xA40AU
205#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_0_4 0xA40BU
206#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_1_0 0xA40CU
207#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_1_1 0xA40DU
208#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_1_2 0xA40EU
209#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_1_3 0xA40FU
210#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_1_4 0xA410U
211#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_2_0 0xA411U
212#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_2_1 0xA412U
213#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_2_2 0xA413U
214#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_2_3 0xA414U
215#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_2_4 0xA415U
216#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_3_0 0xA416U
217#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_3_1 0xA417U
218#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_3_2 0xA418U
219#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_3_3 0xA419U
220#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_3_4 0xA41AU
221#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_4_0 0xA41BU
222#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_4_1 0xA41CU
223#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_4_2 0xA41DU
224#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_4_3 0xA41EU
225#define MT9M114_VAR_AE_RULE_AE_WEIGHT_TABLE_4_4 0xA41FU
226#define MT9M114_VAR_AE_RULE_AE_ADAPTIVE_STRENGTH 0xA420U
227
228/* 04.AE_Track variables */
229#define MT9M114_VAR_AE_TRACK_STATUS 0xA800U
230#define MT9M114_VAR_AE_TRACK_ALGO 0xA804U
231#define MT9M114_VAR_AE_TRACK_TARGET_AVERAGE_LUMA 0xA807U
232#define MT9M114_VAR_AE_TRACK_GATE_PERCENTAGE 0xA808U
233#define MT9M114_VAR_AE_TRACK_CURRENT_AVERAGE_LUMA 0xA809U
234#define MT9M114_VAR_AE_TRACK_AE_TRACKING_DAMPENING_SPEED 0xA80AU
235#define MT9M114_VAR_AE_TRACK_AE_DAMPENING_SPEED 0xA80BU
236#define MT9M114_VAR_AE_TRACK_SKIP_FRAMES_COUNTER 0xA80DU
237#define MT9M114_VAR_AE_TRACK_CURRENT_FLICKER_LINES 0xA80EU
238#define MT9M114_VAR_AE_TRACK_FDZONE 0xA818U
239#define MT9M114_VAR_AE_TRACK_ZONE 0xA81BU
240#define MT9M114_VAR_AE_TRACK_FLICKER_LINES_50HZ 0xA826U
241#define MT9M114_VAR_AE_TRACK_VIRT_EXPOSURE_LOG 0xA828U
242#define MT9M114_VAR_AE_TRACK_MIN_VIRT_EXPOSURE_LOG_ZONE0 0xA82AU
243#define MT9M114_VAR_AE_TRACK_MAX_VIRT_EXPOSURE_LOG_ZONE0 0xA82CU
244#define MT9M114_VAR_AE_TRACK_MAX_VIRT_EXPOSURE_LOG_ZONE1 0xA82EU
245#define MT9M114_VAR_AE_TRACK_VIRT_GAIN 0xA838U
246
247/* 05.AWB variables */
248#define MT9M114_VAR_AWB_STATUS 0xAC00U
249#define MT9M114_VAR_AWB_MODE 0xAC02U
250#define MT9M114_VAR_AWB_R_RATIO_LOWER 0xAC06U
251#define MT9M114_VAR_AWB_R_RATIO_UPPER 0xAC07U
252#define MT9M114_VAR_AWB_B_RATIO_LOWER 0xAC08U
253#define MT9M114_VAR_AWB_B_RATIO_UPPER 0xAC09U
254#define MT9M114_VAR_AWB_R_SCENE_RATIO_LOWER 0xAC0AU
255#define MT9M114_VAR_AWB_R_SCENE_RATIO_UPPER 0xAC0BU
256#define MT9M114_VAR_AWB_B_SCENE_RATIO_LOWER 0xAC0CU
257#define MT9M114_VAR_AWB_B_SCENE_RATIO_UPPER 0xAC0DU
258#define MT9M114_VAR_AWB_R_RATIO_PRE_AWB 0xAC0EU
259#define MT9M114_VAR_AWB_B_RATIO_PRE_AWB 0xAC0FU
260#define MT9M114_VAR_AWB_R_GAIN 0xAC12U
261#define MT9M114_VAR_AWB_B_GAIN 0xAC14U
262#define MT9M114_VAR_AWB_PRE_AWB_RATIOS_TRACKING_SPEED 0xAC16U
263#define MT9M114_VAR_AWB_PIXEL_THRESHOLD_COUNT 0xAC18U
264
265/* 06.BlackLevel variables */
266#define MT9M114_VAR_BLACKLEVEL_ALGO 0xB004U
267#define MT9M114_VAR_BLACKLEVEL_MAX_BLACK_LEVEL 0xB00CU
268#define MT9M114_VAR_BLACKLEVEL_BLACK_LEVEL_DAMPENING 0xB00DU
269
270/* 07.CCM variables */
271#define MT9M114_VAR_CCM_ALGO 0xB404U
272#define MT9M114_VAR_CCM_0 0xB406U
273#define MT9M114_VAR_CCM_1 0xB408U
274#define MT9M114_VAR_CCM_2 0xB40AU
275#define MT9M114_VAR_CCM_3 0xB40CU
276#define MT9M114_VAR_CCM_4 0xB40EU
277#define MT9M114_VAR_CCM_5 0xB410U
278#define MT9M114_VAR_CCM_6 0xB412U
279#define MT9M114_VAR_CCM_7 0xB414U
280#define MT9M114_VAR_CCM_8 0xB416U
281#define MT9M114_VAR_CCM_LL_DELTA_CCM_0 0xB418U
282#define MT9M114_VAR_CCM_LL_DELTA_CCM_1 0xB41AU
283#define MT9M114_VAR_CCM_LL_DELTA_CCM_2 0xB41CU
284#define MT9M114_VAR_CCM_LL_DELTA_CCM_3 0xB41EU
285#define MT9M114_VAR_CCM_LL_DELTA_CCM_4 0xB420U
286#define MT9M114_VAR_CCM_LL_DELTA_CCM_5 0xB422U
287#define MT9M114_VAR_CCM_LL_DELTA_CCM_6 0xB424U
288#define MT9M114_VAR_CCM_LL_DELTA_CCM_7 0xB426U
289#define MT9M114_VAR_CCM_LL_DELTA_CCM_8 0xB428U
290#define MT9M114_VAR_CCM_DELTA_GAIN 0xB42AU
291#define MT9M114_VAR_CCM_DELTA_THRESH 0xB42BU
292
293/* 08.LowLight variables */
294#define MT9M114_VAR_LL_MODE 0xBC02U
295#define MT9M114_VAR_LL_ALGO 0xBC04U
296#define MT9M114_VAR_LL_GAMMA_SELECT 0xBC07U
297#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_0 0xBC0AU
298#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_1 0xBC0BU
299#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_2 0xBC0CU
300#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_3 0xBC0DU
301#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_4 0xBC0EU
302#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_5 0xBC0FU
303#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_6 0xBC10U
304#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_7 0xBC11U
305#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_8 0xBC12U
306#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_9 0xBC13U
307#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_10 0xBC14U
308#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_11 0xBC15U
309#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_12 0xBC16U
310#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_13 0xBC17U
311#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_14 0xBC18U
312#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_15 0xBC19U
313#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_16 0xBC1AU
314#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_17 0xBC1BU
315#define MT9M114_VAR_LL_GAMMA_CONTRAST_CURVE_18 0xBC1CU
316#define MT9M114_VAR_LL_GAMMA_NRCURVE_0 0xBC1DU
317#define MT9M114_VAR_LL_GAMMA_NRCURVE_1 0xBC1EU
318#define MT9M114_VAR_LL_GAMMA_NRCURVE_2 0xBC1FU
319#define MT9M114_VAR_LL_GAMMA_NRCURVE_3 0xBC20U
320#define MT9M114_VAR_LL_GAMMA_NRCURVE_4 0xBC21U
321#define MT9M114_VAR_LL_GAMMA_NRCURVE_5 0xBC22U
322#define MT9M114_VAR_LL_GAMMA_NRCURVE_6 0xBC23U
323#define MT9M114_VAR_LL_GAMMA_NRCURVE_7 0xBC24U
324#define MT9M114_VAR_LL_GAMMA_NRCURVE_8 0xBC25U
325#define MT9M114_VAR_LL_GAMMA_NRCURVE_9 0xBC26U
326#define MT9M114_VAR_LL_GAMMA_NRCURVE_10 0xBC27U
327#define MT9M114_VAR_LL_GAMMA_NRCURVE_11 0xBC28U
328#define MT9M114_VAR_LL_GAMMA_NRCURVE_12 0xBC29U
329#define MT9M114_VAR_LL_GAMMA_NRCURVE_13 0xBC2AU
330#define MT9M114_VAR_LL_GAMMA_NRCURVE_14 0xBC2BU
331#define MT9M114_VAR_LL_GAMMA_NRCURVE_15 0xBC2CU
332#define MT9M114_VAR_LL_GAMMA_NRCURVE_16 0xBC2DU
333#define MT9M114_VAR_LL_GAMMA_NRCURVE_17 0xBC2EU
334#define MT9M114_VAR_LL_GAMMA_NRCURVE_18 0xBC2FU
335#define MT9M114_VAR_LL_BM_PRECISION_BITS 0xBC31U
336#define MT9M114_VAR_LL_AVERAGE_LUMA_FADE_TO_BLACK 0xBC3AU
337#define MT9M114_VAR_LL_FADE_TO_BLACK_DAMPENING_SPEED 0xBC3CU
338
339/* 09.CameraControl variables */
340#define MT9M114_VAR_CAM_SENSOR_CFG_Y_ADDR_START 0xC800U
341#define MT9M114_VAR_CAM_SENSOR_CFG_X_ADDR_START 0xC802U
342#define MT9M114_VAR_CAM_SENSOR_CFG_Y_ADDR_END 0xC804U
343#define MT9M114_VAR_CAM_SENSOR_CFG_X_ADDR_END 0xC806U
344#define MT9M114_VAR_CAM_SENSOR_CFG_PIXCLK 0xC808U
345#define MT9M114_VAR_CAM_SENSOR_CFG_ROW_SPEED 0xC80CU
346#define MT9M114_VAR_CAM_SENSOR_CFG_FINE_INTEG_TIME_MIN 0xC80EU
347#define MT9M114_VAR_CAM_SENSOR_CFG_FINE_INTEG_TIME_MAX 0xC810U
348#define MT9M114_VAR_CAM_SENSOR_CFG_FRAME_LENGTH_LINES 0xC812U
349#define MT9M114_VAR_CAM_SENSOR_CFG_LINE_LENGTH_PCK 0xC814U
350#define MT9M114_VAR_CAM_SENSOR_CFG_FINE_CORRECTION 0xC816U
351#define MT9M114_VAR_CAM_SENSOR_CFG_CPIPE_LAST_ROW 0xC818U
352#define MT9M114_VAR_CAM_SENSOR_CFG_REG_0_DATA 0xC826U
353#define MT9M114_VAR_CAM_SENSOR_CONTROL_READ_MODE 0xC834U
354#define MT9M114_VAR_CAM_SENSOR_CONTROL_ANALOG_GAIN 0xC836U
355#define MT9M114_VAR_CAM_SENSOR_CONTROL_VIRT_COLUMN_GAIN 0xC838U
356#define MT9M114_VAR_CAM_SENSOR_CONTROL_FRAME_LENGTH_LINES 0xC83AU
357#define MT9M114_VAR_CAM_SENSOR_CONTROL_COARSE_INTEGRATION_TIME 0xC83CU
358#define MT9M114_VAR_CAM_SENSOR_CONTROL_FINE_INTEGRATION_TIME 0xC83EU
359#define MT9M114_VAR_CAM_CPIPE_CONTROL_DGAIN_RED 0xC840U
360#define MT9M114_VAR_CAM_CPIPE_CONTROL_DGAIN_GREEN1 0xC842U
361#define MT9M114_VAR_CAM_CPIPE_CONTROL_DGAIN_GREEN2 0xC844U
362#define MT9M114_VAR_CAM_CPIPE_CONTROL_DGAIN_BLUE 0xC846U
363#define MT9M114_VAR_CAM_CPIPE_CONTROL_DGAIN_SECOND 0xC848U
364#define MT9M114_VAR_CAM_CPIPE_CONTROL_SECOND_BLACK_LEVEL 0xC84BU
365#define MT9M114_VAR_CAM_MODE_SELECT 0xC84CU
366#define MT9M114_VAR_CAM_MODE_TEST_PATTERN_SELECT 0xC84DU
367#define MT9M114_VAR_CAM_MODE_TEST_PATTERN_RED 0xC84EU
368#define MT9M114_VAR_CAM_MODE_TEST_PATTERN_GREEN 0xC850U
369#define MT9M114_VAR_CAM_MODE_TEST_PATTERN_BLUE 0xC852U
370#define MT9M114_VAR_CAM_CROP_WINDOW_XOFFSET 0xC854U
371#define MT9M114_VAR_CAM_CROP_WINDOW_YOFFSET 0xC856U
372#define MT9M114_VAR_CAM_CROP_WINDOW_WIDTH 0xC858U
373#define MT9M114_VAR_CAM_CROP_WINDOW_HEIGHT 0xC85AU
374#define MT9M114_VAR_CAM_CROP_CROPMODE 0xC85CU
375#define MT9M114_VAR_CAM_SCALE_VERTICAL_TC_MODE 0xC85EU
376#define MT9M114_VAR_CAM_SCALE_VERTICAL_TC_PERCENTAGE 0xC860U
377#define MT9M114_VAR_CAM_SCALE_VERTICAL_TC_STRETCH_FACTOR 0xC862U
378#define MT9M114_VAR_CAM_OUTPUT_WIDTH 0xC868U
379#define MT9M114_VAR_CAM_OUTPUT_HEIGHT 0xC86AU
380#define MT9M114_VAR_CAM_OUTPUT_FORMAT 0xC86CU
381#define MT9M114_VAR_CAM_OUTPUT_FORMAT_YUV 0xC86EU
382#define MT9M114_VAR_CAM_OUTPUT_Y_OFFSET 0xC870U
383#define MT9M114_VAR_CAM_HUE_ANGLE 0xC873U
384#define MT9M114_VAR_CAM_SFX_CONTROL 0xC874U
385#define MT9M114_VAR_CAM_SFX_SOLARIZATION_THRESH 0xC875U
386#define MT9M114_VAR_CAM_SFX_SEPIA_CR 0xC876U
387#define MT9M114_VAR_CAM_SFX_SEPIA_CB 0xC877U
388#define MT9M114_VAR_CAM_AET_AEMODE 0xC878U
389#define MT9M114_VAR_CAM_AET_SKIP_FRAMES 0xC879U
390#define MT9M114_VAR_CAM_AET_TARGET_AVERAGE_LUMA 0xC87AU
391#define MT9M114_VAR_CAM_AET_TARGET_AVERAGE_LUMA_DARK 0xC87BU
392#define MT9M114_VAR_CAM_AET_BLACK_CLIPPING_TARGET 0xC87CU
393#define MT9M114_VAR_CAM_AET_AE_MIN_VIRT_INT_TIME_PCLK 0xC87EU
394#define MT9M114_VAR_CAM_AET_AE_MIN_VIRT_DGAIN 0xC880U
395#define MT9M114_VAR_CAM_AET_AE_MAX_VIRT_DGAIN 0xC882U
396#define MT9M114_VAR_CAM_AET_AE_MIN_VIRT_AGAIN 0xC884U
397#define MT9M114_VAR_CAM_AET_AE_MAX_VIRT_AGAIN 0xC886U
398#define MT9M114_VAR_CAM_AET_AE_VIRT_GAIN_TH_EG 0xC888U
399#define MT9M114_VAR_CAM_AET_AE_EG_GATE_PERCENTAGE 0xC88AU
400#define MT9M114_VAR_CAM_AET_FLICKER_FREQ_HZ 0xC88BU
401#define MT9M114_VAR_CAM_AET_MAX_FRAME_RATE 0xC88CU
402#define MT9M114_VAR_CAM_AET_MIN_FRAME_RATE 0xC88EU
403#define MT9M114_VAR_CAM_AET_TARGET_GAIN 0xC890U
404#define MT9M114_VAR_CAM_AWB_CCM_L_0 0xC892U
405#define MT9M114_VAR_CAM_AWB_CCM_L_1 0xC894U
406#define MT9M114_VAR_CAM_AWB_CCM_L_2 0xC896U
407#define MT9M114_VAR_CAM_AWB_CCM_L_3 0xC898U
408#define MT9M114_VAR_CAM_AWB_CCM_L_4 0xC89AU
409#define MT9M114_VAR_CAM_AWB_CCM_L_5 0xC89CU
410#define MT9M114_VAR_CAM_AWB_CCM_L_6 0xC89EU
411#define MT9M114_VAR_CAM_AWB_CCM_L_7 0xC8A0U
412#define MT9M114_VAR_CAM_AWB_CCM_L_8 0xC8A2U
413#define MT9M114_VAR_CAM_AWB_CCM_M_0 0xC8A4U
414#define MT9M114_VAR_CAM_AWB_CCM_M_1 0xC8A6U
415#define MT9M114_VAR_CAM_AWB_CCM_M_2 0xC8A8U
416#define MT9M114_VAR_CAM_AWB_CCM_M_3 0xC8AAU
417#define MT9M114_VAR_CAM_AWB_CCM_M_4 0xC8ACU
418#define MT9M114_VAR_CAM_AWB_CCM_M_5 0xC8AEU
419#define MT9M114_VAR_CAM_AWB_CCM_M_6 0xC8B0U
420#define MT9M114_VAR_CAM_AWB_CCM_M_7 0xC8B2U
421#define MT9M114_VAR_CAM_AWB_CCM_M_8 0xC8B4U
422#define MT9M114_VAR_CAM_AWB_CCM_R_0 0xC8B6U
423#define MT9M114_VAR_CAM_AWB_CCM_R_1 0xC8B8U
424#define MT9M114_VAR_CAM_AWB_CCM_R_2 0xC8BAU
425#define MT9M114_VAR_CAM_AWB_CCM_R_3 0xC8BCU
426#define MT9M114_VAR_CAM_AWB_CCM_R_4 0xC8BEU
427#define MT9M114_VAR_CAM_AWB_CCM_R_5 0xC8C0U
428#define MT9M114_VAR_CAM_AWB_CCM_R_6 0xC8C2U
429#define MT9M114_VAR_CAM_AWB_CCM_R_7 0xC8C4U
430#define MT9M114_VAR_CAM_AWB_CCM_R_8 0xC8C6U
431#define MT9M114_VAR_CAM_AWB_CCM_L_RG_GAIN 0xC8C8U
432#define MT9M114_VAR_CAM_AWB_CCM_L_BG_GAIN 0xC8CAU
433#define MT9M114_VAR_CAM_AWB_CCM_M_RG_GAIN 0xC8CCU
434#define MT9M114_VAR_CAM_AWB_CCM_M_BG_GAIN 0xC8CEU
435#define MT9M114_VAR_CAM_AWB_CCM_R_RG_GAIN 0xC8D0U
436#define MT9M114_VAR_CAM_AWB_CCM_R_BG_GAIN 0xC8D2U
437#define MT9M114_VAR_CAM_AWB_CCM_L_CTEMP 0xC8D4U
438#define MT9M114_VAR_CAM_AWB_CCM_M_CTEMP 0xC8D6U
439#define MT9M114_VAR_CAM_AWB_CCM_R_CTEMP 0xC8D8U
440#define MT9M114_VAR_CAM_AWB_LL_CCM_0 0xC8DAU
441#define MT9M114_VAR_CAM_AWB_LL_CCM_1 0xC8DCU
442#define MT9M114_VAR_CAM_AWB_LL_CCM_2 0xC8DEU
443#define MT9M114_VAR_CAM_AWB_LL_CCM_3 0xC8E0U
444#define MT9M114_VAR_CAM_AWB_LL_CCM_4 0xC8E2U
445#define MT9M114_VAR_CAM_AWB_LL_CCM_5 0xC8E4U
446#define MT9M114_VAR_CAM_AWB_LL_CCM_6 0xC8E6U
447#define MT9M114_VAR_CAM_AWB_LL_CCM_7 0xC8E8U
448#define MT9M114_VAR_CAM_AWB_LL_CCM_8 0xC8EAU
449#define MT9M114_VAR_CAM_AWB_COLOR_TEMPERATURE_MIN 0xC8ECU
450#define MT9M114_VAR_CAM_AWB_COLOR_TEMPERATURE_MAX 0xC8EEU
451#define MT9M114_VAR_CAM_AWB_COLOR_TEMPERATURE 0xC8F0U
452#define MT9M114_VAR_CAM_AWB_AWB_XSCALE 0xC8F2U
453#define MT9M114_VAR_CAM_AWB_AWB_YSCALE 0xC8F3U
454#define MT9M114_VAR_CAM_AWB_AWB_WEIGHTS_0 0xC8F4U
455#define MT9M114_VAR_CAM_AWB_AWB_WEIGHTS_1 0xC8F6U
456#define MT9M114_VAR_CAM_AWB_AWB_WEIGHTS_2 0xC8F8U
457#define MT9M114_VAR_CAM_AWB_AWB_WEIGHTS_3 0xC8FAU
458#define MT9M114_VAR_CAM_AWB_AWB_WEIGHTS_4 0xC8FCU
459#define MT9M114_VAR_CAM_AWB_AWB_WEIGHTS_5 0xC8FEU
460#define MT9M114_VAR_CAM_AWB_AWB_WEIGHTS_6 0xC900U
461#define MT9M114_VAR_CAM_AWB_AWB_WEIGHTS_7 0xC902U
462#define MT9M114_VAR_CAM_AWB_AWB_XSHIFT_PRE_ADJ 0xC904U
463#define MT9M114_VAR_CAM_AWB_AWB_YSHIFT_PRE_ADJ 0xC906U
464#define MT9M114_VAR_CAM_AWB_AWBMODE 0xC909U
465#define MT9M114_VAR_CAM_AWB_TINTS_CTEMP_THRESHOLD 0xC90AU
466#define MT9M114_VAR_CAM_AWB_K_R_L 0xC90CU
467#define MT9M114_VAR_CAM_AWB_K_G_L 0xC90DU
468#define MT9M114_VAR_CAM_AWB_K_B_L 0xC90EU
469#define MT9M114_VAR_CAM_AWB_K_R_R 0xC90FU
470#define MT9M114_VAR_CAM_AWB_K_G_R 0xC910U
471#define MT9M114_VAR_CAM_AWB_K_B_R 0xC911U
472#define MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_XSTART 0xC914U
473#define MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_YSTART 0xC916U
474#define MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_XEND 0xC918U
475#define MT9M114_VAR_CAM_STAT_AWB_CLIP_WINDOW_YEND 0xC91AU
476#define MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_XSTART 0xC91CU
477#define MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_YSTART 0xC91EU
478#define MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_XEND 0xC920U
479#define MT9M114_VAR_CAM_STAT_AE_INITIAL_WINDOW_YEND 0xC922U
480#define MT9M114_VAR_CAM_LL_LLMODE 0xC924U
481#define MT9M114_VAR_CAM_LL_START_BRIGHTNESS 0xC926U
482#define MT9M114_VAR_CAM_LL_STOP_BRIGHTNESS 0xC928U
483#define MT9M114_VAR_CAM_LL_START_SATURATION 0xC92AU
484#define MT9M114_VAR_CAM_LL_END_SATURATION 0xC92BU
485#define MT9M114_VAR_CAM_LL_START_DESATURATION 0xC92CU
486#define MT9M114_VAR_CAM_LL_END_DESATURATION 0xC92DU
487#define MT9M114_VAR_CAM_LL_START_DEMOSAIC 0xC92EU
488#define MT9M114_VAR_CAM_LL_START_AP_GAIN 0xC92FU
489#define MT9M114_VAR_CAM_LL_START_AP_THRESH 0xC930U
490#define MT9M114_VAR_CAM_LL_STOP_DEMOSAIC 0xC931U
491#define MT9M114_VAR_CAM_LL_STOP_AP_GAIN 0xC932U
492#define MT9M114_VAR_CAM_LL_STOP_AP_THRESH 0xC933U
493#define MT9M114_VAR_CAM_LL_START_NR_RED 0xC934U
494#define MT9M114_VAR_CAM_LL_START_NR_GREEN 0xC935U
495#define MT9M114_VAR_CAM_LL_START_NR_BLUE 0xC936U
496#define MT9M114_VAR_CAM_LL_START_NR_THRESH 0xC937U
497#define MT9M114_VAR_CAM_LL_STOP_NR_RED 0xC938U
498#define MT9M114_VAR_CAM_LL_STOP_NR_GREEN 0xC939U
499#define MT9M114_VAR_CAM_LL_STOP_NR_BLUE 0xC93AU
500#define MT9M114_VAR_CAM_LL_STOP_NR_THRESH 0xC93BU
501#define MT9M114_VAR_CAM_LL_START_CONTRAST_BM 0xC93CU
502#define MT9M114_VAR_CAM_LL_STOP_CONTRAST_BM 0xC93EU
503#define MT9M114_VAR_CAM_LL_GAMMA 0xC940U
504#define MT9M114_VAR_CAM_LL_START_CONTRAST_GRADIENT 0xC942U
505#define MT9M114_VAR_CAM_LL_STOP_CONTRAST_GRADIENT 0xC943U
506#define MT9M114_VAR_CAM_LL_START_CONTRAST_LUMA_PERCENTAGE 0xC944U
507#define MT9M114_VAR_CAM_LL_STOP_CONTRAST_LUMA_PERCENTAGE 0xC945U
508#define MT9M114_VAR_CAM_LL_START_GAIN_METRIC 0xC946U
509#define MT9M114_VAR_CAM_LL_STOP_GAIN_METRIC 0xC948U
510#define MT9M114_VAR_CAM_LL_START_FADE_TO_BLACK_LUMA 0xC94AU
511#define MT9M114_VAR_CAM_LL_STOP_FADE_TO_BLACK_LUMA 0xC94CU
512#define MT9M114_VAR_CAM_LL_CLUSTER_DC_TH_BM 0xC94EU
513#define MT9M114_VAR_CAM_LL_CLUSTER_DC_GATE_PERCENTAGE 0xC950U
514#define MT9M114_VAR_CAM_LL_SUMMING_SENSITIVITY_FACTOR 0xC951U
515#define MT9M114_VAR_CAM_LL_START_TARGET_LUMA_BM 0xC952U
516#define MT9M114_VAR_CAM_LL_STOP_TARGET_LUMA_BM 0xC954U
517#define MT9M114_VAR_CAM_LL_INV_BRIGHTNESS_METRIC 0xC956U
518#define MT9M114_VAR_CAM_LL_GAIN_METRIC 0xC958U
519#define MT9M114_VAR_CAM_SEQ_UV_COLOR_BOOST 0xC95AU
520#define MT9M114_VAR_CAM_PGA_PGA_CONTROL 0xC95EU
521#define MT9M114_VAR_CAM_PGA_L_CONFIG_COLOUR_TEMP 0xC960U
522#define MT9M114_VAR_CAM_PGA_L_CONFIG_GREEN_RED_Q14 0xC962U
523#define MT9M114_VAR_CAM_PGA_L_CONFIG_RED_Q14 0xC964U
524#define MT9M114_VAR_CAM_PGA_L_CONFIG_GREEN_BLUE_Q14 0xC966U
525#define MT9M114_VAR_CAM_PGA_L_CONFIG_BLUE_Q14 0xC968U
526#define MT9M114_VAR_CAM_PGA_M_CONFIG_COLOUR_TEMP 0xC96AU
527#define MT9M114_VAR_CAM_PGA_M_CONFIG_GREEN_RED_Q14 0xC96CU
528#define MT9M114_VAR_CAM_PGA_M_CONFIG_RED_Q14 0xC96EU
529#define MT9M114_VAR_CAM_PGA_M_CONFIG_GREEN_BLUE_Q14 0xC970U
530#define MT9M114_VAR_CAM_PGA_M_CONFIG_BLUE_Q14 0xC972U
531#define MT9M114_VAR_CAM_PGA_R_CONFIG_COLOUR_TEMP 0xC974U
532#define MT9M114_VAR_CAM_PGA_R_CONFIG_GREEN_RED_Q14 0xC976U
533#define MT9M114_VAR_CAM_PGA_R_CONFIG_RED_Q14 0xC978U
534#define MT9M114_VAR_CAM_PGA_R_CONFIG_GREEN_BLUE_Q14 0xC97AU
535#define MT9M114_VAR_CAM_PGA_R_CONFIG_BLUE_Q14 0xC97CU
536#define MT9M114_VAR_CAM_SYSCTL_PLL_ENABLE 0xC97EU
537#define MT9M114_VAR_CAM_SYSCTL_PLL_DIVIDER_M_N 0xC980U
538#define MT9M114_VAR_CAM_SYSCTL_PLL_DIVIDER_P 0xC982U
539#define MT9M114_VAR_CAM_PORT_OUTPUT_CONTROL 0xC984U
540#define MT9M114_VAR_CAM_PORT_PORCH 0xC986U
541#define MT9M114_VAR_CAM_PORT_MIPI_TIMING_T_HS_ZERO 0xC988U
542#define MT9M114_VAR_CAM_PORT_MIPI_TIMING_T_HS_EXIT_HS_TRAIL 0xC98AU
543#define MT9M114_VAR_CAM_PORT_MIPI_TIMING_T_CLK_POST_CLK_PRE 0xC98CU
544#define MT9M114_VAR_CAM_PORT_MIPI_TIMING_T_CLK_TRAIL_CLK_ZERO 0xC98EU
545#define MT9M114_VAR_CAM_PORT_MIPI_TIMING_T_LPX 0xC990U
546#define MT9M114_VAR_CAM_PORT_MIPI_TIMING_INIT_TIMING 0xC992U
547
548/* 10.UVC_Control variables */
549#define MT9M114_VAR_UVC_AE_MODE_CONTROL 0xCC00U
550#define MT9M114_VAR_UVC_WHITE_BALANCE_TEMPERATURE_AUTO_CONTROL 0xCC01U
551#define MT9M114_VAR_UVC_AE_PRIORITY_CONTROL 0xCC02U
552#define MT9M114_VAR_UVC_POWER_LINE_FREQUENCY_CONTROL 0xCC03U
553#define MT9M114_VAR_UVC_EXPOSURE_TIME_ABSOLUTE_CONTROL 0xCC04U
554#define MT9M114_VAR_UVC_BACKLIGHT_COMPENSATION_CONTROL 0xCC08U
555#define MT9M114_VAR_UVC_BRIGHTNESS_CONTROL 0xCC0AU
556#define MT9M114_VAR_UVC_CONTRAST_CONTROL 0xCC0CU
557#define MT9M114_VAR_UVC_GAIN_CONTROL 0xCC0EU
558#define MT9M114_VAR_UVC_HUE_CONTROL 0xCC10U
559#define MT9M114_VAR_UVC_SATURATION_CONTROL 0xCC12U
560#define MT9M114_VAR_UVC_SHARPNESS_CONTROL 0xCC14U
561#define MT9M114_VAR_UVC_GAMMA_CONTROL 0xCC16U
562#define MT9M114_VAR_UVC_WHITE_BALANCE_TEMPERATURE_CONTROL 0xCC18U
563#define MT9M114_VAR_UVC_FRAME_INTERVAL_CONTROL 0xCC1CU
564#define MT9M114_VAR_UVC_MANUAL_EXPOSURE_CONFIGURATION 0xCC20U
565#define MT9M114_VAR_UVC_FLICKER_AVOIDANCE_CONFIGURATION 0xCC21U
566#define MT9M114_VAR_UVC_ALGO 0xCC22U
567#define MT9M114_VAR_UVC_RESULT_STATUS 0xCC24U
568
569/* 11.SystemManager variables */
570#define MT9M114_VAR_SYSMGR_NEXT_STATE 0xDC00U
571#define MT9M114_VAR_SYSMGR_CURRENT_STATE 0xDC01U
572#define MT9M114_VAR_SYSMGR_CMD_STATUS 0xDC02U
573
574/* 12.PatchLoader variables */
575#define MT9M114_VAR_PATCHLDR_LOADER_ADDRESS 0xE000U
576#define MT9M114_VAR_PATCHLDR_PATCH_ID 0xE002U
577#define MT9M114_VAR_PATCHLDR_FIRMWARE_ID 0xE004U
578#define MT9M114_VAR_PATCHLDR_APPLY_STATUS 0xE008U
579#define MT9M114_VAR_PATCHLDR_NUM_PATCHES 0xE009U
580#define MT9M114_VAR_PATCHLDR_PATCH_ID_0 0xE00AU
581#define MT9M114_VAR_PATCHLDR_PATCH_ID_1 0xE00CU
582#define MT9M114_VAR_PATCHLDR_PATCH_ID_2 0xE00EU
583#define MT9M114_VAR_PATCHLDR_PATCH_ID_3 0xE010U
584#define MT9M114_VAR_PATCHLDR_PATCH_ID_4 0xE012U
585#define MT9M114_VAR_PATCHLDR_PATCH_ID_5 0xE014U
586#define MT9M114_VAR_PATCHLDR_PATCH_ID_6 0xE016U
587#define MT9M114_VAR_PATCHLDR_PATCH_ID_7 0xE018U
588
589/* 13.Patch variables */
590#define MT9M114_VAR_PATCHVARS_DELTA_DK_CORRECTION_FACTOR 0xE400U
591
592/* 14.CommandHandler variables */
593#define MT9M114_VAR_CMD_HANDLER_WAIT_EVENT_ID 0xFC00U
594#define MT9M114_VAR_CMD_HANDLER_NUM_EVENTS 0xFC02U
595
596/*! @brief MT9M114 command definitions. */
597#define MT9M114_COMMAND_APPLY_PATCH 0x0001U
598#define MT9M114_COMMAND_SET_STATE 0x0002U
599#define MT9M114_COMMAND_REFRESH 0x0004U
600#define MT9M114_COMMAND_WAIT_FOR_EVENT 0x0008U
601#define MT9M114_COMMAND_OK 0x8000U
602
603/*! @brief MT9M114 system state definitions. */
604#define MT9M114_SYS_STATE_ENTER_CONFIG_CHANGE 0x28U
605#define MT9M114_SYS_STATE_STREAMING 0x31U
606#define MT9M114_SYS_STATE_START_STREAMING 0x34U
607#define MT9M114_SYS_STATE_ENTER_SUSPEND 0x40U
608#define MT9M114_SYS_STATE_SUSPENDED 0x41U
609#define MT9M114_SYS_STATE_ENTER_STANDBY 0x50U
610#define MT9M114_SYS_STATE_STANDBY 0x52U
611#define MT9M114_SYS_STATE_LEAVE_STANDBY 0x54U
612
613/*! @brief MT9M114 system set-state command retults. */
614#define MT9M114_SYS_STATE_SET_RESULT_ENOERR 0x00U /* command successful */
615#define MT9M114_SYS_STATE_SET_RESULTEINVAL 0x0CU /* invalid configuration */
616#define MT9M114_SYS_STATE_SET_RESULTENOSPC 0x0DU /* resource not available */
617
618/*******************************************************************************
619 * Prototypes
620 ******************************************************************************/
621
622/*!
623 * @brief MT9M114 resource.
624 *
625 * Before initialize the MT9M114, the resource must be initialized that the
626 * Two-Wire-Serial-Interface I2C could start to work.
627 */
628typedef struct _mt9m114_resource
629{
630 video_i2c_send_func_t i2cSendFunc; /*!< I2C send function. */
631 video_i2c_receive_func_t i2cReceiveFunc; /*!< I2C receive function. */
632 void (*pullResetPin)(bool pullUp); /*!< Function to pull reset pin high or low. */
633 uint32_t inputClockFreq_Hz; /*!< Input clock frequency, EXTCLK. */
634} mt9m114_resource_t;
635
636/*! @brief MT9M114 operation functions. */
637extern const camera_device_operations_t mt9m114_ops;
638
639/*******************************************************************************
640 * API
641 ******************************************************************************/
642
643#if defined(__cplusplus)
644extern "C" {
645#endif
646
647#if defined(__cplusplus)
648}
649#endif
650
651#endif /* _FSL_MT9M114_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/driver_camera-device-ov5640.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/driver_camera-device-ov5640.cmake
new file mode 100644
index 000000000..147268cd1
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/driver_camera-device-ov5640.cmake
@@ -0,0 +1,19 @@
1if(NOT DRIVER_CAMERA-DEVICE-OV5640_INCLUDED)
2
3 set(DRIVER_CAMERA-DEVICE-OV5640_INCLUDED true CACHE BOOL "driver_camera-device-ov5640 component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_ov5640.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13
14 include(driver_camera-device-sccb)
15 include(driver_camera-common)
16 include(driver_video-common)
17 include(driver_camera-device-common)
18
19endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/fsl_ov5640.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/fsl_ov5640.c
new file mode 100644
index 000000000..b8d401e68
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/fsl_ov5640.c
@@ -0,0 +1,1124 @@
1/*
2 * Copyright 2017-2018, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#include "fsl_video_common.h"
10#include "fsl_camera.h"
11#include "fsl_camera_device.h"
12#include "fsl_ov5640.h"
13
14/*******************************************************************************
15 * Definitions
16 ******************************************************************************/
17#define OV5640_DelayMs VIDEO_DelayMs
18
19#define OV5640_SCCB_ADDR 0x3CU
20#define OV5640_RESOLUTION_PARAM_NUM 0x16U
21
22#define OV5640_WriteReg(handle, reg, val) \
23 SCCB_WriteReg(OV5640_SCCB_ADDR, kSCCB_RegAddr16Bit, (reg), (val), \
24 ((ov5640_resource_t *)((handle)->resource))->i2cSendFunc)
25
26#define OV5640_WriteMultiRegs(handle, reg, val, len) \
27 SCCB_WriteMultiRegs(OV5640_SCCB_ADDR, kSCCB_RegAddr16Bit, (reg), (val), len, \
28 ((ov5640_resource_t *)((handle)->resource))->i2cSendFunc)
29
30#define OV5640_ReadReg(handle, reg, val) \
31 SCCB_ReadReg(OV5640_SCCB_ADDR, kSCCB_RegAddr16Bit, (reg), (val), \
32 ((ov5640_resource_t *)((handle)->resource))->i2cReceiveFunc)
33
34#define OV5640_ModifyReg(handle, reg, clrMask, val) \
35 SCCB_ModifyReg(OV5640_SCCB_ADDR, kSCCB_RegAddr16Bit, (reg), (clrMask), (val), \
36 ((ov5640_resource_t *)((handle)->resource))->i2cReceiveFunc, \
37 ((ov5640_resource_t *)((handle)->resource))->i2cSendFunc)
38
39#define OV5640_POLARITY_CTRL00_VSYNC_MASK (1U << 0U)
40#define OV5640_POLARITY_CTRL00_HREF_MASK (1U << 1U)
41#define OV5640_POLARITY_CTRL00_GATE_PCLK_HREF_MASK (1U << 2U)
42#define OV5640_POLARITY_CTRL00_GATE_PCLK_VSYNC_MASK (1U << 3U)
43#define OV5640_POLARITY_CTRL00_PCLK_MASK (1U << 5U)
44
45#define OV5640_SDE_CTRL0_REG 0x5580
46#define OV5640_SDE_CTRL1_REG 0x5581
47#define OV5640_SDE_CTRL2_REG 0x5582
48#define OV5640_SDE_CTRL3_REG 0x5583
49#define OV5640_SDE_CTRL4_REG 0x5584
50#define OV5640_SDE_CTRL5_REG 0x5585
51#define OV5640_SDE_CTRL6_REG 0x5586
52#define OV5640_SDE_CTRL7_REG 0x5587
53#define OV5640_SDE_CTRL8_REG 0x5588
54#define OV5640_SDE_CTRL9_REG 0x5589
55#define OV5640_SDE_CTRL10_REG 0x558a
56#define OV5640_SDE_CTRL11_REG 0x558b
57#define OV5640_SDE_CTRL12_REG 0x558c
58
59#define OV5640_AWB_R_H_REG 0x3400
60#define OV5640_AWB_R_L_REG 0x3401
61#define OV5640_AWB_G_H_REG 0x3402
62#define OV5640_AWB_G_L_REG 0x3403
63#define OV5640_AWB_B_H_REG 0x3404
64#define OV5640_AWB_B_L_REG 0x3405
65#define OV5640_AWB_CTRL_REG 0x3406
66
67#define OV5640_CHECK_RET(x) \
68 do \
69 { \
70 status = (x); \
71 if (kStatus_Success != status) \
72 { \
73 return status; \
74 } \
75 } while (false)
76
77typedef struct _ov5640_reg_val
78{
79 uint16_t regAddr; /*!< Register address. */
80 uint8_t regVal; /*!<Register value. */
81} ov5640_reg_val_t;
82
83typedef struct _ov5640_resolution_param
84{
85 uint32_t resolution; /*!< Resolution, see @ref video_resolution_t and @ref FSL_VIDEO_RESOLUTION. */
86 uint8_t param[OV5640_RESOLUTION_PARAM_NUM]; /*!< Parameter 0x3800 to 0x3813. */
87} ov5640_resolution_param_t;
88
89typedef struct
90{
91 uint32_t resolution;
92 uint8_t framePerSec;
93 uint8_t pllCtrl1;
94 uint8_t pllCtrl2;
95 uint8_t vfifoCtrl0C;
96 uint8_t pclkDiv;
97 uint8_t pclkPeriod;
98} ov5640_clock_config_t;
99
100typedef struct
101{
102 uint8_t lightMode;
103 uint8_t awbCtrl;
104 uint8_t awbR_H;
105 uint8_t awbR_L;
106 uint8_t awbG_H;
107 uint8_t awbG_L;
108 uint8_t awbB_H;
109 uint8_t awbB_L;
110} ov5640_light_mode_config_t;
111
112typedef struct
113{
114 uint8_t effect;
115 uint8_t sdeCtrl0;
116 uint8_t sdeCtrl3;
117 uint8_t sdeCtrl4;
118} ov5640_special_effect_config_t;
119
120typedef status_t (*ov5640_cmd_func_t)(camera_device_handle_t *handle, int32_t arg);
121
122typedef struct
123{
124 camera_device_cmd_t cmd;
125 ov5640_cmd_func_t func;
126} ov5640_cmd_func_map_t;
127
128/*******************************************************************************
129 * Prototypes
130 ******************************************************************************/
131status_t OV5640_Init(camera_device_handle_t *handle, const camera_config_t *config);
132
133status_t OV5640_Deinit(camera_device_handle_t *handle);
134
135status_t OV5640_Control(camera_device_handle_t *handle, camera_device_cmd_t cmd, int32_t arg);
136
137status_t OV5640_Start(camera_device_handle_t *handle);
138
139status_t OV5640_Stop(camera_device_handle_t *handle);
140
141status_t OV5640_InitExt(camera_device_handle_t *handle, const camera_config_t *config, const void *specialConfig);
142
143status_t OV5640_SetSpecialEffect(camera_device_handle_t *handle, int32_t effect);
144
145status_t OV5640_SetLightMode(camera_device_handle_t *handle, int32_t lightMode);
146
147status_t OV5640_SetSaturation(camera_device_handle_t *handle, int32_t saturation);
148
149status_t OV5640_SetContrast(camera_device_handle_t *handle, int32_t contrast);
150
151status_t OV5640_SetBrightness(camera_device_handle_t *handle, int32_t brightness);
152
153/*******************************************************************************
154 * Variables
155 ******************************************************************************/
156static const ov5640_reg_val_t ov5640InitParam[] = {
157 {0x3008, 0x42},
158
159 /* System setting. */
160 {0x3103, 0x03},
161 {0x3000, 0x00},
162 {0x3004, 0xff},
163 {0x3002, 0x1c},
164 {0x3006, 0xc3},
165 {0x302e, 0x08},
166 {0x3037, 0x13},
167 {0x3108, 0x01},
168 {0x3618, 0x00},
169 {0x3612, 0x29},
170 {0x3708, 0x64},
171 {0x3709, 0x52},
172 {0x370c, 0x03},
173 {0x3820, 0x41},
174 {0x3821, 0x07},
175 {0x3630, 0x36},
176 {0x3631, 0x0e},
177 {0x3632, 0xe2},
178 {0x3633, 0x12},
179 {0x3621, 0xe0},
180 {0x3704, 0xa0},
181 {0x3703, 0x5a},
182 {0x3715, 0x78},
183 {0x3717, 0x01},
184 {0x370b, 0x60},
185 {0x3705, 0x1a},
186 {0x3905, 0x02},
187 {0x3906, 0x10},
188 {0x3901, 0x0a},
189 {0x3731, 0x12},
190 {0x3600, 0x08},
191 {0x3601, 0x33},
192 {0x302d, 0x60},
193 {0x3620, 0x52},
194 {0x371b, 0x20},
195 {0x471c, 0x50},
196 {0x3a13, 0x43},
197 {0x3a18, 0x00},
198 {0x3a19, 0x7c},
199 {0x3635, 0x13},
200 {0x3636, 0x03},
201 {0x3634, 0x40},
202 {0x3622, 0x01},
203 {0x3c01, 0x00},
204 {0x3a00, 0x58},
205 {0x4001, 0x02},
206 {0x4004, 0x02},
207 {0x4005, 0x1a},
208 {0x5001, 0xa3},
209
210 /* AEC */
211 {0x3a0f, 0x30},
212 {0x3a10, 0x28},
213 {0x3a1b, 0x30},
214 {0x3a1e, 0x26},
215 {0x3a11, 0x60},
216 {0x3a1f, 0x14},
217
218 /* AWB */
219 {0x5180, 0xff},
220 {0x5181, 0xf2},
221 {0x5182, 0x00},
222 {0x5183, 0x14},
223 {0x5184, 0x25},
224 {0x5185, 0x24},
225 {0x5186, 0x09},
226 {0x5187, 0x09},
227 {0x5188, 0x09},
228 {0x5189, 0x88},
229 {0x518a, 0x54},
230 {0x518b, 0xee},
231 {0x518c, 0xb2},
232 {0x518d, 0x50},
233 {0x518e, 0x34},
234 {0x518f, 0x6b},
235 {0x5190, 0x46},
236 {0x5191, 0xf8},
237 {0x5192, 0x04},
238 {0x5193, 0x70},
239 {0x5194, 0xf0},
240 {0x5195, 0xf0},
241 {0x5196, 0x03},
242 {0x5197, 0x01},
243 {0x5198, 0x04},
244 {0x5199, 0x6c},
245 {0x519a, 0x04},
246 {0x519b, 0x00},
247 {0x519c, 0x09},
248 {0x519d, 0x2b},
249 {0x519e, 0x38},
250
251 /* Color Matrix */
252 {0x5381, 0x1e},
253 {0x5382, 0x5b},
254 {0x5383, 0x08},
255 {0x5384, 0x0a},
256 {0x5385, 0x7e},
257 {0x5386, 0x88},
258 {0x5387, 0x7c},
259 {0x5388, 0x6c},
260 {0x5389, 0x10},
261 {0x538a, 0x01},
262 {0x538b, 0x98},
263
264 /* sharp */
265 {0x5300, 0x08},
266 {0x5301, 0x30},
267 {0x5302, 0x10},
268 {0x5303, 0x00},
269 {0x5304, 0x08},
270 {0x5305, 0x30},
271 {0x5306, 0x08},
272 {0x5307, 0x16},
273 {0x5309, 0x08},
274 {0x530a, 0x30},
275 {0x530b, 0x04},
276 {0x530c, 0x06},
277
278 /* Gamma */
279 {0x5480, 0x01},
280 {0x5481, 0x08},
281 {0x5482, 0x14},
282 {0x5483, 0x28},
283 {0x5484, 0x51},
284 {0x5485, 0x65},
285 {0x5486, 0x71},
286 {0x5487, 0x7d},
287 {0x5488, 0x87},
288 {0x5489, 0x91},
289 {0x548a, 0x9a},
290 {0x548b, 0xaa},
291 {0x548c, 0xb8},
292 {0x548d, 0xcd},
293 {0x548e, 0xdd},
294 {0x548f, 0xea},
295 {0x5490, 0x1d},
296
297 /* UV adjust. */
298 {0x5580, 0x02},
299 {0x5583, 0x40},
300 {0x5584, 0x10},
301 {0x5589, 0x10},
302 {0x558a, 0x00},
303 {0x558b, 0xf8},
304
305 /* Lens correction. */
306 {0x5800, 0x23},
307 {0x5801, 0x14},
308 {0x5802, 0x0f},
309 {0x5803, 0x0f},
310 {0x5804, 0x12},
311 {0x5805, 0x26},
312 {0x5806, 0x0c},
313 {0x5807, 0x08},
314 {0x5808, 0x05},
315 {0x5809, 0x05},
316 {0x580a, 0x08},
317 {0x580b, 0x0d},
318 {0x580c, 0x08},
319 {0x580d, 0x03},
320 {0x580e, 0x00},
321 {0x580f, 0x00},
322 {0x5810, 0x03},
323 {0x5811, 0x09},
324 {0x5812, 0x07},
325 {0x5813, 0x03},
326 {0x5814, 0x00},
327 {0x5815, 0x01},
328 {0x5816, 0x03},
329 {0x5817, 0x08},
330 {0x5818, 0x0d},
331 {0x5819, 0x08},
332 {0x581a, 0x05},
333 {0x581b, 0x06},
334 {0x581c, 0x08},
335 {0x581d, 0x0e},
336 {0x581e, 0x29},
337 {0x581f, 0x17},
338 {0x5820, 0x11},
339 {0x5821, 0x11},
340 {0x5822, 0x15},
341 {0x5823, 0x28},
342 {0x5824, 0x46},
343 {0x5825, 0x26},
344 {0x5826, 0x08},
345 {0x5827, 0x26},
346 {0x5828, 0x64},
347 {0x5829, 0x26},
348 {0x582a, 0x24},
349 {0x582b, 0x22},
350 {0x582c, 0x24},
351 {0x582d, 0x24},
352 {0x582e, 0x06},
353 {0x582f, 0x22},
354 {0x5830, 0x40},
355 {0x5831, 0x42},
356 {0x5832, 0x24},
357 {0x5833, 0x26},
358 {0x5834, 0x24},
359 {0x5835, 0x22},
360 {0x5836, 0x22},
361 {0x5837, 0x26},
362 {0x5838, 0x44},
363 {0x5839, 0x24},
364 {0x583a, 0x26},
365 {0x583b, 0x28},
366 {0x583c, 0x42},
367 {0x583d, 0xce},
368};
369
370static const ov5640_resolution_param_t resolutionParam[] = {
371 {
372 .resolution = (uint32_t)kVIDEO_ResolutionVGA,
373 .param = {0x00, 0x00, 0x00, 0x04, 0x0a, 0x3f, 0x07, 0x9b, 0x02, 0x80, 0x01,
374 0xe0, 0x07, 0x68, 0x03, 0xd8, 0x00, 0x10, 0x00, 0x06, 0x31, 0x31},
375 },
376 {
377 .resolution = (uint32_t)kVIDEO_ResolutionQVGA,
378 .param = {0x00, 0x00, 0x00, 0x04, 0x0a, 0x3f, 0x07, 0x9b, 0x01, 0x40, 0x00,
379 0xf0, 0x07, 0x68, 0x03, 0xd8, 0x00, 0x10, 0x00, 0x06, 0x31, 0x31},
380 },
381 {
382 .resolution = FSL_VIDEO_RESOLUTION(480, 272),
383 .param = {0x00, 0x00, 0x00, 0xfa, 0x0a, 0x3f, 0x06, 0xa9, 0x01, 0xE0, 0x01,
384 0x10, 0x07, 0x64, 0x02, 0xe4, 0x00, 0x10, 0x00, 0x04, 0x31, 0x31},
385 },
386 {
387 .resolution = (uint32_t)kVIDEO_Resolution720P,
388 .param = {0x00, 0x00, 0x00, 0xfa, 0x0a, 0x3f, 0x06, 0xa9, 0x05, 0x00, 0x02,
389 0xd0, 0x07, 0x64, 0x02, 0xe4, 0x00, 0x10, 0x00, 0x04, 0x31, 0x31},
390 },
391 {
392 .resolution = (uint32_t)kVIDEO_Resolution1080P,
393 .param = {0x01, 0x50, 0x01, 0xb2, 0x08, 0xef, 0x05, 0xf1, 0x07, 0x80, 0x04,
394 0x38, 0x09, 0xc4, 0x04, 0x60, 0x00, 0x10, 0x00, 0x04, 0x11, 0x11},
395 },
396};
397
398/* DVP */
399static const ov5640_clock_config_t s_ov5640DvpClockConfigs[] = {
400 {
401 .resolution = (uint32_t)kVIDEO_ResolutionVGA,
402 .framePerSec = 15,
403 .pllCtrl1 = 0x21,
404 .pllCtrl2 = 0x46,
405 .vfifoCtrl0C = 0x22,
406 .pclkDiv = 0x02,
407 .pclkPeriod = 0x22,
408 },
409 {
410 .resolution = (uint32_t)kVIDEO_ResolutionVGA,
411 .framePerSec = 30,
412 .pllCtrl1 = 0x11,
413 .pllCtrl2 = 0x46,
414 .vfifoCtrl0C = 0x22,
415 .pclkDiv = 0x02,
416 .pclkPeriod = 0x22,
417 },
418 {
419 .resolution = (uint32_t)kVIDEO_ResolutionQVGA,
420 .framePerSec = 15,
421 .pllCtrl1 = 0x21,
422 .pllCtrl2 = 0x46,
423 .vfifoCtrl0C = 0x22,
424 .pclkDiv = 0x02,
425 .pclkPeriod = 0x22,
426 },
427 {
428 .resolution = (uint32_t)kVIDEO_ResolutionQVGA,
429 .framePerSec = 30,
430 .pllCtrl1 = 0x11,
431 .pllCtrl2 = 0x46,
432 .vfifoCtrl0C = 0x22,
433 .pclkDiv = 0x02,
434 .pclkPeriod = 0x22,
435 },
436 {
437 .resolution = FSL_VIDEO_RESOLUTION(480, 272),
438 .framePerSec = 15,
439 .pllCtrl1 = 0x41,
440 .pllCtrl2 = 0x69,
441 .vfifoCtrl0C = 0x20,
442 .pclkDiv = 0x04,
443 .pclkPeriod = 0x16,
444 },
445 {
446 .resolution = FSL_VIDEO_RESOLUTION(480, 272),
447 .framePerSec = 30,
448 .pllCtrl1 = 0x21,
449 .pllCtrl2 = 0x69,
450 .vfifoCtrl0C = 0x20,
451 .pclkDiv = 0x04,
452 .pclkPeriod = 0x16,
453 },
454 {
455 .resolution = (uint32_t)kVIDEO_Resolution720P,
456 .framePerSec = 15,
457 .pllCtrl1 = 0x41,
458 .pllCtrl2 = 0x69,
459 .vfifoCtrl0C = 0x20,
460 .pclkDiv = 0x04,
461 .pclkPeriod = 0x16,
462 },
463 {
464 .resolution = (uint32_t)kVIDEO_Resolution720P,
465 .framePerSec = 30,
466 .pllCtrl1 = 0x21,
467 .pllCtrl2 = 0x69,
468 .vfifoCtrl0C = 0x20,
469 .pclkDiv = 0x04,
470 .pclkPeriod = 0x16,
471 },
472 {
473 .resolution = (uint32_t)kVIDEO_Resolution1080P,
474 .framePerSec = 15,
475 .pllCtrl1 = 0x21,
476 .pllCtrl2 = 0x69,
477 .vfifoCtrl0C = 0x20,
478 .pclkDiv = 0x04,
479 .pclkPeriod = 0x16,
480 },
481};
482
483/* MIPI */
484static const ov5640_clock_config_t s_ov5640MipiClockConfigs[] = {
485 {
486 .resolution = (uint32_t)kVIDEO_ResolutionVGA,
487 .framePerSec = 15,
488 .pllCtrl1 = 0x22,
489 .pllCtrl2 = 0x38,
490 .vfifoCtrl0C = 0x22,
491 .pclkDiv = 0x02,
492 .pclkPeriod = 0x0a,
493 },
494 {
495 .resolution = (uint32_t)kVIDEO_ResolutionVGA,
496 .framePerSec = 30,
497 .pllCtrl1 = 0x14,
498 .pllCtrl2 = 0x38,
499 .vfifoCtrl0C = 0x22,
500 .pclkDiv = 0x02,
501 .pclkPeriod = 0x0a,
502 },
503 {
504 .resolution = (uint32_t)kVIDEO_ResolutionQVGA,
505 .framePerSec = 15,
506 .pllCtrl1 = 0x22,
507 .pllCtrl2 = 0x38,
508 .vfifoCtrl0C = 0x22,
509 .pclkDiv = 0x02,
510 .pclkPeriod = 0x0a,
511 },
512 {
513 .resolution = (uint32_t)kVIDEO_ResolutionQVGA,
514 .framePerSec = 30,
515 .pllCtrl1 = 0x14,
516 .pllCtrl2 = 0x38,
517 .vfifoCtrl0C = 0x22,
518 .pclkDiv = 0x02,
519 .pclkPeriod = 0x0a,
520 },
521 {
522 .resolution = (uint32_t)kVIDEO_Resolution720P,
523 .framePerSec = 15,
524 .pllCtrl1 = 0x41,
525 .pllCtrl2 = 0x54,
526 .vfifoCtrl0C = 0x20,
527 .pclkDiv = 0x04,
528 .pclkPeriod = 0x0a,
529 },
530 {
531 .resolution = (uint32_t)kVIDEO_Resolution720P,
532 .framePerSec = 30,
533 .pllCtrl1 = 0x21,
534 .pllCtrl2 = 0x54,
535 .vfifoCtrl0C = 0x20,
536 .pclkDiv = 0x04,
537 .pclkPeriod = 0x0a,
538 },
539 {
540 .resolution = (uint32_t)kVIDEO_Resolution1080P,
541 .framePerSec = 15,
542 .pllCtrl1 = 0x21,
543 .pllCtrl2 = 0x54,
544 .vfifoCtrl0C = 0x20,
545 .pclkDiv = 0x04,
546 .pclkPeriod = 0x0a,
547 },
548 {
549 .resolution = (uint32_t)kVIDEO_Resolution1080P,
550 .framePerSec = 30,
551 .pllCtrl1 = 0x11,
552 .pllCtrl2 = 0x54,
553 .vfifoCtrl0C = 0x20,
554 .pclkDiv = 0x04,
555 .pclkPeriod = 0x0a,
556 },
557};
558
559static const ov5640_light_mode_config_t s_ov5640LightModeConfigs[] = {
560 /* Auto. */
561 {
562 .lightMode = CAMERA_LIGHT_MODE_AUTO,
563 .awbCtrl = 0x00,
564 .awbR_H = 0x04,
565 .awbR_L = 0x00,
566 .awbG_H = 0x04,
567 .awbG_L = 0x00,
568 .awbB_H = 0x04,
569 .awbB_L = 0x00,
570 },
571 /* Sunny. */
572 {
573 .lightMode = CAMERA_LIGHT_MODE_SUNNY,
574 .awbCtrl = 0x01,
575 .awbR_H = 0x06,
576 .awbR_L = 0x1c,
577 .awbG_H = 0x04,
578 .awbG_L = 0x00,
579 .awbB_H = 0x04,
580 .awbB_L = 0xf3,
581 },
582 /* Office. */
583 {
584 .lightMode = CAMERA_LIGHT_MODE_OFFICE,
585 .awbCtrl = 0x01,
586 .awbR_H = 0x05,
587 .awbR_L = 0x48,
588 .awbG_H = 0x04,
589 .awbG_L = 0x00,
590 .awbB_H = 0x07,
591 .awbB_L = 0xcf,
592 },
593 /* Cloudy. */
594 {
595 .lightMode = CAMERA_LIGHT_MODE_CLOUDY,
596 .awbCtrl = 0x01,
597 .awbR_H = 0x06,
598 .awbR_L = 0x48,
599 .awbG_H = 0x04,
600 .awbG_L = 0x00,
601 .awbB_H = 0x04,
602 .awbB_L = 0xd3,
603 },
604 /* Home. */
605 {
606 .lightMode = CAMERA_LIGHT_MODE_HOME,
607 .awbCtrl = 0x01,
608 .awbR_H = 0x04,
609 .awbR_L = 0x10,
610 .awbG_H = 0x04,
611 .awbG_L = 0x00,
612 .awbB_H = 0x08,
613 .awbB_L = 0x40,
614 },
615};
616
617static const ov5640_special_effect_config_t s_ov5640SpecialEffectConfigs[] = {
618 /* Normal. */
619 {
620 .effect = CAMERA_SPECIAL_EFFECT_NORMAL,
621 .sdeCtrl0 = 0x06,
622 .sdeCtrl3 = 0x40,
623 .sdeCtrl4 = 0x10,
624 },
625 /* Bluish. */
626 {
627 .effect = CAMERA_SPECIAL_EFFECT_BLUISH,
628 .sdeCtrl0 = 0x1e,
629 .sdeCtrl3 = 0xa0,
630 .sdeCtrl4 = 0x40,
631 },
632 /* Redish. */
633 {
634 .effect = CAMERA_SPECIAL_EFFECT_REDISH,
635 .sdeCtrl0 = 0x1e,
636 .sdeCtrl3 = 0x80,
637 .sdeCtrl4 = 0xc0,
638 },
639 /* B & W */
640 {
641 .effect = CAMERA_SPECIAL_EFFECT_BW,
642 .sdeCtrl0 = 0x1e,
643 .sdeCtrl3 = 0x80,
644 .sdeCtrl4 = 0x80,
645 },
646 /* Sepia. */
647 {
648 .effect = CAMERA_SPECIAL_EFFECT_SEPIA,
649 .sdeCtrl0 = 0x1e,
650 .sdeCtrl3 = 0x40,
651 .sdeCtrl4 = 0xa0,
652 },
653 /* Negtive. */
654 {
655 .effect = CAMERA_SPECIAL_EFFECT_NEGTIVE,
656 .sdeCtrl0 = 0x40,
657 .sdeCtrl3 = 0x40,
658 .sdeCtrl4 = 0x10,
659 },
660 /* Greenish. */
661 {
662 .effect = CAMERA_SPECIAL_EFFECT_GREENISH,
663 .sdeCtrl0 = 0x1e,
664 .sdeCtrl3 = 0x60,
665 .sdeCtrl4 = 0x60,
666 },
667};
668
669static const ov5640_cmd_func_map_t s_ov5640CmdFuncMap[] = {
670 {
671 kCAMERA_DeviceLightMode,
672 OV5640_SetLightMode,
673 },
674 {
675 kCAMERA_DeviceSaturation,
676 OV5640_SetSaturation,
677 },
678 {
679 kCAMERA_DeviceBrightness,
680 OV5640_SetBrightness,
681 },
682 {
683 kCAMERA_DeviceContrast,
684 OV5640_SetContrast,
685 },
686 {
687 kCAMERA_DeviceSpecialEffect,
688 OV5640_SetSpecialEffect,
689 },
690};
691
692const camera_device_operations_t ov5640_ops = {
693 .init = OV5640_Init,
694 .deinit = OV5640_Deinit,
695 .start = OV5640_Start,
696 .stop = OV5640_Stop,
697 .control = OV5640_Control,
698 .init_ext = OV5640_InitExt,
699};
700
701/*******************************************************************************
702 * Code
703 ******************************************************************************/
704
705static status_t OV5640_LoadRegVal(camera_device_handle_t *handle, const ov5640_reg_val_t regVal[], uint32_t num)
706{
707 uint32_t i;
708 status_t status;
709
710 for (i = 0; i < num; i++)
711 {
712 status = OV5640_WriteReg(handle, regVal[i].regAddr, regVal[i].regVal);
713
714 if (kStatus_Success != status)
715 {
716 return status;
717 }
718 }
719
720 return kStatus_Success;
721}
722
723static status_t OV5640_SoftwareReset(camera_device_handle_t *handle)
724{
725 ov5640_reg_val_t param[] = {{0x3103, 0x11}, {0x3008, 0x82}};
726
727 return OV5640_LoadRegVal(handle, param, ARRAY_SIZE(param));
728}
729
730static const uint8_t *OV5640_GetResolutionParam(uint32_t resolution)
731{
732 /*
733 * This function returns the parameter for specific resolution, if
734 * the resolution is not supported, returns NULL.
735 */
736 uint32_t i;
737
738 for (i = 0; i < ARRAY_SIZE(resolutionParam); i++)
739 {
740 if (resolution == resolutionParam[i].resolution)
741 {
742 return resolutionParam[i].param;
743 }
744 }
745
746 return NULL;
747}
748
749static const ov5640_clock_config_t *OV5640_GetClockConfig(const camera_config_t *config)
750{
751 uint32_t i;
752
753 if (kCAMERA_InterfaceMIPI == config->interface)
754 {
755 for (i = 0; i < ARRAY_SIZE(s_ov5640MipiClockConfigs); i++)
756 {
757 if ((config->framePerSec == s_ov5640MipiClockConfigs[i].framePerSec) &&
758 (config->resolution == s_ov5640MipiClockConfigs[i].resolution))
759 {
760 return &s_ov5640MipiClockConfigs[i];
761 }
762 }
763 }
764 else
765 {
766 for (i = 0; i < ARRAY_SIZE(s_ov5640DvpClockConfigs); i++)
767 {
768 if ((config->framePerSec == s_ov5640DvpClockConfigs[i].framePerSec) &&
769 (config->resolution == s_ov5640DvpClockConfigs[i].resolution))
770 {
771 return &s_ov5640DvpClockConfigs[i];
772 }
773 }
774 }
775
776 return NULL;
777}
778
779static status_t OV5640_SetPixelFormat(camera_device_handle_t *handle, video_pixel_format_t pixelFormat)
780{
781 status_t status;
782 uint8_t param[2];
783
784 switch (pixelFormat)
785 {
786 case kVIDEO_PixelFormatYUYV:
787 param[0] = 0x3F;
788 param[1] = 0x00;
789 break;
790
791 case kVIDEO_PixelFormatRGB565:
792 default:
793 param[0] = 0x6f;
794 param[1] = 0x01;
795 break;
796 }
797
798 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x4300, param[0]));
799 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x501f, param[1]));
800
801 return kStatus_Success;
802}
803
804status_t OV5640_Init(camera_device_handle_t *handle, const camera_config_t *config)
805{
806 status_t status;
807 ov5640_resource_t *resource = (ov5640_resource_t *)(handle->resource);
808 uint8_t reg;
809 const ov5640_clock_config_t *clockConfig;
810
811 /* Verify the configuration. */
812 const uint8_t *resParam = OV5640_GetResolutionParam(config->resolution);
813
814 if (NULL == resParam)
815 {
816 return kStatus_InvalidArgument;
817 }
818
819 if ((kVIDEO_PixelFormatYUYV != config->pixelFormat) && (kVIDEO_PixelFormatRGB565 != config->pixelFormat))
820 {
821 return kStatus_InvalidArgument;
822 }
823
824 if ((kCAMERA_InterfaceNonGatedClock != config->interface) && (kCAMERA_InterfaceGatedClock != config->interface) &&
825 (kCAMERA_InterfaceCCIR656 != config->interface) && (kCAMERA_InterfaceMIPI != config->interface))
826 {
827 return kStatus_InvalidArgument;
828 }
829
830 /* Only support 2 data lanes. */
831 if ((kCAMERA_InterfaceMIPI == config->interface) && (2U != config->csiLanes))
832 {
833 return kStatus_InvalidArgument;
834 }
835
836 clockConfig = OV5640_GetClockConfig(config);
837
838 if (NULL == clockConfig)
839 {
840 return kStatus_InvalidArgument;
841 }
842
843 resource->pullPowerDownPin(true);
844 resource->pullResetPin(false);
845
846 /* Delay 5ms. */
847 OV5640_DelayMs(5);
848
849 resource->pullPowerDownPin(false);
850
851 /* Delay 1ms. */
852 OV5640_DelayMs(1);
853
854 resource->pullResetPin(true);
855
856 /* Delay 20ms. */
857 OV5640_DelayMs(20);
858
859 OV5640_CHECK_RET(OV5640_SoftwareReset(handle));
860
861 /* Delay 5ms. */
862 OV5640_DelayMs(5);
863
864 /* Initialize. */
865 status = OV5640_LoadRegVal(handle, ov5640InitParam, ARRAY_SIZE(ov5640InitParam));
866 if (kStatus_Success != status)
867 {
868 return status;
869 }
870
871 /* Resolution. */
872 OV5640_CHECK_RET(OV5640_WriteMultiRegs(handle, 0x3800, resParam, OV5640_RESOLUTION_PARAM_NUM));
873
874 if ((uint32_t)kVIDEO_Resolution1080P == config->resolution)
875 {
876 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3709, 0x12));
877 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3821, 0x06));
878 }
879
880 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x302c, 0xc2));
881
882 /* Pixel format. */
883 OV5640_CHECK_RET(OV5640_SetPixelFormat(handle, config->pixelFormat));
884
885 /* Clock. */
886 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3035, clockConfig->pllCtrl1));
887 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3036, clockConfig->pllCtrl2));
888 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x460c, clockConfig->vfifoCtrl0C));
889 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3824, clockConfig->pclkDiv));
890 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x4837, clockConfig->pclkPeriod));
891
892 /* Interface. */
893 if (kCAMERA_InterfaceMIPI == config->interface)
894 {
895 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3034, 0x18));
896
897 /* Set Frex, Vsync, Href, PCLK, data, GPIO to input. */
898 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3017, 0x00));
899 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3018, 0x00));
900
901 /*
902 * Set to MIPI mode, set data lane. Currently only support 2 data lanes,
903 * if need to use 1 data lane, write 0x25 to register 0x300e.
904 */
905 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x300e, 0x45));
906
907 /* Virtual channel. */
908 OV5640_CHECK_RET(OV5640_ModifyReg(handle, 0x4814, (3U << 6), (uint8_t)(config->mipiChannel) << 6));
909
910 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x4800, 0x04));
911 }
912 else
913 {
914 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3034, 0x1a));
915
916 /* Set Frex, Vsync, Href, PCLK, data, GPIO to output. */
917 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3017, 0xFF));
918 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3018, 0xFF));
919
920 /* DVP mode */
921 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x300e, 0x58));
922
923 if (kCAMERA_InterfaceCCIR656 == config->interface)
924 {
925 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x4719, 0x01));
926 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x4730, 0x01));
927 }
928 }
929
930 /* Signal polarity */
931 reg = 0;
932 if ((uint32_t)kCAMERA_HrefActiveHigh != (config->controlFlags & (uint32_t)kCAMERA_HrefActiveHigh))
933 {
934 reg |= OV5640_POLARITY_CTRL00_HREF_MASK;
935 }
936 if ((uint32_t)kCAMERA_VsyncActiveHigh != (config->controlFlags & (uint32_t)kCAMERA_VsyncActiveHigh))
937 {
938 reg |= OV5640_POLARITY_CTRL00_VSYNC_MASK;
939 }
940 if ((uint32_t)kCAMERA_DataLatchOnRisingEdge == (config->controlFlags & (uint32_t)kCAMERA_DataLatchOnRisingEdge))
941 {
942 reg |= OV5640_POLARITY_CTRL00_PCLK_MASK;
943 }
944
945 if (kCAMERA_InterfaceNonGatedClock == config->interface)
946 {
947 reg |= OV5640_POLARITY_CTRL00_GATE_PCLK_HREF_MASK | OV5640_POLARITY_CTRL00_GATE_PCLK_VSYNC_MASK;
948 }
949
950 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x4740, reg));
951
952 /* Lenc on, raw gamma on, BPC on, WPC on, CIP on. */
953 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x5000, 0xa7));
954
955 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3008, 0x02));
956
957 return kStatus_Success;
958}
959
960status_t OV5640_Deinit(camera_device_handle_t *handle)
961{
962 ((ov5640_resource_t *)(handle->resource))->pullPowerDownPin(true);
963
964 return kStatus_Success;
965}
966
967status_t OV5640_Control(camera_device_handle_t *handle, camera_device_cmd_t cmd, int32_t arg)
968{
969 for (uint8_t i = 0; i < ARRAY_SIZE(s_ov5640CmdFuncMap); i++)
970 {
971 if (s_ov5640CmdFuncMap[i].cmd == cmd)
972 {
973 return s_ov5640CmdFuncMap[i].func(handle, arg);
974 }
975 }
976
977 return kStatus_InvalidArgument;
978}
979
980status_t OV5640_Start(camera_device_handle_t *handle)
981{
982 return OV5640_WriteReg(handle, 0x3008, 0x02);
983}
984
985status_t OV5640_Stop(camera_device_handle_t *handle)
986{
987 return OV5640_WriteReg(handle, 0x3008, 0x42);
988}
989
990status_t OV5640_InitExt(camera_device_handle_t *handle, const camera_config_t *config, const void *specialConfig)
991{
992 return OV5640_Init(handle, config);
993}
994
995status_t OV5640_SetBrightness(camera_device_handle_t *handle, int32_t brightness)
996{
997 status_t status;
998
999 if ((brightness < -4) || (brightness > 4))
1000 {
1001 return kStatus_InvalidArgument;
1002 }
1003
1004 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x03));
1005 if (brightness >= 0)
1006 {
1007 status = OV5640_WriteReg(handle, OV5640_SDE_CTRL8_REG, 0x01);
1008 }
1009 else
1010 {
1011 brightness = -brightness;
1012 status = OV5640_WriteReg(handle, OV5640_SDE_CTRL8_REG, 0x09);
1013 }
1014
1015 if (kStatus_Success != status)
1016 {
1017 return status;
1018 }
1019
1020 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL7_REG, ((uint8_t)brightness) << 4U));
1021
1022 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x13));
1023 return OV5640_WriteReg(handle, 0x3212, 0xa3);
1024}
1025
1026status_t OV5640_SetContrast(camera_device_handle_t *handle, int32_t contrast)
1027{
1028 status_t status;
1029 uint8_t regVal;
1030
1031 if ((-4 > contrast) || (4 < contrast))
1032 {
1033 return kStatus_InvalidArgument;
1034 }
1035
1036 contrast = 0x20 + contrast * 0x04;
1037 regVal = (uint8_t)contrast;
1038
1039 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x03));
1040
1041 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL0_REG, 0x04));
1042 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL5_REG, regVal));
1043 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL6_REG, regVal));
1044
1045 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x13));
1046 return OV5640_WriteReg(handle, 0x3212, 0xa3);
1047}
1048
1049status_t OV5640_SetSaturation(camera_device_handle_t *handle, int32_t saturation)
1050{
1051 status_t status;
1052 uint8_t regVal;
1053
1054 if ((-4 > saturation) || (4 < saturation))
1055 {
1056 return kStatus_InvalidArgument;
1057 }
1058
1059 saturation = 0x40 + saturation * 0x10;
1060 regVal = (uint8_t)saturation;
1061
1062 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x03));
1063
1064 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL0_REG, 0x02));
1065 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL3_REG, regVal));
1066 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL4_REG, regVal));
1067 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL8_REG, 0x41));
1068
1069 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x13));
1070 return OV5640_WriteReg(handle, 0x3212, 0xa3);
1071}
1072
1073status_t OV5640_SetLightMode(camera_device_handle_t *handle, int32_t lightMode)
1074{
1075 status_t status;
1076 uint8_t i;
1077
1078 for (i = 0; i < ARRAY_SIZE(s_ov5640LightModeConfigs); i++)
1079 {
1080 if (lightMode == (int32_t)s_ov5640LightModeConfigs[i].lightMode)
1081 {
1082 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x03));
1083
1084 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_AWB_CTRL_REG, s_ov5640LightModeConfigs[i].awbCtrl));
1085 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_AWB_R_H_REG, s_ov5640LightModeConfigs[i].awbR_H));
1086 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_AWB_R_L_REG, s_ov5640LightModeConfigs[i].awbR_L));
1087 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_AWB_G_H_REG, s_ov5640LightModeConfigs[i].awbG_H));
1088 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_AWB_G_L_REG, s_ov5640LightModeConfigs[i].awbG_L));
1089 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_AWB_B_H_REG, s_ov5640LightModeConfigs[i].awbB_H));
1090 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_AWB_B_L_REG, s_ov5640LightModeConfigs[i].awbB_L));
1091
1092 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x13));
1093 return OV5640_WriteReg(handle, 0x3212, 0xa3);
1094 }
1095 }
1096
1097 /* No configuration found. */
1098 return kStatus_InvalidArgument;
1099}
1100
1101status_t OV5640_SetSpecialEffect(camera_device_handle_t *handle, int32_t effect)
1102{
1103 status_t status;
1104 uint8_t i;
1105
1106 for (i = 0; i < ARRAY_SIZE(s_ov5640SpecialEffectConfigs); i++)
1107 {
1108 if (effect == (int32_t)s_ov5640SpecialEffectConfigs[i].effect)
1109 {
1110 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x03));
1111
1112 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL0_REG, s_ov5640SpecialEffectConfigs[i].sdeCtrl0));
1113 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL3_REG, s_ov5640SpecialEffectConfigs[i].sdeCtrl3));
1114 OV5640_CHECK_RET(OV5640_WriteReg(handle, OV5640_SDE_CTRL4_REG, s_ov5640SpecialEffectConfigs[i].sdeCtrl4));
1115
1116 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x5003, 0x08));
1117 OV5640_CHECK_RET(OV5640_WriteReg(handle, 0x3212, 0x13));
1118 return OV5640_WriteReg(handle, 0x3212, 0xa3);
1119 }
1120 }
1121
1122 /* No configuration found. */
1123 return kStatus_InvalidArgument;
1124}
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/fsl_ov5640.h b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/fsl_ov5640.h
new file mode 100644
index 000000000..5ceb295af
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov5640/fsl_ov5640.h
@@ -0,0 +1,58 @@
1/*
2 * Copyright 2017-2018, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#ifndef _FSL_OV5640_H_
10#define _FSL_OV5640_H_
11
12#include "fsl_common.h"
13#include "fsl_sccb.h"
14
15/*
16 * Change log:
17 *
18 * 1.0.1
19 * - Fix MISRA-C 2012 issues.
20 *
21 * 1.0.0
22 * - Initial version
23 */
24
25/*******************************************************************************
26 * Definitions
27 ******************************************************************************/
28
29/*!
30 * @brief OV5640 resource.
31 *
32 * Before initialize the OV5640, the resource must be initialized that the SCCB
33 * I2C could start to work.
34 */
35typedef struct _ov5640_resource
36{
37 sccb_i2c_send_func_t i2cSendFunc; /*!< I2C send function. */
38 sccb_i2c_receive_func_t i2cReceiveFunc; /*!< I2C receive function. */
39 void (*pullResetPin)(bool pullUp); /*!< Function to pull reset pin high or low. */
40 void (*pullPowerDownPin)(bool pullUp); /*!< Function to pull the power down pin high or low. */
41} ov5640_resource_t;
42
43/*! @brief OV5640 operation functions. */
44extern const camera_device_operations_t ov5640_ops;
45
46/*******************************************************************************
47 * API
48 ******************************************************************************/
49
50#if defined(__cplusplus)
51extern "C" {
52#endif
53
54#if defined(__cplusplus)
55}
56#endif
57
58#endif /* _FSL_OV5640_H_ */
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov7725/driver_camera-device-ov7725.cmake b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov7725/driver_camera-device-ov7725.cmake
new file mode 100644
index 000000000..8f5979d21
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov7725/driver_camera-device-ov7725.cmake
@@ -0,0 +1,19 @@
1if(NOT DRIVER_CAMERA-DEVICE-OV7725_INCLUDED)
2
3 set(DRIVER_CAMERA-DEVICE-OV7725_INCLUDED true CACHE BOOL "driver_camera-device-ov7725 component is included.")
4
5 target_sources(${MCUX_SDK_PROJECT_NAME} PRIVATE
6 ${CMAKE_CURRENT_LIST_DIR}/fsl_ov7725.c
7 )
8
9 target_include_directories(${MCUX_SDK_PROJECT_NAME} PRIVATE
10 ${CMAKE_CURRENT_LIST_DIR}/.
11 )
12
13
14 include(driver_camera-device-sccb)
15 include(driver_camera-common)
16 include(driver_video-common)
17 include(driver_camera-device-common)
18
19endif() \ No newline at end of file
diff --git a/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov7725/fsl_ov7725.c b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov7725/fsl_ov7725.c
new file mode 100644
index 000000000..87a437c26
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/components/video/camera/device/ov7725/fsl_ov7725.c
@@ -0,0 +1,655 @@
1/*
2 * Copyright 2017-2018, 2020 NXP
3 * All rights reserved.
4 *
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
9#include "fsl_video_common.h"
10#include "fsl_camera.h"
11#include "fsl_camera_device.h"
12#include "fsl_ov7725.h"
13
14/*******************************************************************************
15 * Definitions
16 ******************************************************************************/
17#define OV7725_SCCB_ADDR 0x21U
18#define OV7725_REVISION 0x7721U
19
20#define OV7725_WriteReg(handle, reg, val) \
21 SCCB_WriteReg(OV7725_SCCB_ADDR, kSCCB_RegAddr8Bit, (reg), (val), \
22 ((ov7725_resource_t *)((handle)->resource))->i2cSendFunc)
23
24#define OV7725_ReadReg(handle, reg, val) \
25 SCCB_ReadReg(OV7725_SCCB_ADDR, kSCCB_RegAddr8Bit, (reg), (val), \
26 ((ov7725_resource_t *)((handle)->resource))->i2cReceiveFunc)
27
28#define OV7725_ModifyReg(handle, reg, clrMask, val) \
29 SCCB_ModifyReg(OV7725_SCCB_ADDR, kSCCB_RegAddr8Bit, (reg), (clrMask), (val), \
30 ((ov7725_resource_t *)((handle)->resource))->i2cReceiveFunc, \
31 ((ov7725_resource_t *)((handle)->resource))->i2cSendFunc)
32
33#define OV7725_CHECK_RET(x) \
34 do \
35 { \
36 status = (x); \
37 if (kStatus_Success != status) \
38 { \
39 return status; \
40 } \
41 } while (false)
42
43typedef struct _ov7725_clock_config
44{
45 uint32_t frameRate_Hz;
46 uint32_t inputClk_Hz;
47 uint8_t clkrc; /*!< Register CLKRC. */
48 uint8_t com4; /*!< Register COM4. */
49 uint8_t dm_lnl; /*!< Register DM_LNL. */
50} ov7725_clock_config_t;
51
52typedef struct _ov7725_light_mode
53{
54 uint8_t lightMode;
55 uint8_t com8;
56 uint8_t blue;
57 uint8_t red;
58 uint8_t com5;
59} ov7725_light_mode_config_t;
60
61typedef struct _ov7725_special_effect_config
62{
63 uint8_t effect;
64 uint8_t sde;
65 uint8_t ufix;
66 uint8_t vfix;
67} ov7725_special_effect_config_t;
68
69typedef struct _ov7725_night_mode
70{
71 uint8_t nightMode;
72 uint8_t com5;
73} ov7725_night_mode_t;
74
75typedef struct _ov7725_pixel_format_config
76{
77 video_pixel_format_t fmt;
78 uint8_t com7;
79} ov7725_pixel_format_config_t;
80
81typedef status_t (*ov7725_cmd_func_t)(camera_device_handle_t *handle, int32_t arg);
82
83typedef struct _ov7725_cmd_func_map
84{
85 camera_device_cmd_t cmd;
86 ov7725_cmd_func_t func;
87} ov7725_cmd_func_map_t;
88
89typedef struct _ov7725_reg
90{
91 uint8_t reg;
92 uint8_t val;
93} ov7725_reg_t;
94
95/*******************************************************************************
96 * Prototypes
97 ******************************************************************************/
98status_t OV7725_Init(camera_device_handle_t *handle, const camera_config_t *config);
99
100status_t OV7725_InitExt(camera_device_handle_t *handle, const camera_config_t *config, const void *specialConfig);
101
102status_t OV7725_Deinit(camera_device_handle_t *handle);
103
104status_t OV7725_Control(camera_device_handle_t *handle, camera_device_cmd_t cmd, int32_t arg);
105
106status_t OV7725_Start(camera_device_handle_t *handle);
107
108status_t OV7725_Stop(camera_device_handle_t *handle);
109
110status_t OV7725_SetSpecialEffect(camera_device_handle_t *handle, int32_t effect);
111
112status_t OV7725_SetLightMode(camera_device_handle_t *handle, int32_t lightMode);
113
114status_t OV7725_SetNightMode(camera_device_handle_t *handle, int32_t nightMode);
115
116status_t OV7725_SetSaturation(camera_device_handle_t *handle, int32_t saturation);
117
118status_t OV7725_SetContrast(camera_device_handle_t *handle, int32_t contrast);
119
120status_t OV7725_SetBrightness(camera_device_handle_t *handle, int32_t brightness);
121
122/*******************************************************************************
123 * Variables
124 ******************************************************************************/
125const camera_device_operations_t ov7725_ops = {
126 .init = OV7725_Init,
127 .deinit = OV7725_Deinit,
128 .start = OV7725_Start,
129 .stop = OV7725_Stop,
130 .control = OV7725_Control,
131 .init_ext = OV7725_InitExt,
132};
133
134static const ov7725_clock_config_t ov7725ClockConfigs[] = {
135 /* FrameRate, inputClk, clkrc, com4, dm_lnl. */
136 {.frameRate_Hz = 30, .inputClk_Hz = 24000000, .clkrc = 0x01, .com4 = 0x41, .dm_lnl = 0x00},
137 {.frameRate_Hz = 15, .inputClk_Hz = 24000000, .clkrc = 0x03, .com4 = 0x41, .dm_lnl = 0x00},
138 {.frameRate_Hz = 25, .inputClk_Hz = 24000000, .clkrc = 0x01, .com4 = 0x41, .dm_lnl = 0x66},
139 {.frameRate_Hz = 14, .inputClk_Hz = 24000000, .clkrc = 0x03, .com4 = 0x41, .dm_lnl = 0x1a},
140 {.frameRate_Hz = 30, .inputClk_Hz = 26000000, .clkrc = 0x01, .com4 = 0x41, .dm_lnl = 0x2b},
141 {.frameRate_Hz = 15, .inputClk_Hz = 26000000, .clkrc = 0x03, .com4 = 0x41, .dm_lnl = 0x2b},
142 {.frameRate_Hz = 25, .inputClk_Hz = 26000000, .clkrc = 0x01, .com4 = 0x41, .dm_lnl = 0x99},
143 {.frameRate_Hz = 14, .inputClk_Hz = 26000000, .clkrc = 0x03, .com4 = 0x41, .dm_lnl = 0x46},
144 {.frameRate_Hz = 30, .inputClk_Hz = 13000000, .clkrc = 0x00, .com4 = 0x41, .dm_lnl = 0x2b},
145 {.frameRate_Hz = 15, .inputClk_Hz = 13000000, .clkrc = 0x01, .com4 = 0x41, .dm_lnl = 0x2b},
146 {.frameRate_Hz = 25, .inputClk_Hz = 13000000, .clkrc = 0x00, .com4 = 0x41, .dm_lnl = 0x99},
147 {.frameRate_Hz = 14, .inputClk_Hz = 13000000, .clkrc = 0x01, .com4 = 0x41, .dm_lnl = 0x46},
148};
149
150static const ov7725_special_effect_config_t ov7725SpecialEffectConfigs[] = {
151 /* Normal. */
152 {.effect = CAMERA_SPECIAL_EFFECT_NORMAL, .sde = 0x06, .ufix = 0x80, .vfix = 0x80},
153 /* B & W */
154 {.effect = CAMERA_SPECIAL_EFFECT_BW, .sde = 0x26, .ufix = 0x80, .vfix = 0x80},
155 /* Sepia. */
156 {.effect = CAMERA_SPECIAL_EFFECT_SEPIA, .sde = 0x1e, .ufix = 0x40, .vfix = 0xa0},
157 /* Bluish. */
158 {.effect = CAMERA_SPECIAL_EFFECT_BLUISH, .sde = 0x1e, .ufix = 0xa0, .vfix = 0x40},
159 /* Redish. */
160 {.effect = CAMERA_SPECIAL_EFFECT_REDISH, .sde = 0x1e, .ufix = 0x80, .vfix = 0x40},
161 /* Greenish. */
162 {.effect = CAMERA_SPECIAL_EFFECT_GREENISH, .sde = 0x1e, .ufix = 0x60, .vfix = 0x60},
163 /* Negtive. */
164 {.effect = CAMERA_SPECIAL_EFFECT_NEGTIVE, .sde = 0x46, .ufix = 0x00, .vfix = 0x00},
165};
166
167static const ov7725_light_mode_config_t ov7725LightModeConfigs[] = {
168 /* Auto. */
169 {.lightMode = CAMERA_LIGHT_MODE_AUTO, .com8 = 0xff, .blue = 0x80, .red = 0x80, .com5 = 0x65},
170 /* Sunny. */
171 {.lightMode = CAMERA_LIGHT_MODE_SUNNY, .com8 = 0xfd, .blue = 0x5a, .red = 0x5c, .com5 = 0x65},
172 /* Cloudy. */
173 {.lightMode = CAMERA_LIGHT_MODE_CLOUDY, .com8 = 0xfd, .blue = 0x58, .red = 0x60, .com5 = 0x65},
174 /* Office. */
175 {.lightMode = CAMERA_LIGHT_MODE_OFFICE, .com8 = 0xfd, .blue = 0x84, .red = 0x4c, .com5 = 0x65},
176 /* Home. */
177 {.lightMode = CAMERA_LIGHT_MODE_HOME, .com8 = 0xfd, .blue = 0x96, .red = 0x40, .com5 = 0x65},
178 /* Night. */
179 {.lightMode = CAMERA_LIGHT_MODE_NIGHT, .com8 = 0xff, .blue = 0x80, .red = 0x80, .com5 = 0xe5}};
180
181static const ov7725_pixel_format_config_t ov7725PixelFormatConfigs[] = {
182 {.fmt = kVIDEO_PixelFormatYUYV, .com7 = (0)},
183 {.fmt = kVIDEO_PixelFormatRGB565, .com7 = (1 << 2) | (2)},
184 {.fmt = kVIDEO_PixelFormatXRGB1555, .com7 = (2 << 2) | (2)},
185 {.fmt = kVIDEO_PixelFormatXRGB4444, .com7 = (3 << 2) | (2)}};
186
187static const ov7725_night_mode_t ov7725NightModeConfigs[] = {
188 {.nightMode = CAMERA_NIGHT_MODE_DISABLED, .com5 = 0},
189 {.nightMode = CAMERA_NIGHT_MODE_AUTO_FR_DIVBY2, .com5 = 8 | (1 << 4)},
190 {.nightMode = CAMERA_NIGHT_MODE_AUTO_FR_DIVBY4, .com5 = 8 | (2 << 4)},
191 {.nightMode = CAMERA_NIGHT_MODE_AUTO_FR_DIVBY8, .com5 = 8 | (3 << 4)}};
192
193static const ov7725_cmd_func_map_t ov7725CmdFuncMap[] = {
194 {
195 kCAMERA_DeviceLightMode,
196 OV7725_SetLightMode,
197 },
198 {
199 kCAMERA_DeviceSaturation,
200 OV7725_SetSaturation,
201 },
202 {
203 kCAMERA_DeviceBrightness,
204 OV7725_SetBrightness,
205 },
206 {
207 kCAMERA_DeviceContrast,
208 OV7725_SetContrast,
209 },
210 {
211 kCAMERA_DeviceSpecialEffect,
212 OV7725_SetSpecialEffect,
213 },
214 {
215 kCAMERA_DeviceNightMode,
216 OV7725_SetNightMode,
217 },
218};
219
220static const ov7725_reg_t ov7725InitRegs[] = {
221 {0x3d, 0x03},
222 {0x42, 0x7f},
223 {0x4d, 0x09},
224
225 /* DSP */
226 {0x64, 0xff},
227 {0x65, 0x20},
228 {0x66, 0x00},
229 {0x67, 0x48},
230 {0x0f, 0xc5},
231 {0x13, 0xff},
232
233 /* AEC/AGC/AWB */
234 {0x63, 0xe0},
235 {0x14, 0x11},
236 {0x22, 0x3f},
237 {0x23, 0x07},
238 {0x24, 0x40},
239 {0x25, 0x30},
240 {0x26, 0xa1},
241 {0x2b, 0x00},
242 {0x6b, 0xaa},
243 {0x0d, 0x41},
244
245 /* Sharpness. */
246 {0x90, 0x05},
247 {0x91, 0x01},
248 {0x92, 0x03},
249 {0x93, 0x00},
250
251 /* Matrix. */
252 {0x94, 0x90},
253 {0x95, 0x8a},
254 {0x96, 0x06},
255 {0x97, 0x0b},
256 {0x98, 0x95},
257 {0x99, 0xa0},
258 {0x9a, 0x1e},
259
260 /* Brightness. */
261 {0x9b, 0x08},
262 /* Contrast. */
263 {0x9c, 0x20},
264 /* UV */
265 {0x9e, 0x81},
266 /* DSE */
267 {0xa6, 0x04},
268
269 /* Gamma. */
270 {0x7e, 0x0c},
271 {0x7f, 0x16},
272 {0x80, 0x2a},
273 {0x81, 0x4e},
274 {0x82, 0x61},
275 {0x83, 0x6f},
276 {0x84, 0x7b},
277 {0x85, 0x86},
278 {0x86, 0x8e},
279 {0x87, 0x97},
280 {0x88, 0xa4},
281 {0x89, 0xaf},
282 {0x8a, 0xc5},
283 {0x8b, 0xd7},
284 {0x8c, 0xe8},
285};
286
287/*******************************************************************************
288 * Code
289 ******************************************************************************/
290
291static void OV7725_DelayMs(uint32_t ms)
292{
293 VIDEO_DelayMs(ms);
294}
295
296static status_t OV7725_WriteRegs(camera_device_handle_t *handle, const ov7725_reg_t regs[], uint32_t num)
297{
298 status_t status = kStatus_Success;
299
300 for (uint32_t i = 0; i < num; i++)
301 {
302 status = OV7725_WriteReg(handle, regs[i].reg, regs[i].val);
303
304 if (kStatus_Success != status)
305 {
306 break;
307 }
308 }
309
310 return status;
311}
312
313static status_t OV7725_SoftwareReset(camera_device_handle_t *handle)
314{
315 return OV7725_WriteReg(handle, OV7725_COM7_REG, 0x80);
316}
317
318static status_t OV7725_SetClockConfig(camera_device_handle_t *handle, uint32_t frameRate_Hz, uint32_t inputClk_Hz)
319{
320 status_t status;
321
322 for (uint32_t i = 0; i < ARRAY_SIZE(ov7725ClockConfigs); i++)
323 {
324 if ((ov7725ClockConfigs[i].frameRate_Hz == frameRate_Hz) && (ov7725ClockConfigs[i].inputClk_Hz == inputClk_Hz))
325 {
326 OV7725_CHECK_RET(OV7725_WriteReg(handle, OV7725_CLKRC_REG, ov7725ClockConfigs[i].clkrc));
327 OV7725_CHECK_RET(OV7725_ModifyReg(handle, OV7725_COM4_REG, 0xC0, ov7725ClockConfigs[i].com4));
328 OV7725_CHECK_RET(OV7725_WriteReg(handle, OV7725_EXHCL_REG, 0x00));
329 OV7725_CHECK_RET(OV7725_WriteReg(handle, OV7725_DM_LNL_REG, ov7725ClockConfigs[i].dm_lnl));
330 OV7725_CHECK_RET(OV7725_WriteReg(handle, OV7725_DM_LNH_REG, 0x00));
331 OV7725_CHECK_RET(OV7725_WriteReg(handle, OV7725_ADVFL_REG, 0x00));
332 OV7725_CHECK_RET(OV7725_WriteReg(handle, OV7725_ADVFH_REG, 0x00));
333 return OV7725_WriteReg(handle, OV7725_COM5_REG, 0x65);
334 }
335 }
336
337 return kStatus_InvalidArgument;
338}
339
340static status_t OV7725_SetPixelFormat(camera_device_handle_t *handle, video_pixel_format_t fmt)
341{
342 for (uint8_t i = 0; i < ARRAY_SIZE(ov7725PixelFormatConfigs); i++)
343 {
344 if (ov7725PixelFormatConfigs[i].fmt == fmt)
345 {
346 return OV7725_ModifyReg(handle, OV7725_COM7_REG, 0x1FU, ov7725PixelFormatConfigs[i].com7);
347 }
348 }
349
350 return kStatus_InvalidArgument;
351}
352
353status_t OV7725_Init(camera_device_handle_t *handle, const camera_config_t *config)
354{
355 status_t status;
356 uint8_t pid = 0U, ver = 0U;
357 uint8_t com10 = 0;
358 uint8_t tmpReg;
359 uint16_t width, height;
360 uint16_t hstart, vstart, hsize;
361 ov7725_resource_t *resource = (ov7725_resource_t *)(handle->resource);
362
363 if ((kCAMERA_InterfaceNonGatedClock != config->interface) && (kCAMERA_InterfaceGatedClock != config->interface) &&
364 (kCAMERA_InterfaceCCIR656 != config->interface))
365 {
366 return kStatus_InvalidArgument;
367 }
368
369 width = FSL_VIDEO_EXTRACT_WIDTH(config->resolution);
370 height = FSL_VIDEO_EXTRACT_HEIGHT(config->resolution);
371
372 if ((width > 640U) || (height > 480U))
373 {
374 return kStatus_InvalidArgument;
375 }
376
377 resource->pullPowerDownPin(true);
378
379 /* Delay 1ms. */
380 OV7725_DelayMs(1);
381
382 resource->pullPowerDownPin(false);
383
384 /* Delay 1ms. */
385 OV7725_DelayMs(1);
386
387 resource->pullResetPin(false);
388
389 /* Delay 1ms. */
390 OV7725_DelayMs(1);
391
392 resource->pullResetPin(true);
393
394 /* Delay 1ms. */
395 OV7725_DelayMs(1);
396
397 /* Identify the device. */
398 status = OV7725_ReadReg(handle, OV7725_PID_REG, &pid);
399 if (kStatus_Success != status)
400 {
401 return status;
402 }
403
404 status = OV7725_ReadReg(handle, OV7725_VER_REG, &ver);
405 if (kStatus_Success != status)
406 {
407 return status;
408 }
409
410 if (OV7725_REVISION != (((uint32_t)pid << 8U) | (uint32_t)ver))
411 {
412 return kStatus_Fail;
413 }
414
415 /* Device identify OK, perform software reset. */
416 OV7725_CHECK_RET(OV7725_SoftwareReset(handle));
417
418 /* Delay 2ms. */
419 OV7725_DelayMs(2);
420
421 /* Start configuration */
422 status = OV7725_WriteRegs(handle, ov7725InitRegs, ARRAY_SIZE(ov7725InitRegs));
423 if (kStatus_Success != status)
424 {
425 return status;
426 }
427
428 /* Clock setting. */
429 status = OV7725_SetClockConfig(handle, config->framePerSec, resource->inputClockFreq_Hz);
430 if (kStatus_Success != status)
431 {
432 return status;
433 }
434
435 /* Pixel format setting. */
436 status = OV7725_SetPixelFormat(handle, config->pixelFormat);
437 if (kStatus_Success != status)
438 {
439 return status;
440 }
441
442 if (kCAMERA_InterfaceCCIR656 == config->interface)
443 {
444 status = OV7725_ModifyReg(handle, OV7725_COM7_REG, (1U << 5), (1U << 5));
445 width += 2U;