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/enotsup.h> 00026 #include <libexplain/buffer/is_the_null_pointer.h> 00027 #include <libexplain/buffer/v4l2_crop.h> 00028 #include <libexplain/iocontrol/generic.h> 00029 #include <libexplain/iocontrol/vidioc_s_crop.h> 00030 00031 #ifdef VIDIOC_S_CROP 00032 00033 00034 static void 00035 print_data(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00036 int errnum, int fildes, int request, const void *data) 00037 { 00038 (void)p; 00039 (void)errnum; 00040 (void)fildes; 00041 (void)request; 00042 explain_buffer_v4l2_crop(sb, data, 1); 00043 } 00044 00045 00046 static void 00047 print_explanation(const explain_iocontrol_t *p, explain_string_buffer_t *sb, 00048 int errnum, int fildes, int request, const void *data) 00049 { 00050 /* 00051 * Note: Linux: 00052 * drivers/media/video/sh_vou.c can return EIO when it means EINVAL 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 switch (explain_v4l2_crop_check_type(fildes, data)) 00064 { 00065 case explain_v4l2_crop_check_type_no_idea: 00066 default: 00067 goto generic; 00068 00069 case explain_v4l2_crop_check_type_notsup: 00070 explain_buffer_enotsup_device(sb, "data->type"); 00071 break; 00072 00073 case explain_v4l2_crop_check_type_nosuch: 00074 explain_buffer_einval_vague(sb, "data->type"); 00075 break; 00076 00077 case explain_v4l2_crop_check_type_ok: 00078 /* 00079 * FIXME: which of left, top, width, height? 00080 * Sometimes it will be an alignment issue, 00081 * e.g. RGGB and YYUV devices demand even alignment. 00082 */ 00083 explain_buffer_einval_vague(sb, "data->c"); 00084 break; 00085 } 00086 break; 00087 00088 default: 00089 generic: 00090 explain_iocontrol_generic_print_explanation 00091 ( 00092 p, 00093 sb, 00094 errnum, 00095 fildes, 00096 request, 00097 data 00098 ); 00099 break; 00100 } 00101 } 00102 00103 00104 const explain_iocontrol_t explain_iocontrol_vidioc_s_crop = 00105 { 00106 "VIDIOC_S_CROP", /* name */ 00107 VIDIOC_S_CROP, /* value */ 00108 0, /* disambiguate */ 00109 0, /* print_name */ 00110 print_data, 00111 print_explanation, 00112 0, /* print_data_returned */ 00113 sizeof(struct v4l2_crop), /* data_size */ 00114 "struct v4l2_crop *", /* data_type */ 00115 0, /* flags */ 00116 __FILE__, 00117 __LINE__, 00118 }; 00119 00120 #else /* ndef VIDIOC_S_CROP */ 00121 00122 const explain_iocontrol_t explain_iocontrol_vidioc_s_crop = 00123 { 00124 0, /* name */ 00125 0, /* value */ 00126 0, /* disambiguate */ 00127 0, /* print_name */ 00128 0, /* print_data */ 00129 0, /* print_explanation */ 00130 0, /* print_data_returned */ 00131 0, /* data_size */ 00132 0, /* data_type */ 00133 0, /* flags */ 00134 __FILE__, 00135 __LINE__, 00136 }; 00137 00138 #endif /* VIDIOC_S_CROP */ 00139 00140 /* vim: set ts=8 sw=4 et : */