Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8d16e27a authored by Soundrapandian Jeyaprakash's avatar Soundrapandian Jeyaprakash Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: Close camera sub modules, sudevices & video node



The camera kernel module fds needs to be closed when the camera
server crashes. Flush all real time node requests and issue
shutdown call to all associated sub devices and modules.

Change-Id: I8d4f76c14316b88a61e74941f990fbe3f0095ad7
Signed-off-by: default avatarSoundrapandian Jeyaprakash <jsoundra@codeaurora.org>
Signed-off-by: default avatarKarthik Anantha Ram <kartanan@codeaurora.org>
parent b5185952
Loading
Loading
Loading
Loading
+21 −1
Original line number Diff line number Diff line
@@ -36,6 +36,26 @@ static int cam_context_handle_hw_event(void *context, uint32_t evt_id,
	return rc;
}

int cam_context_shutdown(struct cam_context *ctx)
{
	int rc = 0;

	if (ctx->state_machine[ctx->state].ioctl_ops.stop_dev) {
		rc = ctx->state_machine[ctx->state].ioctl_ops.stop_dev(
			ctx, NULL);
		if (rc < 0)
			CAM_ERR(CAM_CORE, "Error while dev stop %d", rc);
	}
	if (ctx->state_machine[ctx->state].ioctl_ops.release_dev) {
		rc = ctx->state_machine[ctx->state].ioctl_ops.release_dev(
			ctx, NULL);
		if (rc < 0)
			CAM_ERR(CAM_CORE, "Error while dev release %d", rc);
	}

	return rc;
}

int cam_context_handle_crm_get_dev_info(struct cam_context *ctx,
	struct cam_req_mgr_device_info *info)
{
@@ -334,7 +354,7 @@ int cam_context_init(struct cam_context *ctx,
	}

	memset(ctx, 0, sizeof(*ctx));

	ctx->dev_hdl = -1;
	INIT_LIST_HEAD(&ctx->list);
	mutex_init(&ctx->ctx_mutex);
	spin_lock_init(&ctx->lock);
+31 −21
Original line number Diff line number Diff line
@@ -185,6 +185,16 @@ struct cam_context {
	void                        *ctxt_to_hw_map;
};

/**
 * cam_context_shutdown()
 *
 * @brief:        Calls while device close or shutdown
 *
 * @ctx:          Object pointer for cam_context
 *
 */
int cam_context_shutdown(struct cam_context *ctx);

/**
 * cam_context_handle_crm_get_dev_info()
 *
+3 −3
Original line number Diff line number Diff line
@@ -180,9 +180,9 @@ int32_t cam_context_release_dev_to_hw(struct cam_context *ctx,
	ctx->hw_mgr_intf->hw_release(ctx->hw_mgr_intf->hw_mgr_priv, &arg);
	ctx->ctxt_to_hw_map = NULL;

	ctx->session_hdl = 0;
	ctx->dev_hdl = 0;
	ctx->link_hdl = 0;
	ctx->session_hdl = -1;
	ctx->dev_hdl = -1;
	ctx->link_hdl = -1;

	while (!list_empty(&ctx->active_req_list)) {
		req = list_first_entry(&ctx->active_req_list,
+23 −9
Original line number Diff line number Diff line
@@ -17,12 +17,6 @@
#include "cam_node.h"
#include "cam_trace.h"
#include "cam_debug_util.h"
static void  __cam_node_handle_shutdown(struct cam_node *node)
{
	if (node->hw_mgr_intf.hw_close)
		node->hw_mgr_intf.hw_close(node->hw_mgr_intf.hw_mgr_priv,
			NULL);
}

static int __cam_node_handle_query_cap(struct cam_node *node,
	struct cam_query_cap_cmd *query)
@@ -307,6 +301,29 @@ int cam_node_deinit(struct cam_node *node)
	return 0;
}

int cam_node_shutdown(struct cam_node *node)
{
	int i = 0;

	if (!node)
		return -EINVAL;

	for (i = 0; i < node->ctx_size; i++) {
		if (node->ctx_list[i].dev_hdl >= 0) {
			cam_context_shutdown(&(node->ctx_list[i]));
			cam_destroy_device_hdl(node->ctx_list[i].dev_hdl);
			list_add_tail(&(node->ctx_list[i].list),
				&node->free_ctx_list);
		}
	}

	if (node->hw_mgr_intf.hw_close)
		node->hw_mgr_intf.hw_close(node->hw_mgr_intf.hw_mgr_priv,
			NULL);

	return 0;
}

int cam_node_init(struct cam_node *node, struct cam_hw_mgr_intf *hw_mgr_intf,
	struct cam_context *ctx_list, uint32_t ctx_size, char *name)
{
@@ -456,9 +473,6 @@ int cam_node_handle_ioctl(struct cam_node *node, struct cam_control *cmd)
		}
		break;
	}
	case CAM_SD_SHUTDOWN:
		__cam_node_handle_shutdown(node);
		break;
	default:
		CAM_ERR(CAM_CORE, "Unknown op code %d", cmd->op_code);
		rc = -EINVAL;
+10 −0
Original line number Diff line number Diff line
@@ -72,6 +72,16 @@ int cam_node_handle_ioctl(struct cam_node *node, struct cam_control *cmd);
 */
int cam_node_deinit(struct cam_node *node);

/**
 * cam_node_shutdown()
 *
 * @brief:       Shutdowns/Closes the cam node.
 *
 * @node:                  Cam_node pointer
 *
 */
int cam_node_shutdown(struct cam_node *node);

/**
 * cam_node_init()
 *
Loading