From: Mauro Carvalho Chehab <mchehab@redhat.com>
To: Huang Shijie <shijie8@gmail.com>
Cc: linux-media@vger.kernel.org
Subject: Re: [PATCH 08/11] add vbi code for tlg2300
Date: Wed, 09 Dec 2009 16:51:34 -0200 [thread overview]
Message-ID: <4B1FF1B6.207@redhat.com> (raw)
In-Reply-To: <1258687493-4012-9-git-send-email-shijie8@gmail.com>
Huang Shijie wrote:
> This is the vbi module for tlg2300.
>
> Signed-off-by: Huang Shijie <shijie8@gmail.com>
> ---
> drivers/media/video/tlg2300/pd-vbi.c | 183 ++++++++++++++++++++++++++++++++++
> 1 files changed, 183 insertions(+), 0 deletions(-)
> create mode 100644 drivers/media/video/tlg2300/pd-vbi.c
>
> diff --git a/drivers/media/video/tlg2300/pd-vbi.c b/drivers/media/video/tlg2300/pd-vbi.c
> new file mode 100644
> index 0000000..fb9ee0d
> --- /dev/null
> +++ b/drivers/media/video/tlg2300/pd-vbi.c
> @@ -0,0 +1,183 @@
> +#include <linux/kernel.h>
> +#include <linux/usb.h>
> +#include <linux/kref.h>
> +#include <linux/uaccess.h>
> +#include <linux/mm.h>
> +#include <linux/vmalloc.h>
> +#include <linux/version.h>
> +#include <media/v4l2-common.h>
> +#include <linux/types.h>
> +#include <media/v4l2-dev.h>
> +#include <linux/fs.h>
> +#include <linux/poll.h>
> +#include <linux/slab.h>
> +#include <linux/string.h>
> +#include <linux/unistd.h>
> +
> +#include "vendorcmds.h"
> +#include "pd-common.h"
> +
> +int vbi_request_buf(struct vbi_data *vbi_data, size_t size)
> +{
> + int i, count = 4;
> +
> + pd_bufqueue_init(&vbi_data->vbi_queue, &count, size, KERNEL_MEM);
> +
> + for (i = 0; i < count; i++)
> + pd_bufqueue_qbuf(&vbi_data->vbi_queue, i);
> +
> + vbi_data->buf_count = count;
> + return 0;
> +}
> +
> +int vbi_release_buf(struct vbi_data *vbi_data)
> +{
> + if (vbi_data->buf_count) {
> + pd_bufqueue_cleanup(&vbi_data->vbi_queue);
> + pd_bufqueue_wakeup(&vbi_data->vbi_queue);
> + vbi_data->buf_count = 0;
> + }
> + return 0;
> +}
> +
> +static long vbi_v4l2_ioctl(struct file *file,
> + u32 cmd, unsigned long argp)
> +{
No. You should use struct v4l2_ioctl_ops for the ioctls. It should be noticed
that VBI setup should happen on _any_ V4L interface. So, the same ioctl that
sets video, should also set VBI.
So, the code bellow should be merged with the video part of the driver.
> + struct poseidon *pd = file->private_data;
> + int ret = 0;
> +
> + mutex_lock(&pd->lock);
> + switch (cmd) {
> + case VIDIOC_QUERYCAP: {
> + struct v4l2_capability *t_cap = (struct v4l2_capability *)argp;
> +
> + strcpy(t_cap->driver, "Telegent Driver");
> + strcpy(t_cap->card, "Telegent Poseidon");
> + strcpy(t_cap->bus_info, "USB bus");
> + t_cap->version = 0;
> + t_cap->capabilities = V4L2_CAP_VBI_CAPTURE;
> + }
> + break;
> +
> + case VIDIOC_S_FMT:
> + case VIDIOC_G_FMT: {
> + struct v4l2_format *v4l2_f = (struct v4l2_format *)argp;
> +
> + v4l2_f->fmt.vbi.sampling_rate = 6750000 * 4;
> + v4l2_f->fmt.vbi.samples_per_line = 720*2/* VBI_LINE_LENGTH */;
> + v4l2_f->fmt.vbi.sample_format = V4L2_PIX_FMT_GREY;
> + v4l2_f->fmt.vbi.offset = 64 * 4; /*FIXME: why offset */
> + if (pd->video_data.tvnormid & V4L2_STD_525_60) {
> + v4l2_f->fmt.vbi.start[0] = 10;
> + v4l2_f->fmt.vbi.start[1] = 264;
> + v4l2_f->fmt.vbi.count[0] = V4L_NTSC_VBI_LINES;
> + v4l2_f->fmt.vbi.count[1] = V4L_NTSC_VBI_LINES;
> + } else {
> + v4l2_f->fmt.vbi.start[0] = 6;
> + v4l2_f->fmt.vbi.start[1] = 314;
> + v4l2_f->fmt.vbi.count[0] = V4L_PAL_VBI_LINES;
> + v4l2_f->fmt.vbi.count[1] = V4L_PAL_VBI_LINES;
> + }
> + /* VBI_UNSYNC VBI_INTERLACED */
> + v4l2_f->fmt.vbi.flags = V4L2_VBI_UNSYNC;
> + }
> + break;
> +
> + default:
> + ret = -EINVAL;
> + }
> + mutex_unlock(&pd->lock);
> + return ret;
> +}
> +
> +static ssize_t vbi_read(struct file *file, char __user *buffer,
> + size_t count, loff_t *ppos)
> +{
> + struct poseidon *pd = file->private_data;
> + struct vbi_data *vbi = &pd->vbi_data;
> +
> + return vbi->buf_count ?
> + pd_bufqueue_read(&vbi->vbi_queue, file->f_flags, buffer, count)
> + : -EINVAL;
> +}
> +
> +static int vbi_open(struct file *file)
> +{
> + int ret = 0;
> + struct video_device *vd = video_devdata(file);
> + struct poseidon *pd = video_get_drvdata(vd);
> +
> + if (!pd)
> + return -ENODEV;
> +
> + mutex_lock(&pd->lock);
> + if (pd->state & POSEIDON_STATE_DISCONNECT) {
> + ret = -ENODEV;
> + goto out;
> + }
> + kref_get(&pd->kref);
> + file->private_data = pd;
> + set_debug_mode(vd, debug_mode);
> +out:
> + mutex_unlock(&pd->lock);
> + return ret;
> +}
> +
> +static int vbi_release(struct file *file)
> +{
> + struct poseidon *pd = file->private_data;
> +
> + if (!pd)
> + return -ENODEV;
> +
> + kref_put(&pd->kref, poseidon_delete);
> + return 0;
> +}
> +
> +static const struct v4l2_file_operations vbi_file_ops = {
> + .owner = THIS_MODULE,
> + .open = vbi_open,
> + .release = vbi_release,
> + .read = vbi_read,
> + .ioctl = vbi_v4l2_ioctl,
> +};
> +
> +static struct video_device vbi_device = {
> + .name = "poseidon_vbi",
> + .fops = &vbi_file_ops,
> + .release = video_device_release,
> +};
> +
> +int vbi_init(struct poseidon *pd)
> +{
> + int ret = 0;
> +
> + memset(&(pd->vbi_data), 0, sizeof(struct vbi_data));
> +
> + pd->vbi_data.vbi_dev = vdev_init(pd, &vbi_device);
> + if (pd->vbi_data.vbi_dev == NULL) {
> + ret = -ENOMEM;
> + goto vbi_error;
> + }
> +
> + if (video_register_device(pd->vbi_data.vbi_dev, VFL_TYPE_VBI, -1) < 0) {
> + video_device_release(pd->vbi_data.vbi_dev);
> + pd->vbi_data.vbi_dev = NULL;
> + printk(KERN_DEBUG"vbi_init : video device register failed\n");
> + ret = -1;
> + }
> +
> +vbi_error:
> + return ret;
> +}
> +
> +int vbi_exit(struct poseidon *pd)
> +{
> + struct vbi_data *vbi_data = &pd->vbi_data;
> +
> + if (vbi_data->vbi_dev) {
> + video_unregister_device(vbi_data->vbi_dev);
> + vbi_data->vbi_dev = NULL;
> + }
> + return 0;
> +}
next prev parent reply other threads:[~2009-12-09 18:51 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-11-20 3:24 [PATCH 00/11] add linux driver for chip TLG2300 Huang Shijie
2009-11-20 3:24 ` [PATCH 01/11] modify video's Kconfig and Makefile for tlg2300 Huang Shijie
2009-11-20 3:24 ` [PATCH 02/11] add maitainers " Huang Shijie
[not found] ` <1258687493-4012-4-git-send-email-shijie8@gmail.com>
2009-11-20 3:24 ` [PATCH 04/11] add Kconfig and Makefile " Huang Shijie
2009-11-20 3:24 ` [PATCH 05/11] add header files " Huang Shijie
2009-11-20 3:24 ` [PATCH 06/11] add the generic file Huang Shijie
2009-11-20 3:24 ` [PATCH 07/11] add video file for tlg2300 Huang Shijie
2009-11-20 3:24 ` [PATCH 08/11] add vbi code " Huang Shijie
2009-11-20 3:24 ` [PATCH 09/11] add audio support " Huang Shijie
2009-11-20 3:24 ` [PATCH 10/11] add DVB-T " Huang Shijie
2009-11-20 3:24 ` [PATCH 11/11] add FM " Huang Shijie
2009-12-09 19:04 ` Mauro Carvalho Chehab
2009-12-09 18:56 ` [PATCH 10/11] add DVB-T " Mauro Carvalho Chehab
2009-12-09 18:52 ` [PATCH 09/11] add audio " Mauro Carvalho Chehab
2009-12-09 18:51 ` Mauro Carvalho Chehab [this message]
2009-12-09 18:48 ` [PATCH 07/11] add video file " Mauro Carvalho Chehab
2009-11-23 3:25 ` [PATCH 06/11] add the generic file Huang Shijie
2009-12-09 18:12 ` Mauro Carvalho Chehab
2009-12-09 19:08 ` [PATCH 00/11] add linux driver for chip TLG2300 Mauro Carvalho Chehab
2010-01-11 13:24 ` Mauro Carvalho Chehab
2010-01-12 1:52 ` Huang Shijie
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4B1FF1B6.207@redhat.com \
--to=mchehab@redhat.com \
--cc=linux-media@vger.kernel.org \
--cc=shijie8@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.