shithub: hantro9

ref: 1e34aeb5776d6061fc6bd206466a0d87947c5de4
dir: /hantest.c/

View raw version
#include <u.h>
#include <libc.h>

static u32int *g1, *g2;

void
main(int argc, char **argv)
{
	ARGBEGIN{
	}ARGEND

	if((g1 = segattach(0, "vpu_hantro_g1", 0, 0x200)) == (void*)-1)
		sysfatal("no G1");
	if((g2 = segattach(0, "vpu_hantro_g2", 0, 0x40c+4)) == (void*)-1)
		sysfatal("no G2");

	print("bus: ");
	switch((g1[50]>>16)&7){
	case 1: print("ahb master, ahb slave"); break;
	case 2: print("ocp master, ocp slave"); break;
	case 3: print("axi master, axi slave"); break;
	case 4: print("axi master, apb slave"); break;
	case 5: print("axi master, ahb slave"); break;
	default: print("ERROR\n"); break;
	}
	char *buswidth[] = {"ERROR", "32", "64", "128"};
	print(", %s bit\n", buswidth[(g1[50]>>12)&3]);

	print("cores: %d\n", 1+(g1[54]>>7)&7);

	print("g1: h.264=%d vp8=%d max_owidth=%d\n",
		!!(g1[57]&(1<<31)),
		(g1[54]&(1<<23)) && (g1[57]&(1<<20)),
		((g1[54]>>14)&3)<<11 | g1[50]&((1<<11)-1)
	);

	print("g2: hevc=%d (main%d) vp9=%d (profile %d) downscale=%d max_owidth=%d max_oheight=%d\n",
		!!(g2[23]&(1<<0)),
		8 + 2*((g2[23]>>8)&0xf),
		!!(g2[23]&(1<<1)),
		0 + 2*((g2[23]>>12)&0xf),
		!!(g2[23]&(1<<3)),
		((g2[54]>>14)&3)<<11 | g2[50]&((1<<11)-1),
		g2[56]&((1<<13)-1)
	);

	print("pp: exists=%d dithering=%d deinterlace=%d upscale=%d downscale=%d max_owidth=%d\n",
		!!(g1[99]&(1<<31)),
		!!(g1[100]&(1<<28)),
		(g1[100]&(1<<25)) && (g1[99]&(1<<30)),
		!!((g1[100]>>26)&3),
		((g1[100]>>26)&3) == 3,
		g1[100]&((1<<13)-1)
	);

	segdetach(g1);
	segdetach(g2);

	exits(nil);
}