pmac.c (d4bbf7e7759afc172e2bfbc5c416324590049cdd) pmac.c (15afafc2565bc785eb7a440b8b4a53f77910cf04)
1/*
2 * PMac DBDMA lowlevel functions
3 *
4 * Copyright (c) by Takashi Iwai <tiwai@suse.de>
5 * code based on dmasound.c.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 688 unchanged lines hidden (view full) ---

697 .ioctl = snd_pcm_lib_ioctl,
698 .hw_params = snd_pmac_pcm_hw_params,
699 .hw_free = snd_pmac_pcm_hw_free,
700 .prepare = snd_pmac_capture_prepare,
701 .trigger = snd_pmac_capture_trigger,
702 .pointer = snd_pmac_capture_pointer,
703};
704
1/*
2 * PMac DBDMA lowlevel functions
3 *
4 * Copyright (c) by Takashi Iwai <tiwai@suse.de>
5 * code based on dmasound.c.
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by

--- 688 unchanged lines hidden (view full) ---

697 .ioctl = snd_pcm_lib_ioctl,
698 .hw_params = snd_pmac_pcm_hw_params,
699 .hw_free = snd_pmac_pcm_hw_free,
700 .prepare = snd_pmac_capture_prepare,
701 .trigger = snd_pmac_capture_trigger,
702 .pointer = snd_pmac_capture_pointer,
703};
704
705int __devinit snd_pmac_pcm_new(struct snd_pmac *chip)
705int snd_pmac_pcm_new(struct snd_pmac *chip)
706{
707 struct snd_pcm *pcm;
708 int err;
709 int num_captures = 1;
710
711 if (! chip->can_capture)
712 num_captures = 0;
713 err = snd_pcm_new(chip->card, chip->card->driver, 0, 1, num_captures, &pcm);

--- 188 unchanged lines hidden (view full) ---

902 return snd_pmac_free(chip);
903}
904
905
906/*
907 * check the machine support byteswap (little-endian)
908 */
909
706{
707 struct snd_pcm *pcm;
708 int err;
709 int num_captures = 1;
710
711 if (! chip->can_capture)
712 num_captures = 0;
713 err = snd_pcm_new(chip->card, chip->card->driver, 0, 1, num_captures, &pcm);

--- 188 unchanged lines hidden (view full) ---

902 return snd_pmac_free(chip);
903}
904
905
906/*
907 * check the machine support byteswap (little-endian)
908 */
909
910static void __devinit detect_byte_swap(struct snd_pmac *chip)
910static void detect_byte_swap(struct snd_pmac *chip)
911{
912 struct device_node *mio;
913
914 /* if seems that Keylargo can't byte-swap */
915 for (mio = chip->node->parent; mio; mio = mio->parent) {
916 if (strcmp(mio->name, "mac-io") == 0) {
917 if (of_device_is_compatible(mio, "Keylargo"))
918 chip->can_byte_swap = 0;

--- 9 unchanged lines hidden (view full) ---

928 if (of_machine_is_compatible("PowerBook2,1"))
929 chip->can_duplex = 0;
930}
931
932
933/*
934 * detect a sound chip
935 */
911{
912 struct device_node *mio;
913
914 /* if seems that Keylargo can't byte-swap */
915 for (mio = chip->node->parent; mio; mio = mio->parent) {
916 if (strcmp(mio->name, "mac-io") == 0) {
917 if (of_device_is_compatible(mio, "Keylargo"))
918 chip->can_byte_swap = 0;

--- 9 unchanged lines hidden (view full) ---

928 if (of_machine_is_compatible("PowerBook2,1"))
929 chip->can_duplex = 0;
930}
931
932
933/*
934 * detect a sound chip
935 */
936static int __devinit snd_pmac_detect(struct snd_pmac *chip)
936static int snd_pmac_detect(struct snd_pmac *chip)
937{
938 struct device_node *sound;
939 struct device_node *dn;
940 const unsigned int *prop;
941 unsigned int l;
942 struct macio_chip* macio;
943
944 if (!machine_is(powermac))

--- 196 unchanged lines hidden (view full) ---

1141 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
1142 if (chip->detect_headphone)
1143 ucontrol->value.integer.value[0] = chip->detect_headphone(chip);
1144 else
1145 ucontrol->value.integer.value[0] = 0;
1146 return 0;
1147}
1148
937{
938 struct device_node *sound;
939 struct device_node *dn;
940 const unsigned int *prop;
941 unsigned int l;
942 struct macio_chip* macio;
943
944 if (!machine_is(powermac))

--- 196 unchanged lines hidden (view full) ---

1141 struct snd_pmac *chip = snd_kcontrol_chip(kcontrol);
1142 if (chip->detect_headphone)
1143 ucontrol->value.integer.value[0] = chip->detect_headphone(chip);
1144 else
1145 ucontrol->value.integer.value[0] = 0;
1146 return 0;
1147}
1148
1149static struct snd_kcontrol_new auto_mute_controls[] __devinitdata = {
1149static struct snd_kcontrol_new auto_mute_controls[] = {
1150 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1151 .name = "Auto Mute Switch",
1152 .info = snd_pmac_boolean_mono_info,
1153 .get = pmac_auto_mute_get,
1154 .put = pmac_auto_mute_put,
1155 },
1156 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1157 .name = "Headphone Detection",
1158 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1159 .info = snd_pmac_boolean_mono_info,
1160 .get = pmac_hp_detect_get,
1161 },
1162};
1163
1150 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1151 .name = "Auto Mute Switch",
1152 .info = snd_pmac_boolean_mono_info,
1153 .get = pmac_auto_mute_get,
1154 .put = pmac_auto_mute_put,
1155 },
1156 { .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
1157 .name = "Headphone Detection",
1158 .access = SNDRV_CTL_ELEM_ACCESS_READ,
1159 .info = snd_pmac_boolean_mono_info,
1160 .get = pmac_hp_detect_get,
1161 },
1162};
1163
1164int __devinit snd_pmac_add_automute(struct snd_pmac *chip)
1164int snd_pmac_add_automute(struct snd_pmac *chip)
1165{
1166 int err;
1167 chip->auto_mute = 1;
1168 err = snd_ctl_add(chip->card, snd_ctl_new1(&auto_mute_controls[0], chip));
1169 if (err < 0) {
1170 printk(KERN_ERR "snd-powermac: Failed to add automute control\n");
1171 return err;
1172 }
1173 chip->hp_detect_ctl = snd_ctl_new1(&auto_mute_controls[1], chip);
1174 return snd_ctl_add(chip->card, chip->hp_detect_ctl);
1175}
1176#endif /* PMAC_SUPPORT_AUTOMUTE */
1177
1178/*
1179 * create and detect a pmac chip record
1180 */
1165{
1166 int err;
1167 chip->auto_mute = 1;
1168 err = snd_ctl_add(chip->card, snd_ctl_new1(&auto_mute_controls[0], chip));
1169 if (err < 0) {
1170 printk(KERN_ERR "snd-powermac: Failed to add automute control\n");
1171 return err;
1172 }
1173 chip->hp_detect_ctl = snd_ctl_new1(&auto_mute_controls[1], chip);
1174 return snd_ctl_add(chip->card, chip->hp_detect_ctl);
1175}
1176#endif /* PMAC_SUPPORT_AUTOMUTE */
1177
1178/*
1179 * create and detect a pmac chip record
1180 */
1181int __devinit snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1181int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return)
1182{
1183 struct snd_pmac *chip;
1184 struct device_node *np;
1185 int i, err;
1186 unsigned int irq;
1187 unsigned long ctrl_addr, txdma_addr, rxdma_addr;
1188 static struct snd_device_ops ops = {
1189 .dev_free = snd_pmac_dev_free,

--- 221 unchanged lines hidden ---
1182{
1183 struct snd_pmac *chip;
1184 struct device_node *np;
1185 int i, err;
1186 unsigned int irq;
1187 unsigned long ctrl_addr, txdma_addr, rxdma_addr;
1188 static struct snd_device_ops ops = {
1189 .dev_free = snd_pmac_dev_free,

--- 221 unchanged lines hidden ---