All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes
@ 2013-01-31 10:25 Hans Verkuil
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
  2013-02-01  2:22 ` [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes Huang Shijie
  0 siblings, 2 replies; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie

Hi all,

Last year I worked on this driver to improve it and fix v4l2-compliance
issues.

It required a lot of effort to even find a USB stick with this chipset
(telegent no longer exists) and unfortunately at some point I managed
to break the USB stick, so I am no longer able to work on it.

This patch series represents that part of the work I've done that has
been tested. I have additional patches in my tlg2300-wip branch:

http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/tlg2300-wip

but since I am no longer certain at what point in those remaining patches
things broke down I've decided not to post them for upstreaming. If I or
someone else ever manages to get a working tlg2300 that code might be used
for further work.

Huang Shijie, are you still able to act as maintainer? If not, then I can
put my name in. The MAINTAINER status should probably move to 'Odd Fixes'
as well.

Regards,

	Hans


^ permalink raw reply	[flat|nested] 49+ messages in thread

* [RFC PATCH 01/18] tlg2300: use correct device parent.
  2013-01-31 10:25 [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes Hans Verkuil
@ 2013-01-31 10:25 ` Hans Verkuil
  2013-01-31 10:25   ` [RFC PATCH 02/18] tlg2300: fix tuner and frequency handling of the radio device Hans Verkuil
                     ` (17 more replies)
  2013-02-01  2:22 ` [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes Huang Shijie
  1 sibling, 18 replies; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Set the correct parent for v4l2_device_register. Also remove an unnecessary
forward reference and fix two weird looking log messages.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-main.c |    9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-main.c b/drivers/media/usb/tlg2300/pd-main.c
index 7b1f6eb..c4eb57a 100644
--- a/drivers/media/usb/tlg2300/pd-main.c
+++ b/drivers/media/usb/tlg2300/pd-main.c
@@ -55,7 +55,6 @@ MODULE_PARM_DESC(debug_mode, "0 = disable, 1 = enable, 2 = verbose");
 
 #define TLG2300_FIRMWARE "tlg2300_firmware.bin"
 static const char *firmware_name = TLG2300_FIRMWARE;
-static struct usb_driver poseidon_driver;
 static LIST_HEAD(pd_device_list);
 
 /*
@@ -316,7 +315,7 @@ static int poseidon_suspend(struct usb_interface *intf, pm_message_t msg)
 		if (get_pm_count(pd) <= 0 && !in_hibernation(pd)) {
 			pd->msg.event = PM_EVENT_AUTO_SUSPEND;
 			pd->pm_resume = NULL; /*  a good guard */
-			printk(KERN_DEBUG "\n\t+ TLG2300 auto suspend +\n\n");
+			printk(KERN_DEBUG "TLG2300 auto suspend\n");
 		}
 		return 0;
 	}
@@ -331,7 +330,7 @@ static int poseidon_resume(struct usb_interface *intf)
 
 	if (!pd)
 		return 0;
-	printk(KERN_DEBUG "\n\t ++ TLG2300 resume ++\n\n");
+	printk(KERN_DEBUG "TLG2300 resume\n");
 
 	if (!is_working(pd)) {
 		if (PM_EVENT_AUTO_SUSPEND == pd->msg.event)
@@ -439,7 +438,7 @@ static int poseidon_probe(struct usb_interface *interface,
 		/* register v4l2 device */
 		snprintf(pd->v4l2_dev.name, sizeof(pd->v4l2_dev.name), "%s %s",
 			dev->driver->name, dev_name(dev));
-		ret = v4l2_device_register(NULL, &pd->v4l2_dev);
+		ret = v4l2_device_register(&interface->dev, &pd->v4l2_dev);
 
 		/* register devices in directory /dev */
 		ret = pd_video_init(pd);
@@ -530,7 +529,7 @@ module_init(poseidon_init);
 module_exit(poseidon_exit);
 
 MODULE_AUTHOR("Telegent Systems");
-MODULE_DESCRIPTION("For tlg2300-based USB device ");
+MODULE_DESCRIPTION("For tlg2300-based USB device");
 MODULE_LICENSE("GPL");
 MODULE_VERSION("0.0.2");
 MODULE_FIRMWARE(TLG2300_FIRMWARE);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 02/18] tlg2300: fix tuner and frequency handling of the radio device.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  3:46     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 03/18] tlg2300: switch to unlocked_ioctl Hans Verkuil
                     ` (16 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

This driver now passes the tuner and frequency tests of v4l2-compliance.

It's the usual bugs: frequency wasn't clamped to the valid frequency range,
incorrect tuner capabilities and tuner fields not filled in, missing test
for invalid tuner index, no initial frequency and incorrect error handling.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-radio.c |   37 +++++++++++++++++++---------------
 1 file changed, 21 insertions(+), 16 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
index 25eeb16..90dc1d1 100644
--- a/drivers/media/usb/tlg2300/pd-radio.c
+++ b/drivers/media/usb/tlg2300/pd-radio.c
@@ -18,8 +18,8 @@ static int set_frequency(struct poseidon *p, __u32 frequency);
 static int poseidon_fm_close(struct file *filp);
 static int poseidon_fm_open(struct file *filp);
 
-#define TUNER_FREQ_MIN_FM 76000000
-#define TUNER_FREQ_MAX_FM 108000000
+#define TUNER_FREQ_MIN_FM 76000000U
+#define TUNER_FREQ_MAX_FM 108000000U
 
 #define MAX_PREEMPHASIS (V4L2_PREEMPHASIS_75_uS + 1)
 static int preemphasis[MAX_PREEMPHASIS] = {
@@ -170,13 +170,14 @@ static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
 		return -EINVAL;
 
 	vt->type	= V4L2_TUNER_RADIO;
-	vt->capability	= V4L2_TUNER_CAP_STEREO;
-	vt->rangelow	= TUNER_FREQ_MIN_FM / 62500;
-	vt->rangehigh	= TUNER_FREQ_MAX_FM / 62500;
+	vt->capability	= V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
+	vt->rangelow	= TUNER_FREQ_MIN_FM * 2 / 125;
+	vt->rangehigh	= TUNER_FREQ_MAX_FM * 2 / 125;
 	vt->rxsubchans	= V4L2_TUNER_SUB_STEREO;
 	vt->audmode	= V4L2_TUNER_MODE_STEREO;
 	vt->signal	= 0;
 	vt->afc 	= 0;
+	strlcpy(vt->name, "Radio", sizeof(vt->name));
 
 	mutex_lock(&p->lock);
 	ret = send_get_req(p, TUNER_STATUS, TLG_MODE_FM_RADIO,
@@ -207,6 +208,8 @@ static int fm_get_freq(struct file *file, void *priv,
 {
 	struct poseidon *p = file->private_data;
 
+	if (argp->tuner)
+		return -EINVAL;
 	argp->frequency = p->radio_data.fm_freq;
 	return 0;
 }
@@ -221,11 +224,8 @@ static int set_frequency(struct poseidon *p, __u32 frequency)
 	ret = send_set_req(p, TUNER_AUD_ANA_STD,
 				p->radio_data.pre_emphasis, &status);
 
-	freq =  (frequency * 125) * 500 / 1000;/* kHZ */
-	if (freq < TUNER_FREQ_MIN_FM/1000 || freq > TUNER_FREQ_MAX_FM/1000) {
-		ret = -EINVAL;
-		goto error;
-	}
+	freq = (frequency * 125) / 2; /* Hz */
+	freq = clamp(freq, TUNER_FREQ_MIN_FM, TUNER_FREQ_MAX_FM);
 
 	ret = send_set_req(p, TUNE_FREQ_SELECT, freq, &status);
 	if (ret < 0)
@@ -240,7 +240,7 @@ static int set_frequency(struct poseidon *p, __u32 frequency)
 				TLG_TUNE_PLAY_SVC_START, &status);
 		p->radio_data.is_radio_streaming = 1;
 	}
-	p->radio_data.fm_freq = frequency;
+	p->radio_data.fm_freq = freq * 2 / 125;
 error:
 	mutex_unlock(&p->lock);
 	return ret;
@@ -251,7 +251,9 @@ static int fm_set_freq(struct file *file, void *priv,
 {
 	struct poseidon *p = file->private_data;
 
-	p->file_for_stream  = file;
+	if (argp->tuner)
+		return -EINVAL;
+	p->file_for_stream = file;
 #ifdef CONFIG_PM
 	p->pm_suspend = pm_fm_suspend;
 	p->pm_resume  = pm_fm_resume;
@@ -401,16 +403,19 @@ static struct video_device poseidon_fm_template = {
 int poseidon_fm_init(struct poseidon *p)
 {
 	struct video_device *fm_dev;
+	int err;
 
 	fm_dev = vdev_init(p, &poseidon_fm_template);
 	if (fm_dev == NULL)
-		return -1;
+		return -ENOMEM;
 
-	if (video_register_device(fm_dev, VFL_TYPE_RADIO, -1) < 0) {
+	p->radio_data.fm_dev = fm_dev;
+	set_frequency(p, TUNER_FREQ_MIN_FM);
+	err = video_register_device(fm_dev, VFL_TYPE_RADIO, -1);
+	if (err < 0) {
 		video_device_release(fm_dev);
-		return -1;
+		return err;
 	}
-	p->radio_data.fm_dev = fm_dev;
 	return 0;
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 03/18] tlg2300: switch to unlocked_ioctl.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
  2013-01-31 10:25   ` [RFC PATCH 02/18] tlg2300: fix tuner and frequency handling of the radio device Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  3:48     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices Hans Verkuil
                     ` (15 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

The driver already does locking, so it is safe to switch to unlocked_ioctl.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-radio.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
index 90dc1d1..c4feffb 100644
--- a/drivers/media/usb/tlg2300/pd-radio.c
+++ b/drivers/media/usb/tlg2300/pd-radio.c
@@ -156,7 +156,7 @@ static const struct v4l2_file_operations poseidon_fm_fops = {
 	.owner         = THIS_MODULE,
 	.open          = poseidon_fm_open,
 	.release       = poseidon_fm_close,
-	.ioctl	       = video_ioctl2,
+	.unlocked_ioctl = video_ioctl2,
 };
 
 static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
  2013-01-31 10:25   ` [RFC PATCH 02/18] tlg2300: fix tuner and frequency handling of the radio device Hans Verkuil
  2013-01-31 10:25   ` [RFC PATCH 03/18] tlg2300: switch to unlocked_ioctl Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:16     ` Huang Shijie
  2013-02-05  4:03     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 05/18] tlg2300: embed video_device instead of allocating it Hans Verkuil
                     ` (14 subsequent siblings)
  17 siblings, 2 replies; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

The input and audio ioctls are only valid for video/vbi nodes.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-radio.c |   27 ---------------------------
 1 file changed, 27 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
index c4feffb..4c76e089 100644
--- a/drivers/media/usb/tlg2300/pd-radio.c
+++ b/drivers/media/usb/tlg2300/pd-radio.c
@@ -350,36 +350,9 @@ static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *vt)
 {
 	return vt->index > 0 ? -EINVAL : 0;
 }
-static int vidioc_s_audio(struct file *file, void *priv, const struct v4l2_audio *va)
-{
-	return (va->index != 0) ? -EINVAL : 0;
-}
-
-static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
-{
-	a->index    = 0;
-	a->mode    = 0;
-	a->capability = V4L2_AUDCAP_STEREO;
-	strcpy(a->name, "Radio");
-	return 0;
-}
-
-static int vidioc_s_input(struct file *filp, void *priv, u32 i)
-{
-	return (i != 0) ? -EINVAL : 0;
-}
-
-static int vidioc_g_input(struct file *filp, void *priv, u32 *i)
-{
-	return (*i != 0) ? -EINVAL : 0;
-}
 
 static const struct v4l2_ioctl_ops poseidon_fm_ioctl_ops = {
 	.vidioc_querycap    = vidioc_querycap,
-	.vidioc_g_audio     = vidioc_g_audio,
-	.vidioc_s_audio     = vidioc_s_audio,
-	.vidioc_g_input     = vidioc_g_input,
-	.vidioc_s_input     = vidioc_s_input,
 	.vidioc_queryctrl   = tlg_fm_vidioc_queryctrl,
 	.vidioc_querymenu   = tlg_fm_vidioc_querymenu,
 	.vidioc_g_ctrl      = tlg_fm_vidioc_g_ctrl,
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 05/18] tlg2300: embed video_device instead of allocating it.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (2 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:26     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 06/18] tlg2300: add control handler for radio device node Hans Verkuil
                     ` (13 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-common.h |    2 +-
 drivers/media/usb/tlg2300/pd-radio.c  |   20 ++++++--------------
 2 files changed, 7 insertions(+), 15 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
index 5dd73b7..3a89128 100644
--- a/drivers/media/usb/tlg2300/pd-common.h
+++ b/drivers/media/usb/tlg2300/pd-common.h
@@ -118,7 +118,7 @@ struct radio_data {
 	int		users;
 	unsigned int	is_radio_streaming;
 	int		pre_emphasis;
-	struct video_device *fm_dev;
+	struct video_device fm_dev;
 };
 
 #define DVB_SBUF_NUM		4
diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
index 4c76e089..719c3da 100644
--- a/drivers/media/usb/tlg2300/pd-radio.c
+++ b/drivers/media/usb/tlg2300/pd-radio.c
@@ -369,31 +369,23 @@ static struct video_device poseidon_fm_template = {
 	.name       = "Telegent-Radio",
 	.fops       = &poseidon_fm_fops,
 	.minor      = -1,
-	.release    = video_device_release,
+	.release    = video_device_release_empty,
 	.ioctl_ops  = &poseidon_fm_ioctl_ops,
 };
 
 int poseidon_fm_init(struct poseidon *p)
 {
-	struct video_device *fm_dev;
-	int err;
+	struct video_device *vfd = &p->radio_data.fm_dev;
 
-	fm_dev = vdev_init(p, &poseidon_fm_template);
-	if (fm_dev == NULL)
-		return -ENOMEM;
+	*vfd = poseidon_fm_template;
+	vfd->v4l2_dev	= &p->v4l2_dev;
+	video_set_drvdata(vfd, p);
 
-	p->radio_data.fm_dev = fm_dev;
 	set_frequency(p, TUNER_FREQ_MIN_FM);
-	err = video_register_device(fm_dev, VFL_TYPE_RADIO, -1);
-	if (err < 0) {
-		video_device_release(fm_dev);
-		return err;
-	}
-	return 0;
+	return video_register_device(vfd, VFL_TYPE_RADIO, -1);
 }
 
 int poseidon_fm_exit(struct poseidon *p)
 {
-	destroy_video_device(&p->radio_data.fm_dev);
 	return 0;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 06/18] tlg2300: add control handler for radio device node.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (3 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 05/18] tlg2300: embed video_device instead of allocating it Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:47     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 07/18] tlg2300: switch to v4l2_fh Hans Verkuil
                     ` (12 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-common.h |    2 +
 drivers/media/usb/tlg2300/pd-radio.c  |  112 ++++++++-------------------------
 2 files changed, 28 insertions(+), 86 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
index 3a89128..b26082a 100644
--- a/drivers/media/usb/tlg2300/pd-common.h
+++ b/drivers/media/usb/tlg2300/pd-common.h
@@ -10,6 +10,7 @@
 #include <linux/poll.h>
 #include <media/videobuf-vmalloc.h>
 #include <media/v4l2-device.h>
+#include <media/v4l2-ctrls.h>
 
 #include "dvb_frontend.h"
 #include "dvbdev.h"
@@ -119,6 +120,7 @@ struct radio_data {
 	unsigned int	is_radio_streaming;
 	int		pre_emphasis;
 	struct video_device fm_dev;
+	struct v4l2_ctrl_handler ctrl_handler;
 };
 
 #define DVB_SBUF_NUM		4
diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
index 719c3da..45b3d7a 100644
--- a/drivers/media/usb/tlg2300/pd-radio.c
+++ b/drivers/media/usb/tlg2300/pd-radio.c
@@ -261,104 +261,34 @@ static int fm_set_freq(struct file *file, void *priv,
 	return set_frequency(p, argp->frequency);
 }
 
-static int tlg_fm_vidioc_g_ctrl(struct file *file, void *priv,
-		struct v4l2_control *arg)
+static int tlg_fm_s_ctrl(struct v4l2_ctrl *ctrl)
 {
-	return 0;
-}
-
-static int tlg_fm_vidioc_g_exts_ctrl(struct file *file, void *fh,
-				struct v4l2_ext_controls *ctrls)
-{
-	struct poseidon *p = file->private_data;
-	int i;
-
-	if (ctrls->ctrl_class != V4L2_CTRL_CLASS_FM_TX)
-		return -EINVAL;
-
-	for (i = 0; i < ctrls->count; i++) {
-		struct v4l2_ext_control *ctrl = ctrls->controls + i;
-
-		if (ctrl->id != V4L2_CID_TUNE_PREEMPHASIS)
-			continue;
-
-		if (i < MAX_PREEMPHASIS)
-			ctrl->value = p->radio_data.pre_emphasis;
-	}
-	return 0;
-}
-
-static int tlg_fm_vidioc_s_exts_ctrl(struct file *file, void *fh,
-			struct v4l2_ext_controls *ctrls)
-{
-	int i;
-
-	if (ctrls->ctrl_class != V4L2_CTRL_CLASS_FM_TX)
-		return -EINVAL;
-
-	for (i = 0; i < ctrls->count; i++) {
-		struct v4l2_ext_control *ctrl = ctrls->controls + i;
-
-		if (ctrl->id != V4L2_CID_TUNE_PREEMPHASIS)
-			continue;
-
-		if (ctrl->value >= 0 && ctrl->value < MAX_PREEMPHASIS) {
-			struct poseidon *p = file->private_data;
-			int pre_emphasis = preemphasis[ctrl->value];
-			u32 status;
-
-			send_set_req(p, TUNER_AUD_ANA_STD,
-						pre_emphasis, &status);
-			p->radio_data.pre_emphasis = pre_emphasis;
-		}
-	}
-	return 0;
-}
-
-static int tlg_fm_vidioc_s_ctrl(struct file *file, void *priv,
-		struct v4l2_control *ctrl)
-{
-	return 0;
-}
-
-static int tlg_fm_vidioc_queryctrl(struct file *file, void *priv,
-		struct v4l2_queryctrl *ctrl)
-{
-	if (!(ctrl->id & V4L2_CTRL_FLAG_NEXT_CTRL))
-		return -EINVAL;
+	struct poseidon *p = container_of(ctrl->handler, struct poseidon,
+						radio_data.ctrl_handler);
+	int pre_emphasis;
+	u32 status;
 
-	ctrl->id &= ~V4L2_CTRL_FLAG_NEXT_CTRL;
-	if (ctrl->id != V4L2_CID_TUNE_PREEMPHASIS) {
-		/* return the next supported control */
-		ctrl->id = V4L2_CID_TUNE_PREEMPHASIS;
-		v4l2_ctrl_query_fill(ctrl, V4L2_PREEMPHASIS_DISABLED,
-					V4L2_PREEMPHASIS_75_uS, 1,
-					V4L2_PREEMPHASIS_50_uS);
-		ctrl->flags = V4L2_CTRL_FLAG_UPDATE;
+	switch (ctrl->id) {
+	case V4L2_CID_TUNE_PREEMPHASIS:
+		pre_emphasis = preemphasis[ctrl->val];
+		send_set_req(p, TUNER_AUD_ANA_STD, pre_emphasis, &status);
+		p->radio_data.pre_emphasis = pre_emphasis;
 		return 0;
 	}
 	return -EINVAL;
 }
 
-static int tlg_fm_vidioc_querymenu(struct file *file, void *fh,
-				struct v4l2_querymenu *qmenu)
-{
-	return v4l2_ctrl_query_menu(qmenu, NULL, NULL);
-}
-
 static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *vt)
 {
 	return vt->index > 0 ? -EINVAL : 0;
 }
 
+static const struct v4l2_ctrl_ops tlg_fm_ctrl_ops = {
+	.s_ctrl = tlg_fm_s_ctrl,
+};
+
 static const struct v4l2_ioctl_ops poseidon_fm_ioctl_ops = {
 	.vidioc_querycap    = vidioc_querycap,
-	.vidioc_queryctrl   = tlg_fm_vidioc_queryctrl,
-	.vidioc_querymenu   = tlg_fm_vidioc_querymenu,
-	.vidioc_g_ctrl      = tlg_fm_vidioc_g_ctrl,
-	.vidioc_s_ctrl      = tlg_fm_vidioc_s_ctrl,
-	.vidioc_s_ext_ctrls = tlg_fm_vidioc_s_exts_ctrl,
-	.vidioc_g_ext_ctrls = tlg_fm_vidioc_g_exts_ctrl,
 	.vidioc_s_tuner     = vidioc_s_tuner,
 	.vidioc_g_tuner     = tlg_fm_vidioc_g_tuner,
 	.vidioc_g_frequency = fm_get_freq,
@@ -376,16 +306,26 @@ static struct video_device poseidon_fm_template = {
 int poseidon_fm_init(struct poseidon *p)
 {
 	struct video_device *vfd = &p->radio_data.fm_dev;
+	struct v4l2_ctrl_handler *hdl = &p->radio_data.ctrl_handler;
 
 	*vfd = poseidon_fm_template;
-	vfd->v4l2_dev	= &p->v4l2_dev;
-	video_set_drvdata(vfd, p);
 
 	set_frequency(p, TUNER_FREQ_MIN_FM);
+	v4l2_ctrl_handler_init(hdl, 1);
+	v4l2_ctrl_new_std_menu(hdl, &tlg_fm_ctrl_ops, V4L2_CID_TUNE_PREEMPHASIS,
+			V4L2_PREEMPHASIS_75_uS, 0, V4L2_PREEMPHASIS_50_uS);
+	if (hdl->error) {
+		v4l2_ctrl_handler_free(hdl);
+		return hdl->error;
+	}
+	vfd->v4l2_dev = &p->v4l2_dev;
+	vfd->ctrl_handler = hdl;
+	video_set_drvdata(vfd, p);
 	return video_register_device(vfd, VFL_TYPE_RADIO, -1);
 }
 
 int poseidon_fm_exit(struct poseidon *p)
 {
+	v4l2_ctrl_handler_free(&p->radio_data.ctrl_handler);
 	return 0;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 07/18] tlg2300: switch to v4l2_fh.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (4 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 06/18] tlg2300: add control handler for radio device node Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:32     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 08/18] tlg2300: fix radio querycap Hans Verkuil
                     ` (11 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

This switch to v4l2_fh resolves the last v4l2_compliance issues with respect
to control events and priority handling.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-common.h |    1 -
 drivers/media/usb/tlg2300/pd-main.c   |    3 ++-
 drivers/media/usb/tlg2300/pd-radio.c  |   35 ++++++++++++++++++---------------
 3 files changed, 21 insertions(+), 18 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
index b26082a..67ad065 100644
--- a/drivers/media/usb/tlg2300/pd-common.h
+++ b/drivers/media/usb/tlg2300/pd-common.h
@@ -116,7 +116,6 @@ struct poseidon_audio {
 
 struct radio_data {
 	__u32		fm_freq;
-	int		users;
 	unsigned int	is_radio_streaming;
 	int		pre_emphasis;
 	struct video_device fm_dev;
diff --git a/drivers/media/usb/tlg2300/pd-main.c b/drivers/media/usb/tlg2300/pd-main.c
index c4eb57a..5be5a73 100644
--- a/drivers/media/usb/tlg2300/pd-main.c
+++ b/drivers/media/usb/tlg2300/pd-main.c
@@ -267,7 +267,8 @@ static inline void set_map_flags(struct poseidon *pd, struct usb_device *udev)
 static inline int get_autopm_ref(struct poseidon *pd)
 {
 	return  pd->video_data.users + pd->vbi_data.users + pd->audio.users
-		+ atomic_read(&pd->dvb_data.users) + pd->radio_data.users;
+		+ atomic_read(&pd->dvb_data.users) +
+		!list_empty(&pd->radio_data.fm_dev.fh_list);
 }
 
 /* fixup something for poseidon */
diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
index 45b3d7a..854ffa0 100644
--- a/drivers/media/usb/tlg2300/pd-radio.c
+++ b/drivers/media/usb/tlg2300/pd-radio.c
@@ -9,6 +9,8 @@
 #include <linux/mm.h>
 #include <linux/mutex.h>
 #include <media/v4l2-ioctl.h>
+#include <media/v4l2-event.h>
+#include <media/v4l2-fh.h>
 #include <linux/sched.h>
 
 #include "pd-common.h"
@@ -77,13 +79,9 @@ static int pm_fm_resume(struct poseidon *p)
 
 static int poseidon_fm_open(struct file *filp)
 {
-	struct video_device *vfd = video_devdata(filp);
-	struct poseidon *p = video_get_drvdata(vfd);
+	struct poseidon *p = video_drvdata(filp);
 	int ret = 0;
 
-	if (!p)
-		return -1;
-
 	mutex_lock(&p->lock);
 	if (p->state & POSEIDON_STATE_DISCONNECT) {
 		ret = -ENODEV;
@@ -94,9 +92,14 @@ static int poseidon_fm_open(struct file *filp)
 		ret = -EBUSY;
 		goto out;
 	}
+	ret = v4l2_fh_open(filp);
+	if (ret)
+		goto out;
 
 	usb_autopm_get_interface(p->interface);
 	if (0 == p->state) {
+		struct video_device *vfd = &p->radio_data.fm_dev;
+
 		/* default pre-emphasis */
 		if (p->radio_data.pre_emphasis == 0)
 			p->radio_data.pre_emphasis = TLG_TUNE_ASTD_FM_EUR;
@@ -109,9 +112,7 @@ static int poseidon_fm_open(struct file *filp)
 		}
 		p->state |= POSEIDON_STATE_FM;
 	}
-	p->radio_data.users++;
 	kref_get(&p->kref);
-	filp->private_data = p;
 out:
 	mutex_unlock(&p->lock);
 	return ret;
@@ -119,13 +120,12 @@ out:
 
 static int poseidon_fm_close(struct file *filp)
 {
-	struct poseidon *p = filp->private_data;
+	struct poseidon *p = video_drvdata(filp);
 	struct radio_data *fm = &p->radio_data;
 	uint32_t status;
 
 	mutex_lock(&p->lock);
-	fm->users--;
-	if (0 == fm->users)
+	if (v4l2_fh_is_singular_file(filp))
 		p->state &= ~POSEIDON_STATE_FM;
 
 	if (fm->is_radio_streaming && filp == p->file_for_stream) {
@@ -136,14 +136,13 @@ static int poseidon_fm_close(struct file *filp)
 	mutex_unlock(&p->lock);
 
 	kref_put(&p->kref, poseidon_delete);
-	filp->private_data = NULL;
-	return 0;
+	return v4l2_fh_release(filp);
 }
 
 static int vidioc_querycap(struct file *file, void *priv,
 			struct v4l2_capability *v)
 {
-	struct poseidon *p = file->private_data;
+	struct poseidon *p = video_drvdata(file);
 
 	strlcpy(v->driver, "tele-radio", sizeof(v->driver));
 	strlcpy(v->card, "Telegent Poseidon", sizeof(v->card));
@@ -156,15 +155,16 @@ static const struct v4l2_file_operations poseidon_fm_fops = {
 	.owner         = THIS_MODULE,
 	.open          = poseidon_fm_open,
 	.release       = poseidon_fm_close,
+	.poll		= v4l2_ctrl_poll,
 	.unlocked_ioctl = video_ioctl2,
 };
 
 static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
 				 struct v4l2_tuner *vt)
 {
+	struct poseidon *p = video_drvdata(file);
 	struct tuner_fm_sig_stat_s fm_stat = {};
 	int ret, status, count = 5;
-	struct poseidon *p = file->private_data;
 
 	if (vt->index != 0)
 		return -EINVAL;
@@ -206,7 +206,7 @@ static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
 static int fm_get_freq(struct file *file, void *priv,
 		       struct v4l2_frequency *argp)
 {
-	struct poseidon *p = file->private_data;
+	struct poseidon *p = video_drvdata(file);
 
 	if (argp->tuner)
 		return -EINVAL;
@@ -249,7 +249,7 @@ error:
 static int fm_set_freq(struct file *file, void *priv,
 		       struct v4l2_frequency *argp)
 {
-	struct poseidon *p = file->private_data;
+	struct poseidon *p = video_drvdata(file);
 
 	if (argp->tuner)
 		return -EINVAL;
@@ -293,6 +293,8 @@ static const struct v4l2_ioctl_ops poseidon_fm_ioctl_ops = {
 	.vidioc_g_tuner     = tlg_fm_vidioc_g_tuner,
 	.vidioc_g_frequency = fm_get_freq,
 	.vidioc_s_frequency = fm_set_freq,
+	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
+	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
 };
 
 static struct video_device poseidon_fm_template = {
@@ -320,6 +322,7 @@ int poseidon_fm_init(struct poseidon *p)
 	}
 	vfd->v4l2_dev = &p->v4l2_dev;
 	vfd->ctrl_handler = hdl;
+	set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags);
 	video_set_drvdata(vfd, p);
 	return video_register_device(vfd, VFL_TYPE_RADIO, -1);
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 08/18] tlg2300: fix radio querycap
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (5 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 07/18] tlg2300: switch to v4l2_fh Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:36     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 09/18] tlg2300: add missing video_unregister_device Hans Verkuil
                     ` (10 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-radio.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
index 854ffa0..80307d3 100644
--- a/drivers/media/usb/tlg2300/pd-radio.c
+++ b/drivers/media/usb/tlg2300/pd-radio.c
@@ -147,7 +147,12 @@ static int vidioc_querycap(struct file *file, void *priv,
 	strlcpy(v->driver, "tele-radio", sizeof(v->driver));
 	strlcpy(v->card, "Telegent Poseidon", sizeof(v->card));
 	usb_make_path(p->udev, v->bus_info, sizeof(v->bus_info));
-	v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
+	v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
+	/* Report all capabilities of the USB device */
+	v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS |
+			V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE |
+			V4L2_CAP_AUDIO | V4L2_CAP_STREAMING |
+			V4L2_CAP_READWRITE;
 	return 0;
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 09/18] tlg2300: add missing video_unregister_device.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (6 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 08/18] tlg2300: fix radio querycap Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:38     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 10/18] tlg2300: embed video_device Hans Verkuil
                     ` (9 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-radio.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
index 80307d3..0f958f7 100644
--- a/drivers/media/usb/tlg2300/pd-radio.c
+++ b/drivers/media/usb/tlg2300/pd-radio.c
@@ -334,6 +334,7 @@ int poseidon_fm_init(struct poseidon *p)
 
 int poseidon_fm_exit(struct poseidon *p)
 {
+	video_unregister_device(&p->radio_data.fm_dev);
 	v4l2_ctrl_handler_free(&p->radio_data.ctrl_handler);
 	return 0;
 }
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 10/18] tlg2300: embed video_device.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (7 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 09/18] tlg2300: add missing video_unregister_device Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:39     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 11/18] tlg2300: fix querycap Hans Verkuil
                     ` (8 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-common.h |    6 ++--
 drivers/media/usb/tlg2300/pd-video.c  |   55 +++++++--------------------------
 2 files changed, 13 insertions(+), 48 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
index 67ad065..052cb0c 100644
--- a/drivers/media/usb/tlg2300/pd-common.h
+++ b/drivers/media/usb/tlg2300/pd-common.h
@@ -40,7 +40,7 @@
 #define TUNER_FREQ_MAX		(862000000)
 
 struct vbi_data {
-	struct video_device	*v_dev;
+	struct video_device	v_dev;
 	struct video_data	*video;
 	struct front_face	*front;
 
@@ -63,7 +63,7 @@ struct running_context {
 
 struct video_data {
 	/* v4l2 video device */
-	struct video_device	*v_dev;
+	struct video_device	v_dev;
 
 	/* the working context */
 	struct running_context	context;
@@ -234,7 +234,6 @@ void dvb_stop_streaming(struct pd_dvb_adapter *);
 /* FM */
 int poseidon_fm_init(struct poseidon *);
 int poseidon_fm_exit(struct poseidon *);
-struct video_device *vdev_init(struct poseidon *, struct video_device *);
 
 /* vendor command ops */
 int send_set_req(struct poseidon*, u8, s32, s32*);
@@ -250,7 +249,6 @@ void free_all_urb_generic(struct urb **urb_array, int num);
 
 /* misc */
 void poseidon_delete(struct kref *kref);
-void destroy_video_device(struct video_device **v_dev);
 extern int debug_mode;
 void set_debug_mode(struct video_device *vfd, int debug_mode);
 
diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index 2172337..312809a 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -1590,48 +1590,18 @@ static struct video_device pd_video_template = {
 	.name = "Telegent-Video",
 	.fops = &pd_video_fops,
 	.minor = -1,
-	.release = video_device_release,
+	.release = video_device_release_empty,
 	.tvnorms = V4L2_STD_ALL,
 	.ioctl_ops = &pd_video_ioctl_ops,
 };
 
-struct video_device *vdev_init(struct poseidon *pd, struct video_device *tmp)
-{
-	struct video_device *vfd;
-
-	vfd = video_device_alloc();
-	if (vfd == NULL)
-		return NULL;
-	*vfd		= *tmp;
-	vfd->minor	= -1;
-	vfd->v4l2_dev	= &pd->v4l2_dev;
-	/*vfd->parent	= &(pd->udev->dev); */
-	vfd->release	= video_device_release;
-	video_set_drvdata(vfd, pd);
-	return vfd;
-}
-
-void destroy_video_device(struct video_device **v_dev)
-{
-	struct video_device *dev = *v_dev;
-
-	if (dev == NULL)
-		return;
-
-	if (video_is_registered(dev))
-		video_unregister_device(dev);
-	else
-		video_device_release(dev);
-	*v_dev = NULL;
-}
-
 void pd_video_exit(struct poseidon *pd)
 {
 	struct video_data *video = &pd->video_data;
 	struct vbi_data *vbi = &pd->vbi_data;
 
-	destroy_video_device(&video->v_dev);
-	destroy_video_device(&vbi->v_dev);
+	video_unregister_device(&video->v_dev);
+	video_unregister_device(&vbi->v_dev);
 	log();
 }
 
@@ -1641,21 +1611,19 @@ int pd_video_init(struct poseidon *pd)
 	struct vbi_data *vbi	= &pd->vbi_data;
 	int ret = -ENOMEM;
 
-	video->v_dev = vdev_init(pd, &pd_video_template);
-	if (video->v_dev == NULL)
-		goto out;
+	video->v_dev = pd_video_template;
+	video->v_dev.v4l2_dev = &pd->v4l2_dev;
+	video_set_drvdata(&video->v_dev, pd);
 
-	ret = video_register_device(video->v_dev, VFL_TYPE_GRABBER, -1);
+	ret = video_register_device(&video->v_dev, VFL_TYPE_GRABBER, -1);
 	if (ret != 0)
 		goto out;
 
 	/* VBI uses the same template as video */
-	vbi->v_dev = vdev_init(pd, &pd_video_template);
-	if (vbi->v_dev == NULL) {
-		ret = -ENOMEM;
-		goto out;
-	}
-	ret = video_register_device(vbi->v_dev, VFL_TYPE_VBI, -1);
+	vbi->v_dev = pd_video_template;
+	vbi->v_dev.v4l2_dev = &pd->v4l2_dev;
+	video_set_drvdata(&vbi->v_dev, pd);
+	ret = video_register_device(&vbi->v_dev, VFL_TYPE_VBI, -1);
 	if (ret != 0)
 		goto out;
 	log("register VIDEO/VBI devices");
@@ -1665,4 +1633,3 @@ out:
 	pd_video_exit(pd);
 	return ret;
 }
-
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 11/18] tlg2300: fix querycap
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (8 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 10/18] tlg2300: embed video_device Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:43     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 12/18] tlg2300: fix frequency handling Hans Verkuil
                     ` (7 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-video.c |   14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index 312809a..8ab2894 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -142,17 +142,23 @@ static int get_audio_std(v4l2_std_id v4l2_std)
 static int vidioc_querycap(struct file *file, void *fh,
 			struct v4l2_capability *cap)
 {
+	struct video_device *vdev = video_devdata(file);
+	struct poseidon *p = video_get_drvdata(vdev);
 	struct front_face *front = fh;
-	struct poseidon *p = front->pd;
 
 	logs(front);
 
 	strcpy(cap->driver, "tele-video");
 	strcpy(cap->card, "Telegent Poseidon");
 	usb_make_path(p->udev, cap->bus_info, sizeof(cap->bus_info));
-	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER |
-				V4L2_CAP_AUDIO | V4L2_CAP_STREAMING |
-				V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE;
+	cap->device_caps = V4L2_CAP_TUNER | V4L2_CAP_AUDIO |
+			V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
+	if (vdev->vfl_type == VFL_TYPE_VBI)
+		cap->device_caps |= V4L2_CAP_VBI_CAPTURE;
+	else
+		cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE;
+	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS |
+		V4L2_CAP_RADIO | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE;
 	return 0;
 }
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 12/18] tlg2300: fix frequency handling.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (9 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 11/18] tlg2300: fix querycap Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:44     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 13/18] tlg2300: fix missing audioset Hans Verkuil
                     ` (6 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

The usual set of problems: the frequency isn't clamped to the frequency range,
no tuner index check and the frequency isn't initialized properly on module
load.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-common.h |    4 ++--
 drivers/media/usb/tlg2300/pd-video.c  |   20 ++++++++++++--------
 2 files changed, 14 insertions(+), 10 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
index 052cb0c..55fe66e 100644
--- a/drivers/media/usb/tlg2300/pd-common.h
+++ b/drivers/media/usb/tlg2300/pd-common.h
@@ -36,8 +36,8 @@
 #define V4L_PAL_VBI_FRAMESIZE	(V4L_PAL_VBI_LINES * 1440 * 2)
 #define V4L_NTSC_VBI_FRAMESIZE	(V4L_NTSC_VBI_LINES * 1440 * 2)
 
-#define TUNER_FREQ_MIN		(45000000)
-#define TUNER_FREQ_MAX		(862000000)
+#define TUNER_FREQ_MIN		(45000000U)
+#define TUNER_FREQ_MAX		(862000000U)
 
 struct vbi_data {
 	struct video_device	v_dev;
diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index 8ab2894..da7cbd4 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -940,7 +940,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int i)
 	return 0;
 }
 
-static struct poseidon_control *check_control_id(__u32 id)
+static struct poseidon_control *check_control_id(u32 id)
 {
 	struct poseidon_control *control = &controls[0];
 	int array_size = ARRAY_SIZE(controls);
@@ -1134,21 +1134,21 @@ static int vidioc_g_frequency(struct file *file, void *fh,
 	return 0;
 }
 
-static int set_frequency(struct poseidon *pd, __u32 frequency)
+static int set_frequency(struct poseidon *pd, u32 *frequency)
 {
 	s32 ret = 0, param, cmd_status;
 	struct running_context *context = &pd->video_data.context;
 
-	param = frequency * 62500 / 1000;
-	if (param < TUNER_FREQ_MIN/1000 || param > TUNER_FREQ_MAX / 1000)
-		return -EINVAL;
+	*frequency = clamp(*frequency,
+			TUNER_FREQ_MIN / 62500, TUNER_FREQ_MAX / 62500);
+	param = (*frequency) * 62500 / 1000;
 
 	mutex_lock(&pd->lock);
 	ret = send_set_req(pd, TUNE_FREQ_SELECT, param, &cmd_status);
 	ret = send_set_req(pd, TAKE_REQUEST, 0, &cmd_status);
 
 	msleep(250); /* wait for a while until the hardware is ready. */
-	context->freq = frequency;
+	context->freq = *frequency;
 	mutex_unlock(&pd->lock);
 	return ret;
 }
@@ -1159,12 +1159,14 @@ static int vidioc_s_frequency(struct file *file, void *fh,
 	struct front_face *front = fh;
 	struct poseidon *pd = front->pd;
 
+	if (freq->tuner)
+		return -EINVAL;
 	logs(front);
 #ifdef CONFIG_PM
 	pd->pm_suspend = pm_video_suspend;
 	pd->pm_resume = pm_video_resume;
 #endif
-	return set_frequency(pd, freq->frequency);
+	return set_frequency(pd, &freq->frequency);
 }
 
 static int vidioc_reqbufs(struct file *file, void *fh,
@@ -1351,7 +1353,7 @@ static int restore_v4l2_context(struct poseidon *pd,
 	vidioc_s_input(NULL, front, context->sig_index);
 	pd_vidioc_s_tuner(pd, context->audio_idx);
 	pd_vidioc_s_fmt(pd, &context->pix);
-	set_frequency(pd, context->freq);
+	set_frequency(pd, &context->freq);
 	return 0;
 }
 
@@ -1615,8 +1617,10 @@ int pd_video_init(struct poseidon *pd)
 {
 	struct video_data *video = &pd->video_data;
 	struct vbi_data *vbi	= &pd->vbi_data;
+	u32 freq = TUNER_FREQ_MIN / 62500;
 	int ret = -ENOMEM;
 
+	set_frequency(pd, &freq);
 	video->v_dev = pd_video_template;
 	video->v_dev.v4l2_dev = &pd->v4l2_dev;
 	video_set_drvdata(&video->v_dev, pd);
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 13/18] tlg2300: fix missing audioset.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (10 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 12/18] tlg2300: fix frequency handling Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:48     ` Huang Shijie
  2013-02-05  4:07     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 14/18] tlg2300: implement the control framework Hans Verkuil
                     ` (5 subsequent siblings)
  17 siblings, 2 replies; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-video.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index da7cbd4..122f299 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -903,7 +903,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
 	 * the audio input index mixed with this video input,
 	 * Poseidon only have one audio/video, set to "0"
 	 */
-	in->audioset	= 0;
+	in->audioset	= 1;
 	in->tuner	= 0;
 	in->std		= V4L2_STD_ALL;
 	in->status	= 0;
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 14/18] tlg2300: implement the control framework.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (11 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 13/18] tlg2300: fix missing audioset Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:46     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 15/18] tlg2300: remove empty vidioc_try_fmt_vid_cap, add missing g_std Hans Verkuil
                     ` (4 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-common.h |    1 +
 drivers/media/usb/tlg2300/pd-video.c  |  128 +++++++++++----------------------
 2 files changed, 41 insertions(+), 88 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
index 55fe66e..cb5cb0f 100644
--- a/drivers/media/usb/tlg2300/pd-common.h
+++ b/drivers/media/usb/tlg2300/pd-common.h
@@ -64,6 +64,7 @@ struct running_context {
 struct video_data {
 	/* v4l2 video device */
 	struct video_device	v_dev;
+	struct v4l2_ctrl_handler ctrl_handler;
 
 	/* the working context */
 	struct running_context	context;
diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index 122f299..849c4bb 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -8,6 +8,7 @@
 
 #include <media/v4l2-ioctl.h>
 #include <media/v4l2-dev.h>
+#include <media/v4l2-ctrls.h>
 
 #include "pd-common.h"
 #include "vendorcmds.h"
@@ -82,31 +83,6 @@ static const struct pd_input pd_inputs[] = {
 };
 static const unsigned int POSEIDON_INPUTS = ARRAY_SIZE(pd_inputs);
 
-struct poseidon_control {
-	struct v4l2_queryctrl v4l2_ctrl;
-	enum cmd_custom_param_id vc_id;
-};
-
-static struct poseidon_control controls[] = {
-	{
-		{ V4L2_CID_BRIGHTNESS, V4L2_CTRL_TYPE_INTEGER,
-			"brightness", 0, 10000, 1, 100, 0, },
-		CUST_PARM_ID_BRIGHTNESS_CTRL
-	}, {
-		{ V4L2_CID_CONTRAST, V4L2_CTRL_TYPE_INTEGER,
-			"contrast", 0, 10000, 1, 100, 0, },
-		CUST_PARM_ID_CONTRAST_CTRL,
-	}, {
-		{ V4L2_CID_HUE, V4L2_CTRL_TYPE_INTEGER,
-			"hue", 0, 10000, 1, 100, 0, },
-		CUST_PARM_ID_HUE_CTRL,
-	}, {
-		{ V4L2_CID_SATURATION, V4L2_CTRL_TYPE_INTEGER,
-			"saturation", 0, 10000, 1, 100, 0, },
-		CUST_PARM_ID_SATURATION_CTRL,
-	},
-};
-
 struct video_std_to_audio_std {
 	v4l2_std_id	video_std;
 	int 		audio_std;
@@ -940,68 +916,28 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int i)
 	return 0;
 }
 
-static struct poseidon_control *check_control_id(u32 id)
-{
-	struct poseidon_control *control = &controls[0];
-	int array_size = ARRAY_SIZE(controls);
-
-	for (; control < &controls[array_size]; control++)
-		if (control->v4l2_ctrl.id  == id)
-			return control;
-	return NULL;
-}
-
-static int vidioc_queryctrl(struct file *file, void *fh,
-			struct v4l2_queryctrl *a)
-{
-	struct poseidon_control *control = NULL;
-
-	control = check_control_id(a->id);
-	if (!control)
-		return -EINVAL;
-
-	*a = control->v4l2_ctrl;
-	return 0;
-}
-
-static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *ctrl)
-{
-	struct front_face *front = fh;
-	struct poseidon *pd = front->pd;
-	struct poseidon_control *control = NULL;
-	struct tuner_custom_parameter_s tuner_param;
-	s32 ret = 0, cmd_status;
-
-	control = check_control_id(ctrl->id);
-	if (!control)
-		return -EINVAL;
-
-	mutex_lock(&pd->lock);
-	ret = send_get_req(pd, TUNER_CUSTOM_PARAMETER, control->vc_id,
-			&tuner_param, &cmd_status, sizeof(tuner_param));
-	mutex_unlock(&pd->lock);
-
-	if (ret || cmd_status)
-		return -1;
-
-	ctrl->value = tuner_param.param_value;
-	return 0;
-}
-
-static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *a)
+static int tlg_s_ctrl(struct v4l2_ctrl *c)
 {
+	struct poseidon *pd = container_of(c->handler, struct poseidon,
+						video_data.ctrl_handler);
 	struct tuner_custom_parameter_s param = {0};
-	struct poseidon_control *control = NULL;
-	struct front_face *front	= fh;
-	struct poseidon *pd		= front->pd;
 	s32 ret = 0, cmd_status, params;
 
-	control = check_control_id(a->id);
-	if (!control)
-		return -EINVAL;
-
-	param.param_value = a->value;
-	param.param_id	= control->vc_id;
+	switch (c->id) {
+	case V4L2_CID_BRIGHTNESS:
+		param.param_id = CUST_PARM_ID_BRIGHTNESS_CTRL;
+		break;
+	case V4L2_CID_CONTRAST:
+		param.param_id = CUST_PARM_ID_CONTRAST_CTRL;
+		break;
+	case V4L2_CID_HUE:
+		param.param_id = CUST_PARM_ID_HUE_CTRL;
+		break;
+	case V4L2_CID_SATURATION:
+		param.param_id = CUST_PARM_ID_SATURATION_CTRL;
+		break;
+	}
+	param.param_value = c->val;
 	params = *(s32 *)&param; /* temp code */
 
 	mutex_lock(&pd->lock);
@@ -1587,11 +1523,6 @@ static const struct v4l2_ioctl_ops pd_video_ioctl_ops = {
 	/* Stream on/off */
 	.vidioc_streamon	= vidioc_streamon,
 	.vidioc_streamoff	= vidioc_streamoff,
-
-	/* Control handling */
-	.vidioc_queryctrl	= vidioc_queryctrl,
-	.vidioc_g_ctrl		= vidioc_g_ctrl,
-	.vidioc_s_ctrl		= vidioc_s_ctrl,
 };
 
 static struct video_device pd_video_template = {
@@ -1603,6 +1534,10 @@ static struct video_device pd_video_template = {
 	.ioctl_ops = &pd_video_ioctl_ops,
 };
 
+static const struct v4l2_ctrl_ops tlg_ctrl_ops = {
+	.s_ctrl = tlg_s_ctrl,
+};
+
 void pd_video_exit(struct poseidon *pd)
 {
 	struct video_data *video = &pd->video_data;
@@ -1610,6 +1545,7 @@ void pd_video_exit(struct poseidon *pd)
 
 	video_unregister_device(&video->v_dev);
 	video_unregister_device(&vbi->v_dev);
+	v4l2_ctrl_handler_free(&video->ctrl_handler);
 	log();
 }
 
@@ -1617,12 +1553,27 @@ int pd_video_init(struct poseidon *pd)
 {
 	struct video_data *video = &pd->video_data;
 	struct vbi_data *vbi	= &pd->vbi_data;
+	struct v4l2_ctrl_handler *hdl = &video->ctrl_handler;
 	u32 freq = TUNER_FREQ_MIN / 62500;
 	int ret = -ENOMEM;
 
+	v4l2_ctrl_handler_init(hdl, 4);
+	v4l2_ctrl_new_std(hdl, &tlg_ctrl_ops, V4L2_CID_BRIGHTNESS,
+			0, 10000, 1, 100);
+	v4l2_ctrl_new_std(hdl, &tlg_ctrl_ops, V4L2_CID_CONTRAST,
+			0, 10000, 1, 100);
+	v4l2_ctrl_new_std(hdl, &tlg_ctrl_ops, V4L2_CID_HUE,
+			0, 10000, 1, 100);
+	v4l2_ctrl_new_std(hdl, &tlg_ctrl_ops, V4L2_CID_SATURATION,
+			0, 10000, 1, 100);
+	if (hdl->error) {
+		v4l2_ctrl_handler_free(hdl);
+		return hdl->error;
+	}
 	set_frequency(pd, &freq);
 	video->v_dev = pd_video_template;
 	video->v_dev.v4l2_dev = &pd->v4l2_dev;
+	video->v_dev.ctrl_handler = hdl;
 	video_set_drvdata(&video->v_dev, pd);
 
 	ret = video_register_device(&video->v_dev, VFL_TYPE_GRABBER, -1);
@@ -1632,6 +1583,7 @@ int pd_video_init(struct poseidon *pd)
 	/* VBI uses the same template as video */
 	vbi->v_dev = pd_video_template;
 	vbi->v_dev.v4l2_dev = &pd->v4l2_dev;
+	vbi->v_dev.ctrl_handler = hdl;
 	video_set_drvdata(&vbi->v_dev, pd);
 	ret = video_register_device(&vbi->v_dev, VFL_TYPE_VBI, -1);
 	if (ret != 0)
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 15/18] tlg2300: remove empty vidioc_try_fmt_vid_cap, add missing g_std.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (12 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 14/18] tlg2300: implement the control framework Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:51     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 16/18] tlg2300: allow multiple opens Hans Verkuil
                     ` (3 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-video.c |   16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index 849c4bb..4c045b3 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -705,12 +705,6 @@ static int vidioc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
 	return 0;
 }
 
-static int vidioc_try_fmt(struct file *file, void *fh,
-		struct v4l2_format *f)
-{
-	return 0;
-}
-
 /*
  * VLC calls VIDIOC_S_STD before VIDIOC_S_FMT, while
  * Mplayer calls them in the reverse order.
@@ -866,6 +860,14 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *norm)
 	return set_std(front->pd, norm);
 }
 
+static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm)
+{
+	struct front_face *front = fh;
+	logs(front);
+	*norm = front->pd->video_data.context.tvnormid;
+	return 0;
+}
+
 static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
 {
 	struct front_face *front = fh;
@@ -1495,7 +1497,6 @@ static const struct v4l2_ioctl_ops pd_video_ioctl_ops = {
 	.vidioc_enum_fmt_vid_cap	= vidioc_enum_fmt,
 	.vidioc_s_fmt_vid_cap	= vidioc_s_fmt,
 	.vidioc_g_fmt_vbi_cap	= vidioc_g_fmt_vbi, /* VBI */
-	.vidioc_try_fmt_vid_cap = vidioc_try_fmt,
 
 	/* Input */
 	.vidioc_g_input		= vidioc_g_input,
@@ -1510,6 +1511,7 @@ static const struct v4l2_ioctl_ops pd_video_ioctl_ops = {
 	/* Tuner ioctls */
 	.vidioc_g_tuner		= vidioc_g_tuner,
 	.vidioc_s_tuner		= vidioc_s_tuner,
+	.vidioc_g_std		= vidioc_g_std,
 	.vidioc_s_std		= vidioc_s_std,
 	.vidioc_g_frequency	= vidioc_g_frequency,
 	.vidioc_s_frequency	= vidioc_s_frequency,
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 16/18] tlg2300: allow multiple opens.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (13 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 15/18] tlg2300: remove empty vidioc_try_fmt_vid_cap, add missing g_std Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:54     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 17/18] tlg2300: Remove logs() macro Hans Verkuil
                     ` (2 subsequent siblings)
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Due to a poor administration of the driver state it wasn't possible to open
a video or vbi device multiple times.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-common.h |    1 -
 drivers/media/usb/tlg2300/pd-video.c  |   40 +++++++++++++--------------------
 2 files changed, 15 insertions(+), 26 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
index cb5cb0f..3010496 100644
--- a/drivers/media/usb/tlg2300/pd-common.h
+++ b/drivers/media/usb/tlg2300/pd-common.h
@@ -26,7 +26,6 @@
 #define POSEIDON_STATE_ANALOG		(0x0001)
 #define POSEIDON_STATE_FM		(0x0002)
 #define POSEIDON_STATE_DVBT		(0x0004)
-#define POSEIDON_STATE_VBI		(0x0008)
 #define POSEIDON_STATE_DISCONNECT	(0x0080)
 
 #define PM_SUSPEND_DELAY	3
diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index 4c045b3..834428d 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -1352,12 +1352,14 @@ static int pd_video_open(struct file *file)
 	mutex_lock(&pd->lock);
 	usb_autopm_get_interface(pd->interface);
 
-	if (vfd->vfl_type == VFL_TYPE_GRABBER
-		&& !(pd->state & POSEIDON_STATE_ANALOG)) {
-		front = kzalloc(sizeof(struct front_face), GFP_KERNEL);
-		if (!front)
-			goto out;
-
+	if (pd->state && !(pd->state & POSEIDON_STATE_ANALOG)) {
+		ret = -EBUSY;
+		goto out;
+	}
+	front = kzalloc(sizeof(struct front_face), GFP_KERNEL);
+	if (!front)
+		goto out;
+	if (vfd->vfl_type == VFL_TYPE_GRABBER) {
 		pd->cur_transfer_mode	= usb_transfer_mode;/* bulk or iso */
 		init_video_context(&pd->video_data.context);
 
@@ -1368,7 +1370,6 @@ static int pd_video_open(struct file *file)
 			goto out;
 		}
 
-		pd->state		|= POSEIDON_STATE_ANALOG;
 		front->type		= V4L2_BUF_TYPE_VIDEO_CAPTURE;
 		pd->video_data.users++;
 		set_debug_mode(vfd, debug_mode);
@@ -1379,13 +1380,7 @@ static int pd_video_open(struct file *file)
 				V4L2_FIELD_INTERLACED,/* video is interlacd */
 				sizeof(struct videobuf_buffer),/*it's enough*/
 				front, NULL);
-	} else if (vfd->vfl_type == VFL_TYPE_VBI
-		&& !(pd->state & POSEIDON_STATE_VBI)) {
-		front = kzalloc(sizeof(struct front_face), GFP_KERNEL);
-		if (!front)
-			goto out;
-
-		pd->state	|= POSEIDON_STATE_VBI;
+	} else {
 		front->type	= V4L2_BUF_TYPE_VBI_CAPTURE;
 		pd->vbi_data.front = front;
 		pd->vbi_data.users++;
@@ -1396,19 +1391,15 @@ static int pd_video_open(struct file *file)
 				V4L2_FIELD_NONE, /* vbi is NONE mode */
 				sizeof(struct videobuf_buffer),
 				front, NULL);
-	} else {
-		/* maybe add FM support here */
-		log("other ");
-		ret = -EINVAL;
-		goto out;
 	}
 
-	front->pd		= pd;
-	front->curr_frame	= NULL;
+	pd->state |= POSEIDON_STATE_ANALOG;
+	front->pd = pd;
+	front->curr_frame = NULL;
 	INIT_LIST_HEAD(&front->active);
 	spin_lock_init(&front->queue_lock);
 
-	file->private_data	= front;
+	file->private_data = front;
 	kref_get(&pd->kref);
 
 	mutex_unlock(&pd->lock);
@@ -1429,8 +1420,6 @@ static int pd_video_release(struct file *file)
 	mutex_lock(&pd->lock);
 
 	if (front->type	== V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-		pd->state &= ~POSEIDON_STATE_ANALOG;
-
 		/* stop the device, and free the URBs */
 		usb_transfer_stop(&pd->video_data);
 		free_all_urb(&pd->video_data);
@@ -1442,10 +1431,11 @@ static int pd_video_release(struct file *file)
 		pd->file_for_stream = NULL;
 		pd->video_data.users--;
 	} else if (front->type	== V4L2_BUF_TYPE_VBI_CAPTURE) {
-		pd->state &= ~POSEIDON_STATE_VBI;
 		pd->vbi_data.front = NULL;
 		pd->vbi_data.users--;
 	}
+	if (!pd->vbi_data.users && !pd->video_data.users)
+		pd->state &= ~POSEIDON_STATE_ANALOG;
 	videobuf_stop(&front->q);
 	videobuf_mmap_free(&front->q);
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 17/18] tlg2300: Remove logs() macro.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (14 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 16/18] tlg2300: allow multiple opens Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:54     ` Huang Shijie
  2013-01-31 10:25   ` [RFC PATCH 18/18] tlg2300: update MAINTAINERS file Hans Verkuil
  2013-02-04  2:40   ` [RFC PATCH 01/18] tlg2300: use correct device parent Huang Shijie
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

ioctl debugging can now be done through the debug parameter in sysfs.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 drivers/media/usb/tlg2300/pd-common.h |    9 ---------
 drivers/media/usb/tlg2300/pd-video.c  |   23 ++---------------------
 2 files changed, 2 insertions(+), 30 deletions(-)

diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
index 3010496..9e23ad32 100644
--- a/drivers/media/usb/tlg2300/pd-common.h
+++ b/drivers/media/usb/tlg2300/pd-common.h
@@ -268,13 +268,4 @@ void set_debug_mode(struct video_device *vfd, int debug_mode);
 				log();\
 		} while (0)
 
-#define logs(f) do { \
-			if ((debug_mode & 0x4) && \
-				(f)->type == V4L2_BUF_TYPE_VBI_CAPTURE) \
-					log("type : VBI");\
-								\
-			if ((debug_mode & 0x8) && \
-				(f)->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) \
-					log("type : VIDEO");\
-		} while (0)
 #endif
diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
index 834428d..dab0ca3 100644
--- a/drivers/media/usb/tlg2300/pd-video.c
+++ b/drivers/media/usb/tlg2300/pd-video.c
@@ -120,9 +120,6 @@ static int vidioc_querycap(struct file *file, void *fh,
 {
 	struct video_device *vdev = video_devdata(file);
 	struct poseidon *p = video_get_drvdata(vdev);
-	struct front_face *front = fh;
-
-	logs(front);
 
 	strcpy(cap->driver, "tele-video");
 	strcpy(cap->card, "Telegent Poseidon");
@@ -205,7 +202,6 @@ static void submit_frame(struct front_face *front)
  */
 static void end_field(struct video_data *video)
 {
-	/* logs(video->front); */
 	if (1 == video->field_count)
 		submit_frame(video->front);
 	else
@@ -700,7 +696,6 @@ static int vidioc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
 	struct front_face *front = fh;
 	struct poseidon *pd = front->pd;
 
-	logs(front);
 	f->fmt.pix = pd->video_data.context.pix;
 	return 0;
 }
@@ -763,7 +758,6 @@ static int vidioc_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
 	struct front_face *front	= fh;
 	struct poseidon *pd		= front->pd;
 
-	logs(front);
 	/* stop VBI here */
 	if (V4L2_BUF_TYPE_VIDEO_CAPTURE != f->type)
 		return -EINVAL;
@@ -804,7 +798,6 @@ static int vidioc_g_fmt_vbi(struct file *file, void *fh,
 		vbi_fmt->count[1] = V4L_PAL_VBI_LINES;
 	}
 	vbi_fmt->flags = V4L2_VBI_UNSYNC;
-	logs(front);
 	return 0;
 }
 
@@ -856,22 +849,20 @@ out:
 static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *norm)
 {
 	struct front_face *front = fh;
-	logs(front);
+
 	return set_std(front->pd, norm);
 }
 
 static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm)
 {
 	struct front_face *front = fh;
-	logs(front);
+
 	*norm = front->pd->video_data.context.tvnormid;
 	return 0;
 }
 
 static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
 {
-	struct front_face *front = fh;
-
 	if (in->index >= POSEIDON_INPUTS)
 		return -EINVAL;
 	strcpy(in->name, pd_inputs[in->index].name);
@@ -885,7 +876,6 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
 	in->tuner	= 0;
 	in->std		= V4L2_STD_ALL;
 	in->status	= 0;
-	logs(front);
 	return 0;
 }
 
@@ -895,7 +885,6 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *i)
 	struct poseidon *pd = front->pd;
 	struct running_context *context = &pd->video_data.context;
 
-	logs(front);
 	*i = context->sig_index;
 	return 0;
 }
@@ -1023,7 +1012,6 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *tuner)
 	tuner->rxsubchans = pd_audio_modes[index].v4l2_audio_sub;
 	tuner->audmode = pd_audio_modes[index].v4l2_audio_mode;
 	tuner->afc = 0;
-	logs(front);
 	return 0;
 }
 
@@ -1051,7 +1039,6 @@ static int vidioc_s_tuner(struct file *file, void *fh, struct v4l2_tuner *a)
 
 	if (0 != a->index)
 		return -EINVAL;
-	logs(front);
 	for (index = 0; index < POSEIDON_AUDIOMODS; index++)
 		if (a->audmode == pd_audio_modes[index].v4l2_audio_mode)
 			return pd_vidioc_s_tuner(pd, index);
@@ -1099,7 +1086,6 @@ static int vidioc_s_frequency(struct file *file, void *fh,
 
 	if (freq->tuner)
 		return -EINVAL;
-	logs(front);
 #ifdef CONFIG_PM
 	pd->pm_suspend = pm_video_suspend;
 	pd->pm_resume = pm_video_resume;
@@ -1111,14 +1097,12 @@ static int vidioc_reqbufs(struct file *file, void *fh,
 				struct v4l2_requestbuffers *b)
 {
 	struct front_face *front = file->private_data;
-	logs(front);
 	return videobuf_reqbufs(&front->q, b);
 }
 
 static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
 {
 	struct front_face *front = file->private_data;
-	logs(front);
 	return videobuf_querybuf(&front->q, b);
 }
 
@@ -1207,7 +1191,6 @@ static int vidioc_streamon(struct file *file, void *fh,
 {
 	struct front_face *front = fh;
 
-	logs(front);
 	if (unlikely(type != front->type))
 		return -EINVAL;
 	return videobuf_streamon(&front->q);
@@ -1218,7 +1201,6 @@ static int vidioc_streamoff(struct file *file, void *fh,
 {
 	struct front_face *front = file->private_data;
 
-	logs(front);
 	if (unlikely(type != front->type))
 		return -EINVAL;
 	return videobuf_streamoff(&front->q);
@@ -1416,7 +1398,6 @@ static int pd_video_release(struct file *file)
 	struct poseidon *pd = front->pd;
 	s32 cmd_status = 0;
 
-	logs(front);
 	mutex_lock(&pd->lock);
 
 	if (front->type	== V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* [RFC PATCH 18/18] tlg2300: update MAINTAINERS file.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (15 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 17/18] tlg2300: Remove logs() macro Hans Verkuil
@ 2013-01-31 10:25   ` Hans Verkuil
  2013-02-04  4:55     ` Huang Shijie
  2013-02-04  2:40   ` [RFC PATCH 01/18] tlg2300: use correct device parent Huang Shijie
  17 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-01-31 10:25 UTC (permalink / raw)
  To: linux-media; +Cc: Huang Shijie, Hans Verkuil

From: Hans Verkuil <hans.verkuil@cisco.com>

Remove two maintainers: telegent.com no longer exists, so those email
addresses are invalid as well.

Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
---
 MAINTAINERS |    2 --
 1 file changed, 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index 975ba7c..00bb196 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -6778,8 +6778,6 @@ F:	drivers/clocksource
 
 TLG2300 VIDEO4LINUX-2 DRIVER
 M:	Huang Shijie <shijie8@gmail.com>
-M:	Kang Yong <kangyong@telegent.com>
-M:	Zhang Xiaobing <xbzhang@telegent.com>
 S:	Supported
 F:	drivers/media/usb/tlg2300
 
-- 
1.7.10.4


^ permalink raw reply related	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes
  2013-01-31 10:25 [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes Hans Verkuil
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
@ 2013-02-01  2:22 ` Huang Shijie
  2013-02-01  7:49   ` Hans Verkuil
  1 sibling, 1 reply; 49+ messages in thread
From: Huang Shijie @ 2013-02-01  2:22 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media

Hi Hans:

On Thu, Jan 31, 2013 at 6:25 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> Hi all,
>
> Last year I worked on this driver to improve it and fix v4l2-compliance
> issues.

I am glad to know that there are still some people use the
tlg2300. thanks a lot.

>
> It required a lot of effort to even find a USB stick with this chipset
> (telegent no longer exists) and unfortunately at some point I managed
> to break the USB stick, so I am no longer able to work on it.
>
> This patch series represents that part of the work I've done that has
> been tested. I have additional patches in my tlg2300-wip branch:
>
> http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/tlg2300-wip
>
> but since I am no longer certain at what point in those remaining patches
> things broke down I've decided not to post them for upstreaming. If I or
> someone else ever manages to get a working tlg2300 that code might be used
> for further work.

Could you tell me how did you test your patch set?
did you test the hibernate and suspend/resume?




>
> Huang Shijie, are you still able to act as maintainer? If not, then I can
> put my name in. The MAINTAINER status should probably move to 'Odd Fixes'

Yes, you can put your name in.
I am busy some other drivers recently.

thanks
Huang Shijie

> as well.
>
> Regards,
>
>         Hans
>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes
  2013-02-01  2:22 ` [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes Huang Shijie
@ 2013-02-01  7:49   ` Hans Verkuil
  2013-02-01  8:02     ` Huang Shijie
  0 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-02-01  7:49 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-media

On Fri February 1 2013 03:22:22 Huang Shijie wrote:
> Hi Hans:
> 
> On Thu, Jan 31, 2013 at 6:25 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> > Hi all,
> >
> > Last year I worked on this driver to improve it and fix v4l2-compliance
> > issues.
> 
> I am glad to know that there are still some people use the
> tlg2300. thanks a lot.
> 
> >
> > It required a lot of effort to even find a USB stick with this chipset
> > (telegent no longer exists) and unfortunately at some point I managed
> > to break the USB stick, so I am no longer able to work on it.
> >
> > This patch series represents that part of the work I've done that has
> > been tested. I have additional patches in my tlg2300-wip branch:
> >
> > http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/tlg2300-wip
> >
> > but since I am no longer certain at what point in those remaining patches
> > things broke down I've decided not to post them for upstreaming. If I or
> > someone else ever manages to get a working tlg2300 that code might be used
> > for further work.
> 
> Could you tell me how did you test your patch set?

I used the v4l2-compliance tool which we use to validate drivers. It's part of
v4l-utils.git: http://git.linuxtv.org/v4l-utils.git


> did you test the hibernate and suspend/resume?

No, it was on my todo list but the stick broke before I had a chance to test it.
However, none of the patches touch on suspend/resume.

> > Huang Shijie, are you still able to act as maintainer? If not, then I can
> > put my name in. The MAINTAINER status should probably move to 'Odd Fixes'
> 
> Yes, you can put your name in.

OK, I'll update that patch.

Regards,

	Hans

> I am busy some other drivers recently.
> 
> thanks
> Huang Shijie
> 
> > as well.
> >
> > Regards,
> >
> >         Hans
> >
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes
  2013-02-01  7:49   ` Hans Verkuil
@ 2013-02-01  8:02     ` Huang Shijie
  2013-02-01  8:07       ` Hans Verkuil
  0 siblings, 1 reply; 49+ messages in thread
From: Huang Shijie @ 2013-02-01  8:02 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media

On Fri, Feb 1, 2013 at 3:49 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> On Fri February 1 2013 03:22:22 Huang Shijie wrote:
>> Hi Hans:
>>
>> On Thu, Jan 31, 2013 at 6:25 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
>> > Hi all,
>> >
>> > Last year I worked on this driver to improve it and fix v4l2-compliance
>> > issues.
>>
>> I am glad to know that there are still some people use the
>> tlg2300. thanks a lot.
>>
>> >
>> > It required a lot of effort to even find a USB stick with this chipset
>> > (telegent no longer exists) and unfortunately at some point I managed
>> > to break the USB stick, so I am no longer able to work on it.
>> >
>> > This patch series represents that part of the work I've done that has
>> > been tested. I have additional patches in my tlg2300-wip branch:
>> >
>> > http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/tlg2300-wip
>> >
>> > but since I am no longer certain at what point in those remaining patches
>> > things broke down I've decided not to post them for upstreaming. If I or
>> > someone else ever manages to get a working tlg2300 that code might be used
>> > for further work.
>>
>> Could you tell me how did you test your patch set?
>
> I used the v4l2-compliance tool which we use to validate drivers. It's part of
> v4l-utils.git: http://git.linuxtv.org/v4l-utils.git
>
>

ok.

>> did you test the hibernate and suspend/resume?
>
> No, it was on my todo list but the stick broke before I had a chance to test it.
> However, none of the patches touch on suspend/resume.
>
Could you test the hibernate and suspend with your patch
set (hibernate when the gmplayer is playing the tv). And if you do not
meet any issue, please send the patch set out again.

thanks a lot.

thanks
Huang Shijie

>> > Huang Shijie, are you still able to act as maintainer? If not, then I can
>> > put my name in. The MAINTAINER status should probably move to 'Odd Fixes'
>>
>> Yes, you can put your name in.
>
> OK, I'll update that patch.
>
> Regards,
>
>         Hans
>
>> I am busy some other drivers recently.
>>
>> thanks
>> Huang Shijie
>>
>> > as well.
>> >
>> > Regards,
>> >
>> >         Hans
>> >
>>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes
  2013-02-01  8:02     ` Huang Shijie
@ 2013-02-01  8:07       ` Hans Verkuil
  0 siblings, 0 replies; 49+ messages in thread
From: Hans Verkuil @ 2013-02-01  8:07 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-media

On Fri February 1 2013 09:02:13 Huang Shijie wrote:
> On Fri, Feb 1, 2013 at 3:49 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> > On Fri February 1 2013 03:22:22 Huang Shijie wrote:
> >> Hi Hans:
> >>
> >> On Thu, Jan 31, 2013 at 6:25 PM, Hans Verkuil <hverkuil@xs4all.nl> wrote:
> >> > Hi all,
> >> >
> >> > Last year I worked on this driver to improve it and fix v4l2-compliance
> >> > issues.
> >>
> >> I am glad to know that there are still some people use the
> >> tlg2300. thanks a lot.
> >>
> >> >
> >> > It required a lot of effort to even find a USB stick with this chipset
> >> > (telegent no longer exists) and unfortunately at some point I managed
> >> > to break the USB stick, so I am no longer able to work on it.
> >> >
> >> > This patch series represents that part of the work I've done that has
> >> > been tested. I have additional patches in my tlg2300-wip branch:
> >> >
> >> > http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/tlg2300-wip
> >> >
> >> > but since I am no longer certain at what point in those remaining patches
> >> > things broke down I've decided not to post them for upstreaming. If I or
> >> > someone else ever manages to get a working tlg2300 that code might be used
> >> > for further work.
> >>
> >> Could you tell me how did you test your patch set?
> >
> > I used the v4l2-compliance tool which we use to validate drivers. It's part of
> > v4l-utils.git: http://git.linuxtv.org/v4l-utils.git
> >
> >
> 
> ok.
> 
> >> did you test the hibernate and suspend/resume?
> >
> > No, it was on my todo list but the stick broke before I had a chance to test it.
> > However, none of the patches touch on suspend/resume.
> >
> Could you test the hibernate and suspend with your patch
> set (hibernate when the gmplayer is playing the tv). And if you do not
> meet any issue, please send the patch set out again.

As I told you, my USB stick died. I can't test this anymore.

Regards,

	Hans

> 
> thanks a lot.
> 
> thanks
> Huang Shijie
> 
> >> > Huang Shijie, are you still able to act as maintainer? If not, then I can
> >> > put my name in. The MAINTAINER status should probably move to 'Odd Fixes'
> >>
> >> Yes, you can put your name in.
> >
> > OK, I'll update that patch.
> >
> > Regards,
> >
> >         Hans
> >
> >> I am busy some other drivers recently.
> >>
> >> thanks
> >> Huang Shijie
> >>
> >> > as well.
> >> >
> >> > Regards,
> >> >
> >> >         Hans
> >> >
> >>
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 01/18] tlg2300: use correct device parent.
  2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
                     ` (16 preceding siblings ...)
  2013-01-31 10:25   ` [RFC PATCH 18/18] tlg2300: update MAINTAINERS file Hans Verkuil
@ 2013-02-04  2:40   ` Huang Shijie
  2013-02-04  8:40     ` Hans Verkuil
  17 siblings, 1 reply; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  2:40 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Set the correct parent for v4l2_device_register. Also remove an unnecessary
> forward reference and fix two weird looking log messages.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-main.c |    9 ++++-----
>  1 file changed, 4 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-main.c b/drivers/media/usb/tlg2300/pd-main.c
> index 7b1f6eb..c4eb57a 100644
> --- a/drivers/media/usb/tlg2300/pd-main.c
> +++ b/drivers/media/usb/tlg2300/pd-main.c
> @@ -55,7 +55,6 @@ MODULE_PARM_DESC(debug_mode, "0 = disable, 1 = enable, 2 = verbose");
>  
>  #define TLG2300_FIRMWARE "tlg2300_firmware.bin"
>  static const char *firmware_name = TLG2300_FIRMWARE;
> -static struct usb_driver poseidon_driver;
>  static LIST_HEAD(pd_device_list);
>  
>  /*
> @@ -316,7 +315,7 @@ static int poseidon_suspend(struct usb_interface *intf, pm_message_t msg)
>  		if (get_pm_count(pd) <= 0 && !in_hibernation(pd)) {
>  			pd->msg.event = PM_EVENT_AUTO_SUSPEND;
>  			pd->pm_resume = NULL; /*  a good guard */
> -			printk(KERN_DEBUG "\n\t+ TLG2300 auto suspend +\n\n");
> +			printk(KERN_DEBUG "TLG2300 auto suspend\n");
>  		}
>  		return 0;
>  	}
> @@ -331,7 +330,7 @@ static int poseidon_resume(struct usb_interface *intf)
>  
>  	if (!pd)
>  		return 0;
> -	printk(KERN_DEBUG "\n\t ++ TLG2300 resume ++\n\n");
> +	printk(KERN_DEBUG "TLG2300 resume\n");
>  
>  	if (!is_working(pd)) {
>  		if (PM_EVENT_AUTO_SUSPEND == pd->msg.event)
> @@ -439,7 +438,7 @@ static int poseidon_probe(struct usb_interface *interface,
>  		/* register v4l2 device */
>  		snprintf(pd->v4l2_dev.name, sizeof(pd->v4l2_dev.name), "%s %s",
>  			dev->driver->name, dev_name(dev));
I think this line could be removed in this patch too. The
v4l2_device_register() will assign the v4l2_dev->name if it's empty.

thanks
Huang Shijie
> -		ret = v4l2_device_register(NULL, &pd->v4l2_dev);
> +		ret = v4l2_device_register(&interface->dev, &pd->v4l2_dev);
>  
>  		/* register devices in directory /dev */
>  		ret = pd_video_init(pd);
> @@ -530,7 +529,7 @@ module_init(poseidon_init);
>  module_exit(poseidon_exit);
>  
>  MODULE_AUTHOR("Telegent Systems");
> -MODULE_DESCRIPTION("For tlg2300-based USB device ");
> +MODULE_DESCRIPTION("For tlg2300-based USB device");
>  MODULE_LICENSE("GPL");
>  MODULE_VERSION("0.0.2");
>  MODULE_FIRMWARE(TLG2300_FIRMWARE);


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 02/18] tlg2300: fix tuner and frequency handling of the radio device.
  2013-01-31 10:25   ` [RFC PATCH 02/18] tlg2300: fix tuner and frequency handling of the radio device Hans Verkuil
@ 2013-02-04  3:46     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  3:46 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> This driver now passes the tuner and frequency tests of v4l2-compliance.
>
> It's the usual bugs: frequency wasn't clamped to the valid frequency range,
> incorrect tuner capabilities and tuner fields not filled in, missing test
> for invalid tuner index, no initial frequency and incorrect error handling.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-radio.c |   37 +++++++++++++++++++---------------
>  1 file changed, 21 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index 25eeb16..90dc1d1 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -18,8 +18,8 @@ static int set_frequency(struct poseidon *p, __u32 frequency);
>  static int poseidon_fm_close(struct file *filp);
>  static int poseidon_fm_open(struct file *filp);
>  
> -#define TUNER_FREQ_MIN_FM 76000000
> -#define TUNER_FREQ_MAX_FM 108000000
> +#define TUNER_FREQ_MIN_FM 76000000U
> +#define TUNER_FREQ_MAX_FM 108000000U
>  
>  #define MAX_PREEMPHASIS (V4L2_PREEMPHASIS_75_uS + 1)
>  static int preemphasis[MAX_PREEMPHASIS] = {
> @@ -170,13 +170,14 @@ static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
>  		return -EINVAL;
>  
>  	vt->type	= V4L2_TUNER_RADIO;
> -	vt->capability	= V4L2_TUNER_CAP_STEREO;
> -	vt->rangelow	= TUNER_FREQ_MIN_FM / 62500;
> -	vt->rangehigh	= TUNER_FREQ_MAX_FM / 62500;
> +	vt->capability	= V4L2_TUNER_CAP_STEREO | V4L2_TUNER_CAP_LOW;
> +	vt->rangelow	= TUNER_FREQ_MIN_FM * 2 / 125;
> +	vt->rangehigh	= TUNER_FREQ_MAX_FM * 2 / 125;
>  	vt->rxsubchans	= V4L2_TUNER_SUB_STEREO;
>  	vt->audmode	= V4L2_TUNER_MODE_STEREO;
>  	vt->signal	= 0;
>  	vt->afc 	= 0;
> +	strlcpy(vt->name, "Radio", sizeof(vt->name));
>  
>  	mutex_lock(&p->lock);
>  	ret = send_get_req(p, TUNER_STATUS, TLG_MODE_FM_RADIO,
> @@ -207,6 +208,8 @@ static int fm_get_freq(struct file *file, void *priv,
>  {
>  	struct poseidon *p = file->private_data;
>  
> +	if (argp->tuner)
> +		return -EINVAL;
>  	argp->frequency = p->radio_data.fm_freq;
>  	return 0;
>  }
> @@ -221,11 +224,8 @@ static int set_frequency(struct poseidon *p, __u32 frequency)
>  	ret = send_set_req(p, TUNER_AUD_ANA_STD,
>  				p->radio_data.pre_emphasis, &status);
>  
> -	freq =  (frequency * 125) * 500 / 1000;/* kHZ */
> -	if (freq < TUNER_FREQ_MIN_FM/1000 || freq > TUNER_FREQ_MAX_FM/1000) {
> -		ret = -EINVAL;
> -		goto error;
> -	}
> +	freq = (frequency * 125) / 2; /* Hz */
> +	freq = clamp(freq, TUNER_FREQ_MIN_FM, TUNER_FREQ_MAX_FM);
>  
>  	ret = send_set_req(p, TUNE_FREQ_SELECT, freq, &status);
>  	if (ret < 0)
> @@ -240,7 +240,7 @@ static int set_frequency(struct poseidon *p, __u32 frequency)
>  				TLG_TUNE_PLAY_SVC_START, &status);
>  		p->radio_data.is_radio_streaming = 1;
>  	}
> -	p->radio_data.fm_freq = frequency;
> +	p->radio_data.fm_freq = freq * 2 / 125;
>  error:
>  	mutex_unlock(&p->lock);
>  	return ret;
> @@ -251,7 +251,9 @@ static int fm_set_freq(struct file *file, void *priv,
>  {
>  	struct poseidon *p = file->private_data;
>  
> -	p->file_for_stream  = file;
> +	if (argp->tuner)
> +		return -EINVAL;
> +	p->file_for_stream = file;
>  #ifdef CONFIG_PM
>  	p->pm_suspend = pm_fm_suspend;
>  	p->pm_resume  = pm_fm_resume;
> @@ -401,16 +403,19 @@ static struct video_device poseidon_fm_template = {
>  int poseidon_fm_init(struct poseidon *p)
>  {
>  	struct video_device *fm_dev;
> +	int err;
>  
>  	fm_dev = vdev_init(p, &poseidon_fm_template);
>  	if (fm_dev == NULL)
> -		return -1;
> +		return -ENOMEM;
>  
> -	if (video_register_device(fm_dev, VFL_TYPE_RADIO, -1) < 0) {
> +	p->radio_data.fm_dev = fm_dev;
> +	set_frequency(p, TUNER_FREQ_MIN_FM);
> +	err = video_register_device(fm_dev, VFL_TYPE_RADIO, -1);
> +	if (err < 0) {
>  		video_device_release(fm_dev);
> -		return -1;
> +		return err;
>  	}
> -	p->radio_data.fm_dev = fm_dev;
>  	return 0;
>  }
>  
thanks.

Acked-by: Huang Shijie <shijie8@gmail.com>




^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 03/18] tlg2300: switch to unlocked_ioctl.
  2013-01-31 10:25   ` [RFC PATCH 03/18] tlg2300: switch to unlocked_ioctl Hans Verkuil
@ 2013-02-04  3:48     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  3:48 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> The driver already does locking, so it is safe to switch to unlocked_ioctl.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-radio.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index 90dc1d1..c4feffb 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -156,7 +156,7 @@ static const struct v4l2_file_operations poseidon_fm_fops = {
>  	.owner         = THIS_MODULE,
>  	.open          = poseidon_fm_open,
>  	.release       = poseidon_fm_close,
> -	.ioctl	       = video_ioctl2,
> +	.unlocked_ioctl = video_ioctl2,
>  };
>  
>  static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices.
  2013-01-31 10:25   ` [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices Hans Verkuil
@ 2013-02-04  4:16     ` Huang Shijie
  2013-02-04  8:34       ` Hans Verkuil
  2013-02-05  4:03     ` Huang Shijie
  1 sibling, 1 reply; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:16 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> The input and audio ioctls are only valid for video/vbi nodes.

I remember that if you do not set these ioctrls, the mplayer will not works.

I can not download the mplayer in my home, so i can not test it.
I will test it in my office.

thanks
Huang Shijie

> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-radio.c |   27 ---------------------------
>  1 file changed, 27 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index c4feffb..4c76e089 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -350,36 +350,9 @@ static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *vt)
>  {
>  	return vt->index > 0 ? -EINVAL : 0;
>  }
> -static int vidioc_s_audio(struct file *file, void *priv, const struct v4l2_audio *va)
> -{
> -	return (va->index != 0) ? -EINVAL : 0;
> -}
> -
> -static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
> -{
> -	a->index    = 0;
> -	a->mode    = 0;
> -	a->capability = V4L2_AUDCAP_STEREO;
> -	strcpy(a->name, "Radio");
> -	return 0;
> -}
> -
> -static int vidioc_s_input(struct file *filp, void *priv, u32 i)
> -{
> -	return (i != 0) ? -EINVAL : 0;
> -}
> -
> -static int vidioc_g_input(struct file *filp, void *priv, u32 *i)
> -{
> -	return (*i != 0) ? -EINVAL : 0;
> -}
>  
>  static const struct v4l2_ioctl_ops poseidon_fm_ioctl_ops = {
>  	.vidioc_querycap    = vidioc_querycap,
> -	.vidioc_g_audio     = vidioc_g_audio,
> -	.vidioc_s_audio     = vidioc_s_audio,
> -	.vidioc_g_input     = vidioc_g_input,
> -	.vidioc_s_input     = vidioc_s_input,
>  	.vidioc_queryctrl   = tlg_fm_vidioc_queryctrl,
>  	.vidioc_querymenu   = tlg_fm_vidioc_querymenu,
>  	.vidioc_g_ctrl      = tlg_fm_vidioc_g_ctrl,


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 05/18] tlg2300: embed video_device instead of allocating it.
  2013-01-31 10:25   ` [RFC PATCH 05/18] tlg2300: embed video_device instead of allocating it Hans Verkuil
@ 2013-02-04  4:26     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:26 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-common.h |    2 +-
>  drivers/media/usb/tlg2300/pd-radio.c  |   20 ++++++--------------
>  2 files changed, 7 insertions(+), 15 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
> index 5dd73b7..3a89128 100644
> --- a/drivers/media/usb/tlg2300/pd-common.h
> +++ b/drivers/media/usb/tlg2300/pd-common.h
> @@ -118,7 +118,7 @@ struct radio_data {
>  	int		users;
>  	unsigned int	is_radio_streaming;
>  	int		pre_emphasis;
> -	struct video_device *fm_dev;
> +	struct video_device fm_dev;
>  };
>  
>  #define DVB_SBUF_NUM		4
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index 4c76e089..719c3da 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -369,31 +369,23 @@ static struct video_device poseidon_fm_template = {
>  	.name       = "Telegent-Radio",
>  	.fops       = &poseidon_fm_fops,
>  	.minor      = -1,
> -	.release    = video_device_release,
> +	.release    = video_device_release_empty,
>  	.ioctl_ops  = &poseidon_fm_ioctl_ops,
>  };
>  
>  int poseidon_fm_init(struct poseidon *p)
>  {
> -	struct video_device *fm_dev;
> -	int err;
> +	struct video_device *vfd = &p->radio_data.fm_dev;
>  
> -	fm_dev = vdev_init(p, &poseidon_fm_template);
> -	if (fm_dev == NULL)
> -		return -ENOMEM;
> +	*vfd = poseidon_fm_template;
> +	vfd->v4l2_dev	= &p->v4l2_dev;
> +	video_set_drvdata(vfd, p);
>  
> -	p->radio_data.fm_dev = fm_dev;
>  	set_frequency(p, TUNER_FREQ_MIN_FM);
> -	err = video_register_device(fm_dev, VFL_TYPE_RADIO, -1);
> -	if (err < 0) {
> -		video_device_release(fm_dev);
> -		return err;
> -	}
> -	return 0;
> +	return video_register_device(vfd, VFL_TYPE_RADIO, -1);
>  }
>  
>  int poseidon_fm_exit(struct poseidon *p)
>  {
> -	destroy_video_device(&p->radio_data.fm_dev);
>  	return 0;
>  }
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 07/18] tlg2300: switch to v4l2_fh.
  2013-01-31 10:25   ` [RFC PATCH 07/18] tlg2300: switch to v4l2_fh Hans Verkuil
@ 2013-02-04  4:32     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:32 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> This switch to v4l2_fh resolves the last v4l2_compliance issues with respect
> to control events and priority handling.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-common.h |    1 -
>  drivers/media/usb/tlg2300/pd-main.c   |    3 ++-
>  drivers/media/usb/tlg2300/pd-radio.c  |   35 ++++++++++++++++++---------------
>  3 files changed, 21 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
> index b26082a..67ad065 100644
> --- a/drivers/media/usb/tlg2300/pd-common.h
> +++ b/drivers/media/usb/tlg2300/pd-common.h
> @@ -116,7 +116,6 @@ struct poseidon_audio {
>  
>  struct radio_data {
>  	__u32		fm_freq;
> -	int		users;
>  	unsigned int	is_radio_streaming;
>  	int		pre_emphasis;
>  	struct video_device fm_dev;
> diff --git a/drivers/media/usb/tlg2300/pd-main.c b/drivers/media/usb/tlg2300/pd-main.c
> index c4eb57a..5be5a73 100644
> --- a/drivers/media/usb/tlg2300/pd-main.c
> +++ b/drivers/media/usb/tlg2300/pd-main.c
> @@ -267,7 +267,8 @@ static inline void set_map_flags(struct poseidon *pd, struct usb_device *udev)
>  static inline int get_autopm_ref(struct poseidon *pd)
>  {
>  	return  pd->video_data.users + pd->vbi_data.users + pd->audio.users
> -		+ atomic_read(&pd->dvb_data.users) + pd->radio_data.users;
> +		+ atomic_read(&pd->dvb_data.users) +
> +		!list_empty(&pd->radio_data.fm_dev.fh_list);
>  }
>  
>  /* fixup something for poseidon */
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index 45b3d7a..854ffa0 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -9,6 +9,8 @@
>  #include <linux/mm.h>
>  #include <linux/mutex.h>
>  #include <media/v4l2-ioctl.h>
> +#include <media/v4l2-event.h>
> +#include <media/v4l2-fh.h>
>  #include <linux/sched.h>
>  
>  #include "pd-common.h"
> @@ -77,13 +79,9 @@ static int pm_fm_resume(struct poseidon *p)
>  
>  static int poseidon_fm_open(struct file *filp)
>  {
> -	struct video_device *vfd = video_devdata(filp);
> -	struct poseidon *p = video_get_drvdata(vfd);
> +	struct poseidon *p = video_drvdata(filp);
>  	int ret = 0;
>  
> -	if (!p)
> -		return -1;
> -
>  	mutex_lock(&p->lock);
>  	if (p->state & POSEIDON_STATE_DISCONNECT) {
>  		ret = -ENODEV;
> @@ -94,9 +92,14 @@ static int poseidon_fm_open(struct file *filp)
>  		ret = -EBUSY;
>  		goto out;
>  	}
> +	ret = v4l2_fh_open(filp);
> +	if (ret)
> +		goto out;
>  
>  	usb_autopm_get_interface(p->interface);
>  	if (0 == p->state) {
> +		struct video_device *vfd = &p->radio_data.fm_dev;
> +
>  		/* default pre-emphasis */
>  		if (p->radio_data.pre_emphasis == 0)
>  			p->radio_data.pre_emphasis = TLG_TUNE_ASTD_FM_EUR;
> @@ -109,9 +112,7 @@ static int poseidon_fm_open(struct file *filp)
>  		}
>  		p->state |= POSEIDON_STATE_FM;
>  	}
> -	p->radio_data.users++;
>  	kref_get(&p->kref);
> -	filp->private_data = p;
>  out:
>  	mutex_unlock(&p->lock);
>  	return ret;
> @@ -119,13 +120,12 @@ out:
>  
>  static int poseidon_fm_close(struct file *filp)
>  {
> -	struct poseidon *p = filp->private_data;
> +	struct poseidon *p = video_drvdata(filp);
>  	struct radio_data *fm = &p->radio_data;
>  	uint32_t status;
>  
>  	mutex_lock(&p->lock);
> -	fm->users--;
> -	if (0 == fm->users)
> +	if (v4l2_fh_is_singular_file(filp))
>  		p->state &= ~POSEIDON_STATE_FM;
>  
>  	if (fm->is_radio_streaming && filp == p->file_for_stream) {
> @@ -136,14 +136,13 @@ static int poseidon_fm_close(struct file *filp)
>  	mutex_unlock(&p->lock);
>  
>  	kref_put(&p->kref, poseidon_delete);
> -	filp->private_data = NULL;
> -	return 0;
> +	return v4l2_fh_release(filp);
>  }
>  
>  static int vidioc_querycap(struct file *file, void *priv,
>  			struct v4l2_capability *v)
>  {
> -	struct poseidon *p = file->private_data;
> +	struct poseidon *p = video_drvdata(file);
>  
>  	strlcpy(v->driver, "tele-radio", sizeof(v->driver));
>  	strlcpy(v->card, "Telegent Poseidon", sizeof(v->card));
> @@ -156,15 +155,16 @@ static const struct v4l2_file_operations poseidon_fm_fops = {
>  	.owner         = THIS_MODULE,
>  	.open          = poseidon_fm_open,
>  	.release       = poseidon_fm_close,
> +	.poll		= v4l2_ctrl_poll,
>  	.unlocked_ioctl = video_ioctl2,
>  };
>  
>  static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
>  				 struct v4l2_tuner *vt)
>  {
> +	struct poseidon *p = video_drvdata(file);
>  	struct tuner_fm_sig_stat_s fm_stat = {};
>  	int ret, status, count = 5;
> -	struct poseidon *p = file->private_data;
>  
>  	if (vt->index != 0)
>  		return -EINVAL;
> @@ -206,7 +206,7 @@ static int tlg_fm_vidioc_g_tuner(struct file *file, void *priv,
>  static int fm_get_freq(struct file *file, void *priv,
>  		       struct v4l2_frequency *argp)
>  {
> -	struct poseidon *p = file->private_data;
> +	struct poseidon *p = video_drvdata(file);
>  
>  	if (argp->tuner)
>  		return -EINVAL;
> @@ -249,7 +249,7 @@ error:
>  static int fm_set_freq(struct file *file, void *priv,
>  		       struct v4l2_frequency *argp)
>  {
> -	struct poseidon *p = file->private_data;
> +	struct poseidon *p = video_drvdata(file);
>  
>  	if (argp->tuner)
>  		return -EINVAL;
> @@ -293,6 +293,8 @@ static const struct v4l2_ioctl_ops poseidon_fm_ioctl_ops = {
>  	.vidioc_g_tuner     = tlg_fm_vidioc_g_tuner,
>  	.vidioc_g_frequency = fm_get_freq,
>  	.vidioc_s_frequency = fm_set_freq,
> +	.vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
> +	.vidioc_unsubscribe_event = v4l2_event_unsubscribe,
>  };
>  
>  static struct video_device poseidon_fm_template = {
> @@ -320,6 +322,7 @@ int poseidon_fm_init(struct poseidon *p)
>  	}
>  	vfd->v4l2_dev = &p->v4l2_dev;
>  	vfd->ctrl_handler = hdl;
> +	set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags);
>  	video_set_drvdata(vfd, p);
>  	return video_register_device(vfd, VFL_TYPE_RADIO, -1);
>  }
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 08/18] tlg2300: fix radio querycap
  2013-01-31 10:25   ` [RFC PATCH 08/18] tlg2300: fix radio querycap Hans Verkuil
@ 2013-02-04  4:36     ` Huang Shijie
  2013-02-04  8:38       ` Hans Verkuil
  0 siblings, 1 reply; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:36 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-radio.c |    7 ++++++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index 854ffa0..80307d3 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -147,7 +147,12 @@ static int vidioc_querycap(struct file *file, void *priv,
>  	strlcpy(v->driver, "tele-radio", sizeof(v->driver));
>  	strlcpy(v->card, "Telegent Poseidon", sizeof(v->card));
>  	usb_make_path(p->udev, v->bus_info, sizeof(v->bus_info));
> -	v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
> +	v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
> +	/* Report all capabilities of the USB device */
> +	v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS |
> +			V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE |
why add these video/vbi capabilities?

> +			V4L2_CAP_AUDIO | V4L2_CAP_STREAMING 
> +			V4L2_CAP_READWRITE;
>  	return 0;
>  }
>  


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 09/18] tlg2300: add missing video_unregister_device.
  2013-01-31 10:25   ` [RFC PATCH 09/18] tlg2300: add missing video_unregister_device Hans Verkuil
@ 2013-02-04  4:38     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:38 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-radio.c |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index 80307d3..0f958f7 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -334,6 +334,7 @@ int poseidon_fm_init(struct poseidon *p)
>  
>  int poseidon_fm_exit(struct poseidon *p)
>  {
> +	video_unregister_device(&p->radio_data.fm_dev);
>  	v4l2_ctrl_handler_free(&p->radio_data.ctrl_handler);
>  	return 0;
>  }
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 10/18] tlg2300: embed video_device.
  2013-01-31 10:25   ` [RFC PATCH 10/18] tlg2300: embed video_device Hans Verkuil
@ 2013-02-04  4:39     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:39 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-common.h |    6 ++--
>  drivers/media/usb/tlg2300/pd-video.c  |   55 +++++++--------------------------
>  2 files changed, 13 insertions(+), 48 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
> index 67ad065..052cb0c 100644
> --- a/drivers/media/usb/tlg2300/pd-common.h
> +++ b/drivers/media/usb/tlg2300/pd-common.h
> @@ -40,7 +40,7 @@
>  #define TUNER_FREQ_MAX		(862000000)
>  
>  struct vbi_data {
> -	struct video_device	*v_dev;
> +	struct video_device	v_dev;
>  	struct video_data	*video;
>  	struct front_face	*front;
>  
> @@ -63,7 +63,7 @@ struct running_context {
>  
>  struct video_data {
>  	/* v4l2 video device */
> -	struct video_device	*v_dev;
> +	struct video_device	v_dev;
>  
>  	/* the working context */
>  	struct running_context	context;
> @@ -234,7 +234,6 @@ void dvb_stop_streaming(struct pd_dvb_adapter *);
>  /* FM */
>  int poseidon_fm_init(struct poseidon *);
>  int poseidon_fm_exit(struct poseidon *);
> -struct video_device *vdev_init(struct poseidon *, struct video_device *);
>  
>  /* vendor command ops */
>  int send_set_req(struct poseidon*, u8, s32, s32*);
> @@ -250,7 +249,6 @@ void free_all_urb_generic(struct urb **urb_array, int num);
>  
>  /* misc */
>  void poseidon_delete(struct kref *kref);
> -void destroy_video_device(struct video_device **v_dev);
>  extern int debug_mode;
>  void set_debug_mode(struct video_device *vfd, int debug_mode);
>  
> diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> index 2172337..312809a 100644
> --- a/drivers/media/usb/tlg2300/pd-video.c
> +++ b/drivers/media/usb/tlg2300/pd-video.c
> @@ -1590,48 +1590,18 @@ static struct video_device pd_video_template = {
>  	.name = "Telegent-Video",
>  	.fops = &pd_video_fops,
>  	.minor = -1,
> -	.release = video_device_release,
> +	.release = video_device_release_empty,
>  	.tvnorms = V4L2_STD_ALL,
>  	.ioctl_ops = &pd_video_ioctl_ops,
>  };
>  
> -struct video_device *vdev_init(struct poseidon *pd, struct video_device *tmp)
> -{
> -	struct video_device *vfd;
> -
> -	vfd = video_device_alloc();
> -	if (vfd == NULL)
> -		return NULL;
> -	*vfd		= *tmp;
> -	vfd->minor	= -1;
> -	vfd->v4l2_dev	= &pd->v4l2_dev;
> -	/*vfd->parent	= &(pd->udev->dev); */
> -	vfd->release	= video_device_release;
> -	video_set_drvdata(vfd, pd);
> -	return vfd;
> -}
> -
> -void destroy_video_device(struct video_device **v_dev)
> -{
> -	struct video_device *dev = *v_dev;
> -
> -	if (dev == NULL)
> -		return;
> -
> -	if (video_is_registered(dev))
> -		video_unregister_device(dev);
> -	else
> -		video_device_release(dev);
> -	*v_dev = NULL;
> -}
> -
>  void pd_video_exit(struct poseidon *pd)
>  {
>  	struct video_data *video = &pd->video_data;
>  	struct vbi_data *vbi = &pd->vbi_data;
>  
> -	destroy_video_device(&video->v_dev);
> -	destroy_video_device(&vbi->v_dev);
> +	video_unregister_device(&video->v_dev);
> +	video_unregister_device(&vbi->v_dev);
>  	log();
>  }
>  
> @@ -1641,21 +1611,19 @@ int pd_video_init(struct poseidon *pd)
>  	struct vbi_data *vbi	= &pd->vbi_data;
>  	int ret = -ENOMEM;
>  
> -	video->v_dev = vdev_init(pd, &pd_video_template);
> -	if (video->v_dev == NULL)
> -		goto out;
> +	video->v_dev = pd_video_template;
> +	video->v_dev.v4l2_dev = &pd->v4l2_dev;
> +	video_set_drvdata(&video->v_dev, pd);
>  
> -	ret = video_register_device(video->v_dev, VFL_TYPE_GRABBER, -1);
> +	ret = video_register_device(&video->v_dev, VFL_TYPE_GRABBER, -1);
>  	if (ret != 0)
>  		goto out;
>  
>  	/* VBI uses the same template as video */
> -	vbi->v_dev = vdev_init(pd, &pd_video_template);
> -	if (vbi->v_dev == NULL) {
> -		ret = -ENOMEM;
> -		goto out;
> -	}
> -	ret = video_register_device(vbi->v_dev, VFL_TYPE_VBI, -1);
> +	vbi->v_dev = pd_video_template;
> +	vbi->v_dev.v4l2_dev = &pd->v4l2_dev;
> +	video_set_drvdata(&vbi->v_dev, pd);
> +	ret = video_register_device(&vbi->v_dev, VFL_TYPE_VBI, -1);
>  	if (ret != 0)
>  		goto out;
>  	log("register VIDEO/VBI devices");
> @@ -1665,4 +1633,3 @@ out:
>  	pd_video_exit(pd);
>  	return ret;
>  }
> -
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 11/18] tlg2300: fix querycap
  2013-01-31 10:25   ` [RFC PATCH 11/18] tlg2300: fix querycap Hans Verkuil
@ 2013-02-04  4:43     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:43 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-video.c |   14 ++++++++++----
>  1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> index 312809a..8ab2894 100644
> --- a/drivers/media/usb/tlg2300/pd-video.c
> +++ b/drivers/media/usb/tlg2300/pd-video.c
> @@ -142,17 +142,23 @@ static int get_audio_std(v4l2_std_id v4l2_std)
>  static int vidioc_querycap(struct file *file, void *fh,
>  			struct v4l2_capability *cap)
>  {
> +	struct video_device *vdev = video_devdata(file);
> +	struct poseidon *p = video_get_drvdata(vdev);
>  	struct front_face *front = fh;
> -	struct poseidon *p = front->pd;
>  
>  	logs(front);
>  
>  	strcpy(cap->driver, "tele-video");
>  	strcpy(cap->card, "Telegent Poseidon");
>  	usb_make_path(p->udev, cap->bus_info, sizeof(cap->bus_info));
> -	cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_TUNER |
> -				V4L2_CAP_AUDIO | V4L2_CAP_STREAMING |
> -				V4L2_CAP_READWRITE | V4L2_CAP_VBI_CAPTURE;
> +	cap->device_caps = V4L2_CAP_TUNER | V4L2_CAP_AUDIO |
> +			V4L2_CAP_STREAMING | V4L2_CAP_READWRITE;
> +	if (vdev->vfl_type == VFL_TYPE_VBI)
> +		cap->device_caps |= V4L2_CAP_VBI_CAPTURE;
> +	else
> +		cap->device_caps |= V4L2_CAP_VIDEO_CAPTURE;
> +	cap->capabilities = cap->device_caps | V4L2_CAP_DEVICE_CAPS |
> +		V4L2_CAP_RADIO | V4L2_CAP_VBI_CAPTURE | V4L2_CAP_VIDEO_CAPTURE;
>  	return 0;
>  }
>  
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 12/18] tlg2300: fix frequency handling.
  2013-01-31 10:25   ` [RFC PATCH 12/18] tlg2300: fix frequency handling Hans Verkuil
@ 2013-02-04  4:44     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:44 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> The usual set of problems: the frequency isn't clamped to the frequency range,
> no tuner index check and the frequency isn't initialized properly on module
> load.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-common.h |    4 ++--
>  drivers/media/usb/tlg2300/pd-video.c  |   20 ++++++++++++--------
>  2 files changed, 14 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
> index 052cb0c..55fe66e 100644
> --- a/drivers/media/usb/tlg2300/pd-common.h
> +++ b/drivers/media/usb/tlg2300/pd-common.h
> @@ -36,8 +36,8 @@
>  #define V4L_PAL_VBI_FRAMESIZE	(V4L_PAL_VBI_LINES * 1440 * 2)
>  #define V4L_NTSC_VBI_FRAMESIZE	(V4L_NTSC_VBI_LINES * 1440 * 2)
>  
> -#define TUNER_FREQ_MIN		(45000000)
> -#define TUNER_FREQ_MAX		(862000000)
> +#define TUNER_FREQ_MIN		(45000000U)
> +#define TUNER_FREQ_MAX		(862000000U)
>  
>  struct vbi_data {
>  	struct video_device	v_dev;
> diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> index 8ab2894..da7cbd4 100644
> --- a/drivers/media/usb/tlg2300/pd-video.c
> +++ b/drivers/media/usb/tlg2300/pd-video.c
> @@ -940,7 +940,7 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int i)
>  	return 0;
>  }
>  
> -static struct poseidon_control *check_control_id(__u32 id)
> +static struct poseidon_control *check_control_id(u32 id)
>  {
>  	struct poseidon_control *control = &controls[0];
>  	int array_size = ARRAY_SIZE(controls);
> @@ -1134,21 +1134,21 @@ static int vidioc_g_frequency(struct file *file, void *fh,
>  	return 0;
>  }
>  
> -static int set_frequency(struct poseidon *pd, __u32 frequency)
> +static int set_frequency(struct poseidon *pd, u32 *frequency)
>  {
>  	s32 ret = 0, param, cmd_status;
>  	struct running_context *context = &pd->video_data.context;
>  
> -	param = frequency * 62500 / 1000;
> -	if (param < TUNER_FREQ_MIN/1000 || param > TUNER_FREQ_MAX / 1000)
> -		return -EINVAL;
> +	*frequency = clamp(*frequency,
> +			TUNER_FREQ_MIN / 62500, TUNER_FREQ_MAX / 62500);
> +	param = (*frequency) * 62500 / 1000;
>  
>  	mutex_lock(&pd->lock);
>  	ret = send_set_req(pd, TUNE_FREQ_SELECT, param, &cmd_status);
>  	ret = send_set_req(pd, TAKE_REQUEST, 0, &cmd_status);
>  
>  	msleep(250); /* wait for a while until the hardware is ready. */
> -	context->freq = frequency;
> +	context->freq = *frequency;
>  	mutex_unlock(&pd->lock);
>  	return ret;
>  }
> @@ -1159,12 +1159,14 @@ static int vidioc_s_frequency(struct file *file, void *fh,
>  	struct front_face *front = fh;
>  	struct poseidon *pd = front->pd;
>  
> +	if (freq->tuner)
> +		return -EINVAL;
>  	logs(front);
>  #ifdef CONFIG_PM
>  	pd->pm_suspend = pm_video_suspend;
>  	pd->pm_resume = pm_video_resume;
>  #endif
> -	return set_frequency(pd, freq->frequency);
> +	return set_frequency(pd, &freq->frequency);
>  }
>  
>  static int vidioc_reqbufs(struct file *file, void *fh,
> @@ -1351,7 +1353,7 @@ static int restore_v4l2_context(struct poseidon *pd,
>  	vidioc_s_input(NULL, front, context->sig_index);
>  	pd_vidioc_s_tuner(pd, context->audio_idx);
>  	pd_vidioc_s_fmt(pd, &context->pix);
> -	set_frequency(pd, context->freq);
> +	set_frequency(pd, &context->freq);
>  	return 0;
>  }
>  
> @@ -1615,8 +1617,10 @@ int pd_video_init(struct poseidon *pd)
>  {
>  	struct video_data *video = &pd->video_data;
>  	struct vbi_data *vbi	= &pd->vbi_data;
> +	u32 freq = TUNER_FREQ_MIN / 62500;
>  	int ret = -ENOMEM;
>  
> +	set_frequency(pd, &freq);
>  	video->v_dev = pd_video_template;
>  	video->v_dev.v4l2_dev = &pd->v4l2_dev;
>  	video_set_drvdata(&video->v_dev, pd);
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 14/18] tlg2300: implement the control framework.
  2013-01-31 10:25   ` [RFC PATCH 14/18] tlg2300: implement the control framework Hans Verkuil
@ 2013-02-04  4:46     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:46 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-common.h |    1 +
>  drivers/media/usb/tlg2300/pd-video.c  |  128 +++++++++++----------------------
>  2 files changed, 41 insertions(+), 88 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
> index 55fe66e..cb5cb0f 100644
> --- a/drivers/media/usb/tlg2300/pd-common.h
> +++ b/drivers/media/usb/tlg2300/pd-common.h
> @@ -64,6 +64,7 @@ struct running_context {
>  struct video_data {
>  	/* v4l2 video device */
>  	struct video_device	v_dev;
> +	struct v4l2_ctrl_handler ctrl_handler;
>  
>  	/* the working context */
>  	struct running_context	context;
> diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> index 122f299..849c4bb 100644
> --- a/drivers/media/usb/tlg2300/pd-video.c
> +++ b/drivers/media/usb/tlg2300/pd-video.c
> @@ -8,6 +8,7 @@
>  
>  #include <media/v4l2-ioctl.h>
>  #include <media/v4l2-dev.h>
> +#include <media/v4l2-ctrls.h>
>  
>  #include "pd-common.h"
>  #include "vendorcmds.h"
> @@ -82,31 +83,6 @@ static const struct pd_input pd_inputs[] = {
>  };
>  static const unsigned int POSEIDON_INPUTS = ARRAY_SIZE(pd_inputs);
>  
> -struct poseidon_control {
> -	struct v4l2_queryctrl v4l2_ctrl;
> -	enum cmd_custom_param_id vc_id;
> -};
> -
> -static struct poseidon_control controls[] = {
> -	{
> -		{ V4L2_CID_BRIGHTNESS, V4L2_CTRL_TYPE_INTEGER,
> -			"brightness", 0, 10000, 1, 100, 0, },
> -		CUST_PARM_ID_BRIGHTNESS_CTRL
> -	}, {
> -		{ V4L2_CID_CONTRAST, V4L2_CTRL_TYPE_INTEGER,
> -			"contrast", 0, 10000, 1, 100, 0, },
> -		CUST_PARM_ID_CONTRAST_CTRL,
> -	}, {
> -		{ V4L2_CID_HUE, V4L2_CTRL_TYPE_INTEGER,
> -			"hue", 0, 10000, 1, 100, 0, },
> -		CUST_PARM_ID_HUE_CTRL,
> -	}, {
> -		{ V4L2_CID_SATURATION, V4L2_CTRL_TYPE_INTEGER,
> -			"saturation", 0, 10000, 1, 100, 0, },
> -		CUST_PARM_ID_SATURATION_CTRL,
> -	},
> -};
> -
>  struct video_std_to_audio_std {
>  	v4l2_std_id	video_std;
>  	int 		audio_std;
> @@ -940,68 +916,28 @@ static int vidioc_s_input(struct file *file, void *fh, unsigned int i)
>  	return 0;
>  }
>  
> -static struct poseidon_control *check_control_id(u32 id)
> -{
> -	struct poseidon_control *control = &controls[0];
> -	int array_size = ARRAY_SIZE(controls);
> -
> -	for (; control < &controls[array_size]; control++)
> -		if (control->v4l2_ctrl.id  == id)
> -			return control;
> -	return NULL;
> -}
> -
> -static int vidioc_queryctrl(struct file *file, void *fh,
> -			struct v4l2_queryctrl *a)
> -{
> -	struct poseidon_control *control = NULL;
> -
> -	control = check_control_id(a->id);
> -	if (!control)
> -		return -EINVAL;
> -
> -	*a = control->v4l2_ctrl;
> -	return 0;
> -}
> -
> -static int vidioc_g_ctrl(struct file *file, void *fh, struct v4l2_control *ctrl)
> -{
> -	struct front_face *front = fh;
> -	struct poseidon *pd = front->pd;
> -	struct poseidon_control *control = NULL;
> -	struct tuner_custom_parameter_s tuner_param;
> -	s32 ret = 0, cmd_status;
> -
> -	control = check_control_id(ctrl->id);
> -	if (!control)
> -		return -EINVAL;
> -
> -	mutex_lock(&pd->lock);
> -	ret = send_get_req(pd, TUNER_CUSTOM_PARAMETER, control->vc_id,
> -			&tuner_param, &cmd_status, sizeof(tuner_param));
> -	mutex_unlock(&pd->lock);
> -
> -	if (ret || cmd_status)
> -		return -1;
> -
> -	ctrl->value = tuner_param.param_value;
> -	return 0;
> -}
> -
> -static int vidioc_s_ctrl(struct file *file, void *fh, struct v4l2_control *a)
> +static int tlg_s_ctrl(struct v4l2_ctrl *c)
>  {
> +	struct poseidon *pd = container_of(c->handler, struct poseidon,
> +						video_data.ctrl_handler);
>  	struct tuner_custom_parameter_s param = {0};
> -	struct poseidon_control *control = NULL;
> -	struct front_face *front	= fh;
> -	struct poseidon *pd		= front->pd;
>  	s32 ret = 0, cmd_status, params;
>  
> -	control = check_control_id(a->id);
> -	if (!control)
> -		return -EINVAL;
> -
> -	param.param_value = a->value;
> -	param.param_id	= control->vc_id;
> +	switch (c->id) {
> +	case V4L2_CID_BRIGHTNESS:
> +		param.param_id = CUST_PARM_ID_BRIGHTNESS_CTRL;
> +		break;
> +	case V4L2_CID_CONTRAST:
> +		param.param_id = CUST_PARM_ID_CONTRAST_CTRL;
> +		break;
> +	case V4L2_CID_HUE:
> +		param.param_id = CUST_PARM_ID_HUE_CTRL;
> +		break;
> +	case V4L2_CID_SATURATION:
> +		param.param_id = CUST_PARM_ID_SATURATION_CTRL;
> +		break;
> +	}
> +	param.param_value = c->val;
>  	params = *(s32 *)&param; /* temp code */
>  
>  	mutex_lock(&pd->lock);
> @@ -1587,11 +1523,6 @@ static const struct v4l2_ioctl_ops pd_video_ioctl_ops = {
>  	/* Stream on/off */
>  	.vidioc_streamon	= vidioc_streamon,
>  	.vidioc_streamoff	= vidioc_streamoff,
> -
> -	/* Control handling */
> -	.vidioc_queryctrl	= vidioc_queryctrl,
> -	.vidioc_g_ctrl		= vidioc_g_ctrl,
> -	.vidioc_s_ctrl		= vidioc_s_ctrl,
>  };
>  
>  static struct video_device pd_video_template = {
> @@ -1603,6 +1534,10 @@ static struct video_device pd_video_template = {
>  	.ioctl_ops = &pd_video_ioctl_ops,
>  };
>  
> +static const struct v4l2_ctrl_ops tlg_ctrl_ops = {
> +	.s_ctrl = tlg_s_ctrl,
> +};
> +
>  void pd_video_exit(struct poseidon *pd)
>  {
>  	struct video_data *video = &pd->video_data;
> @@ -1610,6 +1545,7 @@ void pd_video_exit(struct poseidon *pd)
>  
>  	video_unregister_device(&video->v_dev);
>  	video_unregister_device(&vbi->v_dev);
> +	v4l2_ctrl_handler_free(&video->ctrl_handler);
>  	log();
>  }
>  
> @@ -1617,12 +1553,27 @@ int pd_video_init(struct poseidon *pd)
>  {
>  	struct video_data *video = &pd->video_data;
>  	struct vbi_data *vbi	= &pd->vbi_data;
> +	struct v4l2_ctrl_handler *hdl = &video->ctrl_handler;
>  	u32 freq = TUNER_FREQ_MIN / 62500;
>  	int ret = -ENOMEM;
>  
> +	v4l2_ctrl_handler_init(hdl, 4);
> +	v4l2_ctrl_new_std(hdl, &tlg_ctrl_ops, V4L2_CID_BRIGHTNESS,
> +			0, 10000, 1, 100);
> +	v4l2_ctrl_new_std(hdl, &tlg_ctrl_ops, V4L2_CID_CONTRAST,
> +			0, 10000, 1, 100);
> +	v4l2_ctrl_new_std(hdl, &tlg_ctrl_ops, V4L2_CID_HUE,
> +			0, 10000, 1, 100);
> +	v4l2_ctrl_new_std(hdl, &tlg_ctrl_ops, V4L2_CID_SATURATION,
> +			0, 10000, 1, 100);
> +	if (hdl->error) {
> +		v4l2_ctrl_handler_free(hdl);
> +		return hdl->error;
> +	}
>  	set_frequency(pd, &freq);
>  	video->v_dev = pd_video_template;
>  	video->v_dev.v4l2_dev = &pd->v4l2_dev;
> +	video->v_dev.ctrl_handler = hdl;
>  	video_set_drvdata(&video->v_dev, pd);
>  
>  	ret = video_register_device(&video->v_dev, VFL_TYPE_GRABBER, -1);
> @@ -1632,6 +1583,7 @@ int pd_video_init(struct poseidon *pd)
>  	/* VBI uses the same template as video */
>  	vbi->v_dev = pd_video_template;
>  	vbi->v_dev.v4l2_dev = &pd->v4l2_dev;
> +	vbi->v_dev.ctrl_handler = hdl;
>  	video_set_drvdata(&vbi->v_dev, pd);
>  	ret = video_register_device(&vbi->v_dev, VFL_TYPE_VBI, -1);
>  	if (ret != 0)
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 06/18] tlg2300: add control handler for radio device node.
  2013-01-31 10:25   ` [RFC PATCH 06/18] tlg2300: add control handler for radio device node Hans Verkuil
@ 2013-02-04  4:47     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:47 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-common.h |    2 +
>  drivers/media/usb/tlg2300/pd-radio.c  |  112 ++++++++-------------------------
>  2 files changed, 28 insertions(+), 86 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
> index 3a89128..b26082a 100644
> --- a/drivers/media/usb/tlg2300/pd-common.h
> +++ b/drivers/media/usb/tlg2300/pd-common.h
> @@ -10,6 +10,7 @@
>  #include <linux/poll.h>
>  #include <media/videobuf-vmalloc.h>
>  #include <media/v4l2-device.h>
> +#include <media/v4l2-ctrls.h>
>  
>  #include "dvb_frontend.h"
>  #include "dvbdev.h"
> @@ -119,6 +120,7 @@ struct radio_data {
>  	unsigned int	is_radio_streaming;
>  	int		pre_emphasis;
>  	struct video_device fm_dev;
> +	struct v4l2_ctrl_handler ctrl_handler;
>  };
>  
>  #define DVB_SBUF_NUM		4
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index 719c3da..45b3d7a 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -261,104 +261,34 @@ static int fm_set_freq(struct file *file, void *priv,
>  	return set_frequency(p, argp->frequency);
>  }
>  
> -static int tlg_fm_vidioc_g_ctrl(struct file *file, void *priv,
> -		struct v4l2_control *arg)
> +static int tlg_fm_s_ctrl(struct v4l2_ctrl *ctrl)
>  {
> -	return 0;
> -}
> -
> -static int tlg_fm_vidioc_g_exts_ctrl(struct file *file, void *fh,
> -				struct v4l2_ext_controls *ctrls)
> -{
> -	struct poseidon *p = file->private_data;
> -	int i;
> -
> -	if (ctrls->ctrl_class != V4L2_CTRL_CLASS_FM_TX)
> -		return -EINVAL;
> -
> -	for (i = 0; i < ctrls->count; i++) {
> -		struct v4l2_ext_control *ctrl = ctrls->controls + i;
> -
> -		if (ctrl->id != V4L2_CID_TUNE_PREEMPHASIS)
> -			continue;
> -
> -		if (i < MAX_PREEMPHASIS)
> -			ctrl->value = p->radio_data.pre_emphasis;
> -	}
> -	return 0;
> -}
> -
> -static int tlg_fm_vidioc_s_exts_ctrl(struct file *file, void *fh,
> -			struct v4l2_ext_controls *ctrls)
> -{
> -	int i;
> -
> -	if (ctrls->ctrl_class != V4L2_CTRL_CLASS_FM_TX)
> -		return -EINVAL;
> -
> -	for (i = 0; i < ctrls->count; i++) {
> -		struct v4l2_ext_control *ctrl = ctrls->controls + i;
> -
> -		if (ctrl->id != V4L2_CID_TUNE_PREEMPHASIS)
> -			continue;
> -
> -		if (ctrl->value >= 0 && ctrl->value < MAX_PREEMPHASIS) {
> -			struct poseidon *p = file->private_data;
> -			int pre_emphasis = preemphasis[ctrl->value];
> -			u32 status;
> -
> -			send_set_req(p, TUNER_AUD_ANA_STD,
> -						pre_emphasis, &status);
> -			p->radio_data.pre_emphasis = pre_emphasis;
> -		}
> -	}
> -	return 0;
> -}
> -
> -static int tlg_fm_vidioc_s_ctrl(struct file *file, void *priv,
> -		struct v4l2_control *ctrl)
> -{
> -	return 0;
> -}
> -
> -static int tlg_fm_vidioc_queryctrl(struct file *file, void *priv,
> -		struct v4l2_queryctrl *ctrl)
> -{
> -	if (!(ctrl->id & V4L2_CTRL_FLAG_NEXT_CTRL))
> -		return -EINVAL;
> +	struct poseidon *p = container_of(ctrl->handler, struct poseidon,
> +						radio_data.ctrl_handler);
> +	int pre_emphasis;
> +	u32 status;
>  
> -	ctrl->id &= ~V4L2_CTRL_FLAG_NEXT_CTRL;
> -	if (ctrl->id != V4L2_CID_TUNE_PREEMPHASIS) {
> -		/* return the next supported control */
> -		ctrl->id = V4L2_CID_TUNE_PREEMPHASIS;
> -		v4l2_ctrl_query_fill(ctrl, V4L2_PREEMPHASIS_DISABLED,
> -					V4L2_PREEMPHASIS_75_uS, 1,
> -					V4L2_PREEMPHASIS_50_uS);
> -		ctrl->flags = V4L2_CTRL_FLAG_UPDATE;
> +	switch (ctrl->id) {
> +	case V4L2_CID_TUNE_PREEMPHASIS:
> +		pre_emphasis = preemphasis[ctrl->val];
> +		send_set_req(p, TUNER_AUD_ANA_STD, pre_emphasis, &status);
> +		p->radio_data.pre_emphasis = pre_emphasis;
>  		return 0;
>  	}
>  	return -EINVAL;
>  }
>  
> -static int tlg_fm_vidioc_querymenu(struct file *file, void *fh,
> -				struct v4l2_querymenu *qmenu)
> -{
> -	return v4l2_ctrl_query_menu(qmenu, NULL, NULL);
> -}
> -
>  static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *vt)
>  {
>  	return vt->index > 0 ? -EINVAL : 0;
>  }
>  
> +static const struct v4l2_ctrl_ops tlg_fm_ctrl_ops = {
> +	.s_ctrl = tlg_fm_s_ctrl,
> +};
> +
>  static const struct v4l2_ioctl_ops poseidon_fm_ioctl_ops = {
>  	.vidioc_querycap    = vidioc_querycap,
> -	.vidioc_queryctrl   = tlg_fm_vidioc_queryctrl,
> -	.vidioc_querymenu   = tlg_fm_vidioc_querymenu,
> -	.vidioc_g_ctrl      = tlg_fm_vidioc_g_ctrl,
> -	.vidioc_s_ctrl      = tlg_fm_vidioc_s_ctrl,
> -	.vidioc_s_ext_ctrls = tlg_fm_vidioc_s_exts_ctrl,
> -	.vidioc_g_ext_ctrls = tlg_fm_vidioc_g_exts_ctrl,
>  	.vidioc_s_tuner     = vidioc_s_tuner,
>  	.vidioc_g_tuner     = tlg_fm_vidioc_g_tuner,
>  	.vidioc_g_frequency = fm_get_freq,
> @@ -376,16 +306,26 @@ static struct video_device poseidon_fm_template = {
>  int poseidon_fm_init(struct poseidon *p)
>  {
>  	struct video_device *vfd = &p->radio_data.fm_dev;
> +	struct v4l2_ctrl_handler *hdl = &p->radio_data.ctrl_handler;
>  
>  	*vfd = poseidon_fm_template;
> -	vfd->v4l2_dev	= &p->v4l2_dev;
> -	video_set_drvdata(vfd, p);
>  
>  	set_frequency(p, TUNER_FREQ_MIN_FM);
> +	v4l2_ctrl_handler_init(hdl, 1);
> +	v4l2_ctrl_new_std_menu(hdl, &tlg_fm_ctrl_ops, V4L2_CID_TUNE_PREEMPHASIS,
> +			V4L2_PREEMPHASIS_75_uS, 0, V4L2_PREEMPHASIS_50_uS);
> +	if (hdl->error) {
> +		v4l2_ctrl_handler_free(hdl);
> +		return hdl->error;
> +	}
> +	vfd->v4l2_dev = &p->v4l2_dev;
> +	vfd->ctrl_handler = hdl;
> +	video_set_drvdata(vfd, p);
>  	return video_register_device(vfd, VFL_TYPE_RADIO, -1);
>  }
>  
>  int poseidon_fm_exit(struct poseidon *p)
>  {
> +	v4l2_ctrl_handler_free(&p->radio_data.ctrl_handler);
>  	return 0;
>  }
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 13/18] tlg2300: fix missing audioset.
  2013-01-31 10:25   ` [RFC PATCH 13/18] tlg2300: fix missing audioset Hans Verkuil
@ 2013-02-04  4:48     ` Huang Shijie
  2013-02-04  8:39       ` Hans Verkuil
  2013-02-05  4:07     ` Huang Shijie
  1 sibling, 1 reply; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:48 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-video.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> index da7cbd4..122f299 100644
> --- a/drivers/media/usb/tlg2300/pd-video.c
> +++ b/drivers/media/usb/tlg2300/pd-video.c
> @@ -903,7 +903,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
>  	 * the audio input index mixed with this video input,
>  	 * Poseidon only have one audio/video, set to "0"
>  	 */
> -	in->audioset	= 0;
> +	in->audioset	= 1;
i think it should be 0. it's need to be test.

thanks
Huang Shijie
>  	in->tuner	= 0;
>  	in->std		= V4L2_STD_ALL;
>  	in->status	= 0;


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 15/18] tlg2300: remove empty vidioc_try_fmt_vid_cap, add missing g_std.
  2013-01-31 10:25   ` [RFC PATCH 15/18] tlg2300: remove empty vidioc_try_fmt_vid_cap, add missing g_std Hans Verkuil
@ 2013-02-04  4:51     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:51 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-video.c |   16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> index 849c4bb..4c045b3 100644
> --- a/drivers/media/usb/tlg2300/pd-video.c
> +++ b/drivers/media/usb/tlg2300/pd-video.c
> @@ -705,12 +705,6 @@ static int vidioc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
>  	return 0;
>  }
>  
> -static int vidioc_try_fmt(struct file *file, void *fh,
> -		struct v4l2_format *f)
> -{
> -	return 0;
> -}
> -
>  /*
>   * VLC calls VIDIOC_S_STD before VIDIOC_S_FMT, while
>   * Mplayer calls them in the reverse order.
> @@ -866,6 +860,14 @@ static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *norm)
>  	return set_std(front->pd, norm);
>  }
>  
> +static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm)
> +{
> +	struct front_face *front = fh;
> +	logs(front);
> +	*norm = front->pd->video_data.context.tvnormid;
> +	return 0;
> +}
> +
>  static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
>  {
>  	struct front_face *front = fh;
> @@ -1495,7 +1497,6 @@ static const struct v4l2_ioctl_ops pd_video_ioctl_ops = {
>  	.vidioc_enum_fmt_vid_cap	= vidioc_enum_fmt,
>  	.vidioc_s_fmt_vid_cap	= vidioc_s_fmt,
>  	.vidioc_g_fmt_vbi_cap	= vidioc_g_fmt_vbi, /* VBI */
> -	.vidioc_try_fmt_vid_cap = vidioc_try_fmt,
>  
>  	/* Input */
>  	.vidioc_g_input		= vidioc_g_input,
> @@ -1510,6 +1511,7 @@ static const struct v4l2_ioctl_ops pd_video_ioctl_ops = {
>  	/* Tuner ioctls */
>  	.vidioc_g_tuner		= vidioc_g_tuner,
>  	.vidioc_s_tuner		= vidioc_s_tuner,
> +	.vidioc_g_std		= vidioc_g_std,
>  	.vidioc_s_std		= vidioc_s_std,
>  	.vidioc_g_frequency	= vidioc_g_frequency,
>  	.vidioc_s_frequency	= vidioc_s_frequency,
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 16/18] tlg2300: allow multiple opens.
  2013-01-31 10:25   ` [RFC PATCH 16/18] tlg2300: allow multiple opens Hans Verkuil
@ 2013-02-04  4:54     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:54 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Due to a poor administration of the driver state it wasn't possible to open
> a video or vbi device multiple times.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-common.h |    1 -
>  drivers/media/usb/tlg2300/pd-video.c  |   40 +++++++++++++--------------------
>  2 files changed, 15 insertions(+), 26 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
> index cb5cb0f..3010496 100644
> --- a/drivers/media/usb/tlg2300/pd-common.h
> +++ b/drivers/media/usb/tlg2300/pd-common.h
> @@ -26,7 +26,6 @@
>  #define POSEIDON_STATE_ANALOG		(0x0001)
>  #define POSEIDON_STATE_FM		(0x0002)
>  #define POSEIDON_STATE_DVBT		(0x0004)
> -#define POSEIDON_STATE_VBI		(0x0008)
>  #define POSEIDON_STATE_DISCONNECT	(0x0080)
>  
>  #define PM_SUSPEND_DELAY	3
> diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> index 4c045b3..834428d 100644
> --- a/drivers/media/usb/tlg2300/pd-video.c
> +++ b/drivers/media/usb/tlg2300/pd-video.c
> @@ -1352,12 +1352,14 @@ static int pd_video_open(struct file *file)
>  	mutex_lock(&pd->lock);
>  	usb_autopm_get_interface(pd->interface);
>  
> -	if (vfd->vfl_type == VFL_TYPE_GRABBER
> -		&& !(pd->state & POSEIDON_STATE_ANALOG)) {
> -		front = kzalloc(sizeof(struct front_face), GFP_KERNEL);
> -		if (!front)
> -			goto out;
> -
> +	if (pd->state && !(pd->state & POSEIDON_STATE_ANALOG)) {
> +		ret = -EBUSY;
> +		goto out;
> +	}
> +	front = kzalloc(sizeof(struct front_face), GFP_KERNEL);
> +	if (!front)
> +		goto out;
> +	if (vfd->vfl_type == VFL_TYPE_GRABBER) {
>  		pd->cur_transfer_mode	= usb_transfer_mode;/* bulk or iso */
>  		init_video_context(&pd->video_data.context);
>  
> @@ -1368,7 +1370,6 @@ static int pd_video_open(struct file *file)
>  			goto out;
>  		}
>  
> -		pd->state		|= POSEIDON_STATE_ANALOG;
>  		front->type		= V4L2_BUF_TYPE_VIDEO_CAPTURE;
>  		pd->video_data.users++;
>  		set_debug_mode(vfd, debug_mode);
> @@ -1379,13 +1380,7 @@ static int pd_video_open(struct file *file)
>  				V4L2_FIELD_INTERLACED,/* video is interlacd */
>  				sizeof(struct videobuf_buffer),/*it's enough*/
>  				front, NULL);
> -	} else if (vfd->vfl_type == VFL_TYPE_VBI
> -		&& !(pd->state & POSEIDON_STATE_VBI)) {
> -		front = kzalloc(sizeof(struct front_face), GFP_KERNEL);
> -		if (!front)
> -			goto out;
> -
> -		pd->state	|= POSEIDON_STATE_VBI;
> +	} else {
>  		front->type	= V4L2_BUF_TYPE_VBI_CAPTURE;
>  		pd->vbi_data.front = front;
>  		pd->vbi_data.users++;
> @@ -1396,19 +1391,15 @@ static int pd_video_open(struct file *file)
>  				V4L2_FIELD_NONE, /* vbi is NONE mode */
>  				sizeof(struct videobuf_buffer),
>  				front, NULL);
> -	} else {
> -		/* maybe add FM support here */
> -		log("other ");
> -		ret = -EINVAL;
> -		goto out;
>  	}
>  
> -	front->pd		= pd;
> -	front->curr_frame	= NULL;
> +	pd->state |= POSEIDON_STATE_ANALOG;
> +	front->pd = pd;
> +	front->curr_frame = NULL;
>  	INIT_LIST_HEAD(&front->active);
>  	spin_lock_init(&front->queue_lock);
>  
> -	file->private_data	= front;
> +	file->private_data = front;
>  	kref_get(&pd->kref);
>  
>  	mutex_unlock(&pd->lock);
> @@ -1429,8 +1420,6 @@ static int pd_video_release(struct file *file)
>  	mutex_lock(&pd->lock);
>  
>  	if (front->type	== V4L2_BUF_TYPE_VIDEO_CAPTURE) {
> -		pd->state &= ~POSEIDON_STATE_ANALOG;
> -
>  		/* stop the device, and free the URBs */
>  		usb_transfer_stop(&pd->video_data);
>  		free_all_urb(&pd->video_data);
> @@ -1442,10 +1431,11 @@ static int pd_video_release(struct file *file)
>  		pd->file_for_stream = NULL;
>  		pd->video_data.users--;
>  	} else if (front->type	== V4L2_BUF_TYPE_VBI_CAPTURE) {
> -		pd->state &= ~POSEIDON_STATE_VBI;
>  		pd->vbi_data.front = NULL;
>  		pd->vbi_data.users--;
>  	}
> +	if (!pd->vbi_data.users && !pd->video_data.users)
> +		pd->state &= ~POSEIDON_STATE_ANALOG;
>  	videobuf_stop(&front->q);
>  	videobuf_mmap_free(&front->q);
>  
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 17/18] tlg2300: Remove logs() macro.
  2013-01-31 10:25   ` [RFC PATCH 17/18] tlg2300: Remove logs() macro Hans Verkuil
@ 2013-02-04  4:54     ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:54 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> ioctl debugging can now be done through the debug parameter in sysfs.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-common.h |    9 ---------
>  drivers/media/usb/tlg2300/pd-video.c  |   23 ++---------------------
>  2 files changed, 2 insertions(+), 30 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-common.h b/drivers/media/usb/tlg2300/pd-common.h
> index 3010496..9e23ad32 100644
> --- a/drivers/media/usb/tlg2300/pd-common.h
> +++ b/drivers/media/usb/tlg2300/pd-common.h
> @@ -268,13 +268,4 @@ void set_debug_mode(struct video_device *vfd, int debug_mode);
>  				log();\
>  		} while (0)
>  
> -#define logs(f) do { \
> -			if ((debug_mode & 0x4) && \
> -				(f)->type == V4L2_BUF_TYPE_VBI_CAPTURE) \
> -					log("type : VBI");\
> -								\
> -			if ((debug_mode & 0x8) && \
> -				(f)->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) \
> -					log("type : VIDEO");\
> -		} while (0)
>  #endif
> diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> index 834428d..dab0ca3 100644
> --- a/drivers/media/usb/tlg2300/pd-video.c
> +++ b/drivers/media/usb/tlg2300/pd-video.c
> @@ -120,9 +120,6 @@ static int vidioc_querycap(struct file *file, void *fh,
>  {
>  	struct video_device *vdev = video_devdata(file);
>  	struct poseidon *p = video_get_drvdata(vdev);
> -	struct front_face *front = fh;
> -
> -	logs(front);
>  
>  	strcpy(cap->driver, "tele-video");
>  	strcpy(cap->card, "Telegent Poseidon");
> @@ -205,7 +202,6 @@ static void submit_frame(struct front_face *front)
>   */
>  static void end_field(struct video_data *video)
>  {
> -	/* logs(video->front); */
>  	if (1 == video->field_count)
>  		submit_frame(video->front);
>  	else
> @@ -700,7 +696,6 @@ static int vidioc_g_fmt(struct file *file, void *fh, struct v4l2_format *f)
>  	struct front_face *front = fh;
>  	struct poseidon *pd = front->pd;
>  
> -	logs(front);
>  	f->fmt.pix = pd->video_data.context.pix;
>  	return 0;
>  }
> @@ -763,7 +758,6 @@ static int vidioc_s_fmt(struct file *file, void *fh, struct v4l2_format *f)
>  	struct front_face *front	= fh;
>  	struct poseidon *pd		= front->pd;
>  
> -	logs(front);
>  	/* stop VBI here */
>  	if (V4L2_BUF_TYPE_VIDEO_CAPTURE != f->type)
>  		return -EINVAL;
> @@ -804,7 +798,6 @@ static int vidioc_g_fmt_vbi(struct file *file, void *fh,
>  		vbi_fmt->count[1] = V4L_PAL_VBI_LINES;
>  	}
>  	vbi_fmt->flags = V4L2_VBI_UNSYNC;
> -	logs(front);
>  	return 0;
>  }
>  
> @@ -856,22 +849,20 @@ out:
>  static int vidioc_s_std(struct file *file, void *fh, v4l2_std_id *norm)
>  {
>  	struct front_face *front = fh;
> -	logs(front);
> +
>  	return set_std(front->pd, norm);
>  }
>  
>  static int vidioc_g_std(struct file *file, void *fh, v4l2_std_id *norm)
>  {
>  	struct front_face *front = fh;
> -	logs(front);
> +
>  	*norm = front->pd->video_data.context.tvnormid;
>  	return 0;
>  }
>  
>  static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
>  {
> -	struct front_face *front = fh;
> -
>  	if (in->index >= POSEIDON_INPUTS)
>  		return -EINVAL;
>  	strcpy(in->name, pd_inputs[in->index].name);
> @@ -885,7 +876,6 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
>  	in->tuner	= 0;
>  	in->std		= V4L2_STD_ALL;
>  	in->status	= 0;
> -	logs(front);
>  	return 0;
>  }
>  
> @@ -895,7 +885,6 @@ static int vidioc_g_input(struct file *file, void *fh, unsigned int *i)
>  	struct poseidon *pd = front->pd;
>  	struct running_context *context = &pd->video_data.context;
>  
> -	logs(front);
>  	*i = context->sig_index;
>  	return 0;
>  }
> @@ -1023,7 +1012,6 @@ static int vidioc_g_tuner(struct file *file, void *fh, struct v4l2_tuner *tuner)
>  	tuner->rxsubchans = pd_audio_modes[index].v4l2_audio_sub;
>  	tuner->audmode = pd_audio_modes[index].v4l2_audio_mode;
>  	tuner->afc = 0;
> -	logs(front);
>  	return 0;
>  }
>  
> @@ -1051,7 +1039,6 @@ static int vidioc_s_tuner(struct file *file, void *fh, struct v4l2_tuner *a)
>  
>  	if (0 != a->index)
>  		return -EINVAL;
> -	logs(front);
>  	for (index = 0; index < POSEIDON_AUDIOMODS; index++)
>  		if (a->audmode == pd_audio_modes[index].v4l2_audio_mode)
>  			return pd_vidioc_s_tuner(pd, index);
> @@ -1099,7 +1086,6 @@ static int vidioc_s_frequency(struct file *file, void *fh,
>  
>  	if (freq->tuner)
>  		return -EINVAL;
> -	logs(front);
>  #ifdef CONFIG_PM
>  	pd->pm_suspend = pm_video_suspend;
>  	pd->pm_resume = pm_video_resume;
> @@ -1111,14 +1097,12 @@ static int vidioc_reqbufs(struct file *file, void *fh,
>  				struct v4l2_requestbuffers *b)
>  {
>  	struct front_face *front = file->private_data;
> -	logs(front);
>  	return videobuf_reqbufs(&front->q, b);
>  }
>  
>  static int vidioc_querybuf(struct file *file, void *fh, struct v4l2_buffer *b)
>  {
>  	struct front_face *front = file->private_data;
> -	logs(front);
>  	return videobuf_querybuf(&front->q, b);
>  }
>  
> @@ -1207,7 +1191,6 @@ static int vidioc_streamon(struct file *file, void *fh,
>  {
>  	struct front_face *front = fh;
>  
> -	logs(front);
>  	if (unlikely(type != front->type))
>  		return -EINVAL;
>  	return videobuf_streamon(&front->q);
> @@ -1218,7 +1201,6 @@ static int vidioc_streamoff(struct file *file, void *fh,
>  {
>  	struct front_face *front = file->private_data;
>  
> -	logs(front);
>  	if (unlikely(type != front->type))
>  		return -EINVAL;
>  	return videobuf_streamoff(&front->q);
> @@ -1416,7 +1398,6 @@ static int pd_video_release(struct file *file)
>  	struct poseidon *pd = front->pd;
>  	s32 cmd_status = 0;
>  
> -	logs(front);
>  	mutex_lock(&pd->lock);
>  
>  	if (front->type	== V4L2_BUF_TYPE_VIDEO_CAPTURE) {
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 18/18] tlg2300: update MAINTAINERS file.
  2013-01-31 10:25   ` [RFC PATCH 18/18] tlg2300: update MAINTAINERS file Hans Verkuil
@ 2013-02-04  4:55     ` Huang Shijie
  2013-02-04  8:40       ` Hans Verkuil
  0 siblings, 1 reply; 49+ messages in thread
From: Huang Shijie @ 2013-02-04  4:55 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Remove two maintainers: telegent.com no longer exists, so those email
> addresses are invalid as well.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  MAINTAINERS |    2 --
>  1 file changed, 2 deletions(-)
>
> diff --git a/MAINTAINERS b/MAINTAINERS
> index 975ba7c..00bb196 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -6778,8 +6778,6 @@ F:	drivers/clocksource
>  
>  TLG2300 VIDEO4LINUX-2 DRIVER
>  M:	Huang Shijie <shijie8@gmail.com>
> -M:	Kang Yong <kangyong@telegent.com>
> -M:	Zhang Xiaobing <xbzhang@telegent.com>
>  S:	Supported
>  F:	drivers/media/usb/tlg2300
>  
You can add your name here. I am glad you can maintain it or fix the bugs.

thanks
Huang Shijie



^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices.
  2013-02-04  4:16     ` Huang Shijie
@ 2013-02-04  8:34       ` Hans Verkuil
  0 siblings, 0 replies; 49+ messages in thread
From: Hans Verkuil @ 2013-02-04  8:34 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-media, Hans Verkuil

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: Text/Plain; charset="gb18030", Size: 2187 bytes --]

On Mon February 4 2013 05:16:32 Huang Shijie wrote:
> ÓÚ 2013Äê01ÔÂ31ÈÕ 05:25, Hans Verkuil дµÀ:
> > From: Hans Verkuil <hans.verkuil@cisco.com>
> >
> > The input and audio ioctls are only valid for video/vbi nodes.
> 
> I remember that if you do not set these ioctrls, the mplayer will not works.

I have no problem with using mplayer for radio devices without those ioctls.

Regards,

	Hans

> 
> I can not download the mplayer in my home, so i can not test it.
> I will test it in my office.
> 
> thanks
> Huang Shijie
> 
> > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> > ---
> >  drivers/media/usb/tlg2300/pd-radio.c |   27 ---------------------------
> >  1 file changed, 27 deletions(-)
> >
> > diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> > index c4feffb..4c76e089 100644
> > --- a/drivers/media/usb/tlg2300/pd-radio.c
> > +++ b/drivers/media/usb/tlg2300/pd-radio.c
> > @@ -350,36 +350,9 @@ static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *vt)
> >  {
> >  	return vt->index > 0 ? -EINVAL : 0;
> >  }
> > -static int vidioc_s_audio(struct file *file, void *priv, const struct v4l2_audio *va)
> > -{
> > -	return (va->index != 0) ? -EINVAL : 0;
> > -}
> > -
> > -static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
> > -{
> > -	a->index    = 0;
> > -	a->mode    = 0;
> > -	a->capability = V4L2_AUDCAP_STEREO;
> > -	strcpy(a->name, "Radio");
> > -	return 0;
> > -}
> > -
> > -static int vidioc_s_input(struct file *filp, void *priv, u32 i)
> > -{
> > -	return (i != 0) ? -EINVAL : 0;
> > -}
> > -
> > -static int vidioc_g_input(struct file *filp, void *priv, u32 *i)
> > -{
> > -	return (*i != 0) ? -EINVAL : 0;
> > -}
> >  
> >  static const struct v4l2_ioctl_ops poseidon_fm_ioctl_ops = {
> >  	.vidioc_querycap    = vidioc_querycap,
> > -	.vidioc_g_audio     = vidioc_g_audio,
> > -	.vidioc_s_audio     = vidioc_s_audio,
> > -	.vidioc_g_input     = vidioc_g_input,
> > -	.vidioc_s_input     = vidioc_s_input,
> >  	.vidioc_queryctrl   = tlg_fm_vidioc_queryctrl,
> >  	.vidioc_querymenu   = tlg_fm_vidioc_querymenu,
> >  	.vidioc_g_ctrl      = tlg_fm_vidioc_g_ctrl,
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 08/18] tlg2300: fix radio querycap
  2013-02-04  4:36     ` Huang Shijie
@ 2013-02-04  8:38       ` Hans Verkuil
  2013-02-05  4:07         ` Huang Shijie
  0 siblings, 1 reply; 49+ messages in thread
From: Hans Verkuil @ 2013-02-04  8:38 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-media, Hans Verkuil

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: Text/Plain; charset="gb18030", Size: 1968 bytes --]

On Mon February 4 2013 05:36:56 Huang Shijie wrote:
> ÓÚ 2013Äê01ÔÂ31ÈÕ 05:25, Hans Verkuil дµÀ:
> > From: Hans Verkuil <hans.verkuil@cisco.com>
> >
> > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> > ---
> >  drivers/media/usb/tlg2300/pd-radio.c |    7 ++++++-
> >  1 file changed, 6 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> > index 854ffa0..80307d3 100644
> > --- a/drivers/media/usb/tlg2300/pd-radio.c
> > +++ b/drivers/media/usb/tlg2300/pd-radio.c
> > @@ -147,7 +147,12 @@ static int vidioc_querycap(struct file *file, void *priv,
> >  	strlcpy(v->driver, "tele-radio", sizeof(v->driver));
> >  	strlcpy(v->card, "Telegent Poseidon", sizeof(v->card));
> >  	usb_make_path(p->udev, v->bus_info, sizeof(v->bus_info));
> > -	v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
> > +	v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
> > +	/* Report all capabilities of the USB device */
> > +	v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS |
> > +			V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE |
> why add these video/vbi capabilities?

The capabilities field contains the V4L2 capabilities of the whole device
(i.e. radio+video+vbi), the device_caps field contains the capabilities of
just that node.

In the past different drivers interpreted the capabilities field differently:
either with the capabilities of the whole device or the capabilities of just
that device node. This situation was clarified recently and the device_caps
field was added instead so both the caps for the full device and the current
device node are now available.

This wasn't there when the tlg2300 driver was developed, and the spec was
never clear enough regarding the meaning of the capabilities field.

So this is a later improvement to the V4L2 API.

Regards,

	Hans

> 
> > +			V4L2_CAP_AUDIO | V4L2_CAP_STREAMING 
> > +			V4L2_CAP_READWRITE;
> >  	return 0;
> >  }
> >  
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 13/18] tlg2300: fix missing audioset.
  2013-02-04  4:48     ` Huang Shijie
@ 2013-02-04  8:39       ` Hans Verkuil
  0 siblings, 0 replies; 49+ messages in thread
From: Hans Verkuil @ 2013-02-04  8:39 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-media, Hans Verkuil

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: Text/Plain; charset="gb18030", Size: 1122 bytes --]

On Mon February 4 2013 05:48:36 Huang Shijie wrote:
> ÓÚ 2013Äê01ÔÂ31ÈÕ 05:25, Hans Verkuil дµÀ:
> > From: Hans Verkuil <hans.verkuil@cisco.com>
> >
> > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> > ---
> >  drivers/media/usb/tlg2300/pd-video.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> > index da7cbd4..122f299 100644
> > --- a/drivers/media/usb/tlg2300/pd-video.c
> > +++ b/drivers/media/usb/tlg2300/pd-video.c
> > @@ -903,7 +903,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
> >  	 * the audio input index mixed with this video input,
> >  	 * Poseidon only have one audio/video, set to "0"
> >  	 */
> > -	in->audioset	= 0;
> > +	in->audioset	= 1;
> i think it should be 0. it's need to be test.

The audioset field is a bitmask, not an index. So to tell that audio input 0
is available audioset should be set to 1 << 0 == 1.

Regards,

	Hans

> 
> thanks
> Huang Shijie
> >  	in->tuner	= 0;
> >  	in->std		= V4L2_STD_ALL;
> >  	in->status	= 0;
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 18/18] tlg2300: update MAINTAINERS file.
  2013-02-04  4:55     ` Huang Shijie
@ 2013-02-04  8:40       ` Hans Verkuil
  0 siblings, 0 replies; 49+ messages in thread
From: Hans Verkuil @ 2013-02-04  8:40 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-media, Hans Verkuil

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: Text/Plain; charset="gb18030", Size: 899 bytes --]

On Mon February 4 2013 05:55:34 Huang Shijie wrote:
> ÓÚ 2013Äê01ÔÂ31ÈÕ 05:25, Hans Verkuil дµÀ:
> > From: Hans Verkuil <hans.verkuil@cisco.com>
> >
> > Remove two maintainers: telegent.com no longer exists, so those email
> > addresses are invalid as well.
> >
> > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> > ---
> >  MAINTAINERS |    2 --
> >  1 file changed, 2 deletions(-)
> >
> > diff --git a/MAINTAINERS b/MAINTAINERS
> > index 975ba7c..00bb196 100644
> > --- a/MAINTAINERS
> > +++ b/MAINTAINERS
> > @@ -6778,8 +6778,6 @@ F:	drivers/clocksource
> >  
> >  TLG2300 VIDEO4LINUX-2 DRIVER
> >  M:	Huang Shijie <shijie8@gmail.com>
> > -M:	Kang Yong <kangyong@telegent.com>
> > -M:	Zhang Xiaobing <xbzhang@telegent.com>
> >  S:	Supported
> >  F:	drivers/media/usb/tlg2300
> >  
> You can add your name here. I am glad you can maintain it or fix the bugs.

OK, thanks.

Regards,

	Hans

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 01/18] tlg2300: use correct device parent.
  2013-02-04  2:40   ` [RFC PATCH 01/18] tlg2300: use correct device parent Huang Shijie
@ 2013-02-04  8:40     ` Hans Verkuil
  0 siblings, 0 replies; 49+ messages in thread
From: Hans Verkuil @ 2013-02-04  8:40 UTC (permalink / raw)
  To: Huang Shijie; +Cc: linux-media, Hans Verkuil

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: Text/Plain; charset="gb18030", Size: 2723 bytes --]

On Mon February 4 2013 03:40:32 Huang Shijie wrote:
> ÓÚ 2013Äê01ÔÂ31ÈÕ 05:25, Hans Verkuil дµÀ:
> > From: Hans Verkuil <hans.verkuil@cisco.com>
> >
> > Set the correct parent for v4l2_device_register. Also remove an unnecessary
> > forward reference and fix two weird looking log messages.
> >
> > Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> > ---
> >  drivers/media/usb/tlg2300/pd-main.c |    9 ++++-----
> >  1 file changed, 4 insertions(+), 5 deletions(-)
> >
> > diff --git a/drivers/media/usb/tlg2300/pd-main.c b/drivers/media/usb/tlg2300/pd-main.c
> > index 7b1f6eb..c4eb57a 100644
> > --- a/drivers/media/usb/tlg2300/pd-main.c
> > +++ b/drivers/media/usb/tlg2300/pd-main.c
> > @@ -55,7 +55,6 @@ MODULE_PARM_DESC(debug_mode, "0 = disable, 1 = enable, 2 = verbose");
> >  
> >  #define TLG2300_FIRMWARE "tlg2300_firmware.bin"
> >  static const char *firmware_name = TLG2300_FIRMWARE;
> > -static struct usb_driver poseidon_driver;
> >  static LIST_HEAD(pd_device_list);
> >  
> >  /*
> > @@ -316,7 +315,7 @@ static int poseidon_suspend(struct usb_interface *intf, pm_message_t msg)
> >  		if (get_pm_count(pd) <= 0 && !in_hibernation(pd)) {
> >  			pd->msg.event = PM_EVENT_AUTO_SUSPEND;
> >  			pd->pm_resume = NULL; /*  a good guard */
> > -			printk(KERN_DEBUG "\n\t+ TLG2300 auto suspend +\n\n");
> > +			printk(KERN_DEBUG "TLG2300 auto suspend\n");
> >  		}
> >  		return 0;
> >  	}
> > @@ -331,7 +330,7 @@ static int poseidon_resume(struct usb_interface *intf)
> >  
> >  	if (!pd)
> >  		return 0;
> > -	printk(KERN_DEBUG "\n\t ++ TLG2300 resume ++\n\n");
> > +	printk(KERN_DEBUG "TLG2300 resume\n");
> >  
> >  	if (!is_working(pd)) {
> >  		if (PM_EVENT_AUTO_SUSPEND == pd->msg.event)
> > @@ -439,7 +438,7 @@ static int poseidon_probe(struct usb_interface *interface,
> >  		/* register v4l2 device */
> >  		snprintf(pd->v4l2_dev.name, sizeof(pd->v4l2_dev.name), "%s %s",
> >  			dev->driver->name, dev_name(dev));
> I think this line could be removed in this patch too. The
> v4l2_device_register() will assign the v4l2_dev->name if it's empty.

I agree, I'll remove this in the next version.

Regards,

	Hans

> 
> thanks
> Huang Shijie
> > -		ret = v4l2_device_register(NULL, &pd->v4l2_dev);
> > +		ret = v4l2_device_register(&interface->dev, &pd->v4l2_dev);
> >  
> >  		/* register devices in directory /dev */
> >  		ret = pd_video_init(pd);
> > @@ -530,7 +529,7 @@ module_init(poseidon_init);
> >  module_exit(poseidon_exit);
> >  
> >  MODULE_AUTHOR("Telegent Systems");
> > -MODULE_DESCRIPTION("For tlg2300-based USB device ");
> > +MODULE_DESCRIPTION("For tlg2300-based USB device");
> >  MODULE_LICENSE("GPL");
> >  MODULE_VERSION("0.0.2");
> >  MODULE_FIRMWARE(TLG2300_FIRMWARE);
> 

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices.
  2013-01-31 10:25   ` [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices Hans Verkuil
  2013-02-04  4:16     ` Huang Shijie
@ 2013-02-05  4:03     ` Huang Shijie
  1 sibling, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-05  4:03 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> The input and audio ioctls are only valid for video/vbi nodes.
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-radio.c |   27 ---------------------------
>  1 file changed, 27 deletions(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
> index c4feffb..4c76e089 100644
> --- a/drivers/media/usb/tlg2300/pd-radio.c
> +++ b/drivers/media/usb/tlg2300/pd-radio.c
> @@ -350,36 +350,9 @@ static int vidioc_s_tuner(struct file *file, void *priv, struct v4l2_tuner *vt)
>  {
>  	return vt->index > 0 ? -EINVAL : 0;
>  }
> -static int vidioc_s_audio(struct file *file, void *priv, const struct v4l2_audio *va)
> -{
> -	return (va->index != 0) ? -EINVAL : 0;
> -}
> -
> -static int vidioc_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
> -{
> -	a->index    = 0;
> -	a->mode    = 0;
> -	a->capability = V4L2_AUDCAP_STEREO;
> -	strcpy(a->name, "Radio");
> -	return 0;
> -}
> -
> -static int vidioc_s_input(struct file *filp, void *priv, u32 i)
> -{
> -	return (i != 0) ? -EINVAL : 0;
> -}
> -
> -static int vidioc_g_input(struct file *filp, void *priv, u32 *i)
> -{
> -	return (*i != 0) ? -EINVAL : 0;
> -}
>  
>  static const struct v4l2_ioctl_ops poseidon_fm_ioctl_ops = {
>  	.vidioc_querycap    = vidioc_querycap,
> -	.vidioc_g_audio     = vidioc_g_audio,
> -	.vidioc_s_audio     = vidioc_s_audio,
> -	.vidioc_g_input     = vidioc_g_input,
> -	.vidioc_s_input     = vidioc_s_input,
>  	.vidioc_queryctrl   = tlg_fm_vidioc_queryctrl,
>  	.vidioc_querymenu   = tlg_fm_vidioc_querymenu,
>  	.vidioc_g_ctrl      = tlg_fm_vidioc_g_ctrl,

I tested this patch. it seems ok.
thanks.

Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 08/18] tlg2300: fix radio querycap
  2013-02-04  8:38       ` Hans Verkuil
@ 2013-02-05  4:07         ` Huang Shijie
  0 siblings, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-05  4:07 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=gb18030; format=flowed, Size: 2118 bytes --]

ÓÚ 2013Äê02ÔÂ04ÈÕ 03:38, Hans Verkuil дµÀ:
> On Mon February 4 2013 05:36:56 Huang Shijie wrote:
>> ÓÚ 2013Äê01ÔÂ31ÈÕ 05:25, Hans Verkuil дµÀ:
>>> From: Hans Verkuil<hans.verkuil@cisco.com>
>>>
>>> Signed-off-by: Hans Verkuil<hans.verkuil@cisco.com>
>>> ---
>>>   drivers/media/usb/tlg2300/pd-radio.c |    7 ++++++-
>>>   1 file changed, 6 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/drivers/media/usb/tlg2300/pd-radio.c b/drivers/media/usb/tlg2300/pd-radio.c
>>> index 854ffa0..80307d3 100644
>>> --- a/drivers/media/usb/tlg2300/pd-radio.c
>>> +++ b/drivers/media/usb/tlg2300/pd-radio.c
>>> @@ -147,7 +147,12 @@ static int vidioc_querycap(struct file *file, void *priv,
>>>   	strlcpy(v->driver, "tele-radio", sizeof(v->driver));
>>>   	strlcpy(v->card, "Telegent Poseidon", sizeof(v->card));
>>>   	usb_make_path(p->udev, v->bus_info, sizeof(v->bus_info));
>>> -	v->capabilities = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
>>> +	v->device_caps = V4L2_CAP_TUNER | V4L2_CAP_RADIO;
>>> +	/* Report all capabilities of the USB device */
>>> +	v->capabilities = v->device_caps | V4L2_CAP_DEVICE_CAPS |
>>> +			V4L2_CAP_VIDEO_CAPTURE | V4L2_CAP_VBI_CAPTURE |
>> why add these video/vbi capabilities?
> The capabilities field contains the V4L2 capabilities of the whole device
> (i.e. radio+video+vbi), the device_caps field contains the capabilities of
> just that node.
>
> In the past different drivers interpreted the capabilities field differently:
> either with the capabilities of the whole device or the capabilities of just
> that device node. This situation was clarified recently and the device_caps
> field was added instead so both the caps for the full device and the current
> device node are now available.
>
> This wasn't there when the tlg2300 driver was developed, and the spec was
> never clear enough regarding the meaning of the capabilities field.
>
> So this is a later improvement to the V4L2 API.


thanks for the explanation.

Acked-by: Huang Shijie <shijie8@gmail.com>


> Regards,
>
> 	Hans
>
>>> +			V4L2_CAP_AUDIO | V4L2_CAP_STREAMING
>>> +			V4L2_CAP_READWRITE;
>>>   	return 0;
>>>   }
>>>


^ permalink raw reply	[flat|nested] 49+ messages in thread

* Re: [RFC PATCH 13/18] tlg2300: fix missing audioset.
  2013-01-31 10:25   ` [RFC PATCH 13/18] tlg2300: fix missing audioset Hans Verkuil
  2013-02-04  4:48     ` Huang Shijie
@ 2013-02-05  4:07     ` Huang Shijie
  1 sibling, 0 replies; 49+ messages in thread
From: Huang Shijie @ 2013-02-05  4:07 UTC (permalink / raw)
  To: Hans Verkuil; +Cc: linux-media, Hans Verkuil

于 2013年01月31日 05:25, Hans Verkuil 写道:
> From: Hans Verkuil <hans.verkuil@cisco.com>
>
> Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
> ---
>  drivers/media/usb/tlg2300/pd-video.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/media/usb/tlg2300/pd-video.c b/drivers/media/usb/tlg2300/pd-video.c
> index da7cbd4..122f299 100644
> --- a/drivers/media/usb/tlg2300/pd-video.c
> +++ b/drivers/media/usb/tlg2300/pd-video.c
> @@ -903,7 +903,7 @@ static int vidioc_enum_input(struct file *file, void *fh, struct v4l2_input *in)
>  	 * the audio input index mixed with this video input,
>  	 * Poseidon only have one audio/video, set to "0"
>  	 */
> -	in->audioset	= 0;
> +	in->audioset	= 1;
>  	in->tuner	= 0;
>  	in->std		= V4L2_STD_ALL;
>  	in->status	= 0;
Acked-by: Huang Shijie <shijie8@gmail.com>

^ permalink raw reply	[flat|nested] 49+ messages in thread

end of thread, other threads:[~2013-02-04 15:03 UTC | newest]

Thread overview: 49+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-31 10:25 [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes Hans Verkuil
2013-01-31 10:25 ` [RFC PATCH 01/18] tlg2300: use correct device parent Hans Verkuil
2013-01-31 10:25   ` [RFC PATCH 02/18] tlg2300: fix tuner and frequency handling of the radio device Hans Verkuil
2013-02-04  3:46     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 03/18] tlg2300: switch to unlocked_ioctl Hans Verkuil
2013-02-04  3:48     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 04/18] tlg2300: remove ioctls that are invalid for radio devices Hans Verkuil
2013-02-04  4:16     ` Huang Shijie
2013-02-04  8:34       ` Hans Verkuil
2013-02-05  4:03     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 05/18] tlg2300: embed video_device instead of allocating it Hans Verkuil
2013-02-04  4:26     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 06/18] tlg2300: add control handler for radio device node Hans Verkuil
2013-02-04  4:47     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 07/18] tlg2300: switch to v4l2_fh Hans Verkuil
2013-02-04  4:32     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 08/18] tlg2300: fix radio querycap Hans Verkuil
2013-02-04  4:36     ` Huang Shijie
2013-02-04  8:38       ` Hans Verkuil
2013-02-05  4:07         ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 09/18] tlg2300: add missing video_unregister_device Hans Verkuil
2013-02-04  4:38     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 10/18] tlg2300: embed video_device Hans Verkuil
2013-02-04  4:39     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 11/18] tlg2300: fix querycap Hans Verkuil
2013-02-04  4:43     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 12/18] tlg2300: fix frequency handling Hans Verkuil
2013-02-04  4:44     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 13/18] tlg2300: fix missing audioset Hans Verkuil
2013-02-04  4:48     ` Huang Shijie
2013-02-04  8:39       ` Hans Verkuil
2013-02-05  4:07     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 14/18] tlg2300: implement the control framework Hans Verkuil
2013-02-04  4:46     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 15/18] tlg2300: remove empty vidioc_try_fmt_vid_cap, add missing g_std Hans Verkuil
2013-02-04  4:51     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 16/18] tlg2300: allow multiple opens Hans Verkuil
2013-02-04  4:54     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 17/18] tlg2300: Remove logs() macro Hans Verkuil
2013-02-04  4:54     ` Huang Shijie
2013-01-31 10:25   ` [RFC PATCH 18/18] tlg2300: update MAINTAINERS file Hans Verkuil
2013-02-04  4:55     ` Huang Shijie
2013-02-04  8:40       ` Hans Verkuil
2013-02-04  2:40   ` [RFC PATCH 01/18] tlg2300: use correct device parent Huang Shijie
2013-02-04  8:40     ` Hans Verkuil
2013-02-01  2:22 ` [RFC PATCH 00/18] tlg2300: various v4l2-compliance fixes Huang Shijie
2013-02-01  7:49   ` Hans Verkuil
2013-02-01  8:02     ` Huang Shijie
2013-02-01  8:07       ` Hans Verkuil

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.