예제 #1
0
// On this controller the back-light is controlled by the controllers internal PWM
//	which is why it is in this file rather than the board file.
static inline void set_backlight(GDisplay* g, uint8_t percent) {
	uint8_t temp;

	//Work in progress: the RA8875 has a built-in PWM, its output can
	//be used by a Dynamic Background Control or by a host (user)

	// Enable PWM1
	write_index(g, 0x8a);						//MCLR
	setreadmode(g);
	temp = read_data(g);
	setwritemode(g);
	temp |= 1<<7 ;
	write_data(g, temp);

	// PWM1 function select
	write_index(g, 0x8a);						//MCLR
	setreadmode(g);
	temp = read_data(g);
	setwritemode(g);
	temp &= ~(1<<4);
	write_data(g, temp);

	// PWM1 Clock ratio
	write_index(g, 0x8a);						//MCLR
	setreadmode(g);
	temp = read_data(g);
	setwritemode(g);
	temp &= 0xf0;
	temp |= 0x0b & 0x0f;
	write_data(g, temp);

	// PWM1 Write duty cycle
	write_reg8(g, 0x8b, 54+percent);			// PTNO: Also change percent to range from 0x00 to 0xFF
}
예제 #2
0
static inline void set_viewport(GDisplay* g) {
	write_index(g, SSD1963_SET_PAGE_ADDRESS);
	write_data16(g, g->p.y);
	write_data16(g, g->p.y+g->p.cy-1);
	write_index(g, SSD1963_SET_COLUMN_ADDRESS);
	write_data16(g, g->p.x);
	write_data16(g, g->p.x+g->p.cx-1);
	write_index(g, SSD1963_WRITE_MEMORY_START);
}
예제 #3
0
bool CommandRenumber::run() {
    if (!m_index_directory.empty()) {
        m_vout << "Reading index files...\n";
        read_index(osmium::item_type::node, "nodes");
        read_index(osmium::item_type::way, "ways");
        read_index(osmium::item_type::relation, "relations");

        m_vout << "  Nodes     index contains " << index(osmium::item_type::node).size()     << " items\n";
        m_vout << "  Ways      index contains " << index(osmium::item_type::way).size()      << " items\n";
        m_vout << "  Relations index contains " << index(osmium::item_type::relation).size() << " items\n";
    }

    m_vout << "First pass through input file (reading relations)...\n";
    osmium::io::Reader reader_pass1(m_input_file, osmium::osm_entity_bits::relation);

    osmium::io::Header header = reader_pass1.header();
    header.set("generator", m_generator);
    header.set("xml_josm_upload", "false");
    for (const auto& h : m_output_headers) {
        header.set(h);
    }
    osmium::io::Writer writer(m_output_file, header, m_output_overwrite);

    osmium::io::InputIterator<osmium::io::Reader, osmium::Relation> it { reader_pass1 };
    osmium::io::InputIterator<osmium::io::Reader, osmium::Relation> end {};

    for (; it != end; ++it) {
        lookup(osmium::item_type::relation, it->id());
    }

    reader_pass1.close();

    m_vout << "Second pass through input file...\n";
    osmium::io::Reader reader_pass2(m_input_file);
    while (osmium::memory::Buffer buffer = reader_pass2.read()) {
        renumber(buffer);
        writer(std::move(buffer));
    }
    reader_pass2.close();

    writer.close();

    if (!m_index_directory.empty()) {
        m_vout << "Writing index files...\n";
        write_index(osmium::item_type::node, "nodes");
        write_index(osmium::item_type::way, "ways");
        write_index(osmium::item_type::relation, "relations");
    }

    m_vout << "Done.\n";

    return true;
}
예제 #4
0
파일: g_save.c 프로젝트: Jenco420/q2pro
static void write_field(FILE *f, const save_field_t *field, void *base)
{
    void *p = (byte *)base + field->ofs;
    int i;

    switch (field->type) {
    case F_BYTE:
        write_data(p, field->size, f);
        break;
    case F_SHORT:
        for (i = 0; i < field->size; i++) {
            write_short(f, ((short *)p)[i]);
        }
        break;
    case F_INT:
        for (i = 0; i < field->size; i++) {
            write_int(f, ((int *)p)[i]);
        }
        break;
    case F_FLOAT:
        for (i = 0; i < field->size; i++) {
            write_float(f, ((float *)p)[i]);
        }
        break;
    case F_VECTOR:
        write_vector(f, (vec_t *)p);
        break;

    case F_ZSTRING:
        write_string(f, (char *)p);
        break;
    case F_LSTRING:
        write_string(f, *(char **)p);
        break;

    case F_EDICT:
        write_index(f, *(void **)p, sizeof(edict_t), g_edicts, MAX_EDICTS - 1);
        break;
    case F_CLIENT:
        write_index(f, *(void **)p, sizeof(gclient_t), game.clients, game.maxclients - 1);
        break;
    case F_ITEM:
        write_index(f, *(void **)p, sizeof(gitem_t), itemlist, game.num_items - 1);
        break;

    case F_POINTER:
        write_pointer(f, *(void **)p, field->size);
        break;

    default:
        gi.error("%s: unknown field type", __func__);
    }
}
예제 #5
0
static void set_viewport(GDisplay *g) {
	write_index(g, 0x2A);
	write_data(g, (g->p.x >> 8));
	write_data(g, (uint8_t) g->p.x);
	write_data(g, (g->p.x + g->p.cx - 1) >> 8);
	write_data(g, (uint8_t) (g->p.x + g->p.cx - 1));

	write_index(g, 0x2B);
	write_data(g, (g->p.y >> 8));
	write_data(g, (uint8_t) g->p.y);
	write_data(g, (g->p.y + g->p.cy - 1) >> 8);
	write_data(g, (uint8_t) (g->p.y + g->p.cy - 1));
}
예제 #6
0
static void set_cursor(GDisplay* g) {
	/* Reg SSD2119_REG_X_RAM_ADDR is 9 bit value
	 * Reg SSD2119_REG_Y_RAM_ADDR is an 8 bit
	 * Use a bit mask to make sure they are not set too high
	 */
	switch(g->g.Orientation) {
		default:
		case GDISP_ROTATE_0:
			write_reg(g, SSD2119_REG_X_RAM_ADDR, g->p.x & 0x01FF);
			write_reg(g, SSD2119_REG_Y_RAM_ADDR, g->p.y & 0x00FF);
			break;
		case GDISP_ROTATE_90:
			write_reg(g, SSD2119_REG_X_RAM_ADDR, g->p.y & 0x01FF);
			write_reg(g, SSD2119_REG_Y_RAM_ADDR, (GDISP_SCREEN_HEIGHT-1 - g->p.x) & 0x00FF);
			break;
		case GDISP_ROTATE_180:
			write_reg(g, SSD2119_REG_X_RAM_ADDR, (GDISP_SCREEN_WIDTH-1 - g->p.x) & 0x01FF);
			write_reg(g, SSD2119_REG_Y_RAM_ADDR, (GDISP_SCREEN_HEIGHT-1 - g->p.y) & 0x00FF);
			break;
		case GDISP_ROTATE_270:
			write_reg(g, SSD2119_REG_X_RAM_ADDR, (GDISP_SCREEN_WIDTH-1 - g->p.y) & 0x01FF);
			write_reg(g, SSD2119_REG_Y_RAM_ADDR, g->p.x & 0x00FF);
			break;
	}
	write_index(g, SSD2119_REG_RAM_DATA);
}
예제 #7
0
int main() {

	int ret;

	write_index();

	// All defaults. Bind to all interfaces, port 2001, default plugins, /tmp.
	// No callbacks are used.
	mklib_ctx ctx = mklib_init(NULL, 0, 0, "/tmp");
	if (!ctx) return 1;

	// The default has no index files, let's set index.html as one.
	ret = mklib_config(ctx, MKC_INDEXFILE, "index.html", NULL);
	if (!ret) return 1;

	// Start the server.
	mklib_start(ctx);

	// I'm now free to do my own things. I'm just going to wait for a keypress.
	printf("All set and running! Visit me, I default to localhost:2001.\n");
	printf("Press a key to exit.\n");
	getchar();

	mklib_stop(ctx);

	return 0;
}
예제 #8
0
static int write_header(AVFormatContext *s)
{
    AVIOContext *pb = s->pb;
    WtvContext *wctx = s->priv_data;
    int i, pad, ret;
    AVStream *st;

    wctx->last_chunk_pos     = -1;
    wctx->last_timestamp_pos = -1;

    ff_put_guid(pb, &ff_wtv_guid);
    ff_put_guid(pb, &sub_wtv_guid);

    avio_wl32(pb, 0x01);
    avio_wl32(pb, 0x02);
    avio_wl32(pb, 1 << WTV_SECTOR_BITS);
    avio_wl32(pb, 1 << WTV_BIGSECTOR_BITS);

    //write initial root fields
    avio_wl32(pb, 0); // root_size, update later
    write_pad(pb, 4);
    avio_wl32(pb, 0); // root_sector, update it later.

    write_pad(pb, 32);
    avio_wl32(pb, 0); // file ends pointer, update it later.

    pad = (1 << WTV_SECTOR_BITS) - avio_tell(pb);
    write_pad(pb, pad);

    wctx->timeline_start_pos = avio_tell(pb);

    wctx->serial = 1;
    wctx->last_chunk_pos = -1;
    wctx->first_video_flag = 1;

    for (i = 0; i < s->nb_streams; i++) {
        st = s->streams[i];
        ret = write_stream_codec(s, st);
        if (ret < 0) {
            av_log(s, AV_LOG_ERROR, "write stream codec failed codec_type(0x%x)\n", st->codec->codec_type);
            return -1;
        }
        if (!i)
            write_sync(s);
    }

    for (i = 0; i < s->nb_streams; i++) {
        st = s->streams[i];
        ret  = write_stream_data(s, st);
        if (ret < 0) {
            av_log(s, AV_LOG_ERROR, "write stream data failed codec_type(0x%x)\n", st->codec->codec_type);
            return -1;
        }
    }

    if (wctx->nb_index)
        write_index(s);

    return 0;
}
예제 #9
0
static void finish_chunk(AVFormatContext *s)
{
    WtvContext *wctx = s->priv_data;
    finish_chunk_noindex(s);
    if (wctx->nb_index == MAX_NB_INDEX)
        write_index(s);
}
예제 #10
0
static void set_cursor(GDisplay *g) {
	/*
	 * Reg 0x004E is an 8 bit value - start x position
	 * Reg 0x004F is 9 bit - start y position
	 * Use a bit mask to make sure they are not set too high
	 */
	switch(g->g.Orientation) {
		default:
		case GDISP_ROTATE_0:
			write_reg(g, 0x4e, g->p.x & 0x00FF);
			write_reg(g, 0x4f, g->p.y & 0x01FF);
			break;
		case GDISP_ROTATE_90:
			write_reg(g, 0x4e, g->p.y & 0x00FF);
			write_reg(g, 0x4f, (GDISP_SCREEN_HEIGHT-1-g->p.x) & 0x01FF);
			break;
		case GDISP_ROTATE_180:
			write_reg(g, 0x4e, (GDISP_SCREEN_WIDTH-1-g->p.x) & 0x00FF);
			write_reg(g, 0x4f, (GDISP_SCREEN_HEIGHT-1-g->p.y) & 0x01FF);
			break;
		case GDISP_ROTATE_270:
			write_reg(g, 0x4e, (GDISP_SCREEN_WIDTH-1-g->p.y) & 0x00FF);
			write_reg(g, 0x4f, g->p.x & 0x01FF);
			break;
	}
	write_index(g, 0x22);
}
예제 #11
0
	/**
	 * @brief   Fill an area with a color.
	 * @note    Optional - The high level driver can emulate using software.
	 *
	 * @param[in] x, y     The start filled area
	 * @param[in] cx, cy   The width and height to be filled
	 * @param[in] color    The color of the fill
	 *
	 * @notapi
	 */
	void gdisp_lld_fill_area(coord_t x, coord_t y, coord_t cx, coord_t cy, color_t color) {
		uint32_t area;
    
		#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
			if (x < GDISP.clipx0) { cx -= GDISP.clipx0 - x; x = GDISP.clipx0; }
			if (y < GDISP.clipy0) { cy -= GDISP.clipy0 - y; y = GDISP.clipy0; }
			if (cx <= 0 || cy <= 0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
			if (x+cx > GDISP.clipx1)	cx = GDISP.clipx1 - x;
			if (y+cy > GDISP.clipy1)	cy = GDISP.clipy1 - y;
		#endif
		
		area = cx*cy;

		gdisp_lld_setwindow(x, y, x+cx-1, y+cy-1);
		write_index(RA8875_WRITE_MEMORY_START);

		#if defined(GDISP_USE_FSMC) && defined(GDISP_USE_DMA) && defined(GDISP_DMA_STREAM)
			uint8_t i;
			dmaStreamSetPeripheral(GDISP_DMA_STREAM, &color);
			dmaStreamSetMode(GDISP_DMA_STREAM, STM32_DMA_CR_PL(0) | STM32_DMA_CR_PSIZE_HWORD | STM32_DMA_CR_MSIZE_HWORD | STM32_DMA_CR_DIR_M2M);  
			for (i = area/65535; i; i--) {
				dmaStreamSetTransactionSize(GDISP_DMA_STREAM, 65535);
				dmaStreamEnable(GDISP_DMA_STREAM);
				dmaWaitCompletion(GDISP_DMA_STREAM);
			}
			dmaStreamSetTransactionSize(GDISP_DMA_STREAM, area%65535);
			dmaStreamEnable(GDISP_DMA_STREAM);
			dmaWaitCompletion(GDISP_DMA_STREAM);
		#else
			uint32_t index;
			for(index = 0; index < area; index++)
				write_data(color);
		#endif  //#ifdef GDISP_USE_DMA
}
예제 #12
0
static void cmd_write(BaseSequentialStream *chp, int argc, char *argv[]) {
    (void)argc;
    (void)argv;

    acquire_bus();

    write_index(0x00);
    chprintf(chp,"Device ID %x\r\n",read_data());
    release_bus();
    //chprintf(chp,"GRAM %x\r\n",gdispReadReg(0x22));
 
    /*gdispClear(White);
    chThdSleepMilliseconds(3000);
    gdispClear(Red);
    chThdSleepMilliseconds(3000);
    gdispClear(Blue);
    chThdSleepMilliseconds(3000);
    gdispClear(Green);*/
    #if 0
    uint8_t c = 0xAA;
    uint8_t d = 0x55;

    spiAcquireBus(&SPID1);              /* Acquire ownership of the bus.    */
    spiStart(&SPID1, &spicfg);       /* Setup transfer parameters.       */
    spiSelect(&SPID1);                  /* Slave Select assertion.          */

    spiSend(&SPID1, 1, &c);
    spiSend(&SPID1, 1, &d);

    spiUnselect(&SPID1);                /* Slave Select de-assertion.       */
    spiReleaseBus(&SPID1);              /* Ownership release.               */
    #endif
}
예제 #13
0
파일: vc-utils.c 프로젝트: 2bj/seafile
int
update_index (struct index_state *istate, const char *index_path)
{
    char index_shadow[PATH_MAX];
    int index_fd;
    int ret = 0;

    snprintf (index_shadow, PATH_MAX, "%s.shadow", index_path);
    index_fd = g_open (index_shadow, O_RDWR | O_CREAT | O_TRUNC | O_BINARY, 0666);
    if (index_fd < 0) {
        g_warning ("Failed to open shadow index: %s.\n", strerror(errno));
        return -1;
    }

    if (write_index (istate, index_fd) < 0) {
        g_warning ("Failed to write shadow index: %s.\n", strerror(errno));
        return -1;
    }
    close (index_fd);

    ret = ccnet_rename (index_shadow, index_path);
    if (ret < 0) {
        g_warning ("Failed to update index errno=%d %s\n", errno, strerror(errno));
        return -1;
    }
    return 0;
}
예제 #14
0
파일: index.c 프로젝트: boyski/libgit2
int git_index_write(git_index *index)
{
	git_filebuf file;
	struct stat indexst;
	int error;

	git_vector_sort(&index->entries);

	if ((error = git_filebuf_open(&file, index->index_file_path, GIT_FILEBUF_HASH_CONTENTS)) < GIT_SUCCESS)
		return git__rethrow(error, "Failed to write index");

	if ((error = write_index(index, &file)) < GIT_SUCCESS) {
		git_filebuf_cleanup(&file);
		return git__rethrow(error, "Failed to write index");
	}

	if ((error = git_filebuf_commit(&file)) < GIT_SUCCESS)
		return git__rethrow(error, "Failed to write index");

	if (p_stat(index->index_file_path, &indexst) == 0) {
		index->last_modified = indexst.st_mtime;
		index->on_disk = 1;
	}

	return GIT_SUCCESS;
}
예제 #15
0
static void fill_gap(indexer_dv_context *This, int isPAL)
{
	int i;

	for (i = 0; i < This->fsize; i++) {
		if (This->gap_start == This->ref_time_read &&
		    This->gap_frame == This->curr_frame)
		{
			fprintf(stderr,
			        "indexer_dv::fill_gap: "
			        "can't seek backwards !\n");
			break;
		}
		inc_frame(&This->gap_frame, &This->gap_start, isPAL);
	}

	while (This->gap_start != This->ref_time_read ||
	       This->gap_frame != This->curr_frame)
	{
		inc_frame(&This->gap_frame, &This->gap_start, isPAL);
		This->frameno_offset++;
	}

	for (i = 0; i < This->fsize; i++) {
		write_index(This, This->backbuffer + i);
	}
	This->fsize = 0;
}
예제 #16
0
	LLDSPEC	void gdisp_lld_read_start(GDisplay *g) {
		acquire_bus(g);
		set_viewport(g);
		write_index(g, 0x2E);
		setreadmode(g);
		dummy_read(g);
	}
예제 #17
0
static inline void set_cursor(GDisplay *g) {
    /* R20h - 8 bit
     * R21h - 9 bit
     */
    switch(g->g.Orientation) {
    	default:
        case GDISP_ROTATE_0:
            write_reg(g, 0x20, g->p.x & 0x00FF);
            write_reg(g, 0x21, g->p.y & 0x01FF);
            break;
        case GDISP_ROTATE_90:
            write_reg(g, 0x20, g->p.y & 0x00FF);
            write_reg(g, 0x21, (GDISP_SCREEN_HEIGHT - 1 - g->p.x) & 0x01FF);
            break;
        case GDISP_ROTATE_180:
            write_reg(g, 0x20, (GDISP_SCREEN_WIDTH - 1 - g->p.x) & 0x00FF);
            write_reg(g, 0x21, (GDISP_SCREEN_HEIGHT - 1 - g->p.y) & 0x01FF);
            break;
        case GDISP_ROTATE_270:
            write_reg(g, 0x20, (GDISP_SCREEN_WIDTH - 1 - g->p.y) & 0x00FF);
            write_reg(g, 0x21, g->p.x & 0x01FF);
            break;
    }
    write_index(g, 0x22);
}
예제 #18
0
int store_data(const char *data_dir, const char *index_path, const char *data_path, int infd, ssize_t expected_length)
{
    DataFiles df;
    if (!create_or_open_datafiles(index_path, data_path, &df)) {
        return 0;
    }

    off_t data_offset = lseek(df.data_fd, 0, SEEK_END);
    if (data_offset == (off_t)-1) {
        perror("Failed to find data file offset");
        goto fail;
    }

    SHA_CTX hash_ctx;
    uint8_t sha1_buf[SHA_DIGEST_LENGTH];
    char sha1_hex_buf[2*SHA_DIGEST_LENGTH + 1];
    if (SHA1_Init(&hash_ctx) == 0) {
        fprintf(stderr, "Failed to init SHA1 hash\n");
        goto fail;
    }

    off_t data_len = 0;
    int status = stream_data(infd, df.data_fd, &data_len, expected_length, &hash_ctx);
    if (SHA1_Final(sha1_buf, &hash_ctx) == 0) {
        fprintf(stderr, "Failed to finish SHA1 hash\n");
        goto fail;
    }
    if (!status) {
        goto fail;
    }

    if (fdatasync(df.data_fd) == -1) {
        perror("Failed to sync data file to disk");
        goto fail;
    }

    to_hex(sha1_buf, SHA_DIGEST_LENGTH, sha1_hex_buf);
    if (!write_index(df.index_fd, data_offset, data_len, sha1_hex_buf)) {
        goto fail;
    }

    if (fdatasync(df.index_fd) == -1) {
        perror("Failed to sync index file to disk");
        goto fail;
    }

    if (df.is_new_file) {
        write_site_index(data_dir);  // Ignore potential error. It was logged.
    }

    close_datafiles(df);
    return 1;

fail:
    close_datafiles(df);
    return 0;
}
예제 #19
0
/**
 * @brief   Draws a pixel on the display.
 *
 * @param[in] x        X location of the pixel
 * @param[in] y        Y location of the pixel
 * @param[in] color    The color of the pixel
 *
 * @notapi
 */
void gdisp_lld_draw_pixel(coord_t x, coord_t y, color_t color) {
	#if GDISP_NEED_VALIDATION || GDISP_NEED_CLIP
	if (x < GDISP.clipx0 || y < GDISP.clipy0 || x >= GDISP.clipx1 || y >= GDISP.clipy1) return;
	#endif
	
	gdisp_lld_setwindow(x, y, x, y);
	write_index(RA8875_WRITE_MEMORY_START);
	write_data(color);
}
예제 #20
0
int main(int argc, char *argv[])
{
	char opt;
	char mode = 0;
	char *filename = NULL;
	char *key = NULL;
	
	while ((opt = getopt_long(argc, argv, "odsw", options, NULL))
		       != -1) {
		switch (opt) {
			case 'o':
				mode = 'o';
				break;
			case 'd':
				mode = 'd';
				break;
			case 's':
				mode = 's';
				break;
			case 'w':
				mode = 'w';
				break;
			default:
				print_usage(argv[0]);
		}
	}
	if (!mode)
		print_usage(argv[0]);
	
	if (optind >= argc)
		print_usage(argv[0]);
	filename = argv[optind];
	
	if (mode == 's' || mode == 'w') {
		if (optind+1 >= argc)
			print_usage(argv[0]);
		key = argv[optind+1];
	}
	
	switch(mode) {
		case 'o':
			write_index(filename);
			break;
		case 'd':
			dump_index(filename);
			break;
		case 's':
			search_index(filename, key);
			break;
		case 'w':
			searchwild_index(filename, key);
			break;
	}
	
	return 0;
}
예제 #21
0
파일: tree.c 프로젝트: sakari/libgit2
int git_tree_create_fromindex(git_oid *oid, git_index *index)
{
	int error;

	if (index->repository == NULL)
		return GIT_EBAREINDEX;

	error = write_index(oid, index, "", 0, 0, git_index_entrycount(index));
	return (error < GIT_SUCCESS) ? error : GIT_SUCCESS;
}
예제 #22
0
파일: index.c 프로젝트: gui11aume/mapper
int main(int argc, char *argv[])
{
   //signal(SIGSEGV, SIGSEGV_handler);
   if (argc != 2) {
      fprintf(stderr, "usage: buildindex <genome file>\n");
      exit(EXIT_FAILURE);
   }

   return write_index(argv[1]);
}
예제 #23
0
 void buffer::ensure_writeable_bytes(std::size_t size) {
     SNOW_LOG_DEBUG << "size " << size;
     if(writeable_bytes() >= size) {
         SNOW_LOG_DEBUG << "courent size enough, return direct";
         return;
     }
     if (m_size - readable_bytes() < size) {
         SNOW_LOG_DEBUG << "create a now buffer size " << m_write_index + size;
         std::unique_ptr<char[]> new_buffer(new char[m_write_index + size]);
         SNOW_LOG_DEBUG << "read index " << read_index() << " write index " << write_index();
         std::copy(read_index(), write_index(), new_buffer.get());
         m_buffer.swap(new_buffer);
         m_size = m_write_index + size;
     }
     std::size_t readable = readable_bytes();
     m_read_index         = 0;
     m_write_index        = m_read_index + readable;
     SNOW_LOG_DEBUG << "total size " << m_size << " readable bytes " << m_write_index - m_read_index << " writeable bytes " << m_size - m_write_index;
     assert(writeable_bytes() >= size);
 }
예제 #24
0
static void indexer_dv_delete(anim_index_builder *idx)
{
	int i = 0;
	indexer_dv_context *This = (indexer_dv_context *) idx->private_data;

	for (i = 0; i < This->fsize; i++) {
		write_index(This, This->backbuffer + i);
	}

	MEM_freeN(This);
}
예제 #25
0
파일: mix_edit.cpp 프로젝트: ChangerR/xcc
int Cmix_edit::compact()
{
	t_block_map block_map = Cmix_edit::block_map();
	int error = 0;
	int offset = cb_header(m_index.size());
	for (auto& i : block_map)
	{
		if (i.second->offset != offset)
		{
			assert(i.second->offset > offset);
			error = copy_block(m_f, i.second->offset, m_f, offset, i.second->size);
			if (error)
				break;
			i.second->offset = offset;
		}
		offset += i.second->size;
	}
	error = error ? write_index(), error : write_index();
	return error;
}
예제 #26
0
static void read_and_refresh_cache(struct replay_opts *opts)
{
	static struct lock_file index_lock;
	int index_fd = hold_locked_index(&index_lock, 0);
	if (read_index_preload(&the_index, NULL) < 0)
		die(_("git %s: failed to read the index"), action_name(opts));
	refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);
	if (the_index.cache_changed) {
		if (write_index(&the_index, index_fd) ||
		    commit_locked_index(&index_lock))
			die(_("git %s: failed to refresh the index"), action_name(opts));
	}
	rollback_lock_file(&index_lock);
}
예제 #27
0
파일: revert.c 프로젝트: MikeBrWade/git
static void read_and_refresh_cache(const char *me)
{
	static struct lock_file index_lock;
	int index_fd = hold_locked_index(&index_lock, 0);
	if (read_index_preload(&the_index, NULL) < 0)
		die("git %s: failed to read the index", me);
	refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, NULL, NULL, NULL);
	if (the_index.cache_changed) {
		if (write_index(&the_index, index_fd) ||
		    commit_locked_index(&index_lock))
			die("git %s: failed to refresh the index", me);
	}
	rollback_lock_file(&index_lock);
}
예제 #28
0
/**
 * The backlight is controlled by the controller.
 */
