summaryrefslogtreecommitdiff
path: root/linux/drivers/media/video/em28xx/em28xx-video.c
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <devnull@localhost>2005-11-03 22:31:23 +0000
committerMauro Carvalho Chehab <devnull@localhost>2005-11-03 22:31:23 +0000
commit646e183e74465a8cd42787bcc68b0d12e7bc8b39 (patch)
tree4ba0931c37ab0d7eb12aa47726e30ed00fa36246 /linux/drivers/media/video/em28xx/em28xx-video.c
parent68107d098397a4b8ae5bf4d62910efc1af3381a4 (diff)
downloadmediapointer-dvb-s2-646e183e74465a8cd42787bcc68b0d12e7bc8b39.tar.gz
mediapointer-dvb-s2-646e183e74465a8cd42787bcc68b0d12e7bc8b39.tar.bz2
- em28xx cleanups and fixes.
- Some cleanups and audio amux adjust. - em28xx will allways try, by default, the biggest size alt. - Fixes audio mux code. - Fixes some logs. - added a hack to allow using I2S output (commented). Signed-off-by: Mauro Carvalho Chehab <mchehab@brturbo.com.br>
Diffstat (limited to 'linux/drivers/media/video/em28xx/em28xx-video.c')
-rw-r--r--linux/drivers/media/video/em28xx/em28xx-video.c107
1 files changed, 58 insertions, 49 deletions
diff --git a/linux/drivers/media/video/em28xx/em28xx-video.c b/linux/drivers/media/video/em28xx/em28xx-video.c
index bda4bca6e..2b373799a 100644
--- a/linux/drivers/media/video/em28xx/em28xx-video.c
+++ b/linux/drivers/media/video/em28xx/em28xx-video.c
@@ -336,6 +336,35 @@ static void em28xx_empty_framequeues(struct em28xx *dev)
}
}
+static void video_mux(struct em28xx *dev, int index)
+{
+ int input, ainput;
+
+ input = INPUT(index)->vmux;
+ dev->ctl_input = index;
+ dev->ctl_ainput = INPUT(index)->amux;
+
+ em28xx_i2c_call_clients(dev, DECODER_SET_INPUT, &input);
+
+
+ em28xx_videodbg("Setting input index=%d, vmux=%d, amux=%d\n",index,input,dev->ctl_ainput);
+
+ if (dev->has_msp34xx) {
+ em28xx_i2c_call_clients(dev, VIDIOC_S_AUDIO, &dev->ctl_ainput);
+ ainput = EM28XX_AUDIO_SRC_TUNER;
+ em28xx_audio_source(dev, ainput);
+ } else {
+ switch (dev->ctl_ainput) {
+ case 0:
+ ainput = EM28XX_AUDIO_SRC_TUNER;
+ break;
+ default:
+ ainput = EM28XX_AUDIO_SRC_LINE;
+ }
+ em28xx_audio_source(dev, ainput);
+ }
+}
+
/*
* em28xx_v4l2_open()
* inits the device and starts isoc transfer
@@ -357,7 +386,7 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
filp->private_data=dev;
- em28xx_videodbg("users=%d", dev->users);
+ em28xx_videodbg("users=%d\n", dev->users);
if (!down_read_trylock(&em28xx_disconnect))
return -ERESTARTSYS;
@@ -411,6 +440,8 @@ static int em28xx_v4l2_open(struct inode *inode, struct file *filp)
dev->state |= DEV_INITIALIZED;
+ video_mux(dev, 0);
+
err:
up(&dev->lock);
up_read(&em28xx_disconnect);
@@ -445,7 +476,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
int errCode;
struct em28xx *dev=filp->private_data;
- em28xx_videodbg("users=%d", dev->users);
+ em28xx_videodbg("users=%d\n", dev->users);
down(&dev->lock);
@@ -463,7 +494,7 @@ static int em28xx_v4l2_close(struct inode *inode, struct file *filp)
/* set alternate 0 */
dev->alt = 0;
- em28xx_videodbg("setting alternate 0");
+ em28xx_videodbg("setting alternate 0\n");
errCode = usb_set_interface(dev->udev, 0, 0);
if (errCode < 0) {
em28xx_errdev ("cannot change alternate number to 0 (error=%i)\n",
@@ -504,20 +535,20 @@ em28xx_v4l2_read(struct file *filp, char __user * buf, size_t count,
return -ERESTARTSYS;
if (dev->state & DEV_DISCONNECTED) {
- em28xx_videodbg("device not present");
+ em28xx_videodbg("device not present\n");
up(&dev->fileop_lock);
return -ENODEV;
}
if (dev->state & DEV_MISCONFIGURED) {
- em28xx_videodbg("device misconfigured; close and open it again");
+ em28xx_videodbg("device misconfigured; close and open it again\n");
up(&dev->fileop_lock);
return -EIO;
}
if (dev->io == IO_MMAP) {
em28xx_videodbg ("IO method is set to mmap; close and open"
- " the device again to choose the read method");
+ " the device again to choose the read method\n");
up(&dev->fileop_lock);
return -EINVAL;
}
@@ -594,9 +625,9 @@ static unsigned int em28xx_v4l2_poll(struct file *filp, poll_table * wait)
return POLLERR;
if (dev->state & DEV_DISCONNECTED) {
- em28xx_videodbg("device not present");
+ em28xx_videodbg("device not present\n");
} else if (dev->state & DEV_MISCONFIGURED) {
- em28xx_videodbg("device is misconfigured; close and open it again");
+ em28xx_videodbg("device is misconfigured; close and open it again\n");
} else {
if (dev->io == IO_NONE) {
if (!em28xx_request_buffers
@@ -665,14 +696,14 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
return -ERESTARTSYS;
if (dev->state & DEV_DISCONNECTED) {
- em28xx_videodbg("mmap: device not present");
+ em28xx_videodbg("mmap: device not present\n");
up(&dev->fileop_lock);
return -ENODEV;
}
if (dev->state & DEV_MISCONFIGURED) {
em28xx_videodbg ("mmap: Device is misconfigured; close and "
- "open it again");
+ "open it again\n");
up(&dev->fileop_lock);
return -EIO;
}
@@ -688,7 +719,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
break;
}
if (i == dev->num_frames) {
- em28xx_videodbg("mmap: user supplied mapping address is out of range");
+ em28xx_videodbg("mmap: user supplied mapping address is out of range\n");
up(&dev->fileop_lock);
return -EINVAL;
}
@@ -702,7 +733,7 @@ static int em28xx_v4l2_mmap(struct file *filp, struct vm_area_struct *vma)
page = vmalloc_to_pfn((void *)pos);
if (remap_pfn_range(vma, start, page, PAGE_SIZE,
vma->vm_page_prot)) {
- em28xx_videodbg("mmap: rename page map failed");
+ em28xx_videodbg("mmap: rename page map failed\n");
up(&dev->fileop_lock);
return -EAGAIN;
}
@@ -819,7 +850,7 @@ static int em28xx_stream_interrupt(struct em28xx *dev)
else if (ret) {
dev->state |= DEV_MISCONFIGURED;
em28xx_videodbg("device is misconfigured; close and "
- "open /dev/video%d again", dev->vdev->minor);
+ "open /dev/video%d again\n", dev->vdev->minor);
return ret;
}
@@ -870,28 +901,6 @@ static int em28xx_set_norm(struct em28xx *dev, int width, int height)
return 0;
}
-static void video_mux(struct em28xx *dev, int index)
-{
- int input, ainput;
-
- input = INPUT(index)->vmux;
- dev->ctl_input = index;
-
- em28xx_i2c_call_clients(dev, DECODER_SET_INPUT, &input);
-
- dev->ctl_ainput = INPUT(index)->amux;
-
- switch (dev->ctl_ainput) {
- case 0:
- ainput = EM28XX_AUDIO_SRC_TUNER;
- break;
- default:
- ainput = EM28XX_AUDIO_SRC_LINE;
- }
-
- em28xx_audio_source(dev, ainput);
-}
-
/*
* em28xx_v4l2_do_ioctl()
* This function is _not_ called directly, but from
@@ -1153,7 +1162,7 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
t->signal =
(status & DECODER_STATUS_GOOD) != 0 ? 0xffff : 0;
- em28xx_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x", t->signal,
+ em28xx_videodbg("VIDIO_G_TUNER: signal=%x, afc=%x\n", t->signal,
t->afc);
return 0;
}
@@ -1245,7 +1254,7 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
dev->stream = STREAM_ON; /* FIXME: Start video capture here? */
- em28xx_videodbg("VIDIOC_STREAMON: starting stream");
+ em28xx_videodbg("VIDIOC_STREAMON: starting stream\n");
return 0;
}
@@ -1259,7 +1268,7 @@ static int em28xx_do_ioctl(struct inode *inode, struct file *filp,
return -EINVAL;
if (dev->stream == STREAM_ON) {
- em28xx_videodbg ("VIDIOC_STREAMOFF: interrupting stream");
+ em28xx_videodbg ("VIDIOC_STREAMOFF: interrupting stream\n");
if ((ret = em28xx_stream_interrupt(dev)))
return ret;
}
@@ -1336,7 +1345,7 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
{
struct v4l2_format *format = arg;
- em28xx_videodbg("VIDIOC_G_FMT: type=%s",
+ em28xx_videodbg("VIDIOC_G_FMT: type=%s\n",
format->type ==
V4L2_BUF_TYPE_VIDEO_CAPTURE ?
"V4L2_BUF_TYPE_VIDEO_CAPTURE" : format->type ==
@@ -1367,7 +1376,7 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
format->fmt.pix.field = dev->interlaced ? V4L2_FIELD_INTERLACED : V4L2_FIELD_TOP; /* FIXME: TOP? NONE? BOTTOM? ALTENATE? */
- em28xx_videodbg("VIDIOC_G_FMT: %dx%d", dev->width,
+ em28xx_videodbg("VIDIOC_G_FMT: %dx%d\n", dev->width,
dev->height);
return 0;
}
@@ -1388,7 +1397,7 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
/* int both_fields; */
- em28xx_videodbg("%s: type=%s",
+ em28xx_videodbg("%s: type=%s\n",
cmd ==
VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" :
"VIDIOC_S_FMT",
@@ -1416,7 +1425,7 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
if (format->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
return -EINVAL;
- em28xx_videodbg("%s: requested %dx%d",
+ em28xx_videodbg("%s: requested %dx%d\n",
cmd ==
VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" :
"VIDIOC_S_FMT", format->fmt.pix.width,
@@ -1475,7 +1484,7 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
format->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
format->fmt.pix.field = V4L2_FIELD_INTERLACED;
- em28xx_videodbg("%s: returned %dx%d (%d, %d)",
+ em28xx_videodbg("%s: returned %dx%d (%d, %d)\n",
cmd ==
VIDIOC_TRY_FMT ? "VIDIOC_TRY_FMT" :
"VIDIOC_S_FMT", format->fmt.pix.width,
@@ -1487,13 +1496,13 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
for (i = 0; i < dev->num_frames; i++)
if (dev->frame[i].vma_use_count) {
em28xx_videodbg("VIDIOC_S_FMT failed. "
- "Unmap the buffers first.");
+ "Unmap the buffers first.\n");
return -EINVAL;
}
/* stop io in case it is already in progress */
if (dev->stream == STREAM_ON) {
- em28xx_videodbg("VIDIOC_SET_FMT: interupting stream");
+ em28xx_videodbg("VIDIOC_SET_FMT: interupting stream\n");
if ((ret = em28xx_stream_interrupt(dev)))
return ret;
}
@@ -1559,18 +1568,18 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
if (dev->io == IO_READ) {
em28xx_videodbg ("method is set to read;"
" close and open the device again to"
- " choose the mmap I/O method");
+ " choose the mmap I/O method\n");
return -EINVAL;
}
for (i = 0; i < dev->num_frames; i++)
if (dev->frame[i].vma_use_count) {
- em28xx_videodbg ("VIDIOC_REQBUFS failed; previous buffers are still mapped");
+ em28xx_videodbg ("VIDIOC_REQBUFS failed; previous buffers are still mapped\n");
return -EINVAL;
}
if (dev->stream == STREAM_ON) {
- em28xx_videodbg("VIDIOC_REQBUFS: interrupting stream");
+ em28xx_videodbg("VIDIOC_REQBUFS: interrupting stream\n");
if ((ret = em28xx_stream_interrupt(dev)))
return ret;
}
@@ -1584,7 +1593,7 @@ static int em28xx_video_do_ioctl(struct inode *inode, struct file *filp,
dev->frame_current = NULL;
- em28xx_videodbg ("VIDIOC_REQBUFS: setting io method to mmap: num bufs %i",
+ em28xx_videodbg ("VIDIOC_REQBUFS: setting io method to mmap: num bufs %i\n",
rb->count);
dev->io = rb->count ? IO_MMAP : IO_NONE;
return 0;