Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ba23760b authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: camara: sync: Add callback registration logic for synx"

parents 818a17ec b0d26198
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only

obj-$(CONFIG_SPECTRA_CAMERA) += camera/
#
# Makefile for the qti specific video device drivers
# based on V4L2.
@@ -8,3 +7,4 @@ obj-$(CONFIG_SPECTRA_CAMERA) += camera/
obj-$(CONFIG_MSM_CVP_V4L2) += cvp/
obj-$(CONFIG_MSM_NPU) += npu/
obj-$(CONFIG_MSM_GLOBAL_SYNX) += synx/
obj-$(CONFIG_SPECTRA_CAMERA) += camera/
+1 −0
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only

ccflags-y += -Idrivers/media/platform/msm/camera/cam_utils
ccflags-$(CONFIG_MSM_GLOBAL_SYNX) += -Idrivers/media/platform/msm/synx
ccflags-y += -I$(src)

obj-$(CONFIG_SPECTRA_CAMERA) += cam_sync.o cam_sync_util.o
+25 −1
Original line number Diff line number Diff line
@@ -13,6 +13,9 @@
#include "cam_debug_util.h"
#include "cam_common_util.h"

#ifdef CONFIG_MSM_GLOBAL_SYNX
#include <synx_api.h>
#endif
struct sync_device *sync_dev;

/*
@@ -956,6 +959,25 @@ static int cam_sync_create_debugfs(void)
	return 0;
}

#ifdef CONFIG_MSM_GLOBAL_SYNX
static void cam_sync_register_synx_bind_ops(void)
{
	int rc = 0;
	struct synx_register_params params;

	params.name = CAM_SYNC_NAME;
	params.type = SYNX_TYPE_CSL;
	params.ops.register_callback = cam_sync_register_callback;
	params.ops.deregister_callback = cam_sync_deregister_callback;
	params.ops.enable_signaling = cam_sync_get_obj_ref;
	params.ops.signal = cam_sync_signal;

	rc = synx_register_ops(&params);
	if (rc)
		CAM_ERR(CAM_SYNC, "synx registration fail with %d", rc);
}
#endif

static int cam_sync_probe(struct platform_device *pdev)
{
	int rc;
@@ -1023,7 +1045,9 @@ static int cam_sync_probe(struct platform_device *pdev)

	trigger_cb_without_switch = false;
	cam_sync_create_debugfs();

#ifdef CONFIG_MSM_GLOBAL_SYNX
	cam_sync_register_synx_bind_ops();
#endif
	return rc;

v4l2_fail:
+0 −1
Original line number Diff line number Diff line
# SPDX-License-Identifier: GPL-2.0-only

ccflags-$(CONFIG_SPECTRA_CAMERA) += -Idrivers/media/platform/msm/camera/cam_sync
obj-$(CONFIG_MSM_GLOBAL_SYNX) += synx.o synx_util.o synx_debugfs.o
+80 −78
Original line number Diff line number Diff line
@@ -10,10 +10,6 @@
#include <linux/slab.h>
#include <linux/uaccess.h>

#ifdef CONFIG_SPECTRA_CAMERA
#include <cam_sync_api.h>
#endif

#include "synx_api.h"
#include "synx_util.h"
#include "synx_debugfs.h"
@@ -227,7 +223,6 @@ int synx_signal_core(struct synx_table_row *row, u32 status)
	int rc, ret;
	u32 i = 0;
	u32 idx = 0;
	u32 type;
	s32 sync_id;
	struct synx_external_data *data = NULL;
	struct synx_bind_desc bind_descs[SYNX_MAX_NUM_BINDINGS];
@@ -307,14 +302,13 @@ int synx_signal_core(struct synx_table_row *row, u32 status)
	spin_unlock_bh(&synx_dev->row_spinlocks[row->index]);

	for (i = 0; i < idx; i++) {
		type = bind_descs[i].external_desc.type;
		sync_id = bind_descs[i].external_desc.id[0];
		data = bind_descs[i].external_data;
		if (is_valid_type(type)) {
			bind_ops = &synx_dev->bind_vtbl[type];
			if (!bind_ops->deregister_callback ||
				!bind_ops->signal) {
				pr_err("invalid bind ops for %u\n", type);
		bind_ops = synx_get_bind_ops(
					bind_descs[i].external_desc.type);
		if (!bind_ops) {
			pr_err("invalid bind ops for %u\n",
				bind_descs[i].external_desc.type);
			kfree(data);
			continue;
		}
@@ -343,9 +337,6 @@ int synx_signal_core(struct synx_table_row *row, u32 status)
		if (ret < 0)
			pr_err("signaling fail on sync: %d, err: %d\n",
				sync_id, ret);
		} else {
			pr_warn("unimplemented external type: %u\n", type);
		}

		/*
		 * release the memory allocated for external data.
@@ -536,8 +527,10 @@ int synx_bind(s32 synx_obj, struct synx_external_desc external_sync)
		return -EINVAL;
	}

	if (!is_valid_type(external_sync.type)) {
		pr_err("invalid external sync object\n");
	bind_ops = synx_get_bind_ops(external_sync.type);
	if (!bind_ops) {
		pr_err("invalid bind ops for %u\n",
			external_sync.type);
		return -EINVAL;
	}

@@ -574,15 +567,6 @@ int synx_bind(s32 synx_obj, struct synx_external_desc external_sync)
		}
	}

	bind_ops = &synx_dev->bind_vtbl[external_sync.type];
	if (!bind_ops->register_callback) {
		pr_err("invalid bind register for %u\n",
			external_sync.type);
		spin_unlock_bh(&synx_dev->row_spinlocks[row->index]);
		kfree(data);
		return -EINVAL;
	}

	/* data passed to external callback */
	data->synx_obj = row->synx_obj;
	data->secure_key = synx_generate_secure_key(row);
