mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 09:06:50 +08:00
fix[camera_source]: enumerate device and format
Change-Id: Id4ce3986109f57039cf6716c9252dcc45caebb4e Signed-off-by: xueman.ruan <xueman.ruan@rock-chips.com>
This commit is contained in:
@@ -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");
|
||||
@@ -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)) {
|
||||
|
Reference in New Issue
Block a user