Skip to contentSkip to conversation

Staging: go7007: detector features - add new tuning option

PATCH In review volokh 2 participants 2 messages Apr 18, 2012

Subsystems (2)
lore
Share & tools
lore

volokh

author
#0 lore raw

PATCH 1/1 Staging: go7007: detector features - add new tuning option

Quoted 1 line

From a600b33c0824bf1b5031f820f8afaefa9e51dc16 Mon Sep 17 00:00:00 2001

From: Volokh Konstantin <[email protected]>
Date: Tue, 17 Apr 2012 21:39:15 +0400
Subject: [PATCH] Staging: go7007: detector features - add new tuning option
for card( V4L2_MPEG_VIDEO_ENCODING_H263
,V4L2_CID_MPEG_VIDEO_B_FRAMES) - add
framesizes&frameintervals control - tested&realize motion
detector control( GO7007IOC_REGION_NUMBER
,GO7007IOC_PIXEL_THRESOLD ,GO7007IOC_MOTION_THRESOLD
,GO7007IOC_TRIGGER ,GO7007IOC_REGION_CONTROL
,GO7007IOC_CLIP_LEFT ,GO7007IOC_CLIP_TOP
,GO7007IOC_CLIP_WIDTH ,GO7007IOC_CLIP_HEIGHT)

Tested with Angelo PCI-MPG24(Adlink) with go7007&tw2804 onboard

With Utility script for conversation to 'c' style based on checkpatch.pl

---
 drivers/staging/media/go7007/go7007-priv.h |    3 +-
 drivers/staging/media/go7007/go7007-v4l2.c |  988 ++++++++++++++++++----------
 drivers/staging/media/go7007/go7007.h      |   95 +---
 drivers/staging/media/go7007/wis-tw2804.c  |  414 +++++++-----
 scripts/correctpatch.pl                    |  269 ++++++++
 5 files changed, 1175 insertions(+), 594 deletions(-)
 create mode 100755 scripts/correctpatch.pl
drivers/staging/media/go7007/go7007-priv.h +2 -1
index b58c394..4e47f29 100644
@@ -215,7 +215,8 @@ struct go7007 {
 	} modet[4];
 	unsigned char modet_map[1624];
 	unsigned char active_map[216];
-
+	struct v4l2_rect fClipRegion;
+	unsigned char fCurrentRegion:2;
 	/* Video streaming */
 	struct go7007_buffer *active_buf;
 	enum go7007_parser_state state;
drivers/staging/media/go7007/go7007-v4l2.c +630 -358

1,172 lines not on this page · raw message

drivers/staging/media/go7007/go7007.h +19 -76

105 lines not on this page · raw message

drivers/staging/media/go7007/wis-tw2804.c +255 -159

485 lines not on this page · raw message

scripts/correctpatch.pl new file +269 -0

269 lines not on this page · raw message

Signature · 1 line
1.7.7.6
#1 lore raw
Quoted 13 lines · volokh
Quoted 1 line

From a600b33c0824bf1b5031f820f8afaefa9e51dc16 Mon Sep 17 00:00:00 2001

From: Volokh Konstantin <[email protected]>
Date: Tue, 17 Apr 2012 21:39:15 +0400
Subject: [PATCH] Staging: go7007: detector features - add new tuning option
for card( V4L2_MPEG_VIDEO_ENCODING_H263
,V4L2_CID_MPEG_VIDEO_B_FRAMES) - add
framesizes&frameintervals control - tested&realize motion
detector control( GO7007IOC_REGION_NUMBER
,GO7007IOC_PIXEL_THRESOLD ,GO7007IOC_MOTION_THRESOLD
,GO7007IOC_TRIGGER ,GO7007IOC_REGION_CONTROL
,GO7007IOC_CLIP_LEFT ,GO7007IOC_CLIP_TOP
,GO7007IOC_CLIP_WIDTH ,GO7007IOC_CLIP_HEIGHT)

Quoted 4 lines

Tested with Angelo PCI-MPG24(Adlink) with go7007&tw2804 onboard

