[MPlayer-dev-eng] [PATCH] fix for v4l1 driver
Trent Piepho
xyzzy at speakeasy.org
Sat Apr 28 20:52:32 CEST 2007
On Sat, 28 Apr 2007, Diego Biurrun wrote:
> On Sat, Apr 28, 2007 at 03:54:06AM -0700, Trent Piepho wrote:
> > This patch makes the v4l1 driver work properly. There were some bugs in
> > the kernel v4l1 compat system, but mplayer had some bugs too. This patch
> > applies on top of the cosmetic patch I sent earlier.
>
> I reindented the file, please resend an updated patch.
Why couldn't you just apply my patch and then convert tabs to spaces? There
are still indentation errors in the file that I already fixed once before.
Here is a new (tab free) patch that re-fixes the indentation. I'll wait
until this is done before generating a new fix patch, as I don't know of
anyway to generate a new fix patch after a large white-space change other
than to tediously redo the entire patch by hand, and I'd like to avoid doing
that more than once.
-------------- next part --------------
--- stream/tvi_v4l.c 2007-04-28 11:03:07.000000000 -0700
+++ stream/tvi_v4l.c.cosmetic.spaces 2007-04-28 11:15:12.000000000 -0700
@@ -517,17 +517,17 @@
bparm.decimation, bparm.quality);
if (ioctl(priv->video_fd, MJPIOC_S_PARAMS, &bparm) < 0)
- {
+ {
mp_msg(MSGT_TV, MSGL_ERR,
" MJP: Error setting video parameters: %s\n", strerror(errno));
goto err;
- }
+ }
if (ioctl(priv->video_fd, MJPIOC_G_PARAMS, &bparm) < 0)
{
- mp_msg(MSGT_TV, MSGL_ERR,
- " MJP: Error getting video parameters: %s\n", strerror(errno));
- goto err;
+ mp_msg(MSGT_TV, MSGL_ERR,
+ " MJP: Error getting video parameters: %s\n", strerror(errno));
+ goto err;
}
mp_msg(MSGT_TV, MSGL_INFO,
@@ -549,9 +549,9 @@
breq.size = priv -> mjpeg_bufsize;
if (ioctl(priv->video_fd, MJPIOC_REQBUFS,&(breq)) < 0)
{
- mp_msg (MSGT_TV, MSGL_ERR,
- " MJP: Error requesting video buffers: %s\n", strerror(errno));
- goto err;
+ mp_msg (MSGT_TV, MSGL_ERR,
+ " MJP: Error requesting video buffers: %s\n", strerror(errno));
+ goto err;
}
mp_msg(MSGT_TV, MSGL_INFO,
" MJP: Got %ld buffers of size %ld KB\n",
@@ -599,32 +599,32 @@
if ( !tv_param_mjpeg )
{
- /* map grab buffer */
- if (ioctl(priv->video_fd, VIDIOCGMBUF, &priv->mbuf) == -1)
- {
- mp_msg(MSGT_TV, MSGL_ERR, "ioctl get mbuf failed: %s\n", strerror(errno));
- goto err;
- }
+ /* map grab buffer */
+ if (ioctl(priv->video_fd, VIDIOCGMBUF, &priv->mbuf) == -1)
+ {
+ mp_msg(MSGT_TV, MSGL_ERR, "ioctl get mbuf failed: %s\n", strerror(errno));
+ goto err;
+ }
- mp_msg(MSGT_TV, MSGL_V, "mbuf: size=%d, frames=%d\n",
- priv->mbuf.size, priv->mbuf.frames);
- priv->mmap = mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE,
- MAP_SHARED, priv->video_fd, 0);
- if (priv->mmap == (unsigned char *)-1)
- {
- mp_msg(MSGT_TV, MSGL_ERR, "Unable to map memory for buffers: %s\n", strerror(errno));
- goto err;
- }
- mp_msg(MSGT_TV, MSGL_DBG2, "our buffer: %p\n", priv->mmap);
+ mp_msg(MSGT_TV, MSGL_V, "mbuf: size=%d, frames=%d\n",
+ priv->mbuf.size, priv->mbuf.frames);
+ priv->mmap = mmap(0, priv->mbuf.size, PROT_READ|PROT_WRITE,
+ MAP_SHARED, priv->video_fd, 0);
+ if (priv->mmap == (unsigned char *)-1)
+ {
+ mp_msg(MSGT_TV, MSGL_ERR, "Unable to map memory for buffers: %s\n", strerror(errno));
+ goto err;
+ }
+ mp_msg(MSGT_TV, MSGL_DBG2, "our buffer: %p\n", priv->mmap);
- /* num of buffers */
- priv->nbuf = priv->mbuf.frames;
+ /* num of buffers */
+ priv->nbuf = priv->mbuf.frames;
- /* video buffers */
- priv->buf = calloc(priv->nbuf, sizeof(struct video_mmap));
- if (!priv->buf)
- goto malloc_failed;
- memset(priv->buf, 0, priv->nbuf * sizeof(struct video_mmap));
+ /* video buffers */
+ priv->buf = calloc(priv->nbuf, sizeof(struct video_mmap));
+ if (!priv->buf)
+ goto malloc_failed;
+ memset(priv->buf, 0, priv->nbuf * sizeof(struct video_mmap));
}
/* init v4l audio even when we don't capture */
@@ -793,7 +793,6 @@
priv->picture.brightness, priv->picture.hue,
priv->picture.colour, priv->picture.contrast);
-
if (ioctl(priv->video_fd, VIDIOCSPICT, &priv->picture) == -1)
{
mp_msg(MSGT_TV, MSGL_ERR, "ioctl set picture failed: %s\n", strerror(errno));
@@ -801,15 +800,15 @@
if ( !tv_param_mjpeg )
{
- priv->nbuf = priv->mbuf.frames;
- for (i=0; i < priv->nbuf; i++)
- {
- priv->buf[i].format = priv->picture.palette;
- priv->buf[i].frame = i;
- priv->buf[i].width = priv->width;
- priv->buf[i].height = priv->height;
- mp_msg(MSGT_TV, MSGL_DBG2, "buffer: %d => %p\n", i, &priv->buf[i]);
- }
+ priv->nbuf = priv->mbuf.frames;
+ for (i=0; i < priv->nbuf; i++)
+ {
+ priv->buf[i].format = priv->picture.palette;
+ priv->buf[i].frame = i;
+ priv->buf[i].width = priv->width;
+ priv->buf[i].height = priv->height;
+ mp_msg(MSGT_TV, MSGL_DBG2, "buffer: %d => %p\n", i, &priv->buf[i]);
+ }
}
#if 0
@@ -822,7 +821,7 @@
if (ioctl(priv->video_fd, VIDIOCSPLAYMODE, &pmode) == -1)
{
mp_msg(MSGT_TV, MSGL_ERR, "ioctl set play mode failed: %s\n", strerror(errno));
-// return(0);
+// return(0);
}
}
#endif
@@ -842,7 +841,7 @@
ioctl(priv->video_fd, VIDIOCSWIN, &win);
}
- // initialize video capture
+ // initialize video sub-capture
if (ioctl(priv->video_fd, VIDIOCCAPTURE, &one) == -1)
{
mp_msg(MSGT_TV, MSGL_ERR, "FATAL: ioctl ccapture failed: %s\n", strerror(errno));
@@ -985,7 +984,7 @@
return(TVI_CONTROL_FALSE);
case TVI_CONTROL_IS_TUNER:
{
-// if (priv->capability.type & VID_TYPE_TUNER)
+// if (priv->capability.type & VID_TYPE_TUNER)
if (priv->channels[priv->act_channel].flags & VIDEO_VC_TUNER)
return(TVI_CONTROL_TRUE);
return(TVI_CONTROL_FALSE);
@@ -1007,8 +1006,8 @@
}
else
{
- *(int *)arg = output_fmt;
- mp_msg(MSGT_TV, MSGL_V, "Output format: %s\n", vo_format_name(output_fmt));
+ *(int *)arg = output_fmt;
+ mp_msg(MSGT_TV, MSGL_V, "Output format: %s\n", vo_format_name(output_fmt));
}
return(TVI_CONTROL_TRUE);
}
@@ -1119,8 +1118,8 @@
}
/* tuner uses khz not mhz ! */
-// if (priv->tuner.flags & VIDEO_TUNER_LOW)
-// freq /= 1000;
+// if (priv->tuner.flags & VIDEO_TUNER_LOW)
+// freq /= 1000;
*(unsigned long *)arg = freq;
return(TVI_CONTROL_TRUE);
}
@@ -1137,9 +1136,9 @@
mp_msg(MSGT_TV, MSGL_V, "requested frequency: %.3f\n", (float)freq/16);
/* tuner uses khz not mhz ! */
-// if (priv->tuner.flags & VIDEO_TUNER_LOW)
-// freq *= 1000;
-// mp_msg(MSGT_TV, MSGL_V, " requesting from driver: freq=%.3f\n", (float)freq/16);
+// if (priv->tuner.flags & VIDEO_TUNER_LOW)
+// freq *= 1000;
+// mp_msg(MSGT_TV, MSGL_V, " requesting from driver: freq=%.3f\n", (float)freq/16);
if (ioctl(priv->video_fd, VIDIOCSFREQ, &freq) == -1)
{
mp_msg(MSGT_TV, MSGL_ERR, "ioctl set freq failed: %s\n", strerror(errno));
@@ -1364,7 +1363,7 @@
priv->act_channel = i;
/* update tuner state */
-// if (priv->capability.type & VID_TYPE_TUNER)
+// if (priv->capability.type & VID_TYPE_TUNER)
if (priv->channels[priv->act_channel].flags & VIDEO_VC_TUNER)
control(priv, TVI_CONTROL_TUN_GET_TUNER, 0);
@@ -1480,14 +1479,13 @@
if ( tv_param_mjpeg )
{
- while (ioctl(priv->video_fd, MJPIOC_SYNC, &priv->buf[frame].frame) < 0 &&
- (errno == EAGAIN || errno == EINTR));
-
+ while (ioctl(priv->video_fd, MJPIOC_SYNC, &priv->buf[frame].frame) < 0 &&
+ (errno == EAGAIN || errno == EINTR));
}
else
{
- while (ioctl(priv->video_fd, VIDIOCSYNC, &priv->buf[frame].frame) < 0 &&
- (errno == EAGAIN || errno == EINTR));
+ while (ioctl(priv->video_fd, VIDIOCSYNC, &priv->buf[frame].frame) < 0 &&
+ (errno == EAGAIN || errno == EINTR));
}
mp_dbg(MSGT_TV, MSGL_DBG3, "\npicture sync failed\n");
@@ -1535,7 +1533,7 @@
priv->video_interval_sum += orig_interval-prev_interval;
if (priv->video_avg_ptr >= VIDEO_AVG_BUFFER_SIZE) priv->video_avg_ptr = 0;
-// fprintf(stderr, "fps: %lf\n", (double)1e6*VIDEO_AVG_BUFFER_SIZE/priv->video_interval_sum);
+// fprintf(stderr, "fps: %lf\n", (double)1e6*VIDEO_AVG_BUFFER_SIZE/priv->video_interval_sum);
// interpolate the skew in time
pthread_mutex_lock(&priv->skew_mutex);
@@ -1619,9 +1617,7 @@
continue;
}
}
-
}
-
}
mp_msg(MSGT_TV, MSGL_INFO, " MJP: returning! \n");
return NULL;
More information about the MPlayer-dev-eng
mailing list