~ubuntu-branches/ubuntu/vivid/oss4/vivid

« back to all changes in this revision

Viewing changes to setup/gen_driver_freebsd.inc

  • Committer: Bazaar Package Importer
  • Author(s): Romain Beauxis, Samuel Thibault, Romain Beauxis, Sebastien NOEL
  • Date: 2011-06-14 10:06:56 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110614100656-cx4oc7u426zn812z
Tags: 4.2-build2004-1
[ Samuel Thibault ]
* debian/control: Add liboss4-salsa2, liboss4-salsa-dev and
  liboss4-salsa-asound2 packages, equivalent to (and will replace) those from
  the oss-libsalsa package (Closes: #589127).
* debian/patches/liboss4-salsa.patch: New patch to rename libsalsa into
  liboss4-salsa to avoid conflicts in the archive for no good reason.
* debian/rules: Make in libOSSlib and libsalsa.
* debian/liboss4-salsa-dev.install, debian/liboss4-salsa2.install,
  debian/liboss4-salsa-asound2.links, debian/liboss4-salsa-dev.links:
  Install liboss4-salsa libraries like was done in the oss-libsalsa package.
* include-alsa: Add a copy of ALSA 1.0.5 headers: Cf ALSA_1.0.* symbols in
  libsalsa, this is the roughly supported version.
* debian/copyright: Update for new include-alsa files.
* alsa.pc: New file for compatibility with libasound-dev.
* debian/control:
  - Add Vcs-Browser and Vcs-Svn fields.
  - Use linux-any instead of the list of Linux archs (Closes: #604679).
  - Make dkms dependency linux-any only.
* debian/patches/hurd_iot.patch: New patch to fix soundcard.h usage in
  libsalsa on hurd-i386.
* debian/patches/libsalsa_fixes.patch: New patch to fix some printf usages
  and ioctl declaration in libsalsa.
* debian/patches/no_EBADE.patch: New patch to cope with hurd-i386 not having
  EBADE.
* debian/patches/CFLAGS.patch: New patch to make oss4 take debian/rules
  CFLAGS into account.
* debian/patches/snd_asoundlib_version.patch: New patch to add
  snd_asoundlib_version().
* debian/patches/generic_srccconf.patch: New patch to fix source
  configuration on unknown archs.

[ Romain Beauxis ]
* Fixed README.Debian to only mention dkms' modules.
* Switch to dpkg-source 3.0 (quilt) format
* Added DM-Upload-Allowed: yes

[ Sebastien NOEL ]
* New upstream release (Closes: #595298, #619272).
* Fix typo in initscript (Closes: #627149).
* debian/control: adjust linux-headers dependencies (Closes: #628879).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
static void
 
2
generate_driver (char *name, conf_t * conf, char *cfg_name, char *cfg_header,
 
3
                 char *dirname, char *topdir)
 
4
{
 
5
  /* FreeBSD version */
 
6
 
 
7
  FILE *f, *src;
 
8
  char tmp[256], line[256], *p, *s;
 
9
  int i, n = 0;
 
10
  char *options[MAXOPTS];
 
11
  char *option_desc[MAXOPTS];
 
12
  char desc[65536];
 
13
  int nopts = 0;
 
14
 
 
15
  sprintf (tmp, "target/build/%s.c", name);
 
16
  if ((src = fopen (tmp, "w")) == NULL)
 
17
    {
 
18
      perror (tmp);
 
19
      exit (-1);
 
20
    }
 
21
 
 
22
  fprintf (src, "/*\n");
 
23
  fprintf (src, " * Automatically generated file - do not edit.\n");
 
24
  fprintf (src, " */\n");
 
25
  fprintf (src, "#include \"devid.h\"\n\n");
 
26
 
 
27
  fprintf (src, "#define DRIVER_NAME\t%s\n", name);
 
28
  fprintf (src, "#define DRIVER_NICK\t\"%s\"\n", name);
 
29
  fprintf (src, "#define DRIVER_PURPOSE\t\"%s\"\n", conf->purpose);
 
30
  fprintf (src, "#define DRIVER_STR_INFO\t%s_str_info\n", name);
 
31
  fprintf (src, "#define DRIVER_ATTACH\t%s_attach\n", name);
 
32
  fprintf (src, "#define DRIVER_DETACH\t%s_detach\n", name);
 
33
  fprintf (src, "#define DRIVER_TYPE\tDRV_%s\n", conf->bus);
 
34
  fprintf (src, "#define DEVTYPE_%s\n", conf->bus);
 
35
  fprintf (src, "\n");
 
36
 
 
37
/*
 
38
 * Handle driver specific configuration options
 
39
 */
 
40
  *desc = 0;
 
41
  sprintf (tmp, "%s/.params", dirname);
 
42
  if ((f = fopen (tmp, "r")) != NULL)
 
43
    {
 
44
      while (fgets (line, sizeof (line) - 1, f) != NULL)
 
45
        {
 
46
          p = line + strlen (line) - 1;
 
47
          if (*p == '\n')
 
48
            *p = 0;
 
49
 
 
50
          fprintf (src, "%s\n", line);
 
51
          if (strncmp (line, "int ", 4) == 0)
 
52
            {
 
53
              char *s = line + 4, *p = s;
 
54
 
 
55
              while (*p && *p != '=' && *p != ';' && *p != ' ')
 
56
                p++;
 
57
              *p = 0;
 
58
              if (nopts >= MAXOPTS)
 
59
                {
 
60
                  fprintf (stderr, "Too many options for driver '%s' (%d)\n",
 
61
                           name, nopts);
 
62
                  exit (-1);
 
63
                }
 
64
 
 
65
              if (nopts != 0 && *desc != 0)
 
66
                option_desc[nopts - 1] = strdup (desc);
 
67
              option_desc[nopts] = 0;
 
68
              options[nopts++] = strdup (s);
 
69
              *desc = 0;
 
70
            }
 
71
          else
 
72
            {
 
73
              char *s = line, *p;
 
74
              char tmp[4096];
 
75
              while (*s == ' ' || *s == '/' || *s == '*')
 
76
                s++;
 
77
 
 
78
              p = tmp;
 
79
 
 
80
              while (*s)
 
81
                {
 
82
                  if (*s == '"')
 
83
                    *p++ = '\\';
 
84
 
 
85
                  *p++ = *s++;;
 
86
                }
 
87
              *p = 0;
 
88
 
 
89
              p = desc + strlen (desc);
 
90
              sprintf (p, "\n\"%s\\n\"", tmp);
 
91
            }
 
92
        }
 
93
 
 
94
      fclose (f);
 
95
    }
 
96
 
 
97
  if (nopts > 0 && *desc != 0)
 
98
    option_desc[nopts - 1] = strdup (desc);
 
99
 
 
100
  if ((f = fopen ("devices.list", "r")) == NULL)
 
101
    {
 
102
      perror ("devices.list");
 
103
      exit (-1);
 
104
    }
 
105
 
 
106
  if (strcmp (conf->bus, "PCI") == 0)
 
107
    {
 
108
      fprintf (src, "static device_id_t id_table[] = {\n");
 
109
 
 
110
      while (fgets (line, sizeof (line) - 1, f) != NULL)
 
111
        {
 
112
          int vendor, product;
 
113
          p = line + strlen (line) - 1;
 
114
          if (*p == '\n')
 
115
            *p = 0;
 
116
 
 
117
          p = line;
 
118
          while (*p && *p != '\t')
 
119
            p++;
 
120
          if (*p == '\t')
 
121
            *p++ = 0;
 
122
 
 
123
          if (strcmp (line, name) != 0)
 
124
            continue;
 
125
 
 
126
          n++;
 
127
 
 
128
          s = p;
 
129
          while (*p && *p != '\t')
 
130
            p++;
 
131
          if (*p == '\t')
 
132
            *p++ = 0;
 
133
 
 
134
          if (strncmp (s, "pci", 3) == 0)
 
135
            {
 
136
              if (sscanf (s + 3, "%x,%x", &vendor, &product) != 2)
 
137
                {
 
138
                  fprintf (stderr, "Bad PCI id %s\n", s);
 
139
                }
 
140
 
 
141
              fprintf (src, "\t{0x%x,\t0x%x},\n", vendor, product);
 
142
            }
 
143
 
 
144
        }
 
145
 
 
146
      fclose (f);
 
147
 
 
148
      fprintf (src, "\t{0}\n");
 
149
      fprintf (src, "};\n");
 
150
      fprintf (src, "\n");
 
151
    }
 
152
 
 
153
#if 0
 
154
  if (strcmp (conf->bus, "USB") == 0)
 
155
    {
 
156
      fprintf (src, "#include <linux/mod_devicetable.h>\n\n");
 
157
      fprintf (src, "#define strcpy dummy_strcpy\n");
 
158
      fprintf (src, "#include <linux/usb.h>\n");
 
159
      fprintf (src, "#undef strcpy\n");
 
160
      fprintf (src, "static struct usb_device_id udi_usb_table[] = {\n");
 
161
 
 
162
      while (fgets (line, sizeof (line) - 1, f) != NULL)
 
163
        {
 
164
          int vendor, product;
 
165
          p = line + strlen (line) - 1;
 
166
          if (*p == '\n')
 
167
            *p = 0;
 
168
 
 
169
          p = line;
 
170
          while (*p && *p != '\t')
 
171
            p++;
 
172
          if (*p == '\t')
 
173
            *p++ = 0;
 
174
 
 
175
          if (strcmp (line, name) != 0)
 
176
            continue;
 
177
 
 
178
          n++;
 
179
 
 
180
          s = p;
 
181
          while (*p && *p != '\t')
 
182
            p++;
 
183
          if (*p == '\t')
 
184
            *p++ = 0;
 
185
 
 
186
          if (strcmp (s, "usbif,class1") == 0)
 
187
            continue;
 
188
 
 
189
          if (strncmp (s, "usbi", 4) == 0)
 
190
            {
 
191
              if (sscanf (s + 4, "%x,%x", &vendor, &product) != 2)
 
192
                {
 
193
                  fprintf (stderr, "Bad USB id %s\n", s);
 
194
                }
 
195
 
 
196
              fprintf (src,
 
197
                       "\t{.match_flags=USB_DEVICE_ID_MATCH_DEVICE,\t.idVendor=0x%x,\t.idProduct=0x%x},\n",
 
198
                       vendor, product);
 
199
              continue;
 
200
            }
 
201
 
 
202
          if (strncmp (s, "usb", 3) == 0)
 
203
            {
 
204
              if (sscanf (s + 3, "%x,%x", &vendor, &product) != 2)
 
205
                {
 
206
                  fprintf (stderr, "Bad USB id %s\n", s);
 
207
                }
 
208
 
 
209
              fprintf (src,
 
210
                       "\t{.match_flags=USB_DEVICE_ID_MATCH_DEVICE,\t.idVendor=0x%x,\t.idProduct=0x%x},\n",
 
211
                       vendor, product);
 
212
              continue;
 
213
            }
 
214
 
 
215
 
 
216
        }
 
217
 
 
218
      fclose (f);
 
219
 
 
220
      fprintf (src, "\t{match_flags:USB_DEVICE_ID_MATCH_INT_CLASS,\n");
 
221
      fprintf (src, "\tbInterfaceClass: USB_CLASS_AUDIO},\n");
 
222
      fprintf (src, "\t{0}\n");
 
223
      fprintf (src, "};\n");
 
224
      fprintf (src, "\n");
 
225
    }
 
226
#endif /* USB */
 
227
 
 
228
  fprintf (src, "#include \"module.inc\"\n");
 
229
  fprintf (src, "\n");
 
230
 
 
231
  if (strcmp (conf->bus, "PCI") == 0)
 
232
    {
 
233
      fprintf (src,
 
234
               "DEFINE_CLASS_0(%s, osspci_driver, osspci_methods, sizeof(struct _oss_device_t));\n",
 
235
               name);
 
236
      fprintf (src,
 
237
               "DRIVER_MODULE(%s, pci, osspci_driver, osspci_devclass, 0, 0);\n",
 
238
               name);
 
239
    }
 
240
 
 
241
  for (i = 0; i < nopts; i++)
 
242
    {
 
243
      fprintf (src, "TUNABLE_INT(\"%s.%s\", &%s);\n", name, options[i], options[i]);
 
244
#if 0
 
245
      if (option_desc[i] != NULL)
 
246
        fprintf (src, "MODULE_PARM_DESC(%s, %s);\n", options[i],
 
247
                 option_desc[i]);
 
248
#endif
 
249
    }
 
250
  fprintf (src, "\n");
 
251
 
 
252
  fclose (src);
 
253
 
 
254
  sprintf (tmp, "%s/%s", dirname, cfg_header);
 
255
  if ((src = fopen (tmp, "w")) == NULL)
 
256
    {
 
257
      perror (tmp);
 
258
      exit (-1);
 
259
    }
 
260
 
 
261
  fprintf (src, "/*\n");
 
262
  fprintf (src, " * Automatically generated file - do not edit.\n");
 
263
  fprintf (src, " */\n");
 
264
 
 
265
  fprintf (src, "#include <oss_config.h>\n");
 
266
  fprintf (src, "\n");
 
267
 
 
268
  fprintf (src, "#define DRIVER_NAME\t%s\n", name);
 
269
  fprintf (src, "#define DRIVER_NICK\t\"%s\"\n", name);
 
270
  fprintf (src, "#define DRIVER_STR_INFO\t%s_str_info\n", name);
 
271
  fprintf (src, "#define DRIVER_ATTACH\t%s_attach\n", name);
 
272
  fprintf (src, "#define DRIVER_DETACH\t%s_detach\n", name);
 
273
  fprintf (src, "#define DRIVER_TYPE\tDRV_%s\n", conf->bus);
 
274
  fprintf (src, "\n");
 
275
 
 
276
  fprintf (src, "extern int DRIVER_ATTACH(oss_device_t *ossdev);\n");
 
277
  fprintf (src, "extern int DRIVER_DETACH(oss_device_t *ossdev);\n");
 
278
 
 
279
  fclose (src);
 
280
}