int host1x_gr3d_init(struct host1x *host1x, struct host1x_gr3d *gr3d) { int err; gr3d->commands = host1x_bo_create(host1x, 32 * 4096, NVHOST_BO_FLAG_COMMAND_BUFFER); if (!gr3d->commands) return -ENOMEM; err = HOST1X_BO_MMAP(gr3d->commands, NULL); if (err < 0) { host1x_bo_free(gr3d->commands); return err; } gr3d->attributes = host1x_bo_create(host1x, 12 * 4096, NVHOST_BO_FLAG_ATTRIBUTES); if (!gr3d->attributes) { host1x_bo_free(gr3d->commands); return -ENOMEM; } err = HOST1X_BO_MMAP(gr3d->attributes, NULL); if (err < 0) { host1x_bo_free(gr3d->attributes); host1x_bo_free(gr3d->commands); return err; } if (HOST1X_GR3D_TEST) { err = host1x_gr3d_test(gr3d); if (err < 0) { host1x_error("host1x_gr3d_test() failed: %d\n", err); host1x_bo_free(gr3d->attributes); host1x_bo_free(gr3d->commands); return err; } } err = host1x_gr3d_reset(gr3d); if (err < 0) { host1x_bo_free(gr3d->attributes); host1x_bo_free(gr3d->commands); return err; } return 0; }
int host1x_gr3d_init(struct host1x *host1x, struct host1x_gr3d *gr3d) { int err; gr3d->commands = host1x_bo_create(host1x, 32 * 4096, 2); if (!gr3d->commands) return -ENOMEM; err = host1x_bo_mmap(gr3d->commands, NULL); if (err < 0) { host1x_bo_free(gr3d->commands); return err; } gr3d->attributes = host1x_bo_create(host1x, 12 * 4096, 4); if (!gr3d->attributes) { host1x_bo_free(gr3d->commands); return -ENOMEM; } err = host1x_bo_mmap(gr3d->attributes, NULL); if (err < 0) { host1x_bo_free(gr3d->attributes); host1x_bo_free(gr3d->commands); return err; } if (HOST1X_GR3D_TEST) { err = host1x_gr3d_test(gr3d); if (err < 0) { fprintf(stderr, "host1x_gr3d_test() failed: %d\n", err); host1x_bo_free(gr3d->attributes); host1x_bo_free(gr3d->commands); return err; } } err = host1x_gr3d_reset(gr3d); if (err < 0) { host1x_bo_free(gr3d->attributes); host1x_bo_free(gr3d->commands); return err; } return 0; }
int host1x_gr2d_init(struct host1x *host1x, struct host1x_gr2d *gr2d) { int err; gr2d->commands = host1x_bo_create(host1x, 8 * 4096, 2); if (!gr2d->commands) return -ENOMEM; err = host1x_bo_mmap(gr2d->commands); if (err < 0) return err; gr2d->scratch = host1x_bo_create(host1x, 64, 3); if (!gr2d->scratch) { host1x_bo_free(gr2d->commands); return -ENOMEM; } if (HOST1X_GR2D_TEST) { err = host1x_gr2d_test(gr2d); if (err < 0) { fprintf(stderr, "host1x_gr2d_test() failed: %d\n", err); return err; } } err = host1x_gr2d_reset(gr2d); if (err < 0) { host1x_bo_free(gr2d->scratch); host1x_bo_free(gr2d->commands); return err; } return 0; }
struct host1x_bo *grate_bo_create_and_map(struct grate *grate, unsigned long flags, size_t size, void **map) { struct host1x_bo *bo; int err; bo = HOST1X_BO_CREATE(grate->host1x, size, flags); if (!bo) return NULL; if (!map) return bo; err = HOST1X_BO_MMAP(bo, map); if (err != 0) { host1x_bo_free(bo); return NULL; } return bo; }
void host1x_gr3d_exit(struct host1x_gr3d *gr3d) { host1x_bo_free(gr3d->attributes); host1x_bo_free(gr3d->commands); }
void host1x_gr2d_exit(struct host1x_gr2d *gr2d) { host1x_bo_free(gr2d->commands); host1x_bo_free(gr2d->scratch); }