aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/tvaudio.c
diff options
context:
space:
mode:
authorDaniel Glöckner <daniel-gl@gmx.net>2012-06-09 20:43:56 -0400
committerMauro Carvalho Chehab <mchehab@redhat.com>2012-06-18 19:46:40 -0400
commite21adca897ee3744d15b805321012f9c40d3659c (patch)
tree58418d45bea3f21f8b9119fa2478250a1852b0b0 /drivers/media/video/tvaudio.c
parent3322a59e095d648883fe68909df1b8f13ab096a9 (diff)
[media] tvaudio: obey V4L2 tuner audio matrix
V4L2 specifies the audio mode to use for combinations of possible (rxsubchans) and requested (audmode) audio modes. Up to now tvaudio has made these decisions automatically based on the possible audio modes from setting of the frequency until VIDIOC_S_TUNER was called. It then forced the hardware to use the mode requested by the user. With this patch it continues to adjust the audio mode while taking the requested mode into account. Signed-off-by: Daniel Glöckner <daniel-gl@gmx.net> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
Diffstat (limited to 'drivers/media/video/tvaudio.c')
-rw-r--r--drivers/media/video/tvaudio.c61
1 files changed, 32 insertions, 29 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c
index 58a0e9c2fd4b..04ebdfe30205 100644
--- a/drivers/media/video/tvaudio.c
+++ b/drivers/media/video/tvaudio.c
@@ -118,7 +118,7 @@ struct CHIPSTATE {
118 audiocmd shadow; 118 audiocmd shadow;
119 119
120 /* current settings */ 120 /* current settings */
121 __u16 left,right,treble,bass,muted,mode; 121 __u16 left, right, treble, bass, muted;
122 int prevmode; 122 int prevmode;
123 int radio; 123 int radio;
124 int input; 124 int input;
@@ -287,7 +287,7 @@ static int chip_thread(void *data)
287 struct CHIPSTATE *chip = data; 287 struct CHIPSTATE *chip = data;
288 struct CHIPDESC *desc = chip->desc; 288 struct CHIPDESC *desc = chip->desc;
289 struct v4l2_subdev *sd = &chip->sd; 289 struct v4l2_subdev *sd = &chip->sd;
290 int mode; 290 int mode, selected;
291 291
292 v4l2_dbg(1, debug, sd, "thread started\n"); 292 v4l2_dbg(1, debug, sd, "thread started\n");
293 set_freezable(); 293 set_freezable();
@@ -301,8 +301,8 @@ static int chip_thread(void *data)
301 break; 301 break;
302 v4l2_dbg(1, debug, sd, "thread wakeup\n"); 302 v4l2_dbg(1, debug, sd, "thread wakeup\n");
303 303
304 /* don't do anything for radio or if mode != auto */ 304 /* don't do anything for radio */
305 if (chip->radio || chip->mode != 0) 305 if (chip->radio)
306 continue; 306 continue;
307 307
308 /* have a look what's going on */ 308 /* have a look what's going on */
@@ -315,16 +315,27 @@ static int chip_thread(void *data)
315 315
316 chip->prevmode = mode; 316 chip->prevmode = mode;
317 317
318 if (mode & V4L2_TUNER_SUB_STEREO) 318 selected = V4L2_TUNER_MODE_MONO;
319 desc->setmode(chip, V4L2_TUNER_MODE_STEREO); 319 switch (chip->audmode) {
320 if (mode & V4L2_TUNER_SUB_LANG1_LANG2) 320 case V4L2_TUNER_MODE_MONO:
321 desc->setmode(chip, V4L2_TUNER_MODE_STEREO); 321 if (mode & V4L2_TUNER_SUB_LANG1)
322 else if (mode & V4L2_SUB_MODE_LANG1) 322 selected = V4L2_TUNER_MODE_LANG1;
323 desc->setmode(chip, V4L2_TUNER_MODE_LANG1); 323 break;
324 else if (mode & V4L2_SUB_MODE_LANG2) 324 case V4L2_TUNER_MODE_STEREO:
325 desc->setmode(chip, V4L2_TUNER_MODE_LANG2); 325 case V4L2_TUNER_MODE_LANG1:
326 else 326 if (mode & V4L2_TUNER_SUB_LANG1)
327 desc->setmode(chip, V4L2_TUNER_MODE_MONO); 327 selected = V4L2_TUNER_MODE_LANG1;
328 else if (mode & V4L2_TUNER_SUB_STEREO)
329 selected = V4L2_TUNER_MODE_STEREO;
330 break;
331 case V4L2_TUNER_MODE_LANG2:
332 if (mode & V4L2_TUNER_SUB_LANG2)
333 selected = V4L2_TUNER_MODE_LANG2;
334 else if (mode & V4L2_TUNER_SUB_STEREO)
335 selected = V4L2_TUNER_MODE_STEREO;
336 break;
337 }
338 desc->setmode(chip, selected);
328 339
329 /* schedule next check */ 340 /* schedule next check */
330 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); 341 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000));
@@ -712,7 +723,6 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode)
712 sw_data |= TDA9873_TR_DUALB; 723 sw_data |= TDA9873_TR_DUALB;
713 break; 724 break;
714 default: 725 default:
715 chip->mode = 0;
716 return; 726 return;
717 } 727 }
718 728
@@ -944,7 +954,6 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode)
944 mdacosr = (tda9874a_mode) ? 0x83:0x81; 954 mdacosr = (tda9874a_mode) ? 0x83:0x81;
945 break; 955 break;
946 default: 956 default:
947 chip->mode = 0;
948 return; 957 return;
949 } 958 }
950 chip_write(chip, TDA9874A_AOSR, aosr); 959 chip_write(chip, TDA9874A_AOSR, aosr);
@@ -979,7 +988,6 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode)
979 aosr = 0x20; /* dual B/B */ 988 aosr = 0x20; /* dual B/B */
980 break; 989 break;
981 default: 990 default:
982 chip->mode = 0;
983 return; 991 return;
984 } 992 }
985 chip_write(chip, TDA9874A_FMMR, fmmr); 993 chip_write(chip, TDA9874A_FMMR, fmmr);
@@ -1799,7 +1807,6 @@ static int tvaudio_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
1799{ 1807{
1800 struct CHIPSTATE *chip = to_state(sd); 1808 struct CHIPSTATE *chip = to_state(sd);
1801 struct CHIPDESC *desc = chip->desc; 1809 struct CHIPDESC *desc = chip->desc;
1802 int mode = 0;
1803 1810
1804 if (!desc->setmode) 1811 if (!desc->setmode)
1805 return 0; 1812 return 0;
@@ -1811,21 +1818,20 @@ static int tvaudio_s_tuner(struct v4l2_subdev *sd, struct v4l2_tuner *vt)
1811 case V4L2_TUNER_MODE_STEREO: 1818 case V4L2_TUNER_MODE_STEREO:
1812 case V4L2_TUNER_MODE_LANG1: 1819 case V4L2_TUNER_MODE_LANG1:
1813 case V4L2_TUNER_MODE_LANG2: 1820 case V4L2_TUNER_MODE_LANG2:
1814 mode = vt->audmode;
1815 break; 1821 break;
1816 case V4L2_TUNER_MODE_LANG1_LANG2: 1822 case V4L2_TUNER_MODE_LANG1_LANG2:
1817 mode = V4L2_TUNER_MODE_STEREO; 1823 vt->audmode = V4L2_TUNER_MODE_STEREO;
1818 break; 1824 break;
1819 default: 1825 default:
1820 return -EINVAL; 1826 return -EINVAL;
1821 } 1827 }
1822 chip->audmode = vt->audmode; 1828 chip->audmode = vt->audmode;
1823 1829
1824 if (mode) { 1830 if (chip->thread)
1825 /* del_timer(&chip->wt); */ 1831 wake_up_process(chip->thread);
1826 chip->mode = mode; 1832 else
1827 desc->setmode(chip, mode); 1833 desc->setmode(chip, vt->audmode);
1828 } 1834
1829 return 0; 1835 return 0;
1830} 1836}
1831 1837
@@ -1860,8 +1866,6 @@ static int tvaudio_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *fr
1860 struct CHIPSTATE *chip = to_state(sd); 1866 struct CHIPSTATE *chip = to_state(sd);
1861 struct CHIPDESC *desc = chip->desc; 1867 struct CHIPDESC *desc = chip->desc;
1862 1868
1863 chip->mode = 0; /* automatic */
1864
1865 /* For chips that provide getmode and setmode, and doesn't 1869 /* For chips that provide getmode and setmode, and doesn't
1866 automatically follows the stereo carrier, a kthread is 1870 automatically follows the stereo carrier, a kthread is
1867 created to set the audio standard. In this case, when then 1871 created to set the audio standard. In this case, when then
@@ -1872,8 +1876,7 @@ static int tvaudio_s_frequency(struct v4l2_subdev *sd, struct v4l2_frequency *fr
1872 */ 1876 */
1873 if (chip->thread) { 1877 if (chip->thread) {
1874 desc->setmode(chip, V4L2_TUNER_MODE_MONO); 1878 desc->setmode(chip, V4L2_TUNER_MODE_MONO);
1875 if (chip->prevmode != V4L2_TUNER_MODE_MONO) 1879 chip->prevmode = -1; /* reset previous mode */
1876 chip->prevmode = -1; /* reset previous mode */
1877 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); 1880 mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000));
1878 } 1881 }
1879 return 0; 1882 return 0;