~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/sound/soc/kirkwood/kirkwood-dma.c

Version: ~ [ linux-6.12-rc7 ] ~ [ linux-6.11.7 ] ~ [ linux-6.10.14 ] ~ [ linux-6.9.12 ] ~ [ linux-6.8.12 ] ~ [ linux-6.7.12 ] ~ [ linux-6.6.60 ] ~ [ linux-6.5.13 ] ~ [ linux-6.4.16 ] ~ [ linux-6.3.13 ] ~ [ linux-6.2.16 ] ~ [ linux-6.1.116 ] ~ [ linux-6.0.19 ] ~ [ linux-5.19.17 ] ~ [ linux-5.18.19 ] ~ [ linux-5.17.15 ] ~ [ linux-5.16.20 ] ~ [ linux-5.15.171 ] ~ [ linux-5.14.21 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.229 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.285 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.323 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.336 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.337 ] ~ [ linux-4.4.302 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.12 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

Diff markup

Differences between /sound/soc/kirkwood/kirkwood-dma.c (Version linux-6.12-rc7) and /sound/soc/kirkwood/kirkwood-dma.c (Version linux-2.4.37.11)


  1 // SPDX-License-Identifier: GPL-2.0-or-later        1 
  2 /*                                                
  3  * kirkwood-dma.c                                 
  4  *                                                
  5  * (c) 2010 Arnaud Patard <apatard@mandriva.co    
  6  * (c) 2010 Arnaud Patard <arnaud.patard@rtp-n    
  7  */                                               
  8                                                   
  9 #include <linux/init.h>                           
 10 #include <linux/module.h>                         
 11 #include <linux/device.h>                         
 12 #include <linux/io.h>                             
 13 #include <linux/slab.h>                           
 14 #include <linux/interrupt.h>                      
 15 #include <linux/dma-mapping.h>                    
 16 #include <linux/mbus.h>                           
 17 #include <sound/soc.h>                            
 18 #include "kirkwood.h"                             
 19                                                   
 20 static struct kirkwood_dma_data *kirkwood_priv    
 21 {                                                 
 22         struct snd_soc_pcm_runtime *soc_runtim    
 23         return snd_soc_dai_get_drvdata(snd_soc    
 24 }                                                 
 25                                                   
 26 static const struct snd_pcm_hardware kirkwood_    
 27         .info = SNDRV_PCM_INFO_INTERLEAVED |      
 28                 SNDRV_PCM_INFO_MMAP |             
 29                 SNDRV_PCM_INFO_MMAP_VALID |       
 30                 SNDRV_PCM_INFO_BLOCK_TRANSFER     
 31                 SNDRV_PCM_INFO_PAUSE |            
 32                 SNDRV_PCM_INFO_NO_PERIOD_WAKEU    
 33         .buffer_bytes_max       = KIRKWOOD_SND    
 34         .period_bytes_min       = KIRKWOOD_SND    
 35         .period_bytes_max       = KIRKWOOD_SND    
 36         .periods_min            = KIRKWOOD_SND    
 37         .periods_max            = KIRKWOOD_SND    
 38         .fifo_size              = 0,              
 39 };                                                
 40                                                   
 41 static irqreturn_t kirkwood_dma_irq(int irq, v    
 42 {                                                 
 43         struct kirkwood_dma_data *priv = dev_i    
 44         unsigned long mask, status, cause;        
 45                                                   
 46         mask = readl(priv->io + KIRKWOOD_INT_M    
 47         status = readl(priv->io + KIRKWOOD_INT    
 48                                                   
 49         cause = readl(priv->io + KIRKWOOD_ERR_    
 50         if (unlikely(cause)) {                    
 51                 printk(KERN_WARNING "%s: got e    
 52                                 __func__, caus    
 53                 writel(cause, priv->io + KIRKW    
 54         }                                         
 55                                                   
 56         /* we've enabled only bytes interrupts    
 57         if (status & ~(KIRKWOOD_INT_CAUSE_PLAY    
 58                         KIRKWOOD_INT_CAUSE_REC    
 59                 printk(KERN_WARNING "%s: unexp    
 60                         __func__, status);        
 61                 return IRQ_NONE;                  
 62         }                                         
 63                                                   
 64         /* ack int */                             
 65         writel(status, priv->io + KIRKWOOD_INT    
 66                                                   
 67         if (status & KIRKWOOD_INT_CAUSE_PLAY_B    
 68                 snd_pcm_period_elapsed(priv->s    
 69                                                   
 70         if (status & KIRKWOOD_INT_CAUSE_REC_BY    
 71                 snd_pcm_period_elapsed(priv->s    
 72                                                   
 73         return IRQ_HANDLED;                       
 74 }                                                 
 75                                                   
 76 static void                                       
 77 kirkwood_dma_conf_mbus_windows(void __iomem *b    
 78                                unsigned long d    
 79                                const struct mb    
 80 {                                                 
 81         int i;                                    
 82                                                   
 83         /* First disable and clear windows */     
 84         writel(0, base + KIRKWOOD_AUDIO_WIN_CT    
 85         writel(0, base + KIRKWOOD_AUDIO_WIN_BA    
 86                                                   
 87         /* try to find matching cs for current    
 88         for (i = 0; i < dram->num_cs; i++) {      
 89                 const struct mbus_dram_window     
 90                 if ((cs->base & 0xffff0000) <     
 91                         writel(cs->base & 0xff    
 92                                 base + KIRKWOO    
 93                         writel(((cs->size - 1)    
 94                                 (cs->mbus_attr    
 95                                 (dram->mbus_dr    
 96                                 base + KIRKWOO    
 97                 }                                 
 98         }                                         
 99 }                                                 
100                                                   
101 static int kirkwood_dma_open(struct snd_soc_co    
102                              struct snd_pcm_su    
103 {                                                 
104         int err;                                  
105         struct snd_pcm_runtime *runtime = subs    
106         struct kirkwood_dma_data *priv = kirkw    
107                                                   
108         snd_soc_set_runtime_hwparams(substream    
109                                                   
110         /* Ensure that all constraints linked     
111         err = snd_pcm_hw_constraint_minmax(run    
112                         SNDRV_PCM_HW_PARAM_BUF    
113                         priv->burst * 2,          
114                         KIRKWOOD_AUDIO_BUF_MAX    
115         if (err < 0)                              
116                 return err;                       
117                                                   
118         err = snd_pcm_hw_constraint_step(runti    
119                         SNDRV_PCM_HW_PARAM_BUF    
120                         priv->burst);             
121         if (err < 0)                              
122                 return err;                       
123                                                   
124         err = snd_pcm_hw_constraint_step(subst    
125                          SNDRV_PCM_HW_PARAM_PE    
126                          priv->burst);            
127         if (err < 0)                              
128                 return err;                       
129                                                   
130         if (!priv->substream_play && !priv->su    
131                 err = request_irq(priv->irq, k    
132                                   "kirkwood-i2    
133                 if (err)                          
134                         return err;               
135                                                   
136                 /*                                
137                  * Enable Error interrupts. We    
138                  * it's useful for diagnostics    
139                  */                               
140                 writel((unsigned int)-1, priv-    
141         }                                         
142                                                   
143         if (substream->stream == SNDRV_PCM_STR    
144                 if (priv->substream_play)         
145                         return -EBUSY;            
146                 priv->substream_play = substre    
147         } else {                                  
148                 if (priv->substream_rec)          
149                         return -EBUSY;            
150                 priv->substream_rec = substrea    
151         }                                         
152                                                   
153         return 0;                                 
154 }                                                 
155                                                   
156 static int kirkwood_dma_close(struct snd_soc_c    
157                               struct snd_pcm_s    
158 {                                                 
159         struct kirkwood_dma_data *priv = kirkw    
160                                                   
161         if (!priv)                                
162                 return 0;                         
163                                                   
164         if (substream->stream == SNDRV_PCM_STR    
165                 priv->substream_play = NULL;      
166         else                                      
167                 priv->substream_rec = NULL;       
168                                                   
169         if (!priv->substream_play && !priv->su    
170                 writel(0, priv->io + KIRKWOOD_    
171                 free_irq(priv->irq, priv);        
172         }                                         
173                                                   
174         return 0;                                 
175 }                                                 
176                                                   
177 static int kirkwood_dma_hw_params(struct snd_s    
178                                   struct snd_p    
179                                   struct snd_p    
180 {                                                 
181         struct kirkwood_dma_data *priv = kirkw    
182         const struct mbus_dram_target_info *dr    
183         unsigned long addr = substream->runtim    
184                                                   
185         if (!dram)                                
186                 return 0;                         
187                                                   
188         if (substream->stream == SNDRV_PCM_STR    
189                 kirkwood_dma_conf_mbus_windows    
190                         KIRKWOOD_PLAYBACK_WIN,    
191         else                                      
192                 kirkwood_dma_conf_mbus_windows    
193                         KIRKWOOD_RECORD_WIN, a    
194         return 0;                                 
195 }                                                 
196                                                   
197 static int kirkwood_dma_prepare(struct snd_soc    
198                                 struct snd_pcm    
199 {                                                 
200         struct snd_pcm_runtime *runtime = subs    
201         struct kirkwood_dma_data *priv = kirkw    
202         unsigned long size, count;                
203                                                   
204         /* compute buffer size in term of "wor    
205         size = frames_to_bytes(runtime, runtim    
206         size = (size>>2)-1;                       
207         count = snd_pcm_lib_period_bytes(subst    
208                                                   
209         if (substream->stream == SNDRV_PCM_STR    
210                 writel(count, priv->io + KIRKW    
211                 writel(runtime->dma_addr, priv    
212                 writel(size, priv->io + KIRKWO    
213         } else {                                  
214                 writel(count, priv->io + KIRKW    
215                 writel(runtime->dma_addr, priv    
216                 writel(size, priv->io + KIRKWO    
217         }                                         
218                                                   
219                                                   
220         return 0;                                 
221 }                                                 
222                                                   
223 static snd_pcm_uframes_t kirkwood_dma_pointer(    
224         struct snd_soc_component *component,      
225         struct snd_pcm_substream *substream)      
226 {                                                 
227         struct kirkwood_dma_data *priv = kirkw    
228         snd_pcm_uframes_t count;                  
229                                                   
230         if (substream->stream == SNDRV_PCM_STR    
231                 count = bytes_to_frames(substr    
232                         readl(priv->io + KIRKW    
233         else                                      
234                 count = bytes_to_frames(substr    
235                         readl(priv->io + KIRKW    
236                                                   
237         return count;                             
238 }                                                 
239                                                   
240 static int kirkwood_dma_new(struct snd_soc_com    
241                             struct snd_soc_pcm    
242 {                                                 
243         size_t size = kirkwood_dma_snd_hw.buff    
244         struct snd_card *card = rtd->card->snd    
245         int ret;                                  
246                                                   
247         ret = dma_coerce_mask_and_coherent(car    
248         if (ret)                                  
249                 return ret;                       
250                                                   
251         snd_pcm_set_managed_buffer_all(rtd->pc    
252                                        card->d    
253                                                   
254         return 0;                                 
255 }                                                 
256                                                   
257 const struct snd_soc_component_driver kirkwood    
258         .name           = DRV_NAME,               
259         .open           = kirkwood_dma_open,      
260         .close          = kirkwood_dma_close,     
261         .hw_params      = kirkwood_dma_hw_para    
262         .prepare        = kirkwood_dma_prepare    
263         .pointer        = kirkwood_dma_pointer    
264         .pcm_construct  = kirkwood_dma_new,       
265 };                                                
266                                                   

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

sflogo.php