@@ -888,7 +888,7 @@ static const struct snd_emu1010_pads_info emu1010_pads_info[] = {
888888};
889889
890890
891- static int snd_emu1010_internal_clock_info (struct snd_kcontrol * kcontrol ,
891+ static int snd_emu1010_clock_source_info (struct snd_kcontrol * kcontrol ,
892892 struct snd_ctl_elem_info * uinfo )
893893{
894894 static const char * const texts [4 ] = {
@@ -898,16 +898,16 @@ static int snd_emu1010_internal_clock_info(struct snd_kcontrol *kcontrol,
898898 return snd_ctl_enum_info (uinfo , 1 , 4 , texts );
899899}
900900
901- static int snd_emu1010_internal_clock_get (struct snd_kcontrol * kcontrol ,
901+ static int snd_emu1010_clock_source_get (struct snd_kcontrol * kcontrol ,
902902 struct snd_ctl_elem_value * ucontrol )
903903{
904904 struct snd_emu10k1 * emu = snd_kcontrol_chip (kcontrol );
905905
906- ucontrol -> value .enumerated .item [0 ] = emu -> emu1010 .internal_clock ;
906+ ucontrol -> value .enumerated .item [0 ] = emu -> emu1010 .clock_source ;
907907 return 0 ;
908908}
909909
910- static int snd_emu1010_internal_clock_put (struct snd_kcontrol * kcontrol ,
910+ static int snd_emu1010_clock_source_put (struct snd_kcontrol * kcontrol ,
911911 struct snd_ctl_elem_value * ucontrol )
912912{
913913 struct snd_emu10k1 * emu = snd_kcontrol_chip (kcontrol );
@@ -918,16 +918,14 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
918918 /* Limit: uinfo->value.enumerated.items = 4; */
919919 if (val >= 4 )
920920 return - EINVAL ;
921- change = (emu -> emu1010 .internal_clock != val );
921+ change = (emu -> emu1010 .clock_source != val );
922922 if (change ) {
923- emu -> emu1010 .internal_clock = val ;
923+ emu -> emu1010 .clock_source = val ;
924924 switch (val ) {
925925 case 0 :
926926 /* 44100 */
927927 /* Mute all */
928928 snd_emu1010_fpga_write (emu , EMU_HANA_UNMUTE , EMU_MUTE );
929- /* Default fallback clock 44.1kHz */
930- snd_emu1010_fpga_write (emu , EMU_HANA_DEFCLOCK , EMU_HANA_DEFCLOCK_44_1K );
931929 /* Word Clock source, Internal 44.1kHz x1 */
932930 snd_emu1010_fpga_write (emu , EMU_HANA_WCLOCK ,
933931 EMU_HANA_WCLOCK_INT_44_1K | EMU_HANA_WCLOCK_1X );
@@ -943,8 +941,6 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
943941 /* 48000 */
944942 /* Mute all */
945943 snd_emu1010_fpga_write (emu , EMU_HANA_UNMUTE , EMU_MUTE );
946- /* Default fallback clock 48kHz */
947- snd_emu1010_fpga_write (emu , EMU_HANA_DEFCLOCK , EMU_HANA_DEFCLOCK_48K );
948944 /* Word Clock source, Internal 48kHz x1 */
949945 snd_emu1010_fpga_write (emu , EMU_HANA_WCLOCK ,
950946 EMU_HANA_WCLOCK_INT_48K | EMU_HANA_WCLOCK_1X );
@@ -960,8 +956,6 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
960956 case 2 : /* Take clock from S/PDIF IN */
961957 /* Mute all */
962958 snd_emu1010_fpga_write (emu , EMU_HANA_UNMUTE , EMU_MUTE );
963- /* Default fallback clock 48kHz */
964- snd_emu1010_fpga_write (emu , EMU_HANA_DEFCLOCK , EMU_HANA_DEFCLOCK_48K );
965959 /* Word Clock source, sync to S/PDIF input */
966960 snd_emu1010_fpga_write (emu , EMU_HANA_WCLOCK ,
967961 EMU_HANA_WCLOCK_HANA_SPDIF_IN | EMU_HANA_WCLOCK_1X );
@@ -979,8 +973,6 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
979973 /* Take clock from ADAT IN */
980974 /* Mute all */
981975 snd_emu1010_fpga_write (emu , EMU_HANA_UNMUTE , EMU_MUTE );
982- /* Default fallback clock 48kHz */
983- snd_emu1010_fpga_write (emu , EMU_HANA_DEFCLOCK , EMU_HANA_DEFCLOCK_48K );
984976 /* Word Clock source, sync to ADAT input */
985977 snd_emu1010_fpga_write (emu , EMU_HANA_WCLOCK ,
986978 EMU_HANA_WCLOCK_HANA_ADAT_IN | EMU_HANA_WCLOCK_1X );
@@ -999,15 +991,62 @@ static int snd_emu1010_internal_clock_put(struct snd_kcontrol *kcontrol,
999991 return change ;
1000992}
1001993
1002- static const struct snd_kcontrol_new snd_emu1010_internal_clock =
994+ static const struct snd_kcontrol_new snd_emu1010_clock_source =
1003995{
1004- .access = SNDRV_CTL_ELEM_ACCESS_READWRITE ,
1005- .iface = SNDRV_CTL_ELEM_IFACE_MIXER ,
1006- .name = "Clock Internal Rate" ,
1007- .count = 1 ,
1008- .info = snd_emu1010_internal_clock_info ,
1009- .get = snd_emu1010_internal_clock_get ,
1010- .put = snd_emu1010_internal_clock_put
996+ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE ,
997+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER ,
998+ .name = "Clock Source" ,
999+ .count = 1 ,
1000+ .info = snd_emu1010_clock_source_info ,
1001+ .get = snd_emu1010_clock_source_get ,
1002+ .put = snd_emu1010_clock_source_put
1003+ };
1004+
1005+ static int snd_emu1010_clock_fallback_info (struct snd_kcontrol * kcontrol ,
1006+ struct snd_ctl_elem_info * uinfo )
1007+ {
1008+ static const char * const texts [2 ] = {
1009+ "44100" , "48000"
1010+ };
1011+
1012+ return snd_ctl_enum_info (uinfo , 1 , 2 , texts );
1013+ }
1014+
1015+ static int snd_emu1010_clock_fallback_get (struct snd_kcontrol * kcontrol ,
1016+ struct snd_ctl_elem_value * ucontrol )
1017+ {
1018+ struct snd_emu10k1 * emu = snd_kcontrol_chip (kcontrol );
1019+
1020+ ucontrol -> value .enumerated .item [0 ] = emu -> emu1010 .clock_fallback ;
1021+ return 0 ;
1022+ }
1023+
1024+ static int snd_emu1010_clock_fallback_put (struct snd_kcontrol * kcontrol ,
1025+ struct snd_ctl_elem_value * ucontrol )
1026+ {
1027+ struct snd_emu10k1 * emu = snd_kcontrol_chip (kcontrol );
1028+ unsigned int val = ucontrol -> value .enumerated .item [0 ];
1029+ int change ;
1030+
1031+ if (val >= 2 )
1032+ return - EINVAL ;
1033+ change = (emu -> emu1010 .clock_fallback != val );
1034+ if (change ) {
1035+ emu -> emu1010 .clock_fallback = val ;
1036+ snd_emu1010_fpga_write (emu , EMU_HANA_DEFCLOCK , 1 - val );
1037+ }
1038+ return change ;
1039+ }
1040+
1041+ static const struct snd_kcontrol_new snd_emu1010_clock_fallback =
1042+ {
1043+ .access = SNDRV_CTL_ELEM_ACCESS_READWRITE ,
1044+ .iface = SNDRV_CTL_ELEM_IFACE_MIXER ,
1045+ .name = "Clock Fallback" ,
1046+ .count = 1 ,
1047+ .info = snd_emu1010_clock_fallback_info ,
1048+ .get = snd_emu1010_clock_fallback_get ,
1049+ .put = snd_emu1010_clock_fallback_put
10111050};
10121051
10131052static int snd_emu1010_optical_out_info (struct snd_kcontrol * kcontrol ,
@@ -2297,7 +2336,11 @@ int snd_emu10k1_mixer(struct snd_emu10k1 *emu,
22972336 snd_emu1010_apply_sources (emu );
22982337
22992338 err = snd_ctl_add (card ,
2300- snd_ctl_new1 (& snd_emu1010_internal_clock , emu ));
2339+ snd_ctl_new1 (& snd_emu1010_clock_source , emu ));
2340+ if (err < 0 )
2341+ return err ;
2342+ err = snd_ctl_add (card ,
2343+ snd_ctl_new1 (& snd_emu1010_clock_fallback , emu ));
23012344 if (err < 0 )
23022345 return err ;
23032346
0 commit comments