FM1216ME_MK3 control of GAIN
Hi All,
We can control the sensitivity of the tuner FM1216ME_MK3. This is my test patch for discuss.
1. Add gain variable to tuner structure.
2. Add V4L2_CID_GAIN control to saa7134 and disable this control.
3. Add workaround to simple_post_tune function for write sensitivity level to the tuner.
4. Enable V4L2_CID_GAIN control when module load if card is right.
My expirience not so good, step 4 segfault the kernel. How to we can make it?
Our windows end-user programm control the sensitivity of each TV channel and change when channel changed.
What you think about it??
linux/drivers/media/common/tuners/tuner-simple.c +49 -1
@@ -116,6 +116,7 @@u32 frequency;u32 bandwidth; +signed int gain; };/* ---------------------------------------------------------------------- */
@@ -495,15 +507,57 @@ "(should be 4)\n", rc);break ; } +case TUNER_PHILIPS_FM1216ME_MK3 : + { + buffer[2 ] =0xDE ;/* T2 = 0, T1 = 1 and T0 = 1 */ +switch (priv->gain) { +case 0 : +/* TOP = External AGC, ATC = OFF */ + buffer[3 ] =0x60 ; +break ; +case 1 : +/* TOP = 118 dB, ATC = OFF */ + buffer[3 ] =0x00 ; +break ; +case 2 : +/* TOP = 115 dB, ATC = OFF */ + buffer[3 ] =0x10 ; +break ; +case 3 : +/* TOP = 112 dB, ATC = OFF */ + buffer[3 ] =0x20 ; +break ; +case 4 : +/* TOP = 109 dB, ATC = OFF */ + buffer[3 ] =0x30 ; +break ; +case 5 : +/* TOP = 106 dB, ATC = OFF */ + buffer[3 ] =0x40 ; +break ; +case 6 : +/* TOP = 103 dB, ATC = OFF */ + buffer[3 ] =0x50 ; +break ; +default : +/* TOP = 112 dB, ATC = OFF */ + buffer[3 ] =0x20 ; +break ; + } + +tuner_dbg ("tv 0x%02x 0x%02x 0x%02x 0x%02x\n" , + buffer[0 ], buffer[1 ], buffer[2 ], buffer[3 ]); + + rc =tuner_i2c_xfer_send (&priv->i2c_props, buffer,4 ); +if (4 != rc) +tuner_warn ("i2c i/o error: rc == %d " +"(should be 4)\n" , rc); + +break ; } - + }return 0 ; }
linux/drivers/media/video/saa7134/saa7134-cards.c +12 -0
@@ -6506,6 +6806,20 @@saa_call_all (dev, tuner, s_config, &tea5767_cfg);break ; } +case SAA7134_BOARD_BEHOLD_M6_EXTRA : + { +struct v4l2_queryctrl *ctl; +struct saa7134_fh *fh; +struct file *fl; + + ctl->id =V4L2_CID_GAIN ; +if (saa7134_queryctrl (fl, fh, ctl) ==0 ) { +/* enable this control */ + ctl->flags &= ~(V4L2_CTRL_FLAG_DISABLED ); + } + } }/* switch() */ saa7134_tuner_setup (dev);
linux/drivers/media/video/saa7134/saa7134-video.c +17 -0
@@ -417,6 +417,15 @@ .step = 1, .default_value = 0, .type = V4L2_CTRL_TYPE_INTEGER, + }, { + .id = V4L2_CID_GAIN, + .name = "Gain", + .minimum = 0, + .maximum = 6, + .step = 1, + .default_value = 3, + .type = V4L2_CTRL_TYPE_INTEGER, + .flags = V4L2_CTRL_FLAG_DISABLED, },{ .id = V4L2_CID_HFLIP, .name = "Mirror",
@@ -1129,6 +1138,9 @@case V4L2_CID_HUE : c->value = dev->ctl_hue;break ; +case V4L2_CID_GAIN : + c->value = dev->ctl_gain; +break ;case V4L2_CID_CONTRAST : c->value = dev->ctl_contrast;break ;
@@ -1214,6 +1226,10 @@case V4L2_CID_HUE : dev->ctl_hue = c->value;saa_writeb (SAA7134_DEC_CHROMA_HUE , dev->ctl_hue); +break ; +case V4L2_CID_GAIN : + dev->ctl_gain = c->value; +break ;case V4L2_CID_CONTRAST : dev->ctl_contrast = c->value;
@@ -2502,6 +2518,7 @@ dev->ctl_bright =ctrl_by_id (V4L2_CID_BRIGHTNESS )->default_value; dev->ctl_contrast =ctrl_by_id (V4L2_CID_CONTRAST )->default_value; dev->ctl_hue =ctrl_by_id (V4L2_CID_HUE )->default_value; + dev->ctl_gain =ctrl_by_id (V4L2_CID_GAIN )->default_value; dev->ctl_saturation =ctrl_by_id (V4L2_CID_SATURATION )->default_value; dev->ctl_volume =ctrl_by_id (V4L2_CID_AUDIO_VOLUME )->default_value; dev->ctl_mute =1 ;// ctrl_by_id(V4L2_CID_AUDIO_MUTE)->default_value;
linux/drivers/media/video/saa7134/saa7134.h +1 -0
@@ -548,6 +558,7 @@int ctl_bright;int ctl_contrast;int ctl_hue; +int ctl_gain;/* gain */ int ctl_saturation;int ctl_freq;int ctl_mute;/* audio */
With my best regards, Dmitry.
linux/drivers/media/common/tuners/tuner-simple.c +49 -1
63 lines not on this page · raw message
linux/drivers/media/video/saa7134/saa7134-cards.c +12 -0
@@ -6506,6 +6806,20 @@saa_call_all (dev, tuner, s_config, &tea5767_cfg);break ; } +case SAA7134_BOARD_BEHOLD_M6_EXTRA : + { +struct v4l2_queryctrl *ctl; +struct saa7134_fh *fh; +struct file *fl; + + ctl->id =V4L2_CID_GAIN ; +if (saa7134_queryctrl (fl, fh, ctl) ==0 ) { +/* enable this control */ + ctl->flags &= ~(V4L2_CTRL_FLAG_DISABLED ); + } + } }/* switch() */ saa7134_tuner_setup (dev);
linux/drivers/media/video/saa7134/saa7134-video.c +17 -0
@@ -417,6 +417,15 @@ .step = 1, .default_value = 0, .type = V4L2_CTRL_TYPE_INTEGER, + }, { + .id = V4L2_CID_GAIN, + .name = "Gain", + .minimum = 0, + .maximum = 6, + .step = 1, + .default_value = 3, + .type = V4L2_CTRL_TYPE_INTEGER, + .flags = V4L2_CTRL_FLAG_DISABLED, },{ .id = V4L2_CID_HFLIP, .name = "Mirror",
@@ -1129,6 +1138,9 @@case V4L2_CID_HUE : c->value = dev->ctl_hue;break ; +case V4L2_CID_GAIN : + c->value = dev->ctl_gain; +break ;case V4L2_CID_CONTRAST : c->value = dev->ctl_contrast;break ;
@@ -1214,6 +1226,10 @@case V4L2_CID_HUE : dev->ctl_hue = c->value;saa_writeb (SAA7134_DEC_CHROMA_HUE , dev->ctl_hue); +break ; +case V4L2_CID_GAIN : + dev->ctl_gain = c->value; +break ;case V4L2_CID_CONTRAST : dev->ctl_contrast = c->value;
@@ -2502,6 +2518,7 @@ dev->ctl_bright =ctrl_by_id (V4L2_CID_BRIGHTNESS )->default_value; dev->ctl_contrast =ctrl_by_id (V4L2_CID_CONTRAST )->default_value; dev->ctl_hue =ctrl_by_id (V4L2_CID_HUE )->default_value; + dev->ctl_gain =ctrl_by_id (V4L2_CID_GAIN )->default_value; dev->ctl_saturation =ctrl_by_id (V4L2_CID_SATURATION )->default_value; dev->ctl_volume =ctrl_by_id (V4L2_CID_AUDIO_VOLUME )->default_value; dev->ctl_mute =1 ;// ctrl_by_id(V4L2_CID_AUDIO_MUTE)->default_value;
linux/drivers/media/video/saa7134/saa7134.h +1 -0
@@ -548,6 +558,7 @@int ctl_bright;int ctl_contrast;int ctl_hue; +int ctl_gain;/* gain */ int ctl_saturation;int ctl_freq;int ctl_mute;/* audio */
--
video4linux-list mailing list
Unsubscribe mailto:[email protected]?subject=unsubscribe
https://www.redhat.com/mailman/listinfo/video4linux-list