[PATCH] hverkuil/go7007: media: i2c : tw2804: Revert ADC Control Reverting patch commit 3d321ebba68f1fc50a9461373e8da0887e39fbbc Case: In AdLink MPG24 there is bt878 exists (it captures one frame of a

2013-03-23 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/media/i2c/tw2804.c |   17 +
 1 files changed, 1 insertions(+), 16 deletions(-)

diff --git a/drivers/media/i2c/tw2804.c b/drivers/media/i2c/tw2804.c
index 441b766..c5dc2c3 100644
--- a/drivers/media/i2c/tw2804.c
+++ b/drivers/media/i2c/tw2804.c
@@ -53,7 +53,7 @@ static const u8 global_registers[] = {
0x3d, 0x80,
0x3e, 0x82,
0x3f, 0x82,
-   0x78, 0x0f,
+   0x78, 0x00,
0xff, 0xff, /* Terminator (reg 0xff does not exist) */
 };
 
@@ -337,20 +337,6 @@ static int tw2804_s_video_routing(struct v4l2_subdev *sd, 
u32 input, u32 output,
return 0;
 }
 
-static int tw2804_s_stream(struct v4l2_subdev *sd, int enable)
-{
-   struct tw2804 *dec = to_state(sd);
-   struct i2c_client *client = v4l2_get_subdevdata(sd);
-   u32 reg = read_reg(client, 0x78, 0);
-
-   if (enable == 1)
-   write_reg(client, 0x78, reg & ~(1 << dec->channel), 0);
-   else
-   write_reg(client, 0x78, reg | (1 << dec->channel), 0);
-
-   return 0;
-}
-
 static const struct v4l2_ctrl_ops tw2804_ctrl_ops = {
.g_volatile_ctrl = tw2804_g_volatile_ctrl,
.s_ctrl = tw2804_s_ctrl,
@@ -358,7 +344,6 @@ static const struct v4l2_ctrl_ops tw2804_ctrl_ops = {
 
 static const struct v4l2_subdev_video_ops tw2804_video_ops = {
.s_routing = tw2804_s_video_routing,
-   .s_stream = tw2804_s_stream,
 };
 
 static const struct v4l2_subdev_core_ops tw2804_core_ops = {
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] hverkuil/go7007: staging: media: go7007: rmmod firmware protection stuff

2013-03-12 Thread Volokh Konstantin
If firmware wasn`t load, rmmod fail with oops:

usbcore: deregistering interface driver go7007
BUG: unable to handle kernel NULL pointer dereference at   (null)
IP: [] __mutex_lock_slowpath+0xa2/0x140
PGD 13143b067 PUD 132a52067 PMD 0
Oops: 0002 [#1] SMP
Modules linked in: go7007_usb(C-) go7007(C) videobuf2_core bttv videobuf_dma_sg 
videobuf_core btcx_risc rc_core v4l2_common videodev videobuf2_vmalloc 
videobuf2_memops tveeprom
CPU 0
Pid: 3305, comm: rmmod Tainted: G C   3.9.0-rc1+ #4 To Be Filled By 
O.E.M. To Be Filled By O.E.M./H55MX-S Series
RIP: 0010:[]  [] 
__mutex_lock_slowpath+0xa2/0x140
RSP: 0018:88013220bd18  EFLAGS: 00010246
RAX:  RBX: 880132264c80 RCX: 
RDX: 88013220bd20 RSI: 880130d3ecc0 RDI: 880132264c84
RBP: 88013220bd68 R08:  R09: ea0004c5c940
R10: 811a08d3 R11: 00027854 R12: 880132264c84
R13: 8801325ec410 R14:  R15: 880132264c88
Mar 12 01:25:57 Video kernel: [  128.939419] FS:  7fb32649d700() 
GS:880137c0() knlGS:
CS:  0010 DS:  ES:  CR0: 8005003b
CR2:  CR3: 000130f1d000 CR4: 07f0
DR0:  DR1:  DR2: 
DR3:  DR6: 0ff0 DR7: 0400
Process rmmod (pid: 3305, threadinfo 88013220a000, task 8801325ec410)
Stack:
88013220bd48 880132264c88  880131abf800
880130d3ecc0 880132264c80 880132264c80 880132264478
880132264000  88013220bd88 81797c05
Call Trace:
 [] mutex_lock+0x25/0x40
 [] go7007_usb_disconnect+0x41/0xb0 [go7007_usb]
 [] usb_unbind_interface+0x5b/0x130
 [] __device_release_driver+0x61/0xd0
 [] driver_detach+0xb0/0xc0
 [] bus_remove_driver+0x79/0xd0
 [] driver_unregister+0x5a/0x90
 [] usb_deregister+0x64/0xd0
 [] go7007_usb_driver_exit+0x10/0x12 [go7007_usb]
 [] sys_delete_module+0x15c/0x240
 [] system_call_fastpath+0x16/0x1b
Code: 00 4c 8d 63 04 4c 8d 7b 08 41 be ff ff ff ff 4c 89 e7 e8 92 26 00 00 48 
8b 43 10 48 8d 55 b8 4c 89 7d b8 48 89 53 10 48 89 45 c0 <48> 89 10 44 89 f0 4c 
89 6d c8 87 03 83 f8 01 75 1f eb 27 0f 1f
RIP  [] __mutex_lock_slowpath+0xa2/0x140
RSP 
CR2: 

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-usb.c |   25 +
 1 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index bd23d7d..48ad01f 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1316,18 +1316,19 @@ static void go7007_usb_disconnect(struct usb_interface 
*intf)
 {
struct go7007 *go = to_go7007(usb_get_intfdata(intf));
 
-   mutex_lock(&go->queue_lock);
-   mutex_lock(&go->serialize_lock);
-
-   if (go->audio_enabled)
-   go7007_snd_remove(go);
-
-   go->status = STATUS_SHUTDOWN;
-   v4l2_device_disconnect(&go->v4l2_dev);
-   video_unregister_device(&go->vdev);
-   mutex_unlock(&go->serialize_lock);
-   mutex_unlock(&go->queue_lock);
-
+   if (go->status == STATUS_ONLINE) {
+   mutex_lock(&go->queue_lock);
+   mutex_lock(&go->serialize_lock);
+
+   if (go->audio_enabled)
+   go7007_snd_remove(go);
+
+   go->status = STATUS_SHUTDOWN;
+   v4l2_device_disconnect(&go->v4l2_dev);
+   video_unregister_device(&go->vdev);
+   mutex_unlock(&go->serialize_lock);
+   mutex_unlock(&go->queue_lock);
+   }
v4l2_device_put(&go->v4l2_dev);
 }
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] hverkuil/go7007: staging: media: go7007: Restore b_frame control

2013-03-12 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-priv.h |1 +
 drivers/staging/media/go7007/go7007-v4l2.c |7 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index 0914fa3..5f9b389 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -166,6 +166,7 @@ struct go7007 {
struct v4l2_ctrl *mpeg_video_gop_closure;
struct v4l2_ctrl *mpeg_video_bitrate;
struct v4l2_ctrl *mpeg_video_aspect_ratio;
+   struct v4l2_ctrl *mpeg_video_b_frames;
enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status;
spinlock_t spinlock;
struct mutex hw_lock;
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 3634580..06fc930 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -170,7 +170,7 @@ static void set_formatting(struct go7007 *go)
go->gop_size == 15 &&
go->closed_gop;
go->repeat_seqhead = go->dvd_mode;
-   go->ipb = 0;
+   go->ipb = v4l2_ctrl_g_ctrl(go->mpeg_video_b_frames);
 
switch (v4l2_ctrl_g_ctrl(go->mpeg_video_aspect_ratio)) {
default:
@@ -935,7 +935,7 @@ int go7007_v4l2_ctrl_init(struct go7007 *go)
struct v4l2_ctrl_handler *hdl = &go->hdl;
struct v4l2_ctrl *ctrl;
 
-   v4l2_ctrl_handler_init(hdl, 12);
+   v4l2_ctrl_handler_init(hdl, 13);
go->mpeg_video_gop_size = v4l2_ctrl_new_std(hdl, NULL,
V4L2_CID_MPEG_VIDEO_GOP_SIZE, 0, 34, 1, 15);
go->mpeg_video_gop_closure = v4l2_ctrl_new_std(hdl, NULL,
@@ -943,6 +943,9 @@ int go7007_v4l2_ctrl_init(struct go7007 *go)
go->mpeg_video_bitrate = v4l2_ctrl_new_std(hdl, NULL,
V4L2_CID_MPEG_VIDEO_BITRATE,
64000, 1000, 1, 980);
+   go->mpeg_video_b_frames = v4l2_ctrl_new_std(hdl, NULL,
+   V4L2_CID_MPEG_VIDEO_B_FRAMES, 0, 2, 1, 0);
+
go->mpeg_video_aspect_ratio = v4l2_ctrl_new_std_menu(hdl, NULL,
V4L2_CID_MPEG_VIDEO_ASPECT,
V4L2_MPEG_VIDEO_ASPECT_16x9, 0,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 7/7] hverkuil/go7007: staging: media: go7007: Clean trivial

2013-03-10 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-priv.h |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index 36b271f..9ec5319 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -232,7 +232,6 @@ struct go7007 {
struct v4l2_ctrl *modet_clip_width;
struct v4l2_ctrl *modet_clip_height;
struct v4l2_ctrl *modet_region_number;
-   //struct v4l2_ctrl *mpeg_video_b_frames;
};
/* Video streaming */
struct mutex queue_lock;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 6/7] hverkuil/go7007: staging: media: go7007: Cleanup Unused modet code

2013-03-10 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-v4l2.c |   94 
 1 files changed, 0 insertions(+), 94 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 7ea0ea1..30ae939 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -292,64 +292,6 @@ 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)
-{
-   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;
-   }
-
-   /* Clear old region macroblocks */
-   for (mbnum = 0; mbnum < 1624; ++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;
-   }
-   return 0;
-}
-#endif
-
 static int go7007_s_ctrl(struct v4l2_ctrl *ctrl)
 {
struct go7007 *go =
@@ -1045,42 +987,6 @@ static int vidioc_log_status(struct file *file, void 
*priv)
return call_all(&go->v4l2_dev, core, log_status);
 }
 
-/* FIXME:
-   Those ioctls are private, and not needed, since several standard
-   extended controls already provide streaming control.
-   So, those ioctls should be converted into vidioc_g_ext_ctrls()
-   and vidioc_s_ext_ctrls()
- */
-
-#if 0
-   case GO7007IOC_S_MD_PARAMS:
-   {
-   struct go7007_md_params *mdp = arg;
-
-   if (mdp->region > 3)
-   return -EINVAL;
-   if (mdp->trigger > 0) {
-   go->modet[mdp->region].pixel_threshold =
-   mdp->pixel_threshold >> 1;
-   go->modet[mdp->region].motion_threshold =
-   mdp->motion_threshold >> 1;
-   go->modet[mdp->region].mb_threshold =
-   mdp->trigger >> 1;
-   go->modet[mdp->region].enable = 1;
-   } else
-   go->modet[mdp->region].enable = 0;
-   /* fall-through */
-   }
-   case GO7007IOC_S_MD_REGION:
-   {
-   struct go7007_md_region *region = arg;
-
-   if (region->region < 1 || region->region > 3)
-   return -EINVAL;
-   return clip_to_modet_map(go, region->region, region->clips);
-   }
-#endif
-
 static struct v4l2_ctrl_ops go7007_ctrl_ops = {
.s_ctrl = go7007_s_ctrl,
 };
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 5/7] hverkuil/go7007: staging: media: go7007: Functionality for modet controls

2013-03-10 Thread Volokh Konstantin
The idea of modet controls through userspace is:
The first of all need select region number (0..3) (it value stores)
And then config thresolds (pixel,motion,trigger) for that region.
Also it`s available setup regions controls (each of 16x16 rects of the frame,
where detection will be approve).
In user space need only add/delete or clear some rect (set 
top,left,width,height)
and system automaticaly set up each 16x16 rects for that.
Clear buttom/menu clears all modet region for detection. (idle work)

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-priv.h |9 ++-
 drivers/staging/media/go7007/go7007-v4l2.c |  120 
 2 files changed, 128 insertions(+), 1 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index fc8aac4..36b271f 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -226,7 +226,14 @@ struct go7007 {
} modet[4];
unsigned char modet_map[1624];
unsigned char active_map[216];
-
+   struct { /* modet type control cluster */
+   struct v4l2_ctrl *modet_clip_left;
+   struct v4l2_ctrl *modet_clip_top;
+   struct v4l2_ctrl *modet_clip_width;
+   struct v4l2_ctrl *modet_clip_height;
+   struct v4l2_ctrl *modet_region_number;
+   //struct v4l2_ctrl *mpeg_video_b_frames;
+   };
/* Video streaming */
struct mutex queue_lock;
struct vb2_queue vidq;
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index c4d0ca2..7ea0ea1 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -1137,6 +1137,86 @@ static struct video_device go7007_template = {
.tvnorms= V4L2_STD_ALL,
 };
 
+static void ClearModetMap(struct go7007 *go, char Region)
+{
+   /* Clear old region macroblocks */
+   int mbnum;
+
+   for (mbnum = 0; mbnum < sizeof(go->modet_map); ++mbnum)
+   if (go->modet_map[mbnum] == Region)
+   go->modet_map[mbnum] = 0;
+}
+
+static int RectToModetMap(struct go7007 *go,unsigned char Region,int Delete)
+{
+   register int x, y, mbnum;
+   struct v4l2_rect Rect;
+
+   Rect.left=v4l2_ctrl_g_ctrl(go->modet_clip_left);
+   Rect.top=v4l2_ctrl_g_ctrl(go->modet_clip_top);
+   Rect.width=v4l2_ctrl_g_ctrl(go->modet_clip_width);
+   Rect.height=v4l2_ctrl_g_ctrl(go->modet_clip_height);
+   /*!
+* Check if coordinates are OK and if any macroblocks are already
+* used by other regions (besides 0)
+*/
+
+   if (Rect.left < 0 || (Rect.left & 0xF) || Rect.width <= 0 || 
(Rect.width & 0xF))
+   return -EINVAL;
+
+   if (Rect.left+Rect.width > go->width)
+   return -EINVAL;
+
+   if (Rect.top < 0 || (Rect.top & 0xF) || Rect.height <= 0 || 
(Rect.height & 0xF))
+   return -EINVAL;
+
+   if (Rect.top+Rect.height > go->height)
+   return -EINVAL;
+
+   for (y = 0; y < Rect.height; y += 16)
+   for (x = 0; x < Rect.width; x += 16) {
+   mbnum = 
(go->width>>4)*((Rect.top+y)>>4)+((Rect.left+x)>>4);
+   if (go->modet_map[mbnum] != 0 && go->modet_map[mbnum] != Region)
+   return -EBUSY;
+   else
+   go->modet_map[mbnum] = Delete ? 0 : Region;
+   }
+   return 0;
+}
+
+void go7007_md_ctrl_notify(struct v4l2_ctrl *ctrl, void *priv) {
+   struct go7007 *go=priv;
+   int reg_num=v4l2_ctrl_g_ctrl(go->modet_region_number);
+
+   switch(ctrl->id) {
+   case V4L2_CID_USER_MODET_PIXEL_THRESOLD:
+   go->modet[reg_num].pixel_threshold = v4l2_ctrl_g_ctrl(ctrl) >> 
1;
+   break;
+   case V4L2_CID_USER_MODET_MOTION_THRESOLD:
+   go->modet[reg_num].motion_threshold = v4l2_ctrl_g_ctrl(ctrl) >> 
1;
+   break;
+   case V4L2_CID_USER_MODET_TRIGGER:
+   go->modet[reg_num].mb_threshold = v4l2_ctrl_g_ctrl(ctrl) >> 1;
+   go->modet[reg_num].enable = v4l2_ctrl_g_ctrl(ctrl) > 0;
+   break;
+   case V4L2_CID_USER_MODET_REGION_CONTROL:
+   switch (v4l2_ctrl_g_ctrl(ctrl)) {
+   case rcAdd:
+   RectToModetMap(go, reg_num, 0);
+   break;
+   case rcDelete:
+   RectToModetMap(go, reg_num, 1);
+   break;
+   case rcClear:
+   ClearModetMap(go, reg_num);
+   break;
+   default:
+   break;
+   }
+   break;
+   }
+}
+
 stat

[PATCH 4/7] hverkuil/go7007: staging: media: go7007: Add Modet controls

2013-03-10 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-v4l2.c |   95 
 drivers/staging/media/go7007/go7007.h  |   18 +
 2 files changed, 113 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 91e5572..c4d0ca2 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -1137,6 +1137,101 @@ static struct video_device go7007_template = {
.tvnorms= V4L2_STD_ALL,
 };
 
+static struct v4l2_ctrl_config md_configs[] = {
+   {
+   .ops = &go7007_ctrl_ops
+   ,.id = V4L2_CID_USER_MODET_REGION_NUMBER
+   ,.name = "Region MD"
+   ,.type = V4L2_CTRL_TYPE_INTEGER
+   ,.min = 0
+   ,.max = 3
+   ,.step = 1
+   ,.def = 0
+   }
+   ,{
+   .ops = &go7007_ctrl_ops
+   ,.id = V4L2_CID_USER_MODET_PIXEL_THRESOLD
+   ,.name = "Pixel Thresold"
+   ,.type = V4L2_CTRL_TYPE_INTEGER
+   ,.min = 0
+   ,.max = 65535
+   ,.step = 1
+   ,.def = 32767
+   }
+   ,{
+   .ops = &go7007_ctrl_ops
+   ,.id = V4L2_CID_USER_MODET_MOTION_THRESOLD
+   ,.name = "Motion Thresold"
+   ,.type = V4L2_CTRL_TYPE_INTEGER
+   ,.min = 0
+   ,.max = 65535
+   ,.step = 1
+   ,.def = 32767
+   }
+   ,{
+   .ops = &go7007_ctrl_ops
+   ,.id = V4L2_CID_USER_MODET_TRIGGER
+   ,.name = "Trigger"
+   ,.type = V4L2_CTRL_TYPE_INTEGER
+   ,.min = 0
+   ,.max = 65535
+   ,.step = 1
+   ,.def = 32767
+   }
+   ,{
+   .ops = &go7007_ctrl_ops
+   ,.id = V4L2_CID_USER_MODET_CLIP_LEFT
+   ,.name = "Left of Region"
+   ,.type = V4L2_CTRL_TYPE_INTEGER
+   ,.min = 0
+   ,.step = 1
+   ,.def = 0
+   }
+   ,{
+   .ops = &go7007_ctrl_ops
+   ,.id = V4L2_CID_USER_MODET_CLIP_TOP
+   ,.name = "Top of Region"
+   ,.type = V4L2_CTRL_TYPE_INTEGER
+   ,.min = 0
+   ,.step = 1
+   ,.def = 0
+   }
+   ,{
+   .ops = &go7007_ctrl_ops
+   ,.id = V4L2_CID_USER_MODET_CLIP_WIDTH
+   ,.name = "Width of Region"
+   ,.type = V4L2_CTRL_TYPE_INTEGER
+   ,.min = 0
+   ,.step = 1
+   ,.def = 0
+   }
+   ,{
+   .ops = &go7007_ctrl_ops
+   ,.id = V4L2_CID_USER_MODET_CLIP_HEIGHT
+   ,.name = "Height of Region"
+   ,.type = V4L2_CTRL_TYPE_INTEGER
+   ,.min = 0
+   ,.step = 1
+   ,.def = 0
+   }
+   ,{
+   .ops = &go7007_ctrl_ops
+   ,.id = V4L2_CID_USER_MODET_REGION_CONTROL
+   ,.name = "Region Control"
+   ,.type = V4L2_CTRL_TYPE_MENU
+   ,.min = rcAdd
+   ,.max = rcClear
+   ,.step = 0
+   ,.def = rcClear
+   ,.qmenu = (const char * const[]){
+   "Add"
+   ,"Delete"
+   ,"Clear"
+   ,NULL
+   }
+   }
+};
+
 int go7007_v4l2_ctrl_init(struct go7007 *go)
 {
struct v4l2_ctrl_handler *hdl = &go->hdl;
diff --git a/drivers/staging/media/go7007/go7007.h 
b/drivers/staging/media/go7007/go7007.h
index 54b9897..fcb45ea 100644
--- a/drivers/staging/media/go7007/go7007.h
+++ b/drivers/staging/media/go7007/go7007.h
@@ -38,3 +38,21 @@ struct go7007_md_region {
struct go7007_md_params)
 #defineGO7007IOC_S_MD_REGION   _IOW('V', BASE_VIDIOC_PRIVATE + 8, \
struct go7007_md_region)
+
+#define V4L2_CID_USER_GO7007_BASE  (V4L2_CID_USER_BASE + 
0x1000)
+#define V4L2_CID_USER_MODET_REGION_NUMBER  
(V4L2_CID_USER_GO7007_BASE + 0x01)
+#define V4L2_CID_USER_MODET_PIXEL_THRESOLD 
(V4L2_CID_USER_GO7007_BASE + 0x02)
+#define V4L2_CID_USER_MODET_MOTION_THRESOLD
(V4L2_CID_USER_GO7007_BASE + 0x03)
+#define V4L2_CID_USER_MODET_TRIGGER
(V4L2_CID_USER_GO7007_BASE + 0x04)
+#define V4L2_CID_USER_MODET_REGION_CONTROL 
(V4L2_CID_USER_GO7007_BASE + 0x05)
+#define V4L2_CID_USER_MODET_CLIP_LEFT  
(V4L2_CID_USER_GO7007_BASE + 0x06)
+#define V4L2_CID_USER_MODET_CLIP_TOP  

[PATCH 3/7] hverkuil/go7007: staging: media: go7007: Restore b_frame control

2013-03-10 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-priv.h |1 +
 drivers/staging/media/go7007/go7007-v4l2.c |7 +--
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index e969df1..fc8aac4 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -174,6 +174,7 @@ struct go7007 {
struct v4l2_ctrl *mpeg_video_gop_size;
struct v4l2_ctrl *mpeg_video_gop_closure;
struct v4l2_ctrl *mpeg_video_bitrate;
+   struct v4l2_ctrl *mpeg_video_b_frames;
};
struct v4l2_ctrl *mpeg_video_aspect_ratio;
enum { STATUS_INIT, STATUS_ONLINE, STATUS_SHUTDOWN } status;
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 96538f6..91e5572 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -155,7 +155,7 @@ static void set_formatting(struct go7007 *go)
go->gop_header_enable = 1;
go->repeat_seqhead = 0;
go->dvd_mode = 0;
-   go->ipb = 0;
+   go->ipb = v4l2_ctrl_g_ctrl(go->mpeg_video_b_frames);
 
switch (v4l2_ctrl_g_ctrl(go->mpeg_video_aspect_ratio)) {
default:
@@ -1143,7 +1143,7 @@ int go7007_v4l2_ctrl_init(struct go7007 *go)
struct v4l2_ctrl *ctrl;
int rv;
 
-   v4l2_ctrl_handler_init(hdl, 12);
+   v4l2_ctrl_handler_init(hdl, 24);
go->mpeg_stream_type = v4l2_ctrl_new_std_menu(hdl, &go7007_ctrl_ops,
V4L2_CID_MPEG_STREAM_TYPE,
V4L2_MPEG_STREAM_TYPE_MPEG2_DVD,
@@ -1160,6 +1160,9 @@ int go7007_v4l2_ctrl_init(struct go7007 *go)
go->mpeg_video_bitrate = v4l2_ctrl_new_std(hdl, &go7007_ctrl_ops,
V4L2_CID_MPEG_VIDEO_BITRATE,
64000, 1000, 1, 150);
+   go->mpeg_video_b_frames = v4l2_ctrl_new_std(hdl, &go7007_ctrl_ops,
+   V4L2_CID_MPEG_VIDEO_B_FRAMES,
+   0, 2, 1, 0);
go->mpeg_video_aspect_ratio = v4l2_ctrl_new_std_menu(hdl, 
&go7007_ctrl_ops,
V4L2_CID_MPEG_VIDEO_ASPECT,
V4L2_MPEG_VIDEO_ASPECT_16x9, 0,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/7] hverkuil/go7007: staging: media: go7007: Add Framesizes

2013-03-10 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-v4l2.c |   76 
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 66307ea..4ec9b84 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -612,6 +612,82 @@ static int vidioc_enum_framesizes(struct file *filp, void 
*priv,
 {
struct go7007 *go = video_drvdata(filp);
 
+   if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
+   switch (go->standard) {
+   case GO7007_STD_NTSC:
+   switch (fsize->pixel_format) {
+   case V4L2_PIX_FMT_MJPEG:
+   case V4L2_PIX_FMT_MPEG:
+   case V4L2_PIX_FMT_H263:
+   switch (fsize->index) {
+   case 0:
+   fsize->type = 
V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = 720;
+   fsize->discrete.height = 480;
+   break;
+   case 1:
+   fsize->type = 
V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = 640;
+   fsize->discrete.height = 480;
+   break;
+   case 2:
+   fsize->type = 
V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = 352;
+   fsize->discrete.height = 240;
+   break;
+   case 3:
+   fsize->type = 
V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = 320;
+   fsize->discrete.height = 240;
+   break;
+   case 4:
+   fsize->type = 
V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = 176;
+   fsize->discrete.height = 112;
+   break;
+   default:
+   return -EINVAL;
+   }
+   break;
+   default:
+   return -EINVAL;
+   }
+   break;
+   case GO7007_STD_PAL:
+   switch (fsize->pixel_format) {
+   case V4L2_PIX_FMT_MJPEG:
+   case V4L2_PIX_FMT_MPEG:
+   case V4L2_PIX_FMT_H263:
+   switch (fsize->index) {
+   case 0:
+   fsize->type = 
V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = 720;
+   fsize->discrete.height = 576;
+   break;
+   case 1:
+   fsize->type = 
V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = 352;
+   fsize->discrete.height = 288;
+   break;
+   case 2:
+   fsize->type = 
V4L2_FRMSIZE_TYPE_DISCRETE;
+   fsize->discrete.width = 176;
+   fsize->discrete.height = 144;
+   break;
+   default:
+   return -EINVAL;
+   }
+   break;
+   default:
+   return -EINVAL;
+   }
+   break;
+   default:
+   return -EINVAL;
+   }
+   return 0;
+   }
+
if (fsize->index > 0)
return -EINVAL;
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/7] hverkuil/go7007: staging: media: go7007: Add Frameintervals

2013-03-10 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-v4l2.c |  123 
 1 files changed, 123 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index 4ec9b84..96538f6 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -703,6 +703,129 @@ static int vidioc_enum_frameintervals(struct file *filp, 
void *priv,
 {
struct go7007 *go = video_drvdata(filp);
 
+   if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
+   switch (fival->pixel_format) {
+   case V4L2_PIX_FMT_MJPEG:
+   case V4L2_PIX_FMT_MPEG:
+   case V4L2_PIX_FMT_H263:
+   switch (go->standard) {
+   case GO7007_STD_NTSC:
+   switch (fival->index) {
+   case 0:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*1;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   case 1:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*2;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   case 2:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*3;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   case 3:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*4;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   case 4:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*5;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   case 5:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*6;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   case 6:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*7;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   case 7:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*10;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   case 8:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*15;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   case 9:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*30;
+   fival->discrete.denominator = 
go->sensor_framerate;
+   break;
+   default:
+   return -EINVAL;
+   }
+   break;
+   case GO7007_STD_PAL:
+   switch (fival->index) {
+   case 0:
+   fival->type = 
V4L2_FRMIVAL_TYPE_DISCRETE;
+   fival->discrete.numerator = 1001*1;
+

[PATCH 2/2] hverkuil/go7007: media: i2c: Correct authorship info

2013-03-06 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/media/i2c/tw2804.c |1 -
 1 files changed, 0 insertions(+), 1 deletions(-)

diff --git a/drivers/media/i2c/tw2804.c b/drivers/media/i2c/tw2804.c
index 096b657..45a4cd3 100644
--- a/drivers/media/i2c/tw2804.c
+++ b/drivers/media/i2c/tw2804.c
@@ -431,5 +431,4 @@ module_i2c_driver(wis_tw2804_driver);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("TW2804/TW2802 V4L2 i2c driver");
-MODULE_AUTHOR("Volokh Konstantin ");
 MODULE_AUTHOR("Micronas USA Inc");
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/2] hverkuil/go7007: media: i2c: Fix compilation errors

2013-03-06 Thread Volokh Konstantin
Fix warnings as errors:
error: implicit declaration of function ‘kzalloc’ 
[-Werror=implicit-function-declaration]
error: implicit declaration of function ‘kfree’ 
[-Werror=implicit-function-declaration]

Signed-off-by: Volokh Konstantin 
---
 drivers/media/i2c/ov7640.c|1 +
 drivers/media/i2c/tw9903.c|1 +
 drivers/media/i2c/uda1342.c   |1 +
 drivers/media/tuners/sony-tuner.c |1 +
 4 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/drivers/media/i2c/ov7640.c b/drivers/media/i2c/ov7640.c
index 535cf29..224d7cd 100644
--- a/drivers/media/i2c/ov7640.c
+++ b/drivers/media/i2c/ov7640.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 MODULE_DESCRIPTION("OmniVision ov7640 sensor driver");
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/i2c/tw9903.c b/drivers/media/i2c/tw9903.c
index f859d3a..0c39d38 100644
--- a/drivers/media/i2c/tw9903.c
+++ b/drivers/media/i2c/tw9903.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include 
 
 MODULE_DESCRIPTION("TW9903 I2C subdev driver");
 MODULE_LICENSE("GPL v2");
diff --git a/drivers/media/i2c/uda1342.c b/drivers/media/i2c/uda1342.c
index 82319d0..7800236 100644
--- a/drivers/media/i2c/uda1342.c
+++ b/drivers/media/i2c/uda1342.c
@@ -21,6 +21,7 @@
 #include 
 #include 
 #include 
+#include 
 
 static int write_reg(struct i2c_client *client, int reg, int value)
 {
diff --git a/drivers/media/tuners/sony-tuner.c 
b/drivers/media/tuners/sony-tuner.c
index 1b77529..8411e97 100644
--- a/drivers/media/tuners/sony-tuner.c
+++ b/drivers/media/tuners/sony-tuner.c
@@ -23,6 +23,7 @@
 #include 
 #include 
 #include 
+#include 
 
 MODULE_DESCRIPTION("Sony TV Tuner driver");
 MODULE_LICENSE("GPL v2");
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: Regarding linux go7007 driver

2013-03-06 Thread Volokh Konstantin
On Wed, Mar 06, 2013 at 12:52:00PM -0500, Darrick Burch wrote:
> Kolokh:
> 
> I've been doing some work on the go7007 driver in order to make it work
> properly with my device, an ADS DVD XPress DX2.  This device is USB and
> uses the EZ-USB controller using a tw9906 as a video decoder.  There is
> actually a patch floating around which is supposed to make this work and
> I've been able to merge the needed changes in order for the go7007-usb
> driver to detect the device.
> 
Hi, Darrick,
Hans Verkuil start to a massive overhaul of the go7007 driver , so he collect 
these patches on
http://git.linuxtv.org/hverkuil/media_tree.git/shortlog/refs/heads/go7007

for git use latest:
git remote add hverkuil git://git.linuxtv.org/hverkuil/media_tree.git 
git remote update
git checkout -b go7007 hverkuil/go7007

So, there are last patches applied (including mine).
I hope, what that work will be merged in linux.git branch (when repair will 
done)

> However, I see that there is a problem with the way the i2c subdevice
> modules are written.  When the go7007 module attempts to register any of
> these subdevices with video4linux, there is a kernel oops since their
> private state structs do not contain v4l2_subdev as a first member.
> 
> I see that you had attempted to correct this problem for the tw2804 in
> this patch...
> 
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/staging/media/go7007?id=0982db20aba5fd124bb5942d679d8732478e992a
> 
> ..but it was rejected and reverted.  Was there a reason why it was never
> resubmitted?  I see an opportunity to get acquainted with kernel module
> development by fixing the subdevice drivers, but I didn't know if there
> were any existing plans for this module and whether or not my effort would
> be worth it.
> 
> Thanks,
> -Darrick
Regards,
Volokh
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/4] staging: media: go7007: i2c GPIO initialization Reset i2c stuff for GO7007_BOARDID_ADLINK_MPG24 need reset GPIO always when encoder initialize

2013-01-16 Thread Volokh Konstantin
On Wed, Jan 16, 2013 at 04:36:08PM +0300, Dan Carpenter wrote:
> You've added the writes for GO7007_BOARDID_ADLINK_MPG24 but removed
> them for GO7007_BOARDID_XMEN and GO7007_BOARDID_XMEN_III.  Won't
> that break those boards?
>
I don`t remove code for GO7007_BOARDID_XMEN and GO7007_BOARDID_XMEN_III.
case there are auto reusing for XMen and XMen-III:
look old code:
if ((go->board_id == GO7007_BOARDID_XMEN ||
go->board_id == GO7007_BOARDID_XMEN_III) &&
go->i2c_adapter_online) {
union i2c_smbus_data data;

/* Check to see if register 0x0A is 0x76 */
i2c_smbus_xfer(&go->i2c_adapter, 0x21, I2C_CLIENT_SCCB,
I2C_SMBUS_READ, 0x0A, I2C_SMBUS_BYTE_DATA, &data);
if (data.byte != 0x76) {
if (assume_endura) {
go->board_id = GO7007_BOARDID_ENDURA;
usb->board = board = &board_endura;
go->board_info = &board->main_info;
strncpy(go->name, "Pelco Endura",
sizeof(go->name));
} else {
u16 channel;
-   /* set GPIO5 to be an output, currently low */
-   go7007_write_addr(go, 0x3c82, 0x);
-   go7007_write_addr(go, 0x3c80, 0x00df);
/* read channel number from GPIO[1:0] */
go7007_read_addr(go, 0x3c81, &channel);
channel &= 0x3;
>>> go->board_id = GO7007_BOARDID_ADLINK_MPG24;
Here any XMen or XMen-III will reassigned as Adlink-mpg24 id
so any i2c initialization will reassigned to that id and we can use that id in
init_encoder.
usb->board = board = &board_adlink_mpg24;
go->board_info = &board->main_info;
go->channel_number = channel;
snprintf(go->name, sizeof(go->name),
"Adlink PCI-MPG24, channel #%d",
channel);
}
}
}
> regards,
> dan carpenter
> 
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 2/4] staging: media: go7007: firmware protection Protection for unfirmware load

2013-01-16 Thread Volokh Konstantin
On Wed, Jan 16, 2013 at 04:35:45PM +0300, Dan Carpenter wrote:
> The problem is that the firmware was being unloaded on disconnect?
> 
> regards,
> dan carpenter
If no firmware was loaded (no exists,wrong or some error) then rmmod fails with 
OOPS,
so need some protection stuff
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 1/4] staging: media: go7007: memory clear fix memory clearing for v4l2_subdev allocation

2013-01-16 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-driver.c |2 +-
 drivers/staging/media/go7007/go7007-v4l2.c   |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index ece2dd1..a66e339 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -571,7 +571,7 @@ struct go7007 *go7007_alloc(struct go7007_board_info 
*board, struct device *dev)
struct go7007 *go;
int i;
 
-   go = kmalloc(sizeof(struct go7007), GFP_KERNEL);
+   go = kzalloc(sizeof(struct go7007), GFP_KERNEL);
if (go == NULL)
return NULL;
go->dev = dev;
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index a78133b..e6fa543 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -98,7 +98,7 @@ static int go7007_open(struct file *file)
 
if (go->status != STATUS_ONLINE)
return -EBUSY;
-   gofh = kmalloc(sizeof(struct go7007_file), GFP_KERNEL);
+   gofh = kzalloc(sizeof(struct go7007_file), GFP_KERNEL);
if (gofh == NULL)
return -ENOMEM;
++go->ref_count;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 4/4] staging: media: go7007: call_all stream stuff Some Additional stuff for v4l2_subdev stream events partial need for new style framework. Also need for wis_tw2804 notification stuff

2013-01-16 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-v4l2.c |2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index a69250f..2330861 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -953,6 +953,7 @@ static int vidioc_streamon(struct file *file, void *priv,
}
mutex_unlock(&go->hw_lock);
mutex_unlock(&gofh->lock);
+   call_all(&go->v4l2_dev, video, s_stream, 1);
 
return retval;
 }
@@ -968,6 +969,7 @@ static int vidioc_streamoff(struct file *file, void *priv,
mutex_lock(&gofh->lock);
go7007_streamoff(go);
mutex_unlock(&gofh->lock);
+   call_all(&go->v4l2_dev, video, s_stream, 0);
 
return 0;
 }
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] staging: media: go7007: i2c GPIO initialization Reset i2c stuff for GO7007_BOARDID_ADLINK_MPG24 need reset GPIO always when encoder initialize

2013-01-16 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-driver.c |5 +
 drivers/staging/media/go7007/go7007-usb.c|3 ---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index a66e339..c0ea312 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -173,6 +173,11 @@ static int go7007_init_encoder(struct go7007 *go)
go7007_write_addr(go, 0x3c82, 0x0001);
go7007_write_addr(go, 0x3c80, 0x00fe);
}
+   if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
+   /* set GPIO5 to be an output, currently low */
+   go7007_write_addr(go, 0x3c82, 0x);
+   go7007_write_addr(go, 0x3c80, 0x00df);
+   }
return 0;
 }
 
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index a6cad15..9dbf5ec 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1110,9 +1110,6 @@ static int go7007_usb_probe(struct usb_interface *intf,
} else {
u16 channel;
 
-   /* set GPIO5 to be an output, currently low */
-   go7007_write_addr(go, 0x3c82, 0x);
-   go7007_write_addr(go, 0x3c80, 0x00df);
/* read channel number from GPIO[1:0] */
go7007_read_addr(go, 0x3c81, &channel);
channel &= 0x3;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/4] staging: media: go7007: firmware protection Protection for unfirmware load

2013-01-16 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-usb.c  |2 +-
 drivers/staging/media/go7007/go7007-v4l2.c |3 ++-
 2 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 5443e25..a6cad15 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1245,7 +1245,6 @@ static void go7007_usb_disconnect(struct usb_interface 
*intf)
struct urb *vurb, *aurb;
int i;
 
-   go->status = STATUS_SHUTDOWN;
usb_kill_urb(usb->intr_urb);
 
/* Free USB-related structs */
@@ -1269,6 +1268,7 @@ static void go7007_usb_disconnect(struct usb_interface 
*intf)
kfree(go->hpi_context);
 
go7007_remove(go);
+   go->status = STATUS_SHUTDOWN;
 }
 
 static struct usb_driver go7007_usb_driver = {
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index e6fa543..a69250f 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -1832,5 +1832,6 @@ void go7007_v4l2_remove(struct go7007 *go)
mutex_unlock(&go->hw_lock);
if (go->video_dev)
video_unregister_device(go->video_dev);
-   v4l2_device_unregister(&go->v4l2_dev);
+   if (go->status != STATUS_SHUTDOWN)
+   v4l2_device_unregister(&go->v4l2_dev);
 }
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: go7007 question

2012-09-09 Thread volokh
On Sun, Sep 09, 2012 at 08:21:55AM -0400, Adam Rosi-Kessel wrote:
> On Sat, Sep 08, 2012 at 10:23:31PM -0400, Adam Rosi-Kessel wrote:
> > On Fri, Sep 07, 2012 at 06:18:31PM +0400, vol...@telros.ru wrote:
> > > On Thu, Sep 06, 2012 at 11:10:14PM +0400, Volokh Konstantin wrote:
> > e > On Mon, Sep 03, 2012 at 02:37:16PM -0400, Adam Rosi-Kessel wrote:
> > > > > [469.928881] wis-saa7115: initializing SAA7115 at address 32 on WIS
> > > > > GO7007SB EZ-USB
> > > Hi, I generated patchs, that u may in your own go7007/ folder
> > > It contains go7007 initialization and i2c_subdev fixing
> > > It was checked for 3.6 branch (compile only)
> > So I have this installed now (patched with your 3.6 patch) but I'm not
> > seeing the device.
> 
> OK, this was just a problem of needing to mount /proc/usb. With that
> mounted, the device is detected and the modules load automatically.
> gorecord just hangs, however:
> 
> [ cut here ]
> WARNING: at drivers/usb/core/urb.c:414 usb_submit_urb+0x12a/0x3e0()
> Hardware name: Inspiron 530
> Device: usb
> BOGUS urb xfer, pipe 1 != type 3
> Modules linked in: wis_sony_tuner(C) wis_uda1342(C) go7007_usb(C) go7007(C) 
> v4l2_common videodev media xt_LOG fuse ext4 jbd2 crc16 e1000e
I`m not seeing wis-sa7115 module, (it`s main  module for video device)
> [last unloaded: go7007]
> Pid: 18595, comm: gorecord Tainted: GWC   3.6.0-rc4
> Call Trace:
>  [] warn_slowpath_common+0x6d/0xa0
>  [] ? usb_submit_urb+0x12a/0x3e0
Some error in URB,
did u machine have any ATI chipset?
>  [] ? usb_submit_urb+0x12a/0x3e0
>  [] warn_slowpath_fmt+0x2e/0x30
>  [] usb_submit_urb+0x12a/0x3e0
>  [] go7007_usb_read_interrupt+0x1a/0x40 [go7007_usb]
>  [] go7007_read_interrupt+0x24/0x100 [go7007]
>  [] ? go7007_usb_send_firmware+0x3e/0x60 [go7007_usb]
>  [] go7007_start_encoder+0x7d/0x120 [go7007]
>  [] ? mutex_lock+0x14/0x40
>  [] vidioc_streamon+0xdc/0xf0 [go7007]
>  [] v4l_streamon+0x15/0x20 [videodev]
>  [] __video_do_ioctl+0x28c/0x3a0 [videodev]
>  [] ? ktime_get+0x43/0xf0
>  [] ? clockevents_program_event+0xca/0x180
>  [] ? _copy_from_user+0x38/0x130
>  [] video_usercopy+0x143/0x320 [videodev]
>  [] ? irq_exit+0x54/0xc0
>  [] ? smp_apic_timer_interrupt+0x54/0x90
>  [] ? inotify_handle_event+0x51/0xc0
>  [] ? idr_callback+0x80/0x80
>  [] ? apic_timer_interrupt+0x2a/0x30
>  [] video_ioctl2+0x12/0x20 [videodev]
>  [] ? v4l2_ioctl_get_lock+0x50/0x50 [videodev]
>  [] v4l2_ioctl+0x103/0x150 [videodev]
>  [] ? v4l2_open+0x140/0x140 [videodev]
Can u send me:
ls /dev/video*
ls /dev/audio*
ls /dev/tun*
tail -n 500 /var/log/messages (after calling go_record)
>  [] do_vfs_ioctl+0x7e/0x5c0
>  [] ? file_has_perm+0x9a/0xc0
>  [] ? selinux_file_ioctl+0x56/0x110
>  [] sys_ioctl+0x7f/0x90
>  [] sysenter_do_call+0x12/0x22
> ---[ end trace 04d11de2981e53e3 ]---
Thanks.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: go7007 question

2012-09-09 Thread volokh
On Sat, Sep 08, 2012 at 10:23:31PM -0400, Adam Rosi-Kessel wrote:
> On Fri, Sep 07, 2012 at 06:18:31PM +0400, vol...@telros.ru wrote:
> > On Thu, Sep 06, 2012 at 11:10:14PM +0400, Volokh Konstantin wrote:
> > > On Mon, Sep 03, 2012 at 02:37:16PM -0400, Adam Rosi-Kessel wrote:
> > > > 
> > > > [469.928881] wis-saa7115: initializing SAA7115 at address 32 on WIS
> > > > GO7007SB EZ-USB
> > > > 
> > > > [469.989083] go7007: probing for module i2c:wis_saa7115 failed
> > > > 
> > > > [470.004785] wis-uda1342: initializing UDA1342 at address 26 on WIS
> > > > GO7007SB EZ-USB
> > > > 
> > > > [470.005454] go7007: probing for module i2c:wis_uda1342 failed
> > > > 
> > > > [470.011659] wis-sony-tuner: initializing tuner at address 96 on WIS
> > > > GO7007SB EZ-USB
> > Hi, I generated patchs, that u may in your own go7007/ folder
> > It contains go7007 initialization and i2c_subdev fixing
> > 
> > It was checked for 3.6 branch (compile only)
> 
> So I have this installed now (patched with your 3.6 patch) but I'm not
> seeing the device.
> 
> The module is there:
> 
> [  416.189030] Linux media interface: v0.10
> [  416.198616] Linux video capture interface: v2.00
> [  416.220656] wis_uda1342: module is from the staging directory, the quality 
> is unknown, you have been warned.
> 
> # lsmod|grep -i go7
> go7007_usb 10059  0 
> go7007 46966  1 go7007_usb
> v4l2_common 4206  1 go7007
> videodev   78250  2 go7007,v4l2_common
> 
> # uname -a
> Linux storage 3.6.0-rc4.ajk+ #5 SMP Sat Sep 8 22:05:57 EDT 2012 i686 GNU/Linux
> 
> # grep -i go7 /boot/config-`uname -r`
> CONFIG_VIDEO_GO7007=m
> CONFIG_VIDEO_GO7007_USB=m
> CONFIG_VIDEO_GO7007_OV7640=m
> # CONFIG_VIDEO_GO7007_SAA7113 is not set
Linux must autoload these modules for working:
wis-saa7115
wis-uda1342
wis-sony-tuner,
so need set m below:
> # CONFIG_VIDEO_GO7007_SAA7115 is not set
> CONFIG_VIDEO_GO7007_TW9903=m
> CONFIG_VIDEO_GO7007_UDA1342=m
> CONFIG_VIDEO_GO7007_SONY_TUNER=m
> CONFIG_VIDEO_GO7007_TW2804=m

after compilation need install modules, or handly load them.
modprobe wis-saa7115, etc ... for each modules.

> 
> But I'm not getting any device to appear:
> 
> # ls /dev/video*
> ls: cannot access /dev/video*: No such file or directory
> # gorecord -format mpeg4 test.avi
> Driver loaded but no GO7007 devices found.
> Is the device connected properly?
> 
> When I connect the device I see this:
> 
> [  585.705406] usb 1-4: udev 4, busnum 1, minor = 3
> [  585.705412] usb 1-4: New USB device found, idVendor=093b, idProduct=a004
> [  585.705415] usb 1-4: New USB device strings: Mfr=0, Product=0, 
> SerialNumber=0
> [  585.705532] usb 1-4: usb_probe_device
> [  585.705535] usb 1-4: configuration #1 chosen from 1 choice
> [  585.706233] usb 1-4: adding 1-4:1.0 (config #1, interface 0)
> 
> But no video node.
> 
> Am I missing something?
> 
> Adam
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: go7007 question

2012-09-07 Thread volokh
On Thu, Sep 06, 2012 at 11:10:14PM +0400, Volokh Konstantin wrote:
> On Mon, Sep 03, 2012 at 02:37:16PM -0400, Adam Rosi-Kessel wrote:
> > 
> > [469.928881] wis-saa7115: initializing SAA7115 at address 32 on WIS
> > GO7007SB EZ-USB
> > 
> > [469.989083] go7007: probing for module i2c:wis_saa7115 failed
> > 
> > [470.004785] wis-uda1342: initializing UDA1342 at address 26 on WIS
> > GO7007SB EZ-USB
> > 
> > [470.005454] go7007: probing for module i2c:wis_uda1342 failed
> > 
> > [470.011659] wis-sony-tuner: initializing tuner at address 96 on WIS
> > GO7007SB EZ-USB
Hi, I generated patchs, that u may in your own go7007/ folder
It contains go7007 initialization and i2c_subdev fixing

It was checked for 3.6 branch (compile only)
 
Regards,
Volokh Konstantin
diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index ece2dd1..2dff9b5 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -173,6 +173,11 @@ static int go7007_init_encoder(struct go7007 *go)
go7007_write_addr(go, 0x3c82, 0x0001);
go7007_write_addr(go, 0x3c80, 0x00fe);
}
+   if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
+   /* set GPIO5 to be an output, currently low */
+   go7007_write_addr(go, 0x3c82, 0x);
+   go7007_write_addr(go, 0x3c80, 0x00df);
+   }
return 0;
 }
 
@@ -192,17 +197,23 @@ int go7007_reset_encoder(struct go7007 *go)
 /*
  * Attempt to instantiate an I2C client by ID, probably loading a module.
  */
-static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
-  int addr)
+static int init_i2c_module(struct i2c_adapter *adapter, const struct go_i2c 
*const i2c)
 {
struct go7007 *go = i2c_get_adapdata(adapter);
struct v4l2_device *v4l2_dev = &go->v4l2_dev;
+   struct i2c_board_info info;
+
+   memset(&info, 0, sizeof(info));
+   strlcpy(info.type, i2c->type, sizeof(info.type));
+   info.addr = i2c->addr;
 
-   if (v4l2_i2c_new_subdev(v4l2_dev, adapter, type, addr, NULL))
+   if (i2c->id == I2C_DRIVERID_WIS_TW2804)
+   info.flags |= I2C_CLIENT_TEN;
+   if (v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, NULL))
return 0;
 
-   printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", type);
-   return -1;
+   printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", 
i2c->type);
+   return -EINVAL;
 }
 
 /*
@@ -238,9 +249,7 @@ int go7007_register_encoder(struct go7007 *go)
}
if (go->i2c_adapter_online) {
for (i = 0; i < go->board_info->num_i2c_devs; ++i)
-   init_i2c_module(&go->i2c_adapter,
-   go->board_info->i2c_devs[i].type,
-   go->board_info->i2c_devs[i].addr);
+   init_i2c_module(&go->i2c_adapter, 
&go->board_info->i2c_devs[i]);
if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
i2c_clients_command(&go->i2c_adapter,
DECODER_SET_CHANNEL, &go->channel_number);
@@ -571,7 +580,7 @@ struct go7007 *go7007_alloc(struct go7007_board_info 
*board, struct device *dev)
struct go7007 *go;
int i;
 
-   go = kmalloc(sizeof(struct go7007), GFP_KERNEL);
+   go = kzalloc(sizeof(struct go7007), GFP_KERNEL);
if (go == NULL)
return NULL;
go->dev = dev;
diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index b58c394..b7b939a 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -88,7 +88,7 @@ struct go7007_board_info {
int audio_bclk_div;
int audio_main_div;
int num_i2c_devs;
-   struct {
+   struct go_i2c {
const char *type;
int id;
int addr;
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 5443e25..9dbf5ec 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1110,9 +1110,6 @@ static int go7007_usb_probe(struct usb_interface *intf,
} else {
u16 channel;
 
-   /* set GPIO5 to be an output, currently low */
-   go7007_write_addr(go, 0x3c82, 0x);
-   go7007_write_addr(go, 0x3c80, 0x00df);
/* read channel number from GPIO[1:0] */
go7007_read_addr(go,

Re: go7007 question

2012-09-06 Thread Volokh Konstantin
nel.org/msg50922.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg50924.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg50929.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg50926.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg50925.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg50928.html
http://www.mail-archive.com/linux-media@vger.kernel.org/msg50927.html

It need apply at once.
But It was tested only with Angelo-MPG24 board, although it contans commonly 
initialization part

> Adam

Regards,
Volokh Konstantin
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 01/10] staging: media: go7007: Some additional code for TW2804 driver functionality

2012-08-21 Thread Volokh Konstantin
- using new v4l2 framework controls
- function for reading volatile controls via i2c bus
- separate V4L2_CID_ ctrls into each V4L2 calls

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/wis-tw2804.c |  248 +
 1 files changed, 248 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/media/go7007/wis-tw2804.c 
b/drivers/staging/media/go7007/wis-tw2804.c
index 9134f03..05851d3 100644
--- a/drivers/staging/media/go7007/wis-tw2804.c
+++ b/drivers/staging/media/go7007/wis-tw2804.c
@@ -21,10 +21,18 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #include "wis-i2c.h"
 
 struct wis_tw2804 {
+   struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+   u8 channel:2;
+   u8 input:1;
int channel;
int norm;
int brightness;
@@ -116,9 +124,246 @@ static int write_regs(struct i2c_client *client, u8 
*regs, int channel)
if (i2c_smbus_write_byte_data(client,
regs[i] | (channel << 6), regs[i + 1]) < 0)
return -1;
+static s32 read_reg(struct i2c_client *client, u8 reg, u8 channel)
+{
+   return i2c_smbus_read_byte_data(client, (reg) | (channel << 6));
+}
+
+inline struct wis_tw2804 *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct wis_tw2804, sd);
+}
+
+inline struct wis_tw2804 *to_state_from_ctrl(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl->handler, struct wis_tw2804, hdl);
+}
+
+static int tw2804_log_status(struct v4l2_subdev *sd)
+{
+   struct wis_tw2804 *state = to_state(sd);
+   v4l2_info(sd, "Standard: %s\n",
+   state->norm == V4L2_STD_NTSC ? "NTSC" :
+   state->norm == V4L2_STD_PAL ? "PAL" : "unknown");
+   v4l2_info(sd, "Channel: %d\n", state->channel);
+   v4l2_info(sd, "Input: %d\n", state->input);
+   v4l2_ctrl_handler_log_status(&state->hdl, sd->name);
+   return 0;
+}
+
+static s32 get_ctrl_addr(int ctrl)
+{
+   switch (ctrl) {
+   case V4L2_CID_BRIGHTNESS:
+   return 0x12;
+   case V4L2_CID_CONTRAST:
+   return 0x11;
+   case V4L2_CID_SATURATION:
+   return 0x10;
+   case V4L2_CID_HUE:
+   return 0x0f;
+   case V4L2_CID_AUTOGAIN:
+   return 0x02;
+   case V4L2_CID_COLOR_KILLER:
+   return 0x14;
+   case V4L2_CID_GAIN:
+   return 0x3c;
+   case V4L2_CID_CHROMA_GAIN:
+   return 0x3d;
+   case V4L2_CID_RED_BALANCE:
+   return 0x3f;
+   case V4L2_CID_BLUE_BALANCE:
+   return 0x3e;
+   default:
+   return -EINVAL;
+   }
+}
+
+static int tw2804_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct v4l2_subdev *sd = &to_state_from_ctrl(ctrl)->sd;
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   s32 addr = get_ctrl_addr(ctrl->id);
+
+   if (addr == -EINVAL)
+   return -EINVAL;
+
+   switch (ctrl->id) {
+   case V4L2_CID_GAIN:
+   case V4L2_CID_CHROMA_GAIN:
+   case V4L2_CID_RED_BALANCE:
+   case V4L2_CID_BLUE_BALANCE:
+   ctrl->cur.val = read_reg(client, addr, 0);
+   break;
+   default:
+   return -EINVAL;
+   }
+   return 0;
+}
+
+static int tw2804_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct wis_tw2804 *state = to_state_from_ctrl(ctrl);
+   struct v4l2_subdev *sd = &state->sd;
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   s32 reg = ctrl->val;
+   s32 addr = get_ctrl_addr(ctrl->id);
+
+   if (addr == -EINVAL)
+   return -EINVAL;
+
+   switch (ctrl->id) {
+   case V4L2_CID_AUTOGAIN:
+   reg = read_reg(client, addr, state->channel);
+   if (reg > 0) {
+   if (ctrl->val == 0)
+   reg &= ~(1<<7);
+   else
+   reg |= 1<<7;
+   } else
+   return reg;
+   break;
+   case V4L2_CID_COLOR_KILLER:
+   reg = read_reg(client, addr, state->channel);
+   if (reg > 0)
+   reg = (reg & ~(0x03)) | (ctrl->val == 0 ? 0x02 : 0x03);
+   else
+   return reg;
+   break;
+   default:
+   break;
+   }
+
+   reg = reg > 255 ? 255 : (reg < 0 ? 0 : reg);
+   reg = write_reg(client, addr, (u8)reg,
+   ctrl->id == V4L2_CID_GAIN ||
+   ctrl->id == V4L2_CID_CHROMA_GAIN ||
+   ctrl->id == V4L2_CID_RED_

[PATCH 02/10] staging: media: go7007: TW2804 driver fix

2012-08-21 Thread Volokh Konstantin
- correct cast private data from i2c_get_clientdata()
- initialization priv data
- destroy priv data
- using V4L2 controls framework

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/wis-tw2804.c |   72 +++--
 1 files changed, 57 insertions(+), 15 deletions(-)

diff --git a/drivers/staging/media/go7007/wis-tw2804.c 
b/drivers/staging/media/go7007/wis-tw2804.c
index 05851d3..13f0f63 100644
--- a/drivers/staging/media/go7007/wis-tw2804.c
+++ b/drivers/staging/media/go7007/wis-tw2804.c
@@ -367,10 +367,12 @@ static const struct v4l2_subdev_ops tw2804_ops = {
 static int wis_tw2804_command(struct i2c_client *client,
unsigned int cmd, void *arg)
 {
-   struct wis_tw2804 *dec = i2c_get_clientdata(client);
+   struct v4l2_subdev *sd = i2c_get_clientdata(client);
+   struct wis_tw2804 *dec = to_state(sd);
+   int *input;
 
if (cmd == DECODER_SET_CHANNEL) {
-   int *input = arg;
+   input = arg;
 
if (*input < 0 || *input > 3) {
printk(KERN_ERR "wis-tw2804: channel %d is not "
@@ -539,22 +541,59 @@ static int wis_tw2804_probe(struct i2c_client *client,
const struct i2c_device_id *id)
 {
struct i2c_adapter *adapter = client->adapter;
-   struct wis_tw2804 *dec;
+   struct wis_tw2804 *state;
+   struct v4l2_subdev *sd;
+   struct v4l2_ctrl *ctrl = NULL;
+   int err;
 
if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_BYTE_DATA))
return -ENODEV;
 
-   dec = kmalloc(sizeof(struct wis_tw2804), GFP_KERNEL);
-   if (dec == NULL)
-   return -ENOMEM;
+   state = kzalloc(sizeof(struct wis_tw2804), GFP_KERNEL);
 
-   dec->channel = -1;
-   dec->norm = V4L2_STD_NTSC;
-   dec->brightness = 128;
-   dec->contrast = 128;
-   dec->saturation = 128;
-   dec->hue = 128;
-   i2c_set_clientdata(client, dec);
+   if (state == NULL)
+   return -ENOMEM;
+   sd = &state->sd;
+   v4l2_i2c_subdev_init(sd, client, &tw2804_ops);
+   state->channel = -1;
+   state->norm = V4L2_STD_NTSC;
+
+   v4l2_ctrl_handler_init(&state->hdl, 10);
+   v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_BRIGHTNESS, 0, 255, 1, 128);
+   v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_CONTRAST, 0, 255, 1, 128);
+   v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_SATURATION, 0, 255, 1, 128);
+   v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_HUE, 0, 255, 1, 128);
+   v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_AUTOGAIN, 0, 1, 1, 0);
+   v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_COLOR_KILLER, 0, 1, 1, 0);
+   ctrl = v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_GAIN, 0, 255, 1, 128);
+   if (ctrl)
+   ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
+   ctrl = v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_CHROMA_GAIN, 0, 255, 1, 128);
+   if (ctrl)
+   ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
+   ctrl = v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_BLUE_BALANCE, 0, 255, 1, 122);
+   if (ctrl)
+   ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
+   ctrl = v4l2_ctrl_new_std(&state->hdl, &tw2804_ctrl_ops,
+   V4L2_CID_RED_BALANCE, 0, 255, 1, 122);
+   if (ctrl)
+   ctrl->flags |= V4L2_CTRL_FLAG_VOLATILE;
+   sd->ctrl_handler = &state->hdl;
+   err = state->hdl.error;
+   if (err) {
+   v4l2_ctrl_handler_free(&state->hdl);
+   kfree(state);
+   return err;
+   }
 
printk(KERN_DEBUG "wis-tw2804: creating TW2804 at address %d on %s\n",
client->addr, adapter->name);
@@ -564,9 +603,12 @@ static int wis_tw2804_probe(struct i2c_client *client,
 
 static int wis_tw2804_remove(struct i2c_client *client)
 {
-   struct wis_tw2804 *dec = i2c_get_clientdata(client);
+   struct v4l2_subdev *sd = i2c_get_clientdata(client);
+   struct wis_tw2804 *state = to_state(sd);
 
-   kfree(dec);
+   v4l2_device_unregister_subdev(sd);
+   v4l2_ctrl_handler_free(&state->hdl);
+   kfree(state);
return 0;
 }
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 06/10] staging: media: go7007: tw2804 ADC power control

2012-08-21 Thread Volokh Konstantin
switch off all ADC (max 4) with first init,
we control it then start/stop grabbing frame

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/wis-tw2804.c |1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/media/go7007/wis-tw2804.c 
b/drivers/staging/media/go7007/wis-tw2804.c
index 7bd3058..34cf6b6 100644
--- a/drivers/staging/media/go7007/wis-tw2804.c
+++ b/drivers/staging/media/go7007/wis-tw2804.c
@@ -44,6 +44,7 @@ static u8 global_registers[] = {
0x3d, 0x80,
0x3e, 0x82,
0x3f, 0x82,
+   0x78, 0x0f,
0xff, 0xff, /* Terminator (reg 0xff does not exist) */
 };
 
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 09/10] staging: media: go7007: Adlink_MPG24 board initialization fix.

2012-08-21 Thread Volokh Konstantin
setting via gpio i2c bus support at every time then init encoder.

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-driver.c |5 +
 drivers/staging/media/go7007/go7007-usb.c|3 ---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index a66e339..c0ea312 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -173,6 +173,11 @@ static int go7007_init_encoder(struct go7007 *go)
go7007_write_addr(go, 0x3c82, 0x0001);
go7007_write_addr(go, 0x3c80, 0x00fe);
}
+   if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
+   /* set GPIO5 to be an output, currently low */
+   go7007_write_addr(go, 0x3c82, 0x);
+   go7007_write_addr(go, 0x3c80, 0x00df);
+   }
return 0;
 }
 
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index a6cad15..9dbf5ec 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1110,9 +1110,6 @@ static int go7007_usb_probe(struct usb_interface *intf,
} else {
u16 channel;
 
-   /* set GPIO5 to be an output, currently low */
-   go7007_write_addr(go, 0x3c82, 0x);
-   go7007_write_addr(go, 0x3c80, 0x00df);
/* read channel number from GPIO[1:0] */
go7007_read_addr(go, 0x3c81, &channel);
channel &= 0x3;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 10/10] staging: media: go7007: some i2c initialization

2012-08-21 Thread Volokh Konstantin
i2c initialization via struct item
as tw2804 have 0x00 i2c address, so need to use I2C_CLIENT_TEN
  flag for validity

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-driver.c |   20 
 drivers/staging/media/go7007/go7007-priv.h   |2 +-
 2 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index c0ea312..2dff9b5 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -197,17 +197,23 @@ int go7007_reset_encoder(struct go7007 *go)
 /*
  * Attempt to instantiate an I2C client by ID, probably loading a module.
  */
-static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
-  int addr)
+static int init_i2c_module(struct i2c_adapter *adapter, const struct go_i2c 
*const i2c)
 {
struct go7007 *go = i2c_get_adapdata(adapter);
struct v4l2_device *v4l2_dev = &go->v4l2_dev;
+   struct i2c_board_info info;
 
-   if (v4l2_i2c_new_subdev(v4l2_dev, adapter, type, addr, NULL))
+   memset(&info, 0, sizeof(info));
+   strlcpy(info.type, i2c->type, sizeof(info.type));
+   info.addr = i2c->addr;
+
+   if (i2c->id == I2C_DRIVERID_WIS_TW2804)
+   info.flags |= I2C_CLIENT_TEN;
+   if (v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, NULL))
return 0;
 
-   printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", type);
-   return -1;
+   printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", 
i2c->type);
+   return -EINVAL;
 }
 
 /*
@@ -243,9 +249,7 @@ int go7007_register_encoder(struct go7007 *go)
}
if (go->i2c_adapter_online) {
for (i = 0; i < go->board_info->num_i2c_devs; ++i)
-   init_i2c_module(&go->i2c_adapter,
-   go->board_info->i2c_devs[i].type,
-   go->board_info->i2c_devs[i].addr);
+   init_i2c_module(&go->i2c_adapter, 
&go->board_info->i2c_devs[i]);
if (go->board_id == GO7007_BOARDID_ADLINK_MPG24)
i2c_clients_command(&go->i2c_adapter,
DECODER_SET_CHANNEL, &go->channel_number);
diff --git a/drivers/staging/media/go7007/go7007-priv.h 
b/drivers/staging/media/go7007/go7007-priv.h
index b58c394..b7b939a 100644
--- a/drivers/staging/media/go7007/go7007-priv.h
+++ b/drivers/staging/media/go7007/go7007-priv.h
@@ -88,7 +88,7 @@ struct go7007_board_info {
int audio_bclk_div;
int audio_main_div;
int num_i2c_devs;
-   struct {
+   struct go_i2c {
const char *type;
int id;
int addr;
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 07/10] staging: media: go7007: README TODO

2012-08-21 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/README |   26 ++
 1 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/drivers/staging/media/go7007/README 
b/drivers/staging/media/go7007/README
index aeba132..237f45d 100644
--- a/drivers/staging/media/go7007/README
+++ b/drivers/staging/media/go7007/README
@@ -5,6 +5,32 @@ Todo:
  and added to the build.
- testing?
- handle churn in v4l layer.
+   - Some features for wis-tw2804 subdev control (comb filter,coring,IF 
comp,peak,more over...)
+   - Cropping&Scaling on tw2804
+   - Motion detector on tw2804, spatial&temporal sensitivity & masks 
control,velocity
+   - Control Output Format on tw2804
+   - go7007-v4l2.c need rewrite with new v4l2 style without nonstandard IO 
controls (set detector & bitrate)
+
+13/05/2012 3.4.0-rc+:
+Changes:
+   - Convert to V4L2 control framework
+
+05/05/2012 3.4.0-rc+:
+Changes:
+   - When go7007 reset device, i2c was not working (need rewrite GPIO5)
+   - As wis2804 has i2c_addr=0x00/*really*/, so need to set I2C_CLIENT_TEN 
flag for validity
+   - Some main nonzero initialization, rewrites with kzalloc instead 
kmalloc
+   - STATUS_SHUTDOWN was placed in incorrect place, so if firmware wasn`t 
loaded, we
+   failed v4l2_device_unregister with kernel panic (OOPS)
+   - Some new v4l2 style features as call_all(...s_stream...) for using 
subdev calls
+   - wis-tw2804.ko module code was incompatible with 3.4.x branch in 
initialization v4l2_subdev parts.
+   now i2c_get_clientdata(...) contains v4l2_subdev struct instead 
non standard wis_tw2804 struct
+
+Adds:
+   - Switch between 2 composite video inputs on channel: VIN[1,2,3,4]A and 
VIN[1,2,3,4]B
+   - Additional chipset wis2804 controls with: gain,auto 
gain,inputs[0,1],color kill,chroma gain,gain balances,
+   for all 4 channels (from tw2804.pdf)
+   - Power control for each 4 ADC up when s_stream(...,1), down otherwise 
in wis-tw2804 module
 
 Please send patches to Greg Kroah-Hartman  and Cc: 
Ross
 Cohen  as well.
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 08/10] staging: media: go7007: some additional functionality for sub.

2012-08-21 Thread Volokh Konstantin
zero cleaning allocation for fix.
unregistering bug fixing.

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/go7007-driver.c |2 +-
 drivers/staging/media/go7007/go7007-usb.c|2 +-
 drivers/staging/media/go7007/go7007-v4l2.c   |7 +--
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index ece2dd1..a66e339 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -571,7 +571,7 @@ struct go7007 *go7007_alloc(struct go7007_board_info 
*board, struct device *dev)
struct go7007 *go;
int i;
 
-   go = kmalloc(sizeof(struct go7007), GFP_KERNEL);
+   go = kzalloc(sizeof(struct go7007), GFP_KERNEL);
if (go == NULL)
return NULL;
go->dev = dev;
diff --git a/drivers/staging/media/go7007/go7007-usb.c 
b/drivers/staging/media/go7007/go7007-usb.c
index 5443e25..a6cad15 100644
--- a/drivers/staging/media/go7007/go7007-usb.c
+++ b/drivers/staging/media/go7007/go7007-usb.c
@@ -1245,7 +1245,6 @@ static void go7007_usb_disconnect(struct usb_interface 
*intf)
struct urb *vurb, *aurb;
int i;
 
-   go->status = STATUS_SHUTDOWN;
usb_kill_urb(usb->intr_urb);
 
/* Free USB-related structs */
@@ -1269,6 +1268,7 @@ static void go7007_usb_disconnect(struct usb_interface 
*intf)
kfree(go->hpi_context);
 
go7007_remove(go);
+   go->status = STATUS_SHUTDOWN;
 }
 
 static struct usb_driver go7007_usb_driver = {
diff --git a/drivers/staging/media/go7007/go7007-v4l2.c 
b/drivers/staging/media/go7007/go7007-v4l2.c
index c184ad3..b8f2eb6 100644
--- a/drivers/staging/media/go7007/go7007-v4l2.c
+++ b/drivers/staging/media/go7007/go7007-v4l2.c
@@ -98,7 +98,7 @@ static int go7007_open(struct file *file)
 
if (go->status != STATUS_ONLINE)
return -EBUSY;
-   gofh = kmalloc(sizeof(struct go7007_file), GFP_KERNEL);
+   gofh = kzalloc(sizeof(struct go7007_file), GFP_KERNEL);
if (gofh == NULL)
return -ENOMEM;
++go->ref_count;
@@ -953,6 +953,7 @@ static int vidioc_streamon(struct file *file, void *priv,
}
mutex_unlock(&go->hw_lock);
mutex_unlock(&gofh->lock);
+   call_all(&go->v4l2_dev, video, s_stream, 1);
 
return retval;
 }
@@ -968,6 +969,7 @@ static int vidioc_streamoff(struct file *file, void *priv,
mutex_lock(&gofh->lock);
go7007_streamoff(go);
mutex_unlock(&gofh->lock);
+   call_all(&go->v4l2_dev, video, s_stream, 0);
 
return 0;
 }
@@ -1832,5 +1834,6 @@ void go7007_v4l2_remove(struct go7007 *go)
mutex_unlock(&go->hw_lock);
if (go->video_dev)
video_unregister_device(go->video_dev);
-   v4l2_device_unregister(&go->v4l2_dev);
+   if (go->status != STATUS_SHUTDOWN)
+   v4l2_device_unregister(&go->v4l2_dev);
 }
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 05/10] staging: media: go7007: Cleanup unused old code

2012-08-21 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/wis-tw2804.c |  138 -
 1 files changed, 0 insertions(+), 138 deletions(-)

diff --git a/drivers/staging/media/go7007/wis-tw2804.c 
b/drivers/staging/media/go7007/wis-tw2804.c
index 0b49342..7bd3058 100644
--- a/drivers/staging/media/go7007/wis-tw2804.c
+++ b/drivers/staging/media/go7007/wis-tw2804.c
@@ -33,12 +33,7 @@ struct wis_tw2804 {
struct v4l2_ctrl_handler hdl;
u8 channel:2;
u8 input:1;
-   int channel;
int norm;
-   int brightness;
-   int contrast;
-   int saturation;
-   int hue;
 };
 
 static u8 global_registers[] = {
@@ -404,139 +399,6 @@ static int wis_tw2804_command(struct i2c_client *client,
"channel number is set\n", cmd);
return 0;
}
-
-   switch (cmd) {
-   case VIDIOC_S_STD:
-   {
-   v4l2_std_id *input = arg;
-   u8 regs[] = {
-   0x01, *input & V4L2_STD_NTSC ? 0xc4 : 0x84,
-   0x09, *input & V4L2_STD_NTSC ? 0x07 : 0x04,
-   0x0a, *input & V4L2_STD_NTSC ? 0xf0 : 0x20,
-   0x0b, *input & V4L2_STD_NTSC ? 0x07 : 0x04,
-   0x0c, *input & V4L2_STD_NTSC ? 0xf0 : 0x20,
-   0x0d, *input & V4L2_STD_NTSC ? 0x40 : 0x4a,
-   0x16, *input & V4L2_STD_NTSC ? 0x00 : 0x40,
-   0x17, *input & V4L2_STD_NTSC ? 0x00 : 0x40,
-   0x20, *input & V4L2_STD_NTSC ? 0x07 : 0x0f,
-   0x21, *input & V4L2_STD_NTSC ? 0x07 : 0x0f,
-   0xff,   0xff,
-   };
-   write_regs(client, regs, dec->channel);
-   dec->norm = *input;
-   break;
-   }
-   case VIDIOC_QUERYCTRL:
-   {
-   struct v4l2_queryctrl *ctrl = arg;
-
-   switch (ctrl->id) {
-   case V4L2_CID_BRIGHTNESS:
-   ctrl->type = V4L2_CTRL_TYPE_INTEGER;
-   strncpy(ctrl->name, "Brightness", sizeof(ctrl->name));
-   ctrl->minimum = 0;
-   ctrl->maximum = 255;
-   ctrl->step = 1;
-   ctrl->default_value = 128;
-   ctrl->flags = 0;
-   break;
-   case V4L2_CID_CONTRAST:
-   ctrl->type = V4L2_CTRL_TYPE_INTEGER;
-   strncpy(ctrl->name, "Contrast", sizeof(ctrl->name));
-   ctrl->minimum = 0;
-   ctrl->maximum = 255;
-   ctrl->step = 1;
-   ctrl->default_value = 128;
-   ctrl->flags = 0;
-   break;
-   case V4L2_CID_SATURATION:
-   ctrl->type = V4L2_CTRL_TYPE_INTEGER;
-   strncpy(ctrl->name, "Saturation", sizeof(ctrl->name));
-   ctrl->minimum = 0;
-   ctrl->maximum = 255;
-   ctrl->step = 1;
-   ctrl->default_value = 128;
-   ctrl->flags = 0;
-   break;
-   case V4L2_CID_HUE:
-   ctrl->type = V4L2_CTRL_TYPE_INTEGER;
-   strncpy(ctrl->name, "Hue", sizeof(ctrl->name));
-   ctrl->minimum = 0;
-   ctrl->maximum = 255;
-   ctrl->step = 1;
-   ctrl->default_value = 128;
-   ctrl->flags = 0;
-   break;
-   }
-   break;
-   }
-   case VIDIOC_S_CTRL:
-   {
-   struct v4l2_control *ctrl = arg;
-
-   switch (ctrl->id) {
-   case V4L2_CID_BRIGHTNESS:
-   if (ctrl->value > 255)
-   dec->brightness = 255;
-   else if (ctrl->value < 0)
-   dec->brightness = 0;
-   else
-   dec->brightness = ctrl->value;
-   write_reg(client, 0x12, dec->brightness, dec->channel);
-   break;
-   case V4L2_CID_CONTRAST:
-   if (ctrl->value > 255)
-   dec->contrast = 255;
-   else if (ctrl->value < 0)
-   dec->contrast = 0;
-   else
-   dec->contrast = ctrl->value;
-   write_reg(client, 0x11, dec->contrast, dec->channel);
- 

[PATCH 03/10] staging: media: go7007: Non main code changing

2012-08-21 Thread Volokh Konstantin
types cast approved, max channels==4 (ADC), i2c_smbus_write_
  return s32 type

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/wis-tw2804.c |9 ++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/go7007/wis-tw2804.c 
b/drivers/staging/media/go7007/wis-tw2804.c
index 13f0f63..0b49342 100644
--- a/drivers/staging/media/go7007/wis-tw2804.c
+++ b/drivers/staging/media/go7007/wis-tw2804.c
@@ -111,19 +111,22 @@ static u8 channel_registers[] = {
0xff, 0xff, /* Terminator (reg 0xff does not exist) */
 };
 
-static int write_reg(struct i2c_client *client, u8 reg, u8 value, int channel)
+static s32 write_reg(struct i2c_client *client, u8 reg, u8 value, u8 channel)
 {
return i2c_smbus_write_byte_data(client, reg | (channel << 6), value);
 }
 
-static int write_regs(struct i2c_client *client, u8 *regs, int channel)
+static int write_regs(struct i2c_client *client, u8 *regs, u8 channel)
 {
int i;
 
for (i = 0; regs[i] != 0xff; i += 2)
if (i2c_smbus_write_byte_data(client,
regs[i] | (channel << 6), regs[i + 1]) < 0)
-   return -1;
+   return -EINVAL;
+   return 0;
+}
+
 static s32 read_reg(struct i2c_client *client, u8 reg, u8 channel)
 {
return i2c_smbus_read_byte_data(client, (reg) | (channel << 6));
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 04/10] staging: media: go7007: Add IDENT for TW2802/2804

2012-08-21 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 include/media/v4l2-chip-ident.h |4 
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/include/media/v4l2-chip-ident.h b/include/media/v4l2-chip-ident.h
index 7395c81..5395495 100644
--- a/include/media/v4l2-chip-ident.h
+++ b/include/media/v4l2-chip-ident.h
@@ -113,6 +113,10 @@ enum {
/* module vp27smpx: just ident 2700 */
V4L2_IDENT_VP27SMPX = 2700,
 
+   /* module wis-tw2804: 2802/2804 */
+   V4L2_IDENT_TW2802 = 2802,
+   V4L2_IDENT_TW2804 = 2804,
+
/* module vpx3220: reserved range: 3210-3229 */
V4L2_IDENT_VPX3214C = 3214,
V4L2_IDENT_VPX3216B = 3216,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media: video: bt8xx: Remove duplicated pixel format entry.

2012-05-31 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/media/video/bt8xx/bttv-driver.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/drivers/media/video/bt8xx/bttv-driver.c 
b/drivers/media/video/bt8xx/bttv-driver.c
index a9cfb0f..4e2f96f 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -558,12 +558,6 @@ static const struct bttv_format formats[] = {
.depth= 16,
.flags= FORMAT_FLAGS_PACKED,
},{
-   .name = "4:2:2, packed, YUYV",
-   .fourcc   = V4L2_PIX_FMT_YUYV,
-   .btformat = BT848_COLOR_FMT_YUY2,
-   .depth= 16,
-   .flags= FORMAT_FLAGS_PACKED,
-   },{
.name = "4:2:2, packed, UYVY",
.fourcc   = V4L2_PIX_FMT_UYVY,
.btformat = BT848_COLOR_FMT_YUY2,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] media: video: bt8xx: Remove duplicated pixel format entry.

2012-05-31 Thread volokh
On Thu, May 31, 2012 at 11:08:51AM +0400, vol...@telros.ru wrote:
> Signed-off-by: Volokh Konstantin 
> ---
>  drivers/media/video/bt8xx/bttv-driver.c |6 --
>  1 files changed, 0 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/media/video/bt8xx/bttv-driver.c
> +b/drivers/media/video/bt8xx/bttv-driver.c
> index e581b37..b4ee7de 100644
> --- a/drivers/media/video/bt8xx/bttv-driver.c
> +++ b/drivers/media/video/bt8xx/bttv-driver.c
> @@ -558,12 +558,6 @@ static const struct bttv_format formats[] = {
> .depth= 16,
> .flags= FORMAT_FLAGS_PACKED,
> },{
> -   .name = "4:2:2, packed, YUYV",
> -   .fourcc   = V4L2_PIX_FMT_YUYV,
> -   .btformat = BT848_COLOR_FMT_YUY2,
> -   .depth= 16,
> -   .flags= FORMAT_FLAGS_PACKED,
> -   },{
> .name = "4:2:2, packed, UYVY",
> .fourcc   = V4L2_PIX_FMT_UYVY,
> .btformat = BT848_COLOR_FMT_YUY2,
> --
> 1.7.7.6
> 
> 
Sorry, This patch not applicable on new branch, something was changed.
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] media: video: bt8xx: Remove duplicated pixel format entry.

2012-05-31 Thread volokh
Signed-off-by: Volokh Konstantin 
---
 drivers/media/video/bt8xx/bttv-driver.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/drivers/media/video/bt8xx/bttv-driver.c
+b/drivers/media/video/bt8xx/bttv-driver.c
index e581b37..b4ee7de 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -558,12 +558,6 @@ static const struct bttv_format formats[] = {
.depth= 16,
.flags= FORMAT_FLAGS_PACKED,
},{
-   .name = "4:2:2, packed, YUYV",
-   .fourcc   = V4L2_PIX_FMT_YUYV,
-   .btformat = BT848_COLOR_FMT_YUY2,
-   .depth= 16,
-   .flags= FORMAT_FLAGS_PACKED,
-   },{
.name = "4:2:2, packed, UYVY",
.fourcc   = V4L2_PIX_FMT_UYVY,
.btformat = BT848_COLOR_FMT_YUY2,
--
1.7.7.6


--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 3/3] I don`t know for what, but there`s dublicate item.

2012-05-30 Thread volokh
On Wed, May 30, 2012 at 05:05:47PM -0300, Ezequiel Garcia wrote:
> On Wed, May 30, 2012 at 4:43 PM, Ezequiel Garcia  
> wrote:
> > But the subject is *very* wrong. You should set it to something like:
> > "[bt8xx] Remove duplicated pixel format entry".
> 
> 
> Sorry this should be, "[PATCH] bt8xx: Remove duplicated pixel format entry".
> --
Thanks for correction
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/3] I don`t know for what, but there`s dublicate item.

2012-05-26 Thread Volokh Konstantin
Signed-off-by: Volokh Konstantin 
---
 drivers/media/video/bt8xx/bttv-driver.c |6 --
 1 files changed, 0 insertions(+), 6 deletions(-)

diff --git a/drivers/media/video/bt8xx/bttv-driver.c 
b/drivers/media/video/bt8xx/bttv-driver.c
index e581b37..b4ee7de 100644
--- a/drivers/media/video/bt8xx/bttv-driver.c
+++ b/drivers/media/video/bt8xx/bttv-driver.c
@@ -558,12 +558,6 @@ static const struct bttv_format formats[] = {
.depth= 16,
.flags= FORMAT_FLAGS_PACKED,
},{
-   .name = "4:2:2, packed, YUYV",
-   .fourcc   = V4L2_PIX_FMT_YUYV,
-   .btformat = BT848_COLOR_FMT_YUY2,
-   .depth= 16,
-   .flags= FORMAT_FLAGS_PACKED,
-   },{
.name = "4:2:2, packed, UYVY",
.fourcc   = V4L2_PIX_FMT_UYVY,
.btformat = BT848_COLOR_FMT_YUY2,
-- 
1.7.7.6

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH 1/2] staging: media: go7007: Adlink MPG24 board

2012-05-14 Thread volokh
On Sun, May 13, 2012 at 10:21:48PM +0300, Dan Carpenter wrote:
> On Sun, May 13, 2012 at 10:52:41PM +0400, Volokh Konstantin wrote:
> > This patch applies only for Adlink MPG24 board with go7007, all these 
> > changes were tested for continuous loading & restarting modes
> > 
> > This is minimal changes needed for start up go7007 to work correctly
> >   in 3.4 branch
> > 
> > Changes:
> >   - When go7007 reset device, i2c was not working (need rewrite GPIO5)
> >   - As wis2804 has i2c_addr=0x00/*really*/, so Need set I2C_CLIENT_TEN flag 
> > for validity
> >   - some main nonzero initialization, rewrites with kzalloc instead kmalloc
> >   - STATUS_SHUTDOWN was placed in incorrect place, so if firmware wasn`t 
> > loaded, we
> > failed v4l2_device_unregister with kernel panic (OOPS)
> >   - some new v4l2 style features as call_all(...s_stream...) for using 
> > subdev calls
> > 
> 
> In some ways, yes, I can see that this seems like one thing "Make
> go7007 work correctly", but really it would be better if each of
> the bullet points was its own patch.
> 
> The changelogs should explain why you do something not what you do.
> We can all see that kmalloc() was changed to kzalloc() but why? Is

struct go7007 contains "struct v4l2_device v4l2_dev;" field, so if transfer it 
uninitialized (may be nonzero)
in function: "int v4l2_device_register_subdev(struct v4l2_device *v4l2_dev, 
struct v4l2_subdev *sd)"
(drivers/media/video/v4l2-device.c), so next code may be called:
#if defined(CONFIG_MEDIA_CONTROLLER)
/* Register the entity. */
if (v4l2_dev->mdev) {
err = media_device_register_entity(v4l2_dev->mdev, entity);
if (err < 0) {
if (sd->internal_ops && sd->internal_ops->unregistered)
sd->internal_ops->unregistered(sd);
module_put(sd->owner);
return err;
}
}
#endif
I`ve got error here. because go7007 don`t control mdev field.

The next kzalloc: "gofh = kzalloc(sizeof(struct go7007_file), GFP_KERNEL);" was 
written only for zero initialization on creation purpose, driver work properly 
without it changing
> their and information leak for example?  That might have security
> implications and be good thing to know about.
> 
> regards,
> dan carpenter
> 
> 
> --
> To unsubscribe from this list: send the line "unsubscribe linux-media" in
> the body of a message to majord...@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html

It`s very horrible to describe every changing...

Volokh Konstantin
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 2/2] staging: media: go7007: Adlink MPG24 board

2012-05-13 Thread Volokh Konstantin
Changes:
- wis-tw2804.ko module code was incompatible with 3.4 branch in 
initialization v4l2_subdev parts. now i2c_get_clientdata(...) contains 
v4l2_subdev struct instead non standard wis_tw2804 struct
- Use V4L2 control framework

Adds:
  - Additional chipset tw2804 controls with: gain,auto gain,inputs[0,1],color 
kill,chroma gain,gain balances, for all 4 channels (from tw2804.pdf)
  - Power control for each 4 ADC (tw2804) up when s_stream(...,1), down 
otherwise

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/wis-tw2804.c |  466 +++--
 include/media/v4l2-chip-ident.h   |4 +
 2 files changed, 315 insertions(+), 155 deletions(-)

diff --git a/drivers/staging/media/go7007/wis-tw2804.c 
b/drivers/staging/media/go7007/wis-tw2804.c
index 9134f03..2e613dc 100644
--- a/drivers/staging/media/go7007/wis-tw2804.c
+++ b/drivers/staging/media/go7007/wis-tw2804.c
@@ -21,16 +21,19 @@
 #include 
 #include 
 #include 
+#include 
+#include 
+#include 
+#include 
 
 #include "wis-i2c.h"
 
 struct wis_tw2804 {
-   int channel;
+   struct v4l2_subdev sd;
+   struct v4l2_ctrl_handler hdl;
+   u8 channel:2;
+   u8 input:1;
int norm;
-   int brightness;
-   int contrast;
-   int saturation;
-   int hue;
 };
 
 static u8 global_registers[] = {
@@ -41,6 +44,7 @@ static u8 global_registers[] = {
0x3d, 0x80,
0x3e, 0x82,
0x3f, 0x82,
+   0x78, 0x0f,
0xff, 0xff, /* Terminator (reg 0xff does not exist) */
 };
 
@@ -103,29 +107,271 @@ static u8 channel_registers[] = {
0xff, 0xff, /* Terminator (reg 0xff does not exist) */
 };
 
-static int write_reg(struct i2c_client *client, u8 reg, u8 value, int channel)
+static s32 write_reg(struct i2c_client *client, u8 reg, u8 value, u8 channel)
 {
return i2c_smbus_write_byte_data(client, reg | (channel << 6), value);
 }
 
-static int write_regs(struct i2c_client *client, u8 *regs, int channel)
+static int write_regs(struct i2c_client *client, u8 *regs, u8 channel)
 {
int i;
 
for (i = 0; regs[i] != 0xff; i += 2)
if (i2c_smbus_write_byte_data(client,
regs[i] | (channel << 6), regs[i + 1]) < 0)
-   return -1;
+   return -EINVAL;
return 0;
 }
 
+static s32 read_reg(struct i2c_client *client, u8 reg, u8 channel)
+{
+   return i2c_smbus_read_byte_data(client, (reg) | (channel << 6));
+}
+
+inline struct wis_tw2804 *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct wis_tw2804, sd);
+}
+
+inline struct wis_tw2804 *to_state_from_ctrl(struct v4l2_ctrl *ctrl)
+{
+   return container_of(ctrl->handler, struct wis_tw2804, hdl);
+}
+
+static int tw2804_log_status(struct v4l2_subdev *sd)
+{
+   struct wis_tw2804 *state = to_state(sd);
+   v4l2_info(sd, "Standard: %s\n",
+   state->norm == V4L2_STD_NTSC ? "NTSC" :
+   state->norm == V4L2_STD_PAL ? "PAL" : "unknown");
+   v4l2_info(sd, "Channel: %d\n", state->channel);
+   v4l2_info(sd, "Input: %d\n", state->input);
+   v4l2_ctrl_handler_log_status(&state->hdl, sd->name);
+   return 0;
+}
+
+s32 get_ctrl_addr(int ctrl)
+{
+   switch (ctrl) {
+   case V4L2_CID_BRIGHTNESS:
+   return 0x12;
+   case V4L2_CID_CONTRAST:
+   return 0x11;
+   case V4L2_CID_SATURATION:
+   return 0x10;
+   case V4L2_CID_HUE:
+   return 0x0f;
+   case V4L2_CID_AUTOGAIN:
+   return 0x02;
+   case V4L2_CID_COLOR_KILLER:
+   return 0x14;
+   case V4L2_CID_GAIN:
+   return 0x3c;
+   case V4L2_CID_CHROMA_GAIN:
+   return 0x3d;
+   case V4L2_CID_RED_BALANCE:
+   return 0x3f;
+   case V4L2_CID_BLUE_BALANCE:
+   return 0x3e;
+   default:
+   return -EINVAL;
+   }
+}
+
+static int tw2804_g_volatile_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct v4l2_subdev *sd = &to_state_from_ctrl(ctrl)->sd;
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   s32 addr = get_ctrl_addr(ctrl->id);
+
+   if (addr == -EINVAL)
+   return -EINVAL;
+
+   switch (ctrl->id) {
+   case V4L2_CID_GAIN:
+   case V4L2_CID_CHROMA_GAIN:
+   case V4L2_CID_RED_BALANCE:
+   case V4L2_CID_BLUE_BALANCE:
+   ctrl->cur.val = read_reg(client, addr, 0);
+   break;
+   default:
+   return -EINVAL;
+   }
+   return 0;
+}
+
+static int tw2804_s_ctrl(struct v4l2_ctrl *ctrl)
+{
+   struct wis_tw2804 *state = to_state_from_ctrl(ctrl);
+   struct v4l2_subdev *sd = &state->sd;
+   struct i2c_client *client = v4l2_get_subdevdata(sd);
+   s32 reg = c

[PATCH 1/2] staging: media: go7007: Adlink MPG24 board

2012-05-13 Thread Volokh Konstantin
This patch applies only for Adlink MPG24 board with go7007, all these changes 
were tested for continuous loading & restarting modes

This is minimal changes needed for start up go7007 to work correctly
  in 3.4 branch

Changes:
  - When go7007 reset device, i2c was not working (need rewrite GPIO5)
  - As wis2804 has i2c_addr=0x00/*really*/, so Need set I2C_CLIENT_TEN flag for 
validity
  - some main nonzero initialization, rewrites with kzalloc instead kmalloc
  - STATUS_SHUTDOWN was placed in incorrect place, so if firmware wasn`t 
loaded, we
failed v4l2_device_unregister with kernel panic (OOPS)
  - some new v4l2 style features as call_all(...s_stream...) for using subdev 
calls

Signed-off-by: Volokh Konstantin 
---
 drivers/staging/media/go7007/README  |   22 +
 drivers/staging/media/go7007/go7007-driver.c |   27 +
 drivers/staging/media/go7007/go7007-priv.h   |2 +-
 drivers/staging/media/go7007/go7007-usb.c|5 +---
 drivers/staging/media/go7007/go7007-v4l2.c   |7 -
 5 files changed, 47 insertions(+), 16 deletions(-)

diff --git a/drivers/staging/media/go7007/README 
b/drivers/staging/media/go7007/README
index 48f4476..22544a7 100644
--- a/drivers/staging/media/go7007/README
+++ b/drivers/staging/media/go7007/README
@@ -5,6 +5,28 @@ Todo:
  and added to the build.
- testing?
- handle churn in v4l layer.
+   - Some features for wis-tw2804 subdev control (comb filter,coring,IF 
comp,peak,more over...)
+   - Cropping&Scaling on tw2804
+   - Motion detector on tw2804, spatial&temporal sensitivity & masks 
control,velocity
+   - Control Output Format on tw2804
+   - go7007-v4l2.c need rewrite with new v4l2 style without nonstandard IO 
controls (set detector & bitrate)
+
+05/05/2012 3.4.0-rc+:
+Changes:
+   - When go7007 reset device, i2c was not working (need rewrite GPIO5)
+   - As wis2804 has i2c_addr=0x00/*really*/, so need to set I2C_CLIENT_TEN 
flag for validity
+   - Some main nonzero initialization, rewrites with kzalloc instead 
kmalloc
+   - STATUS_SHUTDOWN was placed in incorrect place, so if firmware wasn`t 
loaded, we
+   failed v4l2_device_unregister with kernel panic (OOPS)
+   - Some new v4l2 style features as call_all(...s_stream...) for using 
subdev calls
+   - wis-tw2804.ko module code was incompatible with 3.4.x branch in 
initialization v4l2_subdev parts.
+   now i2c_get_clientdata(...) contains v4l2_subdev struct instead 
non standard wis_tw2804 struct
+
+Adds:
+   - Switch between 2 composite video inputs on channel: VIN[1,2,3,4]A and 
VIN[1,2,3,4]B
+   - Additional chipset wis2804 controls with: gain,auto 
gain,inputs[0,1],color kill,chroma gain,gain balances,
+   for all 4 channels (from tw2804.pdf)
+   - Power control for each 4 ADC up when s_stream(...,1), down otherwise 
in wis-tw2804 module
 
 Please send patchs to Greg Kroah-Hartman  and Cc: Ross
 Cohen  as well.
diff --git a/drivers/staging/media/go7007/go7007-driver.c 
b/drivers/staging/media/go7007/go7007-driver.c
index ece2dd1..2dff9b5 100644
--- a/drivers/staging/media/go7007/go7007-driver.c
+++ b/drivers/staging/media/go7007/go7007-driver.c
@@ -173,6 +173,11 @@ static int go7007_init_encoder(struct go7007 *go)
go7007_write_addr(go, 0x3c82, 0x0001);
go7007_write_addr(go, 0x3c80, 0x00fe);
}
+   if (go->board_id == GO7007_BOARDID_ADLINK_MPG24) {
+   /* set GPIO5 to be an output, currently low */
+   go7007_write_addr(go, 0x3c82, 0x);
+   go7007_write_addr(go, 0x3c80, 0x00df);
+   }
return 0;
 }
 
@@ -192,17 +197,23 @@ int go7007_reset_encoder(struct go7007 *go)
 /*
  * Attempt to instantiate an I2C client by ID, probably loading a module.
  */
-static int init_i2c_module(struct i2c_adapter *adapter, const char *type,
-  int addr)
+static int init_i2c_module(struct i2c_adapter *adapter, const struct go_i2c 
*const i2c)
 {
struct go7007 *go = i2c_get_adapdata(adapter);
struct v4l2_device *v4l2_dev = &go->v4l2_dev;
+   struct i2c_board_info info;
+
+   memset(&info, 0, sizeof(info));
+   strlcpy(info.type, i2c->type, sizeof(info.type));
+   info.addr = i2c->addr;
 
-   if (v4l2_i2c_new_subdev(v4l2_dev, adapter, type, addr, NULL))
+   if (i2c->id == I2C_DRIVERID_WIS_TW2804)
+   info.flags |= I2C_CLIENT_TEN;
+   if (v4l2_i2c_new_subdev_board(v4l2_dev, adapter, &info, NULL))
return 0;
 
-   printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", type);
-   return -1;
+   printk(KERN_INFO "go7007: probing for module i2c:%s failed\n", 
i2c->type);
+   return -EINVAL;
 }
 
 /*
@@ -238,9 +249,7 @@ int go7007_register_encoder(struct go7007 *go)
}
  

Re: [PATCH] staging: media: go7007: Adlink MPG24 board issues

2012-05-11 Thread volokh
On Fri, May 11, 2012 at 07:07:38PM -0300, Ezequiel Garcia wrote:
> On Fri, May 11, 2012 at 2:06 PM,   wrote:
> >>
> >> One question... shouldn't this changeset be splitted into shorter patches?
> >>
> >
> > Yes, should it.
> > In next iteration i`ll learn how to do that.
> 
> As a git newbie I've found very useful to work like this:
> 
> 1. Always work on a branch that's different from master
> that way you can always do
> 
> git-rebase --interactive master
> 
> and quickly review your commits or even rewrite them.
> 
> 2. If unsure on changeset, add files interactively
> to stage area (aka the index) with
> 
> git-add --patch
> 
> 3. Once you've commit a few stuff, you can simply
> turn them into patches with
> 
> git-format-patch master.
> 
> This way it's very easy to split a change into patches.
> And with git rebase it's very easy to review and clean
> commits, to get a cleaner set of patches to keep
> maintainers happy.
> 
> Just my two cents,
> Hope it helps,
> Ezequiel.
OOh! Very thanks for good idea!
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] staging: media: go7007: Adlink MPG24 board issues

2012-05-11 Thread volokh
On Fri, May 11, 2012 at 01:51:40PM -0300, Ezequiel Garcia wrote:
> Hi,
> 
> Another one here, hope you don't mind ;)
> 
> >
> >> This is minimal changes needed for start up go7007&wis2804 to work 
> >> correctly
> >>    in 3.4 branch
> 
> ^^^
> These are minimal changes.
> 
> ---
> 
> One question... shouldn't this changeset be splitted into shorter patches?
> 
> Good luck!
> Ezequiel.
Yes, should it.
In next iteration i`ll learn how to do that.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCH] staging: media: go7007: Adlink MPG24 board issues

2012-05-11 Thread volokh
>>some simple stuff I found along the way..

On 05/10/2012 10:43 PM, volok...@gmail.com wrote:
> From: Volokh Konstantin   
>
>   
>
> This issuses applyed only for Adlink MPG24 board with go7007  
>

>>this issue applies only for...

>   &  wis2804, all whese changes was tested for continuos  
>
>   load&restart mode   
>
>   
>

>>these changes were tested for continuous

> This is minimal changes needed for start up go7007&wis2804 to work correctly  
>
>in 3.4 branch  
>
>   
>
> Changes:  
>
>- When go7007 reset device, i2c was not worked (need rewrite GPIO5)
>

>>working

>- As wis2804 has i2c_addr=0x00/*really*/, so Need set I2C_CLIENT_TEN flag 
> for validity
>- some main nonzero initialization, rewrites with kzalloc instead kmalloc  
>
>- STATUS_SHUTDOWN was pl


Thanks for english language notation.
I`ve never used it in real word.
--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Video Interface Port VIP2.0 datasheet

2012-04-24 Thread volokh
Hi, Can anybody help me to recieve "Video Interface Port VIP2.0"
datasheet for free.

Huge Thanks.



--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH] [Trivial] staging: go7007: Framesizes features

2012-04-24 Thread volokh
Hi, Can anybody help me to recieve "Video Interface Port VIP2.0"
datasheet for free.

Huge Thanks.

--
To unsubscribe from this list: send the line "unsubscribe linux-media" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Subject: [PATCH] [Trivial] Staging: go7007: wis-tw2804 upstyle to v4l2

2012-04-19 Thread volokh
 Some update to new v4l2 controls

 Signed-off-by:Volokh Konstantin 
---
 drivers/staging/media/go7007/wis-tw2804.c |  378 +
 1 files changed, 228 insertions(+), 150 deletions(-)

diff --git a/drivers/staging/media/go7007/wis-tw2804.c 
b/drivers/staging/media/go7007/wis-tw2804.c
index 9134f03..cffaa2b 100644
--- a/drivers/staging/media/go7007/wis-tw2804.c
+++ b/drivers/staging/media/go7007/wis-tw2804.c
@@ -21,10 +21,13 @@
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include "wis-i2c.h"
 
 struct wis_tw2804 {
+   struct v4l2_subdev sd;
int channel;
int norm;
int brightness;
@@ -33,6 +36,13 @@ struct wis_tw2804 {
int hue;
 };
 
+static inline struct wis_tw2804 *to_state(struct v4l2_subdev *sd)
+{
+   return container_of(sd, struct wis_tw2804, sd);
+}
+
+static int tw2804_log_status(struct v4l2_subdev *sd);
+
 static u8 global_registers[] = {
0x39, 0x00,
0x3a, 0xff,
@@ -105,223 +115,291 @@ static u8 channel_registers[] = {
 
 static int write_reg(struct i2c_client *client, u8 reg, u8 value, int channel)
 {
-   return i2c_smbus_write_byte_data(client, reg | (channel << 6), value);
+   int i;
+
+   for (i = 0; i < 10; i++)
+   /*return */if (i2c_smbus_write_byte_data(client,
+   reg|(channel<<6), value) < 0)
+   return -1;
+   return 0;
 }
 
+/**static u8 read_reg(struct i2c_client *client, u8 reg, int channel)
+{
+  return i2c_smbus_read_byte_data(client,reg|(channel<<6));
+}*/
+
 static int write_regs(struct i2c_client *client, u8 *regs, int channel)
 {
int i;
 
for (i = 0; regs[i] != 0xff; i += 2)
-   if (i2c_smbus_write_byte_data(client,
-   regs[i] | (channel << 6), regs[i + 1]) < 0)
+   if (i2c_smbus_write_byte_data(client
+   , regs[i] | (channel << 6), regs[i + 1]) < 0)
return -1;
return 0;
 }
 
-static int wis_tw2804_command(struct i2c_client *client,
-   unsigned int cmd, void *arg)
+static int wis_tw2804_command(
+   struct i2c_client *client,
+   unsigned int cmd,
+   void *arg)
 {
-   struct wis_tw2804 *dec = i2c_get_clientdata(client);
+   struct v4l2_subdev *sd = i2c_get_clientdata(client);
+   struct wis_tw2804 *dec = to_state(sd);
+   int *input;
+
+   printk(KERN_INFO"wis-tw2804: call command %d\n", cmd);
 
if (cmd == DECODER_SET_CHANNEL) {
-   int *input = arg;
+   printk(KERN_INFO"wis-tw2804: DecoderSetChannel call command 
%d\n", cmd);
+
+   input = arg;
 
if (*input < 0 || *input > 3) {
-   printk(KERN_ERR "wis-tw2804: channel %d is not "
-   "between 0 and 3!\n", *input);
+   printk(KERN_ERR"wis-tw2804: channel %d is not between 0 
and 3!\n", *input);
return 0;
}
dec->channel = *input;
-   printk(KERN_DEBUG "wis-tw2804: initializing TW2804 "
-   "channel %d\n", dec->channel);
-   if (dec->channel == 0 &&
-   write_regs(client, global_registers, 0) < 0) {
-   printk(KERN_ERR "wis-tw2804: error initializing "
-   "TW2804 global registers\n");
+   printk(KERN_DEBUG"wis-tw2804: initializing TW2804 channel 
%d\n", dec->channel);
+   if (dec->channel == 0 && write_regs(client,
+   global_registers, 0) < 0) {
+   printk(KERN_ERR"wis-tw2804: error initializing TW2804 
global registers\n");
return 0;
}
if (write_regs(client, channel_registers, dec->channel) < 0) {
-   printk(KERN_ERR "wis-tw2804: error initializing "
-   "TW2804 channel %d\n", dec->channel);
+   printk(KERN_ERR"wis-tw2804: error initializing TW2804 
channel %d\n", dec->channel);
return 0;
}
return 0;
}
 
if (dec->channel < 0) {
-   printk(KERN_DEBUG "wis-tw2804: ignoring command %08x until "
-   "channel number is set\n", cmd);
+   printk(KERN_DEBUG"wis-tw2804: ignoring command %08x until 
channel number is set\n", cmd);
return 0;
}
 
-   switch (cmd) {
-   case VIDIOC_S_STD:
-   {
-   v4l2_std_id *input = arg;
-   u8 regs[] = {
-   0x01, *input & V4L2_STD_NTSC ? 0xc4 : 0x84,
-   0x09, *input & V4L2_STD_NTSC ? 0x07 : 0x04,
-   0x0a, *input & V4L2_STD_NTSC ? 0xf0 : 0x20,
-   0x0b, *input & V4L2_S

[PATCH] go7007 patch for 3.2.x

2012-03-20 Thread volokh
- 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
Regards Volokh

diff -uprN -X linux-3.2.11-vanilla/Documentation/dontdiff 
linux-3.2.11-vanilla/drivers/staging/media/go7007/go7007.h 
linux-3.2.11/drivers/staging/media/go7007/go7007.h
--- linux-3.2.11-vanilla/drivers/staging/media/go7007/go7007.h  2012-03-13 
21:05:09.0 +0400
+++ linux-3.2.11/drivers/staging/media/go7007/go7007.h  2012-03-20 
16:17:26.095901486 +0400
@@ -21,12 +21,27 @@
  * to select between MPEG1, MPEG2, and MPEG4 */
 #define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4') /* MPEG4 */
 
+/* Temporary defines until accepted in v4l2-api (videodev2.h) */
+#ifndef V4L2_MPEG_STREAM_TYPE_MPEG_ELEM
+  #define V4L2_MPEG_STREAM_TYPE_MPEG_ELEM   6 /* MPEG elementary stream */
+#endif
+#ifndef V4L2_MPEG_VIDEO_ENCODING_MPEG_4
+  #define V4L2_MPEG_VIDEO_ENCODING_MPEG_4   3
+#endif
+
+#ifndef V4L2_MPEG_VIDEO_ENCODING_H263
+  #define V4L2_MPEG_VIDEO_ENCODING_H263 4
+#endif
+
+///deprecated defs
+#if 0
 /* These will be replaced with a better interface
  * soon, so don't get too attached to them */
 #defineGO7007IOC_S_BITRATE _IOW('V', BASE_VIDIOC_PRIVATE + 0, int)
 #defineGO7007IOC_G_BITRATE _IOR('V', BASE_VIDIOC_PRIVATE + 1, int)
 
-enum go7007_aspect_ratio {
+enum go7007_aspect_ratio
+{
GO7007_ASPECT_RATIO_1_1 = 0,
GO7007_ASPECT_RATIO_4_3_NTSC = 1,
GO7007_ASPECT_RATIO_4_3_PAL = 2,
@@ -35,7 +50,8 @@ enum go7007_aspect_ratio {
 };
 
 /* Used to set generic compression parameters */
-struct go7007_comp_params {
+struct go7007_comp_params
+{
__u32 gop_size;
__u32 max_b_frames;
enum go7007_aspect_ratio aspect_ratio;
@@ -46,14 +62,16 @@ struct go7007_comp_params {
 #define GO7007_COMP_CLOSED_GOP 0x0001
 #define GO7007_COMP_OMIT_SEQ_HEADER0x0002
 
-enum go7007_mpeg_video_standard {
+enum go7007_mpeg_video_standard
+{
GO7007_MPEG_VIDEO_MPEG1 = 0,
GO7007_MPEG_VIDEO_MPEG2 = 1,
GO7007_MPEG_VIDEO_MPEG4 = 2,
 };
 
 /* Used to set parameters for V4L2_PIX_FMT_MPEG format */
-struct go7007_mpeg_params {
+struct go7007_mpeg_params
+{
enum go7007_mpeg_video_standard mpeg_video_standard;
__u32 flags;
__u32 pali;
@@ -83,21 +101,6 @@ struct go7007_mpeg_params {
 #define GO7007_MPEG4_PROFILE_AS_L4 GO7007_MPEG_PROFILE(4, 0xf4)
 #define GO7007_MPEG4_PROFILE_AS_L5 GO7007_MPEG_PROFILE(4, 0xf5)
 
-struct go7007_md_params {
-   __u16 region;
-   __u16 trigger;
-   __u16 pixel_threshold;
-   __u16 motion_threshold;
-   __u32 reserved[8];
-};
-
-struct go7007_md_region {
-   __u16 region;
-   __u16 flags;
-   struct v4l2_clip *clips;
-   __u32 reserved[8];
-};
-
 #defineGO7007IOC_S_MPEG_PARAMS _IOWR('V', BASE_VIDIOC_PRIVATE + 2, \
struct go7007_mpeg_params)
 #defineGO7007IOC_G_MPEG_PARAMS _IOR('V', BASE_VIDIOC_PRIVATE + 3, \
@@ -112,3 +115,38 @@ struct go7007_md_region {
struct go7007_md_params)
 #defineGO7007IOC_S_MD_REGION   _IOW('V', BASE_VIDIOC_PRIVATE + 8, \
struct go7007_md_region)
+#endif
+
+struct go7007_md_params
+{
+  __u16 region;
+  __u16 trigger;
+  __u16 pixel_threshold;
+  __u16 motion_threshold;
+  __u32 reserved[8];
+};
+
+struct go7007_md_region
+{
+  __u16 region;
+  __u16 flags;
+  struct v4l2_clip *clips;
+  __u32 reserved[8];
+};
+
+#define GO7007IOC_REGION_NUMBER V4L2_CID_PRIVATE_BASE
+#define GO7007IOC_PIXEL_THRESOLD V4L2_CID_PRIVATE_BASE+1
+#define GO7007IOC_MOTION_THRESOLD V4L2_CID_PRIVATE_BASE+2
+#define GO7007IOC_TRIGGER V4L2_CID_PRIVATE_BASE+3
+#define GO7007IOC_REGION_CONTROL V4L2_CID_PRIVATE_BASE+4
+#define GO7007IOC_CLIP_LEFT V4L2_CID_PRIVATE_BASE+5
+#define GO7007IOC_CLIP_TOP V4L2_CID_PRIVATE_BASE+6
+#define GO7007IOC_CLIP_WIDTH V4L2_CID_PRIVATE_BASE+7
+#define GO7007IOC_CLIP_HEIGHT V4L2_CID_PRIVATE_BASE+8
+
+enum RegionControl
+{
+  rcAdd=0
+  ,rcDelete=1
+  ,rcClear=2
+};
diff -uprN -X linux-3.2.11-vanilla/Documentation/dontdiff 
linux-3.2.11-vanilla/drivers/staging/media/go7007/go7007-priv.h 
linux-3.2.11/drivers/staging/media/go7007/go7007-priv.h
--- linux-3.2.11-vanilla/drivers/staging/media/go7007/go7007-priv.h 
2012-03-13 21:05:09.0 +0400
+++ linux-3.2.11/drivers/staging/media/go7007/go7007-priv.h 2012-03-20 
16:17:58.2

[PATCH] go7007 patch for 3.2.x

2012-03-20 Thread volokh
please reply this at linux-media@vger.kernel.org I`ve some trouble

- 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
Regards Volokh

diff -uprN -X linux-3.2.11-vanilla/Documentation/dontdiff 
linux-3.2.11-vanilla/drivers/staging/media/go7007/go7007.h 
linux-3.2.11/drivers/staging/media/go7007/go7007.h
--- linux-3.2.11-vanilla/drivers/staging/media/go7007/go7007.h  2012-03-13 
21:05:09.0 +0400
+++ linux-3.2.11/drivers/staging/media/go7007/go7007.h  2012-03-20 
16:17:26.095901486 +0400
@@ -21,12 +21,27 @@
  * to select between MPEG1, MPEG2, and MPEG4 */
 #define V4L2_PIX_FMT_MPEG4 v4l2_fourcc('M', 'P', 'G', '4') /* MPEG4 */
 
+/* Temporary defines until accepted in v4l2-api (videodev2.h) */
+#ifndef V4L2_MPEG_STREAM_TYPE_MPEG_ELEM
+  #define V4L2_MPEG_STREAM_TYPE_MPEG_ELEM   6 /* MPEG elementary stream */
+#endif
+#ifndef V4L2_MPEG_VIDEO_ENCODING_MPEG_4
+  #define V4L2_MPEG_VIDEO_ENCODING_MPEG_4   3
+#endif
+
+#ifndef V4L2_MPEG_VIDEO_ENCODING_H263
+  #define V4L2_MPEG_VIDEO_ENCODING_H263 4
+#endif
+
+///deprecated defs
+#if 0
 /* These will be replaced with a better interface
  * soon, so don't get too attached to them */
 #defineGO7007IOC_S_BITRATE _IOW('V', BASE_VIDIOC_PRIVATE + 0, int)
 #defineGO7007IOC_G_BITRATE _IOR('V', BASE_VIDIOC_PRIVATE + 1, int)
 
-enum go7007_aspect_ratio {
+enum go7007_aspect_ratio
+{
GO7007_ASPECT_RATIO_1_1 = 0,
GO7007_ASPECT_RATIO_4_3_NTSC = 1,
GO7007_ASPECT_RATIO_4_3_PAL = 2,
@@ -35,7 +50,8 @@ enum go7007_aspect_ratio {
 };
 
 /* Used to set generic compression parameters */
-struct go7007_comp_params {
+struct go7007_comp_params
+{
__u32 gop_size;
__u32 max_b_frames;
enum go7007_aspect_ratio aspect_ratio;
@@ -46,14 +62,16 @@ struct go7007_comp_params {
 #define GO7007_COMP_CLOSED_GOP 0x0001
 #define GO7007_COMP_OMIT_SEQ_HEADER0x0002
 
-enum go7007_mpeg_video_standard {
+enum go7007_mpeg_video_standard
+{
GO7007_MPEG_VIDEO_MPEG1 = 0,
GO7007_MPEG_VIDEO_MPEG2 = 1,
GO7007_MPEG_VIDEO_MPEG4 = 2,
 };
 
 /* Used to set parameters for V4L2_PIX_FMT_MPEG format */
-struct go7007_mpeg_params {
+struct go7007_mpeg_params
+{
enum go7007_mpeg_video_standard mpeg_video_standard;
__u32 flags;
__u32 pali;
@@ -83,21 +101,6 @@ struct go7007_mpeg_params {
 #define GO7007_MPEG4_PROFILE_AS_L4 GO7007_MPEG_PROFILE(4, 0xf4)
 #define GO7007_MPEG4_PROFILE_AS_L5 GO7007_MPEG_PROFILE(4, 0xf5)
 
-struct go7007_md_params {
-   __u16 region;
-   __u16 trigger;
-   __u16 pixel_threshold;
-   __u16 motion_threshold;
-   __u32 reserved[8];
-};
-
-struct go7007_md_region {
-   __u16 region;
-   __u16 flags;
-   struct v4l2_clip *clips;
-   __u32 reserved[8];
-};
-
 #defineGO7007IOC_S_MPEG_PARAMS _IOWR('V', BASE_VIDIOC_PRIVATE + 2, \
struct go7007_mpeg_params)
 #defineGO7007IOC_G_MPEG_PARAMS _IOR('V', BASE_VIDIOC_PRIVATE + 3, \
@@ -112,3 +115,38 @@ struct go7007_md_region {
struct go7007_md_params)
 #defineGO7007IOC_S_MD_REGION   _IOW('V', BASE_VIDIOC_PRIVATE + 8, \
struct go7007_md_region)
+#endif
+
+struct go7007_md_params
+{
+  __u16 region;
+  __u16 trigger;
+  __u16 pixel_threshold;
+  __u16 motion_threshold;
+  __u32 reserved[8];
+};
+
+struct go7007_md_region
+{
+  __u16 region;
+  __u16 flags;
+  struct v4l2_clip *clips;
+  __u32 reserved[8];
+};
+
+#define GO7007IOC_REGION_NUMBER V4L2_CID_PRIVATE_BASE
+#define GO7007IOC_PIXEL_THRESOLD V4L2_CID_PRIVATE_BASE+1
+#define GO7007IOC_MOTION_THRESOLD V4L2_CID_PRIVATE_BASE+2
+#define GO7007IOC_TRIGGER V4L2_CID_PRIVATE_BASE+3
+#define GO7007IOC_REGION_CONTROL V4L2_CID_PRIVATE_BASE+4
+#define GO7007IOC_CLIP_LEFT V4L2_CID_PRIVATE_BASE+5
+#define GO7007IOC_CLIP_TOP V4L2_CID_PRIVATE_BASE+6
+#define GO7007IOC_CLIP_WIDTH V4L2_CID_PRIVATE_BASE+7
+#define GO7007IOC_CLIP_HEIGHT V4L2_CID_PRIVATE_BASE+8
+
+enum RegionControl
+{
+  rcAdd=0
+  ,rcDelete=1
+  ,rcClear=2
+};
diff -uprN -X linux-3.2.11-vanilla/Documentation/dontdiff 
linux-3.2.11-vanilla/drivers/staging/media/go7007/go7007-priv.h 
linux-3.2.11/drivers/staging/media/go7007/go7007-priv.h
--- linux-3.2.11-vanilla/drivers/staging/media/go7007/go7007-priv.h 
2012-03-13 21:05:09.0 +0400
+++ linux-3.2.11/dri