Commit 7ef37cd9 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Jaroslav Kysela

[ALSA] oxygen: move model-specific data out of common header

Instead of having model-specific fields in the common struct oxygen, put
them into a private structure that is allocated together with the card
structure.
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarJaroslav Kysela <perex@perex.cz>
parent 3b94253b
...@@ -157,6 +157,10 @@ MODULE_DEVICE_TABLE(pci, oxygen_ids); ...@@ -157,6 +157,10 @@ MODULE_DEVICE_TABLE(pci, oxygen_ids);
#define WM8785_PWRDNL 0x010 #define WM8785_PWRDNL 0x010
#define WM8785_TDM_MASK 0x1c0 #define WM8785_TDM_MASK 0x1c0
struct generic_data {
u8 ak4396_ctl2;
};
static void ak4396_write(struct oxygen *chip, unsigned int codec, static void ak4396_write(struct oxygen *chip, unsigned int codec,
u8 reg, u8 value) u8 reg, u8 value)
{ {
...@@ -184,14 +188,15 @@ static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value) ...@@ -184,14 +188,15 @@ static void wm8785_write(struct oxygen *chip, u8 reg, unsigned int value)
static void ak4396_init(struct oxygen *chip) static void ak4396_init(struct oxygen *chip)
{ {
struct generic_data *data = chip->model_data;
unsigned int i; unsigned int i;
chip->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL; data->ak4396_ctl2 = AK4396_DEM_OFF | AK4396_DFS_NORMAL;
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
ak4396_write(chip, i, ak4396_write(chip, i,
AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN); AK4396_CONTROL_1, AK4396_DIF_24_MSB | AK4396_RSTN);
ak4396_write(chip, i, ak4396_write(chip, i,
AK4396_CONTROL_2, chip->ak4396_ctl2); AK4396_CONTROL_2, data->ak4396_ctl2);
ak4396_write(chip, i, ak4396_write(chip, i,
AK4396_CONTROL_3, AK4396_PCM); AK4396_CONTROL_3, AK4396_PCM);
ak4396_write(chip, i, AK4396_LCH_ATT, 0xff); ak4396_write(chip, i, AK4396_LCH_ATT, 0xff);
...@@ -235,17 +240,18 @@ static void generic_cleanup(struct oxygen *chip) ...@@ -235,17 +240,18 @@ static void generic_cleanup(struct oxygen *chip)
static void set_ak4396_params(struct oxygen *chip, static void set_ak4396_params(struct oxygen *chip,
struct snd_pcm_hw_params *params) struct snd_pcm_hw_params *params)
{ {
struct generic_data *data = chip->model_data;
unsigned int i; unsigned int i;
u8 value; u8 value;
value = chip->ak4396_ctl2 & ~AK4396_DFS_MASK; value = data->ak4396_ctl2 & ~AK4396_DFS_MASK;
if (params_rate(params) <= 54000) if (params_rate(params) <= 54000)
value |= AK4396_DFS_NORMAL; value |= AK4396_DFS_NORMAL;
else if (params_rate(params) < 120000) else if (params_rate(params) < 120000)
value |= AK4396_DFS_DOUBLE; value |= AK4396_DFS_DOUBLE;
else else
value |= AK4396_DFS_QUAD; value |= AK4396_DFS_QUAD;
chip->ak4396_ctl2 = value; data->ak4396_ctl2 = value;
for (i = 0; i < 4; ++i) { for (i = 0; i < 4; ++i) {
ak4396_write(chip, i, ak4396_write(chip, i,
AK4396_CONTROL_1, AK4396_DIF_24_MSB); AK4396_CONTROL_1, AK4396_DIF_24_MSB);
...@@ -270,12 +276,14 @@ static void update_ak4396_volume(struct oxygen *chip) ...@@ -270,12 +276,14 @@ static void update_ak4396_volume(struct oxygen *chip)
static void update_ak4396_mute(struct oxygen *chip) static void update_ak4396_mute(struct oxygen *chip)
{ {
struct generic_data *data = chip->model_data;
unsigned int i; unsigned int i;
u8 value; u8 value;
value = chip->ak4396_ctl2 & ~AK4396_SMUTE; value = data->ak4396_ctl2 & ~AK4396_SMUTE;
if (chip->dac_mute) if (chip->dac_mute)
value |= AK4396_SMUTE; value |= AK4396_SMUTE;
data->ak4396_ctl2 = value;
for (i = 0; i < 4; ++i) for (i = 0; i < 4; ++i)
ak4396_write(chip, i, AK4396_CONTROL_2, value); ak4396_write(chip, i, AK4396_CONTROL_2, value);
} }
...@@ -341,6 +349,7 @@ static const struct oxygen_model model_generic = { ...@@ -341,6 +349,7 @@ static const struct oxygen_model model_generic = {
.set_adc_params = set_wm8785_params, .set_adc_params = set_wm8785_params,
.update_dac_volume = update_ak4396_volume, .update_dac_volume = update_ak4396_volume,
.update_dac_mute = update_ak4396_mute, .update_dac_mute = update_ak4396_mute,
.model_data_size = sizeof(struct generic_data),
.used_channels = OXYGEN_CHANNEL_A | .used_channels = OXYGEN_CHANNEL_A |
OXYGEN_CHANNEL_C | OXYGEN_CHANNEL_C |
OXYGEN_CHANNEL_SPDIF | OXYGEN_CHANNEL_SPDIF |
...@@ -362,6 +371,7 @@ static const struct oxygen_model model_meridian = { ...@@ -362,6 +371,7 @@ static const struct oxygen_model model_meridian = {
.set_adc_params = set_ak5385_params, .set_adc_params = set_ak5385_params,
.update_dac_volume = update_ak4396_volume, .update_dac_volume = update_ak4396_volume,
.update_dac_mute = update_ak4396_mute, .update_dac_mute = update_ak4396_mute,
.model_data_size = sizeof(struct generic_data),
.used_channels = OXYGEN_CHANNEL_B | .used_channels = OXYGEN_CHANNEL_B |
OXYGEN_CHANNEL_C | OXYGEN_CHANNEL_C |
OXYGEN_CHANNEL_SPDIF | OXYGEN_CHANNEL_SPDIF |
......
...@@ -49,6 +49,7 @@ struct oxygen { ...@@ -49,6 +49,7 @@ struct oxygen {
struct snd_rawmidi *midi; struct snd_rawmidi *midi;
int irq; int irq;
const struct oxygen_model *model; const struct oxygen_model *model;
void *model_data;
unsigned int interrupt_mask; unsigned int interrupt_mask;
u8 dac_volume[8]; u8 dac_volume[8];
u8 dac_mute; u8 dac_mute;
...@@ -56,7 +57,6 @@ struct oxygen { ...@@ -56,7 +57,6 @@ struct oxygen {
u8 pcm_running; u8 pcm_running;
u8 dac_routing; u8 dac_routing;
u8 spdif_playback_enable; u8 spdif_playback_enable;
u8 ak4396_ctl2;
u8 revision; u8 revision;
u8 has_ac97_0; u8 has_ac97_0;
u8 has_ac97_1; u8 has_ac97_1;
...@@ -84,6 +84,7 @@ struct oxygen_model { ...@@ -84,6 +84,7 @@ struct oxygen_model {
struct snd_pcm_hw_params *params); struct snd_pcm_hw_params *params);
void (*update_dac_volume)(struct oxygen *chip); void (*update_dac_volume)(struct oxygen *chip);
void (*update_dac_mute)(struct oxygen *chip); void (*update_dac_mute)(struct oxygen *chip);
size_t model_data_size;
u8 used_channels; u8 used_channels;
u8 function_flags; u8 function_flags;
u16 dac_i2s_format; u16 dac_i2s_format;
......
...@@ -320,7 +320,8 @@ int __devinit oxygen_pci_probe(struct pci_dev *pci, int index, char *id, ...@@ -320,7 +320,8 @@ int __devinit oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
struct oxygen *chip; struct oxygen *chip;
int err; int err;
card = snd_card_new(index, id, model->owner, sizeof *chip); card = snd_card_new(index, id, model->owner,
sizeof *chip + model->model_data_size);
if (!card) if (!card)
return -ENOMEM; return -ENOMEM;
...@@ -329,6 +330,7 @@ int __devinit oxygen_pci_probe(struct pci_dev *pci, int index, char *id, ...@@ -329,6 +330,7 @@ int __devinit oxygen_pci_probe(struct pci_dev *pci, int index, char *id,
chip->pci = pci; chip->pci = pci;
chip->irq = -1; chip->irq = -1;
chip->model = model; chip->model = model;
chip->model_data = chip + 1;
spin_lock_init(&chip->reg_lock); spin_lock_init(&chip->reg_lock);
mutex_init(&chip->mutex); mutex_init(&chip->mutex);
INIT_WORK(&chip->spdif_input_bits_work, INIT_WORK(&chip->spdif_input_bits_work,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment