Lines Matching defs:onyx
25 * this means you can only have one onyx on a system. This
37 MODULE_DESCRIPTION("pcm3052 (onyx) codec driver for snd-aoa");
39 #include "onyx.h"
44 #define PFX "snd-aoa-codec-onyx: "
46 struct onyx {
63 #define codec_to_onyx(c) container_of(c, struct onyx, codec)
66 static int onyx_read_register(struct onyx *onyx, u8 reg, u8 *value)
71 *value = onyx->cache[reg-FIRSTREGISTER];
74 v = i2c_smbus_read_byte_data(onyx->i2c, reg);
80 onyx->cache[ONYX_REG_CONTROL-FIRSTREGISTER] = *value;
84 static int onyx_write_register(struct onyx *onyx, u8 reg, u8 value)
88 result = i2c_smbus_write_byte_data(onyx->i2c, reg, value);
90 onyx->cache[reg-FIRSTREGISTER] = value;
122 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
125 mutex_lock(&onyx->mutex);
126 onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_LEFT, &l);
127 onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT, &r);
128 mutex_unlock(&onyx->mutex);
139 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
149 mutex_lock(&onyx->mutex);
150 onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_LEFT, &l);
151 onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT, &r);
155 mutex_unlock(&onyx->mutex);
159 onyx_write_register(onyx, ONYX_REG_DAC_ATTEN_LEFT,
162 onyx_write_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT,
165 mutex_unlock(&onyx->mutex);
198 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
201 mutex_lock(&onyx->mutex);
202 onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &ig);
203 mutex_unlock(&onyx->mutex);
214 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
220 mutex_lock(&onyx->mutex);
221 onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &v);
226 onyx_write_register(onyx, ONYX_REG_ADC_CONTROL, n);
227 mutex_unlock(&onyx->mutex);
252 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
255 mutex_lock(&onyx->mutex);
256 onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &v);
257 mutex_unlock(&onyx->mutex);
264 static void onyx_set_capture_source(struct onyx *onyx, int mic)
268 mutex_lock(&onyx->mutex);
269 onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &v);
273 onyx_write_register(onyx, ONYX_REG_ADC_CONTROL, v);
274 mutex_unlock(&onyx->mutex);
312 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
315 mutex_lock(&onyx->mutex);
316 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &c);
317 mutex_unlock(&onyx->mutex);
328 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
332 mutex_lock(&onyx->mutex);
333 if (onyx->analog_locked)
336 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &v);
343 err = onyx_write_register(onyx, ONYX_REG_DAC_CONTROL, c);
346 mutex_unlock(&onyx->mutex);
369 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
376 mutex_lock(&onyx->mutex);
377 onyx_read_register(onyx, address, &c);
378 mutex_unlock(&onyx->mutex);
388 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
397 mutex_lock(&onyx->mutex);
398 if (spdiflock && onyx->spdif_locked) {
403 onyx_read_register(onyx, address, &v);
408 err = onyx_write_register(onyx, address, c);
411 mutex_unlock(&onyx->mutex);
490 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
493 mutex_lock(&onyx->mutex);
494 onyx_read_register(onyx, ONYX_REG_DIG_INFO1, &v);
497 onyx_read_register(onyx, ONYX_REG_DIG_INFO2, &v);
500 onyx_read_register(onyx, ONYX_REG_DIG_INFO3, &v);
503 onyx_read_register(onyx, ONYX_REG_DIG_INFO4, &v);
505 mutex_unlock(&onyx->mutex);
513 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
516 mutex_lock(&onyx->mutex);
517 onyx_read_register(onyx, ONYX_REG_DIG_INFO1, &v);
519 onyx_write_register(onyx, ONYX_REG_DIG_INFO1, v);
522 onyx_write_register(onyx, ONYX_REG_DIG_INFO2, v);
524 onyx_read_register(onyx, ONYX_REG_DIG_INFO3, &v);
526 onyx_write_register(onyx, ONYX_REG_DIG_INFO3, v);
528 onyx_read_register(onyx, ONYX_REG_DIG_INFO4, &v);
530 onyx_write_register(onyx, ONYX_REG_DIG_INFO4, v);
531 mutex_unlock(&onyx->mutex);
579 static int onyx_register_init(struct onyx *onyx)
585 if (!onyx->initialised) {
587 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &val))
594 regs[i] = onyx->cache[register_map[i]-FIRSTREGISTER];
598 if (onyx_write_register(onyx, register_map[i], regs[i]))
601 onyx->initialised = 1;
673 struct onyx *onyx = cii->codec_data;
676 mutex_lock(&onyx->mutex);
677 onyx_read_register(onyx, ONYX_REG_DIG_INFO4, &v);
679 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &v);
683 mutex_unlock(&onyx->mutex);
698 struct onyx *onyx = cii->codec_data;
701 mutex_lock(&onyx->mutex);
706 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &v);
707 if (onyx_write_register(onyx,
711 onyx->analog_locked = 1;
729 if (onyx_write_register(onyx,
733 onyx->spdif_locked = 1;
739 mutex_unlock(&onyx->mutex);
747 struct onyx *onyx = cii->codec_data;
749 mutex_lock(&onyx->mutex);
750 onyx->open_count++;
751 mutex_unlock(&onyx->mutex);
759 struct onyx *onyx = cii->codec_data;
761 mutex_lock(&onyx->mutex);
762 onyx->open_count--;
763 if (!onyx->open_count)
764 onyx->spdif_locked = onyx->analog_locked = 0;
765 mutex_unlock(&onyx->mutex);
773 struct onyx *onyx = cii->codec_data;
775 mutex_lock(&onyx->mutex);
779 onyx->codec.gpio->methods->all_amps_off(onyx->codec.gpio);
782 onyx->codec.gpio->methods->all_amps_restore(onyx->codec.gpio);
787 mutex_unlock(&onyx->mutex);
796 struct onyx *onyx = cii->codec_data;
800 mutex_lock(&onyx->mutex);
801 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &v))
803 onyx_write_register(onyx, ONYX_REG_CONTROL, v | ONYX_ADPSV | ONYX_DAPSV);
807 mutex_unlock(&onyx->mutex);
814 struct onyx *onyx = cii->codec_data;
818 mutex_lock(&onyx->mutex);
821 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
823 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 1);
825 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
829 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &v))
831 onyx_write_register(onyx, ONYX_REG_CONTROL, v & ~(ONYX_ADPSV | ONYX_DAPSV));
835 onyx_register_init(onyx);
838 mutex_unlock(&onyx->mutex);
863 struct onyx *onyx = codec_to_onyx(codec);
869 if (!onyx->codec.gpio || !onyx->codec.gpio->methods) {
874 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
876 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 1);
878 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
881 if (onyx_register_init(onyx)) {
882 printk(KERN_ERR PFX "failed to initialise onyx registers\n");
886 if (aoa_snd_device_new(SNDRV_DEV_CODEC, onyx, &ops)) {
887 printk(KERN_ERR PFX "failed to create onyx snd device!\n");
892 if ((onyx->codec.connected & 0xF) == 0)
896 if ((onyx->codec.connected & 0xC) == 0) {
897 if (!onyx->codec_info)
898 onyx->codec_info = kmalloc(sizeof(struct codec_info), GFP_KERNEL);
899 if (!onyx->codec_info)
901 ci = onyx->codec_info;
907 if ((onyx->codec.connected & 3) == 0) {
908 if (!onyx->codec_info)
909 onyx->codec_info = kmalloc(sizeof(struct codec_info), GFP_KERNEL);
910 if (!onyx->codec_info)
912 ci = onyx->codec_info;
919 if (onyx->codec.soundbus_dev->attach_codec(onyx->codec.soundbus_dev,
921 ci, onyx)) {
922 printk(KERN_ERR PFX "error creating onyx pcm\n");
927 ctl = snd_ctl_new1(&n, onyx); \
930 onyx->codec.soundbus_dev->pcm->device; \
937 if (onyx->codec.soundbus_dev->pcm) {
940 if ((onyx->codec.connected & 0xC) == 0xC)
942 else if (onyx->codec.connected & 4)
943 onyx_set_capture_source(onyx, 0);
945 onyx_set_capture_source(onyx, 1);
946 if (onyx->codec.connected & 0xC)
951 if (onyx->codec.connected & 1) {
960 if (onyx->codec.connected & 2) {
964 if ((onyx->codec.connected & 3) == 3)
967 if ((onyx->codec.connected & 3) == 2) {
968 onyx_read_register(onyx, ONYX_REG_DIG_INFO4, &v);
970 onyx_write_register(onyx, ONYX_REG_DIG_INFO4, v);
974 printk(KERN_INFO PFX "attached to onyx codec via i2c\n");
978 onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx);
979 snd_device_free(aoa_get_card(), onyx);
985 struct onyx *onyx = codec_to_onyx(codec);
987 if (!onyx->codec.soundbus_dev) {
991 onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx);
997 struct onyx *onyx;
1000 onyx = kzalloc(sizeof(struct onyx), GFP_KERNEL);
1002 if (!onyx)
1005 mutex_init(&onyx->mutex);
1006 onyx->i2c = client;
1007 i2c_set_clientdata(client, onyx);
1011 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &dummy) != 0) {
1016 strscpy(onyx->codec.name, "onyx", MAX_CODEC_NAME_LEN);
1017 onyx->codec.owner = THIS_MODULE;
1018 onyx->codec.init = onyx_init_codec;
1019 onyx->codec.exit = onyx_exit_codec;
1020 onyx->codec.node = of_node_get(node);
1022 if (aoa_codec_register(&onyx->codec)) {
1025 printk(KERN_DEBUG PFX "created and attached onyx instance\n");
1028 kfree(onyx);
1034 struct onyx *onyx = i2c_get_clientdata(client);
1036 aoa_codec_unregister(&onyx->codec);
1037 of_node_put(onyx->codec.node);
1038 kfree(onyx->codec_info);
1039 kfree(onyx);