5 #include <linux/soundcard.h>
6 #include <asm/string.h>
8 #define I2C_DRIVERID_TAS_BASE (0xFEBA)
10 #define SET_4_20(shadow, offset, val) \
12 (shadow)[(offset)+0] = ((val) >> 16) & 0xff; \
13 (shadow)[(offset)+1] = ((val) >> 8) & 0xff; \
14 (shadow)[(offset)+2] = ((val) >> 0) & 0xff; \
17 #define GET_4_20(shadow, offset) \
18 (((u_int)((shadow)[(offset)+0]) << 16) | \
19 ((u_int)((shadow)[(offset)+1]) << 8) | \
20 ((u_int)((shadow)[(offset)+2]) << 0))
23 #define TAS_BIQUAD_FAST_LOAD 0x01
25 #define TAS_DRCE_ENABLE 0x01
26 #define TAS_DRCE_ABOVE_RATIO 0x02
27 #define TAS_DRCE_BELOW_RATIO 0x04
28 #define TAS_DRCE_THRESHOLD 0x08
29 #define TAS_DRCE_ENERGY 0x10
30 #define TAS_DRCE_ATTACK 0x20
31 #define TAS_DRCE_DECAY 0x40
33 #define TAS_DRCE_ALL 0x7f
36 #define TAS_OUTPUT_HEADPHONES 0x00
37 #define TAS_OUTPUT_INTERNAL_SPKR 0x01
38 #define TAS_OUTPUT_EXTERNAL_SPKR 0x02
48 struct tas_biquad_ctrl_t {
52 union tas_biquad_t data;
55 struct tas_biquad_ctrl_list_t {
58 struct tas_biquad_ctrl_t biquads[0];
62 unsigned short val; /* 8.8 */
63 unsigned short expand; /* 0 = compress, !0 = expand. */
67 unsigned short enable;
68 struct tas_ratio_t above;
69 struct tas_ratio_t below;
70 short threshold; /* dB, 8.8 signed */
71 unsigned short energy; /* seconds, 4.12 unsigned */
72 unsigned short attack; /* seconds, 4.12 unsigned */
73 unsigned short decay; /* seconds, 4.12 unsigned */
76 struct tas_drce_ctrl_t {
79 struct tas_drce_t data;
90 typedef char tas_shadow_t[0x45];
94 struct i2c_client *client;
96 uint mixer[SOUND_MIXER_NRDEVICES];
99 typedef int (*tas_hook_init_t)(struct i2c_client *);
100 typedef int (*tas_hook_post_init_t)(struct tas_data_t *);
101 typedef void (*tas_hook_uninit_t)(struct tas_data_t *);
103 typedef int (*tas_hook_get_mixer_level_t)(struct tas_data_t *,int,uint *);
104 typedef int (*tas_hook_set_mixer_level_t)(struct tas_data_t *,int,uint);
106 typedef int (*tas_hook_enter_sleep_t)(struct tas_data_t *);
107 typedef int (*tas_hook_leave_sleep_t)(struct tas_data_t *);
109 typedef int (*tas_hook_supported_mixers_t)(struct tas_data_t *);
110 typedef int (*tas_hook_mixer_is_stereo_t)(struct tas_data_t *,int);
111 typedef int (*tas_hook_stereo_mixers_t)(struct tas_data_t *);
113 typedef int (*tas_hook_output_device_change_t)(struct tas_data_t *,int,int,int);
114 typedef int (*tas_hook_device_ioctl_t)(struct tas_data_t *,u_int,u_long);
116 struct tas_driver_hooks_t {
118 * All hardware initialisation must be performed in
119 * post_init(), as tas_dmasound_init() does a hardware reset.
121 * init() is called before tas_dmasound_init() so that
122 * ouput_device_change() is always called after i2c driver
123 * initialisation. The implication is that
124 * output_device_change() must cope with the fact that it
125 * may be called before post_init().
128 tas_hook_init_t init;
129 tas_hook_post_init_t post_init;
130 tas_hook_uninit_t uninit;
132 tas_hook_get_mixer_level_t get_mixer_level;
133 tas_hook_set_mixer_level_t set_mixer_level;
135 tas_hook_enter_sleep_t enter_sleep;
136 tas_hook_leave_sleep_t leave_sleep;
138 tas_hook_supported_mixers_t supported_mixers;
139 tas_hook_mixer_is_stereo_t mixer_is_stereo;
140 tas_hook_stereo_mixers_t stereo_mixers;
142 tas_hook_output_device_change_t output_device_change;
143 tas_hook_device_ioctl_t device_ioctl;
146 enum tas_write_mode_t {
154 tas_mono_to_stereo(uint mono)
157 return mono | (mono<<8);
161 * Todo: make these functions a bit more efficient !
164 tas_write_register( struct tas_data_t *self,
172 if (reg_width==0 || data==NULL || self==NULL)
174 if (!(write_mode & FORCE_WRITE) &&
175 !memcmp(data,self->shadow[reg_num],reg_width))
178 if (write_mode & WRITE_SHADOW)
179 memcpy(self->shadow[reg_num],data,reg_width);
180 if (write_mode & WRITE_HW) {
181 rc=i2c_smbus_write_i2c_block_data(self->client,
186 printk("tas: I2C block write failed \n");
194 tas_sync_register( struct tas_data_t *self,
200 if (reg_width==0 || self==NULL)
202 rc=i2c_smbus_write_i2c_block_data(self->client,
205 self->shadow[reg_num]);
207 printk("tas: I2C block write failed \n");
214 tas_write_byte_register( struct tas_data_t *self,
221 if (!(write_mode & FORCE_WRITE) && data != self->shadow[reg_num][0])
223 if (write_mode & WRITE_SHADOW)
224 self->shadow[reg_num][0]=data;
225 if (write_mode & WRITE_HW) {
226 if (i2c_smbus_write_byte_data(self->client, reg_num, data) < 0) {
227 printk("tas: I2C byte write failed \n");
235 tas_sync_byte_register( struct tas_data_t *self,
239 if (reg_width==0 || self==NULL)
241 if (i2c_smbus_write_byte_data(
242 self->client, reg_num, self->shadow[reg_num][0]) < 0) {
243 printk("tas: I2C byte write failed \n");
250 tas_read_register( struct tas_data_t *self,
255 if (reg_width==0 || data==NULL || self==NULL)
257 memcpy(data,self->shadow[reg_num],reg_width);
261 extern int tas_register_driver(struct tas_driver_hooks_t *hooks);
263 extern int tas_get_mixer_level(int mixer,uint *level);
264 extern int tas_set_mixer_level(int mixer,uint level);
265 extern int tas_enter_sleep(void);
266 extern int tas_leave_sleep(void);
267 extern int tas_supported_mixers(void);
268 extern int tas_mixer_is_stereo(int mixer);
269 extern int tas_stereo_mixers(void);
270 extern int tas_output_device_change(int,int,int);
271 extern int tas_device_ioctl(u_int, u_long);
273 extern void tas_cleanup(void);
274 extern int tas_init(int driver_id,const char *driver_name);
275 extern int tas_post_init(void);
277 #endif /* _TAS_COMMON_H_ */
281 * indent-tabs-mode: t