Merge tag 'JH7110_515_SDK_v5.8.0' into jh7110-mm-devel

This commit is contained in:
Andy Hu
2023-10-11 18:20:18 +08:00
2 changed files with 28 additions and 20 deletions
+3 -3
View File
@@ -299,9 +299,9 @@ CONFIG_FEATURE_SORT_BIG=y
# CONFIG_FEATURE_SORT_OPTIMIZE_MEMORY is not set # CONFIG_FEATURE_SORT_OPTIMIZE_MEMORY is not set
# CONFIG_SPLIT is not set # CONFIG_SPLIT is not set
# CONFIG_FEATURE_SPLIT_FANCY is not set # CONFIG_FEATURE_SPLIT_FANCY is not set
# CONFIG_STAT is not set CONFIG_STAT=y
# CONFIG_FEATURE_STAT_FORMAT is not set CONFIG_FEATURE_STAT_FORMAT=y
# CONFIG_FEATURE_STAT_FILESYSTEM is not set CONFIG_FEATURE_STAT_FILESYSTEM=y
CONFIG_STTY=y CONFIG_STTY=y
# CONFIG_SUM is not set # CONFIG_SUM is not set
CONFIG_SYNC=y CONFIG_SYNC=y
+25 -17
View File
@@ -61,6 +61,7 @@ typedef struct {
enum STF_DISP_TYPE disp_type; enum STF_DISP_TYPE disp_type;
enum IOMethod io_mthd; enum IOMethod io_mthd;
int continuous; int continuous;
uint32_t frm_num;
uint8_t jpegQuality; uint8_t jpegQuality;
char* jpegFilename; char* jpegFilename;
@@ -84,6 +85,7 @@ static void alloc_default_config(ConfigParam_t **pp_data)
cfg_param->disp_type = STF_DISP_NONE; cfg_param->disp_type = STF_DISP_NONE;
cfg_param->continuous = 0; cfg_param->continuous = 0;
cfg_param->frm_num = 3;
cfg_param->jpegQuality = 70; cfg_param->jpegQuality = 70;
cfg_param->io_mthd = IO_METHOD_MMAP; cfg_param->io_mthd = IO_METHOD_MMAP;
@@ -514,12 +516,10 @@ static int frameRead(void)
static void mainloop_select(void) static void mainloop_select(void)
{ {
int count, i; int count, i;
uint32_t numberOfTimeouts;
numberOfTimeouts = 0; count = gp_cfg_param->frm_num;
count = 3;
while (count-- > 0) { while (count > 0) {
for (i = 0; i < 1; i++) { for (i = 0; i < 1; i++) {
fd_set fds; fd_set fds;
struct timeval tv; struct timeval tv;
@@ -538,20 +538,18 @@ static void mainloop_select(void)
} }
errno_exit("select"); errno_exit("select");
} else if (0 == r) { } else if (0 == r) {
if (numberOfTimeouts <= 0) { LOG(STF_LEVEL_ERR, "select timeout\n");
// count++; continue;
} else {
LOG(STF_LEVEL_ERR, "select timeout\n");
exit(EXIT_FAILURE);
}
} }
if (frameRead()) {
break;
}
count--;
if (gp_cfg_param->continuous == 1) { if (gp_cfg_param->continuous == 1) {
count = 3; count = 3;
} }
if (frameRead())
break;
/* EAGAIN - continue select loop. */ /* EAGAIN - continue select loop. */
} }
} }
@@ -599,7 +597,7 @@ static void mainloop()
{ {
struct v4l2_buffer buf; struct v4l2_buffer buf;
int r; int r;
int count = 3; int count = gp_cfg_param->frm_num;
drmEventContext ev; drmEventContext ev;
struct pollfd* fds = NULL; struct pollfd* fds = NULL;
uint32_t nfds = 0; uint32_t nfds = 0;
@@ -661,7 +659,7 @@ static void mainloop()
} }
} }
while (count-- > 0) { while (count > 0) {
r = poll(fds, nfds, 3000); r = poll(fds, nfds, 3000);
if (-1 == r) { if (-1 == r) {
if (EINTR == errno) { if (EINTR == errno) {
@@ -681,6 +679,7 @@ static void mainloop()
if (fds[0].revents & POLLIN) { if (fds[0].revents & POLLIN) {
frameRead(); frameRead();
calc_frame_fps(); calc_frame_fps();
count--;
} }
} else if (STF_DISP_DRM == gp_cfg_param->disp_type && } else if (STF_DISP_DRM == gp_cfg_param->disp_type &&
IO_METHOD_MMAP == gp_cfg_param->io_mthd) { IO_METHOD_MMAP == gp_cfg_param->io_mthd) {
@@ -688,6 +687,7 @@ static void mainloop()
if (fds[0].revents & POLLIN) { if (fds[0].revents & POLLIN) {
frameRead(); frameRead();
calc_frame_fps(); calc_frame_fps();
count--;
} }
if (fds[1].revents & POLLIN) { if (fds[1].revents & POLLIN) {
@@ -719,6 +719,7 @@ static void mainloop()
} }
frameRead(); // TODO: add support for save file later frameRead(); // TODO: add support for save file later
calc_frame_fps(); calc_frame_fps();
count--;
} }
} }
if (fds[1].revents & POLLIN) { if (fds[1].revents & POLLIN) {
@@ -772,6 +773,7 @@ static void usage(FILE* fp, int argc, char** argv)
"-D | --down Set v4l2 image crop y height\n" "-D | --down Set v4l2 image crop y height\n"
"-I | --interval Set frame interval (fps) (-1 to skip)\n" "-I | --interval Set frame interval (fps) (-1 to skip)\n"
"-c | --continuous Do continous capture, stop with SIGINT.\n" "-c | --continuous Do continous capture, stop with SIGINT.\n"
"-n | --frame_num capure frame number, default 30\n"
"-C | --connector Display Connector.\n" "-C | --connector Display Connector.\n"
" 0: INNO HDMI\n" " 0: INNO HDMI\n"
" 1: MIPI/RGB HDMI\n" " 1: MIPI/RGB HDMI\n"
@@ -808,7 +810,7 @@ static void usage(FILE* fp, int argc, char** argv)
argv[0]); argv[0]);
} }
static const char short_options [] = "d:ho:q:m:W:H:I:vcf:t:X:Y:R:D:l:C:s"; static const char short_options [] = "d:ho:q:m:W:H:I:vcn:f:t:X:Y:R:D:l:C:s";
static const struct option long_options [] = { static const struct option long_options [] = {
{ "device", required_argument, NULL, 'd' }, { "device", required_argument, NULL, 'd' },
@@ -825,6 +827,7 @@ static const struct option long_options [] = {
{ "interval", required_argument, NULL, 'I' }, { "interval", required_argument, NULL, 'I' },
{ "version", no_argument, NULL, 'v' }, { "version", no_argument, NULL, 'v' },
{ "continuous", no_argument, NULL, 'c' }, { "continuous", no_argument, NULL, 'c' },
{ "frame_num", required_argument, NULL, 'n' },
{ "format", required_argument, NULL, 'f' }, { "format", required_argument, NULL, 'f' },
{ "distype", required_argument, NULL, 't' }, { "distype", required_argument, NULL, 't' },
{ "loadfw", required_argument, NULL, 'l' }, { "loadfw", required_argument, NULL, 'l' },
@@ -918,6 +921,11 @@ void parse_options(int argc, char **argv, ConfigParam_t *cfg_param)
InstallSIGINTHandler(); InstallSIGINTHandler();
break; break;
case 'n':
// set capture frame number. effective when cfg_param->continuous is 0
cfg_param->frm_num = (uint32_t)strtoul(optarg, NULL, 0);
break;
case 'v': case 'v':
printf("Version: %s\n", TEST_VERSION); printf("Version: %s\n", TEST_VERSION);
exit(EXIT_SUCCESS); exit(EXIT_SUCCESS);