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/errno.h> 00021 #include <libexplain/ac/linux/videodev2.h> 00022 #include <libexplain/ac/string.h> 00023 #include <libexplain/ac/sys/ioctl.h> 00024 00025 #include <libexplain/buffer/enosys.h> 00026 #include <libexplain/buffer/enotsup.h> 00027 #include <libexplain/buffer/einval.h> 00028 #include <libexplain/buffer/is_the_null_pointer.h> 00029 #include <libexplain/buffer/v4l2_dv_timings.h> 00030 #include <libexplain/iocontrol/generic.h> 00031 #include <libexplain/iocontrol/vidioc_s_dv_timings.h> 00032 #include <libexplain/is_efault.h> 00033 00034 #ifdef VIDIOC_S_DV_TIMINGS 00035 00036 00037 static void 00038 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00039 int errnum, int fildes, int request, const void *data) 00040 { 00041 (void)p; 00042 (void)errnum; 00043 (void)fildes; 00044 (void)request; 00045 explain_buffer_v4l2_dv_timings(sb, data); 00046 } 00047 00048 00049 static void 00050 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00051 int errnum, int fildes, int request, const void *data) 00052 { 00053 switch (errnum) 00054 { 00055 case EINVAL: 00056 if (!data) 00057 { 00058 explain_buffer_is_the_null_pointer(sb, "data"); 00059 return; 00060 } 00061 00062 { 00063 const struct v4l2_dv_timings *arg; 00064 00065 arg = data; 00066 if (!explain_is_efault_pointer(arg, sizeof(*arg))) 00067 { 00068 struct v4l2_dv_timings qry; 00069 00070 memset(&qry, 0, sizeof(qry)); 00071 if (ioctl(fildes, VIDIOC_G_DV_TIMINGS, &qry) >= 0) 00072 { 00073 if (arg->type != qry.type) 00074 { 00075 explain_buffer_enotsup_device(sb, "data->type"); 00076 return; 00077 } 00078 } 00079 else if (errno == EINVAL) 00080 { 00081 explain_buffer_enosys_fildes 00082 ( 00083 sb, 00084 fildes, 00085 "fildes", 00086 "ioctl VIDIOC_S_DV_TIMINGS" 00087 ); 00088 return; 00089 } 00090 } 00091 } 00092 00093 /* No idea */ 00094 explain_buffer_einval_vague(sb, "data"); 00095 break; 00096 00097 default: 00098 explain_iocontrol_generic_print_explanation 00099 ( 00100 p, 00101 sb, 00102 errnum, 00103 fildes, 00104 request, 00105 data 00106 ); 00107 break; 00108 } 00109 } 00110 00111 00112 const explain_iocontrol_t explain_iocontrol_vidioc_s_dv_timings = 00113 { 00114 "VIDIOC_S_DV_TIMINGS", /* name */ 00115 VIDIOC_S_DV_TIMINGS, /* value */ 00116 0, /* disambiguate */ 00117 0, /* print_name */ 00118 print_data, 00119 print_explanation, 00120 print_data, /* print_data_returned */ 00121 sizeof(struct v4l2_dv_timings), /* data_size */ 00122 "struct v4l2_dv_timings *", /* data_type */ 00123 0, /* flags */ 00124 __FILE__, 00125 __LINE__, 00126 }; 00127 00128 #else /* ndef VIDIOC_S_DV_TIMINGS */ 00129 00130 const explain_iocontrol_t explain_iocontrol_vidioc_s_dv_timings = 00131 { 00132 0, /* name */ 00133 0, /* value */ 00134 0, /* disambiguate */ 00135 0, /* print_name */ 00136 0, /* print_data */ 00137 0, /* print_explanation */ 00138 0, /* print_data_returned */ 00139 0, /* data_size */ 00140 0, /* data_type */ 00141 0, /* flags */ 00142 __FILE__, 00143 __LINE__, 00144 }; 00145 00146 #endif /* VIDIOC_S_DV_TIMINGS */ 00147 00148 /* vim: set ts=8 sw=4 et : */