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/einval.h> 00025 #include <libexplain/buffer/enosys.h> 00026 #include <libexplain/buffer/is_the_null_pointer.h> 00027 #include <libexplain/buffer/v4l2_priority.h> 00028 #include <libexplain/iocontrol/generic.h> 00029 #include <libexplain/iocontrol/vidioc_s_priority.h> 00030 #include <libexplain/is_efault.h> 00031 00032 #ifdef VIDIOC_S_PRIORITY 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 explain_buffer_v4l2_priority_ptr(sb, data); 00044 } 00045 00046 00047 static void 00048 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00049 int errnum, int fildes, int request, const void *data) 00050 { 00051 switch (errnum) 00052 { 00053 case EINVAL: 00054 if (!data) 00055 { 00056 explain_buffer_is_the_null_pointer(sb, "data"); 00057 return; 00058 } 00059 00060 { 00061 enum v4l2_priority qry; 00062 00063 /* 00064 * It's always possible that VIDIOC_G_PRIORITY is supported 00065 * but VIDIOC_S_PRIORITY is not, but none of the drivers had 00066 * that property when I checked. 00067 */ 00068 if (ioctl(fildes, VIDIOC_G_PRIORITY, &qry) < 0 && errno == EINVAL) 00069 { 00070 explain_buffer_enosys_fildes 00071 ( 00072 sb, 00073 fildes, 00074 "fildes", 00075 "ioctl VIDIOC_S_PRIORITY" 00076 ); 00077 return; 00078 } 00079 } 00080 00081 { 00082 const enum v4l2_priority *arg; 00083 00084 arg = data; 00085 if (!explain_is_efault_pointer(arg, sizeof(*arg))) 00086 { 00087 /* 00088 * Linux Kernel: 00089 * file drivers/media/video/v4l2-common.c, line 88 00090 */ 00091 switch (*arg) 00092 { 00093 case V4L2_PRIORITY_BACKGROUND: 00094 case V4L2_PRIORITY_INTERACTIVE: 00095 case V4L2_PRIORITY_RECORD: 00096 break; 00097 00098 case V4L2_PRIORITY_UNSET: 00099 default: 00100 explain_buffer_einval_out_of_range 00101 ( 00102 sb, 00103 "data", 00104 V4L2_PRIORITY_BACKGROUND, 00105 V4L2_PRIORITY_RECORD 00106 ); 00107 return; 00108 } 00109 } 00110 } 00111 00112 /* No idea */ 00113 explain_buffer_einval_vague(sb, "data"); 00114 return; 00115 00116 default: 00117 explain_iocontrol_generic_print_explanation 00118 ( 00119 p, 00120 sb, 00121 errnum, 00122 fildes, 00123 request, 00124 data 00125 ); 00126 break; 00127 } 00128 } 00129 00130 00131 const explain_iocontrol_t explain_iocontrol_vidioc_s_priority = 00132 { 00133 "VIDIOC_S_PRIORITY", /* name */ 00134 VIDIOC_S_PRIORITY, /* value */ 00135 0, /* disambiguate */ 00136 0, /* print_name */ 00137 print_data, 00138 print_explanation, 00139 0, /* print_data_returned */ 00140 sizeof(enum v4l2_priority), /* data_size */ 00141 "enum v4l2_priority *", /* data_type */ 00142 0, /* flags */ 00143 __FILE__, 00144 __LINE__, 00145 }; 00146 00147 #else /* ndef VIDIOC_S_PRIORITY */ 00148 00149 const explain_iocontrol_t explain_iocontrol_vidioc_s_priority = 00150 { 00151 0, /* name */ 00152 0, /* value */ 00153 0, /* disambiguate */ 00154 0, /* print_name */ 00155 0, /* print_data */ 00156 0, /* print_explanation */ 00157 0, /* print_data_returned */ 00158 0, /* data_size */ 00159 0, /* data_type */ 00160 0, /* flags */ 00161 __FILE__, 00162 __LINE__, 00163 }; 00164 00165 #endif /* VIDIOC_S_PRIORITY */ 00166 00167 /* vim: set ts=8 sw=4 et : */