[PATCH] libv4l1: move VIDIOCGAUDIO and VIDIOCSAUDIO to libv4l1

2010-06-07 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

move VIDIOCGAUDIO and VIDIOCSAUDIO to libv4l1

Signed-of-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1-priv.h |7 ++
 lib/libv4l1/libv4l1.c  |  160 
 2 files changed, 167 insertions(+), 0 deletions(-)

diff --git a/lib/libv4l1/libv4l1-priv.h b/lib/libv4l1/libv4l1-priv.h
index 11f4fd0..11ee57a 100644
--- a/lib/libv4l1/libv4l1-priv.h
+++ b/lib/libv4l1/libv4l1-priv.h
@@ -60,6 +60,13 @@ extern FILE *v4l1_log_file;
 #define min(a, b) (((a)  (b)) ? (a) : (b))
 #endif
 
+#define DIV_ROUND_CLOSEST(x, divisor)(  \
+{   \
+   typeof(divisor) __divisor = divisor;\
+   (((x) + ((__divisor) / 2)) / (__divisor));  \
+}   \
+)
+
 struct v4l1_dev_info {
int fd;
int flags;
diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index 2981c40..263d564 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -233,6 +233,59 @@ static int v4l1_set_format(int index, unsigned int width,
return result;
 }
 
+static int set_v4l_control(int fd, int cid, int value)
+{
+   struct v4l2_queryctrl qctrl2;
+   struct v4l2_control ctrl2;
+   int result;
+
+   qctrl2.id = cid;
+   result = v4l2_ioctl(fd, VIDIOC_QUERYCTRL, qctrl2);
+   if (result  0)
+   return 0;
+   if (result == 0 
+   !(qctrl2.flags  V4L2_CTRL_FLAG_DISABLED) 
+   !(qctrl2.flags  V4L2_CTRL_FLAG_GRABBED)) {
+   if (value  0)
+   value = 0;
+   if (value  65535)
+   value = 65535;
+   if (value  qctrl2.type == V4L2_CTRL_TYPE_BOOLEAN)
+   value = 65535;
+   ctrl2.id = qctrl2.id;
+   ctrl2.value =
+   (value * (qctrl2.maximum - qctrl2.minimum)
+   + 32767)
+   / 65535;
+   ctrl2.value += qctrl2.minimum;
+   result = v4l2_ioctl(fd, VIDIOC_S_CTRL, ctrl2);
+   }
+   return 0;
+}
+
+static int get_v4l_control(int fd, int cid)
+{
+   struct v4l2_queryctrl qctrl2;
+   struct v4l2_control ctrl2;
+   int result;
+
+   qctrl2.id = cid;
+   result = v4l2_ioctl(fd, VIDIOC_QUERYCTRL, qctrl2);
+   if (result  0)
+   return 0;
+   if (result == 0  !(qctrl2.flags  V4L2_CTRL_FLAG_DISABLED)) {
+   ctrl2.id = qctrl2.id;
+   result = v4l2_ioctl(fd, VIDIOC_G_CTRL, ctrl2);
+   if (result  0)
+   return 0;
+
+   return DIV_ROUND_CLOSEST((ctrl2.value-qctrl2.minimum) * 65535,
+   qctrl2.maximum - qctrl2.minimum);
+   }
+   return 0;
+}
+
+
 static void v4l1_find_min_and_max_size(int index, struct v4l2_format *fmt2)
 {
int i;
@@ -983,6 +1036,113 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
 
break;
}
+
+   case VIDIOCSAUDIO: {
+   struct video_audio *aud = arg;
+   struct v4l2_audio aud2 = { 0, };
+   struct v4l2_tuner tun2 = { 0, };
+
+   aud2.index = aud-audio;
+   result = v4l2_ioctl(fd, VIDIOC_S_AUDIO, aud2);
+   if (result  0)
+   break;
+
+   set_v4l_control(fd, V4L2_CID_AUDIO_VOLUME,
+   aud-volume);
+   set_v4l_control(fd, V4L2_CID_AUDIO_BASS,
+   aud-bass);
+   set_v4l_control(fd, V4L2_CID_AUDIO_TREBLE,
+   aud-treble);
+   set_v4l_control(fd, V4L2_CID_AUDIO_BALANCE,
+   aud-balance);
+   set_v4l_control(fd, V4L2_CID_AUDIO_MUTE,
+   !!(aud-flags  VIDEO_AUDIO_MUTE));
+
+   result = v4l2_ioctl(fd, VIDIOC_G_TUNER, tun2);
+   if (result  0)
+   break;
+   if (result == 0) {
+   switch (aud-mode) {
+   default:
+   case VIDEO_SOUND_MONO:
+   case VIDEO_SOUND_LANG1:
+   tun2.audmode = V4L2_TUNER_MODE_MONO;
+   break;
+   case VIDEO_SOUND_STEREO:
+   tun2.audmode = V4L2_TUNER_MODE_STEREO;
+   break;
+   case VIDEO_SOUND_LANG2:
+   tun2.audmode = V4L2_TUNER_MODE_LANG2;
+   break;
+   }
+   result = v4l2_ioctl(fd, VIDIOC_S_TUNER, tun2);
+   }
+   break;
+   }
+
+   case VIDIOCGAUDIO: {
+   int i;
+   struct video_audio *aud = arg;
+   struct v4l2_queryctrl 

[PATCH] libv4l1: move VIDIOCGVBIFMT and VIDIOCSVBIFMT into libv4l1

2010-06-07 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

move VIDIOCGVBIFMT and VIDIOCSVBIFMT into libv4l1

Signed-of-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1.c |   65 +
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index 263d564..6d6caa6 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -1143,6 +1143,71 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
 
}
 
+   case VIDIOCSVBIFMT: {
+   struct vbi_format *fmt = arg;
+   struct v4l2_format fmt2;
+
+   if (VIDEO_PALETTE_RAW != fmt-sample_format) {
+   result = -EINVAL;
+   break;
+   }
+
+   fmt2.type = V4L2_BUF_TYPE_VBI_CAPTURE;
+   fmt2.fmt.vbi.samples_per_line = fmt-samples_per_line;
+   fmt2.fmt.vbi.sampling_rate= fmt-sampling_rate;
+   fmt2.fmt.vbi.sample_format= V4L2_PIX_FMT_GREY;
+   fmt2.fmt.vbi.start[0] = fmt-start[0];
+   fmt2.fmt.vbi.count[0] = fmt-count[0];
+   fmt2.fmt.vbi.start[1] = fmt-start[1];
+   fmt2.fmt.vbi.count[1] = fmt-count[1];
+   fmt2.fmt.vbi.flags= fmt-flags;
+
+   result  = v4l2_ioctl(fd, VIDIOC_TRY_FMT, fmt2);
+   if (result  0)
+   break;
+
+   if (fmt2.fmt.vbi.samples_per_line != fmt-samples_per_line ||
+   fmt2.fmt.vbi.sampling_rate!= fmt-sampling_rate||
+   fmt2.fmt.vbi.sample_format!= V4L2_PIX_FMT_GREY ||
+   fmt2.fmt.vbi.start[0] != fmt-start[0] ||
+   fmt2.fmt.vbi.count[0] != fmt-count[0] ||
+   fmt2.fmt.vbi.start[1] != fmt-start[1] ||
+   fmt2.fmt.vbi.count[1] != fmt-count[1] ||
+   fmt2.fmt.vbi.flags!= fmt-flags) {
+   result = -EINVAL;
+   break;
+   }
+   result = v4l2_ioctl(fd, VIDIOC_S_FMT, fmt2);
+
+   }
+
+   case VIDIOCGVBIFMT: {
+   struct vbi_format *fmt = arg;
+   struct v4l2_format fmt2 = { 0, };
+
+   fmt2.type = V4L2_BUF_TYPE_VBI_CAPTURE;
+   result = v4l2_ioctl(fd, VIDIOC_G_FMT, fmt2);
+
+   if (result  0)
+   break;
+
+   if (fmt2.fmt.vbi.sample_format != V4L2_PIX_FMT_GREY) {
+   result = -EINVAL;
+   break;
+   }
+
+   fmt-samples_per_line = fmt2.fmt.vbi.samples_per_line;
+   fmt-sampling_rate= fmt2.fmt.vbi.sampling_rate;
+   fmt-sample_format= VIDEO_PALETTE_RAW;
+   fmt-start[0] = fmt2.fmt.vbi.start[0];
+   fmt-count[0] = fmt2.fmt.vbi.count[0];
+   fmt-start[1] = fmt2.fmt.vbi.start[1];
+   fmt-count[1] = fmt2.fmt.vbi.count[1];
+   fmt-flags= fmt2.fmt.vbi.flags  0x03;
+
+   break;
+   }
+
default:
/* Pass through libv4l2 for applications which are using v4l2 
through
   libv4l1 (this can happen with the v4l1compat.so wrapper 
preloaded */
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libv4l1: move VIDIOCGAUDIO,VIDIOCSAUDIO,VIDIOCGVBIFMT,VIDIOCSVBIFMT

2010-06-07 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

merged two previous patches, now uses v4l2_set_control and
v4l2_get_control

Signed-of-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1-priv.h |7 ++
 lib/libv4l1/libv4l1.c  |  172 
 2 files changed, 179 insertions(+), 0 deletions(-)

diff --git a/lib/libv4l1/libv4l1-priv.h b/lib/libv4l1/libv4l1-priv.h
index 11f4fd0..11ee57a 100644
--- a/lib/libv4l1/libv4l1-priv.h
+++ b/lib/libv4l1/libv4l1-priv.h
@@ -60,6 +60,13 @@ extern FILE *v4l1_log_file;
 #define min(a, b) (((a)  (b)) ? (a) : (b))
 #endif
 
+#define DIV_ROUND_CLOSEST(x, divisor)(  \
+{   \
+   typeof(divisor) __divisor = divisor;\
+   (((x) + ((__divisor) / 2)) / (__divisor));  \
+}   \
+)
+
 struct v4l1_dev_info {
int fd;
int flags;
diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index 2981c40..830ed6b 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -983,6 +983,178 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
 
break;
}
+
+   case VIDIOCSAUDIO: {
+   struct video_audio *aud = arg;
+   struct v4l2_audio aud2 = { 0, };
+   struct v4l2_tuner tun2 = { 0, };
+
+   aud2.index = aud-audio;
+   result = v4l2_ioctl(fd, VIDIOC_S_AUDIO, aud2);
+   if (result  0)
+   break;
+
+   v4l2_set_control(fd, V4L2_CID_AUDIO_VOLUME,
+   aud-volume);
+   v4l2_set_control(fd, V4L2_CID_AUDIO_BASS,
+   aud-bass);
+   v4l2_set_control(fd, V4L2_CID_AUDIO_TREBLE,
+   aud-treble);
+   v4l2_set_control(fd, V4L2_CID_AUDIO_BALANCE,
+   aud-balance);
+   v4l2_set_control(fd, V4L2_CID_AUDIO_MUTE,
+   !!(aud-flags  VIDEO_AUDIO_MUTE));
+
+   result = v4l2_ioctl(fd, VIDIOC_G_TUNER, tun2);
+   if (result  0)
+   break;
+   if (result == 0) {
+   switch (aud-mode) {
+   default:
+   case VIDEO_SOUND_MONO:
+   case VIDEO_SOUND_LANG1:
+   tun2.audmode = V4L2_TUNER_MODE_MONO;
+   break;
+   case VIDEO_SOUND_STEREO:
+   tun2.audmode = V4L2_TUNER_MODE_STEREO;
+   break;
+   case VIDEO_SOUND_LANG2:
+   tun2.audmode = V4L2_TUNER_MODE_LANG2;
+   break;
+   }
+   result = v4l2_ioctl(fd, VIDIOC_S_TUNER, tun2);
+   }
+   break;
+   }
+
+   case VIDIOCGAUDIO: {
+   int i;
+   struct video_audio *aud = arg;
+   struct v4l2_queryctrl qctrl2;
+   struct v4l2_audio aud2 = { 0, };
+   struct v4l2_tuner tun2;
+
+   result = v4l2_ioctl(fd, VIDIOC_G_AUDIO, aud2);
+   if (result  0)
+   break;
+
+   memcpy(aud-name, aud2.name,
+   min(sizeof(aud-name), sizeof(aud2.name)));
+   aud-name[sizeof(aud-name) - 1] = 0;
+   aud-audio = aud2.index;
+   aud-flags = 0;
+   i = v4l2_get_control(fd, V4L2_CID_AUDIO_VOLUME);
+   if (i = 0) {
+   aud-volume = i;
+   aud-flags |= VIDEO_AUDIO_VOLUME;
+   }
+   i = v4l2_get_control(fd, V4L2_CID_AUDIO_BASS);
+   if (i = 0) {
+   aud-bass = i;
+   aud-flags |= VIDEO_AUDIO_BASS;
+   }
+   i = v4l2_get_control(fd, V4L2_CID_AUDIO_TREBLE);
+   if (i = 0) {
+   aud-treble = i;
+   aud-flags |= VIDEO_AUDIO_TREBLE;
+   }
+   i = v4l2_get_control(fd, V4L2_CID_AUDIO_BALANCE);
+   if (i = 0) {
+   aud-balance = i;
+   aud-flags |= VIDEO_AUDIO_BALANCE;
+   }
+   i = v4l2_get_control(fd, V4L2_CID_AUDIO_MUTE);
+   if (i = 0) {
+   if (i)
+   aud-flags |= VIDEO_AUDIO_MUTE;
+
+   aud-flags |= VIDEO_AUDIO_MUTABLE;
+   }
+   aud-step = 1;
+   qctrl2.id = V4L2_CID_AUDIO_VOLUME;
+   if (v4l2_ioctl(fd, VIDIOC_QUERYCTRL, qctrl2) == 0 
+   !(qctrl2.flags  V4L2_CTRL_FLAG_DISABLED))
+   aud-step = qctrl2.step;
+   aud-mode = 0;
+
+   result 

[PATCH] libv4l1: move VIDIOCGTUNER and VIDIOCSTUNER to libv4l1

2010-06-04 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

move VIDIOCGTUNER and VIDIOCSTUNER to libv4l1

Signed-of-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1.c |   58 +
 1 files changed, 58 insertions(+), 0 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index 75b823c..081ed0a 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -881,6 +881,64 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
break;
}
 
