aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHans Verkuil <hans.verkuil@cisco.com>2013-02-06 10:40:28 -0500
committerMauro Carvalho Chehab <mchehab@redhat.com>2013-03-05 12:12:05 -0500
commit01df530c2791610727e345b3dd97ef75943c7320 (patch)
treec0e6588230df2335afe4ff6a9bd4fc59e635ede2
parent5d478e0de87113b9fa6b4021935e605b71e0ee28 (diff)
[media] bttv: convert to the control framework
Note that the private chroma agc control has been replaced with the standard CHROMA_AGC control. Also fixes a mute/automute problem where closing the file handle would force mute on. That's not what you want since that would make the mute state out of sync with the mute control. Instead check against the user count. Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
-rw-r--r--drivers/media/pci/bt8xx/bttv-cards.c5
-rw-r--r--drivers/media/pci/bt8xx/bttv-driver.c682
-rw-r--r--drivers/media/pci/bt8xx/bttvp.h16
-rw-r--r--include/uapi/linux/v4l2-controls.h5
4 files changed, 271 insertions, 437 deletions
diff --git a/drivers/media/pci/bt8xx/bttv-cards.c b/drivers/media/pci/bt8xx/bttv-cards.c
index c4c59175e52c..682ed893d718 100644
--- a/drivers/media/pci/bt8xx/bttv-cards.c
+++ b/drivers/media/pci/bt8xx/bttv-cards.c
@@ -3554,8 +3554,9 @@ void bttv_init_card2(struct bttv *btv)
3554 I2C_CLIENT_END 3554 I2C_CLIENT_END
3555 }; 3555 };
3556 3556
3557 if (v4l2_i2c_new_subdev(&btv->c.v4l2_dev, 3557 btv->sd_tda7432 = v4l2_i2c_new_subdev(&btv->c.v4l2_dev,
3558 &btv->c.i2c_adap, "tda7432", 0, addrs)) 3558 &btv->c.i2c_adap, "tda7432", 0, addrs);
3559 if (btv->sd_tda7432)
3559 return; 3560 return;
3560 } 3561 }
3561 3562
diff --git a/drivers/media/pci/bt8xx/bttv-driver.c b/drivers/media/pci/bt8xx/bttv-driver.c
index 73404b7a1396..8e0a44d03fc4 100644
--- a/drivers/media/pci/bt8xx/bttv-driver.c
+++ b/drivers/media/pci/bt8xx/bttv-driver.c
@@ -94,7 +94,7 @@ static unsigned int combfilter;
94static unsigned int lumafilter; 94static unsigned int lumafilter;
95static unsigned int automute = 1; 95static unsigned int automute = 1;
96static unsigned int chroma_agc; 96static unsigned int chroma_agc;
97static unsigned int adc_crush = 1; 97static unsigned int agc_crush = 1;
98static unsigned int whitecrush_upper = 0xCF; 98static unsigned int whitecrush_upper = 0xCF;
99static unsigned int whitecrush_lower = 0x7F; 99static unsigned int whitecrush_lower = 0x7F;
100static unsigned int vcr_hack; 100static unsigned int vcr_hack;
@@ -126,7 +126,7 @@ module_param(combfilter, int, 0444);
126module_param(lumafilter, int, 0444); 126module_param(lumafilter, int, 0444);
127module_param(automute, int, 0444); 127module_param(automute, int, 0444);
128module_param(chroma_agc, int, 0444); 128module_param(chroma_agc, int, 0444);
129module_param(adc_crush, int, 0444); 129module_param(agc_crush, int, 0444);
130module_param(whitecrush_upper, int, 0444); 130module_param(whitecrush_upper, int, 0444);
131module_param(whitecrush_lower, int, 0444); 131module_param(whitecrush_lower, int, 0444);
132module_param(vcr_hack, int, 0444); 132module_param(vcr_hack, int, 0444);
@@ -139,27 +139,27 @@ module_param_array(video_nr, int, NULL, 0444);
139module_param_array(radio_nr, int, NULL, 0444); 139module_param_array(radio_nr, int, NULL, 0444);
140module_param_array(vbi_nr, int, NULL, 0444); 140module_param_array(vbi_nr, int, NULL, 0444);
141 141
142MODULE_PARM_DESC(radio,"The TV card supports radio, default is 0 (no)"); 142MODULE_PARM_DESC(radio, "The TV card supports radio, default is 0 (no)");
143MODULE_PARM_DESC(bigendian,"byte order of the framebuffer, default is native endian"); 143MODULE_PARM_DESC(bigendian, "byte order of the framebuffer, default is native endian");
144MODULE_PARM_DESC(bttv_verbose,"verbose startup messages, default is 1 (yes)"); 144MODULE_PARM_DESC(bttv_verbose, "verbose startup messages, default is 1 (yes)");
145MODULE_PARM_DESC(bttv_gpio,"log gpio changes, default is 0 (no)"); 145MODULE_PARM_DESC(bttv_gpio, "log gpio changes, default is 0 (no)");
146MODULE_PARM_DESC(bttv_debug,"debug messages, default is 0 (no)"); 146MODULE_PARM_DESC(bttv_debug, "debug messages, default is 0 (no)");
147MODULE_PARM_DESC(irq_debug,"irq handler debug messages, default is 0 (no)"); 147MODULE_PARM_DESC(irq_debug, "irq handler debug messages, default is 0 (no)");
148MODULE_PARM_DESC(disable_ir, "disable infrared remote support"); 148MODULE_PARM_DESC(disable_ir, "disable infrared remote support");
149MODULE_PARM_DESC(gbuffers,"number of capture buffers. range 2-32, default 8"); 149MODULE_PARM_DESC(gbuffers, "number of capture buffers. range 2-32, default 8");
150MODULE_PARM_DESC(gbufsize,"size of the capture buffers, default is 0x208000"); 150MODULE_PARM_DESC(gbufsize, "size of the capture buffers, default is 0x208000");
151MODULE_PARM_DESC(reset_crop,"reset cropping parameters at open(), default " 151MODULE_PARM_DESC(reset_crop, "reset cropping parameters at open(), default "
152 "is 1 (yes) for compatibility with older applications"); 152 "is 1 (yes) for compatibility with older applications");
153MODULE_PARM_DESC(automute,"mute audio on bad/missing video signal, default is 1 (yes)"); 153MODULE_PARM_DESC(automute, "mute audio on bad/missing video signal, default is 1 (yes)");
154MODULE_PARM_DESC(chroma_agc,"enables the AGC of chroma signal, default is 0 (no)"); 154MODULE_PARM_DESC(chroma_agc, "enables the AGC of chroma signal, default is 0 (no)");
155MODULE_PARM_DESC(adc_crush,"enables the luminance ADC crush, default is 1 (yes)"); 155MODULE_PARM_DESC(agc_crush, "enables the luminance AGC crush, default is 1 (yes)");
156MODULE_PARM_DESC(whitecrush_upper,"sets the white crush upper value, default is 207"); 156MODULE_PARM_DESC(whitecrush_upper, "sets the white crush upper value, default is 207");
157MODULE_PARM_DESC(whitecrush_lower,"sets the white crush lower value, default is 127"); 157MODULE_PARM_DESC(whitecrush_lower, "sets the white crush lower value, default is 127");
158MODULE_PARM_DESC(vcr_hack,"enables the VCR hack (improves synch on poor VCR tapes), default is 0 (no)"); 158MODULE_PARM_DESC(vcr_hack, "enables the VCR hack (improves synch on poor VCR tapes), default is 0 (no)");
159MODULE_PARM_DESC(irq_iswitch,"switch inputs in irq handler"); 159MODULE_PARM_DESC(irq_iswitch, "switch inputs in irq handler");
160MODULE_PARM_DESC(uv_ratio,"ratio between u and v gains, default is 50"); 160MODULE_PARM_DESC(uv_ratio, "ratio between u and v gains, default is 50");
161MODULE_PARM_DESC(full_luma_range,"use the full luma range, default is 0 (no)"); 161MODULE_PARM_DESC(full_luma_range, "use the full luma range, default is 0 (no)");
162MODULE_PARM_DESC(coring,"set the luma coring level, default is 0 (no)"); 162MODULE_PARM_DESC(coring, "set the luma coring level, default is 0 (no)");
163MODULE_PARM_DESC(video_nr, "video device numbers"); 163MODULE_PARM_DESC(video_nr, "video device numbers");
164MODULE_PARM_DESC(vbi_nr, "vbi device numbers"); 164MODULE_PARM_DESC(vbi_nr, "vbi device numbers");
165MODULE_PARM_DESC(radio_nr, "radio device numbers"); 165MODULE_PARM_DESC(radio_nr, "radio device numbers");
@@ -169,6 +169,17 @@ MODULE_AUTHOR("Ralph Metzler & Marcus Metzler & Gerd Knorr");
169MODULE_LICENSE("GPL"); 169MODULE_LICENSE("GPL");
170MODULE_VERSION(BTTV_VERSION); 170MODULE_VERSION(BTTV_VERSION);
171 171
172#define V4L2_CID_PRIVATE_COMBFILTER (V4L2_CID_USER_BTTV_BASE + 0)
173#define V4L2_CID_PRIVATE_AUTOMUTE (V4L2_CID_USER_BTTV_BASE + 1)
174#define V4L2_CID_PRIVATE_LUMAFILTER (V4L2_CID_USER_BTTV_BASE + 2)
175#define V4L2_CID_PRIVATE_AGC_CRUSH (V4L2_CID_USER_BTTV_BASE + 3)
176#define V4L2_CID_PRIVATE_VCR_HACK (V4L2_CID_USER_BTTV_BASE + 4)
177#define V4L2_CID_PRIVATE_WHITECRUSH_LOWER (V4L2_CID_USER_BTTV_BASE + 5)
178#define V4L2_CID_PRIVATE_WHITECRUSH_UPPER (V4L2_CID_USER_BTTV_BASE + 6)
179#define V4L2_CID_PRIVATE_UV_RATIO (V4L2_CID_USER_BTTV_BASE + 7)
180#define V4L2_CID_PRIVATE_FULL_LUMA_RANGE (V4L2_CID_USER_BTTV_BASE + 8)
181#define V4L2_CID_PRIVATE_CORING (V4L2_CID_USER_BTTV_BASE + 9)
182
172/* ----------------------------------------------------------------------- */ 183/* ----------------------------------------------------------------------- */
173/* sysfs */ 184/* sysfs */
174 185
@@ -623,198 +634,6 @@ static const struct bttv_format formats[] = {
623static const unsigned int FORMATS = ARRAY_SIZE(formats); 634static const unsigned int FORMATS = ARRAY_SIZE(formats);
624 635
625/* ----------------------------------------------------------------------- */ 636/* ----------------------------------------------------------------------- */
626
627#define V4L2_CID_PRIVATE_CHROMA_AGC (V4L2_CID_PRIVATE_BASE + 0)
628#define V4L2_CID_PRIVATE_COMBFILTER (V4L2_CID_PRIVATE_BASE + 1)
629#define V4L2_CID_PRIVATE_AUTOMUTE (V4L2_CID_PRIVATE_BASE + 2)
630#define V4L2_CID_PRIVATE_LUMAFILTER (V4L2_CID_PRIVATE_BASE + 3)
631#define V4L2_CID_PRIVATE_AGC_CRUSH (V4L2_CID_PRIVATE_BASE + 4)
632#define V4L2_CID_PRIVATE_VCR_HACK (V4L2_CID_PRIVATE_BASE + 5)
633#define V4L2_CID_PRIVATE_WHITECRUSH_UPPER (V4L2_CID_PRIVATE_BASE + 6)
634#define V4L2_CID_PRIVATE_WHITECRUSH_LOWER (V4L2_CID_PRIVATE_BASE + 7)
635#define V4L2_CID_PRIVATE_UV_RATIO (V4L2_CID_PRIVATE_BASE + 8)
636#define V4L2_CID_PRIVATE_FULL_LUMA_RANGE (V4L2_CID_PRIVATE_BASE + 9)
637#define V4L2_CID_PRIVATE_CORING (V4L2_CID_PRIVATE_BASE + 10)
638#define V4L2_CID_PRIVATE_LASTP1 (V4L2_CID_PRIVATE_BASE + 11)
639
640static const struct v4l2_queryctrl no_ctl = {
641 .name = "42",
642 .flags = V4L2_CTRL_FLAG_DISABLED,
643};
644static const struct v4l2_queryctrl bttv_ctls[] = {
645 /* --- video --- */
646 {
647 .id = V4L2_CID_BRIGHTNESS,
648 .name = "Brightness",
649 .minimum = 0,
650 .maximum = 65535,
651 .step = 256,
652 .default_value = 32768,
653 .type = V4L2_CTRL_TYPE_INTEGER,
654 },{
655 .id = V4L2_CID_CONTRAST,
656 .name = "Contrast",
657 .minimum = 0,
658 .maximum = 65535,
659 .step = 128,
660 .default_value = 27648,
661 .type = V4L2_CTRL_TYPE_INTEGER,
662 },{
663 .id = V4L2_CID_SATURATION,
664 .name = "Saturation",
665 .minimum = 0,
666 .maximum = 65535,
667 .step = 128,
668 .default_value = 32768,
669 .type = V4L2_CTRL_TYPE_INTEGER,
670 },{
671 .id = V4L2_CID_COLOR_KILLER,
672 .name = "Color killer",
673 .minimum = 0,
674 .maximum = 1,
675 .type = V4L2_CTRL_TYPE_BOOLEAN,
676 }, {
677 .id = V4L2_CID_HUE,
678 .name = "Hue",
679 .minimum = 0,
680 .maximum = 65535,
681 .step = 256,
682 .default_value = 32768,
683 .type = V4L2_CTRL_TYPE_INTEGER,
684 },
685 /* --- audio --- */
686 {
687 .id = V4L2_CID_AUDIO_MUTE,
688 .name = "Mute",
689 .minimum = 0,
690 .maximum = 1,
691 .type = V4L2_CTRL_TYPE_BOOLEAN,
692 },{
693 .id = V4L2_CID_AUDIO_VOLUME,
694 .name = "Volume",
695 .minimum = 0,
696 .maximum = 65535,
697 .step = 65535/100,
698 .default_value = 65535,
699 .type = V4L2_CTRL_TYPE_INTEGER,
700 },{
701 .id = V4L2_CID_AUDIO_BALANCE,
702 .name = "Balance",
703 .minimum = 0,
704 .maximum = 65535,
705 .step = 65535/100,
706 .default_value = 32768,
707 .type = V4L2_CTRL_TYPE_INTEGER,
708 },{
709 .id = V4L2_CID_AUDIO_BASS,
710 .name = "Bass",
711 .minimum = 0,
712 .maximum = 65535,
713 .step = 65535/100,
714 .default_value = 32768,
715 .type = V4L2_CTRL_TYPE_INTEGER,
716 },{
717 .id = V4L2_CID_AUDIO_TREBLE,
718 .name = "Treble",
719 .minimum = 0,
720 .maximum = 65535,
721 .step = 65535/100,
722 .default_value = 32768,
723 .type = V4L2_CTRL_TYPE_INTEGER,
724 },
725 /* --- private --- */
726 {
727 .id = V4L2_CID_PRIVATE_CHROMA_AGC,
728 .name = "chroma agc",
729 .minimum = 0,
730 .maximum = 1,
731 .type = V4L2_CTRL_TYPE_BOOLEAN,
732 },{
733 .id = V4L2_CID_PRIVATE_COMBFILTER,
734 .name = "combfilter",
735 .minimum = 0,
736 .maximum = 1,
737 .type = V4L2_CTRL_TYPE_BOOLEAN,
738 },{
739 .id = V4L2_CID_PRIVATE_AUTOMUTE,
740 .name = "automute",
741 .minimum = 0,
742 .maximum = 1,
743 .type = V4L2_CTRL_TYPE_BOOLEAN,
744 },{
745 .id = V4L2_CID_PRIVATE_LUMAFILTER,
746 .name = "luma decimation filter",
747 .minimum = 0,
748 .maximum = 1,
749 .type = V4L2_CTRL_TYPE_BOOLEAN,
750 },{
751 .id = V4L2_CID_PRIVATE_AGC_CRUSH,
752 .name = "agc crush",
753 .minimum = 0,
754 .maximum = 1,
755 .type = V4L2_CTRL_TYPE_BOOLEAN,
756 },{
757 .id = V4L2_CID_PRIVATE_VCR_HACK,
758 .name = "vcr hack",
759 .minimum = 0,
760 .maximum = 1,
761 .type = V4L2_CTRL_TYPE_BOOLEAN,
762 },{
763 .id = V4L2_CID_PRIVATE_WHITECRUSH_UPPER,
764 .name = "whitecrush upper",
765 .minimum = 0,
766 .maximum = 255,
767 .step = 1,
768 .default_value = 0xCF,
769 .type = V4L2_CTRL_TYPE_INTEGER,
770 },{
771 .id = V4L2_CID_PRIVATE_WHITECRUSH_LOWER,
772 .name = "whitecrush lower",
773 .minimum = 0,
774 .maximum = 255,
775 .step = 1,
776 .default_value = 0x7F,
777 .type = V4L2_CTRL_TYPE_INTEGER,
778 },{
779 .id = V4L2_CID_PRIVATE_UV_RATIO,
780 .name = "uv ratio",
781 .minimum = 0,
782 .maximum = 100,
783 .step = 1,
784 .default_value = 50,
785 .type = V4L2_CTRL_TYPE_INTEGER,
786 },{
787 .id = V4L2_CID_PRIVATE_FULL_LUMA_RANGE,
788 .name = "full luma range",
789 .minimum = 0,
790 .maximum = 1,
791 .type = V4L2_CTRL_TYPE_BOOLEAN,
792 },{
793 .id = V4L2_CID_PRIVATE_CORING,
794 .name = "coring",
795 .minimum = 0,
796 .maximum = 3,
797 .step = 1,
798 .default_value = 0,
799 .type = V4L2_CTRL_TYPE_INTEGER,
800 }
801
802
803
804};
805
806static const struct v4l2_queryctrl *ctrl_by_id(int id)
807{
808 int i;
809
810 for (i = 0; i < ARRAY_SIZE(bttv_ctls); i++)
811 if (bttv_ctls[i].id == id)
812 return bttv_ctls+i;
813
814 return NULL;
815}
816
817/* ----------------------------------------------------------------------- */
818/* resource management */ 637/* resource management */
819 638
820/* 639/*
@@ -1173,7 +992,7 @@ static int
1173audio_mux(struct bttv *btv, int input, int mute) 992audio_mux(struct bttv *btv, int input, int mute)
1174{ 993{
1175 int gpio_val, signal; 994 int gpio_val, signal;
1176 struct v4l2_control ctrl; 995 struct v4l2_ctrl *ctrl;
1177 996
1178 gpio_inout(bttv_tvcards[btv->c.type].gpiomask, 997 gpio_inout(bttv_tvcards[btv->c.type].gpiomask,
1179 bttv_tvcards[btv->c.type].gpiomask); 998 bttv_tvcards[btv->c.type].gpiomask);
@@ -1183,7 +1002,8 @@ audio_mux(struct bttv *btv, int input, int mute)
1183 btv->audio = input; 1002 btv->audio = input;
1184 1003
1185 /* automute */ 1004 /* automute */
1186 mute = mute || (btv->opt_automute && !signal && !btv->radio_user); 1005 mute = mute || (btv->opt_automute && (!signal || !btv->users)
1006 && !btv->radio_user);
1187 1007
1188 if (mute) 1008 if (mute)
1189 gpio_val = bttv_tvcards[btv->c.type].gpiomute; 1009 gpio_val = bttv_tvcards[btv->c.type].gpiomute;
@@ -1205,12 +1025,13 @@ audio_mux(struct bttv *btv, int input, int mute)
1205 if (in_interrupt()) 1025 if (in_interrupt())
1206 return 0; 1026 return 0;
1207 1027
1208 ctrl.id = V4L2_CID_AUDIO_MUTE;
1209 ctrl.value = btv->mute;
1210 bttv_call_all(btv, core, s_ctrl, &ctrl);
1211 if (btv->sd_msp34xx) { 1028 if (btv->sd_msp34xx) {
1212 u32 in; 1029 u32 in;
1213 1030
1031 ctrl = v4l2_ctrl_find(btv->sd_msp34xx->ctrl_handler, V4L2_CID_AUDIO_MUTE);
1032 if (ctrl)
1033 v4l2_ctrl_s_ctrl(ctrl, btv->mute);
1034
1214 /* Note: the inputs tuner/radio/extern/intern are translated 1035 /* Note: the inputs tuner/radio/extern/intern are translated
1215 to msp routings. This assumes common behavior for all msp3400 1036 to msp routings. This assumes common behavior for all msp3400
1216 based TV cards. When this assumption fails, then the 1037 based TV cards. When this assumption fails, then the
@@ -1255,9 +1076,19 @@ audio_mux(struct bttv *btv, int input, int mute)
1255 in, MSP_OUTPUT_DEFAULT, 0); 1076 in, MSP_OUTPUT_DEFAULT, 0);
1256 } 1077 }
1257 if (btv->sd_tvaudio) { 1078 if (btv->sd_tvaudio) {
1079 ctrl = v4l2_ctrl_find(btv->sd_tvaudio->ctrl_handler, V4L2_CID_AUDIO_MUTE);
1080
1081 if (ctrl)
1082 v4l2_ctrl_s_ctrl(ctrl, btv->mute);
1258 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing, 1083 v4l2_subdev_call(btv->sd_tvaudio, audio, s_routing,
1259 input, 0, 0); 1084 input, 0, 0);
1260 } 1085 }
1086 if (btv->sd_tda7432) {
1087 ctrl = v4l2_ctrl_find(btv->sd_tda7432->ctrl_handler, V4L2_CID_AUDIO_MUTE);
1088
1089 if (ctrl)
1090 v4l2_ctrl_s_ctrl(ctrl, btv->mute);
1091 }
1261 return 0; 1092 return 0;
1262} 1093}
1263 1094
@@ -1395,8 +1226,6 @@ static void init_irqreg(struct bttv *btv)
1395 1226
1396static void init_bt848(struct bttv *btv) 1227static void init_bt848(struct bttv *btv)
1397{ 1228{
1398 int val;
1399
1400 if (bttv_tvcards[btv->c.type].no_video) { 1229 if (bttv_tvcards[btv->c.type].no_video) {
1401 /* very basic init only */ 1230 /* very basic init only */
1402 init_irqreg(btv); 1231 init_irqreg(btv);
@@ -1416,30 +1245,10 @@ static void init_bt848(struct bttv *btv)
1416 BT848_GPIO_DMA_CTL_GPINTI, 1245 BT848_GPIO_DMA_CTL_GPINTI,
1417 BT848_GPIO_DMA_CTL); 1246 BT848_GPIO_DMA_CTL);
1418 1247
1419 val = btv->opt_chroma_agc ? BT848_SCLOOP_CAGC : 0;
1420 btwrite(val, BT848_E_SCLOOP);
1421 btwrite(val, BT848_O_SCLOOP);
1422
1423 btwrite(0x20, BT848_E_VSCALE_HI); 1248 btwrite(0x20, BT848_E_VSCALE_HI);
1424 btwrite(0x20, BT848_O_VSCALE_HI); 1249 btwrite(0x20, BT848_O_VSCALE_HI);
1425 btwrite(BT848_ADC_RESERVED | (btv->opt_adc_crush ? BT848_ADC_CRUSH : 0),
1426 BT848_ADC);
1427 1250
1428 btwrite(whitecrush_upper, BT848_WC_UP); 1251 v4l2_ctrl_handler_setup(&btv->ctrl_handler);
1429 btwrite(whitecrush_lower, BT848_WC_DOWN);
1430
1431 if (btv->opt_lumafilter) {
1432 btwrite(0, BT848_E_CONTROL);
1433 btwrite(0, BT848_O_CONTROL);
1434 } else {
1435 btwrite(BT848_CONTROL_LDEC, BT848_E_CONTROL);
1436 btwrite(BT848_CONTROL_LDEC, BT848_O_CONTROL);
1437 }
1438
1439 bt848_bright(btv, btv->bright);
1440 bt848_hue(btv, btv->hue);
1441 bt848_contrast(btv, btv->contrast);
1442 bt848_sat(btv, btv->saturation);
1443 1252
1444 /* interrupt */ 1253 /* interrupt */
1445 init_irqreg(btv); 1254 init_irqreg(btv);
@@ -1461,103 +1270,26 @@ static void bttv_reinit_bt848(struct bttv *btv)
1461 set_input(btv, btv->input, btv->tvnorm); 1270 set_input(btv, btv->input, btv->tvnorm);
1462} 1271}
1463 1272
1464static int bttv_g_ctrl(struct file *file, void *priv, 1273static int bttv_s_ctrl(struct v4l2_ctrl *c)
1465 struct v4l2_control *c)
1466{ 1274{
1467 struct bttv_fh *fh = priv; 1275 struct bttv *btv = container_of(c->handler, struct bttv, ctrl_handler);
1468 struct bttv *btv = fh->btv; 1276 int val;
1469
1470 switch (c->id) {
1471 case V4L2_CID_BRIGHTNESS:
1472 c->value = btv->bright;
1473 break;
1474 case V4L2_CID_HUE:
1475 c->value = btv->hue;
1476 break;
1477 case V4L2_CID_CONTRAST:
1478 c->value = btv->contrast;
1479 break;
1480 case V4L2_CID_SATURATION:
1481 c->value = btv->saturation;
1482 break;
1483 case V4L2_CID_COLOR_KILLER:
1484 c->value = btv->opt_color_killer;
1485 break;
1486
1487 case V4L2_CID_AUDIO_MUTE:
1488 case V4L2_CID_AUDIO_VOLUME:
1489 case V4L2_CID_AUDIO_BALANCE:
1490 case V4L2_CID_AUDIO_BASS:
1491 case V4L2_CID_AUDIO_TREBLE:
1492 bttv_call_all(btv, core, g_ctrl, c);
1493 break;
1494
1495 case V4L2_CID_PRIVATE_CHROMA_AGC:
1496 c->value = btv->opt_chroma_agc;
1497 break;
1498 case V4L2_CID_PRIVATE_COMBFILTER:
1499 c->value = btv->opt_combfilter;
1500 break;
1501 case V4L2_CID_PRIVATE_LUMAFILTER:
1502 c->value = btv->opt_lumafilter;
1503 break;
1504 case V4L2_CID_PRIVATE_AUTOMUTE:
1505 c->value = btv->opt_automute;
1506 break;
1507 case V4L2_CID_PRIVATE_AGC_CRUSH:
1508 c->value = btv->opt_adc_crush;
1509 break;
1510 case V4L2_CID_PRIVATE_VCR_HACK:
1511 c->value = btv->opt_vcr_hack;
1512 break;
1513 case V4L2_CID_PRIVATE_WHITECRUSH_UPPER:
1514 c->value = btv->opt_whitecrush_upper;
1515 break;
1516 case V4L2_CID_PRIVATE_WHITECRUSH_LOWER:
1517 c->value = btv->opt_whitecrush_lower;
1518 break;
1519 case V4L2_CID_PRIVATE_UV_RATIO:
1520 c->value = btv->opt_uv_ratio;
1521 break;
1522 case V4L2_CID_PRIVATE_FULL_LUMA_RANGE:
1523 c->value = btv->opt_full_luma_range;
1524 break;
1525 case V4L2_CID_PRIVATE_CORING:
1526 c->value = btv->opt_coring;
1527 break;
1528 default:
1529 return -EINVAL;
1530 }
1531 return 0;
1532}
1533
1534static int bttv_s_ctrl(struct file *file, void *f,
1535 struct v4l2_control *c)
1536{
1537 int err;
1538 struct bttv_fh *fh = f;
1539 struct bttv *btv = fh->btv;
1540
1541 err = v4l2_prio_check(&btv->prio, fh->prio);
1542 if (0 != err)
1543 return err;
1544 1277
1545 switch (c->id) { 1278 switch (c->id) {
1546 case V4L2_CID_BRIGHTNESS: 1279 case V4L2_CID_BRIGHTNESS:
1547 bt848_bright(btv, c->value); 1280 bt848_bright(btv, c->val);
1548 break; 1281 break;
1549 case V4L2_CID_HUE: 1282 case V4L2_CID_HUE:
1550 bt848_hue(btv, c->value); 1283 bt848_hue(btv, c->val);
1551 break; 1284 break;
1552 case V4L2_CID_CONTRAST: 1285 case V4L2_CID_CONTRAST:
1553 bt848_contrast(btv, c->value); 1286 bt848_contrast(btv, c->val);
1554 break; 1287 break;
1555 case V4L2_CID_SATURATION: 1288 case V4L2_CID_SATURATION:
1556 bt848_sat(btv, c->value); 1289 bt848_sat(btv, c->val);
1557 break; 1290 break;
1558 case V4L2_CID_COLOR_KILLER: 1291 case V4L2_CID_COLOR_KILLER:
1559 btv->opt_color_killer = c->value; 1292 if (c->val) {
1560 if (btv->opt_color_killer) {
1561 btor(BT848_SCLOOP_CKILL, BT848_E_SCLOOP); 1293 btor(BT848_SCLOOP_CKILL, BT848_E_SCLOOP);
1562 btor(BT848_SCLOOP_CKILL, BT848_O_SCLOOP); 1294 btor(BT848_SCLOOP_CKILL, BT848_O_SCLOOP);
1563 } else { 1295 } else {
@@ -1566,36 +1298,22 @@ static int bttv_s_ctrl(struct file *file, void *f,
1566 } 1298 }
1567 break; 1299 break;
1568 case V4L2_CID_AUDIO_MUTE: 1300 case V4L2_CID_AUDIO_MUTE:
1569 audio_mute(btv, c->value); 1301 audio_mute(btv, c->val);
1570 /* fall through */
1571 case V4L2_CID_AUDIO_VOLUME:
1572 if (btv->volume_gpio)
1573 btv->volume_gpio(btv, c->value);
1574
1575 bttv_call_all(btv, core, s_ctrl, c);
1576 break; 1302 break;
1577 case V4L2_CID_AUDIO_BALANCE: 1303 case V4L2_CID_AUDIO_VOLUME:
1578 case V4L2_CID_AUDIO_BASS: 1304 btv->volume_gpio(btv, c->val);
1579 case V4L2_CID_AUDIO_TREBLE:
1580 bttv_call_all(btv, core, s_ctrl, c);
1581 break; 1305 break;
1582 1306
1583 case V4L2_CID_PRIVATE_CHROMA_AGC: 1307 case V4L2_CID_CHROMA_AGC:
1584 btv->opt_chroma_agc = c->value; 1308 val = c->val ? BT848_SCLOOP_CAGC : 0;
1585 if (btv->opt_chroma_agc) { 1309 btwrite(val, BT848_E_SCLOOP);
1586 btor(BT848_SCLOOP_CAGC, BT848_E_SCLOOP); 1310 btwrite(val, BT848_O_SCLOOP);
1587 btor(BT848_SCLOOP_CAGC, BT848_O_SCLOOP);
1588 } else {
1589 btand(~BT848_SCLOOP_CAGC, BT848_E_SCLOOP);
1590 btand(~BT848_SCLOOP_CAGC, BT848_O_SCLOOP);
1591 }
1592 break; 1311 break;
1593 case V4L2_CID_PRIVATE_COMBFILTER: 1312 case V4L2_CID_PRIVATE_COMBFILTER:
1594 btv->opt_combfilter = c->value; 1313 btv->opt_combfilter = c->val;
1595 break; 1314 break;
1596 case V4L2_CID_PRIVATE_LUMAFILTER: 1315 case V4L2_CID_PRIVATE_LUMAFILTER:
1597 btv->opt_lumafilter = c->value; 1316 if (c->val) {
1598 if (btv->opt_lumafilter) {
1599 btand(~BT848_CONTROL_LDEC, BT848_E_CONTROL); 1317 btand(~BT848_CONTROL_LDEC, BT848_E_CONTROL);
1600 btand(~BT848_CONTROL_LDEC, BT848_O_CONTROL); 1318 btand(~BT848_CONTROL_LDEC, BT848_O_CONTROL);
1601 } else { 1319 } else {
@@ -1604,36 +1322,31 @@ static int bttv_s_ctrl(struct file *file, void *f,
1604 } 1322 }
1605 break; 1323 break;
1606 case V4L2_CID_PRIVATE_AUTOMUTE: 1324 case V4L2_CID_PRIVATE_AUTOMUTE:
1607 btv->opt_automute = c->value; 1325 btv->opt_automute = c->val;
1608 break; 1326 break;
1609 case V4L2_CID_PRIVATE_AGC_CRUSH: 1327 case V4L2_CID_PRIVATE_AGC_CRUSH:
1610 btv->opt_adc_crush = c->value;
1611 btwrite(BT848_ADC_RESERVED | 1328 btwrite(BT848_ADC_RESERVED |
1612 (btv->opt_adc_crush ? BT848_ADC_CRUSH : 0), 1329 (c->val ? BT848_ADC_CRUSH : 0),
1613 BT848_ADC); 1330 BT848_ADC);
1614 break; 1331 break;
1615 case V4L2_CID_PRIVATE_VCR_HACK: 1332 case V4L2_CID_PRIVATE_VCR_HACK:
1616 btv->opt_vcr_hack = c->value; 1333 btv->opt_vcr_hack = c->val;
1617 break; 1334 break;
1618 case V4L2_CID_PRIVATE_WHITECRUSH_UPPER: 1335 case V4L2_CID_PRIVATE_WHITECRUSH_UPPER:
1619 btv->opt_whitecrush_upper = c->value; 1336 btwrite(c->val, BT848_WC_UP);
1620 btwrite(c->value, BT848_WC_UP);
1621 break; 1337 break;
1622 case V4L2_CID_PRIVATE_WHITECRUSH_LOWER: 1338 case V4L2_CID_PRIVATE_WHITECRUSH_LOWER:
1623 btv->opt_whitecrush_lower = c->value; 1339 btwrite(c->val, BT848_WC_DOWN);
1624 btwrite(c->value, BT848_WC_DOWN);
1625 break; 1340 break;
1626 case V4L2_CID_PRIVATE_UV_RATIO: 1341 case V4L2_CID_PRIVATE_UV_RATIO:
1627 btv->opt_uv_ratio = c->value; 1342 btv->opt_uv_ratio = c->val;
1628 bt848_sat(btv, btv->saturation); 1343 bt848_sat(btv, btv->saturation);
1629 break; 1344 break;
1630 case V4L2_CID_PRIVATE_FULL_LUMA_RANGE: 1345 case V4L2_CID_PRIVATE_FULL_LUMA_RANGE:
1631 btv->opt_full_luma_range = c->value; 1346 btaor((c->val << 7), ~BT848_OFORM_RANGE, BT848_OFORM);
1632 btaor((c->value<<7), ~BT848_OFORM_RANGE, BT848_OFORM);
1633 break; 1347 break;
1634 case V4L2_CID_PRIVATE_CORING: 1348 case V4L2_CID_PRIVATE_CORING:
1635 btv->opt_coring = c->value; 1349 btaor((c->val << 5), ~BT848_OFORM_CORE32, BT848_OFORM);
1636 btaor((c->value<<5), ~BT848_OFORM_CORE32, BT848_OFORM);
1637 break; 1350 break;
1638 default: 1351 default:
1639 return -EINVAL; 1352 return -EINVAL;
@@ -1643,6 +1356,121 @@ static int bttv_s_ctrl(struct file *file, void *f,
1643 1356
1644/* ----------------------------------------------------------------------- */ 1357/* ----------------------------------------------------------------------- */
1645 1358
1359static const struct v4l2_ctrl_ops bttv_ctrl_ops = {
1360 .s_ctrl = bttv_s_ctrl,
1361};
1362
1363static struct v4l2_ctrl_config bttv_ctrl_combfilter = {
1364 .ops = &bttv_ctrl_ops,
1365 .id = V4L2_CID_PRIVATE_COMBFILTER,
1366 .name = "Comb Filter",
1367 .type = V4L2_CTRL_TYPE_BOOLEAN,
1368 .min = 0,
1369 .max = 1,
1370 .step = 1,
1371 .def = 1,
1372};
1373
1374static struct v4l2_ctrl_config bttv_ctrl_automute = {
1375 .ops = &bttv_ctrl_ops,
1376 .id = V4L2_CID_PRIVATE_AUTOMUTE,
1377 .name = "Auto Mute",
1378 .type = V4L2_CTRL_TYPE_BOOLEAN,
1379 .min = 0,
1380 .max = 1,
1381 .step = 1,
1382 .def = 1,
1383};
1384
1385static struct v4l2_ctrl_config bttv_ctrl_lumafilter = {
1386 .ops = &bttv_ctrl_ops,
1387 .id = V4L2_CID_PRIVATE_LUMAFILTER,
1388 .name = "Luma Decimation Filter",
1389 .type = V4L2_CTRL_TYPE_BOOLEAN,
1390 .min = 0,
1391 .max = 1,
1392 .step = 1,
1393 .def = 1,
1394};
1395
1396static struct v4l2_ctrl_config bttv_ctrl_agc_crush = {
1397 .ops = &bttv_ctrl_ops,
1398 .id = V4L2_CID_PRIVATE_AGC_CRUSH,
1399 .name = "AGC Crush",
1400 .type = V4L2_CTRL_TYPE_BOOLEAN,
1401 .min = 0,
1402 .max = 1,
1403 .step = 1,
1404 .def = 1,
1405};
1406
1407static struct v4l2_ctrl_config bttv_ctrl_vcr_hack = {
1408 .ops = &bttv_ctrl_ops,
1409 .id = V4L2_CID_PRIVATE_VCR_HACK,
1410 .name = "VCR Hack",
1411 .type = V4L2_CTRL_TYPE_BOOLEAN,
1412 .min = 0,
1413 .max = 1,
1414 .step = 1,
1415 .def = 1,
1416};
1417
1418static struct v4l2_ctrl_config bttv_ctrl_whitecrush_lower = {
1419 .ops = &bttv_ctrl_ops,
1420 .id = V4L2_CID_PRIVATE_WHITECRUSH_LOWER,
1421 .name = "Whitecrush Lower",
1422 .type = V4L2_CTRL_TYPE_INTEGER,
1423 .min = 0,
1424 .max = 255,
1425 .step = 1,
1426 .def = 0x7f,
1427};
1428
1429static struct v4l2_ctrl_config bttv_ctrl_whitecrush_upper = {
1430 .ops = &bttv_ctrl_ops,
1431 .id = V4L2_CID_PRIVATE_WHITECRUSH_UPPER,
1432 .name = "Whitecrush Upper",
1433 .type = V4L2_CTRL_TYPE_INTEGER,
1434 .min = 0,
1435 .max = 255,
1436 .step = 1,
1437 .def = 0xcf,
1438};
1439
1440static struct v4l2_ctrl_config bttv_ctrl_uv_ratio = {
1441 .ops = &bttv_ctrl_ops,
1442 .id = V4L2_CID_PRIVATE_UV_RATIO,
1443 .name = "UV Ratio",
1444 .type = V4L2_CTRL_TYPE_INTEGER,
1445 .min = 0,
1446 .max = 100,
1447 .step = 1,
1448 .def = 50,
1449};
1450
1451static struct v4l2_ctrl_config bttv_ctrl_full_luma = {
1452 .ops = &bttv_ctrl_ops,
1453 .id = V4L2_CID_PRIVATE_FULL_LUMA_RANGE,
1454 .name = "Full Luma Range",
1455 .type = V4L2_CTRL_TYPE_BOOLEAN,
1456 .min = 0,
1457 .max = 1,
1458 .step = 1,
1459};
1460
1461static struct v4l2_ctrl_config bttv_ctrl_coring = {
1462 .ops = &bttv_ctrl_ops,
1463 .id = V4L2_CID_PRIVATE_CORING,
1464 .name = "Coring",
1465 .type = V4L2_CTRL_TYPE_INTEGER,
1466 .min = 0,
1467 .max = 3,
1468 .step = 1,
1469};
1470
1471
1472/* ----------------------------------------------------------------------- */
1473
1646void bttv_gpio_tracking(struct bttv *btv, char *comment) 1474void bttv_gpio_tracking(struct bttv *btv, char *comment)
1647{ 1475{
1648 unsigned int outbits, data; 1476 unsigned int outbits, data;
@@ -2047,9 +1875,11 @@ static int bttv_s_frequency(struct file *file, void *priv,
2047 1875
2048static int bttv_log_status(struct file *file, void *f) 1876static int bttv_log_status(struct file *file, void *f)
2049{ 1877{
1878 struct video_device *vdev = video_devdata(file);
2050 struct bttv_fh *fh = f; 1879 struct bttv_fh *fh = f;
2051 struct bttv *btv = fh->btv; 1880 struct bttv *btv = fh->btv;
2052 1881
1882 v4l2_ctrl_handler_log_status(vdev->ctrl_handler, btv->c.v4l2_dev.name);
2053 bttv_call_all(btv, core, log_status); 1883 bttv_call_all(btv, core, log_status);
2054 return 0; 1884 return 0;
2055} 1885}
@@ -2939,30 +2769,6 @@ static int bttv_streamoff(struct file *file, void *priv,
2939 return 0; 2769 return 0;
2940} 2770}
2941 2771
2942static int bttv_queryctrl(struct file *file, void *priv,
2943 struct v4l2_queryctrl *c)
2944{
2945 struct bttv_fh *fh = priv;
2946 struct bttv *btv = fh->btv;
2947 const struct v4l2_queryctrl *ctrl;
2948
2949 if ((c->id < V4L2_CID_BASE ||
2950 c->id >= V4L2_CID_LASTP1) &&
2951 (c->id < V4L2_CID_PRIVATE_BASE ||
2952 c->id >= V4L2_CID_PRIVATE_LASTP1))
2953 return -EINVAL;
2954
2955 if (!btv->volume_gpio && (c->id == V4L2_CID_AUDIO_VOLUME))
2956 *c = no_ctl;
2957 else {
2958 ctrl = ctrl_by_id(c->id);
2959
2960 *c = (NULL != ctrl) ? *ctrl : no_ctl;
2961 }
2962
2963 return 0;
2964}
2965
2966static int bttv_g_parm(struct file *file, void *f, 2772static int bttv_g_parm(struct file *file, void *f,
2967 struct v4l2_streamparm *parm) 2773 struct v4l2_streamparm *parm)
2968{ 2774{
@@ -3263,6 +3069,7 @@ static int bttv_open(struct file *file)
3263 fh = kmalloc(sizeof(*fh), GFP_KERNEL); 3069 fh = kmalloc(sizeof(*fh), GFP_KERNEL);
3264 if (unlikely(!fh)) 3070 if (unlikely(!fh))
3265 return -ENOMEM; 3071 return -ENOMEM;
3072 btv->users++;
3266 file->private_data = fh; 3073 file->private_data = fh;
3267 3074
3268 *fh = btv->init; 3075 *fh = btv->init;
@@ -3287,7 +3094,6 @@ static int bttv_open(struct file *file)
3287 set_tvnorm(btv,btv->tvnorm); 3094 set_tvnorm(btv,btv->tvnorm);
3288 set_input(btv, btv->input, btv->tvnorm); 3095 set_input(btv, btv->input, btv->tvnorm);
3289 3096
3290 btv->users++;
3291 3097
3292 /* The V4L2 spec requires one global set of cropping parameters 3098 /* The V4L2 spec requires one global set of cropping parameters
3293 which only change on request. These are stored in btv->crop[1]. 3099 which only change on request. These are stored in btv->crop[1].
@@ -3349,7 +3155,7 @@ static int bttv_release(struct file *file)
3349 bttv_field_count(btv); 3155 bttv_field_count(btv);
3350 3156
3351 if (!btv->users) 3157 if (!btv->users)
3352 audio_mute(btv, 1); 3158 audio_mute(btv, btv->mute);
3353 3159
3354 return 0; 3160 return 0;
3355} 3161}
@@ -3400,9 +3206,6 @@ static const struct v4l2_ioctl_ops bttv_ioctl_ops = {
3400 .vidioc_enum_input = bttv_enum_input, 3206 .vidioc_enum_input = bttv_enum_input,
3401 .vidioc_g_input = bttv_g_input, 3207 .vidioc_g_input = bttv_g_input,
3402 .vidioc_s_input = bttv_s_input, 3208 .vidioc_s_input = bttv_s_input,
3403 .vidioc_queryctrl = bttv_queryctrl,
3404 .vidioc_g_ctrl = bttv_g_ctrl,
3405 .vidioc_s_ctrl = bttv_s_ctrl,
3406 .vidioc_streamon = bttv_streamon, 3209 .vidioc_streamon = bttv_streamon,
3407 .vidioc_streamoff = bttv_streamoff, 3210 .vidioc_streamoff = bttv_streamoff,
3408 .vidioc_g_tuner = bttv_g_tuner, 3211 .vidioc_g_tuner = bttv_g_tuner,
@@ -3511,24 +3314,6 @@ static int radio_s_tuner(struct file *file, void *priv,
3511 return 0; 3314 return 0;
3512} 3315}
3513 3316
3514static int radio_queryctrl(struct file *file, void *priv,
3515 struct v4l2_queryctrl *c)
3516{
3517 const struct v4l2_queryctrl *ctrl;
3518
3519 if (c->id < V4L2_CID_BASE ||
3520 c->id >= V4L2_CID_LASTP1)
3521 return -EINVAL;
3522
3523 if (c->id == V4L2_CID_AUDIO_MUTE) {
3524 ctrl = ctrl_by_id(c->id);
3525 *c = *ctrl;
3526 } else
3527 *c = no_ctl;
3528
3529 return 0;
3530}
3531
3532static ssize_t radio_read(struct file *file, char __user *data, 3317static ssize_t radio_read(struct file *file, char __user *data,
3533 size_t count, loff_t *ppos) 3318 size_t count, loff_t *ppos)
3534{ 3319{
@@ -3570,11 +3355,9 @@ static const struct v4l2_file_operations radio_fops =
3570 3355
3571static const struct v4l2_ioctl_ops radio_ioctl_ops = { 3356static const struct v4l2_ioctl_ops radio_ioctl_ops = {
3572 .vidioc_querycap = bttv_querycap, 3357 .vidioc_querycap = bttv_querycap,
3358 .vidioc_log_status = bttv_log_status,
3573 .vidioc_g_tuner = radio_g_tuner, 3359 .vidioc_g_tuner = radio_g_tuner,
3574 .vidioc_s_tuner = radio_s_tuner, 3360 .vidioc_s_tuner = radio_s_tuner,
3575 .vidioc_queryctrl = radio_queryctrl,
3576 .vidioc_g_ctrl = bttv_g_ctrl,
3577 .vidioc_s_ctrl = bttv_s_ctrl,
3578 .vidioc_g_frequency = bttv_g_frequency, 3361 .vidioc_g_frequency = bttv_g_frequency,
3579 .vidioc_s_frequency = bttv_s_frequency, 3362 .vidioc_s_frequency = bttv_s_frequency,
3580}; 3363};
@@ -4220,6 +4003,7 @@ static int bttv_register_video(struct bttv *btv)
4220 btv->radio_dev = vdev_init(btv, &radio_template, "radio"); 4003 btv->radio_dev = vdev_init(btv, &radio_template, "radio");
4221 if (NULL == btv->radio_dev) 4004 if (NULL == btv->radio_dev)
4222 goto err; 4005 goto err;
4006 btv->radio_dev->ctrl_handler = &btv->radio_ctrl_handler;
4223 if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO, 4007 if (video_register_device(btv->radio_dev, VFL_TYPE_RADIO,
4224 radio_nr[btv->c.nr]) < 0) 4008 radio_nr[btv->c.nr]) < 0)
4225 goto err; 4009 goto err;
@@ -4258,6 +4042,7 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4258 int result; 4042 int result;
4259 unsigned char lat; 4043 unsigned char lat;
4260 struct bttv *btv; 4044 struct bttv *btv;
4045 struct v4l2_ctrl_handler *hdl;
4261 4046
4262 if (bttv_num == BTTV_MAX) 4047 if (bttv_num == BTTV_MAX)
4263 return -ENOMEM; 4048 return -ENOMEM;
@@ -4317,6 +4102,10 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4317 pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr); 4102 pr_warn("%d: v4l2_device_register() failed\n", btv->c.nr);
4318 goto fail0; 4103 goto fail0;
4319 } 4104 }
4105 hdl = &btv->ctrl_handler;
4106 v4l2_ctrl_handler_init(hdl, 20);
4107 btv->c.v4l2_dev.ctrl_handler = hdl;
4108 v4l2_ctrl_handler_init(&btv->radio_ctrl_handler, 6);
4320 4109
4321 btv->revision = dev->revision; 4110 btv->revision = dev->revision;
4322 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat); 4111 pci_read_config_byte(dev, PCI_LATENCY_TIMER, &lat);
@@ -4353,16 +4142,19 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4353 4142
4354 /* init options from insmod args */ 4143 /* init options from insmod args */
4355 btv->opt_combfilter = combfilter; 4144 btv->opt_combfilter = combfilter;
4356 btv->opt_lumafilter = lumafilter; 4145 bttv_ctrl_combfilter.def = combfilter;
4146 bttv_ctrl_lumafilter.def = lumafilter;
4357 btv->opt_automute = automute; 4147 btv->opt_automute = automute;
4358 btv->opt_chroma_agc = chroma_agc; 4148 bttv_ctrl_automute.def = automute;
4359 btv->opt_adc_crush = adc_crush; 4149 bttv_ctrl_agc_crush.def = agc_crush;
4360 btv->opt_vcr_hack = vcr_hack; 4150 btv->opt_vcr_hack = vcr_hack;
4361 btv->opt_whitecrush_upper = whitecrush_upper; 4151 bttv_ctrl_vcr_hack.def = vcr_hack;
4362 btv->opt_whitecrush_lower = whitecrush_lower; 4152 bttv_ctrl_whitecrush_upper.def = whitecrush_upper;
4153 bttv_ctrl_whitecrush_lower.def = whitecrush_lower;
4363 btv->opt_uv_ratio = uv_ratio; 4154 btv->opt_uv_ratio = uv_ratio;
4364 btv->opt_full_luma_range = full_luma_range; 4155 bttv_ctrl_uv_ratio.def = uv_ratio;
4365 btv->opt_coring = coring; 4156 bttv_ctrl_full_luma.def = full_luma_range;
4157 bttv_ctrl_coring.def = coring;
4366 4158
4367 /* fill struct bttv with some useful defaults */ 4159 /* fill struct bttv with some useful defaults */
4368 btv->init.btv = btv; 4160 btv->init.btv = btv;
@@ -4373,6 +4165,34 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4373 btv->init.height = 240; 4165 btv->init.height = 240;
4374 btv->input = 0; 4166 btv->input = 0;
4375 4167
4168 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4169 V4L2_CID_BRIGHTNESS, 0, 0xff00, 0x100, 32768);
4170 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4171 V4L2_CID_CONTRAST, 0, 0xff80, 0x80, 0x6c00);
4172 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4173 V4L2_CID_SATURATION, 0, 0xff80, 0x80, 32768);
4174 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4175 V4L2_CID_COLOR_KILLER, 0, 1, 1, 0);
4176 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4177 V4L2_CID_HUE, 0, 0xff00, 0x100, 32768);
4178 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4179 V4L2_CID_CHROMA_AGC, 0, 1, 1, !!chroma_agc);
4180 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4181 V4L2_CID_AUDIO_MUTE, 0, 1, 1, 0);
4182 if (btv->volume_gpio)
4183 v4l2_ctrl_new_std(hdl, &bttv_ctrl_ops,
4184 V4L2_CID_AUDIO_VOLUME, 0, 0xff00, 0x100, 0xff00);
4185 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_combfilter, NULL);
4186 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_automute, NULL);
4187 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_lumafilter, NULL);
4188 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_agc_crush, NULL);
4189 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_vcr_hack, NULL);
4190 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_whitecrush_lower, NULL);
4191 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_whitecrush_upper, NULL);
4192 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_uv_ratio, NULL);
4193 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_full_luma, NULL);
4194 v4l2_ctrl_new_custom(hdl, &bttv_ctrl_coring, NULL);
4195
4376 /* initialize hardware */ 4196 /* initialize hardware */
4377 if (bttv_gpio) 4197 if (bttv_gpio)
4378 bttv_gpio_tracking(btv,"pre-init"); 4198 bttv_gpio_tracking(btv,"pre-init");
@@ -4400,20 +4220,26 @@ static int bttv_probe(struct pci_dev *dev, const struct pci_device_id *pci_id)
4400 btv->radio_freq = 90500 * 16; /* 90.5Mhz default */ 4220 btv->radio_freq = 90500 * 16; /* 90.5Mhz default */
4401 } 4221 }
4402 init_irqreg(btv); 4222 init_irqreg(btv);
4223 v4l2_ctrl_handler_setup(hdl);
4403 4224
4225 if (hdl->error) {
4226 result = hdl->error;
4227 goto fail2;
4228 }
4404 /* register video4linux + input */ 4229 /* register video4linux + input */
4405 if (!bttv_tvcards[btv->c.type].no_video) { 4230 if (!bttv_tvcards[btv->c.type].no_video) {
4406 bttv_register_video(btv); 4231 v4l2_ctrl_add_handler(&btv->radio_ctrl_handler, hdl,
4407 bt848_bright(btv,32768); 4232 v4l2_ctrl_radio_filter);
4408 bt848_contrast(btv, 27648); 4233 if (btv->radio_ctrl_handler.error) {
4409 bt848_hue(btv,32768); 4234 result = btv->radio_ctrl_handler.error;
4410 bt848_sat(btv,32768); 4235 goto fail2;
4411 audio_mute(btv, 1); 4236 }
4412 set_input(btv, 0, btv->tvnorm); 4237 set_input(btv, 0, btv->tvnorm);
4413 bttv_crop_reset(&btv->crop[0], btv->tvnorm); 4238 bttv_crop_reset(&btv->crop[0], btv->tvnorm);
4414 btv->crop[1] = btv->crop[0]; /* current = default */ 4239 btv->crop[1] = btv->crop[0]; /* current = default */
4415 disclaim_vbi_lines(btv); 4240 disclaim_vbi_lines(btv);
4416 disclaim_video_lines(btv); 4241 disclaim_video_lines(btv);
4242 bttv_register_video(btv);
4417 } 4243 }
4418 4244
4419 /* add subdevices and autoload dvb-bt8xx if needed */ 4245 /* add subdevices and autoload dvb-bt8xx if needed */
@@ -4435,6 +4261,8 @@ fail2:
4435 free_irq(btv->c.pci->irq,btv); 4261 free_irq(btv->c.pci->irq,btv);
4436 4262
4437fail1: 4263fail1:
4264 v4l2_ctrl_handler_free(&btv->ctrl_handler);
4265 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler);
4438 v4l2_device_unregister(&btv->c.v4l2_dev); 4266 v4l2_device_unregister(&btv->c.v4l2_dev);
4439 4267
4440fail0: 4268fail0:
@@ -4476,9 +4304,11 @@ static void bttv_remove(struct pci_dev *pci_dev)
4476 bttv_unregister_video(btv); 4304 bttv_unregister_video(btv);
4477 4305
4478 /* free allocated memory */ 4306 /* free allocated memory */
4307 v4l2_ctrl_handler_free(&btv->ctrl_handler);
4308 v4l2_ctrl_handler_free(&btv->radio_ctrl_handler);
4479 btcx_riscmem_free(btv->c.pci,&btv->main); 4309 btcx_riscmem_free(btv->c.pci,&btv->main);
4480 4310
4481 /* free ressources */ 4311 /* free resources */
4482 free_irq(btv->c.pci->irq,btv); 4312 free_irq(btv->c.pci->irq,btv);
4483 iounmap(btv->bt848_mmio); 4313 iounmap(btv->bt848_mmio);
4484 release_mem_region(pci_resource_start(btv->c.pci,0), 4314 release_mem_region(pci_resource_start(btv->c.pci,0),
diff --git a/drivers/media/pci/bt8xx/bttvp.h b/drivers/media/pci/bt8xx/bttvp.h
index 528e03ec19e8..c3882ef3c529 100644
--- a/drivers/media/pci/bt8xx/bttvp.h
+++ b/drivers/media/pci/bt8xx/bttvp.h
@@ -33,9 +33,10 @@
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>
39#include <media/videobuf-dma-sg.h> 40#include <media/videobuf-dma-sg.h>
40#include <media/tveeprom.h> 41#include <media/tveeprom.h>
41#include <media/rc-core.h> 42#include <media/rc-core.h>
@@ -393,12 +394,17 @@ struct bttv {
393 wait_queue_head_t i2c_queue; 394 wait_queue_head_t i2c_queue;
394 struct v4l2_subdev *sd_msp34xx; 395 struct v4l2_subdev *sd_msp34xx;
395 struct v4l2_subdev *sd_tvaudio; 396 struct v4l2_subdev *sd_tvaudio;
397 struct v4l2_subdev *sd_tda7432;
396 398
397 /* video4linux (1) */ 399 /* video4linux (1) */
398 struct video_device *video_dev; 400 struct video_device *video_dev;
399 struct video_device *radio_dev; 401 struct video_device *radio_dev;
400 struct video_device *vbi_dev; 402 struct video_device *vbi_dev;
401 403
404 /* controls */
405 struct v4l2_ctrl_handler ctrl_handler;
406 struct v4l2_ctrl_handler radio_ctrl_handler;
407
402 /* infrared remote */ 408 /* infrared remote */
403 int has_remote; 409 int has_remote;
404 struct bttv_ir *remote; 410 struct bttv_ir *remote;
@@ -426,17 +432,9 @@ struct bttv {
426 432
427 /* various options */ 433 /* various options */
428 int opt_combfilter; 434 int opt_combfilter;
429 int opt_lumafilter;
430 int opt_automute; 435 int opt_automute;
431 int opt_chroma_agc;
432 int opt_color_killer;
433 int opt_adc_crush;
434 int opt_vcr_hack; 436 int opt_vcr_hack;
435 int opt_whitecrush_upper;
436 int opt_whitecrush_lower;
437 int opt_uv_ratio; 437 int opt_uv_ratio;
438 int opt_full_luma_range;
439 int opt_coring;
440 438
441 /* radio data/state */ 439 /* radio data/state */
442 int has_radio; 440 int has_radio;
diff --git a/include/uapi/linux/v4l2-controls.h b/include/uapi/linux/v4l2-controls.h
index dcd63745e83a..1d00ca9f0ba3 100644
--- a/include/uapi/linux/v4l2-controls.h
+++ b/include/uapi/linux/v4l2-controls.h
@@ -146,6 +146,11 @@ enum v4l2_colorfx {
146 * of controls. We reserve 16 controls for this driver. */ 146 * of controls. We reserve 16 controls for this driver. */
147#define V4L2_CID_USER_MEYE_BASE (V4L2_CID_USER_BASE + 0x1000) 147#define V4L2_CID_USER_MEYE_BASE (V4L2_CID_USER_BASE + 0x1000)
148 148
149/* The base for the bttv driver controls.
150 * We reserve 32 controls for this driver. */
151#define V4L2_CID_USER_BTTV_BASE (V4L2_CID_USER_BASE + 0x1010)
152
153
149/* MPEG-class control IDs */ 154/* MPEG-class control IDs */
150 155
151#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900) 156#define V4L2_CID_MPEG_BASE (V4L2_CTRL_CLASS_MPEG | 0x900)