/*lint -e666*/ static ssize_t vsync_show_event(struct device *dev, struct device_attribute *attr, char *buf) { ssize_t ret = 0; struct fb_info *fbi = NULL; struct hisi_fb_data_type *hisifd = NULL; ktime_t prev_timestamp; BUG_ON(dev == NULL); fbi = dev_get_drvdata(dev); BUG_ON(fbi == NULL); hisifd = (struct hisi_fb_data_type *)fbi->par; BUG_ON(hisifd == NULL); prev_timestamp = hisifd->vsync_ctrl.vsync_timestamp; ret = wait_event_interruptible( hisifd->vsync_ctrl.vsync_wait, vsync_timestamp_changed(hisifd, prev_timestamp) && hisifd->vsync_ctrl.vsync_enabled); /*if (ret == 0) { HISI_FB_ERR("wait vsync timeout!"); return -ETIMEDOUT; }*/ if (ret == 0) { ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu", ktime_to_ns(hisifd->vsync_ctrl.vsync_timestamp)); buf[strlen(buf) + 1] = '\0'; } return ret; }
static int wait_for_vsync_thread(void *data) { struct hisi_fb_data_type *hisifd = (struct hisi_fb_data_type *)data; ktime_t prev_timestamp; int ret = 0; while (!kthread_should_stop()) { prev_timestamp = hisifd->vsync_ctrl.vsync_timestamp; ret = wait_event_interruptible_timeout( hisifd->vsync_ctrl.vsync_wait, vsync_timestamp_changed(hisifd, prev_timestamp) && hisifd->vsync_ctrl.vsync_enabled, msecs_to_jiffies(VSYNC_TIMEOUT_MSEC)); /*if (ret == 0) { HISI_FB_ERR("wait vsync timeout!"); return -ETIMEDOUT; }*/ if (ret > 0) { char *envp[2]; char buf[64]; /* fb%d_VSYNC=%llu */ snprintf(buf, sizeof(buf), "VSYNC=%llu", ktime_to_ns(hisifd->vsync_ctrl.vsync_timestamp)); envp[0] = buf; envp[1] = NULL; kobject_uevent_env(&hisifd->pdev->dev.kobj, KOBJ_CHANGE, envp); } } return 0; }
static ssize_t vsync_show_event(struct device *dev, struct device_attribute *attr, char *buf) { ssize_t ret = 0; int vsync_flag = 0; int secure_flag = 0; struct fb_info *fbi = NULL; struct hisi_fb_data_type *hisifd = NULL; struct hisifb_secure *secure_ctrl = NULL; ktime_t prev_timestamp; if (NULL == dev) { HISI_FB_ERR("NULL Pointer.\n"); return 0; } fbi = dev_get_drvdata(dev); if (NULL == fbi) { HISI_FB_ERR("NULL Pointer.\n"); return 0; } hisifd = (struct hisi_fb_data_type *)fbi->par; if (NULL == hisifd) { HISI_FB_ERR("NULL Pointer.\n"); return 0; } secure_ctrl = &(hisifd->secure_ctrl); if (NULL == secure_ctrl) { HISI_FB_ERR("NULL Pointer.\n"); return 0; } if (NULL == buf) { HISI_FB_ERR("NULL Pointer.\n"); return 0; } prev_timestamp = hisifd->vsync_ctrl.vsync_timestamp; /*lint -e666*/ ret = wait_event_interruptible(hisifd->vsync_ctrl.vsync_wait, (vsync_timestamp_changed(hisifd, prev_timestamp) && hisifd->vsync_ctrl.vsync_enabled) || (secure_ctrl->tui_need_switch)); /*lint +e666*/ vsync_flag = (vsync_timestamp_changed(hisifd, prev_timestamp) && hisifd->vsync_ctrl.vsync_enabled); secure_flag = secure_ctrl->tui_need_switch; if (vsync_flag && secure_flag) { HISI_FB_INFO("report (secure_event = %d) to hwc with vsync at (frame_no = %d).\n", \ secure_ctrl->secure_event, hisifd->ov_req.frame_no); ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu, SecureEvent=%d \n", ktime_to_ns(hisifd->vsync_ctrl.vsync_timestamp), secure_ctrl->secure_event); buf[strlen(buf) + 1] = '\0'; if (secure_ctrl->secure_event == DSS_SEC_DISABLE) { secure_ctrl->tui_need_switch = 0; } } else if (vsync_flag) { ret = snprintf(buf, PAGE_SIZE, "VSYNC=%llu, xxxxxxevent=x \n", ktime_to_ns(hisifd->vsync_ctrl.vsync_timestamp)); buf[strlen(buf) + 1] = '\0'; secure_ctrl->tui_need_skip_report = 0; } else if (secure_flag && !secure_ctrl->tui_need_skip_report) { HISI_FB_INFO("report (secure_event = %d) to hwc at (frame_no = %d).\n", \ secure_ctrl->secure_event, hisifd->ov_req.frame_no); ret = snprintf(buf, PAGE_SIZE, "xxxxx=%llu, SecureEvent=%d \n", ktime_to_ns(hisifd->vsync_ctrl.vsync_timestamp), secure_ctrl->secure_event); buf[strlen(buf) + 1] = '\0'; secure_ctrl->tui_need_skip_report = 1; if (secure_ctrl->secure_event == DSS_SEC_DISABLE) { secure_ctrl->tui_need_switch = 0; } } else { ;//do nothing } return ret; }