@@ -4,7 +4,8 @@
#
media-objs := media-device.o media-devnode.o media-entity.o \
- media-request.o media-request-queue-generic.o
+ media-request.o media-request-queue-generic.o \
+ media-request-entity-generic.o
#
# I2C drivers should come before other drivers, otherwise they'll fail
new file mode 100644
@@ -0,0 +1,56 @@
+/*
+ * Media generic entity ops
+ *
+ * Copyright (C) 2017, The Chromium OS Authors. All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+#include <linux/slab.h>
+
+#include <media/media-entity.h>
+#include <media/media-request.h>
+
+struct media_request_entity_data_generic {
+ struct media_request_entity_data base;
+};
+
+static struct media_request_entity_data *
+alloc_req_data(struct media_request *req, struct media_entity *entity)
+{
+ struct media_request_entity_data_generic *ret;
+
+ ret = kzalloc(sizeof(*ret), GFP_KERNEL);
+ if (!ret)
+ return ERR_PTR(-ENOMEM);
+
+ return &ret->base;
+}
+
+static void release_req_data(struct media_request_entity_data *_data)
+{
+ struct media_request_entity_data_generic *data;
+
+ data = container_of(_data, typeof(*data), base);
+ kfree(data);
+}
+
+static int apply_req_data(struct media_request_entity_data *_data)
+{
+ return 0;
+}
+
+const struct media_request_entity_ops
+media_entity_request_generic_ops = {
+ .alloc_data = alloc_req_data,
+ .release_data = release_req_data,
+ .apply_data = apply_req_data,
+};
+EXPORT_SYMBOL_GPL(media_entity_request_generic_ops);
@@ -240,6 +240,11 @@ struct media_request_entity_ops {
int (*apply_data)(struct media_request_entity_data *data);
};
+/*
+ * Generic entity request support, built on top of standard V4L2 functions
+ */
+extern const struct media_request_entity_ops media_entity_request_generic_ops;
+
/**
* media_device_request_cmd() - perform the REQUEST_CMD ioctl
*
Add skeleton ops for generic entities. The intent is to provide a generic mechanism to apply request parameters to entities using regular media/v4l2 functions. Signed-off-by: Alexandre Courbot <acourbot@chromium.org> --- drivers/media/Makefile | 3 +- drivers/media/media-request-entity-generic.c | 56 ++++++++++++++++++++++++++++ include/media/media-request.h | 5 +++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 drivers/media/media-request-entity-generic.c