libexplain
1.4.D001
|
00001 /* 00002 * libexplain - a library of system-call-specific strerror replacements 00003 * Copyright (C) 2011, 2013 Peter Miller 00004 * Written by Peter Miller <pmiller@opensource.org.au> 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU Lesser General Public License as published by 00008 * the Free Software Foundation; either version 3 of the License, or (at your 00009 * option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but WITHOUT 00012 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00013 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public 00014 * License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public License 00017 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00018 */ 00019 00020 #include <libexplain/ac/assert.h> 00021 #include <libexplain/ac/errno.h> 00022 #include <libexplain/ac/linux/videodev2.h> 00023 #include <libexplain/ac/string.h> 00024 #include <libexplain/ac/sys/ioctl.h> 00025 00026 #include <libexplain/buffer/einval.h> 00027 #include <libexplain/buffer/enotsup.h> 00028 #include <libexplain/buffer/enosys.h> 00029 #include <libexplain/buffer/is_the_null_pointer.h> 00030 #include <libexplain/buffer/v4l2_sliced_vbi_cap.h> 00031 #include <libexplain/iocontrol/generic.h> 00032 #include <libexplain/iocontrol/vidioc_g_sliced_vbi_cap.h> 00033 #include <libexplain/is_efault.h> 00034 00035 #ifdef VIDIOC_G_SLICED_VBI_CAP 00036 00037 00038 static void 00039 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00040 int errnum, int fildes, int request, const void *data) 00041 { 00042 (void)p; 00043 (void)errnum; 00044 (void)fildes; 00045 (void)request; 00046 explain_buffer_v4l2_sliced_vbi_cap(sb, data, 0); 00047 } 00048 00049 00050 static void 00051 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00052 int errnum, int fildes, int request, const void *data) 00053 { 00054 switch (errnum) 00055 { 00056 case EINVAL: 00057 if (!data) 00058 { 00059 explain_buffer_is_the_null_pointer(sb, "data"); 00060 return; 00061 } 00062 00063 { 00064 struct v4l2_capability cap; 00065 00066 memset(&cap, 0, sizeof(cap)); 00067 if (ioctl(fildes, VIDIOC_QUERYCAP, &cap) >= 0) 00068 { 00069 const struct v4l2_sliced_vbi_cap *arg; 00070 int both; 00071 00072 both = V4L2_CAP_SLICED_VBI_CAPTURE | V4L2_CAP_SLICED_VBI_OUTPUT; 00073 if (!(cap.capabilities & both)) 00074 { 00075 explain_buffer_enosys_fildes 00076 ( 00077 sb, 00078 fildes, 00079 "fildes", 00080 "ioctl VIDIOC_G_SLICED_VBI_CAP" 00081 ); 00082 return; 00083 } 00084 00085 arg = data; 00086 if (!explain_is_efault_pointer(arg, sizeof(*arg))) 00087 { 00088 int bit; 00089 00090 bit = 0; 00091 switch (arg->type) 00092 { 00093 case V4L2_BUF_TYPE_SLICED_VBI_CAPTURE: 00094 bit = V4L2_CAP_SLICED_VBI_CAPTURE; 00095 break; 00096 00097 case V4L2_BUF_TYPE_SLICED_VBI_OUTPUT: 00098 bit = V4L2_CAP_SLICED_VBI_OUTPUT; 00099 break; 00100 00101 #ifdef V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE 00102 case V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE: 00103 #endif 00104 #ifdef V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE 00105 case V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE: 00106 #endif 00107 case V4L2_BUF_TYPE_VIDEO_CAPTURE: 00108 case V4L2_BUF_TYPE_VIDEO_OUTPUT: 00109 case V4L2_BUF_TYPE_VIDEO_OVERLAY: 00110 case V4L2_BUF_TYPE_VBI_CAPTURE: 00111 case V4L2_BUF_TYPE_VBI_OUTPUT: 00112 case V4L2_BUF_TYPE_VIDEO_OUTPUT_OVERLAY: 00113 case V4L2_BUF_TYPE_PRIVATE: 00114 default: 00115 explain_buffer_einval_vague(sb, "data->type"); 00116 return; 00117 } 00118 assert(bit); 00119 if (!(cap.capabilities & bit)) 00120 { 00121 explain_buffer_enotsup_device(sb, "data->type"); 00122 return; 00123 } 00124 } 00125 } 00126 } 00127 00128 /* No idea */ 00129 explain_buffer_einval_vague(sb, "data"); 00130 break; 00131 00132 default: 00133 explain_iocontrol_generic_print_explanation 00134 ( 00135 p, 00136 sb, 00137 errnum, 00138 fildes, 00139 request, 00140 data 00141 ); 00142 break; 00143 } 00144 } 00145 00146 00147 static void 00148 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00149 int errnum, int fildes, int request, const void *data) 00150 { 00151 (void)p; 00152 (void)errnum; 00153 (void)fildes; 00154 (void)request; 00155 explain_buffer_v4l2_sliced_vbi_cap(sb, data, 1); 00156 } 00157 00158 00159 const explain_iocontrol_t explain_iocontrol_vidioc_g_sliced_vbi_cap = 00160 { 00161 "VIDIOC_G_SLICED_VBI_CAP", /* name */ 00162 VIDIOC_G_SLICED_VBI_CAP, /* value */ 00163 0, /* disambiguate */ 00164 0, /* print_name */ 00165 print_data, 00166 print_explanation, 00167 print_data_returned, 00168 sizeof(struct v4l2_sliced_vbi_cap), /* data_size */ 00169 "struct v4l2_sliced_vbi_cap *", /* data_type */ 00170 0, /* flags */ 00171 __FILE__, 00172 __LINE__, 00173 }; 00174 00175 #else /* ndef VIDIOC_G_SLICED_VBI_CAP */ 00176 00177 const explain_iocontrol_t explain_iocontrol_vidioc_g_sliced_vbi_cap = 00178 { 00179 0, /* name */ 00180 0, /* value */ 00181 0, /* disambiguate */ 00182 0, /* print_name */ 00183 0, /* print_data */ 00184 0, /* print_explanation */ 00185 0, /* print_data_returned */ 00186 0, /* data_size */ 00187 0, /* data_type */ 00188 0, /* flags */ 00189 __FILE__, 00190 __LINE__, 00191 }; 00192 00193 #endif /* VIDIOC_G_SLICED_VBI_CAP */ 00194 00195 /* vim: set ts=8 sw=4 et : */