summaryrefslogtreecommitdiffstats
path: root/drivers/sound/vidc_mixer.c
blob: 1bdb1e88e58879d51dda64ca934e13338edcc46f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
/*
 * drivers/sound/vidc_mixer.c
 *
 * Mixer routines for VIDC
 *
 * Copyright (C) 1997 Russell King <rmk@arm.uk.linux.org>
 */

#include "sound_config.h"
#include "vidc.h"

int vidc_volume;

static int vidc_get_volume(void)
{
	return vidc_volume;
}

static int vidc_set_volume(int newvol)
{
	vidc_volume = newvol;
/*  printk ("vidc_set_volume: %X\n", newvol); */
	return newvol;
}

static int vidc_default_mixer_ioctl(int dev, unsigned int cmd, caddr_t arg)
{
	int ret;

	switch (cmd)
	{
		case SOUND_MIXER_READ_VOLUME:
			ret = vidc_get_volume();
			break;

		case SOUND_MIXER_WRITE_VOLUME:
			if (get_user(ret, (int *) arg))
				return -EINVAL;
			ret = vidc_set_volume(ret);
			break;

		case SOUND_MIXER_READ_BASS:
		case SOUND_MIXER_WRITE_BASS:
		case SOUND_MIXER_READ_TREBLE:
		case SOUND_MIXER_WRITE_TREBLE:
			ret = 50;
			break;

		case SOUND_MIXER_READ_SYNTH:
			ret = vidc_synth_get_volume();
			break;

		case SOUND_MIXER_WRITE_SYNTH:
			if (get_user(ret, (int *) arg))
				return -EINVAL;
			ret = vidc_synth_set_volume(ret);
			break;

		case SOUND_MIXER_READ_PCM:
			ret = vidc_audio_get_volume();
			break;

		case SOUND_MIXER_WRITE_PCM:
			if (get_user(ret, (int *) arg))
				return -EINVAL;
			ret = vidc_audio_set_volume(ret);
			break;

		case SOUND_MIXER_READ_SPEAKER:
			ret = 100;
			break;

		case SOUND_MIXER_WRITE_SPEAKER:
			ret = 100;
			break;

		case SOUND_MIXER_READ_LINE:
		case SOUND_MIXER_WRITE_LINE:
		case SOUND_MIXER_READ_MIC:
		case SOUND_MIXER_WRITE_MIC:
			ret = 0;
			break;

		case SOUND_MIXER_READ_CD:
		case SOUND_MIXER_WRITE_CD:
			ret = 100 | (100 << 8);
			break;

		case SOUND_MIXER_READ_IMIX:
		case SOUND_MIXER_WRITE_IMIX:
		case SOUND_MIXER_READ_ALTPCM:
		case SOUND_MIXER_WRITE_ALTPCM:
		case SOUND_MIXER_READ_LINE1:
		case SOUND_MIXER_WRITE_LINE1:
		case SOUND_MIXER_READ_LINE2:
		case SOUND_MIXER_WRITE_LINE2:
		case SOUND_MIXER_READ_LINE3:
		case SOUND_MIXER_WRITE_LINE3:
			ret = 0;
			break;

		case SOUND_MIXER_READ_RECSRC:
			ret = 0;
			break;

		case SOUND_MIXER_WRITE_RECSRC:
			return -EINVAL;
			break;

		case SOUND_MIXER_READ_DEVMASK:
			ret = SOUND_MASK_VOLUME | SOUND_MASK_PCM | SOUND_MASK_SYNTH;
			break;

		case SOUND_MIXER_READ_RECMASK:
			ret = 0;
			break;

		case SOUND_MIXER_READ_STEREODEVS:
			ret = SOUND_MASK_VOLUME | SOUND_MASK_PCM | SOUND_MASK_SYNTH;
			break;

		case SOUND_MIXER_READ_CAPS:
			ret = 0;
			break;

		case SOUND_MIXER_READ_MUTE:
			return -EINVAL;
			break;

		default:
			return -EINVAL;
			break;
	}
	return put_user(ret, (int *) arg);
}

static struct mixer_operations vidc_mixer_operations = {
	"VIDC",
	"VIDCsound",
	vidc_default_mixer_ioctl	/* ioctl                */
};

void vidc_mixer_init(struct address_info *hw_config)
{
	int vidc_mixer = sound_alloc_mixerdev();
	vidc_volume = 100 | (100 << 8);
	if (num_mixers < MAX_MIXER_DEV)
		mixer_devs[vidc_mixer] = &vidc_mixer_operations;
}