12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/device.h>
16 #include <linux/ctype.h>
17 #include <linux/random.h>
26 #define FILE_PCM_PLAYBACK "/dev/snd/pcmC0D0p"
27 #define FILE_PCM_CAPTURE "/dev/snd/pcmC0D0c"
28 #define FILE_CONTROL "/dev/snd/controlC0"
52 t.openmin =
t.openmax = 0;
62 if (hw_is_mask(var)) {
63 struct snd_mask *
m = hw_param_mask(params, var);
64 if (val == 0 && dir < 0) {
72 changed = snd_mask_refine_set(
73 hw_param_mask(params, var), val);
75 }
else if (hw_is_interval(var)) {
77 if (val == 0 && dir < 0) {
81 changed = snd_interval_refine_set(i, val);
100 params->
cmask |= 1 << var;
101 params->
rmask |= 1 << var;
127 params = kzalloc(
sizeof(*params),
GFP_KERNEL);
147 "Preparing sound card failed: %d\n", (
int)result);
161 "Hardware params: access %x, format %x, channels %d, rate %d\n",
185 ERROR(card,
"Preparing sound card failed: %d\n",
191 frames = bytes_to_frames(runtime, count);
195 if (result != frames) {
196 ERROR(card,
"Playback error: %d\n", (
int)result);
205 static int u_audio_get_playback_channels(
struct gaudio *card)
210 static int u_audio_get_playback_rate(
struct gaudio *card)
219 static int gaudio_open_snd_dev(
struct gaudio *card)
230 if (IS_ERR(snd->
filp)) {
232 ERROR(card,
"unable to open sound control device file: %s\n",
242 if (IS_ERR(snd->
filp)) {
243 ERROR(card,
"No such PCM playback device: %s\n", fn_play);
246 pcm_file = snd->
filp->private_data;
249 playback_default_hw_params(snd);
254 if (IS_ERR(snd->
filp)) {
255 ERROR(card,
"No such PCM capture device: %s\n", fn_cap);
260 pcm_file = snd->
filp->private_data;
271 static int gaudio_close_snd_dev(
struct gaudio *gau)
293 static struct gaudio *the_card;
305 ret = gaudio_open_snd_dev(card);
307 ERROR(card,
"we need at least one control device\n");
323 gaudio_close_snd_dev(the_card);