Lines Matching defs:onyx

25  *	 this means you can only have one onyx on a system. This
36 MODULE_DESCRIPTION("pcm3052 (onyx) codec driver for snd-aoa");
38 #include "onyx.h"
43 #define PFX "snd-aoa-codec-onyx: "
45 struct onyx {
62 #define codec_to_onyx(c) container_of(c, struct onyx, codec)
65 static int onyx_read_register(struct onyx *onyx, u8 reg, u8 *value)
70 *value = onyx->cache[reg-FIRSTREGISTER];
73 v = i2c_smbus_read_byte_data(onyx->i2c, reg);
79 onyx->cache[ONYX_REG_CONTROL-FIRSTREGISTER] = *value;
83 static int onyx_write_register(struct onyx *onyx, u8 reg, u8 value)
87 result = i2c_smbus_write_byte_data(onyx->i2c, reg, value);
89 onyx->cache[reg-FIRSTREGISTER] = value;
121 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
124 mutex_lock(&onyx->mutex);
125 onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_LEFT, &l);
126 onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT, &r);
127 mutex_unlock(&onyx->mutex);
138 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
148 mutex_lock(&onyx->mutex);
149 onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_LEFT, &l);
150 onyx_read_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT, &r);
154 mutex_unlock(&onyx->mutex);
158 onyx_write_register(onyx, ONYX_REG_DAC_ATTEN_LEFT,
161 onyx_write_register(onyx, ONYX_REG_DAC_ATTEN_RIGHT,
164 mutex_unlock(&onyx->mutex);
197 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
200 mutex_lock(&onyx->mutex);
201 onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &ig);
202 mutex_unlock(&onyx->mutex);
213 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
219 mutex_lock(&onyx->mutex);
220 onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &v);
225 onyx_write_register(onyx, ONYX_REG_ADC_CONTROL, n);
226 mutex_unlock(&onyx->mutex);
251 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
254 mutex_lock(&onyx->mutex);
255 onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &v);
256 mutex_unlock(&onyx->mutex);
263 static void onyx_set_capture_source(struct onyx *onyx, int mic)
267 mutex_lock(&onyx->mutex);
268 onyx_read_register(onyx, ONYX_REG_ADC_CONTROL, &v);
272 onyx_write_register(onyx, ONYX_REG_ADC_CONTROL, v);
273 mutex_unlock(&onyx->mutex);
311 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
314 mutex_lock(&onyx->mutex);
315 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &c);
316 mutex_unlock(&onyx->mutex);
327 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
331 mutex_lock(&onyx->mutex);
332 if (onyx->analog_locked)
335 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &v);
342 err = onyx_write_register(onyx, ONYX_REG_DAC_CONTROL, c);
345 mutex_unlock(&onyx->mutex);
368 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
375 mutex_lock(&onyx->mutex);
376 onyx_read_register(onyx, address, &c);
377 mutex_unlock(&onyx->mutex);
387 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
396 mutex_lock(&onyx->mutex);
397 if (spdiflock && onyx->spdif_locked) {
402 onyx_read_register(onyx, address, &v);
407 err = onyx_write_register(onyx, address, c);
410 mutex_unlock(&onyx->mutex);
489 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
492 mutex_lock(&onyx->mutex);
493 onyx_read_register(onyx, ONYX_REG_DIG_INFO1, &v);
496 onyx_read_register(onyx, ONYX_REG_DIG_INFO2, &v);
499 onyx_read_register(onyx, ONYX_REG_DIG_INFO3, &v);
502 onyx_read_register(onyx, ONYX_REG_DIG_INFO4, &v);
504 mutex_unlock(&onyx->mutex);
512 struct onyx *onyx = snd_kcontrol_chip(kcontrol);
515 mutex_lock(&onyx->mutex);
516 onyx_read_register(onyx, ONYX_REG_DIG_INFO1, &v);
518 onyx_write_register(onyx, ONYX_REG_DIG_INFO1, v);
521 onyx_write_register(onyx, ONYX_REG_DIG_INFO2, v);
523 onyx_read_register(onyx, ONYX_REG_DIG_INFO3, &v);
525 onyx_write_register(onyx, ONYX_REG_DIG_INFO3, v);
527 onyx_read_register(onyx, ONYX_REG_DIG_INFO4, &v);
529 onyx_write_register(onyx, ONYX_REG_DIG_INFO4, v);
530 mutex_unlock(&onyx->mutex);
578 static int onyx_register_init(struct onyx *onyx)
584 if (!onyx->initialised) {
586 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &val))
593 regs[i] = onyx->cache[register_map[i]-FIRSTREGISTER];
597 if (onyx_write_register(onyx, register_map[i], regs[i]))
600 onyx->initialised = 1;
672 struct onyx *onyx = cii->codec_data;
675 mutex_lock(&onyx->mutex);
676 onyx_read_register(onyx, ONYX_REG_DIG_INFO4, &v);
678 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &v);
682 mutex_unlock(&onyx->mutex);
697 struct onyx *onyx = cii->codec_data;
700 mutex_lock(&onyx->mutex);
705 onyx_read_register(onyx, ONYX_REG_DAC_CONTROL, &v);
706 if (onyx_write_register(onyx,
710 onyx->analog_locked = 1;
728 if (onyx_write_register(onyx,
732 onyx->spdif_locked = 1;
738 mutex_unlock(&onyx->mutex);
746 struct onyx *onyx = cii->codec_data;
748 mutex_lock(&onyx->mutex);
749 onyx->open_count++;
750 mutex_unlock(&onyx->mutex);
758 struct onyx *onyx = cii->codec_data;
760 mutex_lock(&onyx->mutex);
761 onyx->open_count--;
762 if (!onyx->open_count)
763 onyx->spdif_locked = onyx->analog_locked = 0;
764 mutex_unlock(&onyx->mutex);
772 struct onyx *onyx = cii->codec_data;
774 mutex_lock(&onyx->mutex);
778 onyx->codec.gpio->methods->all_amps_off(onyx->codec.gpio);
781 onyx->codec.gpio->methods->all_amps_restore(onyx->codec.gpio);
786 mutex_unlock(&onyx->mutex);
795 struct onyx *onyx = cii->codec_data;
799 mutex_lock(&onyx->mutex);
800 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &v))
802 onyx_write_register(onyx, ONYX_REG_CONTROL, v | ONYX_ADPSV | ONYX_DAPSV);
806 mutex_unlock(&onyx->mutex);
813 struct onyx *onyx = cii->codec_data;
817 mutex_lock(&onyx->mutex);
820 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
822 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 1);
824 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
828 if (onyx_read_register(onyx, ONYX_REG_CONTROL, &v))
830 onyx_write_register(onyx, ONYX_REG_CONTROL, v & ~(ONYX_ADPSV | ONYX_DAPSV));
834 onyx_register_init(onyx);
837 mutex_unlock(&onyx->mutex);
862 struct onyx *onyx = codec_to_onyx(codec);
868 if (!onyx->codec.gpio || !onyx->codec.gpio->methods) {
873 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
875 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 1);
877 onyx->codec.gpio->methods->set_hw_reset(onyx->codec.gpio, 0);
880 if (onyx_register_init(onyx)) {
881 printk(KERN_ERR PFX "failed to initialise onyx registers\n");
885 if (aoa_snd_device_new(SNDRV_DEV_CODEC, onyx, &ops)) {
886 printk(KERN_ERR PFX "failed to create onyx snd device!\n");
891 if ((onyx->codec.connected & 0xF) == 0)
895 if ((onyx->codec.connected & 0xC) == 0) {
896 if (!onyx->codec_info)
897 onyx->codec_info = kmalloc(sizeof(struct codec_info), GFP_KERNEL);
898 if (!onyx->codec_info)
900 ci = onyx->codec_info;
906 if ((onyx->codec.connected & 3) == 0) {
907 if (!onyx->codec_info)
908 onyx->codec_info = kmalloc(sizeof(struct codec_info), GFP_KERNEL);
909 if (!onyx->codec_info)
911 ci = onyx->codec_info;
918 if (onyx->codec.soundbus_dev->attach_codec(onyx->codec.soundbus_dev,
920 ci, onyx)) {
921 printk(KERN_ERR PFX "error creating onyx pcm\n");
926 ctl = snd_ctl_new1(&n, onyx); \
929 onyx->codec.soundbus_dev->pcm->device; \
936 if (onyx->codec.soundbus_dev->pcm) {
939 if ((onyx->codec.connected & 0xC) == 0xC)
941 else if (onyx->codec.connected & 4)
942 onyx_set_capture_source(onyx, 0);
944 onyx_set_capture_source(onyx, 1);
945 if (onyx->codec.connected & 0xC)
950 if (onyx->codec.connected & 1) {
959 if (onyx->codec.connected & 2) {
963 if ((onyx->codec.connected & 3) == 3)
966 if ((onyx->codec.connected & 3) == 2) {
967 onyx_read_register(onyx, ONYX_REG_DIG_INFO4, &v);
969 onyx_write_register(onyx, ONYX_REG_DIG_INFO4, v);
973 printk(KERN_INFO PFX "attached to onyx codec via i2c\n");
977 onyx->codec.soundbus_dev->detach_codec(onyx->codec.soundbus_dev, onyx);
978 snd_device_free(aoa_get_card(), onyx);
984 struct onyx *onyx = codec_to_onyx(codec);
986 if (!onyx->codec.soundbus_dev) {
990 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 strlcpy(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);