diff options
author | Takashi Iwai <tiwai@suse.de> | 2015-03-20 12:08:48 +0100 |
---|---|---|
committer | Takashi Iwai <tiwai@suse.de> | 2015-03-23 13:21:13 +0100 |
commit | 9dd3071343bfcfe1329861b8edda7213940c2464 (patch) | |
tree | dc1cccb23852fef0777219eadbc83429ab516e21 | |
parent | 3e582cca5fc671b622ec6c5358d731fe9a055c7a (diff) | |
download | hda-emu-9dd3071343bfcfe1329861b8edda7213940c2464.tar.gz |
Support HD-audio core library for kernel v4.1+
Now the HD-audio code is split and the core helper codes are put in
sound/hda/ directory. hda-emu also follows this change.
The --with-hdadir configure option is replaced with --with-kerneldir
option. Instead of passing the HD-audio directory, pass the root
directory of Linux kernel here.
configure script has been a bit modified to take care of two
directories, sound/hda and sound/pci/hda. The former is built in
lib subdirectory while the latter is still symlinked to hda
subdirectory and built in hda subdirectory.
-rw-r--r-- | Makefile.am | 10 | ||||
-rw-r--r-- | configure.ac | 66 | ||||
-rw-r--r-- | hda-emu.c | 9 | ||||
-rw-r--r-- | include/linux/device.h | 20 | ||||
-rw-r--r-- | include/linux/module.h | 1 | ||||
-rw-r--r-- | include/linux/sysfs.h | 71 | ||||
-rw-r--r-- | include/sound/hdaudio.h | 3 | ||||
-rw-r--r-- | lib/Makefile.am | 3 | ||||
-rw-r--r-- | lib/hda_bus_type.c | 1 | ||||
-rw-r--r-- | lib/hdac_bus.c | 1 | ||||
-rw-r--r-- | lib/hdac_device.c | 1 | ||||
-rw-r--r-- | lib/hdac_sysfs.c | 1 |
12 files changed, 157 insertions, 30 deletions
diff --git a/Makefile.am b/Makefile.am index f1c052b..30f8ce7 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,8 @@ SUBDIRS = kernel include +if HAVE_HDA_CORE +SUBDIRS += lib +endif + bin_PROGRAMS = hda-emu \ hda-decode-verb hda-encode-verb \ hda-decode-pincfg hda-encode-pincfg @@ -6,7 +10,11 @@ bin_PROGRAMS = hda-emu \ hda_emu_SOURCES = snd-control.c snd-vmaster.c snd-wrapper.c \ hda-emu.c hda-parse.c hda-spec.c hda-int.c hda-ctlsh.c hda-log.c \ ctljack.c -hda_emu_LDADD = kernel/libhda.a @LIBREADLINE@ +hda_emu_LDADD = kernel/libhda.a +if HAVE_HDA_CORE +hda_emu_LDADD += lib/libhdacore.a +endif +hda_emu_LDADD += @LIBREADLINE@ hda_decode_verb_SOURCES = hda-decode-verb.c hda-log.c hda-int.c hda_encode_verb_SOURCES = diff --git a/configure.ac b/configure.ac index 9a75225..29ae021 100644 --- a/configure.ac +++ b/configure.ac @@ -39,31 +39,33 @@ if test "$old_workq" = "yes"; then AC_DEFINE(OLD_WORKQUEUE) fi -AC_ARG_WITH(hdadir, - AS_HELP_STRING([--with-hdadir=dir], - [path where HD-audio kernel files are stored]), - hdadir="$withval", hdadir="") - -hdadir="$( cd "$hdadir" && pwd )" - -if test -n "$hdadir"; then - -test -d "$hdadir" || \ - AC_ERROR([Invalid HD-audio directory: $hdadir]) -test -f "$hdadir/hda_codec.c" || \ - AC_ERROR([Invalid HD-audio directory: $hdadir]) - +AC_ARG_WITH(kerneldir, + AS_HELP_STRING([--with-kerneldir=dir], + [path where Linux kernel tree is stored]), + kerneldir="$withval", kerneldir="") + +kerneldir="$( cd "$kerneldir" && pwd )" + +test -n "$kerneldir" || + AC_ERROR([No kernel directory is specified]) +test -d "$kerneldir" || \ + AC_ERROR([Invalid kernel directory: $kerneldir]) +test -f "$kerneldir/sound/pci/hda/hda_codec.c" || \ + AC_ERROR([Invalid kernel directory: $kerneldir]) + +rm -f dist +ln -s $kerneldir dist rm -f hda -ln -s $hdadir hda - -else -dnl check existing kernel codes - -if ! test -f hda/hda_codec.c; then - AC_ERROR([No HD-audio driver codes present in kernel directory; initialize via --with-hdadir]) -fi +ln -s dist/sound/pci/hda hda +have_hda_core= +AC_MSG_CHECKING(for HDA core) +if test -f dist/sound/hda/hdac_bus.c; then + AC_MSG_RESULT(yes) + AC_DEFINE(HAVE_HDA_CORE) + have_hda_core=yes fi +AM_CONDITIONAL(HAVE_HDA_CORE, test "$have_hda_core" = "yes") AC_DEFUN([CHECK_CODEC], [ AC_MSG_CHECKING(for codec $1) @@ -120,23 +122,32 @@ AM_CONDITIONAL(USE_OWN_PROC, test "$own_proc" = "yes") echo "Generating kernel/init_hooks.h..." rm -f kernel/init_hooks.h -if test -f hda/hda_bind.c; then -cat hda/hda_bind.c | grep '^module_init(' | \ + +if test -f dist/sound/hda/hdac_bus.c; then +cat dist/sound/hda/*.c | grep '^subsys_initcall(' | \ + sed -e's/^subsys_initcall(\(.*\))/void call_init_\1(void);/g' >> kernel/init_hooks.h +cat dist/sound/hda/*.c | grep '^module_init(' | \ sed -e's/^module_init(\(.*\))/void call_init_\1(void);/g' >> kernel/init_hooks.h fi cat hda/patch_*.c | grep '^module_init(' | \ sed -e's/^module_init(\(.*\))/void call_init_\1(void);/g' >> kernel/init_hooks.h cat hda/patch_*.c | grep '^module_hda_codec_driver(' | \ sed -e's/^module_hda_codec_driver(\(.*\))/void call_init_\1_init(void);/g' >> kernel/init_hooks.h + echo 'static void gather_codec_hooks(void) {' >> kernel/init_hooks.h -if test -f hda/hda_bind.c; then -cat hda/hda_bind.c | grep '^module_init(' | \ + +if test -f dist/sound/hda/hdac_bus.c; then +cat dist/sound/hda/*.c | grep '^subsys_initcall(' | \ + sed -e's/^subsys_initcall(\(.*\))/call_init_\1();/g' >> kernel/init_hooks.h +cat dist/sound/hda/*.c | grep '^module_init(' | \ sed -e's/^module_init(\(.*\))/call_init_\1();/g' >> kernel/init_hooks.h fi + cat hda/patch_*.c | grep '^module_init(' | \ sed -e's/^module_init(\(.*\))/call_init_\1();/g' >> kernel/init_hooks.h cat hda/patch_*.c | grep '^module_hda_codec_driver(' | \ sed -e's/^module_hda_codec_driver(\(.*\))/call_init_\1_init();/g' >> kernel/init_hooks.h + echo '}' >> kernel/init_hooks.h AC_MSG_CHECKING(for presence of power_save option) @@ -583,5 +594,4 @@ if test "$HAVE_CODEC_USER_MUTEX" = "1"; then AC_DEFINE(HAVE_CODEC_USER_MUTEX) fi -AC_OUTPUT(Makefile kernel/Makefile include/Makefile) - +AC_OUTPUT(Makefile lib/Makefile kernel/Makefile include/Makefile) @@ -500,13 +500,20 @@ void hda_test_pm_reinit(void) static void issue_unsol(int caddr, int res) { + int vendor_id; + /* no unsol handling during D3 */ if (proc.afg.power_current == 3) return; caddr |= 1 << 4; /* ALC880 has incompatible unsol tag */ - if (_codec->vendor_id == 0x10ec0880) +#ifdef HAVE_HDA_CORE + vendor_id = _codec->core.vendor_id; +#else + vendor_id = _codec->vendor_id; +#endif + if (vendor_id == 0x10ec0880) res = (res & 0x3f) << 28; else res = (res & 0x3f) << 26; diff --git a/include/linux/device.h b/include/linux/device.h index fd9b6f1..a19a970 100644 --- a/include/linux/device.h +++ b/include/linux/device.h @@ -1,8 +1,10 @@ #ifndef __LINUX_DEVICE_H #define __LINUX_DEVICE_H +#include <wrapper.h> #include <linux/list.h> #include <linux/pm.h> +#include <linux/sysfs.h> struct device; struct device_driver; @@ -11,6 +13,7 @@ struct class; struct attribute_group; struct device { + struct kobject kobj; struct device *parent; void *driver_data; struct bus_type *bus; @@ -92,4 +95,21 @@ struct bus_type { int bus_register(struct bus_type *bus); void bus_unregister(struct bus_type *bus); +/* + */ +struct device_attribute { + struct attribute attr; + ssize_t (*show)(struct device *dev, struct device_attribute *attr, + char *buf); + ssize_t (*store)(struct device *dev, struct device_attribute *attr, + const char *buf, size_t count); +}; + +#define DEVICE_ATTR(_name, _mode, _show, _store) \ + struct device_attribute dev_attr_##_name = __ATTR(_name, _mode, _show, _store) +#define DEVICE_ATTR_RW(_name) \ + struct device_attribute dev_attr_##_name = __ATTR_RW(_name) +#define DEVICE_ATTR_RO(_name) \ + struct device_attribute dev_attr_##_name = __ATTR_RO(_name) + #endif /* __LINUX_DEVICE_H */ diff --git a/include/linux/module.h b/include/linux/module.h index 999741a..51c4c97 100644 --- a/include/linux/module.h +++ b/include/linux/module.h @@ -13,6 +13,7 @@ #define MODULE_PARM_DESC(a,b) #define module_init(func) int call_init_##func(void) { return func(); } +#define subsys_initcall(func) int call_init_##func(void) { return func(); } #define module_exit(func) void call_exit_##func(void) { func(); } struct module; diff --git a/include/linux/sysfs.h b/include/linux/sysfs.h new file mode 100644 index 0000000..7bed68e --- /dev/null +++ b/include/linux/sysfs.h @@ -0,0 +1,71 @@ +#ifndef __LINUX_SYSFS_H +#define __LINUX_SYSFS_H + +/* + * just dummy definitions to make build hdac_sysfs.c + */ + +struct kobject; +struct kobj_type; + +struct kobject { + char *name; + struct kobj_type *type; +}; + +#define kobj_to_dev(x) NULL +#define kobject_put(k) +#define kobject_init(k, v) ((k)->type = (v)) +#define kobject_add(k, parent, fmt, ...) 0 +static inline struct kobject *kobject_create_and_add(const char *name, struct kobject *kobj) +{ + return calloc(1, sizeof(*kobj)); +} + +#define kobject_uevent(k, e) + +struct kobj_type { + void (*release)(struct kobject *kobj); + const struct sysfs_ops *sysfs_ops; +}; + +typedef int umode_t; + +struct attribute { + char *name; + umode_t mode; +}; + +struct attribute_group { + const char *name; + umode_t (*is_visible)(struct kobject *, + struct attribute *, int); + struct attribute **attrs; + struct bin_attribute **bin_attrs; +}; + +#define __ATTR(_name, _mode, _show, _store) { \ + .attr = {.name = #_name, .mode = (_mode) }, \ + .show = _show, \ + .store = _store, \ +} + +#define __ATTR_RO(_name) { \ + .attr = { .name = #_name, .mode = 0444 }, \ + .show = _name##_show, \ +} + +#define __ATTR_RW(_name) __ATTR(_name, 0644), \ + _name##_show, _name##_store) + +struct sysfs_ops { + ssize_t (*show)(struct kobject *, struct attribute *, char *); + ssize_t (*store)(struct kobject *, struct attribute *, const char *, size_t); +}; + +static inline int sysfs_create_group(struct kobject *kobj, + const struct attribute_group *grp) { return 0; } +static inline void sysfs_remove_group(struct kobject *kobj, + const struct attribute_group *grp) {} + +#endif /* __LINUX_SYSFS_H */ diff --git a/include/sound/hdaudio.h b/include/sound/hdaudio.h new file mode 100644 index 0000000..fdb5f7d --- /dev/null +++ b/include/sound/hdaudio.h @@ -0,0 +1,3 @@ +#include <wrapper.h> +#include <sound/core.h> +#include "../../dist/include/sound/hdaudio.h" diff --git a/lib/Makefile.am b/lib/Makefile.am new file mode 100644 index 0000000..09ebe85 --- /dev/null +++ b/lib/Makefile.am @@ -0,0 +1,3 @@ +noinst_LIBRARIES = libhdacore.a +libhdacore_a_SOURCES = hda_bus_type.c hdac_bus.c hdac_device.c hdac_sysfs.c +INCLUDES = -I$(top_srcdir)/include diff --git a/lib/hda_bus_type.c b/lib/hda_bus_type.c new file mode 100644 index 0000000..8a42b1e --- /dev/null +++ b/lib/hda_bus_type.c @@ -0,0 +1 @@ +#include "../dist/sound/hda/hda_bus_type.c" diff --git a/lib/hdac_bus.c b/lib/hdac_bus.c new file mode 100644 index 0000000..aeb6cf3 --- /dev/null +++ b/lib/hdac_bus.c @@ -0,0 +1 @@ +#include "../dist/sound/hda/hdac_bus.c" diff --git a/lib/hdac_device.c b/lib/hdac_device.c new file mode 100644 index 0000000..b89f3ed --- /dev/null +++ b/lib/hdac_device.c @@ -0,0 +1 @@ +#include "../dist/sound/hda/hdac_device.c" diff --git a/lib/hdac_sysfs.c b/lib/hdac_sysfs.c new file mode 100644 index 0000000..e4d0d46 --- /dev/null +++ b/lib/hdac_sysfs.c @@ -0,0 +1 @@ +#include "../dist/sound/hda/hdac_sysfs.c" |