Skip to contentSkip to conversation

tvp514x fixes

RFC PATCH In review Hans Verkuil 2 participants 14 messages May 9, 2010 – May 11, 2010 Media (V4L/DVB)

lore
Share & tools
lore
#0 lore raw

cover tvp514x fixes

Hi Vaibhav,

While working on the *_fmt to *_mbus_fmt video op conversion I noticed that tvp514x is confusing the current select TV standard with the detected TV standard leading to horrible side-effects where called TRY_FMT can actually magically change the TV standard.

I fixed this and I also simplified the format handling in general. Basically removing the format list table and realizing that since there is only one supported format, you can just return that format directly.

This will also make the next step much easier where enum/try/s/g_fmt is replaced by enum/try/s/g_mbus_fmt.

However, I have no way of testing this. Can you review this code and let me know if it is OK?

Regards,

Hans

Hans Verkuil (6):
tvp514x: do NOT change the std as a side effect
tvp514x: make std_list const
tvp514x: there is only one supported format, so simplify the code
tvp514x: add missing newlines
tvp514x: remove obsolete fmt_list
tvp514x: simplify try/g/s_fmt handling

 drivers/media/video/tvp514x.c |  223 ++++++++---------------------------------
 1 files changed, 40 insertions(+), 183 deletions(-)
#1 lore raw

RFC PATCH 1/6 tvp514x: do NOT change the std as a side effect

Several calls (try_fmt, g_parm among others) changed the current standard as a side effect of that call. But the standard may only be changed by s_std.

---
 drivers/media/video/tvp514x.c |   53 ++++++++++++----------------------------
 1 files changed, 16 insertions(+), 37 deletions(-)
drivers/media/video/tvp514x.c +16 -37
index 97b7db5..1ca1247 100644
@@ -365,13 +365,13 @@ static int tvp514x_write_regs(struct v4l2_subdev *sd,
 }
 
 /**
- * tvp514x_get_current_std() : Get the current standard detected by TVP5146/47
+ * tvp514x_query_current_std() : Query the current standard detected by TVP5146/47
  * @sd: ptr to v4l2_subdev struct
  *
- * Get current standard detected by TVP5146/47, STD_INVALID if there is no
+ * Returns the current standard detected by TVP5146/47, STD_INVALID if there is no
  * standard detected.
  */
