2019-05-27 09:55:05 +03:00
|
|
|
/* SPDX-License-Identifier: GPL-2.0-or-later */
|
2005-04-17 02:20:36 +04:00
|
|
|
/*
|
|
|
|
* Driver for PowerMac onboard soundchips
|
|
|
|
* Copyright (c) 2001 by Takashi Iwai <tiwai@suse.de>
|
|
|
|
* based on dmasound.c.
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __PMAC_H
|
|
|
|
#define __PMAC_H
|
|
|
|
|
|
|
|
#include <sound/control.h>
|
|
|
|
#include <sound/pcm.h>
|
|
|
|
#include "awacs.h"
|
|
|
|
|
|
|
|
#include <linux/adb.h>
|
|
|
|
#ifdef CONFIG_ADB_CUDA
|
|
|
|
#include <linux/cuda.h>
|
|
|
|
#endif
|
|
|
|
#ifdef CONFIG_ADB_PMU
|
|
|
|
#include <linux/pmu.h>
|
|
|
|
#endif
|
|
|
|
#include <linux/nvram.h>
|
|
|
|
#include <linux/tty.h>
|
|
|
|
#include <linux/vt_kern.h>
|
|
|
|
#include <asm/dbdma.h>
|
|
|
|
#include <asm/prom.h>
|
|
|
|
#include <asm/machdep.h>
|
2021-09-03 14:18:40 +03:00
|
|
|
#include <asm/pmac_feature.h>
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* maximum number of fragments */
|
|
|
|
#define PMAC_MAX_FRAGS 32
|
|
|
|
|
|
|
|
|
|
|
|
#define PMAC_SUPPORT_AUTOMUTE
|
|
|
|
|
|
|
|
/*
|
|
|
|
* DBDMA space
|
|
|
|
*/
|
2005-11-17 17:09:46 +03:00
|
|
|
struct pmac_dbdma {
|
[PATCH] ppc64: very basic desktop g5 sound support
This patch hacks the current PowerMac Alsa driver to add some basic support
of analog sound output to some desktop G5s. It has severe limitations
though:
- Only 44100Khz 16 bits
- Only work on G5 models using a TAS3004 analog code, that is early
single CPU desktops and all dual CPU desktops at this date, but none
of the more recent ones like iMac G5.
- It does analog only, no digital/SPDIF support at all, no native
AC3 support
Better support would require a complete rewrite of the driver (which I am
working on, but don't hold your breath), to properly support the diversity
of apple sound HW setup, including dual codecs, several i2s busses, all the
new codecs used in the new machines, proper clock switching with digital,
etc etc etc...
This patch applies on top of the other PowerMac sound patches I posted in
the past couple of days (new powerbook support and sleep fixes).
Note: This is a FAQ entry for PowerMac sound support with TI codecs: They
have a feature called "DRC" which is automatically enabled for the internal
speaker (at least when auto mute control is enabled) which will cause your
sound to fade out to nothing after half a second of playback if you don't
set a proper "DRC Range" in the mixer. So if you have a problem like that,
check alsamixer and raise your DRC Range to something reasonable.
Note2: This patch will also add auto-mute of the speaker when line-out jack
is used on some earlier desktop G4s (and on the G5) in addition to the
headphone jack. If that behaviour isn't what you want, just disable
auto-muting and use the manual mute controls in alsamixer.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-17 02:24:32 +04:00
|
|
|
dma_addr_t dma_base;
|
|
|
|
dma_addr_t addr;
|
2005-04-17 02:20:36 +04:00
|
|
|
struct dbdma_cmd __iomem *cmds;
|
|
|
|
void *space;
|
|
|
|
int size;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* playback/capture stream
|
|
|
|
*/
|
2005-11-17 17:09:46 +03:00
|
|
|
struct pmac_stream {
|
2005-04-17 02:20:36 +04:00
|
|
|
int running; /* boolean */
|
|
|
|
|
|
|
|
int stream; /* PLAYBACK/CAPTURE */
|
|
|
|
|
|
|
|
int dma_size; /* in bytes */
|
|
|
|
int period_size; /* in bytes */
|
|
|
|
int buffer_size; /* in kbytes */
|
|
|
|
int nperiods, cur_period;
|
|
|
|
|
2005-11-17 17:09:46 +03:00
|
|
|
struct pmac_dbdma cmd;
|
2005-04-17 02:20:36 +04:00
|
|
|
volatile struct dbdma_regs __iomem *dma;
|
|
|
|
|
2005-11-17 17:09:46 +03:00
|
|
|
struct snd_pcm_substream *substream;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
unsigned int cur_freqs; /* currently available frequencies */
|
|
|
|
unsigned int cur_formats; /* currently available formats */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
*/
|
|
|
|
|
|
|
|
enum snd_pmac_model {
|
2005-05-01 19:58:43 +04:00
|
|
|
PMAC_AWACS, PMAC_SCREAMER, PMAC_BURGUNDY, PMAC_DACA, PMAC_TUMBLER,
|
2006-06-21 17:43:44 +04:00
|
|
|
PMAC_SNAPPER
|
2005-04-17 02:20:36 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
struct snd_pmac {
|
2005-11-17 17:09:46 +03:00
|
|
|
struct snd_card *card;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* h/w info */
|
|
|
|
struct device_node *node;
|
[PATCH] ppc64: very basic desktop g5 sound support
This patch hacks the current PowerMac Alsa driver to add some basic support
of analog sound output to some desktop G5s. It has severe limitations
though:
- Only 44100Khz 16 bits
- Only work on G5 models using a TAS3004 analog code, that is early
single CPU desktops and all dual CPU desktops at this date, but none
of the more recent ones like iMac G5.
- It does analog only, no digital/SPDIF support at all, no native
AC3 support
Better support would require a complete rewrite of the driver (which I am
working on, but don't hold your breath), to properly support the diversity
of apple sound HW setup, including dual codecs, several i2s busses, all the
new codecs used in the new machines, proper clock switching with digital,
etc etc etc...
This patch applies on top of the other PowerMac sound patches I posted in
the past couple of days (new powerbook support and sleep fixes).
Note: This is a FAQ entry for PowerMac sound support with TI codecs: They
have a feature called "DRC" which is automatically enabled for the internal
speaker (at least when auto mute control is enabled) which will cause your
sound to fade out to nothing after half a second of playback if you don't
set a proper "DRC Range" in the mixer. So if you have a problem like that,
check alsamixer and raise your DRC Range to something reasonable.
Note2: This patch will also add auto-mute of the speaker when line-out jack
is used on some earlier desktop G4s (and on the G5) in addition to the
headphone jack. If that behaviour isn't what you want, just disable
auto-muting and use the manual mute controls in alsamixer.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-17 02:24:32 +04:00
|
|
|
struct pci_dev *pdev;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int revision;
|
|
|
|
unsigned int manufacturer;
|
|
|
|
unsigned int subframe;
|
|
|
|
unsigned int device_id;
|
|
|
|
enum snd_pmac_model model;
|
|
|
|
|
|
|
|
unsigned int has_iic : 1;
|
|
|
|
unsigned int is_pbook_3400 : 1;
|
|
|
|
unsigned int is_pbook_G3 : 1;
|
[PATCH] ppc64: very basic desktop g5 sound support
This patch hacks the current PowerMac Alsa driver to add some basic support
of analog sound output to some desktop G5s. It has severe limitations
though:
- Only 44100Khz 16 bits
- Only work on G5 models using a TAS3004 analog code, that is early
single CPU desktops and all dual CPU desktops at this date, but none
of the more recent ones like iMac G5.
- It does analog only, no digital/SPDIF support at all, no native
AC3 support
Better support would require a complete rewrite of the driver (which I am
working on, but don't hold your breath), to properly support the diversity
of apple sound HW setup, including dual codecs, several i2s busses, all the
new codecs used in the new machines, proper clock switching with digital,
etc etc etc...
This patch applies on top of the other PowerMac sound patches I posted in
the past couple of days (new powerbook support and sleep fixes).
Note: This is a FAQ entry for PowerMac sound support with TI codecs: They
have a feature called "DRC" which is automatically enabled for the internal
speaker (at least when auto mute control is enabled) which will cause your
sound to fade out to nothing after half a second of playback if you don't
set a proper "DRC Range" in the mixer. So if you have a problem like that,
check alsamixer and raise your DRC Range to something reasonable.
Note2: This patch will also add auto-mute of the speaker when line-out jack
is used on some earlier desktop G4s (and on the G5) in addition to the
headphone jack. If that behaviour isn't what you want, just disable
auto-muting and use the manual mute controls in alsamixer.
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Signed-off-by: Andrew Morton <akpm@osdl.org>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
2005-04-17 02:24:32 +04:00
|
|
|
unsigned int is_k2 : 1;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
unsigned int can_byte_swap : 1;
|
|
|
|
unsigned int can_duplex : 1;
|
|
|
|
unsigned int can_capture : 1;
|
|
|
|
|
|
|
|
unsigned int auto_mute : 1;
|
|
|
|
unsigned int initialized : 1;
|
|
|
|
unsigned int feature_is_set : 1;
|
|
|
|
|
2005-12-13 10:01:21 +03:00
|
|
|
unsigned int requested;
|
|
|
|
struct resource rsrc[3];
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
int num_freqs;
|
2020-01-05 17:47:32 +03:00
|
|
|
const int *freq_table;
|
2005-04-17 02:20:36 +04:00
|
|
|
unsigned int freqs_ok; /* bit flags */
|
|
|
|
unsigned int formats_ok; /* pcm hwinfo */
|
|
|
|
int active;
|
|
|
|
int rate_index;
|
|
|
|
int format; /* current format */
|
|
|
|
|
|
|
|
spinlock_t reg_lock;
|
|
|
|
volatile struct awacs_regs __iomem *awacs;
|
|
|
|
int awacs_reg[8]; /* register cache */
|
|
|
|
unsigned int hp_stat_mask;
|
|
|
|
|
|
|
|
unsigned char __iomem *latch_base;
|
|
|
|
unsigned char __iomem *macio_base;
|
|
|
|
|
2005-11-17 17:09:46 +03:00
|
|
|
struct pmac_stream playback;
|
|
|
|
struct pmac_stream capture;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-11-17 17:09:46 +03:00
|
|
|
struct pmac_dbdma extra_dma;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
int irq, tx_irq, rx_irq;
|
|
|
|
|
2005-11-17 17:09:46 +03:00
|
|
|
struct snd_pcm *pcm;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-11-17 17:09:46 +03:00
|
|
|
struct pmac_beep *beep;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
unsigned int control_mask; /* control mask */
|
|
|
|
|
|
|
|
/* mixer stuffs */
|
|
|
|
void *mixer_data;
|
2005-11-17 17:09:46 +03:00
|
|
|
void (*mixer_free)(struct snd_pmac *);
|
|
|
|
struct snd_kcontrol *master_sw_ctl;
|
|
|
|
struct snd_kcontrol *speaker_sw_ctl;
|
|
|
|
struct snd_kcontrol *drc_sw_ctl; /* only used for tumbler -ReneR */
|
|
|
|
struct snd_kcontrol *hp_detect_ctl;
|
|
|
|
struct snd_kcontrol *lineout_sw_ctl;
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* lowlevel callbacks */
|
2005-11-17 17:09:46 +03:00
|
|
|
void (*set_format)(struct snd_pmac *chip);
|
|
|
|
void (*update_automute)(struct snd_pmac *chip, int do_notify);
|
|
|
|
int (*detect_headphone)(struct snd_pmac *chip);
|
2005-06-28 01:36:34 +04:00
|
|
|
#ifdef CONFIG_PM
|
2005-11-17 17:09:46 +03:00
|
|
|
void (*suspend)(struct snd_pmac *chip);
|
|
|
|
void (*resume)(struct snd_pmac *chip);
|
2005-04-17 02:20:36 +04:00
|
|
|
#endif
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
/* exported functions */
|
2005-11-17 17:09:46 +03:00
|
|
|
int snd_pmac_new(struct snd_card *card, struct snd_pmac **chip_return);
|
|
|
|
int snd_pmac_pcm_new(struct snd_pmac *chip);
|
|
|
|
int snd_pmac_attach_beep(struct snd_pmac *chip);
|
|
|
|
void snd_pmac_detach_beep(struct snd_pmac *chip);
|
|
|
|
void snd_pmac_beep_stop(struct snd_pmac *chip);
|
|
|
|
unsigned int snd_pmac_rate_index(struct snd_pmac *chip, struct pmac_stream *rec, unsigned int rate);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-11-17 17:09:46 +03:00
|
|
|
void snd_pmac_beep_dma_start(struct snd_pmac *chip, int bytes, unsigned long addr, int speed);
|
|
|
|
void snd_pmac_beep_dma_stop(struct snd_pmac *chip);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-11-17 19:17:08 +03:00
|
|
|
#ifdef CONFIG_PM
|
|
|
|
void snd_pmac_suspend(struct snd_pmac *chip);
|
|
|
|
void snd_pmac_resume(struct snd_pmac *chip);
|
|
|
|
#endif
|
|
|
|
|
2005-04-17 02:20:36 +04:00
|
|
|
/* initialize mixer */
|
2005-11-17 17:09:46 +03:00
|
|
|
int snd_pmac_awacs_init(struct snd_pmac *chip);
|
|
|
|
int snd_pmac_burgundy_init(struct snd_pmac *chip);
|
|
|
|
int snd_pmac_daca_init(struct snd_pmac *chip);
|
|
|
|
int snd_pmac_tumbler_init(struct snd_pmac *chip);
|
2005-04-17 02:20:36 +04:00
|
|
|
int snd_pmac_tumbler_post_init(void);
|
|
|
|
|
|
|
|
/* i2c functions */
|
2005-11-17 17:09:46 +03:00
|
|
|
struct pmac_keywest {
|
2005-04-17 02:20:36 +04:00
|
|
|
int addr;
|
|
|
|
struct i2c_client *client;
|
|
|
|
int id;
|
2005-11-17 17:09:46 +03:00
|
|
|
int (*init_client)(struct pmac_keywest *i2c);
|
2005-04-17 02:20:36 +04:00
|
|
|
char *name;
|
2005-11-17 17:09:46 +03:00
|
|
|
};
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-11-17 17:09:46 +03:00
|
|
|
int snd_pmac_keywest_init(struct pmac_keywest *i2c);
|
|
|
|
void snd_pmac_keywest_cleanup(struct pmac_keywest *i2c);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
/* misc */
|
2007-07-23 17:42:26 +04:00
|
|
|
#define snd_pmac_boolean_stereo_info snd_ctl_boolean_stereo_info
|
|
|
|
#define snd_pmac_boolean_mono_info snd_ctl_boolean_mono_info
|
2005-04-17 02:20:36 +04:00
|
|
|
|
2005-11-17 17:09:46 +03:00
|
|
|
int snd_pmac_add_automute(struct snd_pmac *chip);
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
#endif /* __PMAC_H */
|