Skip to content

Commit ae7df3d

Browse files
committed
Mirror and flip handled before the video processor, and exposure setting on infinity6
1 parent 4a45f82 commit ae7df3d

File tree

5 files changed

+70
-9
lines changed

5 files changed

+70
-9
lines changed

src/hal/star/i6_hal.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,13 @@ int i6_channel_bind(char index, char framerate)
170170
return EXIT_SUCCESS;
171171
}
172172

173-
int i6_channel_create(char index, short width, short height, char mirror, char flip, char jpeg)
173+
int i6_channel_create(char index, short width, short height, char jpeg)
174174
{
175175
i6_vpe_port port;
176176
port.output.width = width;
177177
port.output.height = height;
178-
port.mirror = mirror;
179-
port.flip = flip;
178+
port.mirror = 0;
179+
port.flip = 0;
180180
port.compress = I6_COMPR_NONE;
181181
port.pixFmt = jpeg ? I6_PIXFMT_YUV422_YUYV : I6_PIXFMT_YUV420SP;
182182

@@ -215,7 +215,7 @@ int i6_config_load(char *path)
215215
return i6_isp.fnLoadChannelConfig(_i6_isp_chn, path, 1234);
216216
}
217217

218-
int i6_pipeline_create(char sensor, short width, short height, char framerate)
218+
int i6_pipeline_create(char sensor, short width, short height, char mirror, char flip, char framerate)
219219
{
220220
int ret;
221221

@@ -251,6 +251,9 @@ int i6_pipeline_create(char sensor, short width, short height, char framerate)
251251
return EXIT_FAILURE;
252252
}
253253

254+
if (ret = i6_snr.fnSetOrientation(_i6_snr_index, mirror, flip))
255+
return ret;
256+
254257
if (ret = i6_snr.fnGetPadInfo(_i6_snr_index, &_i6_snr_pad))
255258
return ret;
256259
if (ret = i6_snr.fnGetPlaneInfo(_i6_snr_index, 0, &_i6_snr_plane))
@@ -473,6 +476,23 @@ int i6_region_setbitmap(int handle, hal_bitmap *bitmap)
473476
return i6_rgn.fnSetBitmap(handle, &nativeBmp);
474477
}
475478

