msm: cvp: optimize CVP HFI packet handling
Remove redundant handling logic. Rename CVP system call
command structure to avoid name conflict with video driver.
Add new commands needed by camera processing pipeline.
Change-Id: I59a628f7ae2bf9ad7c6e075ed3e1a3794f25e05c
Signed-off-by: George Shen <sqiao@codeaurora.org>
diff --git a/drivers/media/platform/msm/cvp/cvp_hfi.c b/drivers/media/platform/msm/cvp/cvp_hfi.c
index 65a108d..43a75fc 100644
--- a/drivers/media/platform/msm/cvp/cvp_hfi.c
+++ b/drivers/media/platform/msm/cvp/cvp_hfi.c
@@ -37,6 +37,45 @@
#define REG_ADDR_OFFSET_BITMASK 0x000FFFFF
#define QDSS_IOVA_START 0x80001000
+const struct msm_cvp_hfi_defs cvp_hfi_defs[] = {
+ {
+ .size = HFI_DFS_CONFIG_CMD_SIZE,
+ .type = HFI_CMD_SESSION_CVP_DFS_CONFIG,
+ .buf_offset = 0,
+ .buf_num = 0,
+ .resp = HAL_SESSION_DFS_CONFIG_CMD_DONE,
+ },
+ {
+ .size = HFI_DFS_FRAME_CMD_SIZE,
+ .type = HFI_CMD_SESSION_CVP_DFS_FRAME,
+ .buf_offset = HFI_DFS_FRAME_BUFFERS_OFFSET,
+ .buf_num = HFI_DFS_BUF_NUM,
+ .resp = HAL_NO_RESP,
+ },
+ {
+ .size = HFI_DME_CONFIG_CMD_SIZE,
+ .type = HFI_CMD_SESSION_CVP_DME_CONFIG,
+ .buf_offset = 0,
+ .buf_num = 0,
+ .resp = HAL_SESSION_DME_CONFIG_CMD_DONE,
+ },
+ {
+ .size = HFI_DME_FRAME_CMD_SIZE,
+ .type = HFI_CMD_SESSION_CVP_DME_FRAME,
+ .buf_offset = HFI_DME_FRAME_BUFFERS_OFFSET,
+ .buf_num = HFI_DME_BUF_NUM,
+ .resp = HAL_NO_RESP,
+ },
+ {
+ .size = HFI_PERSIST_CMD_SIZE,
+ .type = HFI_CMD_SESSION_CVP_SET_PERSIST_BUFFERS,
+ .buf_offset = HFI_PERSIST_BUFFERS_OFFSET,
+ .buf_num = HFI_PERSIST_BUF_NUM,
+ .resp = HAL_NO_RESP,
+ },
+
+};
+
static struct hal_device_data hal_ctxt;
#define TZBSP_MEM_PROTECT_VIDEO_VAR 0x8
@@ -147,6 +186,18 @@
#define ROW_SIZE 32
+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))
+ return i;
+
+ return -EINVAL;
+}
+
static void __dump_packet(u8 *packet, enum cvp_msg_prio log_level)
{
u32 c = 0, packet_size = *(u32 *)packet;
@@ -1292,7 +1343,7 @@
}
trace_msm_cvp_perf_clock_scale(cl->name, freq);
- dprintk(CVP_PROF, "Scaling clock %s to %u\n",
+ dprintk(CVP_DBG, "Scaling clock %s to %u\n",
cl->name, freq);
}
}
@@ -2641,11 +2692,11 @@
return rc;
}
-static int venus_hfi_session_cvp_dme_config(void *sess,
- struct msm_cvp_internal_dmeconfig *dme_config)
+static int venus_hfi_session_send(void *sess,
+ struct cvp_kmd_hfi_packet *in_pkt)
{
int rc = 0;
- struct hfi_cmd_session_cvp_dme_config_packet pkt;
+ struct cvp_kmd_hfi_packet pkt;
struct hal_session *session = sess;
struct venus_hfi_device *device;
@@ -2659,174 +2710,26 @@
if (!__is_session_valid(device, session, __func__)) {
rc = -EINVAL;
- goto dme_config_err;
+ goto err_send_pkt;
}
- rc = call_hfi_pkt_op(device, session_cvp_dme_config,
- &pkt, session, dme_config);
+ rc = call_hfi_pkt_op(device, session_cvp_hfi_packetize,
+ &pkt, session, in_pkt);
if (rc) {
dprintk(CVP_ERR,
- "Session get buf req: failed to create pkt\n");
- goto dme_config_err;
- }
-
- if (__iface_cmdq_write(session->device, &pkt))
- rc = -ENOTEMPTY;
- dprintk(CVP_DBG, "%s: calling __iface_cmdq_write\n", __func__);
-dme_config_err:
- mutex_unlock(&device->lock);
- return rc;
-}
-
-static int venus_hfi_session_cvp_dme_frame(void *sess,
- struct msm_cvp_internal_dmeframe *dme_frame)
-{
- int rc = 0;
- struct hfi_cmd_session_cvp_dme_frame_packet pkt;
- struct hal_session *session = sess;
- struct venus_hfi_device *device;
-
- if (!session || !session->device) {
- dprintk(CVP_ERR, "invalid session");
- return -ENODEV;
- }
-
- device = session->device;
- mutex_lock(&device->lock);
-
- if (!__is_session_valid(device, session, __func__)) {
- rc = -EINVAL;
- goto dme_frame_err;
- }
- rc = call_hfi_pkt_op(device, session_cvp_dme_frame,
- &pkt, session, dme_frame);
- if (rc) {
- dprintk(CVP_ERR,
- "Session get buf req: failed to create pkt\n");
- goto dme_frame_err;
- }
-
- if (__iface_cmdq_write(session->device, &pkt))
- rc = -ENOTEMPTY;
- dprintk(CVP_DBG, "%s: done calling __iface_cmdq_write\n", __func__);
-dme_frame_err:
- mutex_unlock(&device->lock);
- return rc;
-}
-
-
-static int venus_hfi_session_cvp_persist(void *sess,
- struct msm_cvp_internal_persist_cmd *pbuf_cmd)
-{
- int rc = 0;
- struct hfi_cmd_session_cvp_persist_packet pkt;
- struct hal_session *session = sess;
- struct venus_hfi_device *device;
-
- if (!session || !session->device) {
- dprintk(CVP_ERR, "invalid session");
- return -ENODEV;
- }
-
- device = session->device;
- mutex_lock(&device->lock);
-
- if (!__is_session_valid(device, session, __func__)) {
- rc = -EINVAL;
- goto persist_err;
- }
- rc = call_hfi_pkt_op(device, session_cvp_persist,
- &pkt, session, pbuf_cmd);
- if (rc) {
- dprintk(CVP_ERR,
- "Failed to create persist pkt\n");
- goto persist_err;
+ "failed to create pkt\n");
+ goto err_send_pkt;
}
if (__iface_cmdq_write(session->device, &pkt))
rc = -ENOTEMPTY;
- dprintk(CVP_DBG, "%s: done calling __iface_cmdq_write\n", __func__);
-persist_err:
- mutex_unlock(&device->lock);
- return rc;
-}
-
-static int venus_hfi_session_cvp_dfs_config(void *sess,
- struct msm_cvp_internal_dfsconfig *dfs_config)
-{
- int rc = 0;
- struct hfi_cmd_session_cvp_dfs_config_packet pkt;
- struct hal_session *session = sess;
- struct venus_hfi_device *device;
-
- if (!session || !session->device) {
- dprintk(CVP_ERR, "invalid session");
- return -ENODEV;
- }
-
- device = session->device;
- mutex_lock(&device->lock);
-
- if (!__is_session_valid(device, session, __func__)) {
- rc = -EINVAL;
- goto err_create_pkt;
- }
- rc = call_hfi_pkt_op(device, session_cvp_dfs_config,
- &pkt, session, dfs_config);
- if (rc) {
- dprintk(CVP_ERR,
- "Session get buf req: failed to create pkt\n");
- goto err_create_pkt;
- }
-
- dprintk(CVP_DBG, "%s: calling __iface_cmdq_write\n", __func__);
- if (__iface_cmdq_write(session->device, &pkt))
- rc = -ENOTEMPTY;
- dprintk(CVP_DBG, "%s: done calling __iface_cmdq_write\n", __func__);
-err_create_pkt:
+err_send_pkt:
mutex_unlock(&device->lock);
return rc;
return rc;
}
-static int venus_hfi_session_cvp_dfs_frame(void *sess,
- struct msm_cvp_internal_dfsframe *dfs_frame)
-{
- int rc = 0;
- struct hfi_cmd_session_cvp_dfs_frame_packet pkt;
- struct hal_session *session = sess;
- struct venus_hfi_device *device;
-
- if (!session || !session->device) {
- dprintk(CVP_ERR, "invalid session");
- return -ENODEV;
- }
-
- device = session->device;
- mutex_lock(&device->lock);
-
- if (!__is_session_valid(device, session, __func__)) {
- rc = -EINVAL;
- goto err_create_pkt;
- }
- rc = call_hfi_pkt_op(device, session_cvp_dfs_frame,
- &pkt, session, dfs_frame);
- if (rc) {
- dprintk(CVP_ERR,
- "Session get buf req: failed to create pkt\n");
- goto err_create_pkt;
- }
-
- dprintk(CVP_DBG, "%s: calling __iface_cmdq_write\n", __func__);
- if (__iface_cmdq_write(session->device, &pkt))
- rc = -ENOTEMPTY;
- dprintk(CVP_DBG, "%s: done calling __iface_cmdq_write\n", __func__);
-err_create_pkt:
- mutex_unlock(&device->lock);
- return rc;
-}
-
static int venus_hfi_session_get_buf_req(void *sess)
{
struct hfi_cmd_session_get_property_packet pkt;
@@ -4014,30 +3917,14 @@
dprintk(CVP_DBG, "Enabling regulators\n");
venus_hfi_for_each_regulator(device, rinfo) {
- if (rinfo->has_hw_power_collapse) {
- rc = regulator_set_mode(rinfo->regulator,
- REGULATOR_MODE_FAST);
- if (rc) {
- dprintk(CVP_ERR,
- "Failed to enable hwctrl%s: %d\n",
- rinfo->name, rc);
- goto err_reg_enable_failed;
- }
- dprintk(CVP_DBG, "Enabled regulator %s hw ctrl\n",
- rinfo->name);
-
- } else {
- rc = regulator_enable(rinfo->regulator);
- if (rc) {
- dprintk(CVP_ERR,
- "Failed to enable %s: %d\n",
- rinfo->name, rc);
- goto err_reg_enable_failed;
- }
-
- dprintk(CVP_DBG, "Enabled regulator %s\n",
- rinfo->name);
+ rc = regulator_enable(rinfo->regulator);
+ if (rc) {
+ dprintk(CVP_ERR, "Failed to enable %s: %d\n",
+ rinfo->name, rc);
+ goto err_reg_enable_failed;
}
+
+ dprintk(CVP_DBG, "Enabled regulator %s\n", rinfo->name);
c++;
}
@@ -4743,11 +4630,7 @@
hdev->session_continue = venus_hfi_session_continue;
hdev->session_stop = venus_hfi_session_stop;
hdev->session_get_buf_req = venus_hfi_session_get_buf_req;
- hdev->session_cvp_dfs_config = venus_hfi_session_cvp_dfs_config;
- hdev->session_cvp_dfs_frame = venus_hfi_session_cvp_dfs_frame;
- hdev->session_cvp_dme_config = venus_hfi_session_cvp_dme_config;
- hdev->session_cvp_dme_frame = venus_hfi_session_cvp_dme_frame;
- hdev->session_cvp_persist = venus_hfi_session_cvp_persist;
+ hdev->session_cvp_hfi_send = venus_hfi_session_send;
hdev->session_flush = venus_hfi_session_flush;
hdev->session_set_property = venus_hfi_session_set_property;
hdev->session_get_property = venus_hfi_session_get_property;
diff --git a/drivers/media/platform/msm/cvp/cvp_hfi.h b/drivers/media/platform/msm/cvp/cvp_hfi.h
index 8a3de61..ce0be0e 100644
--- a/drivers/media/platform/msm/cvp/cvp_hfi.h
+++ b/drivers/media/platform/msm/cvp/cvp_hfi.h
@@ -581,42 +581,6 @@
u32 buf_size[HFI_MAX_PLANES];
};
-struct hfi_cmd_session_hdr {
- u32 size;
- u32 packet_type;
- u32 session_id;
-};
-
-struct hfi_cmd_session_cvp_dfs_config_packet {
- u32 cvp_internal_dfs_config[CVP_DFS_CONFIG_CMD_SIZE];
-};
-
-struct hfi_cmd_session_cvp_dfs_frame_packet {
- u32 cvp_dfs_frame[CVP_DFS_FRAME_BUFFERS_OFFSET];
- u32 left_view_buffer_addr;
- u32 left_view_buffer_size;
- u32 right_view_buffer_addr;
- u32 right_view_buffer_size;
- u32 disparity_map_buffer_addr;
- u32 disparity_map_buffer_size;
- u32 occlusion_mask_buffer_addr;
- u32 occlusion_mask_buffer_size;
-};
-
-struct hfi_cmd_session_cvp_dme_config_packet {
- u32 cvp_internal_dme_config[CVP_DME_CONFIG_CMD_SIZE];
-};
-
-struct hfi_cmd_session_cvp_dme_frame_packet {
- u32 cvp_dme_frame[CVP_DME_FRAME_BUFFERS_OFFSET];
- struct buf_desc bufs[8];
-};
-
-struct hfi_cmd_session_cvp_persist_packet {
- u32 cvp_persist_frame[CVP_PERSIST_BUFFERS_OFFSET];
- struct buf_desc bufs[CVP_PSRSIST_BUF_NUM];
-};
-
struct hfi_cmd_session_release_buffer_packet {
u32 size;
u32 packet_type;
diff --git a/drivers/media/platform/msm/cvp/cvp_hfi_api.h b/drivers/media/platform/msm/cvp/cvp_hfi_api.h
index dae783a..1ad0a44 100644
--- a/drivers/media/platform/msm/cvp/cvp_hfi_api.h
+++ b/drivers/media/platform/msm/cvp/cvp_hfi_api.h
@@ -13,6 +13,7 @@
#include <linux/hash.h>
#include "msm_cvp_core.h"
#include "msm_cvp_resources.h"
+#include "cvp_hfi_helper.h"
#define CONTAINS(__a, __sz, __t) (\
(__t >= __a) && \
@@ -56,6 +57,21 @@
/* 16 encoder and 16 decoder sessions */
#define CVP_MAX_SESSIONS 32
+#define HFI_DFS_CONFIG_CMD_SIZE 38
+#define HFI_DFS_FRAME_CMD_SIZE 16
+#define HFI_DFS_FRAME_BUFFERS_OFFSET 8
+#define HFI_DFS_BUF_NUM 4
+
+#define HFI_DME_CONFIG_CMD_SIZE 194
+#define HFI_DME_FRAME_CMD_SIZE 28
+#define HFI_DME_FRAME_BUFFERS_OFFSET 12
+#define HFI_DME_BUF_NUM 8
+
+#define HFI_PERSIST_CMD_SIZE 11
+#define HFI_PERSIST_BUFFERS_OFFSET 7
+#define HFI_PERSIST_BUF_NUM 2
+
+
enum cvp_status {
CVP_ERR_NONE = 0x0,
CVP_ERR_FAIL = 0x80000000,
@@ -1082,7 +1098,7 @@
#define IS_HAL_SESSION_CMD(cmd) ((cmd) >= HAL_SESSION_EVENT_CHANGE && \
(cmd) <= HAL_SESSION_ERROR)
enum hal_command_response {
- /* SYSTEM COMMANDS_DONE*/
+ HAL_NO_RESP,
HAL_SYS_INIT_DONE,
HAL_SYS_SET_RESOURCE_DONE,
HAL_SYS_RELEASE_RESOURCE_DONE,
@@ -1411,73 +1427,17 @@
(((q) && (q)->op) ? ((q)->op(args)) : 0)
/* DFS related structures */
-struct msm_cvp_internal_dfsconfig {
- struct list_head list;
- struct msm_smem smem;
- struct msm_cvp_dfs_config dfs_config;
-};
-
struct buf_desc {
u32 fd;
u32 size;
};
-/**
- * struct msm_cvp_dfs_frame_kmd - argument passed with VIDIOC_CVP_CMD
- * @cvp_dfs_frame: parameters for DFS frame command
- * @left_view_buffer_fd: fd for left view buffer
- * @left_view_buffer_size: size for left view buffer
- * @right_view_buffer_fd: fd for right view buffer
- * @right_view_buffer_size: size for right view buffer
- * @disparity_map_buffer_fd: fd for disparity map buffer
- * @disparity_map_buffer_size: size for disparity map buffer
- * @occlusion_mask_buffer_fd: fd for occlusion mask buffer
- * @occlusion_mask_buffer_size: size for occlusion mask buffer
- */
-
-struct msm_cvp_dfs_frame_kmd {
- unsigned int cvp_dfs_frame[CVP_DFS_FRAME_BUFFERS_OFFSET];
- unsigned int left_view_buffer_fd;
- unsigned int left_view_buffer_size;
- unsigned int right_view_buffer_fd;
- unsigned int right_view_buffer_size;
- unsigned int disparity_map_buffer_fd;
- unsigned int disparity_map_buffer_size;
- unsigned int occlusion_mask_buffer_fd;
- unsigned int occlusion_mask_buffer_size;
-};
-
-
-struct msm_cvp_internal_dfsframe {
- struct list_head list;
- struct msm_cvp_dfs_frame_kmd dfs_frame;
-};
-
-/* DME related structures */
-struct msm_cvp_internal_dmeconfig {
- struct list_head list;
- struct msm_smem smem;
- struct msm_cvp_dme_config dme_config;
-};
-
-struct msm_cvp_dme_frame_kmd {
- unsigned int cvp_dme_frame[CVP_DME_FRAME_BUFFERS_OFFSET];
- struct buf_desc bufs[CVP_DME_BUF_NUM];
-};
-
-struct msm_cvp_internal_dmeframe {
- struct list_head list;
- struct msm_cvp_dme_frame_kmd dme_frame;
-};
-
-struct msm_cvp_persist_kmd {
- unsigned int cvp_pcmd[CVP_PERSIST_BUFFERS_OFFSET];
- struct buf_desc bufs[CVP_PSRSIST_BUF_NUM];
-};
-
-struct msm_cvp_internal_persist_cmd {
- struct list_head list;
- struct msm_cvp_persist_kmd persist_cmd;
+struct msm_cvp_hfi_defs {
+ unsigned int size;
+ unsigned int type;
+ unsigned int buf_offset;
+ unsigned int buf_num;
+ enum hal_command_response resp;
};
struct hfi_device {
@@ -1502,18 +1462,8 @@
int (*session_start)(void *sess);
int (*session_continue)(void *sess);
int (*session_stop)(void *sess);
- int (*session_cvp_operation_config)(void *sess,
- struct cvp_frame_data *input_frame);
- int (*session_cvp_dfs_config)(void *sess,
- struct msm_cvp_internal_dfsconfig *dfs_config);
- int (*session_cvp_dfs_frame)(void *sess,
- struct msm_cvp_internal_dfsframe *dfs_frame);
- int (*session_cvp_dme_config)(void *sess,
- struct msm_cvp_internal_dmeconfig *dme_config);
- int (*session_cvp_dme_frame)(void *sess,
- struct msm_cvp_internal_dmeframe *dme_frame);
- int (*session_cvp_persist)(void *sess,
- struct msm_cvp_internal_persist_cmd *pbuf_cmd);
+ int (*session_cvp_hfi_send)(void *sess,
+ struct cvp_kmd_hfi_packet *in_pkt);
int (*session_get_buf_req)(void *sess);
int (*session_flush)(void *sess, enum hal_flush flush_mode);
int (*session_set_property)(void *sess, enum hal_property ptype,
@@ -1547,4 +1497,7 @@
enum hal_domain cvp_get_hal_domain(u32 hfi_domain);
enum hal_video_codec cvp_get_hal_codec(u32 hfi_codec);
+int get_pkt_index(struct cvp_hal_session_cmd_pkt *hdr);
+extern const struct msm_cvp_hfi_defs cvp_hfi_defs[];
+
#endif /*__CVP_HFI_API_H__ */
diff --git a/drivers/media/platform/msm/cvp/hfi_packetization.c b/drivers/media/platform/msm/cvp/hfi_packetization.c
index 86da057..4bd0ae0 100644
--- a/drivers/media/platform/msm/cvp/hfi_packetization.c
+++ b/drivers/media/platform/msm/cvp/hfi_packetization.c
@@ -465,6 +465,7 @@
hfi->bank_spreading = ubwc_config->bank_spreading;
hfi->override_bit_info.bank_spreading_override =
ubwc_config->override_bit_info.bank_spreading_override;
+ hfi->size = sizeof(struct hfi_cmd_sys_set_ubwc_config_packet_type);
return rc;
}
@@ -852,171 +853,42 @@
return rc;
}
-int cvp_create_pkt_cmd_session_cvp_dfs_config(
- struct hfi_cmd_session_cvp_dfs_config_packet *pkt,
+int cvp_create_pkt_cmd_hfi_packetize(
+ struct cvp_kmd_hfi_packet *out_pkt,
struct hal_session *session,
- struct msm_cvp_internal_dfsconfig *dfs_config)
+ struct cvp_kmd_hfi_packet *in_pkt)
{
- struct hfi_cmd_session_hdr *ptr =
- (struct hfi_cmd_session_hdr *)pkt;
+ int def_idx;
+ struct cvp_hal_session_cmd_pkt *ptr =
+ (struct cvp_hal_session_cmd_pkt *)in_pkt;
- if (!pkt || !session)
+ if (!out_pkt || !in_pkt || !session)
return -EINVAL;
- memcpy(pkt, &dfs_config->dfs_config,
- CVP_DFS_CONFIG_CMD_SIZE*sizeof(unsigned int));
+ def_idx = get_pkt_index(ptr);
+ if (def_idx < 0)
+ goto error_hfi_packet;
- if (ptr->size != CVP_DFS_CONFIG_CMD_SIZE*sizeof(unsigned int))
- goto error_dfs_config;
+ if (cvp_hfi_defs[def_idx].type != ptr->packet_type)
+ goto error_hfi_packet;
- if (ptr->packet_type != HFI_CMD_SESSION_CVP_DFS_CONFIG)
- goto error_dfs_config;
+ 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_dfs_config;
+ goto error_hfi_packet;
+
+ memcpy(out_pkt, in_pkt, ptr->size);
return 0;
-error_dfs_config:
- dprintk(CVP_ERR, "%s: size=%d type=%d sessionid=%d\n",
+error_hfi_packet:
+ dprintk(CVP_ERR, "%s incorrect packet: size=%d type=%d sessionid=%d\n",
__func__, ptr->size, ptr->packet_type, ptr->session_id);
return -EINVAL;
}
-
-int cvp_create_pkt_cmd_session_cvp_dfs_frame(
- struct hfi_cmd_session_cvp_dfs_frame_packet *pkt,
- struct hal_session *session,
- struct msm_cvp_internal_dfsframe *dfs_frame)
-{
- struct hfi_cmd_session_hdr *ptr =
- (struct hfi_cmd_session_hdr *)pkt;
-
- if (!pkt || !session)
- return -EINVAL;
-
- memcpy(pkt, &dfs_frame->dfs_frame,
- CVP_DFS_FRAME_CMD_SIZE*sizeof(unsigned int));
-
- if (ptr->size != CVP_DFS_FRAME_CMD_SIZE*sizeof(unsigned int))
- goto error_dfs_frame;
-
- if (ptr->packet_type != HFI_CMD_SESSION_CVP_DFS_FRAME)
- goto error_dfs_frame;
-
- if (ptr->session_id != hash32_ptr(session))
- goto error_dfs_frame;
-
-
- return 0;
-
-error_dfs_frame:
- dprintk(CVP_ERR, "%s: size=%d type=%d sessionid=%d\n",
- __func__, ptr->size, ptr->packet_type, ptr->session_id);
-
- return -EINVAL;
-}
-
-int cvp_create_pkt_cmd_session_cvp_dme_config(
- struct hfi_cmd_session_cvp_dme_config_packet *pkt,
- struct hal_session *session,
- struct msm_cvp_internal_dmeconfig *dme_config)
-{
- struct hfi_cmd_session_hdr *ptr =
- (struct hfi_cmd_session_hdr *)pkt;
-
- if (!pkt || !session)
- return -EINVAL;
-
- memcpy(pkt, &dme_config->dme_config,
- CVP_DME_CONFIG_CMD_SIZE*sizeof(unsigned int));
-
- if (ptr->size != CVP_DME_CONFIG_CMD_SIZE*sizeof(unsigned int))
- goto error_dme_config;
-
- if (ptr->packet_type != HFI_CMD_SESSION_CVP_DME_CONFIG)
- goto error_dme_config;
-
- if (ptr->session_id != hash32_ptr(session))
- goto error_dme_config;
-
- return 0;
-
-error_dme_config:
- dprintk(CVP_ERR, "%s: size=%d type=%d sessionid=%d\n",
- __func__, ptr->size, ptr->packet_type, ptr->session_id);
-
- return -EINVAL;
-}
-
-
-int cvp_create_pkt_cmd_session_cvp_dme_frame(
- struct hfi_cmd_session_cvp_dme_frame_packet *pkt,
- struct hal_session *session,
- struct msm_cvp_internal_dmeframe *dme_frame)
-{
- struct hfi_cmd_session_hdr *ptr =
- (struct hfi_cmd_session_hdr *)pkt;
-
- if (!pkt || !session)
- return -EINVAL;
-
- memcpy(pkt, &dme_frame->dme_frame,
- CVP_DME_FRAME_CMD_SIZE*sizeof(unsigned int));
-
- if (ptr->size != CVP_DME_FRAME_CMD_SIZE*sizeof(unsigned int))
- goto error_dme_frame;
-
- if (ptr->packet_type != HFI_CMD_SESSION_CVP_DME_FRAME)
- goto error_dme_frame;
-
- if (ptr->session_id != hash32_ptr(session))
- goto error_dme_frame;
-
- return 0;
-
-error_dme_frame:
- dprintk(CVP_ERR, "%s: size=%d type=%d sessionid=%d\n",
- __func__, ptr->size, ptr->packet_type, ptr->session_id);
-
- return -EINVAL;
-}
-
-int cvp_create_pckt_cmd_session_cvp_persist(
- struct hfi_cmd_session_cvp_persist_packet *pkt,
- struct hal_session *session,
- struct msm_cvp_internal_persist_cmd *pbuf_cmd)
-{
- struct hfi_cmd_session_hdr *ptr =
- (struct hfi_cmd_session_hdr *)pkt;
-
- if (!pkt || !session)
- return -EINVAL;
-
- memcpy(pkt, &pbuf_cmd->persist_cmd,
- CVP_PERSIST_CMD_SIZE*sizeof(unsigned int));
-
- if (ptr->size != CVP_PERSIST_CMD_SIZE*sizeof(unsigned int))
- goto error_persist;
-
- if (ptr->packet_type != HFI_CMD_SESSION_CVP_SET_PERSIST_BUFFERS)
- goto error_persist;
-
- if (ptr->session_id != hash32_ptr(session))
- goto error_persist;
-
- return 0;
-
-error_persist:
- dprintk(CVP_ERR, "%s: size=%d type=%d sessionid=%d\n",
- __func__, ptr->size, ptr->packet_type, ptr->session_id);
-
- return -EINVAL;
-
-}
-
-
int cvp_create_pkt_cmd_session_flush(struct hfi_cmd_session_flush_packet *pkt,
struct hal_session *session, enum hal_flush flush_mode)
{
@@ -2221,16 +2093,7 @@
.session_flush = cvp_create_pkt_cmd_session_flush,
.session_get_property = cvp_create_pkt_cmd_session_get_property,
.session_set_property = cvp_create_pkt_cmd_session_set_property,
- .session_cvp_dfs_config =
- cvp_create_pkt_cmd_session_cvp_dfs_config,
- .session_cvp_dfs_frame =
- cvp_create_pkt_cmd_session_cvp_dfs_frame,
- .session_cvp_dme_config =
- cvp_create_pkt_cmd_session_cvp_dme_config,
- .session_cvp_dme_frame =
- cvp_create_pkt_cmd_session_cvp_dme_frame,
- .session_cvp_persist =
- cvp_create_pckt_cmd_session_cvp_persist,
+ .session_cvp_hfi_packetize = cvp_create_pkt_cmd_hfi_packetize,
};
struct hfi_packetization_ops *cvp_hfi_get_pkt_ops_handle(
diff --git a/drivers/media/platform/msm/cvp/hfi_packetization.h b/drivers/media/platform/msm/cvp/hfi_packetization.h
index aac76dc..f8e5a1d 100644
--- a/drivers/media/platform/msm/cvp/hfi_packetization.h
+++ b/drivers/media/platform/msm/cvp/hfi_packetization.h
@@ -79,26 +79,10 @@
int (*session_sync_process)(
struct hfi_cmd_session_sync_process_packet *pkt,
struct hal_session *session);
- int (*session_cvp_dfs_config)(
- struct hfi_cmd_session_cvp_dfs_config_packet *pkt,
+ int (*session_cvp_hfi_packetize)(
+ struct cvp_kmd_hfi_packet *out_pkt,
struct hal_session *session,
- struct msm_cvp_internal_dfsconfig *dfs_config);
- int (*session_cvp_dfs_frame)(
- struct hfi_cmd_session_cvp_dfs_frame_packet *pkt,
- struct hal_session *session,
- struct msm_cvp_internal_dfsframe *dfs_frame);
- int (*session_cvp_dme_config)(
- struct hfi_cmd_session_cvp_dme_config_packet *pkt,
- struct hal_session *session,
- struct msm_cvp_internal_dmeconfig *dme_config);
- int (*session_cvp_dme_frame)(
- struct hfi_cmd_session_cvp_dme_frame_packet *pkt,
- struct hal_session *session,
- struct msm_cvp_internal_dmeframe *dme_frame);
- int (*session_cvp_persist)(
- struct hfi_cmd_session_cvp_persist_packet *pkt,
- struct hal_session *session,
- struct msm_cvp_internal_persist_cmd *pbuf_cmd);
+ struct cvp_kmd_hfi_packet *in_pkt);
};
struct hfi_packetization_ops *cvp_hfi_get_pkt_ops_handle(
diff --git a/drivers/media/platform/msm/cvp/msm_cvp.c b/drivers/media/platform/msm/cvp/msm_cvp.c
index 6aaef05..3783b15 100644
--- a/drivers/media/platform/msm/cvp/msm_cvp.c
+++ b/drivers/media/platform/msm/cvp/msm_cvp.c
@@ -14,7 +14,7 @@
MSM_CVP_UHD60E_ISE_CYCLES)
static void print_client_buffer(u32 tag, const char *str,
- struct msm_cvp_inst *inst, struct msm_cvp_buffer *cbuf)
+ struct msm_cvp_inst *inst, struct cvp_kmd_buffer *cbuf)
{
if (!(tag & msm_cvp_debug) || !inst || !cbuf)
return;
@@ -42,13 +42,13 @@
{
enum hal_buffer buftype = HAL_BUFFER_NONE;
- if (type == MSM_CVP_BUFTYPE_INPUT)
+ if (type == CVP_KMD_BUFTYPE_INPUT)
buftype = HAL_BUFFER_INPUT;
- else if (type == MSM_CVP_BUFTYPE_OUTPUT)
+ else if (type == CVP_KMD_BUFTYPE_OUTPUT)
buftype = HAL_BUFFER_OUTPUT;
- else if (type == MSM_CVP_BUFTYPE_INTERNAL_1)
+ else if (type == CVP_KMD_BUFTYPE_INTERNAL_1)
buftype = HAL_BUFFER_INTERNAL_SCRATCH_1;
- else if (type == MSM_CVP_BUFTYPE_INTERNAL_2)
+ else if (type == CVP_KMD_BUFTYPE_INTERNAL_2)
buftype = HAL_BUFFER_INTERNAL_SCRATCH_1;
else
dprintk(CVP_ERR, "%s: unknown buffer type %#x\n",
@@ -87,7 +87,7 @@
}
static int msm_cvp_get_session_info(struct msm_cvp_inst *inst,
- struct msm_cvp_session_info *session)
+ struct cvp_kmd_session_info *session)
{
int rc = 0;
@@ -133,366 +133,11 @@
return 0;
}
-/* DFS feature system call handling */
-static int msm_cvp_session_cvp_dfs_config(
- struct msm_cvp_inst *inst,
- struct msm_cvp_dfs_config *dfs_config)
-{
- int rc = 0;
- struct hfi_device *hdev;
- struct msm_cvp_internal_dfsconfig internal_dfs_config;
-
- dprintk(CVP_DBG, "%s:: Enter inst = %pK\n", __func__, inst);
-
- if (!inst || !inst->core || !dfs_config) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
- hdev = inst->core->device;
- memcpy(&internal_dfs_config.dfs_config.cvp_dfs_config,
- dfs_config, sizeof(struct msm_cvp_dfs_config));
-
- rc = call_hfi_op(hdev, session_cvp_dfs_config,
- (void *)inst->session, &internal_dfs_config);
- if (!rc) {
- rc = wait_for_sess_signal_receipt(inst,
- HAL_SESSION_DFS_CONFIG_CMD_DONE);
- if (rc)
- dprintk(CVP_ERR,
- "%s: wait for signal failed, rc %d\n",
- __func__, rc);
- } else {
- dprintk(CVP_ERR,
- "%s: Failed in call_hfi_op for session_cvp_dfs_config\n",
- __func__);
- }
- return rc;
-}
-
-static int msm_cvp_session_cvp_dfs_frame(
- struct msm_cvp_inst *inst,
- struct msm_cvp_dfs_frame *dfs_frame)
-{
- int rc = 0;
- struct hfi_device *hdev;
- struct msm_cvp_internal_dfsframe internal_dfs_frame;
- struct msm_cvp_dfs_frame_kmd *dest_ptr = &internal_dfs_frame.dfs_frame;
- struct msm_cvp_dfs_frame_kmd src_frame;
- struct msm_cvp_internal_buffer *cbuf;
-
- dprintk(CVP_DBG, "%s:: Enter inst = %pK\n", __func__, inst);
-
- if (!inst || !inst->core || !dfs_frame) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
- src_frame = *(struct msm_cvp_dfs_frame_kmd *)dfs_frame;
- hdev = inst->core->device;
- memset(&internal_dfs_frame, 0,
- sizeof(struct msm_cvp_internal_dfsframe));
-
- memcpy(&internal_dfs_frame.dfs_frame, dfs_frame,
- CVP_DFS_FRAME_CMD_SIZE*sizeof(unsigned int));
-
- rc = msm_cvp_session_get_iova_addr(inst, cbuf,
- src_frame.left_view_buffer_fd,
- src_frame.left_view_buffer_size,
- &dest_ptr->left_view_buffer_fd,
- &dest_ptr->left_view_buffer_size);
- if (rc) {
- dprintk(CVP_ERR, "%s:: left buffer not registered. rc=%d\n",
- __func__, rc);
- return rc;
- }
-
- rc = msm_cvp_session_get_iova_addr(inst, cbuf,
- src_frame.right_view_buffer_fd,
- src_frame.right_view_buffer_size,
- &dest_ptr->right_view_buffer_fd,
- &dest_ptr->right_view_buffer_size);
- if (rc) {
- dprintk(CVP_ERR, "%s:: right buffer not registered. rc=%d\n",
- __func__, rc);
- return rc;
- }
-
- rc = msm_cvp_session_get_iova_addr(inst, cbuf,
- src_frame.disparity_map_buffer_fd,
- src_frame.disparity_map_buffer_size,
- &dest_ptr->disparity_map_buffer_fd,
- &dest_ptr->disparity_map_buffer_size);
- if (rc) {
- dprintk(CVP_ERR, "%s:: disparity map not registered. rc=%d\n",
- __func__, rc);
- return rc;
- }
-
- rc = msm_cvp_session_get_iova_addr(inst, cbuf,
- src_frame.occlusion_mask_buffer_fd,
- src_frame.occlusion_mask_buffer_size,
- &dest_ptr->occlusion_mask_buffer_fd,
- &dest_ptr->occlusion_mask_buffer_size);
- if (rc) {
- dprintk(CVP_ERR, "%s:: occlusion mask not registered. rc=%d\n",
- __func__, rc);
- return rc;
- }
-
- rc = call_hfi_op(hdev, session_cvp_dfs_frame,
- (void *)inst->session, &internal_dfs_frame);
-
- if (rc) {
- dprintk(CVP_ERR,
- "%s: Failed in call_hfi_op for session_cvp_dfs_frame\n",
- __func__);
- }
-
- return rc;
-}
-
-static int msm_cvp_session_cvp_dfs_frame_response(
- struct msm_cvp_inst *inst,
- struct msm_cvp_dfs_frame *dfs_frame)
-{
- int rc = 0;
-
- dprintk(CVP_DBG, "%s:: Enter inst = %pK\n", __func__, inst);
-
- if (!inst || !inst->core || !dfs_frame) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
- rc = wait_for_sess_signal_receipt(inst,
- HAL_SESSION_DFS_FRAME_CMD_DONE);
- if (rc)
- dprintk(CVP_ERR,
- "%s: wait for signal failed, rc %d\n",
- __func__, rc);
- return rc;
-}
-
-/* DME feature system call handling */
-static int msm_cvp_session_cvp_dme_config(
- struct msm_cvp_inst *inst,
- struct msm_cvp_dme_config *dme_config)
-{
- int rc = 0;
- struct hfi_device *hdev;
- struct msm_cvp_internal_dmeconfig internal_dme_config;
-
- dprintk(CVP_DBG, "%s:: Enter inst = %d", __func__, inst);
-
- if (!inst || !inst->core || !dme_config) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
- hdev = inst->core->device;
- memcpy(&internal_dme_config.dme_config.cvp_dme_config,
- dme_config, sizeof(struct msm_cvp_dme_config));
-
- rc = call_hfi_op(hdev, session_cvp_dme_config,
- (void *)inst->session, &internal_dme_config);
- if (!rc) {
- rc = wait_for_sess_signal_receipt(inst,
- HAL_SESSION_DME_CONFIG_CMD_DONE);
- if (rc)
- dprintk(CVP_ERR,
- "%s: wait for signal failed, rc %d\n",
- __func__, rc);
- } else {
- dprintk(CVP_ERR, "%s Failed in call_hfi_op\n", __func__);
- }
- return rc;
-}
-
-static int msm_cvp_session_cvp_dme_frame(
- struct msm_cvp_inst *inst,
- struct msm_cvp_dme_frame *dme_frame)
-{
- int i, rc = 0;
- struct hfi_device *hdev;
- struct msm_cvp_internal_dmeframe internal_dme_frame;
- struct msm_cvp_dme_frame_kmd *dest_ptr = &internal_dme_frame.dme_frame;
- struct msm_cvp_dme_frame_kmd src_frame;
- struct msm_cvp_internal_buffer *cbuf;
-
- dprintk(CVP_DBG, "%s:: Enter inst = %d", __func__, inst);
-
- if (!inst || !inst->core || !dme_frame) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
- src_frame = *(struct msm_cvp_dme_frame_kmd *)dme_frame;
- hdev = inst->core->device;
- memset(&internal_dme_frame, 0,
- sizeof(struct msm_cvp_internal_dmeframe));
-
- memcpy(&internal_dme_frame.dme_frame, dme_frame,
- CVP_DME_FRAME_CMD_SIZE*sizeof(unsigned int));
-
- for (i = 0; i < CVP_DME_BUF_NUM; i++) {
- if (!src_frame.bufs[i].fd) {
- dest_ptr->bufs[i].fd = src_frame.bufs[i].fd;
- dest_ptr->bufs[i].size = src_frame.bufs[i].size;
- continue;
- }
-
- rc = msm_cvp_session_get_iova_addr(inst, cbuf,
- src_frame.bufs[i].fd,
- src_frame.bufs[i].size,
- &dest_ptr->bufs[i].fd,
- &dest_ptr->bufs[i].size);
- if (rc) {
- dprintk(CVP_ERR,
- "%s: %d buffer not registered. rc=%d\n",
- __func__, i, rc);
- return rc;
- }
-
- }
-
- rc = call_hfi_op(hdev, session_cvp_dme_frame,
- (void *)inst->session, &internal_dme_frame);
-
- if (rc) {
- dprintk(CVP_ERR,
- "%s:: Failed in call_hfi_op\n",
- __func__);
- }
-
- return rc;
-}
-
-static int msm_cvp_session_cvp_persist(
- struct msm_cvp_inst *inst,
- struct msm_cvp_persist_buf *pbuf_cmd)
-{
- int i, rc = 0;
- struct hfi_device *hdev;
- struct msm_cvp_internal_persist_cmd internal_pcmd;
- struct msm_cvp_persist_kmd *dest_ptr = &internal_pcmd.persist_cmd;
- struct msm_cvp_persist_kmd src_frame;
- struct msm_cvp_internal_buffer *cbuf;
-
- dprintk(CVP_DBG, "%s:: Enter inst = %d", __func__, inst);
-
- if (!inst || !inst->core || !pbuf_cmd) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
- src_frame = *(struct msm_cvp_persist_kmd *)pbuf_cmd;
- hdev = inst->core->device;
- memset(&internal_pcmd, 0,
- sizeof(struct msm_cvp_internal_persist_cmd));
-
- memcpy(&internal_pcmd.persist_cmd, pbuf_cmd,
- CVP_PERSIST_CMD_SIZE*sizeof(unsigned int));
-
- for (i = 0; i < CVP_PSRSIST_BUF_NUM; i++) {
- if (!src_frame.bufs[i].fd) {
- dest_ptr->bufs[i].fd = src_frame.bufs[i].fd;
- dest_ptr->bufs[i].size = src_frame.bufs[i].size;
- continue;
- }
-
- rc = msm_cvp_session_get_iova_addr(inst, cbuf,
- src_frame.bufs[i].fd,
- src_frame.bufs[i].size,
- &dest_ptr->bufs[i].fd,
- &dest_ptr->bufs[i].size);
- if (rc) {
- dprintk(CVP_ERR,
- "%s:: %d buffer not registered. rc=%d\n",
- __func__, i, rc);
- return rc;
- }
- }
-
- rc = call_hfi_op(hdev, session_cvp_persist,
- (void *)inst->session, &internal_pcmd);
-
- if (rc)
- dprintk(CVP_ERR, "%s: Failed in call_hfi_op\n", __func__);
-
- return rc;
-}
-
-static int msm_cvp_session_cvp_dme_frame_response(
- struct msm_cvp_inst *inst,
- struct msm_cvp_dme_frame *dme_frame)
-{
- int rc = 0;
-
- dprintk(CVP_DBG, "%s:: Enter inst = %d", __func__, inst);
-
- if (!inst || !inst->core || !dme_frame) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
- rc = wait_for_sess_signal_receipt(inst,
- HAL_SESSION_DME_FRAME_CMD_DONE);
- if (rc)
- dprintk(CVP_ERR,
- "%s: wait for signal failed, rc %d\n",
- __func__, rc);
- return rc;
-}
-
-static int msm_cvp_session_cvp_persist_response(
- struct msm_cvp_inst *inst,
- struct msm_cvp_persist_buf *pbuf_cmd)
-{
- int rc = 0;
-
- dprintk(CVP_DBG, "%s:: Enter inst = %d", __func__, inst);
-
- if (!inst || !inst->core || !pbuf_cmd) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
- rc = wait_for_sess_signal_receipt(inst,
- HAL_SESSION_PERSIST_CMD_DONE);
- if (rc)
- dprintk(CVP_ERR,
- "%s: wait for signal failed, rc %d\n",
- __func__, rc);
- return rc;
-}
-
-
-
-static int msm_cvp_send_cmd(struct msm_cvp_inst *inst,
- struct msm_cvp_send_cmd *send_cmd)
-{
- dprintk(CVP_ERR, "%s: UMD gave a deprecated cmd", __func__);
-
- return 0;
-}
-
-static int msm_cvp_request_power(struct msm_cvp_inst *inst,
- struct msm_cvp_request_power *power)
-{
- int rc = 0;
-
- if (!inst || !power) {
- dprintk(CVP_ERR, "%s: invalid params\n", __func__);
- return -EINVAL;
- }
-
- dprintk(CVP_DBG,
- "%s: clock_cycles_a %d, clock_cycles_b %d, ddr_bw %d sys_cache_bw %d\n",
- __func__, power->clock_cycles_a, power->clock_cycles_b,
- power->ddr_bw, power->sys_cache_bw);
-
- return rc;
-}
-
-static int msm_cvp_register_buffer(struct msm_cvp_inst *inst,
- struct msm_cvp_buffer *buf)
+static int msm_cvp_map_buf(struct msm_cvp_inst *inst,
+ struct cvp_kmd_buffer *buf)
{
int rc = 0;
bool found;
- struct hfi_device *hdev;
struct msm_cvp_internal_buffer *cbuf;
struct hal_session *session;
@@ -502,13 +147,6 @@
}
session = (struct hal_session *)inst->session;
- if (!session) {
- dprintk(CVP_ERR, "%s: invalid session\n", __func__);
- return -EINVAL;
- }
- hdev = inst->core->device;
- print_client_buffer(CVP_DBG, "register", inst, buf);
-
mutex_lock(&inst->cvpbufs.lock);
found = false;
list_for_each_entry(cbuf, &inst->cvpbufs.list, list) {
@@ -533,7 +171,7 @@
list_add_tail(&cbuf->list, &inst->cvpbufs.list);
mutex_unlock(&inst->cvpbufs.lock);
- memcpy(&cbuf->buf, buf, sizeof(struct msm_cvp_buffer));
+ memcpy(&cbuf->buf, buf, sizeof(struct cvp_kmd_buffer));
cbuf->smem.buffer_type = get_hal_buftype(__func__, buf->type);
cbuf->smem.fd = buf->fd;
cbuf->smem.offset = buf->offset;
@@ -555,7 +193,6 @@
goto exit;
}
}
-
return rc;
exit:
@@ -570,8 +207,192 @@
return rc;
}
+static int msm_cvp_session_process_hfi(
+ struct msm_cvp_inst *inst,
+ struct cvp_kmd_hfi_packet *in_pkt)
+{
+ int i, pkt_idx, rc = 0;
+ struct hfi_device *hdev;
+ struct msm_cvp_internal_buffer *cbuf;
+ struct buf_desc *buf_ptr;
+ unsigned int offset, buf_num;
+
+ if (!inst || !inst->core || !in_pkt) {
+ dprintk(CVP_ERR, "%s: invalid params\n", __func__);
+ return -EINVAL;
+ }
+ hdev = inst->core->device;
+
+ pkt_idx = get_pkt_index((struct cvp_hal_session_cmd_pkt *)in_pkt);
+ if (pkt_idx < 0) {
+ dprintk(CVP_ERR, "%s incorrect packet %d, %x\n", __func__,
+ in_pkt->pkt_data[0],
+ in_pkt->pkt_data[1]);
+ return pkt_idx;
+ }
+ offset = cvp_hfi_defs[pkt_idx].buf_offset;
+ buf_num = cvp_hfi_defs[pkt_idx].buf_num;
+
+ if (offset != 0 && buf_num != 0) {
+ buf_ptr = (struct buf_desc *)&in_pkt->pkt_data[offset];
+
+ for (i = 0; i < buf_num; i++) {
+ if (!buf_ptr[i].fd)
+ continue;
+
+ rc = msm_cvp_session_get_iova_addr(inst, cbuf,
+ buf_ptr[i].fd,
+ buf_ptr[i].size,
+ &buf_ptr[i].fd,
+ &buf_ptr[i].size);
+ if (rc) {
+ dprintk(CVP_ERR,
+ "%s: buf %d unregistered. rc=%d\n",
+ __func__, i, rc);
+ return rc;
+ }
+ }
+ }
+ rc = call_hfi_op(hdev, session_cvp_hfi_send,
+ (void *)inst->session, in_pkt);
+ if (rc) {
+ dprintk(CVP_ERR,
+ "%s: Failed in call_hfi_op %d, %x\n",
+ __func__, in_pkt->pkt_data[0], in_pkt->pkt_data[1]);
+ }
+
+ if (cvp_hfi_defs[pkt_idx].resp != HAL_NO_RESP) {
+ rc = wait_for_sess_signal_receipt(inst,
+ cvp_hfi_defs[pkt_idx].resp);
+ if (rc)
+ dprintk(CVP_ERR,
+ "%s: wait for signal failed, rc %d %d, %x %d\n",
+ __func__, rc,
+ in_pkt->pkt_data[0],
+ in_pkt->pkt_data[1],
+ cvp_hfi_defs[pkt_idx].resp);
+
+ }
+
+ return rc;
+}
+
+static int msm_cvp_session_cvp_dfs_frame_response(
+ struct msm_cvp_inst *inst,
+ struct cvp_kmd_hfi_packet *dfs_frame)
+{
+ int rc = 0;
+
+ dprintk(CVP_DBG, "%s:: Enter inst = %pK\n", __func__, inst);
+
+ if (!inst || !inst->core || !dfs_frame) {
+ dprintk(CVP_ERR, "%s: invalid params\n", __func__);
+ return -EINVAL;
+ }
+ rc = wait_for_sess_signal_receipt(inst,
+ HAL_SESSION_DFS_FRAME_CMD_DONE);
+ if (rc)
+ dprintk(CVP_ERR,
+ "%s: wait for signal failed, rc %d\n",
+ __func__, rc);
+ return rc;
+}
+
+static int msm_cvp_session_cvp_dme_frame_response(
+ struct msm_cvp_inst *inst,
+ struct cvp_kmd_hfi_packet *dme_frame)
+{
+ int rc = 0;
+
+ dprintk(CVP_DBG, "%s:: Enter inst = %d", __func__, inst);
+
+ if (!inst || !inst->core || !dme_frame) {
+ dprintk(CVP_ERR, "%s: invalid params\n", __func__);
+ return -EINVAL;
+ }
+ rc = wait_for_sess_signal_receipt(inst,
+ HAL_SESSION_DME_FRAME_CMD_DONE);
+ if (rc)
+ dprintk(CVP_ERR,
+ "%s: wait for signal failed, rc %d\n",
+ __func__, rc);
+ return rc;
+}
+
+static int msm_cvp_session_cvp_persist_response(
+ struct msm_cvp_inst *inst,
+ struct cvp_kmd_hfi_packet *pbuf_cmd)
+{
+ int rc = 0;
+
+ dprintk(CVP_DBG, "%s:: Enter inst = %d", __func__, inst);
+
+ if (!inst || !inst->core || !pbuf_cmd) {
+ dprintk(CVP_ERR, "%s: invalid params\n", __func__);
+ return -EINVAL;
+ }
+ rc = wait_for_sess_signal_receipt(inst,
+ HAL_SESSION_PERSIST_CMD_DONE);
+ if (rc)
+ dprintk(CVP_ERR,
+ "%s: wait for signal failed, rc %d\n",
+ __func__, rc);
+ return rc;
+}
+
+
+
+static int msm_cvp_send_cmd(struct msm_cvp_inst *inst,
+ struct cvp_kmd_send_cmd *send_cmd)
+{
+ dprintk(CVP_ERR, "%s: UMD gave a deprecated cmd", __func__);
+
+ return 0;
+}
+
+static int msm_cvp_request_power(struct msm_cvp_inst *inst,
+ struct cvp_kmd_request_power *power)
+{
+ int rc = 0;
+
+ if (!inst || !power) {
+ dprintk(CVP_ERR, "%s: invalid params\n", __func__);
+ return -EINVAL;
+ }
+
+ dprintk(CVP_DBG,
+ "%s: clock_cycles_a %d, clock_cycles_b %d, ddr_bw %d sys_cache_bw %d\n",
+ __func__, power->clock_cycles_a, power->clock_cycles_b,
+ power->ddr_bw, power->sys_cache_bw);
+
+ return rc;
+}
+
+static int msm_cvp_register_buffer(struct msm_cvp_inst *inst,
+ struct cvp_kmd_buffer *buf)
+{
+ struct hfi_device *hdev;
+ struct hal_session *session;
+
+ if (!inst || !inst->core || !buf) {
+ dprintk(CVP_ERR, "%s: invalid params\n", __func__);
+ return -EINVAL;
+ }
+
+ session = (struct hal_session *)inst->session;
+ if (!session) {
+ dprintk(CVP_ERR, "%s: invalid session\n", __func__);
+ return -EINVAL;
+ }
+ hdev = inst->core->device;
+ print_client_buffer(CVP_DBG, "register", inst, buf);
+
+ return msm_cvp_map_buf(inst, buf);
+
+}
+
static int msm_cvp_unregister_buffer(struct msm_cvp_inst *inst,
- struct msm_cvp_buffer *buf)
+ struct cvp_kmd_buffer *buf)
{
int rc = 0;
bool found;
@@ -592,6 +413,11 @@
hdev = inst->core->device;
print_client_buffer(CVP_DBG, "unregister", inst, buf);
+ if (!buf->index) {
+ dprintk(CVP_ERR, "Missing index when unregister buf\n");
+ return 0;
+ }
+
mutex_lock(&inst->cvpbufs.lock);
found = false;
list_for_each_entry(cbuf, &inst->cvpbufs.list, list) {
@@ -626,7 +452,7 @@
return rc;
}
-int msm_cvp_handle_syscall(struct msm_cvp_inst *inst, struct msm_cvp_arg *arg)
+int msm_cvp_handle_syscall(struct msm_cvp_inst *inst, struct cvp_kmd_arg *arg)
{
int rc = 0;
@@ -637,108 +463,79 @@
dprintk(CVP_DBG, "%s:: arg->type = %x", __func__, arg->type);
switch (arg->type) {
- case MSM_CVP_GET_SESSION_INFO:
+ case CVP_KMD_GET_SESSION_INFO:
{
- struct msm_cvp_session_info *session =
- (struct msm_cvp_session_info *)&arg->data.session;
+ struct cvp_kmd_session_info *session =
+ (struct cvp_kmd_session_info *)&arg->data.session;
rc = msm_cvp_get_session_info(inst, session);
break;
}
- case MSM_CVP_REQUEST_POWER:
+ case CVP_KMD_REQUEST_POWER:
{
- struct msm_cvp_request_power *power =
- (struct msm_cvp_request_power *)&arg->data.req_power;
+ struct cvp_kmd_request_power *power =
+ (struct cvp_kmd_request_power *)&arg->data.req_power;
rc = msm_cvp_request_power(inst, power);
break;
}
- case MSM_CVP_REGISTER_BUFFER:
+ case CVP_KMD_REGISTER_BUFFER:
{
- struct msm_cvp_buffer *buf =
- (struct msm_cvp_buffer *)&arg->data.regbuf;
+ struct cvp_kmd_buffer *buf =
+ (struct cvp_kmd_buffer *)&arg->data.regbuf;
rc = msm_cvp_register_buffer(inst, buf);
break;
}
- case MSM_CVP_UNREGISTER_BUFFER:
+ case CVP_KMD_UNREGISTER_BUFFER:
{
- struct msm_cvp_buffer *buf =
- (struct msm_cvp_buffer *)&arg->data.unregbuf;
+ struct cvp_kmd_buffer *buf =
+ (struct cvp_kmd_buffer *)&arg->data.unregbuf;
rc = msm_cvp_unregister_buffer(inst, buf);
break;
}
- case MSM_CVP_HFI_SEND_CMD:
+ case CVP_KMD_HFI_SEND_CMD:
{
- //struct msm_cvp_buffer *buf =
- //(struct msm_cvp_buffer *)&arg->data.unregbuf;
- struct msm_cvp_send_cmd *send_cmd =
- (struct msm_cvp_send_cmd *)&arg->data.send_cmd;
+ struct cvp_kmd_send_cmd *send_cmd =
+ (struct cvp_kmd_send_cmd *)&arg->data.send_cmd;
rc = msm_cvp_send_cmd(inst, send_cmd);
break;
}
- case MSM_CVP_HFI_DFS_CONFIG_CMD:
+ case CVP_KMD_SEND_CMD_PKT:
+ case CVP_KMD_HFI_DFS_CONFIG_CMD:
+ case CVP_KMD_HFI_DFS_FRAME_CMD:
+ case CVP_KMD_HFI_DME_CONFIG_CMD:
+ case CVP_KMD_HFI_DME_FRAME_CMD:
+ case CVP_KMD_HFI_PERSIST_CMD:
{
- struct msm_cvp_dfs_config *dfs_config =
- (struct msm_cvp_dfs_config *)&arg->data.dfs_config;
+ struct cvp_kmd_hfi_packet *in_pkt =
+ (struct cvp_kmd_hfi_packet *)&arg->data.hfi_pkt;
- rc = msm_cvp_session_cvp_dfs_config(inst, dfs_config);
+ rc = msm_cvp_session_process_hfi(inst, in_pkt);
break;
}
- case MSM_CVP_HFI_DFS_FRAME_CMD:
+ case CVP_KMD_HFI_DFS_FRAME_CMD_RESPONSE:
{
- struct msm_cvp_dfs_frame *dfs_frame =
- (struct msm_cvp_dfs_frame *)&arg->data.dfs_frame;
-
- rc = msm_cvp_session_cvp_dfs_frame(inst, dfs_frame);
- break;
- }
- case MSM_CVP_HFI_DFS_FRAME_CMD_RESPONSE:
- {
- struct msm_cvp_dfs_frame *dfs_frame =
- (struct msm_cvp_dfs_frame *)&arg->data.dfs_frame;
+ struct cvp_kmd_hfi_packet *dfs_frame =
+ (struct cvp_kmd_hfi_packet *)&arg->data.hfi_pkt;
rc = msm_cvp_session_cvp_dfs_frame_response(inst, dfs_frame);
break;
}
- case MSM_CVP_HFI_DME_CONFIG_CMD:
+ case CVP_KMD_HFI_DME_FRAME_CMD_RESPONSE:
{
- struct msm_cvp_dme_config *dme_config =
- (struct msm_cvp_dme_config *)&arg->data.dme_config;
+ struct cvp_kmd_hfi_packet *dme_frame =
+ (struct cvp_kmd_hfi_packet *)&arg->data.hfi_pkt;
- rc = msm_cvp_session_cvp_dme_config(inst, dme_config);
+ rc = msm_cvp_session_cvp_dme_frame_response(inst, dme_frame);
break;
}
- case MSM_CVP_HFI_DME_FRAME_CMD:
+ case CVP_KMD_HFI_PERSIST_CMD_RESPONSE:
{
- struct msm_cvp_dme_frame *dme_frame =
- (struct msm_cvp_dme_frame *)&arg->data.dme_frame;
-
- rc = msm_cvp_session_cvp_dme_frame(inst, dme_frame);
- break;
- }
- case MSM_CVP_HFI_DME_FRAME_CMD_RESPONSE:
- {
- struct msm_cvp_dme_frame *dmeframe =
- (struct msm_cvp_dme_frame *)&arg->data.dme_frame;
-
- rc = msm_cvp_session_cvp_dme_frame_response(inst, dmeframe);
- break;
- }
- case MSM_CVP_HFI_PERSIST_CMD:
- {
- struct msm_cvp_persist_buf *pbuf_cmd =
- (struct msm_cvp_persist_buf *)&arg->data.pbuf_cmd;
-
- rc = msm_cvp_session_cvp_persist(inst, pbuf_cmd);
- break;
- }
- case MSM_CVP_HFI_PERSIST_CMD_RESPONSE:
- {
- struct msm_cvp_persist_buf *pbuf_cmd =
- (struct msm_cvp_persist_buf *)&arg->data.pbuf_cmd;
+ struct cvp_kmd_hfi_packet *pbuf_cmd =
+ (struct cvp_kmd_hfi_packet *)&arg->data.hfi_pkt;
rc = msm_cvp_session_cvp_persist_response(inst, pbuf_cmd);
break;
diff --git a/drivers/media/platform/msm/cvp/msm_cvp.h b/drivers/media/platform/msm/cvp/msm_cvp.h
index 6bcb799..9443dab 100644
--- a/drivers/media/platform/msm/cvp/msm_cvp.h
+++ b/drivers/media/platform/msm/cvp/msm_cvp.h
@@ -11,7 +11,7 @@
#include "msm_cvp_clocks.h"
#include "msm_cvp_debug.h"
#include "msm_cvp_dsp.h"
-int msm_cvp_handle_syscall(struct msm_cvp_inst *inst, struct msm_cvp_arg *arg);
+int msm_cvp_handle_syscall(struct msm_cvp_inst *inst, struct cvp_kmd_arg *arg);
int msm_cvp_session_init(struct msm_cvp_inst *inst);
int msm_cvp_session_deinit(struct msm_cvp_inst *inst);
int msm_cvp_session_pause(struct msm_cvp_inst *inst);
diff --git a/drivers/media/platform/msm/cvp/msm_cvp_clocks.c b/drivers/media/platform/msm/cvp/msm_cvp_clocks.c
index aba906b..2b9f902 100644
--- a/drivers/media/platform/msm/cvp/msm_cvp_clocks.c
+++ b/drivers/media/platform/msm/cvp/msm_cvp_clocks.c
@@ -717,7 +717,7 @@
* keep checking from lowest to highest rate until
* table rate >= requested rate
*/
- for (i = core->resources.allowed_clks_tbl_size - 1; i >= 0; i--) {
+ for (i = 0; i < core->resources.allowed_clks_tbl_size; i++) {
rate = allowed_clks_tbl[i].clock_rate;
if (rate >= freq_core_max)
break;
diff --git a/drivers/media/platform/msm/cvp/msm_cvp_core.c b/drivers/media/platform/msm/cvp/msm_cvp_core.c
index 75de60d..d5d5cde 100644
--- a/drivers/media/platform/msm/cvp/msm_cvp_core.c
+++ b/drivers/media/platform/msm/cvp/msm_cvp_core.c
@@ -830,7 +830,7 @@
EXPORT_SYMBOL(msm_cvp_dqevent);
int msm_cvp_private(void *cvp_inst, unsigned int cmd,
- struct msm_cvp_arg *arg)
+ struct cvp_kmd_arg *arg)
{
int rc = 0;
struct msm_cvp_inst *inst = (struct msm_cvp_inst *)cvp_inst;
diff --git a/drivers/media/platform/msm/cvp/msm_cvp_core.h b/drivers/media/platform/msm/cvp/msm_cvp_core.h
index 97339ed..a5692c0 100644
--- a/drivers/media/platform/msm/cvp/msm_cvp_core.h
+++ b/drivers/media/platform/msm/cvp/msm_cvp_core.h
@@ -124,5 +124,5 @@
int msm_cvp_g_crop(void *instance, struct v4l2_crop *a);
int msm_cvp_enum_framesizes(void *instance, struct v4l2_frmsizeenum *fsize);
int msm_cvp_private(void *cvp_inst, unsigned int cmd,
- struct msm_cvp_arg *arg);
+ struct cvp_kmd_arg *arg);
#endif
diff --git a/drivers/media/platform/msm/cvp/msm_cvp_internal.h b/drivers/media/platform/msm/cvp/msm_cvp_internal.h
index a5ca2f2..a6a0099 100644
--- a/drivers/media/platform/msm/cvp/msm_cvp_internal.h
+++ b/drivers/media/platform/msm/cvp/msm_cvp_internal.h
@@ -535,13 +535,7 @@
struct msm_cvp_internal_buffer {
struct list_head list;
struct msm_smem smem;
- struct msm_cvp_buffer buf;
-};
-
-struct msm_cvp_internal_send_cmd {
- struct list_head list;
- struct msm_smem smem;
- struct msm_cvp_send_cmd send_cmd;
+ struct cvp_kmd_buffer buf;
};
void msm_cvp_comm_handle_thermal_event(void);
diff --git a/drivers/media/platform/msm/cvp/msm_cvp_res_parse.c b/drivers/media/platform/msm/cvp/msm_cvp_res_parse.c
index c4962ff..d14e489 100644
--- a/drivers/media/platform/msm/cvp/msm_cvp_res_parse.c
+++ b/drivers/media/platform/msm/cvp/msm_cvp_res_parse.c
@@ -19,7 +19,6 @@
};
#define PERF_GOV "performance"
-#define DEFAULT_CVP_CLK_SVS2
static inline struct device *msm_iommu_get_ctx(const char *ctx_name)
{
@@ -329,14 +328,8 @@
/* A comparator to compare loads (needed later on) */
static int cmp(const void *a, const void *b)
{
-#ifdef DEFAULT_CVP_CLK_SVS2
return ((struct allowed_clock_rates_table *)a)->clock_rate -
((struct allowed_clock_rates_table *)b)->clock_rate;
-#else
- /* want to sort in reverse so flip the comparison */
- return ((struct allowed_clock_rates_table *)b)->clock_rate -
- ((struct allowed_clock_rates_table *)a)->clock_rate;
-#endif
}
static int msm_cvp_load_allowed_clocks_table(
diff --git a/drivers/media/platform/msm/cvp/msm_v4l2_private.c b/drivers/media/platform/msm/cvp/msm_v4l2_private.c
index 35196a3..40c3248 100644
--- a/drivers/media/platform/msm/cvp/msm_v4l2_private.c
+++ b/drivers/media/platform/msm/cvp/msm_v4l2_private.c
@@ -4,12 +4,69 @@
*/
#include "msm_v4l2_private.h"
+#include "cvp_hfi_api.h"
-static int convert_from_user(struct msm_cvp_arg *kp, unsigned long arg)
+static int _get_pkt_hdr_from_user(struct cvp_kmd_arg __user *up,
+ struct cvp_hal_session_cmd_pkt *pkt_hdr)
+{
+ struct cvp_kmd_hfi_packet *u;
+
+ u = &up->data.hfi_pkt;
+
+ if (get_user(pkt_hdr->size, &u->pkt_data[0]))
+ return -EFAULT;
+
+ if (get_user(pkt_hdr->packet_type, &u->pkt_data[1]))
+ return -EFAULT;
+
+ if (get_pkt_index(pkt_hdr) < 0)
+ return -EINVAL;
+
+ if (pkt_hdr->size > MAX_HFI_PKT_SIZE*sizeof(unsigned int))
+ return -EINVAL;
+
+ return 0;
+}
+
+/* Size is in unit of u32 */
+static int _copy_pkt_from_user(struct cvp_kmd_arg *kp,
+ struct cvp_kmd_arg __user *up,
+ unsigned int size)
+{
+ struct cvp_kmd_hfi_packet *k, *u;
+ int i;
+
+ k = &kp->data.hfi_pkt;
+ u = &up->data.hfi_pkt;
+ for (i = 0; i < size; i++)
+ if (get_user(k->pkt_data[i], &u->pkt_data[i]))
+ return -EFAULT;
+
+ return 0;
+}
+
+static int _copy_pkt_to_user(struct cvp_kmd_arg *kp,
+ struct cvp_kmd_arg __user *up,
+ unsigned int size)
+{
+ struct cvp_kmd_hfi_packet *k, *u;
+ int i;
+
+ k = &kp->data.hfi_pkt;
+ u = &up->data.hfi_pkt;
+ for (i = 0; i < size; i++)
+ if (put_user(k->pkt_data[i], &u->pkt_data[i]))
+ return -EFAULT;
+
+ return 0;
+}
+
+static int convert_from_user(struct cvp_kmd_arg *kp, unsigned long arg)
{
int rc = 0;
int i;
- struct msm_cvp_arg __user *up = compat_ptr(arg);
+ struct cvp_kmd_arg __user *up = compat_ptr(arg);
+ struct cvp_hal_session_cmd_pkt pkt_hdr;
if (!kp || !up) {
dprintk(CVP_ERR, "%s: invalid params\n", __func__);
@@ -20,9 +77,9 @@
return -EFAULT;
switch (kp->type) {
- case MSM_CVP_GET_SESSION_INFO:
+ case CVP_KMD_GET_SESSION_INFO:
{
- struct msm_cvp_session_info *k, *u;
+ struct cvp_kmd_session_info *k, *u;
k = &kp->data.session;
u = &up->data.session;
@@ -33,9 +90,9 @@
return -EFAULT;
break;
}
- case MSM_CVP_REQUEST_POWER:
+ case CVP_KMD_REQUEST_POWER:
{
- struct msm_cvp_request_power *k, *u;
+ struct cvp_kmd_request_power *k, *u;
k = &kp->data.req_power;
u = &up->data.req_power;
@@ -49,9 +106,9 @@
return -EFAULT;
break;
}
- case MSM_CVP_REGISTER_BUFFER:
+ case CVP_KMD_REGISTER_BUFFER:
{
- struct msm_cvp_buffer *k, *u;
+ struct cvp_kmd_buffer *k, *u;
k = &kp->data.regbuf;
u = &up->data.regbuf;
@@ -68,9 +125,9 @@
return -EFAULT;
break;
}
- case MSM_CVP_UNREGISTER_BUFFER:
+ case CVP_KMD_UNREGISTER_BUFFER:
{
- struct msm_cvp_buffer *k, *u;
+ struct cvp_kmd_buffer *k, *u;
k = &kp->data.unregbuf;
u = &up->data.unregbuf;
@@ -87,12 +144,10 @@
return -EFAULT;
break;
}
- case MSM_CVP_HFI_SEND_CMD:
+ case CVP_KMD_HFI_SEND_CMD:
{
- struct msm_cvp_send_cmd *k, *u;
+ struct cvp_kmd_send_cmd *k, *u;
- dprintk(CVP_DBG, "%s: MSM_CVP_HFI_SEND_CMD\n",
- __func__);
k = &kp->data.send_cmd;
u = &up->data.send_cmd;
if (get_user(k->cmd_address_fd, &u->cmd_address_fd) ||
@@ -103,79 +158,29 @@
return -EFAULT;
break;
}
- case MSM_CVP_HFI_DFS_CONFIG_CMD:
+ case CVP_KMD_SEND_CMD_PKT:
+ case CVP_KMD_HFI_DFS_CONFIG_CMD:
+ case CVP_KMD_HFI_DFS_FRAME_CMD:
+ case CVP_KMD_HFI_DME_CONFIG_CMD:
+ case CVP_KMD_HFI_DME_FRAME_CMD:
+ case CVP_KMD_HFI_PERSIST_CMD:
{
- struct msm_cvp_dfs_config *k, *u;
+ if (_get_pkt_hdr_from_user(up, &pkt_hdr)) {
+ dprintk(CVP_ERR, "Invalid syscall: %x, %x, %x\n",
+ kp->type, pkt_hdr.size, pkt_hdr.packet_type);
+ return -EFAULT;
+ }
- dprintk(CVP_DBG, "%s: MSM_CVP_HFI_DFS_CONFIG_CMD\n", __func__);
- k = &kp->data.dfs_config;
- u = &up->data.dfs_config;
- for (i = 0; i < CVP_DFS_CONFIG_CMD_SIZE; i++)
- if (get_user(k->cvp_dfs_config[i],
- &u->cvp_dfs_config[i]))
- return -EFAULT;
- break;
- }
- case MSM_CVP_HFI_DFS_FRAME_CMD:
- case MSM_CVP_HFI_DFS_FRAME_CMD_RESPONSE:
- {
- struct msm_cvp_dfs_frame *k, *u;
-
- dprintk(CVP_DBG, "%s: Type =%d\n", __func__, kp->type);
- k = &kp->data.dfs_frame;
- u = &up->data.dfs_frame;
- for (i = 0; i < CVP_DFS_FRAME_CMD_SIZE; i++)
- if (get_user(k->frame_data[i], &u->frame_data[i]))
- return -EFAULT;
-
- break;
- }
- case MSM_CVP_HFI_DME_CONFIG_CMD:
- {
- struct msm_cvp_dme_config *k, *u;
-
- dprintk(CVP_DBG, "%s: MSM_CVP_HFI_DFS_CONFIG_CMD\n", __func__);
- k = &kp->data.dme_config;
- u = &up->data.dme_config;
- for (i = 0; i < CVP_DME_CONFIG_CMD_SIZE; i++)
- if (get_user(k->cvp_dme_config[i],
- &u->cvp_dme_config[i]))
- return -EFAULT;
- break;
- }
- case MSM_CVP_HFI_DME_FRAME_CMD:
- case MSM_CVP_HFI_DME_FRAME_CMD_RESPONSE:
- {
- struct msm_cvp_dme_frame *k, *u;
-
- dprintk(CVP_DBG, "%s: type = %d\n",
- __func__, kp->type);
- k = &kp->data.dme_frame;
- u = &up->data.dme_frame;
-
- for (i = 0; i < CVP_DME_FRAME_CMD_SIZE; i++)
- if (get_user(k->frame_data[i], &u->frame_data[i]))
- return -EFAULT;
-
- break;
- }
- case MSM_CVP_HFI_PERSIST_CMD:
- case MSM_CVP_HFI_PERSIST_CMD_RESPONSE:
- {
- struct msm_cvp_persist_buf *k, *u;
-
- dprintk(CVP_DBG, "%s: type = %d\n",
- __func__, kp->type);
- k = &kp->data.pbuf_cmd;
- u = &up->data.pbuf_cmd;
-
- for (i = 0; i < CVP_PERSIST_CMD_SIZE; i++)
- if (get_user(k->persist_data[i], &u->persist_data[i]))
- return -EFAULT;
-
+ dprintk(CVP_DBG, "system call cmd pkt: %d 0x%x\n",
+ pkt_hdr.size, pkt_hdr.packet_type);
+ rc = _copy_pkt_from_user(kp, up, (pkt_hdr.size >> 2));
break;
}
+ case CVP_KMD_HFI_DFS_FRAME_CMD_RESPONSE:
+ case CVP_KMD_HFI_DME_FRAME_CMD_RESPONSE:
+ case CVP_KMD_HFI_PERSIST_CMD_RESPONSE:
+ break;
default:
dprintk(CVP_ERR, "%s: unknown cmd type 0x%x\n",
__func__, kp->type);
@@ -186,11 +191,12 @@
return rc;
}
-static int convert_to_user(struct msm_cvp_arg *kp, unsigned long arg)
+static int convert_to_user(struct cvp_kmd_arg *kp, unsigned long arg)
{
int rc = 0;
int i;
- struct msm_cvp_arg __user *up = compat_ptr(arg);
+ struct cvp_kmd_arg __user *up = compat_ptr(arg);
+ struct cvp_hal_session_cmd_pkt pkt_hdr;
if (!kp || !up) {
dprintk(CVP_ERR, "%s: invalid params\n", __func__);
@@ -201,9 +207,11 @@
return -EFAULT;
switch (kp->type) {
- case MSM_CVP_GET_SESSION_INFO:
+ case CVP_KMD_RECEIVE_MSG_PKT:
+ break;
+ case CVP_KMD_GET_SESSION_INFO:
{
- struct msm_cvp_session_info *k, *u;
+ struct cvp_kmd_session_info *k, *u;
k = &kp->data.session;
u = &up->data.session;
@@ -214,9 +222,9 @@
return -EFAULT;
break;
}
- case MSM_CVP_REQUEST_POWER:
+ case CVP_KMD_REQUEST_POWER:
{
- struct msm_cvp_request_power *k, *u;
+ struct cvp_kmd_request_power *k, *u;
k = &kp->data.req_power;
u = &up->data.req_power;
@@ -230,9 +238,9 @@
return -EFAULT;
break;
}
- case MSM_CVP_REGISTER_BUFFER:
+ case CVP_KMD_REGISTER_BUFFER:
{
- struct msm_cvp_buffer *k, *u;
+ struct cvp_kmd_buffer *k, *u;
k = &kp->data.regbuf;
u = &up->data.regbuf;
@@ -249,9 +257,9 @@
return -EFAULT;
break;
}
- case MSM_CVP_UNREGISTER_BUFFER:
+ case CVP_KMD_UNREGISTER_BUFFER:
{
- struct msm_cvp_buffer *k, *u;
+ struct cvp_kmd_buffer *k, *u;
k = &kp->data.unregbuf;
u = &up->data.unregbuf;
@@ -268,11 +276,11 @@
return -EFAULT;
break;
}
- case MSM_CVP_HFI_SEND_CMD:
+ case CVP_KMD_HFI_SEND_CMD:
{
- struct msm_cvp_send_cmd *k, *u;
+ struct cvp_kmd_send_cmd *k, *u;
- dprintk(CVP_DBG, "%s: MSM_CVP_HFI_SEND_CMD\n",
+ dprintk(CVP_DBG, "%s: CVP_KMD_HFI_SEND_CMD\n",
__func__);
k = &kp->data.send_cmd;
@@ -285,80 +293,22 @@
return -EFAULT;
break;
}
- case MSM_CVP_HFI_DFS_CONFIG_CMD:
+ case CVP_KMD_SEND_CMD_PKT:
+ case CVP_KMD_HFI_DFS_CONFIG_CMD:
+ case CVP_KMD_HFI_DFS_FRAME_CMD:
+ case CVP_KMD_HFI_DFS_FRAME_CMD_RESPONSE:
+ case CVP_KMD_HFI_DME_CONFIG_CMD:
+ case CVP_KMD_HFI_DME_FRAME_CMD:
+ case CVP_KMD_HFI_DME_FRAME_CMD_RESPONSE:
+ case CVP_KMD_HFI_PERSIST_CMD:
+ case CVP_KMD_HFI_PERSIST_CMD_RESPONSE:
{
- struct msm_cvp_dfs_config *k, *u;
+ if (_get_pkt_hdr_from_user(up, &pkt_hdr))
+ return -EFAULT;
- dprintk(CVP_DBG, "%s: MSM_CVP_HFI_DFS_CONFIG_CMD\n",
- __func__);
-
- k = &kp->data.dfs_config;
- u = &up->data.dfs_config;
- for (i = 0; i < CVP_DFS_CONFIG_CMD_SIZE; i++)
- if (put_user(k->cvp_dfs_config[i],
- &u->cvp_dfs_config[i]))
- return -EFAULT;
- break;
- }
- case MSM_CVP_HFI_DFS_FRAME_CMD:
- case MSM_CVP_HFI_DFS_FRAME_CMD_RESPONSE:
- {
- struct msm_cvp_dfs_frame *k, *u;
-
- dprintk(CVP_DBG, "%s: type = %d\n",
- __func__, kp->type);
- k = &kp->data.dfs_frame;
- u = &up->data.dfs_frame;
-
- for (i = 0; i < CVP_DFS_FRAME_CMD_SIZE; i++)
- if (put_user(k->frame_data[i], &u->frame_data[i]))
- return -EFAULT;
-
- break;
- }
- case MSM_CVP_HFI_DME_CONFIG_CMD:
- {
- struct msm_cvp_dme_config *k, *u;
-
- dprintk(CVP_DBG, "%s: MSM_CVP_HFI_DME_CONFIG_CMD\n", __func__);
- k = &kp->data.dme_config;
- u = &up->data.dme_config;
- for (i = 0; i < CVP_DME_CONFIG_CMD_SIZE; i++)
- if (put_user(k->cvp_dme_config[i],
- &u->cvp_dme_config[i]))
- return -EFAULT;
- break;
- }
- case MSM_CVP_HFI_DME_FRAME_CMD:
- case MSM_CVP_HFI_DME_FRAME_CMD_RESPONSE:
- {
- struct msm_cvp_dme_frame *k, *u;
-
- dprintk(CVP_DBG, "%s: type = %d\n",
- __func__, kp->type);
- k = &kp->data.dme_frame;
- u = &up->data.dme_frame;
-
- for (i = 0; i < CVP_DME_FRAME_CMD_SIZE; i++)
- if (put_user(k->frame_data[i], &u->frame_data[i]))
- return -EFAULT;
-
- break;
- }
- case MSM_CVP_HFI_PERSIST_CMD:
- case MSM_CVP_HFI_PERSIST_CMD_RESPONSE:
- {
- struct msm_cvp_persist_buf *k, *u;
-
- dprintk(CVP_DBG, "%s: type = %d\n",
- __func__, kp->type);
- k = &kp->data.pbuf_cmd;
- u = &up->data.pbuf_cmd;
-
- for (i = 0; i < CVP_PERSIST_CMD_SIZE; i++)
- if (put_user(k->persist_data[i], &u->persist_data[i]))
- return -EFAULT;
-
+ dprintk(CVP_DBG, "Send user cmd pkt: %d %d\n",
+ pkt_hdr.size, pkt_hdr.packet_type);
+ rc = _copy_pkt_to_user(kp, up, (pkt_hdr.size >> 2));
break;
}
default:
@@ -376,7 +326,7 @@
{
int rc;
struct msm_cvp_inst *inst;
- struct msm_cvp_arg karg;
+ struct cvp_kmd_arg karg;
if (!filp || !filp->private_data) {
dprintk(CVP_ERR, "%s: invalid params\n", __func__);
@@ -385,15 +335,18 @@
inst = container_of(filp->private_data, struct msm_cvp_inst,
event_handler);
- memset(&karg, 0, sizeof(struct msm_cvp_arg));
+ memset(&karg, 0, sizeof(struct cvp_kmd_arg));
/*
* the arg points to user space memory and needs
* to be converted to kernel space before using it.
* Check do_video_ioctl() for more details.
*/
- if (convert_from_user(&karg, arg))
+ if (convert_from_user(&karg, arg)) {
+ dprintk(CVP_ERR, "%s: failed to get from user cmd %x\n",
+ __func__, karg.type);
return -EFAULT;
+ }
rc = msm_cvp_private((void *)inst, cmd, &karg);
if (rc) {
diff --git a/include/uapi/media/msm_cvp_private.h b/include/uapi/media/msm_cvp_private.h
index 7eb1166..1200c5c 100644
--- a/include/uapi/media/msm_cvp_private.h
+++ b/include/uapi/media/msm_cvp_private.h
@@ -12,91 +12,103 @@
/* VIDIOC private cvp command */
#define VIDIOC_CVP_CMD \
- _IOWR('V', BASE_VIDIOC_PRIVATE_CVP, struct msm_cvp_arg)
+ _IOWR('V', BASE_VIDIOC_PRIVATE_CVP, struct cvp_kmd_arg)
/* Commands type */
-#define MSM_VIDC_CMD_START 0x10000000
-#define MSM_CVP_CMD_START (MSM_VIDC_CMD_START + 0x1000)
+#define CVP_KMD_CMD_BASE 0x10000000
+#define CVP_KMD_CMD_START (CVP_KMD_CMD_BASE + 0x1000)
/*
* userspace clients pass one of the below arguments type
- * in struct msm_cvp_arg (@type field).
+ * in struct cvp_kmd_arg (@type field).
*/
/*
- * MSM_CVP_GET_SESSION_INFO - this argument type is used to
+ * CVP_KMD_GET_SESSION_INFO - this argument type is used to
* get the session information from driver. it passes
- * struct msm_cvp_session_info {}
+ * struct cvp_kmd_session_info {}
*/
-#define MSM_CVP_GET_SESSION_INFO (MSM_CVP_CMD_START + 1)
+#define CVP_KMD_GET_SESSION_INFO (CVP_KMD_CMD_START + 1)
/*
- * MSM_CVP_REQUEST_POWER - this argument type is used to
+ * CVP_KMD_REQUEST_POWER - this argument type is used to
* set the power required to driver. it passes
- * struct msm_cvp_request_power {}
+ * struct cvp_kmd_request_power {}
*/
-#define MSM_CVP_REQUEST_POWER (MSM_CVP_CMD_START + 2)
+#define CVP_KMD_REQUEST_POWER (CVP_KMD_CMD_START + 2)
/*
- * MSM_CVP_REGISTER_BUFFER - this argument type is used to
+ * CVP_KMD_REGISTER_BUFFER - this argument type is used to
* register the buffer to driver. it passes
- * struct msm_cvp_buffer {}
+ * struct cvp_kmd_buffer {}
*/
-#define MSM_CVP_REGISTER_BUFFER (MSM_CVP_CMD_START + 3)
+#define CVP_KMD_REGISTER_BUFFER (CVP_KMD_CMD_START + 3)
/*
- * MSM_CVP_REGISTER_BUFFER - this argument type is used to
+ * CVP_KMD_REGISTER_BUFFER - this argument type is used to
* unregister the buffer to driver. it passes
- * struct msm_cvp_buffer {}
+ * struct cvp_kmd_buffer {}
*/
-#define MSM_CVP_UNREGISTER_BUFFER (MSM_CVP_CMD_START + 4)
+#define CVP_KMD_UNREGISTER_BUFFER (CVP_KMD_CMD_START + 4)
-#define MSM_CVP_HFI_SEND_CMD (MSM_CVP_CMD_START + 5)
+#define CVP_KMD_HFI_SEND_CMD (CVP_KMD_CMD_START + 5)
-#define MSM_CVP_HFI_DFS_CONFIG_CMD (MSM_CVP_CMD_START + 6)
+#define CVP_KMD_HFI_DFS_CONFIG_CMD (CVP_KMD_CMD_START + 6)
-#define MSM_CVP_HFI_DFS_FRAME_CMD (MSM_CVP_CMD_START + 7)
+#define CVP_KMD_HFI_DFS_FRAME_CMD (CVP_KMD_CMD_START + 7)
-#define MSM_CVP_HFI_DFS_FRAME_CMD_RESPONSE (MSM_CVP_CMD_START + 8)
+#define CVP_KMD_HFI_DFS_FRAME_CMD_RESPONSE (CVP_KMD_CMD_START + 8)
-#define MSM_CVP_HFI_DME_CONFIG_CMD (MSM_CVP_CMD_START + 9)
+#define CVP_KMD_HFI_DME_CONFIG_CMD (CVP_KMD_CMD_START + 9)
-#define MSM_CVP_HFI_DME_FRAME_CMD (MSM_CVP_CMD_START + 10)
+#define CVP_KMD_HFI_DME_FRAME_CMD (CVP_KMD_CMD_START + 10)
-#define MSM_CVP_HFI_DME_FRAME_CMD_RESPONSE (MSM_CVP_CMD_START + 11)
+#define CVP_KMD_HFI_DME_FRAME_CMD_RESPONSE (CVP_KMD_CMD_START + 11)
-#define MSM_CVP_HFI_PERSIST_CMD (MSM_CVP_CMD_START + 12)
+#define CVP_KMD_HFI_PERSIST_CMD (CVP_KMD_CMD_START + 12)
-#define MSM_CVP_HFI_PERSIST_CMD_RESPONSE (MSM_CVP_CMD_START + 13)
+#define CVP_KMD_HFI_PERSIST_CMD_RESPONSE (CVP_KMD_CMD_START + 13)
+
+#define CVP_KMD_HFI_DME_FRAME_FENCE_CMD (CVP_KMD_CMD_START + 14)
+
+#define CVP_KMD_SEND_CMD_PKT (CVP_KMD_CMD_START + 64)
+
+#define CVP_KMD_RECEIVE_MSG_PKT (CVP_KMD_CMD_START + 65)
+
+#define CVP_KMD_SET_SYS_PROPERTY (CVP_KMD_CMD_START + 66)
+
+#define CVP_KMD_GET_SYS_PROPERTY (CVP_KMD_CMD_START + 67)
+
+#define CVP_KMD_SESSION_CONTROL (CVP_KMD_CMD_START + 68)
/* flags */
-#define MSM_CVP_FLAG_UNSECURE 0x00000000
-#define MSM_CVP_FLAG_SECURE 0x00000001
+#define CVP_KMD_FLAG_UNSECURE 0x00000000
+#define CVP_KMD_FLAG_SECURE 0x00000001
/* buffer type */
-#define MSM_CVP_BUFTYPE_INPUT 0x00000001
-#define MSM_CVP_BUFTYPE_OUTPUT 0x00000002
-#define MSM_CVP_BUFTYPE_INTERNAL_1 0x00000003
-#define MSM_CVP_BUFTYPE_INTERNAL_2 0x00000004
+#define CVP_KMD_BUFTYPE_INPUT 0x00000001
+#define CVP_KMD_BUFTYPE_OUTPUT 0x00000002
+#define CVP_KMD_BUFTYPE_INTERNAL_1 0x00000003
+#define CVP_KMD_BUFTYPE_INTERNAL_2 0x00000004
/**
- * struct msm_cvp_session_info - session information
+ * struct cvp_kmd_session_info - session information
* @session_id: current session id
*/
-struct msm_cvp_session_info {
+struct cvp_kmd_session_info {
unsigned int session_id;
unsigned int reserved[10];
};
/**
- * struct msm_cvp_request_power - power / clock data information
+ * struct cvp_kmd_request_power - power / clock data information
* @clock_cycles_a: clock cycles per second required for hardware_a
* @clock_cycles_b: clock cycles per second required for hardware_b
* @ddr_bw: bandwidth required for ddr in bps
* @sys_cache_bw: bandwidth required for system cache in bps
*/
-struct msm_cvp_request_power {
+struct cvp_kmd_request_power {
unsigned int clock_cycles_a;
unsigned int clock_cycles_b;
unsigned int ddr_bw;
@@ -105,7 +117,7 @@
};
/**
- * struct msm_cvp_buffer - buffer information to be registered
+ * struct cvp_kmd_buffer - buffer information to be registered
* @index: index of buffer
* @type: buffer type
* @fd: file descriptor of buffer
@@ -114,7 +126,7 @@
* @pixelformat: fourcc format
* @flags: buffer flags
*/
-struct msm_cvp_buffer {
+struct cvp_kmd_buffer {
unsigned int index;
unsigned int type;
unsigned int fd;
@@ -126,42 +138,42 @@
};
/**
- * struct msm_cvp_send_cmd - sending generic HFI command
+ * struct cvp_kmd_send_cmd - sending generic HFI command
* @cmd_address_fd: file descriptor of cmd_address
* @cmd_size: allocated size of buffer
*/
-struct msm_cvp_send_cmd {
+struct cvp_kmd_send_cmd {
unsigned int cmd_address_fd;
unsigned int cmd_size;
unsigned int reserved[10];
};
/**
- * struct msm_cvp_color_plane_info - color plane info
+ * struct cvp_kmd_color_plane_info - color plane info
* @stride: stride of plane
* @buf_size: size of plane
*/
-struct msm_cvp_color_plane_info {
+struct cvp_kmd_color_plane_info {
int stride[HFI_MAX_PLANES];
unsigned int buf_size[HFI_MAX_PLANES];
};
/**
- * struct msm_cvp_client_data - store generic client
+ * struct cvp_kmd_client_data - store generic client
* data
* @transactionid: transaction id
* @client_data1: client data to be used during callback
* @client_data2: client data to be used during callback
*/
-struct msm_cvp_client_data {
+struct cvp_kmd_client_data {
unsigned int transactionid;
unsigned int client_data1;
unsigned int client_data2;
};
#define CVP_COLOR_PLANE_INFO_SIZE \
- sizeof(struct msm_cvp_color_plane_info)
-#define CVP_CLIENT_DATA_SIZE sizeof(struct msm_cvp_client_data)
+ sizeof(struct cvp_kmd_color_plane_info)
+#define CVP_CLIENT_DATA_SIZE sizeof(struct cvp_kmd_client_data)
#define CVP_DFS_CONFIG_CMD_SIZE 38
#define CVP_DFS_FRAME_CMD_SIZE 16
#define CVP_DFS_FRAME_BUFFERS_OFFSET 8
@@ -175,29 +187,56 @@
#define CVP_PERSIST_BUFFERS_OFFSET 7
#define CVP_PSRSIST_BUF_NUM 2
-struct msm_cvp_dfs_config {
+struct cvp_kmd_dfs_config {
unsigned int cvp_dfs_config[CVP_DFS_CONFIG_CMD_SIZE];
};
-struct msm_cvp_dfs_frame {
+struct cvp_kmd_dfs_frame {
unsigned int frame_data[CVP_DFS_FRAME_CMD_SIZE];
};
-struct msm_cvp_dme_config {
+struct cvp_kmd_dme_config {
unsigned int cvp_dme_config[CVP_DME_CONFIG_CMD_SIZE];
};
-struct msm_cvp_dme_frame {
+struct cvp_kmd_dme_frame {
unsigned int frame_data[CVP_DME_FRAME_CMD_SIZE];
};
-struct msm_cvp_persist_buf {
+struct cvp_kmd_persist_buf {
unsigned int persist_data[CVP_PERSIST_CMD_SIZE];
};
+#define MAX_HFI_PKT_SIZE 250
+
+struct cvp_kmd_hfi_packet {
+ unsigned int pkt_data[MAX_HFI_PKT_SIZE];
+};
+
+struct cvp_kmd_sys_property {
+ unsigned int prop_type;
+ unsigned int data;
+};
+
+struct cvp_kmd_sys_properties {
+ unsigned int prop_num;
+ struct cvp_kmd_sys_property prop_data;
+};
+
+#define MAX_HFI_FENCE_SIZE 16
+#define MAX_HFI_FENCE_OFFSET (MAX_HFI_PKT_SIZE-MAX_HFI_FENCE_SIZE)
+struct cvp_kmd_hfi_fence_packet {
+ unsigned int pkt_data[MAX_HFI_FENCE_OFFSET];
+ unsigned int fence_data[MAX_HFI_FENCE_SIZE];
+};
+
+
/**
- * struct msm_cvp_arg - argument passed with VIDIOC_CVP_CMD
+ * struct cvp_kmd_arg - argument passed with VIDIOC_CVP_CMD
+ * To be deprecated
* @type: command type
+ * @buf_offset: offset to buffer list in the command
+ * @buf_num: number of buffers in the command
* @session: session information
* @req_power: power information
* @regbuf: buffer to be registered
@@ -205,22 +244,28 @@
* @send_cmd: sending generic HFI command
* @dfs_config: sending DFS config command
* @dfs_frame: sending DFS frame command
+ * @hfi_pkt: HFI packet created by user library
+ * @sys_properties System properties read or set by user library
+ * @hfi_fence_pkt: HFI fence packet created by user library
*/
-struct msm_cvp_arg {
+struct cvp_kmd_arg {
unsigned int type;
- union data_t {
- struct msm_cvp_session_info session;
- struct msm_cvp_request_power req_power;
- struct msm_cvp_buffer regbuf;
- struct msm_cvp_buffer unregbuf;
- struct msm_cvp_send_cmd send_cmd;
- struct msm_cvp_dfs_config dfs_config;
- struct msm_cvp_dfs_frame dfs_frame;
- struct msm_cvp_dme_config dme_config;
- struct msm_cvp_dme_frame dme_frame;
- struct msm_cvp_persist_buf pbuf_cmd;
+ unsigned int buf_offset;
+ unsigned int buf_num;
+ union cvp_data_t {
+ struct cvp_kmd_session_info session;
+ struct cvp_kmd_request_power req_power;
+ struct cvp_kmd_buffer regbuf;
+ struct cvp_kmd_buffer unregbuf;
+ struct cvp_kmd_send_cmd send_cmd;
+ struct cvp_kmd_dfs_config dfs_config;
+ struct cvp_kmd_dfs_frame dfs_frame;
+ struct cvp_kmd_dme_config dme_config;
+ struct cvp_kmd_dme_frame dme_frame;
+ struct cvp_kmd_persist_buf pbuf_cmd;
+ struct cvp_kmd_hfi_packet hfi_pkt;
+ struct cvp_kmd_sys_properties sys_properties;
+ struct cvp_kmd_hfi_fence_packet hfi_fence_pkt;
} data;
- unsigned int reserved[12];
};
-
#endif