X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=sound%2Fpci%2Fbt87x.c;h=9ee07d4aac1e4666c0f30364dede0b3dc594be29;hb=43bc926fffd92024b46cafaf7350d669ba9ca884;hp=89a7ffe5e7d7723a0a2317d95144c588c31dfc20;hpb=cee37fe97739d85991964371c1f3a745c00dd236;p=linux-2.6.git diff --git a/sound/pci/bt87x.c b/sound/pci/bt87x.c index 89a7ffe5e..9ee07d4aa 100644 --- a/sound/pci/bt87x.c +++ b/sound/pci/bt87x.c @@ -59,16 +59,6 @@ module_param(load_all, bool, 0444); MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards"); -#ifndef PCI_VENDOR_ID_BROOKTREE -#define PCI_VENDOR_ID_BROOKTREE 0x109e -#endif -#ifndef PCI_DEVICE_ID_BROOKTREE_878 -#define PCI_DEVICE_ID_BROOKTREE_878 0x0878 -#endif -#ifndef PCI_DEVICE_ID_BROOKTREE_879 -#define PCI_DEVICE_ID_BROOKTREE_879 0x0879 -#endif - /* register offsets */ #define REG_INT_STAT 0x100 /* interrupt status */ #define REG_INT_MASK 0x104 /* interrupt mask */ @@ -157,9 +147,8 @@ MODULE_PARM_DESC(load_all, "Allow to load the non-whitelisted cards"); /* SYNC, one WRITE per line, one extra WRITE per page boundary, SYNC, JUMP */ #define MAX_RISC_SIZE ((1 + 255 + (PAGE_ALIGN(255 * 4092) / PAGE_SIZE - 1) + 1 + 1) * 8) -typedef struct snd_bt87x bt87x_t; struct snd_bt87x { - snd_card_t *card; + struct snd_card *card; struct pci_dev *pci; void __iomem *mmio; @@ -169,7 +158,7 @@ struct snd_bt87x { spinlock_t reg_lock; long opened; - snd_pcm_substream_t *substream; + struct snd_pcm_substream *substream; struct snd_dma_buffer dma_risc; unsigned int line_bytes; @@ -185,17 +174,17 @@ struct snd_bt87x { enum { DEVICE_DIGITAL, DEVICE_ANALOG }; -static inline u32 snd_bt87x_readl(bt87x_t *chip, u32 reg) +static inline u32 snd_bt87x_readl(struct snd_bt87x *chip, u32 reg) { return readl(chip->mmio + reg); } -static inline void snd_bt87x_writel(bt87x_t *chip, u32 reg, u32 value) +static inline void snd_bt87x_writel(struct snd_bt87x *chip, u32 reg, u32 value) { writel(value, chip->mmio + reg); } -static int snd_bt87x_create_risc(bt87x_t *chip, snd_pcm_substream_t *substream, +static int snd_bt87x_create_risc(struct snd_bt87x *chip, struct snd_pcm_substream *substream, unsigned int periods, unsigned int period_bytes) { struct snd_sg_buf *sgbuf = snd_pcm_substream_sgbuf(substream); @@ -245,7 +234,7 @@ static int snd_bt87x_create_risc(bt87x_t *chip, snd_pcm_substream_t *substream, return 0; } -static void snd_bt87x_free_risc(bt87x_t *chip) +static void snd_bt87x_free_risc(struct snd_bt87x *chip) { if (chip->dma_risc.area) { snd_dma_free_pages(&chip->dma_risc); @@ -253,7 +242,7 @@ static void snd_bt87x_free_risc(bt87x_t *chip) } } -static void snd_bt87x_pci_error(bt87x_t *chip, unsigned int status) +static void snd_bt87x_pci_error(struct snd_bt87x *chip, unsigned int status) { u16 pci_status; @@ -282,7 +271,7 @@ static void snd_bt87x_pci_error(bt87x_t *chip, unsigned int status) static irqreturn_t snd_bt87x_interrupt(int irq, void *dev_id, struct pt_regs *regs) { - bt87x_t *chip = dev_id; + struct snd_bt87x *chip = dev_id; unsigned int status, irq_status; status = snd_bt87x_readl(chip, REG_INT_STAT); @@ -315,7 +304,7 @@ static irqreturn_t snd_bt87x_interrupt(int irq, void *dev_id, struct pt_regs *re return IRQ_HANDLED; } -static snd_pcm_hardware_t snd_bt87x_digital_hw = { +static struct snd_pcm_hardware snd_bt87x_digital_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -331,7 +320,7 @@ static snd_pcm_hardware_t snd_bt87x_digital_hw = { .periods_max = 255, }; -static snd_pcm_hardware_t snd_bt87x_analog_hw = { +static struct snd_pcm_hardware snd_bt87x_analog_hw = { .info = SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED | SNDRV_PCM_INFO_BLOCK_TRANSFER | @@ -349,7 +338,7 @@ static snd_pcm_hardware_t snd_bt87x_analog_hw = { .periods_max = 255, }; -static int snd_bt87x_set_digital_hw(bt87x_t *chip, snd_pcm_runtime_t *runtime) +static int snd_bt87x_set_digital_hw(struct snd_bt87x *chip, struct snd_pcm_runtime *runtime) { static struct { int rate; @@ -378,15 +367,15 @@ static int snd_bt87x_set_digital_hw(bt87x_t *chip, snd_pcm_runtime_t *runtime) return 0; } -static int snd_bt87x_set_analog_hw(bt87x_t *chip, snd_pcm_runtime_t *runtime) +static int snd_bt87x_set_analog_hw(struct snd_bt87x *chip, struct snd_pcm_runtime *runtime) { - static ratnum_t analog_clock = { + static struct snd_ratnum analog_clock = { .num = ANALOG_CLOCK, .den_min = CLOCK_DIV_MIN, .den_max = CLOCK_DIV_MAX, .den_step = 1 }; - static snd_pcm_hw_constraint_ratnums_t constraint_rates = { + static struct snd_pcm_hw_constraint_ratnums constraint_rates = { .nrats = 1, .rats = &analog_clock }; @@ -397,10 +386,10 @@ static int snd_bt87x_set_analog_hw(bt87x_t *chip, snd_pcm_runtime_t *runtime) &constraint_rates); } -static int snd_bt87x_pcm_open(snd_pcm_substream_t *substream) +static int snd_bt87x_pcm_open(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int err; if (test_and_set_bit(0, &chip->opened)) @@ -426,9 +415,9 @@ _error: return err; } -static int snd_bt87x_close(snd_pcm_substream_t *substream) +static int snd_bt87x_close(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); chip->substream = NULL; clear_bit(0, &chip->opened); @@ -436,10 +425,10 @@ static int snd_bt87x_close(snd_pcm_substream_t *substream) return 0; } -static int snd_bt87x_hw_params(snd_pcm_substream_t *substream, - snd_pcm_hw_params_t *hw_params) +static int snd_bt87x_hw_params(struct snd_pcm_substream *substream, + struct snd_pcm_hw_params *hw_params) { - bt87x_t *chip = snd_pcm_substream_chip(substream); + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); int err; err = snd_pcm_lib_malloc_pages(substream, @@ -451,19 +440,19 @@ static int snd_bt87x_hw_params(snd_pcm_substream_t *substream, params_period_bytes(hw_params)); } -static int snd_bt87x_hw_free(snd_pcm_substream_t *substream) +static int snd_bt87x_hw_free(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); snd_bt87x_free_risc(chip); snd_pcm_lib_free_pages(substream); return 0; } -static int snd_bt87x_prepare(snd_pcm_substream_t *substream) +static int snd_bt87x_prepare(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; int decimation; spin_lock_irq(&chip->reg_lock); @@ -477,7 +466,7 @@ static int snd_bt87x_prepare(snd_pcm_substream_t *substream) return 0; } -static int snd_bt87x_start(bt87x_t *chip) +static int snd_bt87x_start(struct snd_bt87x *chip) { spin_lock(&chip->reg_lock); chip->current_line = 0; @@ -491,7 +480,7 @@ static int snd_bt87x_start(bt87x_t *chip) return 0; } -static int snd_bt87x_stop(bt87x_t *chip) +static int snd_bt87x_stop(struct snd_bt87x *chip) { spin_lock(&chip->reg_lock); chip->reg_control &= ~(CTL_FIFO_ENABLE | CTL_RISC_ENABLE | CTL_ACAP_EN); @@ -502,9 +491,9 @@ static int snd_bt87x_stop(bt87x_t *chip) return 0; } -static int snd_bt87x_trigger(snd_pcm_substream_t *substream, int cmd) +static int snd_bt87x_trigger(struct snd_pcm_substream *substream, int cmd) { - bt87x_t *chip = snd_pcm_substream_chip(substream); + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); switch (cmd) { case SNDRV_PCM_TRIGGER_START: @@ -516,15 +505,15 @@ static int snd_bt87x_trigger(snd_pcm_substream_t *substream, int cmd) } } -static snd_pcm_uframes_t snd_bt87x_pointer(snd_pcm_substream_t *substream) +static snd_pcm_uframes_t snd_bt87x_pointer(struct snd_pcm_substream *substream) { - bt87x_t *chip = snd_pcm_substream_chip(substream); - snd_pcm_runtime_t *runtime = substream->runtime; + struct snd_bt87x *chip = snd_pcm_substream_chip(substream); + struct snd_pcm_runtime *runtime = substream->runtime; return (snd_pcm_uframes_t)bytes_to_frames(runtime, chip->current_line * chip->line_bytes); } -static snd_pcm_ops_t snd_bt87x_pcm_ops = { +static struct snd_pcm_ops snd_bt87x_pcm_ops = { .open = snd_bt87x_pcm_open, .close = snd_bt87x_close, .ioctl = snd_pcm_lib_ioctl, @@ -536,7 +525,8 @@ static snd_pcm_ops_t snd_bt87x_pcm_ops = { .page = snd_pcm_sgbuf_ops_page, }; -static int snd_bt87x_capture_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) +static int snd_bt87x_capture_volume_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *info) { info->type = SNDRV_CTL_ELEM_TYPE_INTEGER; info->count = 1; @@ -545,17 +535,19 @@ static int snd_bt87x_capture_volume_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_bt87x_capture_volume_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_volume_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); value->value.integer.value[0] = (chip->reg_control & CTL_A_GAIN_MASK) >> CTL_A_GAIN_SHIFT; return 0; } -static int snd_bt87x_capture_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_volume_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); u32 old_control; int changed; @@ -569,7 +561,7 @@ static int snd_bt87x_capture_volume_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_v return changed; } -static snd_kcontrol_new_t snd_bt87x_capture_volume = { +static struct snd_kcontrol_new snd_bt87x_capture_volume = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Volume", .info = snd_bt87x_capture_volume_info, @@ -577,7 +569,8 @@ static snd_kcontrol_new_t snd_bt87x_capture_volume = { .put = snd_bt87x_capture_volume_put, }; -static int snd_bt87x_capture_boost_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) +static int snd_bt87x_capture_boost_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *info) { info->type = SNDRV_CTL_ELEM_TYPE_BOOLEAN; info->count = 1; @@ -586,17 +579,19 @@ static int snd_bt87x_capture_boost_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_i return 0; } -static int snd_bt87x_capture_boost_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_boost_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); value->value.integer.value[0] = !! (chip->reg_control & CTL_A_G2X); return 0; } -static int snd_bt87x_capture_boost_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_boost_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); u32 old_control; int changed; @@ -610,7 +605,7 @@ static int snd_bt87x_capture_boost_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_va return changed; } -static snd_kcontrol_new_t snd_bt87x_capture_boost = { +static struct snd_kcontrol_new snd_bt87x_capture_boost = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Boost", .info = snd_bt87x_capture_boost_info, @@ -618,7 +613,8 @@ static snd_kcontrol_new_t snd_bt87x_capture_boost = { .put = snd_bt87x_capture_boost_put, }; -static int snd_bt87x_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_info_t *info) +static int snd_bt87x_capture_source_info(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_info *info) { static char *texts[3] = {"TV Tuner", "FM", "Mic/Line"}; @@ -631,17 +627,19 @@ static int snd_bt87x_capture_source_info(snd_kcontrol_t *kcontrol, snd_ctl_elem_ return 0; } -static int snd_bt87x_capture_source_get(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_source_get(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); value->value.enumerated.item[0] = (chip->reg_control & CTL_A_SEL_MASK) >> CTL_A_SEL_SHIFT; return 0; } -static int snd_bt87x_capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_value_t *value) +static int snd_bt87x_capture_source_put(struct snd_kcontrol *kcontrol, + struct snd_ctl_elem_value *value) { - bt87x_t *chip = snd_kcontrol_chip(kcontrol); + struct snd_bt87x *chip = snd_kcontrol_chip(kcontrol); u32 old_control; int changed; @@ -655,7 +653,7 @@ static int snd_bt87x_capture_source_put(snd_kcontrol_t *kcontrol, snd_ctl_elem_v return changed; } -static snd_kcontrol_new_t snd_bt87x_capture_source = { +static struct snd_kcontrol_new snd_bt87x_capture_source = { .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = "Capture Source", .info = snd_bt87x_capture_source_info, @@ -663,7 +661,7 @@ static snd_kcontrol_new_t snd_bt87x_capture_source = { .put = snd_bt87x_capture_source_put, }; -static int snd_bt87x_free(bt87x_t *chip) +static int snd_bt87x_free(struct snd_bt87x *chip) { if (chip->mmio) { snd_bt87x_stop(chip); @@ -680,16 +678,16 @@ static int snd_bt87x_free(bt87x_t *chip) return 0; } -static int snd_bt87x_dev_free(snd_device_t *device) +static int snd_bt87x_dev_free(struct snd_device *device) { - bt87x_t *chip = device->device_data; + struct snd_bt87x *chip = device->device_data; return snd_bt87x_free(chip); } -static int __devinit snd_bt87x_pcm(bt87x_t *chip, int device, char *name) +static int __devinit snd_bt87x_pcm(struct snd_bt87x *chip, int device, char *name) { int err; - snd_pcm_t *pcm; + struct snd_pcm *pcm; err = snd_pcm_new(chip->card, name, device, 0, 1, &pcm); if (err < 0) @@ -704,13 +702,13 @@ static int __devinit snd_bt87x_pcm(bt87x_t *chip, int device, char *name) (255 * 4092 + 1023) & ~1023); } -static int __devinit snd_bt87x_create(snd_card_t *card, +static int __devinit snd_bt87x_create(struct snd_card *card, struct pci_dev *pci, - bt87x_t **rchip) + struct snd_bt87x **rchip) { - bt87x_t *chip; + struct snd_bt87x *chip; int err; - static snd_device_ops_t ops = { + static struct snd_device_ops ops = { .dev_free = snd_bt87x_dev_free }; @@ -720,7 +718,7 @@ static int __devinit snd_bt87x_create(snd_card_t *card, if (err < 0) return err; - chip = kcalloc(1, sizeof(*chip), GFP_KERNEL); + chip = kzalloc(sizeof(*chip), GFP_KERNEL); if (!chip) { pci_disable_device(pci); return -ENOMEM; @@ -771,15 +769,22 @@ static int __devinit snd_bt87x_create(snd_card_t *card, #define BT_DEVICE(chip, subvend, subdev, rate) \ { .vendor = PCI_VENDOR_ID_BROOKTREE, \ - .device = PCI_DEVICE_ID_BROOKTREE_##chip, \ + .device = chip, \ .subvendor = subvend, .subdevice = subdev, \ .driver_data = rate } /* driver_data is the default digital_rate value for that device */ -static struct pci_device_id snd_bt87x_ids[] = { - BT_DEVICE(878, 0x0070, 0x13eb, 32000), /* Hauppauge WinTV series */ - BT_DEVICE(879, 0x0070, 0x13eb, 32000), /* Hauppauge WinTV series */ - BT_DEVICE(878, 0x0070, 0xff01, 44100), /* Viewcast Osprey 200 */ +static struct pci_device_id snd_bt87x_ids[] __devinitdata = { + /* Hauppauge WinTV series */ + BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0x13eb, 32000), + /* Hauppauge WinTV series */ + BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, 0x0070, 0x13eb, 32000), + /* Viewcast Osprey 200 */ + BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x0070, 0xff01, 44100), + /* AVerMedia Studio No. 103, 203, ...? */ + BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x1461, 0x0003, 48000), + /* Leadtek Winfast tv 2000xp delux */ + BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, 0x107d, 0x6606, 32000), { } }; MODULE_DEVICE_TABLE(pci, snd_bt87x_ids); @@ -790,34 +795,39 @@ static struct { unsigned short subvendor, subdevice; } blacklist[] __devinitdata = { {0x0071, 0x0101}, /* Nebula Electronics DigiTV */ + {0x11bd, 0x001c}, /* Pinnacle PCTV Sat */ {0x11bd, 0x0026}, /* Pinnacle PCTV SAT CI */ {0x1461, 0x0761}, /* AVermedia AverTV DVB-T */ {0x1461, 0x0771}, /* AVermedia DVB-T 771 */ {0x1822, 0x0001}, /* Twinhan VisionPlus DVB-T */ + {0x18ac, 0xd500}, /* DVICO FusionHDTV 5 Lite */ {0x18ac, 0xdb10}, /* DVICO FusionHDTV DVB-T Lite */ {0x270f, 0xfc00}, /* Chaintech Digitop DST-1000 DVB-S */ + {0x7063, 0x2000}, /* pcHDTV HD-2000 TV */ }; +static struct pci_driver driver; + /* return the rate of the card, or a negative value if it's blacklisted */ static int __devinit snd_bt87x_detect_card(struct pci_dev *pci) { int i; const struct pci_device_id *supported; - supported = pci_match_device(snd_bt87x_ids, pci); - if (supported) + supported = pci_match_device(&driver, pci); + if (supported && supported->driver_data > 0) return supported->driver_data; for (i = 0; i < ARRAY_SIZE(blacklist); ++i) if (blacklist[i].subvendor == pci->subsystem_vendor && blacklist[i].subdevice == pci->subsystem_device) { - snd_printdd(KERN_INFO "card %#04x:%#04x has no audio\n", - pci->subsystem_vendor, pci->subsystem_device); + snd_printdd(KERN_INFO "card %#04x-%#04x:%#04x has no audio\n", + pci->device, pci->subsystem_vendor, pci->subsystem_device); return -EBUSY; } - snd_printk(KERN_INFO "unknown card %#04x:%#04x, using default rate 32000\n", - pci->subsystem_vendor, pci->subsystem_device); + snd_printk(KERN_INFO "unknown card %#04x-%#04x:%#04x, using default rate 32000\n", + pci->device, pci->subsystem_vendor, pci->subsystem_device); snd_printk(KERN_DEBUG "please mail id, board name, and, " "if it works, the correct digital_rate option to " "\n"); @@ -828,8 +838,8 @@ static int __devinit snd_bt87x_probe(struct pci_dev *pci, const struct pci_device_id *pci_id) { static int dev; - snd_card_t *card; - bt87x_t *chip; + struct snd_card *card; + struct snd_bt87x *chip; int err, rate; rate = pci_id->driver_data; @@ -901,9 +911,9 @@ static void __devexit snd_bt87x_remove(struct pci_dev *pci) /* default entries for all Bt87x cards - it's not exported */ /* driver_data is set to 0 to call detection */ -static struct pci_device_id snd_bt87x_default_ids[] = { - BT_DEVICE(878, PCI_ANY_ID, PCI_ANY_ID, 0), - BT_DEVICE(879, PCI_ANY_ID, PCI_ANY_ID, 0), +static struct pci_device_id snd_bt87x_default_ids[] __devinitdata = { + BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_878, PCI_ANY_ID, PCI_ANY_ID, 0), + BT_DEVICE(PCI_DEVICE_ID_BROOKTREE_879, PCI_ANY_ID, PCI_ANY_ID, 0), { } }; @@ -918,7 +928,7 @@ static int __init alsa_card_bt87x_init(void) { if (load_all) driver.id_table = snd_bt87x_default_ids; - return pci_module_init(&driver); + return pci_register_driver(&driver); } static void __exit alsa_card_bt87x_exit(void)