aboutsummaryrefslogtreecommitdiffstats
path: root/sound/oss/dmasound/dac3550a.c
diff options
context:
space:
mode:
authorAdrian Bunk <bunk@stusta.de>2007-10-18 06:06:12 -0400
committerLinus Torvalds <torvalds@woody.linux-foundation.org>2007-10-18 17:37:26 -0400
commitfc37449f7959aeedc2d38b183468ae73c9166fb6 (patch)
tree3aaf169f3b9d9c9deb69802aa7c81354d55cf0c8 /sound/oss/dmasound/dac3550a.c
parent5b4db0c2f25925fcfc17fa7233b7b90dc023d207 (diff)
The next round of scheduled OSS code removal
This patch contains the next round of scheduled OSS code removal. Signed-off-by: Adrian Bunk <bunk@stusta.de> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'sound/oss/dmasound/dac3550a.c')
-rw-r--r--sound/oss/dmasound/dac3550a.c209
1 files changed, 0 insertions, 209 deletions
diff --git a/sound/oss/dmasound/dac3550a.c b/sound/oss/dmasound/dac3550a.c
deleted file mode 100644
index 0f0d03a55dab..000000000000
--- a/sound/oss/dmasound/dac3550a.c
+++ /dev/null
@@ -1,209 +0,0 @@
1/*
2 * Driver for the i2c/i2s based DAC3550a sound chip used
3 * on some Apple iBooks. Also known as "DACA".
4 *
5 * This file is subject to the terms and conditions of the GNU General Public
6 * License. See the file COPYING in the main directory of this archive
7 * for more details.
8 */
9
10#include <linux/module.h>
11#include <linux/slab.h>
12#include <linux/delay.h>
13#include <linux/proc_fs.h>
14#include <linux/ioport.h>
15#include <linux/sysctl.h>
16#include <linux/types.h>
17#include <linux/i2c.h>
18#include <linux/init.h>
19#include <asm/uaccess.h>
20#include <asm/errno.h>
21#include <asm/io.h>
22
23#include "dmasound.h"
24
25/* FYI: This code was derived from the tas3001c.c Texas/Tumbler mixer
26 * control code, as well as info derived from the AppleDACAAudio driver
27 * from Darwin CVS (main thing I derived being register numbers and
28 * values, as well as when to make the calls). */
29
30#define I2C_DRIVERID_DACA (0xFDCB)
31
32#define DACA_VERSION "0.1"
33#define DACA_DATE "20010930"
34
35static int cur_left_vol;
36static int cur_right_vol;
37static struct i2c_client *daca_client;
38
39static int daca_attach_adapter(struct i2c_adapter *adapter);
40static int daca_detect_client(struct i2c_adapter *adapter, int address);
41static int daca_detach_client(struct i2c_client *client);
42
43struct i2c_driver daca_driver = {
44 .driver = {
45 .name = "DAC3550A driver V " DACA_VERSION,
46 },
47 .id = I2C_DRIVERID_DACA,
48 .attach_adapter = daca_attach_adapter,
49 .detach_client = daca_detach_client,
50};
51
52#define VOL_MAX ((1<<20) - 1)
53
54void daca_get_volume(uint * left_vol, uint *right_vol)
55{
56 *left_vol = cur_left_vol >> 5;
57 *right_vol = cur_right_vol >> 5;
58}
59
60int daca_set_volume(uint left_vol, uint right_vol)
61{
62 unsigned short voldata;
63
64 if (!daca_client)
65 return -1;
66
67 /* Derived from experience, not from any specific values */
68 left_vol <<= 5;
69 right_vol <<= 5;
70
71 if (left_vol > VOL_MAX)
72 left_vol = VOL_MAX;
73 if (right_vol > VOL_MAX)
74 right_vol = VOL_MAX;
75
76 voldata = ((left_vol >> 14) & 0x3f) << 8;
77 voldata |= (right_vol >> 14) & 0x3f;
78
79 if (i2c_smbus_write_word_data(daca_client, 2, voldata) < 0) {
80 printk("daca: failed to set volume \n");
81 return -1;
82 }
83
84 cur_left_vol = left_vol;
85 cur_right_vol = right_vol;
86
87 return 0;
88}
89
90int daca_leave_sleep(void)
91{
92 if (!daca_client)
93 return -1;
94
95 /* Do a short sleep, just to make sure I2C bus is awake and paying
96 * attention to us
97 */
98 msleep(20);
99 /* Write the sample rate reg the value it needs */
100 i2c_smbus_write_byte_data(daca_client, 1, 8);
101 daca_set_volume(cur_left_vol >> 5, cur_right_vol >> 5);
102 /* Another short delay, just to make sure the other I2C bus writes
103 * have taken...
104 */
105 msleep(20);
106 /* Write the global config reg - invert right power amp,
107 * DAC on, use 5-volt mode */
108 i2c_smbus_write_byte_data(daca_client, 3, 0x45);
109
110 return 0;
111}
112
113int daca_enter_sleep(void)
114{
115 if (!daca_client)
116 return -1;
117
118 i2c_smbus_write_byte_data(daca_client, 1, 8);
119 daca_set_volume(cur_left_vol >> 5, cur_right_vol >> 5);
120
121 /* Write the global config reg - invert right power amp,
122 * DAC on, enter low-power mode, use 5-volt mode
123 */
124 i2c_smbus_write_byte_data(daca_client, 3, 0x65);
125
126 return 0;
127}
128
129static int daca_attach_adapter(struct i2c_adapter *adapter)
130{
131 if (!strncmp(adapter->name, "mac-io", 6))
132 daca_detect_client(adapter, 0x4d);
133 return 0;
134}
135
136static int daca_init_client(struct i2c_client * new_client)
137{
138 /*
139 * Probe is not working with the current i2c-keywest
140 * driver. We try to use addr 0x4d on each adapters
141 * instead, by setting the format register.
142 *
143 * FIXME: I'm sure that can be obtained from the
144 * device-tree. --BenH.
145 */
146
147 /* Write the global config reg - invert right power amp,
148 * DAC on, use 5-volt mode
149 */
150 if (i2c_smbus_write_byte_data(new_client, 3, 0x45))
151 return -1;
152
153 i2c_smbus_write_byte_data(new_client, 1, 8);
154 daca_client = new_client;
155 daca_set_volume(15000, 15000);
156
157 return 0;
158}
159
160static int daca_detect_client(struct i2c_adapter *adapter, int address)
161{
162 const char *client_name = "DAC 3550A Digital Equalizer";
163 struct i2c_client *new_client;
164 int rc = -ENODEV;
165
166 new_client = kzalloc(sizeof(*new_client), GFP_KERNEL);
167 if (!new_client)
168 return -ENOMEM;
169
170 new_client->addr = address;
171 new_client->adapter = adapter;
172 new_client->driver = &daca_driver;
173 new_client->flags = 0;
174 strcpy(new_client->name, client_name);
175
176 if (daca_init_client(new_client))
177 goto bail;
178
179 /* Tell the i2c layer a new client has arrived */
180 if (i2c_attach_client(new_client))
181 goto bail;
182
183 return 0;
184 bail:
185 kfree(new_client);
186 return rc;
187}
188
189
190static int daca_detach_client(struct i2c_client *client)
191{
192 if (client == daca_client)
193 daca_client = NULL;
194
195 i2c_detach_client(client);
196 kfree(client);
197 return 0;
198}
199
200void daca_cleanup(void)
201{
202 i2c_del_driver(&daca_driver);
203}
204
205int daca_init(void)
206{
207 printk("dac3550a driver version %s (%s)\n",DACA_VERSION,DACA_DATE);
208 return i2c_add_driver(&daca_driver);
209}