+   case VIDIOCSTUNER: {
+   struct video_tuner *tun = arg;
+   struct v4l2_tuner t = { 0, };
+
+   t.index = tun-tuner;
+   result = v4l2_ioctl(fd, VIDIOC_S_TUNER, t);
+
+   break;
+   }
+
+   case VIDIOCGTUNER: {
+   int i;
+   struct video_tuner *tun = arg;
+   struct v4l2_tuner tun2 = { 0, };
+   struct v4l2_standard std2 = { 0, };
+   v4l2_std_id sid;
+
+   result = v4l2_ioctl(fd, VIDIOC_G_TUNER, tun2);
+   if (result  0)
+   break;
+
+   memcpy(tun-name, tun2.name,
+   min(sizeof(tun-name), sizeof(tun2.name)));
+   tun-name[sizeof(tun-name) - 1] = 0;
+   tun-rangelow = tun2.rangelow;
+   tun-rangehigh = tun2.rangehigh;
+   tun-flags = 0;
+   tun-mode = VIDEO_MODE_AUTO;
+
+   for (i = 0; i  64; i++) {
+   std2.index = i;
+   if (0 != v4l2_ioctl(fd, VIDIOC_ENUMSTD, std2))
+   break;
+   if (std2.id  V4L2_STD_PAL)
+   tun-flags |= VIDEO_TUNER_PAL;
+   if (std2.id  V4L2_STD_NTSC)
+   tun-flags |= VIDEO_TUNER_NTSC;
+   if (std2.id  V4L2_STD_SECAM)
+   tun-flags |= VIDEO_TUNER_SECAM;
+   }
+
+   if (v4l2_ioctl(fd, VIDIOC_G_STD, sid) == 0) {
+   if (sid  V4L2_STD_PAL)
+   tun-mode = VIDEO_MODE_PAL;
+   if (sid  V4L2_STD_NTSC)
+   tun-mode = VIDEO_MODE_NTSC;
+   if (sid  V4L2_STD_SECAM)
+   tun-mode = VIDEO_MODE_SECAM;
+   }
+   if (tun2.capability  V4L2_TUNER_CAP_LOW)
+   tun-flags |= VIDEO_TUNER_LOW;
+   if (tun2.rxsubchans  V4L2_TUNER_SUB_STEREO)
+   tun-flags |= VIDEO_TUNER_STEREO_ON;
+   tun-signal = tun2.signal;
+
+   break;
+   }
+
default:
/* Pass through libv4l2 for applications which are using v4l2 
through
   libv4l1 (this can happen with the v4l1compat.so wrapper 
preloaded */
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libv4l1: move VIDIOCGFREQ and VIDIOCSFREQ to libv4l1

