Esempio n. 1
0
File: g.cpp Progetto: hphp/Algorithm
void dp(void)
{
	for(int i=0;i<n;i++)
	{
		dp_init(0,i);
		Rmq(0,i);
	}
	for(int i=0;i<m;i++)
	{
		dp_init(1,i);
		Rmq(1,i);
	}
}
int
main(int argc, char *argv[])
{
    int c;
    int delay = -1;
    int do_monitor = 0;
    int dump_settings = 0;
    int first_cmd;

    Display *dpy;
    XDevice *dev;

    if (argc == 1)
        dump_settings = 1;

    /* Parse command line parameters */
    while ((c = getopt(argc, argv, "sm:hlV")) != -1) {
	switch (c) {
	case 'm':
	    do_monitor = 1;
	    if ((delay = atoi(optarg)) < 0)
		usage();
	    break;
	case 'l':
	    dump_settings = 1;
	    break;
	case 'V':
	    printf("%s\n", VERSION);
	    exit(0);
	default:
	    usage();
	}
    }

    first_cmd = optind;
    if (!do_monitor && !dump_settings && first_cmd == argc)
	usage();

    /* Connect to the shared memory area */
    if (do_monitor)
        shm_process_commands(do_monitor, delay);

    dpy = dp_init();
    if (!dpy || !(dev = dp_get_device(dpy)))
        return 1;

    dp_set_variables(dpy, dev, argc, argv, first_cmd);
    if (dump_settings)
        dp_show_settings(dpy, dev);

    XCloseDevice(dpy, dev);
    XCloseDisplay(dpy);

    return 0;
}
Esempio n. 3
0
File: i.cpp Progetto: hphp/Algorithm
void dp()
{
    dp_init();
    double mxmx = 0;
    for(int i=1; i<=n; i++)
    {
        if(stuff[i].type==0)
        {
            for(int j=recmx; j>=0; j--)
            {
                double tmp = 0;
                if(j+stuff[i].c>w)continue;
                tmp = mx[j]+stuff[i].v;
                if(tmp > mx[j+stuff[i].c])
                {
                    mx[j+stuff[i].c]=tmp;
                    if(mxmx < tmp )mxmx = tmp;
                }
            }
        }
        else
        {
            /*			for(int j=0;j<=w;j++)
            				need[j]=0;
            			double reca = stuff[i].v*1.0/stuff[i].c;
            			for(int j=0;j<=recmx&&j<w;j++)
            			{
            				if(mx[j]>=0&&need[j]<stuff[i].c)
            				{
            					double tmp = reca+mx[j];
            					if(mx[j+1]<tmp)
            					{
            						mx[j+1]=tmp;
            						need[j+1]=need[j]+1;
            						printf("%d %d %.2lf\n",j,need[j],tmp);
            						if(tmp > mxmx)
            							mxmx = tmp;
            						if(recmx)
            					}
            				}
            			}*/
        }
        recmx += stuff[i].c;
        if(recmx>w)
            recmx = w;
    }
    printf("%.2lf\n",mxmx);
}
Esempio n. 4
0
/*
 * New collapsed (a)synchronous interface.
 *
 * If the IO is asynchronous (i.e. it has notify.fn), you must either unplug
 * the queue with blk_unplug() some time later or set REQ_SYNC in
io_req->bi_rw. If you fail to do one of these, the IO will be submitted to
 * the disk after q->unplug_delay, which defaults to 3ms in blk-settings.c.
 */
int dm_io(struct dm_io_request *io_req, unsigned num_regions,
	  struct dm_io_region *where, unsigned long *sync_error_bits)
{
	int r;
	struct dpages dp;

	r = dp_init(io_req, &dp);
	if (r)
		return r;

	if (!io_req->notify.fn)
		return sync_io(io_req->client, num_regions, where,
			       io_req->bi_rw, &dp, sync_error_bits);

