blob: 02e153d50f8b6a03aab9086e02bb83b1e8b57e1b [file] [log] [blame]
Jing Zhou076a3092017-02-27 02:43:03 -08001/* Copyright (c) 2017, The Linux Foundation. All rights reserved.
2 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _CAM_NODE_H_
14#define _CAM_NODE_H_
15
16#include "cam_context.h"
17#include "cam_hw_mgr_intf.h"
18#include "cam_req_mgr_interface.h"
19
20#define CAM_NODE_NAME_LENGTH_MAX 256
21
22#define CAM_NODE_STATE_UNINIT 0
23#define CAM_NODE_STATE_INIT 1
24
25/**
26 * struct cam_node - Singleton Node for camera HW devices
27 *
28 * @name: Name for struct cam_node
29 * @state: Node state:
30 * 0 = uninitialized, 1 = initialized
31 * @list_mutex: Mutex for the context pool
32 * @free_ctx_list: Free context pool list
33 * @ctx_list: Context list
34 * @ctx_size: Context list size
35 * @hw_mgr_intf: Interface for cam_node to HW
36 * @crm_node_intf: Interface for the CRM to cam_node
37 *
38 */
39struct cam_node {
40 char name[CAM_NODE_NAME_LENGTH_MAX];
41 uint32_t state;
42
43 /* context pool */
44 struct mutex list_mutex;
45 struct list_head free_ctx_list;
46 struct cam_context *ctx_list;
47 uint32_t ctx_size;
48
49 /* interfaces */
50 struct cam_hw_mgr_intf hw_mgr_intf;
51 struct cam_req_mgr_kmd_ops crm_node_intf;
52};
53
54/**
55 * cam_node_handle_ioctl()
56 *
57 * @brief: Handle ioctl commands
58 *
59 * @node: Node handle
60 * @cmd: IOCTL command
61 *
62 */
63int cam_node_handle_ioctl(struct cam_node *node, struct cam_control *cmd);
64
65/**
66 * cam_node_deinit()
67 *
68 * @brief: Deinitialization function for the Node interface
69 *
70 * @node: Node handle
71 *
72 */
73int cam_node_deinit(struct cam_node *node);
74
75/**
Soundrapandian Jeyaprakash8d16e272017-10-12 11:05:37 -070076 * cam_node_shutdown()
77 *
78 * @brief: Shutdowns/Closes the cam node.
79 *
80 * @node: Cam_node pointer
81 *
82 */
83int cam_node_shutdown(struct cam_node *node);
84
85/**
Jing Zhou076a3092017-02-27 02:43:03 -080086 * cam_node_init()
87 *
88 * @brief: Initialization function for the Node interface.
89 *
90 * @node: Cam_node pointer
91 * @hw_mgr_intf: HW manager interface blob
92 * @ctx_list: List of cam_contexts to be added
93 * @ctx_size: Size of the cam_context
94 * @name: Name for the node
95 *
96 */
97int cam_node_init(struct cam_node *node, struct cam_hw_mgr_intf *hw_mgr_intf,
98 struct cam_context *ctx_list, uint32_t ctx_size, char *name);
99
100#endif /* _CAM_NODE_H_ */