2010-06-04 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

move VIDIOCGFREQ and VIDIOCSFREQ to libv4l1

Signed-of-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1.c |   28 
 1 files changed, 28 insertions(+), 0 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index 081ed0a..579f13b 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -939,6 +939,34 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
break;
}
 
+   case VIDIOCSFREQ: {
+   unsigned long *freq = arg;
+   struct v4l2_frequency freq2 = { 0, };
+
+   result = v4l2_ioctl(fd, VIDIOC_G_FREQUENCY, freq2);
+   if (result  0)
+   break;
+
+   freq2.frequency = *freq;
+
+   result = v4l2_ioctl(fd, VIDIOC_S_FREQUENCY, freq2);
+
+   break;
+   }
+
+   case VIDIOCGFREQ: {
+   unsigned long *freq = arg;
+   struct v4l2_frequency freq2 = { 0, };
+
+   freq2.tuner = 0;
+   result = v4l2_ioctl(fd, VIDIOC_G_FREQUENCY, freq2);
+   if (result  0)
+   break;
+   if (0 == result)
+   *freq = freq2.frequency;
+
+   break;
+   }
default:
/* Pass through libv4l2 for applications which are using v4l2 
through
   libv4l1 (this can happen with the v4l1compat.so wrapper 
preloaded */
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libv4l1: move VIDIOCCAPTURE to libv4l1

