/***************************************************************************** Description : 1s frequency control release timer timeout, this function will be triggered. It will release the minimal CPU and DDR frequency lock. This function run in the frequency control work quenue. Prototype : void k3v2_release_freq_lock_work(struct work_struct *work) Input Param : Output Param : Return Value : ******************************************************************************/ static void k3v2_release_freq_lock_work(struct work_struct *work) { freq_lock_control_t *fl_control_ptr = container_of(work, freq_lock_control_t, release_lock_work); lfprintf("k3v2_release_freq_lock_work call enter.\n"); #ifdef DEBUG_WIFI_FREQ_LOCK pre_release_jiffies = jiffies; #endif if(NULL == fl_control_ptr){ printk("k3v2_release_freq_lock_work NULL point error!\n"); return; } mutex_lock(&fl_control_ptr->lock_freq_mtx); if(LR_SHOULD_DROP_MAGIC == fl_control_ptr->release_work_state ){ lfprintf("k3v2_release_freq_lock_work work has been drop, not do lock release, return here.\n"); fl_control_ptr->release_work_state = LR_DISABLE_MAGIC; return; } if(FREQ_LOCK_ENABLE == fl_control_ptr->lock_mod){ #ifdef CONFIG_CPU_FREQ_GOV_K3HOTPLUG /*lock freq timer timeout, do frequency lock release process here.*/ pm_qos_remove_request(&fl_control_ptr->cpu_qos_request); if(fl_control_ptr->lock_level >= START_DDR_FREQ_LOCK_LEVEL){ pm_qos_remove_request(&fl_control_ptr->ddr_qos_request); } #endif fl_control_ptr->release_work_state = LR_DISABLE_MAGIC; fl_control_ptr->lock_mod = FREQ_LOCK_DISABLE; } mutex_unlock(&fl_control_ptr->lock_freq_mtx); }
int SMTP_STARTTLS_withCL(Connection *Conn,FILE *fc,FILE *tc){ CStr(stat,1024); int fcl; if( willSTLS_CL(Conn) ){ SSLstart = 1; fcl = insertTLS_CL(Conn,FromC,ToS); SSLstart = 0; if( 0 <= fcl ){ lfprintf(NULL,tc,"220 Ready to start TLS\r\n"); fflush(tc); fflush(fc); /* wait the completion of SSL negotiation and * initialization in SSLway thread for safety ... */ PollIn(fcl,TIMEOUT_STLS); dup2(fcl,fileno(tc)); dup2(fcl,fileno(fc)); close(fcl); return 1; } } lfprintf(NULL,tc,"454 A Don't start TLS\r\n"); fflush(tc); return 0; }
/***************************************************************************** Description : Do workqueue release , mamery freee etc while the WiFi driver closing. Prototype : int v9r1_freq_ctrl_destroy(void) Input Param : Output Param : Return Value : ******************************************************************************/ int v9r1_freq_ctrl_destroy(void) { #ifdef CONFIG_CPU_FREQ_GOV_K3HOTPLUG lfprintf("v9r1_freq_ctrl_destroy enter\n"); if (NULL == freq_lock_control_ptr) { lfprintf("freq_lock_control_ptr NULL pointer!\n"); return 0; } mutex_lock(&freq_lock_control_ptr->lock_freq_mtx); del_timer_sync(&freq_lock_control_ptr->lock_freq_timer_list); /*If the Wi-Fi is closing, but the frequency lock release timer is not timeout, * must release the lock directly here!*/ if(FREQ_LOCK_ENABLE == freq_lock_control_ptr->lock_mod){ pm_qos_remove_request(&freq_lock_control_ptr->cpu_qos_request); if(freq_lock_control_ptr->lock_level >= START_DDR_FREQ_LOCK_LEVEL){ pm_qos_remove_request(&freq_lock_control_ptr->ddr_qos_request); } freq_lock_control_ptr->release_work_state = LR_DISABLE_MAGIC; freq_lock_control_ptr->lock_mod = FREQ_LOCK_DISABLE; lfprintf("v9r1_freq_ctrl_destroy freq lock release here!\n"); } #ifdef DEBUG_WIFI_FREQ_LOCK else{ lfprintf("v9r1_freq_ctrl_destroy freq lock has already been released!\n"); } #endif cancel_work_sync(&freq_lock_control_ptr->release_lock_work); cancel_work_sync(&freq_lock_control_ptr->do_freq_lock_work); destroy_workqueue(freq_lock_control_ptr->freq_ctl_wq); mutex_unlock(&freq_lock_control_ptr->lock_freq_mtx); mutex_destroy(&freq_lock_control_ptr->lock_freq_mtx); kfree(freq_lock_control_ptr); freq_lock_control_ptr = NULL; printk("wl monitor exit ok!\n"); #endif /*end of #ifdef CONFIG_CPU_FREQ_GOV_K3HOTPLUG*/ return 0; }
/***************************************************************************** Description : Do memory allocation, workqueue set up etc while the WiFi driver opening. Prototype : int v9r1_freq_ctrl_init(void) Input Param : Output Param : Return Value : ******************************************************************************/ int v9r1_freq_ctrl_init(void){ printk( KERN_ALERT "enter v9r1_freq_ctrl_init"); #ifdef CONFIG_CPU_FREQ_GOV_K3HOTPLUG lfprintf("v9r1_wifi_freq_ctl_init enter,ulong:%d, uint:%d\n", sizeof(unsigned long), sizeof(unsigned int)); /*start cumulate rx tx bytes, record the first start time*/ pre_jiffies = jiffies; #ifdef DEBUG_WIFI_FREQ_LOCK pre_release_jiffies = jiffies; pre_freq_cfg_jiffies = jiffies; #endif wifi_rxtx_tot = 0; /*init frequency lock control module.*/ freq_lock_control_ptr = kzalloc(sizeof(freq_lock_control_t), GFP_KERNEL); if (!freq_lock_control_ptr){ printk("v9r1_wifi_freq_ctl_init kzalloc error!\n"); goto out; } mutex_init(&freq_lock_control_ptr->lock_freq_mtx); mutex_lock(&freq_lock_control_ptr->lock_freq_mtx); spin_lock_init(&freq_lock_control_ptr->speed_calc_lock); INIT_WORK(&freq_lock_control_ptr->release_lock_work, v9r1_release_freq_lock_work); INIT_WORK(&freq_lock_control_ptr->do_freq_lock_work, v9r1_do_freq_lock_work); setup_timer(&freq_lock_control_ptr->lock_freq_timer_list, v9r1_release_freq_lock_timer, (unsigned long) freq_lock_control_ptr); freq_lock_control_ptr->freq_ctl_wq = create_singlethread_workqueue("wifi_lock_freq"); if (!freq_lock_control_ptr->freq_ctl_wq){ printk("v9r1_wifi_freq_ctl_init create_singlethread_workqueue error!\n"); mutex_unlock(&freq_lock_control_ptr->lock_freq_mtx); goto cleanup; } freq_lock_control_ptr->release_work_state = LR_DISABLE_MAGIC; add_ddr_request(); mutex_unlock(&freq_lock_control_ptr->lock_freq_mtx); printk("wl monitor init ok!\n"); return 0; //err_wq: // destroy_workqueue(freq_lock_control_ptr->freq_ctl_wq); cleanup: kfree(freq_lock_control_ptr); freq_lock_control_ptr = NULL; out: #endif /*end of #ifdef CONFIG_CPU_FREQ_GOV_K3HOTPLUG*/ return -1; }
static bool console_write_userfile(FILE * f, struct userrec *u, struct user_entry *e, int idx) { if (u->bot) return 1; struct console_info *i = (struct console_info *) e->u.extra; if (lfprintf(f, "--CONSOLE %s %s %s %d %d %d %d %d %d %d %d\n", i->channel, masktype(i->conflags), stripmasktype(i->stripflags), i->echoflags, i->page, i->conchan, i->color, i->banner, i->channels, i->bots, i->whom) == EOF) return 0; return 1; }
/***************************************************************************** Description : Set the frequency control as the req_lock_level indicate and start or refresh the 1s frequency control release timer. This function run in the frequency control work quenue. Prototype : void k3v2_do_freq_lock_work(struct work_struct *work) Input Param : Output Param : Return Value : ******************************************************************************/ static void k3v2_do_freq_lock_work(struct work_struct *work){ unsigned char req_lock_level = 0; freq_lock_control_t *fl_control_ptr = container_of(work, freq_lock_control_t, do_freq_lock_work); #ifdef DEBUG_WIFI_FREQ_LOCK unsigned long temp_jiffies; unsigned long freq_cfg_duration; #endif if(NULL == fl_control_ptr){ printk("k3v2_do_freq_lock_work NULL point error!\n"); return; } mutex_lock(&fl_control_ptr->lock_freq_mtx); req_lock_level = fl_control_ptr->req_lock_level; if((req_lock_level > MAX_SPEED_FREQ_LEVEL) || (0 == req_lock_level)){ printk("k3v2_do_freq_lock_work invalid lock_level error!\n"); return; } if(LR_START_MAGIC == fl_control_ptr->release_work_state){ fl_control_ptr->release_work_state = LR_SHOULD_DROP_MAGIC; /*disable the pending release lock work in queue here.*/ lfprintf("WARM: k3v2_do_freq_lock_work set magic for delete pending release lock work.\n"); } if(FREQ_LOCK_ENABLE == fl_control_ptr->lock_mod){ if (req_lock_level != fl_control_ptr->lock_level ){ #ifdef CONFIG_CPU_FREQ_GOV_K3HOTPLUG /* Frequency lock level has been changed. Do new level's frequency lock here.*/ pm_qos_update_request(&fl_control_ptr->cpu_qos_request, speed_freq_level[req_lock_level-1].min_cpu_freq); if(fl_control_ptr->lock_level < START_DDR_FREQ_LOCK_LEVEL){ /*Old DDR frequency lock is not open*/ if(req_lock_level >= START_DDR_FREQ_LOCK_LEVEL){ /* need open DDR frequency lock now.*/ pm_qos_add_request(&fl_control_ptr->ddr_qos_request, PM_QOS_DDR_MIN_PROFILE, speed_freq_level[req_lock_level-1].min_ddr_freq); } /*If old and new lock level all smaller than START_DDR_FREQ_LOCK_LEVEL, * not need request the DDR frequency lock still.*/ }else{ /*Old DDR frequency lock is open*/ if(req_lock_level >= START_DDR_FREQ_LOCK_LEVEL){ /*New DDR frequency lock need open also,just update it.*/ pm_qos_update_request(&fl_control_ptr->ddr_qos_request, speed_freq_level[req_lock_level-1].min_ddr_freq); }else{ /*Old DDR frequency lock is open, new lock level not need it to be open, * release the DDR frequency lock .*/ pm_qos_remove_request(&fl_control_ptr->ddr_qos_request); } } fl_control_ptr->lock_level = req_lock_level; #endif /*end of #ifdef CONFIG_CPU_FREQ_GOV_K3HOTPLUG*/ #ifdef DEBUG_WIFI_FREQ_LOCK temp_jiffies = jiffies; freq_cfg_duration = jiffies_to_msecs(temp_jiffies - pre_freq_cfg_jiffies); pre_freq_cfg_jiffies = temp_jiffies; lfprintf("k3v2_do_freq_lock_work enter refresh lock level, with lock_level=%d, interval=%lu.%lu s\n", req_lock_level, freq_cfg_duration/1000, freq_cfg_duration%1000); #endif } }else{ #ifdef DEBUG_WIFI_FREQ_LOCK temp_jiffies = jiffies; freq_cfg_duration = jiffies_to_msecs(temp_jiffies - pre_release_jiffies); lfprintf("k3v2_do_freq_lock_work new lock request from last release time: %lu.%lu s \n", freq_cfg_duration/1000, freq_cfg_duration%1000); #endif /*freq lock is disabled, enable it now*/ fl_control_ptr->lock_mod = FREQ_LOCK_ENABLE; fl_control_ptr->lock_level = req_lock_level; #ifdef CONFIG_CPU_FREQ_GOV_K3HOTPLUG pm_qos_add_request(&fl_control_ptr->cpu_qos_request, PM_QOS_CPU_MIN_PROFILE, speed_freq_level[req_lock_level-1].min_cpu_freq); if(req_lock_level >= START_DDR_FREQ_LOCK_LEVEL){ pm_qos_add_request(&fl_control_ptr->ddr_qos_request, PM_QOS_DDR_MIN_PROFILE, speed_freq_level[req_lock_level-1].min_ddr_freq); } #endif } /*start or reset release timer */ mod_timer(&freq_lock_control_ptr->lock_freq_timer_list, jiffies + msecs_to_jiffies(FREQ_LOCK_TIMEOUT_VAL)); mutex_unlock(&fl_control_ptr->lock_freq_mtx); }
int main( int argc, char **argv ) { config_t *cfg; station_mgr_t *stationmgr = 0; videoinput_t *vidin; int fi, on, tuned; int f, f1, f2, fc; int verbose, norm; int curstation = 1; char error_string[ 4096 ]; /* * Setup i18n. This has to be done as early as possible in order * to show startup messages in the users preferred language. */ setup_i18n(); cfg = config_new(); if( !cfg ) { fprintf( stderr, _("%s: Cannot allocate memory.\n"), argv[ 0 ] ); return 1; } if( !config_parse_tvtime_scanner_command_line( cfg, argc, argv ) ) { config_delete( cfg ); return 1; } verbose = config_get_verbose( cfg ); if( !strcasecmp( config_get_v4l_norm( cfg ), "pal" ) ) { norm = VIDEOINPUT_PAL; } else if( !strcasecmp( config_get_v4l_norm( cfg ), "secam" ) ) { norm = VIDEOINPUT_SECAM; } else if( !strcasecmp( config_get_v4l_norm( cfg ), "pal-nc" ) ) { norm = VIDEOINPUT_PAL_NC; } else if( !strcasecmp( config_get_v4l_norm( cfg ), "pal-m" ) ) { norm = VIDEOINPUT_PAL_M; } else if( !strcasecmp( config_get_v4l_norm( cfg ), "pal-n" ) ) { norm = VIDEOINPUT_PAL_N; } else if( !strcasecmp( config_get_v4l_norm( cfg ), "ntsc-jp" ) ) { norm = VIDEOINPUT_NTSC_JP; } else if( !strcasecmp( config_get_v4l_norm( cfg ), "pal-60" ) ) { norm = VIDEOINPUT_PAL_60; } else { /* Only allow NTSC otherwise. */ norm = VIDEOINPUT_NTSC; } fprintf( stderr, _("Scanning using TV standard %s.\n"), videoinput_get_norm_name( norm ) ); stationmgr = station_new( videoinput_get_norm_name( norm ), "Custom", 0, verbose ); if( !stationmgr ) { lfprintf( stderr, _("%s: Cannot allocate memory.\n"), argv[ 0 ] ); config_delete( cfg ); return 1; } vidin = videoinput_new( config_get_v4l_device( cfg ), config_get_inputwidth( cfg ), config_get_audio_boost( cfg ), norm, verbose, error_string ); if( !vidin ) { station_delete( stationmgr ); config_delete( cfg ); return 1; } else { videoinput_set_input_num( vidin, config_get_inputnum( cfg ) ); } if( !videoinput_has_tuner( vidin ) ) { fprintf( stderr, _("\n" " No tuner found on input %d. If you have a tuner, please\n" " select a different input using --input=<num>.\n\n"), config_get_inputnum( cfg ) ); videoinput_delete( vidin ); station_delete( stationmgr ); config_delete( cfg ); return 1; } /* Scan freqnencies */ fprintf( stderr, _("Scanning from %6.2f MHz to %6.2f MHz.\n"), 44.0, 958.0 ); on = 0; fc = 0; f1 = 0; f2 = 0; fi = -1; for( f = 44*16; f <= 958*16; f += 4 ) { char stationmhz[ 128 ]; fprintf( stderr, _("Checking %6.2f MHz:"), ((double) f) / 16.0 ); videoinput_set_tuner_freq( vidin, (f * 1000) / 16 ); usleep( 200000 ); /* 0.2 sec */ tuned = videoinput_freq_present( vidin ); /* state machine */ if( 0 == on && 0 == tuned ) { fprintf( stderr, " - %-30s\r", _("No signal") ); continue; } if( 0 == on && 0 != tuned ) { fprintf( stderr, " + %-30s\r", _("Signal detected") ); f1 = f; /* if( i != chancount ) { fi = i; fc = f; } */ on = 1; continue; } if( 0 != on && 0 != tuned ) { fprintf( stderr, " * %-30s\r", _("Signal detected") ); /* if( i != chancount ) { fi = i; fc = f; } */ continue; } /* if (on != 0 && 0 == tuned) -- found one, read name from vbi */ f2 = f; if( 0 == fc ) { fc = (f1 + f2) / 2; /* Round to the nearest .25MHz */ fc = ((fc + 2)/4)*4; } fprintf( stderr, "\r" ); fprintf( stderr, _("Found a channel at %6.2f MHz (%.2f - %.2f MHz), " "adding to channel list.\n"), ((double) fc) / 16.0, ((double) f1) / 16.0, ((double) f2) / 16.0 ); sprintf( stationmhz, "%.2fMHz", ((double) fc) / 16.0 ); station_add( stationmgr, curstation, "Custom", stationmhz, stationmhz ); station_writeconfig( stationmgr ); curstation++; on = 0; fc = 0; f1 = 0; f2 = 0; fi = -1; } station_delete( stationmgr ); config_delete( cfg ); return 0; }