All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/4] [media] tuner: Remove remaining usages of T_DIGITAL_TV
       [not found] <cover.1298340861.git.mchehab@redhat.com>
@ 2011-02-22  2:17 ` Mauro Carvalho Chehab
  2011-02-22  2:35   ` Mauro Carvalho Chehab
  2011-02-22  2:17 ` [PATCH 2/4] [media] tvp5150: device detection should be done only once Mauro Carvalho Chehab
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2011-02-22  2:17 UTC (permalink / raw)
  Cc: Linux Media Mailing List

A few places used T_DIGITAL_TV internally. Remove the usage of this
obsolete mode mask.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c
index d95f3b2..efcbc3e 100644
--- a/drivers/media/common/tuners/tuner-xc2028.c
+++ b/drivers/media/common/tuners/tuner-xc2028.c
@@ -933,7 +933,7 @@ static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */,
 	 * that xc2028 will be in a safe state.
 	 * Maybe this might also be needed for DTV.
 	 */
-	if (new_mode == T_ANALOG_TV) {
+	if (new_mode == V4L2_TUNER_ANALOG_TV) {
 		rc = send_seq(priv, {0x00, 0x00});
 
 		/* Analog modes require offset = 0 */
@@ -1054,7 +1054,7 @@ static int xc2028_set_analog_freq(struct dvb_frontend *fe,
 		if (priv->ctrl.input1)
 			type |= INPUT1;
 		return generic_set_freq(fe, (625l * p->frequency) / 10,
-				T_RADIO, type, 0, 0);
+				V4L2_TUNER_RADIO, type, 0, 0);
 	}
 
 	/* if std is not defined, choose one */
@@ -1069,7 +1069,7 @@ static int xc2028_set_analog_freq(struct dvb_frontend *fe,
 	p->std |= parse_audio_std_option();
 
 	return generic_set_freq(fe, 62500l * p->frequency,
-				T_ANALOG_TV, type, p->std, 0);
+				V4L2_TUNER_ANALOG_TV, type, p->std, 0);
 }
 
 static int xc2028_set_params(struct dvb_frontend *fe,
@@ -1174,7 +1174,7 @@ static int xc2028_set_params(struct dvb_frontend *fe,
 	}
 
 	return generic_set_freq(fe, p->frequency,
-				T_DIGITAL_TV, type, 0, demod);
+				V4L2_TUNER_DIGITAL_TV, type, 0, demod);
 }
 
 static int xc2028_sleep(struct dvb_frontend *fe)
diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index f34d524..b2e351c 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -2227,7 +2227,7 @@ em28xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
 	 */
 
 	if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
-		if (res_locked(dev, EM28XX_RESOURCE_VIDEO))
+		if (res_get(dev, EM28XX_RESOURCE_VIDEO))
 			return -EBUSY;
 
 		return videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0,
diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
index 455038b..22a2222 100644
--- a/drivers/staging/tm6000/tm6000-cards.c
+++ b/drivers/staging/tm6000/tm6000-cards.c
@@ -588,8 +588,6 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
 	tun_setup.mode_mask = 0;
 	if (dev->caps.has_tuner)
 		tun_setup.mode_mask |= (T_ANALOG_TV | T_RADIO);
-	if (dev->caps.has_dvb)
-		tun_setup.mode_mask |= T_DIGITAL_TV;
 
 	switch (dev->tuner_type) {
 	case TUNER_XC2028:
diff --git a/include/media/tuner.h b/include/media/tuner.h
index 32dfd5f..963e334 100644
--- a/include/media/tuner.h
+++ b/include/media/tuner.h
@@ -161,7 +161,7 @@
 enum tuner_mode {
 	T_RADIO		= 1 << V4L2_TUNER_RADIO,
 	T_ANALOG_TV     = 1 << V4L2_TUNER_ANALOG_TV,
-	T_DIGITAL_TV    = 1 << V4L2_TUNER_DIGITAL_TV,
+	/* Don't need to map V4L2_TUNER_DIGITAL_TV, as tuner-core won't use it */
 };
 
 /* Older boards only had a single tuner device. Nowadays multiple tuner
-- 
1.7.1



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

* [PATCH 2/4] [media] tvp5150: device detection should be done only once
       [not found] <cover.1298340861.git.mchehab@redhat.com>
  2011-02-22  2:17 ` [PATCH 1/4] [media] tuner: Remove remaining usages of T_DIGITAL_TV Mauro Carvalho Chehab
