2019-06-03 13:45:06 +08:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-only
|
2006-06-21 21:42:43 +08:00
|
|
|
/*
|
|
|
|
* Apple Onboard Audio driver for Toonie codec
|
|
|
|
*
|
|
|
|
* Copyright 2006 Johannes Berg <johannes@sipsolutions.net>
|
|
|
|
*
|
|
|
|
* This is a driver for the toonie codec chip. This chip is present
|
|
|
|
* on the Mac Mini and is nothing but a DAC.
|
|
|
|
*/
|
|
|
|
#include <linux/delay.h>
|
|
|
|
#include <linux/module.h>
|
include cleanup: Update gfp.h and slab.h includes to prepare for breaking implicit slab.h inclusion from percpu.h
percpu.h is included by sched.h and module.h and thus ends up being
included when building most .c files. percpu.h includes slab.h which
in turn includes gfp.h making everything defined by the two files
universally available and complicating inclusion dependencies.
percpu.h -> slab.h dependency is about to be removed. Prepare for
this change by updating users of gfp and slab facilities include those
headers directly instead of assuming availability. As this conversion
needs to touch large number of source files, the following script is
used as the basis of conversion.
http://userweb.kernel.org/~tj/misc/slabh-sweep.py
The script does the followings.
* Scan files for gfp and slab usages and update includes such that
only the necessary includes are there. ie. if only gfp is used,
gfp.h, if slab is used, slab.h.
* When the script inserts a new include, it looks at the include
blocks and try to put the new include such that its order conforms
to its surrounding. It's put in the include block which contains
core kernel includes, in the same order that the rest are ordered -
alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
doesn't seem to be any matching order.
* If the script can't find a place to put a new include (mostly
because the file doesn't have fitting include block), it prints out
an error message indicating which .h file needs to be added to the
file.
The conversion was done in the following steps.
1. The initial automatic conversion of all .c files updated slightly
over 4000 files, deleting around 700 includes and adding ~480 gfp.h
and ~3000 slab.h inclusions. The script emitted errors for ~400
files.
2. Each error was manually checked. Some didn't need the inclusion,
some needed manual addition while adding it to implementation .h or
embedding .c file was more appropriate for others. This step added
inclusions to around 150 files.
3. The script was run again and the output was compared to the edits
from #2 to make sure no file was left behind.
4. Several build tests were done and a couple of problems were fixed.
e.g. lib/decompress_*.c used malloc/free() wrappers around slab
APIs requiring slab.h to be added manually.
5. The script was run on all .h files but without automatically
editing them as sprinkling gfp.h and slab.h inclusions around .h
files could easily lead to inclusion dependency hell. Most gfp.h
inclusion directives were ignored as stuff from gfp.h was usually
wildly available and often used in preprocessor macros. Each
slab.h inclusion directive was examined and added manually as
necessary.
6. percpu.h was updated not to include slab.h.
7. Build test were done on the following configurations and failures
were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
distributed build env didn't work with gcov compiles) and a few
more options had to be turned off depending on archs to make things
build (like ipr on powerpc/64 which failed due to missing writeq).
* x86 and x86_64 UP and SMP allmodconfig and a custom test config.
* powerpc and powerpc64 SMP allmodconfig
* sparc and sparc64 SMP allmodconfig
* ia64 SMP allmodconfig
* s390 SMP allmodconfig
* alpha SMP allmodconfig
* um on x86_64 SMP allmodconfig
8. percpu.h modifications were reverted so that it could be applied as
a separate patch and serve as bisection point.
Given the fact that I had only a couple of failures from tests on step
6, I'm fairly confident about the coverage of this conversion patch.
If there is a breakage, it's likely to be something in one of the arch
headers which should be easily discoverable easily on most builds of
the specific arch.
Signed-off-by: Tejun Heo <tj@kernel.org>
Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
Cc: Ingo Molnar <mingo@redhat.com>
Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>
2010-03-24 16:04:11 +08:00
|
|
|
#include <linux/slab.h>
|
2006-06-21 21:42:43 +08:00
|
|
|
MODULE_AUTHOR("Johannes Berg <johannes@sipsolutions.net>");
|
|
|
|
MODULE_LICENSE("GPL");
|
|
|
|
MODULE_DESCRIPTION("toonie codec driver for snd-aoa");
|
|
|
|
|
|
|
|
#include "../aoa.h"
|
|
|
|
#include "../soundbus/soundbus.h"
|
|
|
|
|
|
|
|
|
|
|
|
#define PFX "snd-aoa-codec-toonie: "
|
|
|
|
|
|
|
|
struct toonie {
|
|
|
|
struct aoa_codec codec;
|
|
|
|
};
|
|
|
|
#define codec_to_toonie(c) container_of(c, struct toonie, codec)
|
|
|
|
|
|
|
|
static int toonie_dev_register(struct snd_device *dev)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2020-01-03 16:16:27 +08:00
|
|
|
static const struct snd_device_ops ops = {
|
2006-06-21 21:42:43 +08:00
|
|
|
.dev_register = toonie_dev_register,
|
|
|
|
};
|
|
|
|
|
|
|
|
static struct transfer_info toonie_transfers[] = {
|
|
|
|
/* This thing *only* has analog output,
|
|
|
|
* the rates are taken from Info.plist
|
|
|
|
* from Darwin. */
|
|
|
|
{
|
|
|
|
.formats = SNDRV_PCM_FMTBIT_S16_BE |
|
|
|
|
SNDRV_PCM_FMTBIT_S24_BE,
|
|
|
|
.rates = SNDRV_PCM_RATE_32000 |
|
|
|
|
SNDRV_PCM_RATE_44100 |
|
|
|
|
SNDRV_PCM_RATE_48000 |
|
|
|
|
SNDRV_PCM_RATE_88200 |
|
|
|
|
SNDRV_PCM_RATE_96000,
|
|
|
|
},
|
|
|
|
{}
|
|
|
|
};
|
|
|
|
|
2006-07-25 22:13:37 +08:00
|
|
|
static int toonie_usable(struct codec_info_item *cii,
|
|
|
|
struct transfer_info *ti,
|
|
|
|
struct transfer_info *out)
|
|
|
|
{
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2006-06-21 21:42:43 +08:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
static int toonie_suspend(struct codec_info_item *cii, pm_message_t state)
|
|
|
|
{
|
|
|
|
/* can we turn it off somehow? */
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int toonie_resume(struct codec_info_item *cii)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_PM */
|
|
|
|
|
|
|
|
static struct codec_info toonie_codec_info = {
|
|
|
|
.transfers = toonie_transfers,
|
|
|
|
.sysclock_factor = 256,
|
|
|
|
.bus_factor = 64,
|
|
|
|
.owner = THIS_MODULE,
|
2006-07-25 22:13:37 +08:00
|
|
|
.usable = toonie_usable,
|
2006-06-21 21:42:43 +08:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
.suspend = toonie_suspend,
|
|
|
|
.resume = toonie_resume,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
static int toonie_init_codec(struct aoa_codec *codec)
|
|
|
|
{
|
|
|
|
struct toonie *toonie = codec_to_toonie(codec);
|
|
|
|
|
2006-07-25 22:13:37 +08:00
|
|
|
/* nothing connected? what a joke! */
|
|
|
|
if (toonie->codec.connected != 1)
|
|
|
|
return -ENOTCONN;
|
|
|
|
|
2014-02-04 18:16:31 +08:00
|
|
|
if (aoa_snd_device_new(SNDRV_DEV_CODEC, toonie, &ops)) {
|
2006-06-21 21:42:43 +08:00
|
|
|
printk(KERN_ERR PFX "failed to create toonie snd device!\n");
|
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (toonie->codec.soundbus_dev->attach_codec(toonie->codec.soundbus_dev,
|
|
|
|
aoa_get_card(),
|
|
|
|
&toonie_codec_info, toonie)) {
|
|
|
|
printk(KERN_ERR PFX "error creating toonie pcm\n");
|
2006-07-25 22:13:37 +08:00
|
|
|
snd_device_free(aoa_get_card(), toonie);
|
2006-06-21 21:42:43 +08:00
|
|
|
return -ENODEV;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void toonie_exit_codec(struct aoa_codec *codec)
|
|
|
|
{
|
|
|
|
struct toonie *toonie = codec_to_toonie(codec);
|
|
|
|
|
|
|
|
if (!toonie->codec.soundbus_dev) {
|
|
|
|
printk(KERN_ERR PFX "toonie_exit_codec called without soundbus_dev!\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
toonie->codec.soundbus_dev->detach_codec(toonie->codec.soundbus_dev, toonie);
|
|
|
|
}
|
|
|
|
|
|
|
|
static struct toonie *toonie;
|
|
|
|
|
|
|
|
static int __init toonie_init(void)
|
|
|
|
{
|
|
|
|
toonie = kzalloc(sizeof(struct toonie), GFP_KERNEL);
|
|
|
|
|
|
|
|
if (!toonie)
|
|
|
|
return -ENOMEM;
|
|
|
|
|
ALSA: Convert strlcpy to strscpy when return value is unused
strlcpy is deprecated. see: Documentation/process/deprecated.rst
Change the calls that do not use the strlcpy return value to the
preferred strscpy.
Done with cocci script:
@@
expression e1, e2, e3;
@@
- strlcpy(
+ strscpy(
e1, e2, e3);
This cocci script leaves the instances where the return value is
used unchanged.
After this patch, sound/ has 3 uses of strlcpy() that need to be
manually inspected for conversion and changed one day.
$ git grep -w strlcpy sound/
sound/usb/card.c: len = strlcpy(card->longname, s, sizeof(card->longname));
sound/usb/mixer.c: return strlcpy(buf, p->name, buflen);
sound/usb/mixer.c: return strlcpy(buf, p->names[index], buflen);
Miscellenea:
o Remove trailing whitespace in conversion of sound/core/hwdep.c
Link: https://lore.kernel.org/lkml/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Joe Perches <joe@perches.com>
Acked-by: Mark Brown <broonie@kernel.org>
Link: https://lore.kernel.org/r/22b393d1790bb268769d0bab7bacf0866dcb0c14.camel@perches.com
Signed-off-by: Takashi Iwai <tiwai@suse.de>
2021-01-05 01:17:34 +08:00
|
|
|
strscpy(toonie->codec.name, "toonie", sizeof(toonie->codec.name));
|
2006-06-21 21:42:43 +08:00
|
|
|
toonie->codec.owner = THIS_MODULE;
|
|
|
|
toonie->codec.init = toonie_init_codec;
|
|
|
|
toonie->codec.exit = toonie_exit_codec;
|
2008-10-23 21:47:56 +08:00
|
|
|
|
2006-06-21 21:42:43 +08:00
|
|
|
if (aoa_codec_register(&toonie->codec)) {
|
|
|
|
kfree(toonie);
|
|
|
|
return -EINVAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void __exit toonie_exit(void)
|
|
|
|
{
|
|
|
|
aoa_codec_unregister(&toonie->codec);
|
|
|
|
kfree(toonie);
|
|
|
|
}
|
|
|
|
|
|
|
|
module_init(toonie_init);
|
|
|
|
module_exit(toonie_exit);
|