void XXObjectRectangle::unionRect(XSWFCONTEXT&cnt,XXVARLIST&list) { XXObjectRectangle*pRect=m_pRoot->m_pGlobal->CreateRectangle(); if(pRect&&list.GetSize()>0&&list[0].IsObject()) { XXObjectRectangle*pr=(XXObjectRectangle*)list[0].pObject; if(pr->IsObject(XXOBJ_RECTANGLE)) { double r=left+width; double b=top+height; double r1=pr->left+pr->width; double b1=pr->top+pr->height; double l=XMIN(left,pr->left); double t=XMIN(top,pr->top); r=XMAX(r,r1); b=XMAX(b,b1); pRect->left=l; pRect->top=t; pRect->width=r-l; pRect->height=b-t; //if(r>l&&b>t) // pVar->iData32=XTRUE; } } cnt.pStack->Push((pRect)); }
unsigned long ChannelStream::GetOutputTime() { if (!this->startedPlaying) return 0; return XMAX(Platform::GetMilliseconds() - this->playStart,0) + this->playOffset; }
int dceslicecompose(DCEslice* s1, DCEslice* s2, DCEslice* result) { int err = NC_NOERR; size_t lastx = 0; DCEslice sr; /* For back compatability so s1 and result can be same object */ #ifdef DEBUG1 slicedump("compose: s1",s1); slicedump("compose: s2",s2); #endif sr.node.sort = CES_SLICE; sr.stride = s1->stride * s2->stride; sr.first = MAP(s1,s2->first); if(sr.first > s1->last) return NC_EINVALCOORDS; lastx = MAP(s1,s2->last); sr.last = XMIN(s1->last,lastx); sr.length = (sr.last + 1) - sr.first; sr.declsize = XMAX(s1->declsize,s2->declsize); /* use max declsize */ /* fill in other fields */ sr.count = (sr.length + (sr.stride - 1))/sr.stride; *result = sr; #ifdef DEBUG1 slicedump("compose: result",result); #endif return err; }
/* Config lcdc timimg when hdmi chooses a resolution * params: mode[lcdc_timimg_parms_t] lcdc timimg to * set * return: null */ void sep0611_hdmi_lcdc_timing(struct lcdc_timing_params_t *mode) { unsigned int plcr = 0; unsigned int pfcr = 0; unsigned int lcdcscr = 0; unsigned int lcdcbcr = 0; plcr = H_WIDTH(mode->lpw) | H_WAIT1((mode->lswc + 1)) | H_WAIT2((mode->lewc + 1)); pfcr = V_WIDTH(mode->fpw) | V_WAIT1((mode->fswc + 1)) | V_WAIT2((mode->fewc + 1)); lcdcscr = XMAX((mode->lpc + 1))|YMAX((mode->flc + 1)); lcdcbcr = readl(LCDC_BCR_V); lcdcbcr &= ~0x3f; lcdcbcr |= PCD(mode->pcd); writel(0x0, LCDC_ECR_V); msleep(20); writel(lcdcbcr, LCDC_BCR_V); writel(plcr, LCDC_PLCR_V); writel(pfcr, LCDC_PFCR_V); writel(lcdcscr, LCDC_SCR_V); msleep(20); writel(0x1, LCDC_ECR_V); msleep(10); }
void XXObjectRectangle::intersects(XSWFCONTEXT&cnt,XXVARLIST&list) { XXVar pVar;//=XXVar::CreateBool(XFALSE); pVar.ToLogic(); if(list.GetSize()>0&&list[0].IsObject()) { XXObjectRectangle*pr=(XXObjectRectangle*)list[0].pObject; if(pr->IsObject(XXOBJ_RECTANGLE)) { double r=left+width; double b=top+height; double r1=pr->left+pr->width; double b1=pr->top+pr->height; double l=XMAX(left,pr->left); double t=XMAX(top,pr->top); r=XMIN(r,r1); b=XMIN(b,b1); if(r>l&&b>t) pVar.iData32=XTRUE; } } cnt.pStack->Push(pVar); }
void XDomTR::RowSpan(DRAWCONTEXT*pDraw,CELLDATA*pData,XBOOL bAdd) { XU16 i=0; while(i<pData->spans.GetSize()) { pData->spans[i]--; if(pData->spans[i]<=0) { SetTabRow(pDraw,pData,0,pData->spans[i+3]);//,0,bAdd); pData->spans.RemoveAt(i,5); } else { pData->spans[i+3]=XMAX(pData->spans[i+3]-pData->rowws[pData->nRow],0); i+=5; } } }
void MAST::GCMMAOptimizationInterface::optimize() { #if MAST_ENABLE_GCMMA == 1 // make sure that all processes have the same problem setup _feval->sanitize_parallel(); int N = _feval->n_vars(), M = _feval->n_eq() + _feval->n_ineq(), n_rel_change_iters = _feval->n_iters_relative_change(); libmesh_assert_greater(N, 0); std::vector<Real> XVAL(N, 0.), XOLD1(N, 0.), XOLD2(N, 0.), XMMA(N, 0.), XMIN(N, 0.), XMAX(N, 0.), XLOW(N, 0.), XUPP(N, 0.), ALFA(N, 0.), BETA(N, 0.), DF0DX(N, 0.), A(M, 0.), B(M, 0.), C(M, 0.), Y(M, 0.), RAA(M, 0.), ULAM(M, 0.), FVAL(M, 0.), FAPP(M, 0.), FNEW(M, 0.), FMAX(M, 0.), DFDX(M*N, 0.), P(M*N, 0.), Q(M*N, 0.), P0(N, 0.), Q0(N, 0.), UU(M, 0.), GRADF(M, 0.), DSRCH(M, 0.), HESSF(M*(M+1)/2, 0.), f0_iters(n_rel_change_iters); std::vector<int> IYFREE(M, 0); std::vector<bool> eval_grads(M, false); Real ALBEFA = 0.1, GHINIT = 0.5, GHDECR = 0.7, GHINCR = 1.2, F0VAL = 0., F0NEW = 0., F0APP = 0., RAA0 = 0., Z = 0., GEPS =_feval->tolerance(); /*C********+*********+*********+*********+*********+*********+*********+ C C The meaning of some of the scalars and vectors in the program: C C N = Complex of variables x_j in the problem. C M = Complex of constraints in the problem (not including C the simple upper and lower bounds on the variables). C ALBEFA = Relative spacing between asymptote and mode limit. Lower value C will cause the move limit (alpha,beta) to move closer to asymptote C values (l, u). C GHINIT = Initial asymptote setting. For the first two iterations the C asymptotes (l, u) are defined based on offsets from the design C point as this fraction of the design variable bounds, ie. C l_j = x_j^k - GHINIT * (x_j^max - x_j^min) C u_j = x_j^k + GHINIT * (x_j^max - x_j^min) C GHDECR = Fraction by which the asymptote is reduced for oscillating C changes in design variables based on three consecutive iterations C GHINCR = Fraction by which the asymptote is increased for non-oscillating C changes in design variables based on three consecutive iterations C INNMAX = Maximal number of inner iterations within each outer iter. C A reasonable choice is INNMAX=10. C ITER = Current outer iteration number ( =1 the first iteration). C GEPS = Tolerance parameter for the constraints. C (Used in the termination criteria for the subproblem.) C C XVAL(j) = Current value of the variable x_j. C XOLD1(j) = Value of the variable x_j one iteration ago. C XOLD2(j) = Value of the variable x_j two iterations ago. C XMMA(j) = Optimal value of x_j in the MMA subproblem. C XMIN(j) = Original lower bound for the variable x_j. C XMAX(j) = Original upper bound for the variable x_j. C XLOW(j) = Value of the lower asymptot l_j. C XUPP(j) = Value of the upper asymptot u_j. C ALFA(j) = Lower bound for x_j in the MMA subproblem. C BETA(j) = Upper bound for x_j in the MMA subproblem. C F0VAL = Value of the objective function f_0(x) C FVAL(i) = Value of the i:th constraint function f_i(x). C DF0DX(j) = Derivative of f_0(x) with respect to x_j. C FMAX(i) = Right hand side of the i:th constraint. C DFDX(k) = Derivative of f_i(x) with respect to x_j, C where k = (j-1)*M + i. C P(k) = Coefficient p_ij in the MMA subproblem, where C k = (j-1)*M + i. C Q(k) = Coefficient q_ij in the MMA subproblem, where C k = (j-1)*M + i. C P0(j) = Coefficient p_0j in the MMA subproblem. C Q0(j) = Coefficient q_0j in the MMA subproblem. C B(i) = Right hand side b_i in the MMA subproblem. C F0APP = Value of the approximating objective function C at the optimal soultion of the MMA subproblem. C FAPP(i) = Value of the approximating i:th constraint function C at the optimal soultion of the MMA subproblem. C RAA0 = Parameter raa_0 in the MMA subproblem. C RAA(i) = Parameter raa_i in the MMA subproblem. C Y(i) = Value of the "artificial" variable y_i. C Z = Value of the "minimax" variable z. C A(i) = Coefficient a_i for the variable z. C C(i) = Coefficient c_i for the variable y_i. C ULAM(i) = Value of the dual variable lambda_i. C GRADF(i) = Gradient component of the dual objective function. C DSRCH(i) = Search direction component in the dual subproblem. C HESSF(k) = Hessian matrix component of the dual function. C IYFREE(i) = 0 for dual variables which are fixed to zero in C the current subspace of the dual subproblem, C = 1 for dual variables which are "free" in C the current subspace of the dual subproblem. C C********+*********+*********+*********+*********+*********+*********+*/ /* * The USER should now give values to the parameters * M, N, GEPS, XVAL (starting point), * XMIN, XMAX, FMAX, A and C. */ // _initi(M,N,GEPS,XVAL,XMIN,XMAX,FMAX,A,C); // Assumed: FMAX == A _feval->_init_dvar_wrapper(XVAL, XMIN, XMAX); // set the value of C[i] to be very large numbers Real max_x = 0.; for (unsigned int i=0; i<N; i++) if (max_x < fabs(XVAL[i])) max_x = fabs(XVAL[i]); std::fill(C.begin(), C.end(), std::max(1.e0*max_x, _constr_penalty)); int INNMAX=_max_inner_iters, ITER=0, ITE=0, INNER=0, ICONSE=0; /* * The outer iterative process starts. */ bool terminate = false, inner_terminate=false; while (!terminate) { ITER=ITER+1; ITE=ITE+1; /* * The USER should now calculate function values and gradients * at XVAL. The result should be put in F0VAL,DF0DX,FVAL,DFDX. */ std::fill(eval_grads.begin(), eval_grads.end(), true); _feval->_evaluate_wrapper(XVAL, F0VAL, true, DF0DX, FVAL, eval_grads, DFDX); if (ITER == 1) // output the very first iteration _feval->_output_wrapper(0, XVAL, F0VAL, FVAL, true); /* * RAA0,RAA,XLOW,XUPP,ALFA and BETA are calculated. */ raasta_(&M, &N, &RAA0, &RAA[0], &XMIN[0], &XMAX[0], &DF0DX[0], &DFDX[0]); asympg_(&ITER, &M, &N, &ALBEFA, &GHINIT, &GHDECR, &GHINCR, &XVAL[0], &XMIN[0], &XMAX[0], &XOLD1[0], &XOLD2[0], &XLOW[0], &XUPP[0], &ALFA[0], &BETA[0]); /* * The inner iterative process starts. */ // write the asymptote data for the inneriterations _output_iteration_data(ITER, XVAL, XMIN, XMAX, XLOW, XUPP, ALFA, BETA); INNER=0; inner_terminate = false; while (!inner_terminate) { /* * The subproblem is generated and solved. */ mmasug_(&ITER, &M, &N, &GEPS, &IYFREE[0], &XVAL[0], &XMMA[0], &XMIN[0], &XMAX[0], &XLOW[0], &XUPP[0], &ALFA[0], &BETA[0], &A[0], &B[0], &C[0], &Y[0], &Z, &RAA0, &RAA[0], &ULAM[0], &F0VAL, &FVAL[0], &F0APP, &FAPP[0], &FMAX[0], &DF0DX[0], &DFDX[0], &P[0], &Q[0], &P0[0], &Q0[0], &UU[0], &GRADF[0], &DSRCH[0], &HESSF[0]); /* * The USER should now calculate function values at XMMA. * The result should be put in F0NEW and FNEW. */ std::fill(eval_grads.begin(), eval_grads.end(), false); _feval->_evaluate_wrapper(XMMA, F0NEW, false, DF0DX, FNEW, eval_grads, DFDX); if (INNER >= INNMAX) { libMesh::out << "** Max Inner Iter Reached: Terminating! Inner Iter = " << INNER << std::endl; inner_terminate = true; } else { /* * It is checked if the approximations were conservative. */ conser_( &M, &ICONSE, &GEPS, &F0NEW, &F0APP, &FNEW[0], &FAPP[0]); if (ICONSE == 1) { libMesh::out << "** Conservative Solution: Terminating! Inner Iter = " << INNER << std::endl; inner_terminate = true; } else { /* * The approximations were not conservative, so RAA0 and RAA * are updated and one more inner iteration is started. */ INNER=INNER+1; raaupd_( &M, &N, &GEPS, &XMMA[0], &XVAL[0], &XMIN[0], &XMAX[0], &XLOW[0], &XUPP[0], &F0NEW, &FNEW[0], &F0APP, &FAPP[0], &RAA0, &RAA[0]); } } } /* * The inner iterative process has terminated, which means * that an outer iteration has been completed. * The variables are updated so that XVAL stands for the new * outer iteration point. The fuction values are also updated. */ xupdat_( &N, &ITER, &XMMA[0], &XVAL[0], &XOLD1[0], &XOLD2[0]); fupdat_( &M, &F0NEW, &FNEW[0], &F0VAL, &FVAL[0]); /* * The USER may now write the current solution. */ _feval->_output_wrapper(ITER, XVAL, F0VAL, FVAL, true); f0_iters[(ITE-1)%n_rel_change_iters] = F0VAL; /* * One more outer iteration is started as long as * ITE is less than MAXITE: */ if (ITE == _feval->max_iters()) { libMesh::out << "GCMMA: Reached maximum iterations, terminating! " << std::endl; terminate = true; } // relative change in objective bool rel_change_conv = true; Real f0_curr = f0_iters[n_rel_change_iters-1]; for (unsigned int i=0; i<n_rel_change_iters-1; i++) { if (f0_curr > sqrt(GEPS)) rel_change_conv = (rel_change_conv && fabs(f0_iters[i]-f0_curr)/fabs(f0_curr) < GEPS); else rel_change_conv = (rel_change_conv && fabs(f0_iters[i]-f0_curr) < GEPS); } if (rel_change_conv) { libMesh::out << "GCMMA: Converged relative change tolerance, terminating! " << std::endl; terminate = true; } } #endif //MAST_ENABLE_GCMMA == 1 }
void XDomTD::LayeroutCells(DRAWCONTEXT*pDraw,CELLDATA*pData,int span) { CELLDATA data; LAYEROUTDATA margin; SpanCol(pData); data.Reset(pData->cur.x,pData->cur.y,XTRUE); PreLayerout(pDraw,&data,&margin); data.pData=XNULL; int cspan=//pDraw->DCOLSPAN;// //span==0?XMAX(FindAttrib(XEAB::COLSPAN,1),1):span; span==0?pDraw->DCOLSPAN:span; int rspan=pDraw->DROWSPAN;// //XMAX(FindAttrib(XEAB::ROWSPAN,1),1); //for debug XRect rw=pDraw->win; // if(pDraw->SETWIDTH==663) // int a=0; XSize sz; if(pData->bFinal) { int w=pData->fixCols[pData->nCol]; for(int i=1;i<cspan;i++) { if(pData->nCol+i>=(int)pData->fixCols.GetSize()) break; w+=pData->fixCols[pData->nCol+i]; } InitMargin(pDraw,&data,&margin,m_nPosX,m_nPosY,w,m_nHeight); XPoint pt=data.cur; if(InitSize(pDraw,&data,w,XFALSE)) m_nFixHeight=data.max.cy-pt.y; //XSize sz; sz=XSize(m_nWidth,m_nHeight); SetMargin(&margin,m_nWidth,m_nHeight,sz); SaveData(&data); //pDraw->win=rt; //m_nFixHeight=m_nHeight; } else { //data.Reset(pData->cur.x,pData->cur.y,XTRUE); int w=0; //if(pData->nCol+cspan<(XINT)pData->setCols.GetSize()) { //w=pData->setCols[pData->nCol]; for(int i=0;i<cspan;i++) { if(pData->nCol+i>=(int)pData->setCols.GetSize()) break; w+=pData->setCols[pData->nCol+i]; } //int w1=0; /*for(int i=0;i<cspan;i++) { if(pData->nCol+i>=(int)pData->cols[i] }*/ } InitMargin(pDraw,&data,&margin,m_nPosX,m_nPosY,w,m_nHeight); XPoint pt=data.cur; XU8 bFix=InitFixed(pDraw,&data,w); sz=XSize(m_nWidth,m_nHeight); SetMargin(&margin,m_nWidth,m_nHeight,sz); //pDraw->win=rt; //m_nHeight=XMAX(m_nHeight,pDraw->SETHEIGHT);//m_nHeight;//XMAX(m_nHeight,pDraw->SPACE); //w=m_nWidth; if(bFix) { m_nFixWidth=m_nWidth; m_nFixHeight=data.max.cy-pt.y; } if(span==0) { int nMin=m_nMin; //if(bFix) m_nFixWidth=data.max.cx- w=m_nFixWidth; for(int i=0;i<cspan;i++) { XU16 id=pData->nCol+i; if(id>=pData->cols.GetSize()) { pData->tabs.Add(bFix==1); pData->cols.Add(nMin/(cspan-i)); pData->fixCols.Add(w/(cspan-i)); nMin-=nMin/(cspan-i); w-=w/(cspan-i); //break; } else if(i+1<cspan) { pData->tabs[id]|=bFix; nMin=XMAX(nMin-pData->cols[id],0); w=XMAX(w-pData->fixCols[id],0); } else { pData->tabs[id]|=bFix; if(pData->cols[id]<nMin) pData->cols[id]=nMin; if(pData->fixCols[id]<w) pData->fixCols[id]=w; } } } } //m_rows.DataFrom(data.rowws); //m_cols.DataFrom(data.fixCols); //XSize size(m_nWidth,m_nHeight); //SetMargin(&margin,m_nWidth,m_nHeight,size); /* XString8 str=FindAttrib(XEAB::ID,""); if(str=="999") int a=0;*/ if(pDraw->bCollapse) { //m_nWidth-=2; //m_nHeight-=2; //sz.cx-=2; sz.cy-=2; } //*///*/ if(rspan<=1) SetTabRow(pDraw,pData,sz.cx,sz.cy);//m_nWidth,m_nHeight);//XSize(m_nWidth,m_nHeight),m_nMin,XTRUE); else { SetTabRow(pDraw,pData,sz.cx,pDraw->SPACE);//XSize(m_nWidth,pDraw->nRowSpace),m_nMin,XTRUE); pData->spans.Add(rspan); pData->spans.Add(pData->nCol); pData->spans.Add(m_nWidth); pData->spans.Add(m_nFixHeight); pData->spans.Add(cspan); } pDraw->win=rw; pData->nCol+=cspan; EndLayerout(pDraw,&data); }
XU32 XDomTable::Paint(DRAWCONTEXT *pDraw) { //XString8 str=FindAttrib(XEAB::ID,""); //if(str=="last") // int a=0; if(m_nWidth<=0) return 0; if(m_nPosX>=pDraw->paint.right|| m_nPosX+m_nWidth<=pDraw->paint.left|| m_nPosY>=pDraw->paint.bottom|| m_nPosY+m_nHeight<=pDraw->paint.top) return 0; XU32 ss=PrePaint(pDraw); XRect rect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight); int bd=FindAttrib(XEAB::BORDER,0); XU8 nType=FindAttrib(XEAB::FRAME,XEnumFrame::BOX); XU8 bCollapse=pDraw->bCollapse; pDraw->bCollapse=FindAttrib(XEAB::BORDER_COLLAPSE,0); int nr=pDraw->SPACING; pDraw->SPACING=XMAX(FindAttrib(XEAB::CELLSPACING,1),0); XU8 d=pDraw->TABBORDER; pDraw->TABBORDER=bd; XRect ar=XRect(rect.left,rect.top,rect.right,rect.bottom); PaintBack(pDraw,ar,XTRUE); XU32 s=HandleChild(XDO_PAINT_TABLE,(XU32)pDraw,0); pDraw->bCollapse=bCollapse; pDraw->TABBORDER=d; if(nType==XEF::VOID_X) bd=0; if(bd>0) { XGraphics*pg=pDraw->pDraw; //pDraw->Save(); XColor cc(pDraw->DCBACK); XColor dc(cc); dc.Dark(60); cc.Dark(30); int bx=m_nPosX,by=m_nPosY; int ex=m_nPosX+m_nWidth-1,ey=m_nPosY+m_nHeight-1; for(int i=0;i<bd;i++) { pg->SetColor(cc); switch(nType) { case XEF::BOX: case XEF::ABOVE: case XEF::BORDER: case XEF::HSIDES: pg->DrawLine(bx,by,ex,by); break; } switch(nType) { case XEF::BORDER: case XEF::BOX: case XEF::VSIDES: case XEF::LHS: pg->DrawLine(bx,by,bx,ey); break; } pg->SetColor(dc); switch(nType) { case XEF::BORDER: case XEF::BOX: case XEF::VSIDES: case XEF::RHS: pg->DrawLine(ex,by,ex,ey); break; } switch(nType) { case XEF::BORDER: case XEF::BOX: case XEF::HSIDES: case XEF::BELOW: pg->DrawLine(bx,ey,ex,ey); break; } cc.Bright(3); dc.Bright(3); bx++; by++; ex--; ey--; } //cc.Dark(20); /*pDraw->pDraw->DrawFrame( XRect(m_nPosX,m_nPosY,m_nPosX+m_nWidth,m_nPosY+m_nHeight), cc,bd,XTRUE);*/ // pDraw->Restore(); } pDraw->SPACING=nr; PaintBorder(pDraw,ar); EndPaint(pDraw); //if(bSave) // pDraw->Restore(); return s; }
XU32 XDomTD::LayeroutPre(DRAWCONTEXT*pDraw,CELLDATA*pData) { XINT i; SpanCol(pData); //LAYEROUTDATA margin; //PreLayerout(pDraw,pData,margin); // if(pDraw->SETWIDTH==-84) // int a=0; int w=FindAttrib(XEAB::WIDTH,0); int cspan=XMAX(FindAttrib(XEAB::COLSPAN,1),1); int rspan=XMAX(FindAttrib(XEAB::ROWSPAN,1),1); /*if(w==0) { if(m_childs.GetSize()>0) pData->setCols.Add(0); } */ //else if(w) { for(i=pData->setCols.GetSize();i<pData->nCol;i++) pData->setCols.Add(0); for(i=0;i<cspan;i++) { XU16 id=pData->nCol+i; if(id>=pData->setCols.GetSize()) { pData->setCols.Add(w/(cspan-i)); w-=w/(cspan-i); } else if(i+1<cspan) { if(w>0) { if(pData->setCols[id]>=0) w=XMAX(w-pData->setCols[id],0); else w-=w/(cspan-i); } else { if(pData->setCols[id]<0) w=XMIN(w-pData->setCols[id],0); else w-=w/(cspan-i); } } else { if(w>0) { if(pData->setCols[id]<w) pData->setCols[id]=w; } else if(pData->setCols[id]>w) pData->setCols[id]=w; } } } // else if(m_childs.GetSize()>0) pData->nCol+=cspan; if(rspan>1) { pData->spans.Add(rspan); pData->spans.Add(pData->nCol); pData->spans.Add(0); pData->spans.Add(0); pData->spans.Add(cspan); } //EndLayerout(pDraw,pData); return 0; }
void XDomTable::LayeroutTable(DRAWCONTEXT *pDraw, CELLDATA &data) { XU32 i; int bd=FindAttrib(XEAB::BORDER,0); int cp=pDraw->SPACING;//XMAX(FindAttrib(XEAB::CELLSPACING,1),0); int wd=pDraw->SETWIDTH;//FindAttrib(XEAB::WIDTH,0); //if(wd==900) // int a=0; //int wmm=wd; if(wd<0) wd=-pDraw->win.Width()*wd/100; //if(wd==660) // int a=0; XRect win=pDraw->win; int cs=pDraw->SPACING;//XMAX(FindAttrib(XEAB::CELLPADDING,1),0);//cellspacing XU8 nType=FindAttrib(XEAB::FRAME,XEnumFrame::BOX); //if(nType==XEF::VOID_X) bd=0; //XU8 nPad=pDraw->PADDING; //XU8 nSpa=pDraw->SPACING; //if(bd) cs++; { pDraw->SPACING=cp; if(bd) pDraw->SPACING+=2; pDraw->PADDING=cs; } if(wd>0) { wd-=(bd<<1)+cp; pDraw->win.left+=bd; pDraw->win.right=pDraw->win.left+wd; } else { pDraw->win.left+=bd; pDraw->win.right-=bd+cp; } XPoint pt(pDraw->win.left,pDraw->win.top); //if(0) { HandleChild(XDO_LAYEROUT_TABPRE,(XU32)pDraw,(XU32)&data); XU32 nc=data.setCols.GetSize(); data.Reset(pt.x,pt.y,XFALSE); if(nc>0) { int pw=0,ww=pDraw->win.Width(),nsc=0,nfc=0; int tw=ww,ssw=0; for(i=0;i<nc;i++) { if(data.setCols[i]>0) { nfc++; tw-=data.setCols[i]; ssw+=data.setCols[i]; } else if(data.setCols[i]<0) pw+=data.setCols[i]; else nsc++; } //if((nsc+nfc)<=0&&pw>-100&&pw<0) //{ //ww=ww*-100/pw; //} tw=tw*(100+pw)/100; if(pw!=0&&nsc>1) tw=tw/nsc; if(tw<=0) tw=ww/nc; if(nsc+nfc>0) pw=-100; //if(nsc<=0&&pw>-100) // ww=ww*100/pw; for(i=0;i<nc;i++) { if(data.setCols[i]>0) { if(ssw>wd) { data.setCols[i]=data.setCols[i]*wd/ssw; //XVar var(XEAB::WIDTH,data.setCols[i]); } continue; } else if(data.setCols[i]<0) { data.setCols[i]=data.setCols[i]*ww/pw; } else data.setCols[i]=tw; } } //data.tabs.InsertAt(0,(XU8)0,data.fixCols.GetSize()); } //else pDraw->win.right--; //XString8 str=FindAttrib(XEAB::ID,""); //if(str=="100") // int a=0; //else if(m_nWidth>0) pDraw->win.right=pDraw->win.left+wd; HandleChild(XDO_LAYEROUT_TABS,(XU32)pDraw,(XU32)&data); MoreRowSpan(&data); data.max.cx=0; //data.max.cy-=my; data.nMin=0; int nFixed=0; for(i=0;i<data.cols.GetSize();i++) { if(data.tabs[i]) nFixed+=data.fixCols[i]; else nFixed+=data.nMin; data.nMin+=data.cols[i]; data.max.cx+=data.fixCols[i]; } //if(data.max.cx==905) // int a=0; int mx=pDraw->win.Width(); int nMin=data.nMin; XBOOL bReset=XFALSE; if(data.max.cx<wd) { bReset=XTRUE; int nTotal=0,nLeft=wd,nLast=wd; for(i=0;i<data.tabs.GetSize();i++) { if(data.tabs[i]) //continue; nLeft-=data.fixCols[i]; else nTotal+=data.fixCols[i]; } if(nTotal==0) { for(i=0;i<data.tabs.GetSize();i++) { if(i+1==data.fixCols.GetSize()) data.fixCols[i]=nLast; else { if(data.max.cx<=0) data.fixCols[i]=wd/data.tabs.GetSize(); else data.fixCols[i]=data.fixCols[i]*wd/data.max.cx; nLast-=data.fixCols[i]; } } } else { for(i=0;i<data.tabs.GetSize();i++) { if(i+1==data.fixCols.GetSize()) data.fixCols[i]=nLast; else { if(!data.tabs[i]) //continue; data.fixCols[i]=data.fixCols[i]*nLeft/nTotal; nLast-=data.fixCols[i]; } } } //if(wmm>0) data.max.cx=wd; //else // data.max.cx= } else if(data.max.cx>mx)//&&m_bNoChild) { /*if(nFixed<mx) { int nLeft=mx-nFixed; for(i=0;i<data.cols.GetSize();i++) { if(data.tabs[i]) continue; int dd=XMAX(data.fixCols[i]-data.cols[i],0); data.fixCols[i]=data.cols[i]+nLeft*dd/(data.max.cx-nFixed); } data.max.cx=mx; } else*/ if(data.nMin<mx) { int nLeft=mx-data.nMin; for(i=0;i<data.cols.GetSize();i++) { int dd=XMAX(data.fixCols[i]-data.cols[i],0); data.fixCols[i]=data.cols[i]+nLeft*dd/(data.max.cx-data.nMin); } data.max.cx=mx; } else { for(i=0;i<data.cols.GetSize();i++) data.fixCols[i]=data.cols[i]; data.max.cx=data.nMin; } bReset=XTRUE; } //if(bReset) { int maxx=data.max.cx; data.Reset(pt.x,pt.y,XFALSE); //data.rowws.RemoveAll(XFALSE); //data.cols.RemoveAll(XFALSE); //data.fixCols.RemoveAll(XFALSE); data.bFinal=XTRUE; for(i=0;i<data.rowws.GetSize();i++) data.rowws[i]=0; HandleChild(XDO_LAYEROUT_TABS,(XU32)pDraw,(XU32)&data); MoreRowSpan(&data); data.max.cx=maxx; //data.max.cy-=my; data.nMin=nMin; } int ds=(bd<<1)+cp; //if(bd>0) { //bd--; data.max.cx+=ds;//bd<<1; //data.max.cy+=ds;//bd<<1; data.nMin+=ds;//bd<<1; } m_nHeight=ds; for(i=0;i<data.rowws.GetSize();i++) m_nHeight+=data.rowws[i]; int sh=pDraw->SETHEIGHT;//FindAttrib(XEAB::HEIGHT,0); /*if(m_nHeight<sh) { for(i=0;i<data.rowws.GetSize();i++) { if(m_nHeight>0) data.rowws[i]=data.rowws[i]*sh/m_nHeight; else data.rowws[i]=sh/data.rowws.GetSize(); } } &*/ m_nHeight=XMAX(m_nHeight,sh); // pDraw->win=rt; m_nMin=data.nMin; m_nWidth=data.max.cx; //m_nHeight=data.max.cy; //pDraw->PADDING=nPad; //pDraw->SPACING=nSpa; pDraw->win=win; }
struct pollfd channel_request_poll(struct channel* c) { if (channel_wanted_readsz(c)) return (struct pollfd){c->fdh->fd, POLLIN, 0}; if (channel_wanted_writesz(c)) return (struct pollfd){c->fdh->fd, POLLOUT, 0}; return (struct pollfd){-1, 0, 0}; } void channel_write(struct channel* c, const struct iovec* iov, unsigned nio) { assert(c->dir == CHANNEL_TO_FD); if (c->fdh == NULL) return; // If the stream is closed, just discard bool try_direct = !c->always_buffer && ringbuf_size(c->rb) == 0; size_t directwrsz = 0; size_t totalsz; if (c->adb_encoding_hack) try_direct = false; // If writing directly, would make us overflow the write counter, // fall back to buffered IO. if (try_direct) { totalsz = iovec_sum(iov, nio); if (c->track_bytes_written && UINT32_MAX - c->bytes_written < totalsz) { try_direct = false; } } if (try_direct) { // If writev fails, just fall back to buffering path directwrsz = XMAX(writev(c->fdh->fd, iov, nio), 0); if (c->track_bytes_written) c->bytes_written += directwrsz; } for (unsigned i = 0; i < nio; ++i) { size_t skip = XMIN(iov[i].iov_len, directwrsz); directwrsz -= skip; char* b = (char*)iov[i].iov_base + skip; size_t blen = iov[i].iov_len - skip; ringbuf_copy_in(c->rb, b, blen); ringbuf_note_added(c->rb, blen); } } // Begin channel shutdown process. Closure is not complete until // channel_dead_p(c) returns true. void channel_close(struct channel* c) { c->pending_close = true; if (c->fdh != NULL && ((c->dir == CHANNEL_TO_FD && ringbuf_size(c->rb) == 0) || c->dir == CHANNEL_FROM_FD)) { fdh_destroy(c->fdh); c->fdh = NULL; } } static void poll_channel_1(void* arg) { struct channel* c = arg; size_t sz; if ((sz = channel_wanted_readsz(c)) > 0) { size_t nr_read; if (c->adb_encoding_hack) nr_read = channel_read_adb_hack(c, sz); else nr_read = channel_read_1(c, sz); assert(nr_read <= c->window); if (c->track_window) c->window -= nr_read; if (nr_read == 0) channel_close(c); } if ((sz = channel_wanted_writesz(c)) > 0) { size_t nr_written; if (c->adb_encoding_hack) nr_written = channel_write_adb_hack(c, sz); else nr_written = channel_write_1(c, sz); assert(nr_written <= UINT32_MAX - c->bytes_written); if (c->track_bytes_written) c->bytes_written += nr_written; if (c->pending_close && ringbuf_size(c->rb) == 0) channel_close(c); } } bool channel_dead_p(struct channel* c) { return (c->fdh == NULL && ringbuf_size(c->rb) == 0 && c->sent_eof == true); } void channel_poll(struct channel* c) { struct errinfo ei = { .want_msg = false }; if (catch_error(poll_channel_1, c, &ei) && ei.err != EINTR) { if (c->dir == CHANNEL_TO_FD) { // Error writing to fd, so purge buffered bytes we'll // never write. By purging, we also make the stream // appear writable (because now there's space available), // but any writes will actually go into a black hole. // This way, if somebody's blocked on being able to write // to this stream, he'll get unblocked. This behavior is // important when c is TO_PEER and lets us complete an // orderly shutdown, flushing any data we've buffered, // without adding special logic all over the place to // account for this situation. ringbuf_note_removed(c->rb, ringbuf_size(c->rb)); } channel_close(c); c->err = ei.err; } }
/******************************** the module driver ************************************************************/ static int sep0611_overlay_ioctl(struct inode *inode, struct file *file, unsigned int cmd, unsigned long arg) { unsigned int intArg,data; overlay_config_t config; lcdc_timming timming_tmp; switch(cmd) { #if 0 case OVERLAY_FORBID: if(copy_from_user(&intArg, (int *)arg, sizeof(int))) return -EFAULT; overlay_forbid = intArg; return 0; #endif #if USE_PICTURE case 111://GET_IMG //if(copy_from_user(&config, (overlay_config_t *)arg, sizeof(overlay_config_t))) // return -EFAULT; return sep0611_overlay_get_img(); #endif case OVERLAY_PRINT_REGS: dprintk("print regs:\n"); for(intArg=0; intArg<=0xCC;intArg+=4) { printk("reg[0x%x] = (0x%x)\n", (unsigned int)io + intArg, readl(io + intArg)); } break; case OVERLAY_GET_STARTBUF: dprintk("overlay_kernel ioctl get startbuffer!\n"); if(copy_to_user((unsigned int *)arg, &over1_addr_phy, sizeof(unsigned int))) { dprintk("error while copy!\n"); return -EFAULT; }else{ // dprintk("success get startbuf: 0x%x",over1_addr_phy); } break; case OVERLAY_AUTORP_CTL: if(copy_from_user(&intArg, (int *)arg, sizeof(int))) return -EFAULT; if(intArg == 1){ writel(0, io + SEP0611_ACSR); data = readl(io + SEP0611_LCDCBCR); data &=~(0x3<<13); data |=(0x2<<13); writel(data, io + SEP0611_LCDCBCR); mdelay(10); writel(1, io + SEP0611_ACSR); dprintk("ctl enable auto repair\n"); }else{ data = readl(io + SEP0611_LCDCBCR); data &=~(0x3<<13); writel(data, io + SEP0611_LCDCBCR); dprintk("ctl disable auto repair\n"); } break; case OVERLAY_SHOW_CURSOR: return sep0611_overlay_drawcursor(); case OVERLAY_SETPOS_CURSOR: if(copy_from_user(&intArg, (int *)arg, sizeof(int))) return -EFAULT; return sep0611_overlay_setpos_cursor(intArg); case OVERLAY_LAYERS_CTL://enable or disable layers if(copy_from_user(&intArg, (int *)arg, sizeof(int))) return -EFAULT; sep0611_overlay_layers_ctl(intArg); break; case 114://set lcdc timming if(copy_from_user(&timming_tmp, (lcdc_timming *)arg, sizeof(lcdc_timming))) return -EFAULT; sep0611_overlay_settimming(timming_tmp); break; case 115://set lcdc base layer size and format if(copy_from_user(&config, (overlay_config_t *)arg, sizeof(overlay_config_t))) return -EFAULT; intArg = 0; dprintk("set base size:(%d,%d)\n", config.width, config.height); intArg = XMAX(config.width)|YMAX(config.height); writel(intArg, io + SEP0611_BBPCR); writel(config.width, io + SEP0611_BASE_RAW_IMAGE_WIDTH); switch(config.format) { case V4L2_PIX_FMT_RGB565: dprintk("use rgb565\n"); data = readl(io + SEP0611_LCDCBCR); data &=~(0x3<<27); writel(data, io + SEP0611_LCDCBCR); break; case V4L2_PIX_FMT_RGB24: dprintk("use rgb888\n"); data = readl(io + SEP0611_LCDCBCR); data &= ~(0x3<<27); data |= (0x2<<27); writel(data, io + SEP0611_LCDCBCR); break; default: dprintk("not support!\n"); break; } break; case OVERLAY_GET_POSITION: return sep0611_overlay_get_pos((overlay_config_t*)arg); case OVERLAY_GET_SCREEN_INFO: return sep0611_overlay_get_screenInfo((overlay_config_t*)arg); case OVERLAY_SET_POSITION: if(copy_from_user(&config, (overlay_config_t *)arg, sizeof(overlay_config_t))) return -EFAULT; return sep0611_overlay_set_pos(config); case OVERLAY_QUEUE_BUFFER: if(copy_from_user(&intArg, (overlay_config_t *)arg, sizeof(unsigned int))) return -EFAULT; return sep0611_overlay_q_buffer((unsigned int)intArg); case OVERLAY_SET_CONFIGURE: if(copy_from_user(&config, (overlay_config_t *)arg, sizeof(overlay_config_t))) return -EFAULT; sep0611_overlay_set_configure(config); //sep0611_overlay_q_buffer(over1_addr_phy); break; case OVERLAY_SET_DISABLE: return sep0611_overlay_disable(); case OVERLAY_SET_ENABLE: return sep0611_overlay_enable(); case OVERLAY_COMMON_ENABLE: sep0611_common_enable(); return 0; case OVERLAY_COMMON_DISABLE: sep0611_common_disable(); return 0; case OVERLAY_SWITCHTO_VIDEO: sep0611_switchto_mode(0); break; case OVERLAY_SWITCHTO_HDMI: sep0611_switchto_mode(1); break; case OVERLAY_SWITCHTO_LCD: sep0611_switchto_mode(2); break; default: dprintk(" Unsupported IOCTL(%d)!!!\n", cmd); break; } return 0; }
static int sep0611_overlay_settimming(lcdc_timming timming) { unsigned int data; dprintk("go to %s\n", __func__); //disable LCDC writel(WIN_DISABLE, io + SEP0611_LCDCECR); #if 1 if(timming.width == 9999)//switch PLL source { data = readl(io_pmu + 0x2c); dprintk("pmu_0x2c = 0x%x\n", data); data = readl(io_pmu + 0x34); dprintk("pmu_0x34 = 0x%x\n", data); data = readl(io_pmu + 0x2c); data &= ~(0x3<<4); if(timming.height == 9999) ;//use MPLL else {data |= 0x1<<4; /*data|=0x1;*/} //use APLL writel(data, io_pmu + 0x2c);//to use APLL 800MHz data = readl(io_pmu + 0x34); data &= ~(0x1<<3); data |= 0x1<<3; writel(data , io_pmu + 0x34); for(;;) { data = readl(io_pmu + 0x34); data &= 0x1<<3; dprintk("data = %d\n",data); if(data ==0) break; msleep(100); } dprintk("after write the regs\n"); data = readl(io_pmu + 0x2c); dprintk("pmu_0x2c = 0x%x\n", data); data = readl(io_pmu + 0x34); dprintk("pmu_0x34 = 0x%x\n", data); dprintk("pmu config OK\n"); writel(WIN_ENABLE, io + SEP0611_LCDCECR); return 0; } #endif dprintk("lcd.t=%d, %d, %d, %d, %d, %d, %d, %d, %d\n",timming.width,timming.height,timming.pcd,timming.h_width,timming.h_wait1,timming.h_wait2,timming.v_width,timming.v_wait1,timming.v_wait2); msleep(10); //size data = 0; data |= XMAX(timming.width)|YMAX(timming.height); writel(data, io + SEP0611_LCDCSCR); // PCD data = readl(io + SEP0611_LCDCBCR); data &=~(0x1F); data |=timming.pcd; writel(data, io + SEP0611_LCDCBCR); // H timming data = 0; data = H_WIDTH(timming.h_width) | H_WAIT1(timming.h_wait1) | H_WAIT2(timming.h_wait2); writel(data, io + SEP0611_PLCR); // V timming data = 0; data = V_WIDTH(timming.v_width) | V_WAIT1(timming.v_wait1) | V_WAIT2(timming.v_wait2); writel(data, io + SEP0611_PFCR); msleep(10); //enable LCDC writel(WIN_ENABLE, io + SEP0611_LCDCECR); return 0; }