@ 2011-02-22  2:17 ` Mauro Carvalho Chehab
  2011-02-22  2:17 ` [PATCH 3/4] [media] em28xx: Fix return value for s_ctrl Mauro Carvalho Chehab
  2011-02-22  2:17 ` [PATCH 4/4] [media] em28xx: properly handle subdev controls Mauro Carvalho Chehab
  3 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2011-02-22  2:17 UTC (permalink / raw)
  Cc: Linux Media Mailing List

Having the device detection happening at reset is bad, as every time,
it will produce a message like:
	tvp5150 2-005c: tvp5150am1 detected.

This only polutes the log and for an accidental kernel hacker, it looks
like a real problem. So, move those printk's to happen during device
probe.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/tvp5150.c b/drivers/media/video/tvp5150.c
index 959d690..e927d25 100644
--- a/drivers/media/video/tvp5150.c
+++ b/drivers/media/video/tvp5150.c
@@ -737,27 +737,6 @@ static int tvp5150_s_std(struct v4l2_subdev *sd, v4l2_std_id std)
 static int tvp5150_reset(struct v4l2_subdev *sd, u32 val)
 {
 	struct tvp5150 *decoder = to_tvp5150(sd);
-	u8 msb_id, lsb_id, msb_rom, lsb_rom;
-
-	msb_id = tvp5150_read(sd, TVP5150_MSB_DEV_ID);
-	lsb_id = tvp5150_read(sd, TVP5150_LSB_DEV_ID);
-	msb_rom = tvp5150_read(sd, TVP5150_ROM_MAJOR_VER);
-	lsb_rom = tvp5150_read(sd, TVP5150_ROM_MINOR_VER);
-
-	if (msb_rom == 4 && lsb_rom == 0) { /* Is TVP5150AM1 */
-		v4l2_info(sd, "tvp%02x%02xam1 detected.\n", msb_id, lsb_id);
-
-		/* ITU-T BT.656.4 timing */
-		tvp5150_write(sd, TVP5150_REV_SELECT, 0);
-	} else {
-		if (msb_rom == 3 || lsb_rom == 0x21) { /* Is TVP5150A */
-			v4l2_info(sd, "tvp%02x%02xa detected.\n", msb_id, lsb_id);
-		} else {
-			v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n",
-					msb_id, lsb_id);
-			v4l2_info(sd, "*** Rom ver is %d.%d\n", msb_rom, lsb_rom);
-		}
-	}
 
 	/* Initializes TVP5150 to its default values */
 	tvp5150_write_inittab(sd, tvp5150_init_default);
@@ -977,6 +956,7 @@ static int tvp5150_probe(struct i2c_client *c,
 {
 	struct tvp5150 *core;
 	struct v4l2_subdev *sd;
+	u8 msb_id, lsb_id, msb_rom, lsb_rom;
 
 	/* Check if the adapter supports the needed features */
 	if (!i2c_check_functionality(c->adapter,
@@ -992,6 +972,26 @@ static int tvp5150_probe(struct i2c_client *c,
 	v4l_info(c, "chip found @ 0x%02x (%s)\n",
 		 c->addr << 1, c->adapter->name);
 
+	msb_id = tvp5150_read(sd, TVP5150_MSB_DEV_ID);
+	lsb_id = tvp5150_read(sd, TVP5150_LSB_DEV_ID);
+	msb_rom = tvp5150_read(sd, TVP5150_ROM_MAJOR_VER);
+	lsb_rom = tvp5150_read(sd, TVP5150_ROM_MINOR_VER);
+
+	if (msb_rom == 4 && lsb_rom == 0) { /* Is TVP5150AM1 */
+		v4l2_info(sd, "tvp%02x%02xam1 detected.\n", msb_id, lsb_id);
+
+		/* ITU-T BT.656.4 timing */
+		tvp5150_write(sd, TVP5150_REV_SELECT, 0);
+	} else {
+		if (msb_rom == 3 || lsb_rom == 0x21) { /* Is TVP5150A */
+			v4l2_info(sd, "tvp%02x%02xa detected.\n", msb_id, lsb_id);
+		} else {
+			v4l2_info(sd, "*** unknown tvp%02x%02x chip detected.\n",
+					msb_id, lsb_id);
+			v4l2_info(sd, "*** Rom ver is %d.%d\n", msb_rom, lsb_rom);
+		}
+	}
+
 	core->norm = V4L2_STD_ALL;	/* Default is autodetect */
 	core->input = TVP5150_COMPOSITE1;
 	core->enable = 1;
-- 
1.7.1



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

* [PATCH 3/4] [media] em28xx: Fix return value for s_ctrl
       [not found] <cover.1298340861.git.mchehab@redhat.com>
  2011-02-22  2:17 ` [PATCH 1/4] [media] tuner: Remove remaining usages of T_DIGITAL_TV Mauro Carvalho Chehab
  2011-02-22  2:17 ` [PATCH 2/4] [media] tvp5150: device detection should be done only once Mauro Carvalho Chehab
@ 2011-02-22  2:17 ` Mauro Carvalho Chehab
  2011-02-22  2:17 ` [PATCH 4/4] [media] em28xx: properly handle subdev controls Mauro Carvalho Chehab
  3 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2011-02-22  2:17 UTC (permalink / raw)
  Cc: Linux Media Mailing List

On some cases, driver returns 1. This should be OK, but qv4l2 is too
strict about return values.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index b2e351c..19b8284 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1452,7 +1452,7 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
 			rc = em28xx_audio_analog_set(dev);
 		}
 	}
-	return rc;
+	return (rc < 0) ? rc : 0;
 }
 
 static int vidioc_g_tuner(struct file *file, void *priv,
-- 
1.7.1



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

* [PATCH 4/4] [media] em28xx: properly handle subdev controls
       [not found] <cover.1298340861.git.mchehab@redhat.com>
                   ` (2 preceding siblings ...)
  2011-02-22  2:17 ` [PATCH 3/4] [media] em28xx: Fix return value for s_ctrl Mauro Carvalho Chehab
@ 2011-02-22  2:17 ` Mauro Carvalho Chehab
  3 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2011-02-22  2:17 UTC (permalink / raw)
  Cc: Linux Media Mailing List