With Utility script for conversation to 'c' style based on checkpatch.pl

Something went desperately wrong with your style script... :(

This patch needs to be broken up into multiple patches. For example one patch could remove the #ifdefed out dead code. Pull all the unrelated cleanups out into their own patches.

drivers/staging/media/go7007/go7007-v4l2.c static u32 get_frame_type_flag(struct go7007_buffer *gobuf, int format) · line 156

Quoted 6 lines
drivers/staging/media/go7007/go7007-v4l2.c +2 -0
@@ -159,6 +152,8 @@ static u32 get_frame_type_flag(struct go7007_buffer *gobuf, int format)
 		default:
 			return 0;
 		}
+	default:
+	  break;

Use 8 space tabs.

Quoted 83 lines
drivers/staging/media/go7007/go7007-v4l2.c +23 -37
 	}
 
 	return 0;
@@ -171,7 +166,7 @@ static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try)
 
 	if (fmt != NULL && fmt->fmt.pix.pixelformat != V4L2_PIX_FMT_MJPEG &&
 			fmt->fmt.pix.pixelformat != V4L2_PIX_FMT_MPEG &&
-			fmt->fmt.pix.pixelformat != V4L2_PIX_FMT_MPEG4)
+			fmt->fmt.pix.pixelformat != V4L2_PIX_FMT_H263)
 		return -EINVAL;
 
 	switch (go->standard) {
@@ -303,11 +298,10 @@ static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try)
 		go->gop_header_enable = 1;
 		go->dvd_mode = 0;
 		break;
-	/* Backwards compatibility only! */
-	case V4L2_PIX_FMT_MPEG4:
-		if (go->format == GO7007_FORMAT_MPEG4)
+	case V4L2_PIX_FMT_H263:
+		if (go->format == GO7007_FORMAT_H263)
 			break;
-		go->format = GO7007_FORMAT_MPEG4;
+		go->format = GO7007_FORMAT_H263;
 		go->pali = 0xf5;
 		go->aspect_ratio = GO7007_RATIO_1_1;
 		go->gop_size = go->sensor_framerate / 1000;
@@ -334,112 +328,388 @@ static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try)
 	return 0;
 }
 
-#if 0
-static int clip_to_modet_map(struct go7007 *go, int region,
-		struct v4l2_clip *clip_list)
+static int md_g_ctrl(struct v4l2_control *ctrl, struct go7007 *go)
 {
-	struct v4l2_clip clip, *clip_ptr;
-	int x, y, mbnum;
-
-	/* Check if coordinates are OK and if any macroblocks are already
-	 * used by other regions (besides 0) */
-	clip_ptr = clip_list;
-	while (clip_ptr) {
-		if (copy_from_user(&clip, clip_ptr, sizeof(clip)))
-			return -EFAULT;
-		if (clip.c.left < 0 || (clip.c.left & 0xF) ||
-				clip.c.width <= 0 || (clip.c.width & 0xF))
-			return -EINVAL;
-		if (clip.c.left + clip.c.width > go->width)
-			return -EINVAL;
-		if (clip.c.top < 0 || (clip.c.top & 0xF) ||
-				clip.c.height <= 0 || (clip.c.height & 0xF))
-			return -EINVAL;
-		if (clip.c.top + clip.c.height > go->height)
-			return -EINVAL;
-		for (y = 0; y < clip.c.height; y += 16)
-			for (x = 0; x < clip.c.width; x += 16) {
-				mbnum = (go->width >> 4) *
-						((clip.c.top + y) >> 4) +
-					((clip.c.left + x) >> 4);
-				if (go->modet_map[mbnum] != 0 &&
-						go->modet_map[mbnum] != region)
-					return -EBUSY;
-			}
-		clip_ptr = clip.next;
+	switch (ctrl->id) {
+	case GO7007IOC_REGION_NUMBER:
+	ctrl->value = go->fCurrentRegion;
+	break;
+	case GO7007IOC_PIXEL_THRESOLD:
+	ctrl->value = (go->modet[go->fCurrentRegion].pixel_threshold<<1)+1;
+	break;
+	case GO7007IOC_MOTION_THRESOLD:
+	ctrl->value = (go->modet[go->fCurrentRegion].motion_threshold<<1)+1;
+	break;
+	case GO7007IOC_TRIGGER:
+	ctrl->value = (go->modet[go->fCurrentRegion].mb_threshold<<1)+1;
+	break;
+	case GO7007IOC_CLIP_LEFT:
+	ctrl->value = go->fClipRegion.left;
+	break;
+	case GO7007IOC_CLIP_TOP:
+	ctrl->value = go->fClipRegion.top;

drivers/staging/media/go7007/go7007-v4l2.c static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try) · line 360

Quoted 10 lines
drivers/staging/media/go7007/go7007-v4l2.c +10 -0
+	break;
+	case GO7007IOC_CLIP_WIDTH:
+	ctrl->value = go->fClipRegion.width;
+	break;
+	case GO7007IOC_CLIP_HEIGHT:
+	ctrl->value = go->fClipRegion.height;
+	break;
+	case GO7007IOC_REGION_CONTROL:
+	default:
+	return -EINVAL;

Indenting on switch statements should look like this:

	switch (ctrl->id) {
	case GO7007IOC_REGION_NUMBER:
		ctrl->value = go->fCurrentRegion;
		break;
	case GO7007IOC_PIXEL_THRESOLD:

etc.

drivers/staging/media/go7007/go7007-v4l2.c static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try) · line 365

Quoted 8 lines
drivers/staging/media/go7007/go7007-v4l2.c +3 -3
 	}
+	return 0;
+}
 
