2019-07-03 04:35:08 +11:00
|
|
|
/*
|
|
|
|
* fonctions pour afficher les structures de V4L2
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2019-07-22 13:10:00 +11:00
|
|
|
#include <inttypes.h>
|
2019-07-03 04:35:08 +11:00
|
|
|
#include <linux/videodev2.h>
|
|
|
|
|
|
|
|
#include "v4l2_pr_structs.h"
|
|
|
|
|
|
|
|
#define FP (stdout)
|
|
|
|
|
|
|
|
extern int verbosity;
|
|
|
|
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
static char *fmttype2str(int type)
|
|
|
|
{
|
|
|
|
|
|
|
|
switch(type) {
|
|
|
|
case 0: return "[zero]";
|
|
|
|
case 1: return "video capture";
|
|
|
|
case 2: return "video output";
|
|
|
|
|
|
|
|
case 13: return "META capture";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-07-22 13:10:00 +11:00
|
|
|
static void pr_capabilities(uint32_t caps)
|
|
|
|
{
|
|
|
|
fputs(" ", FP);
|
|
|
|
|
|
|
|
if (caps & V4L2_CAP_VIDEO_CAPTURE) fputs("vcapt ", FP);
|
|
|
|
if (caps & V4L2_CAP_VIDEO_OUTPUT) fputs("vout ", FP);
|
|
|
|
if (caps & V4L2_CAP_VIDEO_OVERLAY) fputs("overlay ", FP);
|
|
|
|
if (caps & V4L2_CAP_VBI_CAPTURE) fputs("vbicapt ", FP);
|
|
|
|
if (caps & V4L2_CAP_VBI_OUTPUT) fputs("vbiout ", FP);
|
|
|
|
|
|
|
|
/* to be continued */
|
|
|
|
|
|
|
|
if (caps & V4L2_CAP_AUDIO) fputs("audio ", FP);
|
|
|
|
|
|
|
|
|
|
|
|
if (caps & V4L2_CAP_SDR_CAPTURE) fputs("sdrcapt ", FP);
|
|
|
|
if (caps & V4L2_CAP_EXT_PIX_FORMAT) fputs("extpix ", FP);
|
|
|
|
if (caps & V4L2_CAP_SDR_OUTPUT) fputs("sdrout ", FP);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (caps & V4L2_CAP_READWRITE) fputs("rwsysc ", FP);
|
|
|
|
if (caps & V4L2_CAP_ASYNCIO) fputs("asyncio ", FP);
|
|
|
|
if (caps & V4L2_CAP_STREAMING) fputs("stream ", FP);
|
|
|
|
|
|
|
|
|
|
|
|
fputs("\n", FP);
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-07-21 22:36:14 +11:00
|
|
|
int pr_v4l2_capability(char *txt, struct v4l2_capability *ptr)
|
|
|
|
{
|
|
|
|
fprintf(FP, "-- v4l2_capability, %-15s %p\n", txt, ptr);
|
|
|
|
|
2019-07-22 13:10:00 +11:00
|
|
|
fprintf(FP, " driver %s\n", ptr->driver);
|
|
|
|
fprintf(FP, " card %s\n", ptr->card);
|
|
|
|
fprintf(FP, " bus info %s\n", ptr->bus_info);
|
|
|
|
|
|
|
|
fprintf(FP, " version 0x%X\n", ptr->version);
|
|
|
|
fprintf(FP, " capabilities 0x%X\n", ptr->capabilities);
|
|
|
|
pr_capabilities(ptr->capabilities);
|
|
|
|
fprintf(FP, " device caps 0x%X\n", ptr->device_caps);
|
|
|
|
|
2019-07-27 13:03:57 +11:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-07-28 08:51:35 +11:00
|
|
|
/*
|
|
|
|
* warning, this function return a pointer to a static
|
|
|
|
* strint, so it was NOT reentrant !
|
|
|
|
*/
|
|
|
|
char *str_fourcc(uint32_t fcc)
|
|
|
|
{
|
|
|
|
static char chaine[10];
|
|
|
|
|
|
|
|
chaine[0] = '['; chaine[5] = ']'; chaine[6] = '\0';
|
|
|
|
chaine[1] = (fcc>>0) & 0xff;
|
|
|
|
chaine[2] = (fcc>>8) & 0xff;
|
|
|
|
chaine[3] = (fcc>>16) & 0xff;
|
|
|
|
chaine[4] = (fcc>>24) & 0xff;
|
|
|
|
|
|
|
|
return chaine;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
char *str_buf_type(int type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE: return "vidcapt";
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_OUTPUT: return "vidout";
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_OVERLAY: return "vidovrl";
|
|
|
|
case V4L2_BUF_TYPE_VBI_CAPTURE: return "vbicapt";
|
|
|
|
case V4L2_BUF_TYPE_VBI_OUTPUT: return "vbicapt";
|
|
|
|
case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: return "slicevcapt";
|
|
|
|
case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: return "slicevout";
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: return "v-outover";
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: return "v-captmpla";
|
|
|
|
case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: return "v-outmpla";
|
|
|
|
case V4L2_BUF_TYPE_SDR_CAPTURE: return "sdrcapt";
|
|
|
|
case V4L2_BUF_TYPE_SDR_OUTPUT: return "sdrout";
|
|
|
|
/* Deprecated, do not use */
|
|
|
|
case V4L2_BUF_TYPE_PRIVATE: return "private";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-07-27 13:03:57 +11:00
|
|
|
int pr_v4l2_fmtdesc(char *txt, struct v4l2_fmtdesc *ptr)
|
|
|
|
{
|
|
|
|
fprintf(FP, "-- v4l2_fmtdesc, %-15s %p\n", txt, ptr);
|
|
|
|
|
|
|
|
fprintf(FP, " index %d\n", ptr->index);
|
|
|
|
fprintf(FP, " type %d\n", ptr->type); /* enum v4l2_buf_type */
|
|
|
|
fprintf(FP, " flags 0x%X\n", ptr->flags);
|
|
|
|
fprintf(FP, " description %s\n", ptr->description);
|
|
|
|
fprintf(FP, " pixel format 0x%X\n", ptr->pixelformat); /* FOURCC */
|
|
|
|
|
2019-07-22 13:10:00 +11:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-07-25 02:00:07 +11:00
|
|
|
char *str_input_type(int t)
|
2019-07-22 13:10:00 +11:00
|
|
|
{
|
|
|
|
switch (t) {
|
|
|
|
case V4L2_INPUT_TYPE_TUNER: return "tuner";
|
|
|
|
case V4L2_INPUT_TYPE_CAMERA: return "camera";
|
|
|
|
case V4L2_INPUT_TYPE_TOUCH: return "touch";
|
|
|
|
}
|
|
|
|
return "???";
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
static void pr_input_status(uint32_t st)
|
|
|
|
{
|
2019-07-28 08:51:35 +11:00
|
|
|
if (st & V4L2_IN_ST_NO_POWER) fputs("nopow ", FP);
|
|
|
|
if (st & V4L2_IN_ST_NO_SIGNAL) fputs("nosig ", FP);
|
|
|
|
if (st & V4L2_IN_ST_NO_COLOR) fputs("nocol ", FP);
|
2019-07-22 13:10:00 +11:00
|
|
|
|
2019-07-28 08:51:35 +11:00
|
|
|
if (st & V4L2_IN_ST_HFLIP) fputs("hflip ", FP);
|
|
|
|
if (st & V4L2_IN_ST_VFLIP) fputs("vflip ", FP);
|
2019-07-22 13:10:00 +11:00
|
|
|
|
2019-07-28 08:51:35 +11:00
|
|
|
if (st & V4L2_IN_ST_NO_H_LOCK) fputs("nohlck ", FP);
|
|
|
|
if (st & V4L2_IN_ST_COLOR_KILL) fputs("colkil ", FP);
|
|
|
|
if (st & V4L2_IN_ST_NO_V_LOCK) fputs("novlck ", FP);
|
|
|
|
if (st & V4L2_IN_ST_NO_STD_LOCK) fputs("nostdlk ", FP);
|
|
|
|
|
|
|
|
if (st & V4L2_IN_ST_NO_EQU) fputs("noequ ", FP);
|
|
|
|
if (st & V4L2_IN_ST_NO_CARRIER) fputs("nocarr ", FP);
|
|
|
|
|
|
|
|
if (st & V4L2_IN_ST_MACROVISION) fputs("macrov ", FP);
|
|
|
|
if (st & V4L2_IN_ST_NO_ACCESS) fputs("noacces ", FP);
|
|
|
|
if (st & V4L2_IN_ST_VTR) fputs("VTR ", FP);
|
|
|
|
|
|
|
|
/* to be continued ?*/
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
static void pr_input_capabilities(uint32_t st)
|
|
|
|
{
|
|
|
|
if (st & V4L2_IN_CAP_DV_TIMINGS) fputs("DVtime ", FP);
|
|
|
|
if (st & V4L2_IN_CAP_STD) fputs("s_std ", FP);
|
|
|
|
if (st & V4L2_IN_CAP_NATIVE_SIZE) fputs("nativsz ", FP);
|
2019-07-22 13:10:00 +11:00
|
|
|
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int pr_v4l2_input(char *txt, struct v4l2_input *ptr)
|
|
|
|
{
|
|
|
|
fprintf(FP, "-- v4l2_input, %-15s %p\n", txt, ptr);
|
2019-07-21 22:36:14 +11:00
|
|
|
|
2019-07-22 13:10:00 +11:00
|
|
|
fprintf(FP, " index %d\n", ptr->index);
|
|
|
|
fprintf(FP, " name %s\n", ptr->name);
|
|
|
|
fprintf(FP, " type %d %s\n", ptr->type,
|
|
|
|
str_input_type(ptr->type));
|
|
|
|
fprintf(FP, " audioset 0x%X\n", ptr->audioset);
|
|
|
|
fprintf(FP, " tuner 0x%X\n", ptr->tuner);
|
|
|
|
/* XXX v4l2_std_id std; */
|
2019-07-28 08:51:35 +11:00
|
|
|
fprintf(FP, " status 0x%X\n", ptr->status);
|
|
|
|
if (ptr->status) {
|
|
|
|
fputs(" ",FP);
|
|
|
|
pr_input_status(ptr->status);
|
|
|
|
fputs("\n",FP);
|
|
|
|
}
|
2019-07-22 13:10:00 +11:00
|
|
|
fprintf(FP, " capabilities 0x%X\n", ptr->capabilities);
|
2019-07-28 08:51:35 +11:00
|
|
|
if (ptr->capabilities) {
|
|
|
|
fputs(" ",FP);
|
|
|
|
pr_input_capabilities(ptr->capabilities);
|
|
|
|
fputs("\n",FP);
|
|
|
|
}
|
2019-07-21 22:36:14 +11:00
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-07-03 04:35:08 +11:00
|
|
|
int pr_v4l2_format(char *txt, struct v4l2_format *ptr)
|
|
|
|
{
|
|
|
|
fprintf(FP, "-- v4l2_format, %-15s %p\n", txt, ptr);
|
|
|
|
fprintf(FP, " type %d %s\n", ptr->type,/* enum v4l2_buf_type */
|
2019-07-21 22:36:14 +11:00
|
|
|
fmttype2str(ptr->type));
|
2019-07-03 04:35:08 +11:00
|
|
|
|
|
|
|
switch(ptr->type) {
|
|
|
|
|
|
|
|
case 1: // fputs(" Capture\n", FP);
|
|
|
|
fprintf(FP, " dims %dx%d\n",
|
|
|
|
ptr->fmt.pix.width,
|
|
|
|
ptr->fmt.pix.height);
|
|
|
|
break;
|
|
|
|
|
2019-07-21 22:36:14 +11:00
|
|
|
default: fprintf(FP, "type is %d\n", ptr->type);
|
|
|
|
break;
|
2019-07-03 04:35:08 +11:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
fputs(".\n", FP);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
|
|
|
int pr_v4l2_requestbuffers(char *txt, struct v4l2_requestbuffers *ptr)
|
|
|
|
{
|
2019-07-04 00:29:24 +11:00
|
|
|
fprintf(FP, "-- v4l2_requestbuffers, %s %p\n", txt, ptr);
|
2019-07-03 04:35:08 +11:00
|
|
|
fprintf(FP, " type %d\n", ptr->type); /* enum v4l2_buf_type */
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|
2019-07-25 02:00:07 +11:00
|
|
|
char *str_ctrl_type(int type)
|
|
|
|
{
|
|
|
|
switch (type) {
|
|
|
|
case V4L2_CTRL_TYPE_INTEGER: return "integer";
|
|
|
|
case V4L2_CTRL_TYPE_BOOLEAN: return "boolean";
|
|
|
|
case V4L2_CTRL_TYPE_MENU: return "menu";
|
|
|
|
case V4L2_CTRL_TYPE_BUTTON: return "button";
|
|
|
|
case V4L2_CTRL_TYPE_INTEGER64: return "int64";
|
|
|
|
case V4L2_CTRL_TYPE_CTRL_CLASS: return "ctrl-class";
|
|
|
|
case V4L2_CTRL_TYPE_STRING: return "string";
|
|
|
|
case V4L2_CTRL_TYPE_BITMASK: return "bitmask";
|
|
|
|
case V4L2_CTRL_TYPE_INTEGER_MENU: return "int-menu";
|
|
|
|
}
|
|
|
|
|
|
|
|
return "???";
|
|
|
|
}
|
2019-07-03 04:35:08 +11:00
|
|
|
/* --------------------------------------------------------------------- */
|
2019-07-25 02:00:07 +11:00
|
|
|
/*
|
|
|
|
The 32-bit qctrl.id value is subdivided into three bit ranges:
|
|
|
|
the top 4 bits are reserved for flags (e. g. V4L2_CTRL_FLAG_NEXT_CTRL)
|
|
|
|
and are not actually part of the ID.
|
|
|
|
The remaining 28 bits form the control ID, of which the most significant
|
|
|
|
12 bits define the control class and the least significant
|
|
|
|
16 bits identify the control within the control class.
|
|
|
|
*/
|
|
|
|
void pr_ctrl_id(uint32_t id)
|
|
|
|
{
|
|
|
|
|
2019-07-28 09:28:22 +11:00
|
|
|
if (verbosity>1) fprintf(FP, "%08x : ", id);
|
2019-07-25 02:00:07 +11:00
|
|
|
|
|
|
|
fprintf(FP, "%x %03x %04x", (id>>28)&0xf,
|
|
|
|
V4L2_CTRL_ID2CLASS(id)>>16, id&0xffff);
|
|
|
|
|
|
|
|
}
|
2019-07-03 04:35:08 +11:00
|
|
|
/* --------------------------------------------------------------------- */
|
2019-07-25 02:00:07 +11:00
|
|
|
int pr_v4l2_control(char *txt, struct v4l2_control *ptr)
|
|
|
|
{
|
2019-07-03 04:35:08 +11:00
|
|
|
|
2019-07-25 02:00:07 +11:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
/* --------------------------------------------------------------------- */
|