diff options
author | Mauro Carvalho Chehab <mchehab@infradead.org> | 2006-08-25 15:53:08 -0400 |
---|---|---|
committer | Mauro Carvalho Chehab <mchehab@infradead.org> | 2008-01-25 16:01:00 -0500 |
commit | dc3d75da05c3ff2dd6510c32a11deacced49d1a1 (patch) | |
tree | 1139a11450c88201a56c1664a1ef343a8dc44f20 /drivers/media/video/tvaudio.c | |
parent | 155c6ab9ed255745758b6aa0f266e4d40aa32a21 (diff) |
V4L/DVB (6418): Converted tvaudio from V4L1 to V4L2
V4L1 ioctls were replaced to V4L2 were applicable. The older ones
already implemented were removed.
Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/tvaudio.c')
-rw-r--r-- | drivers/media/video/tvaudio.c | 306 |
1 files changed, 178 insertions, 128 deletions
diff --git a/drivers/media/video/tvaudio.c b/drivers/media/video/tvaudio.c index a19cdcc17ef7..bb510dd5ddab 100644 --- a/drivers/media/video/tvaudio.c +++ b/drivers/media/video/tvaudio.c | |||
@@ -307,14 +307,16 @@ static void generic_checkmode(struct CHIPSTATE *chip) | |||
307 | v4l_dbg(1, debug, &chip->c, "%s: thread checkmode\n", chip->c.name); | 307 | v4l_dbg(1, debug, &chip->c, "%s: thread checkmode\n", chip->c.name); |
308 | chip->prevmode = mode; | 308 | chip->prevmode = mode; |
309 | 309 | ||
310 | if (mode & VIDEO_SOUND_STEREO) | 310 | if (mode & V4L2_TUNER_MODE_STEREO) |
311 | desc->setmode(chip,VIDEO_SOUND_STEREO); | 311 | desc->setmode(chip,V4L2_TUNER_MODE_STEREO); |
312 | else if (mode & VIDEO_SOUND_LANG1) | 312 | if (mode & V4L2_TUNER_MODE_LANG1_LANG2) |
313 | desc->setmode(chip,VIDEO_SOUND_LANG1); | 313 | desc->setmode(chip,V4L2_TUNER_MODE_STEREO); |
314 | else if (mode & VIDEO_SOUND_LANG2) | 314 | else if (mode & V4L2_TUNER_MODE_LANG1) |
315 | desc->setmode(chip,VIDEO_SOUND_LANG2); | 315 | desc->setmode(chip,V4L2_TUNER_MODE_LANG1); |
316 | else if (mode & V4L2_TUNER_MODE_LANG2) | ||
317 | desc->setmode(chip,V4L2_TUNER_MODE_LANG2); | ||
316 | else | 318 | else |
317 | desc->setmode(chip,VIDEO_SOUND_MONO); | 319 | desc->setmode(chip,V4L2_TUNER_MODE_MONO); |
318 | } | 320 | } |
319 | 321 | ||
320 | /* ---------------------------------------------------------------------- */ | 322 | /* ---------------------------------------------------------------------- */ |
@@ -345,11 +347,11 @@ static int tda9840_getmode(struct CHIPSTATE *chip) | |||
345 | int val, mode; | 347 | int val, mode; |
346 | 348 | ||
347 | val = chip_read(chip); | 349 | val = chip_read(chip); |
348 | mode = VIDEO_SOUND_MONO; | 350 | mode = V4L2_TUNER_MODE_MONO; |
349 | if (val & TDA9840_DS_DUAL) | 351 | if (val & TDA9840_DS_DUAL) |
350 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 352 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; |
351 | if (val & TDA9840_ST_STEREO) | 353 | if (val & TDA9840_ST_STEREO) |
352 | mode |= VIDEO_SOUND_STEREO; | 354 | mode |= V4L2_TUNER_MODE_STEREO; |
353 | 355 | ||
354 | v4l_dbg(1, debug, &chip->c, "tda9840_getmode(): raw chip read: %d, return: %d\n", | 356 | v4l_dbg(1, debug, &chip->c, "tda9840_getmode(): raw chip read: %d, return: %d\n", |
355 | val, mode); | 357 | val, mode); |
@@ -362,16 +364,16 @@ static void tda9840_setmode(struct CHIPSTATE *chip, int mode) | |||
362 | int t = chip->shadow.bytes[TDA9840_SW + 1] & ~0x7e; | 364 | int t = chip->shadow.bytes[TDA9840_SW + 1] & ~0x7e; |
363 | 365 | ||
364 | switch (mode) { | 366 | switch (mode) { |
365 | case VIDEO_SOUND_MONO: | 367 | case V4L2_TUNER_MODE_MONO: |
366 | t |= TDA9840_MONO; | 368 | t |= TDA9840_MONO; |
367 | break; | 369 | break; |
368 | case VIDEO_SOUND_STEREO: | 370 | case V4L2_TUNER_MODE_STEREO: |
369 | t |= TDA9840_STEREO; | 371 | t |= TDA9840_STEREO; |
370 | break; | 372 | break; |
371 | case VIDEO_SOUND_LANG1: | 373 | case V4L2_TUNER_MODE_LANG1: |
372 | t |= TDA9840_DUALA; | 374 | t |= TDA9840_DUALA; |
373 | break; | 375 | break; |
374 | case VIDEO_SOUND_LANG2: | 376 | case V4L2_TUNER_MODE_LANG2: |
375 | t |= TDA9840_DUALB; | 377 | t |= TDA9840_DUALB; |
376 | break; | 378 | break; |
377 | default: | 379 | default: |
@@ -502,7 +504,7 @@ static int tda985x_getmode(struct CHIPSTATE *chip) | |||
502 | chip_read(chip)) >> 4; | 504 | chip_read(chip)) >> 4; |
503 | /* Add mono mode regardless of SAP and stereo */ | 505 | /* Add mono mode regardless of SAP and stereo */ |
504 | /* Allows forced mono */ | 506 | /* Allows forced mono */ |
505 | return mode | VIDEO_SOUND_MONO; | 507 | return mode | V4L2_TUNER_MODE_MONO; |
506 | } | 508 | } |
507 | 509 | ||
508 | static void tda985x_setmode(struct CHIPSTATE *chip, int mode) | 510 | static void tda985x_setmode(struct CHIPSTATE *chip, int mode) |
@@ -511,13 +513,13 @@ static void tda985x_setmode(struct CHIPSTATE *chip, int mode) | |||
511 | int c6 = chip->shadow.bytes[TDA985x_C6+1] & 0x3f; | 513 | int c6 = chip->shadow.bytes[TDA985x_C6+1] & 0x3f; |
512 | 514 | ||
513 | switch (mode) { | 515 | switch (mode) { |
514 | case VIDEO_SOUND_MONO: | 516 | case V4L2_TUNER_MODE_MONO: |
515 | c6 |= TDA985x_MONO; | 517 | c6 |= TDA985x_MONO; |
516 | break; | 518 | break; |
517 | case VIDEO_SOUND_STEREO: | 519 | case V4L2_TUNER_MODE_STEREO: |
518 | c6 |= TDA985x_STEREO; | 520 | c6 |= TDA985x_STEREO; |
519 | break; | 521 | break; |
520 | case VIDEO_SOUND_LANG1: | 522 | case V4L2_TUNER_MODE_LANG1: |
521 | c6 |= TDA985x_SAP; | 523 | c6 |= TDA985x_SAP; |
522 | break; | 524 | break; |
523 | default: | 525 | default: |
@@ -650,11 +652,11 @@ static int tda9873_getmode(struct CHIPSTATE *chip) | |||
650 | int val,mode; | 652 | int val,mode; |
651 | 653 | ||
652 | val = chip_read(chip); | 654 | val = chip_read(chip); |
653 | mode = VIDEO_SOUND_MONO; | 655 | mode = V4L2_TUNER_MODE_MONO; |
654 | if (val & TDA9873_STEREO) | 656 | if (val & TDA9873_STEREO) |
655 | mode |= VIDEO_SOUND_STEREO; | 657 | mode |= V4L2_TUNER_MODE_STEREO; |
656 | if (val & TDA9873_DUAL) | 658 | if (val & TDA9873_DUAL) |
657 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 659 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; |
658 | v4l_dbg(1, debug, &chip->c, "tda9873_getmode(): raw chip read: %d, return: %d\n", | 660 | v4l_dbg(1, debug, &chip->c, "tda9873_getmode(): raw chip read: %d, return: %d\n", |
659 | val, mode); | 661 | val, mode); |
660 | return mode; | 662 | return mode; |
@@ -674,16 +676,16 @@ static void tda9873_setmode(struct CHIPSTATE *chip, int mode) | |||
674 | v4l_dbg(1, debug, &chip->c, "tda9873_setmode(): sw_data = %d\n", sw_data); | 676 | v4l_dbg(1, debug, &chip->c, "tda9873_setmode(): sw_data = %d\n", sw_data); |
675 | 677 | ||
676 | switch (mode) { | 678 | switch (mode) { |
677 | case VIDEO_SOUND_MONO: | 679 | case V4L2_TUNER_MODE_MONO: |
678 | sw_data |= TDA9873_TR_MONO; | 680 | sw_data |= TDA9873_TR_MONO; |
679 | break; | 681 | break; |
680 | case VIDEO_SOUND_STEREO: | 682 | case V4L2_TUNER_MODE_STEREO: |
681 | sw_data |= TDA9873_TR_STEREO; | 683 | sw_data |= TDA9873_TR_STEREO; |
682 | break; | 684 | break; |
683 | case VIDEO_SOUND_LANG1: | 685 | case V4L2_TUNER_MODE_LANG1: |
684 | sw_data |= TDA9873_TR_DUALA; | 686 | sw_data |= TDA9873_TR_DUALA; |
685 | break; | 687 | break; |
686 | case VIDEO_SOUND_LANG2: | 688 | case V4L2_TUNER_MODE_LANG2: |
687 | sw_data |= TDA9873_TR_DUALB; | 689 | sw_data |= TDA9873_TR_DUALB; |
688 | break; | 690 | break; |
689 | default: | 691 | default: |
@@ -841,7 +843,7 @@ static int tda9874a_getmode(struct CHIPSTATE *chip) | |||
841 | int dsr,nsr,mode; | 843 | int dsr,nsr,mode; |
842 | int necr; /* just for debugging */ | 844 | int necr; /* just for debugging */ |
843 | 845 | ||
844 | mode = VIDEO_SOUND_MONO; | 846 | mode = V4L2_TUNER_MODE_MONO; |
845 | 847 | ||
846 | if(-1 == (dsr = chip_read2(chip,TDA9874A_DSR))) | 848 | if(-1 == (dsr = chip_read2(chip,TDA9874A_DSR))) |
847 | return mode; | 849 | return mode; |
@@ -860,18 +862,18 @@ static int tda9874a_getmode(struct CHIPSTATE *chip) | |||
860 | * that sound has (temporarily) switched from NICAM to | 862 | * that sound has (temporarily) switched from NICAM to |
861 | * mono FM (or AM) on 1st sound carrier due to high NICAM bit | 863 | * mono FM (or AM) on 1st sound carrier due to high NICAM bit |
862 | * error count. So in fact there is no stereo in this case :-( | 864 | * error count. So in fact there is no stereo in this case :-( |
863 | * But changing the mode to VIDEO_SOUND_MONO would switch | 865 | * But changing the mode to V4L2_TUNER_MODE_MONO would switch |
864 | * external 4052 multiplexer in audio_hook(). | 866 | * external 4052 multiplexer in audio_hook(). |
865 | */ | 867 | */ |
866 | if(nsr & 0x02) /* NSR.S/MB=1 */ | 868 | if(nsr & 0x02) /* NSR.S/MB=1 */ |
867 | mode |= VIDEO_SOUND_STEREO; | 869 | mode |= V4L2_TUNER_MODE_STEREO; |
868 | if(nsr & 0x01) /* NSR.D/SB=1 */ | 870 | if(nsr & 0x01) /* NSR.D/SB=1 */ |
869 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 871 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; |
870 | } else { | 872 | } else { |
871 | if(dsr & 0x02) /* DSR.IDSTE=1 */ | 873 | if(dsr & 0x02) /* DSR.IDSTE=1 */ |
872 | mode |= VIDEO_SOUND_STEREO; | 874 | mode |= V4L2_TUNER_MODE_STEREO; |
873 | if(dsr & 0x04) /* DSR.IDDUA=1 */ | 875 | if(dsr & 0x04) /* DSR.IDDUA=1 */ |
874 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 876 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; |
875 | } | 877 | } |
876 | 878 | ||
877 | v4l_dbg(1, debug, &chip->c, "tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", | 879 | v4l_dbg(1, debug, &chip->c, "tda9874a_getmode(): DSR=0x%X, NSR=0x%X, NECR=0x%X, return: %d.\n", |
@@ -902,14 +904,14 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | |||
902 | int mdacosr = (tda9874a_mode) ? 0x82:0x80; | 904 | int mdacosr = (tda9874a_mode) ? 0x82:0x80; |
903 | 905 | ||
904 | switch(mode) { | 906 | switch(mode) { |
905 | case VIDEO_SOUND_MONO: | 907 | case V4L2_TUNER_MODE_MONO: |
906 | case VIDEO_SOUND_STEREO: | 908 | case V4L2_TUNER_MODE_STEREO: |
907 | break; | 909 | break; |
908 | case VIDEO_SOUND_LANG1: | 910 | case V4L2_TUNER_MODE_LANG1: |
909 | aosr = 0x80; /* auto-select, dual A/A */ | 911 | aosr = 0x80; /* auto-select, dual A/A */ |
910 | mdacosr = (tda9874a_mode) ? 0x82:0x80; | 912 | mdacosr = (tda9874a_mode) ? 0x82:0x80; |
911 | break; | 913 | break; |
912 | case VIDEO_SOUND_LANG2: | 914 | case V4L2_TUNER_MODE_LANG2: |
913 | aosr = 0xa0; /* auto-select, dual B/B */ | 915 | aosr = 0xa0; /* auto-select, dual B/B */ |
914 | mdacosr = (tda9874a_mode) ? 0x83:0x81; | 916 | mdacosr = (tda9874a_mode) ? 0x83:0x81; |
915 | break; | 917 | break; |
@@ -927,11 +929,11 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | |||
927 | int fmmr,aosr; | 929 | int fmmr,aosr; |
928 | 930 | ||
929 | switch(mode) { | 931 | switch(mode) { |
930 | case VIDEO_SOUND_MONO: | 932 | case V4L2_TUNER_MODE_MONO: |
931 | fmmr = 0x00; /* mono */ | 933 | fmmr = 0x00; /* mono */ |
932 | aosr = 0x10; /* A/A */ | 934 | aosr = 0x10; /* A/A */ |
933 | break; | 935 | break; |
934 | case VIDEO_SOUND_STEREO: | 936 | case V4L2_TUNER_MODE_STEREO: |
935 | if(tda9874a_mode) { | 937 | if(tda9874a_mode) { |
936 | fmmr = 0x00; | 938 | fmmr = 0x00; |
937 | aosr = 0x00; /* handled by NICAM auto-mute */ | 939 | aosr = 0x00; /* handled by NICAM auto-mute */ |
@@ -940,11 +942,11 @@ static void tda9874a_setmode(struct CHIPSTATE *chip, int mode) | |||
940 | aosr = 0x00; | 942 | aosr = 0x00; |
941 | } | 943 | } |
942 | break; | 944 | break; |
943 | case VIDEO_SOUND_LANG1: | 945 | case V4L2_TUNER_MODE_LANG1: |
944 | fmmr = 0x02; /* dual */ | 946 | fmmr = 0x02; /* dual */ |
945 | aosr = 0x10; /* dual A/A */ | 947 | aosr = 0x10; /* dual A/A */ |
946 | break; | 948 | break; |
947 | case VIDEO_SOUND_LANG2: | 949 | case V4L2_TUNER_MODE_LANG2: |
948 | fmmr = 0x02; /* dual */ | 950 | fmmr = 0x02; /* dual */ |
949 | aosr = 0x20; /* dual B/B */ | 951 | aosr = 0x20; /* dual B/B */ |
950 | break; | 952 | break; |
@@ -1105,20 +1107,20 @@ static void tda8425_setmode(struct CHIPSTATE *chip, int mode) | |||
1105 | { | 1107 | { |
1106 | int s1 = chip->shadow.bytes[TDA8425_S1+1] & 0xe1; | 1108 | int s1 = chip->shadow.bytes[TDA8425_S1+1] & 0xe1; |
1107 | 1109 | ||
1108 | if (mode & VIDEO_SOUND_LANG1) { | 1110 | if (mode & V4L2_TUNER_MODE_LANG1) { |
1109 | s1 |= TDA8425_S1_ML_SOUND_A; | 1111 | s1 |= TDA8425_S1_ML_SOUND_A; |
1110 | s1 |= TDA8425_S1_STEREO_PSEUDO; | 1112 | s1 |= TDA8425_S1_STEREO_PSEUDO; |
1111 | 1113 | ||
1112 | } else if (mode & VIDEO_SOUND_LANG2) { | 1114 | } else if (mode & V4L2_TUNER_MODE_LANG2) { |
1113 | s1 |= TDA8425_S1_ML_SOUND_B; | 1115 | s1 |= TDA8425_S1_ML_SOUND_B; |
1114 | s1 |= TDA8425_S1_STEREO_PSEUDO; | 1116 | s1 |= TDA8425_S1_STEREO_PSEUDO; |
1115 | 1117 | ||
1116 | } else { | 1118 | } else { |
1117 | s1 |= TDA8425_S1_ML_STEREO; | 1119 | s1 |= TDA8425_S1_ML_STEREO; |
1118 | 1120 | ||
1119 | if (mode & VIDEO_SOUND_MONO) | 1121 | if (mode & V4L2_TUNER_MODE_MONO) |
1120 | s1 |= TDA8425_S1_STEREO_MONO; | 1122 | s1 |= TDA8425_S1_STEREO_MONO; |
1121 | if (mode & VIDEO_SOUND_STEREO) | 1123 | if (mode & V4L2_TUNER_MODE_STEREO) |
1122 | s1 |= TDA8425_S1_STEREO_SPATIAL; | 1124 | s1 |= TDA8425_S1_STEREO_SPATIAL; |
1123 | } | 1125 | } |
1124 | chip_write(chip,TDA8425_S1,s1); | 1126 | chip_write(chip,TDA8425_S1,s1); |
@@ -1177,11 +1179,11 @@ static int ta8874z_getmode(struct CHIPSTATE *chip) | |||
1177 | int val, mode; | 1179 | int val, mode; |
1178 | 1180 | ||
1179 | val = chip_read(chip); | 1181 | val = chip_read(chip); |
1180 | mode = VIDEO_SOUND_MONO; | 1182 | mode = V4L2_TUNER_MODE_MONO; |
1181 | if (val & TA8874Z_B1){ | 1183 | if (val & TA8874Z_B1){ |
1182 | mode |= VIDEO_SOUND_LANG1 | VIDEO_SOUND_LANG2; | 1184 | mode |= V4L2_TUNER_MODE_LANG1 | V4L2_TUNER_MODE_LANG2; |
1183 | }else if (!(val & TA8874Z_B0)){ | 1185 | }else if (!(val & TA8874Z_B0)){ |
1184 | mode |= VIDEO_SOUND_STEREO; | 1186 | mode |= V4L2_TUNER_MODE_STEREO; |
1185 | } | 1187 | } |
1186 | /* v4l_dbg(1, debug, &chip->c, "ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ | 1188 | /* v4l_dbg(1, debug, &chip->c, "ta8874z_getmode(): raw chip read: 0x%02x, return: 0x%02x\n", val, mode); */ |
1187 | return mode; | 1189 | return mode; |
@@ -1199,16 +1201,16 @@ static void ta8874z_setmode(struct CHIPSTATE *chip, int mode) | |||
1199 | v4l_dbg(1, debug, &chip->c, "ta8874z_setmode(): mode: 0x%02x\n", mode); | 1201 | v4l_dbg(1, debug, &chip->c, "ta8874z_setmode(): mode: 0x%02x\n", mode); |
1200 | 1202 | ||
1201 | switch(mode){ | 1203 | switch(mode){ |
1202 | case VIDEO_SOUND_MONO: | 1204 | case V4L2_TUNER_MODE_MONO: |
1203 | t = &ta8874z_mono; | 1205 | t = &ta8874z_mono; |
1204 | break; | 1206 | break; |
1205 | case VIDEO_SOUND_STEREO: | 1207 | case V4L2_TUNER_MODE_STEREO: |
1206 | t = &ta8874z_stereo; | 1208 | t = &ta8874z_stereo; |
1207 | break; | 1209 | break; |
1208 | case VIDEO_SOUND_LANG1: | 1210 | case V4L2_TUNER_MODE_LANG1: |
1209 | t = &ta8874z_main; | 1211 | t = &ta8874z_main; |
1210 | break; | 1212 | break; |
1211 | case VIDEO_SOUND_LANG2: | 1213 | case V4L2_TUNER_MODE_LANG2: |
1212 | t = &ta8874z_sub; | 1214 | t = &ta8874z_sub; |
1213 | break; | 1215 | break; |
1214 | default: | 1216 | default: |
@@ -1570,7 +1572,48 @@ static int chip_detach(struct i2c_client *client) | |||
1570 | return 0; | 1572 | return 0; |
1571 | } | 1573 | } |
1572 | 1574 | ||
1573 | static int tvaudio_set_ctrl(struct CHIPSTATE *chip, struct v4l2_control *ctrl) | 1575 | static int tvaudio_get_ctrl(struct CHIPSTATE *chip, |
1576 | struct v4l2_control *ctrl) | ||
1577 | { | ||
1578 | struct CHIPDESC *desc = chiplist + chip->type; | ||
1579 | |||
1580 | switch (ctrl->id) { | ||
1581 | case V4L2_CID_AUDIO_MUTE: | ||
1582 | ctrl->value=chip->muted; | ||
1583 | return 0; | ||
1584 | case V4L2_CID_AUDIO_VOLUME: | ||
1585 | if (!desc->flags & CHIP_HAS_VOLUME) | ||
1586 | break; | ||
1587 | ctrl->value = max(chip->left,chip->right); | ||
1588 | return 0; | ||
1589 | case V4L2_CID_AUDIO_BALANCE: | ||
1590 | { | ||
1591 | int volume; | ||
1592 | if (!desc->flags & CHIP_HAS_VOLUME) | ||
1593 | break; | ||
1594 | volume = max(chip->left,chip->right); | ||
1595 | if (volume) | ||
1596 | ctrl->value=(32768*min(chip->left,chip->right))/volume; | ||
1597 | else | ||
1598 | ctrl->value=32768; | ||
1599 | return 0; | ||
1600 | } | ||
1601 | case V4L2_CID_AUDIO_BASS: | ||
1602 | if (desc->flags & CHIP_HAS_BASSTREBLE) | ||
1603 | break; | ||
1604 | ctrl->value = chip->bass; | ||
1605 | return 0; | ||
1606 | case V4L2_CID_AUDIO_TREBLE: | ||
1607 | if (desc->flags & CHIP_HAS_BASSTREBLE) | ||
1608 | return -EINVAL; | ||
1609 | ctrl->value = chip->treble; | ||
1610 | return 0; | ||
1611 | } | ||
1612 | return -EINVAL; | ||
1613 | } | ||
1614 | |||
1615 | static int tvaudio_set_ctrl(struct CHIPSTATE *chip, | ||
1616 | struct v4l2_control *ctrl) | ||
1574 | { | 1617 | { |
1575 | struct CHIPDESC *desc = chiplist + chip->type; | 1618 | struct CHIPDESC *desc = chiplist + chip->type; |
1576 | 1619 | ||
@@ -1584,11 +1627,60 @@ static int tvaudio_set_ctrl(struct CHIPSTATE *chip, struct v4l2_control *ctrl) | |||
1584 | else | 1627 | else |
1585 | chip_write_masked(chip,desc->inputreg, | 1628 | chip_write_masked(chip,desc->inputreg, |
1586 | desc->inputmap[chip->input],desc->inputmask); | 1629 | desc->inputmap[chip->input],desc->inputmask); |
1587 | break; | 1630 | return 0; |
1588 | default: | 1631 | case V4L2_CID_AUDIO_VOLUME: |
1589 | return -EINVAL; | 1632 | { |
1633 | int volume,balance; | ||
1634 | |||
1635 | if (!desc->flags & CHIP_HAS_VOLUME) | ||
1636 | break; | ||
1637 | |||
1638 | volume = max(chip->left,chip->right); | ||
1639 | if (volume) | ||
1640 | balance=(32768*min(chip->left,chip->right))/volume; | ||
1641 | else | ||
1642 | balance=32768; | ||
1643 | |||
1644 | volume=ctrl->value; | ||
1645 | chip->left = (min(65536 - balance,32768) * volume) / 32768; | ||
1646 | chip->right = (min(balance,volume *(__u16)32768)) / 32768; | ||
1647 | |||
1648 | chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); | ||
1649 | chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); | ||
1650 | |||
1651 | return 0; | ||
1590 | } | 1652 | } |
1591 | return 0; | 1653 | case V4L2_CID_AUDIO_BALANCE: |
1654 | { | ||
1655 | int volume, balance; | ||
1656 | if (!desc->flags & CHIP_HAS_VOLUME) | ||
1657 | break; | ||
1658 | |||
1659 | volume = max(chip->left,chip->right); | ||
1660 | balance = ctrl->value; | ||
1661 | |||
1662 | chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); | ||
1663 | chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); | ||
1664 | |||
1665 | return 0; | ||
1666 | } | ||
1667 | case V4L2_CID_AUDIO_BASS: | ||
1668 | if (desc->flags & CHIP_HAS_BASSTREBLE) | ||
1669 | break; | ||
1670 | chip->bass = ctrl->value; | ||
1671 | chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); | ||
1672 | |||
1673 | return 0; | ||
1674 | case V4L2_CID_AUDIO_TREBLE: | ||
1675 | if (desc->flags & CHIP_HAS_BASSTREBLE) | ||
1676 | return -EINVAL; | ||
1677 | |||
1678 | chip->treble = ctrl->value; | ||
1679 | chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); | ||
1680 | |||
1681 | return 0; | ||
1682 | } | ||
1683 | return -EINVAL; | ||
1592 | } | 1684 | } |
1593 | 1685 | ||
1594 | 1686 | ||
@@ -1609,67 +1701,36 @@ static int chip_command(struct i2c_client *client, | |||
1609 | chip->watch_stereo = 0; | 1701 | chip->watch_stereo = 0; |
1610 | /* del_timer(&chip->wt); */ | 1702 | /* del_timer(&chip->wt); */ |
1611 | break; | 1703 | break; |
1612 | |||
1613 | /* --- v4l ioctls --- */ | 1704 | /* --- v4l ioctls --- */ |
1614 | /* take care: bttv does userspace copying, we'll get a | 1705 | /* take care: bttv does userspace copying, we'll get a |
1615 | kernel pointer here... */ | 1706 | kernel pointer here... */ |
1616 | case VIDIOCGAUDIO: | 1707 | case VIDIOC_QUERYCTRL: |
1617 | { | ||
1618 | struct video_audio *va = arg; | ||
1619 | |||
1620 | if (desc->flags & CHIP_HAS_VOLUME) { | ||
1621 | va->flags |= VIDEO_AUDIO_VOLUME; | ||
1622 | va->volume = max(chip->left,chip->right); | ||
1623 | if (va->volume) | ||
1624 | va->balance = (32768*min(chip->left,chip->right))/ | ||
1625 | va->volume; | ||
1626 | else | ||
1627 | va->balance = 32768; | ||
1628 | } | ||
1629 | if (desc->flags & CHIP_HAS_BASSTREBLE) { | ||
1630 | va->flags |= VIDEO_AUDIO_BASS | VIDEO_AUDIO_TREBLE; | ||
1631 | va->bass = chip->bass; | ||
1632 | va->treble = chip->treble; | ||
1633 | } | ||
1634 | if (!chip->radio) { | ||
1635 | if (desc->getmode) | ||
1636 | va->mode = desc->getmode(chip); | ||
1637 | else | ||
1638 | va->mode = VIDEO_SOUND_MONO; | ||
1639 | } | ||
1640 | break; | ||
1641 | } | ||
1642 | |||
1643 | case VIDIOCSAUDIO: | ||
1644 | { | 1708 | { |
1645 | struct video_audio *va = arg; | 1709 | struct v4l2_queryctrl *qc = arg; |
1646 | 1710 | ||
1647 | if (desc->flags & CHIP_HAS_VOLUME) { | 1711 | switch (qc->id) { |
1648 | chip->left = (min(65536 - va->balance,32768) * | 1712 | case V4L2_CID_AUDIO_MUTE: |
1649 | va->volume) / 32768; | 1713 | break; |
1650 | chip->right = (min(va->balance,(__u16)32768) * | 1714 | case V4L2_CID_AUDIO_VOLUME: |
1651 | va->volume) / 32768; | 1715 | case V4L2_CID_AUDIO_BALANCE: |
1652 | chip_write(chip,desc->leftreg,desc->volfunc(chip->left)); | 1716 | if (!desc->flags & CHIP_HAS_VOLUME) |
1653 | chip_write(chip,desc->rightreg,desc->volfunc(chip->right)); | 1717 | return -EINVAL; |
1654 | } | 1718 | break; |
1655 | if (desc->flags & CHIP_HAS_BASSTREBLE) { | 1719 | case V4L2_CID_AUDIO_BASS: |
1656 | chip->bass = va->bass; | 1720 | case V4L2_CID_AUDIO_TREBLE: |
1657 | chip->treble = va->treble; | 1721 | if (desc->flags & CHIP_HAS_BASSTREBLE) |
1658 | chip_write(chip,desc->bassreg,desc->bassfunc(chip->bass)); | 1722 | return -EINVAL; |
1659 | chip_write(chip,desc->treblereg,desc->treblefunc(chip->treble)); | 1723 | break; |
1660 | } | 1724 | default: |
1661 | if (desc->setmode && va->mode) { | 1725 | return -EINVAL; |
1662 | chip->watch_stereo = 0; | ||
1663 | /* del_timer(&chip->wt); */ | ||
1664 | chip->mode = va->mode; | ||
1665 | desc->setmode(chip,va->mode); | ||
1666 | } | 1726 | } |
1667 | break; | 1727 | return v4l2_ctrl_query_fill_std(qc); |
1668 | } | 1728 | } |
1669 | |||
1670 | case VIDIOC_S_CTRL: | 1729 | case VIDIOC_S_CTRL: |
1671 | return tvaudio_set_ctrl(chip, arg); | 1730 | return tvaudio_set_ctrl(chip, arg); |
1672 | 1731 | ||
1732 | case VIDIOC_G_CTRL: | ||
1733 | return tvaudio_get_ctrl(chip, arg); | ||
1673 | case VIDIOC_INT_G_AUDIO_ROUTING: | 1734 | case VIDIOC_INT_G_AUDIO_ROUTING: |
1674 | { | 1735 | { |
1675 | struct v4l2_routing *rt = arg; | 1736 | struct v4l2_routing *rt = arg; |
@@ -1678,7 +1739,6 @@ static int chip_command(struct i2c_client *client, | |||
1678 | rt->output = 0; | 1739 | rt->output = 0; |
1679 | break; | 1740 | break; |
1680 | } | 1741 | } |
1681 | |||
1682 | case VIDIOC_INT_S_AUDIO_ROUTING: | 1742 | case VIDIOC_INT_S_AUDIO_ROUTING: |
1683 | { | 1743 | { |
1684 | struct v4l2_routing *rt = arg; | 1744 | struct v4l2_routing *rt = arg; |
@@ -1693,7 +1753,6 @@ static int chip_command(struct i2c_client *client, | |||
1693 | desc->inputmap[chip->input], desc->inputmask); | 1753 | desc->inputmap[chip->input], desc->inputmask); |
1694 | break; | 1754 | break; |
1695 | } | 1755 | } |
1696 | |||
1697 | case VIDIOC_S_TUNER: | 1756 | case VIDIOC_S_TUNER: |
1698 | { | 1757 | { |
1699 | struct v4l2_tuner *vt = arg; | 1758 | struct v4l2_tuner *vt = arg; |
@@ -1703,17 +1762,13 @@ static int chip_command(struct i2c_client *client, | |||
1703 | break; | 1762 | break; |
1704 | switch (vt->audmode) { | 1763 | switch (vt->audmode) { |
1705 | case V4L2_TUNER_MODE_MONO: | 1764 | case V4L2_TUNER_MODE_MONO: |
1706 | mode = VIDEO_SOUND_MONO; | ||
1707 | break; | ||
1708 | case V4L2_TUNER_MODE_STEREO: | 1765 | case V4L2_TUNER_MODE_STEREO: |
1709 | case V4L2_TUNER_MODE_LANG1_LANG2: | ||
1710 | mode = VIDEO_SOUND_STEREO; | ||
1711 | break; | ||
1712 | case V4L2_TUNER_MODE_LANG1: | 1766 | case V4L2_TUNER_MODE_LANG1: |
1713 | mode = VIDEO_SOUND_LANG1; | ||
1714 | break; | ||
1715 | case V4L2_TUNER_MODE_LANG2: | 1767 | case V4L2_TUNER_MODE_LANG2: |
1716 | mode = VIDEO_SOUND_LANG2; | 1768 | mode = vt->audmode; |
1769 | break; | ||
1770 | case V4L2_TUNER_MODE_LANG1_LANG2: | ||
1771 | mode = V4L2_TUNER_MODE_STEREO; | ||
1717 | break; | 1772 | break; |
1718 | default: | 1773 | default: |
1719 | return -EINVAL; | 1774 | return -EINVAL; |
@@ -1728,11 +1783,10 @@ static int chip_command(struct i2c_client *client, | |||
1728 | } | 1783 | } |
1729 | break; | 1784 | break; |
1730 | } | 1785 | } |
1731 | |||
1732 | case VIDIOC_G_TUNER: | 1786 | case VIDIOC_G_TUNER: |
1733 | { | 1787 | { |
1734 | struct v4l2_tuner *vt = arg; | 1788 | struct v4l2_tuner *vt = arg; |
1735 | int mode = VIDEO_SOUND_MONO; | 1789 | int mode = V4L2_TUNER_MODE_MONO; |
1736 | 1790 | ||
1737 | if (chip->radio) | 1791 | if (chip->radio) |
1738 | break; | 1792 | break; |
@@ -1744,30 +1798,26 @@ static int chip_command(struct i2c_client *client, | |||
1744 | if (desc->getmode) | 1798 | if (desc->getmode) |
1745 | mode = desc->getmode(chip); | 1799 | mode = desc->getmode(chip); |
1746 | 1800 | ||
1747 | if (mode & VIDEO_SOUND_MONO) | 1801 | if (mode & V4L2_TUNER_MODE_MONO) |
1748 | vt->rxsubchans |= V4L2_TUNER_SUB_MONO; | 1802 | vt->rxsubchans |= V4L2_TUNER_SUB_MONO; |
1749 | if (mode & VIDEO_SOUND_STEREO) | 1803 | if (mode & V4L2_TUNER_MODE_STEREO) |
1750 | vt->rxsubchans |= V4L2_TUNER_SUB_STEREO; | 1804 | vt->rxsubchans |= V4L2_TUNER_SUB_STEREO; |
1751 | /* Note: for SAP it should be mono/lang2 or stereo/lang2. | 1805 | /* Note: for SAP it should be mono/lang2 or stereo/lang2. |
1752 | When this module is converted fully to v4l2, then this | 1806 | When this module is converted fully to v4l2, then this |
1753 | should change for those chips that can detect SAP. */ | 1807 | should change for those chips that can detect SAP. */ |
1754 | if (mode & VIDEO_SOUND_LANG1) | 1808 | if (mode & V4L2_TUNER_MODE_LANG1) |
1755 | vt->rxsubchans = V4L2_TUNER_SUB_LANG1 | | 1809 | vt->rxsubchans = V4L2_TUNER_SUB_LANG1 | |
1756 | V4L2_TUNER_SUB_LANG2; | 1810 | V4L2_TUNER_SUB_LANG2; |
1757 | break; | 1811 | break; |
1758 | } | 1812 | } |
1759 | |||
1760 | case VIDIOCSCHAN: | ||
1761 | case VIDIOC_S_STD: | 1813 | case VIDIOC_S_STD: |
1762 | chip->radio = 0; | 1814 | chip->radio = 0; |
1763 | break; | 1815 | break; |
1764 | |||
1765 | case VIDIOCSFREQ: | ||
1766 | case VIDIOC_S_FREQUENCY: | 1816 | case VIDIOC_S_FREQUENCY: |
1767 | chip->mode = 0; /* automatic */ | 1817 | chip->mode = 0; /* automatic */ |
1768 | if (desc->checkmode) { | 1818 | if (desc->checkmode) { |
1769 | desc->setmode(chip,VIDEO_SOUND_MONO); | 1819 | desc->setmode(chip,V4L2_TUNER_MODE_MONO); |
1770 | if (chip->prevmode != VIDEO_SOUND_MONO) | 1820 | if (chip->prevmode != V4L2_TUNER_MODE_MONO) |
1771 | chip->prevmode = -1; /* reset previous mode */ | 1821 | chip->prevmode = -1; /* reset previous mode */ |
1772 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); | 1822 | mod_timer(&chip->wt, jiffies+msecs_to_jiffies(2000)); |
1773 | /* the thread will call checkmode() later */ | 1823 | /* the thread will call checkmode() later */ |