-	/* Clear old region macroblocks */
-	for (mbnum = 0; mbnum < 1624; ++mbnum)
-		if (go->modet_map[mbnum] == region)
+static void ClearModetMap(struct go7007 *go, char Region)

The original code used "region" and that was better than "Region". Anyway, don't do unrelated renaming because it messes up the patch.

drivers/staging/media/go7007/go7007-v4l2.c static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try) · line 368

Quoted 3 lines
drivers/staging/media/go7007/go7007-v4l2.c +3 -0
+{
+  /* Clear old region macroblocks */
+	int mbnum;

Put a blank line here.

Quoted 23 lines
drivers/staging/media/go7007/go7007-v4l2.c +8 -13
+	for (mbnum = 0; mbnum < sizeof(go->modet_map); ++mbnum)
+		if (go->modet_map[mbnum] == Region)
 			go->modet_map[mbnum] = 0;
+}
 
-	/* Claim macroblocks in this list */
-	clip_ptr = clip_list;
-	while (clip_ptr) {
-		if (copy_from_user(&clip, clip_ptr, sizeof(clip)))
-			return -EFAULT;
-		for (y = 0; y < clip.c.height; y += 16)
-			for (x = 0; x < clip.c.width; x += 16) {
-				mbnum = (go->width >> 4) *
-						((clip.c.top + y) >> 4) +
-					((clip.c.left + x) >> 4);
-				go->modet_map[mbnum] = region;
-			}
-		clip_ptr = clip.next;
+static int RectToModetMap(
+	struct go7007 *go,
+	char Region,
+	struct v4l2_rect *Rect,
+	int Delete)

drivers/staging/media/go7007/go7007-v4l2.c static int set_capture_size(struct go7007 *go, struct v4l2_format *fmt, int try) · line 388

Quoted 10 lines
drivers/staging/media/go7007/go7007-v4l2.c +10 -0
+{
+	register int x, y, mbnum;
+  /* Check if coordinates are OK and if any macroblocks are already
+   * used by other regions (besides 0) */
+/*  if(Rect)*/
+	if (
+	Rect->left < 0 || (
+	Rect->left & 0xF) || Rect->width <= 0 || (
+	Rect->width & 0xF))
+		return -EINVAL;

I'm not sure what went wrong here with indenting. You used a tool to do this automatically? Can you redo it, it's not worth reviewing as is.

So basically this was not a proper review at all, and I understand that. Please break it up into small patch, fix the style issues, and we'll review it properly next time.

regards,
dan carpenter