aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/pci/bt8xx
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/media/pci/bt8xx')
-rw-r--r--drivers/media/pci/bt8xx/bttv-cards.c21
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c1226
-rw-r--r--drivers/media/pci/bt8xx/bttv-i2c.c8
-rw-r--r--drivers/media/pci/bt8xx/bttv-input.c30
-rw-r--r--drivers/media/pci/bt8xx/bttv.h3
-rw-r--r--drivers/media/pci/bt8xx/bttvp.h38
6 files changed, 581 insertions, 745 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c
index c4c59175e52c..b7dc921e1b91 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -3547,6 +3547,16 @@ void bttv_init_card2(struct bttv *btv)
3547 if (btv->sd_msp34xx) 3547 if (btv->sd_msp34xx)
3548 return; 3548 return;
3549 3549
3550 /* Now see if we can find one of the tvaudio devices. */
3551 btv->sd_tvaudio = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3552 &btv->c.i2c_adap, "tvaudio", 0, tvaudio_addrs());
3553 if (btv->sd_tvaudio) {
3554 /* There may be two tvaudio chips on the card, so try to
3555 find another. */
3556 v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3557 &btv->c.i2c_adap, "tvaudio", 0, tvaudio_addrs());
3558 }
3559
3550 /* it might also be a tda7432. */ 3560 /* it might also be a tda7432. */
3551 if (!bttv_tvcards[btv->c.type].no_tda7432) { 3561 if (!bttv_tvcards[btv->c.type].no_tda7432) {
3552 static const unsigned short addrs[] = { 3562 static const unsigned short addrs[] = {
@@ -3554,14 +3564,11 @@ void bttv_init_card2(struct bttv *btv)
3554 I2C_CLIENT_END 3564 I2C_CLIENT_END
3555 }; 3565 };
3556 3566
3557 if (v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3567 btv->sd_tda7432 = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3558 &btv->c.i2c_adap, "tda7432", 0, addrs)) 3568 &btv->c.i2c_adap, "tda7432", 0, addrs);
3569 if (btv->sd_tda7432)
3559 return; 3570 return;
3560 } 3571 }
3561
3562 /* Now see if we can find one of the tvaudio devices. */
3563 btv->sd_tvaudio = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3564 &btv->c.i2c_adap, "tvaudio", 0, tvaudio_addrs());
3565 if (btv->sd_tvaudio) 3572 if (btv->sd_tvaudio)
3566 return; 3573 return;
3567 3574
@@ -3940,7 +3947,7 @@ static void avermedia_eeprom(struct bttv *btv)
3940u32 bttv_tda9880_setnorm(struct bttv *btv, u32 gpiobits) 3947u32 bttv_tda9880_setnorm(struct bttv *btv, u32 gpiobits)
3941{ 3948{
3942 3949
3943 if (btv->audio == TVAUDIO_INPUT_TUNER) { 3950 if (btv->audio_input == TVAUDIO_INPUT_TUNER) {
3944 if (bttv_tvnorms[btv->tvnorm].v4l2_id & V4L2_STD_MN) 3951 if (bttv_tvnorms[btv->tvnorm].v4l2_id & V4L2_STD_MN)
3945 gpiobits |= 0x10000; 3952 gpiobits |= 0x10000;
3946 else 3953 else
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 54579e4c740b..e7d088413411 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -49,6 +49,8 @@
49#include "bttvp.h" 49#include "bttvp.h"
50#include <media/v4l2-common.h> 50#include <media/v4l2-common.h>
51#include <media/v4l2-ioctl.h> 51#include <media/v4l2-ioctl.h>
52#include <media/v4l2-event.h>
53#include <media/v4l2-chip-ident.h>
52#include <media/tvaudio.h> 54#include <media/tvaudio.h>
53#include <media/msp3400.h> 55#include <media/msp3400.h>
54 56
@@ -93,7 +95,7 @@ static unsigned int combfilter;
93static unsigned int lumafilter; 95static unsigned int lumafilter;
94static unsigned int automute = 1; 96static unsigned int automute = 1;
95static unsigned int chroma_agc; 97static unsigned int chroma_agc;
96static unsigned int adc_crush = 1; 98static unsigned int agc_crush = 1;
97static unsigned int whitecrush_upper = 0xCF; 99static unsigned int whitecrush_upper = 0xCF;
98static unsigned int whitecrush_lower = 0x7F; 100static unsigned int whitecrush_lower = 0x7F;
99static unsigned int vcr_hack; 101static unsigned int vcr_hack;
@@ -125,7 +127,7 @@ module_param(combfilter, int, 0444);
125module_param(lumafilter, int, 0444); 127module_param(lumafilter, int, 0444);
126module_param(automute, int, 0444); 128module_param(automute, int, 0444);
127module_param(chroma_agc, int, 0444); 129module_param(chroma_agc, int, 0444);
128module_param(adc_crush, int, 0444); 130module_param(agc_crush, int, 0444);
129module_param(whitecrush_upper, int, 0444); 131module_param(whitecrush_upper, int, 0444);
130module_param(whitecrush_lower, int, 0444); 132module_param(whitecrush_lower, int, 0444);
131module_param(vcr_hack, int, 0444); 133module_param(vcr_hack, int, 0444);
@@ -138,27 +140,27 @@ module_param_array(video_nr, int, NULL, 0444);
138module_param_array(radio_nr, int, NULL, 0444); 140module_param_array(radio_nr, int, NULL, 0444);
139module_param_array(vbi_nr, int, NULL, 0444); 141module_param_array(vbi_nr, int, NULL, 0444);
140 142
141MODULE_PARM_DESC(radio,"The TV card supports radio, default is 0 (no)"); 143MODULE_PARM_DESC(radio, "The TV card supports radio, default is 0 (no)");
142MODULE_PARM_DESC(bigendian,"byte order of the framebuffer, default is native endian"); 144MODULE_PARM_DESC(bigendian, "byte order of the framebuffer, default is native endian");
143MODULE_PARM_DESC(bttv_verbose,"verbose startup messages, default is 1 (yes)"); 145MODULE_PARM_DESC(bttv_verbose, "verbose startup messages, default is 1 (yes)");
144MODULE_PARM_DESC(bttv_gpio,"log gpio changes, default is 0 (no)"); 146MODULE_PARM_DESC(bttv_gpio, "log gpio changes, default is 0 (no)");
145MODULE_PARM_DESC(bttv_debug,"debug messages, default is 0 (no)"); 147MODULE_PARM_DESC(bttv_debug, "debug messages, default is 0 (no)");
146MODULE_PARM_DESC(irq_debug,"irq handler debug messages, default is 0 (no)"); 148MODULE_PARM_DESC(irq_debug, "irq handler debug messages, default is 0 (no)");
147MODULE_PARM_DESC(disable_ir, "disable infrared remote support"); 149MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
148MODULE_PARM_DESC(gbuffers,"number of capture buffers. range 2-32, default 8"); 150MODULE_PARM_DESC(gbuffers, "number of capture buffers. range 2-32, default 8");
149MODULE_PARM_DESC(gbufsize,"size of the capture buffers, default is 0x208000"); 151MODULE_PARM_DESC(gbufsize, "size of the capture buffers, default is 0x208000");
150MODULE_PARM_DESC(reset_crop,"reset cropping parameters at open(), default " 152MODULE_PARM_DESC(reset_crop, "reset cropping parameters at open(), default "
151 "is 1 (yes) for compatibility with older applications"); 153 "is 1 (yes) for compatibility with older applications");
152MODULE_PARM_DESC(automute,"mute audio on bad/missing video signal, default is 1 (yes)"); 154MODULE_PARM_DESC(automute, "mute audio on bad/missing video signal, default is 1 (yes)");
153MODULE_PARM_DESC(chroma_agc,"enables the AGC of chroma signal, default is 0 (no)"); 155MODULE_PARM_DESC(chroma_agc, "enables the AGC of chroma signal, default is 0 (no)");
154MODULE_PARM_DESC(adc_crush,"enables the luminance ADC crush, default is 1 (yes)"); 156MODULE_PARM_DESC(agc_crush, "enables the luminance AGC crush, default is 1 (yes)");
155MODULE_PARM_DESC(whitecrush_upper,"sets the white crush upper value, default is 207"); 157MODULE_PARM_DESC(whitecrush_upper, "sets the white crush upper value, default is 207");
156MODULE_PARM_DESC(whitecrush_lower,"sets the white crush lower value, default is 127"); 158MODULE_PARM_DESC(whitecrush_lower, "sets the white crush lower value, default is 127");
157MODULE_PARM_DESC(vcr_hack,"enables the VCR hack (improves synch on poor VCR tapes), default is 0 (no)"); 159MODULE_PARM_DESC(vcr_hack, "enables the VCR hack (improves synch on poor VCR tapes), default is 0 (no)");
158MODULE_PARM_DESC(irq_iswitch,"switch inputs in irq handler"); 160MODULE_PARM_DESC(irq_iswitch, "switch inputs in irq handler");
159MODULE_PARM_DESC(uv_ratio,"ratio between u and v gains, default is 50"); 161MODULE_PARM_DESC(uv_ratio, "ratio between u and v gains, default is 50");
160MODULE_PARM_DESC(full_luma_range,"use the full luma range, default is 0 (no)"); 162MODULE_PARM_DESC(full_luma_range, "use the full luma range, default is 0 (no)");
161MODULE_PARM_DESC(coring,"set the luma coring level, default is 0 (no)"); 163MODULE_PARM_DESC(coring, "set the luma coring level, default is 0 (no)");
162MODULE_PARM_DESC(video_nr, "video device numbers"); 164MODULE_PARM_DESC(video_nr, "video device numbers");
163MODULE_PARM_DESC(vbi_nr, "vbi device numbers"); 165MODULE_PARM_DESC(vbi_nr, "vbi device numbers");
164MODULE_PARM_DESC(radio_nr, "radio device numbers"); 166MODULE_PARM_DESC(radio_nr, "radio device numbers");
@@ -168,6 +170,17 @@ MODULE_AUTHOR("Ralph Metzler & Marcus Metzler & Gerd Knorr");
168MODULE_LICENSE("GPL"); 170MODULE_LICENSE("GPL");
169MODULE_VERSION(BTTV_VERSION); 171MODULE_VERSION(BTTV_VERSION);
170 172
173#define V4L2_CID_PRIVATE_COMBFILTER (V4L2_CID_USER_BTTV_BASE + 0)
174#define V4L2_CID_PRIVATE_AUTOMUTE (V4L2_CID_USER_BTTV_BASE + 1)
175#define V4L2_CID_PRIVATE_LUMAFILTER (V4L2_CID_USER_BTTV_BASE + 2)
176#define V4L2_CID_PRIVATE_AGC_CRUSH (V4L2_CID_USER_BTTV_BASE + 3)
177#define V4L2_CID_PRIVATE_VCR_HACK (V4L2_CID_USER_BTTV_BASE + 4)
178#define V4L2_CID_PRIVATE_WHITECRUSH_LOWER (V4L2_CID_USER_BTTV_BASE + 5)
179#define V4L2_CID_PRIVATE_WHITECRUSH_UPPER (V4L2_CID_USER_BTTV_BASE + 6)
180#define V4L2_CID_PRIVATE_UV_RATIO (V4L2_CID_USER_BTTV_BASE + 7)
181#define V4L2_CID_PRIVATE_FULL_LUMA_RANGE (V4L2_CID_USER_BTTV_BASE + 8)
182#define V4L2_CID_PRIVATE_CORING (V4L2_CID_USER_BTTV_BASE + 9)
183
171/* ----------------------------------------------------------------------- */ 184/* ----------------------------------------------------------------------- */
172/* sysfs */ 185/* sysfs */
173 186
@@ -632,198 +645,6 @@ static const struct bttv_format formats[] = {
632static const unsigned int FORMATS = ARRAY_SIZE(formats); 645static const unsigned int FORMATS = ARRAY_SIZE(formats);
633 646
634/* ----------------------------------------------------------------------- */ 647/* ----------------------------------------------------------------------- */
635
636#define V4L2_CID_PRIVATE_CHROMA_AGC (V4L2_CID_PRIVATE_BASE + 0)
637#define V4L2_CID_PRIVATE_COMBFILTER (V4L2_CID_PRIVATE_BASE + 1)
638#define V4L2_CID_PRIVATE_AUTOMUTE (V4L2_CID_PRIVATE_BASE + 2)
639#define V4L2_CID_PRIVATE_LUMAFILTER (V4L2_CID_PRIVATE_BASE + 3)
640#define V4L2_CID_PRIVATE_AGC_CRUSH (V4L2_CID_PRIVATE_BASE + 4)
641#define V4L2_CID_PRIVATE_VCR_HACK (V4L2_CID_PRIVATE_BASE + 5)
642#define V4L2_CID_PRIVATE_WHITECRUSH_UPPER (V4L2_CID_PRIVATE_BASE + 6)
643#define V4L2_CID_PRIVATE_WHITECRUSH_LOWER (V4L2_CID_PRIVATE_BASE + 7)
644#define V4L2_CID_PRIVATE_UV_RATIO (V4L2_CID_PRIVATE_BASE + 8)
645#define V4L2_CID_PRIVATE_FULL_LUMA_RANGE (V4L2_CID_PRIVATE_BASE + 9)
646#define V4L2_CID_PRIVATE_CORING (V4L2_CID_PRIVATE_BASE + 10)
647#define V4L2_CID_PRIVATE_LASTP1 (V4L2_CID_PRIVATE_BASE + 11)
648
649static const struct v4l2_queryctrl no_ctl = {
650 .name = "42",
651 .flags = V4L2_CTRL_FLAG_DISABLED,
652};
653static const struct v4l2_queryctrl bttv_ctls[] = {
654 /* --- video --- */
655 {
656 .id = V4L2_CID_BRIGHTNESS,
657 .name = "Brightness",
658 .minimum = 0,
659 .maximum = 65535,
660 .step = 256,
661 .default_value = 32768,
662 .type = V4L2_CTRL_TYPE_INTEGER,
663 },{
664 .id = V4L2_CID_CONTRAST,
665 .name = "Contrast",
666 .minimum = 0,
667 .maximum = 65535,
668 .step = 128,
669 .default_value = 27648,
670 .type = V4L2_CTRL_TYPE_INTEGER,
671 },{
672 .id = V4L2_CID_SATURATION,
673 .name = "Saturation",
674 .minimum = 0,
675 .maximum = 65535,
676 .step = 128,
677 .default_value = 32768,
678 .type = V4L2_CTRL_TYPE_INTEGER,
679 },{
680 .id = V4L2_CID_COLOR_KILLER,
681 .name = "Color killer",
682 .minimum = 0,
683 .maximum = 1,
684 .type = V4L2_CTRL_TYPE_BOOLEAN,
685 }, {
686 .id = V4L2_CID_HUE,
687 .name = "Hue",
688 .minimum = 0,
689 .maximum = 65535,
690 .step = 256,
691 .default_value = 32768,
692 .type = V4L2_CTRL_TYPE_INTEGER,
693 },
694 /* --- audio --- */
695 {
696 .id = V4L2_CID_AUDIO_MUTE,
697 .name = "Mute",
698 .minimum = 0,
699 .maximum = 1,
700 .type = V4L2_CTRL_TYPE_BOOLEAN,
701 },{
702 .id = V4L2_CID_AUDIO_VOLUME,
703 .name = "Volume",
704 .minimum = 0,
705 .maximum = 65535,
706 .step = 65535/100,
707 .default_value = 65535,
708 .type = V4L2_CTRL_TYPE_INTEGER,
709 },{
710 .id = V4L2_CID_AUDIO_BALANCE,
711 .name = "Balance",
712 .minimum = 0,
713 .maximum = 65535,
714 .step = 65535/100,
715 .default_value = 32768,
716 .type = V4L2_CTRL_TYPE_INTEGER,
717 },{
718 .id = V4L2_CID_AUDIO_BASS,
719 .name = "Bass",
720 .minimum = 0,
721 .maximum = 65535,
722 .step = 65535/100,
723 .default_value = 32768,
724 .type = V4L2_CTRL_TYPE_INTEGER,
725 },{
726 .id = V4L2_CID_AUDIO_TREBLE,
727 .name = "Treble",
728 .minimum = 0,
729 .maximum = 65535,
730 .step = 65535/100,
731 .default_value = 32768,
732 .type = V4L2_CTRL_TYPE_INTEGER,
733 },
734 /* --- private --- */
735 {
736 .id = V4L2_CID_PRIVATE_CHROMA_AGC,
737 .name = "chroma agc",
738 .minimum = 0,
739 .maximum = 1,
740 .type = V4L2_CTRL_TYPE_BOOLEAN,
741 },{
742 .id = V4L2_CID_PRIVATE_COMBFILTER,
743 .name = "combfilter",
744 .minimum = 0,
745 .maximum = 1,
746 .type = V4L2_CTRL_TYPE_BOOLEAN,
747 },{
748 .id = V4L2_CID_PRIVATE_AUTOMUTE,
749 .name = "automute",
750 .minimum = 0,
751 .maximum = 1,
752 .type = V4L2_CTRL_TYPE_BOOLEAN,
753 },{
754 .id = V4L2_CID_PRIVATE_LUMAFILTER,
755 .name = "luma decimation filter",
756 .minimum = 0,
757 .maximum = 1,
758 .type = V4L2_CTRL_TYPE_BOOLEAN,
759 },{
760 .id = V4L2_CID_PRIVATE_AGC_CRUSH,
761 .name = "agc crush",
762 .minimum = 0,
763 .maximum = 1,
764 .type = V4L2_CTRL_TYPE_BOOLEAN,
765 },{
766 .id = V4L2_CID_PRIVATE_VCR_HACK,
767 .name = "vcr hack",
768 .minimum = 0,
769 .maximum = 1,
770 .type = V4L2_CTRL_TYPE_BOOLEAN,
771 },{
772 .id = V4L2_CID_PRIVATE_WHITECRUSH_UPPER,
773 .name = "whitecrush upper",
774 .minimum = 0,
775 .maximum = 255,
776 .step = 1,
777 .default_value = 0xCF,
778 .type = V4L2_CTRL_TYPE_INTEGER,
779 },{
780 .id = V4L2_CID_PRIVATE_WHITECRUSH_LOWER,
781 .name = "whitecrush lower",
782 .minimum = 0,
783 .maximum = 255,
784 .step = 1,
785 .default_value = 0x7F,
786 .type = V4L2_CTRL_TYPE_INTEGER,
787 },{
788 .id = V4L2_CID_PRIVATE_UV_RATIO,
789 .name = "uv ratio",
790 .minimum = 0,
791 .maximum = 100,
792 .step = 1,
793 .default_value = 50,
794 .type = V4L2_CTRL_TYPE_INTEGER,
795 },{
796 .id = V4L2_CID_PRIVATE_FULL_LUMA_RANGE,
797 .name = "full luma range",
798 .minimum = 0,
799 .maximum = 1,
800 .type = V4L2_CTRL_TYPE_BOOLEAN,
801 },{
802 .id = V4L2_CID_PRIVATE_CORING,
803 .name = "coring",
804 .minimum = 0,
805 .maximum = 3,
806 .step = 1,
807 .default_value = 0,
808 .type = V4L2_CTRL_TYPE_INTEGER,
809 }
810
811
812
813};
814
815static const struct v4l2_queryctrl *ctrl_by_id(int id)
816{
817 int i;
818
819 for (i = 0; i < ARRAY_SIZE(bttv_ctls); i++)
820 if (bttv_ctls[i].id == id)
821 return bttv_ctls+i;
822
823 return NULL;
824}
825
826/* ----------------------------------------------------------------------- */
827/* resource management */ 648/* resource management */
828 649
829/* 650/*
@@ -1178,23 +999,20 @@ static char *audio_modes[] = {
1178 "audio: intern", "audio: mute" 999 "audio: intern", "audio: mute"
1179}; 1000};
1180 1001
1181static int 1002static void
1182audio_mux(struct bttv *btv, int input, int mute) 1003audio_mux_gpio(struct bttv *btv, int input, int mute)
1183{ 1004{
1184 int gpio_val, signal; 1005 int gpio_val, signal, mute_gpio;
1185 struct v4l2_control ctrl;
1186 1006
1187 gpio_inout(bttv_tvcards[btv->c.type].gpiomask, 1007 gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
1188 bttv_tvcards[btv->c.type].gpiomask); 1008 bttv_tvcards[btv->c.type].gpiomask);
1189 signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC; 1009 signal = btread(BT848_DSTATUS) & BT848_DSTATUS_HLOC;
1190 1010
1191 btv->mute = mute;
1192 btv->audio = input;
1193
1194 /* automute */ 1011 /* automute */
1195 mute = mute || (btv->opt_automute && !signal && !btv->radio_user); 1012 mute_gpio = mute || (btv->opt_automute && (!signal || !btv->users)
1013 && !btv->has_radio_tuner);
1196 1014
1197 if (mute) 1015 if (mute_gpio)
1198 gpio_val = bttv_tvcards[btv->c.type].gpiomute; 1016 gpio_val = bttv_tvcards[btv->c.type].gpiomute;
1199 else 1017 else
1200 gpio_val = bttv_tvcards[btv->c.type].gpiomux[input]; 1018 gpio_val = bttv_tvcards[btv->c.type].gpiomux[input];
@@ -1210,13 +1028,39 @@ audio_mux(struct bttv *btv, int input, int mute)
1210 } 1028 }
1211 1029
1212 if (bttv_gpio) 1030 if (bttv_gpio)
1213 bttv_gpio_tracking(btv, audio_modes[mute ? 4 : input]); 1031 bttv_gpio_tracking(btv, audio_modes[mute_gpio ? 4 : input]);
1214 if (in_interrupt()) 1032}
1215 return 0; 1033
1034static int
1035audio_mute(struct bttv *btv, int mute)
1036{
1037 struct v4l2_ctrl *ctrl;
1038
1039 audio_mux_gpio(btv, btv->audio_input, mute);
1040
1041 if (btv->sd_msp34xx) {
1042 ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE);
1043 if (ctrl)
1044 v4l2_ctrl_s_ctrl(ctrl, mute);
1045 }
1046 if (btv->sd_tvaudio) {
1047 ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE);
1048 if (ctrl)
1049 v4l2_ctrl_s_ctrl(ctrl, mute);
1050 }
1051 if (btv->sd_tda7432) {
1052 ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE);
1053 if (ctrl)
1054 v4l2_ctrl_s_ctrl(ctrl, mute);
1055 }
1056 return 0;
1057}
1058
1059static int
1060audio_input(struct bttv *btv, int input)
1061{
1062 audio_mux_gpio(btv, input, btv->mute);
1216 1063
1217 ctrl.id = V4L2_CID_AUDIO_MUTE;
1218 ctrl.value = btv->mute;
1219 bttv_call_all(btv, core, s_ctrl, &ctrl);
1220 if (btv->sd_msp34xx) { 1064 if (btv->sd_msp34xx) {
1221 u32 in; 1065 u32 in;
1222 1066
@@ -1265,23 +1109,11 @@ audio_mux(struct bttv *btv, int input, int mute)
1265 } 1109 }
1266 if (btv->sd_tvaudio) { 1110 if (btv->sd_tvaudio) {
1267 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, 1111 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing,
1268 input, 0, 0); 1112 input, 0, 0);
1269 } 1113 }
1270 return 0; 1114 return 0;
1271} 1115}
1272 1116
1273static inline int
1274audio_mute(struct bttv *btv, int mute)
1275{
1276 return audio_mux(btv, btv->audio, mute);
1277}
1278
1279static inline int
1280audio_input(struct bttv *btv, int input)
1281{
1282 return audio_mux(btv, input, btv->mute);
1283}
1284
1285static void 1117static void
1286bttv_crop_calc_limits(struct bttv_crop *c) 1118bttv_crop_calc_limits(struct bttv_crop *c)
1287{ 1119{
@@ -1375,8 +1207,9 @@ set_input(struct bttv *btv, unsigned int input, unsigned int norm)
1375 } else { 1207 } else {
1376 video_mux(btv,input); 1208 video_mux(btv,input);
1377 } 1209 }
1378 audio_input(btv, (btv->tuner_type != TUNER_ABSENT && input == 0) ? 1210 btv->audio_input = (btv->tuner_type != TUNER_ABSENT && input == 0) ?
1379 TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN); 1211 TVAUDIO_INPUT_TUNER : TVAUDIO_INPUT_EXTERN;
1212 audio_input(btv, btv->audio_input);
1380 set_tvnorm(btv, norm); 1213 set_tvnorm(btv, norm);
1381} 1214}
1382 1215
@@ -1404,8 +1237,6 @@ static void init_irqreg(struct bttv *btv)
1404 1237
1405static void init_bt848(struct bttv *btv) 1238static void init_bt848(struct bttv *btv)
1406{ 1239{
1407 int val;
1408
1409 if (bttv_tvcards[btv->c.type].no_video) { 1240 if (bttv_tvcards[btv->c.type].no_video) {
1410 /* very basic init only */ 1241 /* very basic init only */
1411 init_irqreg(btv); 1242 init_irqreg(btv);
@@ -1425,30 +1256,10 @@ static void init_bt848(struct bttv *btv)
1425 BT848_GPIO_DMA_CTL_GPINTI, 1256 BT848_GPIO_DMA_CTL_GPINTI,
1426 BT848_GPIO_DMA_CTL); 1257 BT848_GPIO_DMA_CTL);
1427 1258
1428 val = btv->opt_chroma_agc ? BT848_SCLOOP_CAGC : 0;
1429 btwrite(val, BT848_E_SCLOOP);
1430 btwrite(val, BT848_O_SCLOOP);
1431
1432 btwrite(0x20, BT848_E_VSCALE_HI); 1259 btwrite(0x20, BT848_E_VSCALE_HI);
1433 btwrite(0x20, BT848_O_VSCALE_HI); 1260 btwrite(0x20, BT848_O_VSCALE_HI);
1434 btwrite(BT848_ADC_RESERVED | (btv->opt_adc_crush ? BT848_ADC_CRUSH : 0),
1435 BT848_ADC);
1436
1437 btwrite(whitecrush_upper, BT848_WC_UP);
1438 btwrite(whitecrush_lower, BT848_WC_DOWN);
1439
1440 if (btv->opt_lumafilter) {
1441 btwrite(0, BT848_E_CONTROL);
1442 btwrite(0, BT848_O_CONTROL);
1443 } else {
1444 btwrite(BT848_CONTROL_LDEC, BT848_E_CONTROL);
1445 btwrite(BT848_CONTROL_LDEC, BT848_O_CONTROL);
1446 }
1447 1261
1448 bt848_bright(btv, btv->bright); 1262 v4l2_ctrl_handler_setup(&btv->ctrl_handler);
1449 bt848_hue(btv, btv->hue);
1450 bt848_contrast(btv, btv->contrast);
1451 bt848_sat(btv, btv->saturation);
1452 1263
1453 /* interrupt */ 1264 /* interrupt */
1454 init_irqreg(btv); 1265 init_irqreg(btv);
@@ -1470,103 +1281,26 @@ static void bttv_reinit_bt848(struct bttv *btv)
1470 set_input(btv, btv->input, btv->tvnorm); 1281 set_input(btv, btv->input, btv->tvnorm);
1471} 1282}
1472 1283
1473static int bttv_g_ctrl(struct file *file, void *priv, 1284static int bttv_s_ctrl(struct v4l2_ctrl *c)
1474 struct v4l2_control *c)
1475{ 1285{
1476 struct bttv_fh *fh = priv; 1286 struct bttv *btv = container_of(c->handler, struct bttv, ctrl_handler);
1477 struct bttv *btv = fh->btv; 1287 int val;
1478
1479 switch (c->id) {
1480 case V4L2_CID_BRIGHTNESS:
1481 c->value = btv->bright;
1482 break;
1483 case V4L2_CID_HUE:
1484 c->value = btv->hue;
1485 break;
1486 case V4L2_CID_CONTRAST:
1487 c->value = btv->contrast;
1488 break;
1489 case V4L2_CID_SATURATION:
1490 c->value = btv->saturation;
1491 break;
1492 case V4L2_CID_COLOR_KILLER:
1493 c->value = btv->opt_color_killer;
1494 break;
1495
1496 case V4L2_CID_AUDIO_MUTE:
1497 case V4L2_CID_AUDIO_VOLUME:
1498 case V4L2_CID_AUDIO_BALANCE:
1499 case V4L2_CID_AUDIO_BASS:
1500 case V4L2_CID_AUDIO_TREBLE:
1501 bttv_call_all(btv, core, g_ctrl, c);
1502 break;
1503
1504 case V4L2_CID_PRIVATE_CHROMA_AGC:
1505 c->value = btv->opt_chroma_agc;
1506 break;
1507 case V4L2_CID_PRIVATE_COMBFILTER:
1508 c->value = btv->opt_combfilter;
1509 break;
1510 case V4L2_CID_PRIVATE_LUMAFILTER:
1511 c->value = btv->opt_lumafilter;
1512 break;
1513 case V4L2_CID_PRIVATE_AUTOMUTE:
1514 c->value = btv->opt_automute;
1515 break;
1516 case V4L2_CID_PRIVATE_AGC_CRUSH:
1517 c->value = btv->opt_adc_crush;
1518 break;
1519 case V4L2_CID_PRIVATE_VCR_HACK:
1520 c->value = btv->opt_vcr_hack;
1521 break;
1522 case V4L2_CID_PRIVATE_WHITECRUSH_UPPER:
1523 c->value = btv->opt_whitecrush_upper;
1524 break;
1525 case V4L2_CID_PRIVATE_WHITECRUSH_LOWER:
1526 c->value = btv->opt_whitecrush_lower;
1527 break;
1528 case V4L2_CID_PRIVATE_UV_RATIO:
1529 c->value = btv->opt_uv_ratio;
1530 break;
1531 case V4L2_CID_PRIVATE_FULL_LUMA_RANGE:
1532 c->value = btv->opt_full_luma_range;
1533 break;
1534 case V4L2_CID_PRIVATE_CORING:
1535 c->value = btv->opt_coring;
1536 break;
1537 default:
1538 return -EINVAL;
1539 }
1540 return 0;
1541}
1542
1543static int bttv_s_ctrl(struct file *file, void *f,
1544 struct v4l2_control *c)
1545{
1546 int err;
1547 struct bttv_fh *fh = f;
1548 struct bttv *btv = fh->btv;
1549
1550 err = v4l2_prio_check(&btv->prio, fh->prio);
1551 if (0 != err)
1552 return err;
1553 1288
1554 switch (c->id) { 1289 switch (c->id) {
1555 case V4L2_CID_BRIGHTNESS: 1290 case V4L2_CID_BRIGHTNESS:
1556 bt848_bright(btv, c->value); 1291 bt848_bright(btv, c->val);
1557 break; 1292 break;
1558 case V4L2_CID_HUE: 1293 case V4L2_CID_HUE:
1559 bt848_hue(btv, c->value); 1294 bt848_hue(btv, c->val);
1560 break; 1295 break;
1561 case V4L2_CID_CONTRAST: 1296 case V4L2_CID_CONTRAST:
1562 bt848_contrast(btv, c->value); 1297 bt848_contrast(btv, c->val);
1563 break; 1298 break;
1564 case V4L2_CID_SATURATION: 1299 case V4L2_CID_SATURATION:
1565 bt848_sat(btv, c->value); 1300 bt848_sat(btv, c->val);
1566 break; 1301 break;
1567 case V4L2_CID_COLOR_KILLER: 1302 case V4L2_CID_COLOR_KILLER:
1568 btv->opt_color_killer = c->value; 1303 if (c->val) {
1569 if (btv->opt_color_killer) {
1570 btor(BT848_SCLOOP_CKILL, BT848_E_SCLOOP); 1304 btor(BT848_SCLOOP_CKILL, BT848_E_SCLOOP);
1571 btor(BT848_SCLOOP_CKILL, BT848_O_SCLOOP); 1305 btor(BT848_SCLOOP_CKILL, BT848_O_SCLOOP);
1572 } else { 1306 } else {
@@ -1575,36 +1309,23 @@ static int bttv_s_ctrl(struct file *file, void *f,
1575 } 1309 }
1576 break; 1310 break;
1577 case V4L2_CID_AUDIO_MUTE: 1311 case V4L2_CID_AUDIO_MUTE:
1578 audio_mute(btv, c->value); 1312 audio_mute(btv, c->val);
1579 /* fall through */ 1313 btv->mute = c->val;
1580 case V4L2_CID_AUDIO_VOLUME:
1581 if (btv->volume_gpio)
1582 btv->volume_gpio(btv, c->value);
1583
1584 bttv_call_all(btv, core, s_ctrl, c);
1585 break; 1314 break;
1586 case V4L2_CID_AUDIO_BALANCE: 1315 case V4L2_CID_AUDIO_VOLUME:
1587 case V4L2_CID_AUDIO_BASS: 1316 btv->volume_gpio(btv, c->val);
1588 case V4L2_CID_AUDIO_TREBLE:
1589 bttv_call_all(btv, core, s_ctrl, c);
1590 break; 1317 break;
1591 1318
1592 case V4L2_CID_PRIVATE_CHROMA_AGC: 1319 case V4L2_CID_CHROMA_AGC:
1593 btv->opt_chroma_agc = c->value; 1320 val = c->val ? BT848_SCLOOP_CAGC : 0;
1594 if (btv->opt_chroma_agc) { 1321 btwrite(val, BT848_E_SCLOOP);
1595 btor(BT848_SCLOOP_CAGC, BT848_E_SCLOOP); 1322 btwrite(val, BT848_O_SCLOOP);
1596 btor(BT848_SCLOOP_CAGC, BT848_O_SCLOOP);
1597 } else {
1598 btand(~BT848_SCLOOP_CAGC, BT848_E_SCLOOP);
1599 btand(~BT848_SCLOOP_CAGC, BT848_O_SCLOOP);
1600 }
1601 break; 1323 break;
1602 case V4L2_CID_PRIVATE_COMBFILTER: 1324 case V4L2_CID_PRIVATE_COMBFILTER:
1603 btv->opt_combfilter = c->value; 1325 btv->opt_combfilter = c->val;
1604 break; 1326 break;
1605 case V4L2_CID_PRIVATE_LUMAFILTER: 1327 case V4L2_CID_PRIVATE_LUMAFILTER:
1606 btv->opt_lumafilter = c->value; 1328 if (c->val) {
1607 if (btv->opt_lumafilter) {
1608 btand(~BT848_CONTROL_LDEC, BT848_E_CONTROL); 1329 btand(~BT848_CONTROL_LDEC, BT848_E_CONTROL);
1609 btand(~BT848_CONTROL_LDEC, BT848_O_CONTROL); 1330 btand(~BT848_CONTROL_LDEC, BT848_O_CONTROL);
1610 } else { 1331 } else {
@@ -1613,36 +1334,31 @@ static int bttv_s_ctrl(struct file *file, void *f,
1613 } 1334 }
1614 break; 1335 break;
1615 case V4L2_CID_PRIVATE_AUTOMUTE: 1336 case V4L2_CID_PRIVATE_AUTOMUTE:
1616 btv->opt_automute = c->value; 1337 btv->opt_automute = c->val;
1617 break; 1338 break;
1618 case V4L2_CID_PRIVATE_AGC_CRUSH: 1339 case V4L2_CID_PRIVATE_AGC_CRUSH:
1619 btv->opt_adc_crush = c->value;
1620 btwrite(BT848_ADC_RESERVED | 1340 btwrite(BT848_ADC_RESERVED |
1621 (btv->opt_adc_crush ? BT848_ADC_CRUSH : 0), 1341 (c->val ? BT848_ADC_CRUSH : 0),
1622 BT848_ADC); 1342 BT848_ADC);
1623 break; 1343 break;
1624 case V4L2_CID_PRIVATE_VCR_HACK: 1344 case V4L2_CID_PRIVATE_VCR_HACK:
1625 btv->opt_vcr_hack = c->value; 1345 btv->opt_vcr_hack = c->val;
1626 break; 1346 break;
1627 case V4L2_CID_PRIVATE_WHITECRUSH_UPPER: 1347 case V4L2_CID_PRIVATE_WHITECRUSH_UPPER:
1628 btv->opt_whitecrush_upper = c->value; 1348 btwrite(c->val, BT848_WC_UP);
1629 btwrite(c->value, BT848_WC_UP);
1630 break; 1349 break;
1631 case V4L2_CID_PRIVATE_WHITECRUSH_LOWER: 1350 case V4L2_CID_PRIVATE_WHITECRUSH_LOWER:
1632 btv->opt_whitecrush_lower = c->value; 1351 btwrite(c->val, BT848_WC_DOWN);
1633 btwrite(c->value, BT848_WC_DOWN);
1634 break; 1352 break;
1635 case V4L2_CID_PRIVATE_UV_RATIO: 1353 case V4L2_CID_PRIVATE_UV_RATIO:
1636 btv->opt_uv_ratio = c->value; 1354 btv->opt_uv_ratio = c->val;
1637 bt848_sat(btv, btv->saturation); 1355 bt848_sat(btv, btv->saturation);
1638 break; 1356 break;
1639 case V4L2_CID_PRIVATE_FULL_LUMA_RANGE: 1357 case V4L2_CID_PRIVATE_FULL_LUMA_RANGE:
1640 btv->opt_full_luma_range = c->value; 1358 btaor((c->val << 7), ~BT848_OFORM_RANGE, BT848_OFORM);
1641 btaor((c->value<<7), ~BT848_OFORM_RANGE, BT848_OFORM);
1642 break; 1359 break;
1643 case V4L2_CID_PRIVATE_CORING: 1360 case V4L2_CID_PRIVATE_CORING:
1644 btv->opt_coring = c->value; 1361 btaor((c->val << 5), ~BT848_OFORM_CORE32, BT848_OFORM);
1645 btaor((c->value<<5), ~BT848_OFORM_CORE32, BT848_OFORM);
1646 break; 1362 break;
1647 default: 1363 default:
1648 return -EINVAL; 1364 return -EINVAL;
@@ -1652,6 +1368,121 @@ static int bttv_s_ctrl(struct file *file, void *f,
1652 1368
1653/* ----------------------------------------------------------------------- */ 1369/* ----------------------------------------------------------------------- */
1654 1370
1371static const struct v4l2_ctrl_ops bttv_ctrl_ops = {
1372 .s_ctrl = bttv_s_ctrl,
1373};
1374
1375static struct v4l2_ctrl_config bttv_ctrl_combfilter = {
1376 .ops = &bttv_ctrl_ops,
1377 .id = V4L2_CID_PRIVATE_COMBFILTER,
1378 .name = "Comb Filter",
1379 .type = V4L2_CTRL_TYPE_BOOLEAN,
1380 .min = 0,
1381 .max = 1,
1382 .step = 1,
1383 .def = 1,
1384};
1385
1386static struct v4l2_ctrl_config bttv_ctrl_automute = {
1387 .ops = &bttv_ctrl_ops,
1388 .id = V4L2_CID_PRIVATE_AUTOMUTE,
1389 .name = "Auto Mute",
1390 .type = V4L2_CTRL_TYPE_BOOLEAN,
1391 .min = 0,
1392 .max = 1,
1393 .step = 1,
1394 .def = 1,
1395};
1396
1397static struct v4l2_ctrl_config bttv_ctrl_lumafilter = {
1398 .ops = &bttv_ctrl_ops,
1399 .id = V4L2_CID_PRIVATE_LUMAFILTER,
1400 .name = "Luma Decimation Filter",
1401 .type = V4L2_CTRL_TYPE_BOOLEAN,
1402 .min = 0,
1403 .max = 1,
1404 .step = 1,
1405 .def = 1,
1406};
1407
1408static struct v4l2_ctrl_config bttv_ctrl_agc_crush = {
1409 .ops = &bttv_ctrl_ops,
1410 .id = V4L2_CID_PRIVATE_AGC_CRUSH,
1411 .name = "AGC Crush",
1412 .type = V4L2_CTRL_TYPE_BOOLEAN,
1413 .min = 0,
1414 .max = 1,
1415 .step = 1,
1416 .def = 1,
1417};
1418
1419static struct v4l2_ctrl_config bttv_ctrl_vcr_hack = {
1420 .ops = &bttv_ctrl_ops,
1421 .id = V4L2_CID_PRIVATE_VCR_HACK,
1422 .name = "VCR Hack",
1423 .type = V4L2_CTRL_TYPE_BOOLEAN,
1424 .min = 0,
1425 .max = 1,
1426 .step = 1,
1427 .def = 1,
1428};
1429
1430static struct v4l2_ctrl_config bttv_ctrl_whitecrush_lower = {
1431 .ops = &bttv_ctrl_ops,
1432 .id = V4L2_CID_PRIVATE_WHITECRUSH_LOWER,
1433 .name = "Whitecrush Lower",
1434 .type = V4L2_CTRL_TYPE_INTEGER,
1435 .min = 0,
1436 .max = 255,
1437 .step = 1,
1438 .def = 0x7f,
1439};
1440
1441static struct v4l2_ctrl_config bttv_ctrl_whitecrush_upper = {
1442 .ops = &bttv_ctrl_ops,
1443 .id = V4L2_CID_PRIVATE_WHITECRUSH_UPPER,
1444 .name = "Whitecrush Upper",
1445 .type = V4L2_CTRL_TYPE_INTEGER,
1446 .min = 0,
1447 .max = 255,
1448 .step = 1,
1449 .def = 0xcf,
1450};
1451
1452static struct v4l2_ctrl_config bttv_ctrl_uv_ratio = {
1453 .ops = &bttv_ctrl_ops,
1454 .id = V4L2_CID_PRIVATE_UV_RATIO,
1455 .name = "UV Ratio",
1456 .type = V4L2_CTRL_TYPE_INTEGER,
1457 .min = 0,
1458 .max = 100,
1459 .step = 1,
1460 .def = 50,
1461};
1462
1463static struct v4l2_ctrl_config bttv_ctrl_full_luma = {
1464 .ops = &bttv_ctrl_ops,
1465 .id = V4L2_CID_PRIVATE_FULL_LUMA_RANGE,
1466 .name = "Full Luma Range",
1467 .type = V4L2_CTRL_TYPE_BOOLEAN,
1468 .min = 0,
1469 .max = 1,
1470 .step = 1,
1471};
1472
1473static struct v4l2_ctrl_config bttv_ctrl_coring = {
1474 .ops = &bttv_ctrl_ops,
1475 .id = V4L2_CID_PRIVATE_CORING,
1476 .name = "Coring",
1477 .type = V4L2_CTRL_TYPE_INTEGER,
1478 .min = 0,
1479 .max = 3,
1480 .step = 1,
1481};
1482
1483
1484/* ----------------------------------------------------------------------- */
1485
1655void bttv_gpio_tracking(struct bttv *btv, char *comment) 1486void bttv_gpio_tracking(struct bttv *btv, char *comment)
1656{ 1487{
1657 unsigned int outbits, data; 1488 unsigned int outbits, data;
@@ -1881,25 +1712,33 @@ static struct videobuf_queue_ops bttv_video_qops = {
1881 .buf_release = buffer_release, 1712 .buf_release = buffer_release,
1882}; 1713};
1883 1714
1884static int bttv_s_std(struct file *file, void *priv, v4l2_std_id *id) 1715static void radio_enable(struct bttv *btv)
1716{
1717 /* Switch to the radio tuner */
1718 if (!btv->has_radio_tuner) {
1719 btv->has_radio_tuner = 1;
1720 bttv_call_all(btv, tuner, s_radio);
1721 btv->audio_input = TVAUDIO_INPUT_RADIO;
1722 audio_input(btv, btv->audio_input);
1723 }
1724}
1725
1726static int bttv_s_std(struct file *file, void *priv, v4l2_std_id id)
1885{ 1727{
1886 struct bttv_fh *fh = priv; 1728 struct bttv_fh *fh = priv;
1887 struct bttv *btv = fh->btv; 1729 struct bttv *btv = fh->btv;
1888 unsigned int i; 1730 unsigned int i;
1889 int err; 1731 int err = 0;
1890
1891 err = v4l2_prio_check(&btv->prio, fh->prio);
1892 if (err)
1893 goto err;
1894 1732
1895 for (i = 0; i < BTTV_TVNORMS; i++) 1733 for (i = 0; i < BTTV_TVNORMS; i++)
1896 if (*id & bttv_tvnorms[i].v4l2_id) 1734 if (id & bttv_tvnorms[i].v4l2_id)
1897 break; 1735 break;
1898 if (i == BTTV_TVNORMS) { 1736 if (i == BTTV_TVNORMS) {
1899 err = -EINVAL; 1737 err = -EINVAL;
1900 goto err; 1738 goto err;
1901 } 1739 }
1902 1740
1741 btv->std = id;
1903 set_tvnorm(btv, i); 1742 set_tvnorm(btv, i);
1904 1743
1905err: 1744err:
@@ -1907,6 +1746,15 @@ err:
1907 return err; 1746 return err;
1908} 1747}
1909 1748
1749static int bttv_g_std(struct file *file, void *priv, v4l2_std_id *id)
1750{
1751 struct bttv_fh *fh = priv;
1752 struct bttv *btv = fh->btv;
1753
1754 *id = btv->std;
1755 return 0;
1756}
1757
1910static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id) 1758static int bttv_querystd(struct file *file, void *f, v4l2_std_id *id)
1911{ 1759{
1912 struct bttv_fh *fh = f; 1760 struct bttv_fh *fh = f;
@@ -1932,7 +1780,7 @@ static int bttv_enum_input(struct file *file, void *priv,
1932 } 1780 }
1933 1781
1934 i->type = V4L2_INPUT_TYPE_CAMERA; 1782 i->type = V4L2_INPUT_TYPE_CAMERA;
1935 i->audioset = 1; 1783 i->audioset = 0;
1936 1784
1937 if (btv->tuner_type != TUNER_ABSENT && i->index == 0) { 1785 if (btv->tuner_type != TUNER_ABSENT && i->index == 0) {
1938 sprintf(i->name, "Television"); 1786 sprintf(i->name, "Television");
@@ -1974,49 +1822,29 @@ static int bttv_s_input(struct file *file, void *priv, unsigned int i)
1974 struct bttv_fh *fh = priv; 1822 struct bttv_fh *fh = priv;
1975 struct bttv *btv = fh->btv; 1823 struct bttv *btv = fh->btv;
1976 1824
1977 int err; 1825 if (i >= bttv_tvcards[btv->c.type].video_inputs)
1978 1826 return -EINVAL;
1979 err = v4l2_prio_check(&btv->prio, fh->prio);
1980 if (unlikely(err))
1981 goto err;
1982
1983 if (i > bttv_tvcards[btv->c.type].video_inputs) {
1984 err = -EINVAL;
1985 goto err;
1986 }
1987 1827
1988 set_input(btv, i, btv->tvnorm); 1828 set_input(btv, i, btv->tvnorm);
1989
1990err:
1991 return 0; 1829 return 0;
1992} 1830}
1993 1831
1994static int bttv_s_tuner(struct file *file, void *priv, 1832static int bttv_s_tuner(struct file *file, void *priv,
1995 struct v4l2_tuner *t) 1833 const struct v4l2_tuner *t)
1996{ 1834{
1997 struct bttv_fh *fh = priv; 1835 struct bttv_fh *fh = priv;
1998 struct bttv *btv = fh->btv; 1836 struct bttv *btv = fh->btv;
1999 int err;
2000 1837
2001 if (unlikely(0 != t->index)) 1838 if (t->index)
2002 return -EINVAL; 1839 return -EINVAL;
2003 1840
2004 if (unlikely(btv->tuner_type == TUNER_ABSENT)) {
2005 err = -EINVAL;
2006 goto err;
2007 }
2008
2009 err = v4l2_prio_check(&btv->prio, fh->prio);
2010 if (unlikely(err))
2011 goto err;
2012
2013 bttv_call_all(btv, tuner, s_tuner, t); 1841 bttv_call_all(btv, tuner, s_tuner, t);
2014 1842
2015 if (btv->audio_mode_gpio) 1843 if (btv->audio_mode_gpio) {
2016 btv->audio_mode_gpio(btv, t, 1); 1844 struct v4l2_tuner copy = *t;
2017
2018err:
2019 1845
1846 btv->audio_mode_gpio(btv, &copy, 1);
1847 }
2020 return 0; 1848 return 0;
2021} 1849}
2022 1850
@@ -2026,49 +1854,81 @@ static int bttv_g_frequency(struct file *file, void *priv,
2026 struct bttv_fh *fh = priv; 1854 struct bttv_fh *fh = priv;
2027 struct bttv *btv = fh->btv; 1855 struct bttv *btv = fh->btv;
2028 1856
2029 f->type = btv->radio_user ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV; 1857 if (f->tuner)
2030 f->frequency = btv->freq; 1858 return -EINVAL;
1859
1860 if (f->type == V4L2_TUNER_RADIO)
1861 radio_enable(btv);
1862 f->frequency = f->type == V4L2_TUNER_RADIO ?
1863 btv->radio_freq : btv->tv_freq;
2031 1864
2032 return 0; 1865 return 0;
2033} 1866}
2034 1867
1868static void bttv_set_frequency(struct bttv *btv, const struct v4l2_frequency *f)
1869{
1870 struct v4l2_frequency new_freq = *f;
1871
1872 bttv_call_all(btv, tuner, s_frequency, f);
1873 /* s_frequency may clamp the frequency, so get the actual
1874 frequency before assigning radio/tv_freq. */
1875 bttv_call_all(btv, tuner, g_frequency, &new_freq);
1876 if (new_freq.type == V4L2_TUNER_RADIO) {
1877 radio_enable(btv);
1878 btv->radio_freq = new_freq.frequency;
1879 if (btv->has_matchbox)
1880 tea5757_set_freq(btv, btv->radio_freq);
1881 } else {
1882 btv->tv_freq = new_freq.frequency;
1883 }
1884}
1885
2035static int bttv_s_frequency(struct file *file, void *priv, 1886static int bttv_s_frequency(struct file *file, void *priv,
2036 struct v4l2_frequency *f) 1887 const struct v4l2_frequency *f)
2037{ 1888{
2038 struct bttv_fh *fh = priv; 1889 struct bttv_fh *fh = priv;
2039 struct bttv *btv = fh->btv; 1890 struct bttv *btv = fh->btv;
2040 int err;
2041 1891
2042 if (unlikely(f->tuner != 0)) 1892 if (f->tuner)
2043 return -EINVAL; 1893 return -EINVAL;
2044 1894
2045 err = v4l2_prio_check(&btv->prio, fh->prio); 1895 bttv_set_frequency(btv, f);
2046 if (unlikely(err))
2047 goto err;
2048
2049 if (unlikely(f->type != (btv->radio_user
2050 ? V4L2_TUNER_RADIO : V4L2_TUNER_ANALOG_TV))) {
2051 err = -EINVAL;
2052 goto err;
2053 }
2054 btv->freq = f->frequency;
2055 bttv_call_all(btv, tuner, s_frequency, f);
2056 if (btv->has_matchbox && btv->radio_user)
2057 tea5757_set_freq(btv, btv->freq);
2058err:
2059
2060 return 0; 1896 return 0;
2061} 1897}
2062 1898
2063static int bttv_log_status(struct file *file, void *f) 1899static int bttv_log_status(struct file *file, void *f)
2064{ 1900{
1901 struct video_device *vdev = video_devdata(file);
2065 struct bttv_fh *fh = f; 1902 struct bttv_fh *fh = f;
2066 struct bttv *btv = fh->btv; 1903 struct bttv *btv = fh->btv;
2067 1904
1905 v4l2_ctrl_handler_log_status(vdev->ctrl_handler, btv->c.v4l2_dev.name);
2068 bttv_call_all(btv, core, log_status); 1906 bttv_call_all(btv, core, log_status);
2069 return 0; 1907 return 0;
2070} 1908}
2071 1909
1910static int bttv_g_chip_ident(struct file *file, void *f, struct v4l2_dbg_chip_ident *chip)
1911{
1912 struct bttv_fh *fh = f;
1913 struct bttv *btv = fh->btv;
1914
1915 chip->ident = V4L2_IDENT_NONE;
1916 chip->revision = 0;
1917 if (chip->match.type == V4L2_CHIP_MATCH_HOST) {
1918 if (v4l2_chip_match_host(&chip->match)) {
1919 chip->ident = btv->id;
1920 if (chip->ident == PCI_DEVICE_ID_FUSION879)
1921 chip->ident = V4L2_IDENT_BT879;
1922 }
1923 return 0;
1924 }
1925 if (chip->match.type != V4L2_CHIP_MATCH_I2C_DRIVER &&
1926 chip->match.type != V4L2_CHIP_MATCH_I2C_ADDR)
1927 return -EINVAL;
1928 /* TODO: is this correct? */
1929 return bttv_call_all_err(btv, core, g_chip_ident, chip);
1930}
1931
2072#ifdef CONFIG_VIDEO_ADV_DEBUG 1932#ifdef CONFIG_VIDEO_ADV_DEBUG
2073static int bttv_g_register(struct file *file, void *f, 1933static int bttv_g_register(struct file *file, void *f,
2074 struct v4l2_dbg_register *reg) 1934 struct v4l2_dbg_register *reg)
@@ -2079,8 +1939,12 @@ static int bttv_g_register(struct file *file, void *f,
2079 if (!capable(CAP_SYS_ADMIN)) 1939 if (!capable(CAP_SYS_ADMIN))
2080 return -EPERM; 1940 return -EPERM;
2081 1941
2082 if (!v4l2_chip_match_host(&reg->match)) 1942 if (!v4l2_chip_match_host(&reg->match)) {
2083 return -EINVAL; 1943 /* TODO: subdev errors should not be ignored, this should become a
1944 subdev helper function. */
1945 bttv_call_all(btv, core, g_register, reg);
1946 return 0;
1947 }
2084 1948
2085 /* bt848 has a 12-bit register space */ 1949 /* bt848 has a 12-bit register space */
2086 reg->reg &= 0xfff; 1950 reg->reg &= 0xfff;
@@ -2091,7 +1955,7 @@ static int bttv_g_register(struct file *file, void *f,
2091} 1955}
2092 1956
2093static int bttv_s_register(struct file *file, void *f, 1957static int bttv_s_register(struct file *file, void *f,
2094 struct v4l2_dbg_register *reg) 1958 const struct v4l2_dbg_register *reg)
2095{ 1959{
2096 struct bttv_fh *fh = f; 1960 struct bttv_fh *fh = f;
2097 struct bttv *btv = fh->btv; 1961 struct bttv *btv = fh->btv;
@@ -2099,12 +1963,15 @@ static int bttv_s_register(struct file *file, void *f,
2099 if (!capable(CAP_SYS_ADMIN)) 1963 if (!capable(CAP_SYS_ADMIN))
2100 return -EPERM; 1964 return -EPERM;
2101 1965
2102 if (!v4l2_chip_match_host(&reg->match)) 1966 if (!v4l2_chip_match_host(&reg->match)) {
2103 return -EINVAL; 1967 /* TODO: subdev errors should not be ignored, this should become a
1968 subdev helper function. */
1969 bttv_call_all(btv, core, s_register, reg);
1970 return 0;
1971 }
2104 1972
2105 /* bt848 has a 12-bit register space */ 1973 /* bt848 has a 12-bit register space */
2106 reg->reg &= 0xfff; 1974 btwrite(reg->val, reg->reg & 0xfff);
2107 btwrite(reg->val, reg->reg);
2108 1975
2109 return 0; 1976 return 0;
2110} 1977}
@@ -2273,22 +2140,33 @@ limit_scaled_size_lock (struct bttv_fh * fh,
2273 may also adjust the current cropping parameters to get closer 2140 may also adjust the current cropping parameters to get closer
2274 to the desired window size. */ 2141 to the desired window size. */
2275static int 2142static int
2276verify_window_lock (struct bttv_fh * fh, 2143verify_window_lock(struct bttv_fh *fh, struct v4l2_window *win,
2277 struct v4l2_window * win, 2144 int adjust_size, int adjust_crop)
2278 int adjust_size,
2279 int adjust_crop)
2280{ 2145{
2281 enum v4l2_field field; 2146 enum v4l2_field field;
2282 unsigned int width_mask; 2147 unsigned int width_mask;
2283 int rc; 2148 int rc;
2284 2149
2285 if (win->w.width < 48 || win->w.height < 32) 2150 if (win->w.width < 48)
2286 return -EINVAL; 2151 win->w.width = 48;
2152 if (win->w.height < 32)
2153 win->w.height = 32;
2287 if (win->clipcount > 2048) 2154 if (win->clipcount > 2048)
2288 return -EINVAL; 2155 win->clipcount = 2048;
2289 2156
2157 win->chromakey = 0;
2158 win->global_alpha = 0;
2290 field = win->field; 2159 field = win->field;
2291 2160
2161 switch (field) {
2162 case V4L2_FIELD_TOP:
2163 case V4L2_FIELD_BOTTOM:
2164 case V4L2_FIELD_INTERLACED:
2165 break;
2166 default:
2167 field = V4L2_FIELD_ANY;
2168 break;
2169 }
2292 if (V4L2_FIELD_ANY == field) { 2170 if (V4L2_FIELD_ANY == field) {
2293 __s32 height2; 2171 __s32 height2;
2294 2172
@@ -2297,18 +2175,11 @@ verify_window_lock (struct bttv_fh * fh,
2297 ? V4L2_FIELD_INTERLACED 2175 ? V4L2_FIELD_INTERLACED
2298 : V4L2_FIELD_TOP; 2176 : V4L2_FIELD_TOP;
2299 } 2177 }
2300 switch (field) { 2178 win->field = field;
2301 case V4L2_FIELD_TOP:
2302 case V4L2_FIELD_BOTTOM:
2303 case V4L2_FIELD_INTERLACED:
2304 break;
2305 default:
2306 return -EINVAL;
2307 }
2308 2179
2309 /* 4-byte alignment. */
2310 if (NULL == fh->ovfmt) 2180 if (NULL == fh->ovfmt)
2311 return -EINVAL; 2181 return -EINVAL;
2182 /* 4-byte alignment. */
2312 width_mask = ~0; 2183 width_mask = ~0;
2313 switch (fh->ovfmt->depth) { 2184 switch (fh->ovfmt->depth) {
2314 case 8: 2185 case 8:
@@ -2333,8 +2204,6 @@ verify_window_lock (struct bttv_fh * fh,
2333 adjust_size, adjust_crop); 2204 adjust_size, adjust_crop);
2334 if (0 != rc) 2205 if (0 != rc)
2335 return rc; 2206 return rc;
2336
2337 win->field = field;
2338 return 0; 2207 return 0;
2339} 2208}
2340 2209
@@ -2491,6 +2360,7 @@ static int bttv_g_fmt_vid_cap(struct file *file, void *priv,
2491 fh->width, fh->height); 2360 fh->width, fh->height);
2492 f->fmt.pix.field = fh->cap.field; 2361 f->fmt.pix.field = fh->cap.field;
2493 f->fmt.pix.pixelformat = fh->fmt->fourcc; 2362 f->fmt.pix.pixelformat = fh->fmt->fourcc;
2363 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
2494 2364
2495 return 0; 2365 return 0;
2496} 2366}
@@ -2514,6 +2384,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
2514 struct bttv *btv = fh->btv; 2384 struct bttv *btv = fh->btv;
2515 enum v4l2_field field; 2385 enum v4l2_field field;
2516 __s32 width, height; 2386 __s32 width, height;
2387 __s32 height2;
2517 int rc; 2388 int rc;
2518 2389
2519 fmt = format_by_fourcc(f->fmt.pix.pixelformat); 2390 fmt = format_by_fourcc(f->fmt.pix.pixelformat);
@@ -2522,30 +2393,25 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
2522 2393
2523 field = f->fmt.pix.field; 2394 field = f->fmt.pix.field;
2524 2395
2525 if (V4L2_FIELD_ANY == field) {
2526 __s32 height2;
2527
2528 height2 = btv->crop[!!fh->do_crop].rect.height >> 1;
2529 field = (f->fmt.pix.height > height2)
2530 ? V4L2_FIELD_INTERLACED
2531 : V4L2_FIELD_BOTTOM;
2532 }
2533
2534 if (V4L2_FIELD_SEQ_BT == field)
2535 field = V4L2_FIELD_SEQ_TB;
2536
2537 switch (field) { 2396 switch (field) {
2538 case V4L2_FIELD_TOP: 2397 case V4L2_FIELD_TOP:
2539 case V4L2_FIELD_BOTTOM: 2398 case V4L2_FIELD_BOTTOM:
2540 case V4L2_FIELD_ALTERNATE: 2399 case V4L2_FIELD_ALTERNATE:
2541 case V4L2_FIELD_INTERLACED: 2400 case V4L2_FIELD_INTERLACED:
2542 break; 2401 break;
2402 case V4L2_FIELD_SEQ_BT:
2543 case V4L2_FIELD_SEQ_TB: 2403 case V4L2_FIELD_SEQ_TB:
2544 if (fmt->flags & FORMAT_FLAGS_PLANAR) 2404 if (!(fmt->flags & FORMAT_FLAGS_PLANAR)) {
2545 return -EINVAL; 2405 field = V4L2_FIELD_SEQ_TB;
2406 break;
2407 }
2408 /* fall through */
2409 default: /* FIELD_ANY case */
2410 height2 = btv->crop[!!fh->do_crop].rect.height >> 1;
2411 field = (f->fmt.pix.height > height2)
2412 ? V4L2_FIELD_INTERLACED
2413 : V4L2_FIELD_BOTTOM;
2546 break; 2414 break;
2547 default:
2548 return -EINVAL;
2549 } 2415 }
2550 2416
2551 width = f->fmt.pix.width; 2417 width = f->fmt.pix.width;
@@ -2562,6 +2428,7 @@ static int bttv_try_fmt_vid_cap(struct file *file, void *priv,
2562 /* update data for the application */ 2428 /* update data for the application */
2563 f->fmt.pix.field = field; 2429 f->fmt.pix.field = field;
2564 pix_format_set_size(&f->fmt.pix, fmt, width, height); 2430 pix_format_set_size(&f->fmt.pix, fmt, width, height);
2431 f->fmt.pix.colorspace = V4L2_COLORSPACE_SMPTE170M;
2565 2432
2566 return 0; 2433 return 0;
2567} 2434}
@@ -2571,9 +2438,10 @@ static int bttv_try_fmt_vid_overlay(struct file *file, void *priv,
2571{ 2438{
2572 struct bttv_fh *fh = priv; 2439 struct bttv_fh *fh = priv;
2573 2440
2574 return verify_window_lock(fh, &f->fmt.win, 2441 verify_window_lock(fh, &f->fmt.win,
2575 /* adjust_size */ 1, 2442 /* adjust_size */ 1,
2576 /* adjust_crop */ 0); 2443 /* adjust_crop */ 0);
2444 return 0;
2577} 2445}
2578 2446
2579static int bttv_s_fmt_vid_cap(struct file *file, void *priv, 2447static int bttv_s_fmt_vid_cap(struct file *file, void *priv,
@@ -2640,6 +2508,7 @@ static int bttv_s_fmt_vid_overlay(struct file *file, void *priv,
2640static int bttv_querycap(struct file *file, void *priv, 2508static int bttv_querycap(struct file *file, void *priv,
2641 struct v4l2_capability *cap) 2509 struct v4l2_capability *cap)
2642{ 2510{
2511 struct video_device *vdev = video_devdata(file);
2643 struct bttv_fh *fh = priv; 2512 struct bttv_fh *fh = priv;
2644 struct bttv *btv = fh->btv; 2513 struct bttv *btv = fh->btv;
2645 2514
@@ -2652,11 +2521,15 @@ static int bttv_querycap(struct file *file, void *priv,
2652 "PCI:%s", pci_name(btv->c.pci)); 2521 "PCI:%s", pci_name(btv->c.pci));
2653 cap->capabilities = 2522 cap->capabilities =
2654 V4L2_CAP_VIDEO_CAPTURE | 2523 V4L2_CAP_VIDEO_CAPTURE |
2655 V4L2_CAP_VBI_CAPTURE |
2656 V4L2_CAP_READWRITE | 2524 V4L2_CAP_READWRITE |
2657 V4L2_CAP_STREAMING; 2525 V4L2_CAP_STREAMING |
2526 V4L2_CAP_DEVICE_CAPS;
2658 if (no_overlay <= 0) 2527 if (no_overlay <= 0)
2659 cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY; 2528 cap->capabilities |= V4L2_CAP_VIDEO_OVERLAY;
2529 if (btv->vbi_dev)
2530 cap->capabilities |= V4L2_CAP_VBI_CAPTURE;
2531 if (btv->radio_dev)
2532 cap->capabilities |= V4L2_CAP_RADIO;
2660 2533
2661 /* 2534 /*
2662 * No need to lock here: those vars are initialized during board 2535 * No need to lock here: those vars are initialized during board
@@ -2666,6 +2539,25 @@ static int bttv_querycap(struct file *file, void *priv,
2666 cap->capabilities |= V4L2_CAP_RDS_CAPTURE; 2539 cap->capabilities |= V4L2_CAP_RDS_CAPTURE;
2667 if (btv->tuner_type != TUNER_ABSENT) 2540 if (btv->tuner_type != TUNER_ABSENT)
2668 cap->capabilities |= V4L2_CAP_TUNER; 2541 cap->capabilities |= V4L2_CAP_TUNER;
2542 if (vdev->vfl_type == VFL_TYPE_GRABBER)
2543 cap->device_caps = cap->capabilities &
2544 (V4L2_CAP_VIDEO_CAPTURE |
2545 V4L2_CAP_READWRITE |
2546 V4L2_CAP_STREAMING |
2547 V4L2_CAP_VIDEO_OVERLAY |
2548 V4L2_CAP_TUNER);
2549 else if (vdev->vfl_type == VFL_TYPE_VBI)
2550 cap->device_caps = cap->capabilities &
2551 (V4L2_CAP_VBI_CAPTURE |
2552 V4L2_CAP_READWRITE |
2553 V4L2_CAP_STREAMING |
2554 V4L2_CAP_TUNER);
2555 else {
2556 cap->device_caps = V4L2_CAP_RADIO | V4L2_CAP_TUNER;
2557 if (btv->has_saa6588)
2558 cap->device_caps |= V4L2_CAP_READWRITE |
2559 V4L2_CAP_RDS_CAPTURE;
2560 }
2669 return 0; 2561 return 0;
2670} 2562}
2671 2563
@@ -2728,6 +2620,7 @@ static int bttv_g_fbuf(struct file *file, void *f,
2728 2620
2729 *fb = btv->fbuf; 2621 *fb = btv->fbuf;
2730 fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING; 2622 fb->capability = V4L2_FBUF_CAP_LIST_CLIPPING;
2623 fb->flags = V4L2_FBUF_FLAG_PRIMARY;
2731 if (fh->ovfmt) 2624 if (fh->ovfmt)
2732 fb->fmt.pixelformat = fh->ovfmt->fourcc; 2625 fb->fmt.pixelformat = fh->ovfmt->fourcc;
2733 return 0; 2626 return 0;
@@ -2901,36 +2794,15 @@ static int bttv_streamoff(struct file *file, void *priv,
2901 return 0; 2794 return 0;
2902} 2795}
2903 2796
2904static int bttv_queryctrl(struct file *file, void *priv,
2905 struct v4l2_queryctrl *c)
2906{
2907 struct bttv_fh *fh = priv;
2908 struct bttv *btv = fh->btv;
2909 const struct v4l2_queryctrl *ctrl;
2910
2911 if ((c->id < V4L2_CID_BASE ||
2912 c->id >= V4L2_CID_LASTP1) &&
2913 (c->id < V4L2_CID_PRIVATE_BASE ||
2914 c->id >= V4L2_CID_PRIVATE_LASTP1))
2915 return -EINVAL;
2916
2917 if (!btv->volume_gpio && (c->id == V4L2_CID_AUDIO_VOLUME))
2918 *c = no_ctl;
2919 else {
2920 ctrl = ctrl_by_id(c->id);
2921
2922 *c = (NULL != ctrl) ? *ctrl : no_ctl;
2923 }
2924
2925 return 0;
2926}
2927
2928static int bttv_g_parm(struct file *file, void *f, 2797static int bttv_g_parm(struct file *file, void *f,
2929 struct v4l2_streamparm *parm) 2798 struct v4l2_streamparm *parm)
2930{ 2799{
2931 struct bttv_fh *fh = f; 2800 struct bttv_fh *fh = f;
2932 struct bttv *btv = fh->btv; 2801 struct bttv *btv = fh->btv;
2933 2802
2803 if (parm->type != V4L2_BUF_TYPE_VIDEO_CAPTURE)
2804 return -EINVAL;
2805 parm->parm.capture.readbuffers = gbuffers;
2934 v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id, 2806 v4l2_video_std_frame_period(bttv_tvnorms[btv->tvnorm].v4l2_id,
2935 &parm->parm.capture.timeperframe); 2807 &parm->parm.capture.timeperframe);
2936 2808
@@ -2943,15 +2815,13 @@ static int bttv_g_tuner(struct file *file, void *priv,
2943 struct bttv_fh *fh = priv; 2815 struct bttv_fh *fh = priv;
2944 struct bttv *btv = fh->btv; 2816 struct bttv *btv = fh->btv;
2945 2817
2946 if (btv->tuner_type == TUNER_ABSENT)
2947 return -EINVAL;
2948 if (0 != t->index) 2818 if (0 != t->index)
2949 return -EINVAL; 2819 return -EINVAL;
2950 2820
2951 t->rxsubchans = V4L2_TUNER_SUB_MONO; 2821 t->rxsubchans = V4L2_TUNER_SUB_MONO;
2822 t->capability = V4L2_TUNER_CAP_NORM;
2952 bttv_call_all(btv, tuner, g_tuner, t); 2823 bttv_call_all(btv, tuner, g_tuner, t);
2953 strcpy(t->name, "Television"); 2824 strcpy(t->name, "Television");
2954 t->capability = V4L2_TUNER_CAP_NORM;
2955 t->type = V4L2_TUNER_ANALOG_TV; 2825 t->type = V4L2_TUNER_ANALOG_TV;
2956 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC) 2826 if (btread(BT848_DSTATUS)&BT848_DSTATUS_HLOC)
2957 t->signal = 0xffff; 2827 t->signal = 0xffff;
@@ -2962,28 +2832,6 @@ static int bttv_g_tuner(struct file *file, void *priv,
2962 return 0; 2832 return 0;
2963} 2833}
2964 2834
2965static int bttv_g_priority(struct file *file, void *f, enum v4l2_priority *p)
2966{
2967 struct bttv_fh *fh = f;
2968 struct bttv *btv = fh->btv;
2969
2970 *p = v4l2_prio_max(&btv->prio);
2971
2972 return 0;
2973}
2974
2975static int bttv_s_priority(struct file *file, void *f,
2976 enum v4l2_priority prio)
2977{
2978 struct bttv_fh *fh = f;
2979 struct bttv *btv = fh->btv;
2980 int rc;
2981
2982 rc = v4l2_prio_change(&btv->prio, &fh->prio, prio);
2983
2984 return rc;
2985}
2986
2987static int bttv_cropcap(struct file *file, void *priv, 2835static int bttv_cropcap(struct file *file, void *priv,
2988 struct v4l2_cropcap *cap) 2836 struct v4l2_cropcap *cap)
2989{ 2837{
@@ -3036,11 +2884,6 @@ static int bttv_s_crop(struct file *file, void *f, const struct v4l2_crop *crop)
3036 /* Make sure tvnorm, vbi_end and the current cropping 2884 /* Make sure tvnorm, vbi_end and the current cropping
3037 parameters remain consistent until we're done. Note 2885 parameters remain consistent until we're done. Note
3038 read() may change vbi_end in check_alloc_btres_lock(). */ 2886 read() may change vbi_end in check_alloc_btres_lock(). */
3039 retval = v4l2_prio_check(&btv->prio, fh->prio);
3040 if (0 != retval) {
3041 return retval;
3042 }
3043
3044 retval = -EBUSY; 2887 retval = -EBUSY;
3045 2888
3046 if (locked_btres(fh->btv, VIDEO_RESOURCES)) { 2889 if (locked_btres(fh->btv, VIDEO_RESOURCES)) {
@@ -3098,23 +2941,6 @@ static int bttv_s_crop(struct file *file, void *f, const struct v4l2_crop *crop)
3098 return 0; 2941 return 0;
3099} 2942}
3100 2943
3101static int bttv_g_audio(struct file *file, void *priv, struct v4l2_audio *a)
3102{
3103 if (unlikely(a->index))
3104 return -EINVAL;
3105
3106 strcpy(a->name, "audio");
3107 return 0;
3108}
3109
3110static int bttv_s_audio(struct file *file, void *priv, const struct v4l2_audio *a)
3111{
3112 if (unlikely(a->index))
3113 return -EINVAL;
3114
3115 return 0;
3116}
3117
3118static ssize_t bttv_read(struct file *file, char __user *data, 2944static ssize_t bttv_read(struct file *file, char __user *data,
3119 size_t count, loff_t *ppos) 2945 size_t count, loff_t *ppos)
3120{ 2946{
@@ -3154,34 +2980,43 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3154 struct bttv_fh *fh = file->private_data; 2980 struct bttv_fh *fh = file->private_data;
3155 struct bttv_buffer *buf; 2981 struct bttv_buffer *buf;
3156 enum v4l2_field field; 2982 enum v4l2_field field;
3157 unsigned int rc = POLLERR; 2983 unsigned int rc = 0;
2984 unsigned long req_events = poll_requested_events(wait);
2985
2986 if (v4l2_event_pending(&fh->fh))
2987 rc = POLLPRI;
2988 else if (req_events & POLLPRI)
2989 poll_wait(file, &fh->fh.wait, wait);
2990
2991 if (!(req_events & (POLLIN | POLLRDNORM)))
2992 return rc;
3158 2993
3159 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) { 2994 if (V4L2_BUF_TYPE_VBI_CAPTURE == fh->type) {
3160 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI)) 2995 if (!check_alloc_btres_lock(fh->btv,fh,RESOURCE_VBI))
3161 return POLLERR; 2996 return rc | POLLERR;
3162 return videobuf_poll_stream(file, &fh->vbi, wait); 2997 return rc | videobuf_poll_stream(file, &fh->vbi, wait);
3163 } 2998 }
3164 2999
3165 if (check_btres(fh,RESOURCE_VIDEO_STREAM)) { 3000 if (check_btres(fh,RESOURCE_VIDEO_STREAM)) {
3166 /* streaming capture */ 3001 /* streaming capture */
3167 if (list_empty(&fh->cap.stream)) 3002 if (list_empty(&fh->cap.stream))
3168 goto err; 3003 return rc | POLLERR;
3169 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream); 3004 buf = list_entry(fh->cap.stream.next,struct bttv_buffer,vb.stream);
3170 } else { 3005 } else {
3171 /* read() capture */ 3006 /* read() capture */
3172 if (NULL == fh->cap.read_buf) { 3007 if (NULL == fh->cap.read_buf) {
3173 /* need to capture a new frame */ 3008 /* need to capture a new frame */
3174 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM)) 3009 if (locked_btres(fh->btv,RESOURCE_VIDEO_STREAM))
3175 goto err; 3010 return rc | POLLERR;
3176 fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize); 3011 fh->cap.read_buf = videobuf_sg_alloc(fh->cap.msize);
3177 if (NULL == fh->cap.read_buf) 3012 if (NULL == fh->cap.read_buf)
3178 goto err; 3013 return rc | POLLERR;
3179 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR; 3014 fh->cap.read_buf->memory = V4L2_MEMORY_USERPTR;
3180 field = videobuf_next_field(&fh->cap); 3015 field = videobuf_next_field(&fh->cap);
3181 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) { 3016 if (0 != fh->cap.ops->buf_prepare(&fh->cap,fh->cap.read_buf,field)) {
3182 kfree (fh->cap.read_buf); 3017 kfree (fh->cap.read_buf);
3183 fh->cap.read_buf = NULL; 3018 fh->cap.read_buf = NULL;
3184 goto err; 3019 return rc | POLLERR;
3185 } 3020 }
3186 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf); 3021 fh->cap.ops->buf_queue(&fh->cap,fh->cap.read_buf);
3187 fh->cap.read_off = 0; 3022 fh->cap.read_off = 0;
@@ -3192,10 +3027,7 @@ static unsigned int bttv_poll(struct file *file, poll_table *wait)
3192 poll_wait(file, &buf->vb.done, wait); 3027 poll_wait(file, &buf->vb.done, wait);
3193 if (buf->vb.state == VIDEOBUF_DONE || 3028 if (buf->vb.state == VIDEOBUF_DONE ||
3194 buf->vb.state == VIDEOBUF_ERROR) 3029 buf->vb.state == VIDEOBUF_ERROR)
3195 rc = POLLIN|POLLRDNORM; 3030 rc = rc | POLLIN|POLLRDNORM;
3196 else
3197 rc = 0;
3198err:
3199 return rc; 3031 return rc;
3200} 3032}
3201 3033
@@ -3224,15 +3056,15 @@ static int bttv_open(struct file *file)
3224 fh = kmalloc(sizeof(*fh), GFP_KERNEL); 3056 fh = kmalloc(sizeof(*fh), GFP_KERNEL);
3225 if (unlikely(!fh)) 3057 if (unlikely(!fh))
3226 return -ENOMEM; 3058 return -ENOMEM;
3059 btv->users++;
3227 file->private_data = fh; 3060 file->private_data = fh;
3228 3061
3229 *fh = btv->init; 3062 *fh = btv->init;
3063 v4l2_fh_init(&fh->fh, vdev);
3230 3064
3231 fh->type = type; 3065 fh->type = type;
3232 fh->ov.setup_ok = 0; 3066 fh->ov.setup_ok = 0;
3233 3067
3234 v4l2_prio_open(&btv->prio, &fh->prio);
3235
3236 videobuf_queue_sg_init(&fh->cap, &bttv_video_qops, 3068 videobuf_queue_sg_init(&fh->cap, &bttv_video_qops,
3237 &btv->c.pci->dev, &btv->s_lock, 3069 &btv->c.pci->dev, &btv->s_lock,
3238 V4L2_BUF_TYPE_VIDEO_CAPTURE, 3070 V4L2_BUF_TYPE_VIDEO_CAPTURE,
@@ -3247,8 +3079,7 @@ static int bttv_open(struct file *file)
3247 fh, &btv->lock); 3079 fh, &btv->lock);
3248 set_tvnorm(btv,btv->tvnorm); 3080 set_tvnorm(btv,btv->tvnorm);
3249 set_input(btv, btv->input, btv->tvnorm); 3081 set_input(btv, btv->input, btv->tvnorm);
3250 3082 audio_mute(btv, btv->mute);
3251 btv->users++;
3252 3083
3253 /* The V4L2 spec requires one global set of cropping parameters 3084 /* The V4L2 spec requires one global set of cropping parameters
3254 which only change on request. These are stored in btv->crop[1]. 3085 which only change on request. These are stored in btv->crop[1].
@@ -3267,6 +3098,7 @@ static int bttv_open(struct file *file)
3267 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm); 3098 bttv_vbi_fmt_reset(&fh->vbi_fmt, btv->tvnorm);
3268 3099
3269 bttv_field_count(btv); 3100 bttv_field_count(btv);
3101 v4l2_fh_add(&fh->fh);
3270 return 0; 3102 return 0;
3271} 3103}
3272 3104
@@ -3302,16 +3134,17 @@ static int bttv_release(struct file *file)
3302 3134
3303 videobuf_mmap_free(&fh->cap); 3135 videobuf_mmap_free(&fh->cap);
3304 videobuf_mmap_free(&fh->vbi); 3136 videobuf_mmap_free(&fh->vbi);
3305 v4l2_prio_close(&btv->prio, fh->prio);
3306 file->private_data = NULL; 3137 file->private_data = NULL;
3307 kfree(fh);
3308 3138
3309 btv->users--; 3139 btv->users--;
3310 bttv_field_count(btv); 3140 bttv_field_count(btv);
3311 3141
3312 if (!btv->users) 3142 if (!btv->users)
3313 audio_mute(btv, 1); 3143 audio_mute(btv, btv->mute);
3314 3144
3145 v4l2_fh_del(&fh->fh);
3146 v4l2_fh_exit(&fh->fh);
3147 kfree(fh);
3315 return 0; 3148 return 0;
3316} 3149}
3317 3150
@@ -3350,20 +3183,16 @@ static const struct v4l2_ioctl_ops bttv_ioctl_ops = {
3350 .vidioc_g_fmt_vbi_cap = bttv_g_fmt_vbi_cap, 3183 .vidioc_g_fmt_vbi_cap = bttv_g_fmt_vbi_cap,
3351 .vidioc_try_fmt_vbi_cap = bttv_try_fmt_vbi_cap, 3184 .vidioc_try_fmt_vbi_cap = bttv_try_fmt_vbi_cap,
3352 .vidioc_s_fmt_vbi_cap = bttv_s_fmt_vbi_cap, 3185 .vidioc_s_fmt_vbi_cap = bttv_s_fmt_vbi_cap,
3353 .vidioc_g_audio = bttv_g_audio,
3354 .vidioc_s_audio = bttv_s_audio,
3355 .vidioc_cropcap = bttv_cropcap, 3186 .vidioc_cropcap = bttv_cropcap,
3356 .vidioc_reqbufs = bttv_reqbufs, 3187 .vidioc_reqbufs = bttv_reqbufs,
3357 .vidioc_querybuf = bttv_querybuf, 3188 .vidioc_querybuf = bttv_querybuf,
3358 .vidioc_qbuf = bttv_qbuf, 3189 .vidioc_qbuf = bttv_qbuf,
3359 .vidioc_dqbuf = bttv_dqbuf, 3190 .vidioc_dqbuf = bttv_dqbuf,
3360 .vidioc_s_std = bttv_s_std, 3191 .vidioc_s_std = bttv_s_std,
3192 .vidioc_g_std = bttv_g_std,
3361 .vidioc_enum_input = bttv_enum_input, 3193 .vidioc_enum_input = bttv_enum_input,
3362 .vidioc_g_input = bttv_g_input, 3194 .vidioc_g_input = bttv_g_input,
3363 .vidioc_s_input = bttv_s_input, 3195 .vidioc_s_input = bttv_s_input,
3364 .vidioc_queryctrl = bttv_queryctrl,
3365 .vidioc_g_ctrl = bttv_g_ctrl,
3366 .vidioc_s_ctrl = bttv_s_ctrl,
3367 .vidioc_streamon = bttv_streamon, 3196 .vidioc_streamon = bttv_streamon,
3368 .vidioc_streamoff = bttv_streamoff, 3197 .vidioc_streamoff = bttv_streamoff,
3369 .vidioc_g_tuner = bttv_g_tuner, 3198 .vidioc_g_tuner = bttv_g_tuner,
@@ -3373,13 +3202,14 @@ static const struct v4l2_ioctl_ops bttv_ioctl_ops = {
3373 .vidioc_g_fbuf = bttv_g_fbuf, 3202 .vidioc_g_fbuf = bttv_g_fbuf,
3374 .vidioc_s_fbuf = bttv_s_fbuf, 3203 .vidioc_s_fbuf = bttv_s_fbuf,
3375 .vidioc_overlay = bttv_overlay, 3204 .vidioc_overlay = bttv_overlay,
3376 .vidioc_g_priority = bttv_g_priority,
3377 .vidioc_s_priority = bttv_s_priority,
3378 .vidioc_g_parm = bttv_g_parm, 3205 .vidioc_g_parm = bttv_g_parm,
3379 .vidioc_g_frequency = bttv_g_frequency, 3206 .vidioc_g_frequency = bttv_g_frequency,
3380 .vidioc_s_frequency = bttv_s_frequency, 3207 .vidioc_s_frequency = bttv_s_frequency,
3381 .vidioc_log_status = bttv_log_status, 3208 .vidioc_log_status = bttv_log_status,
3382 .vidioc_querystd = bttv_querystd, 3209 .vidioc_querystd = bttv_querystd,
3210 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
3211 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
3212 .vidioc_g_chip_ident = bttv_g_chip_ident,
3383#ifdef CONFIG_VIDEO_ADV_DEBUG 3213#ifdef CONFIG_VIDEO_ADV_DEBUG
3384 .vidioc_g_register = bttv_g_register, 3214 .vidioc_g_register = bttv_g_register,
3385 .vidioc_s_register = bttv_s_register, 3215 .vidioc_s_register = bttv_s_register,
@@ -3390,7 +3220,6 @@ static struct video_device bttv_video_template = {
3390 .fops = &bttv_fops, 3220 .fops = &bttv_fops,
3391 .ioctl_ops = &bttv_ioctl_ops, 3221 .ioctl_ops = &bttv_ioctl_ops,
3392 .tvnorms = BTTV_NORMS, 3222 .tvnorms = BTTV_NORMS,
3393 .current_norm = V4L2_STD_PAL,
3394}; 3223};
3395 3224
3396/* ----------------------------------------------------------------------- */ 3225/* ----------------------------------------------------------------------- */
@@ -3412,13 +3241,12 @@ static int radio_open(struct file *file)
3412 return -ENOMEM; 3241 return -ENOMEM;
3413 file->private_data = fh; 3242 file->private_data = fh;
3414 *fh = btv->init; 3243 *fh = btv->init;
3415 3244 v4l2_fh_init(&fh->fh, vdev);
3416 v4l2_prio_open(&btv->prio, &fh->prio);
3417 3245
3418 btv->radio_user++; 3246 btv->radio_user++;
3247 audio_mute(btv, btv->mute);
3419 3248
3420 bttv_call_all(btv, tuner, s_radio); 3249 v4l2_fh_add(&fh->fh);
3421 audio_input(btv,TVAUDIO_INPUT_RADIO);
3422 3250
3423 return 0; 3251 return 0;
3424} 3252}
@@ -3429,28 +3257,17 @@ static int radio_release(struct file *file)
3429 struct bttv *btv = fh->btv; 3257 struct bttv *btv = fh->btv;
3430 struct saa6588_command cmd; 3258 struct saa6588_command cmd;
3431 3259
3432 v4l2_prio_close(&btv->prio, fh->prio);
3433 file->private_data = NULL; 3260 file->private_data = NULL;
3261 v4l2_fh_del(&fh->fh);
3262 v4l2_fh_exit(&fh->fh);
3434 kfree(fh); 3263 kfree(fh);
3435 3264
3436 btv->radio_user--; 3265 btv->radio_user--;
3437 3266
3438 bttv_call_all(btv, core, ioctl, SAA6588_CMD_CLOSE, &cmd); 3267 bttv_call_all(btv, core, ioctl, SAA6588_CMD_CLOSE, &cmd);
3439 3268
3440 return 0; 3269 if (btv->radio_user == 0)
3441} 3270 btv->has_radio_tuner = 0;
3442
3443static int radio_querycap(struct file *file, void *priv,
3444 struct v4l2_capability *cap)
3445{
3446 struct bttv_fh *fh = priv;
3447 struct bttv *btv = fh->btv;
3448
3449 strcpy(cap->driver, "bttv");
3450 strlcpy(cap->card, btv->radio_dev->name, sizeof(cap->card));
3451 sprintf(cap->bus_info, "PCI:%s", pci_name(btv->c.pci));
3452 cap->capabilities = V4L2_CAP_TUNER;
3453
3454 return 0; 3271 return 0;
3455} 3272}
3456 3273
@@ -3459,12 +3276,11 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
3459 struct bttv_fh *fh = priv; 3276 struct bttv_fh *fh = priv;
3460 struct bttv *btv = fh->btv; 3277 struct bttv *btv = fh->btv;
3461 3278
3462 if (btv->tuner_type == TUNER_ABSENT)
3463 return -EINVAL;
3464 if (0 != t->index) 3279 if (0 != t->index)
3465 return -EINVAL; 3280 return -EINVAL;
3466 strcpy(t->name, "Radio"); 3281 strcpy(t->name, "Radio");
3467 t->type = V4L2_TUNER_RADIO; 3282 t->type = V4L2_TUNER_RADIO;
3283 radio_enable(btv);
3468 3284
3469 bttv_call_all(btv, tuner, g_tuner, t); 3285 bttv_call_all(btv, tuner, g_tuner, t);
3470 3286
@@ -3474,31 +3290,8 @@ static int radio_g_tuner(struct file *file, void *priv, struct v4l2_tuner *t)
3474 return 0; 3290 return 0;
3475} 3291}
3476 3292
3477static int radio_enum_input(struct file *file, void *priv,
3478 struct v4l2_input *i)
3479{
3480 if (i->index != 0)
3481 return -EINVAL;
3482
3483 strcpy(i->name, "Radio");
3484 i->type = V4L2_INPUT_TYPE_TUNER;
3485
3486 return 0;
3487}
3488
3489static int radio_g_audio(struct file *file, void *priv,
3490 struct v4l2_audio *a)
3491{
3492 if (unlikely(a->index))
3493 return -EINVAL;
3494
3495 strcpy(a->name, "Radio");
3496
3497 return 0;
3498}
3499
3500static int radio_s_tuner(struct file *file, void *priv, 3293static int radio_s_tuner(struct file *file, void *priv,
3501 struct v4l2_tuner *t) 3294 const struct v4l2_tuner *t)
3502{ 3295{
3503 struct bttv_fh *fh = priv; 3296 struct bttv_fh *fh = priv;
3504 struct bttv *btv = fh->btv; 3297 struct bttv *btv = fh->btv;
@@ -3506,56 +3299,11 @@ static int radio_s_tuner(struct file *file, void *priv,
3506 if (0 != t->index) 3299 if (0 != t->index)
3507 return -EINVAL; 3300 return -EINVAL;
3508 3301
3302 radio_enable(btv);
3509 bttv_call_all(btv, tuner, s_tuner, t); 3303 bttv_call_all(btv, tuner, s_tuner, t);
3510 return 0; 3304 return 0;
3511} 3305}
3512 3306
3513static int radio_s_audio(struct file *file, void *priv,
3514 const struct v4l2_audio *a)
3515{
3516 if (unlikely(a->index))
3517 return -EINVAL;
3518
3519 return 0;
3520}
3521
3522static int radio_s_input(struct file *filp, void *priv, unsigned int i)
3523{
3524 if (unlikely(i))
3525 return -EINVAL;
3526
3527 return 0;
3528}
3529
3530static int radio_s_std(struct file *file, void *fh, v4l2_std_id *norm)
3531{
3532 return 0;
3533}
3534
3535static int radio_queryctrl(struct file *file, void *priv,
3536 struct v4l2_queryctrl *c)
3537{
3538 const struct v4l2_queryctrl *ctrl;
3539
3540 if (c->id < V4L2_CID_BASE ||
3541 c->id >= V4L2_CID_LASTP1)
3542 return -EINVAL;
3543
3544 if (c->id == V4L2_CID_AUDIO_MUTE) {
3545 ctrl = ctrl_by_id(c->id);
3546 *c = *ctrl;
3547 } else
3548 *c = no_ctl;
3549
3550 return 0;
3551}
3552
3553static int radio_g_input(struct file *filp, void *priv, unsigned int *i)
3554{
3555 *i = 0;
3556 return 0;
3557}
3558
3559static ssize_t radio_read(struct file *file, char __user *data, 3307static ssize_t radio_read(struct file *file, char __user *data,
3560 size_t count, loff_t *ppos) 3308 size_t count, loff_t *ppos)
3561{ 3309{
@@ -3566,6 +3314,7 @@ static ssize_t radio_read(struct file *file, char __user *data,
3566 cmd.buffer = data; 3314 cmd.buffer = data;
3567 cmd.instance = file; 3315 cmd.instance = file;
3568 cmd.result = -ENODEV; 3316 cmd.result = -ENODEV;
3317 radio_enable(btv);
3569 3318
3570 bttv_call_all(btv, core, ioctl, SAA6588_CMD_READ, &cmd); 3319 bttv_call_all(btv, core, ioctl, SAA6588_CMD_READ, &cmd);
3571 3320
@@ -3576,10 +3325,18 @@ static unsigned int radio_poll(struct file *file, poll_table *wait)
3576{ 3325{
3577 struct bttv_fh *fh = file->private_data; 3326 struct bttv_fh *fh = file->private_data;
3578 struct bttv *btv = fh->btv; 3327 struct bttv *btv = fh->btv;
3328 unsigned long req_events = poll_requested_events(wait);
3579 struct saa6588_command cmd; 3329 struct saa6588_command cmd;
3330 unsigned int res = 0;
3331
3332 if (v4l2_event_pending(&fh->fh))
3333 res = POLLPRI;
3334 else if (req_events & POLLPRI)
3335 poll_wait(file, &fh->fh.wait, wait);
3336 radio_enable(btv);
3580 cmd.instance = file; 3337 cmd.instance = file;
3581 cmd.event_list = wait; 3338 cmd.event_list = wait;
3582 cmd.result = -ENODEV; 3339 cmd.result = res;
3583 bttv_call_all(btv, core, ioctl, SAA6588_CMD_POLL, &cmd); 3340 bttv_call_all(btv, core, ioctl, SAA6588_CMD_POLL, &cmd);
3584 3341
3585 return cmd.result; 3342 return cmd.result;
@@ -3596,20 +3353,14 @@ static const struct v4l2_file_operations radio_fops =
3596}; 3353};
3597 3354
3598static const struct v4l2_ioctl_ops radio_ioctl_ops = { 3355static const struct v4l2_ioctl_ops radio_ioctl_ops = {
3599 .vidioc_querycap = radio_querycap, 3356 .vidioc_querycap = bttv_querycap,
3357 .vidioc_log_status = bttv_log_status,
3600 .vidioc_g_tuner = radio_g_tuner, 3358 .vidioc_g_tuner = radio_g_tuner,
3601 .vidioc_enum_input = radio_enum_input,
3602 .vidioc_g_audio = radio_g_audio,
3603 .vidioc_s_tuner = radio_s_tuner, 3359 .vidioc_s_tuner = radio_s_tuner,
3604 .vidioc_s_audio = radio_s_audio,
3605 .vidioc_s_input = radio_s_input,
3606 .vidioc_s_std = radio_s_std,
3607 .vidioc_queryctrl = radio_queryctrl,
3608 .vidioc_g_input = radio_g_input,
3609 .vidioc_g_ctrl = bttv_g_ctrl,
3610 .vidioc_s_ctrl = bttv_s_ctrl,
3611 .vidioc_g_frequency = bttv_g_frequency, 3360 .vidioc_g_frequency = bttv_g_frequency,
3612 .vidioc_s_frequency = bttv_s_frequency, 3361 .vidioc_s_frequency = bttv_s_frequency,
3362 .vidioc_subscribe_event = v4l2_ctrl_subscribe_event,
3363 .vidioc_unsubscribe_event = v4l2_event_unsubscribe,
3613}; 3364};
3614 3365
3615static struct video_device radio_template = { 3366static struct video_device radio_template = {
@@ -4112,7 +3863,8 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
4112 bttv_irq_switch_video(btv); 3863 bttv_irq_switch_video(btv);
4113 3864
4114 if ((astat & BT848_INT_HLOCK) && btv->opt_automute) 3865 if ((astat & BT848_INT_HLOCK) && btv->opt_automute)
4115 audio_mute(btv, btv->mute); /* trigger automute */ 3866 /* trigger automute */
3867 audio_mux_gpio(btv, btv->audio_input, btv->mute);
4116 3868
4117 if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) { 3869 if (astat & (BT848_INT_SCERR|BT848_INT_OCERR)) {
4118 pr_info("%d: %s%s @ %08x,", 3870 pr_info("%d: %s%s @ %08x,",
@@ -4161,7 +3913,7 @@ static irqreturn_t bttv_irq(int irq, void *dev_id)
4161 3913
4162 3914
4163/* ----------------------------------------------------------------------- */ 3915/* ----------------------------------------------------------------------- */
4164/* initialitation */ 3916/* initialization */
4165 3917
4166static struct video_device *vdev_init(struct bttv *btv, 3918static struct video_device *vdev_init(struct bttv *btv,
4167 const struct video_device *template, 3919 const struct video_device *template,
@@ -4176,10 +3928,17 @@ static struct video_device *vdev_init(struct bttv *btv,
4176 vfd->v4l2_dev = &btv->c.v4l2_dev; 3928 vfd->v4l2_dev = &btv->c.v4l2_dev;
4177 vfd->release = video_device_release; 3929 vfd->release = video_device_release;
4178 vfd->debug = bttv_debug; 3930 vfd->debug = bttv_debug;
3931 set_bit(V4L2_FL_USE_FH_PRIO, &vfd->flags);
4179 video_set_drvdata(vfd, btv); 3932 video_set_drvdata(vfd, btv);
4180 snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)", 3933 snprintf(vfd->name, sizeof(vfd->name), "BT%d%s %s (%s)",
4181 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "", 3934 btv->id, (btv->id==848 && btv->revision==0x12) ? "A" : "",
4182 type_name, bttv_tvcards[btv->c.type].name); 3935 type_name, bttv_tvcards[btv->c.type].name);
3936 if (btv->tuner_type == TUNER_ABSENT) {
3937 v4l2_disable_ioctl(vfd, VIDIOC_G_FREQUENCY);
3938 v4l2_disable_ioctl(vfd, VIDIOC_S_FREQUENCY);
3939 v4l2_disable_ioctl(vfd, VIDIOC_G_TUNER);
3940 v4l2_disable_ioctl(vfd, VIDIOC_S_TUNER);
3941 }
4183 return vfd; 3942 return vfd;
4184} 3943}
4185 3944
@@ -4247,6 +4006,7 @@ static int bttv_register_video(struct bttv *btv)
4247 btv->radio_dev = vdev_init(btv, &radio_template, "radio"); 4006 btv->radio_dev = vdev_init(btv, &radio_template, "radio");
4248 if (NULL == btv->radio_dev) 4007 if (NULL == btv->radio_dev)
4249 goto err; 4008 goto err;
4009 btv->radio_dev->ctrl_handler = &btv->radio_ctrl_handler;
4250 if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO, 4010 if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO,
4251 radio_nr[btv->c.nr]) < 0) 4011 radio_nr[btv->c.nr]) < 0)
4252 goto err; 4012 goto err;
@@ -4277,9 +4037,15 @@ static void pci_set_command(struct pci_dev *dev)
4277 4037
4278static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id) 4038static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4279{ 4039{
4040 struct v4l2_frequency init_freq = {
4041 .tuner = 0,
4042 .type = V4L2_TUNER_ANALOG_TV,
4043 .frequency = 980,
4044 };
4280 int result; 4045 int result;
4281 unsigned char lat; 4046 unsigned char lat;
4282 struct bttv *btv; 4047 struct bttv *btv;
4048 struct v4l2_ctrl_handler *hdl;
4283 4049
4284 if (bttv_num == BTTV_MAX) 4050 if (bttv_num == BTTV_MAX)
4285 return -ENOMEM; 4051 return -ENOMEM;
@@ -4301,7 +4067,6 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4301 INIT_LIST_HEAD(&btv->c.subs); 4067 INIT_LIST_HEAD(&btv->c.subs);
4302 INIT_LIST_HEAD(&btv->capture); 4068 INIT_LIST_HEAD(&btv->capture);
4303 INIT_LIST_HEAD(&btv->vcapture); 4069 INIT_LIST_HEAD(&btv->vcapture);
4304 v4l2_prio_init(&btv->prio);
4305 4070
4306 init_timer(&btv->timeout); 4071 init_timer(&btv->timeout);
4307 btv->timeout.function = bttv_irq_timeout; 4072 btv->timeout.function = bttv_irq_timeout;
@@ -4339,6 +4104,10 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4339 pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr); 4104 pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr);
4340 goto fail0; 4105 goto fail0;
4341 } 4106 }
4107 hdl = &btv->ctrl_handler;
4108 v4l2_ctrl_handler_init(hdl, 20);
4109 btv->c.v4l2_dev.ctrl_handler = hdl;
4110 v4l2_ctrl_handler_init(&btv->radio_ctrl_handler, 6);
4342 4111
4343 btv->revision = dev->revision; 4112 btv->revision = dev->revision;
4344 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); 4113 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
@@ -4375,16 +4144,19 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4375 4144
4376 /* init options from insmod args */ 4145 /* init options from insmod args */
4377 btv->opt_combfilter = combfilter; 4146 btv->opt_combfilter = combfilter;
4378 btv->opt_lumafilter = lumafilter; 4147 bttv_ctrl_combfilter.def = combfilter;
4148 bttv_ctrl_lumafilter.def = lumafilter;
4379 btv->opt_automute = automute; 4149 btv->opt_automute = automute;
4380 btv->opt_chroma_agc = chroma_agc; 4150 bttv_ctrl_automute.def = automute;
4381 btv->opt_adc_crush = adc_crush; 4151 bttv_ctrl_agc_crush.def = agc_crush;
4382 btv->opt_vcr_hack = vcr_hack; 4152 btv->opt_vcr_hack = vcr_hack;
4383 btv->opt_whitecrush_upper = whitecrush_upper; 4153 bttv_ctrl_vcr_hack.def = vcr_hack;
4384 btv->opt_whitecrush_lower = whitecrush_lower; 4154 bttv_ctrl_whitecrush_upper.def = whitecrush_upper;
4155 bttv_ctrl_whitecrush_lower.def = whitecrush_lower;
4385 btv->opt_uv_ratio = uv_ratio; 4156 btv->opt_uv_ratio = uv_ratio;
4386 btv->opt_full_luma_range = full_luma_range; 4157 bttv_ctrl_uv_ratio.def = uv_ratio;
4387 btv->opt_coring = coring; 4158 bttv_ctrl_full_luma.def = full_luma_range;
4159 bttv_ctrl_coring.def = coring;
4388 4160
4389 /* fill struct bttv with some useful defaults */ 4161 /* fill struct bttv with some useful defaults */
4390 btv->init.btv = btv; 4162 btv->init.btv = btv;
@@ -4393,8 +4165,39 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4393 btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24); 4165 btv->init.fmt = format_by_fourcc(V4L2_PIX_FMT_BGR24);
4394 btv->init.width = 320; 4166 btv->init.width = 320;
4395 btv->init.height = 240; 4167 btv->init.height = 240;
4168 btv->init.ov.w.width = 320;
4169 btv->init.ov.w.height = 240;
4170 btv->init.ov.field = V4L2_FIELD_INTERLACED;
4396 btv->input = 0; 4171 btv->input = 0;
4397 4172
4173 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4174 V4L2_CID_BRIGHTNESS, 0, 0xff00, 0x100, 32768);
4175 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4176 V4L2_CID_CONTRAST, 0, 0xff80, 0x80, 0x6c00);
4177 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4178 V4L2_CID_SATURATION, 0, 0xff80, 0x80, 32768);
4179 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4180 V4L2_CID_COLOR_KILLER, 0, 1, 1, 0);
4181 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4182 V4L2_CID_HUE, 0, 0xff00, 0x100, 32768);
4183 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4184 V4L2_CID_CHROMA_AGC, 0, 1, 1, !!chroma_agc);
4185 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4186 V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
4187 if (btv->volume_gpio)
4188 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4189 V4L2_CID_AUDIO_VOLUME, 0, 0xff00, 0x100, 0xff00);
4190 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_combfilter, NULL);
4191 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_automute, NULL);
4192 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_lumafilter, NULL);
4193 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_agc_crush, NULL);
4194 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_vcr_hack, NULL);
4195 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_whitecrush_lower, NULL);
4196 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_whitecrush_upper, NULL);
4197 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_uv_ratio, NULL);
4198 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_full_luma, NULL);
4199 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_coring, NULL);
4200
4398 /* initialize hardware */ 4201 /* initialize hardware */
4399 if (bttv_gpio) 4202 if (bttv_gpio)
4400 bttv_gpio_tracking(btv,"pre-init"); 4203 bttv_gpio_tracking(btv,"pre-init");
@@ -4417,21 +4220,34 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4417 /* some card-specific stuff (needs working i2c) */ 4220 /* some card-specific stuff (needs working i2c) */
4418 bttv_init_card2(btv); 4221 bttv_init_card2(btv);
4419 bttv_init_tuner(btv); 4222 bttv_init_tuner(btv);
4223 if (btv->tuner_type != TUNER_ABSENT) {
4224 bttv_set_frequency(btv, &init_freq);
4225 btv->radio_freq = 90500 * 16; /* 90.5Mhz default */
4226 }
4227 btv->std = V4L2_STD_PAL;
4420 init_irqreg(btv); 4228 init_irqreg(btv);
4229 v4l2_ctrl_handler_setup(hdl);
4230 if (hdl->error) {
4231 result = hdl->error;
4232 goto fail2;
4233 }
4234 /* mute device */
4235 audio_mute(btv, 1);
4421 4236
4422 /* register video4linux + input */ 4237 /* register video4linux + input */
4423 if (!bttv_tvcards[btv->c.type].no_video) { 4238 if (!bttv_tvcards[btv->c.type].no_video) {
4424 bttv_register_video(btv); 4239 v4l2_ctrl_add_handler(&btv->radio_ctrl_handler, hdl,
4425 bt848_bright(btv,32768); 4240 v4l2_ctrl_radio_filter);
4426 bt848_contrast(btv, 27648); 4241 if (btv->radio_ctrl_handler.error) {
4427 bt848_hue(btv,32768); 4242 result = btv->radio_ctrl_handler.error;
4428 bt848_sat(btv,32768); 4243 goto fail2;
4429 audio_mute(btv, 1); 4244 }
4430 set_input(btv, 0, btv->tvnorm); 4245 set_input(btv, 0, btv->tvnorm);
4431 bttv_crop_reset(&btv->crop[0], btv->tvnorm); 4246 bttv_crop_reset(&btv->crop[0], btv->tvnorm);
4432 btv->crop[1] = btv->crop[0]; /* current = default */ 4247 btv->crop[1] = btv->crop[0]; /* current = default */
4433 disclaim_vbi_lines(btv); 4248 disclaim_vbi_lines(btv);
4434 disclaim_video_lines(btv); 4249 disclaim_video_lines(btv);
4250 bttv_register_video(btv);
4435 } 4251 }
4436 4252
4437 /* add subdevices and autoload dvb-bt8xx if needed */ 4253 /* add subdevices and autoload dvb-bt8xx if needed */
@@ -4453,6 +4269,8 @@ fail2:
4453 free_irq(btv->c.pci->irq,btv); 4269 free_irq(btv->c.pci->irq,btv);
4454 4270
4455fail1: 4271fail1:
4272 v4l2_ctrl_handler_free(&btv->ctrl_handler);
4273 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler);
4456 v4l2_device_unregister(&btv->c.v4l2_dev); 4274 v4l2_device_unregister(&btv->c.v4l2_dev);
4457 4275
4458fail0: 4276fail0:
@@ -4494,9 +4312,11 @@ static void bttv_remove(struct pci_dev *pci_dev)
4494 bttv_unregister_video(btv); 4312 bttv_unregister_video(btv);
4495 4313
4496 /* free allocated memory */ 4314 /* free allocated memory */
4315 v4l2_ctrl_handler_free(&btv->ctrl_handler);
4316 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler);
4497 btcx_riscmem_free(btv->c.pci,&btv->main); 4317 btcx_riscmem_free(btv->c.pci,&btv->main);
4498 4318
4499 /* free ressources */ 4319 /* free resources */
4500 free_irq(btv->c.pci->irq,btv); 4320 free_irq(btv->c.pci->irq,btv);
4501 iounmap(btv->bt848_mmio); 4321 iounmap(btv->bt848_mmio);
4502 release_mem_region(pci_resource_start(btv->c.pci,0), 4322 release_mem_region(pci_resource_start(btv->c.pci,0),
diff --git a/drivers/media/pci/bt8xx/bttv-i2c.c b/drivers/media/pci/bt8xx/bttv-i2c.c
index c63c643ed1f8..b7c52dc8999c 100644
--- a/drivers/media/pci/bt8xx/bttv-i2c.c
+++ b/drivers/media/pci/bt8xx/bttv-i2c.c
@@ -394,3 +394,11 @@ int init_bttv_i2c(struct bttv *btv)
394 394
395 return btv->i2c_rc; 395 return btv->i2c_rc;
396} 396}
397
398int fini_bttv_i2c(struct bttv *btv)
399{
400 if (0 != btv->i2c_rc)
401 return 0;
402
403 return i2c_del_adapter(&btv->c.i2c_adap);
404}
diff --git a/drivers/media/pci/bt8xx/bttv-input.c b/drivers/media/pci/bt8xx/bttv-input.c
index 04207a799055..f36821367d8d 100644
--- a/drivers/media/pci/bt8xx/bttv-input.c
+++ b/drivers/media/pci/bt8xx/bttv-input.c
@@ -375,6 +375,7 @@ void init_bttv_i2c_ir(struct bttv *btv)
375 I2C_CLIENT_END 375 I2C_CLIENT_END
376 }; 376 };
377 struct i2c_board_info info; 377 struct i2c_board_info info;
378 struct i2c_client *i2c_dev;
378 379
379 if (0 != btv->i2c_rc) 380 if (0 != btv->i2c_rc)
380 return; 381 return;
@@ -390,7 +391,12 @@ void init_bttv_i2c_ir(struct bttv *btv)
390 btv->init_data.ir_codes = RC_MAP_PV951; 391 btv->init_data.ir_codes = RC_MAP_PV951;
391 info.addr = 0x4b; 392 info.addr = 0x4b;
392 break; 393 break;
393 default: 394 }
395
396 if (btv->init_data.name) {
397 info.platform_data = &btv->init_data;
398 i2c_dev = i2c_new_device(&btv->c.i2c_adap, &info);
399 } else {
394 /* 400 /*
395 * The external IR receiver is at i2c address 0x34 (0x35 for 401 * The external IR receiver is at i2c address 0x34 (0x35 for
396 * reads). Future Hauppauge cards will have an internal 402 * reads). Future Hauppauge cards will have an internal
@@ -399,24 +405,14 @@ void init_bttv_i2c_ir(struct bttv *btv)
399 * internal. 405 * internal.
400 * That's why we probe 0x1a (~0x34) first. CB 406 * That's why we probe 0x1a (~0x34) first. CB
401 */ 407 */
402 408 i2c_dev = i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL);
403 i2c_new_probed_device(&btv->c.i2c_adap, &info, addr_list, NULL);
404 return;
405 } 409 }
410 if (NULL == i2c_dev)
411 return;
406 412
407 if (btv->init_data.name) 413#if defined(CONFIG_MODULES) && defined(MODULE)
408 info.platform_data = &btv->init_data; 414 request_module("ir-kbd-i2c");
409 i2c_new_device(&btv->c.i2c_adap, &info); 415#endif
410
411 return;
412}
413
414int fini_bttv_i2c(struct bttv *btv)
415{
416 if (0 != btv->i2c_rc)
417 return 0;
418
419 return i2c_del_adapter(&btv->c.i2c_adap);
420} 416}
421 417
422int bttv_input_init(struct bttv *btv) 418int bttv_input_init(struct bttv *btv)
diff --git a/drivers/media/pci/bt8xx/bttv.h b/drivers/media/pci/bt8xx/bttv.h
index 79a11240a590..6139ce26dc2c 100644
--- a/drivers/media/pci/bt8xx/bttv.h
+++ b/drivers/media/pci/bt8xx/bttv.h
@@ -359,6 +359,9 @@ void bttv_gpio_bits(struct bttv_core *core, u32 mask, u32 bits);
359#define bttv_call_all(btv, o, f, args...) \ 359#define bttv_call_all(btv, o, f, args...) \
360 v4l2_device_call_all(&btv->c.v4l2_dev, 0, o, f, ##args) 360 v4l2_device_call_all(&btv->c.v4l2_dev, 0, o, f, ##args)
361 361
362#define bttv_call_all_err(btv, o, f, args...) \
363 v4l2_device_call_until_err(&btv->c.v4l2_dev, 0, o, f, ##args)
364
362extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for); 365extern int bttv_I2CRead(struct bttv *btv, unsigned char addr, char *probe_for);
363extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1, 366extern int bttv_I2CWrite(struct bttv *btv, unsigned char addr, unsigned char b1,
364 unsigned char b2, int both); 367 unsigned char b2, int both);
diff --git a/drivers/media/pci/bt8xx/bttvp.h b/drivers/media/pci/bt8xx/bttvp.h
index 9ec0adba236c..9c1cc2c50ee2 100644
--- a/drivers/media/pci/bt8xx/bttvp.h
+++ b/drivers/media/pci/bt8xx/bttvp.h
@@ -33,9 +33,11 @@
33#include <linux/input.h> 33#include <linux/input.h>
34#include <linux/mutex.h> 34#include <linux/mutex.h>
35#include <linux/scatterlist.h> 35#include <linux/scatterlist.h>
36#include <linux/device.h>
36#include <asm/io.h> 37#include <asm/io.h>
37#include <media/v4l2-common.h> 38#include <media/v4l2-common.h>
38#include <linux/device.h> 39#include <media/v4l2-ctrls.h>
40#include <media/v4l2-fh.h>
39#include <media/videobuf-dma-sg.h> 41#include <media/videobuf-dma-sg.h>
40#include <media/tveeprom.h> 42#include <media/tveeprom.h>
41#include <media/rc-core.h> 43#include <media/rc-core.h>
@@ -214,11 +216,11 @@ struct bttv_crop {
214}; 216};
215 217
216struct bttv_fh { 218struct bttv_fh {
219 /* This must be the first field in this struct */
220 struct v4l2_fh fh;
221
217 struct bttv *btv; 222 struct bttv *btv;
218 int resources; 223 int resources;
219#ifdef VIDIOC_G_PRIORITY
220 enum v4l2_priority prio;
221#endif
222 enum v4l2_buf_type type; 224 enum v4l2_buf_type type;
223 225
224 /* video capture */ 226 /* video capture */
@@ -298,6 +300,10 @@ extern int no_overlay;
298/* bttv-input.c */ 300/* bttv-input.c */
299 301
300extern void init_bttv_i2c_ir(struct bttv *btv); 302extern void init_bttv_i2c_ir(struct bttv *btv);
303
304/* ---------------------------------------------------------- */
305/* bttv-i2c.c */
306extern int init_bttv_i2c(struct bttv *btv);
301extern int fini_bttv_i2c(struct bttv *btv); 307extern int fini_bttv_i2c(struct bttv *btv);
302 308
303/* ---------------------------------------------------------- */ 309/* ---------------------------------------------------------- */
@@ -308,7 +314,6 @@ extern unsigned int bttv_verbose;
308extern unsigned int bttv_debug; 314extern unsigned int bttv_debug;
309extern unsigned int bttv_gpio; 315extern unsigned int bttv_gpio;
310extern void bttv_gpio_tracking(struct bttv *btv, char *comment); 316extern void bttv_gpio_tracking(struct bttv *btv, char *comment);
311extern int init_bttv_i2c(struct bttv *btv);
312 317
313#define dprintk(fmt, ...) \ 318#define dprintk(fmt, ...) \
314do { \ 319do { \
@@ -393,12 +398,17 @@ struct bttv {
393 wait_queue_head_t i2c_queue; 398 wait_queue_head_t i2c_queue;
394 struct v4l2_subdev *sd_msp34xx; 399 struct v4l2_subdev *sd_msp34xx;
395 struct v4l2_subdev *sd_tvaudio; 400 struct v4l2_subdev *sd_tvaudio;
401 struct v4l2_subdev *sd_tda7432;
396 402
397 /* video4linux (1) */ 403 /* video4linux (1) */
398 struct video_device *video_dev; 404 struct video_device *video_dev;
399 struct video_device *radio_dev; 405 struct video_device *radio_dev;
400 struct video_device *vbi_dev; 406 struct video_device *vbi_dev;
401 407
408 /* controls */
409 struct v4l2_ctrl_handler ctrl_handler;
410 struct v4l2_ctrl_handler radio_ctrl_handler;
411
402 /* infrared remote */ 412 /* infrared remote */
403 int has_remote; 413 int has_remote;
404 struct bttv_ir *remote; 414 struct bttv_ir *remote;
@@ -410,38 +420,30 @@ struct bttv {
410 spinlock_t s_lock; 420 spinlock_t s_lock;
411 struct mutex lock; 421 struct mutex lock;
412 int resources; 422 int resources;
413#ifdef VIDIOC_G_PRIORITY
414 struct v4l2_prio_state prio;
415#endif
416 423
417 /* video state */ 424 /* video state */
418 unsigned int input; 425 unsigned int input;
419 unsigned int audio; 426 unsigned int audio_input;
420 unsigned int mute; 427 unsigned int mute;
421 unsigned long freq; 428 unsigned long tv_freq;
422 unsigned int tvnorm; 429 unsigned int tvnorm;
430 v4l2_std_id std;
423 int hue, contrast, bright, saturation; 431 int hue, contrast, bright, saturation;
424 struct v4l2_framebuffer fbuf; 432 struct v4l2_framebuffer fbuf;
425 unsigned int field_count; 433 unsigned int field_count;
426 434
427 /* various options */ 435 /* various options */
428 int opt_combfilter; 436 int opt_combfilter;
429 int opt_lumafilter;
430 int opt_automute; 437 int opt_automute;
431 int opt_chroma_agc;
432 int opt_color_killer;
433 int opt_adc_crush;
434 int opt_vcr_hack; 438 int opt_vcr_hack;
435 int opt_whitecrush_upper;
436 int opt_whitecrush_lower;
437 int opt_uv_ratio; 439 int opt_uv_ratio;
438 int opt_full_luma_range;
439 int opt_coring;
440 440
441 /* radio data/state */ 441 /* radio data/state */
442 int has_radio; 442 int has_radio;
443 int has_radio_tuner;
443 int radio_user; 444 int radio_user;
444 int radio_uses_msp_demodulator; 445 int radio_uses_msp_demodulator;
446 unsigned long radio_freq;
445 447
446 /* miro/pinnacle + Aimslab VHX 448 /* miro/pinnacle + Aimslab VHX
447 philips matchbox (tea5757 radio tuner) support */ 449 philips matchbox (tea5757 radio tuner) support */