diff options
author | PixelBot AutoMerger <android-nexus-securitybot@system.gserviceaccount.com> | 2023-09-17 18:16:45 -0700 |
---|---|---|
committer | Pindar Yang <pindaryang@google.com> | 2023-09-19 03:36:21 +0000 |
commit | 6f86da5672a118aa7ce59dcaa5c9981cf77e3dde (patch) | |
tree | 978217a9e01fa1313d3453611431d4a33df18553 | |
parent | 2577e90e94a0d0f32804e18f966aeeec0149be20 (diff) | |
parent | 81d1b63026d15e91768527b862ff0becbf900663 (diff) | |
download | camera-kernel-android-msm-redbull-4.19-android14-qpr2.tar.gz |
Merge android-msm-pixel-4.19-udc into android-msm-pixel-4.19-udc-qpr1android-u-qpr3-beta-2_r0.1android-u-qpr3-beta-2.1_r0.6android-u-qpr3-beta-1_r0.6android-u-qpr2-beta-3_r0.1android-u-qpr2-beta-3.1_r0.6android-u-qpr2-beta-1_r0.8android-14.0.0_r0.78android-14.0.0_r0.68android-14.0.0_r0.58android-14.0.0_r0.46android-14.0.0_r0.32android-14.0.0_r0.20android-msm-redbull-4.19-android14-qpr3-betaandroid-msm-redbull-4.19-android14-qpr2-betaandroid-msm-redbull-4.19-android14-qpr2android-msm-redbull-4.19-android14-qpr1
Bug: 292447561
SBMerger: 558810260
Change-Id: Ic7db39529eaeed37a2ccfd25ef2a7bcc3bb01312
Signed-off-by: SecurityBot <android-nexus-securitybot@system.gserviceaccount.com>
-rw-r--r-- | drivers/cam_req_mgr/cam_mem_mgr.c | 18 | ||||
-rw-r--r-- | drivers/cam_req_mgr/cam_req_mgr_core.c | 69 | ||||
-rw-r--r-- | drivers/cam_req_mgr/cam_req_mgr_util.c | 126 | ||||
-rw-r--r-- | drivers/cam_req_mgr/cam_req_mgr_util.h | 55 |
4 files changed, 194 insertions, 74 deletions
diff --git a/drivers/cam_req_mgr/cam_mem_mgr.c b/drivers/cam_req_mgr/cam_mem_mgr.c index 77622e2..d106741 100644 --- a/drivers/cam_req_mgr/cam_mem_mgr.c +++ b/drivers/cam_req_mgr/cam_mem_mgr.c @@ -402,7 +402,6 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, struct dma_buf **buf, int *fd) { - struct dma_buf *dmabuf = NULL; int rc = 0; struct timespec64 ts1, ts2; long microsec = 0; @@ -418,23 +417,18 @@ static int cam_mem_util_get_dma_buf_fd(size_t len, *buf = ion_alloc(len, heap_id_mask, flags); if (IS_ERR_OR_NULL(*buf)) return -ENOMEM; - - *fd = dma_buf_fd(*buf, O_CLOEXEC); - if (*fd < 0) { - CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd); - rc = -EINVAL; - goto get_fd_fail; - } - /* * increment the ref count so that ref count becomes 2 here * when we close fd, refcount becomes 1 and when we do * dmap_put_buf, ref count becomes 0 and memory will be freed. */ - dmabuf = dma_buf_get(*fd); - if (IS_ERR_OR_NULL(dmabuf)) { - CAM_ERR(CAM_MEM, "dma_buf_get failed, *fd=%d", *fd); + get_dma_buf(*buf); + + *fd = dma_buf_fd(*buf, O_CLOEXEC); + if (*fd < 0) { + CAM_ERR(CAM_MEM, "get fd fail, *fd=%d", *fd); rc = -EINVAL; + goto get_fd_fail; } if (tbl.alloc_profile_enable) { diff --git a/drivers/cam_req_mgr/cam_req_mgr_core.c b/drivers/cam_req_mgr/cam_req_mgr_core.c index d9dfa9b..7911255 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_core.c +++ b/drivers/cam_req_mgr/cam_req_mgr_core.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2016-2020, The Linux Foundation. All rights reserved. + * Copyright (c) 2022-2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #include <linux/module.h> @@ -2661,9 +2662,7 @@ static int cam_req_mgr_cb_add_req(struct cam_req_mgr_add_request *add_req) return -EINVAL; } - link = (struct cam_req_mgr_core_link *) - cam_get_device_priv(add_req->link_hdl); - + link = cam_get_link_priv(add_req->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", add_req->link_hdl); return -EINVAL; @@ -2740,8 +2739,7 @@ static int cam_req_mgr_cb_notify_err( goto end; } - link = (struct cam_req_mgr_core_link *) - cam_get_device_priv(err_info->link_hdl); + link = cam_get_link_priv(err_info->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", err_info->link_hdl); rc = -EINVAL; @@ -2827,8 +2825,7 @@ static int cam_req_mgr_cb_notify_timer( goto end; } - link = (struct cam_req_mgr_core_link *) - cam_get_device_priv(timer_data->link_hdl); + link = cam_get_link_priv(timer_data->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", timer_data->link_hdl); rc = -EINVAL; @@ -2874,8 +2871,7 @@ static int cam_req_mgr_cb_notify_stop( goto end; } - link = (struct cam_req_mgr_core_link *) - cam_get_device_priv(stop_info->link_hdl); + link = cam_get_link_priv(stop_info->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", stop_info->link_hdl); rc = -EINVAL; @@ -2936,8 +2932,7 @@ static int cam_req_mgr_cb_notify_trigger( goto end; } - link = (struct cam_req_mgr_core_link *) - cam_get_device_priv(trigger_data->link_hdl); + link = cam_get_link_priv(trigger_data->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", trigger_data->link_hdl); rc = -EINVAL; @@ -3292,7 +3287,7 @@ static int __cam_req_mgr_unlink(struct cam_req_mgr_core_link *link) __cam_req_mgr_destroy_subdev(link->l_dev); /* Destroy the link handle */ - rc = cam_destroy_device_hdl(link->link_hdl); + rc = cam_destroy_link_hdl(link->link_hdl); if (rc < 0) { CAM_ERR(CAM_CRM, "error destroying link hdl %x rc %d", link->link_hdl, rc); @@ -3318,8 +3313,7 @@ int cam_req_mgr_destroy_session( } mutex_lock(&g_crm_core_dev->crm_lock); - cam_session = (struct cam_req_mgr_core_session *) - cam_get_device_priv(ses_info->session_hdl); + cam_session = cam_get_session_priv(ses_info->session_hdl); if (!cam_session) { CAM_ERR(CAM_CRM, "failed to get session priv"); rc = -ENOENT; @@ -3379,8 +3373,8 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info) mutex_lock(&g_crm_core_dev->crm_lock); /* session hdl's priv data is cam session struct */ - cam_session = (struct cam_req_mgr_core_session *) - cam_get_device_priv(link_info->u.link_info_v1.session_hdl); + cam_session = + cam_get_session_priv(link_info->u.link_info_v1.session_hdl); if (!cam_session) { CAM_DBG(CAM_CRM, "NULL pointer"); mutex_unlock(&g_crm_core_dev->crm_lock); @@ -3401,8 +3395,8 @@ int cam_req_mgr_link(struct cam_req_mgr_ver_info *link_info) root_dev.priv = (void *)link; mutex_lock(&link->lock); - /* Create unique dev handle for link */ - link->link_hdl = cam_create_device_hdl(&root_dev); + /* Create unique handle for link */ + link->link_hdl = cam_create_link_hdl(&root_dev); if (link->link_hdl < 0) { CAM_ERR(CAM_CRM, "Insufficient memory to create new device handle"); @@ -3488,8 +3482,8 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info) mutex_lock(&g_crm_core_dev->crm_lock); /* session hdl's priv data is cam session struct */ - cam_session = (struct cam_req_mgr_core_session *) - cam_get_device_priv(link_info->u.link_info_v2.session_hdl); + cam_session = + cam_get_session_priv(link_info->u.link_info_v2.session_hdl); if (!cam_session) { CAM_DBG(CAM_CRM, "NULL pointer"); mutex_unlock(&g_crm_core_dev->crm_lock); @@ -3510,8 +3504,8 @@ int cam_req_mgr_link_v2(struct cam_req_mgr_ver_info *link_info) root_dev.priv = (void *)link; mutex_lock(&link->lock); - /* Create unique dev handle for link */ - link->link_hdl = cam_create_device_hdl(&root_dev); + /* Create unique handle for link */ + link->link_hdl = cam_create_link_hdl(&root_dev); if (link->link_hdl < 0) { CAM_ERR(CAM_CRM, "Insufficient memory to create new device handle"); @@ -3590,8 +3584,7 @@ int cam_req_mgr_unlink(struct cam_req_mgr_unlink_info *unlink_info) CAM_DBG(CAM_CRM, "link_hdl %x", unlink_info->link_hdl); /* session hdl's priv data is cam session struct */ - cam_session = (struct cam_req_mgr_core_session *) - cam_get_device_priv(unlink_info->session_hdl); + cam_session = cam_get_session_priv(unlink_info->session_hdl); if (!cam_session) { CAM_ERR(CAM_CRM, "NULL pointer"); mutex_unlock(&g_crm_core_dev->crm_lock); @@ -3599,7 +3592,7 @@ int cam_req_mgr_unlink(struct cam_req_mgr_unlink_info *unlink_info) } /* link hdl's priv data is core_link struct */ - link = cam_get_device_priv(unlink_info->link_hdl); + link = cam_get_link_priv(unlink_info->link_hdl); if (!link) { CAM_ERR(CAM_CRM, "NULL pointer"); rc = -EINVAL; @@ -3631,8 +3624,7 @@ int cam_req_mgr_schedule_request( } mutex_lock(&g_crm_core_dev->crm_lock); - link = (struct cam_req_mgr_core_link *) - cam_get_device_priv(sched_req->link_hdl); + link = cam_get_link_priv(sched_req->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", sched_req->link_hdl); rc = -EINVAL; @@ -3744,8 +3736,8 @@ int cam_req_mgr_sync_config( mutex_lock(&g_crm_core_dev->crm_lock); /* session hdl's priv data is cam session struct */ - cam_session = (struct cam_req_mgr_core_session *) - cam_get_device_priv(sync_info->session_hdl); + cam_session = + cam_get_session_priv(sync_info->session_hdl); if (!cam_session) { CAM_ERR(CAM_CRM, "NULL pointer"); mutex_unlock(&g_crm_core_dev->crm_lock); @@ -3758,14 +3750,14 @@ int cam_req_mgr_sync_config( sync_info->link_hdls[0], sync_info->link_hdls[1]); /* only two links existing per session in dual cam use case*/ - link1 = cam_get_device_priv(sync_info->link_hdls[0]); + link1 = cam_get_link_priv(sync_info->link_hdls[0]); if (!link1) { CAM_ERR(CAM_CRM, "link1 NULL pointer"); rc = -EINVAL; goto done; } - link2 = cam_get_device_priv(sync_info->link_hdls[1]); + link2 = cam_get_link_priv(sync_info->link_hdls[1]); if (!link2) { CAM_ERR(CAM_CRM, "link2 NULL pointer"); rc = -EINVAL; @@ -3835,8 +3827,7 @@ int cam_req_mgr_flush_requests( mutex_lock(&g_crm_core_dev->crm_lock); /* session hdl's priv data is cam session struct */ - session = (struct cam_req_mgr_core_session *) - cam_get_device_priv(flush_info->session_hdl); + session = cam_get_session_priv(flush_info->session_hdl); if (!session) { CAM_ERR(CAM_CRM, "Invalid session %x", flush_info->session_hdl); rc = -EINVAL; @@ -3848,8 +3839,7 @@ int cam_req_mgr_flush_requests( goto end; } - link = (struct cam_req_mgr_core_link *) - cam_get_device_priv(flush_info->link_hdl); + link = cam_get_link_priv(flush_info->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", flush_info->link_hdl); rc = -EINVAL; @@ -3906,8 +3896,7 @@ int cam_req_mgr_link_control(struct cam_req_mgr_link_control *control) mutex_lock(&g_crm_core_dev->crm_lock); for (i = 0; i < control->num_links; i++) { - link = (struct cam_req_mgr_core_link *) - cam_get_device_priv(control->link_hdls[i]); + link = cam_get_link_priv(control->link_hdls[i]); if (!link) { CAM_ERR(CAM_CRM, "Link(%d) is NULL on session 0x%x", i, control->session_hdl); @@ -3983,8 +3972,7 @@ int cam_req_mgr_dump_request(struct cam_dump_req_cmd *dump_req) mutex_lock(&g_crm_core_dev->crm_lock); /* session hdl's priv data is cam session struct */ - session = (struct cam_req_mgr_core_session *) - cam_get_device_priv(dump_req->session_handle); + session = cam_get_session_priv(dump_req->session_handle); if (!session) { CAM_ERR(CAM_CRM, "Invalid session %x", dump_req->session_handle); @@ -3997,8 +3985,7 @@ int cam_req_mgr_dump_request(struct cam_dump_req_cmd *dump_req) goto end; } - link = (struct cam_req_mgr_core_link *) - cam_get_device_priv(dump_req->link_hdl); + link = cam_get_link_priv(dump_req->link_hdl); if (!link) { CAM_DBG(CAM_CRM, "link ptr NULL %x", dump_req->link_hdl); rc = -EINVAL; diff --git a/drivers/cam_req_mgr/cam_req_mgr_util.c b/drivers/cam_req_mgr/cam_req_mgr_util.c index a1a5da3..9fded8d 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_util.c +++ b/drivers/cam_req_mgr/cam_req_mgr_util.c @@ -1,6 +1,7 @@ // SPDX-License-Identifier: GPL-2.0-only /* * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #define pr_fmt(fmt) "CAM-REQ-MGR_UTIL %s:%d " fmt, __func__, __LINE__ @@ -35,28 +36,29 @@ int cam_req_mgr_util_init(void) rc = -ENOMEM; goto hdl_tbl_alloc_failed; } + bitmap_size = BITS_TO_LONGS(CAM_REQ_MGR_MAX_HANDLES_V2) * sizeof(long); + hdl_tbl_local->bitmap = kzalloc(bitmap_size, GFP_KERNEL); + if (!hdl_tbl_local->bitmap) { + rc = -ENOMEM; + goto bitmap_alloc_fail; + } + hdl_tbl_local->bits = bitmap_size * BITS_PER_BYTE; + spin_lock_bh(&hdl_tbl_lock); if (hdl_tbl) { spin_unlock_bh(&hdl_tbl_lock); rc = -EEXIST; + kfree(hdl_tbl_local->bitmap); kfree(hdl_tbl_local); goto hdl_tbl_check_failed; } hdl_tbl = hdl_tbl_local; spin_unlock_bh(&hdl_tbl_lock); - bitmap_size = BITS_TO_LONGS(CAM_REQ_MGR_MAX_HANDLES_V2) * sizeof(long); - hdl_tbl->bitmap = kzalloc(bitmap_size, GFP_KERNEL); - if (!hdl_tbl->bitmap) { - rc = -ENOMEM; - goto bitmap_alloc_fail; - } - hdl_tbl->bits = bitmap_size * BITS_PER_BYTE; - return rc; bitmap_alloc_fail: - kfree(hdl_tbl); + kfree(hdl_tbl_local); hdl_tbl = NULL; hdl_tbl_alloc_failed: hdl_tbl_check_failed: @@ -121,6 +123,19 @@ static int32_t cam_get_free_handle_index(void) return idx; } +static void cam_dump_tbl_info(void) +{ + int i; + + for (i = 0; i < CAM_REQ_MGR_MAX_HANDLES_V2; i++) + CAM_INFO_RATE_LIMIT_CUSTOM(CAM_CRM, + CAM_RATE_LIMIT_INTERVAL_5SEC, + CAM_REQ_MGR_MAX_HANDLES_V2, + "ses_hdl=%x hdl_value=%x type=%d state=%d", + hdl_tbl->hdl[i].session_hdl, hdl_tbl->hdl[i].hdl_value, + hdl_tbl->hdl[i].type, hdl_tbl->hdl[i].state); +} + int32_t cam_create_session_hdl(void *priv) { int idx; @@ -136,7 +151,9 @@ int32_t cam_create_session_hdl(void *priv) idx = cam_get_free_handle_index(); if (idx < 0) { - CAM_ERR(CAM_CRM, "Unable to create session handle"); + CAM_ERR(CAM_CRM, "Unable to create session handle(idx = %d)", + idx); + cam_dump_tbl_info(); spin_unlock_bh(&hdl_tbl_lock); return idx; } @@ -169,7 +186,9 @@ int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data) idx = cam_get_free_handle_index(); if (idx < 0) { - CAM_ERR(CAM_CRM, "Unable to create device handle"); + CAM_ERR(CAM_CRM, "Unable to create device handle(idx= %d)", + idx); + cam_dump_tbl_info(); spin_unlock_bh(&hdl_tbl_lock); return idx; } @@ -189,7 +208,43 @@ int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data) } EXPORT_SYMBOL_GPL(cam_create_device_hdl); -void *cam_get_device_priv(int32_t dev_hdl) +int32_t cam_create_link_hdl(struct cam_create_dev_hdl *hdl_data) +{ + int idx; + int rand = 0; + int32_t handle; + + spin_lock_bh(&hdl_tbl_lock); + if (!hdl_tbl) { + CAM_ERR(CAM_CRM, "Hdl tbl is NULL"); + spin_unlock_bh(&hdl_tbl_lock); + return -EINVAL; + } + + idx = cam_get_free_handle_index(); + if (idx < 0) { + CAM_ERR(CAM_CRM, "Unable to create link handle(idx = %d)", idx); + cam_dump_tbl_info(); + spin_unlock_bh(&hdl_tbl_lock); + return idx; + } + + get_random_bytes(&rand, CAM_REQ_MGR_RND1_BYTES); + handle = GET_DEV_HANDLE(rand, HDL_TYPE_LINK, idx); + hdl_tbl->hdl[idx].session_hdl = hdl_data->session_hdl; + hdl_tbl->hdl[idx].hdl_value = handle; + hdl_tbl->hdl[idx].type = HDL_TYPE_LINK; + hdl_tbl->hdl[idx].state = HDL_ACTIVE; + hdl_tbl->hdl[idx].priv = hdl_data->priv; + hdl_tbl->hdl[idx].ops = NULL; + spin_unlock_bh(&hdl_tbl_lock); + + CAM_DBG(CAM_CRM, "handle = %x", handle); + return handle; +} +EXPORT_SYMBOL_GPL(cam_create_link_hdl); + +void *cam_get_priv(int32_t dev_hdl, int handle_type) { int idx; int type; @@ -203,17 +258,18 @@ void *cam_get_device_priv(int32_t dev_hdl) idx = CAM_REQ_MGR_GET_HDL_IDX(dev_hdl); if (idx >= CAM_REQ_MGR_MAX_HANDLES_V2) { - CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid idx"); + CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid idx: %d", idx); goto device_priv_fail; } if (hdl_tbl->hdl[idx].state != HDL_ACTIVE) { - CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid state"); + CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid state: %d", + hdl_tbl->hdl[idx].state); goto device_priv_fail; } type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl); - if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type) { + if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type && HDL_TYPE_LINK != type) { CAM_ERR_RATE_LIMIT(CAM_CRM, "Invalid type"); goto device_priv_fail; } @@ -232,8 +288,38 @@ device_priv_fail: spin_unlock_bh(&hdl_tbl_lock); return NULL; } + +void *cam_get_device_priv(int32_t dev_hdl) +{ + void *priv; + + priv = cam_get_priv(dev_hdl, HDL_TYPE_DEV); + return priv; +} EXPORT_SYMBOL_GPL(cam_get_device_priv); +struct cam_req_mgr_core_session *cam_get_session_priv(int32_t dev_hdl) +{ + struct cam_req_mgr_core_session *priv; + + priv = (struct cam_req_mgr_core_session *) + cam_get_priv(dev_hdl, HDL_TYPE_SESSION); + + return priv; +} +EXPORT_SYMBOL_GPL(cam_get_session_priv); + +struct cam_req_mgr_core_link *cam_get_link_priv(int32_t dev_hdl) +{ + struct cam_req_mgr_core_link *priv; + + priv = (struct cam_req_mgr_core_link *) + cam_get_priv(dev_hdl, HDL_TYPE_LINK); + + return priv; +} +EXPORT_SYMBOL_GPL(cam_get_link_priv); + void *cam_get_device_ops(int32_t dev_hdl) { int idx; @@ -258,7 +344,8 @@ void *cam_get_device_ops(int32_t dev_hdl) } type = CAM_REQ_MGR_GET_HDL_TYPE(dev_hdl); - if (HDL_TYPE_DEV != type && HDL_TYPE_SESSION != type) { + if (type != HDL_TYPE_DEV && type != HDL_TYPE_SESSION && + type != HDL_TYPE_LINK) { CAM_ERR(CAM_CRM, "Invalid type"); goto device_ops_fail; } @@ -330,6 +417,13 @@ int cam_destroy_device_hdl(int32_t dev_hdl) } EXPORT_SYMBOL_GPL(cam_destroy_device_hdl); +int cam_destroy_link_hdl(int32_t dev_hdl) +{ + CAM_DBG(CAM_CRM, "handle = %x", dev_hdl); + return cam_destroy_hdl(dev_hdl, HDL_TYPE_LINK); +} +EXPORT_SYMBOL_GPL(cam_destroy_link_hdl); + int cam_destroy_session_hdl(int32_t dev_hdl) { return cam_destroy_hdl(dev_hdl, HDL_TYPE_SESSION); diff --git a/drivers/cam_req_mgr/cam_req_mgr_util.h b/drivers/cam_req_mgr/cam_req_mgr_util.h index c0e339e..2f676ae 100644 --- a/drivers/cam_req_mgr/cam_req_mgr_util.h +++ b/drivers/cam_req_mgr/cam_req_mgr_util.h @@ -1,6 +1,7 @@ /* SPDX-License-Identifier: GPL-2.0-only */ /* * Copyright (c) 2016-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2023 Qualcomm Innovation Center, Inc. All rights reserved. */ #ifndef _CAM_REQ_MGR_UTIL_API_H_ @@ -9,6 +10,9 @@ #include <media/cam_req_mgr.h> #include "cam_req_mgr_util_priv.h" +/* Interval for cam_info_rate_limit_custom() */ +#define CAM_RATE_LIMIT_INTERVAL_5SEC 5 + /** * state of a handle(session/device) * @HDL_FREE: free handle @@ -21,12 +25,14 @@ enum hdl_state { /** * handle type - * @HDL_TYPE_DEV: for device and link + * @HDL_TYPE_DEV: for device * @HDL_TYPE_SESSION: for session + * @HDL_TYPE_LINK: for link */ enum hdl_type { HDL_TYPE_DEV = 1, - HDL_TYPE_SESSION + HDL_TYPE_SESSION, + HDL_TYPE_LINK }; /** @@ -99,8 +105,19 @@ int32_t cam_create_session_hdl(void *priv); int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data); /** - * cam_get_device_priv() - get private data of a handle - * @dev_hdl: handle for a session/link/device + * cam_create_link_hdl() - create a link handle + * @hdl_data: session hdl, flags, ops and priv dara as input + * + * cam_req_mgr_core calls this function to get + * session and link handles + * KMD drivers calls this function to create + * a link handle. Returns a unique link handle + */ +int32_t cam_create_link_hdl(struct cam_create_dev_hdl *hdl_data); + +/** + * cam_get_device_priv() - get private data of a device handle + * @dev_hdl: handle for a device * * cam_req_mgr_core and KMD drivers use this function to * get private data of a handle. Returns a private data @@ -109,6 +126,26 @@ int32_t cam_create_device_hdl(struct cam_create_dev_hdl *hdl_data); void *cam_get_device_priv(int32_t dev_hdl); /** + * cam_get_session_priv() - get private data of a session handle + * @dev_hdl: handle for a session + * + * cam_req_mgr_core and KMD drivers use this function to + * get private data of a handle. Returns a private data + * structure pointer. + */ +struct cam_req_mgr_core_session *cam_get_session_priv(int32_t dev_hdl); + +/** + * cam_get_link_priv() - get private data of a link handle + * @dev_hdl: handle for a link + * + * cam_req_mgr_core and KMD drivers use this function to + * get private data of a handle. Returns a private data + * structure pointer. + */ +struct cam_req_mgr_core_link *cam_get_link_priv(int32_t dev_hdl); + +/** * cam_get_device_ops() - get ops of a handle * @dev_hdl: handle for a session/link/device * @@ -119,13 +156,21 @@ void *cam_get_device_ops(int32_t dev_hdl); /** * cam_destroy_device_hdl() - destroy device handle - * @dev_hdl: handle for a link/device. + * @dev_hdl: handle for a device. * * Returns success/failure */ int32_t cam_destroy_device_hdl(int32_t dev_hdl); /** + * cam_destroy_link_hdl() - destroy link handle + * @dev_hdl: handle for a link. + * + * Returns success/failure + */ +int32_t cam_destroy_link_hdl(int32_t dev_hdl); + +/** * cam_destroy_session_hdl() - destroy device handle * @dev_hdl: handle for a session * |