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: qv4l2: add dv_preset support
Author:  Hans Verkuil <hverk...@xs4all.nl>
Date:    Mon Aug 2 10:50:32 2010 +0200

Signed-off-by: Hans Verkuil <hverk...@xs4all.nl>

 utils/qv4l2/general-tab.cpp |   81 ++++++++++++++++++++++++++++++++++++------
 utils/qv4l2/general-tab.h   |    3 ++
 utils/qv4l2/v4l2-api.cpp    |   48 ++++++++++++++++++++++---
 utils/qv4l2/v4l2-api.h      |    7 +++-
 4 files changed, 119 insertions(+), 20 deletions(-)

---

http://git.linuxtv.org/v4l-utils.git?a=commitdiff;h=9c1095e49e6b24b231c9671f409944a73a9c4851

diff --git a/utils/qv4l2/general-tab.cpp b/utils/qv4l2/general-tab.cpp
index cb8d37b..e00d3b4 100644
--- a/utils/qv4l2/general-tab.cpp
+++ b/utils/qv4l2/general-tab.cpp
@@ -33,6 +33,8 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int 
n, QWidget *parent)
        m_col(0),
        m_cols(n),
        m_audioInput(NULL),
+       m_tvStandard(NULL),
+       m_videoPreset(NULL),
        m_freq(NULL),
        m_vidCapFormats(NULL),
        m_frameSize(NULL),
@@ -58,6 +60,30 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, int 
n, QWidget *parent)
 
        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");
@@ -106,18 +132,6 @@ GeneralTab::GeneralTab(const QString &device, v4l2 &fd, 
int n, QWidget *parent)
                updateAudioOutput();
        }
 
-       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();
-       }
-
        if (m_tuner.type) {
                m_freq = new QSpinBox(parent);
                m_freq->setMinimum(m_tuner.rangelow);
@@ -279,6 +293,15 @@ void GeneralTab::standardChanged(int std)
        updateStandard();
 }
 
+void GeneralTab::presetChanged(int index)
+{
+       v4l2_dv_enum_preset preset;
+
+       enum_dv_preset(preset, true, index);
+       s_dv_preset(preset.preset);
+       updatePreset();
+}
+
 void GeneralTab::freqTableChanged(int)
 {
        updateFreqChannel();
@@ -381,17 +404,29 @@ void GeneralTab::vidOutFormatChanged(int idx)
 void GeneralTab::updateVideoInput()
 {
        int input;
+       v4l2_input in;
 
        g_input(input);
+       enum_input(in, true, input);
        m_videoInput->setCurrentIndex(input);
+       if (m_tvStandard)
+               m_tvStandard->setEnabled(in.capabilities & V4L2_IN_CAP_STD);
+       if (m_videoPreset)
+               m_videoPreset->setEnabled(in.capabilities & 
V4L2_IN_CAP_PRESETS);
 }
 
 void GeneralTab::updateVideoOutput()
 {
        int output;
+       v4l2_output out;
 
        g_output(output);
+       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 GeneralTab::updateAudioInput()
@@ -453,6 +488,28 @@ void GeneralTab::updateStandard()
        m_tvStandard->setWhatsThis(what);
 }
 
+void GeneralTab::updatePreset()
+{
+       __u32 preset;
+       v4l2_dv_enum_preset p;
+       QString what;
+
+       g_dv_preset(preset);
+       if (enum_dv_preset(p, true)) {
+               do {
+                       if (p.preset == preset)
+                               break;
+               } while (enum_dv_preset(p));
+       }
+       if (p.preset != preset)
+               return;
+       m_videoPreset->setCurrentIndex(p.index);
+       what.sprintf("Video Preset (%u)\n"
+               "Frame %ux%u\n",
+               p.preset, p.width, p.height);
+       m_videoPreset->setWhatsThis(what);
+}
+
 void GeneralTab::updateFreq()
 {
        v4l2_frequency f;
diff --git a/utils/qv4l2/general-tab.h b/utils/qv4l2/general-tab.h
index 4309279..9a6615b 100644
--- a/utils/qv4l2/general-tab.h
+++ b/utils/qv4l2/general-tab.h
@@ -48,6 +48,7 @@ private slots:
        void inputAudioChanged(int);
        void outputAudioChanged(int);
        void standardChanged(int);
+       void presetChanged(int);
        void freqTableChanged(int);
        void freqChannelChanged(int);
        void freqChanged(int);
@@ -64,6 +65,7 @@ private:
        void updateAudioInput();
        void updateAudioOutput();
        void updateStandard();
+       void updatePreset();
        void updateFreq();
        void updateFreqChannel();
        void updateVidCapFormat();
@@ -99,6 +101,7 @@ private:
        QComboBox *m_audioInput;
        QComboBox *m_audioOutput;
        QComboBox *m_tvStandard;
+       QComboBox *m_videoPreset;
        QSpinBox  *m_freq;
        QComboBox *m_freqTable;
        QComboBox *m_freqChannel;
diff --git a/utils/qv4l2/v4l2-api.cpp b/utils/qv4l2/v4l2-api.cpp
index 4078f60..6b91bc4 100644
--- a/utils/qv4l2/v4l2-api.cpp
+++ b/utils/qv4l2/v4l2-api.cpp
@@ -204,6 +204,27 @@ bool v4l2::s_std(v4l2_std_id std)
        return ioctl("Set TV Standard", VIDIOC_S_STD, &std);
 }
 
+bool v4l2::g_dv_preset(__u32 &preset)
+{
+       struct v4l2_dv_preset p;
+       int err;
+
+       memset(&p, 0, sizeof(p));
+       err = ioctl(VIDIOC_G_DV_PRESET, &p);
+       preset = p.preset;
+       return err >= 0;
+}
+
+bool v4l2::s_dv_preset(__u32 preset)
+{
+       struct v4l2_dv_preset p;
+
+       memset(&p, 0, sizeof(p));
+       p.preset = preset;
+       return ioctl("Set Preset", VIDIOC_S_DV_PRESET, &p);
+}
+
+
 bool v4l2::g_frequency(v4l2_frequency &freq)
 {
        memset(&freq, 0, sizeof(freq));
@@ -251,21 +272,25 @@ bool v4l2::s_fmt(v4l2_format &fmt)
        return ioctl("Set Capture Format", VIDIOC_S_FMT, &fmt);
 }
 
-bool v4l2::enum_input(v4l2_input &in, bool init)
+bool v4l2::enum_input(v4l2_input &in, bool init, int index)
 {
-       if (init)
+       if (init) {
                memset(&in, 0, sizeof(in));
-       else
+               in.index = index;
+       } else {
                in.index++;
+       }
        return ioctl(VIDIOC_ENUMINPUT, &in) >= 0;
 }
 
-bool v4l2::enum_output(v4l2_output &out, bool init)
+bool v4l2::enum_output(v4l2_output &out, bool init, int index)
 {
-       if (init)
+       if (init) {
                memset(&out, 0, sizeof(out));
-       else
+               out.index = index;
+       } else {
                out.index++;
+       }
        return ioctl(VIDIOC_ENUMOUTPUT, &out) >= 0;
 }
 
@@ -298,6 +323,17 @@ bool v4l2::enum_std(v4l2_standard &std, bool init, int 
index)
        return ioctl(VIDIOC_ENUMSTD, &std) >= 0;
 }
 
