<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[Freeswitch-trunk][14335] </title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<div id="header">FreeSWITCH Subversion</div>
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://fisheye.freeswitch.org/changelog/FreeSWITCH?cs=14335">14335</a></dd>
<dt>Author</dt> <dd>gmaruzz</dd>
<dt>Date</dt> <dd>2009-07-24 07:13:40 -0500 (Fri, 24 Jul 2009)</dd>
</dl>

<h3>Log Message</h3>
<pre>skypiax: added directory 'alsa', contains customized snd-dummy ALSA driver, low load. Please use alsa-<a href="http://jira.freeswitch.org/browse/driver-1">driver-1</a>.0.20 sources from alsa-project.org to compile, older sources got a bug that causes kernel oops</pre>

<h3>Added Paths</h3>
<ul>
<li>freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/</li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxalsaalsadriver1020dummyc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/alsa-driver-1.0.20-dummy.c</a></li>
<li><a href="#freeswitchtrunksrcmodendpointsmod_skypiaxalsadummyc">freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/dummy.c</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxalsaalsadriver1020dummyc"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/alsa-driver-1.0.20-dummy.c (0 => 14335)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/alsa-driver-1.0.20-dummy.c                                (rev 0)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/alsa-driver-1.0.20-dummy.c        2009-07-24 12:13:40 UTC (rev 14335)
</span><span class="lines">@@ -0,0 +1 @@
</span><ins>+link ./dummy.c
</ins><span class="cx">\ No newline at end of file
</span><span class="cx">Property changes on: freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/alsa-driver-1.0.20-dummy.c
</span><span class="cx">___________________________________________________________________
</span><span class="cx">Name: svn:special
</span><span class="cx">   + *
</span></span></pre></div>
<a id="freeswitchtrunksrcmodendpointsmod_skypiaxalsadummyc"></a>
<div class="addfile"><h4>Added: freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/dummy.c (0 => 14335)</h4>
<pre class="diff"><span>
<span class="info">--- freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/dummy.c                                (rev 0)
+++ freeswitch/trunk/src/mod/endpoints/mod_skypiax/alsa/dummy.c        2009-07-24 12:13:40 UTC (rev 14335)
</span><span class="lines">@@ -0,0 +1,958 @@
</span><ins>+/*
+ *  Dummy soundcard
+ *  Copyright (c) by Jaroslav Kysela &lt;perex@perex.cz&gt;
+ *
+ *   This program is free software; you can redistribute it and/or modify
+ *   it under the terms of the GNU General Public License as published by
+ *   the Free Software Foundation; either version 2 of the License, or
+ *   (at your option) any later version.
+ *
+ *   This program is distributed in the hope that it will be useful,
+ *   but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *   GNU General Public License for more details.
+ *
+ *   You should have received a copy of the GNU General Public License
+ *   along with this program; if not, write to the Free Software
+ *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
+ *
+ */
+
+#include &lt;sound/driver.h&gt; //giova
+#include &lt;linux/init.h&gt;
+#include &lt;linux/err.h&gt;
+#include &lt;linux/platform_device.h&gt;
+#include &lt;linux/jiffies.h&gt;
+#include &lt;linux/slab.h&gt;
+#include &lt;linux/time.h&gt;
+#include &lt;linux/wait.h&gt;
+#include &lt;linux/moduleparam.h&gt;
+#include &lt;sound/core.h&gt;
+#include &lt;sound/control.h&gt;
+#include &lt;sound/tlv.h&gt;
+#include &lt;sound/pcm.h&gt;
+#include &lt;sound/rawmidi.h&gt;
+#include &lt;sound/initval.h&gt;
+
+
+MODULE_AUTHOR(&quot;Jaroslav Kysela &lt;perex@perex.cz&gt;&quot;);
+MODULE_DESCRIPTION(&quot;Dummy soundcard (/dev/null)&quot;);
+MODULE_LICENSE(&quot;GPL&quot;);
+MODULE_SUPPORTED_DEVICE(&quot;{{ALSA,Dummy soundcard}}&quot;);
+
+#define MAX_PCM_DEVICES                4
+#define MAX_PCM_SUBSTREAMS        128
+#define MAX_MIDI_DEVICES        2
+
+#if 0 /* emu10k1 emulation */
+#define MAX_BUFFER_SIZE                (128 * 1024)
+static int emu10k1_playback_constraints(struct snd_pcm_runtime *runtime)
+{
+        int err;
+        err = snd_pcm_hw_constraint_integer(runtime, SNDRV_PCM_HW_PARAM_PERIODS);
+        if (err &lt; 0)
+                return err;
+        err = snd_pcm_hw_constraint_minmax(runtime, SNDRV_PCM_HW_PARAM_BUFFER_BYTES, 256, UINT_MAX);
+        if (err &lt; 0)
+                return err;
+        return 0;
+}
+#define add_playback_constraints emu10k1_playback_constraints
+#endif
+
+#if 0 /* RME9652 emulation */
+#define MAX_BUFFER_SIZE                (26 * 64 * 1024)
+#define USE_FORMATS                SNDRV_PCM_FMTBIT_S32_LE
+#define USE_CHANNELS_MIN        26
+#define USE_CHANNELS_MAX        26
+#define USE_PERIODS_MIN                2
+#define USE_PERIODS_MAX                2
+#endif
+
+#if 0 /* ICE1712 emulation */
+#define MAX_BUFFER_SIZE                (256 * 1024)
+#define USE_FORMATS                SNDRV_PCM_FMTBIT_S32_LE
+#define USE_CHANNELS_MIN        10
+#define USE_CHANNELS_MAX        10
+#define USE_PERIODS_MIN                1
+#define USE_PERIODS_MAX                1024
+#endif
+
+#if 0 /* UDA1341 emulation */
+#define MAX_BUFFER_SIZE                (16380)
+#define USE_FORMATS                SNDRV_PCM_FMTBIT_S16_LE
+#define USE_CHANNELS_MIN        2
+#define USE_CHANNELS_MAX        2
+#define USE_PERIODS_MIN                2
+#define USE_PERIODS_MAX                255
+#endif
+
+#if 0 /* simple AC97 bridge (intel8x0) with 48kHz AC97 only codec */
+#define USE_FORMATS                SNDRV_PCM_FMTBIT_S16_LE
+#define USE_CHANNELS_MIN        2
+#define USE_CHANNELS_MAX        2
+#define USE_RATE                SNDRV_PCM_RATE_48000
+#define USE_RATE_MIN                48000
+#define USE_RATE_MAX                48000
+#endif
+
+#if 0 /* CA0106 */
+#define USE_FORMATS                SNDRV_PCM_FMTBIT_S16_LE
+#define USE_CHANNELS_MIN        2
+#define USE_CHANNELS_MAX        2
+#define USE_RATE                (SNDRV_PCM_RATE_48000|SNDRV_PCM_RATE_96000|SNDRV_PCM_RATE_192000) 
+#define USE_RATE_MIN                48000 
+#define USE_RATE_MAX                192000
+#define MAX_BUFFER_SIZE                ((65536-64)*8)
+#define MAX_PERIOD_SIZE                (65536-64)
+#define USE_PERIODS_MIN                2
+#define USE_PERIODS_MAX                8
+#endif
+
+
+/* defaults */
+#ifndef MAX_BUFFER_SIZE
+#define MAX_BUFFER_SIZE                (64*1024)
+#endif
+#ifndef MAX_PERIOD_SIZE
+#define MAX_PERIOD_SIZE                MAX_BUFFER_SIZE
+#endif
+#ifndef USE_FORMATS
+#define USE_FORMATS                 (SNDRV_PCM_FMTBIT_U8 | SNDRV_PCM_FMTBIT_S16_LE)
+#endif
+#ifndef USE_RATE
+#define USE_RATE                SNDRV_PCM_RATE_CONTINUOUS | SNDRV_PCM_RATE_8000_48000
+#define USE_RATE_MIN                5500
+#define USE_RATE_MAX                48000
+#endif
+#ifndef USE_CHANNELS_MIN
+#define USE_CHANNELS_MIN         1
+#endif
+#ifndef USE_CHANNELS_MAX
+#define USE_CHANNELS_MAX         2
+#endif
+#ifndef USE_PERIODS_MIN
+#define USE_PERIODS_MIN         1
+#endif
+#ifndef USE_PERIODS_MAX
+#define USE_PERIODS_MAX         1024
+#endif
+#ifndef add_playback_constraints
+#define add_playback_constraints(x) 0
+#endif
+#ifndef add_capture_constraints
+#define add_capture_constraints(x) 0
+#endif
+
+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)] = 0};
+static int pcm_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 1};
+static int pcm_substreams[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 128};
+//static int midi_devs[SNDRV_CARDS] = {[0 ... (SNDRV_CARDS - 1)] = 2};
+
+module_param_array(index, int, NULL, 0444);
+MODULE_PARM_DESC(index, &quot;Index value for dummy soundcard.&quot;);
+module_param_array(id, charp, NULL, 0444);
+MODULE_PARM_DESC(id, &quot;ID string for dummy soundcard.&quot;);
+module_param_array(enable, bool, NULL, 0444);
+MODULE_PARM_DESC(enable, &quot;Enable this dummy soundcard.&quot;);
+module_param_array(pcm_devs, int, NULL, 0444);
+MODULE_PARM_DESC(pcm_devs, &quot;PCM devices # (0-4) for dummy driver.&quot;);
+module_param_array(pcm_substreams, int, NULL, 0444);
+MODULE_PARM_DESC(pcm_substreams, &quot;PCM substreams # (1-64) for dummy driver.&quot;);
+//module_param_array(midi_devs, int, NULL, 0444);
+//MODULE_PARM_DESC(midi_devs, &quot;MIDI devices # (0-2) for dummy driver.&quot;);
+
+static struct platform_device *devices[SNDRV_CARDS];
+static struct timer_list giovatimer; //giova
+static int giovastarted=0;
+static int giovaindex=0;
+static spinlock_t giovalock;
+struct giovadpcm {
+        struct snd_pcm_substream *substream;
+        struct snd_dummy_pcm *dpcm;
+        int        started;
+};
+static struct giovadpcm giovadpcms[MAX_PCM_SUBSTREAMS];
+
+#define MIXER_ADDR_MASTER        0
+#define MIXER_ADDR_LINE                1
+#define MIXER_ADDR_MIC                2
+#define MIXER_ADDR_SYNTH        3
+#define MIXER_ADDR_CD                4
+#define MIXER_ADDR_LAST                4
+
+static void snd_card_dummy_pcm_timer_function(unsigned long data);
+struct snd_dummy {
+        struct snd_card *card;
+        struct snd_pcm *pcm;
+        spinlock_t mixer_lock;
+        int mixer_volume[MIXER_ADDR_LAST+1][2];
+        int capture_source[MIXER_ADDR_LAST+1][2];
+};
+
+struct snd_dummy_pcm {
+        struct snd_dummy *dummy;
+        spinlock_t lock;
+        struct timer_list timer;
+        unsigned int pcm_buffer_size;
+        unsigned int pcm_period_size;
+        unsigned int pcm_bps;                /* bytes per second */
+        unsigned int pcm_hz;                /* HZ */
+        unsigned int pcm_irq_pos;        /* IRQ position */
+        unsigned int pcm_buf_pos;        /* position in buffer */
+        struct snd_pcm_substream *substream;
+};
+
+
+static inline void snd_card_dummy_pcm_timer_start(struct snd_dummy_pcm *dpcm)
+{
+int i;
+int found=0;
+
+
+//printk(&quot;giova: 1 timer_start %d %p\n&quot;, __LINE__, dpcm);
+for(i=0; i&lt;giovaindex+1; i++){
+        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
+                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
+        }
+
+if(giovadpcms[i].dpcm == dpcm){
+        giovadpcms[i].started=1;
+        found=1;
+}
+}
+if(!found){
+        printk(&quot;skypiax: start, NOT found?\n&quot;);
+}
+
+
+
+//printk(&quot;giova: 2 timer_start %d %p\n&quot;, __LINE__, dpcm);
+}
+
+static inline void snd_card_dummy_pcm_timer_stop(struct snd_dummy_pcm *dpcm)
+{
+        //del_timer(&amp;dpcm-&gt;timer);
+int i;
+int found=0;
+
+//printk(&quot;giova: 1 timer_stop %d %p\n&quot;, __LINE__, dpcm);
+for(i=0; i&lt;giovaindex +1; i++){
+
+        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
+                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
+        }
+if(giovadpcms[i].dpcm == dpcm){
+        giovadpcms[i].started=0;
+        found=1;
+}
+}
+if(!found){
+        //printk(&quot;skypiax: stop, NOT found?\n&quot;);
+        } else { 
+                //printk(&quot;skypiax: stop, YES found!\n&quot;); 
+        }
+
+
+
+//printk(&quot;giova: 2 timer_stop %d %p\n&quot;, __LINE__, dpcm);
+}
+
+static int snd_card_dummy_pcm_trigger(struct snd_pcm_substream *substream, int cmd)
+{
+        struct snd_pcm_runtime *runtime = substream-&gt;runtime;
+        struct snd_dummy_pcm *dpcm = runtime-&gt;private_data;
+        int err = 0;
+
+        //spin_lock(&amp;dpcm-&gt;lock, flags);
+        spin_lock_bh(&amp;giovalock);
+        switch (cmd) {
+        case SNDRV_PCM_TRIGGER_START:
+        case SNDRV_PCM_TRIGGER_RESUME:
+//printk(&quot;giova: trigger timer_start %d %p\n&quot;, __LINE__, dpcm);
+                snd_card_dummy_pcm_timer_start(dpcm);
+                break;
+        case SNDRV_PCM_TRIGGER_STOP:
+        case SNDRV_PCM_TRIGGER_SUSPEND:
+//printk(&quot;giova: trigger timer_stop %d %p\n&quot;, __LINE__, dpcm);
+                snd_card_dummy_pcm_timer_stop(dpcm);
+                break;
+        default:
+                err = -EINVAL;
+                break;
+        }
+        //spin_unlock(&amp;dpcm-&gt;lock, flags);
+        spin_unlock_bh(&amp;giovalock);
+        return 0;
+}
+
+static int snd_card_dummy_pcm_prepare(struct snd_pcm_substream *substream)
+{
+        struct snd_pcm_runtime *runtime = substream-&gt;runtime;
+        struct snd_dummy_pcm *dpcm = runtime-&gt;private_data;
+        int bps;
+
+        bps = snd_pcm_format_width(runtime-&gt;format) * runtime-&gt;rate *
+                runtime-&gt;channels / 8;
+
+        if (bps &lt;= 0)
+                return -EINVAL;
+
+        dpcm-&gt;pcm_bps = bps;
+        dpcm-&gt;pcm_hz = HZ;
+        dpcm-&gt;pcm_buffer_size = snd_pcm_lib_buffer_bytes(substream);
+        dpcm-&gt;pcm_period_size = snd_pcm_lib_period_bytes(substream);
+        dpcm-&gt;pcm_irq_pos = 0;
+        dpcm-&gt;pcm_buf_pos = 0;
+        snd_pcm_format_set_silence(runtime-&gt;format, runtime-&gt;dma_area,
+                        bytes_to_samples(runtime, runtime-&gt;dma_bytes));
+
+//printk(&quot;giova: prepare %d %p\n&quot;, __LINE__, dpcm);
+        return 0;
+}
+
+static void snd_card_dummy_pcm_timer_function(unsigned long data)
+{
+        //struct snd_dummy_pcm *dpcm = (struct snd_dummy_pcm *)data;
+        struct snd_dummy_pcm *dpcm=NULL;
+        //unsigned long flags;
+int i;
+        
+
+        giovatimer.expires = (HZ/100) + jiffies;
+        add_timer(&amp;giovatimer);
+
+for(i=0; i&lt; giovaindex +1; i++) {
+
+        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
+                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
+        }
+//printk(&quot;giova: timer_func %d i=%d\n&quot;, __LINE__, i);
+
+if(giovadpcms[i].started != 1)
+        continue; 
+dpcm = giovadpcms[i].dpcm;
+if(dpcm==NULL){
+        printk(&quot;giova: timer_func %d %d NULL: continue\n&quot;, __LINE__, i);
+        continue;
+        }
+        if(in_irq())
+                printk(&quot;giova: timer_func %d %d we are in HARDWARE IRQ\n&quot;, __LINE__, i);
+        //if(in_softirq())
+                //printk(&quot;giova: timer_func %d %d we are in SOFT IRQ\n&quot;, __LINE__, i);
+//printk(&quot;giova: timer_func %d %d\n&quot;, __LINE__, i);
+        //spin_lock_irqsave(&amp;dpcm-&gt;lock, flags);
+        spin_lock_bh(&amp;dpcm-&gt;lock);
+        dpcm-&gt;pcm_irq_pos += dpcm-&gt;pcm_bps * (HZ/100);
+        dpcm-&gt;pcm_buf_pos += dpcm-&gt;pcm_bps * (HZ/100);
+        dpcm-&gt;pcm_buf_pos %= dpcm-&gt;pcm_buffer_size * dpcm-&gt;pcm_hz;
+        if (dpcm-&gt;pcm_irq_pos &gt;= dpcm-&gt;pcm_period_size * dpcm-&gt;pcm_hz) {
+                dpcm-&gt;pcm_irq_pos %= dpcm-&gt;pcm_period_size * dpcm-&gt;pcm_hz;
+                //spin_unlock_irqrestore(&amp;dpcm-&gt;lock, flags);
+                spin_unlock_bh(&amp;dpcm-&gt;lock);
+                snd_pcm_period_elapsed(dpcm-&gt;substream);
+        } else {
+                //spin_unlock_irqrestore(&amp;dpcm-&gt;lock, flags);
+                spin_unlock_bh(&amp;dpcm-&gt;lock);
+        }
+}
+}
+
+static snd_pcm_uframes_t snd_card_dummy_pcm_pointer(struct snd_pcm_substream *substream)
+{
+        struct snd_pcm_runtime *runtime = substream-&gt;runtime;
+        struct snd_dummy_pcm *dpcm = runtime-&gt;private_data;
+
+//printk(&quot;giova: pointer %d %p\n&quot;, __LINE__, dpcm);
+        //return bytes_to_frames(runtime, dpcm-&gt;pcm_buf_pos / dpcm-&gt;pcm_hz);
+        return (dpcm-&gt;pcm_buf_pos / dpcm-&gt;pcm_hz)/2;
+}
+
+static struct snd_pcm_hardware snd_card_dummy_playback =
+{
+        .info =                        (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
+                                 SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
+        .formats =                USE_FORMATS,
+        .rates =                USE_RATE,
+        .rate_min =                USE_RATE_MIN,
+        .rate_max =                USE_RATE_MAX,
+        .channels_min =                USE_CHANNELS_MIN,
+        .channels_max =                USE_CHANNELS_MAX,
+        .buffer_bytes_max =        MAX_BUFFER_SIZE,
+        .period_bytes_min =        64,
+        .period_bytes_max =        MAX_PERIOD_SIZE,
+        .periods_min =                USE_PERIODS_MIN,
+        .periods_max =                USE_PERIODS_MAX,
+        .fifo_size =                0,
+};
+
+static struct snd_pcm_hardware snd_card_dummy_capture =
+{
+        .info =                        (SNDRV_PCM_INFO_MMAP | SNDRV_PCM_INFO_INTERLEAVED |
+                                 SNDRV_PCM_INFO_RESUME | SNDRV_PCM_INFO_MMAP_VALID),
+        .formats =                USE_FORMATS,
+        .rates =                USE_RATE,
+        .rate_min =                USE_RATE_MIN,
+        .rate_max =                USE_RATE_MAX,
+        .channels_min =                USE_CHANNELS_MIN,
+        .channels_max =                USE_CHANNELS_MAX,
+        .buffer_bytes_max =        MAX_BUFFER_SIZE,
+        .period_bytes_min =        64,
+        .period_bytes_max =        MAX_PERIOD_SIZE,
+        .periods_min =                USE_PERIODS_MIN,
+        .periods_max =                USE_PERIODS_MAX,
+        .fifo_size =                0,
+};
+
+static void snd_card_dummy_runtime_free(struct snd_pcm_runtime *runtime)
+{
+int i;
+//int found=0;
+
+//printk(&quot;snd_card_dummy_runtime_free giova 1 giovaindex=%d dpcm=%p runtime=%p\n&quot;, giovaindex, runtime-&gt;private_data, runtime);
+        spin_lock_bh(&amp;giovalock);
+
+for(i=0; i &lt; giovaindex; i++) {
+
+        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
+                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d \n&quot;, __FILE__, __LINE__, i, giovaindex);
+        }
+        //if((giovadpcms[i].substream == substream)  &amp;&amp; (giovadpcms[i].dpcm == dpcm)){
+        if((giovadpcms[i].dpcm == runtime-&gt;private_data)){
+                //printk(&quot;giova, %s:%d, i=%d, giovaindex=%d %p==%p YES I AM!!!!\n&quot;, __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime-&gt;private_data);
+                //giovadpcms[i].dpcm = NULL;
+                //giovadpcms[i].substream = NULL;
+                giovadpcms[i].started = 0;
+                //break;
+        } else {
+                //printk(&quot;giova, %s:%d, i=%d, giovaindex=%d %p!=%p NOT ME\n&quot;, __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime-&gt;private_data);
+        }
+}
+
+        spin_unlock_bh(&amp;giovalock);
+        kfree(runtime-&gt;private_data);
+}
+
+static int snd_card_dummy_hw_params(struct snd_pcm_substream *substream,
+                                    struct snd_pcm_hw_params *hw_params)
+{
+        return snd_pcm_lib_malloc_pages(substream, params_buffer_bytes(hw_params));
+}
+
+static int snd_card_dummy_hw_free(struct snd_pcm_substream *substream)
+{
+        return snd_pcm_lib_free_pages(substream);
+}
+
+static struct snd_dummy_pcm *new_pcm_stream(struct snd_pcm_substream *substream)
+{
+        struct snd_dummy_pcm *dpcm;
+        int i;
+        int found=0;
+
+        //printk(&quot;giova, %s:%d, i=%d, giovaindex=%d %p==%p YES I AM!!!!\n&quot;, __FILE__, __LINE__, i, giovaindex, giovadpcms[i].dpcm , runtime-&gt;private_data);
+        //printk(&quot;giova, %s:%d, giovaindex=%d\n&quot;, __FILE__, __LINE__, giovaindex);
+        dpcm = kzalloc(sizeof(*dpcm), GFP_KERNEL);
+        //printk(&quot;giova, %s:%d, giovaindex=%d\n&quot;, __FILE__, __LINE__, giovaindex);
+        if (! dpcm){
+                //spin_unlock_bh(&amp;giovalock);
+                printk(&quot;giova, %s:%d, giovaindex=%d NO MEMORY!!!!\n&quot;, __FILE__, __LINE__, giovaindex);
+                return dpcm;
+        }
+        //printk(&quot;giova, %s:%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, giovaindex, dpcm);
+        init_timer(&amp;dpcm-&gt;timer);
+        //dpcm-&gt;timer.data = (unsigned long) dpcm;
+        //dpcm-&gt;timer.function = snd_card_dummy_pcm_timer_function;
+        spin_lock_init(&amp;dpcm-&gt;lock);
+        dpcm-&gt;substream = substream;
+
+        spin_lock_bh(&amp;giovalock);
+        //printk(&quot;giova 1 giovaindex=%d dpcm=%p substream=%p sizeof=%lu\n&quot;, giovaindex, dpcm, substream, sizeof(*dpcm));
+        for(i=0; i &lt; giovaindex; i++) {
+
+        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
+                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
+        }
+                //if((giovadpcms[i].substream == substream)  &amp;&amp; (giovadpcms[i].dpcm == dpcm))
+                if((giovadpcms[i].substream == substream)){
+                        found=1;
+                        break;
+                }
+
+        }
+
+        if(!found){
+
+                giovadpcms[giovaindex].substream=substream;
+                giovaindex++;
+                //printk(&quot;giova 2 giovaindex=%d dpcm=%p substream=%p\n&quot;, giovaindex, dpcm, substream);
+        }
+
+
+
+        found =0;
+        for(i=0; i &lt; giovaindex; i++) {
+
+        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
+                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, i, giovaindex, dpcm);
+        }
+                if(giovadpcms[i].substream == substream){
+                        giovadpcms[i].dpcm=dpcm;
+                        giovadpcms[i].started=0;
+                        found = 1;
+                        //printk(&quot;giova 3 giovaindex=%d dpcm=%p substream=%p\n&quot;, giovaindex, dpcm, substream);
+                        break;
+                } 
+
+        }
+
+        spin_unlock_bh(&amp;giovalock);
+        if(!found) {
+                printk(&quot;skypiax giovaindex=%d NOT found????\n&quot;, giovaindex);
+        }
+
+        //printk(&quot;giova, %s:%d, giovaindex=%d\n&quot;, __FILE__, __LINE__, giovaindex);
+        return dpcm;
+}
+
+static int snd_card_dummy_playback_open(struct snd_pcm_substream *substream)
+{
+        struct snd_pcm_runtime *runtime = substream-&gt;runtime;
+        struct snd_dummy_pcm *dpcm;
+        int err;
+
+        if ((dpcm = new_pcm_stream(substream)) == NULL)
+                return -ENOMEM;
+        //printk(&quot;giova, %s:%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, giovaindex, dpcm);
+        runtime-&gt;private_data = dpcm;
+        /* makes the infrastructure responsible for freeing dpcm */
+        runtime-&gt;private_free = snd_card_dummy_runtime_free;
+        runtime-&gt;hw = snd_card_dummy_playback;
+        if (substream-&gt;pcm-&gt;device &amp; 1) {
+                runtime-&gt;hw.info &amp;= ~SNDRV_PCM_INFO_INTERLEAVED;
+                runtime-&gt;hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
+        }
+        if (substream-&gt;pcm-&gt;device &amp; 2)
+                runtime-&gt;hw.info &amp;= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
+        err = add_playback_constraints(runtime);
+        if (err &lt; 0)
+                return err;
+
+        return 0;
+}
+
+static int snd_card_dummy_capture_open(struct snd_pcm_substream *substream)
+{
+        struct snd_pcm_runtime *runtime = substream-&gt;runtime;
+        struct snd_dummy_pcm *dpcm;
+        int err;
+
+        if ((dpcm = new_pcm_stream(substream)) == NULL)
+                return -ENOMEM;
+        //printk(&quot;giova, %s:%d, giovaindex=%d dpcm=%p\n&quot;, __FILE__, __LINE__, giovaindex, dpcm);
+        runtime-&gt;private_data = dpcm;
+        /* makes the infrastructure responsible for freeing dpcm */
+        runtime-&gt;private_free = snd_card_dummy_runtime_free;
+        runtime-&gt;hw = snd_card_dummy_capture;
+        if (substream-&gt;pcm-&gt;device == 1) {
+                runtime-&gt;hw.info &amp;= ~SNDRV_PCM_INFO_INTERLEAVED;
+                runtime-&gt;hw.info |= SNDRV_PCM_INFO_NONINTERLEAVED;
+        }
+        if (substream-&gt;pcm-&gt;device &amp; 2)
+                runtime-&gt;hw.info &amp;= ~(SNDRV_PCM_INFO_MMAP|SNDRV_PCM_INFO_MMAP_VALID);
+        err = add_capture_constraints(runtime);
+        if (err &lt; 0)
+                return err;
+
+        return 0;
+}
+
+static int snd_card_dummy_playback_close(struct snd_pcm_substream *substream)
+{
+//printk(&quot;play giova 1 giovaindex=%d dpcm=%p substream=%p\n&quot;, giovaindex, substream-&gt;private_data, substream);
+        snd_card_dummy_pcm_timer_stop(substream-&gt;private_data);
+        return 0;
+}
+
+static int snd_card_dummy_capture_close(struct snd_pcm_substream *substream)
+{
+//printk(&quot;capt giova 2 giovaindex=%d dpcm=%p substream=%p\n&quot;, giovaindex, substream-&gt;private_data, substream);
+        snd_card_dummy_pcm_timer_stop(substream-&gt;private_data);
+        return 0;
+}
+
+static struct snd_pcm_ops snd_card_dummy_playback_ops = {
+        .open =                        snd_card_dummy_playback_open,
+        .close =                snd_card_dummy_playback_close,
+        .ioctl =                snd_pcm_lib_ioctl,
+        .hw_params =                snd_card_dummy_hw_params,
+        .hw_free =                snd_card_dummy_hw_free,
+        .prepare =                snd_card_dummy_pcm_prepare,
+        .trigger =                snd_card_dummy_pcm_trigger,
+        .pointer =                snd_card_dummy_pcm_pointer,
+};
+
+static struct snd_pcm_ops snd_card_dummy_capture_ops = {
+        .open =                        snd_card_dummy_capture_open,
+        .close =                snd_card_dummy_capture_close,
+        .ioctl =                snd_pcm_lib_ioctl,
+        .hw_params =                snd_card_dummy_hw_params,
+        .hw_free =                snd_card_dummy_hw_free,
+        .prepare =                snd_card_dummy_pcm_prepare,
+        .trigger =                snd_card_dummy_pcm_trigger,
+        .pointer =                snd_card_dummy_pcm_pointer,
+};
+
+static int __devinit snd_card_dummy_pcm(struct snd_dummy *dummy, int device,
+                                        int substreams)
+{
+        struct snd_pcm *pcm;
+        int err;
+
+        err = snd_pcm_new(dummy-&gt;card, &quot;Dummy PCM&quot;, device,
+                               substreams, substreams, &amp;pcm);
+        if (err &lt; 0)
+                return err;
+        dummy-&gt;pcm = pcm;
+        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_PLAYBACK, &amp;snd_card_dummy_playback_ops);
+        snd_pcm_set_ops(pcm, SNDRV_PCM_STREAM_CAPTURE, &amp;snd_card_dummy_capture_ops);
+        pcm-&gt;private_data = dummy;
+        pcm-&gt;info_flags = 0;
+        strcpy(pcm-&gt;name, &quot;Dummy PCM&quot;);
+        snd_pcm_lib_preallocate_pages_for_all(pcm, SNDRV_DMA_TYPE_CONTINUOUS,
+                                              snd_dma_continuous_data(GFP_KERNEL),
+                                              128*1024, 1024*1024);
+
+        return 0;
+}
+
+#define DUMMY_VOLUME(xname, xindex, addr) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, \
+  .access = SNDRV_CTL_ELEM_ACCESS_READWRITE | SNDRV_CTL_ELEM_ACCESS_TLV_READ, \
+  .name = xname, .index = xindex, \
+  .info = snd_dummy_volume_info, \
+  .get = snd_dummy_volume_get, .put = snd_dummy_volume_put, \
+  .private_value = addr, \
+  .tlv = { .p = db_scale_dummy } }
+
+static int snd_dummy_volume_info(struct snd_kcontrol *kcontrol,
+                                 struct snd_ctl_elem_info *uinfo)
+{
+        uinfo-&gt;type = SNDRV_CTL_ELEM_TYPE_INTEGER;
+        uinfo-&gt;count = 2;
+        uinfo-&gt;value.integer.min = -50;
+        uinfo-&gt;value.integer.max = 100;
+        return 0;
+}

