diff options
Diffstat (limited to 'test/v4l2-ctl.cpp')
-rw-r--r-- | test/v4l2-ctl.cpp | 154 |
1 files changed, 77 insertions, 77 deletions
diff --git a/test/v4l2-ctl.cpp b/test/v4l2-ctl.cpp index a75d7c144..deb7f3fb9 100644 --- a/test/v4l2-ctl.cpp +++ b/test/v4l2-ctl.cpp @@ -226,7 +226,7 @@ static std::string name2var(unsigned char *name) } static void print_qctrl(int fd, struct v4l2_queryctrl *queryctrl, - struct v4l2_ext_control *ctrl, int show_menus) + struct v4l2_ext_control *ctrl, int show_menus) { struct v4l2_querymenu qmenu = { 0 }; std::string s = name2var(queryctrl->name); @@ -247,10 +247,10 @@ static void print_qctrl(int fd, struct v4l2_queryctrl *queryctrl, case V4L2_CTRL_TYPE_BOOLEAN: printf("%31s (bool) : default=%d value=%d", s.c_str(), - queryctrl->default_value, ctrl->value); + queryctrl->default_value, ctrl->value); break; case V4L2_CTRL_TYPE_MENU: - printf("%31s (menu) : min=%d max=%d default=%d value=%d", + printf("%31s (menu) : min=%d max=%d default=%d value=%d", s.c_str(), queryctrl->minimum, queryctrl->maximum, queryctrl->default_value, ctrl->value); @@ -337,7 +337,7 @@ static void list_controls(int fd, int show_menus) if (ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0) print_control(fd, qctrl, show_menus); } - for (qctrl.id = V4L2_CID_PRIVATE_BASE; + for (qctrl.id = V4L2_CID_PRIVATE_BASE; ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0; qctrl.id++) { print_control(fd, qctrl, show_menus); } @@ -350,8 +350,8 @@ static void find_controls(int fd) while (ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0) { if (qctrl.type != V4L2_CTRL_TYPE_CTRL_CLASS) { - ctrl_str2id[name2var(qctrl.name)] = qctrl.id; - ctrl_id2str[qctrl.id] = name2var(qctrl.name); + ctrl_str2id[name2var(qctrl.name)] = qctrl.id; + ctrl_id2str[qctrl.id] = name2var(qctrl.name); } qctrl.id |= V4L2_CTRL_FLAG_NEXT_CTRL; } @@ -360,11 +360,11 @@ static void find_controls(int fd) for (id = V4L2_CID_USER_BASE; id < V4L2_CID_LASTP1; id++) { qctrl.id = id; if (ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0) - ctrl_str2id[name2var(qctrl.name)] = qctrl.id; + ctrl_str2id[name2var(qctrl.name)] = qctrl.id; } - for (qctrl.id = V4L2_CID_PRIVATE_BASE; + for (qctrl.id = V4L2_CID_PRIVATE_BASE; ioctl(fd, VIDIOC_QUERYCTRL, &qctrl) == 0; qctrl.id++) { - ctrl_str2id[name2var(qctrl.name)] = qctrl.id; + ctrl_str2id[name2var(qctrl.name)] = qctrl.id; } } @@ -604,7 +604,7 @@ static int doioctl(int fd, int request, void *parm, const char *name) printf("failed: %s\n", strerror(errno)); else printf("ok\n"); - + return retVal; } @@ -628,10 +628,10 @@ static int parse_subopt(char **subs, char * const *subopts, char **value) static void parse_next_subopt(char **subs, char **value) { - static char *const subopts[] = { - NULL - }; - int opt = getsubopt(subs, subopts, value); + static char *const subopts[] = { + NULL + }; + int opt = getsubopt(subs, subopts, value); if (value == NULL) { fprintf(stderr, "No value given to suboption <%s>\n", @@ -698,11 +698,11 @@ int main(int argc, char **argv) return 0; case OptSetDevice: device = strdup(optarg); - if (device[0] >= '0' && device[0] <= '9' && device[1] == 0) { - char dev = device[0]; + if (device[0] >= '0' && device[0] <= '9' && device[1] == 0) { + char dev = device[0]; - sprintf(device, "/dev/video%c", dev); - } + sprintf(device, "/dev/video%c", dev); + } break; case OptSetVideoFormat: subs = optarg; @@ -741,65 +741,65 @@ int main(int argc, char **argv) freq = strtod(optarg, NULL); break; case OptSetStandard: - if (!strncmp(optarg, "pal", 3)) { + if (!strncmp(optarg, "pal", 3)) { if (optarg[3]) std = parse_pal(optarg + 3); else - std = V4L2_STD_PAL; - } - else if (!strncmp(optarg, "ntsc", 4)) { + std = V4L2_STD_PAL; + } + else if (!strncmp(optarg, "ntsc", 4)) { if (optarg[4]) std = parse_ntsc(optarg + 4); else - std = V4L2_STD_NTSC; - } - else if (!strncmp(optarg, "secam", 5)) { + std = V4L2_STD_NTSC; + } + else if (!strncmp(optarg, "secam", 5)) { if (optarg[5]) std = parse_secam(optarg + 5); else - std = V4L2_STD_SECAM; - } - else { - std = strtol(optarg, 0L, 0); - } + std = V4L2_STD_SECAM; + } + else { + std = strtol(optarg, 0L, 0); + } break; case OptGetCtrl: subs = optarg; while (*subs != '\0') { - parse_next_subopt(&subs, &value); - if (strchr(value, '=')) { - usage(); - exit(1); - } - else { - get_ctrls.push_back(value); - } + parse_next_subopt(&subs, &value); + if (strchr(value, '=')) { + usage(); + exit(1); + } + else { + get_ctrls.push_back(value); + } } break; case OptSetCtrl: subs = optarg; while (*subs != '\0') { - parse_next_subopt(&subs, &value); - if (const char *equal = strchr(value, '=')) { - set_ctrls[std::string(value, (equal - value))] = equal + 1; - } - else { - fprintf(stderr, "control '%s' without '='\n", value); - exit(1); - } + parse_next_subopt(&subs, &value); + if (const char *equal = strchr(value, '=')) { + set_ctrls[std::string(value, (equal - value))] = equal + 1; + } + else { + fprintf(stderr, "control '%s' without '='\n", value); + exit(1); + } } break; case OptSetTuner: if (!strcmp(optarg, "stereo")) - mode = V4L2_TUNER_MODE_STEREO; + mode = V4L2_TUNER_MODE_STEREO; else if (!strcmp(optarg, "lang1")) - mode = V4L2_TUNER_MODE_LANG1; + mode = V4L2_TUNER_MODE_LANG1; else if (!strcmp(optarg, "lang2")) - mode = V4L2_TUNER_MODE_LANG2; + mode = V4L2_TUNER_MODE_LANG2; else if (!strcmp(optarg, "bilingual")) - mode = V4L2_TUNER_MODE_LANG1_LANG2; + mode = V4L2_TUNER_MODE_LANG1_LANG2; else if (!strcmp(optarg, "mono")) - mode = V4L2_TUNER_MODE_MONO; + mode = V4L2_TUNER_MODE_MONO; else { fprintf(stderr, "Unknown audio mode\n"); usage(); @@ -834,19 +834,19 @@ int main(int argc, char **argv) } free(device); - find_controls(fd); - for (ctrl_get_list::iterator iter = get_ctrls.begin(); iter != get_ctrls.end(); ++iter) { - if (ctrl_str2id.find(*iter) == ctrl_str2id.end()) { - fprintf(stderr, "unknown control '%s'\n", (*iter).c_str()); - exit(1); - } - } - for (ctrl_set_map::iterator iter = set_ctrls.begin(); iter != set_ctrls.end(); ++iter) { - if (ctrl_str2id.find(iter->first) == ctrl_str2id.end()) { - fprintf(stderr, "unknown control '%s'\n", iter->first.c_str()); - exit(1); - } - } + find_controls(fd); + for (ctrl_get_list::iterator iter = get_ctrls.begin(); iter != get_ctrls.end(); ++iter) { + if (ctrl_str2id.find(*iter) == ctrl_str2id.end()) { + fprintf(stderr, "unknown control '%s'\n", (*iter).c_str()); + exit(1); + } + } + for (ctrl_set_map::iterator iter = set_ctrls.begin(); iter != set_ctrls.end(); ++iter) { + if (ctrl_str2id.find(iter->first) == ctrl_str2id.end()) { + fprintf(stderr, "unknown control '%s'\n", iter->first.c_str()); + exit(1); + } + } if (option_all) { options[OptGetVideoFormat] = 1; @@ -905,19 +905,19 @@ int main(int argc, char **argv) vf.tuner = 0; vf.type = (enum v4l2_tuner_type)0; vf.frequency = __u32(freq * fac); - if (doioctl(fd, VIDIOC_S_FREQUENCY, &vf, + if (doioctl(fd, VIDIOC_S_FREQUENCY, &vf, "VIDIOC_S_FREQUENCY") == 0) printf("Frequency set to %d (%f MHz)\n", vf.frequency, vf.frequency / fac); } if (options[OptSetStandard]) { - if (std < 16) { - vs.index = std; - if (ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) { - std = vs.id; - } - } + if (std < 16) { + vs.index = std; + if (ioctl(fd, VIDIOC_ENUMSTD, &vs) >= 0) { + std = vs.id; + } + } if (doioctl(fd, VIDIOC_S_STD, &std, "VIDIOC_S_STD") == 0) printf("Standard set to %08llx\n", (unsigned long long)std); } @@ -925,7 +925,7 @@ int main(int argc, char **argv) if (options[OptSetCtrl] && !set_ctrls.empty()) { struct v4l2_ext_controls ctrls = { 0 }; - for (ctrl_set_map::iterator iter = set_ctrls.begin(); + for (ctrl_set_map::iterator iter = set_ctrls.begin(); iter != set_ctrls.end(); ++iter) { struct v4l2_ext_control ctrl = { 0 }; @@ -1138,13 +1138,13 @@ int main(int argc, char **argv) if (options[OptListCtrlsMenus]) { list_controls(fd, 1); } - + if (options[OptGetCtrl] && !get_ctrls.empty()) { struct v4l2_ext_controls ctrls = { 0 }; mpeg_ctrls.clear(); user_ctrls.clear(); - for (ctrl_get_list::iterator iter = get_ctrls.begin(); + for (ctrl_get_list::iterator iter = get_ctrls.begin(); iter != get_ctrls.end(); ++iter) { struct v4l2_ext_control ctrl = { 0 }; @@ -1188,7 +1188,7 @@ int main(int argc, char **argv) vt.rangelow / 16.0, vt.rangehigh / 16.0); printf("\tSignal strength : %d%%\n", (int)(vt.signal / 655.35)); printf("\tCurrent audio mode : %s\n", audmode2s(vt.audmode)); - printf("\tAvailable subchannels: %s\n", + printf("\tAvailable subchannels: %s\n", rxsubchans2s(vt.rxsubchans).c_str()); } } @@ -1205,7 +1205,7 @@ int main(int argc, char **argv) } if (option_version) { - //printf("ivtvctl version " IVTV_VERSION "\n"); + //printf("ivtvctl version " IVTV_VERSION "\n"); } if (options[OptListCtrls]) { @@ -1236,7 +1236,7 @@ int main(int argc, char **argv) printf("%s", p); } } - } + } } if (option_streamon) { |