~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/pci/oxygen/xonar_lib.c

Version: ~ [ linux-6.11.5 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.58 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.114 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.169 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.228 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.284 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.322 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.9 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 // SPDX-License-Identifier: GPL-2.0-only
  2 /*
  3  * helper functions for Asus Xonar cards
  4  *
  5  * Copyright (c) Clemens Ladisch <clemens@ladisch.de>
  6  */
  7 
  8 #include <linux/delay.h>
  9 #include <sound/core.h>
 10 #include <sound/control.h>
 11 #include <sound/pcm.h>
 12 #include <sound/pcm_params.h>
 13 #include "xonar.h"
 14 
 15 
 16 #define GPIO_CS53x1_M_MASK      0x000c
 17 #define GPIO_CS53x1_M_SINGLE    0x0000
 18 #define GPIO_CS53x1_M_DOUBLE    0x0004
 19 #define GPIO_CS53x1_M_QUAD      0x0008
 20 
 21 
 22 void xonar_enable_output(struct oxygen *chip)
 23 {
 24         struct xonar_generic *data = chip->model_data;
 25 
 26         oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, data->output_enable_bit);
 27         msleep(data->anti_pop_delay);
 28         oxygen_set_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit);
 29 }
 30 
 31 void xonar_disable_output(struct oxygen *chip)
 32 {
 33         struct xonar_generic *data = chip->model_data;
 34 
 35         oxygen_clear_bits16(chip, OXYGEN_GPIO_DATA, data->output_enable_bit);
 36 }
 37 
 38 static void xonar_ext_power_gpio_changed(struct oxygen *chip)
 39 {
 40         struct xonar_generic *data = chip->model_data;
 41         u8 has_power;
 42 
 43         has_power = !!(oxygen_read8(chip, data->ext_power_reg)
 44                        & data->ext_power_bit);
 45         if (has_power != data->has_power) {
 46                 data->has_power = has_power;
 47                 if (has_power) {
 48                         dev_notice(chip->card->dev, "power restored\n");
 49                 } else {
 50                         dev_crit(chip->card->dev,
 51                                    "Hey! Don't unplug the power cable!\n");
 52                         /* TODO: stop PCMs */
 53                 }
 54         }
 55 }
 56 
 57 void xonar_init_ext_power(struct oxygen *chip)
 58 {
 59         struct xonar_generic *data = chip->model_data;
 60 
 61         oxygen_set_bits8(chip, data->ext_power_int_reg,
 62                          data->ext_power_bit);
 63         chip->interrupt_mask |= OXYGEN_INT_GPIO;
 64         chip->model.gpio_changed = xonar_ext_power_gpio_changed;
 65         data->has_power = !!(oxygen_read8(chip, data->ext_power_reg)
 66                              & data->ext_power_bit);
 67 }
 68 
 69 void xonar_init_cs53x1(struct oxygen *chip)
 70 {
 71         oxygen_set_bits16(chip, OXYGEN_GPIO_CONTROL, GPIO_CS53x1_M_MASK);
 72         oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
 73                               GPIO_CS53x1_M_SINGLE, GPIO_CS53x1_M_MASK);
 74 }
 75 
 76 void xonar_set_cs53x1_params(struct oxygen *chip,
 77                              struct snd_pcm_hw_params *params)
 78 {
 79         unsigned int value;
 80 
 81         if (params_rate(params) <= 54000)
 82                 value = GPIO_CS53x1_M_SINGLE;
 83         else if (params_rate(params) <= 108000)
 84                 value = GPIO_CS53x1_M_DOUBLE;
 85         else
 86                 value = GPIO_CS53x1_M_QUAD;
 87         oxygen_write16_masked(chip, OXYGEN_GPIO_DATA,
 88                               value, GPIO_CS53x1_M_MASK);
 89 }
 90 
 91 int xonar_gpio_bit_switch_get(struct snd_kcontrol *ctl,
 92                               struct snd_ctl_elem_value *value)
 93 {
 94         struct oxygen *chip = ctl->private_data;
 95         u16 bit = ctl->private_value;
 96         bool invert = ctl->private_value & XONAR_GPIO_BIT_INVERT;
 97 
 98         value->value.integer.value[0] =
 99                 !!(oxygen_read16(chip, OXYGEN_GPIO_DATA) & bit) ^ invert;
100         return 0;
101 }
102 
103 int xonar_gpio_bit_switch_put(struct snd_kcontrol *ctl,
104                               struct snd_ctl_elem_value *value)
105 {
106         struct oxygen *chip = ctl->private_data;
107         u16 bit = ctl->private_value;
108         bool invert = ctl->private_value & XONAR_GPIO_BIT_INVERT;
109         u16 old_bits, new_bits;
110         int changed;
111 
112         spin_lock_irq(&chip->reg_lock);
113         old_bits = oxygen_read16(chip, OXYGEN_GPIO_DATA);
114         if (!!value->value.integer.value[0] ^ invert)
115                 new_bits = old_bits | bit;
116         else
117                 new_bits = old_bits & ~bit;
118         changed = new_bits != old_bits;
119         if (changed)
120                 oxygen_write16(chip, OXYGEN_GPIO_DATA, new_bits);
121         spin_unlock_irq(&chip->reg_lock);
122         return changed;
123 }
124 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php