diff options
author | Steven Toth <stoth@kernellabs.com> | 2010-07-31 15:06:06 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@redhat.com> | 2010-10-21 05:55:06 -0400 |
commit | e8ce2f21665442a29a2b2d1b25197b05405a7216 (patch) | |
tree | da2b06eb5b2047f453ebbc2d87a027c7487266f3 /drivers/media/video/saa7164/saa7164-api.c | |
parent | 11bd27b2e7ab8125b0f8d763b8b61d07a5a38acf (diff) |
[media] saa7164: add NTSC VBI support
IRQ handlers, firmware messages, deferred queue handlers, V4L api's
etc.
Signed-off-by: Steven Toth <stoth@kernellabs.com>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/saa7164/saa7164-api.c')
-rw-r--r-- | drivers/media/video/saa7164/saa7164-api.c | 111 |
1 files changed, 106 insertions, 5 deletions
diff --git a/drivers/media/video/saa7164/saa7164-api.c b/drivers/media/video/saa7164/saa7164-api.c index 9fd39326b85a..814751deb218 100644 --- a/drivers/media/video/saa7164/saa7164-api.c +++ b/drivers/media/video/saa7164/saa7164-api.c | |||
@@ -24,6 +24,62 @@ | |||
24 | 24 | ||
25 | #include "saa7164.h" | 25 | #include "saa7164.h" |
26 | 26 | ||
27 | int saa7164_api_set_vbi_format(struct saa7164_port *port) | ||
28 | { | ||
29 | struct saa7164_dev *dev = port->dev; | ||
30 | tmComResProbeCommit_t fmt, rsp; | ||
31 | int ret; | ||
32 | |||
33 | dprintk(DBGLVL_API, "%s(nr=%d)\n", __func__, port->nr); | ||
34 | |||
35 | fmt.bmHint = 0; | ||
36 | fmt.bFormatIndex = 1; | ||
37 | fmt.bFrameIndex = 1; | ||
38 | |||
39 | /* Probe, see if it can support this format */ | ||
40 | ret = saa7164_cmd_send(port->dev, port->hwcfg.unitid, | ||
41 | SET_CUR, SAA_PROBE_CONTROL, sizeof(fmt), &fmt); | ||
42 | if (ret != SAA_OK) | ||
43 | printk(KERN_ERR "%s() set error, ret = 0x%x\n", __func__, ret); | ||
44 | |||
45 | /* See of the format change was successful */ | ||
46 | ret = saa7164_cmd_send(port->dev, port->hwcfg.unitid, | ||
47 | GET_CUR, SAA_PROBE_CONTROL, sizeof(rsp), &rsp); | ||
48 | if (ret != SAA_OK) { | ||
49 | printk(KERN_ERR "%s() get error, ret = 0x%x\n", __func__, ret); | ||
50 | } else { | ||
51 | /* Compare requested vs received, should be same */ | ||
52 | if (memcmp(&fmt, &rsp, sizeof(rsp)) == 0) { | ||
53 | /* Ask the device to select the negotiated format */ | ||
54 | ret = saa7164_cmd_send(port->dev, port->hwcfg.unitid, | ||
55 | SET_CUR, SAA_COMMIT_CONTROL, sizeof(fmt), &fmt); | ||
56 | if (ret != SAA_OK) | ||
57 | printk(KERN_ERR "%s() commit error, ret = 0x%x\n", | ||
58 | __func__, ret); | ||
59 | |||
60 | ret = saa7164_cmd_send(port->dev, port->hwcfg.unitid, | ||
61 | GET_CUR, SAA_COMMIT_CONTROL, sizeof(rsp), &rsp); | ||
62 | if (ret != SAA_OK) | ||
63 | printk(KERN_ERR "%s() GET commit error, ret = 0x%x\n", | ||
64 | __func__, ret); | ||
65 | |||
66 | if (memcmp(&fmt, &rsp, sizeof(rsp)) != 0) | ||
67 | printk(KERN_ERR "%s() memcmp error, ret = 0x%x\n", | ||
68 | __func__, ret); | ||
69 | |||
70 | dprintk(DBGLVL_API, "rsp.bmHint = 0x%x\n", rsp.bmHint); | ||
71 | dprintk(DBGLVL_API, "rsp.bFormatIndex = 0x%x\n", rsp.bFormatIndex); | ||
72 | dprintk(DBGLVL_API, "rsp.bFrameIndex = 0x%x\n", rsp.bFrameIndex); | ||
73 | } else | ||
74 | printk(KERN_ERR "%s() compare failed\n", __func__); | ||
75 | } | ||
76 | |||
77 | if (ret == SAA_OK) | ||
78 | dprintk(DBGLVL_API, "%s(nr=%d) Success\n", __func__, port->nr); | ||
79 | |||
80 | return ret; | ||
81 | } | ||
82 | |||
27 | int saa7164_api_set_gop_size(struct saa7164_port *port) | 83 | int saa7164_api_set_gop_size(struct saa7164_port *port) |
28 | { | 84 | { |
29 | struct saa7164_dev *dev = port->dev; | 85 | struct saa7164_dev *dev = port->dev; |
@@ -463,7 +519,8 @@ int saa7164_api_set_dif(struct saa7164_port *port, u8 reg, u8 val) | |||
463 | int ret; | 519 | int ret; |
464 | u8 mas; | 520 | u8 mas; |
465 | 521 | ||
466 | dprintk(DBGLVL_API, "%s()\n", __func__); | 522 | dprintk(DBGLVL_API, "%s(nr=%d type=%d val=%x)\n", __func__, |
523 | port->nr, port->type, val); | ||
467 | 524 | ||
468 | if (port->nr == 0) | 525 | if (port->nr == 0) |
469 | mas = 0xd0; | 526 | mas = 0xd0; |
@@ -516,7 +573,7 @@ int saa7164_api_configure_dif(struct saa7164_port *port, u32 std) | |||
516 | int ret = 0; | 573 | int ret = 0; |
517 | u8 agc_disable; | 574 | u8 agc_disable; |
518 | 575 | ||
519 | dprintk(DBGLVL_API, "%s(%p, 0x%x)\n", __func__, port, std); | 576 | dprintk(DBGLVL_API, "%s(nr=%d, 0x%x)\n", __func__, port->nr, std); |
520 | 577 | ||
521 | if (std & V4L2_STD_NTSC) { | 578 | if (std & V4L2_STD_NTSC) { |
522 | dprintk(DBGLVL_API, " NTSC\n"); | 579 | dprintk(DBGLVL_API, " NTSC\n"); |
@@ -580,6 +637,9 @@ int saa7164_api_initialize_dif(struct saa7164_port *port) | |||
580 | int ret = -EINVAL; | 637 | int ret = -EINVAL; |
581 | u32 std = 0; | 638 | u32 std = 0; |
582 | 639 | ||
640 | dprintk(DBGLVL_API, "%s(nr=%d type=%d)\n", __func__, | ||
641 | port->nr, port->type); | ||
642 | |||
583 | if (port->type == SAA7164_MPEG_ENCODER) { | 643 | if (port->type == SAA7164_MPEG_ENCODER) { |
584 | /* Pick any analog standard to init the diff. | 644 | /* Pick any analog standard to init the diff. |
585 | * we'll come back during encoder_init' | 645 | * we'll come back during encoder_init' |
@@ -593,6 +653,13 @@ int saa7164_api_initialize_dif(struct saa7164_port *port) | |||
593 | else | 653 | else |
594 | p = &dev->ports[ SAA7164_PORT_ENC2 ]; | 654 | p = &dev->ports[ SAA7164_PORT_ENC2 ]; |
595 | } else | 655 | } else |
656 | if (port->type == SAA7164_MPEG_VBI) { | ||
657 | std = V4L2_STD_NTSC; | ||
658 | if (port->nr == SAA7164_PORT_VBI1) | ||
659 | p = &dev->ports[ SAA7164_PORT_ENC1 ]; | ||
660 | else | ||
661 | p = &dev->ports[ SAA7164_PORT_ENC2 ]; | ||
662 | } else | ||
596 | BUG(); | 663 | BUG(); |
597 | 664 | ||
598 | if (p) | 665 | if (p) |
@@ -603,12 +670,18 @@ int saa7164_api_initialize_dif(struct saa7164_port *port) | |||
603 | 670 | ||
604 | int saa7164_api_transition_port(struct saa7164_port *port, u8 mode) | 671 | int saa7164_api_transition_port(struct saa7164_port *port, u8 mode) |
605 | { | 672 | { |
673 | struct saa7164_dev *dev = port->dev; | ||
674 | |||
606 | int ret; | 675 | int ret; |
607 | 676 | ||
677 | dprintk(DBGLVL_API, "%s(nr=%d unitid=0x%x,%d)\n", | ||
678 | __func__, port->nr, port->hwcfg.unitid, mode); | ||
679 | |||
608 | ret = saa7164_cmd_send(port->dev, port->hwcfg.unitid, SET_CUR, | 680 | ret = saa7164_cmd_send(port->dev, port->hwcfg.unitid, SET_CUR, |
609 | SAA_STATE_CONTROL, sizeof(mode), &mode); | 681 | SAA_STATE_CONTROL, sizeof(mode), &mode); |
610 | if (ret != SAA_OK) | 682 | if (ret != SAA_OK) |
611 | printk(KERN_ERR "%s() error, ret = 0x%x\n", __func__, ret); | 683 | printk(KERN_ERR "%s(portnr %d unitid 0x%x) error, ret = 0x%x\n", |
684 | __func__, port->nr, port->hwcfg.unitid, ret); | ||
612 | 685 | ||
613 | return ret; | 686 | return ret; |
614 | } | 687 | } |
@@ -639,6 +712,23 @@ int saa7164_api_read_eeprom(struct saa7164_dev *dev, u8 *buf, int buflen) | |||
639 | } | 712 | } |
640 | 713 | ||
641 | 714 | ||
715 | int saa7164_api_configure_port_vbi(struct saa7164_dev *dev, | ||
716 | struct saa7164_port *port) | ||
717 | { | ||
718 | tmComResVBIFormatDescrHeader_t *fmt = &port->vbi_fmt_ntsc; | ||
719 | |||
720 | dprintk(DBGLVL_API, " bFormatIndex = 0x%x\n", fmt->bFormatIndex); | ||
721 | dprintk(DBGLVL_API, " VideoStandard = 0x%x\n", fmt->VideoStandard); | ||
722 | dprintk(DBGLVL_API, " StartLine = %d\n", fmt->StartLine); | ||
723 | dprintk(DBGLVL_API, " EndLine = %d\n", fmt->EndLine); | ||
724 | dprintk(DBGLVL_API, " FieldRate = %d\n", fmt->FieldRate); | ||
725 | dprintk(DBGLVL_API, " bNumLines = %d\n", fmt->bNumLines); | ||
726 | dprintk(DBGLVL_API, " = VS_FORMAT_VBI (becomes dev->en[%d])\n", | ||
727 | port->nr); | ||
728 | |||
729 | return 0; | ||
730 | } | ||
731 | |||
642 | int saa7164_api_configure_port_mpeg2ts(struct saa7164_dev *dev, | 732 | int saa7164_api_configure_port_mpeg2ts(struct saa7164_dev *dev, |
643 | struct saa7164_port *port, | 733 | struct saa7164_port *port, |
644 | tmComResTSFormatDescrHeader_t *tsfmt) | 734 | tmComResTSFormatDescrHeader_t *tsfmt) |
@@ -710,6 +800,7 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len) | |||
710 | { | 800 | { |
711 | struct saa7164_port *tsport = 0; | 801 | struct saa7164_port *tsport = 0; |
712 | struct saa7164_port *encport = 0; | 802 | struct saa7164_port *encport = 0; |
803 | struct saa7164_port *vbiport = 0; | ||
713 | u32 idx, next_offset; | 804 | u32 idx, next_offset; |
714 | int i; | 805 | int i; |
715 | tmComResDescrHeader_t *hdr, *t; | 806 | tmComResDescrHeader_t *hdr, *t; |
@@ -724,6 +815,7 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len) | |||
724 | tmComResProcDescrHeader_t *pdh; | 815 | tmComResProcDescrHeader_t *pdh; |
725 | tmComResAFeatureDescrHeader_t *afd; | 816 | tmComResAFeatureDescrHeader_t *afd; |
726 | tmComResEncoderDescrHeader_t *edh; | 817 | tmComResEncoderDescrHeader_t *edh; |
818 | tmComResVBIFormatDescrHeader_t *vbifmt; | ||
727 | u32 currpath = 0; | 819 | u32 currpath = 0; |
728 | 820 | ||
729 | dprintk(DBGLVL_API, | 821 | dprintk(DBGLVL_API, |
@@ -881,8 +973,17 @@ int saa7164_api_dump_subdevs(struct saa7164_dev *dev, u8 *buf, int len) | |||
881 | encport, psfmt); | 973 | encport, psfmt); |
882 | break; | 974 | break; |
883 | case VS_FORMAT_VBI: | 975 | case VS_FORMAT_VBI: |
884 | dprintk(DBGLVL_API, | 976 | vbifmt = |
885 | " = VS_FORMAT_VBI\n"); | 977 | (tmComResVBIFormatDescrHeader_t *)t; |
978 | if (currpath == 1) | ||
979 | vbiport = &dev->ports[ SAA7164_PORT_VBI1 ]; | ||
980 | else | ||
981 | vbiport = &dev->ports[ SAA7164_PORT_VBI2 ]; | ||
982 | memcpy(&vbiport->hwcfg, vcoutputtermhdr, | ||
983 | sizeof(*vcoutputtermhdr)); | ||
984 | memcpy(&vbiport->vbi_fmt_ntsc, vbifmt, sizeof(*vbifmt)); | ||
985 | saa7164_api_configure_port_vbi(dev, | ||
986 | vbiport); | ||
886 | break; | 987 | break; |
887 | case VS_FORMAT_RDS: | 988 | case VS_FORMAT_RDS: |
888 | dprintk(DBGLVL_API, | 989 | dprintk(DBGLVL_API, |