示例#1
0
VSFlowReturn 
_configMasterVideoLayer(void * vshandle, void  * config)
{
    VS_FLOW("Fun %s in\n", __FUNCTION__);

    VideoSurface * vs;
    vs = (VideoSurface *)vshandle;

    if (NEXTSURFACE(vs)==NULL)
        return VS_FLOW_OK;

    VideoDevice * vd=SURFACE2DEVICE(vs);
      
    VS_LOCK(gVSlock);

    _removeVideoSurfaceFromDevice(vd,vs);
    _addVideoSurface2Device(vd,vs);
    
    _refreshOnDevice(vd);

    VS_UNLOCK(gVSlock);
    VS_FLOW("Fun %s out\n", __FUNCTION__);

    return VS_FLOW_OK;
}
void
_destroyVideoSurface (void *vshandle, int force)
{
  VideoSurface *vs, *vs1;

  VideoDevice *vd;
  vs = (VideoSurface *) vshandle;

  if (vs == NULL)
    return;

  VS_LOCK (gVSlock);

  if (force == 0) {
    vs1 = gvslocal;
    if (vs1 == vs) {
      gvslocal = vs->next;
    } else {
      while (vs1->next != vs)
        vs1 = vs1->next;
      vs1->next = vs->next;
    }
  }

  vd = SURFACE2DEVICE (vs);

  _removeVideoSurfaceFromDevice (vd, vs);
  // _clearBackground(vd, vs);

  _destroySubFrameBuffer (vs);
  vd->cleanmask = 0xffffffff;


  vd->cnt--;


  if (DEVICE2HEADSURFACE (vd) == NULL) {
    _closeDevice (vd);
    vd->init = 0;
  } else {
    if (_checkOnDevice (vd)) {
      _reconfigAllVideoSurfaces (vd);
      _setDeviceConfig (vd);
    }

    if (vd->setalpha)
      _setAlpha (vd);

    _refreshOnDevice (vd);
  }


  VS_MESSAGE ("VS%d destroyed, force=%d!\n", vs->id - 1, force);

  vs->status = VS_STATUS_IDLE;

  VS_UNLOCK (gVSlock);
}
示例#3
0
/*=============================================================================
FUNCTION:           render2VideoSurface

DESCRIPTION:        This function render a new frame on specific video surface
                    It also will refresh other video surfaces in same video device
                    automaticallly.
==============================================================================*/
VSFlowReturn 
render2VideoSurface(void * vshandle, SourceFrame * frame, SourceFmt * srcfmt)
{
    VS_FLOW("Fun %s in\n", __FUNCTION__);

    VideoDevice * vd;
    VideoSurface * vsurface, *vsurface1;
    Updated updated;

    if ((vshandle==NULL)||(frame==NULL)){
        VS_ERROR("%s: parameters error!\n", __FUNCTION__);
        return VS_FLOW_PARAMETER_ERROR;
    }

    vsurface = (VideoSurface *)vshandle;

    if (vsurface->status == VS_STATUS_INVISIBLE) /* no need to render */
        return VS_FLOW_OK;
    
    vsurface->paddr = frame->paddr;
    vsurface->rendmask = 0;/*clear mask*/
    
    vd = SURFACE2DEVICE(vsurface);

    if (sem_trywait(gVSlock))
        return VS_FLOW_PENDING;



    vsurface1 = DEVICE2HEADSURFACE(vd);

    memset((void *)(&updated), 0, sizeof(Updated));
    while(vsurface1){
        if (_needRender(vsurface1, &updated, vd->renderidx)){
            _renderSuface(vsurface1, vd, &updated);
        }
        vsurface1 = NEXTSURFACE(vsurface1);
    };

    _FlipOnDevice(vd);

#if 0 /* no need to sleep anymore */
    if (vd->cnt>1)
        usleep(10000);
#endif

done:
    VS_UNLOCK(gVSlock);

    VS_FLOW("Fun %s out\n", __FUNCTION__);
    return VS_FLOW_OK;
err:
    return VS_FLOW_ERROR;
}
示例#4
0
VSFlowReturn 
_configMasterVideoSurface(void * vshandle, void  * config)
{
    VS_FLOW("Fun %s in\n", __FUNCTION__);
    DestinationFmt * des = (DestinationFmt *)config;

    VideoSurface * vs;
    SourceFmt src;
    vs = (VideoSurface *)vshandle;

    VS_MESSAGE("reconfig win from "WIN_FMT" to "WIN_FMT"\n", WIN_ARGS(&vs->desfmt.rect), WIN_ARGS(&des->rect));

    VideoDevice * vd=SURFACE2DEVICE(vs);

      
    VS_LOCK(gVSlock);
    vs->desfmt = *des;
    vs->outside = _adjustDestRect(&des->rect, vd);
    vs->adjustdesrect = des->rect;

    if (NEXTSURFACE(vs)){
        _removeVideoSurfaceFromDevice(vd,vs);
        _addVideoSurface2Device(vd,vs);
    }

    _clearVideoSurfaceBackground(vd, vs);
    
    if (_checkOnDevice(vd)){
        _reconfigAllVideoSurfaces(vd);
        _setDeviceConfig(vd);
    }else{
        _initVSIPUTask(vs);
    }
    if (vd->setalpha)
        _setAlpha(vd);

    vs->mainframeupdate = 1;

    if (vs->itask.mode){
        _reconfigSubFrameBuffer(vs);
        vs->mainframeupdate = 0;
        _updateSubFrame(vs);
    }

    
    _refreshOnDevice(vd);

    VS_UNLOCK(gVSlock);
    VS_FLOW("Fun %s out\n", __FUNCTION__);

    return VS_FLOW_OK;

}
void
_initVSIPUTask (VideoSurface * surf)
{
  VideoDevice *vd = SURFACE2DEVICE (surf);
  IPUTaskOne *t1 = &surf->itask;
  Rect *rect = &(surf->srcfmt.croprect.win), *desrect;

  VS_FLOW ("Fun %s in\n", __FUNCTION__);

  desrect = &(surf->adjustdesrect);

  if (surf->outside & VS_INVISIBLE) {
    surf->status = VS_STATUS_INVISIBLE;
    return;
  }
  surf->status = VS_STATUS_VISIBLE;

  INPUT_FORMAT (t1) = surf->srcfmt.fmt;
  INPUT_WIDTH (t1) = surf->srcfmt.croprect.width;
  INPUT_HEIGHT (t1) = surf->srcfmt.croprect.height;

  INPUT_CROP_X (t1) = rect->left;
  INPUT_CROP_Y (t1) = rect->top;
  INPUT_CROP_WIDTH (t1) = RECT_WIDTH (rect);
  INPUT_CROP_HEIGHT (t1) = RECT_HEIGHT (rect);
  if (surf->outside) {

    /* output outside of screen, need crop in input */
    int xx[4] = { 0, 0, 0, 0 };
    Rect *origrect = &surf->desfmt.rect;
    int x_len, y_len;


    if (surf->desfmt.rot <= ROTATION_180_CLOCKWISE) {
      x_len = RECT_WIDTH (rect);
      y_len = RECT_HEIGHT (rect);
    } else {
      y_len = RECT_WIDTH (rect);
      x_len = RECT_HEIGHT (rect);
    }

    if (surf->outside & VS_LEFT_OUT) {
      xx[0] =
          (DEVICE_LEFT_EDGE - origrect->left) * x_len / RECT_WIDTH (origrect);
      xx[0] = ALIGNLEFT8 (xx[0]);
    }
    if (surf->outside & VS_RIGHT_OUT) {
      xx[1] = (origrect->right - vd->resX) * x_len / RECT_WIDTH (origrect);
      xx[1] = ALIGNLEFT8 (xx[1]);
    }
    if (surf->outside & VS_TOP_OUT) {
      xx[2] =
          (DEVICE_TOP_EDGE - origrect->top) * y_len / RECT_HEIGHT (origrect);
      xx[2] = ALIGNLEFT8 (xx[2]);
    }
    if (surf->outside & VS_BOTTOM_OUT) {
      xx[3] = (origrect->bottom - vd->resY) * y_len / RECT_HEIGHT (origrect);
      xx[3] = ALIGNLEFT8 (xx[3]);
    }

    if (surf->desfmt.rot <= ROTATION_180_CLOCKWISE) {
      INPUT_CROP_WIDTH (t1) -= (xx[0] + xx[1]);
      INPUT_CROP_HEIGHT (t1) -= (xx[2] + xx[3]);
    } else {
      INPUT_CROP_WIDTH (t1) -= (xx[2] + xx[3]);
      INPUT_CROP_HEIGHT (t1) -= (xx[0] + xx[1]);
    }

    INPUT_CROP_X (t1) += xx[g_vstable[surf->desfmt.rot][0]];
    INPUT_CROP_Y (t1) += xx[g_vstable[surf->desfmt.rot][1]];



  }
  OUTPUT_FORMAT (t1) = vd->fmt;
  OUTPUT_WIDTH (t1) = vd->disp.right - vd->disp.left;
  OUTPUT_HEIGHT (t1) = vd->disp.bottom - vd->disp.top;
  OUTPUT_CROP_X (t1) = desrect->left - vd->disp.left;
  OUTPUT_CROP_Y (t1) = desrect->top - vd->disp.top;
  OUTPUT_CROP_WIDTH (t1) = desrect->right - desrect->left;
  OUTPUT_CROP_HEIGHT (t1) = desrect->bottom - desrect->top;
  OUTPUT_ROTATION (t1) = surf->desfmt.rot;
  if ((INPUT_CROP_WIDTH (t1) < 16) || (INPUT_CROP_HEIGHT (t1) < 16)
      || (OUTPUT_CROP_WIDTH (t1) < 16) || (OUTPUT_CROP_HEIGHT (t1) < 16)) {
    surf->status = VS_STATUS_INVISIBLE;
  }


}
示例#6
0
void
_initVSIPUTask(VideoSurface * surf)
{
    VS_FLOW("Fun %s in\n", __FUNCTION__);

    VideoDevice * vd = SURFACE2DEVICE(surf);
    ipu_lib_input_param_t * input = &surf->itask.input;

    Rect * rect = &(surf->srcfmt.croprect.win), *desrect;
    
    desrect = &(surf->adjustdesrect);
   
    input->fmt = surf->srcfmt.fmt;
    input->width = surf->srcfmt.croprect.width;
    input->height = surf->srcfmt.croprect.height;

    if (surf->outside==0){
        input->input_crop_win.pos.x = rect->left;
        input->input_crop_win.pos.y = rect->top;
        input->input_crop_win.win_w = RECT_WIDTH(rect);
        input->input_crop_win.win_h = RECT_HEIGHT(rect);
    }else{
        /* output outside of screen, need crop in input */
        int xl=0, xr=0, xt=0, xb=0;
        Rect * origrect = &surf->desfmt.rect;
        if (surf->outside&VS_LEFT_OUT){
            xl = (DEVICE_LEFT_EDGE-origrect->left)*RECT_WIDTH(rect)/RECT_WIDTH(origrect);
            ALIGNLEFT8(xl);
        }
        if (surf->outside&VS_RIGHT_OUT){
            xr = (origrect->right-vd->resX)*RECT_WIDTH(rect)/RECT_WIDTH(origrect);
            ALIGNLEFT8(xr);
        }
        if (surf->outside&VS_TOP_OUT){
            xt = (DEVICE_TOP_EDGE-origrect->top)*RECT_HEIGHT(rect)/RECT_HEIGHT(origrect);
            ALIGNLEFT8(xt);
        }
        if (surf->outside&VS_BOTTOM_OUT){
            xb = (origrect->bottom-vd->resY)*RECT_HEIGHT(rect)/RECT_HEIGHT(origrect);
            ALIGNLEFT8(xb);
        }
        
        input->input_crop_win.pos.x = rect->left+xl;
        input->input_crop_win.pos.y = rect->top+xt;
        input->input_crop_win.win_w = RECT_WIDTH(rect)-xl-xr;
        input->input_crop_win.win_h = RECT_HEIGHT(rect)-xt-xb;
        
    }

    input->user_def_paddr[0] = input->user_def_paddr[1] = 0;
    
    ipu_lib_output_param_t * output = &surf->itask.output;
    
    output->fmt = vd->fmt;
    output->width = vd->disp.right-vd->disp.left;
    output->height = vd->disp.bottom-vd->disp.top;
    output->output_win.pos.x = desrect->left-vd->disp.left;
    output->output_win.pos.y = desrect->top-vd->disp.top;
    output->output_win.win_w = desrect->right-desrect->left;
    output->output_win.win_h = desrect->bottom-desrect->top;
    output->user_def_paddr[0] = output->user_def_paddr[1] = 0;
    output->rot = surf->desfmt.rot;

}