Ejemplo n.º 1
0
int fdt_decode_usb(const void *blob, int node, unsigned osc_frequency_mhz,
		struct fdt_usb *config)
{
	int clk_node = 0, rate;

	/* Find the parameters for our oscillator frequency */
	do {
		clk_node = fdt_node_offset_by_compatible(blob, clk_node,
					"nvidia,tegra250-usbparams");
		if (clk_node < 0)
			return -FDT_ERR_MISSING;
		rate = get_int(blob, clk_node, "osc-frequency", 0);
	} while (rate != osc_frequency_mhz);

	config->reg = (struct usb_ctlr *)get_addr(blob, node, "reg");
	config->host_mode = get_int(blob, node, "host-mode", 0);
	config->utmi = lookup_phandle(blob, node, "utmi") >= 0;
	config->enabled = get_is_enabled(blob, node, 1);
	config->periph_id = get_int(blob, node, "periph-id", -1);
	if (config->periph_id == -1)
		return -FDT_ERR_MISSING;
#if defined(CONFIG_TEGRA3)
	decode_gpio(blob, node, "vbus-gpio", &config->vbus_gpio);
	decode_gpio(blob, node, "vbus_pullup-gpio", &config->vbus_pullup_gpio);
#endif
	return get_int_array(blob, clk_node, "params", config->params,
			PARAM_COUNT);
}
Ejemplo n.º 2
0
Floyd_Result *floyd(const Graph *graph) {
    int i, j, k;
    Floyd_Result *result = (Floyd_Result *) malloc(sizeof(Floyd_Result));
    result->min_path = get_int_array(graph->size, graph->size);
    result->min_weight = get_int_array(graph->size, graph->size);

    for (i = 0; i < graph->size; ++i) {
        for (j = 0; j < graph->size; ++j) {
            if (i == j) {
                result->min_path[i][j] = i;
                result->min_weight[i][j] = 0;
                continue;
            }
            result->min_weight[i][j] = MAX;
            result->min_path[i][j] = NOT_FIND;
        }
    }

    Graph_Edge *temp;
    for (i = 0; i < graph->size; ++i) {
        temp = graph->node[i].first;
        while (temp) {
            result->min_path[i][temp->adj] = i;
            result->min_weight[i][temp->adj] = temp->weight;
            temp = temp->next;
        }
    }

    for (k = 0; k < graph->size; ++k) {
        for (i = 0; i < graph->size; ++i) {
            for (j = 0; j < graph->size; ++j) {
                if (j == k || j == i || k == i)
                    continue;
                if (result->min_weight[i][j] > result->min_weight[i][k] + result->min_weight[k][j]) {
                    result->min_weight[i][j] = result->min_weight[i][k] + result->min_weight[k][j];
                    result->min_path[i][j] = k;
                }
            }
        }
    }

    return result;
}
Ejemplo n.º 3
0
int fdt_decode_lcd(const void *blob, struct fdt_lcd *config)
{
	int node, err, bpp, bit;
	int display_node;

	node = fdt_node_offset_by_compatible(blob, 0, "nvidia,tegra2-lcd");
	if (node < 0)
		return node;
	display_node = lookup_phandle(blob, node, "display");
	if (display_node < 0)
		return display_node;
	config->reg = get_addr(blob, display_node, "reg");
	config->width = get_int(blob, node, "width", -1);
	config->height = get_int(blob, node, "height", -1);
	bpp = get_int(blob, node, "bits_per_pixel", -1);
	bit = ffs(bpp) - 1;
	if (bpp == (1 << bit))
		config->log2_bpp = bit;
	else
		config->log2_bpp = bpp;
	config->bpp = bpp;
	config->pwfm = (struct pwfm_ctlr *)lookup_phandle_reg(blob, node,
							      "pwfm");
	config->disp = (struct disp_ctlr *)lookup_phandle_reg(blob, node,
							  "display");
	config->pixel_clock = get_int(blob, node, "pixel_clock", 0);
	err = get_int_array(blob, node, "horiz_timing", config->horiz_timing,
			FDT_LCD_TIMING_COUNT);
	if (!err)
		err = get_int_array(blob, node, "vert_timing",
				config->vert_timing, FDT_LCD_TIMING_COUNT);
	if (err)
		return err;
	if (!config->pixel_clock || config->reg == -1U || bpp == -1 ||
			config->width == -1 || config->height == -1 ||
			!config->pwfm || !config->disp)
		return -FDT_ERR_MISSING;
	config->frame_buffer = get_addr(blob, node, "frame-buffer");
	return decode_gpio_list(blob, node, "gpios", config->gpios,
				FDT_LCD_GPIOS);
}
Ejemplo n.º 4
0
/*@null@*/ static PyObject*
PyTabprm_get_sense(
    PyTabprm* self,
    /*@unused@*/ void* closure) {

  Py_ssize_t M = 0;

  if (is_null(self->x->sense)) {
    return NULL;
  }

  M = (Py_ssize_t)self->x->M;

  return get_int_array("sense", self->x->sense, 1, &M, (PyObject*)self);
}
Ejemplo n.º 5
0
Dijkstra_Result *dijkstra(const Graph *graph, const int original) {
    // 这点的最短路径前趋
    int *min_path;
    // 点到点的距离
    int **min_weight;

    min_weight = get_int_array(graph->size, graph->size);
    min_path = get_visit_array(graph);

    int i, j;
    for (i = 0; i < graph->size; ++i) {
        for (j = 0; j < graph->size; ++j) {
            if (i == j) {
                min_weight[i][j] = 0;
                continue;
            }
            min_weight[i][j] = MAX;
        }
    }

    Graph_Edge *edge;
    for (i = 0; i < graph->size; ++i) {
        edge = graph->node[i].first;
        while (edge) {
            min_weight[i][edge->adj] = edge->weight;
            min_path[edge->adj] = original;
            edge = edge->next;
        }
    }


    // find 数组记录已经找到最短路径的点
    int *find;
    find = (int *) malloc(graph->size * sizeof(int));
    memset(find, FIND, (unsigned long) graph->size);
    // 首先自己肯定已经找到了最短路径
    find[original] = NOT_FIND;


    int min_index, min;
    for (j = 1; j < graph->size; ++j) {
        // 找出原点中最短的一条边
        min_index = FIND;
        min = MAX;
        for (i = 0; i < graph->size; ++i) {
            if (find[i] != FIND && min_weight[original][i] < min) {
                min = min_weight[original][i];
                min_index = i;
            }
        }
        // 如果这个点已经被标记过,那么证明所有的点都处理过
        if (find[min_index] == FIND)
            break;
        // 标记这个点
        find[min_index] = FIND;
        // 以这个点为中间点,更新最短路程和最短路径前趋
        for (i = 0; i < graph->size; ++i) {
            if (find[i] == FIND)
                continue;
            if (min_weight[original][min_index] + min_weight[min_index][i] < min_weight[original][i]) {
                min_weight[original][i] = min_weight[original][min_index] + min_weight[min_index][i];
                min_path[i] = min_index;
            }
        }
    }
    for (i = 0; i < graph->size; ++i) {
        if (i != original)
            free(min_weight[i]);
    }

    Dijkstra_Result *result;
    result = (Dijkstra_Result *) malloc(sizeof(Dijkstra_Result));
    result->original = original;
    result->min_path = min_path;
    result->min_weight = min_weight[original];
    result->size = graph->size;
    return result;
}