Subdev controls return codes are evil, as they return -EINVAL to mean
both unsupported and invalid arguments. Due to that, we need to use a
trick to identify what controls are supported by a subdev.

Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>

diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 19b8284..23e7742 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1387,6 +1387,27 @@ static int vidioc_queryctrl(struct file *file, void *priv,
 		return -EINVAL;
 }
 
+/*
+ * FIXME: This is an indirect way to check if a control exists at a
+ * subdev. Instead of that hack, maybe the better would be to change all
+ * subdevs to return -ENOIOCTLCMD, if an ioctl is not supported.
+ */
+static int check_subdev_ctrl(struct em28xx *dev, int id)
+{
+	struct v4l2_queryctrl qc;
+
+	memset(&qc, 0, sizeof(qc));
+	qc.id = id;
+
+	/* enumerate V4L2 device controls */
+	v4l2_device_call_all(&dev->v4l2_dev, 0, core, queryctrl, &qc);
+
+	if (qc.type)
+		return 0;
+	else
+		return -EINVAL;
+}
+
 static int vidioc_g_ctrl(struct file *file, void *priv,
 				struct v4l2_control *ctrl)
 {
@@ -1399,7 +1420,6 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
 		return rc;
 	rc = 0;
 
-
 	/* Set an AC97 control */
 	if (dev->audio_mode.ac97 != EM28XX_NO_AC97)
 		rc = ac97_get_ctrl(dev, ctrl);
@@ -1408,6 +1428,9 @@ static int vidioc_g_ctrl(struct file *file, void *priv,
 
 	/* It were not an AC97 control. Sends it to the v4l2 dev interface */
 	if (rc == 1) {
+		if (check_subdev_ctrl(dev, ctrl->id))
+			return -EINVAL;
+
 		v4l2_device_call_all(&dev->v4l2_dev, 0, core, g_ctrl, ctrl);
 		rc = 0;
 	}
@@ -1434,8 +1457,10 @@ static int vidioc_s_ctrl(struct file *file, void *priv,
 
 	/* It isn't an AC97 control. Sends it to the v4l2 dev interface */
 	if (rc == 1) {
-		rc = v4l2_device_call_until_err(&dev->v4l2_dev, 0, core, s_ctrl, ctrl);
-
+		rc = check_subdev_ctrl(dev, ctrl->id);
+		if (!rc)
+			v4l2_device_call_all(&dev->v4l2_dev, 0,
+					     core, s_ctrl, ctrl);
 		/*
 		 * In the case of non-AC97 volume controls, we still need
 		 * to do some setups at em28xx, in order to mute/unmute
-- 
1.7.1


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

* Re: [PATCH 1/4] [media] tuner: Remove remaining usages of T_DIGITAL_TV
  2011-02-22  2:17 ` [PATCH 1/4] [media] tuner: Remove remaining usages of T_DIGITAL_TV Mauro Carvalho Chehab
@ 2011-02-22  2:35   ` Mauro Carvalho Chehab
  0 siblings, 0 replies; 5+ messages in thread
From: Mauro Carvalho Chehab @ 2011-02-22  2:35 UTC (permalink / raw)
  Cc: Linux Media Mailing List

Em 21-02-2011 23:17, Mauro Carvalho Chehab escreveu:
> A few places used T_DIGITAL_TV internally. Remove the usage of this
> obsolete mode mask.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
> 
> diff --git a/drivers/media/common/tuners/tuner-xc2028.c b/drivers/media/common/tuners/tuner-xc2028.c
> index d95f3b2..efcbc3e 100644
> --- a/drivers/media/common/tuners/tuner-xc2028.c
> +++ b/drivers/media/common/tuners/tuner-xc2028.c
> @@ -933,7 +933,7 @@ static int generic_set_freq(struct dvb_frontend *fe, u32 freq /* in HZ */,
>  	 * that xc2028 will be in a safe state.
>  	 * Maybe this might also be needed for DTV.
>  	 */
> -	if (new_mode == T_ANALOG_TV) {
> +	if (new_mode == V4L2_TUNER_ANALOG_TV) {
>  		rc = send_seq(priv, {0x00, 0x00});
>  
>  		/* Analog modes require offset = 0 */
> @@ -1054,7 +1054,7 @@ static int xc2028_set_analog_freq(struct dvb_frontend *fe,
>  		if (priv->ctrl.input1)
>  			type |= INPUT1;
>  		return generic_set_freq(fe, (625l * p->frequency) / 10,
> -				T_RADIO, type, 0, 0);
> +				V4L2_TUNER_RADIO, type, 0, 0);
>  	}
>  
>  	/* if std is not defined, choose one */
> @@ -1069,7 +1069,7 @@ static int xc2028_set_analog_freq(struct dvb_frontend *fe,
>  	p->std |= parse_audio_std_option();
>  
>  	return generic_set_freq(fe, 62500l * p->frequency,
> -				T_ANALOG_TV, type, p->std, 0);
> +				V4L2_TUNER_ANALOG_TV, type, p->std, 0);
>  }
>  
>  static int xc2028_set_params(struct dvb_frontend *fe,
> @@ -1174,7 +1174,7 @@ static int xc2028_set_params(struct dvb_frontend *fe,
>  	}
>  
>  	return generic_set_freq(fe, p->frequency,
> -				T_DIGITAL_TV, type, 0, demod);
> +				V4L2_TUNER_DIGITAL_TV, type, 0, demod);
>  }
>  
>  static int xc2028_sleep(struct dvb_frontend *fe)
> diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
> index f34d524..b2e351c 100644
> --- a/drivers/media/video/em28xx/em28xx-video.c
> +++ b/drivers/media/video/em28xx/em28xx-video.c
> @@ -2227,7 +2227,7 @@ em28xx_v4l2_read(struct file *filp, char __user *buf, size_t count,
>  	 */
>  
>  	if (fh->type == V4L2_BUF_TYPE_VIDEO_CAPTURE) {
> -		if (res_locked(dev, EM28XX_RESOURCE_VIDEO))
> +		if (res_get(dev, EM28XX_RESOURCE_VIDEO))
>  			return -EBUSY;
>  
>  		return videobuf_read_stream(&fh->vb_vidq, buf, count, pos, 0,

This hunk obviously doesn't belong here. It were just part of a test I did. I'll discard
it at the final version.

> diff --git a/drivers/staging/tm6000/tm6000-cards.c b/drivers/staging/tm6000/tm6000-cards.c
> index 455038b..22a2222 100644
> --- a/drivers/staging/tm6000/tm6000-cards.c
> +++ b/drivers/staging/tm6000/tm6000-cards.c
> @@ -588,8 +588,6 @@ static void tm6000_config_tuner(struct tm6000_core *dev)
>  	tun_setup.mode_mask = 0;
>  	if (dev->caps.has_tuner)
>  		tun_setup.mode_mask |= (T_ANALOG_TV | T_RADIO);
> -	if (dev->caps.has_dvb)
> -		tun_setup.mode_mask |= T_DIGITAL_TV;
>  
>  	switch (dev->tuner_type) {
>  	case TUNER_XC2028:
> diff --git a/include/media/tuner.h b/include/media/tuner.h
> index 32dfd5f..963e334 100644
> --- a/include/media/tuner.h
> +++ b/include/media/tuner.h
> @@ -161,7 +161,7 @@
>  enum tuner_mode {
>  	T_RADIO		= 1 << V4L2_TUNER_RADIO,
>  	T_ANALOG_TV     = 1 << V4L2_TUNER_ANALOG_TV,
> -	T_DIGITAL_TV    = 1 << V4L2_TUNER_DIGITAL_TV,
> +	/* Don't need to map V4L2_TUNER_DIGITAL_TV, as tuner-core won't use it */
>  };
>  
>  /* Older boards only had a single tuner device. Nowadays multiple tuner


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

end of thread, other threads:[~2011-02-22  2:35 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <cover.1298340861.git.mchehab@redhat.com>
2011-02-22  2:17 ` [PATCH 1/4] [media] tuner: Remove remaining usages of T_DIGITAL_TV Mauro Carvalho Chehab
2011-02-22  2:35   ` Mauro Carvalho Chehab
2011-02-22  2:17 ` [PATCH 2/4] [media] tvp5150: device detection should be done only once Mauro Carvalho Chehab
2011-02-22  2:17 ` [PATCH 3/4] [media] em28xx: Fix return value for s_ctrl Mauro Carvalho Chehab
2011-02-22  2:17 ` [PATCH 4/4] [media] em28xx: properly handle subdev controls Mauro Carvalho Chehab

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.