Skip to content

Commit f348994

Browse files
committed
(Continued)
1 parent 233032d commit f348994

File tree

5 files changed

+60
-71
lines changed

5 files changed

+60
-71
lines changed

README.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,9 @@ _* At the moment, only text, 24-bit and 32-bit RGB overlays are handled, matrici
6262

6363
### Roadmap
6464

65-
- [ ] Assorted WebUI to handle media reconfiguration and live preview
65+
- [ ] Writing config changes
66+
- [ ] Safe mode feature
67+
- [ ] Additional WebUI functionalities
6668
- [ ] Motion detection reimplementation
6769
- [ ] Hardware support improvement (older SoCs, general usage chips)
6870
- [ ] Alternative audio codecs

src/hal/hisi/v1_hal.c

+24-7
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,6 @@ int v1_pipeline_create(void)
258258
if (ret = v1_vi.fnEnableChannel(_v1_vi_chn))
259259
return ret;
260260

261-
if (ret = v1_snr_drv.fnInit())
262-
return ret;
263261
if (ret = v1_snr_drv.fnRegisterCallback())
264262
return ret;
265263

@@ -274,6 +272,7 @@ int v1_pipeline_create(void)
274272
return ret;
275273
if (ret = v1_isp.fnSetImageConfig(&v1_config.img))
276274
return ret;
275+
v1_config.tim.mode = V1_ISP_WIN_BOTH;
277276
if (ret = v1_isp.fnSetInputTiming(&v1_config.tim))
278277
return ret;
279278

@@ -423,8 +422,6 @@ int v1_sensor_init(char *name, char *obj)
423422
} if (!v1_snr_drv.handle)
424423
HAL_ERROR("v1_snr", "Failed to load the sensor driver");
425424

426-
if (!(v1_snr_drv.fnInit = (int(*)(void))dlsym(v1_snr_drv.handle, "sensor_init")))
427-
HAL_ERROR("v1_snr", "Failed to connect the init function");
428425
if (!(v1_snr_drv.fnRegisterCallback = (int(*)(void))dlsym(v1_snr_drv.handle, "sensor_register_callback")))
429426
HAL_ERROR("v1_snr", "Failed to connect the callback register function");
430427
if (!(v1_snr_drv.fnUnRegisterCallback = (int(*)(void))dlsym(v1_snr_drv.handle, "sensor_unregister_callback")))
@@ -447,9 +444,10 @@ int v1_video_create(char index, hal_vidconfig *config)
447444
channel.attrib.jpg.bufSize =
448445
config->height * config->width * 2;
449446
channel.attrib.jpg.byFrame = 1;
447+
channel.attrib.jpg.fieldOrFrame = 0;
448+
channel.attrib.jpg.priority = 0;
450449
channel.attrib.jpg.pic.width = config->width;
451450
channel.attrib.jpg.pic.height = config->height;
452-
channel.attrib.jpg.dcfThumbs = 0;
453451
goto attach;
454452
} else if (config->codec == HAL_VIDCODEC_MJPG) {
455453
channel.attrib.codec = V1_VENC_CODEC_MJPG;
@@ -458,6 +456,9 @@ int v1_video_create(char index, hal_vidconfig *config)
458456
channel.attrib.mjpg.bufSize =
459457
config->height * config->width * 2;
460458
channel.attrib.mjpg.byFrame = 1;
459+
channel.attrib.mjpg.mainStrmOn = index ? 0 : 1;
460+
channel.attrib.mjpg.fieldOrFrame = 0;
461+
channel.attrib.mjpg.priority = 0;
461462
channel.attrib.mjpg.pic.width = config->width;
462463
channel.attrib.mjpg.pic.height = config->height;
463464
switch (config->mode) {
@@ -507,14 +508,24 @@ int v1_video_create(char index, hal_vidconfig *config)
507508
attrib->bufSize = config->height * config->width * 2;
508509
attrib->profile = config->profile;
509510
attrib->byFrame = 1;
511+
attrib->fieldOn = 0;
512+
attrib->mainStrmOn = index ? 0 : 1;
513+
attrib->priority = 0;
514+
attrib->fieldOrFrame = 0;
510515
attrib->pic.width = config->width;
511516
attrib->pic.height = config->height;
512517
attrib->bFrameNum = 0;
513518
attrib->refNum = 1;
514519
attach:
520+
if (ret = v1_venc.fnCreateGroup(_v1_venc_dev))
521+
return ret;
522+
515523
if (ret = v1_venc.fnCreateChannel(index, &channel))
516524
return ret;
517525

526+
if (ret = v1_venc.fnRegisterChannel(_v1_venc_dev, index))
527+
return ret;
528+
518529
if (config->codec != HAL_VIDCODEC_JPG &&
519530
(ret = v1_venc.fnStartReceiving(index)))
520531
return ret;
@@ -542,8 +553,14 @@ int v1_video_destroy(char index)
542553
return ret;
543554
}
544555

556+
if (ret = v1_venc.fnUnregisterChannel(index))
557+
return ret;
558+
545559
if (ret = v1_venc.fnDestroyChannel(index))
546560
return ret;
561+
562+
if (ret = v1_venc.fnDestroyGroup(_v1_venc_dev))
563+
return ret;
547564

548565
if (ret = v1_vpss.fnDisableChannel(_v1_vpss_grp, index))
549566
return ret;
@@ -809,8 +826,8 @@ int v1_system_init(char *snrConfig)
809826
v1_config.vichn.capt.width : v1_config.videv.rect.width,
810827
v1_config.vichn.capt.height ?
811828
v1_config.vichn.capt.height : v1_config.videv.rect.height,
812-
V1_PIXFMT_YUV420SP, alignWidth);
813-
pool.comm[0].blockCnt = 4;
829+
alignWidth);
830+
pool.comm[0].blockCnt = 12;
814831

