2 * Driver for the i2c/i2s based TA3004 sound chip used
3 * on some Apple hardware. Also known as "snapper".
5 * Tobias Sargeant <tobias.sargeant@bigpond.com>
6 * Based upon, tas3001c.c by Christopher C. Chimelis <chris@debian.org>:
10 * * Enable control over input line 2 (is this connected?)
11 * * Implement sleep support (at least mute everything and
12 * * set gains to minimum during sleep)
13 * * Look into some of Darwin's tweaks regarding the mute
14 * * lines (delays & different behaviour on some HW)
18 #include <linux/module.h>
19 #include <linux/slab.h>
20 #include <linux/proc_fs.h>
21 #include <linux/ioport.h>
22 #include <linux/sysctl.h>
23 #include <linux/types.h>
24 #include <linux/i2c.h>
25 #include <linux/init.h>
26 #include <linux/soundcard.h>
27 #include <linux/workqueue.h>
28 #include <asm/uaccess.h>
29 #include <asm/errno.h>
34 #include "tas_common.h"
37 #include "tas_ioctl.h"
39 #define TAS3001C_BIQUAD_FILTER_COUNT 6
40 #define TAS3001C_BIQUAD_CHANNEL_COUNT 2
42 #define VOL_DEFAULT (100 * 4 / 5)
43 #define INPUT_DEFAULT (100 * 4 / 5)
44 #define BASS_DEFAULT (100 / 2)
45 #define TREBLE_DEFAULT (100 / 2)
47 struct tas3001c_data_t
{
48 struct tas_data_t super
;
52 struct tas_drce_t drce_state
;
56 static const union tas_biquad_t
58 .buf
= { 0x100000, 0x000000, 0x000000, 0x000000, 0x000000 }
62 static inline unsigned char db_to_regval(short db
) {
67 if (r
< 0x91) return 0x91;
68 if (r
> 0xef) return 0xef;
72 static inline short quantize_db(short db
) {
73 return db_to_regval(db
) * 0x60 - 0x59a0;
78 register_width(enum tas3001c_reg_t r
)
81 case TAS3001C_REG_MCR
:
82 case TAS3001C_REG_TREBLE
:
83 case TAS3001C_REG_BASS
:
86 case TAS3001C_REG_DRC
:
89 case TAS3001C_REG_MIXER1
:
90 case TAS3001C_REG_MIXER2
:
93 case TAS3001C_REG_VOLUME
:
96 case TAS3001C_REG_LEFT_BIQUAD0
:
97 case TAS3001C_REG_LEFT_BIQUAD1
:
98 case TAS3001C_REG_LEFT_BIQUAD2
:
99 case TAS3001C_REG_LEFT_BIQUAD3
:
100 case TAS3001C_REG_LEFT_BIQUAD4
:
101 case TAS3001C_REG_LEFT_BIQUAD5
:
102 case TAS3001C_REG_LEFT_BIQUAD6
:
104 case TAS3001C_REG_RIGHT_BIQUAD0
:
105 case TAS3001C_REG_RIGHT_BIQUAD1
:
106 case TAS3001C_REG_RIGHT_BIQUAD2
:
107 case TAS3001C_REG_RIGHT_BIQUAD3
:
108 case TAS3001C_REG_RIGHT_BIQUAD4
:
109 case TAS3001C_REG_RIGHT_BIQUAD5
:
110 case TAS3001C_REG_RIGHT_BIQUAD6
:
119 tas3001c_write_register( struct tas3001c_data_t
*self
,
120 enum tas3001c_reg_t reg_num
,
124 if (reg_num
==TAS3001C_REG_MCR
||
125 reg_num
==TAS3001C_REG_BASS
||
126 reg_num
==TAS3001C_REG_TREBLE
) {
127 return tas_write_byte_register(&self
->super
,
132 return tas_write_register(&self
->super
,
134 register_width(reg_num
),
141 tas3001c_sync_register( struct tas3001c_data_t
*self
,
142 enum tas3001c_reg_t reg_num
)
144 if (reg_num
==TAS3001C_REG_MCR
||
145 reg_num
==TAS3001C_REG_BASS
||
146 reg_num
==TAS3001C_REG_TREBLE
) {
147 return tas_sync_byte_register(&self
->super
,
149 register_width(reg_num
));
151 return tas_sync_register(&self
->super
,
153 register_width(reg_num
));
158 tas3001c_read_register( struct tas3001c_data_t
*self
,
159 enum tas3001c_reg_t reg_num
,
163 return tas_read_register(&self
->super
,
165 register_width(reg_num
),
170 tas3001c_fast_load(struct tas3001c_data_t
*self
, int fast
)
173 self
->super
.shadow
[TAS3001C_REG_MCR
][0] |= 0x80;
175 self
->super
.shadow
[TAS3001C_REG_MCR
][0] &= 0x7f;
176 return tas3001c_sync_register(self
,TAS3001C_REG_MCR
);
180 tas3001c_supported_mixers(struct tas3001c_data_t
*self
)
182 return SOUND_MASK_VOLUME
|
190 tas3001c_mixer_is_stereo(struct tas3001c_data_t
*self
,int mixer
)
193 case SOUND_MIXER_VOLUME
:
201 tas3001c_stereo_mixers(struct tas3001c_data_t
*self
)
203 uint r
=tas3001c_supported_mixers(self
);
206 for (i
=1; i
<SOUND_MIXER_NRDEVICES
; i
++)
207 if (r
&(1<<i
) && !tas3001c_mixer_is_stereo(self
,i
))
213 tas3001c_get_mixer_level(struct tas3001c_data_t
*self
,int mixer
,uint
*level
)
218 *level
=self
->super
.mixer
[mixer
];
224 tas3001c_set_mixer_level(struct tas3001c_data_t
*self
,int mixer
,uint level
)
227 tas_shadow_t
*shadow
;
235 shadow
=self
->super
.shadow
;
237 if (!tas3001c_mixer_is_stereo(self
,mixer
))
238 level
= tas_mono_to_stereo(level
);
241 case SOUND_MIXER_VOLUME
:
242 temp
= tas3001c_gain
.master
[level
&0xff];
243 shadow
[TAS3001C_REG_VOLUME
][0] = (temp
>> 16) & 0xff;
244 shadow
[TAS3001C_REG_VOLUME
][1] = (temp
>> 8) & 0xff;
245 shadow
[TAS3001C_REG_VOLUME
][2] = (temp
>> 0) & 0xff;
246 temp
= tas3001c_gain
.master
[(level
>>8)&0xff];
247 shadow
[TAS3001C_REG_VOLUME
][3] = (temp
>> 16) & 0xff;
248 shadow
[TAS3001C_REG_VOLUME
][4] = (temp
>> 8) & 0xff;
249 shadow
[TAS3001C_REG_VOLUME
][5] = (temp
>> 0) & 0xff;
250 rc
= tas3001c_sync_register(self
,TAS3001C_REG_VOLUME
);
252 case SOUND_MIXER_ALTPCM
:
253 /* tas3001c_fast_load(self, 1); */
254 level
= tas_mono_to_stereo(level
);
255 temp
= tas3001c_gain
.mixer
[level
&0xff];
256 shadow
[TAS3001C_REG_MIXER2
][offset
+0] = (temp
>> 16) & 0xff;
257 shadow
[TAS3001C_REG_MIXER2
][offset
+1] = (temp
>> 8) & 0xff;
258 shadow
[TAS3001C_REG_MIXER2
][offset
+2] = (temp
>> 0) & 0xff;
259 rc
= tas3001c_sync_register(self
,TAS3001C_REG_MIXER2
);
260 /* tas3001c_fast_load(self, 0); */
262 case SOUND_MIXER_PCM
:
263 /* tas3001c_fast_load(self, 1); */
264 level
= tas_mono_to_stereo(level
);
265 temp
= tas3001c_gain
.mixer
[level
&0xff];
266 shadow
[TAS3001C_REG_MIXER1
][offset
+0] = (temp
>> 16) & 0xff;
267 shadow
[TAS3001C_REG_MIXER1
][offset
+1] = (temp
>> 8) & 0xff;
268 shadow
[TAS3001C_REG_MIXER1
][offset
+2] = (temp
>> 0) & 0xff;
269 rc
= tas3001c_sync_register(self
,TAS3001C_REG_MIXER1
);
270 /* tas3001c_fast_load(self, 0); */
272 case SOUND_MIXER_TREBLE
:
273 temp
= tas3001c_gain
.treble
[level
&0xff];
274 shadow
[TAS3001C_REG_TREBLE
][0]=temp
&0xff;
275 rc
= tas3001c_sync_register(self
,TAS3001C_REG_TREBLE
);
277 case SOUND_MIXER_BASS
:
278 temp
= tas3001c_gain
.bass
[level
&0xff];
279 shadow
[TAS3001C_REG_BASS
][0]=temp
&0xff;
280 rc
= tas3001c_sync_register(self
,TAS3001C_REG_BASS
);
288 self
->super
.mixer
[mixer
]=level
;
293 tas3001c_leave_sleep(struct tas3001c_data_t
*self
)
295 unsigned char mcr
= (1<<6)+(2<<4)+(2<<2);
300 /* Make sure something answers on the i2c bus */
301 if (tas3001c_write_register(self
, TAS3001C_REG_MCR
, &mcr
,
302 WRITE_NORMAL
|FORCE_WRITE
) < 0)
305 tas3001c_fast_load(self
, 1);
307 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD0
);
308 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD1
);
309 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD2
);
310 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD3
);
311 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD4
);
312 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD5
);
314 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD0
);
315 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD1
);
316 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD2
);
317 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD3
);
318 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD4
);
319 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD5
);
321 tas3001c_fast_load(self
, 0);
323 (void)tas3001c_sync_register(self
,TAS3001C_REG_BASS
);
324 (void)tas3001c_sync_register(self
,TAS3001C_REG_TREBLE
);
325 (void)tas3001c_sync_register(self
,TAS3001C_REG_MIXER1
);
326 (void)tas3001c_sync_register(self
,TAS3001C_REG_MIXER2
);
327 (void)tas3001c_sync_register(self
,TAS3001C_REG_VOLUME
);
333 tas3001c_enter_sleep(struct tas3001c_data_t
*self
)
335 /* Stub for now, but I have the details on low-power mode */
342 tas3001c_sync_biquad( struct tas3001c_data_t
*self
,
346 enum tas3001c_reg_t reg
;
348 if (channel
>= TAS3001C_BIQUAD_CHANNEL_COUNT
||
349 filter
>= TAS3001C_BIQUAD_FILTER_COUNT
) return -EINVAL
;
351 reg
=( channel
? TAS3001C_REG_RIGHT_BIQUAD0
: TAS3001C_REG_LEFT_BIQUAD0
) + filter
;
353 return tas3001c_sync_register(self
,reg
);
357 tas3001c_write_biquad_shadow( struct tas3001c_data_t
*self
,
360 const union tas_biquad_t
*biquad
)
362 tas_shadow_t
*shadow
=self
->super
.shadow
;
363 enum tas3001c_reg_t reg
;
365 if (channel
>= TAS3001C_BIQUAD_CHANNEL_COUNT
||
366 filter
>= TAS3001C_BIQUAD_FILTER_COUNT
) return -EINVAL
;
368 reg
=( channel
? TAS3001C_REG_RIGHT_BIQUAD0
: TAS3001C_REG_LEFT_BIQUAD0
) + filter
;
370 SET_4_20(shadow
[reg
], 0,biquad
->coeff
.b0
);
371 SET_4_20(shadow
[reg
], 3,biquad
->coeff
.b1
);
372 SET_4_20(shadow
[reg
], 6,biquad
->coeff
.b2
);
373 SET_4_20(shadow
[reg
], 9,biquad
->coeff
.a1
);
374 SET_4_20(shadow
[reg
],12,biquad
->coeff
.a2
);
380 tas3001c_write_biquad( struct tas3001c_data_t
*self
,
383 const union tas_biquad_t
*biquad
)
387 rc
=tas3001c_write_biquad_shadow(self
, channel
, filter
, biquad
);
388 if (rc
< 0) return rc
;
390 return tas3001c_sync_biquad(self
, channel
, filter
);
394 tas3001c_write_biquad_list( struct tas3001c_data_t
*self
,
397 struct tas_biquad_ctrl_t
*biquads
)
402 if (flags
& TAS_BIQUAD_FAST_LOAD
) tas3001c_fast_load(self
,1);
404 for (i
=0; i
<filter_count
; i
++) {
405 rc
=tas3001c_write_biquad(self
,
412 if (flags
& TAS_BIQUAD_FAST_LOAD
) {
413 tas3001c_fast_load(self
,0);
415 (void)tas3001c_sync_register(self
,TAS3001C_REG_BASS
);
416 (void)tas3001c_sync_register(self
,TAS3001C_REG_TREBLE
);
417 (void)tas3001c_sync_register(self
,TAS3001C_REG_MIXER1
);
418 (void)tas3001c_sync_register(self
,TAS3001C_REG_MIXER2
);
419 (void)tas3001c_sync_register(self
,TAS3001C_REG_VOLUME
);
426 tas3001c_read_biquad( struct tas3001c_data_t
*self
,
429 union tas_biquad_t
*biquad
)
431 tas_shadow_t
*shadow
=self
->super
.shadow
;
432 enum tas3001c_reg_t reg
;
434 if (channel
>= TAS3001C_BIQUAD_CHANNEL_COUNT
||
435 filter
>= TAS3001C_BIQUAD_FILTER_COUNT
) return -EINVAL
;
437 reg
=( channel
? TAS3001C_REG_RIGHT_BIQUAD0
: TAS3001C_REG_LEFT_BIQUAD0
) + filter
;
439 biquad
->coeff
.b0
=GET_4_20(shadow
[reg
], 0);
440 biquad
->coeff
.b1
=GET_4_20(shadow
[reg
], 3);
441 biquad
->coeff
.b2
=GET_4_20(shadow
[reg
], 6);
442 biquad
->coeff
.a1
=GET_4_20(shadow
[reg
], 9);
443 biquad
->coeff
.a2
=GET_4_20(shadow
[reg
],12);
449 tas3001c_eq_rw( struct tas3001c_data_t
*self
,
454 struct tas_biquad_ctrl_t biquad
;
455 void __user
*argp
= (void __user
*)arg
;
457 if (copy_from_user(&biquad
, argp
, sizeof(struct tas_biquad_ctrl_t
))) {
462 rc
=tas3001c_write_biquad(self
, biquad
.channel
, biquad
.filter
, &biquad
.data
);
463 if (rc
!= 0) return rc
;
466 if (cmd
& SIOC_OUT
) {
467 rc
=tas3001c_read_biquad(self
, biquad
.channel
, biquad
.filter
, &biquad
.data
);
468 if (rc
!= 0) return rc
;
470 if (copy_to_user(argp
, &biquad
, sizeof(struct tas_biquad_ctrl_t
))) {
479 tas3001c_eq_list_rw( struct tas3001c_data_t
*self
,
487 char sync_required
[2][6];
488 struct tas_biquad_ctrl_t biquad
;
489 struct tas_biquad_ctrl_list_t __user
*argp
= (void __user
*)arg
;
491 memset(sync_required
,0,sizeof(sync_required
));
493 if (copy_from_user(&filter_count
, &argp
->filter_count
, sizeof(int)))
496 if (copy_from_user(&flags
, &argp
->flags
, sizeof(int)))
502 for (i
=0; i
< filter_count
; i
++) {
503 if (copy_from_user(&biquad
, &argp
->biquads
[i
],
504 sizeof(struct tas_biquad_ctrl_t
))) {
509 sync_required
[biquad
.channel
][biquad
.filter
]=1;
510 rc
=tas3001c_write_biquad_shadow(self
, biquad
.channel
, biquad
.filter
, &biquad
.data
);
511 if (rc
!= 0) return rc
;
514 if (cmd
& SIOC_OUT
) {
515 rc
=tas3001c_read_biquad(self
, biquad
.channel
, biquad
.filter
, &biquad
.data
);
516 if (rc
!= 0) return rc
;
518 if (copy_to_user(&argp
->biquads
[i
], &biquad
,
519 sizeof(struct tas_biquad_ctrl_t
))) {
526 if (flags
& TAS_BIQUAD_FAST_LOAD
) tas3001c_fast_load(self
,1);
527 for (i
=0; i
<2; i
++) {
528 for (j
=0; j
<6; j
++) {
529 if (sync_required
[i
][j
]) {
530 rc
=tas3001c_sync_biquad(self
, i
, j
);
531 if (rc
< 0) return rc
;
535 if (flags
& TAS_BIQUAD_FAST_LOAD
) {
536 tas3001c_fast_load(self
,0);
537 /* now we need to set up the mixers again,
538 because leaving fast mode resets them. */
539 (void)tas3001c_sync_register(self
,TAS3001C_REG_BASS
);
540 (void)tas3001c_sync_register(self
,TAS3001C_REG_TREBLE
);
541 (void)tas3001c_sync_register(self
,TAS3001C_REG_MIXER1
);
542 (void)tas3001c_sync_register(self
,TAS3001C_REG_MIXER2
);
543 (void)tas3001c_sync_register(self
,TAS3001C_REG_VOLUME
);
551 tas3001c_update_drce( struct tas3001c_data_t
*self
,
553 struct tas_drce_t
*drce
)
555 tas_shadow_t
*shadow
;
556 shadow
=self
->super
.shadow
;
558 shadow
[TAS3001C_REG_DRC
][1] = 0xc1;
560 if (flags
& TAS_DRCE_THRESHOLD
) {
561 self
->drce_state
.threshold
=quantize_db(drce
->threshold
);
562 shadow
[TAS3001C_REG_DRC
][2] = db_to_regval(self
->drce_state
.threshold
);
565 if (flags
& TAS_DRCE_ENABLE
) {
566 self
->drce_state
.enable
= drce
->enable
;
569 if (!self
->drce_state
.enable
) {
570 shadow
[TAS3001C_REG_DRC
][0] = 0xf0;
574 printk("DRCE IOCTL: set [ ENABLE:%x THRESH:%x\n",
575 self
->drce_state
.enable
,
576 self
->drce_state
.threshold
);
578 printk("DRCE IOCTL: reg [ %02x %02x ]\n",
579 (unsigned char)shadow
[TAS3001C_REG_DRC
][0],
580 (unsigned char)shadow
[TAS3001C_REG_DRC
][1]);
583 return tas3001c_sync_register(self
, TAS3001C_REG_DRC
);
587 tas3001c_drce_rw( struct tas3001c_data_t
*self
,
592 struct tas_drce_ctrl_t drce_ctrl
;
593 void __user
*argp
= (void __user
*)arg
;
595 if (copy_from_user(&drce_ctrl
, argp
, sizeof(struct tas_drce_ctrl_t
)))
599 printk("DRCE IOCTL: input [ FLAGS:%x ENABLE:%x THRESH:%x\n",
601 drce_ctrl
.data
.enable
,
602 drce_ctrl
.data
.threshold
);
606 rc
= tas3001c_update_drce(self
, drce_ctrl
.flags
, &drce_ctrl
.data
);
611 if (cmd
& SIOC_OUT
) {
612 if (drce_ctrl
.flags
& TAS_DRCE_ENABLE
)
613 drce_ctrl
.data
.enable
= self
->drce_state
.enable
;
615 if (drce_ctrl
.flags
& TAS_DRCE_THRESHOLD
)
616 drce_ctrl
.data
.threshold
= self
->drce_state
.threshold
;
618 if (copy_to_user(argp
, &drce_ctrl
,
619 sizeof(struct tas_drce_ctrl_t
))) {
628 tas3001c_update_device_parameters(struct tas3001c_data_t
*self
)
634 if (self
->output_id
== TAS_OUTPUT_HEADPHONES
) {
635 tas3001c_fast_load(self
, 1);
637 for (i
=0; i
<TAS3001C_BIQUAD_CHANNEL_COUNT
; i
++) {
638 for (j
=0; j
<TAS3001C_BIQUAD_FILTER_COUNT
; j
++) {
639 tas3001c_write_biquad(self
, i
, j
, &tas3001c_eq_unity
);
643 tas3001c_fast_load(self
, 0);
645 (void)tas3001c_sync_register(self
,TAS3001C_REG_BASS
);
646 (void)tas3001c_sync_register(self
,TAS3001C_REG_TREBLE
);
647 (void)tas3001c_sync_register(self
,TAS3001C_REG_MIXER1
);
648 (void)tas3001c_sync_register(self
,TAS3001C_REG_MIXER2
);
649 (void)tas3001c_sync_register(self
,TAS3001C_REG_VOLUME
);
654 for (i
=0; tas3001c_eq_prefs
[i
]; i
++) {
655 struct tas_eq_pref_t
*eq
= tas3001c_eq_prefs
[i
];
657 if (eq
->device_id
== self
->device_id
&&
658 (eq
->output_id
== 0 || eq
->output_id
== self
->output_id
) &&
659 (eq
->speaker_id
== 0 || eq
->speaker_id
== self
->speaker_id
)) {
661 tas3001c_update_drce(self
, TAS_DRCE_ALL
, eq
->drce
);
662 tas3001c_write_biquad_list(self
, eq
->filter_count
, TAS_BIQUAD_FAST_LOAD
, eq
->biquads
);
670 tas3001c_device_change_handler(void *self
)
673 tas3001c_update_device_parameters(self
);
676 static struct work_struct device_change
;
679 tas3001c_output_device_change( struct tas3001c_data_t
*self
,
684 self
->device_id
=device_id
;
685 self
->output_id
=output_id
;
686 self
->speaker_id
=speaker_id
;
688 schedule_work(&device_change
);
693 tas3001c_device_ioctl( struct tas3001c_data_t
*self
,
697 uint __user
*argp
= (void __user
*)arg
;
701 return tas3001c_eq_rw(self
, cmd
, arg
);
703 case TAS_READ_EQ_LIST
:
704 case TAS_WRITE_EQ_LIST
:
705 return tas3001c_eq_list_rw(self
, cmd
, arg
);
707 case TAS_READ_EQ_FILTER_COUNT
:
708 put_user(TAS3001C_BIQUAD_FILTER_COUNT
, argp
);
711 case TAS_READ_EQ_CHANNEL_COUNT
:
712 put_user(TAS3001C_BIQUAD_CHANNEL_COUNT
, argp
);
717 return tas3001c_drce_rw(self
, cmd
, arg
);
719 case TAS_READ_DRCE_CAPS
:
720 put_user(TAS_DRCE_ENABLE
| TAS_DRCE_THRESHOLD
, argp
);
723 case TAS_READ_DRCE_MIN
:
724 case TAS_READ_DRCE_MAX
: {
725 struct tas_drce_ctrl_t drce_ctrl
;
727 if (copy_from_user(&drce_ctrl
, argp
,
728 sizeof(struct tas_drce_ctrl_t
))) {
732 if (drce_ctrl
.flags
& TAS_DRCE_THRESHOLD
) {
733 if (cmd
== TAS_READ_DRCE_MIN
) {
734 drce_ctrl
.data
.threshold
=-36<<8;
736 drce_ctrl
.data
.threshold
=-6<<8;
740 if (copy_to_user(argp
, &drce_ctrl
,
741 sizeof(struct tas_drce_ctrl_t
))) {
751 tas3001c_init_mixer(struct tas3001c_data_t
*self
)
753 unsigned char mcr
= (1<<6)+(2<<4)+(2<<2);
755 /* Make sure something answers on the i2c bus */
756 if (tas3001c_write_register(self
, TAS3001C_REG_MCR
, &mcr
,
757 WRITE_NORMAL
|FORCE_WRITE
) < 0)
760 tas3001c_fast_load(self
, 1);
762 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD0
);
763 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD1
);
764 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD2
);
765 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD3
);
766 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD4
);
767 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD5
);
768 (void)tas3001c_sync_register(self
,TAS3001C_REG_RIGHT_BIQUAD6
);
770 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD0
);
771 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD1
);
772 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD2
);
773 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD3
);
774 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD4
);
775 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD5
);
776 (void)tas3001c_sync_register(self
,TAS3001C_REG_LEFT_BIQUAD6
);
778 tas3001c_fast_load(self
, 0);
780 tas3001c_set_mixer_level(self
, SOUND_MIXER_VOLUME
, VOL_DEFAULT
<<8 | VOL_DEFAULT
);
781 tas3001c_set_mixer_level(self
, SOUND_MIXER_PCM
, INPUT_DEFAULT
<<8 | INPUT_DEFAULT
);
782 tas3001c_set_mixer_level(self
, SOUND_MIXER_ALTPCM
, 0);
784 tas3001c_set_mixer_level(self
, SOUND_MIXER_BASS
, BASS_DEFAULT
);
785 tas3001c_set_mixer_level(self
, SOUND_MIXER_TREBLE
, TREBLE_DEFAULT
);
791 tas3001c_uninit_mixer(struct tas3001c_data_t
*self
)
793 tas3001c_set_mixer_level(self
, SOUND_MIXER_VOLUME
, 0);
794 tas3001c_set_mixer_level(self
, SOUND_MIXER_PCM
, 0);
795 tas3001c_set_mixer_level(self
, SOUND_MIXER_ALTPCM
, 0);
797 tas3001c_set_mixer_level(self
, SOUND_MIXER_BASS
, 0);
798 tas3001c_set_mixer_level(self
, SOUND_MIXER_TREBLE
, 0);
804 tas3001c_init(struct i2c_client
*client
)
806 struct tas3001c_data_t
*self
;
807 size_t sz
= sizeof(*self
) + (TAS3001C_REG_MAX
*sizeof(tas_shadow_t
));
810 self
= kmalloc(sz
, GFP_KERNEL
);
815 self
->super
.client
= client
;
816 self
->super
.shadow
= (tas_shadow_t
*)(self
+1);
817 self
->output_id
= TAS_OUTPUT_HEADPHONES
;
819 dev_set_drvdata(&client
->dev
, self
);
821 for (i
= 0; i
< TAS3001C_BIQUAD_CHANNEL_COUNT
; i
++)
822 for (j
= 0; j
< TAS3001C_BIQUAD_FILTER_COUNT
; j
++)
823 tas3001c_write_biquad_shadow(self
, i
, j
,
826 INIT_WORK(&device_change
, tas3001c_device_change_handler
, self
);
831 tas3001c_uninit(struct tas3001c_data_t
*self
)
833 tas3001c_uninit_mixer(self
);
837 struct tas_driver_hooks_t tas3001c_hooks
= {
838 .init
= (tas_hook_init_t
)tas3001c_init
,
839 .post_init
= (tas_hook_post_init_t
)tas3001c_init_mixer
,
840 .uninit
= (tas_hook_uninit_t
)tas3001c_uninit
,
841 .get_mixer_level
= (tas_hook_get_mixer_level_t
)tas3001c_get_mixer_level
,
842 .set_mixer_level
= (tas_hook_set_mixer_level_t
)tas3001c_set_mixer_level
,
843 .enter_sleep
= (tas_hook_enter_sleep_t
)tas3001c_enter_sleep
,
844 .leave_sleep
= (tas_hook_leave_sleep_t
)tas3001c_leave_sleep
,
845 .supported_mixers
= (tas_hook_supported_mixers_t
)tas3001c_supported_mixers
,
846 .mixer_is_stereo
= (tas_hook_mixer_is_stereo_t
)tas3001c_mixer_is_stereo
,
847 .stereo_mixers
= (tas_hook_stereo_mixers_t
)tas3001c_stereo_mixers
,
848 .output_device_change
= (tas_hook_output_device_change_t
)tas3001c_output_device_change
,
849 .device_ioctl
= (tas_hook_device_ioctl_t
)tas3001c_device_ioctl