Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 81 lines (70 sloc) 1.814 kb
3a28a28 @felipec New utility gstdsp_register()
authored
1 /*
da3c02c @felipec Update copyright notices
authored
2 * Copyright (C) 2009-2010 Felipe Contreras
3a28a28 @felipec New utility gstdsp_register()
authored
3 *
4 * Author: Felipe Contreras <felipe.contreras@gmail.com>
5 *
e6c5dd8 @felipec Update licence notices
authored
6 * This file may be used under the terms of the GNU Lesser General Public
7 * License version 2.1, a copy of which is found in LICENSE included in the
8 * packaging of this file.
3a28a28 @felipec New utility gstdsp_register()
authored
9 */
10
11 #include "util.h"
12
13 #include <glib.h>
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
14 #include <gst/gst.h>
3a28a28 @felipec New utility gstdsp_register()
authored
15
16 bool gstdsp_register(int dsp_handle,
5db1989 @felipec Remove usage of typedefs
authored
17 const struct dsp_uuid *uuid,
3a28a28 @felipec New utility gstdsp_register()
authored
18 int type,
19 const char *filename)
20 {
21 gchar *path;
22 path = g_build_filename(DSPDIR, filename, NULL);
23 if (!dsp_register(dsp_handle, uuid, type, path)) {
24 g_free(path);
25 return false;
26 }
27
28 g_free(path);
29 return true;
30 }
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
31
32 static inline bool
7e75904 util: cleanup gstdsp_map_buffer() a bit
Felipe Contreras authored
33 buffer_is_aligned(void *buf_data, size_t buf_size, dmm_buffer_t *b)
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
34 {
f91a7da Use b->dir instead lf b->alignment
Felipe Contreras authored
35 int alignment = b->dir == DMA_TO_DEVICE ? 0 : 128;
36 if (alignment == 0)
7e75904 util: cleanup gstdsp_map_buffer() a bit
Felipe Contreras authored
37 return true;
f91a7da Use b->dir instead lf b->alignment
Felipe Contreras authored
38 if ((size_t) buf_data % alignment != 0)
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
39 return false;
f91a7da Use b->dir instead lf b->alignment
Felipe Contreras authored
40 if (((size_t) buf_data + buf_size) % alignment != 0)
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
41 return false;
42 return true;
43 }
44
5c670b1 util: improve buffer alignment warning message
Felipe Contreras authored
45 static inline const char *
46 dma_dir_to_str(int dir)
47 {
48 switch (dir) {
49 case DMA_BIDIRECTIONAL: return "bidirectional";
50 case DMA_TO_DEVICE: return "to device";
51 case DMA_FROM_DEVICE: return "from device";
52 default: return "unknown";
53 }
54 }
55
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
56 bool gstdsp_map_buffer(void *self,
2537c04 util: cleanup gstdsp_map_buffer() variables
Felipe Contreras authored
57 GstBuffer *buf,
58 dmm_buffer_t *b)
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
59 {
5c670b1 util: improve buffer alignment warning message
Felipe Contreras authored
60 int alignment = b->dir == DMA_TO_DEVICE ? 0 : 128;
61
2537c04 util: cleanup gstdsp_map_buffer() variables
Felipe Contreras authored
62 if (buffer_is_aligned(buf->data, buf->size, b)) {
63 dmm_buffer_use(b, buf->data, buf->size);
64 gst_buffer_ref(buf);
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
65 return true;
66 }
67
2537c04 util: cleanup gstdsp_map_buffer() variables
Felipe Contreras authored
68 if (b->dir != DMA_TO_DEVICE) {
5c670b1 util: improve buffer alignment warning message
Felipe Contreras authored
69 pr_warning(self, "buffer not aligned: %p(%u)-%p(%u): %s",
2537c04 util: cleanup gstdsp_map_buffer() variables
Felipe Contreras authored
70 buf->data,
5c670b1 util: improve buffer alignment warning message
Felipe Contreras authored
71 (size_t)buf->data % alignment,
72 buf->data + buf->size,
2274a49 util: fix map_buffer() warning message
Felipe Contreras authored
73 (size_t)(buf->data + buf->size) % alignment,
5c670b1 util: improve buffer alignment warning message
Felipe Contreras authored
74 dma_dir_to_str(b->dir));
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
75 }
76
2537c04 util: cleanup gstdsp_map_buffer() variables
Felipe Contreras authored
77 dmm_buffer_allocate(b, buf->size);
78 b->need_copy = true;
a0e985a Refactor code into common gstdsp_map_buffer()
Felipe Contreras authored
79 return false;
80 }
Something went wrong with that request. Please try again.