static inline void set_backlight(GDisplay *g, uint8_t percent) {
	//duty_cycle is 00..FF
	//Work in progress: the SSD1963 has a built-in PWM, its output can
	//be used by a Dynamic Background Control or by a host (user)
	//Check your LCD's hardware, the PWM connection is default left open and instead
	//connected to a LED connection on the breakout board
	write_index(g, SSD1963_SET_PWM_CONF);		//set PWM for BackLight
	write_data(g, 0x01);
	write_data(g, (55+percent*2) & 0x00FF);
	write_data(g, 0x01);						//controlled by host (not DBC), enabled
	write_data(g, 0xFF);
	write_data(g, 0x60);						//don't let it go too dark, avoid a useless LCD
	write_data(g, 0x0F);						//prescaler ???
}
예제 #29
0
static void indexer_dv_proc_frame(anim_index_builder *idx,
                                  unsigned char *buffer,
                                  int UNUSED(data_size),
                                  struct anim_index_entry *entry)
{
	int isPAL;
	
	indexer_dv_context *This = (indexer_dv_context *) idx->private_data;

	isPAL = (buffer[3] & 0x80);

	This->got_record_date = FALSE;
	This->got_record_time = FALSE;

	parse_frame(This, buffer, isPAL);
	proc_frame(This, buffer, isPAL);

	if (This->curr_frame >= 0) {
		write_index(This, entry);
		inc_frame(&This->curr_frame, &This->ref_time_read, isPAL);
	}
	else {
		This->backbuffer[This->fsize++] = *entry;
		if (This->fsize >= 31) {
			int i;

			fprintf(stderr, "indexer_dv::indexer_dv_proc_frame: "
			        "backbuffer overrun, emergency flush");

			for (i = 0; i < This->fsize; i++) {
				write_index(This, This->backbuffer + i);
			}
			This->fsize = 0;
		}
	}
}
예제 #30
0
static void set_cursor(GDisplay *g) {
	switch(g->g.Orientation) {
		default:
		case GDISP_ROTATE_0:
		case GDISP_ROTATE_180:
			write_reg(g, 0x20, g->p.x);
			write_reg(g, 0x21, g->p.y);
			break;

		case GDISP_ROTATE_90:
		case GDISP_ROTATE_270:
			write_reg(g, 0x20, g->p.y);
			write_reg(g, 0x21, g->p.x);
			break;
	}
	write_index(g, 0x22);
}