2010-06-04 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

move VIDIOCCAPTURE to libv4l1

Signed-of-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1.c |   16 
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index 579f13b..2981c40 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -967,6 +967,22 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
 
break;
}
+
+   case VIDIOCCAPTURE: {
+   int *on = arg;
+   enum v4l2_buf_type captype = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+
+   if (0 == *on) {
+   /* dirty hack time.  But v4l1 has no STREAMOFF
+   * equivalent in the API, and this one at
+   * least comes close ... */
+   v4l2_ioctl(fd, VIDIOC_STREAMOFF, captype);
+   }
+
+   result = v4l2_ioctl(fd, VIDIOC_OVERLAY, on);
+
+   break;
+   }
default:
/* Pass through libv4l2 for applications which are using v4l2 
through
   libv4l1 (this can happen with the v4l1compat.so wrapper 
preloaded */
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libv4l1: Move VIDIOCSFBUF into libv4l1

2010-06-01 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@fedora-12.(none)

Move VIDIOCSFBUF into libv4l1 and correct a missing
break with the last commit

Signed-Off-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1.c |   32 
 1 files changed, 32 insertions(+), 0 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index ac3c2d9..877508c 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -847,6 +847,38 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
(buffer-width * buffer-depth + 7)  7;
buffer-bytesperline = 3;
}
+   break;
+   }
+
+   case VIDIOCSFBUF: {
+   struct video_buffer *buffer = arg;
+   struct v4l2_framebuffer fbuf = { 0, };
+
+   fbuf.base = buffer-base;
+   fbuf.fmt.height = buffer-height;
+   fbuf.fmt.width = buffer-width;
+
+   switch (buffer-depth) {
+   case 8:
+   fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB332;
+   break;
+   case 15:
+   fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB555;
+   break;
+   case 16:
+   fbuf.fmt.pixelformat = V4L2_PIX_FMT_RGB565;
+   break;
+   case 24:
+   fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR24;
+   break;
+   case 32:
+   fbuf.fmt.pixelformat = V4L2_PIX_FMT_BGR32;
+   break;
+   }
+
+   fbuf.fmt.bytesperline = buffer-bytesperline;
+   result = v4l2_ioctl(fd, VIDIOC_G_FBUF, buffer);
+   break;
}
 