@@ -1397,39 +1381,60 @@ static const struct file_operations synx_fops = {
#endif
};

#ifdef CONFIG_SPECTRA_CAMERA
static void synx_bind_ops_csl_type(struct bind_operations *vtbl)
int synx_register_ops(const struct synx_register_params *params)
{
	if (!vtbl)
		return;

	vtbl->register_callback = cam_sync_register_callback;
	vtbl->deregister_callback = cam_sync_deregister_callback;
	vtbl->enable_signaling = cam_sync_get_obj_ref;
	vtbl->signal = cam_sync_signal;
	s32 rc;
	struct synx_registered_ops *client_ops;

	if (!params || !params->name ||
		!is_valid_type(params->type) ||
		!params->ops.register_callback ||
		!params->ops.deregister_callback ||
		!params->ops.signal) {
		pr_err("invalid register params\n");
		return -EINVAL;
	}

	pr_debug("csl bind functionality set\n");
	mutex_lock(&synx_dev->table_lock);
	client_ops = &synx_dev->bind_vtbl[params->type];
	if (!client_ops->valid) {
		client_ops->valid = true;
		memcpy(&client_ops->ops, &params->ops,
			sizeof(client_ops->ops));
		strlcpy(client_ops->name, params->name,
			sizeof(client_ops->name));
		client_ops->type = params->type;
		pr_info("registered bind ops for %s\n",
			params->name);
		rc = 0;
	} else {
		pr_info("client already registered by %s\n",
			client_ops->name);
		rc = -EINVAL;
	}
#else
static void synx_bind_ops_csl_type(struct bind_operations *vtbl)
{
	pr_debug("csl bind functionality not available\n");
	mutex_unlock(&synx_dev->table_lock);

	return rc;
}
#endif

static void synx_bind_ops_register(struct synx_device *synx_dev)
int synx_deregister_ops(const struct synx_register_params *params)
{
	u32 i;
	struct synx_registered_ops *client_ops;

	for (i = 0; i < SYNX_MAX_BIND_TYPES; i++) {
		switch (i) {
		case SYNX_TYPE_CSL:
			synx_bind_ops_csl_type(&synx_dev->bind_vtbl[i]);
			break;
		default:
			pr_err("invalid external sync type\n");
		}
	if (!params || !params->name ||
		!is_valid_type(params->type)) {
		pr_err("invalid params\n");
		return -EINVAL;
	}

	mutex_lock(&synx_dev->table_lock);
	client_ops = &synx_dev->bind_vtbl[params->type];
	memset(client_ops, 0, sizeof(*client_ops));
	pr_info("deregistered bind ops for %s\n",
		params->name);
	mutex_unlock(&synx_dev->table_lock);

	return 0;
}

static int __init synx_init(void)
@@ -1487,9 +1492,6 @@ static int __init synx_init(void)
	synx_dev->dma_context = dma_fence_context_alloc(1);

	synx_dev->debugfs_root = init_synx_debug_dir(synx_dev);

	synx_bind_ops_register(synx_dev);

	pr_info("synx device init success\n");

	return 0;
Loading