aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTakashi Iwai <tiwai@suse.de>2015-02-17 08:46:40 -0500
committerTakashi Iwai <tiwai@suse.de>2015-02-17 08:46:40 -0500
commit922c88a8368a61ee93653d4a2888a7f4ce263102 (patch)
treeab75d851d8d609bef5a3baf4d30a9f1547fd6a1b
parentef7449780ebb596b47d5019eb7ba7878c30a3404 (diff)
ALSA: hda - Embed struct hda_bus_unsolicited into struct hda_bus
There is no big merit to handle hda_bus_unsolicited object individually, as it's tightly coupled with the hda_bus object itself. Embedding it makes the code simpler in the end. Signed-off-by: Takashi Iwai <tiwai@suse.de>
-rw-r--r--sound/pci/hda/hda_codec.c39
-rw-r--r--sound/pci/hda/hda_codec.h13
-rw-r--r--sound/pci/hda/hda_local.h17
3 files changed, 15 insertions, 54 deletions
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c
index 215bf048c668..0734cb35887d 100644
--- a/sound/pci/hda/hda_codec.c
+++ b/sound/pci/hda/hda_codec.c
@@ -762,10 +762,7 @@ int snd_hda_queue_unsol_event(struct hda_bus *bus, u32 res, u32 res_ex)
762 return 0; 762 return 0;
763 763
764 trace_hda_unsol_event(bus, res, res_ex); 764 trace_hda_unsol_event(bus, res, res_ex);
765 unsol = bus->unsol; 765 unsol = &bus->unsol;
766 if (!unsol)
767 return 0;
768
769 wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE; 766 wp = (unsol->wp + 1) % HDA_UNSOL_QUEUE_SIZE;
770 unsol->wp = wp; 767 unsol->wp = wp;
771 768
@@ -784,9 +781,8 @@ EXPORT_SYMBOL_GPL(snd_hda_queue_unsol_event);
784 */ 781 */
785static void process_unsol_events(struct work_struct *work) 782static void process_unsol_events(struct work_struct *work)
786{ 783{
787 struct hda_bus_unsolicited *unsol = 784 struct hda_bus *bus = container_of(work, struct hda_bus, unsol.work);
788 container_of(work, struct hda_bus_unsolicited, work); 785 struct hda_bus_unsolicited *unsol = &bus->unsol;
789 struct hda_bus *bus = unsol->bus;
790 struct hda_codec *codec; 786 struct hda_codec *codec;
791 unsigned int rp, caddr, res; 787 unsigned int rp, caddr, res;
792 788
@@ -805,27 +801,6 @@ static void process_unsol_events(struct work_struct *work)
805} 801}
806 802
807/* 803/*
808 * initialize unsolicited queue
809 */
810static int init_unsol_queue(struct hda_bus *bus)
811{
812 struct hda_bus_unsolicited *unsol;
813
814 if (bus->unsol) /* already initialized */
815 return 0;
816
817 unsol = kzalloc(sizeof(*unsol), GFP_KERNEL);
818 if (!unsol) {
819 dev_err(bus->card->dev, "can't allocate unsolicited queue\n");
820 return -ENOMEM;
821 }
822 INIT_WORK(&unsol->work, process_unsol_events);
823 unsol->bus = bus;
824 bus->unsol = unsol;
825 return 0;
826}
827
828/*
829 * destructor 804 * destructor
830 */ 805 */
831static void snd_hda_bus_free(struct hda_bus *bus) 806static void snd_hda_bus_free(struct hda_bus *bus)
@@ -836,7 +811,6 @@ static void snd_hda_bus_free(struct hda_bus *bus)
836 WARN_ON(!list_empty(&bus->codec_list)); 811 WARN_ON(!list_empty(&bus->codec_list));
837 if (bus->workq) 812 if (bus->workq)
838 flush_workqueue(bus->workq); 813 flush_workqueue(bus->workq);
839 kfree(bus->unsol);
840 if (bus->ops.private_free) 814 if (bus->ops.private_free)
841 bus->ops.private_free(bus); 815 bus->ops.private_free(bus);
842 if (bus->workq) 816 if (bus->workq)
@@ -888,6 +862,7 @@ int snd_hda_bus_new(struct snd_card *card,
888 mutex_init(&bus->cmd_mutex); 862 mutex_init(&bus->cmd_mutex);
889 mutex_init(&bus->prepare_mutex); 863 mutex_init(&bus->prepare_mutex);
890 INIT_LIST_HEAD(&bus->codec_list); 864 INIT_LIST_HEAD(&bus->codec_list);
865 INIT_WORK(&bus->unsol.work, process_unsol_events);
891 866
892 snprintf(bus->workq_name, sizeof(bus->workq_name), 867 snprintf(bus->workq_name, sizeof(bus->workq_name),
893 "hd-audio%d", card->number); 868 "hd-audio%d", card->number);
@@ -1689,12 +1664,6 @@ int snd_hda_codec_configure(struct hda_codec *codec)
1689 return err; 1664 return err;
1690 } 1665 }
1691 1666
1692 if (codec->patch_ops.unsol_event) {
1693 err = init_unsol_queue(codec->bus);
1694 if (err < 0)
1695 return err;
1696 }
1697
1698 /* audio codec should override the mixer name */ 1667 /* audio codec should override the mixer name */
1699 if (codec->afg || !*codec->bus->card->mixername) 1668 if (codec->afg || !*codec->bus->card->mixername)
1700 snprintf(codec->bus->card->mixername, 1669 snprintf(codec->bus->card->mixername,
diff --git a/sound/pci/hda/hda_codec.h b/sound/pci/hda/hda_codec.h
index 5a6594884069..96421a3b32cd 100644
--- a/sound/pci/hda/hda_codec.h
+++ b/sound/pci/hda/hda_codec.h
@@ -66,7 +66,6 @@ struct hda_beep;
66struct hda_codec; 66struct hda_codec;
67struct hda_pcm; 67struct hda_pcm;
68struct hda_pcm_stream; 68struct hda_pcm_stream;
69struct hda_bus_unsolicited;
70 69
71/* NID type */ 70/* NID type */
72typedef u16 hda_nid_t; 71typedef u16 hda_nid_t;
@@ -101,6 +100,16 @@ struct hda_bus_ops {
101#endif 100#endif
102}; 101};
103 102
103/* unsolicited event handler */
104#define HDA_UNSOL_QUEUE_SIZE 64
105struct hda_bus_unsolicited {
106 /* ring buffer */
107 u32 queue[HDA_UNSOL_QUEUE_SIZE * 2];
108 unsigned int rp, wp;
109 /* workqueue */
110 struct work_struct work;
111};
112
104/* 113/*
105 * codec bus 114 * codec bus
106 * 115 *
@@ -126,7 +135,7 @@ struct hda_bus {
126 struct mutex prepare_mutex; 135 struct mutex prepare_mutex;
127 136
128 /* unsolicited event queue */ 137 /* unsolicited event queue */
129 struct hda_bus_unsolicited *unsol; 138 struct hda_bus_unsolicited unsol;
130 char workq_name[16]; 139 char workq_name[16];
131 struct workqueue_struct *workq; /* common workqueue for codecs */ 140 struct workqueue_struct *workq; /* common workqueue for codecs */
132 141
diff --git a/sound/pci/hda/hda_local.h b/sound/pci/hda/hda_local.h
index 62658f2f8c9f..49c08a7278c4 100644
--- a/sound/pci/hda/hda_local.h
+++ b/sound/pci/hda/hda_local.h
@@ -466,23 +466,6 @@ void snd_hda_pick_pin_fixup(struct hda_codec *codec,
466 const struct snd_hda_pin_quirk *pin_quirk, 466 const struct snd_hda_pin_quirk *pin_quirk,
467 const struct hda_fixup *fixlist); 467 const struct hda_fixup *fixlist);
468 468
469
470/*
471 * unsolicited event handler
472 */
473
474#define HDA_UNSOL_QUEUE_SIZE 64
475
476struct hda_bus_unsolicited {
477 /* ring buffer */
478 u32 queue[HDA_UNSOL_QUEUE_SIZE * 2];
479 unsigned int rp, wp;
480
481 /* workqueue */
482 struct work_struct work;
483 struct hda_bus *bus;
484};
485
486/* helper macros to retrieve pin default-config values */ 469/* helper macros to retrieve pin default-config values */
487#define get_defcfg_connect(cfg) \ 470#define get_defcfg_connect(cfg) \
488 ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT) 471 ((cfg & AC_DEFCFG_PORT_CONN) >> AC_DEFCFG_PORT_CONN_SHIFT)