-static enum tvp514x_std tvp514x_get_current_std(struct v4l2_subdev *sd)
+static enum tvp514x_std tvp514x_query_current_std(struct v4l2_subdev *sd)
 {
 	u8 std, std_status;
 
@@ -517,7 +517,7 @@ static int tvp514x_detect(struct v4l2_subdev *sd,
  * @std_id: standard V4L2 std_id ioctl enum
  *
  * Returns the current standard detected by TVP5146/47. If no active input is
- * detected, returns -EINVAL
+ * detected then *std_id is set to 0 and the function returns 0.
  */
 static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
 {
@@ -529,10 +529,12 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
 	if (std_id == NULL)
 		return -EINVAL;
 
-	/* get the current standard */
-	current_std = tvp514x_get_current_std(sd);
+	*std_id = V4L2_STD_UNKNOWN;
+
+	/* query the current standard */
+	current_std = tvp514x_query_current_std(sd);
 	if (current_std == STD_INVALID)
-		return -EINVAL;
+		return 0;
 
 	input_sel = decoder->input;
 
@@ -574,12 +576,11 @@ static int tvp514x_querystd(struct v4l2_subdev *sd, v4l2_std_id *std_id)
 	/* check whether signal is locked */
 	sync_lock_status = tvp514x_read_reg(sd, REG_STATUS1);
 	if (lock_mask != (sync_lock_status & lock_mask))
-		return -EINVAL;	/* No input detected */
+		return 0;	/* No input detected */
 
-	decoder->current_std = current_std;
 	*std_id = decoder->std_list[current_std].standard.id;
 
-	v4l2_dbg(1, debug, sd, "Current STD: %s",
+	v4l2_dbg(1, debug, sd, "Current STD: %s\n",
 			decoder->std_list[current_std].standard.name);
 	return 0;
 }
@@ -636,7 +637,6 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
 	int err;
 	enum tvp514x_input input_sel;
 	enum tvp514x_output output_sel;
-	enum tvp514x_std current_std = STD_INVALID;
 	u8 sync_lock_status, lock_mask;
 	int try_count = LOCK_RETRY_COUNT;
 
@@ -720,11 +720,6 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
 		/* Allow decoder to sync up with new input */
 		msleep(LOCK_RETRY_DELAY);
 
-		/* get the current standard for future reference */
-		current_std = tvp514x_get_current_std(sd);
-		if (current_std == STD_INVALID)
-			continue;
-
 		sync_lock_status = tvp514x_read_reg(sd,
 				REG_STATUS1);
 		if (lock_mask == (sync_lock_status & lock_mask))
@@ -732,15 +727,13 @@ static int tvp514x_s_routing(struct v4l2_subdev *sd,
 			break;
 	}
 
-	if ((current_std == STD_INVALID) || (try_count < 0))
+	if (try_count < 0)
 		return -EINVAL;
 
-	decoder->current_std = current_std;
 	decoder->input = input;
 	decoder->output = output;
 
-	v4l2_dbg(1, debug, sd, "Input set to: %d, std : %d",
-			input_sel, current_std);
+	v4l2_dbg(1, debug, sd, "Input set to: %d\n", input_sel);
 
 	return 0;
 }
@@ -1017,11 +1010,8 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 	pix = &f->fmt.pix;
 
 	/* Calculate height and width based on current standard */
-	current_std = tvp514x_get_current_std(sd);
-	if (current_std == STD_INVALID)
-		return -EINVAL;
+	current_std = decoder->current_std;
 
-	decoder->current_std = current_std;
 	pix->width = decoder->std_list[current_std].width;
 	pix->height = decoder->std_list[current_std].height;
 
@@ -1131,15 +1121,8 @@ tvp514x_g_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
 		/* only capture is supported */
 		return -EINVAL;
 
-	memset(a, 0, sizeof(*a));
-	a->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
-
 	/* get the current standard */
-	current_std = tvp514x_get_current_std(sd);
-	if (current_std == STD_INVALID)
-		return -EINVAL;
-
-	decoder->current_std = current_std;
+	current_std = decoder->current_std;
 
 	cparm = &a->parm.capture;
 	cparm->capability = V4L2_CAP_TIMEPERFRAME;
@@ -1174,11 +1157,7 @@ tvp514x_s_parm(struct v4l2_subdev *sd, struct v4l2_streamparm *a)
 	timeperframe = &a->parm.capture.timeperframe;
 
 	/* get the current standard */
-	current_std = tvp514x_get_current_std(sd);
-	if (current_std == STD_INVALID)
-		return -EINVAL;
-
-	decoder->current_std = current_std;
+	current_std = decoder->current_std;
 
 	*timeperframe =
 	    decoder->std_list[current_std].standard.frameperiod;
Signature · 1 line
1.6.4.2
Reviewed-by Tested-by Acked-by on v1 1/6
#2 lore raw

RE: [PATCH 1/6] [RFC] tvp514x: do NOT change the std as a side effect

Quoted 18 lines

-----Original Message-----
From: Hans Verkuil [mailto:[email protected]]
Sent: Sunday, May 09, 2010 7:27 PM
To: [email protected]
Cc: Hiremath, Vaibhav
Subject: [PATCH 1/6] [RFC] tvp514x: do NOT change the std as a side effect

Several calls (try_fmt, g_parm among others) changed the current standard as a side effect of that call. But the standard may only be changed by s_std.

---
 drivers/media/video/tvp514x.c |   53 ++++++++++++--------------------------
--
 1 files changed, 16 insertions(+), 37 deletions(-)

<snip>

Quoted 7 lines
drivers/media/video/tvp514x.c +1 -2
-	decoder->current_std = current_std;
+	current_std = decoder->current_std;
 
 	*timeperframe =
 	    decoder->std_list[current_std].standard.frameperiod;
--

1.6.4.2

[Hiremath, Vaibhav] Looks ok to me. I have tested it on AM3517EVM platform.

Thanks,
Vaibhav

#3 lore raw

RFC PATCH 2/6 tvp514x: make std_list const

In reply to Hans Verkuil
---
 drivers/media/video/tvp514x.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/video/tvp514x.c +2 -2
index 1ca1247..9d8d5c8 100644
@@ -110,7 +110,7 @@ struct tvp514x_decoder {
 
 	enum tvp514x_std current_std;
 	int num_stds;
-	struct tvp514x_std_info *std_list;
+	const struct tvp514x_std_info *std_list;
 	/* Input and Output Routing parameters */
 	u32 input;
 	u32 output;
@@ -222,7 +222,7 @@ static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
  * Currently supports two standards only, need to add support for rest of the
  * modes, like SECAM, etc...
  */
-static struct tvp514x_std_info tvp514x_std_list[] = {
+static const struct tvp514x_std_info tvp514x_std_list[] = {
 	/* Standard: STD_NTSC_MJ */
 	[STD_NTSC_MJ] = {
 	 .width = NTSC_NUM_ACTIVE_PIXELS,
Signature · 1 line
1.6.4.2
Reviewed-by Tested-by Acked-by on v1 2/6
#4 lore raw

RE: [PATCH 2/6] [RFC] tvp514x: make std_list const

Quoted 31 lines

-----Original Message-----
From: Hans Verkuil [mailto:[email protected]]
Sent: Sunday, May 09, 2010 7:27 PM
To: [email protected]
Cc: Hiremath, Vaibhav
Subject: [PATCH 2/6] [RFC] tvp514x: make std_list const

---
 drivers/media/video/tvp514x.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/media/video/tvp514x.c +1 -1
index 1ca1247..9d8d5c8 100644
@@ -110,7 +110,7 @@ struct tvp514x_decoder {
 
 	enum tvp514x_std current_std;
 	int num_stds;
-	struct tvp514x_std_info *std_list;
+	const struct tvp514x_std_info *std_list;
 	/* Input and Output Routing parameters */
 	u32 input;
 	u32 output;
@@ -222,7 +222,7 @@ static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
  * Currently supports two standards only, need to add support for rest of

the
* modes, like SECAM, etc...
*/

drivers/media/video/tvp514x.c static const struct v4l2_fmtdesc tvp514x_fmt_list[] = { · line 228

Quoted 5 lines
drivers/media/video/tvp514x.c +1 -1
-static struct tvp514x_std_info tvp514x_std_list[] = {
+static const struct tvp514x_std_info tvp514x_std_list[] = {
 	/* Standard: STD_NTSC_MJ */
 	[STD_NTSC_MJ] = {
 	 .width = NTSC_NUM_ACTIVE_PIXELS,

[Hiremath, Vaibhav]

Thanks,
Vaibhav

Quoted 2 lines

--
1.6.4.2

#5 lore raw

RFC PATCH 3/6 tvp514x: there is only one supported format, so simplify the code

In reply to Hans Verkuil

Get rid of unnecessary code since this driver supports only one pixel format. Removing this code will make the transition to the mbus API easier as well.

---
 drivers/media/video/tvp514x.c |   45 ++++++++--------------------------------
 1 files changed, 9 insertions(+), 36 deletions(-)
drivers/media/video/tvp514x.c +9 -36
index 9d8d5c8..8c1609f 100644
@@ -88,8 +88,6 @@ static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable);
  * @ver: Chip version
  * @streaming: TVP5146/47 decoder streaming - enabled or disabled.
  * @pix: Current pixel format
- * @num_fmts: Number of formats
- * @fmt_list: Format list
  * @current_std: Current standard
  * @num_stds: Number of standards
  * @std_list: Standards list
@@ -105,8 +103,6 @@ struct tvp514x_decoder {
 	int streaming;
 
 	struct v4l2_pix_format pix;
-	int num_fmts;
-	const struct v4l2_fmtdesc *fmt_list;
 
 	enum tvp514x_std current_std;
 	int num_stds;
@@ -959,27 +955,18 @@ tvp514x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 static int
 tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt)
 {
-	struct tvp514x_decoder *decoder = to_decoder(sd);
-	int index;
-
-	if (fmt == NULL)
-		return -EINVAL;
-
-	index = fmt->index;
-	if ((index >= decoder->num_fmts) || (index < 0))
-		/* Index out of bound */
+	if (fmt == NULL || fmt->index)
 		return -EINVAL;
 
 	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 		/* only capture is supported */
 		return -EINVAL;
 
-	memcpy(fmt, &decoder->fmt_list[index],
-		sizeof(struct v4l2_fmtdesc));
-
-	v4l2_dbg(1, debug, sd, "Current FMT: index - %d (%s)",
-			decoder->fmt_list[index].index,
-			decoder->fmt_list[index].description);
+	/* only one format */
+	fmt->flags = 0;
+	strlcpy(fmt->description, "8-bit UYVY 4:2:2 Format",
+					sizeof(fmt->description));
+	fmt->pixelformat = V4L2_PIX_FMT_UYVY;
 	return 0;
 }
 
@@ -996,7 +983,6 @@ static int
 tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 {
 	struct tvp514x_decoder *decoder = to_decoder(sd);
-	int ifmt;
 	struct v4l2_pix_format *pix;
 	enum tvp514x_std current_std;
 
@@ -1012,28 +998,18 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 	/* Calculate height and width based on current standard */
 	current_std = decoder->current_std;
 
+	pix->pixelformat = V4L2_PIX_FMT_UYVY;
 	pix->width = decoder->std_list[current_std].width;
 	pix->height = decoder->std_list[current_std].height;
-
-	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
-		if (pix->pixelformat ==
-			decoder->fmt_list[ifmt].pixelformat)
-			break;
-	}
-	if (ifmt == decoder->num_fmts)
-		/* None of the format matched, select default */
-		ifmt = 0;
-	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
-
 	pix->field = V4L2_FIELD_INTERLACED;
 	pix->bytesperline = pix->width * 2;
 	pix->sizeimage = pix->bytesperline * pix->height;
 	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
 	pix->priv = 0;
 
-	v4l2_dbg(1, debug, sd, "Try FMT: pixelformat - %s, bytesperline - %d"
+	v4l2_dbg(1, debug, sd, "Try FMT: bytesperline - %d"
 			"Width - %d, Height - %d",
-			decoder->fmt_list[ifmt].description, pix->bytesperline,
+			pix->bytesperline,
 			pix->width, pix->height);
 	return 0;
 }
@@ -1253,9 +1229,6 @@ static const struct v4l2_subdev_ops tvp514x_ops = {
 static struct tvp514x_decoder tvp514x_dev = {
 	.streaming = 0,
 
-	.fmt_list = tvp514x_fmt_list,
-	.num_fmts = ARRAY_SIZE(tvp514x_fmt_list),
-
 	.pix = {
 		/* Default to NTSC 8-bit YUV 422 */
 		.width = NTSC_NUM_ACTIVE_PIXELS,
Signature · 1 line
1.6.4.2
Reviewed-by Tested-by Acked-by on v1 3/6
#6 lore raw

RE: [PATCH 3/6] [RFC] tvp514x: there is only one supported format, so simplify the code

Quoted 119 lines

-----Original Message-----
From: Hans Verkuil [mailto:[email protected]]
Sent: Sunday, May 09, 2010 7:27 PM
To: [email protected]
Cc: Hiremath, Vaibhav
Subject: [PATCH 3/6] [RFC] tvp514x: there is only one supported format, so simplify the code

Get rid of unnecessary code since this driver supports only one pixel format. Removing this code will make the transition to the mbus API easier as well.

---
 drivers/media/video/tvp514x.c |   45 ++++++++------------------------------
--
 1 files changed, 9 insertions(+), 36 deletions(-)
drivers/media/video/tvp514x.c +0 -2
index 9d8d5c8..8c1609f 100644
@@ -88,8 +88,6 @@ static int tvp514x_s_stream(struct v4l2_subdev *sd, int
 enable);
  * @ver: Chip version
  * @streaming: TVP5146/47 decoder streaming - enabled or disabled.
  * @pix: Current pixel format
- * @num_fmts: Number of formats
- * @fmt_list: Format list
  * @current_std: Current standard
  * @num_stds: Number of standards

* @std_list: Standards list

drivers/media/video/tvp514x.c +9 -31
@@ -105,8 +103,6 @@ struct tvp514x_decoder {
 	int streaming;
 
 	struct v4l2_pix_format pix;
-	int num_fmts;
-	const struct v4l2_fmtdesc *fmt_list;
 
 	enum tvp514x_std current_std;
 	int num_stds;
@@ -959,27 +955,18 @@ tvp514x_s_ctrl(struct v4l2_subdev *sd, struct
 v4l2_control *ctrl)
 static int
 tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt)
 {
-	struct tvp514x_decoder *decoder = to_decoder(sd);
-	int index;
-
-	if (fmt == NULL)
-		return -EINVAL;
-
-	index = fmt->index;
-	if ((index >= decoder->num_fmts) || (index < 0))
-		/* Index out of bound */
+	if (fmt == NULL || fmt->index)
 		return -EINVAL;
 
 	if (fmt->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
 		/* only capture is supported */
 		return -EINVAL;
 
-	memcpy(fmt, &decoder->fmt_list[index],
-		sizeof(struct v4l2_fmtdesc));
-
-	v4l2_dbg(1, debug, sd, "Current FMT: index - %d (%s)",
-			decoder->fmt_list[index].index,
-			decoder->fmt_list[index].description);
+	/* only one format */
+	fmt->flags = 0;
+	strlcpy(fmt->description, "8-bit UYVY 4:2:2 Format",
+					sizeof(fmt->description));
+	fmt->pixelformat = V4L2_PIX_FMT_UYVY;
 	return 0;
 }
@@ -996,7 +983,6 @@ static int
 tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 {
 	struct tvp514x_decoder *decoder = to_decoder(sd);
-	int ifmt;
 	struct v4l2_pix_format *pix;
 	enum tvp514x_std current_std;
 
@@ -1012,28 +998,18 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct
 v4l2_format *f)
 	/* Calculate height and width based on current standard */
 	current_std = decoder->current_std;
 
+	pix->pixelformat = V4L2_PIX_FMT_UYVY;
 	pix->width = decoder->std_list[current_std].width;
 	pix->height = decoder->std_list[current_std].height;
-
-	for (ifmt = 0; ifmt < decoder->num_fmts; ifmt++) {
-		if (pix->pixelformat ==
-			decoder->fmt_list[ifmt].pixelformat)
-			break;
-	}
-	if (ifmt == decoder->num_fmts)
-		/* None of the format matched, select default */
-		ifmt = 0;
-	pix->pixelformat = decoder->fmt_list[ifmt].pixelformat;
-
 	pix->field = V4L2_FIELD_INTERLACED;
 	pix->bytesperline = pix->width * 2;
 	pix->sizeimage = pix->bytesperline * pix->height;
 	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
 	pix->priv = 0;
 
-	v4l2_dbg(1, debug, sd, "Try FMT: pixelformat - %s, bytesperline - %d"
+	v4l2_dbg(1, debug, sd, "Try FMT: bytesperline - %d"
 			"Width - %d, Height - %d",
-			decoder->fmt_list[ifmt].description, pix->bytesperline,
+			pix->bytesperline,
 			pix->width, pix->height);
 	return 0;

}

drivers/media/video/tvp514x.c static const struct v4l2_subdev_ops tvp514x_ops = { · line 1234

Quoted 9 lines
drivers/media/video/tvp514x.c +0 -3
@@ -1253,9 +1229,6 @@ static const struct v4l2_subdev_ops tvp514x_ops = {
 static struct tvp514x_decoder tvp514x_dev = {
 	.streaming = 0,
 
-	.fmt_list = tvp514x_fmt_list,
-	.num_fmts = ARRAY_SIZE(tvp514x_fmt_list),
-
 	.pix = {
 		/* Default to NTSC 8-bit YUV 422 */
 		.width = NTSC_NUM_ACTIVE_PIXELS,

[Hiremath, Vaibhav]

Thanks,
Vaibhav

Quoted 2 lines

--
1.6.4.2

#7 lore raw

RFC PATCH 4/6 tvp514x: add missing newlines

In reply to Hans Verkuil
---
 drivers/media/video/tvp514x.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/media/video/tvp514x.c +6 -6
index 8c1609f..4e22621 100644
@@ -610,7 +610,7 @@ static int tvp514x_s_std(struct v4l2_subdev *sd, v4l2_std_id std_id)
 	decoder->tvp514x_regs[REG_VIDEO_STD].val =
 		decoder->std_list[i].video_std;
 
-	v4l2_dbg(1, debug, sd, "Standard set to: %s",
+	v4l2_dbg(1, debug, sd, "Standard set to: %s\n",
 			decoder->std_list[i].standard.name);
 	return 0;
 }
@@ -782,7 +782,7 @@ tvp514x_queryctrl(struct v4l2_subdev *sd, struct v4l2_queryctrl *qctrl)
 		return err;
 	}
 
-	v4l2_dbg(1, debug, sd, "Query Control:%s: Min - %d, Max - %d, Def - %d",
+	v4l2_dbg(1, debug, sd, "Query Control:%s: Min - %d, Max - %d, Def - %d\n",
 			qctrl->name, qctrl->minimum, qctrl->maximum,
 			qctrl->default_value);
 
@@ -839,7 +839,7 @@ tvp514x_g_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 		return -EINVAL;
 	}
 
-	v4l2_dbg(1, debug, sd, "Get Control: ID - %d - %d",
+	v4l2_dbg(1, debug, sd, "Get Control: ID - %d - %d\n",
 			ctrl->id, ctrl->value);
 	return 0;
 }
@@ -939,7 +939,7 @@ tvp514x_s_ctrl(struct v4l2_subdev *sd, struct v4l2_control *ctrl)
 		return err;
 	}
 
-	v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d",
+	v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d\n",
 			ctrl->id, ctrl->value);
 
 	return err;
@@ -1008,7 +1008,7 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 	pix->priv = 0;
 
 	v4l2_dbg(1, debug, sd, "Try FMT: bytesperline - %d"
-			"Width - %d, Height - %d",
+			"Width - %d, Height - %d\n",
 			pix->bytesperline,
 			pix->width, pix->height);
 	return 0;
@@ -1070,7 +1070,7 @@ tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 	f->fmt.pix = decoder->pix;
 
 	v4l2_dbg(1, debug, sd, "Current FMT: bytesperline - %d"
-			"Width - %d, Height - %d",
+			"Width - %d, Height - %d\n",
 			decoder->pix.bytesperline,
 			decoder->pix.width, decoder->pix.height);
 	return 0;
Signature · 1 line
1.6.4.2
Reviewed-by Tested-by Acked-by on v1 4/6
#8 lore raw

RE: [PATCH 4/6] [RFC] tvp514x: add missing newlines

Quoted 77 lines

-----Original Message-----
From: Hans Verkuil [mailto:[email protected]]
Sent: Sunday, May 09, 2010 7:27 PM
To: [email protected]
Cc: Hiremath, Vaibhav
Subject: [PATCH 4/6] [RFC] tvp514x: add missing newlines

---
 drivers/media/video/tvp514x.c |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
drivers/media/video/tvp514x.c +1 -1
index 8c1609f..4e22621 100644
@@ -610,7 +610,7 @@ static int tvp514x_s_std(struct v4l2_subdev *sd,
 v4l2_std_id std_id)
 	decoder->tvp514x_regs[REG_VIDEO_STD].val =
 		decoder->std_list[i].video_std;
 
-	v4l2_dbg(1, debug, sd, "Standard set to: %s",
+	v4l2_dbg(1, debug, sd, "Standard set to: %s\n",
 			decoder->std_list[i].standard.name);
 	return 0;

}

drivers/media/video/tvp514x.c +1 -1
@@ -782,7 +782,7 @@ tvp514x_queryctrl(struct v4l2_subdev *sd, struct
 v4l2_queryctrl *qctrl)
 		return err;
 	}
 
-	v4l2_dbg(1, debug, sd, "Query Control:%s: Min - %d, Max - %d, Def -
 %d",
+	v4l2_dbg(1, debug, sd, "Query Control:%s: Min - %d, Max - %d, Def -
 %d\n",
drivers/media/video/tvp514x.c +1 -1
 			qctrl->name, qctrl->minimum, qctrl->maximum,
 			qctrl->default_value);
@@ -839,7 +839,7 @@ tvp514x_g_ctrl(struct v4l2_subdev *sd, struct
 v4l2_control *ctrl)
 		return -EINVAL;
 	}
 
-	v4l2_dbg(1, debug, sd, "Get Control: ID - %d - %d",
+	v4l2_dbg(1, debug, sd, "Get Control: ID - %d - %d\n",
 			ctrl->id, ctrl->value);
 	return 0;

}

drivers/media/video/tvp514x.c +1 -1
@@ -939,7 +939,7 @@ tvp514x_s_ctrl(struct v4l2_subdev *sd, struct
 v4l2_control *ctrl)
 		return err;
 	}
 
-	v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d",
+	v4l2_dbg(1, debug, sd, "Set Control: ID - %d - %d\n",
 			ctrl->id, ctrl->value);
 
drivers/media/video/tvp514x.c +1 -1
 	return err;
@@ -1008,7 +1008,7 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct
 v4l2_format *f)
 	pix->priv = 0;
 
 	v4l2_dbg(1, debug, sd, "Try FMT: bytesperline - %d"
-			"Width - %d, Height - %d",
+			"Width - %d, Height - %d\n",
 			pix->bytesperline,
 			pix->width, pix->height);
drivers/media/video/tvp514x.c +1 -1
 	return 0;
@@ -1070,7 +1070,7 @@ tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct
 v4l2_format *f)
 	f->fmt.pix = decoder->pix;
 
 	v4l2_dbg(1, debug, sd, "Current FMT: bytesperline - %d"
-			"Width - %d, Height - %d",
+			"Width - %d, Height - %d\n",
 			decoder->pix.bytesperline,
 			decoder->pix.width, decoder->pix.height);
Quoted 1 line

return 0;

[Hiremath, Vaibhav]

Thanks,
Vaibhav

Quoted 2 lines

--
1.6.4.2

#9 lore raw

RFC PATCH 5/6 tvp514x: remove obsolete fmt_list

In reply to Hans Verkuil
---
 drivers/media/video/tvp514x.c |   15 ---------------
 1 files changed, 0 insertions(+), 15 deletions(-)
drivers/media/video/tvp514x.c +0 -15
index 4e22621..1c3417b 100644
@@ -198,21 +198,6 @@ static struct tvp514x_reg tvp514x_reg_list_default[] = {
 };
 
 /**
- * List of image formats supported by TVP5146/47 decoder
- * Currently we are using 8 bit mode only, but can be
- * extended to 10/20 bit mode.
- */
-static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {
-	{
-	 .index = 0,
-	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
-	 .flags = 0,
-	 .description = "8-bit UYVY 4:2:2 Format",
-	 .pixelformat = V4L2_PIX_FMT_UYVY,
-	},
-};
-
-/**
  * Supported standards -
  *
  * Currently supports two standards only, need to add support for rest of the
Signature · 1 line
1.6.4.2
Reviewed-by Tested-by Acked-by on v1 5/6
#10 lore raw

RE: [PATCH 5/6] [RFC] tvp514x: remove obsolete fmt_list

Quoted 27 lines

-----Original Message-----
From: Hans Verkuil [mailto:[email protected]]
Sent: Sunday, May 09, 2010 7:27 PM
To: [email protected]
Cc: Hiremath, Vaibhav
Subject: [PATCH 5/6] [RFC] tvp514x: remove obsolete fmt_list

---
 drivers/media/video/tvp514x.c |   15 ---------------
 1 files changed, 0 insertions(+), 15 deletions(-)
drivers/media/video/tvp514x.c +0 -5
index 4e22621..1c3417b 100644
@@ -198,21 +198,6 @@ static struct tvp514x_reg tvp514x_reg_list_default[] =
 {
 };
 
 /**
- * List of image formats supported by TVP5146/47 decoder
- * Currently we are using 8 bit mode only, but can be
- * extended to 10/20 bit mode.
- */
-static const struct v4l2_fmtdesc tvp514x_fmt_list[] = {

drivers/media/video/tvp514x.c static struct tvp514x_reg tvp514x_reg_list_default[] = · line 216

Quoted 10 lines
drivers/media/video/tvp514x.c +0 -10
-	{
-	 .index = 0,
-	 .type = V4L2_BUF_TYPE_VIDEO_CAPTURE,
-	 .flags = 0,
-	 .description = "8-bit UYVY 4:2:2 Format",
-	 .pixelformat = V4L2_PIX_FMT_UYVY,
-	},
-};
-
-/**

[Hiremath, Vaibhav] This can be part of [PATCH 3/6]

Subject: [RFC] tvp514x: there is only one supported format, so simplify the code

Irrespective of this, this is required so,

Thanks,
Vaibhav

Quoted 6 lines
drivers/media/video/tvp514x.c +0 -0
  * Supported standards -
  *

* Currently supports two standards only, need to add support for rest of
the
--
1.6.4.2

#11 lore raw

RFC PATCH 6/6 tvp514x: simplify try/g/s_fmt handling

In reply to Hans Verkuil

Since there is only one possible format just have all three calls do the same.

---
 drivers/media/video/tvp514x.c |   98 ++++-------------------------------------
 1 files changed, 9 insertions(+), 89 deletions(-)
drivers/media/video/tvp514x.c +9 -89
index 1c3417b..b0465d2 100644
@@ -87,7 +87,6 @@ static int tvp514x_s_stream(struct v4l2_subdev *sd, int enable);
  * @pdata: Board specific
  * @ver: Chip version
  * @streaming: TVP5146/47 decoder streaming - enabled or disabled.
- * @pix: Current pixel format
  * @current_std: Current standard
  * @num_stds: Number of standards
  * @std_list: Standards list
@@ -102,8 +101,6 @@ struct tvp514x_decoder {
 	int ver;
 	int streaming;
 
-	struct v4l2_pix_format pix;
-
 	enum tvp514x_std current_std;
 	int num_stds;
 	const struct tvp514x_std_info *std_list;
@@ -956,16 +953,15 @@ tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct v4l2_fmtdesc *fmt)
 }
 
 /**
- * tvp514x_try_fmt_cap() - V4L2 decoder interface handler for try_fmt
+ * tvp514x_fmt_cap() - V4L2 decoder interface handler for try/s/g_fmt
  * @sd: pointer to standard V4L2 sub-device structure
  * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
  *
- * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
- * ioctl is used to negotiate the image capture size and pixel format
- * without actually making it take effect.
+ * Implement the VIDIOC_TRY/S/G_FMT ioctl for the CAPTURE buffer type. This
+ * ioctl is used to negotiate the image capture size and pixel format.
  */
 static int
-tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
+tvp514x_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 {
 	struct tvp514x_decoder *decoder = to_decoder(sd);
 	struct v4l2_pix_format *pix;
@@ -975,8 +971,7 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 		return -EINVAL;
 
 	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		/* only capture is supported */
-		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+		return -EINVAL;
 
 	pix = &f->fmt.pix;
 
@@ -992,7 +987,7 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
 	pix->priv = 0;
 
-	v4l2_dbg(1, debug, sd, "Try FMT: bytesperline - %d"
+	v4l2_dbg(1, debug, sd, "FMT: bytesperline - %d"
 			"Width - %d, Height - %d\n",
 			pix->bytesperline,
 			pix->width, pix->height);
@@ -1000,68 +995,6 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 }
 
 /**
- * tvp514x_s_fmt_cap() - V4L2 decoder interface handler for s_fmt
- * @sd: pointer to standard V4L2 sub-device structure
- * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
- *
- * If the requested format is supported, configures the HW to use that
- * format, returns error code if format not supported or HW can't be
- * correctly configured.
- */
-static int
-tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
-	struct tvp514x_decoder *decoder = to_decoder(sd);
-	struct v4l2_pix_format *pix;
-	int rval;
-
-	if (f == NULL)
-		return -EINVAL;
-
-	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		/* only capture is supported */
-		return -EINVAL;
-
-	pix = &f->fmt.pix;
-	rval = tvp514x_try_fmt_cap(sd, f);
-	if (rval)
-		return rval;
-
-		decoder->pix = *pix;
-
-	return rval;
-}
-
-/**
- * tvp514x_g_fmt_cap() - V4L2 decoder interface handler for tvp514x_g_fmt_cap
- * @sd: pointer to standard V4L2 sub-device structure
- * @f: pointer to standard V4L2 v4l2_format structure
- *
- * Returns the decoder's current pixel format in the v4l2_format
- * parameter.
- */
-static int
-tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
-	struct tvp514x_decoder *decoder = to_decoder(sd);
-
-	if (f == NULL)
-		return -EINVAL;
-
-	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		/* only capture is supported */
-		return -EINVAL;
-
-	f->fmt.pix = decoder->pix;
-
-	v4l2_dbg(1, debug, sd, "Current FMT: bytesperline - %d"
-			"Width - %d, Height - %d\n",
-			decoder->pix.bytesperline,
-			decoder->pix.width, decoder->pix.height);
-	return 0;
-}
-
-/**
  * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm
  * @sd: pointer to standard V4L2 sub-device structure
  * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
@@ -1198,9 +1131,9 @@ static const struct v4l2_subdev_video_ops tvp514x_video_ops = {
 	.s_routing = tvp514x_s_routing,
 	.querystd = tvp514x_querystd,
 	.enum_fmt = tvp514x_enum_fmt_cap,
-	.g_fmt = tvp514x_g_fmt_cap,
-	.try_fmt = tvp514x_try_fmt_cap,
-	.s_fmt = tvp514x_s_fmt_cap,
+	.g_fmt = tvp514x_fmt_cap,
+	.try_fmt = tvp514x_fmt_cap,
+	.s_fmt = tvp514x_fmt_cap,
 	.g_parm = tvp514x_g_parm,
 	.s_parm = tvp514x_s_parm,
 	.s_stream = tvp514x_s_stream,
@@ -1213,19 +1146,6 @@ static const struct v4l2_subdev_ops tvp514x_ops = {
 
 static struct tvp514x_decoder tvp514x_dev = {
 	.streaming = 0,
-
-	.pix = {
-		/* Default to NTSC 8-bit YUV 422 */
-		.width = NTSC_NUM_ACTIVE_PIXELS,
-		.height = NTSC_NUM_ACTIVE_LINES,
-		.pixelformat = V4L2_PIX_FMT_UYVY,
-		.field = V4L2_FIELD_INTERLACED,
-		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
-		.sizeimage =
-		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
-		.colorspace = V4L2_COLORSPACE_SMPTE170M,
-		},
-
 	.current_std = STD_NTSC_MJ,
 	.std_list = tvp514x_std_list,
 	.num_stds = ARRAY_SIZE(tvp514x_std_list),
Signature · 1 line
1.6.4.2
Reviewed-by Tested-by Acked-by on v1 6/6
#12 lore raw

RE: [PATCH 6/6] [RFC] tvp514x: simplify try/g/s_fmt handling

Quoted 177 lines

-----Original Message-----
From: Hans Verkuil [mailto:[email protected]]
Sent: Sunday, May 09, 2010 7:27 PM
To: [email protected]
Cc: Hiremath, Vaibhav
Subject: [PATCH 6/6] [RFC] tvp514x: simplify try/g/s_fmt handling

Since there is only one possible format just have all three calls do the same.

---
 drivers/media/video/tvp514x.c |   98 ++++----------------------------------
---
 1 files changed, 9 insertions(+), 89 deletions(-)
drivers/media/video/tvp514x.c +0 -1
index 1c3417b..b0465d2 100644
@@ -87,7 +87,6 @@ static int tvp514x_s_stream(struct v4l2_subdev *sd, int
 enable);
  * @pdata: Board specific
  * @ver: Chip version
  * @streaming: TVP5146/47 decoder streaming - enabled or disabled.
- * @pix: Current pixel format
  * @current_std: Current standard
  * @num_stds: Number of standards

* @std_list: Standards list

drivers/media/video/tvp514x.c +4 -7
@@ -102,8 +101,6 @@ struct tvp514x_decoder {
 	int ver;
 	int streaming;
 
-	struct v4l2_pix_format pix;
-
 	enum tvp514x_std current_std;
 	int num_stds;
 	const struct tvp514x_std_info *std_list;
@@ -956,16 +953,15 @@ tvp514x_enum_fmt_cap(struct v4l2_subdev *sd, struct
 v4l2_fmtdesc *fmt)
 }
 
 /**
- * tvp514x_try_fmt_cap() - V4L2 decoder interface handler for try_fmt
+ * tvp514x_fmt_cap() - V4L2 decoder interface handler for try/s/g_fmt
  * @sd: pointer to standard V4L2 sub-device structure
  * @f: pointer to standard V4L2 VIDIOC_TRY_FMT ioctl structure
  *
- * Implement the VIDIOC_TRY_FMT ioctl for the CAPTURE buffer type. This
- * ioctl is used to negotiate the image capture size and pixel format
- * without actually making it take effect.
+ * Implement the VIDIOC_TRY/S/G_FMT ioctl for the CAPTURE buffer type. This
+ * ioctl is used to negotiate the image capture size and pixel format.
  */
 static int
-tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
+tvp514x_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
 {
 	struct tvp514x_decoder *decoder = to_decoder(sd);
drivers/media/video/tvp514x.c +2 -3
 	struct v4l2_pix_format *pix;
@@ -975,8 +971,7 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct
 v4l2_format *f)
 		return -EINVAL;
 
 	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		/* only capture is supported */
-		f->type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
+		return -EINVAL;
 
 	pix = &f->fmt.pix;
@@ -992,7 +987,7 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct
 v4l2_format *f)
 	pix->colorspace = V4L2_COLORSPACE_SMPTE170M;
 	pix->priv = 0;
 
-	v4l2_dbg(1, debug, sd, "Try FMT: bytesperline - %d"
+	v4l2_dbg(1, debug, sd, "FMT: bytesperline - %d"
 			"Width - %d, Height - %d\n",
 			pix->bytesperline,
drivers/media/video/tvp514x.c +0 -34
 			pix->width, pix->height);
@@ -1000,68 +995,6 @@ tvp514x_try_fmt_cap(struct v4l2_subdev *sd, struct
 v4l2_format *f)
 }
 
 /**
- * tvp514x_s_fmt_cap() - V4L2 decoder interface handler for s_fmt
- * @sd: pointer to standard V4L2 sub-device structure
- * @f: pointer to standard V4L2 VIDIOC_S_FMT ioctl structure
- *
- * If the requested format is supported, configures the HW to use that
- * format, returns error code if format not supported or HW can't be
- * correctly configured.
- */
-static int
-tvp514x_s_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
-	struct tvp514x_decoder *decoder = to_decoder(sd);
-	struct v4l2_pix_format *pix;
-	int rval;
-
-	if (f == NULL)
-		return -EINVAL;
-
-	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		/* only capture is supported */
-		return -EINVAL;
-
-	pix = &f->fmt.pix;
-	rval = tvp514x_try_fmt_cap(sd, f);
-	if (rval)
-		return rval;
-
-		decoder->pix = *pix;
-
-	return rval;
-}
-
-/**
- * tvp514x_g_fmt_cap() - V4L2 decoder interface handler for

tvp514x_g_fmt_cap
- * @sd: pointer to standard V4L2 sub-device structure
- * @f: pointer to standard V4L2 v4l2_format structure
- *
- * Returns the decoder's current pixel format in the v4l2_format
- * parameter.
- */

drivers/media/video/tvp514x.c +3 -25
-static int
-tvp514x_g_fmt_cap(struct v4l2_subdev *sd, struct v4l2_format *f)
-{
-	struct tvp514x_decoder *decoder = to_decoder(sd);
-
-	if (f == NULL)
-		return -EINVAL;
-
-	if (f->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
-		/* only capture is supported */
-		return -EINVAL;
-
-	f->fmt.pix = decoder->pix;
-
-	v4l2_dbg(1, debug, sd, "Current FMT: bytesperline - %d"
-			"Width - %d, Height - %d\n",
-			decoder->pix.bytesperline,
-			decoder->pix.width, decoder->pix.height);
-	return 0;
-}
-
-/**
  * tvp514x_g_parm() - V4L2 decoder interface handler for g_parm
  * @sd: pointer to standard V4L2 sub-device structure
  * @a: pointer to standard V4L2 VIDIOC_G_PARM ioctl structure
@@ -1198,9 +1131,9 @@ static const struct v4l2_subdev_video_ops
 tvp514x_video_ops = {
 	.s_routing = tvp514x_s_routing,
 	.querystd = tvp514x_querystd,
 	.enum_fmt = tvp514x_enum_fmt_cap,
-	.g_fmt = tvp514x_g_fmt_cap,
-	.try_fmt = tvp514x_try_fmt_cap,
-	.s_fmt = tvp514x_s_fmt_cap,
+	.g_fmt = tvp514x_fmt_cap,
+	.try_fmt = tvp514x_fmt_cap,
+	.s_fmt = tvp514x_fmt_cap,
 	.g_parm = tvp514x_g_parm,
 	.s_parm = tvp514x_s_parm,
drivers/media/video/tvp514x.c +0 -6
 	.s_stream = tvp514x_s_stream,
@@ -1213,19 +1146,6 @@ static const struct v4l2_subdev_ops tvp514x_ops = {
 
 static struct tvp514x_decoder tvp514x_dev = {
 	.streaming = 0,
-
-	.pix = {
-		/* Default to NTSC 8-bit YUV 422 */
-		.width = NTSC_NUM_ACTIVE_PIXELS,
-		.height = NTSC_NUM_ACTIVE_LINES,
-		.pixelformat = V4L2_PIX_FMT_UYVY,

drivers/media/video/tvp514x.c static const struct v4l2_subdev_ops tvp514x_ops = { · line 1151

Quoted 10 lines
drivers/media/video/tvp514x.c +0 -7
-		.field = V4L2_FIELD_INTERLACED,
-		.bytesperline = NTSC_NUM_ACTIVE_PIXELS * 2,
-		.sizeimage =
-		NTSC_NUM_ACTIVE_PIXELS * 2 * NTSC_NUM_ACTIVE_LINES,
-		.colorspace = V4L2_COLORSPACE_SMPTE170M,
-		},
-
 	.current_std = STD_NTSC_MJ,
 	.std_list = tvp514x_std_list,
 	.num_stds = ARRAY_SIZE(tvp514x_std_list),

[Hiremath, Vaibhav]

Thanks,
Vaibhav

Quoted 2 lines

--
1.6.4.2

#13 lore raw
In reply to Hans Verkuil
Quoted 19 lines

-----Original Message-----
From: Hans Verkuil [mailto:[email protected]]
Sent: Sunday, May 09, 2010 7:27 PM
To: [email protected]
Cc: Hiremath, Vaibhav
Subject: [PATCH 0/6] [RFC] tvp514x fixes

Hi Vaibhav,

While working on the *_fmt to *_mbus_fmt video op conversion I noticed that tvp514x is confusing the current select TV standard with the detected TV standard leading to horrible side-effects where called TRY_FMT can actually magically change the TV standard.

I fixed this and I also simplified the format handling in general. Basically removing the format list table and realizing that since there is only one supported format, you can just return that format directly.

Quoted 6 lines

This will also make the next step much easier where enum/try/s/g_fmt is replaced by enum/try/s/g_mbus_fmt.

However, I have no way of testing this. Can you review this code and let me know if it is OK?

[Hiremath, Vaibhav] Sorry Hans for delayed response on this, actually today almost whole day I had to spend collecting docs for VISA application and stuff.

Thanks for working on this and changing the driver, I will take a look at it (Also I will validate it here at my end) and update you on this.

Thanks,
Vaibhav

Quoted 15 lines

Regards,

Hans

Hans Verkuil (6):
tvp514x: do NOT change the std as a side effect
tvp514x: make std_list const
tvp514x: there is only one supported format, so simplify the code
tvp514x: add missing newlines
tvp514x: remove obsolete fmt_list
tvp514x: simplify try/g/s_fmt handling

 drivers/media/video/tvp514x.c |  223 ++++++++------------------------------
---
 1 files changed, 40 insertions(+), 183 deletions(-)