__u32 ApplicationWindow::tpgDefaultColorspace() { v4l2_dv_timings timings = { 0 }; v4l2_output out; __u32 io_caps; bool dvi_d = false; g_output(out.index); enum_output(out, true, out.index); io_caps = out.capabilities; v4l2_control ctrl = { V4L2_CID_DV_TX_MODE }; if (!g_ctrl(ctrl)) dvi_d = ctrl.value == V4L2_DV_TX_MODE_DVI_D; if (io_caps & V4L2_OUT_CAP_STD) return V4L2_COLORSPACE_SMPTE170M; if (!(io_caps & V4L2_OUT_CAP_DV_TIMINGS)) return V4L2_COLORSPACE_SRGB; g_dv_timings(timings); if (!(timings.bt.standards & V4L2_DV_BT_STD_CEA861) || dvi_d) return V4L2_COLORSPACE_SRGB; if (timings.bt.width == 720 && timings.bt.height <= 576) return V4L2_COLORSPACE_SMPTE170M; return V4L2_COLORSPACE_REC709; }
void GeneralTab::updateVideoOutput() { int output; v4l2_output out; if (!g_output(output)) return; enum_output(out, true, output); m_videoOutput->setCurrentIndex(output); if (m_tvStandard) m_tvStandard->setEnabled(out.capabilities & V4L2_OUT_CAP_STD); if (m_videoPreset) m_videoPreset->setEnabled(out.capabilities & V4L2_OUT_CAP_PRESETS); }
void ApplicationWindow::updateLimRGBRange() { if (m_tpgLimRGBRange == NULL) return; v4l2_output out; g_output(out.index); enum_output(out, true, out.index); if (out.capabilities & V4L2_OUT_CAP_STD) { m_tpgLimRGBRange->setChecked(false); } else if (out.capabilities & V4L2_OUT_CAP_DV_TIMINGS) { v4l2_dv_timings timings; g_dv_timings(timings); if (timings.bt.standards & V4L2_DV_BT_STD_CEA861) m_tpgLimRGBRange->setChecked(true); else m_tpgLimRGBRange->setChecked(false); } else { m_tpgLimRGBRange->setChecked(false); } }
GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int n, QWidget *parent) : QGridLayout(parent), v4l2(fd), m_row(0), m_col(0), m_cols(n), m_audioInput(NULL), m_tvStandard(NULL), m_videoPreset(NULL), m_freq(NULL), m_vidCapFormats(NULL), m_frameSize(NULL), m_vidOutFormats(NULL) { setSpacing(3); setSizeConstraint(QLayout::SetMinimumSize); if (querycap(m_querycap)) { addLabel("Device:"); addLabel(device + (useWrapper() ? " (wrapped)" : ""), Qt::AlignLeft); addLabel("Driver:"); addLabel((char *)m_querycap.driver, Qt::AlignLeft); addLabel("Card:"); addLabel((char *)m_querycap.card, Qt::AlignLeft); addLabel("Bus:"); addLabel((char *)m_querycap.bus_info, Qt::AlignLeft); } g_tuner(m_tuner); v4l2_standard vs; if (enum_std(vs, true)) { addLabel("TV Standard"); m_tvStandard = new QComboBox(parent); do { m_tvStandard->addItem((char *)vs.name); } while (enum_std(vs)); addWidget(m_tvStandard); connect(m_tvStandard, SIGNAL(activated(int)), SLOT(standardChanged(int))); updateStandard(); } v4l2_dv_enum_preset preset; if (enum_dv_preset(preset, true)) { addLabel("Video Preset"); m_videoPreset = new QComboBox(parent); do { m_videoPreset->addItem((char *)preset.name); } while (enum_dv_preset(preset)); addWidget(m_videoPreset); connect(m_videoPreset, SIGNAL(activated(int)), SLOT(presetChanged(int))); updatePreset(); } v4l2_input vin; if (enum_input(vin, true)) { addLabel("Input"); m_videoInput = new QComboBox(parent); do { m_videoInput->addItem((char *)vin.name); } while (enum_input(vin)); addWidget(m_videoInput); connect(m_videoInput, SIGNAL(activated(int)), SLOT(inputChanged(int))); updateVideoInput(); } v4l2_output vout; if (enum_output(vout, true)) { addLabel("Output"); m_videoOutput = new QComboBox(parent); do { m_videoOutput->addItem((char *)vout.name); } while (enum_output(vout)); addWidget(m_videoOutput); connect(m_videoOutput, SIGNAL(activated(int)), SLOT(outputChanged(int))); updateVideoOutput(); } v4l2_audio vaudio; if (enum_audio(vaudio, true)) { addLabel("Input Audio"); m_audioInput = new QComboBox(parent); do { m_audioInput->addItem((char *)vaudio.name); } while (enum_audio(vaudio)); addWidget(m_audioInput); connect(m_audioInput, SIGNAL(activated(int)), SLOT(inputAudioChanged(int))); updateAudioInput(); } v4l2_audioout vaudout; if (enum_audout(vaudout, true)) { addLabel("Output Audio"); m_audioOutput = new QComboBox(parent); do { m_audioOutput->addItem((char *)vaudout.name); } while (enum_audout(vaudout)); addWidget(m_audioOutput); connect(m_audioOutput, SIGNAL(activated(int)), SLOT(outputAudioChanged(int))); updateAudioOutput(); } if (m_tuner.type) { m_freq = new QSpinBox(parent); m_freq->setMinimum(m_tuner.rangelow); m_freq->setMaximum(m_tuner.rangehigh); m_freq->setWhatsThis(QString("Frequency\nLow: %1\nHigh: %2") .arg(m_tuner.rangelow).arg(m_tuner.rangehigh)); connect(m_freq, SIGNAL(valueChanged(int)), SLOT(freqChanged(int))); updateFreq(); addLabel("Frequency"); addWidget(m_freq); addLabel("Frequency Table"); m_freqTable = new QComboBox(parent); for (int i = 0; v4l2_channel_lists[i].name; i++) { m_freqTable->addItem(v4l2_channel_lists[i].name); } addWidget(m_freqTable); connect(m_freqTable, SIGNAL(activated(int)), SLOT(freqTableChanged(int))); addLabel("Channels"); m_freqChannel = new QComboBox(parent); m_freqChannel->setSizeAdjustPolicy(QComboBox::AdjustToContents); addWidget(m_freqChannel); connect(m_freqChannel, SIGNAL(activated(int)), SLOT(freqChannelChanged(int))); updateFreqChannel(); } v4l2_fmtdesc fmt; addLabel("Capture Image Formats"); m_vidCapFormats = new QComboBox(parent); if (enum_fmt_cap(fmt, true)) { do { m_vidCapFormats->addItem(pixfmt2s(fmt.pixelformat) + " - " + (const char *)fmt.description); } while (enum_fmt_cap(fmt)); } addWidget(m_vidCapFormats); connect(m_vidCapFormats, SIGNAL(activated(int)), SLOT(vidCapFormatChanged(int))); addLabel("Frame Width"); m_frameWidth = new QSpinBox(parent); addWidget(m_frameWidth); connect(m_frameWidth, SIGNAL(editingFinished()), SLOT(frameWidthChanged())); addLabel("Frame Height"); m_frameHeight = new QSpinBox(parent); addWidget(m_frameHeight); connect(m_frameHeight, SIGNAL(editingFinished()), SLOT(frameHeightChanged())); addLabel("Frame Size"); m_frameSize = new QComboBox(parent); m_frameSize->setSizeAdjustPolicy(QComboBox::AdjustToContents); addWidget(m_frameSize); connect(m_frameSize, SIGNAL(activated(int)), SLOT(frameSizeChanged(int))); addLabel("Frame Interval"); m_frameInterval = new QComboBox(parent); m_frameInterval->setSizeAdjustPolicy(QComboBox::AdjustToContents); addWidget(m_frameInterval); connect(m_frameInterval, SIGNAL(activated(int)), SLOT(frameIntervalChanged(int))); updateVidCapFormat(); if (caps() & V4L2_CAP_VIDEO_OUTPUT) { addLabel("Output Image Formats"); m_vidOutFormats = new QComboBox(parent); if (enum_fmt_out(fmt, true)) { do { m_vidOutFormats->addItem(pixfmt2s(fmt.pixelformat) + " - " + (const char *)fmt.description); } while (enum_fmt_out(fmt)); } addWidget(m_vidOutFormats); connect(m_vidOutFormats, SIGNAL(activated(int)), SLOT(vidOutFormatChanged(int))); } addLabel("Capture Method"); m_capMethods = new QComboBox(parent); if (m_querycap.capabilities & V4L2_CAP_STREAMING) { v4l2_requestbuffers reqbuf; // Yuck. The videobuf framework does not accept a count of 0. // This is out-of-spec, but it means that the only way to test which // method is supported is to give it a non-zero count. But non-videobuf // drivers like uvc do not allow e.g. S_FMT calls after a REQBUFS call // with non-zero counts unless there is a REQBUFS call with count == 0 // in between. This is actual proper behavior, although somewhat // unexpected. So the only way at the moment to do this that works // everywhere is to call REQBUFS with a count of 1, and then again with // a count of 0. if (reqbufs_user_cap(reqbuf, 1)) { m_capMethods->addItem("User pointer I/O", QVariant(methodUser)); reqbufs_user_cap(reqbuf, 0); } if (reqbufs_mmap_cap(reqbuf, 1)) { m_capMethods->addItem("Memory mapped I/O", QVariant(methodMmap)); reqbufs_mmap_cap(reqbuf, 0); } } if (m_querycap.capabilities & V4L2_CAP_READWRITE) { m_capMethods->addItem("read()", QVariant(methodRead)); } addWidget(m_capMethods); QGridLayout::addWidget(new QWidget(parent), rowCount(), 0, 1, n); setRowStretch(rowCount() - 1, 1); }