479+
int i6_sensor_exposure(unsigned int micros)
480+
{
481+
int ret;
482+
483+
{
484+
i6_isp_exp config;
485+
if (ret = i6_isp.fnGetExposureLimit(0, &config))
486+
return ret;
487+
488+
config.maxShutterUs = micros;
489+
if (ret = i6_isp.fnSetExposureLimit(0, &config))
490+
return ret;
491+
}
492+
493+
return ret;
494+
}
495+
476496
int i6_video_create(char index, hal_vidconfig *config)
477497
{
478498
int ret;

src/hal/star/i6_hal.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,13 +30,13 @@ int i6_audio_init(int samplerate, int gain);
3030
void *i6_audio_thread(void);
3131

3232
int i6_channel_bind(char index, char framerate);
33-
int i6_channel_create(char index, short width, short height, char mirror, char flip, char jpeg);
33+
int i6_channel_create(char index, short width, short height, char jpeg);
3434
int i6_channel_grayscale(char enable);
3535
int i6_channel_unbind(char index);
3636

3737
int i6_config_load(char *path);
3838

39-
int i6_pipeline_create(char sensor, short width, short height, char framerate);
39+
int i6_pipeline_create(char sensor, short width, short height, char mirror, char flip, char framerate);
4040
void i6_pipeline_destroy(void);
4141

4242
int i6_region_create(char handle, hal_rect rect, short opacity);
@@ -45,6 +45,8 @@ void i6_region_destroy(char handle);
4545
void i6_region_init(void);
4646
int i6_region_setbitmap(int handle, hal_bitmap *bitmap);
4747

48+
int i6_sensor_exposure(unsigned int micros);
49+
4850
int i6_video_create(char index, hal_vidconfig *config);
4951
int i6_video_destroy(char index);
5052
int i6_video_destroy_all(void);

src/hal/star/i6_isp.h

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,30 @@
22

33
#include "i6_common.h"
44

5+
typedef struct {
6+
unsigned int minShutterUs;
7+
unsigned int maxShutterUs;
8+
unsigned int minApertX10;
9+
unsigned int maxApertX10;
10+
unsigned int minSensorGain;
11+
unsigned int minIspGain;
12+
unsigned int maxSensorGain;
13+
unsigned int maxIspGain;
14+
} i6_isp_exp;
15+
16+
typedef struct {
17+
int params[13];
18+
} i6_isp_p3a;
19+
520
typedef struct {
621
void *handle, *handleCus3a, *handleIspAlgo;
722

23+
int (*fnDisableUserspace3A)(int channel);
24+
int (*fnEnableUserspace3A)(int channel, i6_isp_p3a *params);
825
int (*fnLoadChannelConfig)(int channel, char *path, unsigned int key);
926
int (*fnSetColorToGray)(int channel, char *enable);
27+
int (*fnGetExposureLimit)(int channel, i6_isp_exp *config);
28+
int (*fnSetExposureLimit)(int channel, i6_isp_exp *config);
1029
} i6_isp_impl;
1130

1231
static int i6_isp_load(i6_isp_impl *isp_lib) {
@@ -17,6 +36,14 @@ static int i6_isp_load(i6_isp_impl *isp_lib) {
1736
if (!(isp_lib->handle = dlopen("libmi_isp.so", RTLD_LAZY | RTLD_GLOBAL)))
1837
HAL_ERROR("i6_isp", "Failed to load library!\nError: %s\n", dlerror());
1938

39+
if (!(isp_lib->fnDisableUserspace3A = (int(*)(int channel))
40+
hal_symbol_load("i6_isp", isp_lib->handle, "MI_ISP_DisableUserspace3A")))
41+
return EXIT_FAILURE;
42+
43+
if (!(isp_lib->fnEnableUserspace3A = (int(*)(int channel, i6_isp_p3a *params))
44+
hal_symbol_load("i6_isp", isp_lib->handle, "MI_ISP_CUS3A_Enable")))
45+
return EXIT_FAILURE;
46+
2047
if (!(isp_lib->fnLoadChannelConfig = (int(*)(int channel, char *path, unsigned int key))
2148
hal_symbol_load("i6_isp", isp_lib->handle, "MI_ISP_API_CmdLoadBinFile")))
2249
return EXIT_FAILURE;
@@ -25,6 +52,14 @@ static int i6_isp_load(i6_isp_impl *isp_lib) {
2552
hal_symbol_load("i6_isp", isp_lib->handle, "MI_ISP_IQ_SetColorToGray")))
2653
return EXIT_FAILURE;
2754

55+
if (!(isp_lib->fnGetExposureLimit = (int(*)(int channel, i6_isp_exp *config))
56+
hal_symbol_load("i6_isp", isp_lib->handle, "MI_ISP_AE_GetExposureLimit")))
57+
return EXIT_FAILURE;
58+
59+
if (!(isp_lib->fnSetExposureLimit = (int(*)(int channel, i6_isp_exp *config))
60+
hal_symbol_load("i6_isp", isp_lib->handle, "MI_ISP_AE_SetExposureLimit")))
61+
return EXIT_FAILURE;
62+
2863
return EXIT_SUCCESS;
2964
}
3065

src/hal/star/i6_snr.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ typedef struct {
7878
int (*fnEnable)(unsigned int sensor);
7979

8080
int (*fnSetFramerate)(unsigned int sensor, unsigned int framerate);
81+
int (*fnSetOrientation)(unsigned int sensor, unsigned char mirror, unsigned char flip);
8182

8283
int (*fnGetPadInfo)(unsigned int sensor, i6_snr_pad *info);
8384
int (*fnGetPlaneInfo)(unsigned int sensor, unsigned int index, i6_snr_plane *info);
@@ -105,6 +106,10 @@ static int i6_snr_load(i6_snr_impl *snr_lib) {
105106
hal_symbol_load("i6_snr", snr_lib->handle, "MI_SNR_SetFps")))
106107
return EXIT_FAILURE;
107108

109+
if (!(snr_lib->fnSetOrientation = (int(*)(unsigned int sensor, unsigned char mirror, unsigned char flip))
110+
hal_symbol_load("i6_snr", snr_lib->handle, "MI_SNR_SetOrien")))
111+
return EXIT_FAILURE;
112+
108113
if (!(snr_lib->fnGetPadInfo = (int(*)(unsigned int sensor, i6_snr_pad *info))
109114
hal_symbol_load("i6_snr", snr_lib->handle, "MI_SNR_GetPadInfo")))
110115
return EXIT_FAILURE;

src/media.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,8 +275,7 @@ int take_next_free_channel(bool mainLoop) {
275275
int create_channel(char index, short width, short height, char framerate, char jpeg) {
276276
switch (plat) {
277277
#if defined(__ARM_PCS_VFP)
278-
case HAL_PLATFORM_I6: return i6_channel_create(index, width, height,
279-
app_config.mirror, app_config.flip, jpeg);
278+
case HAL_PLATFORM_I6: return i6_channel_create(index, width, height, jpeg);
280279
case HAL_PLATFORM_I6C: return i6c_channel_create(index, width, height,
281280
app_config.mirror, app_config.flip, jpeg);
282281
case HAL_PLATFORM_M6: return m6_channel_create(index, width, height,
@@ -747,7 +746,7 @@ int start_sdk(void) {
747746
switch (plat) {
748747
#if defined(__ARM_PCS_VFP)
749748
case HAL_PLATFORM_I6: ret = i6_pipeline_create(0, width,
750-
height, framerate); break;
749+
height, app_config.mirror, app_config.flip, framerate); break;
751750
case HAL_PLATFORM_I6C: ret = i6c_pipeline_create(0, width,
752751
height, framerate); break;
753752
case HAL_PLATFORM_M6: ret = m6_pipeline_create(0, width,

0 commit comments

Comments
 (0)