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/sys/ioctl.h> 00023 00024 #include <libexplain/buffer/dac.h> 00025 #include <libexplain/buffer/eperm.h> 00026 #include <libexplain/buffer/is_the_null_pointer.h> 00027 #include <libexplain/buffer/v4l2_dbg_register.h> 00028 #include <libexplain/buffer/v4l2_register.h> 00029 #include <libexplain/iocontrol/generic.h> 00030 #include <libexplain/iocontrol/vidioc_dbg_g_register.h> 00031 00032 #ifdef VIDIOC_DBG_G_REGISTER 00033 00034 00035 static void 00036 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00037 int errnum, int fildes, int request, const void *data) 00038 { 00039 (void)p; 00040 (void)errnum; 00041 (void)fildes; 00042 (void)request; 00043 #ifdef HAVE_V4L2_DBG_REGISTER 00044 explain_buffer_v4l2_dbg_register(sb, data, 0); 00045 #else 00046 explain_buffer_v4l2_register(sb, data, 0); 00047 #endif 00048 } 00049 00050 00051 static void 00052 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00053 int errnum, int fildes, int request, const void *data) 00054 { 00055 switch (errnum) 00056 { 00057 case EPERM: 00058 explain_buffer_eperm_vague(sb, "ioctl VIDIOC_DBG_G_REGISTER"); 00059 explain_buffer_dac_sys_admin(sb); 00060 break; 00061 00062 case EINVAL: 00063 if (!data) 00064 { 00065 explain_buffer_is_the_null_pointer(sb, "data"); 00066 return; 00067 } 00068 00069 /* 00070 * It could be the address is invalid, or it could be that this 00071 * actually means ENOTTY. Guess the latter. 00072 */ 00073 errnum = ENOTTY; 00074 /* Fall through... */ 00075 00076 default: 00077 explain_iocontrol_generic_print_explanation 00078 ( 00079 p, 00080 sb, 00081 errnum, 00082 fildes, 00083 request, 00084 data 00085 ); 00086 break; 00087 } 00088 } 00089 00090 00091 static void 00092 print_data_returned(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00093 int errnum, int fildes, int request, const void *data) 00094 { 00095 (void)p; 00096 (void)errnum; 00097 (void)fildes; 00098 (void)request; 00099 #ifdef HAVE_V4L2_DBG_REGISTER 00100 explain_buffer_v4l2_dbg_register(sb, data, 1); 00101 #else 00102 explain_buffer_v4l2_register(sb, data, 1); 00103 #endif 00104 } 00105 00106 00107 const explain_iocontrol_t explain_iocontrol_vidioc_dbg_g_register = 00108 { 00109 "VIDIOC_DBG_G_REGISTER", /* name */ 00110 VIDIOC_DBG_G_REGISTER, /* value */ 00111 0, /* disambiguate */ 00112 0, /* print_name */ 00113 print_data, 00114 print_explanation, 00115 print_data_returned, 00116 #ifdef HAVE_V4L2_DBG_REGISTER 00117 sizeof(struct v4l2_dbg_register), /* data_size */ 00118 "struct v4l2_dbg_register *", /* data_type */ 00119 0, /* flags */ 00120 #else 00121 sizeof(struct v4l2_register), /* data_size */ 00122 "struct v4l2_register *", /* data_type */ 00123 0, /* flags */ 00124 #endif 00125 __FILE__, 00126 __LINE__, 00127 }; 00128 00129 #else /* ndef VIDIOC_DBG_G_REGISTER */ 00130 00131 const explain_iocontrol_t explain_iocontrol_vidioc_dbg_g_register = 00132 { 00133 0, /* name */ 00134 0, /* value */ 00135 0, /* disambiguate */ 00136 0, /* print_name */ 00137 0, /* print_data */ 00138 0, /* print_explanation */ 00139 0, /* print_data_returned */ 00140 0, /* data_size */ 00141 0, /* data_type */ 00142 0, /* flags */ 00143 __FILE__, 00144 __LINE__, 00145 }; 00146 00147 #endif /* VIDIOC_DBG_G_REGISTER */ 00148 00149 /* vim: set ts=8 sw=4 et : */