ALSA: hda - Don't call snd_hda_codec_configure in snd_hda_codec_new()
[safe/jmp/linux-2.6] / sound / pci / hda / hda_codec.h
index a77ba22..b7ca7d5 100644 (file)
@@ -539,6 +539,16 @@ static inline void snd_array_init(struct snd_array *array, unsigned int size,
        array->alloc_align = align;
 }
 
+static inline void *snd_array_elem(struct snd_array *array, unsigned int idx)
+{
+       return array->list + idx * array->elem_size;
+}
+
+static inline unsigned int snd_array_index(struct snd_array *array, void *ptr)
+{
+       return (unsigned long)(ptr - array->list) / array->elem_size;
+}
+
 /*
  * Structures
  */
@@ -556,17 +566,19 @@ typedef u16 hda_nid_t;
 /* bus operators */
 struct hda_bus_ops {
        /* send a single command */
-       int (*command)(struct hda_codec *codec, hda_nid_t nid, int direct,
-                      unsigned int verb, unsigned int parm);
+       int (*command)(struct hda_bus *bus, unsigned int cmd);
        /* get a response from the last command */
-       unsigned int (*get_response)(struct hda_codec *codec);
+       unsigned int (*get_response)(struct hda_bus *bus);
        /* free the private data */
        void (*private_free)(struct hda_bus *);
        /* attach a PCM stream */
-       int (*attach_pcm)(struct hda_codec *codec, struct hda_pcm *pcm);
+       int (*attach_pcm)(struct hda_bus *bus, struct hda_codec *codec,
+                         struct hda_pcm *pcm);
+       /* reset bus for retry verb */
+       void (*bus_reset)(struct hda_bus *bus);
 #ifdef CONFIG_SND_HDA_POWER_SAVE
        /* notify power-up/down from codec to controller */
-       void (*pm_notify)(struct hda_codec *codec);
+       void (*pm_notify)(struct hda_bus *bus);
 #endif
 };
 
@@ -575,6 +587,7 @@ struct hda_bus_template {
        void *private_data;
        struct pci_dev *pci;
        const char *modelname;
+       int *power_save;
        struct hda_bus_ops ops;
 };
 
@@ -591,6 +604,7 @@ struct hda_bus {
        void *private_data;
        struct pci_dev *pci;
        const char *modelname;
+       int *power_save;
        struct hda_bus_ops ops;
 
        /* codec linked list */
@@ -602,11 +616,21 @@ struct hda_bus {
 
        /* unsolicited event queue */
        struct hda_bus_unsolicited *unsol;
+       char workq_name[16];
+       struct workqueue_struct *workq; /* common workqueue for codecs */
 
-       struct snd_info_entry *proc;
+       /* assigned PCMs */
+       DECLARE_BITMAP(pcm_dev_bits, SNDRV_PCM_DEVICES);
 
        /* misc op flags */
        unsigned int needs_damn_long_delay :1;
+       unsigned int allow_bus_reset:1; /* allow bus reset at fatal error */
+       unsigned int sync_write:1;      /* sync after verb write */
+       /* status for codec/controller */
+       unsigned int shutdown :1;       /* being unloaded */
+       unsigned int rirb_error:1;      /* error in codec communication */
+       unsigned int response_reset:1;  /* controller was reset */
+       unsigned int in_reset:1;        /* during reset operation */
 };
 
 /*
@@ -626,6 +650,16 @@ struct hda_codec_preset {
        int (*patch)(struct hda_codec *codec);
 };
        
+struct hda_codec_preset_list {
+       const struct hda_codec_preset *preset;
+       struct module *owner;
+       struct list_head list;
+};
+
+/* initial hook */
+int snd_hda_add_codec_preset(struct hda_codec_preset_list *preset);
+int snd_hda_delete_codec_preset(struct hda_codec_preset_list *preset);
+
 /* ops set by the preset patch */
 struct hda_codec_ops {
        int (*build_controls)(struct hda_codec *codec);
@@ -713,13 +747,16 @@ struct hda_codec {
        hda_nid_t mfg;  /* MFG node id */
 
        /* ids */
+       u32 function_id;
        u32 vendor_id;
        u32 subsystem_id;
        u32 revision_id;
 
        /* detected preset */
        const struct hda_codec_preset *preset;
-       const char *name;       /* codec name */
+       struct module *owner;
+       const char *vendor_name;        /* codec vendor name */
+       const char *chip_name;          /* codec chip name */
        const char *modelname;  /* model name for preset */
 
        /* set by patch */
@@ -746,15 +783,19 @@ struct hda_codec {
        struct hda_cache_rec cmd_cache; /* cache for other commands */
 
        struct mutex spdif_mutex;
+       struct mutex control_mutex;
        unsigned int spdif_status;      /* IEC958 status bits */
        unsigned short spdif_ctls;      /* SPDIF control bits */
        unsigned int spdif_in_enable;   /* SPDIF input enable? */
        hda_nid_t *slave_dig_outs; /* optional digital out slave widgets */
+       struct snd_array init_pins;     /* initial (BIOS) pin configurations */
+       struct snd_array driver_pins;   /* pin configs set by codec parser */
 
 #ifdef CONFIG_SND_HDA_HWDEP
        struct snd_hwdep *hwdep;        /* assigned hwdep device */
        struct snd_array init_verbs;    /* additional init verbs */
        struct snd_array hints;         /* additional hints */
+       struct snd_array user_pins;     /* default pin configs to override */
 #endif
 
        /* misc flags */
@@ -762,12 +803,19 @@ struct hda_codec {
                                             * status change
                                             * (e.g. Realtek codecs)
                                             */
+       unsigned int pin_amp_workaround:1; /* pin out-amp takes index
+                                           * (e.g. Conexant codecs)
+                                           */
 #ifdef CONFIG_SND_HDA_POWER_SAVE
        unsigned int power_on :1;       /* current (global) power-state */
        unsigned int power_transition :1; /* power-state in transition */
        int power_count;        /* current (global) power refcount */
        struct delayed_work power_work; /* delayed task for powerdown */
 #endif
+
+       /* codec-specific additional proc output */
+       void (*proc_widget_hook)(struct snd_info_buffer *buffer,
+                                struct hda_codec *codec, hda_nid_t nid);
 };
 
 /* direction */
@@ -783,6 +831,7 @@ int snd_hda_bus_new(struct snd_card *card, const struct hda_bus_template *temp,
                    struct hda_bus **busp);
 int snd_hda_codec_new(struct hda_bus *bus, unsigned int codec_addr,
                      struct hda_codec **codecp);
+int snd_hda_codec_configure(struct hda_codec *codec);
 
 /*
  * low level functions
@@ -823,6 +872,18 @@ void snd_hda_codec_resume_cache(struct hda_codec *codec);
 #define snd_hda_sequence_write_cache   snd_hda_sequence_write
 #endif
 
+/* the struct for codec->pin_configs */
+struct hda_pincfg {
+       hda_nid_t nid;
+       unsigned int cfg;
+};
+
+unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid);
+int snd_hda_codec_set_pincfg(struct hda_codec *codec, hda_nid_t nid,
+                            unsigned int cfg);
+int snd_hda_add_pincfg(struct hda_codec *codec, struct snd_array *list,
+                      hda_nid_t nid, unsigned int cfg); /* for hwdep */
+
 /*
  * Mixer
  */
@@ -833,6 +894,7 @@ int snd_hda_codec_build_controls(struct hda_codec *codec);
  * PCM
  */
 int snd_hda_build_pcms(struct hda_bus *bus);
+int snd_hda_codec_build_pcms(struct hda_codec *codec);
 void snd_hda_codec_setup_stream(struct hda_codec *codec, hda_nid_t nid,
                                u32 stream_tag,
                                int channel_id, int format);
@@ -841,8 +903,6 @@ unsigned int snd_hda_calc_stream_format(unsigned int rate,
                                        unsigned int channels,
                                        unsigned int format,
                                        unsigned int maxbps);
-int snd_hda_query_supported_pcm(struct hda_codec *codec, hda_nid_t nid,
-                               u32 *ratesp, u64 *formatsp, unsigned int *bpsp);
 int snd_hda_is_supported_format(struct hda_codec *codec, hda_nid_t nid,
                                unsigned int format);
 
@@ -855,23 +915,43 @@ void snd_hda_get_codec_name(struct hda_codec *codec, char *name, int namelen);
  * power management
  */
 #ifdef CONFIG_PM
-int snd_hda_suspend(struct hda_bus *bus, pm_message_t state);
+int snd_hda_suspend(struct hda_bus *bus);
 int snd_hda_resume(struct hda_bus *bus);
 #endif
 
 /*
+ * get widget information
+ */
+const char *snd_hda_get_jack_connectivity(u32 cfg);
+const char *snd_hda_get_jack_type(u32 cfg);
+const char *snd_hda_get_jack_location(u32 cfg);
+
+/*
  * power saving
  */
 #ifdef CONFIG_SND_HDA_POWER_SAVE
 void snd_hda_power_up(struct hda_codec *codec);
 void snd_hda_power_down(struct hda_codec *codec);
 #define snd_hda_codec_needs_resume(codec) codec->power_count
-int snd_hda_codecs_inuse(struct hda_bus *bus);
 #else
 static inline void snd_hda_power_up(struct hda_codec *codec) {}
 static inline void snd_hda_power_down(struct hda_codec *codec) {}
 #define snd_hda_codec_needs_resume(codec) 1
-#define snd_hda_codecs_inuse(bus) 1
+#endif
+
+/*
+ * Codec modularization
+ */
+
+/* Export symbols only for communication with codec drivers;
+ * When built in kernel, all HD-audio drivers are supposed to be statically
+ * linked to the kernel.  Thus, the symbols don't have to (or shouldn't) be
+ * exported unless it's built as a module.
+ */
+#ifdef MODULE
+#define EXPORT_SYMBOL_HDA(sym) EXPORT_SYMBOL_GPL(sym)
+#else
+#define EXPORT_SYMBOL_HDA(sym)
 #endif
 
 #endif /* __SOUND_HDA_CODEC_H */