Files
android_kernel_samsung_sm86…/drivers/cam_sync/cam_sync_synx.h
Petar Nedev f22f48c91f msm: camera: sync: Add support for synx objects
Add support to create, release, signal and import a synx object
using the existing generic fence operations. Handle signaling of
underlying synx object when a sync object is signaled & vice versa.

CRs-Fixed: 3317280
Change-Id: Ia6fac6eb732ed7091ec62f04875bdb30d88c8676
Signed-off-by: Petar Nedev <quic_pnedev@quicinc.com>
2022-10-27 17:06:36 -07:00

158 lines
4.0 KiB
C

/* SPDX-License-Identifier: GPL-2.0-only
*
* Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
*/
#ifndef __CAM_SYNC_SYNX_H__
#define __CAM_SYNC_SYNX_H__
#include <linux/types.h>
#include <linux/spinlock_types.h>
#include <linux/bitmap.h>
#include <synx_api.h>
#include "cam_sync.h"
#include "cam_debug_util.h"
#define CAM_SYNX_MAX_OBJS 64
#define CAM_SYNX_OBJ_NAME_LEN 64
/* Synx obj state */
enum cam_synx_obj_state {
CAM_SYNX_OBJ_STATE_INVALID,
CAM_SYNX_OBJ_STATE_ACTIVE,
CAM_SYNX_OBJ_STATE_SIGNALED,
};
/**
* struct cam_synx_obj_release_params - Synx release payload
* Based on the flag row_idx or synx_obj is consumed
*
* @synx_row_idx : Synx obj row idx
* @synx_obj : Synx object handle
* @use_row_idx : Use row idx
*/
struct cam_synx_obj_release_params {
union {
int32_t synx_row_idx;
uint32_t synx_obj;
} u;
bool use_row_idx;
};
/**
* struct cam_synx_obj_fence_signal_sync_obj - SYNX -> sync signal info
* Payload to signal sync on a synx fence being signaled
*
* @synx_obj : Synx object handle
* @status : Sync signal status
*/
struct cam_synx_obj_signal_sync_obj {
int32_t synx_obj;
int32_t status;
};
/* Synx obj callback function type */
typedef int (*cam_sync_callback_for_synx_obj)(int32_t sync_obj,
struct cam_synx_obj_signal_sync_obj *signal_sync_obj);
/**
* @brief Find the synx obj in the device's table
*
* @param synx_obj : Synx obj
* @param idx : Synx object table index
*
* @return Status of operation. Zero in case of success.
*/
int cam_synx_obj_find_obj_in_table(uint32_t synx_obj, int32_t *idx);
/**
* @brief Create a synx object
*
* @param name : Synx obj name
* @param flags : Creation flags
* @param synx_obj : Created synx obj handle
* @param row_idx : Created synx obj table row idx
*
* @return Status of operation. Zero in case of success.
* -EINVAL will be returned if params were invalid.
* -ENOMEM will be returned if the kernel can't allocate space for
* synx object.
*/
int cam_synx_obj_create(const char *name, uint32_t flags, uint32_t *synx_obj,
int32_t *row_idx);
/**
* @brief Signal a synx obj when sync obj is signaled
*
* @param row_idx : Synx obj table row index
* @param signal_synx_obj : Info on synx obj to be signaled
*
* @return Status of operation. Negative in case of error. Zero otherwise.
*/
int cam_synx_obj_internal_signal(int32_t row_idx,
struct cam_synx_obj_signal *signal_synx_obj);
/**
* @brief Import a synx obj for synchronization
*
* @param name : Synx obj name
* @param flags : Import flags
* @param fence : DMA fence ptr
* @param synx_obj : New synx obj handle
* @param row_idx : Imported obj table row idx
*
* @return 0 upon success, -EINVAL if synx object is bad state
*/
int cam_synx_obj_import_dma_fence(const char *name, uint32_t flags, void *fence,
uint32_t *synx_obj, int32_t *row_idx);
/**
* @brief Release a synx object
*
* @param release_params : Synx obj release info
*
* @return 0 upon success, negative value otherwise
*/
int cam_synx_obj_release(struct cam_synx_obj_release_params *release_params);
/**
* @brief Signal a synx obj [userspace API]
*
* @param signal_synx_obj : Signal info
*
* @return 0 upon success, negative value otherwise
*/
int cam_synx_obj_signal_obj(struct cam_synx_obj_signal *signal_synx_obj);
/**
* @brief Synx obj register callback
*
* @param sync_obj : Sync object
* @param row_idx : Synx obj table row idx
* @param sync_cb : Sync object callback
*
* @return Status of operation. Negative in case of error. Zero otherwise.
*/
int cam_synx_obj_register_cb(int32_t *sync_obj, int32_t row_idx,
cam_sync_callback_for_synx_obj sync_cb);
/**
* @brief: cam synx driver close
*
*/
void cam_synx_obj_close(void);
/**
* @brief: cam synx driver initialize
*
*/
int cam_synx_obj_driver_init(void);
/**
* @brief: cam synx driver deinit
*
*/
void cam_synx_obj_driver_deinit(void);
#endif /* __CAM_SYNC_SYNX_H__ */