Skip to content

Commit 59d417d

Browse files
Camera Software IntegrationGerrit - the friendly Code Review server
authored andcommitted
Merge changes I2d0133d6,I8298f6ca into camera-kernel.qclinux.1.0
* changes: msm: camera: reqmgr: adding support sched_req ver3 msm: camera: uapi: new structure for SAT frame sync
2 parents 460d527 + 18ee654 commit 59d417d

4 files changed

Lines changed: 254 additions & 34 deletions

File tree

camera/drivers/cam_req_mgr/cam_req_mgr_core.c

Lines changed: 130 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
// SPDX-License-Identifier: GPL-2.0-only
22
/*
33
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2022-2024, Qualcomm Innovation Center, Inc. All rights reserved.
54
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
65
*/
76

@@ -3239,20 +3238,18 @@ int cam_req_mgr_process_flush_req(void *priv, void *data)
32393238
int cam_req_mgr_process_sched_req(void *priv, void *data)
32403239
{
32413240
int rc = 0, i, sync_idx = 0;
3242-
struct cam_req_mgr_sched_request_v2 *sched_req = NULL;
3241+
struct cam_req_mgr_core_sched_req *sched_req = NULL;
32433242
struct cam_req_mgr_core_link *link = NULL;
32443243
struct cam_req_mgr_req_queue *in_q = NULL;
32453244
struct cam_req_mgr_slot *slot = NULL;
3246-
struct crm_task_payload *task_data = NULL;
32473245

32483246
if (!data || !priv) {
32493247
CAM_ERR(CAM_CRM, "input args NULL %pK %pK", data, priv);
32503248
rc = -EINVAL;
32513249
goto end;
32523250
}
32533251
link = (struct cam_req_mgr_core_link *)priv;
3254-
task_data = (struct crm_task_payload *)data;
3255-
sched_req = (struct cam_req_mgr_sched_request_v2 *)&task_data->u;
3252+
sched_req = (struct cam_req_mgr_core_sched_req *)data;
32563253
in_q = link->req.in_q;
32573254

32583255
CAM_DBG(CAM_CRM,
@@ -5164,8 +5161,7 @@ int cam_req_mgr_schedule_request(
51645161
int rc = 0;
51655162
struct cam_req_mgr_core_link *link = NULL;
51665163
struct cam_req_mgr_core_session *session = NULL;
5167-
struct cam_req_mgr_sched_request_v2 *sched;
5168-
struct crm_task_payload task_data;
5164+
struct cam_req_mgr_core_sched_req sched;
51695165

51705166
if (!sched_req) {
51715167
CAM_ERR(CAM_CRM, "csl_req is NULL");
@@ -5203,20 +5199,20 @@ int cam_req_mgr_schedule_request(
52035199
CAM_DBG(CAM_CRM, "link 0x%x req %lld, sync_mode %d",
52045200
sched_req->link_hdl, sched_req->req_id, sched_req->sync_mode);
52055201

5206-
task_data.type = CRM_WORKQ_TASK_SCHED_REQ;
5207-
sched = (struct cam_req_mgr_sched_request_v2 *)&task_data.u;
5208-
sched->req_id = sched_req->req_id;
5209-
sched->sync_mode = sched_req->sync_mode;
5210-
sched->link_hdl = sched_req->link_hdl;
5211-
sched->additional_timeout = sched_req->additional_timeout;
5202+
memset(&sched, 0, sizeof(sched));
5203+
5204+
sched.req_id = sched_req->req_id;
5205+
sched.sync_mode = sched_req->sync_mode;
5206+
sched.link_hdl = sched_req->link_hdl;
5207+
sched.additional_timeout = sched_req->additional_timeout;
52125208
if (session->force_err_recovery == AUTO_RECOVERY) {
5213-
sched->bubble_enable = sched_req->bubble_enable;
5209+
sched.bubble_enable = sched_req->bubble_enable;
52145210
} else {
5215-
sched->bubble_enable =
5211+
sched.bubble_enable =
52165212
(session->force_err_recovery == FORCE_ENABLE_RECOVERY) ? 1 : 0;
52175213
}
52185214

5219-
rc = cam_req_mgr_process_sched_req(link, &task_data);
5215+
rc = cam_req_mgr_process_sched_req(link, &sched);
52205216

52215217
CAM_DBG(CAM_REQ, "Open req %lld on link 0x%x with sync_mode %d",
52225218
sched_req->req_id, sched_req->link_hdl, sched_req->sync_mode);
@@ -5232,12 +5228,10 @@ int cam_req_mgr_schedule_request_v2(
52325228
int rc = 0;
52335229
struct cam_req_mgr_core_link *link = NULL;
52345230
struct cam_req_mgr_core_session *session = NULL;
5235-
struct crm_task_payload task_data;
5236-
struct cam_req_mgr_sched_request_v2 *sched;
5231+
struct cam_req_mgr_core_sched_req sched;
52375232
struct cam_req_mgr_core_link *sync_links[MAXIMUM_LINKS_PER_SESSION];
52385233

52395234
mutex_lock(&g_crm_core_dev->crm_lock);
5240-
52415235
link = cam_get_link_priv(sched_req->link_hdl);
52425236
if (!link || (link->link_hdl != sched_req->link_hdl)) {
52435237
CAM_ERR(CAM_CRM, "link: %s, sched_req->link_hdl:%x, link->link_hdl:%x",
@@ -5269,17 +5263,20 @@ int cam_req_mgr_schedule_request_v2(
52695263
sched_req->link_hdl, sched_req->req_id, sched_req->sync_mode,
52705264
sched_req->num_links);
52715265

5272-
task_data.type = CRM_WORKQ_TASK_SCHED_REQ;
5273-
sched = (struct cam_req_mgr_sched_request_v2 *)&task_data.u;
5274-
sched->req_id = sched_req->req_id;
5275-
sched->sync_mode = sched_req->sync_mode;
5276-
sched->link_hdl = sched_req->link_hdl;
5277-
sched->additional_timeout = sched_req->additional_timeout;
5266+
memset(&sched, 0, sizeof(sched));
5267+
5268+
sched.req_id = sched_req->req_id;
5269+
sched.sync_mode = sched_req->sync_mode;
5270+
sched.link_hdl = sched_req->link_hdl;
5271+
sched.additional_timeout = sched_req->additional_timeout;
5272+
sched.num_valid_params = sched_req->num_valid_params;
5273+
sched.param_mask = sched_req->param_mask;
5274+
sched.params = sched_req->params;
52785275

52795276
if (session->force_err_recovery == AUTO_RECOVERY) {
5280-
sched->bubble_enable = sched_req->bubble_enable;
5277+
sched.bubble_enable = sched_req->bubble_enable;
52815278
} else {
5282-
sched->bubble_enable =
5279+
sched.bubble_enable =
52835280
(session->force_err_recovery == FORCE_ENABLE_RECOVERY) ? 1 : 0;
52845281
}
52855282

@@ -5311,14 +5308,116 @@ int cam_req_mgr_schedule_request_v2(
53115308
rc = -EINVAL;
53125309
goto end;
53135310
}
5311+
}
5312+
sched.num_links = sched_req->num_links;
5313+
sched.link_hdls = sched_req->link_hdls;
5314+
} else
5315+
sched.num_links = 0;
5316+
5317+
rc = cam_req_mgr_process_sched_req(link, &sched);
5318+
5319+
CAM_DBG(CAM_REQ, "Open req %lld on link 0x%x with sync_mode %d",
5320+
sched_req->req_id, sched_req->link_hdl, sched_req->sync_mode);
5321+
end:
5322+
mutex_unlock(&g_crm_core_dev->crm_lock);
5323+
return rc;
5324+
}
5325+
5326+
int cam_req_mgr_schedule_request_v3(
5327+
struct cam_req_mgr_sched_request_v3 *sched_req)
5328+
{
5329+
int i = 0;
5330+
int rc = 0;
5331+
struct cam_req_mgr_core_link *link = NULL;
5332+
struct cam_req_mgr_core_session *session = NULL;
5333+
struct cam_req_mgr_core_sched_req sched;
5334+
struct cam_req_mgr_core_link *sync_links[MAXIMUM_LINKS_PER_SESSION];
5335+
5336+
mutex_lock(&g_crm_core_dev->crm_lock);
5337+
5338+
link = cam_get_link_priv(sched_req->link_hdl);
5339+
if (!link || (link->link_hdl != sched_req->link_hdl)) {
5340+
CAM_ERR(CAM_CRM, "link: %s, sched_req->link_hdl:%x, link->link_hdl:%x",
5341+
CAM_IS_NULL_TO_STR(link), sched_req->link_hdl,
5342+
(!link) ? CAM_REQ_MGR_DEFAULT_HDL_VAL : link->link_hdl);
5343+
rc = -EINVAL;
5344+
goto end;
5345+
}
5346+
5347+
session = (struct cam_req_mgr_core_session *)link->parent;
5348+
if (!session) {
5349+
CAM_WARN(CAM_CRM, "session ptr NULL %x", sched_req->link_hdl);
5350+
rc = -EINVAL;
5351+
goto end;
5352+
}
5353+
5354+
if (sched_req->req_id <= link->last_flush_id) {
5355+
CAM_INFO(CAM_CRM,
5356+
"request %lld is flushed, last_flush_id to flush %d",
5357+
sched_req->req_id, link->last_flush_id);
5358+
rc = -EBADR;
5359+
goto end;
5360+
}
5361+
5362+
if (sched_req->req_id > link->last_flush_id)
5363+
link->last_flush_id = 0;
5364+
5365+
CAM_DBG(CAM_CRM, "link 0x%x req %lld, sync_mode %d num_links %d",
5366+
sched_req->link_hdl, sched_req->req_id, sched_req->sync_mode,
5367+
sched_req->num_links);
5368+
5369+
memset(&sched, 0, sizeof(sched));
5370+
5371+
sched.req_id = sched_req->req_id;
5372+
sched.sync_mode = sched_req->sync_mode;
5373+
sched.link_hdl = sched_req->link_hdl;
5374+
sched.additional_timeout = sched_req->additional_timeout;
5375+
sched.num_valid_params = sched_req->num_valid_params;
5376+
sched.param_mask = sched_req->param_mask;
5377+
sched.params = sched_req->params;
5378+
5379+
if (session->force_err_recovery == AUTO_RECOVERY) {
5380+
sched.bubble_enable = sched_req->bubble_enable;
5381+
} else {
5382+
sched.bubble_enable =
5383+
(session->force_err_recovery == FORCE_ENABLE_RECOVERY) ? 1 : 0;
5384+
}
5385+
5386+
if (sched_req->sync_mode == CAM_REQ_MGR_SYNC_MODE_SYNC) {
5387+
if ((sched_req->num_links <= 0) &&
5388+
(sched_req->num_links > MAXIMUM_LINKS_PER_SESSION)) {
5389+
CAM_ERR(CAM_CRM, "link:0x%x req:%lld invalid num_links:%d",
5390+
link->link_hdl, sched_req->req_id, sched_req->num_links);
5391+
rc = -EINVAL;
5392+
goto end;
5393+
}
5394+
5395+
for (i = 0; i < sched_req->num_links; i++) {
5396+
if (!sched_req->link_hdls[i]) {
5397+
CAM_ERR(CAM_CRM, "link handle %d in sched_req is null", i);
5398+
rc = -EINVAL;
5399+
goto end;
5400+
}
53145401

5315-
sched->link_hdls[i] = sched_req->link_hdls[i];
5402+
sync_links[i] = cam_get_link_priv(sched_req->link_hdls[i]);
5403+
if (!sync_links[i] ||
5404+
(sync_links[i]->link_hdl != sched_req->link_hdls[i])) {
5405+
CAM_ERR(CAM_CRM,
5406+
"Invalid sync link, sync link[%d]: %s sched_req->link_hdl: %x sync_links->link_hdl: 0x%x",
5407+
i, CAM_IS_NULL_TO_STR(sync_links[i]),
5408+
sched_req->link_hdls[i],
5409+
((!sync_links[i]) ? CAM_REQ_MGR_DEFAULT_HDL_VAL :
5410+
sync_links[i]->link_hdl));
5411+
rc = -EINVAL;
5412+
goto end;
5413+
}
53165414
}
5317-
sched->num_links = sched_req->num_links;
5415+
sched.num_links = sched_req->num_links;
5416+
sched.link_hdls = sched_req->link_hdls;
53185417
} else
5319-
sched->num_links = 0;
5418+
sched.num_links = 0;
53205419

5321-
rc = cam_req_mgr_process_sched_req(link, &task_data);
5420+
rc = cam_req_mgr_process_sched_req(link, &sched);
53225421

53235422
CAM_DBG(CAM_REQ, "Open req %lld on link 0x%x with sync_mode %d",
53245423
sched_req->req_id, sched_req->link_hdl, sched_req->sync_mode);

camera/drivers/cam_req_mgr/cam_req_mgr_core.h

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* SPDX-License-Identifier: GPL-2.0-only */
22
/*
33
* Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
4-
* Copyright (c) 2022-2025, Qualcomm Innovation Center, Inc. All rights reserved.
4+
* Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
55
*/
66

77
#ifndef _CAM_REQ_MGR_CORE_H_
@@ -665,6 +665,48 @@ struct cam_req_mgr_core_link_mini_dump {
665665
bool wq_congestion;
666666
};
667667

668+
/**
669+
* struct cam_req_mgr_core_sched_req
670+
*
671+
* - Common members
672+
* @session_hdl : Input param - Identifier for CSL session
673+
* @ink_hdl : Input Param -Identifier for link including itself.
674+
* @bubble_enable : Input Param - Cam req mgr will do bubble recovery if this
675+
* flag is set.
676+
* @sync_mode : Type of Sync mode for this request
677+
* @additional_timeout : Additional timeout value (in ms) associated with
678+
* this request. This value needs to be 0 in cases where long exposure is
679+
* not configured for the sensor.The max timeout that will be supported
680+
* is 50000 ms
681+
* @req_id : Input Param - Request Id from which all requests will be flushed
682+
*
683+
* - Support sched_request
684+
* @reserved : Reserved
685+
*
686+
* - Support sched_request_v2/sched_request_v3
687+
* @version : Version number
688+
* @num_links : Input Param - Num of links for sync
689+
* @num_valid_params : Number of valid params
690+
* @param_mask : mask to indicate what the parameters are
691+
* @params : pointer, point to parameters passed from user space
692+
* @link_hdls : pointer, point to Input Param - Array of link handles to be for sync
693+
*/
694+
struct cam_req_mgr_core_sched_req {
695+
int32_t session_hdl;
696+
int32_t link_hdl;
697+
int32_t bubble_enable;
698+
int32_t sync_mode;
699+
int32_t additional_timeout;
700+
int64_t req_id;
701+
int32_t reserved;
702+
int32_t version;
703+
int32_t num_links;
704+
int32_t num_valid_params;
705+
int32_t param_mask;
706+
int32_t *params;
707+
int32_t *link_hdls;
708+
};
709+
668710
/**
669711
* struct cam_req_mgr_core_mini_dump
670712
* @link : Array of dumped links
@@ -732,6 +774,13 @@ int cam_req_mgr_schedule_request(struct cam_req_mgr_sched_request *sched_req);
732774
*/
733775
int cam_req_mgr_schedule_request_v2(struct cam_req_mgr_sched_request_v2 *sched_req);
734776

777+
/**
778+
* cam_req_mgr_schedule_request_v3()
779+
* @brief: Request is scheduled
780+
* @sched_req: request id, session, link id info, bubble recovery info and sync info
781+
*/
782+
int cam_req_mgr_schedule_request_v3(struct cam_req_mgr_sched_request_v3 *sched_req);
783+
735784
/**
736785
* cam_req_mgr_sync_config()
737786
* @brief: sync for links in a session

camera/drivers/cam_req_mgr/cam_req_mgr_dev.c

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,45 @@ static long cam_private_ioctl(struct file *file, void *fh,
505505
}
506506
break;
507507

508+
case CAM_REQ_MGR_SCHED_REQ_V3: {
509+
struct cam_req_mgr_sched_request_v3 *sched_req;
510+
struct cam_req_mgr_sched_request_v3 crm_sched_req;
511+
int sched_req_size;
512+
513+
if (k_ioctl->size < 0)
514+
return -EINVAL;
515+
516+
if (copy_from_user(&crm_sched_req,
517+
u64_to_user_ptr(k_ioctl->handle),
518+
sizeof(struct cam_req_mgr_sched_request_v3))) {
519+
return -EFAULT;
520+
}
521+
522+
if (crm_sched_req.num_links > MAXIMUM_LINKS_PER_SESSION)
523+
return -EINVAL;
524+
525+
sched_req_size = sizeof(struct cam_req_mgr_sched_request_v3) +
526+
((crm_sched_req.num_links) * sizeof(__signed__ int));
527+
528+
if (k_ioctl->size != sched_req_size)
529+
return -EINVAL;
530+
531+
sched_req = kzalloc(sched_req_size, GFP_KERNEL);
532+
if (!sched_req) {
533+
return -ENOMEM;
534+
}
535+
536+
if (copy_from_user(sched_req, u64_to_user_ptr(k_ioctl->handle), sched_req_size)) {
537+
kfree(sched_req);
538+
sched_req = NULL;
539+
return -EFAULT;
540+
}
541+
542+
rc = cam_req_mgr_schedule_request_v3(sched_req);
543+
kfree(sched_req);
544+
}
545+
break;
546+
508547
case CAM_REQ_MGR_FLUSH_REQ: {
509548
struct cam_req_mgr_flush_info flush_info;
510549

0 commit comments

Comments
 (0)