X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=rpikern;a=blobdiff_plain;f=src%2Fmain.c;h=8f502699b4d3d1c609b8b3b5b28ad3efcdecd45d;hp=47e23b6ac347bd01e06f565951bae3f6f670b033;hb=23900e0baeb014e7e0b7e8e55942771da1523050;hpb=4cdb0feb633bc6181644704cea8f18368b5bcfd1 diff --git a/src/main.c b/src/main.c index 47e23b6..8f50269 100644 --- a/src/main.c +++ b/src/main.c @@ -38,23 +38,59 @@ #define PROP_CODE_REQ 0 #define PROP_RESP_OK 0x80000000 -#define PROP_TAG_END 0 -#define PROP_TAG_BLANKSCR 0x40002 + +#define PROP_TAG_END 0 + +#define PROP_TAG_SET 0x08000 +#define PROP_TAG_TEST 0x04000 +#define PROP_TAG_GET 0 + +#define PROP_TAG_ALLOCBUF 0x40001 +#define PROP_TAG_BLANKSCR 0x40002 +#define PROP_TAG_PHYSRES 0x40003 +#define PROP_TAG_VIRTRES 0x40004 +#define PROP_TAG_DEPTH 0x40005 +#define PROP_TAG_PIXEL_ORDER 0x40006 +#define PROP_TAG_ALPHA_MODE 0x40007 +#define PROP_TAG_PITCH 0x40008 +#define PROP_TAG_VOFFS 0x40009 +#define PROP_TAG_OVERSCAN 0x4000a +#define PROP_TAG_PALETTE 0x4000b +#define PROP_TAG_CUR_INFO 0x00010 +#define PROP_TAG_CUR_STATE 0x00011 + int prop_blankscr(int onoff); +int prop_setvres(int xsz, int ysz); +void *prop_allocbuf(void); uint32_t mb_read(int chan); void mb_write(int chan, uint32_t val); int main(void) { - prop_blankscr(1); + int i; + uint16_t *fb; + + prop_setvres(640, 480); + fb = prop_allocbuf(); + + for(i=0; i<640 * 480; i++) { + *fb++ = (i & 0xff) | ((i & 0xff) << 8); + } return 0; } static uint32_t propbuf[64] __attribute__((aligned(16))); +static int send_prop(uint32_t *buf) +{ + mb_write(MB_CHAN_PROP, (uint32_t)buf >> 4); + mb_read(MB_CHAN_PROP); + return propbuf[1] == PROP_RESP_OK ? 0 : -1; +} + int prop_blankscr(int onoff) { uint32_t *pb = propbuf; @@ -69,10 +105,47 @@ int prop_blankscr(int onoff) *pb++ = 0; /* padding */ propbuf[0] = (char*)pb - (char*)propbuf; - mb_write(MB_CHAN_PROP, (uint32_t)propbuf >> 4); - mb_read(MB_CHAN_PROP); + return send_prop(propbuf); +} - return propbuf[1] == PROP_RESP_OK ? 0 : -1; +int prop_setvres(int xsz, int ysz) +{ + uint32_t *pb = propbuf; + + *pb++ = 0; + *pb++ = 0; + *pb++ = PROP_TAG_VIRTRES | PROP_TAG_SET; + *pb++ = 8; /* data size */ + *pb++ = PROP_CODE_REQ; + *pb++ = xsz; + *pb++ = ysz; + *pb++ = PROP_TAG_END; + propbuf[0] = (char*)pb - (char*)propbuf; + + return send_prop(propbuf); +} + +void *prop_allocbuf(void) +{ + uint32_t *pb = propbuf; + uint32_t *data; + + *pb++ = 0; + *pb++ = 0; + *pb++ = PROP_TAG_ALLOCBUF; + *pb++ = 8; /* data size */ + *pb++ = PROP_CODE_REQ; + data = pb; + *pb++ = 16; /* alignment */ + *pb++ = 0; + *pb++ = PROP_TAG_END; + propbuf[0] = (char*)pb - (char*)propbuf; + + if(send_prop(propbuf) == -1) { + return 0; + } + + return (void*)bus2phys(*data); } uint32_t mb_read(int chan)