~ubuntu-branches/ubuntu/precise/linux-ti-omap4/precise

« back to all changes in this revision

Viewing changes to sound/pci/es1968.c

  • Committer: Bazaar Package Importer
  • Author(s): Paolo Pisati
  • Date: 2011-06-29 15:23:51 UTC
  • mfrom: (26.1.1 natty-proposed)
  • Revision ID: james.westby@ubuntu.com-20110629152351-xs96tm303d95rpbk
Tags: 3.0.0-1200.2
* Rebased against 3.0.0-6.7
* BSP from TI based on 3.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
112
112
#include <sound/ac97_codec.h>
113
113
#include <sound/initval.h>
114
114
 
 
115
#ifdef CONFIG_SND_ES1968_RADIO
 
116
#include <sound/tea575x-tuner.h>
 
117
#endif
 
118
 
115
119
#define CARD_NAME "ESS Maestro1/2"
116
120
#define DRIVER_NAME "ES1968"
117
121
 
553
557
        spinlock_t ac97_lock;
554
558
        struct tasklet_struct hwvol_tq;
555
559
#endif
 
560
 
 
561
#ifdef CONFIG_SND_ES1968_RADIO
 
562
        struct snd_tea575x tea;
 
563
#endif
556
564
};
557
565
 
558
566
static irqreturn_t snd_es1968_interrupt(int irq, void *dev_id);
2571
2579
}
2572
2580
#endif /* CONFIG_SND_ES1968_INPUT */
2573
2581
 
 
2582
#ifdef CONFIG_SND_ES1968_RADIO
 
2583
#define GPIO_DATA       0x60
 
2584
#define IO_MASK         4      /* mask      register offset from GPIO_DATA
 
2585
                                bits 1=unmask write to given bit */
 
2586
#define IO_DIR          8      /* direction register offset from GPIO_DATA
 
2587
                                bits 0/1=read/write direction */
 
2588
/* mask bits for GPIO lines */
 
2589
#define STR_DATA        0x0040 /* GPIO6 */
 
2590
#define STR_CLK         0x0080 /* GPIO7 */
 
2591
#define STR_WREN        0x0100 /* GPIO8 */
 
2592
#define STR_MOST        0x0200 /* GPIO9 */
 
2593
 
 
2594
static void snd_es1968_tea575x_set_pins(struct snd_tea575x *tea, u8 pins)
 
2595
{
 
2596
        struct es1968 *chip = tea->private_data;
 
2597
        unsigned long io = chip->io_port + GPIO_DATA;
 
2598
        u16 val = 0;
 
2599
 
 
2600
        val |= (pins & TEA575X_DATA) ? STR_DATA : 0;
 
2601
        val |= (pins & TEA575X_CLK)  ? STR_CLK  : 0;
 
2602
        val |= (pins & TEA575X_WREN) ? STR_WREN : 0;
 
2603
 
 
2604
        outw(val, io);
 
2605
}
 
2606
 
 
2607
static u8 snd_es1968_tea575x_get_pins(struct snd_tea575x *tea)
 
2608
{
 
2609
        struct es1968 *chip = tea->private_data;
 
2610
        unsigned long io = chip->io_port + GPIO_DATA;
 
2611
        u16 val = inw(io);
 
2612
 
 
2613
        return  (val & STR_DATA) ? TEA575X_DATA : 0 |
 
2614
                (val & STR_MOST) ? TEA575X_MOST : 0;
 
2615
}
 
2616
 
 
2617
static void snd_es1968_tea575x_set_direction(struct snd_tea575x *tea, bool output)
 
2618
{
 
2619
        struct es1968 *chip = tea->private_data;
 
2620
        unsigned long io = chip->io_port + GPIO_DATA;
 
2621
        u16 odir = inw(io + IO_DIR);
 
2622
 
 
2623
        if (output) {
 
2624
                outw(~(STR_DATA | STR_CLK | STR_WREN), io + IO_MASK);
 
2625
                outw(odir | STR_DATA | STR_CLK | STR_WREN, io + IO_DIR);
 
2626
        } else {
 
2627
                outw(~(STR_CLK | STR_WREN | STR_DATA | STR_MOST), io + IO_MASK);
 
2628
                outw((odir & ~(STR_DATA | STR_MOST)) | STR_CLK | STR_WREN, io + IO_DIR);
 
2629
        }
 
2630
}
 
2631
 
 
2632
static struct snd_tea575x_ops snd_es1968_tea_ops = {
 
2633
        .set_pins = snd_es1968_tea575x_set_pins,
 
2634
        .get_pins = snd_es1968_tea575x_get_pins,
 
2635
        .set_direction = snd_es1968_tea575x_set_direction,
 
2636
};
 
2637
#endif
 
2638
 
2574
2639
static int snd_es1968_free(struct es1968 *chip)
2575
2640
{
2576
2641
#ifdef CONFIG_SND_ES1968_INPUT
2585
2650
                outw(0, chip->io_port + ESM_PORT_HOST_IRQ); /* disable IRQ */
2586
2651
        }
2587
2652
 
 
2653
#ifdef CONFIG_SND_ES1968_RADIO
 
2654
        snd_tea575x_exit(&chip->tea);
 
2655
#endif
 
2656
 
2588
2657
        if (chip->irq >= 0)
2589
2658
                free_irq(chip->irq, chip);
2590
2659
        snd_es1968_free_gameport(chip);
2723
2792
 
2724
2793
        snd_card_set_dev(card, &pci->dev);
2725
2794
 
 
2795
#ifdef CONFIG_SND_ES1968_RADIO
 
2796
        chip->tea.private_data = chip;
 
2797
        chip->tea.ops = &snd_es1968_tea_ops;
 
2798
        strlcpy(chip->tea.card, "SF64-PCE2", sizeof(chip->tea.card));
 
2799
        sprintf(chip->tea.bus_info, "PCI:%s", pci_name(pci));
 
2800
        if (!snd_tea575x_init(&chip->tea))
 
2801
                printk(KERN_INFO "es1968: detected TEA575x radio\n");
 
2802
#endif
 
2803
 
2726
2804
        *chip_ret = chip;
2727
2805
 
2728
2806
        return 0;