2 sound/oss/at32dac.c | 72 +++++++++++++++++++++++++++++++---------------------
3 1 file changed, 43 insertions(+), 29 deletions(-)
5 Index: linux-2.6.18-avr32/sound/oss/at32dac.c
6 ===================================================================
7 --- linux-2.6.18-avr32.orig/sound/oss/at32dac.c 2006-11-01 14:30:47.000000000 +0100
8 +++ linux-2.6.18-avr32/sound/oss/at32dac.c 2006-11-01 14:32:05.000000000 +0100
9 @@ -71,6 +71,7 @@ struct at32_dac {
10 struct dma_request_cyclic req;
13 + struct clk *sample_clk;
14 struct platform_device *pdev;
17 @@ -116,24 +117,6 @@ static void at32dac_update_dma_tail(stru
21 -static int at32dac_start_genclock(struct at32_dac *dac)
25 - div = ((clk_get_rate(boot_cpu_data.clk) + 256 * dac->dsp_settings.sample_rate)
26 - / (512 * dac->dsp_settings.sample_rate) - 1);
27 - pr_debug("Real sample rate: %llu (div=%u)\n",
28 - boot_cpu_data.cpu_hz / (512 * (div + 1)), div);
29 - writel((div << 8) | 0x16, (void __iomem *)(0xfff00060 + 4 * 6));
34 -static void at32dac_stop_genclock(struct at32_dac *dac)
36 - writel(0, (void __iomem *)(0xfff00060 + 4 * 6));
39 static int at32dac_start(struct at32_dac *dac)
42 @@ -143,13 +126,11 @@ static int at32dac_start(struct at32_dac
44 memset(dac->dma.buf, 0, DMA_BUFFER_SIZE);
46 - ret = at32dac_start_genclock(dac);
49 + clk_enable(dac->sample_clk);
51 ret = dma_prepare_request_cyclic(dac->req.req.dmac, &dac->req);
53 - goto out_stop_genclock;
54 + goto out_stop_clock;
56 pr_debug("Starting DMA...\n");
57 ret = dma_start_request(dac->req.req.dmac, dac->req.req.channel);
58 @@ -164,8 +145,8 @@ static int at32dac_start(struct at32_dac
60 dma_stop_request(dac->req.req.dmac,
61 dac->req.req.channel);
63 - at32dac_stop_genclock(dac);
65 + clk_disable(dac->sample_clk);
69 @@ -176,7 +157,7 @@ static int at32dac_stop(struct at32_dac
70 dac_writel(dac, DATA, 0);
71 dac_writel(dac, CTRL, 0);
73 - at32dac_stop_genclock(dac);
74 + clk_disable(dac->sample_clk);
78 @@ -360,6 +341,26 @@ static int at32dac_set_format(struct at3
82 +static int at32dac_set_sample_rate(struct at32_dac *dac, unsigned long rate)
84 + unsigned long new_rate;
87 + ret = clk_set_rate(dac->sample_clk, 256 * rate);
91 + /* TODO: mplayer seems to have a problem with this */
93 + new_rate = clk_get_rate(dac->sample_clk);
94 + dac->dsp_settings.sample_rate = new_rate / 256;
96 + dac->dsp_settings.sample_rate = rate;
102 static ssize_t at32dac_dsp_write(struct file *file,
103 const char __user *buffer,
104 size_t count, loff_t *ppos)
105 @@ -449,7 +450,9 @@ static int at32dac_dsp_ioctl(struct inod
109 - dac->dsp_settings.sample_rate = val;
110 + ret = at32dac_set_sample_rate(dac, val);
114 return put_user(dac->dsp_settings.sample_rate, up);
116 @@ -534,10 +537,11 @@ static int at32dac_dsp_open(struct inode
117 dac->dma.head = dac->dma.tail = 0;
119 /* FIXME: What are the correct defaults? */
120 - dac->dsp_settings.format = AFMT_S16_BE;
121 dac->dsp_settings.channels = 2;
122 - dac->dsp_settings.sample_rate = 8000;
123 - dac->dsp_settings.input_order = 2;
124 + at32dac_set_format(dac, AFMT_S16_BE);
125 + ret = at32dac_set_sample_rate(dac, 8000);
129 file->private_data = dac;
131 @@ -578,6 +582,7 @@ static int __devinit at32dac_probe(struc
132 struct at32_dac *dac;
133 struct resource *regs;
135 + struct clk *sample_clk;
139 @@ -594,6 +599,11 @@ static int __devinit at32dac_probe(struc
140 mck = clk_get(&pdev->dev, "mck");
143 + sample_clk = clk_get(&pdev->dev, "sample_clk");
144 + if (IS_ERR(sample_clk)) {
145 + ret = PTR_ERR(sample_clk);
151 @@ -606,6 +616,7 @@ static int __devinit at32dac_probe(struc
152 init_waitqueue_head(&dac->write_wait);
155 + dac->sample_clk = sample_clk;
157 dac->regs = ioremap(regs->start, regs->end - regs->start + 1);
159 @@ -658,6 +669,8 @@ out_free_dac:
163 + clk_put(sample_clk);
168 @@ -673,6 +686,7 @@ static int __devexit at32dac_remove(stru
169 free_irq(platform_get_irq(pdev, 0), dac);
171 clk_disable(dac->mck);
172 + clk_put(dac->sample_clk);
175 platform_set_drvdata(pdev, NULL);