void create_chunk( int N_u, int N_v, int N_r, double r_min, double r_max, double gamma, long nnodes, pvo_float3_t* pts, long ncells, int* cia, int* cja, uint8_t* types, double* U, float* V ) { int iu, iv, ir, i, k; double theta, phi, r, t, u, v, z; // Mesh spacing double dr = (r_max - r_min)/N_r; /* We compute the values on the sphere by projection from the plane with this z value on the sphere. The closer this value is to 1.0, the lower is the curvature */ z = sqrt(0.5*(1 - gamma*gamma)); for( ir = 0; ir <= N_r; ++ir ) for( iv = 0; iv <= N_v; ++iv ) for( iu = 0; iu <= N_u; ++iu ) { u = -z + ( (2*z)/(double )N_u )*iu; v = -z + ( (2*z)/(double )N_v )*iv; r = r_min + ir*dr; t = sqrt(u*u + v*v + gamma*gamma); k = iu + (N_u+1)*iv + (N_u+1)*(N_v+1)*ir; pts[k][0] = u *r/t; pts[k][1] = v *r/t; pts[k][2] = gamma*r/t; } for( ir = 0; ir < N_r; ++ir ) for( iv = 0; iv < N_v; ++iv ) for( iu = 0; iu < N_u; ++iu ) { k = 8*(iu + N_u*iv + N_u*N_v*ir); #undef INDEX #define INDEX(iu,iv,ir) ( (iu) + (N_u+1)*(iv) + (N_u+1)*(N_v+1)*(ir) ) cja[k+0] = INDEX(iu ,iv ,ir ); cja[k+1] = INDEX(iu+1,iv ,ir ); cja[k+2] = INDEX(iu+1,iv+1,ir ); cja[k+3] = INDEX(iu ,iv+1,ir ); cja[k+4] = INDEX(iu ,iv ,ir+1); cja[k+5] = INDEX(iu+1,iv ,ir+1); cja[k+6] = INDEX(iu+1,iv+1,ir+1); cja[k+7] = INDEX(iu ,iv+1,ir+1); } for( i = 0; i <= ncells; ++i ) cia[i] = 8*i; for( i = 0; i < ncells; ++i ) types[i] = PVO_VTU_HEXAHEDRON; srand( 0 ); for( i = 0; i < nnodes; ++i ) { U[3*i+0] = (1.0*rand())/(1.0*RAND_MAX); U[3*i+1] = (1.0*rand())/(1.0*RAND_MAX); U[3*i+2] = (1.0*rand())/(1.0*RAND_MAX); } for( i = 0; i < ncells; ++i ) V[i] = (1.0*rand())/(1.0*RAND_MAX); }
/* Get the last set of updates seen, (last+1) to n is returned. */ krb5_error_code ulog_get_entries(krb5_context context, const kdb_last_t *last, kdb_incr_result_t *ulog_handle) { XDR xdrs; kdb_ent_header_t *indx_log; kdb_incr_update_t *upd; unsigned int indx, count; uint32_t sno; krb5_error_code retval; kdb_log_context *log_ctx; kdb_hlog_t *ulog = NULL; uint32_t ulogentries; INIT_ULOG(context); ulogentries = log_ctx->ulogentries; retval = lock_ulog(context, KRB5_LOCKMODE_SHARED); if (retval) return retval; /* If another process terminated mid-update, reset the ulog and force full * resyncs. */ if (ulog->kdb_state != KDB_STABLE) reset_header(ulog); ulog_handle->ret = get_sno_status(log_ctx, last); if (ulog_handle->ret != UPDATE_OK) goto cleanup; sno = last->last_sno; count = ulog->kdb_last_sno - sno; upd = calloc(count, sizeof(kdb_incr_update_t)); if (upd == NULL) { ulog_handle->ret = UPDATE_ERROR; retval = ENOMEM; goto cleanup; } ulog_handle->updates.kdb_ulog_t_val = upd; for (; sno < ulog->kdb_last_sno; sno++) { indx = sno % ulogentries; indx_log = INDEX(ulog, indx); memset(upd, 0, sizeof(kdb_incr_update_t)); xdrmem_create(&xdrs, (char *)indx_log->entry_data, indx_log->kdb_entry_size, XDR_DECODE); if (!xdr_kdb_incr_update_t(&xdrs, upd)) { ulog_handle->ret = UPDATE_ERROR; retval = KRB5_LOG_CONV; goto cleanup; } /* Mark commitment since we didn't want to decode and encode the incr * update record the first time. */ upd->kdb_commit = indx_log->kdb_commit; upd++; } ulog_handle->updates.kdb_ulog_t_len = count; ulog_handle->lastentry.last_sno = ulog->kdb_last_sno; ulog_handle->lastentry.last_time.seconds = ulog->kdb_last_time.seconds; ulog_handle->lastentry.last_time.useconds = ulog->kdb_last_time.useconds; ulog_handle->ret = UPDATE_OK; cleanup: unlock_ulog(context); return retval; }
/* ------------------------------------------------------------------- Main MEX function - interface to Matlab. -------------------------------------------------------------------- */ void mexFunction( int nlhs, mxArray *plhs[],int nrhs, const mxArray*prhs[] ) { char solver[20]; /* solver identifier */ int exitflag; /* output arg */ int buf_len; /* real length of the solver identifier */ int verb; /* input argument */ long i,j ; /* common use loop variables */ long inx1, inx2; long num_data; /* number of input training examples */ long tmax; /* input arg - max number of iteration */ long t; /* output arg - number of iterations */ double tolrel; /* input arg */ double tolabs; /* input arg */ double thlb; /* input arg */ double *tmp_ptr; double *alpha; /* output arg */ double *History; /* output arg */ double *diag_H; /* diagonal of matrix H */ double *vector_c; /* vector c */ double *vector_y; double aHa11; double aHa22; /*------------------------------------------------------------------- */ /* Take input arguments */ /*------------------------------------------------------------------- */ if( nrhs != 9) mexErrMsgTxt("Incorrect number of input arguments."); /* matrix H */ matrix_H = mxGetPr(prhs[0]); dim = mxGetM(prhs[0]); if(dim != mxGetN(prhs[0])) mexErrMsgTxt("Matrix H mast be squared."); /* vector c */ vector_c = mxGetPr(prhs[1]); if((MAX(mxGetM(prhs[1]),mxGetN(prhs[1])) != dim) || (MIN(mxGetM(prhs[1]),mxGetN(prhs[1])) != 1)) mexErrMsgTxt("Vector is of wrong size."); /* vector y */ vector_y = mxGetPr(prhs[2]); if((MAX(mxGetM(prhs[2]),mxGetN(prhs[2])) != dim) || (MIN(mxGetM(prhs[2]),mxGetN(prhs[2])) != 1)) mexErrMsgTxt("Vector is of wrong size."); /* string identifier of QP solver to be used */ if( mxIsChar( prhs[3] ) != 1) mexErrMsgTxt("Solver must be a string."); buf_len = (mxGetM(prhs[3]) * mxGetN(prhs[3])) + 1; buf_len = (buf_len > 20) ? 20 : buf_len; mxGetString( prhs[3], solver, buf_len ); /* maximal allowed number of iterations */ tmax = mxIsInf( mxGetScalar(prhs[4])) ? INT_MAX : (long)mxGetScalar(prhs[4]); tolabs = mxGetScalar(prhs[5]); /* abs. precision defining stopping cond*/ tolrel = mxGetScalar(prhs[6]); /* rel. precision defining stopping cond*/ /* threshold on lower bound */ thlb = mxIsInf( mxGetScalar(prhs[7])) ? DBL_MAX : (double)mxGetScalar(prhs[7]); verb = (int)mxGetScalar(prhs[8]); /* verbosity on/off */ if( verb == 1 ) { mexPrintf("Settings of QP solver\n"); mexPrintf("solver : %s\n", solver ); mexPrintf("tmax : %d\n", tmax ); mexPrintf("tolabs : %f\n", tolabs ); mexPrintf("tolrel : %f\n", tolrel ); mexPrintf("dim : %d\n", dim ); } /*------------------------------------------------------------------- */ /* Inicialization */ /*------------------------------------------------------------------- */ /* output "solution" vector alpha [dim x 1] */ plhs[0] = mxCreateDoubleMatrix(dim,1,mxREAL); alpha = mxGetPr(plhs[0]); /* allocattes and precomputes diagonal of virtual K matrix */ diag_H = mxCalloc(dim, sizeof(double)); if( diag_H == NULL ) mexErrMsgTxt("Not enough memory."); for(i = 0; i < dim; i++ ) { diag_H[i] = matrix_H[dim*i+i]; } /* counter of access to matrix H */ access = dim; /*------------------------------------------------------------------- */ /* Call QP solver */ /*------------------------------------------------------------------- */ if ( strcmp( solver, "mdm" ) == 0 ) { exitflag = gnpp_mdm( &get_col, diag_H, vector_c, vector_y, dim, tmax, tolabs, tolrel, thlb, alpha, &t, &aHa11, &aHa22, &History, verb ); } else if ( strcmp( solver, "imdm" ) == 0 ) { exitflag = gnpp_imdm( &get_col, diag_H, vector_c, vector_y, dim, tmax, tolabs, tolrel, thlb, alpha, &t, &aHa11, &aHa22, &History, verb ); } else { mexErrMsgTxt("Unknown QP solver identifier!"); } /*------------------------------------------------------------------- */ /* Generate outputs */ /*------------------------------------------------------------------- */ /* exitflag [1x1] */ plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL); *(mxGetPr(plhs[1])) = (double)exitflag; /* t [1x1] */ plhs[2] = mxCreateDoubleMatrix(1,1,mxREAL); *(mxGetPr(plhs[2])) = (double)t; /* access [1x1] */ plhs[3] = mxCreateDoubleMatrix(1,1,mxREAL); *(mxGetPr(plhs[3])) = (double)access; /* History [2 x (t+1)] */ plhs[4] = mxCreateDoubleMatrix(2,t+1,mxREAL); tmp_ptr = mxGetPr( plhs[4] ); for( i = 0; i <= t; i++ ) { tmp_ptr[INDEX(0,i,2)] = History[INDEX(0,i,2)]; tmp_ptr[INDEX(1,i,2)] = History[INDEX(1,i,2)]; } /*------------------------------------------------------------------- */ /* Free used memory */ /*------------------------------------------------------------------- */ mxFree( History ); mxFree( diag_H ); }
void mexFunction( int nlhs, mxArray *plhs[],int nrhs, const mxArray *prhs[] ) { if(nrhs < 4 || nrhs > 5) mexErrMsgTxt("Improper number of input arguments.\n\n" "ARGMAX_MEX estimates the position of landmarks.\n\n" "Synopsis: \n" " [ \\hat{s} ]= argmax_mex(options, W, mapTable, lbp [, L]) \n" "\n" " Input: \n" " options [1 x 1 structure] detector options\n" " W [n x 1 (double)] joint parameter vector\n" " mapTable [M x 4 (double)] mapping table for joint parameter vector W\n" " lbp [1 x M (cell)] LBP sparse features\n" " L [M x 1 (cell)] precomputed losses, optional parameter (for learning stage)\n" " Output: \n" " \\hat{s} [M x 2 (double)] estimated landmark positions\n"); //-------------------------------------------------------------------------- // Load input double * W; uint32_t W_ROWS, W_COLS; FLANDMARK_Options options; uint8_t M; const mwSize *dims; double * tmp_ptr; mxArray *tmp_field_ptr, *cell_ptr; mxArray * psigs0 = mxGetField(prhs[0], 0, "PsiGS0"); dims = mxGetDimensions(psigs0); options.PSIG_ROWS[0] = dims[0]; options.PSIG_COLS[0] = dims[1]; mxArray * psigs1 = mxGetField(prhs[0], 0, "PsiGS1"); dims = mxGetDimensions(psigs1); options.PSIG_ROWS[1] = dims[0]; options.PSIG_COLS[1] = dims[1]; mxArray * psigs2 = mxGetField(prhs[0], 0, "PsiGS2"); dims = mxGetDimensions(psigs2); options.PSIG_ROWS[2] = dims[0]; options.PSIG_COLS[2] = dims[1]; int tsize = -1, rows = -1, cols = -1; double * result; bool lossy = (nrhs > 4) ? true : false; // options ---------------------------------------------------------------- //options.M = 7; tmp_field_ptr = mxGetField(prhs[0], 0, "M"); tmp_ptr = (double*)mxGetPr(tmp_field_ptr); options.M = (int)tmp_ptr[0]; M = options.M; //int mapTable[7*4]; int * mapTable = (int*)calloc(M*4, sizeof(int)); options.S = (int*)calloc(4*M, sizeof(int)); // options.S --------------------------------------------------- tmp_field_ptr = mxGetField(prhs[0], 0, "S"); dims = mxGetDimensions(tmp_field_ptr); tmp_ptr = (double*)mxGetPr(tmp_field_ptr); for (int i = 0; i < 4*options.M; ++i) { options.S[i] = (int)tmp_ptr[i]; } // W ---------------------------------------------------------------------- dims = mxGetDimensions(prhs[1]); W_ROWS = dims[0]; W_COLS = dims[1]; bool WisSparse = mxIsSparse(prhs[1]); if (WisSparse) { W = (double*)calloc(W_ROWS*W_COLS, sizeof(double)); double * pr = (double*)mxGetPr(prhs[1]); mwIndex * ir = mxGetIr(prhs[1]); mwSize nzmax = mxGetNzmax(prhs[1]); for (int ii = 0; ii < nzmax; ++ii) { W[ir[ii]] = pr[ii]; } } else { W = (double*)mxGetPr(prhs[1]); } // ------------------------------------------------------------------------ // mapTable tmp_ptr = (double*)mxGetPr(prhs[2]); dims = mxGetDimensions(prhs[2]); if (dims[0]*dims[1] != M*4) { mexErrMsgTxt("mapTable must be a matrix [M x 4 (double)]"); } for (int i = 0; i < M*4; ++i) { mapTable[i] = (int)tmp_ptr[i]; } // prepare output matrix plhs[0] = mxCreateNumericMatrix(2, M, mxDOUBLE_CLASS, mxREAL); result = (double*)mxGetPr(plhs[0]); //-------------------------------------------------------------------------- // get Q, G double ** q = (double**)calloc(M, sizeof(double*)); double ** g = (double**)calloc((M-1), sizeof(double*)); int idx_qtemp = 0; double * L; for (int idx = 0; idx < M; ++idx) { // Q tsize = mapTable[INDEX(idx, 1, M)] - mapTable[INDEX(idx, 0, M)] + 1; double * q_temp = (double*)calloc(tsize, sizeof(double)); memcpy(q_temp, W+mapTable[INDEX(idx, 0, M)]-1, tsize*sizeof(double)); // sparse dot product <W_q, PSI_q> cell_ptr = mxGetCell(prhs[3], idx); dims = mxGetDimensions(cell_ptr); cols = dims[1]; rows = dims[0]; uint32_t *psi_temp = (uint32_t*)mxGetPr(cell_ptr); if (lossy) { L = (double*)mxGetPr(mxGetCell(prhs[4], idx)); } q[idx] = (double*)malloc(cols*sizeof(double)); for (int i = 0; i < cols; ++i) { double dotprod = 0.0f; for (int j = 0; j < rows; ++j) { idx_qtemp = psi_temp[(rows*i) + j]; dotprod += q_temp[ idx_qtemp ]; } q[idx][i] = dotprod; if (lossy) { q[idx][i] += L[i]; } } free(q_temp); // G if (idx > 0) { tsize = mapTable[INDEX(idx, 3, M)] - mapTable[INDEX(idx, 2, M)] + 1; g[idx - 1] = (double*)malloc(tsize*sizeof(double)); memcpy(g[idx - 1], W+mapTable[INDEX(idx, 2, M)]-1, tsize*sizeof(double)); } } // compute argmax int * indices = (int*)malloc(M*sizeof(int)); tsize = mapTable[INDEX(1, 3, M)] - mapTable[INDEX(1, 2, M)] + 1; // left branch - store maximum and index of s5 for all positions of s1 dims = mxGetDimensions(mxGetCell(prhs[3], 1)); int q1_length = dims[1]; double * s1 = (double *)calloc(2*q1_length, sizeof(double)); double * s1_maxs = (double *)calloc(q1_length, sizeof(double)); for (int i = 0; i < q1_length; ++i) { // dot product <g_5, PsiGS1> dims = mxGetDimensions(mxGetCell(psigs1, INDEX(i, 0, options.PSIG_ROWS[1]))); maximize_gdotprod( &s1[INDEX(0, i, 2)], &s1[INDEX(1, i, 2)], q[5], g[4], (double*)mxGetPr(mxGetCell(psigs1, INDEX(i, 0, options.PSIG_ROWS[1]))), dims[1], tsize); s1[INDEX(0, i, 2)] += q[1][i]; } for (int i = 0; i < q1_length; ++i) { s1_maxs[i] = s1[INDEX(0, i, 2)]; } // right branch (s2->s6) - store maximum and index of s6 for all positions of s2 dims = mxGetDimensions(mxGetCell(prhs[3], 2)); int q2_length = dims[1]; double * s2 = (double *)calloc(2*q2_length, sizeof(double)); double * s2_maxs = (double *)calloc(q2_length, sizeof(double)); for (int i = 0; i < q2_length; ++i) { // dot product <g_6, PsiGS2> dims = mxGetDimensions(mxGetCell(psigs2, INDEX(i, 0, options.PSIG_ROWS[2]))); maximize_gdotprod( &s2[INDEX(0, i, 2)], (double*)&s2[INDEX(1, i, 2)], q[6], g[5], (double*)mxGetPr(mxGetCell(psigs2, INDEX(i, 0, options.PSIG_ROWS[2]))), dims[1], tsize); s2[INDEX(0, i, 2)] += q[2][i]; } for (int i = 0; i < q2_length; ++i) { s2_maxs[i] = s2[INDEX(0, i, 2)]; } // the root s0 and its connections dims = mxGetDimensions(mxGetCell(prhs[3], 0)); int q0_length = dims[1]; double maxs0 = -FLT_MAX; int maxs0_idx = -1; double maxq10 = -FLT_MAX, maxq20 = -FLT_MAX, maxq30 = -FLT_MAX, maxq40 = -FLT_MAX, maxq70 = -FLT_MAX; double * s0 = (double *)calloc(M*q0_length, sizeof(double)); for (int i = 0; i < q0_length; ++i) { // q10 maxq10 = -FLT_MAX; dims = mxGetDimensions(mxGetCell(psigs0, INDEX(i, 0, options.PSIG_ROWS[0]))); maximize_gdotprod( &maxq10, &s0[INDEX(1, i, M)], s1_maxs, g[0], (double*)mxGetPr(mxGetCell(psigs0, INDEX(i, 0, options.PSIG_ROWS[0]))), dims[1], tsize); s0[INDEX(5, i, M)] = s1[INDEX(1, (int)s0[INDEX(1, i, M)], 2)]; // q20 maxq20 = -FLT_MAX; dims = mxGetDimensions(mxGetCell(psigs0, INDEX(i, 1, options.PSIG_ROWS[0]))); maximize_gdotprod( &maxq20, &s0[INDEX(2, i, M)], s2_maxs, g[1], (double*)mxGetPr(mxGetCell(psigs0, INDEX(i, 1, options.PSIG_ROWS[0]))), dims[1], tsize); s0[INDEX(6, i, M)] = s2[INDEX(1, (int)s0[INDEX(2, i, M)], 2)]; // q30 maxq30 = -FLT_MAX; dims = mxGetDimensions(mxGetCell(psigs0, INDEX(i, 2, options.PSIG_ROWS[0]))); maximize_gdotprod( &maxq30, &s0[INDEX(3, i, M)], q[3], g[2], (double*)mxGetPr(mxGetCell(psigs0, INDEX(i, 2, options.PSIG_ROWS[0]))), dims[1], tsize); // q40 maxq40 = -FLT_MAX; dims = mxGetDimensions(mxGetCell(psigs0, INDEX(i, 3, options.PSIG_ROWS[0]))); maximize_gdotprod( &maxq40, &s0[INDEX(4, i, M)], q[4], g[3], (double*)mxGetPr(mxGetCell(psigs0, INDEX(i, 3, options.PSIG_ROWS[0]))), dims[1], tsize); // q70 maxq70 = -FLT_MAX; dims = mxGetDimensions(mxGetCell(psigs0, INDEX(i, 4, options.PSIG_ROWS[0]))); maximize_gdotprod( &maxq70, &s0[INDEX(7, i, M)], q[7], g[6], (double*)mxGetPr(mxGetCell(psigs0, INDEX(i, 4, options.PSIG_ROWS[0]))), dims[1], tsize); // sum q10+q20+q30+q40+q70 if (maxs0 < maxq10+maxq20+maxq30+maxq40+maxq70+q[0][i]) { maxs0_idx = i; s0[INDEX(0, i, M)] = i; maxs0 = maxq10+maxq20+maxq30+maxq40+maxq70+q[0][i]; } } // get indices for (int i = 0; i < M; ++i) { indices[i] = (int)s0[INDEX(0, maxs0_idx, M)+i]+1; } // cleanup temp variables free(s0); free(s1); free(s1_maxs); free(s2); free(s2_maxs); // cleanup W if it was created if (WisSparse) { free(W); } // cleanup q for (int i = 0; i < M; ++i) { free(q[i]); } free(q); // cleanup g for (int i = 0; i < M - 1; ++i) { free(g[i]); } free(g); // convert 1D indices to 2D coordinates of estimated positions int * optionsS = &options.S[0]; for (int i = 0; i < M; ++i) { int rows = optionsS[INDEX(3, i, 4)] - optionsS[INDEX(1, i, 4)] + 1; result[INDEX(0, i, 2)] = COL(indices[i], rows) + optionsS[INDEX(0, i, 4)]; result[INDEX(1, i, 2)] = ROW(indices[i], rows) + optionsS[INDEX(1, i, 4)]; } free(indices); free(options.S); free(mapTable); return; }
/* ------------------------------------------------------------------- Main MEX function - interface to Matlab. [x,exitflag,t,access,History] = qpbsvm_mex(H,f,UB,tmax,tolabs,tolrel,verb,x0,Nabla0) -------------------------------------------------------------------- */ void mexFunction( int nlhs, mxArray *plhs[],int nrhs, const mxArray*prhs[] ) { char solver[20]; /* solver identifier */ int exitflag; /* output arg */ int verb; /* input argument -- verbosity */ int buf_len; /* real length of the solver identifier */ long i, j; /* loop variable */ long tmax; /* input arg - max number of iteration */ long t; /* output arg - number of iterations */ double tolrel; /* input arg */ double tolabs; /* input arg */ double tolKKT; double *tmp_ptr; double *x; /* output arg -- solution*/ double *x0; double *Nabla; double *History; /* output arg */ double *diag_H; /* diagonal of matrix H */ double *f; /* vector f */ double UB; /*------------------------------------------------------------------- */ /* Take input arguments */ /*------------------------------------------------------------------- */ if( nrhs != 11) mexErrMsgTxt("Incorrect number of input arguments."); /* matrix H */ matrix_H = mxGetPr(prhs[0]); dim = mxGetM(prhs[0]); if(dim != mxGetN(prhs[0])) mexErrMsgTxt("Matrix H mast be squared."); /* vector f */ f = mxGetPr(prhs[1]); if((MAX(mxGetM(prhs[1]),mxGetN(prhs[1])) != dim) || (MIN(mxGetM(prhs[1]),mxGetN(prhs[1])) != 1)) mexErrMsgTxt("Vector f is of wrong size."); UB = mxGetScalar(prhs[2]); /* string identifier of QP solver to be used */ if( mxIsChar( prhs[3] ) != 1) mexErrMsgTxt("Solver must be a string."); buf_len = (mxGetM(prhs[3]) * mxGetN(prhs[3])) + 1; buf_len = (buf_len > 20) ? 20 : buf_len; mxGetString( prhs[3], solver, buf_len ); tmax = mxIsInf( mxGetScalar(prhs[4])) ? INT_MAX : (long)mxGetScalar(prhs[4]); tolabs = mxGetScalar(prhs[5]); /* abs. precision defining stopping cond*/ tolrel = mxGetScalar(prhs[6]); /* rel. precision defining stopping cond*/ tolKKT = mxGetScalar(prhs[7]); /* rel. precision defining stopping cond*/ verb = (int)(mxGetScalar(prhs[8])); /* verbosity on/off */ /* output "solution" vector alpha [dim x 1] */ plhs[0] = mxCreateDoubleMatrix(dim,1,mxREAL); x = mxGetPr(plhs[0]); x0 = mxGetPr(prhs[9]); for(i=0; i < dim; i++) x[i] = x0[i]; /* Nabla = H*x + f */ plhs[5] = mxCreateDoubleMatrix(dim,1,mxREAL); Nabla = mxGetPr(plhs[5]); tmp_ptr = mxGetPr(prhs[10]); for(i=0; i < dim; i++) Nabla[i] = tmp_ptr[i]; if( verb > 0 ) { mexPrintf("Settings of QP solver\n"); mexPrintf("nrhs : %d\n", nrhs); mexPrintf("solver : %s\n", solver); mexPrintf("UB : %f\n", UB ); mexPrintf("tmax : %d\n", tmax ); mexPrintf("tolabs : %f\n", tolabs ); mexPrintf("tolrel : %f\n", tolrel ); mexPrintf("dim : %d\n", dim ); mexPrintf("verb : %d\n", verb ); } /*------------------------------------------------------------------- */ /* Inicialization */ /*------------------------------------------------------------------- */ /* allocattes and precomputes diagonal of virtual K matrix */ diag_H = mxCalloc(dim, sizeof(double)); if( diag_H == NULL ) mexErrMsgTxt("Not enough memory."); for(i = 0; i < dim; i++ ) { diag_H[i] = matrix_H[dim*i+i]; } /* counter of access to matrix H */ access = dim; /*------------------------------------------------------------------- */ /* Call QP solver */ /*------------------------------------------------------------------- */ if ( strcmp( solver, "sca" ) == 0 ) { exitflag = qpbsvm_sca( &get_col, diag_H, f, UB, dim, tmax, tolabs, tolrel, tolKKT, x, Nabla, &t, &History, verb ); } else if (strcmp( solver, "scas" ) == 0 ) { exitflag = qpbsvm_scas( &get_col, diag_H, f, UB, dim, tmax, tolabs, tolrel, tolKKT, x, Nabla, &t, &History, verb ); } else if (strcmp( solver, "scamv" ) == 0 ) { exitflag = qpbsvm_scamv( &get_col, diag_H, f, UB, dim, tmax, tolabs, tolrel, tolKKT, x, Nabla, &t, &History, verb ); } else { mexErrMsgTxt("Unknown QP solver identifier!"); } /*------------------------------------------------------------------- */ /* Generate outputs */ /*------------------------------------------------------------------- */ /* exitflag [1x1] */ plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL); *(mxGetPr(plhs[1])) = (double)exitflag; /* t [1x1] */ plhs[2] = mxCreateDoubleMatrix(1,1,mxREAL); *(mxGetPr(plhs[2])) = (double)t; /* access [1x1] */ plhs[3] = mxCreateDoubleMatrix(1,1,mxREAL); *(mxGetPr(plhs[3])) = (double)access; /* History [2 x (t+1)] */ plhs[4] = mxCreateDoubleMatrix(2,t+1,mxREAL); tmp_ptr = mxGetPr( plhs[4] ); for( i = 0; i <= t; i++ ) { tmp_ptr[INDEX(0,i,2)] = History[INDEX(0,i,2)]; tmp_ptr[INDEX(1,i,2)] = History[INDEX(1,i,2)]; } /*------------------------------------------------------------------- */ /* Free used memory */ /*------------------------------------------------------------------- */ mxFree( History ); mxFree( diag_H ); }
status_t ExynosCameraFrameFactory::initPipes(void) { ALOGI("INFO(%s[%d])", __FUNCTION__, __LINE__); int ret = 0; camera_pipe_info_t pipeInfo[3]; ExynosRect tempRect; int maxSensorW = 0, maxSensorH = 0, hwSensorW = 0, hwSensorH = 0; int maxPreviewW = 0, maxPreviewH = 0, hwPreviewW = 0, hwPreviewH = 0; int hwPictureW = 0, hwPictureH = 0; int bayerFormat = CAMERA_BAYER_FORMAT; int previewFormat = m_parameters->getHwPreviewFormat(); int pictureFormat = m_parameters->getPictureFormat(); struct ExynosConfigInfo *config = m_parameters->getConfig(); m_parameters->getMaxSensorSize(&maxSensorW, &maxSensorH); m_parameters->getHwSensorSize(&hwSensorW, &hwSensorH); m_parameters->getMaxPreviewSize(&maxPreviewW, &maxPreviewH); m_parameters->getHwPreviewSize(&hwPreviewW, &hwPreviewH); m_parameters->getHwPictureSize(&hwPictureW, &hwPictureH); ALOGI("INFO(%s[%d]): MaxSensorSize(%dx%d), HWSensorSize(%dx%d)", __FUNCTION__, __LINE__, maxSensorW, maxSensorH, hwSensorW, hwSensorH); ALOGI("INFO(%s[%d]): MaxPreviewSize(%dx%d), HwPreviewSize(%dx%d)", __FUNCTION__, __LINE__, maxPreviewW, maxPreviewH, hwPreviewW, hwPreviewH); ALOGI("INFO(%s[%d]): HWPictureSize(%dx%d)", __FUNCTION__, __LINE__, hwPictureW, hwPictureH); memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* FLITE pipe */ #ifdef FIXED_SENSOR_SIZE tempRect.fullW = maxSensorW + 16; tempRect.fullH = maxSensorH + 10; #else tempRect.fullW = hwSensorW + 16; tempRect.fullH = hwSensorH + 10; #endif tempRect.colorFormat = bayerFormat; pipeInfo[0].rectInfo = tempRect; pipeInfo[0].bufInfo.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; pipeInfo[0].bufInfo.memory = V4L2_CAMERA_MEMORY_TYPE; pipeInfo[0].bufInfo.count = config->current->bufInfo.num_bayer_buffers; /* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 0; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_NONE; #ifdef CAMERA_PACKED_BAYER_ENABLE /* packed bayer bytesPerPlane */ pipeInfo[0].bytesPerPlane[0] = ROUND_UP(pipeInfo[0].rectInfo.fullW, 10) * 8 / 5; #endif ret = m_pipes[INDEX(PIPE_FLITE)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]):FLITE setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } /* setParam for Frame rate */ uint32_t min, max, frameRate; struct v4l2_streamparm streamParam; memset(&streamParam, 0x0, sizeof(v4l2_streamparm)); m_parameters->getPreviewFpsRange(&min, &max); if (m_parameters->getScalableSensorMode() == true) frameRate = 24; else frameRate = max; streamParam.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; streamParam.parm.capture.timeperframe.numerator = 1; streamParam.parm.capture.timeperframe.denominator = frameRate; ALOGI("INFO(%s[%d]:set framerate (denominator=%d)", __FUNCTION__, __LINE__, frameRate); ret = setParam(streamParam, PIPE_FLITE); if (ret < 0) { ALOGE("ERR(%s[%d]):FLITE setParam fail, ret(%d)", __FUNCTION__, __LINE__, ret); return INVALID_OPERATION; } #if 0 /* setParam for Frame rate */ int bnsScaleRatio = m_parameters->getBnsScaleRatio(); int bnsSize = 0; ret = m_pipes[PIPE_FLITE]->setControl(V4L2_CID_IS_S_BNS, bnsScaleRatio); if (ret < 0) { ALOGE("ERR(%s[%d]): set BNS(%d) fail, ret(%d)", __FUNCTION__, __LINE__, bnsScaleRatio, ret); } else { ret = m_pipes[PIPE_FLITE]->getControl(V4L2_CID_IS_G_BNS_SIZE, &bnsSize); if (ret < 0) { ALOGE("ERR(%s[%d]): get BNS size fail, ret(%d)", __FUNCTION__, __LINE__, ret); bnsSize = -1; } } int bnsWidth = 0; int bnsHeight = 0; if (bnsSize > 0) { bnsHeight = bnsSize & 0xffff; bnsWidth = bnsSize >> 16; ALOGI("INFO(%s[%d]): BNS scale down ratio(%.1f), size (%dx%d)", __FUNCTION__, __LINE__, (float)(bnsScaleRatio / 1000), bnsWidth, bnsHeight); m_parameters->setBnsSize(bnsWidth - 16, bnsHeight - 10); }
void updateGraph() { if(dist) { free(dist); dist = NULL; } if(prev) { free(prev); prev = NULL; } if(graph) { free(graph); graph = NULL; } int r= 0, s=0; dist = (int *) malloc(nl_nsites(nl) * sizeof(int)); prev = (int *) malloc(nl_nsites(nl) * sizeof(int)); graph = (int *) malloc(sizeof(int) * (nl_nsites(nl)) * (nl_nsites(nl))); for(r=0;r<nl_nsites(nl);r++) { dist[r] = INFINITY; prev[r] = UNDEFINED; for(s=0;s<nl_nsites(nl);s++) { graph[INDEX(r, s, nl_nsites(nl))] = 0; } } struct gossip *g = gossip; while(g != NULL) { int len = strlen(gossip_latest(g)); char *lat = (char *) malloc(sizeof(char) * (len+1)); strcpy(lat, gossip_latest(g)); char *addr = lat; char *ctr = index(addr, '/'); *ctr++ = 0; char *payload = index(ctr, '/'); *payload++ = 0; char *token = strtok(payload, ";"); while (token) { //printf("Address = %s\n", addr); //printf("Token = %s\n", token); set_dist(nl, graph, nl_nsites(nl), addr, token, 1); token = strtok(NULL, ";"); } g = gossip_next(g); free(lat); } char *my_addr_str = addr_to_string(my_addr); int my_index = nl_index(nl, my_addr_str); // update connections of immediate neighbours struct file_info *f = file_info; while (f) { char *addr = addr_to_string(f->addr); if(strcmp(addr,my_addr_str ) != 0 && (f->type == FI_INCOMING || (f->type == FI_OUTGOING && f->status == FI_KNOWN && f->u.fi_outgoing.status == FI_CONNECTED))) { set_dist(nl, graph, nl_nsites(nl), addr, my_addr_str, 1); } f = f->next; free(addr); } free(my_addr_str); // call graph on updated graph dijkstra(graph, nl_nsites(nl), my_index, dist, prev); printf("PRINTING GRAPH\n"); for(r=0;r<nl_nsites(nl);r++) { for(s=0;s<nl_nsites(nl);s++) { printf("%d ", graph[INDEX(r, s, nl_nsites(nl))]); } printf("\n"); } printf("\nPRINTING DISTANCE\n"); for(r=0;r<nl_nsites(nl);r++) { printf("Distance to Site [%d] %s = %d\n", r, nl_name(nl,r), dist[r]); } printf("\nPRINTING PREV\n"); for(r=0;r<nl_nsites(nl);r++) { printf("Previous to Site [%d] %s = %d\n", r, nl_name(nl,r), prev[r]); } }
/* Algorithm taken from Matrix Algorithms Vol. II by G.W. Stewart. Given an upper Hessenberg matrix, H, hqr overwrites it iwth a unitary similar triangular matrix whose diagonals are the eigenvalues of H. I beleive this is called Schur form. n is the size of the matrix H -1 is returned if more than maxiter iterations are required to to deflate the matrix at any eigenvalue. If everything completes successfully, a 0 is returned. c, s, r1, r2, and t are arrays of length n, used for scratch work */ int hqr(Complex *H, Complex *Q, Real *c, Complex *s, Complex *r1, Complex *r2, Complex *t, int n, int maxiter, Real epsilon) { int i1, i2, iter, oldi2, i, j; Complex k, tmp; //2. i1 = 1; i2 = n i1 = 0; i2 = n-1;//this is used both as an index and an upper bound in loops, so //it must be n-1, but I must use <= in loops. //3. iter = 0; iter = 0; //4. while(true) while(1) { //5. iter = iter+1 iter += 1; //6. if(iter > maxiter) error return fi if(iter > maxiter) return -1; //7. oldi2 = i2 oldi2 = i2; //8. backsearch(H, i2, i1, i2) backsearch(H, n, i2, &i1, &i2, epsilon); //9. if(i2 = 1) leave hqr fi if(i2 == 0) return 0; //10. if(i2 != oldi2)iter = 0 fi if(i2 != oldi2) iter = 0;//I suppose we moved to the next eigenvalue //11. wilkshift(H[i2-1,i2-1], H[i2-1,i2], H[i2,i2-1], H[i2,i2], k) wilkshift(&INDEX(H,n,(i2-1),(i2-1)), &INDEX(H,n,(i2-1),i2), &INDEX(H,n,i2,(i2-1)), &INDEX(H,n,i2,i2), &k); //12. H[i1,i1] = H[i1,i1] - k INDEX(H,n,i1,i1).real -= k.real; INDEX(H,n,i1,i1).imag -= k.imag; //13. for i = i1 to i2-1 for(i = i1; i <= i2-1; i++) { //14. rotgen(H[i,i], H[i+1, i], c_i, s_i) rotgen(&INDEX(H,n,i,i), &INDEX(H,n,(i+1),i), &c[i], &s[i]); //15. H[i+1, i+1] = H[i+1, i+1] - k INDEX(H,n,(i+1),(i+1)).real -= k.real; INDEX(H,n,(i+1),(i+1)).imag -= k.imag; //16. rotapp(c_i, s_i, H[i, i+1:n], H[i+1,i+1:n]) //Unfortunately, we are now using a row. Before we were looking at //single columns, so I indexed the arrays H[i,j] = H[i + j*n], so //that &INDEX(H,n,i,j) could be used to equal H[i:n,j]. I can't do //that with rows now. //I will be using the array r1 and r2 for these two rows //copy the contents fo the rows to r1,r2 for(j = i+1; j < n; j++) { r1[j].real = INDEX(H,n,i,j).real; r1[j].imag = INDEX(H,n,i,j).imag; r2[j].real = INDEX(H,n,(i+1),j).real; r2[j].imag = INDEX(H,n,(i+1),j).imag; } rotapp(&c[i], &s[i], &r1[i+1], &r2[i+1], t, n-i-1); //now copy the results back to H for(j = i+1; j < n; j++) { INDEX(H,n,i,j).real = r1[j].real; INDEX(H,n,i,j).imag = r1[j].imag; INDEX(H,n,(i+1),j).real = r2[j].real; INDEX(H,n,(i+1),j).imag = r2[j].imag; } }//17. end for i //18. for i = i1 to i2-1 for(i = i1; i <= i2-1; i++) { //19. rotapp(c_i, s_i_bar, H[1:i+1, i], H[1:i+1, i+1] tmp.real = s[i].real; tmp.imag = -s[i].imag; //I can use the column as a continuous array rotapp(&c[i], &tmp, &INDEX(H,n,0,i), &INDEX(H,n,0,(i+1)), t, i+2); //20. rotapp(c_i, s_i_bar, Q[1:n,i], Q[1:n,i+1) //I can use the column as a continuous array rotapp(&c[i], &tmp, &INDEX(Q,n,0,i), &INDEX(Q,n,0,(i+1)), t, n); //21. H[i,i] = H[i,i] + k INDEX(H,n,i,i).real += k.real; INDEX(H,n,i,i).imag += k.imag; }//22. end for i //23. H[i2,i2] = H[i2,i2] + k INDEX(H,n,i2,i2).real += k.real; INDEX(H,n,i2,i2).imag += k.imag; }//24. end while }//25 end hqr
/* Algorithm taken from Matrix Algorithms Vol. II by G.W. Stewart. REturns the right eigenvectors of the upper tiangular matrix T in the matrix X. T and X and n*n Complex matrices. */ void righteigvec(Complex *T, Complex *X, int n) { int k, i, j; Real dmin, tmp, s; Complex d, tmp_c; //fill X with zeros just in case for(i = 0; i < n; i++) { for(j = 0; j < n; j++) { INDEX(X,n,i,j).real = 0.0; INDEX(X,n,i,j).imag = 0.0; } } //4. for k = n to 1 by -1 for(k = n-1; k >= 0; k--) { //5. X[1:k-1,k] = -T[1:k-1,k] for(i = 0; i <= k-1; i++) { INDEX(X,n,i,k).real = -INDEX(T,n,i,k).real; INDEX(X,n,i,k).imag = -INDEX(T,n,i,k).imag; } //6. X[k,k] = 1 INDEX(X,n,k,k).real = 1.0; INDEX(X,n,k,k).imag = 0.0; //7. X[k+1:n,k] = 0 for(i = k+1; i < n; i++) { INDEX(X,n,i,k).real = 0.0; INDEX(X,n,i,k).imag = 0.0; } //8. dmin = max{eps_M*|T[k,k]|,smallnum} dmin = 0.0; tmp = INDEX(T,n,k,k).real * INDEX(T,n,k,k).real + INDEX(T,n,k,k).imag * INDEX(T,n,k,k).imag; tmp = EPS_M * sqrt(tmp); if(tmp > SMALLNUM) dmin = tmp; else dmin = SMALLNUM; //9. for j = k-1 to 1 by -1 for(j = k-1; j >= 0; j--) { //10. d = T[j,j] - T[k,k] d.real = INDEX(T,n,j,j).real - INDEX(T,n,k,k).real; d.imag = INDEX(T,n,j,j).imag - INDEX(T,n,k,k).imag; //11. if(|d| <= dmin) d = dmin fi if(norm(&d,1) <= dmin) { d.real = dmin; d.imag = 0.0; } //12. if(|X[j,k]|/bignum >= |d|) if(norm(&(INDEX(X,n,j,k)),1)/BIGNUM >= norm(&d,1)) { //13. s = |d|/|X[j,k]| s = norm(&d, 1)/norm(&INDEX(X,n,j,k),1); //14. X[1:k,k] = s*X[1:k,k] for(i = 0; i <= k; i++) { INDEX(X,n,i,k).real = s*INDEX(X,n,i,k).real; INDEX(X,n,i,k).imag = s*INDEX(X,n,i,k).imag; } }//15. endif //16. X[j,k] = X[j,k]/d tmp = INDEX(X,n,j,k).real; INDEX(X,n,j,k).real = INDEX(X,n,j,k).real*d.real + INDEX(X,n,j,k).imag*d.imag; INDEX(X,n,j,k).imag = INDEX(X,n,j,k).imag*d.real - tmp*d.imag; tmp = d.real*d.real + d.imag*d.imag; INDEX(X,n,j,k).real /= tmp; INDEX(X,n,j,k).imag /= tmp; //17. X[1:j-1,k] = X[1:j-1,k] - X[j,k]*T[1:j-1,j] for(i = 0; i <= j-1; i++) { tmp_c = complexMult(INDEX(X,n,j,k), INDEX(T,n,i,j)); INDEX(X,n,i,k).real = INDEX(X,n,i,k).real - tmp_c.real; INDEX(X,n,i,k).imag = INDEX(X,n,i,k).imag - tmp_c.imag; } }//18. end for j //19. X[1:k,k] = X[1:k,k]/||X[1:k,k]||_2 tmp = norm(&INDEX(X,n,0,k),k+1); for(i = 0; i <= k; i++) { INDEX(X,n,i,k).real /= tmp; INDEX(X,n,i,k).imag /= tmp; } }//20. end for k }//21. end righteigvec
{NAME("prof_gdump"), CTL(opt_prof_gdump)}, {NAME("prof_final"), CTL(opt_prof_final)}, {NAME("prof_leak"), CTL(opt_prof_leak)}, {NAME("prof_accum"), CTL(opt_prof_accum)} }; static const ctl_named_node_t arena_i_node[] = { {NAME("purge"), CTL(arena_i_purge)}, {NAME("dss"), CTL(arena_i_dss)} }; static const ctl_named_node_t super_arena_i_node[] = { {NAME(""), CHILD(named, arena_i)} }; static const ctl_indexed_node_t arena_node[] = { {INDEX(arena_i)} }; static const ctl_named_node_t arenas_bin_i_node[] = { {NAME("size"), CTL(arenas_bin_i_size)}, {NAME("nregs"), CTL(arenas_bin_i_nregs)}, {NAME("run_size"), CTL(arenas_bin_i_run_size)} }; static const ctl_named_node_t super_arenas_bin_i_node[] = { {NAME(""), CHILD(named, arenas_bin_i)} }; static const ctl_indexed_node_t arenas_bin_node[] = { {INDEX(arenas_bin_i)} };
/* Algorithm taken from Matrix Algorithms Vol. II by G.W. Stewart. This function takes a vector A of order n and reduces it to Hessenberg form by Householder transformations. In the future it may be possible to remove H entirely and do the transformation in place. A is an n*n matrix that I am transforming H is an n*n matrix where I will put the result Q is an n*n matrix where I will accumulate the transformations u is a vector of length n for scratch work. vH is another vector of length n for scratch work */ void hessreduce(Complex *A, Complex *H, Complex *Q, Complex *u, Complex *vH, int n) { int k, i, j, l; Complex tmp; if(n < 2) return; //Reduce A //H = A copyMat(A,H,n,n); //3. for k = 1 to n-2 for(k = 0; k < n-2; k++) { //Generate the Transformation //housegen(H[k+1:n,k],u,H[k+1,k]) housegen(&INDEX(H,n,(k+1),k),u+k+1,&INDEX(H,n,(k+1),k),n-k-1); //5. Q[k+1:n,k] = u copyVect(u+k+1, &INDEX(Q, n, (k+1), k), n-k-1); //Premultiply the transformation //6. vH = uH*H[k+1:n,k+1:n] for(i = k+1; i < n; i++) { vH[i].real = 0.0; vH[i].imag = 0.0; for(j = k+1; j < n; j++) { tmp = INDEX(H,n,j,i); vH[i].real += u[j].real * tmp.real; vH[i].real += u[j].imag * tmp.imag;//minus minus for hermitian vH[i].imag += u[j].real * tmp.imag; vH[i].imag -= u[j].imag * tmp.real;//minus sign is for hermitian } } //7. H[k+1:n,k+1:n] = H[k+1:n, k+1:n] - u*vH for(i = k+1; i < n; i++) { for(j = k+1; j < n; j++) { INDEX(H,n,i,j).real -= u[i].real *vH[j].real; INDEX(H,n,i,j).real += u[i].imag *vH[j].imag; INDEX(H,n,i,j).imag -= u[i].real *vH[j].imag; INDEX(H,n,i,j).imag -= u[i].imag *vH[j].real; } } //H[k+2:n,k] = 0 for(i = k+2; i < n; i++) { INDEX(H,n,i,k).real = 0.0; INDEX(H,n,i,k).imag = 0.0; } //Postmultiply the transformation //9. v = H[1:n, k+1:n]*u //I will use the variable vH for v (for space). for(i = 0; i < n; i++) { vH[i].real = 0.0; vH[i].imag = 0.0; for(j = k+1; j < n; j++) { tmp = INDEX(H,n,i,j); vH[i].real += tmp.real * u[j].real; vH[i].real -= tmp.imag * u[j].imag; vH[i].imag += tmp.real * u[j].imag; vH[i].imag += tmp.imag * u[j].real; } } //10. H[1:n, k+1:n] = H[1:n,k+1:n] - v*uH for(i = 0; i < n; i++) { for(j = k+1; j < n; j++) { INDEX(H,n,i,j).real -= vH[i].real * u[j].real; INDEX(H,n,i,j).real -= vH[i].imag * u[j].imag; INDEX(H,n,i,j).imag += vH[i].real * u[j].imag; INDEX(H,n,i,j).imag -= vH[i].imag * u[j].real; } } }//end k //Accumulate the Transformations //12. Q[:,n] = e_n; Q[:,n-1] = e_(n-1) for(i = 0; i < n; i++) { INDEX(Q,n,i,(n-1)).real = 0.0; INDEX(Q,n,i,(n-1)).imag = 0.0; INDEX(Q,n,i,(n-2)).real = 0.0; INDEX(Q,n,i,(n-2)).imag = 0.0; } INDEX(Q,n,(n-1),(n-1)).real = 1.0; INDEX(Q,n,(n-2),(n-2)).real = 1.0; //13. for k = n-2 to 1 by -1 for(k = n-3; k >= 0; k--) { //14. u = Q[k+1:n,k] copyVect(&INDEX(Q,n,(k+1),k), u+k+1, n-(k+1)); //15. vH = uH*Q[k+1:n,k+1:n]//Q[k+1:n,k] = u for(i = k+1; i < n; i++) { vH[i].real = 0.0; vH[i].imag = 0.0; for(j = k+1; j < n; j++) { tmp.real = u[j].real; tmp.imag = -u[j].imag; tmp = complexMult(tmp, INDEX(Q, n, j, i)); vH[i].real += tmp.real; vH[i].imag += tmp.imag; } } //16. Q[k+1:n, k+1:n] = Q[k+1:n, k+1:n] -u*vH for(i = k+1; i < n; i++) { for(j = k+1; j < n; j++) { tmp = complexMult(u[i],vH[j]); INDEX(Q,n,i,j).real -= tmp.real; INDEX(Q,n,i,j).imag -= tmp.imag; } } //17. Q[:,k] = e_k for(i = 0; i < n; i++) { INDEX(Q,n,i,k).real = 0.0; INDEX(Q,n,i,k).imag = 0.0; } INDEX(Q,n,k,k).real = 1.0; }// 18. end for k }//end hessreduce
static void cvm_oct_rgmii_poll(struct ifnet *ifp) { cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc; cvmx_helper_link_info_t link_info; /* Take the global register lock since we are going to touch registers that affect more than one port */ mtx_lock_spin(&global_register_lock); link_info = cvmx_helper_link_get(priv->port); if (link_info.u64 == priv->link_info) { /* If the 10Mbps preamble workaround is supported and we're at 10Mbps we may need to do some special checking */ if (USE_10MBPS_PREAMBLE_WORKAROUND && (link_info.s.speed == 10)) { /* Read the GMXX_RXX_INT_REG[PCTERR] bit and see if we are getting preamble errors */ int interface = INTERFACE(priv->port); int index = INDEX(priv->port); cvmx_gmxx_rxx_int_reg_t gmxx_rxx_int_reg; gmxx_rxx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(index, interface)); if (gmxx_rxx_int_reg.s.pcterr) { /* We are getting preamble errors at 10Mbps. Most likely the PHY is giving us packets with mis aligned preambles. In order to get these packets we need to disable preamble checking and do it in software */ cvmx_gmxx_rxx_frm_ctl_t gmxx_rxx_frm_ctl; cvmx_ipd_sub_port_fcs_t ipd_sub_port_fcs; /* Disable preamble checking */ gmxx_rxx_frm_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface)); gmxx_rxx_frm_ctl.s.pre_chk = 0; cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface), gmxx_rxx_frm_ctl.u64); /* Disable FCS stripping */ ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); ipd_sub_port_fcs.s.port_bit &= 0xffffffffull ^ (1ull<<priv->port); cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64); /* Clear any error bits */ cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface), gmxx_rxx_int_reg.u64); DEBUGPRINT("%s: Using 10Mbps with software preamble removal\n", if_name(ifp)); } } mtx_unlock_spin(&global_register_lock); return; } /* If the 10Mbps preamble workaround is allowed we need to on preamble checking, FCS stripping, and clear error bits on every speed change. If errors occur during 10Mbps operation the above code will change this stuff */ if (USE_10MBPS_PREAMBLE_WORKAROUND) { cvmx_gmxx_rxx_frm_ctl_t gmxx_rxx_frm_ctl; cvmx_ipd_sub_port_fcs_t ipd_sub_port_fcs; cvmx_gmxx_rxx_int_reg_t gmxx_rxx_int_reg; int interface = INTERFACE(priv->port); int index = INDEX(priv->port); /* Enable preamble checking */ gmxx_rxx_frm_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface)); gmxx_rxx_frm_ctl.s.pre_chk = 1; cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface), gmxx_rxx_frm_ctl.u64); /* Enable FCS stripping */ ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); ipd_sub_port_fcs.s.port_bit |= 1ull<<priv->port; cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64); /* Clear any error bits */ gmxx_rxx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(index, interface)); cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface), gmxx_rxx_int_reg.u64); } if (priv->miibus == NULL) { link_info = cvmx_helper_link_autoconf(priv->port); priv->link_info = link_info.u64; priv->need_link_update = 1; } mtx_unlock_spin(&global_register_lock); }
int cvm_oct_rgmii_init(struct ifnet *ifp) { struct octebus_softc *sc; cvm_oct_private_t *priv = (cvm_oct_private_t *)ifp->if_softc; int error; int rid; if (cvm_oct_common_init(ifp) != 0) return ENXIO; priv->open = cvm_oct_common_open; priv->stop = cvm_oct_common_stop; priv->stop(ifp); /* Due to GMX errata in CN3XXX series chips, it is necessary to take the link down immediately whne the PHY changes state. In order to do this we call the poll function every time the RGMII inband status changes. This may cause problems if the PHY doesn't implement inband status properly */ if (number_rgmii_ports == 0) { sc = device_get_softc(device_get_parent(priv->dev)); rid = 0; sc->sc_rgmii_irq = bus_alloc_resource(sc->sc_dev, SYS_RES_IRQ, &rid, OCTEON_IRQ_RML, OCTEON_IRQ_RML, 1, RF_ACTIVE); if (sc->sc_rgmii_irq == NULL) { device_printf(sc->sc_dev, "could not allocate RGMII irq"); return ENXIO; } error = bus_setup_intr(sc->sc_dev, sc->sc_rgmii_irq, INTR_TYPE_NET | INTR_MPSAFE, cvm_oct_rgmii_rml_interrupt, NULL, &number_rgmii_ports, NULL); if (error != 0) { device_printf(sc->sc_dev, "could not setup RGMII irq"); return error; } } number_rgmii_ports++; /* Only true RGMII ports need to be polled. In GMII mode, port 0 is really a RGMII port */ if (((priv->imode == CVMX_HELPER_INTERFACE_MODE_GMII) && (priv->port == 0)) || (priv->imode == CVMX_HELPER_INTERFACE_MODE_RGMII)) { if (cvmx_sysinfo_get()->board_type != CVMX_BOARD_TYPE_SIM) { cvmx_gmxx_rxx_int_en_t gmx_rx_int_en; int interface = INTERFACE(priv->port); int index = INDEX(priv->port); /* Enable interrupts on inband status changes for this port */ gmx_rx_int_en.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_EN(index, interface)); gmx_rx_int_en.s.phy_dupx = 1; gmx_rx_int_en.s.phy_link = 1; gmx_rx_int_en.s.phy_spd = 1; cvmx_write_csr(CVMX_GMXX_RXX_INT_EN(index, interface), gmx_rx_int_en.u64); priv->poll = cvm_oct_rgmii_poll; } } return 0; }
void mxmg_c ( const void * m1, const void * m2, SpiceInt nrow1, SpiceInt ncol1, SpiceInt ncol2, void * mout ) /* -Brief_I/O VARIABLE I/O DESCRIPTION -------- --- -------------------------------------------------- m1 I nrow1 X ncol1 double precision matrix. m2 I ncol1 X ncol2 double precision matrix. nrow1 I Row dimension of m1 (and also mout). ncol1 I Column dimension of m1 and row dimension of m2. ncol2 I Column dimension of m2 (and also mout). mout O nrow1 X ncol2 double precision matrix. -Detailed_Input m1 is any double precision matrix of arbitrary size. m2 is any double precision matrix of arbitrary size. The number of rows in m2 must match the number of columns in m1. nrow1 is the number of rows in both m1 and mout. ncol1 is the number of columns in m1 and (by necessity) the number of rows of m2. ncol2 is the number of columns in both m2 and mout. -Detailed_Output mout mout is the product matrix defined by mout = (m1) x (m2) mout is a double precision matrix of dimension nrow1 x ncol2. mout may overwrite m1 or m2. Note that this capability does not exist in the Fortran version of SPICELIB; in the Fortran version, the output must not overwrite either input. -Parameters None. -Exceptions 1) If dynamic allocation of memory fails, the error SPICE(MEMALLOCFAILED) is signalled. -Files None. -Particulars The code reflects precisely the following mathematical expression For each value of the subscript i from 1 to nrow1, and j from 1 to ncol2: mout(i,j) = Summation from k=1 to ncol1 of m1(i,k) * m2(k,j) -Examples Let m1 = | 1.0 4.0 | and m2 = | 1.0 3.0 5.0 | | | | | 2.0 5.0 | | 2.0 4.0 6.0 | | | | 3.0 6.0 | and nrow1 = 3 ncol1 = 2 ncol2 = 3 Then the call mxmg ( m1, m2, nrow1, ncol1, ncol2, mout ); produces the matrix mout = | 9.0 19.0 29.0 | | | | 12.0 26.0 40.0 | | | | 15.0 33.0 51.0 | -Restrictions 1) No error checking is performed to prevent numeric overflow or underflow. 2) No error checking performed to determine if the input and output matrices have, in fact, been correctly dimensioned. -Literature_References None. -Author_and_Institution N.J. Bachman (JPL) W.M. Owen (JPL) -Version -CSPICE Version 1.1.2, 16-JAN-2008 (EDW) Corrected typos in header titles: Detailed Input to Detailed_Input Detailed Output to Detailed_Output -CSPICE Version 1.1.1, 10-NOV-2006 (EDW) Added Parameters section header. -CSPICE Version 1.1.0, 28-AUG-2001 (NJB) Const-qualified input arrays. -CSPICE Version 1.0.0, 16-APR-1999 (NJB) -Index_Entries matrix times matrix n-dimensional_case -& */ { /* Begin mxmg_c */ /* Local macros We'd like to be able to refer to the elements of the input and output matrices using normal subscripts, for example, m1[2][3]. Since the compiler doesn't know how to compute index offsets for the array arguments, which have user-adjustable size, we must compute the offsets ourselves. To make syntax a little easier to read (we hope), we'll use macros to do the computations. The macro INDEX(width, i,j) computes the index offset from the array base of the element at position [i][j] in a 2-dimensional matrix having the number of columns indicated by width. For example, if the input matrix m1 has 2 rows and 3 columns, the element at position [0][1] would be indicated by m1[ INDEX(3,0,1) ] */ #define INDEX( width, row, col ) ( (row)*(width) + (col) ) /* Local variables */ SpiceDouble innerProduct; SpiceDouble *tmpmat; SpiceDouble *loc_m1; SpiceDouble *loc_m2; SpiceInt col; SpiceInt nelts; SpiceInt row; SpiceInt i; size_t size; /* Allocate space for a temporary copy of the output matrix, which has nrow1 rows and ncol2 columns. */ nelts = nrow1 * ncol2; size = (size_t) ( nelts * sizeof(SpiceDouble) ); tmpmat = (SpiceDouble *) malloc ( size ); if ( tmpmat == (SpiceDouble *)0 ) { chkin_c ( "mxmg_c" ); setmsg_c ( "An attempt to create a temporary matrix failed." ); sigerr_c ( "SPICE(MEMALLOCFAILED)" ); chkout_c ( "mxmg_c" ); return; } /* Cast the input pointers to pointers to SpiceDoubles. Note: the original variables are pointers to void so that callers may supply the array names as arguments without casting them to SpiceDoubles. The naked array name is considered by the compiler to be an incompatible pointer type with (SpiceDouble *), so we can't simply declare the arguments to be (SpiceDouble *). On the other hand, every pointer type can be cast to (void *). */ loc_m1 = (SpiceDouble *) m1; loc_m2 = (SpiceDouble *) m2; /* Compute the product. The matrix element at position (row,col) is the inner product of the row of m1 having index row and the column of m2 having index col. We compute index offsets using the macro INDEX. */ for ( row = 0; row < nrow1; row++ ) { for ( col = 0; col < ncol2; col++ ) { innerProduct = 0.0; for ( i = 0; i < ncol1; i++ ) { innerProduct += loc_m1[ INDEX(ncol1, row, i ) ] * loc_m2[ INDEX(ncol2, i, col) ]; } tmpmat [ INDEX( ncol2, row, col ) ] = innerProduct; } } /* Move the result from tmpmat into mout. */ MOVED ( tmpmat, nelts, mout ); /* Free the temporary matrix. */ free ( tmpmat ); } /* End mxmg_c */
status_t ExynosCameraFrameFactory::fastenAeStable(int32_t numFrames, ExynosCameraBuffer *buffers) { ALOGI("INFO(%s[%d]): Start", __FUNCTION__, __LINE__); int ret = 0; ExynosCameraFrame *newFrame = NULL; ExynosCameraFrame *queueFrame = NULL; ExynosCameraFrameEntity *newEntity = NULL; ExynosCameraFrameEntity *prevEntity = NULL; ExynosCameraList<ExynosCameraFrame *> instantQ; frame_queue_t *instanceOnDoneQ = NULL; m_instanceOnMaxCnt = numFrames; m_instanceOnCurCnt = 0; instanceOnDoneQ = new frame_queue_t; /* TODO 1. setup pipes for 120FPS */ camera_pipe_info_t pipeInfo[3]; ExynosRect tempRect; int hwSensorW = 0, hwSensorH = 0; int hwPreviewW = 0, hwPreviewH = 0; int bayerFormat = CAMERA_BAYER_FORMAT; int previewFormat = m_parameters->getHwPreviewFormat(); int pictureFormat = m_parameters->getPictureFormat(); ExynosRect bayerCropSize; uint32_t frameRate = 0; struct v4l2_streamparm streamParam; sp<Thread> instanceOnThread; int count = 0; #if 0 m_parameters->getMaxSensorSize(&bayerCropSize.w, &bayerCropSize.h); frameRate = 30; bayerCropSize.w = 3248; bayerCropSize.h = 2438; bayerCropSize.x = 0; bayerCropSize.y = 0; hwSensorW = bayerCropSize.w; hwSensorH = bayerCropSize.h; hwPreviewW = hwSensorW; hwPreviewH = hwSensorH; /* frameRate = 30; m_parameters->getMaxSensorSize(&maxSensorW, &maxSensorH); m_parameters->getMaxPreviewSize(&maxPreviewW, &maxPreviewH); m_parameters->getHwPreviewSize(&hwPreviewW, &hwPreviewH); */ #else frameRate = FASTEN_AE_FPS; bayerCropSize.w = FASTEN_AE_WIDTH; bayerCropSize.h = FASTEN_AE_HEIGHT; bayerCropSize.x = 0; bayerCropSize.y = 0; hwSensorW = bayerCropSize.w; hwSensorH = bayerCropSize.h; hwPreviewW = hwSensorW; hwPreviewH = hwSensorH; #endif ALOGI("INFO(%s[%d]): hwSensorSize (%dx%d)", __FUNCTION__, __LINE__, hwSensorW, hwSensorH); memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* FLITE pipe */ tempRect.fullW = hwSensorW + 16; tempRect.fullH = hwSensorH + 10; tempRect.colorFormat = bayerFormat; pipeInfo[0].rectInfo = tempRect; pipeInfo[0].bufInfo.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; pipeInfo[0].bufInfo.memory = V4L2_CAMERA_MEMORY_TYPE; pipeInfo[0].bufInfo.count = NUM_FASTAESTABLE_BUFFER; /* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 0; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_NONE; #ifdef CAMERA_PACKED_BAYER_ENABLE /* packed bayer bytesPerPlane */ pipeInfo[0].bytesPerPlane[0] = ROUND_UP(pipeInfo[0].rectInfo.fullW, 10) * 8 / 5; #endif ret = m_pipes[INDEX(PIPE_FLITE)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]):FLITE setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ goto cleanup; } /* setParam for Frame rate */ memset(&streamParam, 0x0, sizeof(v4l2_streamparm)); streamParam.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; streamParam.parm.capture.timeperframe.numerator = 1; streamParam.parm.capture.timeperframe.denominator = frameRate; ALOGI("INFO(%s[%d]:set framerate (denominator=%d)", __FUNCTION__, __LINE__, frameRate); ret = setParam(streamParam, PIPE_FLITE); if (ret < 0) { ALOGE("ERR(%s[%d]):FLITE setParam fail, ret(%d)", __FUNCTION__, __LINE__, ret); goto cleanup; } memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* ISP pipe */ tempRect.fullW = hwSensorW + 16; tempRect.fullH = hwSensorH + 10; #if 0 tempRect.w = hwSensorW + 16; tempRect.h = hwSensorH + 10; tempRect.x = 0; tempRect.y = 0; #endif tempRect.colorFormat = bayerFormat; /* ISP pipe */ pipeInfo[0].rectInfo = tempRect; pipeInfo[0].bufInfo.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; pipeInfo[0].bufInfo.memory = V4L2_CAMERA_MEMORY_TYPE; pipeInfo[0].bufInfo.count = numFrames; /* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 3; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_LEADER; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perframeInfoIndex = PERFRAME_INFO_ISP; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameVideoID = (FIMC_IS_VIDEO_ISP_NUM - FIMC_IS_VIDEO_SS0_NUM); pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[0].perFrameNodeType = PERFRAME_NODE_TYPE_CAPTURE; pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[0].perFrameVideoID = (FIMC_IS_VIDEO_SCC_NUM - FIMC_IS_VIDEO_SS0_NUM); pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[1].perFrameNodeType = PERFRAME_NODE_TYPE_CAPTURE; pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[1].perFrameVideoID = (FIMC_IS_VIDEO_SCP_NUM - FIMC_IS_VIDEO_SS0_NUM); #ifdef CAMERA_PACKED_BAYER_ENABLE /* packed bayer bytesPerPlane */ pipeInfo[0].bytesPerPlane[0] = ROUND_UP(pipeInfo[0].rectInfo.fullW, 10) * 8 / 5; #endif ret = m_pipes[INDEX(PIPE_ISP)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]):ISP setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ goto cleanup; } memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* SCC pipe */ tempRect.fullW = hwPreviewW; tempRect.fullH = hwPreviewH; tempRect.colorFormat = pictureFormat; pipeInfo[0].rectInfo = tempRect; pipeInfo[0].bufInfo.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; pipeInfo[0].bufInfo.memory = V4L2_CAMERA_MEMORY_TYPE; pipeInfo[0].bufInfo.count = NUM_PREVIEW_BUFFERS; /* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 0; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_NONE; ret = m_pipes[INDEX(PIPE_SCC)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]):SCP setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ goto cleanup; } memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* SCP pipe */ tempRect.fullW = hwPreviewW; tempRect.fullH = hwPreviewH; tempRect.colorFormat = previewFormat; pipeInfo[0].rectInfo = tempRect; pipeInfo[0].bufInfo.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; pipeInfo[0].bufInfo.memory = V4L2_CAMERA_MEMORY_TYPE; pipeInfo[0].bufInfo.count = NUM_PREVIEW_BUFFERS; /* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 0; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_NONE; ret = m_pipes[INDEX(PIPE_SCP)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]):SCP setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ goto cleanup; } for (int i = 0; i < numFrames; i++) { /* 2. generate instant frames */ newFrame = new ExynosCameraFrame(m_parameters, i); ret = m_initFrameMetadata(newFrame); if (ret < 0) ALOGE("(%s[%d]): frame(%d) metadata initialize fail", __FUNCTION__, __LINE__, i); prevEntity = new ExynosCameraFrameEntity(PIPE_FLITE, ENTITY_TYPE_OUTPUT_ONLY, ENTITY_BUFFER_FIXED); newFrame->addSiblingEntity(NULL, prevEntity); newEntity = new ExynosCameraFrameEntity(PIPE_ISP, ENTITY_TYPE_INPUT_ONLY, ENTITY_BUFFER_FIXED); newFrame->addChildEntity(prevEntity, newEntity); newFrame->setNumRequestPipe(1); ret = m_initPipelines(newFrame); if (ret < 0) { ALOGE("ERR(%s):m_initPipelines fail, ret(%d)", __FUNCTION__, ret); } camera2_node_group node_group_info_isp; int zoom = m_parameters->getZoomLevel(); memset(&node_group_info_isp, 0x0, sizeof(camera2_node_group)); node_group_info_isp.leader.request = 1; node_group_info_isp.leader.input.cropRegion[0] = 0; node_group_info_isp.leader.input.cropRegion[1] = 0; node_group_info_isp.leader.input.cropRegion[2] = bayerCropSize.w; node_group_info_isp.leader.input.cropRegion[3] = bayerCropSize.h; node_group_info_isp.leader.output.cropRegion[0] = node_group_info_isp.leader.input.cropRegion[0]; node_group_info_isp.leader.output.cropRegion[1] = node_group_info_isp.leader.input.cropRegion[1]; node_group_info_isp.leader.output.cropRegion[2] = node_group_info_isp.leader.input.cropRegion[2]; node_group_info_isp.leader.output.cropRegion[3] = node_group_info_isp.leader.input.cropRegion[3]; newFrame->storeNodeGroupInfo(&node_group_info_isp, PERFRAME_INFO_ISP, zoom); setRequestSCC(false); setRequestSCP(false); prevEntity->setDstBuf(buffers[i]); newEntity->setSrcBuf(buffers[i]); /* set metadata for instant on */ camera2_shot_ext *shot_ext = (struct camera2_shot_ext *)(buffers[i].addr[1]); newFrame->getMetaData(shot_ext); if (shot_ext != NULL) { shot_ext->shot.ctl.scaler.cropRegion[0] = 0; shot_ext->shot.ctl.scaler.cropRegion[1] = 0; shot_ext->shot.ctl.scaler.cropRegion[2] = hwPreviewW; shot_ext->shot.ctl.scaler.cropRegion[3] = hwPreviewH; } /* 3. push instance frames to pipe */ ret = pushFrameToPipe(&newFrame, PIPE_FLITE); if (ret < 0) { ALOGE("DEBUG(%s[%d]): pushFrameToPipeFail, ret(%d)", __FUNCTION__, __LINE__, ret); goto cleanup; } /* 3. push instance frames to doneQ*/ ret = setOutputFrameQToPipe(instanceOnDoneQ, PIPE_ISP); if (ret < 0) { ALOGE("DEBUG(%s[%d]): pushFrameToPipeFail, ret(%d)", __FUNCTION__, __LINE__, ret); goto cleanup; } ALOGD("DEBUG(%s[%d]): Instant shot - FD(%d, %d) frameCnt(%d) frame(%p)", __FUNCTION__, __LINE__, buffers[i].fd[0], buffers[i].fd[1], newFrame->getFrameCount(), newFrame); instantQ.pushProcessQ(&newFrame); } for( int k = 0 ; k < numFrames ; k++ ) { ret = m_pipes[INDEX(PIPE_FLITE)]->instantOnQbuf(&queueFrame, BUFFER_POS::DST); if (ret < 0) { ALOGE("DEBUG(%s[%d]): FLITE instantOnQbuf fail, ret(%d)", __FUNCTION__, __LINE__, ret); goto cleanup; } } /* 4. pipe instant on */ ret = m_pipes[INDEX(PIPE_FLITE)]->instantOn(numFrames); if (ret < 0) { ALOGE("DEBUG(%s[%d]): PIPE_FLITE On fail, ret(%d)", __FUNCTION__, __LINE__, ret); goto cleanup; } ret = m_pipes[INDEX(PIPE_ISP)]->instantOn(0); if (ret < 0) { ALOGE("DEBUG(%s[%d]): PIPE_ISP On fail, ret(%d)", __FUNCTION__, __LINE__, ret); goto cleanup; } instanceOnThread = ExynosCameraThreadFactory::createThread(this, &ExynosCameraFrameFactory::m_instanceOnThreadFunc, "InstanceOnThread", PRIORITY_URGENT_DISPLAY); instanceOnThread->run(); /* 5. setControl to sensor instant on */ ret = m_pipes[INDEX(PIPE_FLITE)]->setControl(V4L2_CID_IS_S_STREAM, (1 | 1 << SENSOR_NOBLOCK_SHIFT | numFrames << SENSOR_INSTANT_SHIFT)); if (ret < 0) { ALOGE("DEBUG(%s[%d]): instantOn fail, ret(%d)", __FUNCTION__, __LINE__, ret); goto cleanup; } while( true ) { newFrame = NULL; ret = instanceOnDoneQ->waitAndPopProcessQ(&newFrame); if (ret < 0) { /* TODO: We need to make timeout duration depends on FPS */ if (ret == TIMED_OUT) { ALOGW("WARN(%s):wait timeout", __FUNCTION__); } else { ALOGE("ERR(%s):wait and pop fail, ret(%d)", __FUNCTION__, ret); /* TODO: doing exception handling */ } continue; } count++; ALOGE("Instance On wait Frame count(%d) numFrames(%d)", count, numFrames); if( numFrames <= count ) break; } instanceOnThread->requestExit(); /* 6. pipe instant off */ ret = m_pipes[INDEX(PIPE_FLITE)]->instantOff(); if (ret < 0) { ALOGE("DEBUG(%s[%d]): FLITE Off fail, ret(%d)", __FUNCTION__, __LINE__, ret); } ret = m_pipes[INDEX(PIPE_ISP)]->instantOff(); if (ret < 0) { ALOGE("DEBUG(%s[%d]): ISP Off fail, ret(%d)", __FUNCTION__, __LINE__, ret); } cleanup: newFrame = NULL; /* clean up all frames */ for (int i = 0; i < numFrames; i++) { if (instantQ.getSizeOfProcessQ() == 0) break; ret = instantQ.popProcessQ(&newFrame); if (ret < 0) { ALOGE("ERR(%s[%d]): pop instantQ fail, ret(%d)", __FUNCTION__, __LINE__, ret); continue; } if (newFrame == NULL) { ALOGE("ERR(%s[%d]): newFrame is NULL,", __FUNCTION__, __LINE__); continue; } delete newFrame; newFrame = NULL; } if (instanceOnDoneQ != NULL) { delete instanceOnDoneQ; instanceOnDoneQ = NULL; } ALOGI("INFO(%s[%d]): Done", __FUNCTION__, __LINE__); return ret; }
double timeTest(int num) { //linux wall time struct timeval tvBegin, tvEnd, tvDiff; int i; #define N 8 Complex A[N*N]; Real c[N]; Complex s[N], r1[N], r2[N], t[N]; INDEX(A,8,0,0).real = -1.2; INDEX(A,8,0,0).imag = 3.1; INDEX(A,8,0,1).real = 2.4; INDEX(A,8,0,1).imag = -0.1; INDEX(A,8,0,2).real = 0.3; INDEX(A,8,0,2).imag = -1.0; INDEX(A,8,0,3).real = 3.6; INDEX(A,8,0,3).imag = -0.2; INDEX(A,8,0,4).real = 1.0; INDEX(A,8,0,4).imag = 0.0; INDEX(A,8,0,5).real = 0.1; INDEX(A,8,0,5).imag = -3.2; INDEX(A,8,0,6).real = 2.3; INDEX(A,8,0,6).imag = 1.6; INDEX(A,8,0,7).real = 0.4; INDEX(A,8,0,7).imag = -2.3; INDEX(A,8,1,0).real = 1.1; INDEX(A,8,1,0).imag = -0.2; INDEX(A,8,1,1).real = -2.0; INDEX(A,8,1,1).imag = 1.0; INDEX(A,8,1,2).real = 3.2; INDEX(A,8,1,2).imag = 3.8; INDEX(A,8,1,3).real = -2.1; INDEX(A,8,1,3).imag = -1.2; INDEX(A,8,1,4).real = 1.6; INDEX(A,8,1,4).imag = 0.9; INDEX(A,8,1,5).real = -2.1; INDEX(A,8,1,5).imag = -0.1; INDEX(A,8,1,6).real = 1.3; INDEX(A,8,1,6).imag = 2.1; INDEX(A,8,1,7).real = 4.2; INDEX(A,8,1,7).imag = 0.0; INDEX(A,8,2,0).real = -1.2; INDEX(A,8,2,0).imag = 3.1; INDEX(A,8,2,1).real = 2.4; INDEX(A,8,2,1).imag = -0.1; INDEX(A,8,2,2).real = 0.3; INDEX(A,8,2,2).imag = -1.0; INDEX(A,8,2,3).real = 3.6; INDEX(A,8,2,3).imag = -0.2; INDEX(A,8,2,4).real = 1.0; INDEX(A,8,2,4).imag = 0.0; INDEX(A,8,2,5).real = 0.1; INDEX(A,8,2,5).imag = -3.2; INDEX(A,8,2,6).real = 0.0; INDEX(A,8,2,6).imag = 0.0; INDEX(A,8,2,7).real = 0.4; INDEX(A,8,2,7).imag = -2.3; INDEX(A,8,3,0).real = 1.1; INDEX(A,8,3,0).imag = -0.2; INDEX(A,8,3,1).real = -2.0; INDEX(A,8,3,1).imag = 1.0; INDEX(A,8,3,2).real = 3.2; INDEX(A,8,3,2).imag = 3.8; INDEX(A,8,3,3).real = -2.1; INDEX(A,8,3,3).imag = -1.2; INDEX(A,8,3,4).real = 1.6; INDEX(A,8,3,4).imag = 0.9; INDEX(A,8,3,5).real = -2.1; INDEX(A,8,3,5).imag = -0.1; INDEX(A,8,3,6).real = 1.3; INDEX(A,8,3,6).imag = 2.1; INDEX(A,8,3,7).real = 4.2; INDEX(A,8,3,7).imag = 0.0; INDEX(A,8,4,0).real = 1.2; INDEX(A,8,4,0).imag = 3.1; INDEX(A,8,4,1).real = 0.4; INDEX(A,8,4,1).imag = -0.1; INDEX(A,8,4,2).real = 0.3; INDEX(A,8,4,2).imag = -1.0; INDEX(A,8,4,3).real = 3.6; INDEX(A,8,4,3).imag = -0.2; INDEX(A,8,4,4).real = 0.0; INDEX(A,8,4,4).imag = 0.0; INDEX(A,8,4,5).real = 3.1; INDEX(A,8,4,5).imag = -3.2; INDEX(A,8,4,6).real = 2.3; INDEX(A,8,4,6).imag = 1.6; INDEX(A,8,4,7).real = 0.4; INDEX(A,8,4,7).imag = -2.3; INDEX(A,8,5,0).real = 2.1; INDEX(A,8,5,0).imag = -0.2; INDEX(A,8,5,1).real = -2.0; INDEX(A,8,5,1).imag = 1.0; INDEX(A,8,5,2).real = 3.2; INDEX(A,8,5,2).imag = -3.8; INDEX(A,8,5,3).real = 2.1; INDEX(A,8,5,3).imag = -1.2; INDEX(A,8,5,4).real = 1.6; INDEX(A,8,5,4).imag = 0.9; INDEX(A,8,5,5).real = 0.0; INDEX(A,8,5,5).imag = 0.0; INDEX(A,8,5,6).real = 1.3; INDEX(A,8,5,6).imag = 2.1; INDEX(A,8,5,7).real = -4.2; INDEX(A,8,5,7).imag = 0.0; INDEX(A,8,6,0).real = -1.2; INDEX(A,8,6,0).imag = 3.1; INDEX(A,8,6,1).real = -2.4; INDEX(A,8,6,1).imag = -0.1; INDEX(A,8,6,2).real = 0.3; INDEX(A,8,6,2).imag = -1.6; INDEX(A,8,6,3).real = 0.0; INDEX(A,8,6,3).imag = 0.0; INDEX(A,8,6,4).real = 1.0; INDEX(A,8,6,4).imag = 0.7; INDEX(A,8,6,5).real = 0.1; INDEX(A,8,6,5).imag = -3.2; INDEX(A,8,6,6).real = 2.3; INDEX(A,8,6,6).imag = -1.6; INDEX(A,8,6,7).real = -0.4; INDEX(A,8,6,7).imag = 2.3; INDEX(A,8,7,0).real = 1.1; INDEX(A,8,7,0).imag = 0.2; INDEX(A,8,7,1).real = 0.0; INDEX(A,8,7,1).imag = 0.0; INDEX(A,8,7,2).real = -3.2; INDEX(A,8,7,2).imag = -3.8; INDEX(A,8,7,3).real = -2.1; INDEX(A,8,7,3).imag = -1.2; INDEX(A,8,7,4).real = 1.6; INDEX(A,8,7,4).imag = 2.9; INDEX(A,8,7,5).real = -2.1; INDEX(A,8,7,5).imag = -0.1; INDEX(A,8,7,6).real = 1.3; INDEX(A,8,7,6).imag = 0.1; INDEX(A,8,7,7).real = 4.2; INDEX(A,8,7,7).imag = 0.0; printf("Original Matrix:\n"); printMat(A,N); Complex V[N*N]; Complex Q[N*N]; Real rv1[N]; Complex cv1[N],cv2[N],cv3[N],eigenValues[N]; Real epsilon = 0.000000001; gettimeofday(&tvBegin, NULL);//linux wall time for(i = 0; i < num; i++) { eigenDecomp(A, V, Q, eigenValues, rv1, cv1, cv2, cv3, N, epsilon, 50); INDEX(A,8,0,0).real = -1.2; INDEX(A,8,0,0).imag = 3.1; INDEX(A,8,0,1).real = 2.4; INDEX(A,8,0,1).imag = -0.1; INDEX(A,8,0,2).real = 0.3; INDEX(A,8,0,2).imag = -1.0; INDEX(A,8,0,3).real = 3.6; INDEX(A,8,0,3).imag = -0.2; INDEX(A,8,0,4).real = 1.0; INDEX(A,8,0,4).imag = 0.0; INDEX(A,8,0,5).real = 0.1; INDEX(A,8,0,5).imag = -3.2; INDEX(A,8,0,6).real = 2.3; INDEX(A,8,0,6).imag = 1.6; INDEX(A,8,0,7).real = 0.4; INDEX(A,8,0,7).imag = -2.3; INDEX(A,8,1,0).real = 1.1; INDEX(A,8,1,0).imag = -0.2; INDEX(A,8,1,1).real = -2.0; INDEX(A,8,1,1).imag = 1.0; INDEX(A,8,1,2).real = 3.2; INDEX(A,8,1,2).imag = 3.8; INDEX(A,8,1,3).real = -2.1; INDEX(A,8,1,3).imag = -1.2; INDEX(A,8,1,4).real = 1.6; INDEX(A,8,1,4).imag = 0.9; INDEX(A,8,1,5).real = -2.1; INDEX(A,8,1,5).imag = -0.1; INDEX(A,8,1,6).real = 1.3; INDEX(A,8,1,6).imag = 2.1; INDEX(A,8,1,7).real = 4.2; INDEX(A,8,1,7).imag = 0.0; INDEX(A,8,2,0).real = -1.2; INDEX(A,8,2,0).imag = 3.1; INDEX(A,8,2,1).real = 2.4; INDEX(A,8,2,1).imag = -0.1; INDEX(A,8,2,2).real = 0.3; INDEX(A,8,2,2).imag = -1.0; INDEX(A,8,2,3).real = 3.6; INDEX(A,8,2,3).imag = -0.2; INDEX(A,8,2,4).real = 1.0; INDEX(A,8,2,4).imag = 0.0; INDEX(A,8,2,5).real = 0.1; INDEX(A,8,2,5).imag = -3.2; INDEX(A,8,2,6).real = 0.0; INDEX(A,8,2,6).imag = 0.0; INDEX(A,8,2,7).real = 0.4; INDEX(A,8,2,7).imag = -2.3; INDEX(A,8,3,0).real = 1.1; INDEX(A,8,3,0).imag = -0.2; INDEX(A,8,3,1).real = -2.0; INDEX(A,8,3,1).imag = 1.0; INDEX(A,8,3,2).real = 3.2; INDEX(A,8,3,2).imag = 3.8; INDEX(A,8,3,3).real = -2.1; INDEX(A,8,3,3).imag = -1.2; INDEX(A,8,3,4).real = 1.6; INDEX(A,8,3,4).imag = 0.9; INDEX(A,8,3,5).real = -2.1; INDEX(A,8,3,5).imag = -0.1; INDEX(A,8,3,6).real = 1.3; INDEX(A,8,3,6).imag = 2.1; INDEX(A,8,3,7).real = 4.2; INDEX(A,8,3,7).imag = 0.0; INDEX(A,8,4,0).real = 1.2; INDEX(A,8,4,0).imag = 3.1; INDEX(A,8,4,1).real = 0.4; INDEX(A,8,4,1).imag = -0.1; INDEX(A,8,4,2).real = 0.3; INDEX(A,8,4,2).imag = -1.0; INDEX(A,8,4,3).real = 3.6; INDEX(A,8,4,3).imag = -0.2; INDEX(A,8,4,4).real = 0.0; INDEX(A,8,4,4).imag = 0.0; INDEX(A,8,4,5).real = 3.1; INDEX(A,8,4,5).imag = -3.2; INDEX(A,8,4,6).real = 2.3; INDEX(A,8,4,6).imag = 1.6; INDEX(A,8,4,7).real = 0.4; INDEX(A,8,4,7).imag = -2.3; INDEX(A,8,5,0).real = 2.1; INDEX(A,8,5,0).imag = -0.2; INDEX(A,8,5,1).real = -2.0; INDEX(A,8,5,1).imag = 1.0; INDEX(A,8,5,2).real = 3.2; INDEX(A,8,5,2).imag = -3.8; INDEX(A,8,5,3).real = 2.1; INDEX(A,8,5,3).imag = -1.2; INDEX(A,8,5,4).real = 1.6; INDEX(A,8,5,4).imag = 0.9; INDEX(A,8,5,5).real = 0.0; INDEX(A,8,5,5).imag = 0.0; INDEX(A,8,5,6).real = 1.3; INDEX(A,8,5,6).imag = 2.1; INDEX(A,8,5,7).real = -4.2; INDEX(A,8,5,7).imag = 0.0; INDEX(A,8,6,0).real = -1.2; INDEX(A,8,6,0).imag = 3.1; INDEX(A,8,6,1).real = -2.4; INDEX(A,8,6,1).imag = -0.1; INDEX(A,8,6,2).real = 0.3; INDEX(A,8,6,2).imag = -1.6; INDEX(A,8,6,3).real = 0.0; INDEX(A,8,6,3).imag = 0.0; INDEX(A,8,6,4).real = 1.0; INDEX(A,8,6,4).imag = 0.7; INDEX(A,8,6,5).real = 0.1; INDEX(A,8,6,5).imag = -3.2; INDEX(A,8,6,6).real = 2.3; INDEX(A,8,6,6).imag = -1.6; INDEX(A,8,6,7).real = -0.4; INDEX(A,8,6,7).imag = 2.3; INDEX(A,8,7,0).real = 1.1; INDEX(A,8,7,0).imag = 0.2; INDEX(A,8,7,1).real = 0.0; INDEX(A,8,7,1).imag = 0.0; INDEX(A,8,7,2).real = -3.2; INDEX(A,8,7,2).imag = -3.8; INDEX(A,8,7,3).real = -2.1; INDEX(A,8,7,3).imag = -1.2; INDEX(A,8,7,4).real = 1.6; INDEX(A,8,7,4).imag = 2.9; INDEX(A,8,7,5).real = -2.1; INDEX(A,8,7,5).imag = -0.1; INDEX(A,8,7,6).real = 1.3; INDEX(A,8,7,6).imag = 0.1; INDEX(A,8,7,7).real = 4.2; INDEX(A,8,7,7).imag = 0.0; } gettimeofday(&tvEnd, NULL);//linux wall time // diff timeval_subtract(&tvDiff, &tvEnd, &tvBegin); printf("eigenvalues:\n"); for(i = 0; i < N; i++) { printf("%1.4f + %1.4fi\n", eigenValues[i].real, eigenValues[i].imag); } printf("eigenvectors:\n"); printMat(V,N); printf("max norm for Av-lv: %f\n",eigenTest(A,V,eigenValues,N)); //return elapsedTime; return tvDiff.tv_sec*1000 + tvDiff.tv_usec/1000; }
ExynosCameraFrame *ExynosCameraFrameFactory::createNewFrame(void) { int ret = 0; ExynosCameraFrameEntity *newEntity[MAX_NUM_PIPES] = {}; ExynosCameraFrame *frame = new ExynosCameraFrame(m_parameters, m_frameCount); int requestEntityCount = 0; setRequestSCP(true); ret = m_initFrameMetadata(frame); if (ret < 0) ALOGE("(%s[%d]): frame(%d) metadata initialize fail", __FUNCTION__, __LINE__, m_frameCount); /* set FLITE pipe to linkageList */ newEntity[INDEX(PIPE_FLITE)] = new ExynosCameraFrameEntity(PIPE_FLITE, ENTITY_TYPE_OUTPUT_ONLY, ENTITY_BUFFER_FIXED); frame->addSiblingEntity(NULL, newEntity[INDEX(PIPE_FLITE)]); requestEntityCount++; /* set ISP pipe to linkageList */ newEntity[INDEX(PIPE_ISP)] = new ExynosCameraFrameEntity(PIPE_ISP, ENTITY_TYPE_INPUT_ONLY, ENTITY_BUFFER_FIXED); frame->addChildEntity(newEntity[INDEX(PIPE_FLITE)], newEntity[INDEX(PIPE_ISP)]); /* set SCC pipe to linkageList */ newEntity[INDEX(PIPE_SCC)] = new ExynosCameraFrameEntity(PIPE_SCC, ENTITY_TYPE_OUTPUT_ONLY, ENTITY_BUFFER_DELIVERY); frame->addSiblingEntity(NULL, newEntity[INDEX(PIPE_SCC)]); requestEntityCount++; /* set SCP pipe to linkageList */ newEntity[INDEX(PIPE_SCP)] = new ExynosCameraFrameEntity(PIPE_SCP, ENTITY_TYPE_OUTPUT_ONLY, ENTITY_BUFFER_FIXED); frame->addSiblingEntity(NULL, newEntity[INDEX(PIPE_SCP)]); requestEntityCount++; /* set GSC pipe to linkageList */ newEntity[INDEX(PIPE_GSC)] = new ExynosCameraFrameEntity(PIPE_GSC, ENTITY_TYPE_INPUT_OUTPUT, ENTITY_BUFFER_FIXED); frame->addSiblingEntity(NULL, newEntity[INDEX(PIPE_GSC)]); /* set GSC-Picture pipe to linkageList */ newEntity[INDEX(PIPE_GSC_PICTURE)] = new ExynosCameraFrameEntity(PIPE_GSC_PICTURE, ENTITY_TYPE_INPUT_OUTPUT, ENTITY_BUFFER_FIXED); frame->addSiblingEntity(NULL, newEntity[INDEX(PIPE_GSC_PICTURE)]); /* set GSC-Video pipe to linkageList */ newEntity[INDEX(PIPE_GSC_VIDEO)] = new ExynosCameraFrameEntity(PIPE_GSC_VIDEO, ENTITY_TYPE_INPUT_OUTPUT, ENTITY_BUFFER_FIXED); frame->addSiblingEntity(NULL, newEntity[INDEX(PIPE_GSC_VIDEO)]); /* set JPEG pipe to linkageList */ newEntity[INDEX(PIPE_JPEG)] = new ExynosCameraFrameEntity(PIPE_JPEG, ENTITY_TYPE_INPUT_OUTPUT, ENTITY_BUFFER_FIXED); frame->addSiblingEntity(NULL, newEntity[INDEX(PIPE_JPEG)]); ret = m_initPipelines(frame); if (ret < 0) { ALOGE("ERR(%s):m_initPipelines fail, ret(%d)", __FUNCTION__, ret); } m_fillNodeGroupInfo(frame); /* TODO: make it dynamic */ frame->setNumRequestPipe(requestEntityCount); m_frameCount++; return frame; }
void read_scroll() { THING *obj; PLACE *pp; int y, x; char ch; int i; bool discardit = FALSE; struct room *cur_room; THING *orig_obj; static coord mp; obj = get_item("read", SCROLL); if (obj == NULL) return; if (obj->o_type != SCROLL) { if (!terse) msg("there is nothing on it to read"); else msg("nothing to read"); return; } /* * Calculate the effect it has on the poor guy. */ if (obj == cur_weapon) cur_weapon = NULL; /* * Get rid of the thing */ discardit = (bool)(obj->o_count == 1); leave_pack(obj, FALSE, FALSE); orig_obj = obj; switch (obj->o_which) { case S_CONFUSE: /* * Scroll of monster confusion. Give player that power. */ player.t_flags |= CANHUH; msg("your hands begin to glow %s", pick_color("red")); when S_ARMOR: if (cur_armor != NULL) { cur_armor->o_arm--; cur_armor->o_flags &= ~ISCURSED; msg("your armor glows %s for a moment", pick_color("silver")); } when S_HOLD: /* * Hold monster scroll. Stop all monsters within two spaces * from chasing after the hero. */ ch = 0; for (x = hero.x - 2; x <= hero.x + 2; x++) if (x >= 0 && x < NUMCOLS) for (y = hero.y - 2; y <= hero.y + 2; y++) if (y >= 0 && y <= NUMLINES - 1) if ((obj = moat(y, x)) != NULL && on(*obj, ISRUN)) { obj->t_flags &= ~ISRUN; obj->t_flags |= ISHELD; ch++; } if (ch) { addmsg("the monster"); if (ch > 1) addmsg("s around you"); addmsg(" freeze"); if (ch == 1) addmsg("s"); endmsg(); scr_info[S_HOLD].oi_know = TRUE; } else msg("you feel a strange sense of loss"); when S_SLEEP: /* * Scroll which makes you fall asleep */ scr_info[S_SLEEP].oi_know = TRUE; no_command += rnd(SLEEPTIME) + 4; player.t_flags &= ~ISRUN; msg("you fall asleep"); when S_CREATE: /* * Create a monster: * First look in a circle around him, next try his room * otherwise give up */ i = 0; for (y = hero.y - 1; y <= hero.y + 1; y++) for (x = hero.x - 1; x <= hero.x + 1; x++) /* * Don't put a monster in top of the player. */ if (y == hero.y && x == hero.x) continue; /* * Or anything else nasty */ else if (step_ok(ch = winat(y, x))) { if (ch == SCROLL && find_obj(y, x)->o_which == S_SCARE) continue; else if (rnd(++i) == 0) { mp.y = y; mp.x = x; } } if (i == 0) msg("you hear a faint cry of anguish in the distance"); else { obj = new_item(); new_monster(obj, randmonster(FALSE), &mp); } when S_ID_POTION: case S_ID_SCROLL: case S_ID_WEAPON: case S_ID_ARMOR: case S_ID_R_OR_S: { static char id_type[S_ID_R_OR_S + 1] = { 0, 0, 0, 0, 0, POTION, SCROLL, WEAPON, ARMOR, R_OR_S }; /* * Identify, let him figure something out */ scr_info[obj->o_which].oi_know = TRUE; msg("this scroll is an %s scroll", scr_info[obj->o_which].oi_name); whatis(TRUE, id_type[obj->o_which]); } when S_MAP: /* * Scroll of magic mapping. */ scr_info[S_MAP].oi_know = TRUE; msg("oh, now this scroll has a map on it"); /* * take all the things we want to keep hidden out of the window */ for (y = 1; y < NUMLINES - 1; y++) for (x = 0; x < NUMCOLS; x++) { pp = INDEX(y, x); switch (ch = pp->p_ch) { case DOOR: case STAIRS: break; case '-': case '|': if (!(pp->p_flags & F_REAL)) { ch = pp->p_ch = DOOR; pp->p_flags |= F_REAL; } break; case ' ': if (pp->p_flags & F_REAL) goto def; pp->p_flags |= F_REAL; ch = pp->p_ch = PASSAGE; /* FALLTHROUGH */ case PASSAGE: pass: if (!(pp->p_flags & F_REAL)) pp->p_ch = PASSAGE; pp->p_flags |= (F_SEEN|F_REAL); ch = PASSAGE; break; case FLOOR: if (pp->p_flags & F_REAL) ch = ' '; else { ch = TRAP; pp->p_ch = TRAP; pp->p_flags |= (F_SEEN|F_REAL); } break; default: def: if (pp->p_flags & F_PASS) goto pass; ch = ' '; break; } if (ch != ' ') { if ((obj = pp->p_monst) != NULL) obj->t_oldch = ch; if (obj == NULL || !on(player, SEEMONST)) mvaddch(y, x, ch); } } when S_FDET: /* * Potion of gold detection */ ch = FALSE; wclear(hw); for (obj = lvl_obj; obj != NULL; obj = next(obj)) if (obj->o_type == FOOD) { ch = TRUE; wmove(hw, obj->o_pos.y, obj->o_pos.x); waddch(hw, FOOD); } if (ch) { scr_info[S_FDET].oi_know = TRUE; show_win("Your nose tingles and you smell food.--More--"); } else msg("your nose tingles"); when S_TELEP: /* * Scroll of teleportation: * Make player disappear and reappear */ { cur_room = proom; teleport(); if (cur_room != proom) scr_info[S_TELEP].oi_know = TRUE; } when S_ENCH: if (cur_weapon == NULL || cur_weapon->o_type != WEAPON) msg("you feel a strange sense of loss"); else { cur_weapon->o_flags &= ~ISCURSED; if (rnd(2) == 0) cur_weapon->o_hplus++; else cur_weapon->o_dplus++; msg("your %s glows %s for a moment", weap_info[cur_weapon->o_which].oi_name, pick_color("blue")); } when S_SCARE: /* * Reading it is a mistake and produces laughter at her * poor boo boo. */ msg("you hear wild laughter in the distance"); when S_REMOVE: uncurse(cur_armor); uncurse(cur_weapon); uncurse(cur_ring[LEFT]); uncurse(cur_ring[RIGHT]); msg(choose_str("you feel in touch with the Universal Onenes", "you feel as if somebody is watching over you")); when S_AGGR: /* * This scroll aggravates all the monsters on the current * level and sets them running towards the hero */ aggravate(); msg("you hear a high pitched humming noise"); when S_PROTECT: if (cur_armor != NULL) { cur_armor->o_flags |= ISPROT; msg("your armor is covered by a shimmering %s shield", pick_color("gold")); } else msg("you feel a strange sense of loss"); #ifdef MASTER otherwise: msg("what a puzzling scroll!"); return; #endif } obj = orig_obj; look(TRUE); /* put the result of the scroll on the screen */ status(); call_it(&scr_info[obj->o_which]); if (discardit) discard(obj); }
status_t ExynosCameraFrameFactory::create(void) { ALOGI("INFO(%s[%d])", __FUNCTION__, __LINE__); int ret = 0; int sensorId = getSensorId(m_cameraId); int32_t nodeNums[MAX_NODE] = {-1}; int32_t sensorIds[MAX_NODE] = {-1}; nodeNums[OUTPUT_NODE] = -1; nodeNums[CAPTURE_NODE] = MAIN_CAMERA_FLITE_NUM; nodeNums[SUB_NODE] = -1; m_pipes[INDEX(PIPE_FLITE)] = (ExynosCameraPipe*)new ExynosCameraPipeFlite(m_cameraId, m_parameters, false, nodeNums); m_pipes[INDEX(PIPE_FLITE)]->setPipeId(PIPE_FLITE); m_pipes[INDEX(PIPE_FLITE)]->setPipeName("PIPE_FLITE"); nodeNums[OUTPUT_NODE] = FIMC_IS_VIDEO_ISP_NUM; nodeNums[CAPTURE_NODE] = -1; nodeNums[SUB_NODE] = -1; m_pipes[INDEX(PIPE_ISP)] = (ExynosCameraPipe*)new ExynosCameraPipeISP(m_cameraId, m_parameters, false, nodeNums); m_pipes[INDEX(PIPE_ISP)]->setPipeId(PIPE_ISP); m_pipes[INDEX(PIPE_ISP)]->setPipeName("PIPE_ISP"); nodeNums[OUTPUT_NODE] = -1; nodeNums[CAPTURE_NODE] = FIMC_IS_VIDEO_SCC_NUM; nodeNums[SUB_NODE] = -1; m_pipes[INDEX(PIPE_SCC)] = (ExynosCameraPipe*)new ExynosCameraPipeSCC(m_cameraId, m_parameters, false, nodeNums); m_pipes[INDEX(PIPE_SCC)]->setPipeId(PIPE_SCC); m_pipes[INDEX(PIPE_SCC)]->setPipeName("PIPE_SCC"); nodeNums[OUTPUT_NODE] = -1; nodeNums[CAPTURE_NODE] = FIMC_IS_VIDEO_SCP_NUM; nodeNums[SUB_NODE] = -1; m_pipes[INDEX(PIPE_SCP)] = (ExynosCameraPipe*)new ExynosCameraPipeSCP(m_cameraId, m_parameters, false, nodeNums); m_pipes[INDEX(PIPE_SCP)]->setPipeId(PIPE_SCP); m_pipes[INDEX(PIPE_SCP)]->setPipeName("PIPE_SCP"); nodeNums[OUTPUT_NODE] = PREVIEW_GSC_NODE_NUM; nodeNums[CAPTURE_NODE] = -1; nodeNums[SUB_NODE] = -1; m_pipes[INDEX(PIPE_GSC)] = (ExynosCameraPipe*)new ExynosCameraPipeGSC(m_cameraId, m_parameters, true, nodeNums); m_pipes[INDEX(PIPE_GSC)]->setPipeId(PIPE_GSC); m_pipes[INDEX(PIPE_GSC)]->setPipeName("PIPE_GSC"); nodeNums[OUTPUT_NODE] = VIDEO_GSC_NODE_NUM; nodeNums[CAPTURE_NODE] = -1; nodeNums[SUB_NODE] = -1; m_pipes[INDEX(PIPE_GSC_VIDEO)] = (ExynosCameraPipe*)new ExynosCameraPipeGSC(m_cameraId, m_parameters, false, nodeNums); m_pipes[INDEX(PIPE_GSC_VIDEO)]->setPipeId(PIPE_GSC_VIDEO); m_pipes[INDEX(PIPE_GSC_VIDEO)]->setPipeName("PIPE_GSC_VIDEO"); nodeNums[OUTPUT_NODE] = PICTURE_GSC_NODE_NUM; nodeNums[CAPTURE_NODE] = -1; nodeNums[SUB_NODE] = -1; m_pipes[INDEX(PIPE_GSC_PICTURE)] = (ExynosCameraPipe*)new ExynosCameraPipeGSC(m_cameraId, m_parameters, true, nodeNums); m_pipes[INDEX(PIPE_GSC_PICTURE)]->setPipeId(PIPE_GSC_PICTURE); m_pipes[INDEX(PIPE_GSC_PICTURE)]->setPipeName("PIPE_GSC_PICTURE"); nodeNums[OUTPUT_NODE] = -1; nodeNums[CAPTURE_NODE] = -1; nodeNums[SUB_NODE] = -1; m_pipes[INDEX(PIPE_JPEG)] = (ExynosCameraPipe*)new ExynosCameraPipeJpeg(m_cameraId, m_parameters, true, nodeNums); m_pipes[INDEX(PIPE_JPEG)]->setPipeId(PIPE_JPEG); m_pipes[INDEX(PIPE_JPEG)]->setPipeName("PIPE_JPEG"); /* flite pipe initialize */ sensorIds[OUTPUT_NODE] = -1; sensorIds[CAPTURE_NODE] = (0 << REPROCESSING_SHIFT) | ((FIMC_IS_VIDEO_SS0_NUM - FIMC_IS_VIDEO_SS0_NUM) << SSX_VINDEX_SHIFT) | (sensorId << 0); sensorIds[SUB_NODE] = -1; ret = m_pipes[INDEX(PIPE_FLITE)]->create(sensorIds); if (ret < 0) { ALOGE("ERR(%s[%d]):FLITE create fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ALOGD("DEBUG(%s):Pipe(%d) created", __FUNCTION__, INDEX(PIPE_FLITE)); /* ISP pipe initialize */ sensorIds[OUTPUT_NODE] = (0 << REPROCESSING_SHIFT) | ((MAIN_CAMERA_FLITE_NUM - FIMC_IS_VIDEO_SS0_NUM) << SSX_VINDEX_SHIFT) | ((MAIN_CAMERA_3AA_NUM - FIMC_IS_VIDEO_SS0_NUM) << TAX_VINDEX_SHIFT) | (sensorId << 0); sensorIds[CAPTURE_NODE] = -1; sensorIds[SUB_NODE] = -1; ret = m_pipes[INDEX(PIPE_ISP)]->create(sensorIds); if (ret < 0) { ALOGE("ERR(%s[%d]):ISP create fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ALOGD("DEBUG(%s):Pipe(%d) created", __FUNCTION__, INDEX(PIPE_ISP)); /* SCC pipe initialize * TODO: preview Frame dose not need SCC * Will be removed after driver fix. */ sensorIds[OUTPUT_NODE] = -1; sensorIds[CAPTURE_NODE] = (0 << REPROCESSING_SHIFT) | ((FIMC_IS_VIDEO_SCC_NUM - FIMC_IS_VIDEO_SS0_NUM) << TAX_VINDEX_SHIFT) | (sensorId << 0); sensorIds[SUB_NODE] = -1; ret = m_pipes[INDEX(PIPE_SCC)]->create(sensorIds); if (ret < 0) { ALOGE("ERR(%s[%d]):SCC create fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ALOGD("DEBUG(%s):Pipe(%d) created", __FUNCTION__, INDEX(PIPE_SCC)); /* SCP pipe initialize */ sensorIds[OUTPUT_NODE] = -1; sensorIds[CAPTURE_NODE] = (0 << REPROCESSING_SHIFT) | ((FIMC_IS_VIDEO_SCP_NUM - FIMC_IS_VIDEO_SS0_NUM) << TAX_VINDEX_SHIFT) | (sensorId << 0); sensorIds[SUB_NODE] = -1; ret = m_pipes[INDEX(PIPE_SCP)]->create(sensorIds); if (ret < 0) { ALOGE("ERR(%s[%d]):SCP create fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ALOGD("DEBUG(%s):Pipe(%d) created", __FUNCTION__, INDEX(PIPE_SCP)); /* GSC pipe initialize */ ret = m_pipes[INDEX(PIPE_GSC)]->create(NULL); if (ret < 0) { ALOGE("ERR(%s[%d]):GSC create fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ALOGD("DEBUG(%s):Pipe(%d) created", __FUNCTION__, INDEX(PIPE_GSC)); /* GSC pipe initialize */ ret = m_pipes[INDEX(PIPE_GSC_VIDEO)]->create(NULL); if (ret < 0) { ALOGE("ERR(%s[%d]):GSC create fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ALOGD("DEBUG(%s):Pipe(%d) created", __FUNCTION__, INDEX(PIPE_GSC_VIDEO)); /* GSC pipe initialize */ ret = m_pipes[INDEX(PIPE_GSC_PICTURE)]->create(NULL); if (ret < 0) { ALOGE("ERR(%s[%d]):GSC create fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ALOGD("DEBUG(%s):Pipe(%d) created", __FUNCTION__, INDEX(PIPE_GSC_PICTURE)); /* JPEG pipe initialize */ ret = m_pipes[INDEX(PIPE_JPEG)]->create(NULL); if (ret < 0) { ALOGE("ERR(%s[%d]):JPEG create fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ALOGD("DEBUG(%s):Pipe(%d) created", __FUNCTION__, INDEX(PIPE_JPEG)); return NO_ERROR; }
void LoopUnroller::unroll(otawa::CFG *cfg, BasicBlock *header, VirtualCFG *vcfg) { VectorQueue<BasicBlock*> workList; VectorQueue<BasicBlock*> loopList; VectorQueue<BasicBlock*> virtualCallList; genstruct::Vector<BasicBlock*> doneList; typedef genstruct::Vector<Pair<VirtualBasicBlock*, Edge::kind_t> > BackEdgePairVector; BackEdgePairVector backEdges; bool dont_unroll = false; BasicBlock *unrolled_from; int start; /* Avoid unrolling loops with LOOP_COUNT of 0, since it would create a LOOP_COUNT of -1 for the non-unrolled part of the loop*/ /* if (header && (ipet::LOOP_COUNT(header) == 0)) { dont_unroll = true; } */ //if (header) dont_unroll = true; start = dont_unroll ? 1 : 0; for (int i = start; ((i < 2) && header) || (i < 1); i++) { doneList.clear(); ASSERT(workList.isEmpty()); ASSERT(loopList.isEmpty()); ASSERT(doneList.isEmpty()); workList.put(header ? header : cfg->entry()); doneList.add(header ? header : cfg->entry()); genstruct::Vector<BasicBlock*> bbs; while (!workList.isEmpty()) { BasicBlock *current = workList.get(); if (LOOP_HEADER(current) && (current != header)) { /* we enter another loop */ loopList.put(current); /* add exit edges destinations to the worklist */ for (genstruct::Vector<Edge*>::Iterator exitedge(**EXIT_LIST(current)); exitedge; exitedge++) { if (!doneList.contains(exitedge->target())) { workList.put(exitedge->target()); doneList.add(exitedge->target()); } } } else { VirtualBasicBlock *new_bb = 0; if ((!current->isEntry()) && (!current->isExit())) { /* Duplicate the current basic block */ new_bb = new VirtualBasicBlock(current); new_bb->removeAllProp(&ENCLOSING_LOOP_HEADER); new_bb->removeAllProp(&EXIT_LIST); new_bb->removeAllProp(&REVERSE_DOM); new_bb->removeAllProp(&LOOP_EXIT_EDGE); new_bb->removeAllProp(&LOOP_HEADER); new_bb->removeAllProp(&ENTRY); /* Remember the call block so we can correct its destination when we have processed it */ if (VIRTUAL_RETURN_BLOCK(new_bb)) virtualCallList.put(new_bb); if ((current == header) && (!dont_unroll)) { if (i == 0) { unrolled_from = new_bb; } else { UNROLLED_FROM(new_bb) = unrolled_from; } } /* if (ipet::LOOP_COUNT(new_bb) != -1) { if (i == 0) { new_bb->removeAllProp(&ipet::LOOP_COUNT); } else { int old_count = ipet::LOOP_COUNT(new_bb); new_bb->removeAllProp(&ipet::LOOP_COUNT); ipet::LOOP_COUNT(new_bb) = old_count - (1 - start); ASSERT(ipet::LOOP_COUNT(new_bb) >= 0); } } */ INDEX(new_bb) = idx; idx++; vcfg->addBB(new_bb); bbs.add(current); map.put(current, new_bb); } /* add successors which are in loop (including possible sub-loop headers) */ for (BasicBlock::OutIterator outedge(current); outedge; outedge++) { if (outedge->target() == cfg->exit()) continue; if (outedge->kind() == Edge::CALL) continue; if (ENCLOSING_LOOP_HEADER(outedge->target()) == header) { // cout << "Test for add: " << outedge->target()->number() << "\n"; if (!doneList.contains(outedge->target())) { workList.put(outedge->target()); doneList.add(outedge->target()); } } if (LOOP_EXIT_EDGE(outedge)) { ASSERT(new_bb); /* Connect exit edge */ VirtualBasicBlock *vdst = map.get(outedge->target()); new Edge(new_bb, vdst, outedge->kind()); } } } } while (!virtualCallList.isEmpty()) { BasicBlock *vcall = virtualCallList.get(); BasicBlock *vreturn = map.get(VIRTUAL_RETURN_BLOCK(vcall), 0); ASSERT(vreturn != 0); VIRTUAL_RETURN_BLOCK(vcall) = vreturn; } while (!loopList.isEmpty()) { BasicBlock *loop = loopList.get(); unroll(cfg, loop, vcfg); } /* Connect the internal edges for the current loop */ for (genstruct::Vector<BasicBlock*>::Iterator bb(bbs); bb; bb++) { for (BasicBlock::OutIterator outedge(bb); outedge; outedge++) { if (LOOP_EXIT_EDGE(outedge)) continue; if (LOOP_HEADER(outedge->target()) && (outedge->target() != header)) continue; if (outedge->target() == cfg->exit()) continue; VirtualBasicBlock *vsrc = map.get(*bb, 0); VirtualBasicBlock *vdst = map.get(outedge->target(), 0); if (outedge->kind() == Edge::CALL) { CFG *called_cfg = outedge->calledCFG(); int called_idx = INDEX(called_cfg); CFG *called_vcfg = coll->get(called_idx); Edge *vedge = new Edge(vsrc, called_vcfg->entry(), Edge::CALL); CALLED_BY(called_vcfg).add(vedge); ENTRY(called_vcfg->entry()) = called_vcfg; CALLED_CFG(outedge) = called_vcfg; /* XXX: ??!? */ } else if ((outedge->target() != header) || ((i == 1) /* XXX && !dont_unroll XXX*/ )) { new Edge(vsrc, vdst, outedge->kind()); } else { backEdges.add(pair(vsrc, outedge->kind())); } } } if (i == start) { /* Connect virtual entry edges */ if (header) { for (BasicBlock::InIterator inedge(header); inedge; inedge++) { if (Dominance::dominates(header, inedge->source())) continue; /* skip back edges */ if (inedge->source() == cfg->entry()) continue; VirtualBasicBlock *vsrc = map.get(inedge->source()); VirtualBasicBlock *vdst = map.get(header); new Edge(vsrc, vdst, inedge->kind()); } } } else { /* Connect virtual backedges from the first to the other iterations */ for (BackEdgePairVector::Iterator iter(backEdges); iter; iter++) { VirtualBasicBlock *vdst = map.get(header); new Edge((*iter).fst, vdst, (*iter).snd); } } } if (!header) { /* add main entry edges */ for (BasicBlock::OutIterator outedge(cfg->entry()); outedge; outedge++) { VirtualBasicBlock *vdst = map.get(outedge->target()); new Edge(vcfg->entry(), vdst, Edge::VIRTUAL_CALL); } /* add main exit edges */ for (BasicBlock::InIterator inedge(cfg->exit()); inedge; inedge++) { VirtualBasicBlock *vsrc = map.get(inedge->source()); new Edge(vsrc, vcfg->exit(), Edge::VIRTUAL_RETURN); } } }
Stores OBJECT in the extra info entry of the Heathen Code Block\n\ Profile Buffer.\n\ \n\ This is for mondo bizarro sampler frobnication purposes only.\n\ \n\ Only officially designated moby wizards should even think of thinking of\n\ using this most ultra super duper secret primitive. FNORD!\ "); /*-------------------------------------------------------------------------*/ declare_primitive ("%PC-SAMPLE/SET-ZONE!", Prim_pc_sample_set_current_zone, 1, 1, "(index)\n\ Set current pc-sampling zone to INDEX (a small exact integer), returning \ the previous value if different, else #F if same."); declare_primitive ("%PC-SAMPLE/MAX-ZONE", Prim_pc_sample_get_max_zone, 0, 0, 0); declare_primitive ("%PC-SAMPLE/CLEAR-ZONES!", Prim_pc_sample_clear_zones, 0, 0, "()\nZero zone counts."); declare_primitive ("%PC-SAMPLE/READ-ZONES!", Prim_pc_sample_read_zones, 1, 1, "(flonum-vector)\n\ Copy zone counts into FLONUM-VECTOR. Returns the number copied, which \ is limited by either the number of zones to the capacity of FLONUM-VECTOR."); }
static void cvm_oct_rgmii_poll(struct net_device *dev) { struct octeon_ethernet *priv = netdev_priv(dev); unsigned long flags; cvmx_helper_link_info_t link_info; spin_lock_irqsave(&global_register_lock, flags); link_info = cvmx_helper_link_get(priv->port); if (link_info.u64 == priv->link_info) { if (USE_10MBPS_PREAMBLE_WORKAROUND && (link_info.s.speed == 10)) { int interface = INTERFACE(priv->port); int index = INDEX(priv->port); union cvmx_gmxx_rxx_int_reg gmxx_rxx_int_reg; gmxx_rxx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG (index, interface)); if (gmxx_rxx_int_reg.s.pcterr) { union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl; union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs; gmxx_rxx_frm_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL (index, interface)); gmxx_rxx_frm_ctl.s.pre_chk = 0; cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL (index, interface), gmxx_rxx_frm_ctl.u64); ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); ipd_sub_port_fcs.s.port_bit &= 0xffffffffull ^ (1ull << priv->port); cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64); cvmx_write_csr(CVMX_GMXX_RXX_INT_REG (index, interface), gmxx_rxx_int_reg.u64); DEBUGPRINT("%s: Using 10Mbps with software " "preamble removal\n", dev->name); } } spin_unlock_irqrestore(&global_register_lock, flags); return; } if (USE_10MBPS_PREAMBLE_WORKAROUND) { union cvmx_gmxx_rxx_frm_ctl gmxx_rxx_frm_ctl; union cvmx_ipd_sub_port_fcs ipd_sub_port_fcs; union cvmx_gmxx_rxx_int_reg gmxx_rxx_int_reg; int interface = INTERFACE(priv->port); int index = INDEX(priv->port); gmxx_rxx_frm_ctl.u64 = cvmx_read_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface)); gmxx_rxx_frm_ctl.s.pre_chk = 1; cvmx_write_csr(CVMX_GMXX_RXX_FRM_CTL(index, interface), gmxx_rxx_frm_ctl.u64); ipd_sub_port_fcs.u64 = cvmx_read_csr(CVMX_IPD_SUB_PORT_FCS); ipd_sub_port_fcs.s.port_bit |= 1ull << priv->port; cvmx_write_csr(CVMX_IPD_SUB_PORT_FCS, ipd_sub_port_fcs.u64); gmxx_rxx_int_reg.u64 = cvmx_read_csr(CVMX_GMXX_RXX_INT_REG(index, interface)); cvmx_write_csr(CVMX_GMXX_RXX_INT_REG(index, interface), gmxx_rxx_int_reg.u64); } link_info = cvmx_helper_link_autoconf(priv->port); priv->link_info = link_info.u64; spin_unlock_irqrestore(&global_register_lock, flags); if (link_info.s.link_up) { if (!netif_carrier_ok(dev)) netif_carrier_on(dev); if (priv->queue != -1) DEBUGPRINT ("%s: %u Mbps %s duplex, port %2d, queue %2d\n", dev->name, link_info.s.speed, (link_info.s.full_duplex) ? "Full" : "Half", priv->port, priv->queue); else DEBUGPRINT("%s: %u Mbps %s duplex, port %2d, POW\n", dev->name, link_info.s.speed, (link_info.s.full_duplex) ? "Full" : "Half", priv->port); } else { if (netif_carrier_ok(dev)) netif_carrier_off(dev); DEBUGPRINT("%s: Link down\n", dev->name); } }
inline T& matrix<T>::operator() (int i, int j) { assert(i >= 0 && i < m_rows && j >= 0 && j < m_cols); return p[INDEX(i,j)]; }
status_t ExynosCameraFrameFactoryFront::initPipes(void) { ALOGI("INFO(%s[%d])", __FUNCTION__, __LINE__); int ret = 0; camera_pipe_info_t pipeInfo[3]; ExynosRect tempRect; int maxSensorW = 0, maxSensorH = 0, hwSensorW = 0, hwSensorH = 0; int maxPreviewW = 0, maxPreviewH = 0, hwPreviewW = 0, hwPreviewH = 0; int maxPictureW = 0, maxPictureH = 0, hwPictureW = 0, hwPictureH = 0; int bayerFormat = V4L2_PIX_FMT_SBGGR12; int previewFormat = m_parameters->getHwPreviewFormat(); int pictureFormat = m_parameters->getPictureFormat(); m_parameters->getMaxSensorSize(&maxSensorW, &maxSensorH); m_parameters->getHwSensorSize(&hwSensorW, &hwSensorH); m_parameters->getMaxPreviewSize(&maxPreviewW, &maxPreviewH); m_parameters->getHwPreviewSize(&hwPreviewW, &hwPreviewH); m_parameters->getMaxPictureSize(&maxPictureW, &maxPictureH); m_parameters->getHwPictureSize(&hwPictureW, &hwPictureH); ALOGI("INFO(%s[%d]): MaxSensorSize(%dx%d), HwSensorSize(%dx%d)", __FUNCTION__, __LINE__, maxSensorW, maxSensorH, hwSensorW, hwSensorH); ALOGI("INFO(%s[%d]): MaxPreviewSize(%dx%d), HwPreviewSize(%dx%d)", __FUNCTION__, __LINE__, maxPreviewW, maxPreviewH, hwPreviewW, hwPreviewH); ALOGI("INFO(%s[%d]): MaxPixtureSize(%dx%d), HwPixtureSize(%dx%d)", __FUNCTION__, __LINE__, maxPictureW, maxPictureH, hwPictureW, hwPictureH); memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* FLITE pipe */ tempRect.fullW = maxSensorW + 16; tempRect.fullH = maxSensorH + 10; tempRect.colorFormat = bayerFormat; pipeInfo[0].rectInfo = tempRect; pipeInfo[0].bufInfo.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; pipeInfo[0].bufInfo.memory = V4L2_CAMERA_MEMORY_TYPE; pipeInfo[0].bufInfo.count = FRONT_NUM_BAYER_BUFFERS; /* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 0; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_NONE; #ifdef CAMERA_PACKED_BAYER_ENABLE /* packed bayer bytesPerPlane */ pipeInfo[0].bytesPerPlane[0] = ROUND_UP(pipeInfo[0].rectInfo.fullW, 10) * 8 / 5; #endif ret = m_pipes[INDEX(PIPE_FLITE_FRONT)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]):FLITE setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* ISP pipe */ tempRect.fullW = maxSensorW + 16; tempRect.fullH = maxSensorH + 10; tempRect.colorFormat = bayerFormat; pipeInfo[0].rectInfo = tempRect; pipeInfo[0].bufInfo.type = V4L2_BUF_TYPE_VIDEO_OUTPUT_MPLANE; pipeInfo[0].bufInfo.memory = V4L2_CAMERA_MEMORY_TYPE; pipeInfo[0].bufInfo.count = FRONT_NUM_BAYER_BUFFERS; /* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 3; /* ISP, SCP */ pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_LEADER; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perframeInfoIndex = PERFRAME_INFO_ISP; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameVideoID = (FIMC_IS_VIDEO_ISP_NUM - FIMC_IS_VIDEO_SS0_NUM); pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[0].perFrameNodeType = PERFRAME_NODE_TYPE_CAPTURE; pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[0].perFrameVideoID = (FIMC_IS_VIDEO_SCC_NUM - FIMC_IS_VIDEO_SS0_NUM); pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[1].perFrameNodeType = PERFRAME_NODE_TYPE_CAPTURE; pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[1].perFrameVideoID = (FIMC_IS_VIDEO_SCP_NUM - FIMC_IS_VIDEO_SS0_NUM); #ifdef CAMERA_PACKED_BAYER_ENABLE /* packed bayer bytesPerPlane */ pipeInfo[0].bytesPerPlane[0] = ROUND_UP(pipeInfo[0].rectInfo.fullW, 10) * 8 / 5; #endif ret = m_pipes[INDEX(PIPE_ISP_FRONT)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]):ISP setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* SCC output pipe */ tempRect.fullW = hwPictureW; tempRect.fullH = hwPictureH; tempRect.colorFormat = pictureFormat; pipeInfo[0].rectInfo = tempRect; pipeInfo[0].bufInfo.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; pipeInfo[0].bufInfo.memory = V4L2_CAMERA_MEMORY_TYPE; pipeInfo[0].bufInfo.count = FRONT_NUM_PICTURE_BUFFERS; /* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 0; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_NONE; ret = m_pipes[INDEX(PIPE_SCC_FRONT)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]):SCC setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* SCP pipe */ hwPreviewW = m_parameters->getHwPreviewStride(); ALOGV("INFO(%s[%d]):stride=%d", __FUNCTION__, __LINE__, hwPreviewW); tempRect.fullW = hwPreviewW; tempRect.fullH = hwPreviewH; tempRect.colorFormat = previewFormat; pipeInfo[0].rectInfo = tempRect; pipeInfo[0].bufInfo.type = V4L2_BUF_TYPE_VIDEO_CAPTURE_MPLANE; pipeInfo[0].bufInfo.memory = V4L2_CAMERA_MEMORY_TYPE; pipeInfo[0].bufInfo.count = NUM_PREVIEW_BUFFERS; /* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 0; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_NONE; ret = m_pipes[INDEX(PIPE_SCP_FRONT)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]):SCP setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } m_frameCount = 0; return NO_ERROR; }
/* * Add an update to the log. The update's kdb_entry_sno and kdb_time fields * must already be set. The layout of the update log looks like: * * header log -> [ update header -> xdr(kdb_incr_update_t) ], ... */ static krb5_error_code store_update(kdb_log_context *log_ctx, kdb_incr_update_t *upd) { XDR xdrs; kdb_ent_header_t *indx_log; unsigned int i, recsize; unsigned long upd_size; krb5_error_code retval; kdb_hlog_t *ulog = log_ctx->ulog; uint32_t ulogentries = log_ctx->ulogentries; upd_size = xdr_sizeof((xdrproc_t)xdr_kdb_incr_update_t, upd); recsize = sizeof(kdb_ent_header_t) + upd_size; if (recsize > ulog->kdb_block) { retval = resize(ulog, ulogentries, log_ctx->ulogfd, recsize); if (retval) return retval; } ulog->kdb_state = KDB_UNSTABLE; i = (upd->kdb_entry_sno - 1) % ulogentries; indx_log = INDEX(ulog, i); memset(indx_log, 0, ulog->kdb_block); indx_log->kdb_umagic = KDB_ULOG_MAGIC; indx_log->kdb_entry_size = upd_size; indx_log->kdb_entry_sno = upd->kdb_entry_sno; indx_log->kdb_time = upd->kdb_time; indx_log->kdb_commit = FALSE; xdrmem_create(&xdrs, (char *)indx_log->entry_data, indx_log->kdb_entry_size, XDR_ENCODE); if (!xdr_kdb_incr_update_t(&xdrs, upd)) return KRB5_LOG_CONV; indx_log->kdb_commit = TRUE; retval = sync_update(ulog, indx_log); if (retval) return retval; /* Modify the ulog header to reflect the new update. */ ulog->kdb_last_sno = upd->kdb_entry_sno; ulog->kdb_last_time = upd->kdb_time; if (ulog->kdb_num == 0) { ulog->kdb_num = 1; ulog->kdb_first_sno = upd->kdb_entry_sno; ulog->kdb_first_time = upd->kdb_time; } else if (ulog->kdb_num < ulogentries) { ulog->kdb_num++; } else { /* We are circling; set kdb_first_sno and time to the next update. */ i = upd->kdb_entry_sno % ulogentries; indx_log = INDEX(ulog, i); ulog->kdb_first_sno = indx_log->kdb_entry_sno; ulog->kdb_first_time = indx_log->kdb_time; } ulog->kdb_state = KDB_STABLE; sync_header(ulog); return 0; }
status_t ExynosCameraFrameFactoryFront::stopPipes(void) { int ret = 0; ret = m_pipes[INDEX(PIPE_SCC_FRONT)]->stopThread(); if (ret < 0) { ALOGE("ERR(%s[%d]):SCC stopThread fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ret = m_pipes[INDEX(PIPE_SCP_FRONT)]->stopThread(); if (ret < 0) { ALOGE("ERR(%s[%d]):SCP stopThread fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } /* stream off for ISP */ ret = m_pipes[INDEX(PIPE_ISP_FRONT)]->stopThread(); if (ret < 0) { ALOGE("ERR(%s[%d]):ISP stopThread fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ret = m_pipes[INDEX(PIPE_FLITE_FRONT)]->sensorStream(false); if (ret < 0) { ALOGE("ERR(%s[%d]):FLITE sensorStream fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ret = m_pipes[INDEX(PIPE_ISP_FRONT)]->setControl(V4L2_CID_IS_FORCE_DONE, 0x1000); if (ret < 0) { ALOGE("ERR(%s[%d]):ISP setControl fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ret = m_pipes[INDEX(PIPE_FLITE_FRONT)]->stop(); if (ret < 0) { ALOGE("ERR(%s[%d]):FLITE stop fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } /* stream off for ISP */ ret = m_pipes[INDEX(PIPE_ISP_FRONT)]->stop(); if (ret < 0) { ALOGE("ERR(%s[%d]):ISP stop fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ret = m_pipes[INDEX(PIPE_SCC_FRONT)]->stop(); if (ret < 0) { ALOGE("ERR(%s[%d]):SCC stop fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ret = m_pipes[INDEX(PIPE_SCP_FRONT)]->stop(); if (ret < 0) { ALOGE("ERR(%s[%d]):SCP stop fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } ALOGI("INFO(%s[%d]):Stopping Front [FLITE>3AA>ISP>SCC>SCP] Success!", __FUNCTION__, __LINE__); return NO_ERROR; }
/* ------------------------------------------------------------- The gateway routine. ------------------------------------------------------------- */ void mexFunction( int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[] ) { int exitflag; /* status of the solution (output arg) */ long t; /* number of iterations (output arg) */ double *x; /* solution vector (output arg)*/ double *History; /* UB and LB history (output arg) */ int verb; /* verbosity (input arg)*/ long tmax; /* max number of iteration (input arg)*/ double tolrel; /* stopping condition (input arg) */ double tolabs; /* stopping condition (input arg) */ double *x0; /* initial solution (input arg)*/ double *f; /* vector f (input arg) */ double b; /* scalar b (input arg) */ uint16_T *I; /* vector of uint16_T (input arg) */ double *diag_H; /* diagonal of matrix H */ long i ; /* loop variable */ double *tmp_ptr; /*------------------------------------------------------------------- */ /* Take input arguments */ /* [...] = qpssvm_mex(H,f,b,I,x0,tmax,tolabs,tolrel,verb) */ /*------------------------------------------------------------------- */ if( nrhs != 9) mexErrMsgTxt("Incorrect number of input arguments."); /* matrix H */ matrix_H = mxGetPr(prhs[0]); dim = mxGetM(prhs[0]); if(dim != mxGetN(prhs[0])) mexErrMsgTxt("Matrix H mast be squared."); /* vector f */ f = mxGetPr(prhs[1]); if((MAX(mxGetM(prhs[1]),mxGetN(prhs[1])) != dim) || (MIN(mxGetM(prhs[1]),mxGetN(prhs[1])) != 1)) mexErrMsgTxt("Vector f is of wrong size."); /* vector b */ b = mxGetScalar(prhs[2]); /* vector I */ I = (uint16_T*)mxGetPr(prhs[3]); if((MAX(mxGetM(prhs[3]),mxGetN(prhs[3])) != dim) || (MIN(mxGetM(prhs[3]),mxGetN(prhs[3])) != 1)) mexErrMsgTxt("Vector I is of wrong size."); /* vector x0 */ x0 = mxGetPr(prhs[4]); if((MAX(mxGetM(prhs[4]),mxGetN(prhs[4])) != dim) || (MIN(mxGetM(prhs[4]),mxGetN(prhs[4])) != 1)) mexErrMsgTxt("Vector x0 is of wrong size."); /* maximal allowed number of iterations */ tmax = mxIsInf( mxGetScalar(prhs[5])) ? INT_MAX : (long)mxGetScalar(prhs[5]); /* abs. precision defining stopping cond*/ tolabs = mxGetScalar(prhs[6]); /* rel. precision defining stopping cond*/ tolrel = mxGetScalar(prhs[7]); /* verbosity parameter */ verb = (int)mxGetScalar(prhs[8]); /* verbosity on/off */ /* print input setting if required */ if( verb > 0 ) { mexPrintf("Settings of QP solver:\n"); mexPrintf("tmax : %d\n", tmax ); mexPrintf("tolabs : %f\n", tolabs ); mexPrintf("tolrel : %f\n", tolrel ); mexPrintf("dim : %d\n", dim ); mexPrintf("b : %f\n", b ); mexPrintf("verb : %d\n", verb ); } /*------------------------------------------------------------------- Inicialization ------------------------------------------------------------------- */ /* solution vector x [dim x 1] */ plhs[0] = mxCreateDoubleMatrix(dim,1,mxREAL); x = mxGetPr(plhs[0]); for(i=0; i < dim; i++ ) { x[i] = x0[i]; } /* make diagonal of the Hessian matrix */ diag_H = mxCalloc(dim, sizeof(double)); if( diag_H == NULL ) mexErrMsgTxt("Not enough memory."); /* to replace with memcpy(void *dest, const void *src, size_t n); */ for(i = 0; i < dim; i++ ) { diag_H[i] = matrix_H[dim*i+i]; } /* counter of access to matrix H */ access = dim; /*------------------------------------------------------------------- Call the QP solver. -------------------------------------------------------------------*/ /* exitflag = qpssvm_solver( &get_col, diag_H, f, b, I, x, dim, tmax, tolabs, tolrel, &t, &History, verb ); */ exitflag = qpssvm_imdm( &get_col, diag_H, f, b, I, x, dim, tmax, tolabs, tolrel, &t, &History, verb ); /*------------------------------------------------------------------- Set up output arguments [x,exitflag,t,access,History] = qpssvm_mex(...) ------------------------------------------------------------------- */ /* exitflag [1x1] */ plhs[1] = mxCreateDoubleMatrix(1,1,mxREAL); *(mxGetPr(plhs[1])) = (double)exitflag; /* t [1x1] */ plhs[2] = mxCreateDoubleMatrix(1,1,mxREAL); *(mxGetPr(plhs[2])) = (double)t; /* access [1x1] */ plhs[3] = mxCreateDoubleMatrix(1,1,mxREAL); *(mxGetPr(plhs[3])) = (double)access; /* History [2 x (t+1)] */ plhs[4] = mxCreateDoubleMatrix(2,t+1,mxREAL); tmp_ptr = mxGetPr( plhs[4] ); for( i = 0; i <= t; i++ ) { tmp_ptr[INDEX(0,i,2)] = History[INDEX(0,i,2)]; tmp_ptr[INDEX(1,i,2)] = History[INDEX(1,i,2)]; } /*------------------------------------------------------------------- Free used memory ------------------------------------------------------------------- */ mxFree( History ); mxFree( diag_H ); return; }
/* per frame info */ pipeInfo[0].perFrameNodeGroupInfo.perframeSupportNodeNum = 3; /* ISP, SCP */ pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameNodeType = PERFRAME_NODE_TYPE_LEADER; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perframeInfoIndex = PERFRAME_INFO_ISP; pipeInfo[0].perFrameNodeGroupInfo.perFrameLeaderInfo.perFrameVideoID = (FIMC_IS_VIDEO_ISP_NUM - FIMC_IS_VIDEO_SS0_NUM); pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[0].perFrameNodeType = PERFRAME_NODE_TYPE_CAPTURE; pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[0].perFrameVideoID = (FIMC_IS_VIDEO_SCC_NUM - FIMC_IS_VIDEO_SS0_NUM); pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[1].perFrameNodeType = PERFRAME_NODE_TYPE_CAPTURE; pipeInfo[0].perFrameNodeGroupInfo.perFrameCaptureInfo[1].perFrameVideoID = (FIMC_IS_VIDEO_SCP_NUM - FIMC_IS_VIDEO_SS0_NUM); #ifdef CAMERA_PACKED_BAYER_ENABLE /* packed bayer bytesPerPlane */ pipeInfo[0].bytesPerPlane[0] = ROUND_UP(pipeInfo[0].rectInfo.fullW, 10) * 8 / 5; #endif ret = m_pipes[INDEX(PIPE_ISP)]->setupPipe(pipeInfo); if (ret < 0) { ALOGE("ERR(%s[%d]): ISP setupPipe fail, ret(%d)", __FUNCTION__, __LINE__, ret); /* TODO: exception handling */ return INVALID_OPERATION; } memset(pipeInfo, 0, (sizeof(camera_pipe_info_t) * 3)); /* SCC output pipe */ #ifdef FIXED_SENSOR_SIZE tempRect.fullW = maxSensorW; tempRect.fullH = maxSensorH; #else tempRect.fullW = hwSensorW; tempRect.fullH = hwSensorH;
static float GetNoiseValue( int x, int y, int z, int t ) { int index = INDEX( ( int ) x, ( int ) y, ( int ) z, ( int ) t ); return s_noise_table[index]; }
/* Get the last set of updates seen, (last+1) to n is returned. */ krb5_error_code ulog_get_entries(krb5_context context, kdb_last_t last, kdb_incr_result_t *ulog_handle) { XDR xdrs; kdb_ent_header_t *indx_log; kdb_incr_update_t *upd; unsigned int indx, count; uint32_t sno; krb5_error_code retval; kdb_log_context *log_ctx; kdb_hlog_t *ulog = NULL; uint32_t ulogentries; INIT_ULOG(context); ulogentries = log_ctx->ulogentries; retval = ulog_lock(context, KRB5_LOCKMODE_SHARED); if (retval) return retval; /* Check to make sure we don't have a corrupt ulog first. */ if (ulog->kdb_state == KDB_CORRUPT) { ulog_handle->ret = UPDATE_ERROR; (void)ulog_lock(context, KRB5_LOCKMODE_UNLOCK); return KRB5_LOG_CORRUPT; } /* * We need to lock out other processes here, such as kadmin.local, since we * are looking at the last_sno and looking up updates. So we can share * with other readers. */ retval = krb5_db_lock(context, KRB5_LOCKMODE_SHARED); if (retval) { (void)ulog_lock(context, KRB5_LOCKMODE_UNLOCK); return retval; } /* If we have the same sno and timestamp, return a nil update. If a * different timestamp, the sno was reused and we need a full resync. */ if (last.last_sno == ulog->kdb_last_sno) { ulog_handle->ret = time_equal(&last.last_time, &ulog->kdb_last_time) ? UPDATE_NIL : UPDATE_FULL_RESYNC_NEEDED; goto cleanup; } /* We may have overflowed the update log or shrunk the log, or the client * may have created its ulog. */ if (last.last_sno > ulog->kdb_last_sno || last.last_sno < ulog->kdb_first_sno) { ulog_handle->lastentry.last_sno = ulog->kdb_last_sno; ulog_handle->ret = UPDATE_FULL_RESYNC_NEEDED; goto cleanup; } sno = last.last_sno; indx = (sno - 1) % ulogentries; indx_log = (kdb_ent_header_t *)INDEX(ulog, indx); if (!time_equal(&indx_log->kdb_time, &last.last_time)) { /* We have time stamp mismatch or we no longer have the slave's last * sno, so we brute force it. */ ulog_handle->ret = UPDATE_FULL_RESYNC_NEEDED; goto cleanup; } count = ulog->kdb_last_sno - sno; upd = calloc(count, sizeof(kdb_incr_update_t)); if (upd == NULL) { ulog_handle->ret = UPDATE_ERROR; retval = ENOMEM; goto cleanup; } ulog_handle->updates.kdb_ulog_t_val = upd; for (; sno < ulog->kdb_last_sno; sno++) { indx = sno % ulogentries; indx_log = (kdb_ent_header_t *)INDEX(ulog, indx); memset(upd, 0, sizeof(kdb_incr_update_t)); xdrmem_create(&xdrs, (char *)indx_log->entry_data, indx_log->kdb_entry_size, XDR_DECODE); if (!xdr_kdb_incr_update_t(&xdrs, upd)) { ulog_handle->ret = UPDATE_ERROR; retval = KRB5_LOG_CONV; goto cleanup; } /* Mark commitment since we didn't want to decode and encode the incr * update record the first time. */ upd->kdb_commit = indx_log->kdb_commit; upd++; } ulog_handle->updates.kdb_ulog_t_len = count; ulog_handle->lastentry.last_sno = ulog->kdb_last_sno; ulog_handle->lastentry.last_time.seconds = ulog->kdb_last_time.seconds; ulog_handle->lastentry.last_time.useconds = ulog->kdb_last_time.useconds; ulog_handle->ret = UPDATE_OK; cleanup: (void)ulog_lock(context, KRB5_LOCKMODE_UNLOCK); (void)krb5_db_unlock(context); return retval; }