Ejemplo n.º 1
0
/* like fd_device_new() but creates it's own private dup() of the fd
 * which is close()d when the device is finalized.
 */
struct fd_device * fd_device_new_dup(int fd)
{
	struct fd_device *dev = fd_device_new(dup(fd));
	if (dev)
		dev->closefd = 1;
	return dev;
}
Ejemplo n.º 2
0
static void init(void)
{
	int fd = drmOpen("kgsl", NULL);

	drmSetMaster(fd);

	dev = fd_device_new(fd);
	pipe = fd_pipe_new(dev, FD_PIPE_2D);

	context_bos[0] = fd_bo_new(dev, 0x1000, DRM_FREEDRENO_GEM_TYPE_KMEM);
	context_bos[1] = fd_bo_new(dev, 0x9000, DRM_FREEDRENO_GEM_TYPE_KMEM);
	context_bos[2] = fd_bo_new(dev, 0x81000, DRM_FREEDRENO_GEM_TYPE_KMEM);

	next_ring();

	ring_pre(ring);

	BEGIN_RING(8);
	OUT_RING  (ring, REGM(VGV1_DIRTYBASE, 3));
	OUT_RELOC (ring, context_bos[0]); /* VGV1_DIRTYBASE */
	OUT_RELOC (ring, context_bos[1]); /* VGV1_CBASE1 */
	OUT_RELOC (ring, context_bos[2]); /* VGV1_UBASE2 */
	OUT_RING  (ring, 0x11000000);
	OUT_RING  (ring, 0x10fff000);
	OUT_RING  (ring, 0x10ffffff);
	OUT_RING  (ring, 0x0d000404);
	END_RING  ();
}
Ejemplo n.º 3
0
/* like fd_device_new() but creates it's own private dup() of the fd
 * which is close()d when the device is finalized.
 */
struct fd_device * fd_device_new_dup(int fd)
{
	int dup_fd = dup(fd);
	struct fd_device *dev = fd_device_new(dup_fd);
	if (dev)
		dev->closefd = 1;
	else
		close(dup_fd);
	return dev;
}
Ejemplo n.º 4
0
int main(int argc, char *argv[])
{
	struct fd_device *dev;
	struct fd_pipe *pipe;
	struct fd_ringbuffer *ring;
	struct fd_bo *bo;
	uint32_t i = 0;
	uint32_t *ptr;
	int fd, ret;

	fd = drmOpen("msm", NULL);
	if (fd < 0) {
		printf("failed to initialize DRM\n");
		return fd;
	}

	dev = fd_device_new(fd);
	if (!dev) {
		printf("failed to initialize freedreno device\n");
		return -1;
	}

	pipe = fd_pipe_new(dev, FD_PIPE_3D);
	if (!pipe) {
		printf("failed to initialize freedreno pipe\n");
		return -1;
	}

	ring = fd_ringbuffer_new(pipe, 4096);
	if (!ring) {
		printf("failed to initialize freedreno ring\n");
		return -1;
	}

	bo = fd_bo_new(dev, 4096, 0);

#define BASE REG_A3XX_GRAS_CL_VPORT_XOFFSET
#define SIZE 6

	OUT_PKT0(ring, REG_AXXX_CP_SCRATCH_REG4, 1);
	OUT_RING(ring, 0x123);

	OUT_PKT0(ring, BASE, SIZE);
	for (i = 0; i < SIZE; i++)
		OUT_RING(ring, i);

	/* this adds the value of CP_SCRATCH_REG4 to 0x111 and writes
	 * to REG_BASE+2
	 */
	OUT_PKT3(ring, CP_SET_CONSTANT, 3);
	OUT_RING(ring, 0x80000000 | CP_REG(BASE + 2));
	OUT_RING(ring, REG_AXXX_CP_SCRATCH_REG4);
	OUT_RING(ring, 0x111);

	/* read back all the regs: */
	for (i = 0; i < SIZE; i++) {
		OUT_PKT3(ring, CP_REG_TO_MEM, 2);
		OUT_RING(ring, BASE + i);
		OUT_RELOCW(ring, bo, i * 4, 0, 0);
	}

	fd_ringbuffer_flush(ring);

	/* and read back the values: */
	fd_bo_cpu_prep(bo, pipe, DRM_FREEDRENO_PREP_READ);
	ptr = fd_bo_map(bo);
	for (i = 0; i < SIZE; i++) {
		printf("%02x: %08x\n", i, ptr[i]);
	}
	fd_bo_cpu_fini(bo);

	return 0;
}