From c1e12d920074b82dfca2b1c1c50176bc94629593 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Thu, 16 Aug 2007 14:38:46 -0700 Subject: compat: ALSA compat code From: Trent Piepho Removed some ALSA compat code from bt87x and put it into compat.h, then use this code in cx88-alsa and saa7134-alsa to avoid lots and lots of #ifs. All the kernel version checks in cx88-alsa and saa7134 were off by one too, which is now fixed. Signed-off-by: Trent Piepho --- linux/drivers/media/video/cx88/cx88-alsa.c | 94 ------------------ linux/drivers/media/video/saa7134/saa7134-alsa.c | 115 +---------------------- linux/sound/pci/bt87x.c | 17 ---- v4l/compat.h | 26 +++++ 4 files changed, 27 insertions(+), 225 deletions(-) diff --git a/linux/drivers/media/video/cx88/cx88-alsa.c b/linux/drivers/media/video/cx88/cx88-alsa.c index a2d0abae6..bf5477afa 100644 --- a/linux/drivers/media/video/cx88/cx88-alsa.c +++ b/linux/drivers/media/video/cx88/cx88-alsa.c @@ -66,11 +66,7 @@ struct cx88_audio_dev { /* audio controls */ int irq; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_card_t *card; -#else struct snd_card *card; -#endif spinlock_t reg_lock; @@ -89,11 +85,7 @@ struct cx88_audio_dev { struct cx88_buffer *buf; long opened; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_substream_t *substream; -#else struct snd_pcm_substream *substream; -#endif }; typedef struct cx88_audio_dev snd_cx88_card_t; @@ -110,11 +102,7 @@ typedef struct cx88_audio_dev snd_cx88_card_t; static int index[SNDRV_CARDS] = SNDRV_DEFAULT_IDX; /* Index 0-MAX */ static char *id[SNDRV_CARDS] = SNDRV_DEFAULT_STR; /* ID for this card */ static int enable[SNDRV_CARDS] = {1, [1 ... (SNDRV_CARDS - 1)] = 1}; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_card_t *snd_cx88_cards[SNDRV_CARDS]; -#else static struct snd_card *snd_cx88_cards[SNDRV_CARDS]; -#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,10) static unsigned int dummy; @@ -352,11 +340,7 @@ static int dsp_buffer_free(snd_cx88_card_t *chip) /* * Digital hardware definition */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_pcm_hardware_t snd_cx88_digital_hw = { -#else static struct snd_pcm_hardware snd_cx88_digital_hw = { -#endif .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -378,28 +362,16 @@ static struct snd_pcm_hardware snd_cx88_digital_hw = { /* * audio pcm capture runtime free */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static void snd_card_cx88_runtime_free(snd_pcm_runtime_t *runtime) -#else static void snd_card_cx88_runtime_free(struct snd_pcm_runtime *runtime) -#endif { } /* * audio pcm capture open callback */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_cx88_pcm_open(snd_pcm_substream_t *substream) -#else static int snd_cx88_pcm_open(struct snd_pcm_substream *substream) -#endif { snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_runtime_t *runtime = substream->runtime; -#else struct snd_pcm_runtime *runtime = substream->runtime; -#endif int err; if (test_and_set_bit(0, &chip->opened)) @@ -428,11 +400,7 @@ _error: /* * audio close callback */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_cx88_close(snd_pcm_substream_t *substream) -#else static int snd_cx88_close(struct snd_pcm_substream *substream) -#endif { snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); @@ -445,13 +413,8 @@ static int snd_cx88_close(struct snd_pcm_substream *substream) /* * hw_params callback */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_cx88_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) -#else static int snd_cx88_hw_params(struct snd_pcm_substream * substream, struct snd_pcm_hw_params * hw_params) -#endif { snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); struct cx88_buffer *buf; @@ -508,11 +471,7 @@ static int snd_cx88_hw_params(struct snd_pcm_substream * substream, /* * hw free callback */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_cx88_hw_free(snd_pcm_substream_t * substream) -#else static int snd_cx88_hw_free(struct snd_pcm_substream * substream) -#endif { snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); @@ -528,11 +487,7 @@ static int snd_cx88_hw_free(struct snd_pcm_substream * substream) /* * prepare callback */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_cx88_prepare(snd_pcm_substream_t *substream) -#else static int snd_cx88_prepare(struct snd_pcm_substream *substream) -#endif { return 0; } @@ -541,11 +496,7 @@ static int snd_cx88_prepare(struct snd_pcm_substream *substream) /* * trigger callback */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_cx88_card_trigger(snd_pcm_substream_t *substream, int cmd) -#else static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd) -#endif { snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); int err; @@ -572,18 +523,10 @@ static int snd_cx88_card_trigger(struct snd_pcm_substream *substream, int cmd) /* * pointer callback */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_pcm_uframes_t snd_cx88_pointer(snd_pcm_substream_t *substream) -#else static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream) -#endif { snd_cx88_card_t *chip = snd_pcm_substream_chip(substream); -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_runtime_t *runtime = substream->runtime; -#else struct snd_pcm_runtime *runtime = substream->runtime; -#endif if (chip->read_count) { chip->read_count -= snd_pcm_lib_period_bytes(substream); @@ -600,11 +543,7 @@ static snd_pcm_uframes_t snd_cx88_pointer(struct snd_pcm_substream *substream) /* * operators */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_pcm_ops_t snd_cx88_pcm_ops = { -#else static struct snd_pcm_ops snd_cx88_pcm_ops = { -#endif .open = snd_cx88_pcm_open, .close = snd_cx88_close, .ioctl = snd_pcm_lib_ioctl, @@ -621,11 +560,7 @@ static struct snd_pcm_ops snd_cx88_pcm_ops = { static int __devinit snd_cx88_pcm(snd_cx88_card_t *chip, int device, char *name) { int err; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_t *pcm; -#else struct snd_pcm *pcm; -#endif err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm); if (err < 0) @@ -640,12 +575,8 @@ static int __devinit snd_cx88_pcm(snd_cx88_card_t *chip, int device, char *name) /**************************************************************************** CONTROL INTERFACE ****************************************************************************/ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_cx88_capture_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) -#else static int snd_cx88_capture_volume_info(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_info *info) -#endif { info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; info->count = 1; @@ -656,12 +587,8 @@ static int snd_cx88_capture_volume_info(struct snd_kcontrol *kcontrol, } /* OK - TODO: test it */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_cx88_capture_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) -#else static int snd_cx88_capture_volume_get(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *value) -#endif { snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_core *core=chip->core; @@ -672,12 +599,8 @@ static int snd_cx88_capture_volume_get(struct snd_kcontrol *kcontrol, } /* OK - TODO: test it */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_cx88_capture_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) -#else static int snd_cx88_capture_volume_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *value) -#endif { snd_cx88_card_t *chip = snd_kcontrol_chip(kcontrol); struct cx88_core *core=chip->core; @@ -693,11 +616,7 @@ static int snd_cx88_capture_volume_put(struct snd_kcontrol *kcontrol, return v != old_control; } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_kcontrol_new_t snd_cx88_capture_volume = { -#else static struct snd_kcontrol_new snd_cx88_capture_volume = { -#endif .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Volume", .info = snd_cx88_capture_volume_info, @@ -743,11 +662,7 @@ static int snd_cx88_free(snd_cx88_card_t *chip) /* * Component Destructor */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static void snd_cx88_dev_free(snd_card_t * card) -#else static void snd_cx88_dev_free(struct snd_card * card) -#endif { snd_cx88_card_t *chip = card->private_data; @@ -760,14 +675,9 @@ static void snd_cx88_dev_free(struct snd_card * card) */ static int devno; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int __devinit snd_cx88_create(snd_card_t *card, struct pci_dev *pci, - snd_cx88_card_t **rchip) -#else static int __devinit snd_cx88_create(struct snd_card *card, struct pci_dev *pci, snd_cx88_card_t **rchip) -#endif { snd_cx88_card_t *chip; struct cx88_core *core; @@ -837,11 +747,7 @@ static int __devinit snd_cx88_create(struct snd_card *card, static int __devinit cx88_audio_initdev(struct pci_dev *pci, const struct pci_device_id *pci_id) { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_card_t *card; -#else struct snd_card *card; -#endif snd_cx88_card_t *chip; int err; diff --git a/linux/drivers/media/video/saa7134/saa7134-alsa.c b/linux/drivers/media/video/saa7134/saa7134-alsa.c index 13916f207..aeedf3eec 100644 --- a/linux/drivers/media/video/saa7134/saa7134-alsa.c +++ b/linux/drivers/media/video/saa7134/saa7134-alsa.c @@ -74,11 +74,7 @@ MODULE_PARM_DESC(enable, "Enable (or not) the SAA7134 capture interface(s)."); */ typedef struct snd_card_saa7134 { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_card_t *card; -#else struct snd_card *card; -#endif spinlock_t mixer_lock; int mixer_volume[MIXER_ADDR_LAST+1][2]; int capture_source[MIXER_ADDR_LAST+1][2]; @@ -106,18 +102,10 @@ typedef struct snd_card_saa7134_pcm { spinlock_t lock; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_substream_t *substream; -#else struct snd_pcm_substream *substream; -#endif } snd_card_saa7134_pcm_t; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_card_t *snd_saa7134_cards[SNDRV_CARDS]; -#else static struct snd_card *snd_saa7134_cards[SNDRV_CARDS]; -#endif /* @@ -274,18 +262,10 @@ out: * */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_card_saa7134_capture_trigger(snd_pcm_substream_t * substream, -#else static int snd_card_saa7134_capture_trigger(struct snd_pcm_substream * substream, -#endif - int cmd) + int cmd) { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_runtime_t *runtime = substream->runtime; -#else struct snd_pcm_runtime *runtime = substream->runtime; -#endif snd_card_saa7134_pcm_t *pcm = runtime->private_data; struct saa7134_dev *dev=pcm->dev; int err = 0; @@ -363,17 +343,9 @@ static int dsp_buffer_free(struct saa7134_dev *dev) * */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_card_saa7134_capture_prepare(snd_pcm_substream_t * substream) -#else static int snd_card_saa7134_capture_prepare(struct snd_pcm_substream * substream) -#endif { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_runtime_t *runtime = substream->runtime; -#else struct snd_pcm_runtime *runtime = substream->runtime; -#endif int bswap, sign; u32 fmt, control; snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); @@ -460,18 +432,10 @@ static int snd_card_saa7134_capture_prepare(struct snd_pcm_substream * substream * */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(snd_pcm_substream_t * substream) -#else static snd_pcm_uframes_t snd_card_saa7134_capture_pointer(struct snd_pcm_substream * substream) -#endif { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_runtime_t *runtime = substream->runtime; -#else struct snd_pcm_runtime *runtime = substream->runtime; -#endif snd_card_saa7134_pcm_t *pcm = runtime->private_data; struct saa7134_dev *dev=pcm->dev; @@ -489,11 +453,7 @@ snd_card_saa7134_capture_pointer(struct snd_pcm_substream * substream) * ALSA hardware capabilities definition */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_pcm_hardware_t snd_card_saa7134_capture = -#else static struct snd_pcm_hardware snd_card_saa7134_capture = -#endif { .info = (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -516,11 +476,7 @@ static struct snd_pcm_hardware snd_card_saa7134_capture = .periods_max = 1024, }; -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static void snd_card_saa7134_runtime_free(snd_pcm_runtime_t *runtime) -#else static void snd_card_saa7134_runtime_free(struct snd_pcm_runtime *runtime) -#endif { snd_card_saa7134_pcm_t *pcm = runtime->private_data; @@ -537,13 +493,8 @@ static void snd_card_saa7134_runtime_free(struct snd_pcm_runtime *runtime) * */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_card_saa7134_hw_params(snd_pcm_substream_t * substream, - snd_pcm_hw_params_t * hw_params) -#else static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream, struct snd_pcm_hw_params * hw_params) -#endif { snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); struct saa7134_dev *dev; @@ -622,11 +573,7 @@ static int snd_card_saa7134_hw_params(struct snd_pcm_substream * substream, * */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_card_saa7134_hw_free(snd_pcm_substream_t * substream) -#else static int snd_card_saa7134_hw_free(struct snd_pcm_substream * substream) -#endif { snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); struct saa7134_dev *dev; @@ -652,11 +599,7 @@ static int snd_card_saa7134_hw_free(struct snd_pcm_substream * substream) * */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_card_saa7134_capture_close(snd_pcm_substream_t * substream) -#else static int snd_card_saa7134_capture_close(struct snd_pcm_substream * substream) -#endif { snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); struct saa7134_dev *dev = saa7134->dev; @@ -678,17 +621,9 @@ static int snd_card_saa7134_capture_close(struct snd_pcm_substream * substream) * */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_card_saa7134_capture_open(snd_pcm_substream_t * substream) -#else static int snd_card_saa7134_capture_open(struct snd_pcm_substream * substream) -#endif { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_runtime_t *runtime = substream->runtime; -#else struct snd_pcm_runtime *runtime = substream->runtime; -#endif snd_card_saa7134_pcm_t *pcm; snd_card_saa7134_t *saa7134 = snd_pcm_substream_chip(substream); struct saa7134_dev *dev = saa7134->dev; @@ -735,11 +670,7 @@ static int snd_card_saa7134_capture_open(struct snd_pcm_substream * substream) * ALSA capture callbacks definition */ -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_pcm_ops_t snd_card_saa7134_capture_ops = { -#else static struct snd_pcm_ops snd_card_saa7134_capture_ops = { -#endif .open = snd_card_saa7134_capture_open, .close = snd_card_saa7134_capture_close, .ioctl = snd_pcm_lib_ioctl, @@ -760,11 +691,7 @@ static struct snd_pcm_ops snd_card_saa7134_capture_ops = { static int snd_card_saa7134_pcm(snd_card_saa7134_t *saa7134, int device) { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_pcm_t *pcm; -#else struct snd_pcm *pcm; -#endif int err; if ((err = snd_pcm_new(saa7134->card, "SAA7134 PCM", device, 0, 1, &pcm)) < 0) @@ -782,12 +709,8 @@ static int snd_card_saa7134_pcm(snd_card_saa7134_t *saa7134, int device) .get = snd_saa7134_volume_get, .put = snd_saa7134_volume_put, \ .private_value = addr } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_saa7134_volume_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) -#else static int snd_saa7134_volume_info(struct snd_kcontrol * kcontrol, struct snd_ctl_elem_info * uinfo) -#endif { uinfo->type = SNDRV_CTL_ELEM_TYPE_INTEGER; uinfo->count = 2; @@ -796,12 +719,8 @@ static int snd_saa7134_volume_info(struct snd_kcontrol * kcontrol, return 0; } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_saa7134_volume_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) -#else static int snd_saa7134_volume_get(struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol) -#endif { snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); int addr = kcontrol->private_value; @@ -811,12 +730,8 @@ static int snd_saa7134_volume_get(struct snd_kcontrol * kcontrol, return 0; } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_saa7134_volume_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) -#else static int snd_saa7134_volume_put(struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol) -#endif { snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); struct saa7134_dev *dev = chip->dev; @@ -891,12 +806,8 @@ static int snd_saa7134_volume_put(struct snd_kcontrol * kcontrol, .get = snd_saa7134_capsrc_get, .put = snd_saa7134_capsrc_put, \ .private_value = addr } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_saa7134_capsrc_info(snd_kcontrol_t * kcontrol, snd_ctl_elem_info_t * uinfo) -#else static int snd_saa7134_capsrc_info(struct snd_kcontrol * kcontrol, struct snd_ctl_elem_info * uinfo) -#endif { uinfo->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; uinfo->count = 2; @@ -905,12 +816,8 @@ static int snd_saa7134_capsrc_info(struct snd_kcontrol * kcontrol, return 0; } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_saa7134_capsrc_get(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) -#else static int snd_saa7134_capsrc_get(struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol) -#endif { snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); int addr = kcontrol->private_value; @@ -923,12 +830,8 @@ static int snd_saa7134_capsrc_get(struct snd_kcontrol * kcontrol, return 0; } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static int snd_saa7134_capsrc_put(snd_kcontrol_t * kcontrol, snd_ctl_elem_value_t * ucontrol) -#else static int snd_saa7134_capsrc_put(struct snd_kcontrol * kcontrol, struct snd_ctl_elem_value * ucontrol) -#endif { snd_card_saa7134_t *chip = snd_kcontrol_chip(kcontrol); int change, addr = kcontrol->private_value; @@ -1005,11 +908,7 @@ static int snd_saa7134_capsrc_put(struct snd_kcontrol * kcontrol, return change; } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static snd_kcontrol_new_t snd_saa7134_controls[] = { -#else static struct snd_kcontrol_new snd_saa7134_controls[] = { -#endif SAA713x_VOLUME("Video Volume", 0, MIXER_ADDR_TVTUNER), SAA713x_CAPSRC("Video Capture Switch", 0, MIXER_ADDR_TVTUNER), SAA713x_VOLUME("Line Volume", 1, MIXER_ADDR_LINE1), @@ -1028,11 +927,7 @@ SAA713x_CAPSRC("Line Capture Switch", 2, MIXER_ADDR_LINE2), static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip) { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_card_t *card = chip->card; -#else struct snd_card *card = chip->card; -#endif unsigned int idx; int err; @@ -1046,11 +941,7 @@ static int snd_card_saa7134_new_mixer(snd_card_saa7134_t * chip) return 0; } -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) -static void snd_saa7134_free(snd_card_t * card) -#else static void snd_saa7134_free(struct snd_card * card) -#endif { snd_card_saa7134_t *chip = card->private_data; @@ -1077,11 +968,7 @@ static void snd_saa7134_free(struct snd_card * card) static int alsa_card_saa7134_create(struct saa7134_dev *dev, int devnum) { -#if LINUX_VERSION_CODE <= KERNEL_VERSION(2,6,16) - snd_card_t *card; -#else struct snd_card *card; -#endif snd_card_saa7134_t *chip; int err; diff --git a/linux/sound/pci/bt87x.c b/linux/sound/pci/bt87x.c index cbbd22b4a..a6e7971e3 100644 --- a/linux/sound/pci/bt87x.c +++ b/linux/sound/pci/bt87x.c @@ -35,23 +35,6 @@ #include #include #include "compat.h" -#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) -/* structs that used to be typedefs */ -#define snd_card _snd_card -#define snd_pcm _snd_pcm -#define snd_pcm_substream _snd_pcm_substream -#define snd_pcm_hardware _snd_pcm_hardware -#define snd_pcm_runtime _snd_pcm_runtime -#define snd_pcm_hw_params sndrv_pcm_hw_params -#define snd_pcm_ops _snd_pcm_ops -#define snd_ctl_elem_info sndrv_ctl_elem_info -#define snd_ctl_elem_value sndrv_ctl_elem_value -#undef snd_kcontrol -#define snd_kcontrol _snd_kcontrol -#define snd_kcontrol_new _snd_kcontrol_new -#undef snd_device -#define snd_device _snd_device -#endif #if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,14) /* From linux/pch_ids.h, appeared in 2.6.14 */ #define PCI_DEVICE_ID_BROOKTREE_879 0x0879 diff --git a/v4l/compat.h b/v4l/compat.h index 1162dadac..3910ae2aa 100644 --- a/v4l/compat.h +++ b/v4l/compat.h @@ -399,6 +399,32 @@ static inline u8 v4l_compat_pci_rev(struct pci_dev *pci) { u8 rev; pci_read_config_byte(pci, PCI_REVISION_ID, &rev); return rev; } #endif +/* ALSA removed a bunch of typedefs and renamed some structs in 2.6.16 */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,16) +# ifdef __SOUND_CORE_H +# define snd_card _snd_card /* struct _snd_card became struct snd_card */ +# define snd_pcm _snd_pcm +# undef snd_device +# define snd_device _snd_device +# endif +# ifdef __SOUND_PCM_H +# define snd_pcm_substream _snd_pcm_substream +# define snd_pcm_hardware _snd_pcm_hardware +# define snd_pcm_runtime _snd_pcm_runtime +# define snd_pcm_ops _snd_pcm_ops +# endif +# ifdef __SOUND_ASOUND_H +# define snd_pcm_hw_params sndrv_pcm_hw_params +# define snd_ctl_elem_info sndrv_ctl_elem_info +# define snd_ctl_elem_value sndrv_ctl_elem_value +# endif +# ifdef __SOUND_CONTROL_H +# undef snd_kcontrol +# define snd_kcontrol _snd_kcontrol +# define snd_kcontrol_new _snd_kcontrol_new +# endif +#endif + #endif /* * Local variables: -- cgit v1.2.3 From 64137fed722bbfcf5d708511972690fe23189ff8 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Thu, 16 Aug 2007 15:23:20 -0700 Subject: compat: Add missing compat.h From: Trent Piepho dvb_ca_en50221.c and dvb-pll.c were missing compat.h, and they used kzalloc which is something that compat.h takes care of. Signed-off-by: Trent Piepho --- linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c | 1 + linux/drivers/media/dvb/frontends/dvb-pll.c | 1 + 2 files changed, 2 insertions(+) diff --git a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c index 4fadddb26..423eaeb03 100644 --- a/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c +++ b/linux/drivers/media/dvb/dvb-core/dvb_ca_en50221.c @@ -37,6 +37,7 @@ #include #include #include +#include "compat.h" #include "dvb_ca_en50221.h" #include "dvb_ringbuffer.h" diff --git a/linux/drivers/media/dvb/frontends/dvb-pll.c b/linux/drivers/media/dvb/frontends/dvb-pll.c index 11f7d5939..2ea254570 100644 --- a/linux/drivers/media/dvb/frontends/dvb-pll.c +++ b/linux/drivers/media/dvb/frontends/dvb-pll.c @@ -21,6 +21,7 @@ #include #include #include +#include "compat.h" #include "dvb-pll.h" -- cgit v1.2.3 From 4fefe837f00fab3129d41139be8a0e327cfdb496 Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Fri, 17 Aug 2007 01:50:22 -0700 Subject: cx88: Add parameter to control radio deemphasis time constant From: Trent Piepho FM radio transmission use a preemphasis/deemphasis scheme to reduce high-frequency noise. The cx88 audio decoder is supposedly set to no deemphasis by the current driver. However, the "no deemphasis" setting doesn't work. On my chip, cx23883, it produces the same result as the 75 us time constant. Maybe the default settings on the cx23881 are for 50 us? Since the deemphasis time constant varies by country, allow setting it via a module parameter. Signed-off-by: Trent Piepho --- linux/drivers/media/video/cx88/cx88-tvaudio.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/linux/drivers/media/video/cx88/cx88-tvaudio.c b/linux/drivers/media/video/cx88/cx88-tvaudio.c index 1060f4815..460ae4082 100644 --- a/linux/drivers/media/video/cx88/cx88-tvaudio.c +++ b/linux/drivers/media/video/cx88/cx88-tvaudio.c @@ -68,6 +68,10 @@ static unsigned int always_analog = 0; module_param(always_analog,int,0644); MODULE_PARM_DESC(always_analog,"force analog audio out"); +static unsigned int radio_deemphasis = 0; +module_param(radio_deemphasis,int,0644); +MODULE_PARM_DESC(radio_deemphasis, "Radio deemphasis time constant, " + "0=None, 1=50us (elsewhere), 2=75us (USA)"); #define dprintk(fmt, arg...) if (audio_debug) \ printk(KERN_DEBUG "%s/0: " fmt, core->name , ## arg) @@ -684,6 +688,10 @@ static void set_audio_standard_FM(struct cx88_core *core, }; /* It is enough to leave default values? */ + /* No, it's not! The deemphasis registers are reset to the 75us + * values by default. Analyzing the spectrum of the decoded audio + * reveals that "no deemphasis" is the same as 75 us, while the 50 us + * setting results in less deemphasis. */ static const struct rlist fm_no_deemph[] = { {AUD_POLYPH80SCALEFAC, 0x0003}, @@ -694,6 +702,7 @@ static void set_audio_standard_FM(struct cx88_core *core, set_audio_start(core, SEL_FMRADIO); switch (deemph) { + default: case FM_NO_DEEMPH: set_audio_registers(core, fm_no_deemph); break; @@ -763,7 +772,7 @@ void cx88_set_tvaudio(struct cx88_core *core) set_audio_standard_EIAJ(core); break; case WW_FM: - set_audio_standard_FM(core, FM_NO_DEEMPH); + set_audio_standard_FM(core, radio_deemphasis); break; case WW_NONE: default: -- cgit v1.2.3 From f2ead120937d5077a260732019a12e6ed6c6752e Mon Sep 17 00:00:00 2001 From: Trent Piepho Date: Fri, 17 Aug 2007 12:38:05 -0700 Subject: compat: Fix device_create compat code From: Trent Piepho The current compat code for device_create/destroy doesn't work properly for kernels 2.6.14 or below, and 2.6.18 to 2.6.23. For kernels 2.6.14 and below, the device_create/destroy compat code wasn't enabled. Those kernels need it too. For kernels 2.6.18 to 2.6.23, compat code _was_ getting including, which caused errors since 2.6.18 and above already have device_create and device_destroy. Signed-off-by: Trent Piepho --- linux/drivers/media/dvb/dvb-core/dvbdev.c | 2 +- v4l/compat.h | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/linux/drivers/media/dvb/dvb-core/dvbdev.c b/linux/drivers/media/dvb/dvb-core/dvbdev.c index 564c57b79..b4165ddb3 100644 --- a/linux/drivers/media/dvb/dvb-core/dvbdev.c +++ b/linux/drivers/media/dvb/dvb-core/dvbdev.c @@ -211,7 +211,7 @@ int dvb_register_device(struct dvb_adapter *adap, struct dvb_device **pdvbdev, { struct dvb_device *dvbdev; struct file_operations *dvbdevfops; -#if LINUX_VERSION_CODE > KERNEL_VERSION(2,6,23) +#if LINUX_VERSION_CODE >= KERNEL_VERSION(2,6,18) struct device *clsdev; #else struct class_device *clsdev; diff --git a/v4l/compat.h b/v4l/compat.h index 3910ae2aa..05bada3bc 100644 --- a/v4l/compat.h +++ b/v4l/compat.h @@ -284,7 +284,10 @@ static inline int vm_insert_page(struct vm_area_struct *vma, # define class_destroy(a) class_simple_destroy(a) #elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,15) # define class_device_create(a, b, c, d, e, f, g, h) class_device_create(a, c, d, e, f, g, h) -#elif LINUX_VERSION_CODE < KERNEL_VERSION(2,6,24) +#endif +/* device_create/destroy added in 2.6.18 */ +#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,18) +/* on older kernels, class_device_create will in turn be a compat macro */ # define device_create(a, b, c, d, e, f, g) class_device_create(a, NULL, c, b, d, e, f, g) # define device_destroy(a, b) class_device_destroy(a, b) #endif -- cgit v1.2.3