tizen 2.3.1 release
[external/alsa-lib.git] / src / hwdep / hwdep.c
1 /**
2  * \file hwdep/hwdep.c
3  * \brief HwDep Interface (hardware dependent)
4  * \author Jaroslav Kysela <perex@perex.cz>
5  * \date 2000-2001
6  *
7  * HwDep (hardware dependent) Interface is designed for individual hardware
8  * access. This interface does not cover any API specification.
9  */
10 /*
11  *  Hardware dependent Interface - main file
12  *  Copyright (c) 2000 by Jaroslav Kysela <perex@perex.cz>
13  *
14  *
15  *   This library is free software; you can redistribute it and/or modify
16  *   it under the terms of the GNU Lesser General Public License as
17  *   published by the Free Software Foundation; either version 2.1 of
18  *   the License, or (at your option) any later version.
19  *
20  *   This program is distributed in the hope that it will be useful,
21  *   but WITHOUT ANY WARRANTY; without even the implied warranty of
22  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23  *   GNU Lesser General Public License for more details.
24  *
25  *   You should have received a copy of the GNU Lesser General Public
26  *   License along with this library; if not, write to the Free Software
27  *   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
28  *
29  */
30
31 #include <stdio.h>
32 #include <stdlib.h>
33 #include <unistd.h>
34 #include <string.h>
35 #include <fcntl.h>
36 #include <sys/ioctl.h>
37 #include "hwdep_local.h"
38
39 static int snd_hwdep_open_conf(snd_hwdep_t **hwdep,
40                                const char *name, snd_config_t *hwdep_root,
41                                snd_config_t *hwdep_conf, int mode)
42 {
43         const char *str;
44         char buf[256];
45         int err;
46         snd_config_t *conf, *type_conf = NULL;
47         snd_config_iterator_t i, next;
48         const char *id;
49         const char *lib = NULL, *open_name = NULL;
50         int (*open_func)(snd_hwdep_t **, const char *, snd_config_t *, snd_config_t *, int) = NULL;
51 #ifndef PIC
52         extern void *snd_hwdep_open_symbols(void);
53 #endif
54         void *h = NULL;
55         if (snd_config_get_type(hwdep_conf) != SND_CONFIG_TYPE_COMPOUND) {
56                 if (name)
57                         SNDERR("Invalid type for HWDEP %s definition", name);
58                 else
59                         SNDERR("Invalid type for HWDEP definition");
60                 return -EINVAL;
61         }
62         err = snd_config_search(hwdep_conf, "type", &conf);
63         if (err < 0) {
64                 SNDERR("type is not defined");
65                 return err;
66         }
67         err = snd_config_get_id(conf, &id);
68         if (err < 0) {
69                 SNDERR("unable to get id");
70                 return err;
71         }
72         err = snd_config_get_string(conf, &str);
73         if (err < 0) {
74                 SNDERR("Invalid type for %s", id);
75                 return err;
76         }
77         err = snd_config_search_definition(hwdep_root, "hwdep_type", str, &type_conf);
78         if (err >= 0) {
79                 if (snd_config_get_type(type_conf) != SND_CONFIG_TYPE_COMPOUND) {
80                         SNDERR("Invalid type for HWDEP type %s definition", str);
81                         err = -EINVAL;
82                         goto _err;
83                 }
84                 snd_config_for_each(i, next, type_conf) {
85                         snd_config_t *n = snd_config_iterator_entry(i);
86                         const char *id;
87                         if (snd_config_get_id(n, &id) < 0)
88                                 continue;
89                         if (strcmp(id, "comment") == 0)
90                                 continue;
91                         if (strcmp(id, "lib") == 0) {
92                                 err = snd_config_get_string(n, &lib);
93                                 if (err < 0) {
94                                         SNDERR("Invalid type for %s", id);
95                                         goto _err;
96                                 }
97                                 continue;
98                         }
99                         if (strcmp(id, "open") == 0) {
100                                 err = snd_config_get_string(n, &open_name);
101                                 if (err < 0) {
102                                         SNDERR("Invalid type for %s", id);
103                                         goto _err;
104                                 }
105                                 continue;
106                         }
107                         SNDERR("Unknown field %s", id);
108                         err = -EINVAL;
109                         goto _err;
110                 }
111         }
112         if (!open_name) {
113                 open_name = buf;
114                 snprintf(buf, sizeof(buf), "_snd_hwdep_%s_open", str);
115         }
116 #ifndef PIC
117         snd_hwdep_open_symbols();
118 #endif
119         h = snd_dlopen(lib, RTLD_NOW);
120         if (h)
121                 open_func = snd_dlsym(h, open_name, SND_DLSYM_VERSION(SND_HWDEP_DLSYM_VERSION));
122         err = 0;
123         if (!h) {
124                 SNDERR("Cannot open shared library %s", lib);
125                 err = -ENOENT;
126         } else if (!open_func) {
127                 SNDERR("symbol %s is not defined inside %s", open_name, lib);
128                 snd_dlclose(h);
129                 err = -ENXIO;
130         }
131        _err:
132         if (type_conf)
133                 snd_config_delete(type_conf);
134         if (err >= 0) {
135                 err = open_func(hwdep, name, hwdep_root, hwdep_conf, mode);
136                 if (err >= 0) {
137                         (*hwdep)->dl_handle = h;
138                 } else {
139                         snd_dlclose(h);
140                 }
141         }
142         return err;
143 }
144
145 static int snd_hwdep_open_noupdate(snd_hwdep_t **hwdep, snd_config_t *root, const char *name, int mode)
146 {
147         int err;
148         snd_config_t *hwdep_conf;
149         err = snd_config_search_definition(root, "hwdep", name, &hwdep_conf);
150         if (err < 0) {
151                 SNDERR("Unknown HwDep %s", name);
152                 return err;
153         }
154         err = snd_hwdep_open_conf(hwdep, name, root, hwdep_conf, mode);
155         snd_config_delete(hwdep_conf);
156         return err;
157 }
158
159 /**
160  * \brief Opens a new connection to the HwDep interface.
161  * \param hwdep Returned handle (NULL if not wanted)
162  * \param name ASCII identifier of the HwDep handle
163  * \param mode Open mode
164  * \return 0 on success otherwise a negative error code
165  *
166  * Opens a new connection to the HwDep interface specified with
167  * an ASCII identifier and mode.
168  */
169 int snd_hwdep_open(snd_hwdep_t **hwdep, const char *name, int mode)
170 {
171         int err;
172         assert(hwdep && name);
173         err = snd_config_update();
174         if (err < 0)
175                 return err;
176         return snd_hwdep_open_noupdate(hwdep, snd_config, name, mode);
177 }
178
179 /**
180  * \brief Opens a new connection to the HwDep interface using local configuration
181  * \param hwdep Returned handle (NULL if not wanted)
182  * \param name ASCII identifier of the HwDep handle
183  * \param mode Open mode
184  * \param lconf The local configuration tree
185  * \return 0 on success otherwise a negative error code
186  *
187  * Opens a new connection to the HwDep interface specified with
188  * an ASCII identifier and mode.
189  */
190 int snd_hwdep_open_lconf(snd_hwdep_t **hwdep, const char *name,
191                          int mode, snd_config_t *lconf)
192 {
193         assert(hwdep && name && lconf);
194         return snd_hwdep_open_noupdate(hwdep, lconf, name, mode);
195 }
196
197 /**
198  * \brief close HwDep handle
199  * \param hwdep HwDep handle
200  * \return 0 on success otherwise a negative error code
201  *
202  * Closes the specified HwDep handle and frees all associated
203  * resources.
204  */
205 int snd_hwdep_close(snd_hwdep_t *hwdep)
206 {
207         int err;
208         assert(hwdep);
209         err = hwdep->ops->close(hwdep);
210         if (hwdep->dl_handle)
211                 snd_dlclose(hwdep->dl_handle);
212         free(hwdep->name);
213         free(hwdep);
214         return err;
215 }
216
217 /**
218  * \brief get identifier of HwDep handle
219  * \param hwdep a Hwdep handle
220  * \return ascii identifier of HwDep handle
221  *
222  * Returns the ASCII identifier of given HwDep handle. It's the same
223  * identifier specified in snd_hwdep_open().
224  */
225 const char *snd_hwdep_name(snd_hwdep_t *hwdep)
226 {
227         assert(hwdep);
228         return hwdep->name;
229 }
230
231 /**
232  * \brief get type of HwDep handle
233  * \param hwdep a HwDep handle
234  * \return type of HwDep handle
235  *
236  * Returns the type #snd_hwdep_type_t of given HwDep handle.
237  */
238 snd_hwdep_type_t snd_hwdep_type(snd_hwdep_t *hwdep)
239 {
240         assert(hwdep);
241         return hwdep->type;
242 }
243
244 /**
245  * \brief get count of poll descriptors for HwDep handle
246  * \param hwdep HwDep handle
247  * \return count of poll descriptors
248  */
249 int snd_hwdep_poll_descriptors_count(snd_hwdep_t *hwdep)
250 {
251         assert(hwdep);
252         return 1;
253 }
254
255 /**
256  * \brief get poll descriptors
257  * \param hwdep HwDep handle
258  * \param pfds array of poll descriptors
259  * \param space space in the poll descriptor array
260  * \return count of filled descriptors
261  */
262 int snd_hwdep_poll_descriptors(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned int space)
263 {
264         assert(hwdep);
265         if (space >= 1) {
266                 pfds->fd = hwdep->poll_fd;
267                 switch (hwdep->mode & O_ACCMODE) {
268                 case O_WRONLY:
269                         pfds->events = POLLOUT|POLLERR|POLLNVAL;
270                         break;
271                 case O_RDONLY:
272                         pfds->events = POLLIN|POLLERR|POLLNVAL;
273                         break;
274                 case O_RDWR:
275                         pfds->events = POLLOUT|POLLIN|POLLERR|POLLNVAL;
276                         break;
277                 default:
278                         return -EIO;
279                 }
280                 return 1;
281         }
282         return 0;
283 }
284
285 /**
286  * \brief get returned events from poll descriptors
287  * \param hwdep HwDep  handle
288  * \param pfds array of poll descriptors
289  * \param nfds count of poll descriptors
290  * \param revents returned events
291  * \return zero if success, otherwise a negative error code
292  */
293 int snd_hwdep_poll_descriptors_revents(snd_hwdep_t *hwdep, struct pollfd *pfds, unsigned int nfds, unsigned short *revents)
294 {
295         assert(hwdep && pfds && revents);
296         if (nfds == 1) {
297                 *revents = pfds->revents;
298                 return 0;
299         }
300         return -EINVAL;
301 }                                                                       
302                                                                        
303 /**
304  * \brief set nonblock mode
305  * \param hwdep HwDep handle
306  * \param nonblock 0 = block, 1 = nonblock mode
307  * \return 0 on success otherwise a negative error code
308  */
309 int snd_hwdep_nonblock(snd_hwdep_t *hwdep, int nonblock)
310 {
311         int err;
312         assert(hwdep);
313         if ((err = hwdep->ops->nonblock(hwdep, nonblock)) < 0)
314                 return err;
315         if (nonblock)
316                 hwdep->mode |= SND_HWDEP_OPEN_NONBLOCK;
317         else
318                 hwdep->mode &= ~SND_HWDEP_OPEN_NONBLOCK;
319         return 0;
320 }
321
322 /**
323  * \brief get size of the snd_hwdep_info_t structure in bytes
324  * \return size of the snd_hwdep_info_t structure in bytes
325  */
326 size_t snd_hwdep_info_sizeof()
327 {
328         return sizeof(snd_hwdep_info_t);
329 }
330
331 /**
332  * \brief allocate a new snd_hwdep_info_t structure
333  * \param info returned pointer
334  * \return 0 on success otherwise a negative error code if fails
335  *
336  * Allocates a new snd_hwdep_info_t structure using the standard
337  * malloc C library function.
338  */
339 int snd_hwdep_info_malloc(snd_hwdep_info_t **info)
340 {
341         assert(info);
342         *info = calloc(1, sizeof(snd_hwdep_info_t));
343         if (!*info)
344                 return -ENOMEM;
345         return 0;
346 }
347
348 /**
349  * \brief frees the snd_hwdep_info_t structure
350  * \param info pointer to the snd_hwdep_info_t structure to free
351  *
352  * Frees the given snd_hwdep_info_t structure using the standard
353  * free C library function.
354  */
355 void snd_hwdep_info_free(snd_hwdep_info_t *info)
356 {
357         assert(info);
358         free(info);
359 }
360
361 /**
362  * \brief copy one snd_hwdep_info_t structure to another
363  * \param dst destination snd_hwdep_info_t structure
364  * \param src source snd_hwdep_info_t structure
365  */
366 void snd_hwdep_info_copy(snd_hwdep_info_t *dst, const snd_hwdep_info_t *src)
367 {
368         assert(dst && src);
369         *dst = *src;
370 }
371
372 /**
373  * \brief get hwdep card number
374  * \param obj pointer to a snd_hwdep_info_t structure
375  * \return hwdep card number
376  */
377 int snd_hwdep_info_get_card(const snd_hwdep_info_t *obj)
378 {
379         assert(obj);
380         return obj->card;
381 }
382
383 /**
384  * \brief get hwdep device number
385  * \param info pointer to a snd_hwdep_info_t structure
386  * \return hwdep device number
387  */
388 unsigned int snd_hwdep_info_get_device(const snd_hwdep_info_t *info)
389 {
390         assert(info);
391         return info->device;
392 }
393
394 /**
395  * \brief get hwdep driver identifier
396  * \param obj pointer to a snd_hwdep_info_t structure
397  * \return hwdep driver identifier
398  */
399 const char *snd_hwdep_info_get_id(const snd_hwdep_info_t *obj)
400 {
401         assert(obj);
402         return (const char *)obj->id;
403 }
404
405 /**
406  * \brief get hwdep driver name
407  * \param obj pointer to a snd_hwdep_info_t structure
408  * \return hwdep driver name
409  */
410 const char *snd_hwdep_info_get_name(const snd_hwdep_info_t *obj)
411 {
412         assert(obj);
413         return (const char *)obj->name;
414 }
415
416 /**
417  * \brief get hwdep protocol interface
418  * \param obj pointer to a snd_hwdep_info_t structure
419  * \return hwdep protocol interface
420  */
421 snd_hwdep_iface_t snd_hwdep_info_get_iface(const snd_hwdep_info_t *obj)
422 {
423         assert(obj);
424         return obj->iface;
425 }
426
427 /**
428  * \brief set hwdep device number
429  * \param obj pointer to a snd_hwdep_info_t structure
430  * \param val hwdep device
431  */
432 void snd_hwdep_info_set_device(snd_hwdep_info_t *obj, unsigned int val)
433 {
434         assert(obj);
435         obj->device = val;
436 }
437
438 /**
439  * \brief get information about HwDep handle
440  * \param hwdep HwDep handle
441  * \param info pointer to a snd_hwdep_info_t structure to be filled
442  * \return 0 on success otherwise a negative error code
443  */
444 int snd_hwdep_info(snd_hwdep_t *hwdep, snd_hwdep_info_t * info)
445 {
446         assert(hwdep);
447         assert(info);
448         return hwdep->ops->info(hwdep, info);
449 }
450
451 /**
452  * \brief do hardware dependent ioctl
453  * \param hwdep HwDep handle
454  * \param request ioctl command
455  * \param arg ioctl argument
456  * \return 0 on success otherwise a negative error code
457  */
458 int snd_hwdep_ioctl(snd_hwdep_t *hwdep, unsigned int request, void * arg)
459 {
460         assert(hwdep);
461         return hwdep->ops->ioctl(hwdep, request, arg);
462 }
463
464 /**
465  * \brief write bytes using HwDep handle
466  * \param hwdep HwDep handle
467  * \param buffer buffer containing bytes to write
468  * \param size output buffer size in bytes
469  */
470 ssize_t snd_hwdep_write(snd_hwdep_t *hwdep, const void *buffer, size_t size)
471 {
472         assert(hwdep);
473         assert(((hwdep->mode & O_ACCMODE) == O_WRONLY) || ((hwdep->mode & O_ACCMODE) == O_RDWR));
474         assert(buffer || size == 0);
475         return hwdep->ops->write(hwdep, buffer, size);
476 }
477
478 /**
479  * \brief read bytes using HwDep handle
480  * \param hwdep HwDep handle
481  * \param buffer buffer to store the input bytes
482  * \param size input buffer size in bytes
483  */
484 ssize_t snd_hwdep_read(snd_hwdep_t *hwdep, void *buffer, size_t size)
485 {
486         assert(hwdep);
487         assert(((hwdep->mode & O_ACCMODE) == O_RDONLY) || ((hwdep->mode & O_ACCMODE) == O_RDWR));
488         assert(buffer || size == 0);
489         return (hwdep->ops->read)(hwdep, buffer, size);
490 }
491
492 /**
493  * \brief get the DSP status information
494  * \param hwdep HwDep handle
495  * \param info pointer to a snd_hwdep_dsp_status_t structure to be filled
496  * \return 0 on success otherwise a negative error code
497  */
498 int snd_hwdep_dsp_status(snd_hwdep_t *hwdep, snd_hwdep_dsp_status_t *info)
499 {
500         assert(hwdep);
501         assert(info);
502         return hwdep->ops->ioctl(hwdep, SNDRV_HWDEP_IOCTL_DSP_STATUS, (void*)info);
503 }
504
505 /**
506  * \brief load the DSP block
507  * \param hwdep HwDep handle
508  * \param block pointer to a snd_hwdep_dsp_image_t structure to transfer
509  * \return 0 on success otherwise a negative error code
510  */
511 int snd_hwdep_dsp_load(snd_hwdep_t *hwdep, snd_hwdep_dsp_image_t *block)
512 {
513         assert(hwdep);
514         assert(block);
515         return hwdep->ops->ioctl(hwdep, SNDRV_HWDEP_IOCTL_DSP_LOAD, (void*)block);
516 }
517
518 /**
519  * \brief get size of the snd_hwdep_dsp_status_t structure in bytes
520  * \return size of the snd_hwdep_dsp_status_t structure in bytes
521  */
522 size_t snd_hwdep_dsp_status_sizeof()
523 {
524         return sizeof(snd_hwdep_dsp_status_t);
525 }
526
527 /**
528  * \brief allocate a new snd_hwdep_dsp_status_t structure
529  * \param info returned pointer
530  * \return 0 on success otherwise a negative error code if fails
531  *
532  * Allocates a new snd_hwdep_dsp_status_t structure using the standard
533  * malloc C library function.
534  */
535 int snd_hwdep_dsp_status_malloc(snd_hwdep_dsp_status_t **info)
536 {
537         assert(info);
538         *info = calloc(1, sizeof(snd_hwdep_dsp_status_t));
539         if (!*info)
540                 return -ENOMEM;
541         return 0;
542 }
543
544 /**
545  * \brief frees the snd_hwdep_dsp_status_t structure
546  * \param info pointer to the snd_hwdep_dsp_status_t structure to free
547  *
548  * Frees the given snd_hwdep_dsp_status_t structure using the standard
549  * free C library function.
550  */
551 void snd_hwdep_dsp_status_free(snd_hwdep_dsp_status_t *info)
552 {
553         assert(info);
554         free(info);
555 }
556
557 /**
558  * \brief copy one snd_hwdep_dsp_status_t structure to another
559  * \param dst destination snd_hwdep_dsp_status_t structure
560  * \param src source snd_hwdep_dsp_status_t structure
561  */
562 void snd_hwdep_dsp_status_copy(snd_hwdep_dsp_status_t *dst, const snd_hwdep_dsp_status_t *src)
563 {
564         assert(dst && src);
565         *dst = *src;
566 }
567
568 /**
569  * \brief get the driver version of dsp loader
570  * \param obj pointer to a snd_hwdep_dsp_status_t structure
571  * \return the driver version
572  */
573 unsigned int snd_hwdep_dsp_status_get_version(const snd_hwdep_dsp_status_t *obj)
574 {
575         assert(obj);
576         return obj->version;
577 }
578
579 /**
580  * \brief get the driver id of dsp loader
581  * \param obj pointer to a snd_hwdep_dsp_status_t structure
582  * \return the driver id string
583  */
584 const char *snd_hwdep_dsp_status_get_id(const snd_hwdep_dsp_status_t *obj)
585 {
586         assert(obj);
587         return (const char *)obj->id;
588 }
589
590 /**
591  * \brief get number of dsp blocks
592  * \param obj pointer to a snd_hwdep_dsp_status_t structure
593  * \return number of dsp blocks
594  */
595 unsigned int snd_hwdep_dsp_status_get_num_dsps(const snd_hwdep_dsp_status_t *obj)
596 {
597         assert(obj);
598         return obj->num_dsps;
599 }
600
601 /**
602  * \brief get the bit flags of the loaded dsp blocks
603  * \param info pointer to a snd_hwdep_dsp_status_t structure
604  * \return the big flags of the loaded dsp blocks
605  */
606 unsigned int snd_hwdep_dsp_status_get_dsp_loaded(const snd_hwdep_dsp_status_t *info)
607 {
608         assert(info);
609         return info->dsp_loaded;
610 }
611
612 /**
613  * \brief get the chip status of dsp loader
614  * \param obj pointer to a snd_hwdep_dsp_status_t structure
615  * \return non-zero if all DSP blocks are loaded and the chip is ready
616  */
617 unsigned int snd_hwdep_dsp_status_get_chip_ready(const snd_hwdep_dsp_status_t *obj)
618 {
619         assert(obj);
620         return obj->chip_ready;
621 }
622
623 /**
624  * \brief get size of the snd_hwdep_dsp_image_t structure in bytes
625  * \return size of the snd_hwdep_dsp_image_t structure in bytes
626  */
627 size_t snd_hwdep_dsp_image_sizeof()
628 {
629         return sizeof(snd_hwdep_dsp_image_t);
630 }
631
632 /**
633  * \brief allocate a new snd_hwdep_dsp_image_t structure
634  * \param info returned pointer
635  * \return 0 on success otherwise a negative error code if fails
636  *
637  * Allocates a new snd_hwdep_dsp_image_t structure using the standard
638  * malloc C library function.
639  */
640 int snd_hwdep_dsp_image_malloc(snd_hwdep_dsp_image_t **info)
641 {
642         assert(info);
643         *info = calloc(1, sizeof(snd_hwdep_dsp_image_t));
644         if (!*info)
645                 return -ENOMEM;
646         return 0;
647 }
648
649 /**
650  * \brief frees the snd_hwdep_dsp_image_t structure
651  * \param info pointer to the snd_hwdep_dsp_image_t structure to free
652  *
653  * Frees the given snd_hwdep_dsp_image_t structure using the standard
654  * free C library function.
655  */
656 void snd_hwdep_dsp_image_free(snd_hwdep_dsp_image_t *info)
657 {
658         assert(info);
659         free(info);
660 }
661
662 /**
663  * \brief copy one snd_hwdep_dsp_image_t structure to another
664  * \param dst destination snd_hwdep_dsp_image_t structure
665  * \param src source snd_hwdep_dsp_image_t structure
666  */
667 void snd_hwdep_dsp_image_copy(snd_hwdep_dsp_image_t *dst, const snd_hwdep_dsp_image_t *src)
668 {
669         assert(dst && src);
670         *dst = *src;
671 }
672
673 /**
674  * \brief get the DSP block index
675  * \param obj pointer to a snd_hwdep_dsp_image_t structure
676  * \return the index of the DSP block
677  */
678 unsigned int snd_hwdep_dsp_image_get_index(const snd_hwdep_dsp_image_t *obj)
679 {
680         assert(obj);
681         return obj->index;
682 }
683
684 /**
685  * \brief get the name of the DSP block
686  * \param obj pointer to a snd_hwdep_dsp_image_t structure
687  * \return the name string of the DSP block
688  */
689 const char *snd_hwdep_dsp_image_get_name(const snd_hwdep_dsp_image_t *obj)
690 {
691         assert(obj);
692         return (const char *)obj->name;
693 }
694
695 /**
696  * \brief get the length of the DSP block
697  * \param obj pointer to a snd_hwdep_dsp_image_t structure
698  * \return the length of the DSP block in bytes
699  */
700 size_t snd_hwdep_dsp_image_get_length(const snd_hwdep_dsp_image_t *obj)
701 {
702         assert(obj);
703         return obj->length;
704 }
705
706 /**
707  * \brief get the image pointer of the DSP block
708  * \param obj pointer to a snd_hwdep_dsp_image_t structure
709  * \return the image pointer of the DSP block
710  */
711 const void *snd_hwdep_dsp_image_get_image(const snd_hwdep_dsp_image_t *obj)
712 {
713         assert(obj);
714         return obj->image;
715 }
716
717 /**
718  * \brief set the DSP block index
719  * \param obj pointer to a snd_hwdep_dsp_image_t structure
720  * \param index the index value to set
721  */
722 void snd_hwdep_dsp_image_set_index(snd_hwdep_dsp_image_t *obj, unsigned int index)
723 {
724         assert(obj);
725         obj->index = index;
726 }
727
728 /**
729  * \brief set the name of the DSP block
730  * \param obj pointer to a snd_hwdep_dsp_image_t structure
731  * \param name the name string
732  */
733 void snd_hwdep_dsp_image_set_name(snd_hwdep_dsp_image_t *obj, const char *name)
734 {
735         assert(obj && name);
736         strncpy((char *)obj->name, name, sizeof(obj->name));
737         obj->name[sizeof(obj->name)-1] = 0;
738 }
739
740 /**
741  * \brief set the DSP block length
742  * \param obj pointer to a snd_hwdep_dsp_image_t structure
743  * \param length the length of the DSP block
744  */
745 void snd_hwdep_dsp_image_set_length(snd_hwdep_dsp_image_t *obj, size_t length)
746 {
747         assert(obj);
748         obj->length = length;
749 }
750
751 /**
752  * \brief set the DSP block image pointer
753  * \param obj pointer to a snd_hwdep_dsp_image_t structure
754  * \param image the DSP image pointer
755  */
756 void snd_hwdep_dsp_image_set_image(snd_hwdep_dsp_image_t *obj, void *image)
757 {
758         assert(obj);
759         obj->image = image;
760 }
761