	return async_io(io_req->client, num_regions, where, io_req->bi_rw,
			&dp, io_req->notify.fn, io_req->notify.context);
}
Esempio n. 5
0
int
main(int argc, char *argv[])
{
    int c;
    int dump_settings = 0;
    int first_cmd;

    Display *dpy;
    XDevice *dev;

    if (argc == 1)
        dump_settings = 1;

    /* Parse command line parameters */
    while ((c = getopt(argc, argv, "lV?")) != -1) {
        switch (c) {
        case 'l':
            dump_settings = 1;
            break;
        case 'V':
            printf("%s\n", VERSION);
            exit(0);
        case '?':
        default:
            usage();
        }
    }

    first_cmd = optind;
    if (!dump_settings && first_cmd == argc)
        usage();

    dpy = dp_init();
    if (!dpy || !(dev = dp_get_device(dpy)))
        return 1;

    dp_set_variables(dpy, dev, argc, argv, first_cmd);
    if (dump_settings)
        dp_show_settings(dpy, dev);

    XCloseDevice(dpy, dev);
    XCloseDisplay(dpy);

    return 0;
}
Esempio n. 6
0
File: G.cpp Progetto: hphp/Algorithm
void dp(void)
{
	dp_init();
	for(int i=1;i<=n;i++)
	{
		mxearn[i]=mxearn[i-1];
		for(int j=1;j<i;j++)
		{
			Int temp;
			if(mxearn[j-1]>=price[j])
				temp = (mxearn[j-1]/price[j])*price[i]+mxearn[j-1]%price[j]-s;
			else temp = 0;
			if(temp>mxearn[i])
				mxearn[i]=temp;
		}
	//	printf("%lld\n",mxearn[i]);
	}
}
Esempio n. 7
0
/* this is really aimed at the lcd panel. That said, there are two display
 * devices on this part and we may someday want to extend it for other boards.
 */
