示例#1
0
static int adf_interface_init(struct adf_pdata *pdata)
{
    struct adf_interface_data intf_data;
    int ret = 0;
    int err;

    err = adf_get_interface_data(pdata->intf_fd, &intf_data);
    if (err < 0)
        return err;

    err = adf_surface_init(pdata, &intf_data.current_mode, &pdata->surfaces[0]);
    if (err < 0) {
        fprintf(stderr, "allocating surface 0 failed: %s\n", strerror(-err));
        ret = err;
        goto done;
    }

    err = adf_surface_init(pdata, &intf_data.current_mode,
            &pdata->surfaces[1]);
    if (err < 0) {
        fprintf(stderr, "allocating surface 1 failed: %s\n", strerror(-err));
        memset(&pdata->surfaces[1], 0, sizeof(pdata->surfaces[1]));
        pdata->n_surfaces = 1;
    } else {
        pdata->n_surfaces = 2;
    }

done:
    adf_free_interface_data(&intf_data);
    return ret;
}
示例#2
0
int MinuiBackendAdf::InterfaceInit() {
  adf_interface_data intf_data;
  int err = adf_get_interface_data(intf_fd, &intf_data);
  if (err < 0) return err;

  int ret = 0;
  err = SurfaceInit(&intf_data.current_mode, &surfaces[0]);
  if (err < 0) {
    fprintf(stderr, "allocating surface 0 failed: %s\n", strerror(-err));
    ret = err;
    goto done;
  }

  err = SurfaceInit(&intf_data.current_mode, &surfaces[1]);
  if (err < 0) {
    fprintf(stderr, "allocating surface 1 failed: %s\n", strerror(-err));
    surfaces[1] = {};
    n_surfaces = 1;
  } else {
    n_surfaces = 2;
  }

done:
  adf_free_interface_data(&intf_data);
  return ret;
}
static int adf_interface_init(adf_pdata *pdata)
{
    adf_interface_data intf_data;
    int ret = 0;
    int err;
    unsigned char* framebuffer_data = nullptr;

    err = adf_get_interface_data(pdata->intf_fd, &intf_data);
    if (err < 0) {
        return err;
    }

    err = adf_surface_init(pdata, &intf_data.current_mode, &pdata->surfaces[0]);
    if (err < 0) {
        fprintf(stderr, "allocating surface 0 failed: %s\n", strerror(-err));
        ret = err;
        goto done;
    }

    /* Allocate a single buffer for drawing. graphics.cpp will draw to
     * this buffer which will later be copied to the mmapped adf buffer.
     * Using a regular memory buffer improves performance by about 10x. */
    framebuffer_data = (unsigned char*) calloc(pdata->surfaces[0].pitch * pdata->surfaces[0].base.height, 1);
    if (framebuffer_data == nullptr) {
        printf("failed to calloc surface data\n");
        close(pdata->surfaces[0].fd);
        munmap(pdata->surfaces[0].adf_data, pdata->surfaces[0].pitch * pdata->surfaces[0].base.height);
        ret = -1;
        goto done;
    }
    pdata->surfaces[0].base.data = framebuffer_data;

    err = adf_surface_init(pdata, &intf_data.current_mode,
            &pdata->surfaces[1]);
    if (err < 0) {
        fprintf(stderr, "allocating surface 1 failed: %s\n", strerror(-err));
        memset(&pdata->surfaces[1], 0, sizeof(pdata->surfaces[1]));
        pdata->n_surfaces = 1;
    } else {
        pdata->n_surfaces = 2;
        pdata->surfaces[1].base.data = framebuffer_data;
    }

done:
    adf_free_interface_data(&intf_data);
    return ret;
}
 void getInterfaceData(adf_interface_data &data) {
      int err = adf_get_interface_data(intf, &data);
      ASSERT_GE(err, 0) << "getting ADF interface data failed: " <<
              strerror(-err);
 }