aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/video/msp3400-driver.c
diff options
context:
space:
mode:
authorHans Verkuil <hverkuil@xs4all.nl>2007-12-12 06:25:18 -0500
committerMauro Carvalho Chehab <mchehab@infradead.org>2008-01-25 16:04:06 -0500
commitd52c7385ec8d4d2081b0db47e309723ce3eae816 (patch)
treeaf05ca1d3a625a6cf6ec825b45d5e73e79503775 /drivers/media/video/msp3400-driver.c
parent35df38c015866b3c28bfb1914b14eba92086cdd1 (diff)
V4L/DVB (6866): msp3400: CodingStyle cleanups
Signed-off-by: Hans Verkuil <hverkuil@xs4all.nl> Signed-off-by: Mauro Carvalho Chehab <mchehab@infradead.org>
Diffstat (limited to 'drivers/media/video/msp3400-driver.c')
-rw-r--r--drivers/media/video/msp3400-driver.c167
1 files changed, 97 insertions, 70 deletions
diff --git a/drivers/media/video/msp3400-driver.c b/drivers/media/video/msp3400-driver.c
index f4c14604b0b..7a11f3159e3 100644
--- a/drivers/media/video/msp3400-driver.c
+++ b/drivers/media/video/msp3400-driver.c
@@ -42,7 +42,8 @@
42 * 42 *
43 * You should have received a copy of the GNU General Public License 43 * You should have received a copy of the GNU General Public License
44 * along with this program; if not, write to the Free Software 44 * along with this program; if not, write to the Free Software
45 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 45 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
46 * 02110-1301, USA.
46 */ 47 */
47 48
48 49
@@ -72,7 +73,8 @@ int msp_debug; /* msp_debug output */
72int msp_once; /* no continous stereo monitoring */ 73int msp_once; /* no continous stereo monitoring */
73int msp_amsound; /* hard-wire AM sound at 6.5 Hz (france), 74int msp_amsound; /* hard-wire AM sound at 6.5 Hz (france),
74 the autoscan seems work well only with FM... */ 75 the autoscan seems work well only with FM... */
75int msp_standard = 1; /* Override auto detect of audio msp_standard, if needed. */ 76int msp_standard = 1; /* Override auto detect of audio msp_standard,
77 if needed. */
76int msp_dolby; 78int msp_dolby;
77 79
78int msp_stereo_thresh = 0x190; /* a2 threshold for stereo/bilingual 80int msp_stereo_thresh = 0x190; /* a2 threshold for stereo/bilingual
@@ -82,12 +84,12 @@ int msp_stereo_thresh = 0x190; /* a2 threshold for stereo/bilingual
82module_param(opmode, int, 0444); 84module_param(opmode, int, 0444);
83 85
84/* read-write */ 86/* read-write */
85module_param_named(once,msp_once, bool, 0644); 87module_param_named(once, msp_once, bool, 0644);
86module_param_named(debug,msp_debug, int, 0644); 88module_param_named(debug, msp_debug, int, 0644);
87module_param_named(stereo_threshold,msp_stereo_thresh, int, 0644); 89module_param_named(stereo_threshold, msp_stereo_thresh, int, 0644);
88module_param_named(standard,msp_standard, int, 0644); 90module_param_named(standard, msp_standard, int, 0644);
89module_param_named(amsound,msp_amsound, bool, 0644); 91module_param_named(amsound, msp_amsound, bool, 0644);
90module_param_named(dolby,msp_dolby, bool, 0644); 92module_param_named(dolby, msp_dolby, bool, 0644);
91 93
92MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Autodetect, 2=Autodetect and autoselect"); 94MODULE_PARM_DESC(opmode, "Forces a MSP3400 opmode. 0=Manual, 1=Autodetect, 2=Autodetect and autoselect");
93MODULE_PARM_DESC(once, "No continuous stereo monitoring"); 95MODULE_PARM_DESC(once, "No continuous stereo monitoring");
@@ -161,12 +163,13 @@ static int msp_read(struct i2c_client *client, int dev, int addr)
161 schedule_timeout_interruptible(msecs_to_jiffies(10)); 163 schedule_timeout_interruptible(msecs_to_jiffies(10));
162 } 164 }
163 if (err == 3) { 165 if (err == 3) {
164 v4l_warn(client, "giving up, resetting chip. Sound will go off, sorry folks :-|\n"); 166 v4l_warn(client, "resetting chip, sound will go off.\n");
165 msp_reset(client); 167 msp_reset(client);
166 return -1; 168 return -1;
167 } 169 }
168 retval = read[0] << 8 | read[1]; 170 retval = read[0] << 8 | read[1];
169 v4l_dbg(3, msp_debug, client, "msp_read(0x%x, 0x%x): 0x%x\n", dev, addr, retval); 171 v4l_dbg(3, msp_debug, client, "msp_read(0x%x, 0x%x): 0x%x\n",
172 dev, addr, retval);
170 return retval; 173 return retval;
171} 174}
172 175
@@ -191,7 +194,8 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val)
191 buffer[3] = val >> 8; 194 buffer[3] = val >> 8;
192 buffer[4] = val & 0xff; 195 buffer[4] = val & 0xff;
193 196
194 v4l_dbg(3, msp_debug, client, "msp_write(0x%x, 0x%x, 0x%x)\n", dev, addr, val); 197 v4l_dbg(3, msp_debug, client, "msp_write(0x%x, 0x%x, 0x%x)\n",
198 dev, addr, val);
195 for (err = 0; err < 3; err++) { 199 for (err = 0; err < 3; err++) {
196 if (i2c_master_send(client, buffer, 5) == 5) 200 if (i2c_master_send(client, buffer, 5) == 5)
197 break; 201 break;
@@ -200,7 +204,7 @@ static int msp_write(struct i2c_client *client, int dev, int addr, int val)
200 schedule_timeout_interruptible(msecs_to_jiffies(10)); 204 schedule_timeout_interruptible(msecs_to_jiffies(10));
201 } 205 }
202 if (err == 3) { 206 if (err == 3) {
203 v4l_warn(client, "giving up, resetting chip. Sound will go off, sorry folks :-|\n"); 207 v4l_warn(client, "resetting chip, sound will go off.\n");
204 msp_reset(client); 208 msp_reset(client);
205 return -1; 209 return -1;
206 } 210 }
@@ -274,7 +278,7 @@ void msp_set_scart(struct i2c_client *client, int in, int out)
274 state->acb = 0xf60; /* Mute Input and SCART 1 Output */ 278 state->acb = 0xf60; /* Mute Input and SCART 1 Output */
275 279
276 v4l_dbg(1, msp_debug, client, "scart switch: %s => %d (ACB=0x%04x)\n", 280 v4l_dbg(1, msp_debug, client, "scart switch: %s => %d (ACB=0x%04x)\n",
277 scart_names[in], out, state->acb); 281 scart_names[in], out, state->acb);
278 msp_write_dsp(client, 0x13, state->acb); 282 msp_write_dsp(client, 0x13, state->acb);
279 283
280 /* Sets I2S speed 0 = 1.024 Mbps, 1 = 2.048 Mbps */ 284 /* Sets I2S speed 0 = 1.024 Mbps, 1 = 2.048 Mbps */
@@ -293,7 +297,8 @@ void msp_set_audio(struct i2c_client *client)
293 val = (state->volume * 0x7f / 65535) << 8; 297 val = (state->volume * 0x7f / 65535) << 8;
294 298
295 v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n", 299 v4l_dbg(1, msp_debug, client, "mute=%s scanning=%s volume=%d\n",
296 state->muted ? "on" : "off", state->scan_in_progress ? "yes" : "no", 300 state->muted ? "on" : "off",
301 state->scan_in_progress ? "yes" : "no",
297 state->volume); 302 state->volume);
298 303
299 msp_write_dsp(client, 0x0000, val); 304 msp_write_dsp(client, 0x0000, val);
@@ -682,14 +687,14 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
682 v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", *a); 687 v4l_dbg(1, msp_debug, client, "Setting I2S speed to %d\n", *a);
683 688
684 switch (*a) { 689 switch (*a) {
685 case 1024000: 690 case 1024000:
686 state->i2s_mode = 0; 691 state->i2s_mode = 0;
687 break; 692 break;
688 case 2048000: 693 case 2048000:
689 state->i2s_mode = 1; 694 state->i2s_mode = 1;
690 break; 695 break;
691 default: 696 default:
692 return -EINVAL; 697 return -EINVAL;
693 } 698 }
694 break; 699 break;
695 } 700 }
@@ -699,22 +704,22 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
699 struct v4l2_queryctrl *qc = arg; 704 struct v4l2_queryctrl *qc = arg;
700 705
701 switch (qc->id) { 706 switch (qc->id) {
702 case V4L2_CID_AUDIO_VOLUME: 707 case V4L2_CID_AUDIO_VOLUME:
703 case V4L2_CID_AUDIO_MUTE: 708 case V4L2_CID_AUDIO_MUTE:
704 return v4l2_ctrl_query_fill_std(qc); 709 return v4l2_ctrl_query_fill_std(qc);
705 default: 710 default:
706 break; 711 break;
707 } 712 }
708 if (!state->has_sound_processing) 713 if (!state->has_sound_processing)
709 return -EINVAL; 714 return -EINVAL;
710 switch (qc->id) { 715 switch (qc->id) {
711 case V4L2_CID_AUDIO_LOUDNESS: 716 case V4L2_CID_AUDIO_LOUDNESS:
712 case V4L2_CID_AUDIO_BALANCE: 717 case V4L2_CID_AUDIO_BALANCE:
713 case V4L2_CID_AUDIO_BASS: 718 case V4L2_CID_AUDIO_BASS:
714 case V4L2_CID_AUDIO_TREBLE: 719 case V4L2_CID_AUDIO_TREBLE:
715 return v4l2_ctrl_query_fill_std(qc); 720 return v4l2_ctrl_query_fill_std(qc);
716 default: 721 default:
717 return -EINVAL; 722 return -EINVAL;
718 } 723 }
719 } 724 }
720 725
@@ -736,13 +741,14 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
736 state->volume, state->muted ? " (muted)" : ""); 741 state->volume, state->muted ? " (muted)" : "");
737 if (state->has_sound_processing) { 742 if (state->has_sound_processing) {
738 v4l_info(client, "Audio: balance %d bass %d treble %d loudness %s\n", 743 v4l_info(client, "Audio: balance %d bass %d treble %d loudness %s\n",
739 state->balance, state->bass, state->treble, 744 state->balance, state->bass,
745 state->treble,
740 state->loudness ? "on" : "off"); 746 state->loudness ? "on" : "off");
741 } 747 }
742 switch (state->mode) { 748 switch (state->mode) {
743 case MSP_MODE_AM_DETECT: p = "AM (for carrier detect)"; break; 749 case MSP_MODE_AM_DETECT: p = "AM (for carrier detect)"; break;
744 case MSP_MODE_FM_RADIO: p = "FM Radio"; break; 750 case MSP_MODE_FM_RADIO: p = "FM Radio"; break;
745 case MSP_MODE_FM_TERRA: p = "Terrestial FM-mono + FM-stereo"; break; 751 case MSP_MODE_FM_TERRA: p = "Terrestial FM-mono/stereo"; break;
746 case MSP_MODE_FM_SAT: p = "Satellite FM-mono"; break; 752 case MSP_MODE_FM_SAT: p = "Satellite FM-mono"; break;
747 case MSP_MODE_FM_NICAM1: p = "NICAM/FM (B/G, D/K)"; break; 753 case MSP_MODE_FM_NICAM1: p = "NICAM/FM (B/G, D/K)"; break;
748 case MSP_MODE_FM_NICAM2: p = "NICAM/FM (I)"; break; 754 case MSP_MODE_FM_NICAM2: p = "NICAM/FM (I)"; break;
@@ -773,7 +779,8 @@ static int msp_command(struct i2c_client *client, unsigned int cmd, void *arg)
773 } 779 }
774 780
775 case VIDIOC_G_CHIP_IDENT: 781 case VIDIOC_G_CHIP_IDENT:
776 return v4l2_chip_ident_i2c_client(client, arg, state->ident, (state->rev1 << 16) | state->rev2); 782 return v4l2_chip_ident_i2c_client(client, arg, state->ident,
783 (state->rev1 << 16) | state->rev2);
777 784
778 default: 785 default:
779 /* unknown */ 786 /* unknown */
@@ -816,9 +823,8 @@ static int msp_probe(struct i2c_client *client)
816 } 823 }
817 824
818 state = kzalloc(sizeof(*state), GFP_KERNEL); 825 state = kzalloc(sizeof(*state), GFP_KERNEL);
819 if (!state) { 826 if (!state)
820 return -ENOMEM; 827 return -ENOMEM;
821 }
822 828
823 i2c_set_clientdata(client, state); 829 i2c_set_clientdata(client, state);
824 830
@@ -840,9 +846,11 @@ static int msp_probe(struct i2c_client *client)
840 state->rev1 = msp_read_dsp(client, 0x1e); 846 state->rev1 = msp_read_dsp(client, 0x1e);
841 if (state->rev1 != -1) 847 if (state->rev1 != -1)
842 state->rev2 = msp_read_dsp(client, 0x1f); 848 state->rev2 = msp_read_dsp(client, 0x1f);
843 v4l_dbg(1, msp_debug, client, "rev1=0x%04x, rev2=0x%04x\n", state->rev1, state->rev2); 849 v4l_dbg(1, msp_debug, client, "rev1=0x%04x, rev2=0x%04x\n",
850 state->rev1, state->rev2);
844 if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) { 851 if (state->rev1 == -1 || (state->rev1 == 0 && state->rev2 == 0)) {
845 v4l_dbg(1, msp_debug, client, "not an msp3400 (cannot read chip version)\n"); 852 v4l_dbg(1, msp_debug, client,
853 "not an msp3400 (cannot read chip version)\n");
846 kfree(state); 854 kfree(state);
847 return -ENODEV; 855 return -ENODEV;
848 } 856 }
@@ -860,37 +868,55 @@ static int msp_probe(struct i2c_client *client)
860 msp_family, msp_product, 868 msp_family, msp_product,
861 msp_revision, msp_hard, msp_rom); 869 msp_revision, msp_hard, msp_rom);
862 /* Rev B=2, C=3, D=4, G=7 */ 870 /* Rev B=2, C=3, D=4, G=7 */
863 state->ident = msp_family * 10000 + 4000 + msp_product * 10 + msp_revision - '@'; 871 state->ident = msp_family * 10000 + 4000 + msp_product * 10 +
872 msp_revision - '@';
864 873
865 /* Has NICAM support: all mspx41x and mspx45x products have NICAM */ 874 /* Has NICAM support: all mspx41x and mspx45x products have NICAM */
866 state->has_nicam = msp_prod_hi == 1 || msp_prod_hi == 5; 875 state->has_nicam =
876 msp_prod_hi == 1 || msp_prod_hi == 5;
867 /* Has radio support: was added with revision G */ 877 /* Has radio support: was added with revision G */
868 state->has_radio = msp_revision >= 'G'; 878 state->has_radio =
879 msp_revision >= 'G';
869 /* Has headphones output: not for stripped down products */ 880 /* Has headphones output: not for stripped down products */
870 state->has_headphones = msp_prod_lo < 5; 881 state->has_headphones =
882 msp_prod_lo < 5;
871 /* Has scart2 input: not in stripped down products of the '3' family */ 883 /* Has scart2 input: not in stripped down products of the '3' family */
872 state->has_scart2 = msp_family >= 4 || msp_prod_lo < 7; 884 state->has_scart2 =
885 msp_family >= 4 || msp_prod_lo < 7;
873 /* Has scart3 input: not in stripped down products of the '3' family */ 886 /* Has scart3 input: not in stripped down products of the '3' family */
874 state->has_scart3 = msp_family >= 4 || msp_prod_lo < 5; 887 state->has_scart3 =
888 msp_family >= 4 || msp_prod_lo < 5;
875 /* Has scart4 input: not in pre D revisions, not in stripped D revs */ 889 /* Has scart4 input: not in pre D revisions, not in stripped D revs */
876 state->has_scart4 = msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5); 890 state->has_scart4 =
877 /* Has scart2 output: not in stripped down products of the '3' family */ 891 msp_family >= 4 || (msp_revision >= 'D' && msp_prod_lo < 5);
878 state->has_scart2_out = msp_family >= 4 || msp_prod_lo < 5; 892 /* Has scart2 output: not in stripped down products of
893 * the '3' family */
894 state->has_scart2_out =
895 msp_family >= 4 || msp_prod_lo < 5;
879 /* Has scart2 a volume control? Not in pre-D revisions. */ 896 /* Has scart2 a volume control? Not in pre-D revisions. */
880 state->has_scart2_out_volume = msp_revision > 'C' && state->has_scart2_out; 897 state->has_scart2_out_volume =
898 msp_revision > 'C' && state->has_scart2_out;
881 /* Has a configurable i2s out? */ 899 /* Has a configurable i2s out? */
882 state->has_i2s_conf = msp_revision >= 'G' && msp_prod_lo < 7; 900 state->has_i2s_conf =
883 /* Has subwoofer output: not in pre-D revs and not in stripped down products */ 901 msp_revision >= 'G' && msp_prod_lo < 7;
884 state->has_subwoofer = msp_revision >= 'D' && msp_prod_lo < 5; 902 /* Has subwoofer output: not in pre-D revs and not in stripped down
885 /* Has soundprocessing (bass/treble/balance/loudness/equalizer): not in 903 * products */
886 stripped down products */ 904 state->has_subwoofer =
887 state->has_sound_processing = msp_prod_lo < 7; 905 msp_revision >= 'D' && msp_prod_lo < 5;
906 /* Has soundprocessing (bass/treble/balance/loudness/equalizer):
907 * not in stripped down products */
908 state->has_sound_processing =
909 msp_prod_lo < 7;
888 /* Has Virtual Dolby Surround: only in msp34x1 */ 910 /* Has Virtual Dolby Surround: only in msp34x1 */
889 state->has_virtual_dolby_surround = msp_revision == 'G' && msp_prod_lo == 1; 911 state->has_virtual_dolby_surround =
912 msp_revision == 'G' && msp_prod_lo == 1;
890 /* Has Virtual Dolby Surround & Dolby Pro Logic: only in msp34x2 */ 913 /* Has Virtual Dolby Surround & Dolby Pro Logic: only in msp34x2 */
891 state->has_dolby_pro_logic = msp_revision == 'G' && msp_prod_lo == 2; 914 state->has_dolby_pro_logic =
892 /* The msp343xG supports BTSC only and cannot do Automatic Standard Detection. */ 915 msp_revision == 'G' && msp_prod_lo == 2;
893 state->force_btsc = msp_family == 3 && msp_revision == 'G' && msp_prod_hi == 3; 916 /* The msp343xG supports BTSC only and cannot do Automatic Standard
917 * Detection. */
918 state->force_btsc =
919 msp_family == 3 && msp_revision == 'G' && msp_prod_hi == 3;
894 920
895 state->opmode = opmode; 921 state->opmode = opmode;
896 if (state->opmode == OPMODE_AUTO) { 922 if (state->opmode == OPMODE_AUTO) {
@@ -905,32 +931,33 @@ static int msp_probe(struct i2c_client *client)
905 } 931 }
906 932
907 /* hello world :-) */ 933 /* hello world :-) */
908 v4l_info(client, "%s found @ 0x%x (%s)\n", client->name, client->addr << 1, client->adapter->name); 934 v4l_info(client, "%s found @ 0x%x (%s)\n", client->name,
935 client->addr << 1, client->adapter->name);
909 v4l_info(client, "%s ", client->name); 936 v4l_info(client, "%s ", client->name);
910 if (state->has_nicam && state->has_radio) 937 if (state->has_nicam && state->has_radio)
911 printk("supports nicam and radio, "); 938 printk(KERN_CONT "supports nicam and radio, ");
912 else if (state->has_nicam) 939 else if (state->has_nicam)
913 printk("supports nicam, "); 940 printk(KERN_CONT "supports nicam, ");
914 else if (state->has_radio) 941 else if (state->has_radio)
915 printk("supports radio, "); 942 printk(KERN_CONT "supports radio, ");
916 printk("mode is "); 943 printk(KERN_CONT "mode is ");
917 944
918 /* version-specific initialization */ 945 /* version-specific initialization */
919 switch (state->opmode) { 946 switch (state->opmode) {
920 case OPMODE_MANUAL: 947 case OPMODE_MANUAL:
921 printk("manual"); 948 printk(KERN_CONT "manual");
922 thread_func = msp3400c_thread; 949 thread_func = msp3400c_thread;
923 break; 950 break;
924 case OPMODE_AUTODETECT: 951 case OPMODE_AUTODETECT:
925 printk("autodetect"); 952 printk(KERN_CONT "autodetect");
926 thread_func = msp3410d_thread; 953 thread_func = msp3410d_thread;
927 break; 954 break;
928 case OPMODE_AUTOSELECT: 955 case OPMODE_AUTOSELECT:
929 printk("autodetect and autoselect"); 956 printk(KERN_CONT "autodetect and autoselect");
930 thread_func = msp34xxg_thread; 957 thread_func = msp34xxg_thread;
931 break; 958 break;
932 } 959 }
933 printk("\n"); 960 printk(KERN_CONT "\n");
934 961
935 /* startup control thread if needed */ 962 /* startup control thread if needed */
936 if (thread_func) { 963 if (thread_func) {