bool is_same_hour(time_t t1, time_t t2) { tm tm1 = time_to_tm(t1); tm tm2 = time_to_tm(t2); if ( tm1.tm_year == tm2.tm_year && tm1.tm_yday == tm2.tm_yday && tm1.tm_hour == tm2.tm_hour) { return true; } return false; }
static void vivid_vbi_gen_set_time_of_day(u8 *packet) { struct tm tm; u8 checksum, i; time_to_tm(get_seconds(), 0, &tm); packet[0] = calc_parity(0x07); packet[1] = calc_parity(0x01); packet[2] = calc_parity(0x40 | tm.tm_min); packet[3] = calc_parity(0x40 | tm.tm_hour); packet[4] = calc_parity(0x40 | tm.tm_mday); if (tm.tm_mday == 1 && tm.tm_mon == 2 && sys_tz.tz_minuteswest > tm.tm_min + tm.tm_hour * 60) packet[4] = calc_parity(0x60 | tm.tm_mday); packet[5] = calc_parity(0x40 | (1 + tm.tm_mon)); packet[6] = calc_parity(0x40 | (1 + tm.tm_wday)); packet[7] = calc_parity(0x40 | ((tm.tm_year - 90) & 0x3f)); packet[8] = calc_parity(0x0f); for (checksum = i = 0; i <= 8; i++) checksum += packet[i] & 0x7f; packet[9] = calc_parity(0x100 - checksum); checksum = 0; packet[10] = calc_parity(0x07); packet[11] = calc_parity(0x04); if (sys_tz.tz_minuteswest >= 0) packet[12] = calc_parity(0x40 | ((sys_tz.tz_minuteswest / 60) & 0x1f)); else packet[12] = calc_parity(0x40 | ((24 + sys_tz.tz_minuteswest / 60) & 0x1f)); packet[13] = calc_parity(0); packet[14] = calc_parity(0x0f); for (checksum = 0, i = 10; i <= 14; i++) checksum += packet[i] & 0x7f; packet[15] = calc_parity(0x100 - checksum); }
ssize_t mod_clock_read(struct file* f, char *buf, size_t count, loff_t *offp ) { ssize_t len = 0; /* only output data, if offset == 0 and read_times was reset. */ if (*offp == 0 && read_times == 0) { struct timeval tv; struct tm t; do_gettimeofday(&tv); time_to_tm(tv.tv_sec, 0, &t); len += sprintf(buf + len, "%d:%d:%d:%ld\n", t.tm_hour, t.tm_min, t.tm_sec, tv.tv_usec); } read_times += 1; /* We're returing '0' -> this stops the current read process -> next time a read as allowed -> reset 'read_times'. */ if (len == 0) { read_times = 0; } return len; }
static int ce1702_isp_event_store(struct device* dev, struct device_attribute* attr, const char* buf, size_t n) { int val; struct timespec time; struct tm tm_result; uint8_t filename[128]; time = __current_kernel_time(); time_to_tm(time.tv_sec, sys_tz.tz_minuteswest * 60 * (-1), &tm_result); sprintf(filename, "/data/event_%02d%02d%02d%02d%02d.bin", tm_result.tm_mon + 1, tm_result.tm_mday, tm_result.tm_hour, tm_result.tm_min, tm_result.tm_sec); sscanf(buf,"%x", &val); if (val) { int32_t rc, num_read; uint8_t data[130]; uint8_t packet_size[2] = {0, }; rc = ce1702_i2c_read(ce1702_s_interface_ctrl->sensor_i2c_addr, 0xDB, NULL, 0, packet_size, 2); if (rc < 0) { LDBGE("%s: num_read reading error\n", __func__); return n; } num_read = packet_size[0] + (packet_size[1] << 8); LDBGE("%s: num_read : %d, [%x|%x]\n", __func__, num_read, packet_size[0], packet_size[1]); if (num_read > 0) { mm_segment_t old_fs; uint8_t *dump_data; int32_t dump_data_len, nloop, fd; dump_data_len = num_read * 128 * sizeof(uint8_t); dump_data = kmalloc(dump_data_len, GFP_KERNEL); for (nloop = 0; nloop < num_read; nloop++) { rc = ce1702_i2c_read(ce1702_s_interface_ctrl->sensor_i2c_addr, 0xDC, NULL, 0, data, 130); if (rc < 0) { LDBGE("%s: %d-th reading error\n", __func__, nloop); continue; } memcpy(&dump_data[nloop * 128], &data[2], sizeof(uint8_t) * 128); } old_fs = get_fs(); set_fs(KERNEL_DS); fd = sys_open(filename, O_RDWR | O_CREAT , 0644); if (fd >= 0) { sys_write(fd, dump_data, dump_data_len); sys_close(fd); LDBGE("%s: isp eventlog (%s) successfully writed (%d)!! \n", __func__, filename, nloop); } set_fs(old_fs); kfree(dump_data); } } return n; }
void print_time(char *info, u32 time) { struct tm t; /* it convert to year since 1900 */ time_to_tm((time_t)(time), 0, &t); KDEBUG(M4SH_INFO, "%s(%d) %02d:%02d:%02d %02d/%02d/%04d\n",\ info, (int)time, t.tm_hour, t.tm_min, t.tm_sec,\ t.tm_mon+1, t.tm_mday, (int)t.tm_year+1900); }
static ssize_t generate_pretty_time(char* buf, time_t sec) { struct tm time; time_to_tm(sec, 0, &time); return snprintf(buf, OUTSTR_SIZE, "current time: %ld-%d-%d %d:%d:%d%c", time.tm_year + 1900, time.tm_mon +1, time.tm_mday, time.tm_hour, time.tm_min, time.tm_sec, '\0'); }
void copy_and_format_trace_data(struct fc_trace_hdr *tdata, fnic_dbgfs_t *fnic_dbgfs_prt, int *orig_len, u8 rdata_flag) { struct tm tm; int j, i = 1, len; char *fc_trace, *fmt; int ethhdr_len = sizeof(struct ethhdr) - 1; int fcoehdr_len = sizeof(struct fcoe_hdr); int fchdr_len = sizeof(struct fc_frame_header); int max_size = fnic_fc_trace_max_pages * PAGE_SIZE * 3; tdata->frame_type = tdata->frame_type & 0x7F; len = *orig_len; time_to_tm(tdata->time_stamp.tv_sec, 0, &tm); fmt = "%02d:%02d:%04ld %02d:%02d:%02d.%09lu ns%8x %c%8x\t"; len += snprintf(fnic_dbgfs_prt->buffer + len, max_size - len, fmt, tm.tm_mon + 1, tm.tm_mday, tm.tm_year + 1900, tm.tm_hour, tm.tm_min, tm.tm_sec, tdata->time_stamp.tv_nsec, tdata->host_no, tdata->frame_type, tdata->frame_len); fc_trace = (char *)FC_TRACE_ADDRESS(tdata); for (j = 0; j < min_t(u8, tdata->frame_len, (u8)(FC_TRC_SIZE_BYTES - FC_TRC_HEADER_SIZE)); j++) { if (tdata->frame_type == FNIC_FC_LE) { len += snprintf(fnic_dbgfs_prt->buffer + len, max_size - len, "%c", fc_trace[j]); } else { len += snprintf(fnic_dbgfs_prt->buffer + len, max_size - len, "%02x", fc_trace[j] & 0xff); len += snprintf(fnic_dbgfs_prt->buffer + len, max_size - len, " "); if (j == ethhdr_len || j == ethhdr_len + fcoehdr_len || j == ethhdr_len + fcoehdr_len + fchdr_len || (i > 3 && j%fchdr_len == 0)) { len += snprintf(fnic_dbgfs_prt->buffer + len, max_size - len, "\n\t\t\t\t\t\t\t\t"); i++; } } /* end of else*/ } /* End of for loop*/ len += snprintf(fnic_dbgfs_prt->buffer + len, max_size - len, "\n"); *orig_len = len; }
void ts2utc(struct timespec *ts, struct utc_time *utc) { struct tm tm; time_to_tm((ts->tv_sec - (sys_tz.tz_minuteswest * 60)), 0, &tm); utc->year = 1900 + tm.tm_year; utc->mon = 1 + tm.tm_mon; utc->day = tm.tm_mday; utc->hour = tm.tm_hour; utc->min = tm.tm_min; utc->sec = tm.tm_sec; utc->msec = ns2ms(ts->tv_nsec); }
void mntn_get_cur_time_str(char *poutstr, unsigned int ulen) { struct tm tm_rtc = {0}; unsigned long cur_secs = 0; if (NULL != poutstr) { cur_secs = get_seconds(); cur_secs -= sys_tz.tz_minuteswest * 60; time_to_tm(cur_secs, 0, &tm_rtc); snprintf(poutstr, ulen, "%lu%.2d%.2d-%.2d%.2d%.2d", 1900 + tm_rtc.tm_year, tm_rtc.tm_mon + 1, tm_rtc.tm_mday, tm_rtc.tm_hour, tm_rtc.tm_min, tm_rtc.tm_sec); } }
static void rk29_adc_battery_timer_work(struct work_struct *work) { struct tm tm; static int fd_log = -1; struct rk30_adc_battery_platform_data *pdata = gBatteryData->pdata; rk29_adc_battery_status_samples(gBatteryData); if (poweron_check) { poweron_check = 0; rk29_adc_battery_poweron_capacity_check(); } rk29_adc_battery_voltage_samples(gBatteryData); rk29_adc_battery_capacity_samples(gBatteryData); /*update battery parameter after adc and capacity has been changed*/ if(gBatteryData->bat_change) { gBatteryData->bat_change = 0; rk29_adc_battery_put_capacity(gBatteryData->bat_capacity); power_supply_changed(&rk29_battery_supply); } if (rk29_battery_dbg_level) { if (++AdcTestCnt >= 20) { char buf[256] = {0}; time_to_tm(get_seconds(), 0, &tm); AdcTestCnt = 0; #if SAVE_BAT_LOG if (fd_log < 0) { fd_log = sys_open("/data/local/bat.log", O_CREAT | O_APPEND | O_RDWR, 0); printk("create /data/local/bat.log, fd_log = %d\n", fd_log); } else { sprintf(buf, "[%02d:%02d:%02d], bat_status = %d, RealAdc = %d, RealVol = %d, gBatVol = %d, gBatCap = %d, RealCapacity = %d,\ dischargecnt = %d, chargecnt = %d, dc_det = %d, charge_ok = %d\n", tm.tm_hour, tm.tm_min, tm.tm_sec, gBatteryData->bat_status, AdcTestvalue, adc_to_voltage(AdcTestvalue), gBatteryData->bat_voltage, gBatteryData->bat_capacity, capacitytmp, gBatCapacityDisChargeCnt, gBatCapacityChargeCnt, gpio_get_value(pdata->dc_det_pin), gpio_get_value(pdata->charge_ok_pin)); int ret = sys_write(fd_log, (const char __user *)buf, strlen(buf)); printk("undate charge info, ret = %d, len=%d\n", ret, strlen(buf)); } #endif printk("Status = %d, RealAdcVal = %d, RealVol = %d,gBatVol = %d, gBatCap = %d, RealCapacity = %d, dischargecnt = %d, chargecnt = %d\n", gBatteryData->bat_status, AdcTestvalue, adc_to_voltage(AdcTestvalue), gBatteryData->bat_voltage, gBatteryData->bat_capacity, capacitytmp, gBatCapacityDisChargeCnt, gBatCapacityChargeCnt); } }
static int time_init_module(void) { struct timeval tv; struct tm tm; do_gettimeofday(&tv); pr_info("second: %ld\n", tv.tv_sec); time_to_tm(tv.tv_sec, 0, &tm); pr_info("year: %ld, month: %d, day: %d, hour: %d, minute: %d, second: %d\n", tm.tm_year, tm.tm_mon, tm.tm_mday, tm.tm_hour, tm.tm_min, tm.tm_sec); return 0; }
const char *show_date(unsigned long time, int tz, enum date_mode mode) { struct tm *tm; static char timebuf[200]; if (mode == DATE_RAW) { snprintf(timebuf, sizeof(timebuf), "%lu %+05d", time, tz); return timebuf; } if (mode == DATE_RELATIVE) { struct timeval now; gettimeofday(&now, NULL); return show_date_relative(time, tz, &now, timebuf, sizeof(timebuf)); } if (mode == DATE_LOCAL) tz = local_tzoffset(time); tm = time_to_tm(time, tz); if (!tm) return NULL; if (mode == DATE_SHORT) sprintf(timebuf, "%04d-%02d-%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); else if (mode == DATE_ISO8601) sprintf(timebuf, "%04d-%02d-%02d %02d:%02d:%02d %+05d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tz); else if (mode == DATE_RFC2822) sprintf(timebuf, "%.3s, %d %.3s %d %02d:%02d:%02d %+05d", weekday_names[tm->tm_wday], tm->tm_mday, month_names[tm->tm_mon], tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec, tz); else sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d%c%+05d", weekday_names[tm->tm_wday], month_names[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_year + 1900, (mode == DATE_LOCAL) ? 0 : ' ', tz); return timebuf; }
/** Function Name : deeds_clock_module_read Function Type : Kernel Callback Method Description : Method is invoked whenever the deeds_clock file is read. This callback method is triggered when a read operation performed on the above mentioned file which is registered to the file operation object. /proc/deeds_clock is a read only file. Whereas /proc/deeds_clock_config is a read/write file. Based on the value stored in the config file the clock format is modified. The possible values stored are 0,1. */ static ssize_t deeds_clock_module_read(struct file *file, char *buf, size_t count, loff_t *ppos) { /** Timeval object defined for obtaining the current time in seconds. */ struct timeval timeval_obj; /** Time object defined to vary the output based on specific time formats.*/ struct tm tm_obj; int ret=0; /** Kernel call obtains the current time and stores the information in timeval object. */ do_gettimeofday(&timeval_obj); printk(KERN_INFO "Deeds Clock Module read.\n"); /** To check EOF is reached. */ if(!finished_clock) { /** To check which clock format is in use. */ if(option) { /** Since option=1, clock format is yy-mm-dd h:m:s*/ time_to_tm(get_seconds(),CEST/*sys_tz.tz_minuteswest * 60*/, &tm_obj); ret = sprintf(buf,"current time:%04ld-%02d-%02d %02d:%02d:%02d\n", tm_obj.tm_year + 1900, tm_obj.tm_mon + 1, tm_obj.tm_mday, tm_obj.tm_hour, tm_obj.tm_min, tm_obj.tm_sec); if(ret < 0) { /** Memory Allocation Problem */ return -ENOMEM; } } else { /** option = 0, clock format is in seconds.*/ ret = sprintf(buf,"current time:%ld seconds\n",timeval_obj.tv_sec); if(ret <0) { /** Memory Allocation Problem */ return -ENOMEM; } } /** Flag set to true indicating EOF */ finished_clock = 1; /** Total bytes read successfully returned.*/ return ret; } /** Successful execution of read call back. EOF reached.*/ return 0; }
static void print_current_time(int is_new_line) { struct timeval *tv; struct tm *t; tv = kmalloc(sizeof(struct timeval), GFP_KERNEL); t = kmalloc(sizeof(struct tm),GFP_KERNEL) ; do_gettimeofday(tv); time_to_tm(tv->tv_sec, 0, t); printk(KERN_ALERT "%ld-%d-%d %d:%d:%d",t->tm_year + 1900, t->tm_mon + 1, t->tm_mday,(t->tm_hour + 8), t->tm_min,t->tm_sec); if (is_new_line == 1) printk(KERN_ALERT "\n"); kfree(tv); kfree(t); }
std::string CTimerFileInfo::format_date(std::time_t tm_value) { char date_buf[256]; struct tm tm_time = time_to_tm(tm_value); // dir/prefix_year_month_day_hour_seq.suffix snprintf(date_buf, 256, "%04d_%02d_%02d_%02d_%02d_%02d", tm_time.tm_year + 1900, tm_time.tm_mon + 1, tm_time.tm_mday, tm_time.tm_hour, tm_time.tm_min, tm_time.tm_sec ); std::string str = date_buf; return str; }
char *get_timestamp(void) { static char ret[400]; struct timeval t; struct tm broken; do_gettimeofday(&t); time_to_tm(t.tv_sec, 0, &broken); if (lines_omitted == 0) sprintf(ret, "Log contents for time = %2d:%2d:%2d.%ld\n", broken.tm_hour, broken.tm_min, broken.tm_sec, t.tv_usec); else sprintf(ret, "Log was full. %d lines were omitted.\n" "Log has been flushed to terminal. Beginning new log " "for time = %2d:%2d:%2d.%ld\n", lines_omitted, broken.tm_hour, broken.tm_min, broken.tm_sec, t.tv_usec); return ret; }
static ssize_t sta_connected_time_read(struct file *file, char __user *userbuf, size_t count, loff_t *ppos) { struct sta_info *sta = file->private_data; struct timespec uptime; struct tm result; long connected_time_secs; char buf[100]; int res; do_posix_clock_monotonic_gettime(&uptime); connected_time_secs = uptime.tv_sec - sta->last_connected; time_to_tm(connected_time_secs, 0, &result); result.tm_year -= 70; result.tm_mday -= 1; res = scnprintf(buf, sizeof(buf), "years - %ld\nmonths - %d\ndays - %d\nclock - %d:%d:%d\n\n", result.tm_year, result.tm_mon, result.tm_mday, result.tm_hour, result.tm_min, result.tm_sec); return simple_read_from_buffer(userbuf, count, ppos, buf, res); }
/* * Prepare current date in the format required for HTTP "Date:" * header field. See RFC 2616 section 3.3. */ static void tfw_http_prep_date(char *buf) { struct tm tm; struct timespec ts; char *ptr = buf; static char *wday[] __read_mostly = { "Sun, ", "Mon, ", "Tue, ", "Wed, ", "Thu, ", "Fri, ", "Sat, " }; static char *month[] __read_mostly = { " Jan ", " Feb ", " Mar ", " Apr ", " May ", " Jun ", " Jul ", " Aug ", " Sep ", " Oct ", " Nov ", " Dec " }; #define PRINT_2DIGIT(p, n) \ *p++ = (n <= 9) ? '0' : '0' + n / 10; \ *p++ = '0' + n % 10; getnstimeofday(&ts); time_to_tm(ts.tv_sec, 0, &tm); memcpy(ptr, wday[tm.tm_wday], 5); ptr += 5; PRINT_2DIGIT(ptr, tm.tm_mday); memcpy(ptr, month[tm.tm_mon], 5); ptr += 5; PRINT_2DIGIT(ptr, (tm.tm_year + 1900) / 100); PRINT_2DIGIT(ptr, (tm.tm_year + 1900) % 100); *ptr++ = ' '; PRINT_2DIGIT(ptr, tm.tm_hour); *ptr++ = ':'; PRINT_2DIGIT(ptr, tm.tm_min); *ptr++ = ':'; PRINT_2DIGIT(ptr, tm.tm_sec); memcpy(ptr, " GMT", 4); #undef PRINT_2DIGIT }
STATIC int balong_ade_overlay_commit(struct ade_compose_data_type *ade_pri_data, void __user *p) { struct overlay_compose_info comp_info; struct balong_fb_data_type *balongfd = NULL; int ret = 0; u32 struct_len = sizeof(struct ovly_hnd_info) * ADE_OVERLAY_MAX_LAYERS; #if ADE_SYNC_SUPPORT int fenceId = 0; unsigned long flags; #endif BUG_ON(ade_pri_data == NULL); balongfb_logi_display_debugfs("balong_ade_overlay_commit enter succ ! \n"); if (copy_from_user(&comp_info, p, sizeof(comp_info))) { balongfb_loge("copy from user failed!\n"); return -EFAULT; } balongfd = (struct balong_fb_data_type *)platform_get_drvdata(ade_pri_data->parent); BUG_ON(balongfd == NULL); if ((!balongfd->frame_updated) && lcd_pwr_status.panel_power_on) { balongfd->frame_updated = 1; lcd_pwr_status.lcd_dcm_pwr_status |= BIT(2); do_gettimeofday(&lcd_pwr_status.tvl_set_frame); time_to_tm(lcd_pwr_status.tvl_set_frame.tv_sec, 0, &lcd_pwr_status.tm_set_frame); } down(&balong_fb_blank_sem); if (!balongfd->ade_core_power_on) { up(&balong_fb_blank_sem); balongfb_logi("ade_core_power_on is false !\n"); return -EPERM; } if (ADE_TRUE == comp_info.is_finished) { spin_lock_irqsave(&balongfd->refresh_lock, flags); balongfd->refresh++; spin_unlock_irqrestore(&balongfd->refresh_lock, flags); balongfd->timeline_max++; //release the reserved buffer of fb if((true == ade_pri_data->fb_reserved_flag) && (ade_pri_data->frame_count)) { balong_ion_free_mem_to_buddy(); ade_pri_data->fb_reserved_flag = false; } if (PANEL_MIPI_VIDEO == ade_pri_data->lcd_type) { spin_lock_irqsave(&(balongfd->vsync_info.spin_lock), flags); set_LDI_INT_MASK_bit(balongfd->ade_base, LDI_ISR_FRAME_END_INT); balongfd->vsync_info.vsync_ctrl_expire_count = 0; spin_unlock_irqrestore(&(balongfd->vsync_info.spin_lock), flags); if (balongfd->vsync_info.vsync_ctrl_disabled_set) { if (balongfd->ldi_irq) { enable_irq(balongfd->ldi_irq); balongfd->vsync_info.vsync_ctrl_disabled_set = false; } } } #ifndef PC_UT_TEST_ON #ifdef CONFIG_TRACING trace_dot(SF, "7", 0); #endif #endif #if ADE_DEBUG_LOG_ENABLE g_debug_frame_number = comp_info.frame_number; #endif } ret = ade_overlay_commit(ade_pri_data, &comp_info); if ((ADE_TRUE == comp_info.is_finished)) { if (ret == 0) { set_LDI_INT_MASK_bit(ade_pri_data->ade_base, LDI_ISR_UNDER_FLOW_INT); #if PARTIAL_UPDATE if ((PANEL_MIPI_CMD == ade_pri_data->lcd_type) && (true == balongfd->dirty_update)) { balongfb_set_display_region(balongfd); balongfd->dirty_update = false; } #endif if (PANEL_MIPI_VIDEO == ade_pri_data->lcd_type) { if ((ade_pri_data->overlay_ctl.comp_info.compose_mode != OVERLAY_COMP_TYPE_ONLINE) || (balongfd->vpu_power_on)){ /* ade_core_rate is default value (360M) */ balongfd->ade_set_core_rate = balongfd->ade_core_rate; } if (balongfd->last_ade_core_rate != balongfd->ade_set_core_rate) { if (clk_set_rate(balongfd->ade_clk, balongfd->ade_set_core_rate) != 0) { balongfb_loge("clk_set_rate ade_core_rate error \n"); } } balongfd->last_ade_core_rate = balongfd->ade_set_core_rate; } set_LDI_CTRL_ldi_en(ade_pri_data->ade_base, ADE_ENABLE); balongfd->ade_ldi_on = true; if (PANEL_MIPI_CMD == ade_pri_data->lcd_type) { set_LDI_INT_MASK_bit(balongfd->ade_base, LDI_ISR_DSI_TE0_PIN_INT); /* enable fake vsync timer */ if (balongfd->frc_state != BALONG_FB_FRC_IDLE_PLAYING) { balongfd->use_cmd_vsync = (balongfb_frc_get_fps(balongfd) < BALONG_FB_FRC_NORMAL_FPS ? true : false); } /* report vsync with timer */ if (balongfd->use_cmd_vsync) { hrtimer_restart(&balongfd->cmd_vsync_hrtimer); } else { hrtimer_cancel(&balongfd->cmd_vsync_hrtimer); } } #ifndef PC_UT_TEST_ON #ifdef CONFIG_TRACING trace_dot(SF, "8", 0); #endif #endif #if ADE_SYNC_SUPPORT /* In online/hybrid mode, ADE must create release fenceFd. * In offline mode, don't create release fenceFd * because ADE will read HAL's offline buffer instead of layer's buffer. */ /* spin_lock_irqsave(&balongfd->refresh_lock, flags); balongfd->refresh++; spin_unlock_irqrestore(&balongfd->refresh_lock, flags); balongfd->timeline_max++; */ if ((OVERLAY_COMP_TYPE_ONLINE == comp_info.compose_mode) || (OVERLAY_COMP_TYPE_HYBRID == comp_info.compose_mode)) { fenceId = balong_ade_overlay_fence_create(balongfd->timeline, "ADE", balongfd->timeline_max); if (fenceId < 0) { balongfb_loge("ADE failed to create fence!\n"); } comp_info.release_fence = fenceId; if (copy_to_user((struct overlay_compose_info __user*)p, &comp_info, sizeof(struct overlay_compose_info)) && (fenceId >= 0)) { fenceId = -EFAULT; balongfb_loge("ADE failed to copy fence to user!\n"); put_unused_fd(comp_info.release_fence); up(&balong_fb_blank_sem); return fenceId; } } #endif /* ADE_SYNC_SUPPORT */ ade_overlay_handle_unlock(balongfd); memcpy(balongfd->locked_hnd, balongfd->locking_hnd, struct_len); memset(balongfd->locking_hnd, 0, struct_len); } else { ade_overlay_handle_unlock(balongfd); memcpy(balongfd->locked_hnd, balongfd->locking_hnd, struct_len); memset(balongfd->locking_hnd, 0, struct_len); up(&balong_fb_blank_sem); return ret; } } up(&balong_fb_blank_sem); balongfb_logi_display_debugfs("balong_ade_overlay_commit exit succ ! \n"); return 0; }
/* * Attempt to parse a data blob for a key as an X509 certificate. */ static int x509_key_preparse(struct key_preparsed_payload *prep) { struct x509_certificate *cert; struct tm now; size_t srlen, sulen; char *desc = NULL; int ret; cert = x509_cert_parse(prep->data, prep->datalen); if (IS_ERR(cert)) return PTR_ERR(cert); pr_devel("Cert Issuer: %s\n", cert->issuer); pr_devel("Cert Subject: %s\n", cert->subject); pr_devel("Cert Key Algo: %s\n", pkey_algo[cert->pkey_algo]); pr_devel("Cert Valid From: %04ld-%02d-%02d %02d:%02d:%02d\n", cert->valid_from.tm_year + 1900, cert->valid_from.tm_mon + 1, cert->valid_from.tm_mday, cert->valid_from.tm_hour, cert->valid_from.tm_min, cert->valid_from.tm_sec); pr_devel("Cert Valid To: %04ld-%02d-%02d %02d:%02d:%02d\n", cert->valid_to.tm_year + 1900, cert->valid_to.tm_mon + 1, cert->valid_to.tm_mday, cert->valid_to.tm_hour, cert->valid_to.tm_min, cert->valid_to.tm_sec); pr_devel("Cert Signature: %s + %s\n", pkey_algo[cert->sig_pkey_algo], pkey_hash_algo[cert->sig_hash_algo]); if (!cert->fingerprint || !cert->authority) { pr_warn("Cert for '%s' must have SubjKeyId and AuthKeyId extensions\n", cert->subject); ret = -EKEYREJECTED; goto error_free_cert; } time_to_tm(CURRENT_TIME.tv_sec, 0, &now); pr_devel("Now: %04ld-%02d-%02d %02d:%02d:%02d\n", now.tm_year + 1900, now.tm_mon + 1, now.tm_mday, now.tm_hour, now.tm_min, now.tm_sec); if (now.tm_year < cert->valid_from.tm_year || (now.tm_year == cert->valid_from.tm_year && (now.tm_mon < cert->valid_from.tm_mon || (now.tm_mon == cert->valid_from.tm_mon && (now.tm_mday < cert->valid_from.tm_mday || (now.tm_mday == cert->valid_from.tm_mday && (now.tm_hour < cert->valid_from.tm_hour || (now.tm_hour == cert->valid_from.tm_hour && (now.tm_min < cert->valid_from.tm_min || (now.tm_min == cert->valid_from.tm_min && (now.tm_sec < cert->valid_from.tm_sec ))))))))))) { pr_warn("Cert %s is not yet valid\n", cert->fingerprint); /* ret = -EKEYREJECTED; * goto error_free_cert; */ } if (now.tm_year > cert->valid_to.tm_year || (now.tm_year == cert->valid_to.tm_year && (now.tm_mon > cert->valid_to.tm_mon || (now.tm_mon == cert->valid_to.tm_mon && (now.tm_mday > cert->valid_to.tm_mday || (now.tm_mday == cert->valid_to.tm_mday && (now.tm_hour > cert->valid_to.tm_hour || (now.tm_hour == cert->valid_to.tm_hour && (now.tm_min > cert->valid_to.tm_min || (now.tm_min == cert->valid_to.tm_min && (now.tm_sec > cert->valid_to.tm_sec ))))))))))) { pr_warn("Cert %s has expired\n", cert->fingerprint); ret = -EKEYEXPIRED; goto error_free_cert; } cert->pub->algo = x509_public_key_algorithms[cert->pkey_algo]; cert->pub->id_type = PKEY_ID_X509; /* Check the signature on the key */ if (strcmp(cert->fingerprint, cert->authority) == 0) { ret = x509_check_signature(cert->pub, cert); if (ret < 0) goto error_free_cert; } /* Propose a description */ sulen = strlen(cert->subject); srlen = strlen(cert->fingerprint); ret = -ENOMEM; desc = kmalloc(sulen + 2 + srlen + 1, GFP_KERNEL); if (!desc) goto error_free_cert; memcpy(desc, cert->subject, sulen); desc[sulen] = ':'; desc[sulen + 1] = ' '; memcpy(desc + sulen + 2, cert->fingerprint, srlen); desc[sulen + 2 + srlen] = 0; /* We're pinning the module by being linked against it */ __module_get(public_key_subtype.owner); prep->type_data[0] = &public_key_subtype; prep->type_data[1] = cert->fingerprint; prep->payload = cert->pub; prep->description = desc; prep->quotalen = 100; /* We've finished with the certificate */ cert->pub = NULL; cert->fingerprint = NULL; desc = NULL; ret = 0; error_free_cert: x509_free_certificate(cert); return ret; }
/* * This RDS generator creates 57 RDS groups (one group == four RDS blocks). * Groups 0-3, 22-25 and 44-47 (spaced 22 groups apart) are filled with a * standard 0B group containing the PI code and PS name. * * Groups 4-19 and 26-41 use group 2A for the radio text. * * Group 56 contains the time (group 4A). * * All remaining groups use a filler group 15B block that just repeats * the PI and PTY codes. */ void vivid_rds_generate(struct vivid_rds_gen *rds) { struct v4l2_rds_data *data = rds->data; unsigned grp; struct tm tm; unsigned date; unsigned time; int l; for (grp = 0; grp < VIVID_RDS_GEN_GROUPS; grp++, data += VIVID_RDS_GEN_BLKS_PER_GRP) { data[0].lsb = rds->picode & 0xff; data[0].msb = rds->picode >> 8; data[0].block = V4L2_RDS_BLOCK_A | (V4L2_RDS_BLOCK_A << 3); data[1].lsb = rds->pty << 5; data[1].msb = (rds->pty >> 3) | (rds->tp << 2); data[1].block = V4L2_RDS_BLOCK_B | (V4L2_RDS_BLOCK_B << 3); data[3].block = V4L2_RDS_BLOCK_D | (V4L2_RDS_BLOCK_D << 3); switch (grp) { case 0 ... 3: case 22 ... 25: case 44 ... 47: /* Group 0B */ data[1].lsb |= (rds->ta << 4) | (rds->ms << 3); data[1].lsb |= vivid_get_di(rds, grp % 22); data[1].msb |= 1 << 3; data[2].lsb = rds->picode & 0xff; data[2].msb = rds->picode >> 8; data[2].block = V4L2_RDS_BLOCK_C_ALT | (V4L2_RDS_BLOCK_C_ALT << 3); data[3].lsb = rds->psname[2 * (grp % 22) + 1]; data[3].msb = rds->psname[2 * (grp % 22)]; break; case 4 ... 19: case 26 ... 41: /* Group 2A */ data[1].lsb |= (grp - 4) % 22; data[1].msb |= 4 << 3; data[2].msb = rds->radiotext[4 * ((grp - 4) % 22)]; data[2].lsb = rds->radiotext[4 * ((grp - 4) % 22) + 1]; data[2].block = V4L2_RDS_BLOCK_C | (V4L2_RDS_BLOCK_C << 3); data[3].msb = rds->radiotext[4 * ((grp - 4) % 22) + 2]; data[3].lsb = rds->radiotext[4 * ((grp - 4) % 22) + 3]; break; case 56: /* * Group 4A * * Uses the algorithm from Annex G of the RDS standard * EN 50067:1998 to convert a UTC date to an RDS Modified * Julian Day. */ time_to_tm(get_seconds(), 0, &tm); l = tm.tm_mon <= 1; date = 14956 + tm.tm_mday + ((tm.tm_year - l) * 1461) / 4 + ((tm.tm_mon + 2 + l * 12) * 306001) / 10000; time = (tm.tm_hour << 12) | (tm.tm_min << 6) | (sys_tz.tz_minuteswest >= 0 ? 0x20 : 0) | (abs(sys_tz.tz_minuteswest) / 30); data[1].lsb &= ~3; data[1].lsb |= date >> 15; data[1].msb |= 8 << 3; data[2].lsb = (date << 1) & 0xfe; data[2].lsb |= (time >> 16) & 1; data[2].msb = (date >> 7) & 0xff; data[2].block = V4L2_RDS_BLOCK_C | (V4L2_RDS_BLOCK_C << 3); data[3].lsb = time & 0xff; data[3].msb = (time >> 8) & 0xff; break; default: /* Group 15B */ data[1].lsb |= (rds->ta << 4) | (rds->ms << 3); data[1].lsb |= vivid_get_di(rds, grp % 22); data[1].msb |= 0x1f << 3; data[2].lsb = rds->picode & 0xff; data[2].msb = rds->picode >> 8; data[2].block = V4L2_RDS_BLOCK_C_ALT | (V4L2_RDS_BLOCK_C_ALT << 3); data[3].lsb = rds->pty << 5; data[3].lsb |= (rds->ta << 4) | (rds->ms << 3); data[3].lsb |= vivid_get_di(rds, grp % 22); data[3].msb |= rds->pty >> 3; data[3].msb |= 0x1f << 3; break; } } }
void _write_time_log(char *filename, char *data, int data_include) { struct file *file; loff_t pos = 0; char *fname = NULL; char time_string[64] = {0}; struct timespec my_time; struct tm my_date; mm_segment_t old_fs = get_fs(); my_time = __current_kernel_time(); time_to_tm(my_time.tv_sec, sys_tz.tz_minuteswest * 60 * (-1), &my_date); snprintf(time_string, sizeof(time_string), "%02d-%02d %02d:%02d:%02d.%03lu\n\n", my_date.tm_mon + 1, my_date.tm_mday, my_date.tm_hour, my_date.tm_min, my_date.tm_sec, (unsigned long) my_time.tv_nsec / 1000000); set_fs(KERNEL_DS); if (filename == NULL) { switch (mfts_mode) { case 0: fname = "/mnt/sdcard/touch_self_test.txt"; break; case 1: fname = "/mnt/sdcard/touch_self_test_mfts_folder.txt"; break; case 2: fname = "/mnt/sdcard/touch_self_test_mfts_flat.txt"; break; case 3: fname = "/mnt/sdcard/touch_self_test_mfts_curved.txt"; break; default: TOUCH_I("%s : not support mfts_mode\n", __func__); break; } } else { fname = filename; } if (fname) { file = filp_open(fname, O_WRONLY|O_CREAT|O_APPEND, 0666); } else { TOUCH_E("%s : fname is NULL, can not open FILE\n", __func__); return; } if (IS_ERR(file)) { TOUCH_I("%s : Open file error [%s], err = %ld\n", __func__, fname, PTR_ERR(file)); set_fs(old_fs); return; } vfs_write(file, time_string, strlen(time_string), &pos); filp_close(file, 0); set_fs(old_fs); }
const char *show_date(unsigned long time, int tz, enum date_mode mode) { struct tm *tm; static struct strbuf timebuf = STRBUF_INIT; if (mode == DATE_RAW) { strbuf_reset(&timebuf); strbuf_addf(&timebuf, "%lu %+05d", time, tz); return timebuf.buf; } if (mode == DATE_RELATIVE) { struct timeval now; strbuf_reset(&timebuf); gettimeofday(&now, NULL); show_date_relative(time, tz, &now, &timebuf); return timebuf.buf; } if (mode == DATE_LOCAL) tz = local_tzoffset(time); tm = time_to_tm(time, tz); if (!tm) { tm = time_to_tm(0, 0); tz = 0; } strbuf_reset(&timebuf); if (mode == DATE_SHORT) strbuf_addf(&timebuf, "%04d-%02d-%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); else if (mode == DATE_ISO8601) strbuf_addf(&timebuf, "%04d-%02d-%02d %02d:%02d:%02d %+05d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tz); else if (mode == DATE_ISO8601_STRICT) { char sign = (tz >= 0) ? '+' : '-'; tz = abs(tz); strbuf_addf(&timebuf, "%04d-%02d-%02dT%02d:%02d:%02d%c%02d:%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, sign, tz / 100, tz % 100); } else if (mode == DATE_RFC2822) strbuf_addf(&timebuf, "%.3s, %d %.3s %d %02d:%02d:%02d %+05d", weekday_names[tm->tm_wday], tm->tm_mday, month_names[tm->tm_mon], tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec, tz); else strbuf_addf(&timebuf, "%.3s %.3s %d %02d:%02d:%02d %d%c%+05d", weekday_names[tm->tm_wday], month_names[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_year + 1900, (mode == DATE_LOCAL) ? 0 : ' ', tz); return timebuf.buf; }
static void modem_ssr_report_work_fn(struct work_struct *work) { int fd, ret = 0; char report_index, index_to_write; char path_prefix[]="/data/logger/modem_ssr_report"; char index_file_path[]="/data/logger/modem_ssr_index"; char report_file_path[128]; #ifdef FEATURE_LGE_MODEM_CHIPVER_INFO char chip_info_path[]="/data/logger/modem_chip_info"; struct timespec time; struct tm tmresult; char time_stamp[128]; #endif char watchdog_bite[]="Watchdog bite received from modem software!"; char unexpected_reset1[]="unexpected reset external modem"; char unexpected_reset2[]="MDM2AP_STATUS did not go high"; mm_segment_t oldfs; oldfs = get_fs(); set_fs(get_ds()); fd = sys_open(index_file_path, O_RDONLY, 0664); if (fd < 0) { printk("%s : can't open the index file\n", __func__); report_index = '0'; } else { ret = sys_read(fd, &report_index, 1); if (ret < 0) { printk("%s : can't read the index file\n", __func__); report_index = '0'; } sys_close(fd); } if (report_index == '9') { index_to_write = '0'; } else if (report_index >= '0' && report_index <= '8') { index_to_write = report_index + 1; } else { index_to_write = '1'; report_index = '0'; } fd = sys_open(index_file_path, O_WRONLY | O_CREAT | O_TRUNC, 0664); if (fd < 0) { printk("%s : can't open the index file\n", __func__); return; } ret = sys_write(fd, &index_to_write, 1); if (ret < 0) { printk("%s : can't write the index file\n", __func__); return; } ret = sys_close(fd); if (ret < 0) { printk("%s : can't close the index file\n", __func__); return; } sprintf(report_file_path, "%s%c", path_prefix, report_index); fd = sys_open(report_file_path, O_WRONLY | O_CREAT | O_TRUNC, 0664); if (fd < 0) { printk("%s : can't open the report file\n", __func__); return; } #ifdef FEATURE_LGE_MODEM_CHIPVER_INFO time = __current_kernel_time(); time_to_tm(time.tv_sec, sys_tz.tz_minuteswest * 60 * (-1), &tmresult); sprintf(time_stamp, "%02d-%02d %02d:%02d:%02d.%03lu\n", tmresult.tm_mon+1,tmresult.tm_mday,tmresult.tm_hour, tmresult.tm_min,tmresult.tm_sec,(unsigned long) time.tv_nsec/1000000); ret = sys_write(fd, time_stamp, strlen(time_stamp)); if (ret < 0) { printk("%s : can't write the report file\n", __func__); return; } #endif switch (modem_debug.modem_ssr_event) { case MODEM_SSR_ERR_FATAL: ret = sys_write(fd, modem_debug.save_ssr_reason, strlen(modem_debug.save_ssr_reason)); break; case MODEM_SSR_WATCHDOG_BITE: ret = sys_write(fd, watchdog_bite, sizeof(watchdog_bite) - 1); break; case MODEM_SSR_UNEXPECTED_RESET1: ret = sys_write(fd, unexpected_reset1, sizeof(unexpected_reset1) - 1); break; case MODEM_SSR_UNEXPECTED_RESET2: ret = sys_write(fd, unexpected_reset2, sizeof(unexpected_reset2) - 1); break; default: printk("%s : modem_ssr_event error %d\n", __func__, modem_debug.modem_ssr_event); break; } if (ret < 0) { printk("%s : can't write the report file\n", __func__); return; } ret = sys_close(fd); if (ret < 0) { printk("%s : can't close the report file\n", __func__); return; } #ifdef FEATURE_LGE_MODEM_CHIPVER_INFO fd = sys_open(chip_info_path, O_WRONLY | O_CREAT | O_TRUNC, 0664); if (fd < 0) { pr_err("can't open the report file\n"); return; } ret = sys_write(fd, modem_debug.save_msm_chip_info, strlen(modem_debug.save_msm_chip_info)); if (ret < 0) { pr_err("can't write the report file\n"); return; } ret = sys_close(fd); if (ret < 0) { printk("%s : can't close the report file\n", __func__); return; } #endif sys_sync(); set_fs(oldfs); }
int mipi_dsi_on(struct platform_device *pdev) { int ret = 0; struct balong_fb_data_type *balongfd = NULL; unsigned long timeout = jiffies; if (NULL == pdev) { balongfb_loge("NULL Pointer\n"); return -EINVAL; } balongfd = (struct balong_fb_data_type *)platform_get_drvdata(pdev); if (NULL == balongfd) { balongfb_loge("NULL Pointer\n"); return -EINVAL; } /* set LCD init step before LCD on*/ balongfd->panel_info.lcd_init_step = LCD_INIT_POWER_ON; ret = panel_next_on(pdev); /* mipi dphy clock enable */ ret = clk_prepare_enable(balongfd->dsi_cfg_clk); if (ret != 0) { balongfb_loge("failed to enable dsi_cfg_clk, error=%d!\n", ret); return ret; } /* dsi pixel on */ set_reg(balongfd->ade_base + LDI_HDMI_DSI_GT_REG, 0x0, 1, 0); /* mipi init */ mipi_init(balongfd); /* modified for b052 bbit begin */ /* switch to command mode */ set_MIPIDSI_MODE_CFG(MIPIDSI_COMMAND_MODE); set_MIPIDSI_CMD_MODE_CFG_all_en_flag(1); /* 禁止向Clock Lane发起HS时钟传输请求 */ set_MIPIDSI_LPCLK_CTRL_phy_txrequestclkhs(0); /* add for timeout print log */ balongfb_loge("%s: dsi_on_time = %u,curfreq = %d\n", __func__,jiffies_to_msecs(jiffies-timeout),cpufreq_get_fb(0)); timeout = jiffies; ret = panel_next_on(pdev); /* modified for b052 bbit begin */ /* add for timeout print log */ balongfb_loge("%s: panel_on_time = %u,curfreq = %d\n", __func__,jiffies_to_msecs(jiffies-timeout),cpufreq_get_fb(0)); /* reset Core */ set_MIPIDSI_PWR_UP_shutdownz(0); if (balongfd->panel_info.type == PANEL_MIPI_VIDEO) { /* switch to video mode */ set_MIPIDSI_MODE_CFG(MIPIDSI_VIDEO_MODE); #if ADE_DEBUG_LOG_ENABLE /* set to video lcd mode */ g_panel_lcd_mode = 0; #endif } if (balongfd->panel_info.type == PANEL_MIPI_CMD) { /* switch to cmd mode */ set_MIPIDSI_CMD_MODE_CFG_all_en_flag(0); #if ADE_DEBUG_LOG_ENABLE /* set to command lcd mode */ g_panel_lcd_mode = 1; #endif } /* enable generate High Speed clock */ set_MIPIDSI_LPCLK_CTRL_phy_txrequestclkhs(1); /* Waking up Core */ set_MIPIDSI_PWR_UP_shutdownz(1); /*set max packet size, 0x1 << 8 |0x37*/ set_MIPIDSI_GEN_HDR(NULL, 0x137); lcd_pwr_status.lcd_dcm_pwr_status |= BIT(1); do_gettimeofday(&lcd_pwr_status.tvl_lcd_on); time_to_tm(lcd_pwr_status.tvl_lcd_on.tv_sec, 0, &lcd_pwr_status.tm_lcd_on); return ret; }
/* * Program the ccdc sdram address. * In the programed sdram address the new frame from the sensor be filled. */ int isp_prg_sdram_addr(cam_data *cam) { int i; unsigned int load_address_base_index = 0; static struct timeval timestamp; unsigned int dummy_count = 0; unsigned int valid_buf = 0; struct tm timecode; #ifndef CONFIG_CTRL_FRAME_RATE_FRM_SENSOR static unsigned int frame_skip_count; static unsigned int capture_frame_rate; static unsigned int current_fps = SENS_MAX_FPS; static struct timeval timestamp_rec; #endif if (!cam) return -1; /* Take the current time stamp */ do_gettimeofday(×tamp); #ifndef CONFIG_CTRL_FRAME_RATE_FRM_SENSOR if (!timestamp_rec.tv_sec && !timestamp_rec.tv_usec) do_gettimeofday(×tamp_rec); if (timestamp.tv_sec > timestamp_rec.tv_sec) { current_fps = capture_frame_rate; capture_frame_rate = DISABLE; timestamp_rec = timestamp; } capture_frame_rate++; #endif if (cam->task.bit.still == ENABLE) { cam->isp->isp_ccdc.reg.CCDC_SDR_ADDR = cam->still.phy_addr; } else if (cam->task.bit.capture == ENABLE) { for (valid_buf = 0, i = 0; i < cam->capture.available_buf; i++) { if ((cam->capture.frame[i].buffer.flags & (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED)) == (V4L2_BUF_FLAG_QUEUED | V4L2_BUF_FLAG_MAPPED)) { if ((cam->capture.frame[i].buffer.timestamp.tv_sec < timestamp.tv_sec) || ((cam->capture.frame[i].buffer.timestamp.tv_sec == timestamp.tv_sec) && (cam->capture.frame[i].buffer.timestamp.tv_usec <= timestamp.tv_usec))) { memcpy(×tamp, &cam->capture.frame[i].buffer.timestamp, sizeof(struct timeval)); load_address_base_index = i; } if ((cam->capture.frame[i].buffer.flags & V4L2_BUF_FLAG_DONE) == V4L2_BUF_FLAG_DONE) { valid_buf++; wake_up_interruptible(&cam->capture.capture_frame_complete); } } else { dummy_count++; } } #ifndef CONFIG_CTRL_FRAME_RATE_FRM_SENSOR frame_skip_count += ((1000000 * cam->capture.s_parm.parm.capture.timeperframe.denominator) / current_fps); if (frame_skip_count > 1000000) frame_skip_count -=1000000; else dummy_count = cam->capture.available_buf; #endif if (dummy_count == cam->capture.available_buf) { cam->isp->isp_ccdc.reg.CCDC_SDR_ADDR = cam->capture.frame[cam->capture.available_buf].buffer.m.offset; cam->capture.using_buf = cam->capture.available_buf; } else { cam->capture.buffer_sequence++; /* Fill the New time stamp */ do_gettimeofday(&cam->capture.frame[load_address_base_index].buffer.timestamp); cam->isp->isp_ccdc.reg.CCDC_SDR_ADDR = cam->capture.frame[load_address_base_index].buffer.m.offset; cam->capture.using_buf = load_address_base_index; cam->capture.frame[load_address_base_index].buffer.flags |= V4L2_BUF_FLAG_DONE; time_to_tm(cam->capture.frame[load_address_base_index].buffer.timestamp.tv_sec,DISABLE, &timecode); cam->capture.frame[load_address_base_index].buffer.timecode.seconds = timecode.tm_sec; cam->capture.frame[load_address_base_index].buffer.timecode.minutes = timecode.tm_min; cam->capture.frame[load_address_base_index].buffer.timecode.hours = timecode.tm_hour; cam->capture.frame[load_address_base_index].buffer.timecode.type = V4L2_TC_TYPE_30FPS; cam->capture.frame[load_address_base_index].buffer.timecode.flags = V4L2_TC_FLAG_COLORFRAME; cam->capture.frame[load_address_base_index].buffer.timecode.frames = cam->capture.buffer_sequence; cam->capture.frame[load_address_base_index].buffer.sequence = cam->capture.buffer_sequence; } /* Note the valid buffers available in the pool */ cam->capture.valid_buf = valid_buf; } return SUCCESS; }
const char *show_date(unsigned long time, int tz, enum date_mode mode) { struct tm *tm; static char timebuf[200]; if (mode == DATE_RELATIVE) { unsigned long diff; struct timeval now; gettimeofday(&now, NULL); if (now.tv_sec < time) return "in the future"; diff = now.tv_sec - time; if (diff < 90) { snprintf(timebuf, sizeof(timebuf), "%lu seconds ago", diff); return timebuf; } /* Turn it into minutes */ diff = (diff + 30) / 60; if (diff < 90) { snprintf(timebuf, sizeof(timebuf), "%lu minutes ago", diff); return timebuf; } /* Turn it into hours */ diff = (diff + 30) / 60; if (diff < 36) { snprintf(timebuf, sizeof(timebuf), "%lu hours ago", diff); return timebuf; } /* We deal with number of days from here on */ diff = (diff + 12) / 24; if (diff < 14) { snprintf(timebuf, sizeof(timebuf), "%lu days ago", diff); return timebuf; } /* Say weeks for the past 10 weeks or so */ if (diff < 70) { snprintf(timebuf, sizeof(timebuf), "%lu weeks ago", (diff + 3) / 7); return timebuf; } /* Say months for the past 12 months or so */ if (diff < 360) { snprintf(timebuf, sizeof(timebuf), "%lu months ago", (diff + 15) / 30); return timebuf; } /* Else fall back on absolute format.. */ } if (mode == DATE_LOCAL) tz = local_tzoffset(time); tm = time_to_tm(time, tz); if (!tm) return NULL; if (mode == DATE_SHORT) sprintf(timebuf, "%04d-%02d-%02d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday); else if (mode == DATE_ISO8601) sprintf(timebuf, "%04d-%02d-%02d %02d:%02d:%02d %+05d", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tz); else if (mode == DATE_RFC2822) sprintf(timebuf, "%.3s, %d %.3s %d %02d:%02d:%02d %+05d", weekday_names[tm->tm_wday], tm->tm_mday, month_names[tm->tm_mon], tm->tm_year + 1900, tm->tm_hour, tm->tm_min, tm->tm_sec, tz); else sprintf(timebuf, "%.3s %.3s %d %02d:%02d:%02d %d%c%+05d", weekday_names[tm->tm_wday], month_names[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_year + 1900, (mode == DATE_LOCAL) ? 0 : ' ', tz); return timebuf; }
static void cpwatcher_work_func(struct work_struct *wq) { struct cpwatcher_dev *dev = cpwatcher; unsigned int status = 0; //int ret = 0; //unsigned char data; //Blocked due to CS Issue struct timeval now; struct tm gmt_time; char* argv[] = {"/system/bin/ifx_coredump", "CP_CRASH_IRQ", NULL}; char *envp[] = { "HOME=/", "PATH=/sbin:/bin:/system/bin", NULL }; do_gettimeofday(&now); time_to_tm(now.tv_sec, 0, &gmt_time); printk("[CPW] cpwatcher_work_func()\n"); printk(KERN_ERR "%d-%d-%d %d:%d:%d.%ld *\n", gmt_time.tm_year + 1900, gmt_time.tm_mon + 1, gmt_time.tm_mday, gmt_time.tm_hour - sys_tz.tz_minuteswest / 60, gmt_time.tm_min, gmt_time.tm_sec, now.tv_usec); time_to_stop = 1; // if (dev->onoff) { cpwatcher_get_status(&status); printk("[CPW] %s(), status: %d\n", __FUNCTION__, status); if (status == 0) {//If High, CP error wake_lock(&dev->wake_lock); // UPDATE CP_CRASH_COUNT -- //Blocked due to CS Issue // //data++; // // CHECK CP_CRASH_DUMP OPTION //if (lge_is_crash_dump_enabled() != 1) //this line will be enabled rev.e { input_report_key(dev->input, EVENT_KEY, 1); input_report_key(dev->input, EVENT_KEY, 0); input_sync(dev->input); printk("[CPW] CP Crash : input_report_key(): %d\n", EVENT_KEY); is_cp_crash = 1; //RIP-13119 : RIL recovery should be started by USB-disconnection. //RIP-73256 - S if(lge_is_ril_recovery_mode_enabled() != 1) { printk("[CPW] CP Crash : lge_is_ril_recovery_mode_enabled() = 1 ...change to CP_USB mode \n"); gpio_set_value(KEYBACKLIGHT_LEDS_GPIO, 1); //Temporary -- Keybacklight on when occurs CP Crash extern void muic_proc_set_cp_usb_force(void); muic_proc_set_cp_usb_force(); } wake_unlock(&dev->wake_lock); //RIP-73256 - E return; } // { // extern void tegra_ehci_shutdown_global(void); // tegra_ehci_shutdown_global(); // } // Enabled after Fixing Baudrate Issue // ret = call_usermodehelper(argv[0], argv, envp, UMH_WAIT_EXEC); // printk("[CP CRASH IRQ] launch ifx_coredump process ret:%d\n", ret); } } }
void parse_commit_object(object_info *oi, commit *pcmt) { //ヘッダー部は読み飛ばす char *cp = oi->buf + oi->header_length; //ボディのサイズはヘッダに書かれてあるのを参照する //char *end = oi->buf + oi->header_length + oi->size; char tree_sha1[41]; char parent_sha1[41]; char author_name[256]; char frmted_time[256]; /** * spec of commit object body * ------- * tree <sha1> * parent <sha1> * [parent <sha1> * author .... * committer .... * * message * -------- */ // skip 'tree ' cp += 5; int i = 0; while (*cp != '\n') { tree_sha1[i++] = *(cp++); } tree_sha1[40] = '\0'; cp++; // skip 'parent ' if (*cp == 'p') { cp += 7; i = 0; while (*cp != '\n') { parent_sha1[i++] = *(cp++); } parent_sha1[40] = '\0'; cp++; // skip '\n' } else { memset(parent_sha1, '\0', 41); } validate_sha1(parent_sha1); //マージコミットの場合はまたparentがある。 cp += 7; // skip 'author ' i = 0; while (*cp != '>') { author_name[i++] = *(cp++); } author_name[i++] = *(cp++); author_name[i] = '\0'; cp++; //skip ' ' char str_timestamp[11]; for (i=0;i<10;i++) { str_timestamp[i] = *(cp++); } str_timestamp[10] = '\0'; char timediff[6]; cp++; //skip ' ' for (i=0;i<5;i++) { timediff[i] = *(cp++); } timediff[5] = '\0'; while (*(++cp) != '\n') ; cp+=2; //skip \n and \n time_t t; t = atoi(str_timestamp); struct tm *tm; int tz = atoi(timediff); tm = time_to_tm(t, tz); // see show_date in date.c#L207 sprintf(frmted_time ,"%.3s %.3s %d %02d:%02d:%02d %d%c%+05d", weekday_names[tm->tm_wday], month_names[tm->tm_mon], tm->tm_mday, tm->tm_hour, tm->tm_min, tm->tm_sec, tm->tm_year + 1900, ' ', tz ); strcpy(pcmt->tree_sha1, tree_sha1); strcpy(pcmt->parent_sha1, parent_sha1); strcpy(pcmt->frmted_time, frmted_time); strcpy(pcmt->author_name, author_name); pcmt->message = cp; }