+bool v4l2::enum_dv_preset(v4l2_dv_enum_preset &preset, bool init, int index)
+{
+       if (init) {
+               memset(&preset, 0, sizeof(preset));
+               preset.index = index;
+       } else {
+               preset.index++;
+       }
+       return ioctl(VIDIOC_ENUM_DV_PRESETS, &preset) >= 0;
+}
+
 bool v4l2::enum_fmt_cap(v4l2_fmtdesc &fmt, bool init, int index)
 {
        if (init) {
diff --git a/utils/qv4l2/v4l2-api.h b/utils/qv4l2/v4l2-api.h
index 99c67b6..8b8c55a 100644
--- a/utils/qv4l2/v4l2-api.h
+++ b/utils/qv4l2/v4l2-api.h
@@ -65,6 +65,8 @@ public:
        bool s_audout(int output);
        bool s_std(v4l2_std_id std);
        bool g_std(v4l2_std_id &std);
+       bool s_dv_preset(__u32 preset);
+       bool g_dv_preset(__u32 &preset);
        bool g_frequency(v4l2_frequency &freq);
        bool s_frequency(v4l2_frequency &freq);
        bool s_frequency(int freq);
@@ -72,11 +74,12 @@ public:
        bool g_fmt_out(v4l2_format &fmt);
        bool try_fmt(v4l2_format &fmt);
        bool s_fmt(v4l2_format &fmt);
-       bool enum_input(v4l2_input &in, bool init = false);
-       bool enum_output(v4l2_output &out, bool init = false);
+       bool enum_input(v4l2_input &in, bool init = false, int index = 0);
+       bool enum_output(v4l2_output &out, bool init = false, int index = 0);
        bool enum_audio(v4l2_audio &audio, bool init = false);
        bool enum_audout(v4l2_audioout &audout, bool init = false);
        bool enum_std(v4l2_standard &std, bool init = false, int index = 0);
+       bool enum_dv_preset(v4l2_dv_enum_preset &preset, bool init = false, int 
index = 0);
        bool enum_fmt_cap(v4l2_fmtdesc &std, bool init = false, int index = 0);
        bool enum_fmt_out(v4l2_fmtdesc &std, bool init = false, int index = 0);
        bool enum_framesizes(v4l2_frmsizeenum &frm, __u32 init_pixfmt = 0, int 
index = 0);

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
http://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to