/* kpse:lookup("plain.tex", {}) */ static int do_lua_kpathsea_lookup(lua_State * L, kpathsea kpse, int idx) { int i; string ret = NULL; string *ret_list = NULL; const_string name = NULL; string user_path = NULL; boolean show_all = false; boolean must_exist = false; kpse_file_format_type user_format = kpse_last_format; int dpi = 600; str_list_type subdir_paths = { 0, NULL }; unsigned saved_debug = kpse->debug; int saved_mktexpk = kpse->format_info[kpse_pk_format].program_enabled_p; int saved_mktexmf = kpse->format_info[kpse_mf_format].program_enabled_p; int saved_mktextex = kpse->format_info[kpse_tex_format].program_enabled_p; int saved_mktextfm = kpse->format_info[kpse_tfm_format].program_enabled_p; name = luaL_checkstring(L, idx); /* todo: fetch parameter values */ if (lua_type(L, idx + 1) == LUA_TTABLE) { lua_pushstring(L, "format"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TSTRING) { int op = luaL_checkoption(L, -1, NULL, filetypenames); user_format = filetypes[op]; } lua_pop(L, 1); lua_pushstring(L, "dpi"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TNUMBER) { dpi=(int)lua_tonumber(L, -1); } lua_pop(L, 1); lua_pushstring(L, "debug"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TNUMBER) { int d = 0; d=(int)lua_tonumber(L, -1); kpse->debug |= d; } lua_pop(L, 1); lua_pushstring(L, "path"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TSTRING) { user_path = xstrdup(lua_tostring(L, -1)); } lua_pop(L, 1); lua_pushstring(L, "all"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TBOOLEAN) { show_all = lua_toboolean(L, -1); } lua_pop(L, 1); lua_pushstring(L, "mktexpk"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TBOOLEAN) { kpathsea_maketex_option(kpse, "pk", lua_toboolean(L, -1)); } lua_pop(L, 1); lua_pushstring(L, "mktextex"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TBOOLEAN) { kpathsea_maketex_option(kpse, "tex", lua_toboolean(L, -1)); } lua_pop(L, 1); lua_pushstring(L, "mktexmf"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TBOOLEAN) { kpathsea_maketex_option(kpse, "mf", lua_toboolean(L, -1)); } lua_pop(L, 1); lua_pushstring(L, "mktextfm"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TBOOLEAN) { kpathsea_maketex_option(kpse, "tfm", lua_toboolean(L, -1)); } lua_pop(L, 1); lua_pushstring(L, "mustexist"); lua_gettable(L, idx + 1); if (lua_type(L, -1) == LUA_TBOOLEAN) { must_exist = lua_toboolean(L, -1); } lua_pop(L, 1); lua_pushstring(L, "subdir"); lua_gettable(L, idx + 1); if (lua_istable(L, -1)) { lua_pushnil(L); while (lua_next(L, -2) != 0) { /* numeric value */ if (lua_isstring(L, -1)) { char *s = xstrdup(lua_tostring(L, -1)); str_list_add(&subdir_paths, s); xfree(s); } lua_pop(L, 1); } } else if (lua_isstring(L, -1)) { char *s = xstrdup(lua_tostring(L, -1)); str_list_add(&subdir_paths, s); xfree(s); } lua_pop(L, 1); if (STR_LIST_LENGTH(subdir_paths) > 0) { show_all = 1; } } if (user_path) { /* Translate ; to : if that's our ENV_SEP. See cnf.c. */ if (IS_ENV_SEP(':')) { string loc; for (loc = user_path; *loc; loc++) { if (*loc == ';') *loc = ':'; } } user_path = kpathsea_path_expand(kpse, user_path); if (show_all) { ret_list = kpathsea_all_path_search(kpse, user_path, name); } else { ret = kpathsea_path_search(kpse, user_path, name, must_exist); } free(user_path); } else { /* No user-specified search path, check user format or guess from NAME. */ kpse_file_format_type fmt; if (user_format != kpse_last_format) fmt = user_format; else fmt = find_format(kpse, name, true); switch (fmt) { case kpse_pk_format: case kpse_gf_format: case kpse_any_glyph_format: { kpse_glyph_file_type glyph_ret; string temp = remove_suffix (name); /* Try to extract the resolution from the name. */ unsigned local_dpi = find_dpi(name); if (!local_dpi) local_dpi = (unsigned) dpi; ret = kpathsea_find_glyph(kpse, temp, local_dpi, fmt, &glyph_ret); if (temp != name) free (temp); } break; case kpse_last_format: /* If the suffix isn't recognized, assume it's a tex file. */ fmt = kpse_tex_format; /* fall through */ default: if (show_all) { ret_list = kpathsea_find_file_generic(kpse, name, fmt, must_exist, true); } else { ret = kpathsea_find_file(kpse, name, fmt, must_exist); } } } /* Turn single return into a null-terminated list for uniform treatment. */ if (ret) { ret_list = XTALLOC(2, string); ret_list[0] = ret; ret_list[1] = NULL; } /* Filter by subdirectories, if specified. */ if (STR_LIST_LENGTH(subdir_paths) > 0) { string *new_list = subdir_match(subdir_paths, ret_list); free(ret_list); ret_list = new_list; } kpse->debug = saved_debug; kpse->format_info[kpse_pk_format].program_enabled_p = saved_mktexpk; kpse->format_info[kpse_mf_format].program_enabled_p = saved_mktexmf; kpse->format_info[kpse_tex_format].program_enabled_p = saved_mktextex; kpse->format_info[kpse_tfm_format].program_enabled_p = saved_mktextfm; /* Print output. */ i = 0; if (ret_list) { for (; ret_list[i]; i++) { lua_pushstring(L, ret_list[i]); } free(ret_list); } if (i == 0) { i++; lua_pushnil(L); } return i; }
PixmanBitmap::PixmanBitmap(void *pixels, int width, int height, int pitch, const DynamicFormat& _format) { format = _format; pixman_format = find_format(format); Init(width, height, pixels, pitch, false); }
int fimc_register_capture_device(struct fimc_dev *fimc) { struct v4l2_device *v4l2_dev = &fimc->vid_cap.v4l2_dev; struct video_device *vfd; struct fimc_vid_cap *vid_cap; struct fimc_ctx *ctx; struct v4l2_format f; int ret; ctx = kzalloc(sizeof *ctx, GFP_KERNEL); if (!ctx) return -ENOMEM; ctx->fimc_dev = fimc; ctx->in_path = FIMC_CAMERA; ctx->out_path = FIMC_DMA; ctx->state = FIMC_CTX_CAP; f.fmt.pix.pixelformat = V4L2_PIX_FMT_RGB24; ctx->d_frame.fmt = find_format(&f, FMT_FLAGS_M2M); if (!v4l2_dev->name[0]) snprintf(v4l2_dev->name, sizeof(v4l2_dev->name), "%s.capture", dev_name(&fimc->pdev->dev)); ret = v4l2_device_register(NULL, v4l2_dev); if (ret) goto err_info; vfd = video_device_alloc(); if (!vfd) { v4l2_err(v4l2_dev, "Failed to allocate video device\n"); goto err_v4l2_reg; } snprintf(vfd->name, sizeof(vfd->name), "%s:cap", dev_name(&fimc->pdev->dev)); vfd->fops = &fimc_capture_fops; vfd->ioctl_ops = &fimc_capture_ioctl_ops; vfd->minor = -1; vfd->release = video_device_release; video_set_drvdata(vfd, fimc); vid_cap = &fimc->vid_cap; vid_cap->vfd = vfd; vid_cap->active_buf_cnt = 0; vid_cap->reqbufs_count = 0; vid_cap->refcnt = 0; /* The default color format for image sensor. */ vid_cap->fmt.code = V4L2_MBUS_FMT_YUYV8_2X8; INIT_LIST_HEAD(&vid_cap->pending_buf_q); INIT_LIST_HEAD(&vid_cap->active_buf_q); spin_lock_init(&ctx->slock); vid_cap->ctx = ctx; videobuf_queue_dma_contig_init(&vid_cap->vbq, &fimc_qops, vid_cap->v4l2_dev.dev, &fimc->irqlock, V4L2_BUF_TYPE_VIDEO_CAPTURE, V4L2_FIELD_NONE, sizeof(struct fimc_vid_buffer), (void *)ctx); ret = video_register_device(vfd, VFL_TYPE_GRABBER, -1); if (ret) { v4l2_err(v4l2_dev, "Failed to register video device\n"); goto err_vd_reg; } v4l2_info(v4l2_dev, "FIMC capture driver registered as /dev/video%d\n", vfd->num); return 0; err_vd_reg: video_device_release(vfd); err_v4l2_reg: v4l2_device_unregister(v4l2_dev); err_info: dev_err(&fimc->pdev->dev, "failed to install\n"); return ret; }
PixmanBitmap::PixmanBitmap(int width, int height, bool transparent) { format = (transparent ? pixel_format : opaque_pixel_format); pixman_format = find_format(format); Init(width, height, (void *) NULL); }