815832
if (ret = v1_vb.fnConfigPool(&pool))
816833
return ret;

src/hal/hisi/v1_snr.h

-19
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,9 @@
22

33
#include "v1_common.h"
44

5-
#include <asm/ioctl.h>
6-
#include <fcntl.h>
7-
8-
#define V1_SNR_IOC_MAGIC 'm'
95
#define V1_SNR_LANE_NUM 8
106
#define V1_SNR_WDR_VC_NUM 4
117

12-
enum {
13-
V1_SNR_CMD_CONF_DEV = 1,
14-
V1_SNR_CMD_CONF_EDGE,
15-
V1_SNR_CMD_CONF_MSB
16-
};
17-
188
typedef enum {
199
V1_SNR_INPUT_MIPI,
2010
V1_SNR_INPUT_SUBLVDS,
@@ -59,18 +49,9 @@ typedef struct {
5949
short laneId[V1_SNR_LANE_NUM];
6050
} v1_snr_mipi;
6151

62-
typedef struct {
63-
v1_snr_input input;
64-
union {
65-
v1_snr_mipi mipi;
66-
v1_snr_lvds lvds;
67-
};
68-
} v1_snr_dev;
69-
7052
typedef struct {
7153
void *handle;
7254

73-
int (*fnInit)(void);
7455
int (*fnRegisterCallback)(void);
7556
int (*fnUnRegisterCallback)(void);
7657
} v1_snr_drv_impl;

src/hal/hisi/v1_vb.h

+3-43
Original file line numberDiff line numberDiff line change
@@ -44,50 +44,10 @@ static void v1_vb_unload(v1_vb_impl *vb_lib) {
4444
memset(vb_lib, 0, sizeof(*vb_lib));
4545
}
4646

47-
inline static unsigned int v1_buffer_calculate_vi(
48-
unsigned int width, unsigned int height, v1_common_pixfmt pixFmt,
49-
v1_common_compr compr, unsigned int alignWidth)
50-
{
51-
unsigned int bitWidth = 16;
52-
unsigned int size = 0, stride = 0;
53-
unsigned int cmpRatioLine = 1600, cmpRatioFrame = 2000;
54-
55-
if (!alignWidth)
56-
alignWidth = 16;
57-
else if (alignWidth > 64)
58-
alignWidth = 64;
59-
else
60-
alignWidth = ALIGN_UP(alignWidth, 16);
61-
62-
if (compr == V1_COMPR_NONE) {
63-
stride = ALIGN_UP(ALIGN_UP(width * bitWidth, 8) / 8,
64-
alignWidth);
65-
size = stride * height;
66-
} else if (compr == V1_COMPR_LINE) {
67-
unsigned int temp = ALIGN_UP(
68-
(16 + width * bitWidth * 1000UL /
69-
cmpRatioLine + 8192 + 127) / 128, 2);
70-
stride = ALIGN_UP(temp * 16, alignWidth);
71-
size = stride * height;
72-
} else if (compr == V1_COMPR_FRAME) {
73-
size = ALIGN_UP(height * width * bitWidth * 1000UL /
74-
(cmpRatioFrame * 8), alignWidth);
75-
}
76-
77-
return size;
78-
}
79-
80-
inline static unsigned int v1_buffer_calculate_venc(short width, short height, v1_common_pixfmt pixFmt,
47+
inline static unsigned int v1_buffer_calculate_venc(short width, short height,
8148
unsigned int alignWidth)
8249
{
8350
unsigned int bufSize = CEILING_2_POWER(width, alignWidth) *
84-
CEILING_2_POWER(height, alignWidth) *
85-
(pixFmt == V1_PIXFMT_YUV422SP ? 2 : 1.5);
86-
unsigned int headSize = 16 * height;
87-
if (pixFmt == V1_PIXFMT_YUV422SP || pixFmt == V1_PIXFMT_RGB_BAYER)
88-
headSize *= 2;
89-
else if (pixFmt == V1_PIXFMT_YUV420SP)
90-
headSize *= 3;
91-
headSize >>= 1;
92-
return bufSize + headSize;
51+
CEILING_2_POWER(height, alignWidth) * 2;
52+
return bufSize;
9353
}

src/hal/hisi/v1_venc.h

+30-1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ typedef struct {
4747
unsigned int bufSize;
4848
unsigned int profile;
4949
int byFrame;
50+
int fieldOn;
51+
int mainStrmOn;
52+
unsigned int priority;
53+
int fieldOrFrame;
5054
v1_common_dim pic;
5155
unsigned int bFrameNum;
5256
unsigned int refNum;
@@ -56,15 +60,19 @@ typedef struct {
5660
v1_common_dim maxPic;
5761
unsigned int bufSize;
5862
int byFrame;
63+
int mainStrmOn;
64+
int fieldOrFrame;
65+
unsigned int priority;
5966
v1_common_dim pic;
6067
} v1_venc_attr_mjpg;
6168

6269
typedef struct {
6370
v1_common_dim maxPic;
6471
unsigned int bufSize;
6572
int byFrame;
73+
int fieldOrFrame;
74+
unsigned int priority;
6675
v1_common_dim pic;
67-
int dcfThumbs;
6876
} v1_venc_attr_jpg;
6977

7078
typedef struct {
@@ -231,6 +239,11 @@ typedef struct {
231239
typedef struct {
232240
void *handle;
233241

242+
int (*fnCreateGroup)(int group);
243+
int (*fnDestroyGroup)(int group);
244+
int (*fnRegisterChannel)(int group, int channel);
245+
int (*fnUnregisterChannel)(int channel);
246+
234247
int (*fnCreateChannel)(int channel, v1_venc_chn *config);
235248
int (*fnGetChannelConfig)(int channel, v1_venc_chn *config);
236249
int (*fnDestroyChannel)(int channel);
@@ -257,6 +270,22 @@ static int v1_venc_load(v1_venc_impl *venc_lib) {
257270
if (!(venc_lib->handle = dlopen("libmpi.so", RTLD_LAZY | RTLD_GLOBAL)))
258271
HAL_ERROR("v1_venc", "Failed to load library!\nError: %s\n", dlerror());
259272

273+
if (!(venc_lib->fnCreateGroup = (int(*)(int group))
274+
hal_symbol_load("v1_venc", venc_lib->handle, "HI_MPI_VENC_CreateGroup")))
275+
return EXIT_FAILURE;
276+
277+
if (!(venc_lib->fnDestroyGroup = (int(*)(int group))
278+
hal_symbol_load("v1_venc", venc_lib->handle, "HI_MPI_VENC_DestroyGroup")))
279+
return EXIT_FAILURE;
280+
281+
if (!(venc_lib->fnRegisterChannel = (int(*)(int group, int channel))
282+
hal_symbol_load("v1_venc", venc_lib->handle, "HI_MPI_VENC_RegisterChn")))
283+
return EXIT_FAILURE;
284+
285+
if (!(venc_lib->fnUnregisterChannel = (int(*)(int channel))
286+
hal_symbol_load("v1_venc", venc_lib->handle, "HI_MPI_VENC_UnRegisterChn")))
287+
return EXIT_FAILURE;
288+
260289
if (!(venc_lib->fnCreateChannel = (int(*)(int channel, v1_venc_chn *config))
261290
hal_symbol_load("v1_venc", venc_lib->handle, "HI_MPI_VENC_CreateChn")))
262291
return EXIT_FAILURE;

0 commit comments

Comments
 (0)