aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPete Eberlein <pete@sensoray.com>2008-10-30 15:56:33 -0400
committerGreg Kroah-Hartman <gregkh@suse.de>2009-01-06 16:52:06 -0500
commitd73f822ce775e004836ffc01ce9feae27d0d65cf (patch)
tree4b731a46fdd6536417ff5f1ee8d2091500ccb83e
parentb2d6a78d9f5323dcb69f7e10476f9fd001c296ff (diff)
Staging: go7007: saa7134 updates
- Added documentation including README files from the original go7007 driver package. - Added Video4Linux2 MPEG controls. - Added Video4Linux2 audio ioctls, which pass thru to the i2c driver. - Improved saa7134 interface, to pass thru controls and video settings. - Fixed a bug in sony tuner, as reported by Bifferos on the Go7007 wiki. Signed-off-by: Pete Eberlein <pete@sensoray.com> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
-rw-r--r--drivers/staging/go7007/go7007-driver.c2
-rw-r--r--drivers/staging/go7007/go7007-priv.h1
-rw-r--r--drivers/staging/go7007/go7007-usb.c2
-rw-r--r--drivers/staging/go7007/go7007-v4l2.c281
-rw-r--r--drivers/staging/go7007/go7007.txt481
-rw-r--r--drivers/staging/go7007/saa7134-go7007.c52
-rw-r--r--drivers/staging/go7007/wis-sony-tuner.c2
7 files changed, 803 insertions, 18 deletions
diff --git a/drivers/staging/go7007/go7007-driver.c b/drivers/staging/go7007/go7007-driver.c
index e4ead96679c..510c23b4684 100644
--- a/drivers/staging/go7007/go7007-driver.c
+++ b/drivers/staging/go7007/go7007-driver.c
@@ -227,7 +227,7 @@ static int init_i2c_module(struct i2c_adapter *adapter, int id, int addr)
227 return 0; 227 return 0;
228 if (modname != NULL) 228 if (modname != NULL)
229 printk(KERN_INFO 229 printk(KERN_INFO
230 "go7007: probing for module %s failed", modname); 230 "go7007: probing for module %s failed\n", modname);
231 else 231 else
232 printk(KERN_INFO 232 printk(KERN_INFO
233 "go7007: sensor %u seems to be unsupported!\n", id); 233 "go7007: sensor %u seems to be unsupported!\n", id);
diff --git a/drivers/staging/go7007/go7007-priv.h b/drivers/staging/go7007/go7007-priv.h
index 005542d16a5..f61d983efa3 100644
--- a/drivers/staging/go7007/go7007-priv.h
+++ b/drivers/staging/go7007/go7007-priv.h
@@ -104,6 +104,7 @@ struct go7007_hpi_ops {
104 int (*stream_start)(struct go7007 *go); 104 int (*stream_start)(struct go7007 *go);
105 int (*stream_stop)(struct go7007 *go); 105 int (*stream_stop)(struct go7007 *go);
106 int (*send_firmware)(struct go7007 *go, u8 *data, int len); 106 int (*send_firmware)(struct go7007 *go, u8 *data, int len);
107 int (*send_command)(struct go7007 *go, unsigned int cmd, void *arg);
107}; 108};
108 109
109/* The video buffer size must be a multiple of PAGE_SIZE */ 110/* The video buffer size must be a multiple of PAGE_SIZE */
diff --git a/drivers/staging/go7007/go7007-usb.c b/drivers/staging/go7007/go7007-usb.c
index 3f5ee3424e7..04cc144e0c1 100644
--- a/drivers/staging/go7007/go7007-usb.c
+++ b/drivers/staging/go7007/go7007-usb.c
@@ -225,7 +225,7 @@ static struct go7007_usb_board board_px_tv402u = {
225 .inputs = { 225 .inputs = {
226 { 226 {
227 .video_input = 1, 227 .video_input = 1,
228 .audio_input = TVAUDIO_INPUT_EXTERN, 228 .audio_input = TVAUDIO_INPUT_EXTERN,
229 .name = "Composite", 229 .name = "Composite",
230 }, 230 },
231 { 231 {
diff --git a/drivers/staging/go7007/go7007-v4l2.c b/drivers/staging/go7007/go7007-v4l2.c
index dfbc2e91c23..e0b17a0145c 100644
--- a/drivers/staging/go7007/go7007-v4l2.c
+++ b/drivers/staging/go7007/go7007-v4l2.c
@@ -38,6 +38,14 @@
38#include "go7007-priv.h" 38#include "go7007-priv.h"
39#include "wis-i2c.h" 39#include "wis-i2c.h"
40 40
41/* Temporary defines until accepted in v4l-dvb */
42#ifndef V4L2_MPEG_STREAM_TYPE_MPEG_ELEM
43#define V4L2_MPEG_STREAM_TYPE_MPEG_ELEM 6 /* MPEG elementary stream */
44#endif
45#ifndef V4L2_MPEG_VIDEO_ENCODING_MPEG_4
46#define V4L2_MPEG_VIDEO_ENCODING_MPEG_4 3
47#endif
48
41static void deactivate_buffer(struct go7007_buffer *gobuf) 49static void deactivate_buffer(struct go7007_buffer *gobuf)
42{ 50{
43 int i; 51 int i;
@@ -375,6 +383,223 @@ static int clip_to_modet_map(struct go7007 *go, int region,
375 return 0; 383 return 0;
376} 384}
377 385
386static int mpeg_queryctrl(u32 id, struct v4l2_queryctrl *ctrl)
387{
388 static const u32 user_ctrls[] = {
389 V4L2_CID_USER_CLASS,
390 0
391 };
392 static const u32 mpeg_ctrls[] = {
393 V4L2_CID_MPEG_CLASS,
394 V4L2_CID_MPEG_STREAM_TYPE,
395 V4L2_CID_MPEG_VIDEO_ENCODING,
396 V4L2_CID_MPEG_VIDEO_ASPECT,
397 V4L2_CID_MPEG_VIDEO_GOP_SIZE,
398 V4L2_CID_MPEG_VIDEO_GOP_CLOSURE,
399 V4L2_CID_MPEG_VIDEO_BITRATE,
400 0
401 };
402 static const u32 *ctrl_classes[] = {
403 user_ctrls,
404 mpeg_ctrls,
405 NULL
406 };
407
408 /* The ctrl may already contain the queried i2c controls,
409 * query the mpeg controls if the existing ctrl id is
410 * greater than the next mpeg ctrl id.
411 */
412 id = v4l2_ctrl_next(ctrl_classes, id);
413 if (id >= ctrl->id && ctrl->name[0])
414 return 0;
415
416 memset(ctrl, 0, sizeof(*ctrl));
417 ctrl->id = id;
418
419 switch (ctrl->id) {
420 case V4L2_CID_USER_CLASS:
421 case V4L2_CID_MPEG_CLASS:
422 return v4l2_ctrl_query_fill_std(ctrl);
423 case V4L2_CID_MPEG_STREAM_TYPE:
424 return v4l2_ctrl_query_fill(ctrl,
425 V4L2_MPEG_STREAM_TYPE_MPEG2_DVD,
426 V4L2_MPEG_STREAM_TYPE_MPEG_ELEM, 1,
427 V4L2_MPEG_STREAM_TYPE_MPEG_ELEM);
428 case V4L2_CID_MPEG_VIDEO_ENCODING:
429 return v4l2_ctrl_query_fill(ctrl,
430 V4L2_MPEG_VIDEO_ENCODING_MPEG_1,
431 V4L2_MPEG_VIDEO_ENCODING_MPEG_4, 1,
432 V4L2_MPEG_VIDEO_ENCODING_MPEG_2);
433 case V4L2_CID_MPEG_VIDEO_ASPECT:
434 return v4l2_ctrl_query_fill(ctrl,
435 V4L2_MPEG_VIDEO_ASPECT_1x1,
436 V4L2_MPEG_VIDEO_ASPECT_16x9, 1,
437 V4L2_MPEG_VIDEO_ASPECT_1x1);
438 case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
439 case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE:
440 return v4l2_ctrl_query_fill_std(ctrl);
441 case V4L2_CID_MPEG_VIDEO_BITRATE:
442 return v4l2_ctrl_query_fill(ctrl,
443 64000,
444 10000000, 1,
445 9800000);
446 default:
447 break;
448 }
449 return -EINVAL;
450}
451
452static int mpeg_s_control(struct v4l2_control *ctrl, struct go7007 *go)
453{
454 /* pretty sure we can't change any of these while streaming */
455 if (go->streaming)
456 return -EBUSY;
457
458 switch (ctrl->id) {
459 case V4L2_CID_MPEG_STREAM_TYPE:
460 switch (ctrl->value) {
461 case V4L2_MPEG_STREAM_TYPE_MPEG2_DVD:
462 go->format = GO7007_FORMAT_MPEG2;
463 go->bitrate = 9800000;
464 go->gop_size = 15;
465 go->pali = 0x48;
466 go->closed_gop = 1;
467 go->repeat_seqhead = 0;
468 go->seq_header_enable = 1;
469 go->gop_header_enable = 1;
470 go->dvd_mode = 1;
471 break;
472 case V4L2_MPEG_STREAM_TYPE_MPEG_ELEM:
473 /* todo: */
474 break;
475 default:
476 return -EINVAL;
477 }
478 break;
479 case V4L2_CID_MPEG_VIDEO_ENCODING:
480 switch (ctrl->value) {
481 case V4L2_MPEG_VIDEO_ENCODING_MPEG_1:
482 go->format = GO7007_FORMAT_MPEG1;
483 go->pali = 0;
484 break;
485 case V4L2_MPEG_VIDEO_ENCODING_MPEG_2:
486 go->format = GO7007_FORMAT_MPEG2;
487 /*if (mpeg->pali >> 24 == 2)
488 go->pali = mpeg->pali & 0xff;
489 else*/
490 go->pali = 0x48;
491 break;
492 case V4L2_MPEG_VIDEO_ENCODING_MPEG_4:
493 go->format = GO7007_FORMAT_MPEG4;
494 /*if (mpeg->pali >> 24 == 4)
495 go->pali = mpeg->pali & 0xff;
496 else*/
497 go->pali = 0xf5;
498 break;
499 default:
500 return -EINVAL;
501 }
502 go->gop_header_enable =
503 /*mpeg->flags & GO7007_MPEG_OMIT_GOP_HEADER
504 ? 0 :*/ 1;
505 /*if (mpeg->flags & GO7007_MPEG_REPEAT_SEQHEADER)
506 go->repeat_seqhead = 1;
507 else*/
508 go->repeat_seqhead = 0;
509 go->dvd_mode = 0;
510 break;
511 case V4L2_CID_MPEG_VIDEO_ASPECT:
512 if (go->format == GO7007_FORMAT_MJPEG)
513 return -EINVAL;
514 switch (ctrl->value) {
515 case V4L2_MPEG_VIDEO_ASPECT_1x1:
516 go->aspect_ratio = GO7007_RATIO_1_1;
517 break;
518 case V4L2_MPEG_VIDEO_ASPECT_4x3:
519 go->aspect_ratio = GO7007_RATIO_4_3;
520 break;
521 case V4L2_MPEG_VIDEO_ASPECT_16x9:
522 go->aspect_ratio = GO7007_RATIO_16_9;
523 break;
524 case V4L2_MPEG_VIDEO_ASPECT_221x100:
525 default:
526 return -EINVAL;
527 }
528 break;
529 case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
530 go->gop_size = ctrl->value;
531 break;
532 case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE:
533 if (ctrl->value != 0 && ctrl->value != 1)
534 return -EINVAL;
535 go->closed_gop = ctrl->value;
536 break;
537 case V4L2_CID_MPEG_VIDEO_BITRATE:
538 /* Upper bound is kind of arbitrary here */
539 if (ctrl->value < 64000 || ctrl->value > 10000000)
540 return -EINVAL;
541 go->bitrate = ctrl->value;
542 break;
543 default:
544 return -EINVAL;
545 }
546 return 0;
547}
548
549static int mpeg_g_control(struct v4l2_control *ctrl, struct go7007 *go)
550{
551 switch (ctrl->id) {
552 case V4L2_CID_MPEG_STREAM_TYPE:
553 if (go->dvd_mode)
554 ctrl->value = V4L2_MPEG_STREAM_TYPE_MPEG2_DVD;
555 else
556 ctrl->value = V4L2_MPEG_STREAM_TYPE_MPEG_ELEM;
557 break;
558 case V4L2_CID_MPEG_VIDEO_ENCODING:
559 switch (go->format) {
560 case GO7007_FORMAT_MPEG1:
561 ctrl->value = V4L2_MPEG_VIDEO_ENCODING_MPEG_1;
562 break;
563 case GO7007_FORMAT_MPEG2:
564 ctrl->value = V4L2_MPEG_VIDEO_ENCODING_MPEG_2;
565 break;
566 case GO7007_FORMAT_MPEG4:
567 ctrl->value = V4L2_MPEG_VIDEO_ENCODING_MPEG_4;
568 break;
569 default:
570 return -EINVAL;
571 }
572 break;
573 case V4L2_CID_MPEG_VIDEO_ASPECT:
574 switch (go->aspect_ratio) {
575 case GO7007_RATIO_1_1:
576 ctrl->value = V4L2_MPEG_VIDEO_ASPECT_1x1;
577 break;
578 case GO7007_RATIO_4_3:
579 ctrl->value = V4L2_MPEG_VIDEO_ASPECT_4x3;
580 break;
581 case GO7007_RATIO_16_9:
582 ctrl->value = V4L2_MPEG_VIDEO_ASPECT_16x9;
583 break;
584 default:
585 return -EINVAL;
586 }
587 break;
588 case V4L2_CID_MPEG_VIDEO_GOP_SIZE:
589 ctrl->value = go->gop_size;
590 break;
591 case V4L2_CID_MPEG_VIDEO_GOP_CLOSURE:
592 ctrl->value = go->closed_gop;
593 break;
594 case V4L2_CID_MPEG_VIDEO_BITRATE:
595 ctrl->value = go->bitrate;
596 break;
597 default:
598 return -EINVAL;
599 }
600 return 0;
601}
602
378static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg) 603static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg)
379{ 604{
380 struct go7007_file *gofh = file->private_data; 605 struct go7007_file *gofh = file->private_data;
@@ -392,7 +617,7 @@ static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg)
392 strncpy(cap->card, go->name, sizeof(cap->card)); 617 strncpy(cap->card, go->name, sizeof(cap->card));
393 cap->version = KERNEL_VERSION(0, 9, 8); 618 cap->version = KERNEL_VERSION(0, 9, 8);
394 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE | 619 cap->capabilities = V4L2_CAP_VIDEO_CAPTURE |
395 V4L2_CAP_STREAMING; /* | V4L2_CAP_AUDIO; */ 620 V4L2_CAP_STREAMING | V4L2_CAP_AUDIO;
396 if (go->board_info->flags & GO7007_BOARD_HAS_TUNER) 621 if (go->board_info->flags & GO7007_BOARD_HAS_TUNER)
397 cap->capabilities |= V4L2_CAP_TUNER; 622 cap->capabilities |= V4L2_CAP_TUNER;
398 return 0; 623 return 0;
@@ -464,6 +689,19 @@ static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg)
464 return -EBUSY; 689 return -EBUSY;
465 return set_capture_size(go, fmt, 0); 690 return set_capture_size(go, fmt, 0);
466 } 691 }
692 case VIDIOC_ENUMAUDIO:
693 case VIDIOC_G_AUDIO:
694 case VIDIOC_S_AUDIO:
695 {
696 struct v4l2_audio *audio = arg;
697
698 if (!go->i2c_adapter_online)
699 return -EIO;
700 i2c_clients_command(&go->i2c_adapter, cmd, arg);
701 if (cmd == VIDIOC_ENUMAUDIO && !audio->name[0])
702 return -EINVAL;
703 return 0;
704 }
467 case VIDIOC_G_FBUF: 705 case VIDIOC_G_FBUF:
468 case VIDIOC_S_FBUF: 706 case VIDIOC_S_FBUF:
469 return -EINVAL; 707 return -EINVAL;
@@ -699,12 +937,16 @@ static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg)
699 struct v4l2_queryctrl *ctrl = arg; 937 struct v4l2_queryctrl *ctrl = arg;
700 u32 id; 938 u32 id;
701 939
702 if (!go->i2c_adapter_online)
703 return -EIO;
704 id = ctrl->id; 940 id = ctrl->id;
705 memset(ctrl, 0, sizeof(*ctrl)); 941 memset(ctrl, 0, sizeof(*ctrl));
706 ctrl->id = id; 942 ctrl->id = id;
707 i2c_clients_command(&go->i2c_adapter, VIDIOC_QUERYCTRL, arg); 943 if (go->i2c_adapter_online)
944 i2c_clients_command(&go->i2c_adapter,
945 VIDIOC_QUERYCTRL, arg);
946 else if (go->hpi_ops && go->hpi_ops->send_command)
947 go->hpi_ops->send_command(go, cmd, arg);
948 if (id & V4L2_CTRL_FLAG_NEXT_CTRL || ctrl->name[0] == 0)
949 return mpeg_queryctrl(id, ctrl);
708 return ctrl->name[0] == 0 ? -EINVAL : 0; 950 return ctrl->name[0] == 0 ? -EINVAL : 0;
709 } 951 }
710 case VIDIOC_G_CTRL: 952 case VIDIOC_G_CTRL:
@@ -712,13 +954,16 @@ static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg)
712 struct v4l2_control *ctrl = arg; 954 struct v4l2_control *ctrl = arg;
713 struct v4l2_queryctrl query; 955 struct v4l2_queryctrl query;
714 956
715 if (!go->i2c_adapter_online)
716 return -EIO;
717 memset(&query, 0, sizeof(query)); 957 memset(&query, 0, sizeof(query));
718 query.id = ctrl->id; 958 query.id = ctrl->id;
719 i2c_clients_command(&go->i2c_adapter, VIDIOC_QUERYCTRL, &query); 959 if (go->i2c_adapter_online)
960 i2c_clients_command(&go->i2c_adapter,
961 VIDIOC_QUERYCTRL, &query);
962 else if (go->hpi_ops && go->hpi_ops->send_command)
963 if (0 == go->hpi_ops->send_command(go, cmd, arg))
964 return 0;
720 if (query.name[0] == 0) 965 if (query.name[0] == 0)
721 return -EINVAL; 966 return mpeg_g_control(ctrl, go);
722 i2c_clients_command(&go->i2c_adapter, VIDIOC_G_CTRL, arg); 967 i2c_clients_command(&go->i2c_adapter, VIDIOC_G_CTRL, arg);
723 return 0; 968 return 0;
724 } 969 }
@@ -727,13 +972,16 @@ static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg)
727 struct v4l2_control *ctrl = arg; 972 struct v4l2_control *ctrl = arg;
728 struct v4l2_queryctrl query; 973 struct v4l2_queryctrl query;
729 974
730 if (!go->i2c_adapter_online)
731 return -EIO;
732 memset(&query, 0, sizeof(query)); 975 memset(&query, 0, sizeof(query));
733 query.id = ctrl->id; 976 query.id = ctrl->id;
734 i2c_clients_command(&go->i2c_adapter, VIDIOC_QUERYCTRL, &query); 977 if (go->i2c_adapter_online)
978 i2c_clients_command(&go->i2c_adapter,
979 VIDIOC_QUERYCTRL, &query);
980 else if (go->hpi_ops && go->hpi_ops->send_command)
981 if (0 == go->hpi_ops->send_command(go, cmd, arg))
982 return 0;
735 if (query.name[0] == 0) 983 if (query.name[0] == 0)
736 return -EINVAL; 984 return mpeg_s_control(ctrl, go);
737 i2c_clients_command(&go->i2c_adapter, VIDIOC_S_CTRL, arg); 985 i2c_clients_command(&go->i2c_adapter, VIDIOC_S_CTRL, arg);
738 return 0; 986 return 0;
739 } 987 }
@@ -826,6 +1074,8 @@ static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg)
826 *std = V4L2_STD_NTSC; 1074 *std = V4L2_STD_NTSC;
827 else 1075 else
828 *std = V4L2_STD_PAL | V4L2_STD_SECAM; 1076 *std = V4L2_STD_PAL | V4L2_STD_SECAM;
1077 } else if (go->hpi_ops && go->hpi_ops->send_command) {
1078 go->hpi_ops->send_command(go, cmd, arg);
829 } else 1079 } else
830 *std = 0; 1080 *std = 0;
831 return 0; 1081 return 0;
@@ -864,6 +1114,9 @@ static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg)
864 if (go->i2c_adapter_online) 1114 if (go->i2c_adapter_online)
865 i2c_clients_command(&go->i2c_adapter, 1115 i2c_clients_command(&go->i2c_adapter,
866 VIDIOC_S_STD, std); 1116 VIDIOC_S_STD, std);
1117 if (go->hpi_ops && go->hpi_ops->send_command)
1118 go->hpi_ops->send_command(go, cmd, arg);
1119
867 set_capture_size(go, NULL, 0); 1120 set_capture_size(go, NULL, 0);
868 return 0; 1121 return 0;
869 } 1122 }
@@ -1316,7 +1569,7 @@ static long go7007_do_ioctl(struct file *file, unsigned int cmd, void *arg)
1316 return clip_to_modet_map(go, region->region, region->clips); 1569 return clip_to_modet_map(go, region->region, region->clips);
1317 } 1570 }
1318 default: 1571 default:
1319 printk(KERN_DEBUG "go7007: unsupported ioctl %d\n", cmd); 1572 printk(KERN_INFO "go7007-v4l2: unsupported ioctl %d\n", cmd);
1320 return -ENOIOCTLCMD; 1573 return -ENOIOCTLCMD;
1321 } 1574 }
1322 return 0; 1575 return 0;
@@ -1474,6 +1727,8 @@ int go7007_v4l2_init(struct go7007 *go)
1474 } 1727 }
1475 video_set_drvdata(go->video_dev, go); 1728 video_set_drvdata(go->video_dev, go);
1476 ++go->ref_count; 1729 ++go->ref_count;
1730 printk(KERN_INFO "%s: registered device video%d [v4l2]\n",
1731 go->video_dev->name, go->video_dev->num);
1477 1732
1478 return 0; 1733 return 0;
1479} 1734}
diff --git a/drivers/staging/go7007/go7007.txt b/drivers/staging/go7007/go7007.txt
new file mode 100644
index 00000000000..9f6772bc68c
--- /dev/null
+++ b/drivers/staging/go7007/go7007.txt
@@ -0,0 +1,481 @@
1This is a driver for the WIS GO7007SB multi-format video encoder.
2
3Pete Eberlein <pete@sensoray.com>
4
5The driver was orignally released under the GPL and is currently hosted at:
6http://nikosapi.org/wiki/index.php/WIS_Go7007_Linux_driver
7The go7007 firmware can be acquired from the package on the site above.
8
9I've modified the driver to support the following Video4Linux2 MPEG
10controls, with acceptable values:
11
12V4L2_CID_MPEG_STREAM_TYPE V4L2_MPEG_STREAM_TYPE_MPEG2_DVD
13 V4L2_MPEG_STREAM_TYPE_MPEG_ELEM
14V4L2_CID_MPEG_VIDEO_ENCODING V4L2_MPEG_VIDEO_ENCODING_MPEG_1
15 V4L2_MPEG_VIDEO_ENCODING_MPEG_2
16 V4L2_MPEG_VIDEO_ENCODING_MPEG_4
17V4L2_CID_MPEG_VIDEO_ASPECT V4L2_MPEG_VIDEO_ASPECT_1x1
18 V4L2_MPEG_VIDEO_ASPECT_4x3
19 V4L2_MPEG_VIDEO_ASPECT_16x9
20V4L2_CID_MPEG_VIDEO_GOP_SIZE integer
21V4L2_CID_MPEG_VIDEO_BITRATE 64000 .. 10000000
22
23These should be used instead of the non-standard GO7007 ioctls described
24below.
25
26
27The README files from the orignal package appear below:
28
29---------------------------------------------------------------------------
30 WIS GO7007SB Public Linux Driver
31---------------------------------------------------------------------------
32
33
34*** Please see the file RELEASE-NOTES for important last-minute updates ***
35
36
37 0. OVERVIEW AND LICENSING/DISCLAIMER
38
39
40This driver kit contains Linux drivers for the WIS GO7007SB multi-format
41video encoder. Only kernel version 2.6.x is supported. The video stream
42is available through the Video4Linux2 API and the audio stream is available
43through the ALSA API (or the OSS emulation layer of the ALSA system).
44
45The files in kernel/ and hotplug/ are licensed under the GNU General Public
46License Version 2 from the Free Software Foundation. A copy of the license
47is included in the file COPYING.
48
49The example applications in apps/ and C header files in include/ are
50licensed under a permissive license included in the source files which
51allows copying, modification and redistribution for any purpose without
52attribution.
53
54The firmware files included in the firmware/ directory may be freely
55redistributed only in conjunction with this document; but modification,
56tampering and reverse engineering are prohibited.
57
58MICRONAS USA, INC., MAKES NO WARRANTIES TO ANY PERSON OR ENTITY WITH
59RESPECT TO THE SOFTWARE OR ANY DERIVATIVES THEREOF OR ANY SERVICES OR
60LICENSES AND DISCLAIMS ALL IMPLIED WARRANTIES, INCLUDING WITHOUT LIMITATION
61WARRANTIES OF MERCHANTABILITY, SUPPORT, AND FITNESS FOR A PARTICULAR
62PURPOSE AND NON-INFRINGEMENT.
63
64
65 1. SYSTEM REQUIREMENTS
66
67
68This driver requires Linux kernel 2.6. Kernel 2.4 is not supported. Using
69kernel 2.6.10 or later is recommended, as earlier kernels are known to have
70unstable USB 2.0 support.
71
72A fully built kernel source tree must be available. Typically this will be
73linked from "/lib/modules/<KERNEL VERSION>/build" for convenience. If this
74link does not exist, an extra parameter will need to be passed to the
75`make` command.
76
77All vendor-built kernels should already be configured properly. However,
78for custom-built kernels, the following options need to be enabled in the
79kernel as built-in or modules:
80
81 CONFIG_HOTPLUG - Support for hot-pluggable devices
82 CONFIG_MODULES - Enable loadable module support
83 CONFIG_KMOD - Automatic kernel module loading
84 CONFIG_FW_LOADER - Hotplug firmware loading support
85 CONFIG_I2C - I2C support
86 CONFIG_VIDEO_DEV - Video For Linux
87 CONFIG_SOUND - Sound card support
88 CONFIG_SND - Advanced Linux Sound Architecture
89 CONFIG_USB - Support for Host-side USB
90 CONFIG_USB_DEVICEFS - USB device filesystem
91 CONFIG_USB_EHCI_HCD - EHCI HCD (USB 2.0) support
92
93Additionally, to use the example application, the following options need to
94be enabled in the ALSA section:
95
96 CONFIG_SND_MIXER_OSS - OSS Mixer API
97 CONFIG_SND_PCM_OSS - OSS PCM (digital audio) API
98
99The hotplug scripts, along with the fxload utility, must also be installed.
100These scripts can be obtained from <http://linux-hotplug.sourceforge.net/>.
101Hotplugging is used for loading firmware into the Cypruss EZ-USB chip using
102fxload and for loading firmware into the driver using the firmware agent.
103
104
105 2. COMPILING AND INSTALLING THE DRIVER
106
107
108Most users should be able to compile the driver by simply running:
109
110 $ make
111
112in the top-level directory of the driver kit. First the kernel modules
113will be built, followed by the example applications.
114
115If the build system is unable to locate the kernel source tree for the
116currently-running kernel, or if the module should be built for a kernel
117other than the currently-running kernel, an additional parameter will need
118to be passed to make to specify the appropriate kernel source directory:
119
120 $ make KERNELSRC=/usr/src/linux-2.6.10-custom3
121
122Once the compile completes, the driver and firmware files should be
123installed by running:
124
125 $ make install
126
127The kernel modules will be placed in "/lib/modules/<KERNEL VERSION>/extra"
128and the firmware files will be placed in the appropriate hotplug firmware
129directory, usually /lib/firmware. In addition, USB maps and scripts will
130be placed in /etc/hotplug/usb to enable fxload to initialize the EZ-USB
131control chip when the device is connected.
132
133
134 3. PAL/SECAM TUNER CONFIGURATION (TV402U-EU only)
135
136
137The PAL model of the Plextor ConvertX TV402U may require additional
138configuration to correctly select the appropriate TV frequency band and
139audio subchannel.
140
141Users with a device other than the Plextor ConvertX TV402U-EU should skip
142this section.
143
144The wide variety of PAL TV systems used in Europe requires that additional
145information about the local TV standards be passed to the driver in order
146to properly tune TV channels. The two necessary parameters are (a) the PAL
147TV band, and (b) the audio subchannel format in use.
148
149In many cases, the appropriate TV band selection is passed to the driver
150from applications. However, in some cases, the application only specifies
151that the driver should use PAL but not the specific information about the
152appropriate TV band. To work around this issue, the correct TV band may be
153specified in the "force_band" parameter to the wis-sony-tuner module:
154
155 TV band force_band
156 ------- ----------
157 PAL B/G B
158 PAL I I
159 PAL D/K D
160 SECAM L L
161
162If the "force_band" parameter is specified, the driver will ignore any TV
163band specified by applications and will always use the band provided in the
164module parameter.
165
166The other parameter that can be specified is the audio subchannel format.
167There are several stereo audio carrier systems in use, including NICAM and
168three varieties of A2. To receive audio broadcast on one of these stereo
169carriers, the "force_mpx_mode" parameter must be specified to the
170wis-sony-tuner module.
171
172 TV band Audio subcarrier force_mpx_mode
173 ------- ---------------- --------------
174 PAL B/G Mono (default) 1
175 PAL B/G A2 2
176 PAL B/G NICAM 3
177 PAL I Mono (default) 4
178 PAL I NICAM 5
179 PAL D/K Mono (default) 6
180 PAL D/K A2 (1) 7
181 PAL D/K A2 (2) 8
182 PAL D/K A2 (3) 9
183 PAL D/K NICAM 10
184 SECAM L Mono (default) 11
185 SECAM L NICAM 12
186
187If the "force_mpx_mode" parameter is not specified, the correct mono-only
188mode will be chosen based on the TV band. However, the tuner will not
189receive stereo audio or bilingual broadcasts correctly.
190
191To pass the "force_band" or "force_mpx_mode" parameters to the
192wis-sony-tuner module, the following line must be added to the modprobe
193configuration file, which varies from one Linux distribution to another.
194
195 options wis-sony-tuner force_band=B force_mpx_mode=2
196
197The above example would force the tuner to the PAL B/G TV band and receive
198stereo audio broadcasts on the A2 carrier.
199
200To verify that the configuration has been placed in the correct location,
201execute:
202
203 $ modprobe -c | grep wis-sony-tuner
204
205If the configuration line appears, then modprobe will pass the parameters
206correctly the next time the wis-sony-tuner module is loaded into the
207kernel.
208
209
210 4. TESTING THE DRIVER
211
212
213Because few Linux applications are able to correctly capture from
214Video4Linux2 devices with only compressed formats supported, the new driver
215should be tested with the "gorecord" application in the apps/ directory.
216
217First connect a video source to the device, such as a DVD player or VCR.
218This will be captured to a file for testing the driver. If an input source
219is unavailable, a test file can still be captured, but the video will be
220black and the audio will be silent.
221
222This application will auto-detect the V4L2 and ALSA/OSS device names of the
223hardware and will record video and audio to an AVI file for a specified
224number of seconds. For example:
225
226 $ apps/gorecord -duration 60 capture.avi
227
228If this application does not successfully record an AVI file, the error
229messages produced by gorecord and recorded in the system log (usually in
230/var/log/messages) should provide information to help resolve the problem.
231
232Supplying no parameters to gorecord will cause it to probe the available
233devices and exit. Use the -help flag for usage information.
234
235
236 5. USING THE DRIVER
237
238
239The V4L2 device implemented by the driver provides a standard compressed
240format API, within the following criteria:
241
242 * Applications that only support the original Video4Linux1 API will not
243 be able to communicate with this driver at all.
244
245 * No raw video modes are supported, so applications like xawtv that
246 expect only uncompressed video will not function.
247
248 * Supported compression formats are: Motion-JPEG, MPEG1, MPEG2 and MPEG4.
249
250 * MPEG video formats are delivered as Video Elementary Streams only.
251 Program Stream (PS), Transport Stream (TS) and Packetized Elementary
252 Stream (PES) formats are not supported.
253
254 * Video parameters such as format and input port may not be changed while
255 the encoder is active.
256
257 * The audio capture device only functions when the video encoder is
258 actively capturing video. Attempts to read from the audio device when
259 the encoder is inactive will result in an I/O error.
260
261 * The native format of the audio device is 48Khz 2-channel 16-bit
262 little-endian PCM, delivered through the ALSA system. No audio
263 compression is implemented in the hardware. ALSA may convert to other
264 uncompressed formats on the fly.
265
266The include/ directory contains a C header file describing non-standard
267features of the GO7007SB encoder, which are described below:
268
269
270 GO7007IOC_S_COMP_PARAMS, GO7007IOC_G_COMP_PARAMS
271
272 These ioctls are used to negotiate general compression parameters.
273
274 To query the current parameters, call the GO7007IOC_G_COMP_PARAMS ioctl
275 with a pointer to a struct go7007_comp_params. If the driver is not
276 set to MPEG format, the EINVAL error code will be returned.
277
278 To change the current parameters, initialize all fields of a struct
279 go7007_comp_params and call the GO7007_IOC_S_COMP_PARAMS ioctl with a
280 pointer to this structure. The driver will return the current
281 parameters with any necessary changes to conform to the limitations of
282 the hardware or current compression mode. Any or all fields can be set
283 to zero to request a reasonable default value. If the driver is not
284 set to MPEG format, the EINVAL error code will be returned. When I/O
285 is in progress, the EBUSY error code will be returned.
286
287 Fields in struct go7007_comp_params:
288
289 __u32 The maximum number of frames in each
290 gop_size Group Of Pictures; i.e. the maximum
291 number of frames minus one between
292 each key frame.
293
294 __u32 The maximum number of sequential
295 max_b_frames bidirectionally-predicted frames.
296 (B-frames are not yet supported.)
297
298 enum go7007_aspect_ratio The aspect ratio to be encoded in the
299 aspect_ratio meta-data of the compressed format.
300
301 Choices are:
302 GO7007_ASPECT_RATIO_1_1
303 GO7007_ASPECT_RATIO_4_3_NTSC
304 GO7007_ASPECT_RATIO_4_3_PAL
305 GO7007_ASPECT_RATIO_16_9_NTSC
306 GO7007_ASPECT_RATIO_16_9_PAL
307
308 __u32 Bit-wise OR of control flags (below)
309 flags
310
311 Flags in struct go7007_comp_params:
312
313 GO7007_COMP_CLOSED_GOP Only produce self-contained GOPs, used
314 to produce streams appropriate for
315 random seeking.
316
317 GO7007_COMP_OMIT_SEQ_HEADER Omit the stream sequence header.
318
319
320 GO7007IOC_S_MPEG_PARAMS, GO7007IOC_G_MPEG_PARAMS
321
322 These ioctls are used to negotiate MPEG-specific stream parameters when
323 the pixelformat has been set to V4L2_PIX_FMT_MPEG.
324
325 To query the current parameters, call the GO7007IOC_G_MPEG_PARAMS ioctl
326 with a pointer to a struct go7007_mpeg_params. If the driver is not
327 set to MPEG format, the EINVAL error code will be returned.
328
329 To change the current parameters, initialize all fields of a struct
330 go7007_mpeg_params and call the GO7007_IOC_S_MPEG_PARAMS ioctl with a
331 pointer to this structure. The driver will return the current
332 parameters with any necessary changes to conform to the limitations of
333 the hardware or selected MPEG mode. Any or all fields can be set to
334 zero to request a reasonable default value. If the driver is not set
335 to MPEG format, the EINVAL error code will be returned. When I/O is in
336 progress, the EBUSY error code will be returned.
337
338 Fields in struct go7007_mpeg_params:
339
340 enum go7007_mpeg_video_standard
341 mpeg_video_standard The MPEG video standard in which to
342 compress the video.
343
344 Choices are:
345 GO7007_MPEG_VIDEO_MPEG1
346 GO7007_MPEG_VIDEO_MPEG2
347 GO7007_MPEG_VIDEO_MPEG4
348
349 __u32 Bit-wise OR of control flags (below)
350 flags
351
352 __u32 The profile and level indication to be
353 pali stored in the sequence header. This
354 is only used as an indicator to the
355 decoder, and does not affect the MPEG
356 features used in the video stream.
357 Not valid for MPEG1.
358
359 Choices for MPEG2 are:
360 GO7007_MPEG2_PROFILE_MAIN_MAIN
361
362 Choices for MPEG4 are:
363 GO7007_MPEG4_PROFILE_S_L0
364 GO7007_MPEG4_PROFILE_S_L1
365 GO7007_MPEG4_PROFILE_S_L2
366 GO7007_MPEG4_PROFILE_S_L3
367 GO7007_MPEG4_PROFILE_ARTS_L1
368 GO7007_MPEG4_PROFILE_ARTS_L2
369 GO7007_MPEG4_PROFILE_ARTS_L3
370 GO7007_MPEG4_PROFILE_ARTS_L4
371 GO7007_MPEG4_PROFILE_AS_L0
372 GO7007_MPEG4_PROFILE_AS_L1
373 GO7007_MPEG4_PROFILE_AS_L2
374 GO7007_MPEG4_PROFILE_AS_L3
375 GO7007_MPEG4_PROFILE_AS_L4
376 GO7007_MPEG4_PROFILE_AS_L5
377
378 Flags in struct go7007_mpeg_params:
379
380 GO7007_MPEG_FORCE_DVD_MODE Force all compression parameters and
381 bitrate control settings to comply
382 with DVD MPEG2 stream requirements.
383 This overrides most compression and
384 bitrate settings!
385
386 GO7007_MPEG_OMIT_GOP_HEADER Omit the GOP header.
387
388 GO7007_MPEG_REPEAT_SEQHEADER Repeat the MPEG sequence header at
389 the start of each GOP.
390
391
392 GO7007IOC_S_BITRATE, GO7007IOC_G_BITRATE
393
394 These ioctls are used to set and query the target bitrate value for the
395 compressed video stream. The bitrate may be selected by storing the
396 target bits per second in an int and calling GO7007IOC_S_BITRATE with a
397 pointer to the int. The bitrate may be queried by calling
398 GO7007IOC_G_BITRATE with a pointer to an int where the current bitrate
399 will be stored.
400
401 Note that this is the primary means of controlling the video quality
402 for all compression modes, including V4L2_PIX_FMT_MJPEG. The
403 VIDIOC_S_JPEGCOMP ioctl is not supported.
404
405
406----------------------------------------------------------------------------
407 Installing the WIS PCI Voyager Driver
408---------------------------------------------------------------------------
409
410The WIS PCI Voyager driver requires several patches to the Linux 2.6.11.x
411kernel source tree before compiling the driver. These patches update the
412in-kernel SAA7134 driver to the newest development version and patch bugs
413in the TDA8290/TDA8275 tuner driver.
414
415The following patches must be downloaded from Gerd Knorr's website and
416applied in the order listed:
417
418 http://dl.bytesex.org/patches/2.6.11-2/i2c-tuner
419 http://dl.bytesex.org/patches/2.6.11-2/i2c-tuner2
420 http://dl.bytesex.org/patches/2.6.11-2/v4l2-api-mpeg
421 http://dl.bytesex.org/patches/2.6.11-2/saa7134-update
422
423The following patches are included with this SDK and can be applied in any
424order:
425
426 patches/2.6.11/saa7134-voyager.diff
427 patches/2.6.11/tda8275-newaddr.diff
428 patches/2.6.11/tda8290-ntsc.diff
429
430Check to make sure the CONFIG_VIDEO_SAA7134 option is enabled in the kernel
431configuration, and build and install the kernel.
432
433After rebooting into the new kernel, the GO7007 driver can be compiled and
434installed:
435
436 $ make SAA7134_BUILD=y
437 $ make install
438 $ modprobe saa7134-go7007
439
440There will be two V4L video devices associated with the PCI Voyager. The
441first device (most likely /dev/video0) provides access to the raw video
442capture mode of the SAA7133 device and is used to configure the source
443video parameters and tune the TV tuner. This device can be used with xawtv
444or other V4L(2) video software as a standard uncompressed device.
445
446The second device (most likely /dev/video1) provides access to the
447compression functions of the GO7007. It can be tested using the gorecord
448application in the apps/ directory of this SDK:
449
450 $ apps/gorecord -vdevice /dev/video1 -noaudio test.avi
451
452Currently the frame resolution is fixed at 720x480 (NTSC) or 720x576 (PAL),
453and the video standard must be specified to both the raw and the compressed
454video devices (xawtv and gorecord, for example).
455
456
457--------------------------------------------------------------------------
458RELEASE NOTES FOR WIS GO7007SB LINUX DRIVER
459---------------------------------------------------------------------------
460
461Last updated: 5 November 2005
462
463 - Release 0.9.7 includes new support for using udev to run fxload. The
464 install script should automatically detect whether the old hotplug
465 scripts or the new udev rules should be used. To force the use of
466 hotplug, run "make install USE_UDEV=n". To force the use of udev, run
467 "make install USE_UDEV=y".
468
469 - Motion detection is supported but undocumented. Try the `modet` app
470 for a demonstration of how to use the facility.
471
472 - Using USB2.0 devices such as the TV402U with USB1.1 HCDs or hubs can
473 cause buffer overruns and frame drops, even at low framerates, due to
474 inconsistency in the bitrate control mechanism.
475
476 - On devices with an SAA7115, including the Plextor ConvertX, video height
477 values of 96, 128, 160, 192, 256, 320, and 384 do not work in NTSC mode.
478 All valid heights up to 512 work correctly in PAL mode.
479
480 - The WIS Star Trek and PCI Voyager boards have no support yet for audio
481 or the TV tuner.
diff --git a/drivers/staging/go7007/saa7134-go7007.c b/drivers/staging/go7007/saa7134-go7007.c
index c4a6d8ef907..665bbf59d02 100644
--- a/drivers/staging/go7007/saa7134-go7007.c
+++ b/drivers/staging/go7007/saa7134-go7007.c
@@ -27,7 +27,7 @@
27#include <linux/usb.h> 27#include <linux/usb.h>
28#include <linux/i2c.h> 28#include <linux/i2c.h>
29#include <asm/byteorder.h> 29#include <asm/byteorder.h>
30#include <media/audiochip.h> 30#include <media/v4l2-common.h>
31 31
32#include "saa7134-reg.h" 32#include "saa7134-reg.h"
33#include "saa7134.h" 33#include "saa7134.h"
@@ -314,7 +314,13 @@ static int saa7134_go7007_stream_start(struct go7007 *go)
314static int saa7134_go7007_stream_stop(struct go7007 *go) 314static int saa7134_go7007_stream_stop(struct go7007 *go)
315{ 315{
316 struct saa7134_go7007 *saa = go->hpi_context; 316 struct saa7134_go7007 *saa = go->hpi_context;
317 struct saa7134_dev *dev = saa->dev; 317 struct saa7134_dev *dev;
318
319 if (!saa)
320 return -EINVAL;
321 dev = saa->dev;
322 if (!dev)
323 return -EINVAL;
318 324
319 /* Shut down TS FIFO */ 325 /* Shut down TS FIFO */
320 saa_clearl(SAA7134_MAIN_CTRL, SAA7134_MAIN_CTRL_TE5); 326 saa_clearl(SAA7134_MAIN_CTRL, SAA7134_MAIN_CTRL_TE5);
@@ -373,6 +379,47 @@ static int saa7134_go7007_send_firmware(struct go7007 *go, u8 *data, int len)
373 return 0; 379 return 0;
374} 380}
375 381
382static int saa7134_go7007_send_command(struct go7007 *go, unsigned int cmd,
383 void *arg)
384{
385 struct saa7134_go7007 *saa = go->hpi_context;
386 struct saa7134_dev *dev = saa->dev;
387
388 switch (cmd) {
389 case VIDIOC_S_STD:
390 {
391 v4l2_std_id *std = arg;
392 return saa7134_s_std_internal(dev, NULL, std);
393 }
394 case VIDIOC_G_STD:
395 {
396 v4l2_std_id *std = arg;
397 *std = dev->tvnorm->id;
398 return 0;
399 }
400 case VIDIOC_QUERYCTRL:
401 {
402 struct v4l2_queryctrl *ctrl = arg;
403 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_USER)
404 return saa7134_queryctrl(NULL, NULL, ctrl);
405 }
406 case VIDIOC_G_CTRL:
407 {
408 struct v4l2_control *ctrl = arg;
409 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_USER)
410 return saa7134_g_ctrl_internal(dev, NULL, ctrl);
411 }
412 case VIDIOC_S_CTRL:
413 {
414 struct v4l2_control *ctrl = arg;
415 if (V4L2_CTRL_ID2CLASS(ctrl->id) == V4L2_CTRL_CLASS_USER)
416 return saa7134_s_ctrl_internal(dev, NULL, ctrl);
417 }
418 }
419 return -EINVAL;
420
421}
422
376static struct go7007_hpi_ops saa7134_go7007_hpi_ops = { 423static struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
377 .interface_reset = saa7134_go7007_interface_reset, 424 .interface_reset = saa7134_go7007_interface_reset,
378 .write_interrupt = saa7134_go7007_write_interrupt, 425 .write_interrupt = saa7134_go7007_write_interrupt,
@@ -380,6 +427,7 @@ static struct go7007_hpi_ops saa7134_go7007_hpi_ops = {
380 .stream_start = saa7134_go7007_stream_start, 427 .stream_start = saa7134_go7007_stream_start,
381 .stream_stop = saa7134_go7007_stream_stop, 428 .stream_stop = saa7134_go7007_stream_stop,
382 .send_firmware = saa7134_go7007_send_firmware, 429 .send_firmware = saa7134_go7007_send_firmware,
430 .send_command = saa7134_go7007_send_command,
383}; 431};
384 432
385/********************* Add/remove functions *********************/ 433/********************* Add/remove functions *********************/
diff --git a/drivers/staging/go7007/wis-sony-tuner.c b/drivers/staging/go7007/wis-sony-tuner.c
index 5a91ee409a7..58fddb12237 100644
--- a/drivers/staging/go7007/wis-sony-tuner.c
+++ b/drivers/staging/go7007/wis-sony-tuner.c
@@ -604,7 +604,7 @@ static int tuner_command(struct i2c_client *client, unsigned int cmd, void *arg)
604 { 604 {
605 struct v4l2_tuner *tun = arg; 605 struct v4l2_tuner *tun = arg;
606 606
607 memset(t, 0, sizeof(*tun)); 607 memset(tun, 0, sizeof(*tun));
608 strcpy(tun->name, "Television"); 608 strcpy(tun->name, "Television");
609 tun->type = V4L2_TUNER_ANALOG_TV; 609 tun->type = V4L2_TUNER_ANALOG_TV;
610 tun->rangelow = 0UL; /* does anything use these? */ 610 tun->rangelow = 0UL; /* does anything use these? */