Linux kernel & device driver programming

Cross-Referenced Linux and Device Driver Code

[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ]
Version: [ 2.6.11.8 ] [ 2.6.25 ] [ 2.6.25.8 ] [ 2.6.31.13 ] Architecture: [ i386 ]

Diff markup

Differences between /linux/sound/core/seq/seq_system.c (Version 2.6.11.8) and /linux/sound/core/seq/seq_system.c (Version 2.6.25.8)


  1 /*                                                  1 /*
  2  *   ALSA sequencer System services Client          2  *   ALSA sequencer System services Client
  3  *   Copyright (c) 1998-1999 by Frank van de P      3  *   Copyright (c) 1998-1999 by Frank van de Pol <fvdpol@coil.demon.nl>
  4  *                                                  4  *
  5  *                                                  5  *
  6  *   This program is free software; you can re      6  *   This program is free software; you can redistribute it and/or modify
  7  *   it under the terms of the GNU General Pub      7  *   it under the terms of the GNU General Public License as published by
  8  *   the Free Software Foundation; either vers      8  *   the Free Software Foundation; either version 2 of the License, or
  9  *   (at your option) any later version.            9  *   (at your option) any later version.
 10  *                                                 10  *
 11  *   This program is distributed in the hope t     11  *   This program is distributed in the hope that it will be useful,
 12  *   but WITHOUT ANY WARRANTY; without even th     12  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 13  *   MERCHANTABILITY or FITNESS FOR A PARTICUL     13  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 14  *   GNU General Public License for more detai     14  *   GNU General Public License for more details.
 15  *                                                 15  *
 16  *   You should have received a copy of the GN     16  *   You should have received a copy of the GNU General Public License
 17  *   along with this program; if not, write to     17  *   along with this program; if not, write to the Free Software
 18  *   Foundation, Inc., 59 Temple Place, Suite      18  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 19  *                                                 19  *
 20  */                                                20  */
 21                                                    21 
 22 #include <sound/driver.h>                      << 
 23 #include <linux/init.h>                            22 #include <linux/init.h>
 24 #include <sound/core.h>                            23 #include <sound/core.h>
 25 #include "seq_system.h"                            24 #include "seq_system.h"
 26 #include "seq_timer.h"                             25 #include "seq_timer.h"
 27 #include "seq_queue.h"                             26 #include "seq_queue.h"
 28                                                    27 
 29 /* internal client that provide system service     28 /* internal client that provide system services, access to timer etc. */
 30                                                    29 
 31 /*                                                 30 /*
 32  * Port "Timer"                                    31  * Port "Timer"
 33  *      - send tempo /start/stop etc. events t     32  *      - send tempo /start/stop etc. events to this port to manipulate the 
 34  *        queue's timer. The queue address is      33  *        queue's timer. The queue address is specified in
 35  *        data.queue.queue.                        34  *        data.queue.queue.
 36  *      - this port supports subscription. The     35  *      - this port supports subscription. The received timer events are 
 37  *        broadcasted to all subscribed client     36  *        broadcasted to all subscribed clients. The modified tempo
 38  *        value is stored on data.queue.value.     37  *        value is stored on data.queue.value.
 39  *        The modifier client/port is not send     38  *        The modifier client/port is not send.
 40  *                                                 39  *
 41  * Port "Announce"                                 40  * Port "Announce"
 42  *      - does not receive message                 41  *      - does not receive message
 43  *      - supports supscription. For each clie     42  *      - supports supscription. For each client or port attaching to or 
 44  *        detaching from the system an announc     43  *        detaching from the system an announcement is send to the subscribed
 45  *        clients.                                 44  *        clients.
 46  *                                                 45  *
 47  * Idea: the subscription mechanism might also     46  * Idea: the subscription mechanism might also work handy for distributing 
 48  * synchronisation and timing information. In      47  * synchronisation and timing information. In this case we would ideally have
 49  * a list of subscribers for each type of sync     48  * a list of subscribers for each type of sync (time, tick), for each timing
 50  * queue.                                          49  * queue.
 51  *                                                 50  *
 52  * NOTE: the queue to be started, stopped, etc     51  * NOTE: the queue to be started, stopped, etc. must be specified
 53  *       in data.queue.addr.queue field.  queu     52  *       in data.queue.addr.queue field.  queue is used only for
 54  *       scheduling, and no longer referred as     53  *       scheduling, and no longer referred as affected queue.
 55  *       They are used only for timer broadcas     54  *       They are used only for timer broadcast (see above).
 56  *                                                 55  *                                                      -- iwai
 57  */                                                56  */
 58                                                    57 
 59                                                    58 
 60 /* client id of our system client */               59 /* client id of our system client */
 61 static int sysclient = -1;                         60 static int sysclient = -1;
 62                                                    61 
 63 /* port id numbers for this client */              62 /* port id numbers for this client */
 64 static int announce_port = -1;                     63 static int announce_port = -1;
 65                                                    64 
 66                                                    65 
 67                                                    66 
 68 /* fill standard header data, source port & ch     67 /* fill standard header data, source port & channel are filled in */
 69 static int setheader(snd_seq_event_t * ev, int !!  68 static int setheader(struct snd_seq_event * ev, int client, int port)
 70 {                                                  69 {
 71         if (announce_port < 0)                     70         if (announce_port < 0)
 72                 return -ENODEV;                    71                 return -ENODEV;
 73                                                    72 
 74         memset(ev, 0, sizeof(snd_seq_event_t)) !!  73         memset(ev, 0, sizeof(struct snd_seq_event));
 75                                                    74 
 76         ev->flags &= ~SNDRV_SEQ_EVENT_LENGTH_M     75         ev->flags &= ~SNDRV_SEQ_EVENT_LENGTH_MASK;
 77         ev->flags |= SNDRV_SEQ_EVENT_LENGTH_FI     76         ev->flags |= SNDRV_SEQ_EVENT_LENGTH_FIXED;
 78                                                    77 
 79         ev->source.client = sysclient;             78         ev->source.client = sysclient;
 80         ev->source.port = announce_port;           79         ev->source.port = announce_port;
 81         ev->dest.client = SNDRV_SEQ_ADDRESS_SU     80         ev->dest.client = SNDRV_SEQ_ADDRESS_SUBSCRIBERS;
 82                                                    81 
 83         /* fill data */                            82         /* fill data */
 84         /*ev->data.addr.queue = SNDRV_SEQ_ADDR     83         /*ev->data.addr.queue = SNDRV_SEQ_ADDRESS_UNKNOWN;*/
 85         ev->data.addr.client = client;             84         ev->data.addr.client = client;
 86         ev->data.addr.port = port;                 85         ev->data.addr.port = port;
 87                                                    86 
 88         return 0;                                  87         return 0;
 89 }                                                  88 }
 90                                                    89 
 91                                                    90 
 92 /* entry points for broadcasting system events     91 /* entry points for broadcasting system events */
 93 void snd_seq_system_broadcast(int client, int      92 void snd_seq_system_broadcast(int client, int port, int type)
 94 {                                                  93 {
 95         snd_seq_event_t ev;                    !!  94         struct snd_seq_event ev;
 96                                                    95         
 97         if (setheader(&ev, client, port) < 0)      96         if (setheader(&ev, client, port) < 0)
 98                 return;                            97                 return;
 99         ev.type = type;                            98         ev.type = type;
100         snd_seq_kernel_client_dispatch(sysclie     99         snd_seq_kernel_client_dispatch(sysclient, &ev, 0, 0);
101 }                                                 100 }
102                                                   101 
103 /* entry points for broadcasting system events    102 /* entry points for broadcasting system events */
104 int snd_seq_system_notify(int client, int port !! 103 int snd_seq_system_notify(int client, int port, struct snd_seq_event *ev)
105 {                                                 104 {
106         ev->flags = SNDRV_SEQ_EVENT_LENGTH_FIX    105         ev->flags = SNDRV_SEQ_EVENT_LENGTH_FIXED;
107         ev->source.client = sysclient;            106         ev->source.client = sysclient;
108         ev->source.port = announce_port;          107         ev->source.port = announce_port;
109         ev->dest.client = client;                 108         ev->dest.client = client;
110         ev->dest.port = port;                     109         ev->dest.port = port;
111         return snd_seq_kernel_client_dispatch(    110         return snd_seq_kernel_client_dispatch(sysclient, ev, 0, 0);
112 }                                                 111 }
113                                                   112 
114 /* call-back handler for timer events */          113 /* call-back handler for timer events */
115 static int event_input_timer(snd_seq_event_t * !! 114 static int event_input_timer(struct snd_seq_event * ev, int direct, void *private_data, int atomic, int hop)
116 {                                                 115 {
117         return snd_seq_control_queue(ev, atomi    116         return snd_seq_control_queue(ev, atomic, hop);
118 }                                                 117 }
119                                                   118 
120 /* register our internal client */                119 /* register our internal client */
121 int __init snd_seq_system_client_init(void)       120 int __init snd_seq_system_client_init(void)
122 {                                                 121 {
                                                   >> 122         struct snd_seq_port_callback pcallbacks;
                                                   >> 123         struct snd_seq_port_info *port;
123                                                   124 
124         snd_seq_client_callback_t callbacks;   !! 125         port = kzalloc(sizeof(*port), GFP_KERNEL);
125         snd_seq_port_callback_t pcallbacks;    !! 126         if (!port)
126         snd_seq_client_info_t inf;             !! 127                 return -ENOMEM;
127         snd_seq_port_info_t port;              << 
128                                                   128 
129         memset(&callbacks, 0, sizeof(callbacks << 
130         memset(&pcallbacks, 0, sizeof(pcallbac    129         memset(&pcallbacks, 0, sizeof(pcallbacks));
131         memset(&inf, 0, sizeof(inf));          << 
132         memset(&port, 0, sizeof(port));        << 
133         pcallbacks.owner = THIS_MODULE;           130         pcallbacks.owner = THIS_MODULE;
134         pcallbacks.event_input = event_input_t    131         pcallbacks.event_input = event_input_timer;
135                                                   132 
136         /* register client */                     133         /* register client */
137         callbacks.allow_input = callbacks.allo !! 134         sysclient = snd_seq_create_kernel_client(NULL, 0, "System");
138         sysclient = snd_seq_create_kernel_clie << 
139                                                << 
140         /* set our name */                     << 
141         inf.client = 0;                        << 
142         inf.type = KERNEL_CLIENT;              << 
143         strcpy(inf.name, "System");            << 
144         snd_seq_kernel_client_ctl(sysclient, S << 
145                                                   135 
146         /* register timer */                      136         /* register timer */
147         strcpy(port.name, "Timer");            !! 137         strcpy(port->name, "Timer");
148         port.capability = SNDRV_SEQ_PORT_CAP_W !! 138         port->capability = SNDRV_SEQ_PORT_CAP_WRITE; /* accept queue control */
149         port.capability |= SNDRV_SEQ_PORT_CAP_ !! 139         port->capability |= SNDRV_SEQ_PORT_CAP_READ|SNDRV_SEQ_PORT_CAP_SUBS_READ; /* for broadcast */
150         port.kernel = &pcallbacks;             !! 140         port->kernel = &pcallbacks;
151         port.type = 0;                         !! 141         port->type = 0;
152         port.flags = SNDRV_SEQ_PORT_FLG_GIVEN_ !! 142         port->flags = SNDRV_SEQ_PORT_FLG_GIVEN_PORT;
153         port.addr.client = sysclient;          !! 143         port->addr.client = sysclient;
154         port.addr.port = SNDRV_SEQ_PORT_SYSTEM !! 144         port->addr.port = SNDRV_SEQ_PORT_SYSTEM_TIMER;
155         snd_seq_kernel_client_ctl(sysclient, S !! 145         snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT, port);
156                                                   146 
157         /* register announcement port */          147         /* register announcement port */
158         strcpy(port.name, "Announce");         !! 148         strcpy(port->name, "Announce");
159         port.capability = SNDRV_SEQ_PORT_CAP_R !! 149         port->capability = SNDRV_SEQ_PORT_CAP_READ|SNDRV_SEQ_PORT_CAP_SUBS_READ; /* for broadcast only */
160         port.kernel = NULL;                    !! 150         port->kernel = NULL;
161         port.type = 0;                         !! 151         port->type = 0;
162         port.flags = SNDRV_SEQ_PORT_FLG_GIVEN_ !! 152         port->flags = SNDRV_SEQ_PORT_FLG_GIVEN_PORT;
163         port.addr.client = sysclient;          !! 153         port->addr.client = sysclient;
164         port.addr.port = SNDRV_SEQ_PORT_SYSTEM !! 154         port->addr.port = SNDRV_SEQ_PORT_SYSTEM_ANNOUNCE;
165         snd_seq_kernel_client_ctl(sysclient, S !! 155         snd_seq_kernel_client_ctl(sysclient, SNDRV_SEQ_IOCTL_CREATE_PORT, port);
166         announce_port = port.addr.port;        !! 156         announce_port = port->addr.port;
167                                                   157 
                                                   >> 158         kfree(port);
168         return 0;                                 159         return 0;
169 }                                                 160 }
170                                                   161 
171                                                   162 
172 /* unregister our internal client */              163 /* unregister our internal client */
173 void __exit snd_seq_system_client_done(void)      164 void __exit snd_seq_system_client_done(void)
174 {                                                 165 {
175         int oldsysclient = sysclient;             166         int oldsysclient = sysclient;
176                                                   167 
177         if (oldsysclient >= 0) {                  168         if (oldsysclient >= 0) {
178                 sysclient = -1;                   169                 sysclient = -1;
179                 announce_port = -1;               170                 announce_port = -1;
180                 snd_seq_delete_kernel_client(o    171                 snd_seq_delete_kernel_client(oldsysclient);
181         }                                         172         }
182 }                                                 173 }
183                                                   174 
  This page was automatically generated by the LXR engine.