void test_VIDIOC_QUERYCAP() { int ret; struct v4l2_capability cap; struct v4l2_capability cap2; memset(&cap, 0xff, sizeof(cap)); ret = ioctl(get_video_fd(), VIDIOC_QUERYCAP, &cap); dprintf("VIDIOC_QUERYCAP, ret=%i\n", ret); dprintf("\tcap = { .driver = \"%s\", .card = \"%s\", " ".bus_info = \"%s\", " ".version = %u.%u.%u, " ".capabilities = 0x%X, " ".reserved[]={ 0x%X, 0x%X, 0x%X, 0x%X } }\n", cap.driver, cap.card, cap.bus_info, (cap.version >> 16) & 0xFF, (cap.version >> 8) & 0xFF, cap.version & 0xFF, cap.capabilities, cap.reserved[0], cap.reserved[1], cap.reserved[2], cap.reserved[3] ); /* This ioctl must be implemented by ALL drivers */ CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { CU_ASSERT(0 < strlen( (char*)cap.driver) ); CU_ASSERT(valid_string((char*)cap.driver, sizeof(cap.driver))); CU_ASSERT(0 < strlen( (char*)cap.card) ); CU_ASSERT(valid_string((char*)cap.card, sizeof(cap.card))); /* cap.bus_info is allowed to be an empty string ("") if no * is info available */ CU_ASSERT(valid_string((char*)cap.bus_info, sizeof(cap.bus_info))); //CU_ASSERT_EQUAL(cap.version, ?); CU_ASSERT(valid_capabilities(cap.capabilities)); CU_ASSERT_EQUAL(cap.reserved[0], 0); CU_ASSERT_EQUAL(cap.reserved[1], 0); CU_ASSERT_EQUAL(cap.reserved[2], 0); CU_ASSERT_EQUAL(cap.reserved[3], 0); /* Check if the unused bytes of the driver, card and bus_info * strings are also filled with zeros. Also check if there is * any padding byte between any two fields then this padding * byte is also filled with zeros. */ memset(&cap2, 0, sizeof(cap2)); strncpy((char*)cap2.driver, (char*)cap.driver, sizeof(cap2.driver)); strncpy((char*)cap2.card, (char*)cap.card, sizeof(cap2.card)); strncpy((char*)cap2.bus_info, (char*)cap.bus_info, sizeof(cap2.bus_info)); cap2.version = cap.version; cap2.capabilities = cap.capabilities; CU_ASSERT_EQUAL(memcmp(&cap, &cap2, sizeof(cap)), 0); } }
void test_VIDIOC_CROPCAP_NULL() { int ret_capture, errno_capture; int ret_output, errno_output; int ret_overlay, errno_overlay; int ret_private, errno_private; int ret_private_1, errno_private_1; int ret_null, errno_null; struct v4l2_cropcap cropcap; memset(&cropcap, 0xff, sizeof(cropcap)); cropcap.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; ret_capture = ioctl(get_video_fd(), VIDIOC_CROPCAP, &cropcap); errno_capture = errno; dprintf("\t%s:%u: VIDIOC_CROPCAP, ret_capture=%i, errno_capture=%i\n", __FILE__, __LINE__, ret_capture, errno_capture); memset(&cropcap, 0xff, sizeof(cropcap)); cropcap.type = V4L2_BUF_TYPE_VIDEO_OUTPUT; ret_output = ioctl(get_video_fd(), VIDIOC_CROPCAP, &cropcap); errno_output = errno; dprintf("\t%s:%u: VIDIOC_CROPCAP, ret_output=%i, errno_output=%i\n", __FILE__, __LINE__, ret_output, errno_output); memset(&cropcap, 0xff, sizeof(cropcap)); cropcap.type = V4L2_BUF_TYPE_VIDEO_OVERLAY; ret_overlay = ioctl(get_video_fd(), VIDIOC_CROPCAP, &cropcap); errno_overlay = errno; dprintf("\t%s:%u: VIDIOC_CROPCAP, ret_overlay=%i, errno_overlay=%i\n", __FILE__, __LINE__, ret_overlay, errno_overlay); memset(&cropcap, 0xff, sizeof(cropcap)); cropcap.type = V4L2_BUF_TYPE_PRIVATE; ret_private = ioctl(get_video_fd(), VIDIOC_CROPCAP, &cropcap); errno_private = errno; dprintf("\t%s:%u: VIDIOC_CROPCAP, ret_private=%i, errno_private=%i\n", __FILE__, __LINE__, ret_private, errno_private); memset(&cropcap, 0xff, sizeof(cropcap)); cropcap.type = V4L2_BUF_TYPE_PRIVATE + 1; ret_private_1 = ioctl(get_video_fd(), VIDIOC_CROPCAP, &cropcap); errno_private_1 = errno; dprintf ("\t%s:%u: VIDIOC_CROPCAP, ret_private_1=%i, errno_private_1=%i\n", __FILE__, __LINE__, ret_private_1, errno_private_1); ret_null = ioctl(get_video_fd(), VIDIOC_CROPCAP, NULL); errno_null = errno; dprintf("\t%s:%u: VIDIOC_CROPCAP, ret_null=%i, errno_null=%i\n", __FILE__, __LINE__, ret_null, errno_null); /* Check if at least one type was supported */ if (ret_capture == 0 || ret_output == 0 || ret_overlay == 0 || ret_private == 0 || ret_private_1 == 0) { /* the parameter shall be validated */ CU_ASSERT_EQUAL(ret_null, -1); CU_ASSERT_EQUAL(errno_null, EFAULT); } else { /* VIDIOC_CROPCAP is not supported at all, the parameter * shall also not be checked. */ CU_ASSERT_EQUAL(ret_capture, -1); CU_ASSERT_EQUAL(errno_capture, EINVAL); CU_ASSERT_EQUAL(ret_output, -1); CU_ASSERT_EQUAL(errno_output, EINVAL); CU_ASSERT_EQUAL(ret_overlay, -1); CU_ASSERT_EQUAL(errno_overlay, EINVAL); CU_ASSERT_EQUAL(ret_private, -1); CU_ASSERT_EQUAL(errno_private, EINVAL); CU_ASSERT_EQUAL(ret_private_1, -1); CU_ASSERT_EQUAL(errno_private_1, EINVAL); CU_ASSERT_EQUAL(ret_null, -1); CU_ASSERT_EQUAL(errno_null, EINVAL); } }
static void do_ioctl_VIDIOC_CROPCAP(enum v4l2_buf_type buf_type, int expected_ret) { int ret_cap, errno_cap; struct v4l2_cropcap cropcap; struct v4l2_cropcap cropcap2; memset(&cropcap, 0xff, sizeof(cropcap)); cropcap.type = buf_type; ret_cap = ioctl(get_video_fd(), VIDIOC_CROPCAP, &cropcap); errno_cap = errno; dprintf("\t%s:%u: type=%i, ret_cap=%i, errno_cap=%i, expected_ret=%i\n", __FILE__, __LINE__, buf_type, ret_cap, errno_cap, expected_ret); if (expected_ret != 0) { CU_ASSERT_EQUAL(ret_cap, expected_ret); } if (ret_cap == 0) { CU_ASSERT_EQUAL(ret_cap, 0); CU_ASSERT_EQUAL(cropcap.type, buf_type); /* | left x */ /* ----+----+--------------------------------------> */ /* | : */ /* top + +-------- cropcap ------------+ ^ */ /* | | | | */ /* | | +------- defrect ---------+ | | */ /* | | | | | | */ /* | | | | | | */ /* | | | | | | height */ /* | | +-------------------------+ | | */ /* | | | | */ /* | | | | */ /* | +-----------------------------+ v */ /* | : : */ /* | <---------- width ------------> */ /* | */ /* v y */ /* top left corner */ CU_ASSERT(cropcap.bounds.left <= cropcap.defrect.left); CU_ASSERT(cropcap.bounds.top <= cropcap.defrect.top); /* size of default cropping rectangle should be smaller or */ /* equal to the cropping bounds */ CU_ASSERT(cropcap.defrect.width <= cropcap.bounds.width); CU_ASSERT(cropcap.defrect.height <= cropcap.bounds.height); /* the right bottom corner should not exceed bounds */ CU_ASSERT(cropcap.defrect.left + cropcap.defrect.width <= cropcap.bounds.left + cropcap.bounds.width); CU_ASSERT(cropcap.defrect.top + cropcap.defrect.height <= cropcap.bounds.top + cropcap.bounds.height); //CU_ASSERT_EQUAL(cropcap.pixelaspect.numerator, ?); CU_ASSERT_NOT_EQUAL(cropcap.pixelaspect.numerator, 0); //CU_ASSERT_EQUAL(cropcap.pixelaspect.denominator, ?); CU_ASSERT_NOT_EQUAL(cropcap.pixelaspect.denominator, 0); dprintf("\tcropcap = { .type = %i, " ".bounds = { .left = %i, .top = %i, .width = %i, .height = %i }, " ".defrect = { .left = %i, .top = %i, .width = %i, .height = %i }, " ".pixelaspect = { .numerator = %u, .denominator = %u } " "}\n", cropcap.type, cropcap.bounds.left, cropcap.bounds.top, cropcap.bounds.width, cropcap.bounds.height, cropcap.defrect.left, cropcap.defrect.top, cropcap.defrect.width, cropcap.defrect.height, cropcap.pixelaspect.numerator, cropcap.pixelaspect.denominator); } else { CU_ASSERT_EQUAL(ret_cap, -1); CU_ASSERT_EQUAL(errno_cap, EINVAL); memset(&cropcap2, 0xff, sizeof(cropcap2)); cropcap2.type = buf_type; CU_ASSERT_EQUAL(memcmp(&cropcap, &cropcap2, sizeof(cropcap)), 0); } }
void test_VIDIOC_S_FREQUENCY() { int ret_get, errno_get; int ret_set, errno_set; __u32 tuner; struct v4l2_frequency orig_freq; struct v4l2_frequency freq; struct v4l2_frequency new_freq; tuner = 0; /* fetch the current frequency setting */ memset(&orig_freq, 0xff, sizeof(orig_freq)); orig_freq.tuner = tuner; ret_get = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &orig_freq); errno_get = errno; dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret_get=%i, errno_get=%i\n", __FILE__, __LINE__, ret_get, errno_get); if (ret_get == 0) { CU_ASSERT_EQUAL(orig_freq.tuner, tuner); /* try to set the frequency again to the actual value */ memset(&freq, 0xff, sizeof(freq)); freq.tuner = tuner; freq.frequency = orig_freq.frequency; freq.type = V4L2_TUNER_ANALOG_TV; ret_set = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &orig_freq); errno_set = errno; dprintf("\t%s:%u: VIDIOC_S_FREQUENCY, ret_set=%i, errno_set=%i\n", __FILE__, __LINE__, ret_set, errno_set); CU_ASSERT_EQUAL(ret_set, 0); if (ret_set == 0) { /* check wheteher the frequency has not been changed */ memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = tuner; ret_get = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); errno_get = errno; dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret_get=%i, errno_get=%i\n", __FILE__, __LINE__, ret_get, errno_get); CU_ASSERT_EQUAL(ret_get, 0); if (ret_get == 0) { dprintf("\t%s:%u: current frequency=%u (expected %u)\n", __FILE__, __LINE__, new_freq.frequency, orig_freq.frequency); CU_ASSERT_EQUAL(new_freq.frequency, orig_freq.frequency); } } } else { CU_ASSERT_EQUAL(ret_get, -1); CU_ASSERT_EQUAL(errno_get, EINVAL); /* VIDIOC_G_FREQUENCY not supported, so shall be VIDIOC_S_FREQUENCY */ memset(&freq, 0, sizeof(freq)); freq.tuner = tuner; freq.type = V4L2_TUNER_ANALOG_TV; freq.frequency = 0; ret_set = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); errno_set = errno; dprintf("\t%s:%u: VIDIOC_S_FREQUENCY, ret_set=%i, errno_set=%i\n", __FILE__, __LINE__, ret_set, errno_set); CU_ASSERT_EQUAL(ret_set, -1); CU_ASSERT_EQUAL(errno_set, EINVAL); } }
void test_VIDIOC_ENUMOUTPUT() { int ret_enum, errno_enum; struct v4l2_output output; struct v4l2_output output2; __u32 i; i = 0; do { memset(&output, 0xff, sizeof(output)); output.index = i; ret_enum = ioctl(get_video_fd(), VIDIOC_ENUMOUTPUT, &output); errno_enum = errno; dprintf("\t%s:%u: VIDIOC_ENUMOUTPUT, ret_enum=%i, errno_enum=%i\n", __FILE__, __LINE__, ret_enum, errno_enum); if (ret_enum == 0) { CU_ASSERT_EQUAL(ret_enum, 0); CU_ASSERT_EQUAL(output.index, i); CU_ASSERT(0 < strlen( (char*)output.name )); CU_ASSERT(valid_string((char*)output.name, sizeof(output.name))); //CU_ASSERT_EQUAL(output.type, ?); //CU_ASSERT_EQUAL(output.audioset, ?); //CU_ASSERT_EQUAL(output.modulator, ?); CU_ASSERT(valid_v4l2_std_id(output.std)); CU_ASSERT_EQUAL(output.reserved[0], 0); CU_ASSERT_EQUAL(output.reserved[1], 0); CU_ASSERT_EQUAL(output.reserved[2], 0); CU_ASSERT_EQUAL(output.reserved[3], 0); /* Check if the unused bytes of the name string are * also filled with zeros. Also check if there is any * padding byte between any two fields then this * padding byte is also filled with zeros. */ memset(&output2, 0, sizeof(output2)); output2.index = output.index; strncpy((char*)output2.name, (char*)output.name, sizeof(output2.name)); output2.type = output.type; output2.audioset = output.audioset; output2.modulator = output.modulator; output2.std = output.std; CU_ASSERT_EQUAL(memcmp(&output, &output2, sizeof(output)), 0); dprintf("\toutput = {.index=%u, .name=\"%s\", " ".type=0x%X, .audioset=0x%X, .modulator=0x%X, " ".std=%llX, " ".reserved[]={ 0x%X, 0x%X, 0x%X, 0x%X } }\n", output.index, output.name, output.type, output.audioset, output.modulator, output.std, output.reserved[0], output.reserved[1], output.reserved[2], output.reserved[3] ); } else { CU_ASSERT_EQUAL(ret_enum, -1); CU_ASSERT_EQUAL(errno_enum, EINVAL); memset(&output2, 0xff, sizeof(output2)); output2.index = i; CU_ASSERT_EQUAL(memcmp(&output, &output2, sizeof(output)), 0); dprintf("\terrno=%i\n", errno); } i++; } while (ret_enum == 0); }
void test_invalid_ioctl_4() { do_invalid_ioctl(get_video_fd(), _IO('V', 0xFF)); }
void test_VIDIOC_ENUMAUDOUT() { int ret_enum, errno_enum; struct v4l2_audioout audioout; struct v4l2_audioout audioout2; __u32 i; i = 0; do { memset(&audioout, 0xff, sizeof(audioout)); audioout.index = i; ret_enum = ioctl(get_video_fd(), VIDIOC_ENUMAUDOUT, &audioout); errno_enum = errno; dprintf("\tVIDIOC_ENUMAUDOUT, ret_enum=%i, errno_enum=%i\n", ret_enum, errno_enum); if (ret_enum == 0) { CU_ASSERT_EQUAL(ret_enum, 0); CU_ASSERT_EQUAL(audioout.index, i); CU_ASSERT(0 < strlen( (char*)audioout.name )); CU_ASSERT(valid_string((char*)audioout.name, sizeof(audioout.name))); //CU_ASSERT_EQUAL(audioout.capability, ?); //CU_ASSERT_EQUAL(audioout.mode, ?); CU_ASSERT_EQUAL(audioout.reserved[0], 0); CU_ASSERT_EQUAL(audioout.reserved[1], 0); /* Check if the unused bytes of the name string are * also filled with zeros. Also check if there is any * padding byte between any two fields then this * padding byte is also filled with zeros. */ memset(&audioout2, 0, sizeof(audioout2)); audioout2.index = audioout.index; strncpy((char*)audioout2.name, (char*)audioout.name, sizeof(audioout2.name)); audioout2.capability = audioout.capability; audioout2.mode = audioout.mode; CU_ASSERT_EQUAL(memcmp(&audioout, &audioout2, sizeof(audioout)), 0); dprintf("\taudioout = {.index=%u, .name=\"%s\", " ".capability=0x%X, .mode=0x%X, " ".reserved[]={ 0x%X, 0x%X } }\n", audioout.index, audioout.name, audioout.capability, audioout.mode, audioout.reserved[0], audioout.reserved[1] ); } else { CU_ASSERT_EQUAL(ret_enum, -1); CU_ASSERT_EQUAL(errno_enum, EINVAL); /* check whether the structure is untouched */ memset(&audioout2, 0xff, sizeof(audioout2)); audioout2.index = i; CU_ASSERT_EQUAL(memcmp(&audioout, &audioout2, sizeof(audioout)), 0); } i++; } while (ret_enum == 0); }
void test_VIDIOC_QUERYCTRL_private() { int ret_query, errno_query; struct v4l2_queryctrl queryctrl; struct v4l2_queryctrl queryctrl2; __u32 i; i = V4L2_CID_PRIVATE_BASE; do { memset(&queryctrl, 0xff, sizeof(queryctrl)); queryctrl.id = i; ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; dprintf("\t%s:%u: VIDIOC_QUERYCTRL, id=%u (V4L2_CID_BASE+%i), ret_query=%i, errno_query=%i\n", __FILE__, __LINE__, i, i-V4L2_CID_BASE, ret_query, errno_query); if (ret_query == 0) { CU_ASSERT_EQUAL(ret_query, 0); CU_ASSERT_EQUAL(queryctrl.id, i); CU_ASSERT(0 < strlen( (char*)queryctrl.name )); CU_ASSERT(valid_string((char*)queryctrl.name, sizeof(queryctrl.name))); CU_ASSERT(valid_control_type(queryctrl.type)); switch (queryctrl.type) { case V4L2_CTRL_TYPE_INTEGER: /* min < max, because otherwise this control makes no sense */ CU_ASSERT(queryctrl.minimum < queryctrl.maximum); CU_ASSERT(0 < queryctrl.step); CU_ASSERT(queryctrl.minimum <= queryctrl.default_value); CU_ASSERT(queryctrl.default_value <= queryctrl.maximum); break; case V4L2_CTRL_TYPE_BOOLEAN: CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT_EQUAL(queryctrl.maximum, 1); CU_ASSERT_EQUAL(queryctrl.step, 1); CU_ASSERT((queryctrl.default_value == 0) || (queryctrl.default_value == 1)); break; case V4L2_CTRL_TYPE_MENU: CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT(queryctrl.minimum <= queryctrl.default_value); CU_ASSERT_EQUAL(queryctrl.step, 1); CU_ASSERT(queryctrl.minimum <= queryctrl.default_value); CU_ASSERT(queryctrl.default_value <= queryctrl.maximum); break; case V4L2_CTRL_TYPE_BUTTON: CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT_EQUAL(queryctrl.maximum, 0); CU_ASSERT_EQUAL(queryctrl.step, 0); CU_ASSERT_EQUAL(queryctrl.default_value, 0); break; case V4L2_CTRL_TYPE_INTEGER64: /* fallthrough */ case V4L2_CTRL_TYPE_CTRL_CLASS: /* These parameters are defined as n/a by V4L2, so * they should be filled with zeros, the same like * the reserved fields. */ CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT_EQUAL(queryctrl.maximum, 0); CU_ASSERT_EQUAL(queryctrl.step, 0); CU_ASSERT_EQUAL(queryctrl.default_value, 0); break; default: CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT_EQUAL(queryctrl.maximum, 0); CU_ASSERT_EQUAL(queryctrl.step, 0); CU_ASSERT_EQUAL(queryctrl.default_value, 0); } CU_ASSERT(valid_control_flag(queryctrl.flags)); CU_ASSERT_EQUAL(queryctrl.reserved[0], 0); CU_ASSERT_EQUAL(queryctrl.reserved[1], 0); /* Check if the unused bytes of the name string are * also filled with zeros. Also check if there is any * padding byte between any two fields then this * padding byte is also filled with zeros. */ memset(&queryctrl2, 0, sizeof(queryctrl2)); queryctrl2.id = queryctrl.id; queryctrl2.type = queryctrl.type; strncpy((char*)queryctrl2.name, (char*)queryctrl.name, sizeof(queryctrl2.name)); queryctrl2.minimum = queryctrl.minimum; queryctrl2.maximum = queryctrl.maximum; queryctrl2.step = queryctrl.step; queryctrl2.default_value = queryctrl.default_value; queryctrl2.flags = queryctrl.flags; CU_ASSERT_EQUAL(memcmp(&queryctrl, &queryctrl2, sizeof(queryctrl)), 0); dprintf("\tqueryctrl = {.id=%u, .type=%i, .name=\"%s\", " ".minimum=%i, .maximum=%i, .step=%i, " ".default_value=%i, " ".flags=0x%X, " ".reserved[]={ 0x%X, 0x%X } }\n", queryctrl.id, queryctrl.type, queryctrl.name, queryctrl.minimum, queryctrl.maximum, queryctrl.step, queryctrl.default_value, queryctrl.flags, queryctrl.reserved[0], queryctrl.reserved[1] ); } else { CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); memset(&queryctrl2, 0xff, sizeof(queryctrl2)); queryctrl2.id = i; CU_ASSERT_EQUAL(memcmp(&queryctrl, &queryctrl2, sizeof(queryctrl)), 0); } } while (ret_query == 0); }
void test_VIDIOC_QUERYCTRL_NULL() { int ret_query, errno_query; int ret_null, errno_null; struct v4l2_queryctrl queryctrl; __u32 i; unsigned int count_ctrl; count_ctrl = 0; i = V4L2_CID_BASE; for (i = V4L2_CID_BASE; i < V4L2_CID_LASTP1; i++) { memset(&queryctrl, 0xff, sizeof(queryctrl)); queryctrl.id = i; ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; dprintf("\t%s:%u: VIDIOC_QUERYCTRL, id=%u (V4L2_CID_BASE+%i), ret_query=%i, errno_query=%i\n", __FILE__, __LINE__, i, i-V4L2_CID_BASE, ret_query, errno_query); if (ret_query == 0) { CU_ASSERT_EQUAL(ret_query, 0); count_ctrl++; } else { CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); } } i = V4L2_CID_PRIVATE_BASE; do { memset(&queryctrl, 0xff, sizeof(queryctrl)); queryctrl.id = i; ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; dprintf("\t%s:%u: VIDIOC_QUERYCTRL, id=%u (V4L2_CID_PRIVATE_BASE+%i), ret_query=%i, errno_query=%i\n", __FILE__, __LINE__, i, i-V4L2_CID_PRIVATE_BASE, ret_query, errno_query); if (ret_query == 0) { CU_ASSERT_EQUAL(ret_query, 0); count_ctrl++; } else { CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); } i++; } while (ret_query == 0 && V4L2_CID_PRIVATE_BASE <= i); ret_null = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, NULL); errno_null = errno; dprintf("\t%s:%u: VIDIOC_QUERYCTRL, ret_null=%i, errno_null=%i\n", __FILE__, __LINE__, ret_null, errno_null); if (0 < count_ctrl) { CU_ASSERT_EQUAL(ret_null, -1); CU_ASSERT_EQUAL(errno_null, EFAULT); } else { CU_ASSERT_EQUAL(ret_null, -1); CU_ASSERT_EQUAL(errno_null, EINVAL); } }
void test_VIDIOC_S_AUDIO_NULL() { int ret_orig, errno_orig; int ret_set, errno_set; int ret_null, errno_null; struct v4l2_audio audio_orig; struct v4l2_audio audio_set; /* remember the original settings */ memset(&audio_orig, 0, sizeof(audio_orig)); ret_orig = ioctl(get_video_fd(), VIDIOC_G_AUDIO, &audio_orig); errno_orig = errno; dprintf("\t%s:%u: VIDIOC_G_AUDIO, ret_orig=%i, errno_orig=%i\n", __FILE__, __LINE__, ret_orig, errno_orig); memset(&audio_set, 0, sizeof(audio_set)); ret_set = ioctl(get_video_fd(), VIDIOC_S_AUDIO, &audio_set); errno_set = errno; dprintf("\t%s:%u: VIDIOC_S_AUDIO, ret_set=%i, errno_set=%i\n", __FILE__, __LINE__, ret_set, errno_set); ret_null = ioctl(get_video_fd(), VIDIOC_S_AUDIO, NULL); errno_null = errno; dprintf("\t%s:%u: VIDIOC_S_AUDIO, ret_null=%i, errno_null=%i\n", __FILE__, __LINE__, ret_null, errno_null); if (ret_set == 0) { CU_ASSERT_EQUAL(ret_set, 0); CU_ASSERT_EQUAL(ret_null, -1); CU_ASSERT_EQUAL(errno_null, EFAULT); } else { CU_ASSERT_EQUAL(ret_set, -1); CU_ASSERT_EQUAL(errno_set, EINVAL); CU_ASSERT_EQUAL(ret_null, -1); CU_ASSERT_EQUAL(errno_null, EINVAL); } /* restore the original audio input settings */ memset(&audio_set, 0, sizeof(audio_set)); audio_set.index = audio_orig.index; ret_set = ioctl(get_video_fd(), VIDIOC_S_AUDIO, &audio_set); errno_set = errno; dprintf("\t%s:%u: VIDIOC_S_AUDIO, ret_set=%i, errno_set=%i\n", __FILE__, __LINE__, ret_set, errno_set); if (ret_orig == 0) { /* If it was possible at the beginning to get the audio input then * it shall be possible to set it again. */ CU_ASSERT_EQUAL(ret_orig, 0); CU_ASSERT_EQUAL(ret_set, 0); } else { /* In case we could not fetch the audio input value at the start * of this test case: the VIDIOC_S_AUDIO shall also fail. */ CU_ASSERT_EQUAL(ret_orig, -1); CU_ASSERT_EQUAL(errno_orig, EINVAL); CU_ASSERT_EQUAL(ret_set, -1); CU_ASSERT_EQUAL(errno_set, EINVAL); } }
void test_VIDIOC_QUERYCTRL_flag_NEXT_CTRL() { int ret_query, errno_query; char count_controls1[V4L2_CID_LASTP1-V4L2_CID_BASE]; char count_controls2[V4L2_CID_LASTP1-V4L2_CID_BASE]; struct v4l2_queryctrl controls[V4L2_CID_LASTP1-V4L2_CID_BASE]; struct v4l2_queryctrl queryctrl; __u32 i; /* find out all the possible user controls */ memset(count_controls1, 0, sizeof(count_controls1)); memset(controls, 0, sizeof(controls)); for (i = V4L2_CID_BASE; i < V4L2_CID_LASTP1; i++) { memset(&queryctrl, 0xff, sizeof(queryctrl)); queryctrl.id = i; ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; if (ret_query == 0) { CU_ASSERT_EQUAL(ret_query, 0); CU_ASSERT_EQUAL(queryctrl.id, i); count_controls1[i-V4L2_CID_BASE]++; controls[i-V4L2_CID_BASE] = queryctrl; dprintf("\tqueryctrl = {.id=%u, .type=%i, .name=\"%s\", " ".minimum=%i, .maximum=%i, .step=%i, " ".default_value=%i, " ".flags=0x%X, " ".reserved[]={ 0x%X, 0x%X } }\n", queryctrl.id, queryctrl.type, queryctrl.name, queryctrl.minimum, queryctrl.maximum, queryctrl.step, queryctrl.default_value, queryctrl.flags, queryctrl.reserved[0], queryctrl.reserved[1] ); } else { CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); } } /* enumerate the controls with V4L2_CTRL_FLAG_NEXT_CTRL */ dprintf1("\tStarting enumeration with V4L2_CTRL_FLAG_NEXT_CTRL\n"); memset(count_controls2, 0, sizeof(count_controls2)); /* As described at V4L2 Chapter 1.9.3. Enumerating Extended Controls */ i = 0; memset(&queryctrl, 0xff, sizeof(queryctrl)); queryctrl.id = i | V4L2_CTRL_FLAG_NEXT_CTRL; dprintf("\tasking for id=%i=V4L2_CID_BASE+%i | V4L2_CTRL_FLAG_NEXT_CTRL\n", i, i-V4L2_CID_BASE); ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; dprintf("\tret_query=%i\n", ret_query); if (ret_query == 0) { do { /* protect the count_controls2[] from overindexing */ if ((V4L2_CID_BASE <= queryctrl.id) && (queryctrl.id < V4L2_CID_LASTP1)) { count_controls2[queryctrl.id-V4L2_CID_BASE]++; CU_ASSERT_EQUAL(memcmp(&queryctrl, &controls[queryctrl.id-V4L2_CID_BASE], sizeof(queryctrl)), 0); } /* "The VIDIOC_QUERYCTRL ioctl will return the first * control with a higher ID than the specified one." */ CU_ASSERT(i < queryctrl.id); CU_ASSERT(V4L2_CID_BASE <= queryctrl.id); CU_ASSERT(queryctrl.id < V4L2_CID_LASTP1); dprintf("\tqueryctrl = {.id=%u, .type=%i, .name=\"%s\", " ".minimum=%i, .maximum=%i, .step=%i, " ".default_value=%i, " ".flags=0x%X, " ".reserved[]={ 0x%X, 0x%X } }\n", queryctrl.id, queryctrl.type, queryctrl.name, queryctrl.minimum, queryctrl.maximum, queryctrl.step, queryctrl.default_value, queryctrl.flags, queryctrl.reserved[0], queryctrl.reserved[1] ); i = queryctrl.id; memset(&queryctrl, 0xff, sizeof(queryctrl)); queryctrl.id = i | V4L2_CTRL_FLAG_NEXT_CTRL; dprintf("\tasking for id=%i=V4L2_CID_BASE+%i | V4L2_CTRL_FLAG_NEXT_CTRL\n", i, i-V4L2_CID_BASE); ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; dprintf("\tret_query=%i\n", ret_query); } while (ret_query == 0 && V4L2_CTRL_ID2CLASS(queryctrl.id) == V4L2_CTRL_CLASS_USER); if (ret_query == 0) { /* some other controls also exists, stop for now. */ } else { CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); } /* Check whether the same controls are reported if using * V4L2_CTRL_FLAG_NEXT_CTRL and without using it. * This also checks if one control is not reported twice. */ CU_ASSERT_EQUAL(memcmp(count_controls1, count_controls2, sizeof(count_controls1)), 0); dprintf1("count_controls1 = { "); for (i=0; i<sizeof(count_controls1)/sizeof(*count_controls1); i++) { dprintf("%i ", count_controls1[i]); } dprintf1("}\n"); dprintf1("count_controls2 = { "); for (i=0; i<sizeof(count_controls2)/sizeof(*count_controls2); i++) { dprintf("%i ", count_controls2[i]); } dprintf1("}\n"); } else { dprintf1("V4L2_CTRL_FLAG_NEXT_CTRL is not supported or no control is available\n"); /* The flag V4L2_CTRL_FLAG_NEXT_CTRL is not supported * or no control is avaliable at all. Do not continue the * enumeration. */ CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); } }
void test_VIDIOC_S_AUDIO() { int ret_orig, errno_orig; int ret_set, errno_set; int ret_enum, errno_enum; __u32 index; __u32 i; struct v4l2_audio audio_orig; struct v4l2_audio audio_enum; struct v4l2_audio audio_set; /* This testcase tries to find out the relations between the following * commands: * - VIDIOC_ENUMAUDIO * - VIDIOC_G_AUDIO * - VIDIOC_S_AUDIO */ /* remember the original settings */ memset(&audio_orig, 0, sizeof(audio_orig)); ret_orig = ioctl(get_video_fd(), VIDIOC_G_AUDIO, &audio_orig); errno_orig = errno; dprintf("\t%s:%u: VIDIOC_G_AUDIO, ret_orig=%i, errno_orig=%i\n", __FILE__, __LINE__, ret_orig, errno_orig); if (ret_orig == 0) { CU_ASSERT_EQUAL(ret_orig, 0); } else { CU_ASSERT_EQUAL(ret_orig, -1); CU_ASSERT_EQUAL(errno_orig, EINVAL); } /* try to continue even if VIDIOC_G_AUDIO seems to be not supported */ index = 0; do { memset(&audio_enum, 0, sizeof(audio_enum)); audio_enum.index = index; ret_enum = ioctl(get_video_fd(), VIDIOC_ENUMAUDIO, &audio_enum); errno_enum = errno; if (ret_enum == 0) { memset(&audio_set, 0xff, sizeof(audio_set)); audio_set.index = index; ret_set = ioctl(get_video_fd(), VIDIOC_S_AUDIO, &audio_set); errno_set = errno; /* It shall be always possible to set the audio input to the * enumerated values. */ CU_ASSERT_EQUAL(ret_enum, 0); index++; } } while (ret_enum == 0); CU_ASSERT_EQUAL(ret_enum, -1); CU_ASSERT_EQUAL(errno_enum, EINVAL); /* try to set audio input to beyond the enumerated values */ for (i=0; i<=32; i++) { memset(&audio_set, 0xff, sizeof(audio_set)); audio_set.index = index; ret_set = ioctl(get_video_fd(), VIDIOC_S_AUDIO, &audio_set); errno_set = errno; CU_ASSERT_EQUAL(ret_set, -1); CU_ASSERT_EQUAL(errno_set, EINVAL); index++; } /* restore the original audio input settings */ memset(&audio_set, 0, sizeof(audio_set)); audio_set.index = audio_orig.index; ret_set = ioctl(get_video_fd(), VIDIOC_S_AUDIO, &audio_set); errno_set = errno; if (ret_orig == 0) { /* If it was possible at the beginning to get the audio input then * it shall be possible to set it again. */ CU_ASSERT_EQUAL(ret_set, 0); } else { /* In case we could not fetch the audio input value at the start * of this test case: the VIDIOC_S_AUDIO shall also fail. */ CU_ASSERT_EQUAL(ret_set, -1); CU_ASSERT_EQUAL(errno_set, EINVAL); } }
void test_VIDIOC_S_FREQUENCY_scan() { int ret_g_tuner, errno_g_tuner; int ret_g_freq, errno_g_freq; int ret_get, errno_get; int ret_set, errno_set; __u32 index; struct v4l2_frequency orig_freq; struct v4l2_frequency freq; struct v4l2_frequency new_freq; struct v4l2_frequency prev_freq; struct v4l2_tuner tuner; __u32 i; /* this test case depends on working VIDIOC_G_FREQUENCY command */ index = 0; /* fetch the minimum (tuner.rangelow) and maximum (tuner.rangehigh) frequency */ memset(&tuner, 0xff, sizeof(tuner)); tuner.index = index; ret_g_tuner = ioctl(get_video_fd(), VIDIOC_G_TUNER, &tuner); errno_g_tuner = errno; dprintf("\t%s:%u: VIDIOC_G_TUNER, ret_g_tuner=%i, errno_g_tuner=%i\n", __FILE__, __LINE__, ret_g_tuner, errno_g_tuner); CU_ASSERT_EQUAL(tuner.index, index); /* fetch the current frequency setting */ memset(&orig_freq, 0xff, sizeof(orig_freq)); orig_freq.tuner = index; ret_g_freq = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &orig_freq); errno_g_freq = errno; dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret_g_freq=%i, errno_g_freq=%i, orig_freq.frequency=%u\n", __FILE__, __LINE__, ret_g_freq, errno_g_freq, orig_freq.frequency); CU_ASSERT_EQUAL(orig_freq.tuner, index); if (ret_g_freq == 0) { CU_ASSERT_EQUAL(orig_freq.tuner, index); dprintf("\t%s:%u: tuner.rangelow=%u, tuner.rangehigh=%u\n", __FILE__, __LINE__, tuner.rangelow, tuner.rangehigh); i = tuner.rangelow; prev_freq.frequency = 0; do { /* try to set the frequency */ memset(&freq, 0xff, sizeof(freq)); freq.tuner = index; freq.type = orig_freq.type; freq.frequency = i; ret_set = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); errno_set = errno; dprintf("\t%s:%u: VIDIOC_S_FREQUENCY, ret_set=%i, errno_set=%i, freq.frequency=%u\n", __FILE__, __LINE__, ret_set, errno_set, i); CU_ASSERT_EQUAL(ret_set, 0); if (ret_set == 0) { memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = index; ret_get = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); errno_get = errno; dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret_get=%i, errno_get=%i, new_freq.frequency=%u\n", __FILE__, __LINE__, ret_get, errno_get, new_freq.frequency); CU_ASSERT_EQUAL(ret_get, 0); if (ret_get == 0) { CU_ASSERT(prev_freq.frequency <= new_freq.frequency); CU_ASSERT(tuner.rangelow <= new_freq.frequency); CU_ASSERT(new_freq.frequency <= tuner.rangehigh); prev_freq = new_freq; } } else { printf("\tError %i while setting to %u\n", errno_set, i); } i++; } while (i <= tuner.rangehigh); /* try restore the original frequency settings */ memset(&freq, 0xff, sizeof(freq)); freq.tuner = index; freq.type = orig_freq.type; freq.frequency = orig_freq.frequency; ret_set = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); errno_set = errno; dprintf("\t%s:%u: VIDIOC_S_FREQUENCY, ret_set=%i, errno_set=%i\n", __FILE__, __LINE__, ret_set, errno_set); CU_ASSERT_EQUAL(ret_set, 0); if (ret_set == 0) { /* check wheteher the frequency has been restored */ memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = index; ret_get = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); errno_get = errno; dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret_get=%i, errno_get=%i, new_freq.frequency=%u\n", __FILE__, __LINE__, ret_get, errno_get, new_freq.frequency); CU_ASSERT_EQUAL(ret_get, 0); if (ret_get == 0) { CU_ASSERT_EQUAL(new_freq.frequency, orig_freq.frequency); } } } if (ret_g_freq != 0) { CU_ASSERT_EQUAL(ret_g_freq, -1); CU_ASSERT_EQUAL(errno, EINVAL); } if (ret_g_tuner != 0) { CU_ASSERT_EQUAL(ret_g_tuner, -1); CU_ASSERT_EQUAL(errno, EINVAL); } }
void test_VIDIOC_S_FREQUENCY_boundaries() { int ret_g_tuner = 0; int ret_g_freq = 0; int errno_g_tuner = 0; int errno_g_freq = 0; int ret; __u32 index; struct v4l2_frequency orig_freq; struct v4l2_frequency freq; struct v4l2_frequency new_freq; struct v4l2_tuner tuner; /* this test case depends on working VIDIOC_G_TUNER and VIDIOC_G_FREQUENCY commands */ index = 0; /* fetch the minimum (tuner.rangelow) and maximum (tuner.rangehigh) frequency */ memset(&tuner, 0xff, sizeof(tuner)); tuner.index = index; ret_g_tuner = ioctl(get_video_fd(), VIDIOC_G_TUNER, &tuner); errno_g_tuner = errno; dprintf("\t%s:%u: VIDIOC_G_TUNER, ret=%i, tuner.rangelow=%u, tuner.rangehigh=%u\n", __FILE__, __LINE__, ret_g_tuner, tuner.rangelow, tuner.rangehigh); CU_ASSERT_EQUAL(tuner.index, index); /* fetch the current frequency setting */ memset(&orig_freq, 0xff, sizeof(orig_freq)); orig_freq.tuner = index; ret_g_freq = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &orig_freq); errno_g_freq = errno; dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret_g_freq=%i, orig_freq.frequency=%u\n", __FILE__, __LINE__, ret_g_freq, orig_freq.frequency); CU_ASSERT_EQUAL(orig_freq.tuner, index); if (ret_g_tuner == 0 && ret_g_freq == 0) { CU_ASSERT_EQUAL(orig_freq.tuner, index); /* try to set the frequency to zero */ memset(&freq, 0xff, sizeof(freq)); freq.tuner = index; freq.type = orig_freq.type; freq.frequency = 0; ret = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); dprintf("\t%s:%u: set to %u: VIDIOC_S_FREQUENCY, ret=%i\n", __FILE__, __LINE__, 0, ret); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { /* check wheteher the frequency has been changed to the lowest * possible value */ memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = index; ret = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret=%i, new_freq.frequency=%u\n", __FILE__, __LINE__, ret, new_freq.frequency); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { CU_ASSERT_EQUAL(new_freq.frequency, tuner.rangelow); } } /* try to set the frequency to tuner.rangelow-1, if applicable */ if (0 < tuner.rangelow) { memset(&freq, 0xff, sizeof(freq)); freq.tuner = index; freq.type = orig_freq.type; freq.frequency = tuner.rangelow-1; ret = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); dprintf("\t%s:%u: set to %u: VIDIOC_S_FREQUENCY, ret=%i\n", __FILE__, __LINE__, tuner.rangelow-1, ret); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { /* check wheteher the frequency has been changed to the lowest * possible value */ memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = index; ret = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret=%i, new_freq.frequency=%u\n", __FILE__, __LINE__, ret, new_freq.frequency); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { dprintf("\t%s:%u: current frequency=%u (expected %u)\n", __FILE__, __LINE__, new_freq.frequency, tuner.rangelow); CU_ASSERT_EQUAL(new_freq.frequency, tuner.rangelow); } } } /* try to set the frequency to tuner.rangelow */ memset(&freq, 0xff, sizeof(freq)); freq.tuner = index; freq.type = orig_freq.type; freq.frequency = tuner.rangelow; ret = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); dprintf("\t%s:%u: set to %u: VIDIOC_S_FREQUENCY, ret=%i\n", __FILE__, __LINE__, tuner.rangelow, ret); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { /* check wheteher the frequency has been changed to the lowest * possible value */ memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = index; ret = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret=%i, new_freq.frequency=%u\n", __FILE__, __LINE__, ret, new_freq.frequency); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { dprintf("\t%s:%u: current frequency=%u (expected %u)\n", __FILE__, __LINE__, new_freq.frequency, tuner.rangelow); CU_ASSERT_EQUAL(new_freq.frequency, tuner.rangelow); } } /* try to set the frequency to tuner.rangehigh */ memset(&freq, 0xff, sizeof(freq)); freq.tuner = index; freq.type = orig_freq.type; freq.frequency = tuner.rangehigh; ret = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); dprintf("\t%s:%u: set to %u: VIDIOC_S_FREQUENCY, ret=%i\n", __FILE__, __LINE__, tuner.rangehigh, ret); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { /* check wheteher the frequency has been changed to the highest * possible value */ memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = index; ret = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret=%i, new_freq.frequency=%u\n", __FILE__, __LINE__, ret, new_freq.frequency); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { dprintf("\t%s:%u: current frequency=%u (expected %u)\n", __FILE__, __LINE__, new_freq.frequency, tuner.rangehigh); CU_ASSERT_EQUAL(new_freq.frequency, tuner.rangehigh); } } /* try to set the frequency to tuner.rangehigh+1, if applicable */ if (tuner.rangehigh < U32_MAX) { memset(&freq, 0xff, sizeof(freq)); freq.tuner = index; freq.type = orig_freq.type; freq.frequency = tuner.rangehigh+1; ret = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); dprintf("\t%s:%u: set to %u: VIDIOC_S_FREQUENCY, ret=%i\n", __FILE__, __LINE__, tuner.rangehigh+1, ret); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { /* check wheteher the frequency has been changed to the highest * possible value */ memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = index; ret = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret=%i, new_freq.frequency=%u\n", __FILE__, __LINE__, ret, new_freq.frequency); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { dprintf("\t%s:%u: current frequency=%u (expected %u)\n", __FILE__, __LINE__, new_freq.frequency, tuner.rangehigh); CU_ASSERT_EQUAL(new_freq.frequency, tuner.rangehigh); } } } /* try to set the frequency to U32_MAX */ memset(&freq, 0xff, sizeof(freq)); freq.tuner = index; freq.type = orig_freq.type; freq.frequency = U32_MAX; ret = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); dprintf("\t%s:%u: set to %u: VIDIOC_S_FREQUENCY, ret=%i\n", __FILE__, __LINE__, U32_MAX, ret); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { /* check wheteher the frequency has been changed to the highest * possible value */ memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = index; ret = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret=%i, new_freq.frequency=%u\n", __FILE__, __LINE__, ret, new_freq.frequency); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { dprintf("\t%s:%u: current frequency=%u (expected %u)\n", __FILE__, __LINE__, new_freq.frequency, tuner.rangehigh); CU_ASSERT_EQUAL(new_freq.frequency, tuner.rangehigh); } } /* try restore the original frequency settings */ memset(&freq, 0xff, sizeof(freq)); freq.tuner = index; freq.type = orig_freq.type; freq.frequency = orig_freq.frequency; ret = ioctl(get_video_fd(), VIDIOC_S_FREQUENCY, &freq); dprintf("\t%s:%u: set to %u: VIDIOC_S_FREQUENCY, ret=%i\n", __FILE__, __LINE__, orig_freq.frequency, ret); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { /* check wheteher the frequency has been restored */ memset(&new_freq, 0xff, sizeof(new_freq)); new_freq.tuner = index; ret = ioctl(get_video_fd(), VIDIOC_G_FREQUENCY, &new_freq); dprintf("\t%s:%u: VIDIOC_G_FREQUENCY, ret=%i, new_freq.frequency=%u\n", __FILE__, __LINE__, ret, new_freq.frequency); CU_ASSERT_EQUAL(ret, 0); if (ret == 0) { dprintf("\t%s:%u: current frequency=%u (expected %u)\n", __FILE__, __LINE__, new_freq.frequency, orig_freq.frequency); CU_ASSERT_EQUAL(new_freq.frequency, orig_freq.frequency); } } } if (ret_g_freq != 0) { dprintf("\t%s:%u: ret_g_freq=%d (expected %d)\n", __FILE__, __LINE__, ret_g_freq, -1); dprintf("\t%s:%u: errno_g_freq=%d (expected %d)\n", __FILE__, __LINE__, errno_g_freq, EINVAL); CU_ASSERT_EQUAL(ret_g_freq, -1); CU_ASSERT_EQUAL(errno, EINVAL); } if (ret_g_tuner != 0) { dprintf("\t%s:%u: ret_g_tuner=%d (expected %d)\n", __FILE__, __LINE__, ret_g_tuner, -1); dprintf("\t%s:%u: errno_g_tuner=%d (expected %d)\n", __FILE__, __LINE__, errno_g_tuner, EINVAL); CU_ASSERT_EQUAL(ret_g_tuner, -1); CU_ASSERT_EQUAL(errno, EINVAL); } }
void test_invalid_ioctl_1() { do_invalid_ioctl(get_video_fd(), _IO(0, 0)); }
void test_VIDIOC_QUERYCTRL() { int ret_query, errno_query; struct v4l2_queryctrl queryctrl; struct v4l2_queryctrl queryctrl2; __u32 i; /* The available controls and their parameters * may change with different * - input or output * - tuner or modulator * - audio input or audio output * See V4L API specification rev. 0.24, Chapter 1.8. * "User Controls" for details * * TODO: iterate through the mentioned settings. * TODO: check for deprecated controls (maybe in a * separated test case which could fail when a * deprecated control is supported) */ for (i = V4L2_CID_BASE; i < V4L2_CID_LASTP1; i++) { memset(&queryctrl, 0xff, sizeof(queryctrl)); queryctrl.id = i; ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; dprintf("\t%s:%u: VIDIOC_QUERYCTRL, id=%u (V4L2_CID_BASE+%i), ret_query=%i, errno_query=%i\n", __FILE__, __LINE__, i, i-V4L2_CID_BASE, ret_query, errno_query); if (ret_query == 0) { CU_ASSERT_EQUAL(ret_query, 0); CU_ASSERT_EQUAL(queryctrl.id, i); CU_ASSERT(0 < strlen( (char*)queryctrl.name )); CU_ASSERT(valid_string((char*)queryctrl.name, sizeof(queryctrl.name))); CU_ASSERT(valid_control_type(queryctrl.type)); switch (queryctrl.type) { case V4L2_CTRL_TYPE_INTEGER: /* min < max, because otherwise this control makes no sense */ CU_ASSERT(queryctrl.minimum < queryctrl.maximum); CU_ASSERT(0 < queryctrl.step); CU_ASSERT(queryctrl.minimum <= queryctrl.default_value); CU_ASSERT(queryctrl.default_value <= queryctrl.maximum); break; case V4L2_CTRL_TYPE_BOOLEAN: CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT_EQUAL(queryctrl.maximum, 1); CU_ASSERT_EQUAL(queryctrl.step, 1); CU_ASSERT((queryctrl.default_value == 0) || (queryctrl.default_value == 1)); break; case V4L2_CTRL_TYPE_MENU: CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT(queryctrl.minimum <= queryctrl.default_value); CU_ASSERT_EQUAL(queryctrl.step, 1); CU_ASSERT(queryctrl.minimum <= queryctrl.default_value); CU_ASSERT(queryctrl.default_value <= queryctrl.maximum); break; case V4L2_CTRL_TYPE_BUTTON: CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT_EQUAL(queryctrl.maximum, 0); CU_ASSERT_EQUAL(queryctrl.step, 0); CU_ASSERT_EQUAL(queryctrl.default_value, 0); break; case V4L2_CTRL_TYPE_INTEGER64: /* fallthrough */ case V4L2_CTRL_TYPE_CTRL_CLASS: /* These parameters are defined as n/a by V4L2, so * they should be filled with zeros, the same like * the reserved fields. */ CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT_EQUAL(queryctrl.maximum, 0); CU_ASSERT_EQUAL(queryctrl.step, 0); CU_ASSERT_EQUAL(queryctrl.default_value, 0); break; default: CU_ASSERT_EQUAL(queryctrl.minimum, 0); CU_ASSERT_EQUAL(queryctrl.maximum, 0); CU_ASSERT_EQUAL(queryctrl.step, 0); CU_ASSERT_EQUAL(queryctrl.default_value, 0); } CU_ASSERT(valid_control_flag(queryctrl.flags)); CU_ASSERT_EQUAL(queryctrl.reserved[0], 0); CU_ASSERT_EQUAL(queryctrl.reserved[1], 0); /* Check if the unused bytes of the name string are * also filled with zeros. Also check if there is any * padding byte between any two fields then this * padding byte is also filled with zeros. */ memset(&queryctrl2, 0, sizeof(queryctrl2)); queryctrl2.id = queryctrl.id; queryctrl2.type = queryctrl.type; strncpy((char*)queryctrl2.name, (char*)queryctrl.name, sizeof(queryctrl2.name)); queryctrl2.minimum = queryctrl.minimum; queryctrl2.maximum = queryctrl.maximum; queryctrl2.step = queryctrl.step; queryctrl2.default_value = queryctrl.default_value; queryctrl2.flags = queryctrl.flags; CU_ASSERT_EQUAL(memcmp(&queryctrl, &queryctrl2, sizeof(queryctrl)), 0); dprintf("\tqueryctrl = {.id=%u, .type=%i, .name=\"%s\", " ".minimum=%i, .maximum=%i, .step=%i, " ".default_value=%i, " ".flags=0x%X, " ".reserved[]={ 0x%X, 0x%X } }\n", queryctrl.id, queryctrl.type, queryctrl.name, queryctrl.minimum, queryctrl.maximum, queryctrl.step, queryctrl.default_value, queryctrl.flags, queryctrl.reserved[0], queryctrl.reserved[1] ); } else { CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); memset(&queryctrl2, 0xff, sizeof(queryctrl2)); queryctrl2.id = i; CU_ASSERT_EQUAL(memcmp(&queryctrl, &queryctrl2, sizeof(queryctrl)), 0); } } }
void test_invalid_ioctl_2() { do_invalid_ioctl(get_video_fd(), _IO(0xFF, 0xFF)); }
void test_VIDIOC_ENUMINPUT() { int ret_enum, errno_enum; struct v4l2_input input; struct v4l2_input input2; __u32 i; i = 0; do { memset(&input, 0xff, sizeof(input)); input.index = i; ret_enum = ioctl(get_video_fd(), VIDIOC_ENUMINPUT, &input); errno_enum = errno; dprintf("\t%s:%u: VIDIOC_ENUMINPUT, ret_enum=%i, errno_enum=%i\n", __FILE__, __LINE__, ret_enum, errno_enum); if (ret_enum == 0) { CU_ASSERT_EQUAL(ret_enum, 0); CU_ASSERT_EQUAL(input.index, i); CU_ASSERT(0 < strlen( (char*)input.name )); CU_ASSERT(valid_string((char*)input.name, sizeof(input.name))); //CU_ASSERT_EQUAL(input.type, ?); //CU_ASSERT_EQUAL(input.audioset, ?); //CU_ASSERT_EQUAL(input.tuner, ?); CU_ASSERT(valid_v4l2_std_id(input.std)); //CU_ASSERT_EQUAL(input.status, ?); CU_ASSERT_EQUAL(input.reserved[0], 0); CU_ASSERT_EQUAL(input.reserved[1], 0); CU_ASSERT_EQUAL(input.reserved[2], 0); CU_ASSERT_EQUAL(input.reserved[3], 0); /* Check if the unused bytes of the name string are * also filled with zeros. Also check if there is any * padding byte between any two fields then this * padding byte is also filled with zeros. */ memset(&input2, 0, sizeof(input2)); input2.index = input.index; strncpy((char*)input2.name, (char*)input.name, sizeof(input2.name)); input2.type = input.type; input2.audioset = input.audioset; input2.tuner = input.tuner; input2.std = input.std; input2.status = input.status; CU_ASSERT_EQUAL(memcmp(&input, &input2, sizeof(input)), 0); show_v4l2_input(&input); } else { CU_ASSERT_EQUAL(ret_enum, -1); CU_ASSERT_EQUAL(errno_enum, EINVAL); memset(&input2, 0xff, sizeof(input2)); input2.index = i; CU_ASSERT_EQUAL(memcmp(&input, &input2, sizeof(input)), 0); } i++; } while (ret_enum == 0); }
void test_VIDIOC_QUERYMENU_private() { int ret_query, errno_query; struct v4l2_queryctrl queryctrl; __u32 i; i = V4L2_CID_PRIVATE_BASE; do { memset(&queryctrl, 0, sizeof(queryctrl)); queryctrl.id = i; ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; dprintf("\t%s:%u: VIDIOC_QUERYCTRL, id=%u (V4L2_CID_BASE+%i), ret_query=%i, errno_query=%i\n", __FILE__, __LINE__, i, i-V4L2_CID_BASE, ret_query, errno_query); if (ret_query == 0) { CU_ASSERT_EQUAL(ret_query, 0); CU_ASSERT_EQUAL(queryctrl.id, i); dprintf("\tqueryctrl = {.id=%u, .type=%i, .name=\"%s\", " ".minimum=%i, .maximum=%i, .step=%i, " ".default_value=%i, " ".flags=0x%X, " ".reserved[]={ 0x%X, 0x%X } }\n", queryctrl.id, queryctrl.type, queryctrl.name, queryctrl.minimum, queryctrl.maximum, queryctrl.step, queryctrl.default_value, queryctrl.flags, queryctrl.reserved[0], queryctrl.reserved[1] ); switch (queryctrl.type) { case V4L2_CTRL_TYPE_MENU: do_query_menu(i); break; case V4L2_CTRL_TYPE_INTEGER: case V4L2_CTRL_TYPE_BOOLEAN: case V4L2_CTRL_TYPE_BUTTON: case V4L2_CTRL_TYPE_INTEGER64: /* fallthrough */ case V4L2_CTRL_TYPE_CTRL_CLASS: default: do_query_menu_invalid(i); } } else { CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); do_query_menu_invalid(i); } } while (ret_query == 0); }
void test_VIDIOC_S_TUNER_invalid() { int ret1, errno1; int ret_set, errno_set; struct v4l2_tuner tuner_orig; struct v4l2_tuner tuner_set; /* remember the tuner settings */ memset(&tuner_orig, 0, sizeof(tuner_orig)); ret1 = ioctl(get_video_fd(), VIDIOC_G_TUNER, &tuner_orig); errno1 = errno; dprintf("\t%s:%u: VIDIOC_G_TUNER, ret1=%i, errno1=%i\n", __FILE__, __LINE__, ret1, errno1); if (ret1 == 0) { CU_ASSERT_EQUAL(ret1, 0); /* try with invalid index */ do_set_tuner_audmode_invalid(tuner_orig.index+1, V4L2_TUNER_MODE_MONO); do_set_tuner_audmode_invalid(tuner_orig.index-1, V4L2_TUNER_MODE_MONO); do_set_tuner_audmode_invalid((__u32)S32_MAX, V4L2_TUNER_MODE_MONO); do_set_tuner_audmode_invalid(((__u32)S32_MAX)+1, V4L2_TUNER_MODE_MONO); do_set_tuner_audmode_invalid(U32_MAX, V4L2_TUNER_MODE_MONO); do_set_tuner_audmode_invalid(tuner_orig.index+1, V4L2_TUNER_MODE_STEREO); do_set_tuner_audmode_invalid(tuner_orig.index-1, V4L2_TUNER_MODE_STEREO); do_set_tuner_audmode_invalid((__u32)S32_MAX, V4L2_TUNER_MODE_STEREO); do_set_tuner_audmode_invalid(((__u32)S32_MAX)+1, V4L2_TUNER_MODE_STEREO); do_set_tuner_audmode_invalid(U32_MAX, V4L2_TUNER_MODE_STEREO); do_set_tuner_audmode_invalid(tuner_orig.index+1, V4L2_TUNER_MODE_LANG1); do_set_tuner_audmode_invalid(tuner_orig.index-1, V4L2_TUNER_MODE_LANG1); do_set_tuner_audmode_invalid((__u32)S32_MAX, V4L2_TUNER_MODE_LANG1); do_set_tuner_audmode_invalid(((__u32)S32_MAX)+1, V4L2_TUNER_MODE_LANG1); do_set_tuner_audmode_invalid(U32_MAX, V4L2_TUNER_MODE_LANG1); do_set_tuner_audmode_invalid(tuner_orig.index+1, V4L2_TUNER_MODE_LANG2); do_set_tuner_audmode_invalid(tuner_orig.index-1, V4L2_TUNER_MODE_LANG2); do_set_tuner_audmode_invalid((__u32)S32_MAX, V4L2_TUNER_MODE_LANG2); do_set_tuner_audmode_invalid(((__u32)S32_MAX)+1, V4L2_TUNER_MODE_LANG2); do_set_tuner_audmode_invalid(U32_MAX, V4L2_TUNER_MODE_LANG2); do_set_tuner_audmode_invalid(tuner_orig.index+1, V4L2_TUNER_MODE_SAP); do_set_tuner_audmode_invalid(tuner_orig.index-1, V4L2_TUNER_MODE_SAP); do_set_tuner_audmode_invalid((__u32)S32_MAX, V4L2_TUNER_MODE_SAP); do_set_tuner_audmode_invalid(((__u32)S32_MAX)+1, V4L2_TUNER_MODE_SAP); do_set_tuner_audmode_invalid(U32_MAX, V4L2_TUNER_MODE_SAP); do_set_tuner_audmode_invalid(tuner_orig.index+1, V4L2_TUNER_MODE_LANG1_LANG2); do_set_tuner_audmode_invalid(tuner_orig.index-1, V4L2_TUNER_MODE_LANG1_LANG2); do_set_tuner_audmode_invalid((__u32)S32_MAX, V4L2_TUNER_MODE_LANG1_LANG2); do_set_tuner_audmode_invalid(((__u32)S32_MAX)+1, V4L2_TUNER_MODE_LANG1_LANG2); do_set_tuner_audmode_invalid(U32_MAX, V4L2_TUNER_MODE_LANG1_LANG2); } else { CU_ASSERT_EQUAL(ret1, -1); CU_ASSERT_EQUAL(errno1, EINVAL); } /* try with invalid audmode */ do_set_tuner_audmode_invalid(tuner_orig.index, 5); do_set_tuner_audmode_invalid(tuner_orig.index, (__u32)S32_MAX); do_set_tuner_audmode_invalid(tuner_orig.index, ((__u32)S32_MAX)+1); do_set_tuner_audmode_invalid(tuner_orig.index, U32_MAX); if (ret1 == 0) { /* restore the tuner settings */ memset(&tuner_set, 0xff, sizeof(tuner_set)); tuner_set.index = tuner_orig.index; tuner_set.audmode = tuner_orig.audmode; ret_set = ioctl(get_video_fd(), VIDIOC_S_TUNER, &tuner_orig); errno_set = errno; dprintf("\t%s:%u: VIDIOC_S_TUNER, ret_set=%i, errno_set=%i\n", __FILE__, __LINE__, ret_set, errno_set); CU_ASSERT_EQUAL(ret_set, 0); } }
void test_VIDIOC_QUERYMENU_NULL() { int ret_query, errno_query; int ret_menu, errno_menu; int ret_null, errno_null; struct v4l2_queryctrl queryctrl; struct v4l2_querymenu menu; __u32 i; unsigned int count_menu; count_menu = 0; i = V4L2_CID_BASE; for (i = V4L2_CID_BASE; i < V4L2_CID_LASTP1; i++) { memset(&queryctrl, 0xff, sizeof(queryctrl)); queryctrl.id = i; ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; dprintf ("\t%s:%u: VIDIOC_QUERYCTRL, id=%u (V4L2_CID_BASE+%i), ret_query=%i, errno_query=%i\n", __FILE__, __LINE__, i, i - V4L2_CID_BASE, ret_query, errno_query); if (ret_query == 0) { CU_ASSERT_EQUAL(ret_query, 0); if (queryctrl.type == V4L2_CTRL_TYPE_MENU) { memset(&menu, 0, sizeof(menu)); menu.id = i; menu.index = 0; ret_menu = ioctl(get_video_fd(), VIDIOC_QUERYMENU, &menu); errno_menu = errno; dprintf ("\t%s:%u: VIDIOC_QUERYMENU, id=%u, (V4L2_CID_BASE+%i), index=%u, ret_query=%i, errno_query=%i\n", __FILE__, __LINE__, i, i - V4L2_CID_BASE, 0, ret_query, errno_query); if (ret_menu == 0) { CU_ASSERT_EQUAL(ret_menu, 0); count_menu++; } else { CU_ASSERT_EQUAL(ret_menu, -1); CU_ASSERT_EQUAL(errno_menu, EINVAL); } } } else { CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); } } i = V4L2_CID_PRIVATE_BASE; do { memset(&queryctrl, 0xff, sizeof(queryctrl)); queryctrl.id = i; ret_query = ioctl(get_video_fd(), VIDIOC_QUERYCTRL, &queryctrl); errno_query = errno; dprintf ("\t%s:%u: VIDIOC_QUERYCTRL, id=%u (V4L2_CID_PRIVATE_BASE+%i), ret_query=%i, errno_query=%i\n", __FILE__, __LINE__, i, i - V4L2_CID_PRIVATE_BASE, ret_query, errno_query); if (ret_query == 0) { CU_ASSERT_EQUAL(ret_query, 0); if (queryctrl.type == V4L2_CTRL_TYPE_MENU) { memset(&menu, 0, sizeof(menu)); menu.id = i; menu.index = 0; ret_menu = ioctl(get_video_fd(), VIDIOC_QUERYMENU, &menu); errno_menu = errno; dprintf ("\t%s:%u: VIDIOC_QUERYMENU, id=%u, (V4L2_CID_BASE+%i), index=%u, ret_query=%i, errno_query=%i\n", __FILE__, __LINE__, i, i - V4L2_CID_BASE, 0, ret_query, errno_query); if (ret_menu == 0) { CU_ASSERT_EQUAL(ret_menu, 0); count_menu++; } else { CU_ASSERT_EQUAL(ret_menu, -1); CU_ASSERT_EQUAL(errno_menu, EINVAL); } } } else { CU_ASSERT_EQUAL(ret_query, -1); CU_ASSERT_EQUAL(errno_query, EINVAL); } i++; } while (ret_query == 0 && V4L2_CID_PRIVATE_BASE <= i); ret_null = ioctl(get_video_fd(), VIDIOC_QUERYMENU, NULL); errno_null = errno; dprintf("\t%s:%u: VIDIOC_QUERYMENU, ret_null=%i, errno_null=%i\n", __FILE__, __LINE__, ret_null, errno_null); if (0 < count_menu) { CU_ASSERT_EQUAL(ret_null, -1); CU_ASSERT_EQUAL(errno_null, EFAULT); } else { CU_ASSERT_EQUAL(ret_null, -1); CU_ASSERT_EQUAL(errno_null, EINVAL); } }
static void do_get_param(enum v4l2_buf_type type) { int ret_get, errno_get; struct v4l2_streamparm parm; struct v4l2_streamparm parm2; memset(&parm, 0xff, sizeof(parm)); parm.type = type; ret_get = ioctl(get_video_fd(), VIDIOC_G_PARM, &parm); errno_get = errno; dprintf("\t%s:%u: VIDIOC_G_PARM, type=%i, ret_get=%i, errno_get=%i\n", __FILE__, __LINE__, type, ret_get, errno_get); if (ret_get == 0) { CU_ASSERT_EQUAL(ret_get, 0); CU_ASSERT_EQUAL(parm.type, type); switch (parm.type) { case V4L2_BUF_TYPE_VIDEO_CAPTURE: dprintf("\t%s:%u: { .type=%i, parm.capture = { " ".capability = 0x%X, " ".capturemode = 0x%X, " ".timeperframe = { .numerator = %u, .denominator = %u }, " ".extendedmode = %u, " ".readbuffers = %u, " "reserved[] = { 0x%X, 0x%X, 0x%X, 0x%X }}}\n", __FILE__, __LINE__, parm.type, parm.parm.capture.capability, parm.parm.capture.capturemode, parm.parm.capture.timeperframe.numerator, parm.parm.capture.timeperframe.denominator, parm.parm.capture.extendedmode, parm.parm.capture.readbuffers, parm.parm.capture.reserved[0], parm.parm.capture.reserved[1], parm.parm.capture.reserved[2], parm.parm.capture.reserved[3] ); CU_ASSERT(valid_v4l2_captureparm_capability(parm.parm.capture.capability)); CU_ASSERT(valid_v4l2_captureparm_capturemode(parm.parm.capture.capturemode)); if (parm.parm.capture.capability & V4L2_CAP_TIMEPERFRAME) { //CU_ASSERT_EQUAL(parm.parm.capture.timeperframe.numerator, ???); //CU_ASSERT_EQUAL(parm.parm.capture.timeperframe.denominator, ???); CU_ASSERT(parm.parm.capture.timeperframe.denominator != 0); // TODO: timerperframe: check struct v4l2_standard frameperiod field } else { //CU_ASSERT_EQUAL(parm.parm.capture.timeperframe.numerator, 0); //CU_ASSERT_EQUAL(parm.parm.capture.timeperframe.denominator, 0); CU_ASSERT(parm.parm.output.timeperframe.denominator != 0); } //CU_ASSERT_EQUAL(parm.parm.capture.extendedmode, ???); //CU_ASSERT_EQUAL(parm.parm.capture.readbuffers, ???); CU_ASSERT_EQUAL(parm.parm.capture.reserved[0], 0); CU_ASSERT_EQUAL(parm.parm.capture.reserved[1], 0); CU_ASSERT_EQUAL(parm.parm.capture.reserved[2], 0); CU_ASSERT_EQUAL(parm.parm.capture.reserved[3], 0); break; case V4L2_BUF_TYPE_VIDEO_OUTPUT: dprintf("\t%s:%u: { .type=%i, parm.output = { " ".capability = 0x%X, " ".outputmode = 0x%X, " ".timeperframe = { .numerator = %u, .denominator = %u }, " ".extendedmode = %u, " ".writebuffers = %u, " "reserved[] = { 0x%X, 0x%X, 0x%X, 0x%X }}}\n", __FILE__, __LINE__, parm.type, parm.parm.output.capability, parm.parm.output.outputmode, parm.parm.output.timeperframe.numerator, parm.parm.output.timeperframe.denominator, parm.parm.output.extendedmode, parm.parm.output.writebuffers, parm.parm.output.reserved[0], parm.parm.output.reserved[1], parm.parm.output.reserved[2], parm.parm.output.reserved[3] ); CU_ASSERT(valid_v4l2_outputparm_capability(parm.parm.output.capability)); CU_ASSERT(valid_v4l2_outputparm_outputpmode(parm.parm.output.outputmode)); if (parm.parm.output.capability & V4L2_CAP_TIMEPERFRAME) { //CU_ASSERT_EQUAL(parm.parm.output.timeperframe.numerator, ???); //CU_ASSERT_EQUAL(parm.parm.output.timeperframe.denominator, ???); CU_ASSERT(parm.parm.output.timeperframe.denominator != 0); // TODO: timerperframe: check struct v4l2_standard frameperiod field } else { //CU_ASSERT_EQUAL(parm.parm.output.timeperframe.numerator, 0); //CU_ASSERT_EQUAL(parm.parm.output.timeperframe.denominator, 0); CU_ASSERT(parm.parm.output.timeperframe.denominator != 0); } //CU_ASSERT_EQUAL(parm.parm.output.extendedmode, ???); //CU_ASSERT_EQUAL(parm.parm.output.writebuffers, ???); CU_ASSERT_EQUAL(parm.parm.output.reserved[0], 0); CU_ASSERT_EQUAL(parm.parm.output.reserved[1], 0); CU_ASSERT_EQUAL(parm.parm.output.reserved[2], 0); CU_ASSERT_EQUAL(parm.parm.output.reserved[3], 0); break; default: ; } } else { CU_ASSERT_EQUAL(ret_get, -1); CU_ASSERT_EQUAL(errno_get, EINVAL); /* check whether the parm structure is untouched */ memset(&parm2, 0xff, sizeof(parm2)); parm2.type = type; CU_ASSERT_EQUAL(memcmp(&parm, &parm2, sizeof(parm)), 0); } }