2 * Apple Onboard Audio driver -- layout fabric
4 * Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
6 * GPL v2, can be found in COPYING.
9 * This fabric module looks for sound codecs
10 * based on the layout-id property in the device tree.
15 #include <linux/list.h>
16 #include <linux/module.h>
18 #include "../soundbus/soundbus.h"
20 MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
21 MODULE_LICENSE("GPL");
22 MODULE_DESCRIPTION("Layout-ID fabric for snd-aoa");
24 #define MAX_CODECS_PER_BUS 2
26 /* These are the connections the layout fabric
27 * knows about. It doesn't really care about the
28 * input ones, but I thought I'd separate them
29 * to give them proper names. The thing is that
30 * Apple usually will distinguish the active output
31 * by GPIOs, while the active input is set directly
32 * on the codec. Hence we here tell the codec what
33 * we think is connected. This information is hard-
35 #define CC_SPEAKERS (1<<0)
36 #define CC_HEADPHONE (1<<1)
37 #define CC_LINEOUT (1<<2)
38 #define CC_DIGITALOUT (1<<3)
39 #define CC_LINEIN (1<<4)
40 #define CC_MICROPHONE (1<<5)
41 #define CC_DIGITALIN (1<<6)
42 /* pretty bogus but users complain...
43 * This is a flag saying that the LINEOUT
44 * should be renamed to HEADPHONE.
45 * be careful with input detection! */
46 #define CC_LINEOUT_LABELLED_HEADPHONE (1<<7)
48 struct codec_connection {
49 /* CC_ flags from above */
51 /* codec dependent bit to be set in the aoa_codec.connected field.
52 * This intentionally doesn't have any generic flags because the
53 * fabric has to know the codec anyway and all codecs might have
54 * different connectors */
58 struct codec_connect_info {
60 struct codec_connection *connections;
63 #define LAYOUT_FLAG_COMBO_LINEOUT_SPDIF (1<<0)
66 unsigned int layout_id;
67 struct codec_connect_info codecs[MAX_CODECS_PER_BUS];
70 /* if busname is not assigned, we use 'Master' below,
71 * so that our layout table doesn't need to be filled
73 * We only assign these two if we expect to find more
74 * than one soundbus, i.e. on those machines with
75 * multiple layout-ids */
80 MODULE_ALIAS("sound-layout-41");
81 MODULE_ALIAS("sound-layout-45");
82 MODULE_ALIAS("sound-layout-51");
83 MODULE_ALIAS("sound-layout-58");
84 MODULE_ALIAS("sound-layout-60");
85 MODULE_ALIAS("sound-layout-61");
86 MODULE_ALIAS("sound-layout-64");
87 MODULE_ALIAS("sound-layout-65");
88 MODULE_ALIAS("sound-layout-68");
89 MODULE_ALIAS("sound-layout-69");
90 MODULE_ALIAS("sound-layout-70");
91 MODULE_ALIAS("sound-layout-72");
92 MODULE_ALIAS("sound-layout-80");
93 MODULE_ALIAS("sound-layout-82");
94 MODULE_ALIAS("sound-layout-84");
95 MODULE_ALIAS("sound-layout-86");
96 MODULE_ALIAS("sound-layout-92");
97 MODULE_ALIAS("sound-layout-96");
99 /* onyx with all but microphone connected */
100 static struct codec_connection onyx_connections_nomic[] = {
102 .connected = CC_SPEAKERS | CC_HEADPHONE | CC_LINEOUT,
106 .connected = CC_DIGITALOUT,
110 .connected = CC_LINEIN,
113 {} /* terminate array by .connected == 0 */
116 /* onyx on machines without headphone */
117 static struct codec_connection onyx_connections_noheadphones[] = {
119 .connected = CC_SPEAKERS | CC_LINEOUT |
120 CC_LINEOUT_LABELLED_HEADPHONE,
124 .connected = CC_DIGITALOUT,
127 /* FIXME: are these correct? probably not for all the machines
128 * below ... If not this will need separating. */
130 .connected = CC_LINEIN,
134 .connected = CC_MICROPHONE,
137 {} /* terminate array by .connected == 0 */
140 /* onyx on machines with real line-out */
141 static struct codec_connection onyx_connections_reallineout[] = {
143 .connected = CC_SPEAKERS | CC_LINEOUT | CC_HEADPHONE,
147 .connected = CC_DIGITALOUT,
151 .connected = CC_LINEIN,
154 {} /* terminate array by .connected == 0 */
157 /* tas on machines without line out */
158 static struct codec_connection tas_connections_nolineout[] = {
160 .connected = CC_SPEAKERS | CC_HEADPHONE,
164 .connected = CC_LINEIN,
168 .connected = CC_MICROPHONE,
171 {} /* terminate array by .connected == 0 */
174 /* tas on machines with neither line out nor line in */
175 static struct codec_connection tas_connections_noline[] = {
177 .connected = CC_SPEAKERS | CC_HEADPHONE,
181 .connected = CC_MICROPHONE,
184 {} /* terminate array by .connected == 0 */
187 /* tas on machines without microphone */
188 static struct codec_connection tas_connections_nomic[] = {
190 .connected = CC_SPEAKERS | CC_HEADPHONE | CC_LINEOUT,
194 .connected = CC_LINEIN,
197 {} /* terminate array by .connected == 0 */
200 /* tas on machines with everything connected */
201 static struct codec_connection tas_connections_all[] = {
203 .connected = CC_SPEAKERS | CC_HEADPHONE | CC_LINEOUT,
207 .connected = CC_LINEIN,
211 .connected = CC_MICROPHONE,
214 {} /* terminate array by .connected == 0 */
217 static struct codec_connection toonie_connections[] = {
219 .connected = CC_SPEAKERS | CC_HEADPHONE,
222 {} /* terminate array by .connected == 0 */
225 static struct codec_connection topaz_input[] = {
227 .connected = CC_DIGITALIN,
230 {} /* terminate array by .connected == 0 */
233 static struct codec_connection topaz_output[] = {
235 .connected = CC_DIGITALOUT,
238 {} /* terminate array by .connected == 0 */
241 static struct codec_connection topaz_inout[] = {
243 .connected = CC_DIGITALIN,
247 .connected = CC_DIGITALOUT,
250 {} /* terminate array by .connected == 0 */
253 static struct layout layouts[] = {
254 /* last PowerBooks (15" Oct 2005) */
256 .flags = LAYOUT_FLAG_COMBO_LINEOUT_SPDIF,
259 .connections = onyx_connections_noheadphones,
263 .connections = topaz_input,
270 .connections = onyx_connections_reallineout,
277 .connections = topaz_input,
282 .flags = LAYOUT_FLAG_COMBO_LINEOUT_SPDIF,
285 .connections = onyx_connections_noheadphones,
292 .connections = topaz_input,
295 /* PowerBook5,9 [17" Oct 2005] */
297 .flags = LAYOUT_FLAG_COMBO_LINEOUT_SPDIF,
300 .connections = onyx_connections_noheadphones,
304 .connections = topaz_input,
311 .connections = onyx_connections_noheadphones,
315 .connections = topaz_input,
318 /* Quad PowerMac (analog in, analog/digital out) */
322 .connections = onyx_connections_nomic,
325 /* Quad PowerMac (digital in) */
329 .connections = topaz_input,
331 .busname = "digital in", .pcmid = 1 },
332 /* Early 2005 PowerBook (PowerBook 5,6) */
336 .connections = tas_connections_nolineout,
343 .connections = tas_connections_nolineout,
350 .connections = tas_connections_noline,
357 .connections = tas_connections_nolineout,
364 .connections = onyx_connections_nomic,
368 .connections = topaz_input,
375 .connections = tas_connections_nolineout,
378 /* PowerMac10,1 (Mac Mini) */
382 .connections = toonie_connections,
389 .connections = onyx_connections_noheadphones,
392 /* unknown, untested, but this comes from Apple */
396 .connections = tas_connections_all,
402 .connections = tas_connections_nomic,
406 .connections = topaz_inout,
412 .connections = onyx_connections_noheadphones,
418 .connections = topaz_input,
424 .connections = onyx_connections_nomic,
430 .connections = topaz_input,
436 .connections = onyx_connections_noheadphones,
442 .connections = topaz_input,
448 .connections = onyx_connections_noheadphones,
452 .connections = topaz_output,
458 .connections = onyx_connections_noheadphones,
464 .connections = topaz_input,
470 .connections = tas_connections_nomic,
474 .connections = topaz_inout,
480 .connections = tas_connections_noline,
486 /* but it has an external mic?? how to select? */
487 .connections = onyx_connections_noheadphones,
493 .connections = toonie_connections,
499 .connections = topaz_input,
503 .connections = onyx_connections_noheadphones,
509 static struct layout *find_layout_by_id(unsigned int id)
514 while (l->layout_id) {
515 if (l->layout_id == id)
522 static void use_layout(struct layout *l)
526 for (i=0; i<MAX_CODECS_PER_BUS; i++) {
527 if (l->codecs[i].name) {
528 request_module("snd-aoa-codec-%s", l->codecs[i].name);
531 /* now we wait for the codecs to call us back */
536 struct layout_dev_ptr {
537 struct layout_dev *ptr;
541 struct list_head list;
542 struct soundbus_dev *sdev;
543 struct device_node *sound;
544 struct aoa_codec *codecs[MAX_CODECS_PER_BUS];
545 struct layout *layout;
546 struct gpio_runtime gpio;
548 /* we need these for headphone/lineout detection */
549 struct snd_kcontrol *headphone_ctrl;
550 struct snd_kcontrol *lineout_ctrl;
551 struct snd_kcontrol *speaker_ctrl;
552 struct snd_kcontrol *headphone_detected_ctrl;
553 struct snd_kcontrol *lineout_detected_ctrl;
555 struct layout_dev_ptr selfptr_headphone;
556 struct layout_dev_ptr selfptr_lineout;
558 u32 have_lineout_detect:1,
559 have_headphone_detect:1,
560 switch_on_headphone:1,
564 static LIST_HEAD(layouts_list);
565 static int layouts_list_items;
566 /* this can go away but only if we allow multiple cards,
567 * make the fabric handle all the card stuff, etc... */
568 static struct layout_dev *layout_device;
570 static int control_info(struct snd_kcontrol *kcontrol,
571 struct snd_ctl_elem_info *uinfo)
573 uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN;
575 uinfo->value.integer.min = 0;
576 uinfo->value.integer.max = 1;
580 #define AMP_CONTROL(n, description) \
581 static int n##_control_get(struct snd_kcontrol *kcontrol, \
582 struct snd_ctl_elem_value *ucontrol) \
584 struct gpio_runtime *gpio = snd_kcontrol_chip(kcontrol); \
585 if (gpio->methods && gpio->methods->get_##n) \
586 ucontrol->value.integer.value[0] = \
587 gpio->methods->get_##n(gpio); \
590 static int n##_control_put(struct snd_kcontrol *kcontrol, \
591 struct snd_ctl_elem_value *ucontrol) \
593 struct gpio_runtime *gpio = snd_kcontrol_chip(kcontrol); \
594 if (gpio->methods && gpio->methods->get_##n) \
595 gpio->methods->set_##n(gpio, \
596 ucontrol->value.integer.value[0]); \
599 static struct snd_kcontrol_new n##_ctl = { \
600 .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
601 .name = description, \
602 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE, \
603 .info = control_info, \
604 .get = n##_control_get, \
605 .put = n##_control_put, \
608 AMP_CONTROL(headphone, "Headphone Switch");
609 AMP_CONTROL(speakers, "Speakers Switch");
610 AMP_CONTROL(lineout, "Line-Out Switch");
612 static int detect_choice_get(struct snd_kcontrol *kcontrol,
613 struct snd_ctl_elem_value *ucontrol)
615 struct layout_dev *ldev = snd_kcontrol_chip(kcontrol);
617 switch (kcontrol->private_value) {
619 ucontrol->value.integer.value[0] = ldev->switch_on_headphone;
622 ucontrol->value.integer.value[0] = ldev->switch_on_lineout;
630 static int detect_choice_put(struct snd_kcontrol *kcontrol,
631 struct snd_ctl_elem_value *ucontrol)
633 struct layout_dev *ldev = snd_kcontrol_chip(kcontrol);
635 switch (kcontrol->private_value) {
637 ldev->switch_on_headphone = !!ucontrol->value.integer.value[0];
640 ldev->switch_on_lineout = !!ucontrol->value.integer.value[0];
648 static struct snd_kcontrol_new headphone_detect_choice = {
649 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
650 .name = "Headphone Detect Autoswitch",
651 .info = control_info,
652 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
653 .get = detect_choice_get,
654 .put = detect_choice_put,
658 static struct snd_kcontrol_new lineout_detect_choice = {
659 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
660 .name = "Line-Out Detect Autoswitch",
661 .info = control_info,
662 .access = SNDRV_CTL_ELEM_ACCESS_READWRITE,
663 .get = detect_choice_get,
664 .put = detect_choice_put,
668 static int detected_get(struct snd_kcontrol *kcontrol,
669 struct snd_ctl_elem_value *ucontrol)
671 struct layout_dev *ldev = snd_kcontrol_chip(kcontrol);
674 switch (kcontrol->private_value) {
676 v = ldev->gpio.methods->get_detect(&ldev->gpio,
677 AOA_NOTIFY_HEADPHONE);
680 v = ldev->gpio.methods->get_detect(&ldev->gpio,
681 AOA_NOTIFY_LINE_OUT);
686 ucontrol->value.integer.value[0] = v;
690 static struct snd_kcontrol_new headphone_detected = {
691 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
692 .name = "Headphone Detected",
693 .info = control_info,
694 .access = SNDRV_CTL_ELEM_ACCESS_READ,
699 static struct snd_kcontrol_new lineout_detected = {
700 .iface = SNDRV_CTL_ELEM_IFACE_MIXER,
701 .name = "Line-Out Detected",
702 .info = control_info,
703 .access = SNDRV_CTL_ELEM_ACCESS_READ,
708 static int check_codec(struct aoa_codec *codec,
709 struct layout_dev *ldev,
710 struct codec_connect_info *cci)
714 struct codec_connection *cc;
716 /* if the codec has a 'codec' node, we require a reference */
717 if (codec->node && (strcmp(codec->node->name, "codec") == 0)) {
718 snprintf(propname, sizeof(propname),
719 "platform-%s-codec-ref", codec->name);
720 ref = (u32*)get_property(ldev->sound, propname, NULL);
722 printk(KERN_INFO "snd-aoa-fabric-layout: "
723 "required property %s not present\n", propname);
726 if (*ref != codec->node->linux_phandle) {
727 printk(KERN_INFO "snd-aoa-fabric-layout: "
728 "%s doesn't match!\n", propname);
732 if (layouts_list_items != 1) {
733 printk(KERN_INFO "snd-aoa-fabric-layout: "
734 "more than one soundbus, but no references.\n");
738 codec->soundbus_dev = ldev->sdev;
739 codec->gpio = &ldev->gpio;
741 cc = cci->connections;
745 printk(KERN_INFO "snd-aoa-fabric-layout: can use this codec\n");
747 codec->connected = 0;
748 codec->fabric_data = cc;
750 while (cc->connected) {
751 codec->connected |= 1<<cc->codec_bit;
758 static int layout_found_codec(struct aoa_codec *codec)
760 struct layout_dev *ldev;
763 list_for_each_entry(ldev, &layouts_list, list) {
764 for (i=0; i<MAX_CODECS_PER_BUS; i++) {
765 if (!ldev->layout->codecs[i].name)
767 if (strcmp(ldev->layout->codecs[i].name, codec->name) == 0) {
768 if (check_codec(codec,
770 &ldev->layout->codecs[i]) == 0)
778 static void layout_remove_codec(struct aoa_codec *codec)
781 /* here remove the codec from the layout dev's
784 codec->soundbus_dev = NULL;
786 for (i=0; i<MAX_CODECS_PER_BUS; i++) {
790 static void layout_notify(void *data)
792 struct layout_dev_ptr *dptr = data;
793 struct layout_dev *ldev;
795 struct snd_kcontrol *detected, *c;
796 struct snd_card *card = aoa_get_card();
799 if (data == &ldev->selfptr_headphone) {
800 v = ldev->gpio.methods->get_detect(&ldev->gpio, AOA_NOTIFY_HEADPHONE);
801 detected = ldev->headphone_detected_ctrl;
802 update = ldev->switch_on_headphone;
804 ldev->gpio.methods->set_speakers(&ldev->gpio, !v);
805 ldev->gpio.methods->set_headphone(&ldev->gpio, v);
806 ldev->gpio.methods->set_lineout(&ldev->gpio, 0);
808 } else if (data == &ldev->selfptr_lineout) {
809 v = ldev->gpio.methods->get_detect(&ldev->gpio, AOA_NOTIFY_LINE_OUT);
810 detected = ldev->lineout_detected_ctrl;
811 update = ldev->switch_on_lineout;
813 ldev->gpio.methods->set_speakers(&ldev->gpio, !v);
814 ldev->gpio.methods->set_headphone(&ldev->gpio, 0);
815 ldev->gpio.methods->set_lineout(&ldev->gpio, v);
821 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &detected->id);
823 c = ldev->headphone_ctrl;
825 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &c->id);
826 c = ldev->speaker_ctrl;
828 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &c->id);
829 c = ldev->lineout_ctrl;
831 snd_ctl_notify(card, SNDRV_CTL_EVENT_MASK_VALUE, &c->id);
835 static void layout_attached_codec(struct aoa_codec *codec)
837 struct codec_connection *cc;
838 struct snd_kcontrol *ctl;
839 int headphones, lineout;
840 struct layout_dev *ldev = layout_device;
842 /* need to add this codec to our codec array! */
844 cc = codec->fabric_data;
846 headphones = codec->gpio->methods->get_detect(codec->gpio,
847 AOA_NOTIFY_HEADPHONE);
848 lineout = codec->gpio->methods->get_detect(codec->gpio,
849 AOA_NOTIFY_LINE_OUT);
851 while (cc->connected) {
852 if (cc->connected & CC_SPEAKERS) {
853 if (headphones <= 0 && lineout <= 0)
854 ldev->gpio.methods->set_speakers(codec->gpio, 1);
855 ctl = snd_ctl_new1(&speakers_ctl, codec->gpio);
856 ldev->speaker_ctrl = ctl;
857 aoa_snd_ctl_add(ctl);
859 if (cc->connected & CC_HEADPHONE) {
861 ldev->gpio.methods->set_headphone(codec->gpio, 1);
862 ctl = snd_ctl_new1(&headphone_ctl, codec->gpio);
863 ldev->headphone_ctrl = ctl;
864 aoa_snd_ctl_add(ctl);
865 ldev->have_headphone_detect =
867 ->set_notify(&ldev->gpio,
868 AOA_NOTIFY_HEADPHONE,
870 &ldev->selfptr_headphone);
871 if (ldev->have_headphone_detect) {
872 ctl = snd_ctl_new1(&headphone_detect_choice,
874 aoa_snd_ctl_add(ctl);
875 ctl = snd_ctl_new1(&headphone_detected,
877 ldev->headphone_detected_ctrl = ctl;
878 aoa_snd_ctl_add(ctl);
881 if (cc->connected & CC_LINEOUT) {
883 ldev->gpio.methods->set_lineout(codec->gpio, 1);
884 ctl = snd_ctl_new1(&lineout_ctl, codec->gpio);
885 if (cc->connected & CC_LINEOUT_LABELLED_HEADPHONE)
886 strlcpy(ctl->id.name,
887 "Headphone Switch", sizeof(ctl->id.name));
888 ldev->lineout_ctrl = ctl;
889 aoa_snd_ctl_add(ctl);
890 ldev->have_lineout_detect =
892 ->set_notify(&ldev->gpio,
895 &ldev->selfptr_lineout);
896 if (ldev->have_lineout_detect) {
897 ctl = snd_ctl_new1(&lineout_detect_choice,
899 if (cc->connected & CC_LINEOUT_LABELLED_HEADPHONE)
900 strlcpy(ctl->id.name,
901 "Headphone Detect Autoswitch",
902 sizeof(ctl->id.name));
903 aoa_snd_ctl_add(ctl);
904 ctl = snd_ctl_new1(&lineout_detected,
906 if (cc->connected & CC_LINEOUT_LABELLED_HEADPHONE)
907 strlcpy(ctl->id.name,
908 "Headphone Detected",
909 sizeof(ctl->id.name));
910 ldev->lineout_detected_ctrl = ctl;
911 aoa_snd_ctl_add(ctl);
916 /* now update initial state */
917 if (ldev->have_headphone_detect)
918 layout_notify(&ldev->selfptr_headphone);
919 if (ldev->have_lineout_detect)
920 layout_notify(&ldev->selfptr_lineout);
923 static struct aoa_fabric layout_fabric = {
924 .name = "SoundByLayout",
925 .owner = THIS_MODULE,
926 .found_codec = layout_found_codec,
927 .remove_codec = layout_remove_codec,
928 .attached_codec = layout_attached_codec,
931 static int aoa_fabric_layout_probe(struct soundbus_dev *sdev)
933 struct device_node *sound = NULL;
934 unsigned int *layout_id;
935 struct layout *layout;
936 struct layout_dev *ldev = NULL;
939 /* hm, currently we can only have one ... */
943 /* by breaking out we keep a reference */
944 while ((sound = of_get_next_child(sdev->ofdev.node, sound))) {
945 if (sound->type && strcasecmp(sound->type, "soundchip") == 0)
948 if (!sound) return -ENODEV;
950 layout_id = (unsigned int *) get_property(sound, "layout-id", NULL);
953 printk(KERN_INFO "snd-aoa-fabric-layout: found bus with layout %d ", *layout_id);
955 layout = find_layout_by_id(*layout_id);
957 printk("(no idea how to handle)\n");
961 ldev = kzalloc(sizeof(struct layout_dev), GFP_KERNEL);
965 layout_device = ldev;
968 ldev->layout = layout;
969 ldev->gpio.node = sound->parent;
970 switch (layout->layout_id) {
971 case 41: /* that unknown machine no one seems to have */
972 case 51: /* PowerBook5,4 */
973 case 58: /* Mac Mini */
974 ldev->gpio.methods = ftr_gpio_methods;
977 ldev->gpio.methods = pmf_gpio_methods;
979 ldev->selfptr_headphone.ptr = ldev;
980 ldev->selfptr_lineout.ptr = ldev;
981 sdev->ofdev.dev.driver_data = ldev;
984 list_add(&ldev->list, &layouts_list);
985 layouts_list_items++;
987 /* assign these before registering ourselves, so
988 * callbacks that are done during registration
989 * already have the values */
990 sdev->pcmid = ldev->layout->pcmid;
991 if (ldev->layout->busname) {
992 sdev->pcmname = ldev->layout->busname;
994 sdev->pcmname = "Master";
997 ldev->gpio.methods->init(&ldev->gpio);
999 err = aoa_fabric_register(&layout_fabric);
1000 if (err && err != -EALREADY) {
1001 printk(KERN_INFO "snd-aoa-fabric-layout: can't use,"
1002 " another fabric is active!\n");
1007 ldev->switch_on_headphone = 1;
1008 ldev->switch_on_lineout = 1;
1011 /* we won't be using these then... */
1012 ldev->gpio.methods->exit(&ldev->gpio);
1013 /* reset if we didn't use it */
1014 sdev->pcmname = NULL;
1016 list_del(&ldev->list);
1017 layouts_list_items--;
1019 if (sound) of_node_put(sound);
1020 layout_device = NULL;
1021 if (ldev) kfree(ldev);
1025 static int aoa_fabric_layout_remove(struct soundbus_dev *sdev)
1027 struct layout_dev *ldev = sdev->ofdev.dev.driver_data;
1030 for (i=0; i<MAX_CODECS_PER_BUS; i++) {
1031 if (ldev->codecs[i]) {
1032 aoa_fabric_unlink_codec(ldev->codecs[i]);
1034 ldev->codecs[i] = NULL;
1036 list_del(&ldev->list);
1037 layouts_list_items--;
1038 of_node_put(ldev->sound);
1040 ldev->gpio.methods->set_notify(&ldev->gpio,
1041 AOA_NOTIFY_HEADPHONE,
1044 ldev->gpio.methods->set_notify(&ldev->gpio,
1045 AOA_NOTIFY_LINE_OUT,
1049 ldev->gpio.methods->exit(&ldev->gpio);
1050 layout_device = NULL;
1053 sdev->pcmname = NULL;
1058 static int aoa_fabric_layout_suspend(struct soundbus_dev *sdev, pm_message_t state)
1060 struct layout_dev *ldev = sdev->ofdev.dev.driver_data;
1062 printk("aoa_fabric_layout_suspend()\n");
1064 if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off)
1065 ldev->gpio.methods->all_amps_off(&ldev->gpio);
1070 static int aoa_fabric_layout_resume(struct soundbus_dev *sdev)
1072 struct layout_dev *ldev = sdev->ofdev.dev.driver_data;
1074 printk("aoa_fabric_layout_resume()\n");
1076 if (ldev->gpio.methods && ldev->gpio.methods->all_amps_off)
1077 ldev->gpio.methods->all_amps_restore(&ldev->gpio);
1083 static struct soundbus_driver aoa_soundbus_driver = {
1084 .name = "snd_aoa_soundbus_drv",
1085 .owner = THIS_MODULE,
1086 .probe = aoa_fabric_layout_probe,
1087 .remove = aoa_fabric_layout_remove,
1089 .suspend = aoa_fabric_layout_suspend,
1090 .resume = aoa_fabric_layout_resume,
1094 static int __init aoa_fabric_layout_init(void)
1098 err = soundbus_register_driver(&aoa_soundbus_driver);
1104 static void __exit aoa_fabric_layout_exit(void)
1106 soundbus_unregister_driver(&aoa_soundbus_driver);
1107 aoa_fabric_unregister(&layout_fabric);
1110 module_init(aoa_fabric_layout_init);
1111 module_exit(aoa_fabric_layout_exit);