This is an automatic generated email to let you know that the following patch were queued at the http://git.linuxtv.org/v4l-utils.git tree:
Subject: v4l2-ctl: add VIDIOC_ENUM_FREQ_BANDS support. Author: Hans Verkuil <[email protected]> Date: Wed Aug 1 21:57:20 2012 +0200 Signed-off-by: Hans Verkuil <[email protected]> (cherry picked from commit f4f00fa38ea6a79a36349a3eeb52a1a4513b3097) Signed-off-by: Gregor Jasny <[email protected]> utils/v4l2-ctl/v4l2-ctl-tuner.cpp | 55 +++++++++++++++++++++++++++++++++--- utils/v4l2-ctl/v4l2-ctl.cpp | 3 ++ utils/v4l2-ctl/v4l2-ctl.h | 1 + 3 files changed, 54 insertions(+), 5 deletions(-) --- http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=902f01c24002ecdec3f115449bec1a96d0592eee diff --git a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp index 1211664..cb6b01e 100644 --- a/utils/v4l2-ctl/v4l2-ctl-tuner.cpp +++ b/utils/v4l2-ctl/v4l2-ctl-tuner.cpp @@ -40,6 +40,8 @@ void tuner_usage(void) " set the audio mode of the tuner [VIDIOC_S_TUNER]\n" " Possible values: mono, stereo, lang2, lang1, bilingual\n" " --tuner-index=<idx> Use idx as tuner idx for tuner/modulator commands\n" + " --list-freq-bands display all frequency bands for the tuner/modulator\n" + " [VIDIOC_ENUM_FREQ_BANDS]\n" " --get-modulator query the modulator settings [VIDIOC_G_MODULATOR]\n" " --set-modulator=<txsubchans>\n" " set the sub-carrier modulation [VIDIOC_S_MODULATOR]\n" @@ -127,9 +129,26 @@ static std::string tcap2s(unsigned cap) s += "lang2 "; if (cap & V4L2_TUNER_CAP_RDS) s += "rds "; + if (cap & V4L2_TUNER_CAP_FREQ_BANDS) + s += "freq-bands "; + if (cap & V4L2_TUNER_CAP_HWSEEK_PROG_LIM) + s += "hwseek-prog-lim "; return s; } +static std::string modulation2s(unsigned modulation) +{ + switch (modulation) { + case V4L2_BAND_MODULATION_VSB: + return "VSB"; + case V4L2_BAND_MODULATION_FM: + return "FM"; + case V4L2_BAND_MODULATION_AM: + return "AM"; + } + return "Unknown"; +} + static void parse_freq_seek(char *optarg, struct v4l2_hw_freq_seek &seek) { char *value; @@ -216,17 +235,19 @@ void tuner_cmd(int ch, char *optarg) void tuner_set(int fd) { + __u32 type = (capabilities & V4L2_CAP_RADIO) ? + V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; + if (options[OptSetFreq]) { double fac = 16; + vf.type = type; if (capabilities & V4L2_CAP_MODULATOR) { - vf.type = V4L2_TUNER_RADIO; modulator.index = tuner_index; if (doioctl(fd, VIDIOC_G_MODULATOR, &modulator) == 0) { fac = (modulator.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16; } } else { - vf.type = V4L2_TUNER_ANALOG_TV; tuner.index = tuner_index; if (doioctl(fd, VIDIOC_G_TUNER, &tuner) == 0) { fac = (tuner.capability & V4L2_TUNER_CAP_LOW) ? 16000 : 16; @@ -251,6 +272,30 @@ void tuner_set(int fd) } } + if (options[OptListFreqBands]) { + struct v4l2_frequency_band band; + + memset(&band, 0, sizeof(band)); + band.tuner = tuner_index; + band.type = type; + band.index = 0; + printf("ioctl: VIDIOC_ENUM_FREQ_BANDS\n"); + while (test_ioctl(fd, VIDIOC_ENUM_FREQ_BANDS, &band) >= 0) { + if (band.index) + printf("\n"); + printf("\tIndex : %d\n", band.index); + printf("\tModulation : %s\n", modulation2s(band.modulation).c_str()); + printf("\tCapability : %s\n", tcap2s(band.capability).c_str()); + if (band.capability & V4L2_TUNER_CAP_LOW) + printf("\tFrequency Range: %.3f MHz - %.3f MHz\n", + band.rangelow / 16000.0, band.rangehigh / 16000.0); + else + printf("\tFrequency Range: %.3f MHz - %.3f MHz\n", + band.rangelow / 16.0, band.rangehigh / 16.0); + band.index++; + } + } + if (options[OptSetModulator]) { struct v4l2_modulator mt; @@ -264,7 +309,7 @@ void tuner_set(int fd) if (options[OptFreqSeek]) { freq_seek.tuner = tuner_index; - freq_seek.type = V4L2_TUNER_RADIO; + freq_seek.type = type; doioctl(fd, VIDIOC_S_HW_FREQ_SEEK, &freq_seek); } } @@ -303,10 +348,10 @@ void tuner_get(int fd) printf("\tName : %s\n", vt.name); printf("\tCapabilities : %s\n", tcap2s(vt.capability).c_str()); if (vt.capability & V4L2_TUNER_CAP_LOW) - printf("\tFrequency range : %.1f MHz - %.1f MHz\n", + printf("\tFrequency range : %.3f MHz - %.3f MHz\n", vt.rangelow / 16000.0, vt.rangehigh / 16000.0); else - printf("\tFrequency range : %.1f MHz - %.1f MHz\n", + printf("\tFrequency range : %.3f MHz - %.3f MHz\n", vt.rangelow / 16.0, vt.rangehigh / 16.0); printf("\tSignal strength/AFC : %d%%/%d\n", (int)((vt.signal / 655.35)+0.5), vt.afc); printf("\tCurrent audio mode : %s\n", audmode2s(vt.audmode)); diff --git a/utils/v4l2-ctl/v4l2-ctl.cpp b/utils/v4l2-ctl/v4l2-ctl.cpp index 19edcf2..0a5826f 100644 --- a/utils/v4l2-ctl/v4l2-ctl.cpp +++ b/utils/v4l2-ctl/v4l2-ctl.cpp @@ -122,6 +122,7 @@ static struct option long_options[] = { {"get-ctrl", required_argument, 0, OptGetCtrl}, {"get-tuner", no_argument, 0, OptGetTuner}, {"set-tuner", required_argument, 0, OptSetTuner}, + {"list-freq-bands", no_argument, 0, OptListFreqBands}, {"silent", no_argument, 0, OptSilent}, {"verbose", no_argument, 0, OptVerbose}, {"log-status", no_argument, 0, OptLogStatus}, @@ -883,6 +884,8 @@ int main(int argc, char **argv) verbose = options[OptVerbose]; doioctl(fd, VIDIOC_QUERYCAP, &vcap); capabilities = vcap.capabilities; + if (capabilities & V4L2_CAP_DEVICE_CAPS) + capabilities = vcap.device_caps; common_process_controls(fd); diff --git a/utils/v4l2-ctl/v4l2-ctl.h b/utils/v4l2-ctl/v4l2-ctl.h index 4ff1cf7..c6363bd 100644 --- a/utils/v4l2-ctl/v4l2-ctl.h +++ b/utils/v4l2-ctl/v4l2-ctl.h @@ -108,6 +108,7 @@ enum Option { OptSetJpegComp, OptGetModulator, OptSetModulator, + OptListFreqBands, OptListDevices, OptGetOutputParm, OptSetOutputParm, _______________________________________________ linuxtv-commits mailing list [email protected] http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits
