Skip to content

Commit

Permalink
ALSA: hda - Add sysfs to codec object, too
Browse files Browse the repository at this point in the history
We have currently sysfs attributes for each hwdep, but basically these
should belong to the codec itself, per se.  Let's add them to the
codec object while keeping them for hwdep as is for compatibility.

While we are at it, split the sysfs-related stuff into a separate
source file, hda_sysfs.c, and keep only the stuff necessary for hwdep
in hda_hwdep.c.

Signed-off-by: Takashi Iwai <tiwai@suse.de>
  • Loading branch information
Takashi Iwai committed Feb 25, 2014
1 parent 13aeaf6 commit 648a8d2
Show file tree
Hide file tree
Showing 7 changed files with 788 additions and 764 deletions.
4 changes: 0 additions & 4 deletions sound/pci/hda/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ config SND_HDA_HWDEP

config SND_HDA_RECONFIG
bool "Allow dynamic codec reconfiguration"
depends on SND_HDA_HWDEP
help
Say Y here to enable the HD-audio codec re-configuration feature.
This adds the sysfs interfaces to allow user to clear the whole
Expand Down Expand Up @@ -76,16 +75,13 @@ config SND_HDA_INPUT_JACK
config SND_HDA_PATCH_LOADER
bool "Support initialization patch loading for HD-audio"
select FW_LOADER
select SND_HDA_HWDEP
select SND_HDA_RECONFIG
help
Say Y here to allow the HD-audio driver to load a pseudo
firmware file ("patch") for overriding the BIOS setup at
start up. The "patch" file can be specified via patch module
option, such as patch=hda-init.

This option turns on hwdep and reconfig features automatically.

config SND_HDA_CODEC_REALTEK
tristate "Build Realtek HD-audio codec support"
select SND_HDA_GENERIC
Expand Down
2 changes: 1 addition & 1 deletion sound/pci/hda/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ snd-hda-intel-objs := hda_intel.o
# for haswell power well
snd-hda-intel-$(CONFIG_SND_HDA_I915) += hda_i915.o

snd-hda-codec-y := hda_codec.o hda_jack.o hda_auto_parser.o
snd-hda-codec-y := hda_codec.o hda_jack.o hda_auto_parser.o hda_sysfs.o
snd-hda-codec-$(CONFIG_PROC_FS) += hda_proc.o
snd-hda-codec-$(CONFIG_SND_HDA_HWDEP) += hda_hwdep.o
snd-hda-codec-$(CONFIG_SND_HDA_INPUT_BEEP) += hda_beep.o
Expand Down
11 changes: 8 additions & 3 deletions sound/pci/hda/hda_codec.c
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ unsigned int snd_hda_codec_get_pincfg(struct hda_codec *codec, hda_nid_t nid)
{
struct hda_pincfg *pin;

#ifdef CONFIG_SND_HDA_HWDEP
#ifdef CONFIG_SND_HDA_RECONFIG
{
unsigned int cfg = 0;
mutex_lock(&codec->user_mutex);
Expand Down Expand Up @@ -1285,7 +1285,7 @@ static void free_hda_cache(struct hda_cache_rec *cache);
static void free_init_pincfgs(struct hda_codec *codec)
{
snd_array_free(&codec->driver_pins);
#ifdef CONFIG_SND_HDA_HWDEP
#ifdef CONFIG_SND_HDA_RECONFIG
snd_array_free(&codec->user_pins);
#endif
snd_array_free(&codec->init_pins);
Expand Down Expand Up @@ -1359,6 +1359,7 @@ static void snd_hda_codec_free(struct hda_codec *codec)
if (codec->patch_ops.free)
codec->patch_ops.free(codec);
hda_call_pm_notify(codec, false); /* cancel leftover refcounts */
snd_hda_sysfs_clear(codec);
unload_parser(codec);
module_put(codec->owner);
free_hda_cache(&codec->amp_cache);
Expand Down Expand Up @@ -1447,8 +1448,10 @@ int snd_hda_codec_new(struct hda_bus *bus,
codec->dev.parent = &bus->card->card_dev;
codec->dev.class = sound_class;
codec->dev.release = snd_hda_codec_dev_release;
codec->dev.groups = snd_hda_dev_attr_groups;
dev_set_name(&codec->dev, "hdaudioC%dD%d", bus->card->number,
codec_addr);
dev_set_drvdata(&codec->dev, codec); /* for sysfs */

codec->bus = bus;
codec->addr = codec_addr;
Expand Down Expand Up @@ -1480,6 +1483,8 @@ int snd_hda_codec_new(struct hda_bus *bus,
hda_keep_power_on(codec);
#endif

snd_hda_sysfs_init(codec);

if (codec->bus->modelname) {
codec->modelname = kstrdup(codec->bus->modelname, GFP_KERNEL);
if (!codec->modelname) {
Expand Down Expand Up @@ -4038,7 +4043,7 @@ static void sync_power_up_states(struct hda_codec *codec)
}
}

#ifdef CONFIG_SND_HDA_HWDEP
#ifdef CONFIG_SND_HDA_RECONFIG
/* execute additional init verbs */
static void hda_exec_init_verbs(struct hda_codec *codec)
{
Expand Down
7 changes: 5 additions & 2 deletions sound/pci/hda/hda_codec.h
Original file line number Diff line number Diff line change
Expand Up @@ -333,14 +333,17 @@ struct hda_codec {
struct snd_array driver_pins; /* pin configs set by codec parser */
struct snd_array cvt_setups; /* audio convert setups */

#ifdef CONFIG_SND_HDA_HWDEP
#ifdef CONFIG_SND_HDA_RECONFIG
struct mutex user_mutex;
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

#ifdef CONFIG_SND_HDA_HWDEP
struct snd_hwdep *hwdep; /* assigned hwdep device */
#endif

/* misc flags */
unsigned int spdif_status_reset :1; /* needs to toggle SPDIF for each
* status change
Expand Down
Loading

0 comments on commit 648a8d2

Please sign in to comment.