Merge "msm: camera: Add sensor stats type"
diff --git a/drivers/media/platform/msm/vidc/msm_vidc_common.c b/drivers/media/platform/msm/vidc/msm_vidc_common.c
index 84b0780..8176b06 100755
--- a/drivers/media/platform/msm/vidc/msm_vidc_common.c
+++ b/drivers/media/platform/msm/vidc/msm_vidc_common.c
@@ -3164,6 +3164,40 @@
mutex_unlock(&inst->lock);
}
+void msm_comm_flush_pending_dynamic_buffers(struct msm_vidc_inst *inst)
+{
+ struct buffer_info *binfo = NULL;
+ struct list_head *list = NULL;
+
+ if (!inst)
+ return;
+
+ if (inst->buffer_mode_set[CAPTURE_PORT] != HAL_BUFFER_MODE_DYNAMIC)
+ return;
+
+ if (list_empty(&inst->pendingq) || list_empty(&inst->registered_bufs))
+ return;
+
+ list = &inst->registered_bufs;
+
+ /*
+ * Dynamic Buffer mode - Since pendingq is not empty
+ * no output buffers have been sent to firmware yet.
+ * Hence remove reference to all pendingq o/p buffers
+ * before flushing them.
+ */
+
+ list_for_each_entry(binfo, list, list) {
+ if (binfo && binfo->type ==
+ V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE) {
+ dprintk(VIDC_DBG,
+ "%s: binfo = %p device_addr = 0x%pa\n",
+ __func__, binfo, &binfo->device_addr[0]);
+ buf_ref_put(inst, binfo);
+ }
+ }
+}
+
int msm_comm_flush(struct msm_vidc_inst *inst, u32 flags)
{
int rc = 0;
@@ -3229,6 +3263,8 @@
} else {
if (!list_empty(&inst->pendingq)) {
+ msm_comm_flush_pending_dynamic_buffers(inst);
+
/*If flush is called after queueing buffers but before
* streamon driver should flush the pending queue*/
list_for_each_safe(ptr, next, &inst->pendingq) {
diff --git a/drivers/misc/qseecom.c b/drivers/misc/qseecom.c
index 7c20d1e..9d294f0 100644
--- a/drivers/misc/qseecom.c
+++ b/drivers/misc/qseecom.c
@@ -116,6 +116,7 @@
struct list_head list;
u32 app_id;
u32 ref_cnt;
+ char app_name[MAX_APP_NAME_SIZE];
};
struct qseecom_registered_kclient_list {
@@ -185,6 +186,7 @@
uint32_t user_virt_sb_base;
size_t sb_length;
struct ion_handle *ihandle; /* Retrieve phy addr */
+ char app_name[MAX_APP_NAME_SIZE];
};
struct qseecom_listener_handle {
@@ -999,7 +1001,9 @@
}
entry->app_id = app_id;
entry->ref_cnt = 1;
-
+ memset((void *)entry->app_name, 0, MAX_APP_NAME_SIZE);
+ memcpy((void *)entry->app_name,
+ (void *)load_img_req.img_name, MAX_APP_NAME_SIZE);
/* Deallocate the handle */
if (!IS_ERR_OR_NULL(ihandle))
ion_free(qseecom.ion_clnt, ihandle);
@@ -1013,6 +1017,9 @@
(char *)(load_img_req.img_name));
}
data->client.app_id = app_id;
+ memset((void *)data->client.app_name, 0, MAX_APP_NAME_SIZE);
+ memcpy((void *)data->client.app_name,
+ (void *)load_img_req.img_name, MAX_APP_NAME_SIZE);
load_img_req.app_id = app_id;
if (copy_to_user(argp, &load_img_req, sizeof(load_img_req))) {
pr_err("copy_to_user failed\n");
@@ -1061,53 +1068,55 @@
bool app_crash)
{
unsigned long flags;
+ unsigned long flags1;
int ret = 0;
struct qseecom_command_scm_resp resp;
- struct qseecom_registered_app_list *ptr_app;
+ struct qseecom_registered_app_list *ptr_app = NULL;
bool unload = false;
bool found_app = false;
+ bool found_dead_app = false;
+
+ if (!memcmp(data->client.app_name, "keymaste", strlen("keymaste"))) {
+ pr_warn("Do not unload keymaster app from tz\n");
+ return 0;
+ }
if (data->client.app_id > 0) {
spin_lock_irqsave(&qseecom.registered_app_list_lock, flags);
list_for_each_entry(ptr_app, &qseecom.registered_app_list_head,
list) {
if (ptr_app->app_id == data->client.app_id) {
- found_app = true;
- if (app_crash) {
- ptr_app->ref_cnt = 0;
- unload = true;
+ if (!memcmp((void *)ptr_app->app_name,
+ (void *)data->client.app_name,
+ strlen(data->client.app_name))) {
+ found_app = true;
+ if (app_crash || ptr_app->ref_cnt == 1)
+ unload = true;
break;
} else {
- if (ptr_app->ref_cnt == 1) {
- unload = true;
- break;
- } else {
- ptr_app->ref_cnt--;
- pr_debug("Can't unload app(%d) inuse\n",
- ptr_app->app_id);
- break;
- }
+ found_dead_app = true;
+ break;
}
}
}
spin_unlock_irqrestore(&qseecom.registered_app_list_lock,
flags);
- if (found_app == false) {
- pr_err("Cannot find app with id = %d\n",
- data->client.app_id);
+ if (found_app == false && found_dead_app == false) {
+ pr_err("Cannot find app with id = %d (%s)\n",
+ data->client.app_id,
+ (char *)data->client.app_name);
return -EINVAL;
}
}
+ if (found_dead_app) {
+ pr_warn("cleanup app_id %d(%s)\n", data->client.app_id,
+ (char *)data->client.app_name);
+ __qseecom_cleanup_app(data);
+ }
+
if (unload) {
struct qseecom_unload_app_ireq req;
-
- __qseecom_cleanup_app(data);
- spin_lock_irqsave(&qseecom.registered_app_list_lock, flags);
- list_del(&ptr_app->list);
- kzfree(ptr_app);
- spin_unlock_irqrestore(&qseecom.registered_app_list_lock,
- flags);
/* Populate the structure for sending scm call to load image */
req.qsee_cmd_id = QSEOS_APP_SHUTDOWN_COMMAND;
req.app_id = data->client.app_id;
@@ -1123,6 +1132,15 @@
} else {
pr_warn("App id %d now unloaded\n", req.app_id);
}
+ if (resp.result == QSEOS_RESULT_FAILURE) {
+ pr_err("app (%d) unload_failed!!\n",
+ data->client.app_id);
+ return -EFAULT;
+ }
+ if (resp.result == QSEOS_RESULT_SUCCESS)
+ pr_info("App (%d) is unloaded!!\n",
+ data->client.app_id);
+ __qseecom_cleanup_app(data);
if (resp.result == QSEOS_RESULT_INCOMPLETE) {
ret = __qseecom_process_incomplete_cmd(data, &resp);
if (ret) {
@@ -1132,6 +1150,29 @@
}
}
}
+
+ if (found_app) {
+ spin_lock_irqsave(&qseecom.registered_app_list_lock, flags1);
+ if (app_crash) {
+ ptr_app->ref_cnt = 0;
+ pr_debug("app_crash: ref_count = 0\n");
+ } else {
+ if (ptr_app->ref_cnt == 1) {
+ ptr_app->ref_cnt = 0;
+ pr_info("ref_count set to 0\n");
+ } else {
+ ptr_app->ref_cnt--;
+ pr_info("Can't unload app(%d) inuse\n",
+ ptr_app->app_id);
+ }
+ }
+ if (unload) {
+ list_del(&ptr_app->list);
+ kzfree(ptr_app);
+ }
+ spin_unlock_irqrestore(&qseecom.registered_app_list_lock,
+ flags1);
+ }
qseecom_unmap_ion_allocated_memory(data);
data->released = true;
return ret;
@@ -1326,6 +1367,9 @@
u32 reqd_len_sb_in = 0;
struct qseecom_client_send_data_ireq send_data_req;
struct qseecom_command_scm_resp resp;
+ unsigned long flags;
+ struct qseecom_registered_app_list *ptr_app;
+ bool found_app = false;
if (req->cmd_req_buf == NULL || req->resp_buf == NULL) {
pr_err("cmd buffer or response buffer is null\n");
@@ -1367,6 +1411,26 @@
return -ENOMEM;
}
+ /* find app_id & img_name from list */
+ spin_lock_irqsave(&qseecom.registered_app_list_lock, flags);
+ list_for_each_entry(ptr_app, &qseecom.registered_app_list_head,
+ list) {
+ if ((ptr_app->app_id == data->client.app_id) &&
+ (!memcmp((void *)ptr_app->app_name,
+ (void *)data->client.app_name,
+ strlen(data->client.app_name)))) {
+ found_app = true;
+ break;
+ }
+ }
+ spin_unlock_irqrestore(&qseecom.registered_app_list_lock, flags);
+
+ if (!found_app) {
+ pr_err("app_id %d (%s) is not found\n", data->client.app_id,
+ (char *)data->client.app_name);
+ return -EINVAL;
+ }
+
send_data_req.qsee_cmd_id = QSEOS_CLIENT_SEND_DATA_COMMAND;
send_data_req.app_id = data->client.app_id;
send_data_req.req_ptr = (void *)(__qseecom_uvirt_to_kphys(data,
@@ -2841,7 +2905,9 @@
&qseecom.registered_app_list_lock, flags);
data->client.app_id = ret;
query_req.app_id = ret;
-
+ memset((void *)data->client.app_name, 0, MAX_APP_NAME_SIZE);
+ memcpy((void *)data->client.app_name,
+ (void *)query_req.app_name, MAX_APP_NAME_SIZE);
if (copy_to_user(argp, &query_req, sizeof(query_req))) {
pr_err("copy_to_user failed\n");
return -EFAULT;
@@ -3516,7 +3582,6 @@
ret = -EINVAL;
break;
}
- data->type = QSEECOM_CLIENT_APP;
pr_debug("SET_MEM_PARAM: qseecom addr = 0x%x\n", (u32)data);
ret = qseecom_set_client_mem_param(data, argp);
if (ret)
@@ -3850,6 +3915,7 @@
data->abort = 0;
data->type = QSEECOM_GENERIC;
data->released = false;
+ memset((void *)data->client.app_name, 0, MAX_APP_NAME_SIZE);
data->mode = INACTIVE;
init_waitqueue_head(&data->abort_wq);
atomic_set(&data->ioctl_count, 0);
diff --git a/drivers/platform/msm/qpnp-pwm.c b/drivers/platform/msm/qpnp-pwm.c
index 588afc6..80b0892 100644
--- a/drivers/platform/msm/qpnp-pwm.c
+++ b/drivers/platform/msm/qpnp-pwm.c
@@ -136,12 +136,6 @@
(value |= (BIT(id) >> QPNP_RAMP_CONTROL_SHIFT)); \
} while (0)
-#define QPNP_DISABLE_LUT_V1(value, id) \
-do { \
- (id < 8) ? (value &= ~BIT(id)) : \
- (value &= (~BIT(id) >> QPNP_RAMP_CONTROL_SHIFT)); \
-} while (0)
-
/* LPG Control for RAMP_STEP_DURATION_LSB */
#define QPNP_RAMP_STEP_DURATION_LSB_MASK 0xFF
@@ -1018,7 +1012,6 @@
QPNP_ENABLE_LUT_V1(value1, pwm->pwm_config.channel_id);
value2 = QPNP_ENABLE_LPG_MODE;
} else {
- QPNP_DISABLE_LUT_V1(value1, pwm->pwm_config.channel_id);
value2 = QPNP_DISABLE_LPG_MODE;
}
mask1 = value1;
@@ -1038,8 +1031,10 @@
if (rc)
return rc;
- return qpnp_lpg_save_and_write(value1, mask1, reg1,
+ if (state == QPNP_LUT_ENABLE || chip->revision == QPNP_LPG_REVISION_0)
+ rc = qpnp_lpg_save_and_write(value1, mask1, reg1,
addr1, 1, chip);
+ return rc;
}
static inline int qpnp_enable_pwm_mode(struct qpnp_pwm_config *pwm_conf)