default:
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libv4l1: Move VIDIOCGFBUF into libv4l1

2010-05-31 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@fedora-12.(none)

Move VIDIOCGFBUF into libv4l1

Signed-off-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1.c |   45 +
 1 files changed, 45 insertions(+), 0 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index e13feba..5b2dc29 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -804,6 +804,51 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
break;
}
 
+   case VIDIOCGFBUF: {
+   struct video_buffer *buffer = arg;
+   struct v4l2_framebuffer fbuf = { 0, };
+
+   result = v4l2_ioctl(fd, VIDIOC_G_FBUF, buffer);
+   if (result  0)
+   break;
+
+   buffer-base = fbuf.base;
+   buffer-height = fbuf.fmt.height;
+   buffer-width = fbuf.fmt.width;
+
+   switch (fbuf.fmt.pixelformat) {
+   case V4L2_PIX_FMT_RGB332:
+   buffer-depth = 8;
+   break;
+   case V4L2_PIX_FMT_RGB555:
+   buffer-depth = 15;
+   break;
+   case V4L2_PIX_FMT_RGB565:
+   buffer-depth = 16;
+   break;
+   case V4L2_PIX_FMT_BGR24:
+   buffer-depth = 24;
+   break;
+   case V4L2_PIX_FMT_BGR32:
+   buffer-depth = 32;
+   break;
+   default:
+   buffer-depth = 0;
+   }
+
+   if (fbuf.fmt.bytesperline) {
+   buffer-bytesperline = fbuf.fmt.bytesperline;
+   if (!buffer-depth  buffer-width)
+   buffer-depth = ((fbuf.fmt.bytesperline3)
+   + (buffer-width-1))
+   / buffer-width;
+   } else {
+   buffer-bytesperline =
+   (buffer-width * buffer-depth + 7)  7;
+   buffer-bytesperline = 3;
+   }
+   }
+
default:
/* Pass through libv4l2 for applications which are using v4l2 
through
   libv4l1 (this can happen with the v4l1compat.so wrapper 
preloaded */
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libv4l1: move v4l1 ioctls from kernel to libv4l1: VIDIOCSCHAN move VIDIOCSCHAN to libv4l1 Signed-off-by: Huzaifa Sidhpurwala huzai...@redhat.com

