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

Commit 46a2dd27 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: cvp: Support CVP new HFI version 0.1.0"

parents 02595bfe 9e783950
Loading
Loading
Loading
Loading
+110 −7
Original line number Diff line number Diff line
@@ -322,8 +322,7 @@ int get_pkt_index(struct cvp_hal_session_cmd_pkt *hdr)
	int i, pkt_num = ARRAY_SIZE(cvp_hfi_defs);

	for (i = 0; i < pkt_num; i++)
		if ((cvp_hfi_defs[i].size*sizeof(unsigned int) == hdr->size) &&
			(cvp_hfi_defs[i].type == hdr->packet_type))
		if (cvp_hfi_defs[i].type == hdr->packet_type)
			return i;

	return -EINVAL;
@@ -350,6 +349,88 @@ int set_feature_bitmask(int pkt_idx, unsigned long *bitmask)
	return -EINVAL;
}

int get_hfi_version(void)
{
	struct msm_cvp_core *core;
	struct iris_hfi_device *hfi;

	core = list_first_entry(&cvp_driver->cores, struct msm_cvp_core, list);
	hfi = (struct iris_hfi_device *)core->device->hfi_device_data;

	return hfi->version;
}

unsigned int get_msg_size(void)
{
	unsigned int ver;

	ver = get_hfi_version();
	ver = (ver & HFI_VERSION_MINOR_MASK) >> HFI_VERSION_MINOR_SHIFT;

	if (ver < 1)
		return sizeof(struct cvp_hfi_msg_session_hdr_d);

	return sizeof(struct cvp_hfi_msg_session_hdr);
}

unsigned int get_msg_session_id(void *msg)
{
	unsigned int ver;
	struct cvp_hfi_msg_session_hdr *hdr =
		(struct cvp_hfi_msg_session_hdr *)msg;

	ver = get_hfi_version();
	ver = (ver & HFI_VERSION_MINOR_MASK) >> HFI_VERSION_MINOR_SHIFT;

	if (ver < 1) {
		struct cvp_hfi_msg_session_hdr_d *old_hdr =
			(struct cvp_hfi_msg_session_hdr_d *)msg;
		return old_hdr->session_id;
	}
	return hdr->session_id;
}

unsigned int get_msg_errorcode(void *msg)
{
	unsigned int ver;
	struct cvp_hfi_msg_session_hdr *hdr =
		(struct cvp_hfi_msg_session_hdr *)msg;

	ver = get_hfi_version();
	ver = (ver & HFI_VERSION_MINOR_MASK) >> HFI_VERSION_MINOR_SHIFT;

	if (ver < 1) {
		struct cvp_hfi_msg_session_hdr_d *old_hdr =
			(struct cvp_hfi_msg_session_hdr_d *)msg;
		return old_hdr->error_type;
	}
	return hdr->error_type;
}

int get_msg_opconfigs(void *msg, unsigned int *session_id,
		unsigned int *error_type, unsigned int *config_id)
{
	unsigned int ver;
	struct cvp_hfi_msg_session_op_cfg_packet *cfg =
		(struct cvp_hfi_msg_session_op_cfg_packet *)msg;

	ver = get_hfi_version();
	ver = (ver & HFI_VERSION_MINOR_MASK) >> HFI_VERSION_MINOR_SHIFT;

	if (ver < 1) {
		struct cvp_hfi_msg_session_op_cfg_packet_d *old_cfg
			= (struct cvp_hfi_msg_session_op_cfg_packet_d *)msg;
		*session_id = old_cfg->session_id;
		*error_type = old_cfg->error_type;
		*config_id = old_cfg->op_conf_id;
		return 0;
	}
	*session_id = cfg->session_id;
	*error_type = cfg->error_type;
	*config_id = cfg->op_conf_id;
	return 0;
}

