@@ -182,7 +182,7 @@ static int snd_sbmixer_put_double(struct snd_kcontrol *kcontrol, struct snd_ctl_
182182
183183static int snd_dt019x_input_sw_info (struct snd_kcontrol * kcontrol , struct snd_ctl_elem_info * uinfo )
184184{
185- static char * texts [5 ] = {
185+ static const char * texts [5 ] = {
186186 "CD" , "Mic" , "Line" , "Synth" , "Master"
187187 };
188188
@@ -268,13 +268,74 @@ static int snd_dt019x_input_sw_put(struct snd_kcontrol *kcontrol, struct snd_ctl
268268 return change ;
269269}
270270
271+ /*
272+ * ALS4000 mono recording control switch
273+ */
274+
275+ static int snd_als4k_mono_capture_route_info (struct snd_kcontrol * kcontrol ,
276+ struct snd_ctl_elem_info * uinfo )
277+ {
278+ static const char * texts [3 ] = {
279+ "L chan only" , "R chan only" , "L ch/2 + R ch/2"
280+ };
281+
282+ uinfo -> type = SNDRV_CTL_ELEM_TYPE_ENUMERATED ;
283+ uinfo -> count = 1 ;
284+ uinfo -> value .enumerated .items = 3 ;
285+ if (uinfo -> value .enumerated .item > 2 )
286+ uinfo -> value .enumerated .item = 2 ;
287+ strcpy (uinfo -> value .enumerated .name ,
288+ texts [uinfo -> value .enumerated .item ]);
289+ return 0 ;
290+ }
291+
292+ static int snd_als4k_mono_capture_route_get (struct snd_kcontrol * kcontrol ,
293+ struct snd_ctl_elem_value * ucontrol )
294+ {
295+ struct snd_sb * sb = snd_kcontrol_chip (kcontrol );
296+ unsigned long flags ;
297+ unsigned char oval ;
298+
299+ spin_lock_irqsave (& sb -> mixer_lock , flags );
300+ oval = snd_sbmixer_read (sb , SB_ALS4000_MONO_IO_CTRL );
301+ spin_unlock_irqrestore (& sb -> mixer_lock , flags );
302+ oval >>= 6 ;
303+ if (oval > 2 )
304+ oval = 2 ;
305+
306+ ucontrol -> value .enumerated .item [0 ] = oval ;
307+ return 0 ;
308+ }
309+
310+ static int snd_als4k_mono_capture_route_put (struct snd_kcontrol * kcontrol ,
311+ struct snd_ctl_elem_value * ucontrol )
312+ {
313+ struct snd_sb * sb = snd_kcontrol_chip (kcontrol );
314+ unsigned long flags ;
315+ int change ;
316+ unsigned char nval , oval ;
317+
318+ if (ucontrol -> value .enumerated .item [0 ] > 2 )
319+ return - EINVAL ;
320+ spin_lock_irqsave (& sb -> mixer_lock , flags );
321+ oval = snd_sbmixer_read (sb , SB_ALS4000_MONO_IO_CTRL );
322+
323+ nval = (oval & ~(3 << 6 ))
324+ | (ucontrol -> value .enumerated .item [0 ] << 6 );
325+ change = nval != oval ;
326+ if (change )
327+ snd_sbmixer_write (sb , SB_ALS4000_MONO_IO_CTRL , nval );
328+ spin_unlock_irqrestore (& sb -> mixer_lock , flags );
329+ return change ;
330+ }
331+
271332/*
272333 * SBPRO input multiplexer
273334 */
274335
275336static int snd_sb8mixer_info_mux (struct snd_kcontrol * kcontrol , struct snd_ctl_elem_info * uinfo )
276337{
277- static char * texts [3 ] = {
338+ static const char * texts [3 ] = {
278339 "Mic" , "CD" , "Line"
279340 };
280341
@@ -442,6 +503,12 @@ int snd_sbmixer_add_ctl(struct snd_sb *chip, const char *name, int index, int ty
442503 .get = snd_dt019x_input_sw_get ,
443504 .put = snd_dt019x_input_sw_put ,
444505 },
506+ [SB_MIX_MONO_CAPTURE_ALS4K ] = {
507+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER ,
508+ .info = snd_als4k_mono_capture_route_info ,
509+ .get = snd_als4k_mono_capture_route_get ,
510+ .put = snd_als4k_mono_capture_route_put ,
511+ },
445512 };
446513 struct snd_kcontrol * ctl ;
447514 int err ;
@@ -636,6 +703,8 @@ static struct sbmix_elem snd_dt019x_ctl_capture_source =
636703 };
637704
638705static struct sbmix_elem * snd_dt019x_controls [] = {
706+ /* ALS4000 below has some parts which we might be lacking,
707+ * e.g. snd_als4000_ctl_mono_playback_switch - check it! */
639708 & snd_dt019x_ctl_master_play_vol ,
640709 & snd_dt019x_ctl_pcm_play_vol ,
641710 & snd_dt019x_ctl_synth_play_vol ,
@@ -666,18 +735,21 @@ static unsigned char snd_dt019x_init_values[][2] = {
666735/*
667736 * ALS4000 specific mixer elements
668737 */
669- /* FIXME: SB_ALS4000_MONO_IO_CTRL needs output select ctrl! */
670738static struct sbmix_elem snd_als4000_ctl_master_mono_playback_switch =
671739 SB_SINGLE ("Master Mono Playback Switch" , SB_ALS4000_MONO_IO_CTRL , 5 , 1 );
672- static struct sbmix_elem snd_als4000_ctl_master_mono_capture_route =
673- SB_SINGLE ("Master Mono Capture Route" , SB_ALS4000_MONO_IO_CTRL , 6 , 0x03 );
674- /* FIXME: mono playback switch also available on DT019X? */
740+ static struct sbmix_elem snd_als4k_ctl_master_mono_capture_route = {
741+ .name = "Master Mono Capture Route" ,
742+ .type = SB_MIX_MONO_CAPTURE_ALS4K
743+ };
675744static struct sbmix_elem snd_als4000_ctl_mono_playback_switch =
676745 SB_SINGLE ("Mono Playback Switch" , SB_DT019X_OUTPUT_SW2 , 0 , 1 );
677746static struct sbmix_elem snd_als4000_ctl_mic_20db_boost =
678747 SB_SINGLE ("Mic Boost (+20dB)" , SB_ALS4000_MIC_IN_GAIN , 0 , 0x03 );
679- static struct sbmix_elem snd_als4000_ctl_mixer_loopback =
680- SB_SINGLE ("Analog Loopback" , SB_ALS4000_MIC_IN_GAIN , 7 , 0x01 );
748+ static struct sbmix_elem snd_als4000_ctl_mixer_analog_loopback =
749+ SB_SINGLE ("Analog Loopback Switch" , SB_ALS4000_MIC_IN_GAIN , 7 , 0x01 );
750+ static struct sbmix_elem snd_als4000_ctl_mixer_digital_loopback =
751+ SB_SINGLE ("Digital Loopback Switch" ,
752+ SB_ALS4000_CR3_CONFIGURATION , 7 , 0x01 );
681753/* FIXME: functionality of 3D controls might be swapped, I didn't find
682754 * a description of how to identify what is supposed to be what */
683755static struct sbmix_elem snd_als4000_3d_control_switch =
@@ -694,6 +766,9 @@ static struct sbmix_elem snd_als4000_3d_control_delay =
694766 SB_SINGLE ("3D Control - Wide" , SB_ALS4000_3D_TIME_DELAY , 0 , 0x0f );
695767static struct sbmix_elem snd_als4000_3d_control_poweroff_switch =
696768 SB_SINGLE ("3D PowerOff Switch" , SB_ALS4000_3D_TIME_DELAY , 4 , 0x01 );
769+ static struct sbmix_elem snd_als4000_ctl_3db_freq_control_switch =
770+ SB_SINGLE ("Master Playback 8kHz / 20kHz LPF Switch" ,
771+ SB_ALS4000_FMDAC , 5 , 0x01 );
697772#ifdef NOT_AVAILABLE
698773static struct sbmix_elem snd_als4000_ctl_fmdac =
699774 SB_SINGLE ("FMDAC Switch (Option ?)" , SB_ALS4000_FMDAC , 0 , 0x01 );
@@ -702,35 +777,37 @@ static struct sbmix_elem snd_als4000_ctl_qsound =
702777#endif
703778
704779static struct sbmix_elem * snd_als4000_controls [] = {
705- & snd_sb16_ctl_master_play_vol ,
706- & snd_dt019x_ctl_pcm_play_switch ,
707- & snd_sb16_ctl_pcm_play_vol ,
708- & snd_sb16_ctl_synth_capture_route ,
709- & snd_dt019x_ctl_synth_play_switch ,
710- & snd_sb16_ctl_synth_play_vol ,
711- & snd_sb16_ctl_cd_capture_route ,
712- & snd_sb16_ctl_cd_play_switch ,
713- & snd_sb16_ctl_cd_play_vol ,
714- & snd_sb16_ctl_line_capture_route ,
715- & snd_sb16_ctl_line_play_switch ,
716- & snd_sb16_ctl_line_play_vol ,
717- & snd_sb16_ctl_mic_capture_route ,
718- & snd_als4000_ctl_mic_20db_boost ,
719- & snd_sb16_ctl_auto_mic_gain ,
720- & snd_sb16_ctl_mic_play_switch ,
721- & snd_sb16_ctl_mic_play_vol ,
722- & snd_sb16_ctl_pc_speaker_vol ,
723- & snd_sb16_ctl_capture_vol ,
724- & snd_sb16_ctl_play_vol ,
725- & snd_als4000_ctl_master_mono_playback_switch ,
726- & snd_als4000_ctl_master_mono_capture_route ,
727- & snd_als4000_ctl_mono_playback_switch ,
728- & snd_als4000_ctl_mixer_loopback ,
729- & snd_als4000_3d_control_switch ,
730- & snd_als4000_3d_control_ratio ,
731- & snd_als4000_3d_control_freq ,
732- & snd_als4000_3d_control_delay ,
733- & snd_als4000_3d_control_poweroff_switch ,
780+ /* ALS4000a.PDF regs page */
781+ & snd_sb16_ctl_master_play_vol , /* MX30/31 12 */
782+ & snd_dt019x_ctl_pcm_play_switch , /* MX4C 16 */
783+ & snd_sb16_ctl_pcm_play_vol , /* MX32/33 12 */
784+ & snd_sb16_ctl_synth_capture_route , /* MX3D/3E 14 */
785+ & snd_dt019x_ctl_synth_play_switch , /* MX4C 16 */
786+ & snd_sb16_ctl_synth_play_vol , /* MX34/35 12/13 */
787+ & snd_sb16_ctl_cd_capture_route , /* MX3D/3E 14 */
788+ & snd_sb16_ctl_cd_play_switch , /* MX3C 14 */
789+ & snd_sb16_ctl_cd_play_vol , /* MX36/37 13 */
790+ & snd_sb16_ctl_line_capture_route , /* MX3D/3E 14 */
791+ & snd_sb16_ctl_line_play_switch , /* MX3C 14 */
792+ & snd_sb16_ctl_line_play_vol , /* MX38/39 13 */
793+ & snd_sb16_ctl_mic_capture_route , /* MX3D/3E 14 */
794+ & snd_als4000_ctl_mic_20db_boost , /* MX4D 16 */
795+ & snd_sb16_ctl_mic_play_switch , /* MX3C 14 */
796+ & snd_sb16_ctl_mic_play_vol , /* MX3A 13 */
797+ & snd_sb16_ctl_pc_speaker_vol , /* MX3B 14 */
798+ & snd_sb16_ctl_capture_vol , /* MX3F/40 15 */
799+ & snd_sb16_ctl_play_vol , /* MX41/42 15 */
800+ & snd_als4000_ctl_master_mono_playback_switch , /* MX4C 16 */
801+ & snd_als4k_ctl_master_mono_capture_route , /* MX4B 16 */
802+ & snd_als4000_ctl_mono_playback_switch , /* MX4C 16 */
803+ & snd_als4000_ctl_mixer_analog_loopback , /* MX4D 16 */
804+ & snd_als4000_ctl_mixer_digital_loopback , /* CR3 21 */
805+ & snd_als4000_3d_control_switch , /* MX50 17 */
806+ & snd_als4000_3d_control_ratio , /* MX50 17 */
807+ & snd_als4000_3d_control_freq , /* MX50 17 */
808+ & snd_als4000_3d_control_delay , /* MX51 18 */
809+ & snd_als4000_3d_control_poweroff_switch , /* MX51 18 */
810+ & snd_als4000_ctl_3db_freq_control_switch , /* MX4F 17 */
734811#ifdef NOT_AVAILABLE
735812 & snd_als4000_ctl_fmdac ,
736813 & snd_als4000_ctl_qsound ,
@@ -905,22 +982,25 @@ static unsigned char dt019x_saved_regs[] = {
905982};
906983
907984static unsigned char als4000_saved_regs [] = {
985+ /* please verify in dsheet whether regs to be added
986+ are actually real H/W or just dummy */
908987 SB_DSP4_MASTER_DEV , SB_DSP4_MASTER_DEV + 1 ,
909988 SB_DSP4_OUTPUT_SW ,
910989 SB_DSP4_PCM_DEV , SB_DSP4_PCM_DEV + 1 ,
911990 SB_DSP4_INPUT_LEFT , SB_DSP4_INPUT_RIGHT ,
912991 SB_DSP4_SYNTH_DEV , SB_DSP4_SYNTH_DEV + 1 ,
913992 SB_DSP4_CD_DEV , SB_DSP4_CD_DEV + 1 ,
914- SB_DSP4_MIC_AGC ,
915993 SB_DSP4_MIC_DEV ,
916994 SB_DSP4_SPEAKER_DEV ,
917995 SB_DSP4_IGAIN_DEV , SB_DSP4_IGAIN_DEV + 1 ,
918996 SB_DSP4_OGAIN_DEV , SB_DSP4_OGAIN_DEV + 1 ,
919997 SB_DT019X_OUTPUT_SW2 ,
920998 SB_ALS4000_MONO_IO_CTRL ,
921999 SB_ALS4000_MIC_IN_GAIN ,
1000+ SB_ALS4000_FMDAC ,
9221001 SB_ALS4000_3D_SND_FX ,
9231002 SB_ALS4000_3D_TIME_DELAY ,
1003+ SB_ALS4000_CR3_CONFIGURATION ,
9241004};
9251005
9261006static void save_mixer (struct snd_sb * chip , unsigned char * regs , int num_regs )
0 commit comments