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

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

Merge "msm: synx: support for synx kernel clients"

parents 2875cbfc 7df26226
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -16,6 +16,7 @@
#include "msm_cvp_clocks.h"
#include <linux/dma-buf.h>
#include <uapi/media/msm_media_info.h>
#include <synx_api.h>

#define MAX_EVENTS 30
#define NUM_CYCLES16X16_HCD_FRAME 95
@@ -302,6 +303,8 @@ void *msm_cvp_open(int core_id, int session_type)

	kref_init(&inst->kref);

	synx_initialize(NULL);

	inst->session_type = session_type;
	inst->state = MSM_CVP_CORE_UNINIT_DONE;
	inst->core = core;
@@ -353,6 +356,8 @@ void *msm_cvp_open(int core_id, int session_type)
	DEINIT_MSM_CVP_LIST(&inst->cvpdspbufs);
	DEINIT_MSM_CVP_LIST(&inst->frames);

	synx_uninitialize();

	kfree(inst);
	inst = NULL;
err_invalid_core:
@@ -388,6 +393,8 @@ int msm_cvp_destroy(struct msm_cvp_inst *inst)
	list_del(&inst->list);
	mutex_unlock(&core->lock);

	synx_uninitialize();

	DEINIT_MSM_CVP_LIST(&inst->persistbufs);
	DEINIT_MSM_CVP_LIST(&inst->cvpcpubufs);
	DEINIT_MSM_CVP_LIST(&inst->cvpdspbufs);
+40 −10
Original line number Diff line number Diff line
@@ -1313,21 +1313,12 @@ static int synx_open(struct inode *inode, struct file *filep)
	return 0;
}

static int synx_close(struct inode *inode, struct file *filep)
static void synx_table_cleanup(void)
{
	int rc = 0;
	int i;
	struct synx_device *synx_dev = NULL;
	struct synx_client *client;
	struct synx_import_data *data, *tmp_data;

	pr_debug("Enter %s from pid: %d\n", __func__, current->pid);

	synx_dev = get_synx_device(filep);
	client = filep->private_data;

	mutex_lock(&synx_dev->table_lock);

	synx_dev->open_cnt--;
	if (!synx_dev->open_cnt) {
		for (i = 1; i < SYNX_MAX_OBJS; i++) {
@@ -1398,7 +1389,20 @@ static int synx_close(struct inode *inode, struct file *filep)
			kfree(data);
		}
	}
}

static int synx_close(struct inode *inode, struct file *filep)
{
	struct synx_device *synx_dev = NULL;
	struct synx_client *client;

	pr_debug("Enter %s from pid: %d\n", __func__, current->pid);

	synx_dev = get_synx_device(filep);
	client = filep->private_data;

	mutex_lock(&synx_dev->table_lock);
	synx_table_cleanup();
	list_del_init(&client->list);
	kfree(client);
	mutex_unlock(&synx_dev->table_lock);
@@ -1420,6 +1424,32 @@ static const struct file_operations synx_fops = {
#endif
};

int synx_initialize(struct synx_initialization_params *params)
{
	pr_debug("Enter %s from pid: %d\n", __func__, current->pid);

	mutex_lock(&synx_dev->table_lock);
	synx_dev->open_cnt++;
	mutex_unlock(&synx_dev->table_lock);

	if (params)
		pr_debug("synx client session initialized for %s\n",
			params->name);
	return 0;
}

int synx_uninitialize(void)
{
	pr_debug("Enter %s from pid: %d\n",
		__func__, current->pid);

	mutex_lock(&synx_dev->table_lock);
	synx_table_cleanup();
	mutex_unlock(&synx_dev->table_lock);

	return 0;
}

int synx_register_ops(const struct synx_register_params *params)
{
	s32 rc;
+29 −0
Original line number Diff line number Diff line
@@ -44,6 +44,16 @@ struct synx_register_params {
	u32 type;
};

/**
 * struct synx_initialization_params - Session params (optional)
 *
 * @name : Client session name
 *         Only first 64 bytes are accepted, rest will be ignored
 */
struct synx_initialization_params {
	const char *name;
};

/* Kernel APIs */

/* @brief: Register operations for external synchronization
@@ -70,6 +80,25 @@ int synx_register_ops(const struct synx_register_params *params);
 */
int synx_deregister_ops(const struct synx_register_params *params);

/**
 * @brief: Initializes a new client session
 *
 * @param params : Pointer to session init params
 *
 * @return Status of operation. Zero in case of success.
 * -EINVAL will be returned if params is not valid.
 * -ENOMEM will be returned if the kernel can't allocate space for
 * new client
 */
int synx_initialize(struct synx_initialization_params *params);

/**
 * @brief: Destroys the client session
 *
 * @return Status of operation. Zero in case of success.
 */
int synx_uninitialize(void);

/**
 * @brief: Creates a synx object
 *