• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* SPDX-License-Identifier: LGPL-2.1-only */
2 /*
3  * Copyright 2018 Cisco Systems, Inc. and/or its affiliates. All rights reserved.
4  */
5 
6 #ifndef _V4L2_INFO_H
7 #define _V4L2_INFO_H
8 
9 #include <string>
10 
11 #include <linux/videodev2.h>
12 #include <linux/v4l2-subdev.h>
13 
14 #define v4l2_tracer_info(fmt, args...)					\
15 	do {								\
16 		char msg[256];						\
17 		snprintf(msg, sizeof(msg), "v4l2-tracer: " fmt, ##args);\
18 		write(open("/dev/null", O_WRONLY), msg, strlen(msg));	\
19 	} while (0)
20 
21 /*
22  * The max value comes from a check in the kernel source code
23  * drivers/media/v4l2-core/v4l2-ioctl.c check_array_args()
24  */
25 #define NUM_ROUTES_MAX 256
26 
27 struct flag_def {
28 	unsigned flag;
29 	const char *str;
30 };
31 
32 /* Return a comma-separated string of flags or hex value if unknown */
33 std::string flags2s(unsigned val, const flag_def *def);
34 
35 /* Print capability information */
36 void v4l2_info_capability(const v4l2_capability &cap);
37 void v4l2_info_subdev_capability(const v4l2_subdev_capability &subdevcap,
38 				 const v4l2_subdev_client_capability &subdevclientcap);
39 
40 /* Return fourcc pixelformat string */
41 std::string fcc2s(__u32 val);
42 
43 /* Return the description of the pixel format */
44 std::string pixfmt2s(__u32 format);
45 
46 /* Return buffer type description */
47 std::string buftype2s(int type);
48 
49 /* Return buffer capability description */
50 std::string bufcap2s(__u32 caps);
51 
buftype2s(enum v4l2_buf_type type)52 static inline std::string buftype2s(enum v4l2_buf_type type)
53 {
54        return buftype2s((int)type);
55 }
56 
57 /* Return field description */
58 std::string field2s(int val);
59 
60 /* Return colorspace description */
61 std::string colorspace2s(int val);
62 
63 /* Return transfer function description */
64 std::string xfer_func2s(int val);
65 
66 /* Return YCbCr encoding description */
67 std::string ycbcr_enc2s(int val);
68 
69 /* Return quantization description */
70 std::string quantization2s(int val);
71 
72 /* Return v4l2_pix_format flags description */
73 std::string pixflags2s(unsigned flags);
74 
75 /* Return sliced vbi services description */
76 std::string service2s(unsigned service);
77 
78 /* Return v4l2_subdev_mbus_code_enum flags description */
79 std::string mbus2s(unsigned flags, bool is_hsv);
80 
81 /* Return v4l2_fmtdesc flags description */
82 std::string fmtdesc2s(unsigned flags, bool is_hsv);
83 
84 /* Return selection flags description */
85 std::string selflags2s(__u32 flags);
86 
87 /* Return selection target description */
88 std::string seltarget2s(__u32 target);
89 
90 /*
91  * v4l2-info.cpp has a table with valid selection targets,
92  * these functions help navigate that table.
93  */
94 
95 /* Return true if the table at index i has a valid selection target */
96 bool valid_seltarget_at_idx(unsigned i);
97 
98 /* Return the selection target in the table at index i (or 0 if out of range) */
99 unsigned seltarget_at_idx(unsigned i);
100 
101 /* Return v4l2_std description, separate entries by sep */
102 std::string std2s(v4l2_std_id std, const char *sep = " ");
103 
104 /* Return control flags description */
105 std::string ctrlflags2s(__u32 flags);
106 
107 /* Return input status description */
108 std::string in_status2s(__u32 status);
109 
110 /* Return input capabilities description */
111 std::string input_cap2s(__u32 capabilities);
112 
113 /* Return output capabilities description */
114 std::string output_cap2s(__u32 capabilities);
115 
116 /* Return framebuffer capabilities description */
117 std::string fbufcap2s(unsigned cap);
118 
119 /* Return framebuffer flags description */
120 std::string fbufflags2s(unsigned fl);
121 
122 /* Return DV Timings standards description */
123 std::string dv_standards2s(__u32 flags);
124 
125 /*
126  * Return DV Timings flags description, vsync is the
127  * vertical sync value.
128  */
129 std::string dvflags2s(unsigned vsync, int val);
130 
131 /* Return DV Timings capabilities description */
132 std::string dv_caps2s(__u32 flags);
133 
134 /* Return v4l2_timecode flags description */
135 std::string tc_flags2s(__u32 flags);
136 
137 /* Return v4l2_buffer flags description */
138 std::string bufferflags2s(__u32 flags);
139 
140 /* Return vbi flags description */
141 std::string vbiflags2s(__u32 flags);
142 
143 /* Return tuner type description */
144 std::string ttype2s(int type);
145 
146 /* Return audio mode description */
147 std::string audmode2s(int audmode);
148 
149 /* Return RX subchannels description */
150 std::string rxsubchans2s(int rxsubchans);
151 
152 /* Return TX subchannels description */
153 std::string txsubchans2s(int txsubchans);
154 
155 /* Return tuner capabilities description */
156 std::string tcap2s(unsigned cap);
157 
158 /* Return band modulation description */
159 std::string modulation2s(unsigned modulation);
160 
161 /* Return subdev client capabilities description */
162 std::string subdevclientcap2s(__u64 cap);
163 
164 #endif
165