/* * Get the dp uniphy transmitter link. * Encoder term is used for transmitter link here */ static long path_grphs_parse(struct ctx *ctx, u8 idx, struct path *p) { u8 grphs_n; u16 id; u8 sub_id; u8 type; grphs_n = grphs_n_compute(p); if (grphs_n != 1) { dev_err(ctx->atb->adev.dev, "atombios:error, only one encoder graphic object is supported (grphs_n=%u)\n", grphs_n); return -ATB_ERR; } id = get_unaligned_le16(&p->grph_ids); sub_id = id_decode_sub_id(id); type = id_decode_type(id); if (type != GRPH_TYPE_ENCODER && sub_id != ENCODER_SUB_ID_INTERNAL_UNIPHY0 && sub_id != ENCODER_SUB_ID_INTERNAL_UNIPHY1 && sub_id != ENCODER_SUB_ID_INTERNAL_UNIPHY2) { dev_err(ctx->atb->adev.dev, "atombios:error, only uniphy link encoder graphic object is supported (id=0x%04x)\n", id); return -ATB_ERR; } ctx->dp_paths[idx].i = trans(id) * 2 + link_type(id); ctx->dp_paths[idx].uniphy_link_hbr2 = 0; uniphy_link_hbr2_get(ctx, id, &ctx->dp_paths[idx].uniphy_link_hbr2); return 0; }
int DagDrawingTool::link_type( int source_row, int source_index, int target_row, int target_index ) { DagNodeTable& table = *node_table; if( abs( source_row - target_row ) != 1 ) return DDT_LINK_NONE; return link_type( table[source_row][source_index], table[target_row][target_index], source_row < target_row ? DDT_UP_DAG : DDT_DOWN_DAG ); }
void DagDrawingTool::one_sort_pass( int start, int end, float* val_list ) { int i, j, k; DagNodeTable& table = *node_table; //int row_count = table.rows(); int cur_row_len = 0; if( start == end ) return; int dir = (start < end) ? 1 : -1; //for each parent row of the passed row of nodes... for( i = start; i != (end + dir); i += dir ) { //populate the array with the values to sort by cur_row_len = table[i].length(); for( j = 0; j < cur_row_len; j++ ) { val_list[j] = 0.0; int link_count = 0; for( k = 0; k < table[i-dir].length(); k++ ) { if( link_type( i, j, i - dir, k ) ) { val_list[j] += (float)k; link_count++; } } if( link_count ) val_list[j] /= (float)link_count; } //sort the row by the values in value_list for( j = 0; j < cur_row_len - 1; j++ ) { int smallest = j; for( k = j + 1; k < cur_row_len; k++ ) { if( val_list[k] < val_list[smallest] ) smallest = k; } if( smallest != j ) { //float temp = val_list[j]; val_list[j] = val_list[smallest]; val_list[smallest] = val_list[j]; ModelEntity* node = table[i][j]; table[i][j] = table[i][smallest]; table[i][smallest] = node; } } } }
void DagDrawingTool::sort_row( int row, int wrt_dir ) { assert((wrt_dir == 1) || (wrt_dir == -1)); DagNodeTable& table = *node_table; int row_len = table[row].length(); int rel_row = row + wrt_dir; if( (row_len < 2) || (rel_row < 0) || (rel_row == table.rows()) ) return; int* index_array = new int[row_len]; int num_rels = table[rel_row].length(); int i, j, k, l, m; //Append first node to list index_array[0] = 0; //For each remaining node, insert it in the location at which //it causes the least intersections of links. for( i = 1; i < row_len; i++ ) { int best_index = 0; int intersection_count = 0; //Get the intersection count if the node were inserted first //in the row. //For each possible parent node for( k = 1; k < num_rels; k++ ) { //Is it a parent? if( ! link_type( row, i, rel_row, k ) ) continue; //Count how many other links that link intersects. //For all the other nodes in the list... for( l = 0; l < i; l++ ) { //For each parent to the left of my parent for( m = 0; m < k; m++ ) { if( link_type( row, index_array[l], rel_row, m ) ) intersection_count++; } } } //Now check the intersection count for each additional //possible location of insertion. for( j = 1; j <= i; j++ ) { int current_count = 0; //For each possible parent node for( k = 0; k < num_rels; k++ ) { //Is it a parent? if( ! link_type( row, i, rel_row, k ) ) continue; //Count how many other links from nodes to the //left of me intersect with my link to this parent. for( l = 0; l < j; l++ ) { //For each parent to the right of my parent for( m = k+1; m < num_rels; m++ ) { if( link_type( row, index_array[l], rel_row, m ) ) current_count++; } } //Count how many other links from nodes to the //right of me intersect with my link to this parent. for( l = j; l < i; l++ ) { //For each parent to the left of my parent for( m = 0; m < k; m++ ) { if( link_type( row, index_array[l], rel_row, m ) ) current_count++; } } } if( current_count <= intersection_count ) { intersection_count = current_count; best_index = j; } } //Now insert this node at the best location. for( j = i; j > best_index; j-- ) index_array[j] = index_array[j-1]; index_array[best_index] = i; } //Now rearrange the nodes in the actual row to match //what is stored in index_list ModelEntity** node_array = new ModelEntity*[row_len]; for( i = 0; i < row_len; i++ ) { node_array[i] = table[row][index_array[i]]; } for( i = 0; i < row_len; i++ ) { table[row][i] = node_array[i]; } delete [] node_array; delete [] index_array; }