Skip to content

Commit

Permalink
Merge "Merge commit '57c62991313f06062ec34fda40dcc8506ec5f1d4' msm-4.…
Browse files Browse the repository at this point in the history
…9.c2_UPSTREAM_0130_PC91"
  • Loading branch information
lnxbuild authored and Gerrit - the friendly Code Review server committed Feb 1, 2018
2 parents f19a150 + 7202fa8 commit 8605477
Show file tree
Hide file tree
Showing 31 changed files with 1,012 additions and 257 deletions.
33 changes: 28 additions & 5 deletions drivers/media/platform/msm/camera/cam_core/cam_context.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -196,6 +196,30 @@ int cam_context_handle_crm_flush_req(struct cam_context *ctx,
return rc;
}

int cam_context_handle_crm_process_evt(struct cam_context *ctx,
struct cam_req_mgr_link_evt_data *process_evt)
{
int rc = 0;

if (!ctx->state_machine) {
CAM_ERR(CAM_CORE, "Context is not ready");
return -EINVAL;
}

mutex_lock(&ctx->ctx_mutex);
if (ctx->state_machine[ctx->state].crm_ops.process_evt) {
rc = ctx->state_machine[ctx->state].crm_ops.process_evt(ctx,
process_evt);
} else {
/* handling of this message is optional */
CAM_DBG(CAM_CORE, "No crm process evt in dev %d, state %d",
ctx->dev_hdl, ctx->state);
}
mutex_unlock(&ctx->ctx_mutex);

return rc;
}