int get_signal_from_pkt_type(unsigned int type)
{
	int i, pkt_num = ARRAY_SIZE(cvp_hfi_defs);
@@ -2613,7 +2694,7 @@ static int venus_hfi_session_set_buffers(void *sess,
static int venus_hfi_session_release_buffers(void *sess,
				struct cvp_buffer_addr_info *buffer_info)
{
	struct cvp_hfi_cmd_session_release_buffers_packet pkt;
	struct cvp_session_release_buffers_packet pkt;
	int rc = 0;
	struct cvp_hal_session *session = sess;
	struct iris_hfi_device *device;
@@ -3166,12 +3247,34 @@ static void **get_session_id(struct msm_cvp_cb_info *info)
	return session_id;
}

static void print_msg_hdr(struct cvp_hfi_msg_session_hdr *hdr)
static void print_msg_hdr(void *hdr)
{
	unsigned int ver;

	ver = get_hfi_version();
	ver = (ver & HFI_VERSION_MINOR_MASK) >> HFI_VERSION_MINOR_SHIFT;

	if (ver >= 1) {
		struct cvp_hfi_msg_session_hdr *new_hdr =
			(struct cvp_hfi_msg_session_hdr *)hdr;
	dprintk(CVP_DBG, "HFI MSG received: %x %x %x %x %x %x %x\n",
			new_hdr->size, new_hdr->packet_type,
			new_hdr->session_id,
			new_hdr->client_data.transaction_id,
			new_hdr->client_data.data1,
			new_hdr->client_data.data2,
			new_hdr->error_type);
	} else {
		struct cvp_hfi_msg_session_hdr_d *old_hdr =
			(struct cvp_hfi_msg_session_hdr_d *)hdr;
		dprintk(CVP_DBG, "HFI MSG received: %x %x %x %x %x %x %x\n",
		hdr->size, hdr->packet_type, hdr->session_id,
		hdr->client_data.transaction_id, hdr->client_data.data1,
		hdr->client_data.data2, hdr->error_type);
			old_hdr->size, old_hdr->packet_type,
			old_hdr->session_id,
			old_hdr->client_data.transaction_id,
			old_hdr->client_data.data1,
			old_hdr->client_data.data2,
			old_hdr->error_type);
	}
}

static int __response_handler(struct iris_hfi_device *device)
+13 −6
Original line number Diff line number Diff line
@@ -96,6 +96,13 @@
#define PERSIST_BIT_OFFSET (CVP_KMD_HFI_PERSIST_CMD - CVP_KMD_CMD_START)
#define ICA_BIT_OFFSET (CVP_KMD_HFI_ICA_FRAME_CMD - CVP_KMD_CMD_START)

#define HFI_VERSION_MAJOR_MASK 0xFF000000
#define HFI_VERSION_MAJOR_SHFIT 24
#define HFI_VERSION_MINOR_MASK 0x00FFFFE0
#define HFI_VERSION_MINOR_SHIFT 5
#define HFI_VERSION_BRANCH_MASK 0x0000001F
#define HFI_VERSION_BRANCH_SHIFT 0

enum cvp_status {
	CVP_ERR_NONE = 0x0,
	CVP_ERR_FAIL = 0x80000000,
@@ -511,12 +518,6 @@ struct cvp_hal_cmd_sys_get_property_packet {
#define call_hfi_op(q, op, args...)			\
	(((q) && (q)->op) ? ((q)->op(args)) : 0)

/* DFS related structures */
struct cvp_buf_desc {
	u32 fd;
	u32 size;
};

struct msm_cvp_hfi_defs {
	unsigned int size;
	unsigned int type;
@@ -578,6 +579,12 @@ void cvp_hfi_deinitialize(enum msm_cvp_hfi_type hfi_type,
int get_pkt_index(struct cvp_hal_session_cmd_pkt *hdr);
int get_signal_from_pkt_type(unsigned int type);
int set_feature_bitmask(int pkt_index, unsigned long *bitmask);
int get_hfi_version(void);
unsigned int get_msg_size(void);
unsigned int get_msg_session_id(void *msg);
unsigned int get_msg_errorcode(void *msg);
int get_msg_opconfigs(void *msg, unsigned int *session_id,
		unsigned int *error_type, unsigned int *config_id);
extern const struct msm_cvp_hfi_defs cvp_hfi_defs[];

#endif /*__CVP_HFI_API_H__ */
+54 −65
Original line number Diff line number Diff line
@@ -571,6 +571,30 @@ struct cvp_hfi_client {
	u32 transaction_id;
	u32 data1;
	u32 data2;
	u32 data3;
	u32 data4;
	u32 reserved1;
	u32 reserved2;
};

struct cvp_hfi_client_d {
	u32 transaction_id;
	u32 data1;
	u32 data2;
};

struct cvp_buf_desc {
	u32 fd;
	u32 size;
};

struct cvp_buf_type {
	u32 fd;
	u32 size;
	u32 offset;
	u32 flags;
	u32 reserved1;
	u32 reserved2;
};

struct cvp_hfi_cmd_session_set_buffers_packet {
@@ -578,15 +602,34 @@ struct cvp_hfi_cmd_session_set_buffers_packet {
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client client_data;
	struct cvp_buf_type buf_type;
};

struct cvp_hfi_cmd_session_set_buffers_packet_d {
	u32 size;
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client_d client_data;
	u32 buffer_addr;
	u32 buffer_size;
};

struct cvp_hfi_cmd_session_release_buffers_packet {
struct cvp_session_release_buffers_packet {
	u32 size;
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client client_data;
	u32 kernel_type;
	u32 buffer_type;
	u32 num_buffers;
	u32 buffer_idx;
};

struct cvp_session_release_buffers_packet_d {
	u32 size;
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client_d client_data;
	u32 buffer_type;
	u32 num_buffers;
	u32 buffer_idx;
@@ -596,19 +639,17 @@ struct cvp_hfi_msg_session_hdr {
	u32 size;
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client client_data;
	u32 error_type;
	struct cvp_hfi_client client_data;
	u32 stream_idx;
};

struct cvp_hfi_msg_session_set_buffers_done_packet {
struct cvp_hfi_msg_session_hdr_d {
	u32 size;
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client client_data;
	struct cvp_hfi_client_d client_data;
	u32 error_type;
	u32 buffer_type;
	u32 buffer_addr;
	u32 buffer_size;
};

struct cvp_hfi_buffer_mapping_type {
@@ -635,75 +676,23 @@ struct cvp_hfi_msg_event_notify_packet {
	u32 rg_ext_event_data[1];
};

struct cvp_hfi_client_data {
	u32 transactionid;
	u32 client_data1;
	u32 client_data2;
};

struct cvp_hfi_msg_session_op_cfg_done_packet_type {
struct cvp_hfi_msg_session_op_cfg_packet_d {
	u32 size;
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client_data  client_data;
	struct cvp_hfi_client_d  client_data;
	u32 op_conf_id;
	u32 error_type;
};

struct cvp_hfi_msg_session_dfs_packet_type {
	u32 size;
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client_data  client_data;
	u32 error_type;
	u32 width;
	u32 height;
	u32 occlusionmask_enable;
	u32 left_view_buf_addr;
	u32 left_view_buf_size;
	u32 right_view_buf_addr;
	u32 right_view_buf_size;
	u32 disparity_map_buf_addr;
	u32 disparity_map_buf_size;
	u32 occ_mask_buf_addr;
	u32 occ_mask_buf_size;
};

struct cvp_hfi_msg_session_dme_packet_type {
struct cvp_hfi_msg_session_op_cfg_packet {
	u32 size;
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client_data  client_data;
	u32 error_type;
	u32 skip_mv_calc;
	u32 src_buf_addr;
	u32 src_buf_size;
	u32 src_frame_ctx_buf_addr;
	u32 src_frame_ctx_buf_size;
	u32 ref_buf_addr;
	u32 ref_buf_size;
	u32 ref_frame_ctxt_buf_addr;
	u32 ref_frame_ctxt_buf_size;
	u32 video_spatial_temp_status_buf_addr;
	u32 video_spatial_temp_status_buf_size;
	u32 full_res_height;
	u32 full_res_width;
	u32 proc_frame_width;
	u32 proc_frame_height;
	u32 transform_confidence;
};

struct cvp_hfi_msg_session_persist_packet_type {
	u32 size;
	u32 packet_type;
	u32 session_id;
	struct cvp_hfi_client_data  client_data;
	u32 error_type;
	u32 cvp_op;
	u32 persist1_buffer_fd;
	u32 persist1_size;
	u32 persist2_fd;
	u32 persist2_size;
	struct cvp_hfi_client client_data;
	u32 stream_idx;
	u32 op_conf_id;
};

struct cvp_hfi_msg_release_buffer_ref_event_packet {
+61 −22
Original line number Diff line number Diff line
@@ -344,48 +344,90 @@ static u32 get_hfi_buffer(int hal_buffer)
}

int cvp_create_pkt_cmd_session_set_buffers(
		struct cvp_hfi_cmd_session_set_buffers_packet *pkt,
		void *cmd,
		struct cvp_hal_session *session,
		struct cvp_buffer_addr_info *buffer_info)
{
	int rc = 0;
	unsigned int ver;

	if (!pkt || !session)
	ver = get_hfi_version();
	ver = (ver & HFI_VERSION_MINOR_MASK) >> HFI_VERSION_MINOR_SHIFT;

	if (!cmd || !session)
		return -EINVAL;

	if (ver < 1) {
		struct cvp_hfi_cmd_session_set_buffers_packet_d *pkt;

		pkt = (struct cvp_hfi_cmd_session_set_buffers_packet_d *)cmd;
		pkt->packet_type = HFI_CMD_SESSION_CVP_SET_BUFFERS;
		pkt->session_id = hash32_ptr(session);
		pkt->buffer_addr = buffer_info->align_device_addr;
		pkt->buffer_size = buffer_info->buffer_size;
	pkt->size = sizeof(struct cvp_hfi_cmd_session_set_buffers_packet);
		pkt->size =
			sizeof(struct cvp_hfi_cmd_session_set_buffers_packet_d);
	} else {
		struct cvp_hfi_cmd_session_set_buffers_packet *pkt;

		pkt = (struct cvp_hfi_cmd_session_set_buffers_packet *)cmd;
		pkt->packet_type = HFI_CMD_SESSION_CVP_SET_BUFFERS;
		pkt->session_id = hash32_ptr(session);
		pkt->buf_type.fd = buffer_info->align_device_addr;
		pkt->buf_type.size = buffer_info->buffer_size;
		pkt->size =
			sizeof(struct cvp_hfi_cmd_session_set_buffers_packet);
	}

	return rc;
}

int cvp_create_pkt_cmd_session_release_buffers(
		struct cvp_hfi_cmd_session_release_buffers_packet *pkt,
		void *cmd,
		struct cvp_hal_session *session,
		struct cvp_buffer_addr_info *buffer_info)
{
	if (!pkt || !session)
	unsigned int ver;

	ver = get_hfi_version();
	ver = (ver & HFI_VERSION_MINOR_MASK) >> HFI_VERSION_MINOR_SHIFT;

	if (!cmd || !session)
		return -EINVAL;

	if (ver < 1) {
		struct cvp_session_release_buffers_packet_d *pkt;

		pkt = (struct cvp_session_release_buffers_packet_d *)cmd;
		pkt->packet_type = HFI_CMD_SESSION_CVP_RELEASE_BUFFERS;
		pkt->session_id = hash32_ptr(session);
		pkt->num_buffers = buffer_info->num_buffers;

	if (buffer_info->buffer_type == HAL_BUFFER_OUTPUT ||
		buffer_info->buffer_type == HAL_BUFFER_OUTPUT2) {
		dprintk(CVP_ERR, "%s: deprecated buffer_type\n", __func__);
		pkt->buffer_type = get_hfi_buffer(buffer_info->buffer_type);
		if (!pkt->buffer_type)
			return -EINVAL;
	}

	pkt->size = sizeof(struct cvp_hfi_cmd_session_release_buffers_packet) +
		pkt->size =
			sizeof(struct cvp_session_release_buffers_packet_d) +
			((buffer_info->num_buffers - 1) * sizeof(u32));
	} else {
		struct cvp_session_release_buffers_packet *pkt;

		pkt = (struct cvp_session_release_buffers_packet *)cmd;
		pkt->packet_type = HFI_CMD_SESSION_CVP_RELEASE_BUFFERS;
		pkt->session_id = hash32_ptr(session);
		pkt->num_buffers = buffer_info->num_buffers;
		pkt->buffer_type = get_hfi_buffer(buffer_info->buffer_type);
		if (!pkt->buffer_type)
			return -EINVAL;
		pkt->size =
			sizeof(struct cvp_session_release_buffers_packet) +
			((buffer_info->num_buffers - 1) * sizeof(u32));
	}

	if (buffer_info->buffer_type == HAL_BUFFER_OUTPUT ||
		buffer_info->buffer_type == HAL_BUFFER_OUTPUT2) {
		dprintk(CVP_ERR, "%s: deprecated buffer_type\n", __func__);
		return -EINVAL;
	}

	return 0;
}
@@ -432,9 +474,6 @@ int cvp_create_pkt_cmd_session_send(
	if (cvp_hfi_defs[def_idx].type != ptr->packet_type)
		goto error_hfi_packet;

	if ((cvp_hfi_defs[def_idx].size*sizeof(unsigned int)) != ptr->size)
		goto error_hfi_packet;

	if (ptr->session_id != hash32_ptr(session))
		goto error_hfi_packet;

+2 −2
Original line number Diff line number Diff line
@@ -51,11 +51,11 @@ struct cvp_hfi_packetization_ops {
	int (*session_cmd)(struct cvp_hal_session_cmd_pkt *pkt,
		int pkt_type, struct cvp_hal_session *session);
	int (*session_set_buffers)(
		struct cvp_hfi_cmd_session_set_buffers_packet *pkt,
		void *pkt,
		struct cvp_hal_session *session,
		struct cvp_buffer_addr_info *buffer_info);
	int (*session_release_buffers)(
		struct cvp_hfi_cmd_session_release_buffers_packet *pkt,
		void *pkt,
		struct cvp_hal_session *session,
		struct cvp_buffer_addr_info *buffer_info);
	int (*session_get_buf_req)(
Loading