2010-05-27 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@fedora-12.(none)

---
 lib/libv4l1/libv4l1.c |   39 ++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index f64025a..077d57c 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -702,7 +702,44 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
struct video_channel *chan = arg;
if ((devices[index].flags  V4L1_SUPPORTS_ENUMINPUT) 
(devices[index].flags  V4L1_SUPPORTS_ENUMSTD)) 
{
-   result = SYS_IOCTL(fd, request, arg);
+
+   v4l2_std_id sid;
+
+   input2.index = chan-channel;
+   result = SYS_IOCTL(fd, VIDIOC_ENUMINPUT, input2);
+   if (result  0)
+   break;
+
+   chan-channel = input2.index;
+   memcpy(chan-name, input2.name,
+   min(sizeof(chan-name), sizeof(input2.name)));
+
+   chan-name[sizeof(chan-name) - 1] = 0;
+   chan-tuners =
+   (input2.type == V4L2_INPUT_TYPE_TUNER) ? 1 : 0;
+
+   chan-flags = (chan-tuners) ? VIDEO_VC_TUNER : 0;
+   switch (input2.type) {
+   case V4L2_INPUT_TYPE_TUNER:
+   chan-type = VIDEO_TYPE_TV;
+   break;
+   default:
+   case V4L2_INPUT_TYPE_CAMERA:
+   chan-type = VIDEO_TYPE_CAMERA;
+   break;
+   }
+   chan-norm = 0;
+   if (SYS_IOCTL(fd, VIDIOC_G_STD, sid) == 0) {
+   if (sid  V4L2_STD_PAL)
+   chan-norm = VIDEO_MODE_PAL;
+   if (sid  V4L2_STD_NTSC)
+   chan-norm = VIDEO_MODE_NTSC;
+   if (sid  V4L2_STD_SECAM)
+   chan-norm = VIDEO_MODE_SECAM;
+   if (sid == V4L2_STD_ALL)
+   chan-norm = VIDEO_MODE_AUTO;
+   }
+
break;
}
/* In case of no ENUMSTD support, ignore the norm member of the
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libv4l1: move v4l1 ioctls from kernel to libv4l1: VIDIOCSCHAN move VIDIOCSCHAN to libv4l1 Signed-off-by: Huzaifa Sidhpurwala huzai...@redhat.com

2010-05-27 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

---
 lib/libv4l1/libv4l1.c |   39 ++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index f64025a..077d57c 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -702,7 +702,44 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
struct video_channel *chan = arg;
if ((devices[index].flags  V4L1_SUPPORTS_ENUMINPUT) 
(devices[index].flags  V4L1_SUPPORTS_ENUMSTD)) 
{
-   result = SYS_IOCTL(fd, request, arg);
+
+   v4l2_std_id sid;
+
+   input2.index = chan-channel;
+   result = SYS_IOCTL(fd, VIDIOC_ENUMINPUT, input2);
+   if (result  0)
+   break;
+
+   chan-channel = input2.index;
+   memcpy(chan-name, input2.name,
+   min(sizeof(chan-name), sizeof(input2.name)));
+
+   chan-name[sizeof(chan-name) - 1] = 0;
+   chan-tuners =
+   (input2.type == V4L2_INPUT_TYPE_TUNER) ? 1 : 0;
+
+   chan-flags = (chan-tuners) ? VIDEO_VC_TUNER : 0;
+   switch (input2.type) {
+   case V4L2_INPUT_TYPE_TUNER:
+   chan-type = VIDEO_TYPE_TV;
+   break;
+   default:
+   case V4L2_INPUT_TYPE_CAMERA:
+   chan-type = VIDEO_TYPE_CAMERA;
+   break;
+   }
+   chan-norm = 0;
+   if (SYS_IOCTL(fd, VIDIOC_G_STD, sid) == 0) {
+   if (sid  V4L2_STD_PAL)
+   chan-norm = VIDEO_MODE_PAL;
+   if (sid  V4L2_STD_NTSC)
+   chan-norm = VIDEO_MODE_NTSC;
+   if (sid  V4L2_STD_SECAM)
+   chan-norm = VIDEO_MODE_SECAM;
+   if (sid == V4L2_STD_ALL)
+   chan-norm = VIDEO_MODE_AUTO;
+   }
+
break;
}
/* In case of no ENUMSTD support, ignore the norm member of the
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] move v4l1 ioctls from kernel to libv4l1: VIDIOCSCHAN move VIDIOCSCHAN to libv4l1 Signed-off-by: Huzaifa Sidhpurwala huzai...@redhat.com

2010-05-27 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

---
 lib/libv4l1/libv4l1.c |   30 +-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index f64025a..4a65222 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -702,7 +702,35 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
struct video_channel *chan = arg;
if ((devices[index].flags  V4L1_SUPPORTS_ENUMINPUT) 
(devices[index].flags  V4L1_SUPPORTS_ENUMSTD)) 
{
-   result = SYS_IOCTL(fd, request, arg);
+
+   v4l2_std_id sid = 0;
+   struct v4l2_input input2;
+
+   result = SYS_IOCTL(fd, VIDIOC_ENUMINPUT, input2);
+   if (result  0)
+   break;
+
+   switch (chan-norm) {
+   case VIDEO_MODE_PAL:
+   sid = V4L2_STD_PAL;
+   break;
+   case VIDEO_MODE_NTSC:
+   sid = V4L2_STD_NTSC;
+   break;
+   case VIDEO_MODE_SECAM:
+   sid = V4L2_STD_SECAM;
+   break;
+   case VIDEO_MODE_AUTO:
+   sid = V4L2_STD_ALL;
+   break;
+   }
+   
+   if (0 != sid) {
+   result = SYS_IOCTLdrv(fd, VIDIOC_S_STD, sid);
+   if (result  0)
+   break;
+   }
+   
break;
}
/* In case of no ENUMSTD support, ignore the norm member of the
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libv4l1: move v4l1 ioctls from kernel to libv4l1: VIDIOCSCHAN

2010-05-27 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

move VIDIOCSCHAN to libv4l1

Signed-Off-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1.c |   30 +-
 1 files changed, 29 insertions(+), 1 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index f64025a..c9b6bf9 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -702,7 +702,35 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
struct video_channel *chan = arg;
if ((devices[index].flags  V4L1_SUPPORTS_ENUMINPUT) 
(devices[index].flags  V4L1_SUPPORTS_ENUMSTD)) 
{
-   result = SYS_IOCTL(fd, request, arg);
+
+   v4l2_std_id sid = 0;
+   struct v4l2_input input2;
+
+   result = SYS_IOCTL(fd, VIDIOC_ENUMINPUT, input2);
+   if (result  0)
+   break;
+
+   switch (chan-norm) {
+   case VIDEO_MODE_PAL:
+   sid = V4L2_STD_PAL;
+   break;
+   case VIDEO_MODE_NTSC:
+   sid = V4L2_STD_NTSC;
+   break;
+   case VIDEO_MODE_SECAM:
+   sid = V4L2_STD_SECAM;
+   break;
+   case VIDEO_MODE_AUTO:
+   sid = V4L2_STD_ALL;
+   break;
+   }
+
+   if (0 != sid) {
+   result = SYS_IOCTL(fd, VIDIOC_S_STD, sid);
+   if (result  0)
+   break;
+   }
+
break;
}
/* In case of no ENUMSTD support, ignore the norm member of the
-- 
1.6.6.1

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] libv4l1: move v4l1 ioctls from kernel to libv4l1:VIDIOCGCHAN

2010-05-25 Thread huzaifas
From: Huzaifa Sidhpurwala huzai...@redhat.com

move VIDIOCGCHAN to libv4l1

Signed-off-by: Huzaifa Sidhpurwala huzai...@redhat.com
---
 lib/libv4l1/libv4l1.c |   39 ++-
 1 files changed, 38 insertions(+), 1 deletions(-)

diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index 9bfddd3..f64025a 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -624,7 +624,44 @@ int v4l1_ioctl(int fd, unsigned long int request, ...)
 
if ((devices[index].flags  V4L1_SUPPORTS_ENUMINPUT) 
(devices[index].flags  V4L1_SUPPORTS_ENUMSTD)) 
{
-   result = SYS_IOCTL(fd, request, arg);
+
+   v4l2_std_id sid;
+
+   input2.index = chan-channel;
+   result = SYS_IOCTL(fd, VIDIOC_ENUMINPUT, input2);
+   if (result  0)
+   break;
+
+   chan-channel = input2.index;
+   memcpy(chan-name, input2.name,
+   min(sizeof(chan-name), sizeof(input2.name)));
+
+   chan-name[sizeof(chan-name) - 1] = 0;
+   chan-tuners =
+   (input2.type == V4L2_INPUT_TYPE_TUNER) ? 1 : 0;
+
+   chan-flags = (chan-tuners) ? VIDEO_VC_TUNER : 0;
+   switch (input2.type) {
+   case V4L2_INPUT_TYPE_TUNER:
+   chan-type = VIDEO_TYPE_TV;
+   break;
+   default:
+   case V4L2_INPUT_TYPE_CAMERA:
+   chan-type = VIDEO_TYPE_CAMERA;
+   break;
+   }
+   chan-norm = 0;
+   if (SYS_IOCTL(fd, VIDIOC_G_STD, sid) == 0) {
+   if (sid  V4L2_STD_PAL)
+   chan-norm = VIDEO_MODE_PAL;
+   if (sid  V4L2_STD_NTSC)
+   chan-norm = VIDEO_MODE_NTSC;
+   if (sid  V4L2_STD_SECAM)
+   chan-norm = VIDEO_MODE_SECAM;
+   if (sid == V4L2_STD_ALL)
+   chan-norm = VIDEO_MODE_AUTO;
+   }
+
break;
}
 
-- 
1.6.6

--
To unsubscribe from this list: send the line unsubscribe linux-media in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html