+static int snd_dummy_volume_get(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
+{
+        struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
+        int addr = kcontrol-&gt;private_value;
+        //unsigned long flags;
+
+        if(in_irq())
+                printk(&quot;giova: line %d we are in HARDWARE IRQ\n&quot;, __LINE__);
+//printk(&quot;giova: volume get %d %d\n&quot;, __LINE__, addr);
+        //spin_lock_irq(&amp;dummy-&gt;mixer_lock);
+        //spin_lock_irqsave(&amp;dummy-&gt;mixer_lock, flags);
+        spin_lock_bh(&amp;dummy-&gt;mixer_lock);
+        ucontrol-&gt;value.integer.value[0] = dummy-&gt;mixer_volume[addr][0];
+        ucontrol-&gt;value.integer.value[1] = dummy-&gt;mixer_volume[addr][1];
+        //spin_unlock_irqrestore(&amp;dummy-&gt;mixer_lock, flags);
+        spin_unlock_bh(&amp;dummy-&gt;mixer_lock);
+        return 0;
+}
+
+static int snd_dummy_volume_put(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
+{
+        struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
+        int change, addr = kcontrol-&gt;private_value;
+        int left, right;
+        //unsigned long flags;
+
+        if(in_irq())
+                printk(&quot;giova: line %d we are in HARDWARE IRQ\n&quot;, __LINE__);
+        left = ucontrol-&gt;value.integer.value[0];
+        if (left &lt; -50)
+                left = -50;
+        if (left &gt; 100)
+                left = 100;
+        right = ucontrol-&gt;value.integer.value[1];
+        if (right &lt; -50)
+                right = -50;
+        if (right &gt; 100)
+                right = 100;
+//printk(&quot;giova: volume put %d %d\n&quot;, __LINE__, addr);
+        //spin_lock_irq(&amp;dummy-&gt;mixer_lock);
+        //spin_lock_irqsave(&amp;dummy-&gt;mixer_lock, flags);
+        spin_lock_bh(&amp;dummy-&gt;mixer_lock);
+        change = dummy-&gt;mixer_volume[addr][0] != left ||
+                 dummy-&gt;mixer_volume[addr][1] != right;
+        dummy-&gt;mixer_volume[addr][0] = left;
+        dummy-&gt;mixer_volume[addr][1] = right;
+        //spin_unlock_irq(&amp;dummy-&gt;mixer_lock);
+        //spin_unlock_irqrestore(&amp;dummy-&gt;mixer_lock, flags);
+        spin_unlock_bh(&amp;dummy-&gt;mixer_lock);
+        return change;
+}
+
+static const DECLARE_TLV_DB_SCALE(db_scale_dummy, -4500, 30, 0);
+
+#define DUMMY_CAPSRC(xname, xindex, addr) \
+{ .iface = SNDRV_CTL_ELEM_IFACE_MIXER, .name = xname, .index = xindex, \
+  .info = snd_dummy_capsrc_info, \
+  .get = snd_dummy_capsrc_get, .put = snd_dummy_capsrc_put, \
+  .private_value = addr }
+
+#define snd_dummy_capsrc_info        snd_ctl_boolean_stereo_info

+static int snd_dummy_capsrc_get(struct snd_kcontrol *kcontrol,
+                                struct snd_ctl_elem_value *ucontrol)
+{
+        struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
+        int addr = kcontrol-&gt;private_value;
+        //unsigned long flags;
+
+        if(in_irq())
+                printk(&quot;giova: line %d we are in HARDWARE IRQ\n&quot;, __LINE__);
+        //spin_lock_irq(&amp;dummy-&gt;mixer_lock);
+        //spin_lock_irqsave(&amp;dummy-&gt;mixer_lock, flags);
+        spin_lock_bh(&amp;dummy-&gt;mixer_lock);
+        ucontrol-&gt;value.integer.value[0] = dummy-&gt;capture_source[addr][0];
+        ucontrol-&gt;value.integer.value[1] = dummy-&gt;capture_source[addr][1];
+        //spin_unlock_irq(&amp;dummy-&gt;mixer_lock);
+        //spin_unlock_irqrestore(&amp;dummy-&gt;mixer_lock, flags);
+        spin_unlock_bh(&amp;dummy-&gt;mixer_lock);
+//printk(&quot;giova: capsrc_get %d %d\n&quot;, __LINE__, addr);
+        return 0;
+}
+
+static int snd_dummy_capsrc_put(struct snd_kcontrol *kcontrol, struct snd_ctl_elem_value *ucontrol)
+{
+        struct snd_dummy *dummy = snd_kcontrol_chip(kcontrol);
+        int change, addr = kcontrol-&gt;private_value;
+        int left, right;
+        //unsigned long flags;
+
+        if(in_irq())
+                printk(&quot;giova: line %d we are in HARDWARE IRQ\n&quot;, __LINE__);
+        left = ucontrol-&gt;value.integer.value[0] &amp; 1;
+        right = ucontrol-&gt;value.integer.value[1] &amp; 1;
+        //spin_lock_irq(&amp;dummy-&gt;mixer_lock);
+        //spin_lock_irqsave(&amp;dummy-&gt;mixer_lock, flags);
+        spin_lock_bh(&amp;dummy-&gt;mixer_lock);
+        change = dummy-&gt;capture_source[addr][0] != left &amp;&amp;
+                 dummy-&gt;capture_source[addr][1] != right;
+        dummy-&gt;capture_source[addr][0] = left;
+        dummy-&gt;capture_source[addr][1] = right;
+        //spin_unlock_irq(&amp;dummy-&gt;mixer_lock);
+        //spin_unlock_irqrestore(&amp;dummy-&gt;mixer_lock, flags);
+        spin_unlock_bh(&amp;dummy-&gt;mixer_lock);
+//printk(&quot;giova: capsrc_put %d %d\n&quot;, __LINE__, addr);
+        return change;
+}
+
+static struct snd_kcontrol_new snd_dummy_controls[] = {
+DUMMY_VOLUME(&quot;Master Volume&quot;, 0, MIXER_ADDR_MASTER),
+DUMMY_CAPSRC(&quot;Master Capture Switch&quot;, 0, MIXER_ADDR_MASTER),
+DUMMY_VOLUME(&quot;Synth Volume&quot;, 0, MIXER_ADDR_SYNTH),
+DUMMY_CAPSRC(&quot;Synth Capture Switch&quot;, 0, MIXER_ADDR_SYNTH),
+DUMMY_VOLUME(&quot;Line Volume&quot;, 0, MIXER_ADDR_LINE),
+DUMMY_CAPSRC(&quot;Line Capture Switch&quot;, 0, MIXER_ADDR_LINE),
+DUMMY_VOLUME(&quot;Mic Volume&quot;, 0, MIXER_ADDR_MIC),
+DUMMY_CAPSRC(&quot;Mic Capture Switch&quot;, 0, MIXER_ADDR_MIC),
+DUMMY_VOLUME(&quot;CD Volume&quot;, 0, MIXER_ADDR_CD),
+DUMMY_CAPSRC(&quot;CD Capture Switch&quot;, 0, MIXER_ADDR_CD)
+};
+
+static int __devinit snd_card_dummy_new_mixer(struct snd_dummy *dummy)
+{
+        struct snd_card *card = dummy-&gt;card;
+        unsigned int idx;
+        int err;
+
+        //giova if (snd_BUG_ON(!dummy))
+                //giova return -EINVAL;
+        spin_lock_init(&amp;dummy-&gt;mixer_lock);
+        strcpy(card-&gt;mixername, &quot;Dummy Mixer&quot;);
+//printk(&quot;giova: new_mixer %d\n&quot;, __LINE__);
+        return 0; //giova no mixer
+
+        for (idx = 0; idx &lt; ARRAY_SIZE(snd_dummy_controls); idx++) {
+                err = snd_ctl_add(card, snd_ctl_new1(&amp;snd_dummy_controls[idx], dummy));
+                if (err &lt; 0)
+                        return err;
+        }
+        return 0;
+}
+
+static int __devinit snd_dummy_probe(struct platform_device *devptr)
+{
+        struct snd_card *card;
+        struct snd_dummy *dummy;
+        int idx, err;
+        int dev = devptr-&gt;id;
+
+        card = snd_card_new(index[dev], id[dev], THIS_MODULE,
+                            sizeof(struct snd_dummy));
+        if (card == NULL)
+                return -ENOMEM;
+
+        //giova err = snd_card_create(index[dev], id[dev], THIS_MODULE,
+                              //giova sizeof(struct snd_dummy), &amp;card);
+        //giova if (err &lt; 0)
+                //giova return err;
+        dummy = card-&gt;private_data;
+        dummy-&gt;card = card;
+        for (idx = 0; idx &lt; MAX_PCM_DEVICES &amp;&amp; idx &lt; pcm_devs[dev]; idx++) {
+                if (pcm_substreams[dev] &lt; 1)
+                        pcm_substreams[dev] = 1;
+                if (pcm_substreams[dev] &gt; MAX_PCM_SUBSTREAMS)
+                        pcm_substreams[dev] = MAX_PCM_SUBSTREAMS;
+                err = snd_card_dummy_pcm(dummy, idx, pcm_substreams[dev]);
+                if (err &lt; 0)
+                        goto __nodev;
+        }
+        err = snd_card_dummy_new_mixer(dummy);
+        if (err &lt; 0)
+                goto __nodev;
+        strcpy(card-&gt;driver, &quot;Dummy&quot;);
+        strcpy(card-&gt;shortname, &quot;Dummy&quot;);
+        sprintf(card-&gt;longname, &quot;Dummy %i&quot;, dev + 1);
+
+        snd_card_set_dev(card, &amp;devptr-&gt;dev);
+
+        err = snd_card_register(card);
+        if (err == 0) {
+                platform_set_drvdata(devptr, card);
+                return 0;
+        }
+      __nodev:
+        snd_card_free(card);
+        return err;
+}
+
+static int __devexit snd_dummy_remove(struct platform_device *devptr)
+{
+
+        del_timer(&amp;giovatimer);
+        snd_card_free(platform_get_drvdata(devptr));
+        platform_set_drvdata(devptr, NULL);
+        return 0;
+}
+
+#ifdef CONFIG_PM
+static int snd_dummy_suspend(struct platform_device *pdev, pm_message_t state)
+{
+        struct snd_card *card = platform_get_drvdata(pdev);
+        struct snd_dummy *dummy = card-&gt;private_data;
+
+        snd_power_change_state(card, SNDRV_CTL_POWER_D3hot);
+        snd_pcm_suspend_all(dummy-&gt;pcm);
+        return 0;
+}
+        
+static int snd_dummy_resume(struct platform_device *pdev)
+{
+        struct snd_card *card = platform_get_drvdata(pdev);
+
+        snd_power_change_state(card, SNDRV_CTL_POWER_D0);
+        return 0;
+}
+#endif
+
+#define SND_DUMMY_DRIVER        &quot;snd_dummy&quot;
+
+static struct platform_driver snd_dummy_driver = {
+        .probe                = snd_dummy_probe,
+        .remove                = __devexit_p(snd_dummy_remove),
+#ifdef CONFIG_PM
+        .suspend        = snd_dummy_suspend,
+        .resume                = snd_dummy_resume,
+#endif
+        .driver                = {
+                .name        = SND_DUMMY_DRIVER
+        },
+};
+
+static void snd_dummy_unregister_all(void)
+{
+        int i;
+
+        for (i = 0; i &lt; ARRAY_SIZE(devices); ++i)
+                platform_device_unregister(devices[i]);
+        platform_driver_unregister(&amp;snd_dummy_driver);
+}
+
+static int __init alsa_card_dummy_init(void)
+{
+        int i, cards, err;
+
+        err = platform_driver_register(&amp;snd_dummy_driver);
+        if (err &lt; 0)
+                return err;
+
+if(!giovastarted){
+giovastarted=1;
+        spin_lock_init(&amp;giovalock);
+
+        spin_lock_bh(&amp;giovalock);
+for(i=0; i&lt;MAX_PCM_SUBSTREAMS;i++){
+
+        if(i &gt; MAX_PCM_SUBSTREAMS || giovaindex &gt; MAX_PCM_SUBSTREAMS){
+                printk(&quot;giova, %s:%d, i=%d, giovaindex=%d \n&quot;, __FILE__, __LINE__, i, giovaindex);
+        }
+giovadpcms[i].substream=NULL;
+giovadpcms[i].dpcm=NULL;
+giovadpcms[i].started=0;
+}
+        init_timer(&amp;giovatimer);
+        //giovatimer.data = (unsigned long) dpcm;
+        giovatimer.data = (unsigned long) &amp;giovadpcms;
+        giovatimer.function = snd_card_dummy_pcm_timer_function;
+        giovatimer.expires = (HZ/100) + jiffies;
+        add_timer(&amp;giovatimer);
+printk(&quot;giova skypiax: %d\n&quot;, __LINE__);
+        spin_unlock_bh(&amp;giovalock);
+}
+
+
+        cards = 0;
+        for (i = 0; i &lt; SNDRV_CARDS; i++) {
+                struct platform_device *device;
+                if (! enable[i])
+                        continue;
+                device = platform_device_register_simple(SND_DUMMY_DRIVER,
+                                                         i, NULL, 0);
+                if (IS_ERR(device))
+                        continue;
+                if (!platform_get_drvdata(device)) {
+                        platform_device_unregister(device);
+                        continue;
+                }
+                devices[i] = device;
+                cards++;
+        }
+        if (!cards) {
+#ifdef MODULE
+                printk(KERN_ERR &quot;Dummy soundcard not found or device busy\n&quot;);
+#endif
+                snd_dummy_unregister_all();
+                return -ENODEV;
+        }
+        return 0;
+}
+
+static void __exit alsa_card_dummy_exit(void)
+{
+        del_timer(&amp;giovatimer);
+        snd_dummy_unregister_all();
+}
+
+module_init(alsa_card_dummy_init)
+module_exit(alsa_card_dummy_exit)
</ins></span></pre>
</div>
</div>
<div id="footer">See you at ClueCon</div>

</body>
</html>