void display_startup(device_t dev)
{
	struct soc_nvidia_tegra124_config *config = dev->chip_info;
	struct display_controller *disp_ctrl = (void *)config->display_controller;
	struct pwm_controller 	*pwm = (void *)TEGRA_PWM_BASE;
	struct tegra_dc		*dc = &dc_data;
	u32 plld_rate;

	/* init dc */
	dc->base = (void *)TEGRA_ARM_DISPLAYA;
	dc->config = config;
	config->dc_data = dc;

	/* Note dp_init may read EDID and change some config values. */
	dp_init(config);

	/* should probably just make it all MiB ... in future */
	u32 framebuffer_size_mb = config->framebuffer_size / MiB;
	u32 framebuffer_base_mb= config->framebuffer_base / MiB;

	/* light it all up */
	/* This one may have been done in romstage but that's ok for now. */
	if (config->panel_vdd_gpio){
		gpio_output(config->panel_vdd_gpio, 1);
		printk(BIOS_SPEW,"%s: panel_vdd setting gpio %08x to %d\n",
			__func__, config->panel_vdd_gpio, 1);
	}
	udelay(config->vdd_delay_ms * 1000);
	if (config->backlight_vdd_gpio){
		gpio_output(config->backlight_vdd_gpio, 1);
		printk(BIOS_SPEW,"%s: backlight vdd setting gpio %08x to %d\n",
			__func__, config->backlight_vdd_gpio, 1);
	}
	if (config->lvds_shutdown_gpio){
		gpio_output(config->lvds_shutdown_gpio, 0);
		printk(BIOS_SPEW,"%s: lvds shutdown setting gpio %08x to %d\n",
			__func__, config->lvds_shutdown_gpio, 0);
	}

	if (framebuffer_size_mb == 0){
		framebuffer_size_mb = ALIGN_UP(config->xres * config->yres *
			(config->framebuffer_bits_per_pixel / 8), MiB)/MiB;
	}

	if (! framebuffer_base_mb)
		framebuffer_base_mb = fb_base_mb();

	config->framebuffer_size = framebuffer_size_mb * MiB;
	config->framebuffer_base = framebuffer_base_mb * MiB;

	mmu_config_range(framebuffer_base_mb, framebuffer_size_mb,
		config->cache_policy);

	printk(BIOS_SPEW, "LCD frame buffer at %dMiB to %dMiB\n", framebuffer_base_mb,
		   framebuffer_base_mb + framebuffer_size_mb);

	/* GPIO magic here if needed to start powering up things. You
	 * really only want to enable vdd, wait a bit, and then enable
	 * the panel. However ... the timings in the tegra20 dts make
	 * no sense to me. I'm pretty sure they're wrong.
	 * The panel_vdd is done in the romstage, so we need only
	 * light things up here once we're sure it's all working.
	 */

	/* The plld is programmed with the assumption of the SHIFT_CLK_DIVIDER
	 * and PIXEL_CLK_DIVIDER are zero (divide by 1). See the
	 * update_display_mode() for detail.
	 */
	plld_rate = clock_display(config->pixel_clock * 2);
	if (plld_rate == 0) {
		printk(BIOS_ERR, "dc: clock init failed\n");
		return;
	} else if (plld_rate != config->pixel_clock * 2) {
		printk(BIOS_WARNING, "dc: plld rounded to %u\n", plld_rate);
		config->pixel_clock = plld_rate / 2;
	}

	/* Init dc */
	if (tegra_dc_init(disp_ctrl)) {
		printk(BIOS_ERR, "dc: init failed\n");
		return;
	}

	/* Configure dc mode */
	if (update_display_mode(disp_ctrl, config)) {
		printk(BIOS_ERR, "dc: failed to configure display mode.\n");
		return;
	}

	/* Enable dp */
	dp_enable(dc->out);

	/* Init frame buffer */
	memset((void *)(framebuffer_base_mb*MiB), 0x00,
			framebuffer_size_mb*MiB);

	update_window(disp_ctrl, config);

	/* Set up Tegra PWM n (where n is specified in config->pwm) to drive the
	 * panel backlight.
	 */
	printk(BIOS_SPEW, "%s: enable panel backlight pwm\n", __func__);
	WRITEL(((1 << NV_PWM_CSR_ENABLE_SHIFT) |
		(220 << NV_PWM_CSR_PULSE_WIDTH_SHIFT) | /* 220/256 */
		0x02e), /* frequency divider */
	       &pwm->pwm[config->pwm].csr);

	udelay(config->pwm_to_bl_delay_ms * 1000);
	if (config->backlight_en_gpio){
		gpio_output(config->backlight_en_gpio, 1);
		printk(BIOS_SPEW,"%s: backlight enable setting gpio %08x to %d\n",
			__func__, config->backlight_en_gpio, 1);
	}

	printk(BIOS_INFO, "%s: display init done.\n", __func__);

	/* tell depthcharge ...
	 */
	struct edid edid;
	edid.bytes_per_line = ((config->xres * config->framebuffer_bits_per_pixel / 8 + 31) /
				32 * 32);
	edid.x_resolution = edid.bytes_per_line / (config->framebuffer_bits_per_pixel / 8);
	edid.y_resolution = config->yres;
	edid.framebuffer_bits_per_pixel = config->framebuffer_bits_per_pixel;
	set_vbe_mode_info_valid(&edid, (uintptr_t)(framebuffer_base_mb*MiB));
}
Esempio n. 8
0
int
main(int argc, char *argv[])
{
    int c;
    int delay = -1;
    int do_monitor = 0;
    int dump_hw = 0;
    int dump_settings = 0;
    int use_shm = 1;
    int first_cmd;

#ifdef HAVE_PROPERTIES
    use_shm = 0;
#endif

    /* Parse command line parameters */
    while ((c = getopt(argc, argv, "sm:hlV")) != -1) {
	switch (c) {
	case 's':
	    use_shm = 1;
	    break;
	case 'm':
	    use_shm = 1;
	    do_monitor = 1;
	    if ((delay = atoi(optarg)) < 0)
		usage();
	    break;
	case 'h':
	    use_shm = 1;
	    dump_hw = 1;
	    break;
	case 'l':
	    dump_settings = 1;
	    break;
	case 'V':
//	    printf("%s\n", VERSION);
	    exit(0);
	default:
	    usage();
	}
    }

    first_cmd = optind;
    if (!do_monitor && !dump_hw && !dump_settings && first_cmd == argc)
	usage();

    /* Connect to the shared memory area */
    if (use_shm)
    {
	SynapticsSHM *synshm = NULL;

	synshm = shm_init();
	if (!synshm)
	    return 1;

	/* Perform requested actions */
	if (dump_hw)
	    shm_show_hw_info(synshm);

	shm_set_variables(synshm, argc, argv, first_cmd);

	if (dump_settings)
	    shm_show_settings(synshm);
	if (do_monitor)
	    shm_monitor(synshm, delay);
    }
#ifdef HAVE_PROPERTIES
    else /* Device properties */
    {
	Display *dpy;
	XDevice *dev;

	dpy = dp_init();
	if (!dpy || !(dev = dp_get_device(dpy)))
	    return 1;

	dp_set_variables(dpy, dev, argc, argv, first_cmd);
	if (dump_settings)
	    dp_show_settings(dpy, dev);

	XCloseDevice(dpy, dev);
	XCloseDisplay(dpy);
    }
#endif

    return 0;
}
Esempio n. 9
0
static int
thread_init ()
{
    gStopTickTask = FALSE;
    /*
     * This will have already been called for CPR CNU code,
     * but may be called here for Windows emulation.
     */
    (void) cprPreInit();


    PHNChangeState(STATE_FILE_CFG);

    /* initialize message queues */
    sip_msgq = cprCreateMessageQueue("SIPQ", SIPQSZ);
    gsm_msgq = cprCreateMessageQueue("GSMQ", GSMQSZ);

    if (FALSE == gHardCodeSDPMode) {
        misc_app_msgq = cprCreateMessageQueue("MISCAPPQ", DEFQSZ);
    }
    ccapp_msgq = cprCreateMessageQueue("CCAPPQ", DEFQSZ);
#ifdef JINDO_DEBUG_SUPPORTED
    debug_msgq = cprCreateMessageQueue("DEBUGAPPQ", DEFQSZ);
#endif
#ifdef EXTERNAL_TICK_REQUIRED
    ticker_msgq = cprCreateMessageQueue("Ticker", DEFQSZ);
#endif


    /*
     * Initialize the command parser and debug infrastructure
     */
    debugInit();

    /* create threads */
    ccapp_thread = cprCreateThread("CCAPP Task",
                                 (cprThreadStartRoutine) CCApp_task,
                                 GSMSTKSZ, CCPROVIDER_THREAD_RELATIVE_PRIORITY /* pri */, ccapp_msgq);
    if (ccapp_thread == NULL) {
        err_msg("failed to create CCAPP task \n");
    }

#ifdef JINDO_DEBUG_SUPPORTED
#ifndef VENDOR_BUILD
    debug_thread = cprCreateThread("Debug Task",
                                   (cprThreadStartRoutine) debug_task, STKSZ,
                                   0 /*pri */ , debug_msgq);

    if (debug_thread == NULL) {
        err_msg("failed to create debug task\n");
    }
#endif
#endif
	
    /* SIP main thread */
    sip_thread = cprCreateThread("SIPStack task",
                                 (cprThreadStartRoutine) sip_platform_task_loop,
                                 STKSZ, SIP_THREAD_RELATIVE_PRIORITY /* pri */, sip_msgq);
    if (sip_thread == NULL) {
        err_msg("failed to create sip task \n");
    }

#ifdef NO_SOCKET_POLLING
    /* SIP message wait queue task */
    sip_msgqwait_thread = cprCreateThread("SIP MsgQueueWait task",
                                          (cprThreadStartRoutine)
                                          sip_platform_task_msgqwait,
                                          STKSZ, SIP_THREAD_RELATIVE_PRIORITY /* pri */, sip_msgq);
    if (sip_msgqwait_thread == NULL) {
        err_msg("failed to create sip message queue wait task\n");
    }
#endif

    gsm_thread = cprCreateThread("GSM Task",
                                 (cprThreadStartRoutine) GSMTask,
                                 GSMSTKSZ, GSM_THREAD_RELATIVE_PRIORITY /* pri */, gsm_msgq);
    if (gsm_thread == NULL) {
        err_msg("failed to create gsm task \n");
    }

    if (FALSE == gHardCodeSDPMode) {
    	misc_app_thread = cprCreateThread("MiscApp Task",
    			(cprThreadStartRoutine) MiscAppTask,
    			STKSZ, 0 /* pri */, misc_app_msgq);
    	if (misc_app_thread == NULL) {
    		err_msg("failed to create MiscApp task \n");
    	}
    }

#ifdef EXTERNAL_TICK_REQUIRED
    ticker_thread = cprCreateThread("Ticker task",
                                    (cprThreadStartRoutine) TickerTask,
                                    STKSZ, 0, ticker_msgq);
    if (ticker_thread == NULL) {
        err_msg("failed to create ticker task \n");
    }
#endif

    /* Associate the threads with the message queues */
    (void) cprSetMessageQueueThread(sip_msgq, sip_thread);  
    (void) cprSetMessageQueueThread(gsm_msgq, gsm_thread);

    if (FALSE == gHardCodeSDPMode) {
    	(void) cprSetMessageQueueThread(misc_app_msgq, misc_app_thread);
    }

    (void) cprSetMessageQueueThread(ccapp_msgq, ccapp_thread);
#ifdef JINDO_DEBUG_SUPPORTED
    (void) cprSetMessageQueueThread(debug_msgq, debug_thread);
#endif
#ifdef EXTERNAL_TICK_REQUIRED
    (void) cprSetMessageQueueThread(ticker_msgq, ticker_thread);
#endif

    /*
     * initialize debugs of other modules.
     *
     * dp_init needs the gsm_msgq id. This
     * is set in a global variable by the
     * GSM task running. However due to timing
     * issues dp_init is sometimes run before
     * the GSM task has set this variable resulting
     * in a NULL msgqueue ptr being passed to CPR
     * which returns an error and does not create
     * the dialplan timer. Thus pass is the same
     * data to dp_init that is passed into the
     * cprCreateThread call for GSM above.
     */
    config_init();
    vcmInit();
    dp_init(gsm_msgq);

    if (sip_minimum_config_check() != 0) {
        PHNChangeState(STATE_UNPROVISIONED);
    } else {
        PHNChangeState(STATE_CONNECTED);
    }

    (void) cprPostInit();

    if ( vcmGetVideoCodecList(VCM_DSP_FULLDUPLEX) ) {
        cc_media_update_native_video_support(TRUE);
    }

    return (0);
}