2005-04-17 05:20:36 +07:00
|
|
|
/*
|
|
|
|
*
|
|
|
|
* (c) 2004 Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/list.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/delay.h>
|
|
|
|
|
|
|
|
#include "saa7134-reg.h"
|
|
|
|
#include "saa7134.h"
|
|
|
|
|
|
|
|
#include <media/saa6752hs.h>
|
2006-01-10 00:32:31 +07:00
|
|
|
#include <media/v4l2-common.h>
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
|
|
|
|
static unsigned int empress_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
|
2005-12-12 15:37:28 +07:00
|
|
|
|
2005-04-17 05:20:36 +07:00
|
|
|
module_param_array(empress_nr, int, NULL, 0444);
|
|
|
|
MODULE_PARM_DESC(empress_nr,"ts device number");
|
|
|
|
|
2008-04-23 00:41:48 +07:00
|
|
|
static unsigned int debug;
|
2005-04-17 05:20:36 +07:00
|
|
|
module_param(debug, int, 0644);
|
|
|
|
MODULE_PARM_DESC(debug,"enable debug messages");
|
|
|
|
|
|
|
|
#define dprintk(fmt, arg...) if (debug) \
|
|
|
|
printk(KERN_DEBUG "%s/empress: " fmt, dev->name , ## arg)
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
|
|
|
static void ts_reset_encoder(struct saa7134_dev* dev)
|
|
|
|
{
|
|
|
|
if (!dev->empress_started)
|
|
|
|
return;
|
|
|
|
|
|
|
|
saa_writeb(SAA7134_SPECIAL_MODE, 0x00);
|
|
|
|
msleep(10);
|
2005-11-09 12:37:43 +07:00
|
|
|
saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
|
2005-04-17 05:20:36 +07:00
|
|
|
msleep(100);
|
|
|
|
dev->empress_started = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int ts_init_encoder(struct saa7134_dev* dev)
|
|
|
|
{
|
2008-08-26 23:44:40 +07:00
|
|
|
u32 leading_null_bytes = 0;
|
2006-06-19 02:40:10 +07:00
|
|
|
|
2008-08-26 23:44:40 +07:00
|
|
|
/* If more cards start to need this, then this
|
|
|
|
should probably be added to the card definitions. */
|
|
|
|
switch (dev->board) {
|
|
|
|
case SAA7134_BOARD_BEHOLD_M6:
|
|
|
|
case SAA7134_BOARD_BEHOLD_M63:
|
|
|
|
case SAA7134_BOARD_BEHOLD_M6_EXTRA:
|
|
|
|
leading_null_bytes = 1;
|
|
|
|
break;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
ts_reset_encoder(dev);
|
2009-01-17 22:17:14 +07:00
|
|
|
saa_call_all(dev, core, init, leading_null_bytes);
|
2005-04-17 05:20:36 +07:00
|
|
|
dev->empress_started = 1;
|
2005-11-09 12:37:43 +07:00
|
|
|
return 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* ------------------------------------------------------------------ */
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int ts_open(struct file *file)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2009-12-10 20:47:13 +07:00
|
|
|
struct video_device *vdev = video_devdata(file);
|
2009-12-10 20:44:04 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_fh *fh;
|
2005-04-17 05:20:36 +07:00
|
|
|
int err;
|
|
|
|
|
2009-12-10 20:47:13 +07:00
|
|
|
dprintk("open dev=%s\n", video_device_node_name(vdev));
|
2005-04-17 05:20:36 +07:00
|
|
|
err = -EBUSY;
|
2008-01-31 23:57:53 +07:00
|
|
|
if (!mutex_trylock(&dev->empress_tsq.vb_lock))
|
2010-01-29 16:51:08 +07:00
|
|
|
return err;
|
2008-07-26 19:01:24 +07:00
|
|
|
if (atomic_read(&dev->empress_users))
|
2010-01-29 16:51:08 +07:00
|
|
|
goto done;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2013-12-14 18:28:26 +07:00
|
|
|
/* allocate + initialize per filehandle data */
|
|
|
|
fh = kzalloc(sizeof(*fh), GFP_KERNEL);
|
|
|
|
err = -ENOMEM;
|
|
|
|
if (NULL == fh)
|
|
|
|
goto done;
|
|
|
|
|
|
|
|
v4l2_fh_init(&fh->fh, vdev);
|
|
|
|
file->private_data = fh;
|
|
|
|
fh->is_empress = true;
|
|
|
|
v4l2_fh_add(&fh->fh);
|
|
|
|
|
2007-06-20 15:37:27 +07:00
|
|
|
/* Unmute audio */
|
|
|
|
saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
|
|
|
|
saa_readb(SAA7134_AUDIO_MUTE_CTRL) & ~(1 << 6));
|
|
|
|
|
2008-07-26 19:01:24 +07:00
|
|
|
atomic_inc(&dev->empress_users);
|
2005-04-17 05:20:36 +07:00
|
|
|
err = 0;
|
|
|
|
|
|
|
|
done:
|
2010-01-29 16:51:08 +07:00
|
|
|
mutex_unlock(&dev->empress_tsq.vb_lock);
|
2005-04-17 05:20:36 +07:00
|
|
|
return err;
|
|
|
|
}
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static int ts_release(struct file *file)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
|
|
|
struct saa7134_fh *fh = file->private_data;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-11-14 06:11:26 +07:00
|
|
|
videobuf_stop(&dev->empress_tsq);
|
2005-04-17 05:20:36 +07:00
|
|
|
videobuf_mmap_free(&dev->empress_tsq);
|
|
|
|
|
|
|
|
/* stop the encoder */
|
|
|
|
ts_reset_encoder(dev);
|
|
|
|
|
2007-06-20 15:37:27 +07:00
|
|
|
/* Mute audio */
|
|
|
|
saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
|
|
|
|
saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6));
|
|
|
|
|
2008-07-26 19:01:24 +07:00
|
|
|
atomic_dec(&dev->empress_users);
|
2008-06-23 03:03:02 +07:00
|
|
|
|
2013-12-14 18:28:26 +07:00
|
|
|
v4l2_fh_del(&fh->fh);
|
|
|
|
v4l2_fh_exit(&fh->fh);
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static ssize_t
|
|
|
|
ts_read(struct file *file, char __user *data, size_t count, loff_t *ppos)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (!dev->empress_started)
|
|
|
|
ts_init_encoder(dev);
|
|
|
|
|
|
|
|
return videobuf_read_stream(&dev->empress_tsq,
|
|
|
|
data, count, ppos, 0,
|
|
|
|
file->f_flags & O_NONBLOCK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static unsigned int
|
|
|
|
ts_poll(struct file *file, struct poll_table_struct *wait)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
return videobuf_poll_stream(file, &dev->empress_tsq, wait);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static int
|
|
|
|
ts_mmap(struct file *file, struct vm_area_struct * vma)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
return videobuf_mmap_mapper(&dev->empress_tsq, vma);
|
|
|
|
}
|
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int empress_enum_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-11 22:56:23 +07:00
|
|
|
struct v4l2_fmtdesc *f)
|
|
|
|
{
|
|
|
|
if (f->index != 0)
|
|
|
|
return -EINVAL;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-11 22:56:23 +07:00
|
|
|
strlcpy(f->description, "MPEG TS", sizeof(f->description));
|
|
|
|
f->pixelformat = V4L2_PIX_FMT_MPEG;
|
2013-06-01 20:02:38 +07:00
|
|
|
f->flags = V4L2_FMT_FLAG_COMPRESSED;
|
2007-12-11 22:56:23 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int empress_g_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-11 22:56:23 +07:00
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2010-05-09 19:41:41 +07:00
|
|
|
struct v4l2_mbus_framefmt mbus_fmt;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-05-09 19:41:41 +07:00
|
|
|
saa_call_all(dev, video, g_mbus_fmt, &mbus_fmt);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-05-09 19:41:41 +07:00
|
|
|
v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt);
|
2007-12-11 22:56:23 +07:00
|
|
|
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
|
|
|
|
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
|
2013-06-01 20:02:38 +07:00
|
|
|
f->fmt.pix.bytesperline = 0;
|
|
|
|
f->fmt.pix.priv = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-11 22:56:23 +07:00
|
|
|
return 0;
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-05-28 22:16:41 +07:00
|
|
|
static int empress_s_fmt_vid_cap(struct file *file, void *priv,
|
2007-12-11 22:56:23 +07:00
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2010-05-09 19:41:41 +07:00
|
|
|
struct v4l2_mbus_framefmt mbus_fmt;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2010-05-09 19:41:41 +07:00
|
|
|
v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED);
|
|
|
|
saa_call_all(dev, video, s_mbus_fmt, &mbus_fmt);
|
|
|
|
v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-11 22:56:23 +07:00
|
|
|
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
|
|
|
|
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
|
2013-06-01 20:02:38 +07:00
|
|
|
f->fmt.pix.bytesperline = 0;
|
|
|
|
f->fmt.pix.priv = 0;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2007-12-11 22:56:23 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-05-28 11:58:57 +07:00
|
|
|
static int empress_try_fmt_vid_cap(struct file *file, void *priv,
|
|
|
|
struct v4l2_format *f)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2013-06-01 20:02:38 +07:00
|
|
|
struct v4l2_mbus_framefmt mbus_fmt;
|
|
|
|
|
|
|
|
v4l2_fill_mbus_format(&mbus_fmt, &f->fmt.pix, V4L2_MBUS_FMT_FIXED);
|
|
|
|
saa_call_all(dev, video, try_mbus_fmt, &mbus_fmt);
|
|
|
|
v4l2_fill_pix_format(&f->fmt.pix, &mbus_fmt);
|
2009-05-28 11:58:57 +07:00
|
|
|
|
|
|
|
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
|
|
|
|
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
|
2013-06-01 20:02:38 +07:00
|
|
|
f->fmt.pix.bytesperline = 0;
|
|
|
|
f->fmt.pix.priv = 0;
|
2009-05-28 11:58:57 +07:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
2007-12-11 22:56:23 +07:00
|
|
|
|
|
|
|
static int empress_reqbufs(struct file *file, void *priv,
|
|
|
|
struct v4l2_requestbuffers *p)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-11 22:56:23 +07:00
|
|
|
|
|
|
|
return videobuf_reqbufs(&dev->empress_tsq, p);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int empress_querybuf(struct file *file, void *priv,
|
|
|
|
struct v4l2_buffer *b)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-11 22:56:23 +07:00
|
|
|
|
|
|
|
return videobuf_querybuf(&dev->empress_tsq, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int empress_qbuf(struct file *file, void *priv, struct v4l2_buffer *b)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-11 22:56:23 +07:00
|
|
|
|
|
|
|
return videobuf_qbuf(&dev->empress_tsq, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int empress_dqbuf(struct file *file, void *priv, struct v4l2_buffer *b)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-11 22:56:23 +07:00
|
|
|
|
|
|
|
return videobuf_dqbuf(&dev->empress_tsq, b,
|
|
|
|
file->f_flags & O_NONBLOCK);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int empress_streamon(struct file *file, void *priv,
|
|
|
|
enum v4l2_buf_type type)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-11 22:56:23 +07:00
|
|
|
|
|
|
|
return videobuf_streamon(&dev->empress_tsq);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int empress_streamoff(struct file *file, void *priv,
|
|
|
|
enum v4l2_buf_type type)
|
|
|
|
{
|
2013-12-14 18:28:26 +07:00
|
|
|
struct saa7134_dev *dev = video_drvdata(file);
|
2007-12-11 22:56:23 +07:00
|
|
|
|
|
|
|
return videobuf_streamoff(&dev->empress_tsq);
|
|
|
|
}
|
|
|
|
|
2008-12-30 16:58:20 +07:00
|
|
|
static const struct v4l2_file_operations ts_fops =
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
|
|
|
.owner = THIS_MODULE,
|
|
|
|
.open = ts_open,
|
|
|
|
.release = ts_release,
|
|
|
|
.read = ts_read,
|
|
|
|
.poll = ts_poll,
|
|
|
|
.mmap = ts_mmap,
|
2007-12-11 22:56:23 +07:00
|
|
|
.ioctl = video_ioctl2,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2008-07-21 12:57:38 +07:00
|
|
|
static const struct v4l2_ioctl_ops ts_ioctl_ops = {
|
2013-12-14 18:28:25 +07:00
|
|
|
.vidioc_querycap = saa7134_querycap,
|
2008-05-28 22:16:41 +07:00
|
|
|
.vidioc_enum_fmt_vid_cap = empress_enum_fmt_vid_cap,
|
2009-05-28 11:58:57 +07:00
|
|
|
.vidioc_try_fmt_vid_cap = empress_try_fmt_vid_cap,
|
2008-05-28 22:16:41 +07:00
|
|
|
.vidioc_s_fmt_vid_cap = empress_s_fmt_vid_cap,
|
|
|
|
.vidioc_g_fmt_vid_cap = empress_g_fmt_vid_cap,
|
2007-12-11 22:56:23 +07:00
|
|
|
.vidioc_reqbufs = empress_reqbufs,
|
|
|
|
.vidioc_querybuf = empress_querybuf,
|
|
|
|
.vidioc_qbuf = empress_qbuf,
|
|
|
|
.vidioc_dqbuf = empress_dqbuf,
|
|
|
|
.vidioc_streamon = empress_streamon,
|
|
|
|
.vidioc_streamoff = empress_streamoff,
|
2013-12-14 18:28:25 +07:00
|
|
|
.vidioc_g_frequency = saa7134_g_frequency,
|
|
|
|
.vidioc_s_frequency = saa7134_s_frequency,
|
|
|
|
.vidioc_g_tuner = saa7134_g_tuner,
|
|
|
|
.vidioc_s_tuner = saa7134_s_tuner,
|
|
|
|
.vidioc_enum_input = saa7134_enum_input,
|
|
|
|
.vidioc_g_input = saa7134_g_input,
|
|
|
|
.vidioc_s_input = saa7134_s_input,
|
|
|
|
.vidioc_s_std = saa7134_s_std,
|
|
|
|
.vidioc_g_std = saa7134_g_std,
|
2008-07-21 12:57:38 +07:00
|
|
|
};
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
|
|
|
|
static struct video_device saa7134_empress_template = {
|
|
|
|
.name = "saa7134-empress",
|
|
|
|
.fops = &ts_fops,
|
|
|
|
.ioctl_ops = &ts_ioctl_ops,
|
2007-12-11 22:56:23 +07:00
|
|
|
|
|
|
|
.tvnorms = SAA7134_NORMS,
|
2005-04-17 05:20:36 +07:00
|
|
|
};
|
|
|
|
|
2006-11-22 21:57:56 +07:00
|
|
|
static void empress_signal_update(struct work_struct *work)
|
2005-04-17 05:20:36 +07:00
|
|
|
{
|
2006-11-22 21:57:56 +07:00
|
|
|
struct saa7134_dev* dev =
|
|
|
|
container_of(work, struct saa7134_dev, empress_workqueue);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (dev->nosignal) {
|
|
|
|
dprintk("no video signal\n");
|
|
|
|
} else {
|
|
|
|
dprintk("video signal acquired\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void empress_signal_change(struct saa7134_dev *dev)
|
|
|
|
{
|
|
|
|
schedule_work(&dev->empress_workqueue);
|
|
|
|
}
|
|
|
|
|
2013-12-14 18:28:24 +07:00
|
|
|
static bool empress_ctrl_filter(const struct v4l2_ctrl *ctrl)
|
|
|
|
{
|
|
|
|
switch (ctrl->id) {
|
|
|
|
case V4L2_CID_BRIGHTNESS:
|
|
|
|
case V4L2_CID_HUE:
|
|
|
|
case V4L2_CID_CONTRAST:
|
|
|
|
case V4L2_CID_SATURATION:
|
|
|
|
case V4L2_CID_AUDIO_MUTE:
|
|
|
|
case V4L2_CID_AUDIO_VOLUME:
|
|
|
|
case V4L2_CID_PRIVATE_INVERT:
|
|
|
|
case V4L2_CID_PRIVATE_AUTOMUTE:
|
|
|
|
return true;
|
|
|
|
default:
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
static int empress_init(struct saa7134_dev *dev)
|
|
|
|
{
|
2013-12-14 18:28:24 +07:00
|
|
|
struct v4l2_ctrl_handler *hdl = &dev->empress_ctrl_handler;
|
2005-04-17 05:20:36 +07:00
|
|
|
int err;
|
|
|
|
|
2008-04-09 09:20:00 +07:00
|
|
|
dprintk("%s: %s\n",dev->name,__func__);
|
2005-04-17 05:20:36 +07:00
|
|
|
dev->empress_dev = video_device_alloc();
|
|
|
|
if (NULL == dev->empress_dev)
|
|
|
|
return -ENOMEM;
|
|
|
|
*(dev->empress_dev) = saa7134_empress_template;
|
2013-06-20 20:57:10 +07:00
|
|
|
dev->empress_dev->v4l2_dev = &dev->v4l2_dev;
|
2005-04-17 05:20:36 +07:00
|
|
|
dev->empress_dev->release = video_device_release;
|
|
|
|
snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name),
|
|
|
|
"%s empress (%s)", dev->name,
|
|
|
|
saa7134_boards[dev->board].name);
|
2013-12-14 18:28:24 +07:00
|
|
|
v4l2_ctrl_handler_init(hdl, 21);
|
|
|
|
v4l2_ctrl_add_handler(hdl, &dev->ctrl_handler, empress_ctrl_filter);
|
|
|
|
if (dev->empress_sd)
|
|
|
|
v4l2_ctrl_add_handler(hdl, dev->empress_sd->ctrl_handler, NULL);
|
|
|
|
if (hdl->error) {
|
|
|
|
video_device_release(dev->empress_dev);
|
|
|
|
return hdl->error;
|
|
|
|
}
|
|
|
|
dev->empress_dev->ctrl_handler = hdl;
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-11-22 21:57:56 +07:00
|
|
|
INIT_WORK(&dev->empress_workqueue, empress_signal_update);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2009-12-10 20:44:04 +07:00
|
|
|
video_set_drvdata(dev->empress_dev, dev);
|
2005-04-17 05:20:36 +07:00
|
|
|
err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
|
|
|
|
empress_nr[dev->nr]);
|
|
|
|
if (err < 0) {
|
|
|
|
printk(KERN_INFO "%s: can't register video device\n",
|
|
|
|
dev->name);
|
|
|
|
video_device_release(dev->empress_dev);
|
|
|
|
dev->empress_dev = NULL;
|
|
|
|
return err;
|
|
|
|
}
|
2009-11-27 23:57:15 +07:00
|
|
|
printk(KERN_INFO "%s: registered device %s [mpeg]\n",
|
|
|
|
dev->name, video_device_node_name(dev->empress_dev));
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2008-04-23 00:42:13 +07:00
|
|
|
videobuf_queue_sg_init(&dev->empress_tsq, &saa7134_ts_qops,
|
|
|
|
&dev->pci->dev, &dev->slock,
|
2005-04-17 05:20:36 +07:00
|
|
|
V4L2_BUF_TYPE_VIDEO_CAPTURE,
|
|
|
|
V4L2_FIELD_ALTERNATE,
|
|
|
|
sizeof(struct saa7134_buf),
|
2010-09-21 03:39:46 +07:00
|
|
|
dev, NULL);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
2006-11-22 21:57:56 +07:00
|
|
|
empress_signal_update(&dev->empress_workqueue);
|
2005-04-17 05:20:36 +07:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int empress_fini(struct saa7134_dev *dev)
|
|
|
|
{
|
2008-04-09 09:20:00 +07:00
|
|
|
dprintk("%s: %s\n",dev->name,__func__);
|
2005-04-17 05:20:36 +07:00
|
|
|
|
|
|
|
if (NULL == dev->empress_dev)
|
|
|
|
return 0;
|
2012-08-21 04:51:24 +07:00
|
|
|
flush_work(&dev->empress_workqueue);
|
2005-04-17 05:20:36 +07:00
|
|
|
video_unregister_device(dev->empress_dev);
|
2013-12-14 18:28:24 +07:00
|
|
|
v4l2_ctrl_handler_free(&dev->empress_ctrl_handler);
|
2005-04-17 05:20:36 +07:00
|
|
|
dev->empress_dev = NULL;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct saa7134_mpeg_ops empress_ops = {
|
|
|
|
.type = SAA7134_MPEG_EMPRESS,
|
|
|
|
.init = empress_init,
|
|
|
|
.fini = empress_fini,
|
|
|
|
.signal_change = empress_signal_change,
|
|
|
|
};
|
|
|
|
|
|
|
|
static int __init empress_register(void)
|
|
|
|
{
|
|
|
|
return saa7134_ts_register(&empress_ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit empress_unregister(void)
|
|
|
|
{
|
|
|
|
saa7134_ts_unregister(&empress_ops);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(empress_register);
|
|
|
|
module_exit(empress_unregister);
|
|
|
|
|
|
|
|
/* ----------------------------------------------------------- */
|
|
|
|
/*
|
|
|
|
* Local variables:
|
|
|
|
* c-basic-offset: 8
|
|
|
|
* End:
|
|
|
|
*/
|