Skip to content

Commit

Permalink
fix[camera_source]: enumerate device and format
Browse files Browse the repository at this point in the history
Change-Id: Id4ce3986109f57039cf6716c9252dcc45caebb4e
Signed-off-by: xueman.ruan <[email protected]>
  • Loading branch information
xueman.ruan authored and HermanChen committed Sep 28, 2023
1 parent 7017dbd commit d127b5c
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions utils/camera_source.c
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,16 @@ CamSource *camera_source_init(const char *device, RK_U32 bufcnt, RK_U32 width, R
goto FAIL;
}

{
struct v4l2_input input;

input.index = 0;
while (!camera_source_ioctl(ctx->fd, VIDIOC_ENUMINPUT, &input)) {
mpp_log("input devices:%s\n", input.name);
++input.index;
}
}

// Determine if fd is a V4L2 Device
if (0 != camera_source_ioctl(ctx->fd, VIDIOC_QUERYCAP, &cap)) {
mpp_err_f("Not v4l2 compatible\n");
Expand All @@ -157,6 +167,20 @@ CamSource *camera_source_init(const char *device, RK_U32 bufcnt, RK_U32 width, R
vfmt.fmt.pix.width = width;
vfmt.fmt.pix.height = height;

{
struct v4l2_fmtdesc fmtdesc;

fmtdesc.index = 0;
fmtdesc.type = vfmt.type;
while (!camera_source_ioctl(ctx->fd, VIDIOC_ENUM_FMT, &fmtdesc)) {
mpp_log("fmt name: [%s]\n", fmtdesc.description);
mpp_log("fmt pixelformat: '%c%c%c%c', description = '%s'\n", fmtdesc.pixelformat & 0xFF,
(fmtdesc.pixelformat >> 8) & 0xFF, (fmtdesc.pixelformat >> 16) & 0xFF,
(fmtdesc.pixelformat >> 24) & 0xFF, fmtdesc.description);
fmtdesc.index++;
}
}

if (MPP_FRAME_FMT_IS_YUV(format)) {
vfmt.fmt.pix.pixelformat = V4L2_yuv_cfg[format - MPP_FRAME_FMT_YUV];
} else if (MPP_FRAME_FMT_IS_RGB(format)) {
Expand Down

0 comments on commit d127b5c

Please sign in to comment.