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

Commit 85afac75 authored by Seemanta Dutta's avatar Seemanta Dutta
Browse files

msm: camera: Send frame information to user space



For each frame generated from the hardware, there may be associated
information like error notification, timestamp etc. Add a mechanism
in the kernel to send such information to user space via the V4L2
event framework of the request manager device.

This information will be consumed by user space to process the frames
correctly and recover from errors, if any.

CRs-Fixed: 2048149
Change-Id: I1b726c2fd5dd3f845eba47eca30977f8cabd7fda
Signed-off-by: default avatarSeemanta Dutta <seemanta@codeaurora.org>
parent ea5149e3
Loading
Loading
Loading
Loading
+21 −0
Original line number Diff line number Diff line
@@ -461,6 +461,27 @@ static int cam_video_device_setup(void)
	return rc;
}

int cam_req_mgr_notify_frame_message(struct cam_req_mgr_message *msg,
	uint32_t id,
	uint32_t type)
{
	struct v4l2_event event;
	struct cam_req_mgr_message *ev_header;

	if (!msg)
		return -EINVAL;

	event.id = id;
	event.type = type;
	ev_header = CAM_REQ_MGR_GET_PAYLOAD_PTR(event,
		struct cam_req_mgr_message);
	memcpy(ev_header, msg, sizeof(struct cam_req_mgr_message));
	v4l2_event_queue(g_dev.video, &event);

	return 0;
}
EXPORT_SYMBOL(cam_req_mgr_notify_frame_message);

void cam_video_device_cleanup(void)
{
	video_unregister_device(g_dev.video);
+7 −0
Original line number Diff line number Diff line
@@ -40,4 +40,11 @@ struct cam_req_mgr_device {
	spinlock_t cam_eventq_lock;
};

#define CAM_REQ_MGR_GET_PAYLOAD_PTR(ev, type)        \
	(type *)((char *)ev.u.data)

int cam_req_mgr_notify_frame_message(struct cam_req_mgr_message *msg,
	uint32_t id,
	uint32_t type);

#endif /* _CAM_REQ_MGR_DEV_H_ */
+51 −0
Original line number Diff line number Diff line
@@ -325,4 +325,55 @@ struct cam_mem_cache_ops_cmd {
	uint32_t mem_cache_ops;
};

/**
 * Request Manager : error message type
 * @CAM_REQ_MGR_ERROR_TYPE_DEVICE: Device error message, fatal to session
 * @CAM_REQ_MGR_ERROR_TYPE_REQUEST: Error on a single request, not fatal
 * @CAM_REQ_MGR_ERROR_TYPE_BUFFER: Buffer was not filled, not fatal
 */
#define CAM_REQ_MGR_ERROR_TYPE_DEVICE           0
#define CAM_REQ_MGR_ERROR_TYPE_REQUEST          1
#define CAM_REQ_MGR_ERROR_TYPE_BUFFER           2

/**
 * struct cam_req_mgr_error_msg
 * @error_type: type of error
 * @request_id: request id of frame
 * @device_hdl: device handle
 * @reserved: reserved field
 * @resource_size: size of the resource
 */
struct cam_req_mgr_error_msg {
	uint32_t error_type;
	uint32_t request_id;
	int32_t device_hdl;
	int32_t reserved;
	uint64_t resource_size;
};

/**
 * struct cam_req_mgr_frame_msg
 * @request_id: request id of frame
 * @frame_count: running count of frames
 * @timestamp: timestamp of frame
 */
struct cam_req_mgr_frame_msg {
	uint64_t request_id;
	uint64_t frame_count;
	uint64_t timestamp;
};

/**
 * struct cam_req_mgr_message
 * @session_hdl: session to which the frame belongs to
 * @reserved: reserved field
 * @u: union which can either be error or frame message
 */
struct cam_req_mgr_message {
	int32_t session_hdl;
	union {
		struct cam_req_mgr_error_msg err_msg;
		struct cam_req_mgr_frame_msg frame_msg;
	} u;
};
#endif /* __UAPI_LINUX_CAM_REQ_MGR_H */