VSFlowReturn
_configDeinterlace (void *vshandle, void *config)
{
  VS_FLOW ("Fun %s in\n", __FUNCTION__);

  VideoSurface *vs;
  vs = (VideoSurface *) vshandle;
  int *mode = (int *) config;

  VS_LOCK (gVSlock);

  VS_MESSAGE ("set deinterlace mode %d\n", *mode);

  if (*mode) {
    INPUT_ENABLE_DEINTERLACE (&vs->itask);
  } else {
    INPUT_DISABLE_DEINTERLACE (&vs->itask);
  }

  INPUT_DEINTERLACE_MODE (&vs->itask) = *mode;

  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);
}
Esempio n. 3
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
_getVideoDeviceInfo (VideoDevice * vd)
{
  int fd;
  struct fb_var_screeninfo fb_var;

  if ((vd->fbidx != vd->main_fbidx) || (vd->mode_num == 0)) {
    fd = open (gFBDescs[vd->main_fbidx].devname, O_RDWR, 0);

    if (fd > 0) {

      VS_IOCTL (fd, FBIOGET_VSCREENINFO, error, &fb_var);
      vd->resX = ALIGNLEFT8(fb_var.xres);
      vd->resY = ALIGNLEFT8(fb_var.yres);
      VS_MESSAGE ("MAX resolution %dx%d\n", fb_var.xres, fb_var.yres);
    error:
      close (fd);
    }
  }
}
/*=============================================================================
FUNCTION:           createVideoSurface

DESCRIPTION:        This function create a video surface.
==============================================================================*/
void *
createVideoSurface (int devid, int mode_idx, SourceFmt * src,
    DestinationFmt * des)
{
  VS_FLOW ("Fun %s in\n", __FUNCTION__);

  VideoSurfacesControl *vc;
  VideoSurface *vs = NULL;
  VideoDevice *vd;
  int i;

  if (_checkSource (src)) {
    VS_ERROR ("source fmt error\n");
    goto err;
  }

  if ((des == NULL) || (src == NULL)) {
    VS_ERROR ("%s: parameters error!\n", __FUNCTION__);
    goto err;
  }

  if (gVSctl == NULL) {
    gVSlock = _getAndLockVSLock (VS_IPC_CREATE);
    if (gVSlock == NULL) {
      VS_ERROR ("Can not create/open ipc semphone!\n");
      goto err;
    }

    gVSctl = _getVSControl (VS_IPC_CREATE);
    if (gVSctl == NULL) {
      VS_ERROR ("Can not create/open ipc sharememory!\n");
      VS_UNLOCK (gVSlock);
      goto err;
    }
  } else {

    VS_LOCK (gVSlock);
  }

  vc = gVSctl;

  if ((vd = _getDevicebyDevID (devid)) == NULL) {
    VS_ERROR ("Can not find dev id %d!\n", devid);
    VS_UNLOCK (gVSlock);
    goto err;
  }

  if (vd->cnt >= vd->vsmax) {
    VS_UNLOCK (gVSlock);
    VS_ERROR ("%s: max surfaces on device support on device%d exceeded!\n",
        __FUNCTION__, devid);
    goto err;
  }

  for (i = 0; i < VS_MAX; i++) {
    if (vc->surfaces[i].status == VS_STATUS_IDLE) {
      break;
    }
  }

  if (i == VS_MAX) {
    VS_UNLOCK (gVSlock);
    VS_ERROR ("%s: max surface support exceeded!\n", __FUNCTION__);
    goto err;
  }

  vs = &vc->surfaces[i];
  vs->status = VS_STATUS_VISIBLE;
  vs->vd_id = vd->id;
  vs->srcfmt = *src;
  vs->desfmt = *des;

  vs->itask.mode = 0;
  vs->mainframeupdate = 1;

  memset (&vs->itask, 0, sizeof (IPUTaskOne));

  if (vd->init == 0) {
    if (_initVideoDevice (vd, mode_idx)) {
      VS_UNLOCK (gVSlock);
      VS_ERROR ("%s: error config!\n", __FUNCTION__);
      goto err;
    }

  }

  vs->outside = _adjustDestRect (&des->rect, vd);
  vs->adjustdesrect = des->rect;

  VS_MESSAGE ("VS%d created. in fmt[" FOURCC_FMT "] win" WIN_FMT " out win"
      WIN_FMT "\n", vs->id - 1, FOURCC_ARGS (src->fmt),
      WIN_ARGS (&src->croprect.win), WIN_ARGS (&vs->desfmt.rect));

  vs->next = gvslocal;
  gvslocal = vs;

  vd->cnt++;

  if (vd->cnt == 1) {
    _openDevice (vd);

  }
  _addVideoSurface2Device (vd, vs);

  if (_checkOnDevice (vd)) {
    _reconfigAllVideoSurfaces (vd);
    _setDeviceConfig (vd);
  }

  vd->init = 1;
  _initVSIPUTask (vs);

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

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

  return (void *) vs;
err:
  if (vs) {
    vs->status = VS_STATUS_IDLE;
  }
  return NULL;
}