summaryrefslogtreecommitdiffstats
path: root/adf
diff options
context:
space:
mode:
authorGreg Hackmann <ghackmann@google.com>2013-11-12 10:38:36 -0800
committerGreg Hackmann <ghackmann@google.com>2013-11-26 15:40:02 -0800
commit47e0c8d849277a4b96fc364e5703f301e2b94519 (patch)
tree9194cbaf4f28b3eb89854422559d8d102affaf38 /adf
parentebb26c71fe59c1904dc198b00948c581d31bd412 (diff)
downloadsystem_core-47e0c8d849277a4b96fc364e5703f301e2b94519.zip
system_core-47e0c8d849277a4b96fc364e5703f301e2b94519.tar.gz
system_core-47e0c8d849277a4b96fc364e5703f301e2b94519.tar.bz2
libadf: filter overlay engines by a list of acceptable formats
Change-Id: Ibb294f0520a7a7a6a2a89e1e3eb3c335906d3e66 Signed-off-by: Greg Hackmann <ghackmann@google.com>
Diffstat (limited to 'adf')
-rw-r--r--adf/libadf/adf.c31
-rw-r--r--adf/libadf/include/adf/adf.h6
2 files changed, 25 insertions, 12 deletions
diff --git a/adf/libadf/adf.c b/adf/libadf/adf.c
index dfcb0e4..5fd6bc2 100644
--- a/adf/libadf/adf.c
+++ b/adf/libadf/adf.c
@@ -494,8 +494,8 @@ done:
static ssize_t adf_overlay_engines_filter(struct adf_device *dev,
adf_id_t *in, size_t n_in, adf_id_t **out,
- bool (*filter)(struct adf_overlay_engine_data *data, __u32 match),
- __u32 match)
+ bool (*filter)(struct adf_overlay_engine_data *data, void *cookie),
+ void *cookie)
{
size_t n = 0;
ssize_t ret;
@@ -515,7 +515,7 @@ static ssize_t adf_overlay_engines_filter(struct adf_device *dev,
if (ret < 0)
goto done;
- if (!filter(&data, match))
+ if (!filter(&data, cookie))
continue;
adf_id_t *new_ids = realloc(ids_ret, (n + 1) * sizeof(ids_ret[0]));
@@ -539,21 +539,32 @@ done:
return ret;
}
-static bool adf_overlay_engine_format_filter(struct adf_overlay_engine_data *data,
- __u32 format)
+struct format_filter_cookie {
+ const __u32 *formats;
+ size_t n_formats;
+};
+
+static bool adf_overlay_engine_format_filter(
+ struct adf_overlay_engine_data *data, void *cookie)
{
+ struct format_filter_cookie *c = cookie;
size_t i;
- for (i = 0; i < data->n_supported_formats; i++)
- if (data->supported_formats[i] == format)
- return true;
+ for (i = 0; i < data->n_supported_formats; i++) {
+ size_t j;
+ for (j = 0; j < c->n_formats; j++)
+ if (data->supported_formats[i] == c->formats[j])
+ return true;
+ }
return false;
}
ssize_t adf_overlay_engines_filter_by_format(struct adf_device *dev,
- __u32 format, adf_id_t *in, size_t n_in, adf_id_t **out)
+ const __u32 *formats, size_t n_formats, adf_id_t *in, size_t n_in,
+ adf_id_t **out)
{
+ struct format_filter_cookie cookie = { formats, n_formats };
return adf_overlay_engines_filter(dev, in, n_in, out,
- adf_overlay_engine_format_filter, format);
+ adf_overlay_engine_format_filter, &cookie);
}
int adf_overlay_engine_open(struct adf_device *dev, adf_id_t id, int flags)
diff --git a/adf/libadf/include/adf/adf.h b/adf/libadf/include/adf/adf.h
index 5d301f3..8ce994f 100644
--- a/adf/libadf/include/adf/adf.h
+++ b/adf/libadf/include/adf/adf.h
@@ -182,10 +182,12 @@ ssize_t adf_overlay_engines_for_interface(struct adf_device *dev,
/**
* Filters a list of overlay engines by supported buffer format.
*
- * The caller must free() the returned list of overlay engine IDs.
+ * Returns the overlay engines which support at least one of the specified
+ * formats. The caller must free() the returned list of overlay engine IDs.
*/
ssize_t adf_overlay_engines_filter_by_format(struct adf_device *dev,
- __u32 format, adf_id_t *in, size_t n_in, adf_id_t **out);
+ const __u32 *formats, size_t n_formats, adf_id_t *in, size_t n_in,
+ adf_id_t **out);
/**
* Opens an ADF overlay engine.