2,851
社区成员




首先是需要合入以下的kernel的patch
diff --git a/drivers/cam_req_mgr/cam_req_mgr_dev.c b/drivers/cam_req_mgr/cam_req_mgr_dev.c
index 7392d776f..775370650 100644
--- a/drivers/cam_req_mgr/cam_req_mgr_dev.c
+++ b/drivers/cam_req_mgr/cam_req_mgr_dev.c
@@ -34,6 +34,7 @@
#define CAM_REQ_MGR_EVENT_MAX 30
#define CAM_I3C_MASTER_COMPAT "qcom,geni-i3c"
+#define CAM_MULTI
static struct cam_req_mgr_device g_dev;
struct kmem_cache *g_cam_req_mgr_timer_cachep;
@@ -141,11 +142,14 @@ static int cam_req_mgr_open(struct file *filep)
cam_req_mgr_rwsem_write_op(CAM_SUBDEV_LOCK);
mutex_lock(&g_dev.cam_lock);
+#ifndef CAM_MULTI
+ CAM_ERR(CAM_CRM, "[ts_debug] cam_req_mgr_open.");
+
if (g_dev.open_cnt >= 1) {
rc = -EALREADY;
goto end;
}
-
+#endif
rc = v4l2_fh_open(filep);
if (rc) {
CAM_ERR(CAM_CRM, "v4l2_fh_open failed: %d", rc);
@@ -157,13 +161,26 @@ static int cam_req_mgr_open(struct file *filep)
spin_unlock_bh(&g_dev.cam_eventq_lock);
g_dev.open_cnt++;
+#ifndef CAM_MULTI
+ CAM_ERR(CAM_CRM, "[ts_debug] CAM_MULTI not define");
rc = cam_mem_mgr_init();
if (rc) {
g_dev.open_cnt--;
CAM_ERR(CAM_CRM, "mem mgr init failed");
goto mem_mgr_init_fail;
}
-
+#else
+ CAM_ERR(CAM_CRM, "CAM_MULTI define");
+ if(g_dev.open_cnt == 1) {
+ rc = cam_mem_mgr_init();
+ if (rc) {
+ g_dev.open_cnt--;
+ CAM_ERR(CAM_CRM, "mem mgr init failed");
+ goto mem_mgr_init_fail;
+ }
+
+ }
+#endif
mutex_unlock(&g_dev.cam_lock);
cam_req_mgr_rwsem_write_op(CAM_SUBDEV_UNLOCK);
return rc;
@@ -213,6 +230,18 @@ static int cam_req_mgr_close(struct file *filep)
return -EINVAL;
}
+ g_dev.open_cnt--;
+#ifndef CAM_MULTI
+
+#else
+ if (g_dev.open_cnt > 0) {
+ CAM_ERR(CAM_CRM, "%s:%d open_cnt %d", __func__, __LINE__, g_dev.open_cnt);
+ v4l2_fh_release(filep);
+ mutex_unlock(&g_dev.cam_lock);
+ return 0;
+ }
+#endif
+
cam_req_mgr_handle_core_shutdown();
g_dev.shutdown_state = true;
@@ -228,7 +257,7 @@ static int cam_req_mgr_close(struct file *filep)
}
}
- g_dev.open_cnt--;
+ //g_dev.open_cnt--;
g_dev.shutdown_state = false;
v4l2_fh_release(filep);
diff --git a/drivers/cam_sync/cam_sync.c b/drivers/cam_sync/cam_sync.c
index 2eb5f7422..650fdd93a 100644
--- a/drivers/cam_sync/cam_sync.c
+++ b/drivers/cam_sync/cam_sync.c
@@ -46,10 +46,15 @@ static void cam_sync_print_fence_table(void)
spin_unlock_bh(&sync_dev->row_spinlocks[idx]);
}
}
-
+#ifndef CAM_MULTI
static int cam_sync_create_util(
int32_t *sync_obj, const char *name,
struct cam_dma_fence_create_sync_obj_payload *dma_sync_create_info)
+#else
+static int cam_sync_create_util(
+ int32_t *sync_obj, const char *name,
+ struct cam_dma_fence_create_sync_obj_payload *dma_sync_create_info, int instance)
+#endif
{
int rc;
long idx;
@@ -109,18 +114,28 @@ static int cam_sync_create_util(
name, *sync_obj, dma_sync_create_info->fd);
goto end;
}
-
+#ifdef CAM_MULTI
+ sync_dev->sync_instance_map[idx] = instance;
+ CAM_DBG(CAM_SYNC, "[ts_debug] instance: %d", instance);
+#endif
CAM_DBG(CAM_SYNC, "sync_obj: %s[%i]", name, *sync_obj);
end:
spin_unlock_bh(&sync_dev->row_spinlocks[idx]);
return rc;
}
-
+#ifndef CAM_MULTI
int cam_sync_create(int32_t *sync_obj, const char *name)
{
return cam_sync_create_util(sync_obj, name, NULL);
}
+#else
+int cam_sync_create(int32_t *sync_obj, const char *name, int instance)
+{
+ return cam_sync_create_util(sync_obj, name, NULL, instance);
+}
+#endif
+
int cam_sync_register_callback(sync_callback cb_func,
void *userdata, int32_t sync_obj)
@@ -399,6 +414,9 @@ int cam_sync_merge(int32_t *sync_obj, uint32_t num_objs, int32_t *merged_obj)
long idx = 0;
bool bit;
int i = 0;
+#ifdef CAM_MULTI
+ int instance = -1;
+#endif
if (!sync_obj || !merged_obj) {
CAM_ERR(CAM_SYNC, "Invalid pointer(s)");
@@ -416,6 +434,20 @@ int cam_sync_merge(int32_t *sync_obj, uint32_t num_objs, int32_t *merged_obj)
return -EINVAL;
}
+#ifdef CAM_MULTI
+ spin_lock_bh(&sync_dev->cam_sync_eventq_lock);
+ for (i = 0; i < num_objs; i++){
+ if (sync_dev->sync_instance_map[sync_obj[i]] >= 0 && sync_dev->sync_instance_map[sync_obj[i]] < CAM_SYNC_MAX_INSTANCE){
+ instance = sync_dev->sync_instance_map[sync_obj[i]];
+ break;
+ }
+ }
+ if (i == num_objs || num_objs <= 0){
+ CAM_ERR(CAM_SYNC,"Merge sync_obj:%d error sync_instance_map:%d num_obj:%d current:%s",*merged_obj,sync_dev->sync_instance_map[idx],num_objs,current->comm);
+ }
+ spin_unlock_bh(&sync_dev->cam_sync_eventq_lock);
+#endif
+
for (i = 0; i < num_objs; i++) {
rc = cam_sync_check_valid(sync_obj[i]);
if (rc) {
@@ -444,6 +476,9 @@ int cam_sync_merge(int32_t *sync_obj, uint32_t num_objs, int32_t *merged_obj)
}
CAM_DBG(CAM_SYNC, "Init row at idx:%ld to merge objects", idx);
*merged_obj = idx;
+#ifdef CAM_MULTI
+ sync_dev->sync_instance_map[idx] = instance;
+#endif
spin_unlock_bh(&sync_dev->row_spinlocks[idx]);
return 0;
@@ -569,12 +604,19 @@ int cam_sync_wait(int32_t sync_obj, uint64_t timeout_ms)
return rc;
}
-
+#ifndef CAM_MULTI
static int cam_sync_handle_create(struct cam_private_ioctl_arg *k_ioctl)
+#else
+static int cam_sync_handle_create(struct file *filep,struct cam_private_ioctl_arg *k_ioctl)
+#endif
{
struct cam_sync_info sync_create;
int result;
-
+#ifndef CAM_MULTI
+#else
+ int i;
+ int instance = -1;
+#endif
if (k_ioctl->size != sizeof(struct cam_sync_info))
return -EINVAL;
@@ -586,9 +628,25 @@ static int cam_sync_handle_create(struct cam_private_ioctl_arg *k_ioctl)
k_ioctl->size))
return -EFAULT;
sync_create.name[SYNC_DEBUG_NAME_LEN] = '\0';
-
+#ifndef CAM_MULTI
result = cam_sync_create(&sync_create.sync_obj,
sync_create.name);
+#else
+ spin_lock_bh(&sync_dev->cam_sync_eventq_lock);
+ for (i = 0; i < CAM_SYNC_MAX_INSTANCE; i++){
+ if (sync_dev->cam_sync_eventq[i] == filep->private_data){
+ instance = i;
+ break;
+ }
+ }
+ if (CAM_SYNC_MAX_INSTANCE == i){
+ CAM_ERR(CAM_SYNC,"create sync_obj:%d error sync_instance_map:%d",sync_create.sync_obj,sync_dev->sync_instance_map[sync_create.sync_obj]);
+ }
+ spin_unlock_bh(&sync_dev->cam_sync_eventq_lock);
+
+ result = cam_sync_create(&sync_create.sync_obj,
+ sync_create.name,instance);
+#endif
if (!result)
if (copy_to_user(
@@ -629,8 +687,11 @@ static int cam_sync_handle_signal(struct cam_private_ioctl_arg *k_ioctl)
sync_signal.sync_state,
CAM_SYNC_COMMON_SYNC_SIGNAL_EVENT);
}
-
+#ifndef CAM_MULTI
static int cam_sync_handle_merge(struct cam_private_ioctl_arg *k_ioctl)
+#else
+static int cam_sync_handle_merge(struct file *filep, struct cam_private_ioctl_arg *k_ioctl)
+#endif
{
struct cam_sync_merge sync_merge;
uint32_t *sync_objs;
@@ -1147,8 +1208,13 @@ static int cam_generic_fence_handle_dma_import(
dma_sync_create.sync_created_with_dma = false;
/* Create new sync object and associate dma fence */
+#ifndef CAM_MULTI
rc = cam_sync_create_util(&fence_cfg->sync_obj, fence_cfg->name,
&dma_sync_create);
+#else
+ rc = cam_sync_create_util(&fence_cfg->sync_obj, fence_cfg->name,
+ &dma_sync_create, 0);
+#endif
if (rc) {
fence_cfg->reason_code = rc;
@@ -1278,8 +1344,13 @@ static int cam_generic_fence_handle_sync_create(
dma_fence_created = true;
}
+#ifndef CAM_MULTI
rc = cam_sync_create_util(&fence_cfg->sync_obj, fence_cfg->name,
(dma_fence_created ? &dma_sync_create : NULL));
+#else
+ rc = cam_sync_create_util(&fence_cfg->sync_obj, fence_cfg->name,
+ (dma_fence_created ? &dma_sync_create : NULL), 0);
+#endif
if (rc) {
fence_cfg->reason_code = rc;
if (dma_fence_created) {
@@ -1514,7 +1585,11 @@ static long cam_sync_dev_ioctl(struct file *filep, void *fh,
switch (k_ioctl.id) {
case CAM_SYNC_CREATE:
+#ifndef CAM_MULTI
rc = cam_sync_handle_create(&k_ioctl);
+#else
+ rc = cam_sync_handle_create(filep,&k_ioctl);
+#endif
break;
case CAM_SYNC_DESTROY:
rc = cam_sync_handle_destroy(&k_ioctl);
@@ -1531,7 +1606,11 @@ static long cam_sync_dev_ioctl(struct file *filep, void *fh,
rc = cam_sync_handle_signal(&k_ioctl);
break;
case CAM_SYNC_MERGE:
+#ifndef CAM_MULTI
rc = cam_sync_handle_merge(&k_ioctl);
+#else
+ rc = cam_sync_handle_merge(filep,&k_ioctl);
+#endif
break;
case CAM_SYNC_WAIT:
rc = cam_sync_handle_wait(&k_ioctl);
@@ -1579,18 +1658,28 @@ static int cam_sync_open(struct file *filep)
}
mutex_lock(&sync_dev->table_lock);
+#ifndef CAM_MULTI
if (sync_dev->open_cnt >= 1) {
mutex_unlock(&sync_dev->table_lock);
return -EALREADY;
}
-
+#endif
rc = v4l2_fh_open(filep);
if (!rc) {
+#ifndef CAM_MULTI
sync_dev->open_cnt++;
cam_dma_fence_open();
spin_lock_bh(&sync_dev->cam_sync_eventq_lock);
sync_dev->cam_sync_eventq = filep->private_data;
spin_unlock_bh(&sync_dev->cam_sync_eventq_lock);
+#else
+ cam_dma_fence_open();
+ spin_lock_bh(&sync_dev->cam_sync_eventq_lock);
+ sync_dev->cam_sync_eventq[sync_dev->open_cnt] = filep->private_data;
+ spin_unlock_bh(&sync_dev->cam_sync_eventq_lock);
+ sync_dev->open_cnt++;
+#endif
+
} else {
CAM_ERR(CAM_SYNC, "v4l2_fh_open failed : %d", rc);
}
@@ -1660,7 +1749,16 @@ static int cam_sync_close(struct file *filep)
mutex_unlock(&sync_dev->table_lock);
spin_lock_bh(&sync_dev->cam_sync_eventq_lock);
+#ifndef CAM_MULTI
sync_dev->cam_sync_eventq = NULL;
+#else
+ for (i = 0; i < CAM_SYNC_MAX_INSTANCE; i++){
+ if (sync_dev->cam_sync_eventq[i] == filep->private_data){
+ sync_dev->cam_sync_eventq[i] = NULL;
+ }
+ }
+
+#endif
spin_unlock_bh(&sync_dev->cam_sync_eventq_lock);
v4l2_fh_release(filep);
@@ -1947,6 +2045,10 @@ static int cam_sync_component_bind(struct device *dev,
cam_sync_init_entity(sync_dev);
video_set_drvdata(sync_dev->vdev, sync_dev);
+#ifndef CAM_MULTI
+#else
+ memset(&sync_dev->sync_instance_map, -1,sizeof(sync_dev->sync_instance_map));
+#endif
bitmap_zero(sync_dev->bitmap, CAM_SYNC_MAX_OBJS);
/*
diff --git a/drivers/cam_sync/cam_sync_api.h b/drivers/cam_sync/cam_sync_api.h
index c79fda8df..ce3cab416 100644
--- a/drivers/cam_sync/cam_sync_api.h
+++ b/drivers/cam_sync/cam_sync_api.h
@@ -12,6 +12,7 @@
#include <linux/videodev2.h>
#include <media/cam_sync.h>
+#define CAM_MULTI
#define SYNC_DEBUG_NAME_LEN 63
typedef void (*sync_callback)(int32_t sync_obj, int status, void *data);
@@ -33,7 +34,11 @@ typedef void (*sync_callback)(int32_t sync_obj, int status, void *data);
* -ENOMEM will be returned if the kernel can't allocate space for
* sync object.
*/
+ #ifndef CAM_MULTI
int cam_sync_create(int32_t *sync_obj, const char *name);
+#else
+int cam_sync_create(int32_t *sync_obj, const char *name, int instance);
+#endif
/**
* @brief: Registers a callback with a sync object
diff --git a/drivers/cam_sync/cam_sync_private.h b/drivers/cam_sync/cam_sync_private.h
index e91777057..566eb2321 100644
--- a/drivers/cam_sync/cam_sync_private.h
+++ b/drivers/cam_sync/cam_sync_private.h
@@ -44,6 +44,11 @@
#define CAM_SYNC_TYPE_INDV 0
#define CAM_SYNC_TYPE_GROUP 1
+#ifndef CAM_MULTI
+#else
+#define CAM_SYNC_MAX_INSTANCE 3
+#endif
+
/**
* enum sync_type - Enum to indicate the type of sync object,
* i.e. individual or group.
@@ -217,9 +222,18 @@ struct sync_device {
int open_cnt;
struct dentry *dentry;
struct workqueue_struct *work_queue;
+#ifndef CAM_MULTI
struct v4l2_fh *cam_sync_eventq;
+#else
+ struct v4l2_fh *cam_sync_eventq[CAM_SYNC_MAX_INSTANCE];
+#endif
spinlock_t cam_sync_eventq_lock;
DECLARE_BITMAP(bitmap, CAM_SYNC_MAX_OBJS);
+#ifndef CAM_MULTI
+#else
+ int sync_instance_map[CAM_SYNC_MAX_OBJS];
+#endif
+
#if IS_REACHABLE(CONFIG_MSM_GLOBAL_SYNX)
struct synx_register_params params;
#endif
diff --git a/drivers/cam_sync/cam_sync_util.c b/drivers/cam_sync/cam_sync_util.c
index 551deac18..1b9e3ab7f 100644
--- a/drivers/cam_sync/cam_sync_util.c
+++ b/drivers/cam_sync/cam_sync_util.c
@@ -298,6 +298,9 @@ int cam_sync_deinit_object(struct sync_table_row *table, uint32_t idx,
memset(row, 0, sizeof(*row));
clear_bit(idx, sync_dev->bitmap);
+#ifdef CAM_MULTI
+ sync_dev->sync_instance_map[idx] = -1;
+#endif
INIT_LIST_HEAD(&row->callback_list);
INIT_LIST_HEAD(&row->parents_list);
INIT_LIST_HEAD(&row->children_list);
@@ -332,6 +335,10 @@ void cam_sync_util_dispatch_signaled_cb(int32_t sync_obj,
struct sync_table_row *signalable_row;
struct sync_user_payload *temp_payload_info;
+#ifdef CAM_MULTI
+ int instance = -1;
+#endif
+
signalable_row = sync_dev->sync_table + sync_obj;
if (signalable_row->state == CAM_SYNC_STATE_INVALID) {
CAM_DBG(CAM_SYNC,
@@ -349,11 +356,21 @@ void cam_sync_util_dispatch_signaled_cb(int32_t sync_obj,
&sync_cb->cb_dispatch_work);
}
+#ifdef CAM_MULTI
+ instance = sync_dev->sync_instance_map[sync_obj];
+ if (instance < 0 || instance >= CAM_SYNC_MAX_INSTANCE){
+ CAM_ERR(CAM_SYNC,"ERRRRRRRRRRRRRRRRRRRRRRRRrrrr, instance:%d sync_obj:%d",instance,sync_obj);
+ }
+#endif
/* Dispatch user payloads if any were registered earlier */
list_for_each_entry_safe(payload_info, temp_payload_info,
&signalable_row->user_payload_list, list) {
spin_lock_bh(&sync_dev->cam_sync_eventq_lock);
+#ifndef CAM_MULTI
if (!sync_dev->cam_sync_eventq) {
+#else
+ if (!sync_dev->cam_sync_eventq[instance]) {
+#endif
spin_unlock_bh(
&sync_dev->cam_sync_eventq_lock);
break;
@@ -392,6 +409,11 @@ void cam_sync_util_send_v4l2_event(uint32_t id,
struct v4l2_event event;
__u64 *payload_data = NULL;
+#ifndef CAM_MULTI
+#else
+ struct v4l2_fh *fh;
+#endif
+
if (sync_dev->version == CAM_SYNC_V4L_EVENT_V2) {
struct cam_sync_ev_header_v2 *ev_header = NULL;
@@ -418,7 +440,18 @@ void cam_sync_util_send_v4l2_event(uint32_t id,
}
memcpy(payload_data, payload, len);
+#ifndef CAM_MULTI
v4l2_event_queue(sync_dev->vdev, &event);
+#else
+ list_for_each_entry(fh, &sync_dev->vdev->fh_list, list){
+ int instance = sync_dev->sync_instance_map[sync_obj];
+ CAM_DBG(CAM_SYNC,"[ts_debug] fh:%p instance:%d cam_sync_eventq:%p\n",fh,instance,sync_dev->cam_sync_eventq[instance]);
+ if (fh == sync_dev->cam_sync_eventq[instance]){
+ v4l2_event_queue_fh(fh,&event);
+ }
+ }
+
+#endif
CAM_DBG(CAM_SYNC, "send v4l2 event version %d for sync_obj :%d",
sync_dev->version,
sync_obj);
diff --git a/drivers/cam_utils/cam_debug_util.c b/drivers/cam_utils/cam_debug_util.c
index 81dcf2439..bb3809492 100644
--- a/drivers/cam_utils/cam_debug_util.c
+++ b/drivers/cam_utils/cam_debug_util.c
@@ -12,7 +12,8 @@
#include "cam_debug_util.h"
-unsigned long long debug_mdl;
+//unsigned long long debug_mdl;
+unsigned long long debug_mdl = 0x80;
module_param(debug_mdl, ullong, 0644);
/* 0x0 - only logs, 0x1 - only trace, 0x2 - logs + trace */
然后使用以下的代码进行调用:
vendor\qcom\proprietary\camx\src\hwl\jpeg\camxjpegencconfig.cpp
就可以单独的实现jpeg 硬件的编码。