Release 4.11 drivers/media/pci/saa7134/saa7134-empress.c
/*
*
* (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.
*/
#include "saa7134.h"
#include "saa7134-reg.h"
#include <linux/init.h>
#include <linux/list.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/delay.h>
#include <media/v4l2-common.h>
#include <media/v4l2-event.h>
/* ------------------------------------------------------------------ */
MODULE_AUTHOR("Gerd Knorr <kraxel@bytesex.org> [SuSE Labs]");
MODULE_LICENSE("GPL");
static unsigned int empress_nr[] = {[0 ... (SAA7134_MAXBOARDS - 1)] = UNSET };
module_param_array(empress_nr, int, NULL, 0444);
MODULE_PARM_DESC(empress_nr,"ts device number");
/* ------------------------------------------------------------------ */
static int start_streaming(struct vb2_queue *vq, unsigned int count)
{
struct saa7134_dmaqueue *dmaq = vq->drv_priv;
struct saa7134_dev *dev = dmaq->dev;
u32 leading_null_bytes = 0;
int err;
err = saa7134_ts_start_streaming(vq, count);
if (err)
return err;
/* 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;
}
saa_call_all(dev, core, init, leading_null_bytes);
/* Unmute audio */
saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
saa_readb(SAA7134_AUDIO_MUTE_CTRL) & ~(1 << 6));
dev->empress_started = 1;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hans Verkuil | 74 | 62.71% | 4 | 66.67% |
Dmitry Belimov | 25 | 21.19% | 1 | 16.67% |
Gerd Knorr | 19 | 16.10% | 1 | 16.67% |
Total | 118 | 100.00% | 6 | 100.00% |
static void stop_streaming(struct vb2_queue *vq)
{
struct saa7134_dmaqueue *dmaq = vq->drv_priv;
struct saa7134_dev *dev = dmaq->dev;
saa7134_ts_stop_streaming(vq);
saa_writeb(SAA7134_SPECIAL_MODE, 0x00);
msleep(20);
saa_writeb(SAA7134_SPECIAL_MODE, 0x01);
msleep(100);
/* Mute audio */
saa_writeb(SAA7134_AUDIO_MUTE_CTRL,
saa_readb(SAA7134_AUDIO_MUTE_CTRL) | (1 << 6));
dev->empress_started = 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hans Verkuil | 66 | 81.48% | 2 | 66.67% |
Gerd Knorr | 15 | 18.52% | 1 | 33.33% |
Total | 81 | 100.00% | 3 | 100.00% |
static const struct vb2_ops saa7134_empress_qops = {
.queue_setup = saa7134_ts_queue_setup,
.buf_init = saa7134_ts_buffer_init,
.buf_prepare = saa7134_ts_buffer_prepare,
.buf_queue = saa7134_vb2_buffer_queue,
.wait_prepare = vb2_ops_wait_prepare,
.wait_finish = vb2_ops_wait_finish,
.start_streaming = start_streaming,
.stop_streaming = stop_streaming,
};
/* ------------------------------------------------------------------ */
static int empress_enum_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_fmtdesc *f)
{
if (f->index != 0)
return -EINVAL;
strlcpy(f->description, "MPEG TS", sizeof(f->description));
f->pixelformat = V4L2_PIX_FMT_MPEG;
f->flags = V4L2_FMT_FLAG_COMPRESSED;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerd Knorr | 40 | 63.49% | 1 | 25.00% |
Mauro Carvalho Chehab | 16 | 25.40% | 1 | 25.00% |
Hans Verkuil | 7 | 11.11% | 2 | 50.00% |
Total | 63 | 100.00% | 4 | 100.00% |
static int empress_g_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
struct saa7134_dev *dev = video_drvdata(file);
struct v4l2_subdev_format fmt = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
struct v4l2_mbus_framefmt *mbus_fmt = &fmt.format;
saa_call_all(dev, pad, get_fmt, NULL, &fmt);
v4l2_fill_pix_format(&f->fmt.pix, mbus_fmt);
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
f->fmt.pix.bytesperline = 0;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hans Verkuil | 54 | 46.55% | 6 | 60.00% |
Gerd Knorr | 35 | 30.17% | 1 | 10.00% |
Mauro Carvalho Chehab | 21 | 18.10% | 1 | 10.00% |
Frederic Cand | 5 | 4.31% | 1 | 10.00% |
Dmitry Belimov | 1 | 0.86% | 1 | 10.00% |
Total | 116 | 100.00% | 10 | 100.00% |
static int empress_s_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
struct saa7134_dev *dev = video_drvdata(file);
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_ACTIVE,
};
v4l2_fill_mbus_format(&format.format, &f->fmt.pix, MEDIA_BUS_FMT_FIXED);
saa_call_all(dev, pad, set_fmt, NULL, &format);
v4l2_fill_pix_format(&f->fmt.pix, &format.format);
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
f->fmt.pix.bytesperline = 0;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hans Verkuil | 63 | 50.00% | 6 | 54.55% |
Gerd Knorr | 35 | 27.78% | 1 | 9.09% |
Mauro Carvalho Chehab | 21 | 16.67% | 1 | 9.09% |
Frederic Cand | 5 | 3.97% | 1 | 9.09% |
Boris Brezillon | 1 | 0.79% | 1 | 9.09% |
Dmitry Belimov | 1 | 0.79% | 1 | 9.09% |
Total | 126 | 100.00% | 11 | 100.00% |
static int empress_try_fmt_vid_cap(struct file *file, void *priv,
struct v4l2_format *f)
{
struct saa7134_dev *dev = video_drvdata(file);
struct v4l2_subdev_pad_config pad_cfg;
struct v4l2_subdev_format format = {
.which = V4L2_SUBDEV_FORMAT_TRY,
};
v4l2_fill_mbus_format(&format.format, &f->fmt.pix, MEDIA_BUS_FMT_FIXED);
saa_call_all(dev, pad, set_fmt, &pad_cfg, &format);
v4l2_fill_pix_format(&f->fmt.pix, &format.format);
f->fmt.pix.pixelformat = V4L2_PIX_FMT_MPEG;
f->fmt.pix.sizeimage = TS_PACKET_SIZE * dev->ts.nr_packets;
f->fmt.pix.bytesperline = 0;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hans Verkuil | 74 | 56.49% | 3 | 60.00% |
Dmitry Belimov | 56 | 42.75% | 1 | 20.00% |
Boris Brezillon | 1 | 0.76% | 1 | 20.00% |
Total | 131 | 100.00% | 5 | 100.00% |
static const struct v4l2_file_operations ts_fops =
{
.owner = THIS_MODULE,
.open = v4l2_fh_open,
.release = vb2_fop_release,
.read = vb2_fop_read,
.poll = vb2_fop_poll,
.mmap = vb2_fop_mmap,
.unlocked_ioctl = video_ioctl2,
};
static const struct v4l2_ioctl_ops ts_ioctl_ops = {
.vidioc_querycap = saa7134_querycap,
.vidioc_enum_fmt_vid_cap = empress_enum_fmt_vid_cap,
.vidioc_try_fmt_vid_cap = empress_try_fmt_vid_cap,
.vidioc_s_fmt_vid_cap = empress_s_fmt_vid_cap,
.vidioc_g_fmt_vid_cap = empress_g_fmt_vid_cap,
.vidioc_reqbufs = vb2_ioctl_reqbufs,
.vidioc_querybuf = vb2_ioctl_querybuf,
.vidioc_qbuf = vb2_ioctl_qbuf,
.vidioc_dqbuf = vb2_ioctl_dqbuf,
.vidioc_expbuf = vb2_ioctl_expbuf,
.vidioc_streamon = vb2_ioctl_streamon,
.vidioc_streamoff = vb2_ioctl_streamoff,
.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,
.vidioc_querystd = saa7134_querystd,
.vidioc_log_status = v4l2_ctrl_log_status,
.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
};
/* ----------------------------------------------------------- */
static struct video_device saa7134_empress_template = {
.name = "saa7134-empress",
.fops = &ts_fops,
.ioctl_ops = &ts_ioctl_ops,
.tvnorms = SAA7134_NORMS,
};
static void empress_signal_update(struct work_struct *work)
{
struct saa7134_dev* dev =
container_of(work, struct saa7134_dev, empress_workqueue);
if (dev->nosignal) {
pr_debug("no video signal\n");
} else {
pr_debug("video signal acquired\n");
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerd Knorr | 35 | 74.47% | 1 | 33.33% |
David Howells | 10 | 21.28% | 1 | 33.33% |
Mauro Carvalho Chehab | 2 | 4.26% | 1 | 33.33% |
Total | 47 | 100.00% | 3 | 100.00% |
static void empress_signal_change(struct saa7134_dev *dev)
{
schedule_work(&dev->empress_workqueue);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerd Knorr | 19 | 100.00% | 1 | 100.00% |
Total | 19 | 100.00% | 1 | 100.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;
}
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hans Verkuil | 51 | 100.00% | 1 | 100.00% |
Total | 51 | 100.00% | 1 | 100.00% |
static int empress_init(struct saa7134_dev *dev)
{
struct v4l2_ctrl_handler *hdl = &dev->empress_ctrl_handler;
struct vb2_queue *q;
int err;
pr_debug("%s: %s\n", dev->name, __func__);
dev->empress_dev = video_device_alloc();
if (NULL == dev->empress_dev)
return -ENOMEM;
*(dev->empress_dev) = saa7134_empress_template;
dev->empress_dev->v4l2_dev = &dev->v4l2_dev;
dev->empress_dev->release = video_device_release;
dev->empress_dev->lock = &dev->lock;
snprintf(dev->empress_dev->name, sizeof(dev->empress_dev->name),
"%s empress (%s)", dev->name,
saa7134_boards[dev->board].name);
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;
INIT_WORK(&dev->empress_workqueue, empress_signal_update);
q = &dev->empress_vbq;
q->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
/*
* Do not add VB2_USERPTR: the saa7134 DMA engine cannot handle
* transfers that do not start at the beginning of a page. A USERPTR
* can start anywhere in a page, so USERPTR support is a no-go.
*/
q->io_modes = VB2_MMAP | VB2_DMABUF | VB2_READ;
q->drv_priv = &dev->ts_q;
q->ops = &saa7134_empress_qops;
q->gfp_flags = GFP_DMA32;
q->mem_ops = &vb2_dma_sg_memops;
q->buf_struct_size = sizeof(struct saa7134_buf);
q->timestamp_flags = V4L2_BUF_FLAG_TIMESTAMP_MONOTONIC;
q->lock = &dev->lock;
q->dev = &dev->pci->dev;
err = vb2_queue_init(q);
if (err)
return err;
dev->empress_dev->queue = q;
video_set_drvdata(dev->empress_dev, dev);
err = video_register_device(dev->empress_dev,VFL_TYPE_GRABBER,
empress_nr[dev->nr]);
if (err < 0) {
pr_info("%s: can't register video device\n",
dev->name);
video_device_release(dev->empress_dev);
dev->empress_dev = NULL;
return err;
}
pr_info("%s: registered device %s [mpeg]\n",
dev->name, video_device_node_name(dev->empress_dev));
empress_signal_update(&dev->empress_workqueue);
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hans Verkuil | 205 | 50.62% | 5 | 38.46% |
Gerd Knorr | 180 | 44.44% | 2 | 15.38% |
Laurent Pinchart | 13 | 3.21% | 2 | 15.38% |
David Howells | 3 | 0.74% | 1 | 7.69% |
Mauro Carvalho Chehab | 3 | 0.74% | 2 | 15.38% |
Harvey Harrison | 1 | 0.25% | 1 | 7.69% |
Total | 405 | 100.00% | 13 | 100.00% |
static int empress_fini(struct saa7134_dev *dev)
{
pr_debug("%s: %s\n", dev->name, __func__);
if (NULL == dev->empress_dev)
return 0;
flush_work(&dev->empress_workqueue);
video_unregister_device(dev->empress_dev);
vb2_queue_release(&dev->empress_vbq);
v4l2_ctrl_handler_free(&dev->empress_ctrl_handler);
dev->empress_dev = NULL;
return 0;
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerd Knorr | 48 | 65.75% | 2 | 25.00% |
Hans Verkuil | 16 | 21.92% | 2 | 25.00% |
Tejun Heo | 7 | 9.59% | 2 | 25.00% |
Harvey Harrison | 1 | 1.37% | 1 | 12.50% |
Mauro Carvalho Chehab | 1 | 1.37% | 1 | 12.50% |
Total | 73 | 100.00% | 8 | 100.00% |
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);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerd Knorr | 16 | 100.00% | 1 | 100.00% |
Total | 16 | 100.00% | 1 | 100.00% |
static void __exit empress_unregister(void)
{
saa7134_ts_unregister(&empress_ops);
}
Contributors
Person | Tokens | Prop | Commits | CommitProp |
Gerd Knorr | 15 | 100.00% | 1 | 100.00% |
Total | 15 | 100.00% | 1 | 100.00% |
module_init(empress_register);
module_exit(empress_unregister);
Overall Contributors
Person | Tokens | Prop | Commits | CommitProp |
Hans Verkuil | 759 | 46.54% | 20 | 47.62% |
Gerd Knorr | 599 | 36.73% | 2 | 4.76% |
Mauro Carvalho Chehab | 128 | 7.85% | 4 | 9.52% |
Dmitry Belimov | 88 | 5.40% | 3 | 7.14% |
David Howells | 13 | 0.80% | 1 | 2.38% |
Laurent Pinchart | 13 | 0.80% | 2 | 4.76% |
Frederic Cand | 10 | 0.61% | 1 | 2.38% |
Tejun Heo | 7 | 0.43% | 2 | 4.76% |
Mikhail Domrachev | 5 | 0.31% | 1 | 2.38% |
Michael Ira Krufky | 2 | 0.12% | 1 | 2.38% |
Harvey Harrison | 2 | 0.12% | 1 | 2.38% |
Boris Brezillon | 2 | 0.12% | 1 | 2.38% |
Julia Lawall | 1 | 0.06% | 1 | 2.38% |
Sakari Ailus | 1 | 0.06% | 1 | 2.38% |
Arjan van de Ven | 1 | 0.06% | 1 | 2.38% |
Total | 1631 | 100.00% | 42 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.