/* * Get/Set level abilities */ int print_caps_level(const struct rig_caps *caps, void *data) { setting_t level; int i; if (!data) { return 0; } level = (*(int *)data) ? caps->has_set_level : caps->has_get_level; printf("<A NAME=\"%slevel%d\"><TR><TD>%s</TD>", (*(int *)data) ? "set" : "get", caps->rig_model, caps->model_name); /* * bitmap_level: only those who have a label */ for (i = 0; i < 32; i++) { if (rig_idx2setting(i) & bitmap_level) { print_yn(level & rig_idx2setting(i)); } } printf("</TR></A>\n"); return 1; }
/* * Get/Set func abilities */ int print_caps_func(const struct rig_caps *caps, void *data) { setting_t func; int i; if (!data) { return 0; } func = (*(int *)data) ? caps->has_set_func : caps->has_get_func; printf("<A NAME=\"%sfunc%d\"><TR><TD>%s</TD>", (*(int *)data) ? "set" : "get", caps->rig_model, caps->model_name); /* * bitmap_func: only those who have a label */ for (i = 0; i < RIG_SETTING_MAX; i++) { if (rig_idx2setting(i) & bitmap_func) { print_yn(func & rig_idx2setting(i)); } } printf("</TR></A>\n"); return 1; }
int v4l_print_cap(char *v4l_dev) { int fd, c, t; struct video_capability v4l_cap; struct video_channel v4l_chan; struct video_tuner v4l_tuner; errno=0; fd=open(v4l_dev, O_RDWR); if(fd==-1) { fprintf(stderr, " Error opening device: %s\n", strerror(errno)); return 1; } // get capabilities errno=0; if(ioctl(fd, VIDIOCGCAP, &v4l_cap)==-1) { fprintf(stderr," Error calling capability query: %s\n", strerror(errno)); errno=0; if(close(fd)==-1) { fprintf(stderr, " Error closing file '%s': %s\n",v4l_dev,strerror(errno) ); } return 1; } // print card capabiities printf("Device name: %s\n",v4l_cap.name); printf("Can capture to memory: "); if(!print_yn(v4l_cap.type&VID_TYPE_CAPTURE)) printf("Warning: This card is not capable of capturing frames. You can only use it to watch TV!\n"); printf("Has a tuner of some form: "); print_yn(v4l_cap.type&VID_TYPE_TUNER); printf("Has teletext capability: "); print_yn(v4l_cap.type&VID_TYPE_TELETEXT); printf("Can overlay its image onto the frame buffer: "); print_yn(v4l_cap.type&VID_TYPE_OVERLAY); printf("Overlay is Chromakeyed: "); print_yn(v4l_cap.type&VID_TYPE_CHROMAKEY); printf("Overlay clipping is supported: "); print_yn(v4l_cap.type&VID_TYPE_CLIPPING); printf("Overlay overwrites frame buffer memory: "); print_yn(v4l_cap.type&VID_TYPE_FRAMERAM); printf("The hardware supports image scaling: "); print_yn(v4l_cap.type&VID_TYPE_SCALES); printf("Image capture is grey scale only: "); print_yn(v4l_cap.type&VID_TYPE_MONOCHROME); printf("Capture can be of only part of the image: "); print_yn(v4l_cap.type&VID_TYPE_SUBCAPTURE); printf("Number of radio/tv channels: %d\n", v4l_cap.channels); printf("Number of audio devices: %d\n",v4l_cap.audios); printf("Maximum capture width: %d\n",v4l_cap.maxwidth); printf("Maximum capture height: %d\n",v4l_cap.maxheight); printf("Minimum capture width: %d\n",v4l_cap.minwidth); printf("Minimum capture height: %d\n",v4l_cap.minheight); // print channel information for(c=0;c<v4l_cap.channels;c++) { // set input v4l_chan.channel=c; // get information errno=0; if(ioctl(fd, VIDIOCGCHAN, &v4l_chan)==-1) { fprintf(stderr, " Error getting channel %d proprieties: %s\n", c, strerror(errno)); errno=0; if(close(fd)==-1) { fprintf(stderr, " Error closing file '%s': %s\n",v4l_dev,strerror(errno) ); } return 1; } // print info printf("Channel: %d\n",v4l_chan.channel); printf(" Name: %s\n",v4l_chan.name); printf(" Tuners: %d\n", v4l_chan.tuners); // get info if(v4l_chan.tuners) for(t=0; t<v4l_chan.tuners; t++) { // set tuner v4l_tuner.tuner=t; // get info errno=0; if(ioctl(fd, VIDIOCGTUNER, &v4l_tuner)==-1) { fprintf(stderr, " Error getting tuner information: %s\n", strerror(errno)); errno=0; if(close(fd)==-1) { fprintf(stderr, " Error closing file '%s': %s\n",v4l_dev,strerror(errno) ); } return 1; } // print info printf(" Number of the tuner: %d\n", v4l_tuner.tuner); printf(" Canonical name: %s\n", v4l_tuner.name); printf(" Lowest tunable frequency: %ld\n", v4l_tuner.rangelow); printf(" Highest tunable frequency: %ld\n", v4l_tuner.rangehigh); printf(" PAL tuning is supported: "); print_yn(v4l_tuner.flags&VIDEO_TUNER_PAL); printf(" NTSC tuning is supported: "); print_yn(v4l_tuner.flags&VIDEO_TUNER_NTSC); printf(" SECAM tuning is supported: "); print_yn(v4l_tuner.flags&VIDEO_TUNER_SECAM); printf(" Frequency is in a lower range: "); print_yn(v4l_tuner.flags&VIDEO_TUNER_LOW); printf(" The norm for this tuner is settable: "); print_yn(v4l_tuner.flags&VIDEO_TUNER_NORM); printf(" The tuner is seeing stereo audio: "); print_yn(v4l_tuner.flags&VIDEO_TUNER_STEREO_ON); printf(" The tuner is seeing a RDS datastream: "); print_yn(v4l_tuner.flags&VIDEO_TUNER_RDS_ON); printf(" The tuner is seeing a MBS datastream: "); print_yn(v4l_tuner.flags&VIDEO_TUNER_MBS_ON); } //printf(" Channel has tuners: "); //print_yn(v4l_chan.flags&VIDEO_VC_TUNER); printf(" Channel has audio: "); print_yn(v4l_chan.flags&VIDEO_VC_AUDIO); // missing in driver... but exists in documentation... //printf(" Channel has norm setting: "); //print_yn(v4l_chan.flags&VIDEO_VC_NORM); if(v4l_chan.type&VIDEO_TYPE_TV) printf(" The input is a TV input\n"); if(v4l_chan.type&VIDEO_TYPE_CAMERA) printf(" The input is a camera\n"); } // TODO Audio capture information errno=0; if(close(fd)==-1) { fprintf(stderr, " Error closing file '%s': %s\n",v4l_dev,strerror(errno) ); return 1; } return 0; }
/* * backend functions definied * * TODO: add new API calls! */ int print_caps_caps(const struct rig_caps *caps, void *data) { printf("<A NAME=\"caps%d\"><TR><TD>%s</TD>", caps->rig_model, caps->model_name); /* targetable_vfo is not a function, but a boolean */ print_yn(caps->targetable_vfo); print_yn(caps->set_freq); print_yn(caps->get_freq); print_yn(caps->set_mode); print_yn(caps->get_mode); print_yn(caps->set_vfo); print_yn(caps->get_vfo); print_yn(caps->set_ptt); print_yn(caps->get_ptt); print_yn(caps->get_dcd); print_yn(caps->set_rptr_shift); print_yn(caps->get_rptr_shift); print_yn(caps->set_rptr_offs); print_yn(caps->get_rptr_offs); print_yn(caps->set_split_freq); print_yn(caps->get_split_freq); print_yn(caps->set_split_vfo); print_yn(caps->get_split_vfo); print_yn(caps->set_ts); print_yn(caps->get_ts); print_yn(caps->set_ctcss_tone); print_yn(caps->get_ctcss_tone); print_yn(caps->set_dcs_code); print_yn(caps->get_dcs_code); print_yn(caps->set_powerstat); print_yn(caps->get_powerstat); print_yn(caps->set_trn); print_yn(caps->set_trn); print_yn(caps->decode_event); print_yn(caps->get_info); printf("</TR></A>\n"); return 1; }