int cam_context_handle_acquire_dev(struct cam_context *ctx,
struct cam_acquire_dev_cmd *cmd)
{
Expand Down Expand Up @@ -257,10 +281,10 @@ int cam_context_handle_release_dev(struct cam_context *ctx,
int cam_context_handle_flush_dev(struct cam_context *ctx,
struct cam_flush_dev_cmd *cmd)
{
int rc;
int rc = 0;

if (!ctx->state_machine) {
CAM_ERR(CAM_CORE, "context is not ready");
CAM_ERR(CAM_CORE, "Context is not ready");
return -EINVAL;
}

Expand All @@ -274,9 +298,8 @@ int cam_context_handle_flush_dev(struct cam_context *ctx,
rc = ctx->state_machine[ctx->state].ioctl_ops.flush_dev(
ctx, cmd);
} else {
CAM_ERR(CAM_CORE, "No flush device in dev %d, state %d",
CAM_WARN(CAM_CORE, "No flush device in dev %d, state %d",
ctx->dev_hdl, ctx->state);
rc = -EPROTO;
}
mutex_unlock(&ctx->ctx_mutex);

Expand Down
17 changes: 16 additions & 1 deletion drivers/media/platform/msm/camera/cam_core/cam_context.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -110,6 +110,7 @@ struct cam_ctx_ioctl_ops {
* @unlink: Unlink the context
* @apply_req: Apply setting for the context
* @flush_req: Flush request to remove request ids
* @process_evt: Handle event notification from CRM.(optional)
*
*/
struct cam_ctx_crm_ops {
Expand All @@ -123,6 +124,8 @@ struct cam_ctx_crm_ops {
struct cam_req_mgr_apply_request *apply);
int (*flush_req)(struct cam_context *ctx,
struct cam_req_mgr_flush_request *flush);
int (*process_evt)(struct cam_context *ctx,
struct cam_req_mgr_link_evt_data *evt_data);
};


Expand Down Expand Up @@ -272,6 +275,18 @@ int cam_context_handle_crm_apply_req(struct cam_context *ctx,
int cam_context_handle_crm_flush_req(struct cam_context *ctx,
struct cam_req_mgr_flush_request *apply);

/**
* cam_context_handle_crm_process_evt()
*
* @brief: Handle process event command
*
* @ctx: Object pointer for cam_context
* @process_evt: process event command payload
*
*/
int cam_context_handle_crm_process_evt(struct cam_context *ctx,
struct cam_req_mgr_link_evt_data *process_evt);

/**
* cam_context_handle_acquire_dev()
*
Expand Down
83 changes: 65 additions & 18 deletions drivers/media/platform/msm/camera/cam_core/cam_context_utils.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -430,6 +430,8 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
uint32_t i;
int rc = 0;

CAM_DBG(CAM_CTXT, "E: NRT flush ctx");

/*
* flush pending requests, take the sync lock to synchronize with the
* sync callback thread so that the sync cb thread does not try to
Expand All @@ -444,23 +446,33 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
while (!list_empty(&temp_list)) {
req = list_first_entry(&temp_list,
struct cam_ctx_request, list);

list_del_init(&req->list);
req->flushed = 1;

flush_args.flush_req_pending[flush_args.num_req_pending++] =
req->req_priv;
for (i = 0; i < req->num_out_map_entries; i++)
if (req->out_map_entries[i].sync_id != -1)
cam_sync_signal(req->out_map_entries[i].sync_id,
if (req->out_map_entries[i].sync_id != -1) {
rc = cam_sync_signal(
req->out_map_entries[i].sync_id,
CAM_SYNC_STATE_SIGNALED_ERROR);
if (rc == -EALREADY) {
CAM_ERR(CAM_CTXT,
"Req: %llu already signalled, sync_id:%d",
req->request_id,
req->out_map_entries[i].
sync_id);
break;
}
}
}
mutex_unlock(&ctx->sync_mutex);

if (ctx->hw_mgr_intf->hw_flush) {
flush_args.num_req_active = 0;
spin_lock(&ctx->lock);
INIT_LIST_HEAD(&temp_list);
list_splice_init(&ctx->active_req_list, &temp_list);
list_for_each_entry(req, &temp_list, list) {
list_for_each_entry(req, &ctx->active_req_list, list) {
flush_args.flush_req_active[flush_args.num_req_active++]
= req->req_priv;
}
Expand All @@ -474,24 +486,42 @@ int32_t cam_context_flush_ctx_to_hw(struct cam_context *ctx)
}
}

INIT_LIST_HEAD(&temp_list);
spin_lock(&ctx->lock);
list_splice_init(&ctx->active_req_list, &temp_list);
INIT_LIST_HEAD(&ctx->active_req_list);
spin_unlock(&ctx->lock);

while (!list_empty(&temp_list)) {
req = list_first_entry(&temp_list,
struct cam_ctx_request, list);
list_del_init(&req->list);
for (i = 0; i < req->num_out_map_entries; i++)
for (i = 0; i < req->num_out_map_entries; i++) {
if (req->out_map_entries[i].sync_id != -1) {
cam_sync_signal(req->out_map_entries[i].sync_id,
rc = cam_sync_signal(
req->out_map_entries[i].sync_id,
CAM_SYNC_STATE_SIGNALED_ERROR);
if (rc == -EALREADY) {
CAM_ERR(CAM_CTXT,
"Req: %llu already signalled ctx: %pK dev_name: %s dev_handle: %d ctx_state: %d",
req->request_id, req->ctx,
req->ctx->dev_name,
req->ctx->dev_hdl,
req->ctx->state);
break;
}
}
}

spin_lock(&ctx->lock);
list_add_tail(&req->list, &ctx->free_req_list);
spin_unlock(&ctx->lock);
req->ctx = NULL;
}
INIT_LIST_HEAD(&ctx->active_req_list);

return rc;
CAM_DBG(CAM_CTXT, "X: NRT flush ctx");

return 0;
}

int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
Expand All @@ -502,6 +532,8 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
uint32_t i;
int rc = 0;

CAM_DBG(CAM_CTXT, "E: NRT flush req");

flush_args.num_req_pending = 0;
flush_args.num_req_active = 0;
mutex_lock(&ctx->sync_mutex);
Expand All @@ -510,7 +542,9 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
if (req->request_id != cmd->req_id)
continue;

list_del_init(&req->list);
req->flushed = 1;

flush_args.flush_req_pending[flush_args.num_req_pending++] =
req->req_priv;
break;
Expand All @@ -525,6 +559,8 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,
if (req->request_id != cmd->req_id)
continue;

list_del_init(&req->list);

flush_args.flush_req_active[
flush_args.num_req_active++] =
req->req_priv;
Expand All @@ -543,20 +579,31 @@ int32_t cam_context_flush_req_to_hw(struct cam_context *ctx,

if (req) {
if (flush_args.num_req_pending || flush_args.num_req_active) {
list_del_init(&req->list);
for (i = 0; i < req->num_out_map_entries; i++)
if (req->out_map_entries[i].sync_id != -1)
cam_sync_signal(
if (req->out_map_entries[i].sync_id != -1) {
rc = cam_sync_signal(
req->out_map_entries[i].sync_id,
CAM_SYNC_STATE_SIGNALED_ERROR);
spin_lock(&ctx->lock);
list_add_tail(&req->list, &ctx->free_req_list);
spin_unlock(&ctx->lock);
req->ctx = NULL;
if (rc == -EALREADY) {
CAM_ERR(CAM_CTXT,
"Req: %llu already signalled, sync_id:%d",
req->request_id,
req->out_map_entries[i].
sync_id);
break;
}
}
if (flush_args.num_req_active) {
spin_lock(&ctx->lock);
list_add_tail(&req->list, &ctx->free_req_list);
spin_unlock(&ctx->lock);
req->ctx = NULL;
}
}
}
CAM_DBG(CAM_CTXT, "X: NRT flush req");

return rc;
return 0;
}

int32_t cam_context_flush_dev_to_hw(struct cam_context *ctx,
Expand Down
24 changes: 22 additions & 2 deletions drivers/media/platform/msm/camera/cam_core/cam_node.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2018, The Linux Foundation. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 2 and
Expand Down Expand Up @@ -220,7 +220,7 @@ static int __cam_node_handle_flush_dev(struct cam_node *node,

rc = cam_context_handle_flush_dev(ctx, flush);
if (rc)
CAM_ERR(CAM_CORE, "FLush failure for node %s", node->name);
CAM_ERR(CAM_CORE, "Flush failure for node %s", node->name);

return rc;
}
Expand Down Expand Up @@ -342,6 +342,25 @@ static int __cam_node_crm_flush_req(struct cam_req_mgr_flush_request *flush)
return cam_context_handle_crm_flush_req(ctx, flush);
}

static int __cam_node_crm_process_evt(
struct cam_req_mgr_link_evt_data *evt_data)
{
struct cam_context *ctx = NULL;

if (!evt_data) {
CAM_ERR(CAM_CORE, "Invalid process event request payload");
return -EINVAL;
}

ctx = (struct cam_context *) cam_get_device_priv(evt_data->dev_hdl);
if (!ctx) {
CAM_ERR(CAM_CORE, "Can not get context for handle %d",
evt_data->dev_hdl);
return -EINVAL;
}
return cam_context_handle_crm_process_evt(ctx, evt_data);
}

int cam_node_deinit(struct cam_node *node)
{
if (node)
Expand Down Expand Up @@ -394,6 +413,7 @@ int cam_node_init(struct cam_node *node, struct cam_hw_mgr_intf *hw_mgr_intf,
node->crm_node_intf.get_dev_info = __cam_node_crm_get_dev_info;
node->crm_node_intf.link_setup = __cam_node_crm_link_setup;
node->crm_node_intf.flush_req = __cam_node_crm_flush_req;
node->crm_node_intf.process_evt = __cam_node_crm_process_evt;

mutex_init(&node->list_mutex);
INIT_LIST_HEAD(&node->free_ctx_list);
Expand Down
Loading

0 comments on commit 8605477

Please sign in to comment.