aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhnaradla <hanumantha.naradla@linaro.org>2014-07-22 17:55:57 +0530
committerhnaradla <hanumantha.naradla@linaro.org>2014-07-22 17:55:57 +0530
commit389f9f18903f96b41eb5df6f10ca27879cd07881 (patch)
tree1d2c908b8be3ab31e24e53a770f65bc2ac49fd78
parentddb952c9721f90579476d96e91fe06f29ab31082 (diff)
downloadvpb-master.tar.gz
vpb: add video playback test.HEADvpb_addmaster
- decodes via h/w accelarated decoder. - renders via mdp4. - add yuv tiled frames conversion to rgb for 156x128 frames. - limitations: works only for 156x128 frames.
-rwxr-xr-xbuffers.c24
-rwxr-xr-xbuffers.h3
-rwxr-xr-xdecoder_driver_test.c194
-rwxr-xr-xdecoder_driver_test.h3
-rwxr-xr-xmsmdumb.c32
-rwxr-xr-xmsmmodetest.c183
6 files changed, 359 insertions, 80 deletions
diff --git a/buffers.c b/buffers.c
index 59be7b6..5f6ecab 100755
--- a/buffers.c
+++ b/buffers.c
@@ -1059,7 +1059,7 @@ ion_allocate_buffer_msm(unsigned int width, unsigned int height)
*/
static struct msm_bo *
-allocate_buffer(struct msm_driver *msm, unsigned int width, unsigned int height,
+allocate_buffer(int prime_handle, struct msm_driver *msm, unsigned int width, unsigned int height,
unsigned int *stride)
{
struct msm_bo *bo;
@@ -1070,12 +1070,9 @@ allocate_buffer(struct msm_driver *msm, unsigned int width, unsigned int height,
MSM_TERMINATE_PROP_LIST
};
int ret;
- int buf_fd = 0;
bo_attribs[1] = width;
bo_attribs[3] = height;
-
- buf_fd = ion_allocate_buffer_msm(width, height);
- ret = msm_bo_create(msm, bo_attribs, &bo, buf_fd);
+ ret = msm_bo_create(msm, bo_attribs, &bo, prime_handle);
if (ret) {
fprintf(stderr, "failed to alloc buffer: %s\n",
strerror(-ret));
@@ -1094,7 +1091,8 @@ allocate_buffer(struct msm_driver *msm, unsigned int width, unsigned int height,
}
struct msm_bo *
-create_test_buffer(struct msm_driver *msm, unsigned int format,
+create_test_buffer(int prime_handle, void * pmapaddress,
+ struct msm_driver *msm, unsigned int format,
unsigned int width, unsigned int height,
unsigned int handles[4], unsigned int pitches[4],
unsigned int offsets[4], enum fill_pattern pattern)
@@ -1121,18 +1119,20 @@ create_test_buffer(struct msm_driver *msm, unsigned int format,
break;
}
- bo = allocate_buffer(msm, width, virtual_height, &pitches[0]);
+ bo = allocate_buffer(prime_handle, msm, width, virtual_height, &pitches[0]);
if (!bo)
return NULL;
- ret = msm_bo_map(bo, &virtual);
+ /*ret = msm_bo_map(bo, &virtual);
if (ret) {
fprintf(stderr, "failed to map buffer: %s\n",
strerror(-ret));
msm_bo_destroy(&bo);
return NULL;
- }
- fprintf(stderr, "msm_bo_map virtual pointer: %p \n", virtual);
+ }*/
+ virtual = pmapaddress;
+
+ fprintf(stderr, "msm_bo_map virtual pointer: %p \n", virtual);
/* just testing a limited # of formats to test single
* and multi-planar path.. would be nice to add more..
*/
@@ -1224,8 +1224,8 @@ create_test_buffer(struct msm_driver *msm, unsigned int format,
break;
}
- fill_pattern(format, pattern, planes, width, height, pitches[0]);
- msm_bo_unmap(bo);
+ //fill_pattern(format, pattern, planes, width, height, pitches[0]);
+ //msm_bo_unmap(bo);
return bo;
}
diff --git a/buffers.h b/buffers.h
index 81c6da6..57897a9 100755
--- a/buffers.h
+++ b/buffers.h
@@ -36,7 +36,8 @@ enum fill_pattern {
PATTERN_SMPTE = 2,
};
-struct msm_bo *create_test_buffer(struct msm_driver *msm, unsigned int format,
+struct msm_bo *create_test_buffer(int prime_handle, void * pmapaddress,
+ struct msm_driver *msm, unsigned int format,
unsigned int width, unsigned int height,
unsigned int handles[4], unsigned int pitches[4],
unsigned int offsets[4], enum fill_pattern pattern);
diff --git a/decoder_driver_test.c b/decoder_driver_test.c
index 30d16a7..7b91ee0 100755
--- a/decoder_driver_test.c
+++ b/decoder_driver_test.c
@@ -195,6 +195,72 @@ int main (int argc, char **argv)
return error;
}
+/*
+ * ion_allocate_fb_buffer - Allocate Ion Buffer to be used by drm for display
+ * @width: Width in pixels
+ * @height: Height in pixels
+ *
+ * Returns the file descriptor that can be passed around for sharing
+ */
+static int
+ion_allocate_fb_buffer(unsigned int width, unsigned int height, int data_w)
+{
+ int ion_devicefd = 0;
+ struct ion_fd_data fd_data;
+ struct ion_allocation_data alloc_data;
+ int rc = -1;
+ int pitch = 0;
+ int size = 0;
+ int bpp = (data_w*8); // Inline with BO_TYPE s that are 32bpp formats
+
+ /* Open ion drive for memory allocations */
+ ion_devicefd = open ("/dev/ion", O_RDONLY);
+
+ if (ion_devicefd < 0) {
+ fprintf(stderr, "ERROR: ION Device open() Failed --------\n");
+ return -1;
+ }
+#define ALIGN(v,a) (((v) + (a) - 1) & ~((a) - 1))
+ pitch = ((bpp + 7)/8) * (ALIGN(width, 32));
+ size = ALIGN((pitch * height) + 0x1000, 0x1000);
+
+ alloc_data.len = size;
+ alloc_data.flags = ION_HEAP_TYPE_DMA_MASK;
+ alloc_data.align = 0x1000; // 2048;
+ alloc_data.heap_mask = 0x2000000;
+
+ rc = ioctl(ion_devicefd, ION_IOC_ALLOC, &alloc_data);
+ if (rc || !alloc_data.handle) {
+ fprintf(stderr, "ION ALLOC failed, ion_devicefd = %d, rc = %d\n"
+ "handle = 0x%p", ion_devicefd,
+ rc, alloc_data.handle);
+ alloc_data.handle = NULL;
+ return -1;
+ }
+
+ fd_data.handle = alloc_data.handle;
+
+ rc = ioctl(ion_devicefd,ION_IOC_SHARE,&fd_data);
+ if (rc) {
+ fprintf(stderr, "ON_IOC_SHARE failed, fd = %d, handle = 0x%p\n",
+ ion_devicefd, fd_data.handle);
+ fd_data.fd = -1;
+ return -1;
+ }
+ fprintf(stderr, "ION_IOC_SHARE success, fd = %d\n", fd_data.fd);
+ return fd_data.fd;
+}
+
+static int
+ion_free_fb_buffer(int fd, void * pmap)
+{
+ if (fd != -1)
+ {
+ munmap (pmap,(1920*1080*3)+0x1000);
+ close (fd);
+ }
+}
+
int init_decoder ( struct video_decoder_context *init_decode )
{
struct vdec_ioctl_msg ioctl_msg = {NULL,NULL};
@@ -221,6 +287,18 @@ int init_decoder ( struct video_decoder_context *init_decode )
return -1;
}
+ init_decode->ppmodetest = NULL;
+ init_decode->ion_fd_fb = ion_allocate_fb_buffer(1920, 1080, 3);
+
+ init_decode->pfb_buffer = (unsigned char *)mmap(NULL,
+ (1920*1080*3)+0x1000,
+ PROT_READ|PROT_WRITE, MAP_SHARED, init_decode->ion_fd_fb, 0);
+ if (init_decode->pfb_buffer == MAP_FAILED)
+ {
+ init_decode->ion_fd_fb = -1;
+ DEBUG_PRINT("\n Map Failed to allocate pfb_buffer");
+ }
+ DEBUG_PRINT("\n pfb_buffer %p", init_decode->pfb_buffer);
/*Initialize Decoder with codec type and resolution*/
ioctl_msg.in = &init_decode->decoder_format;
@@ -777,6 +855,11 @@ int deinit_decoder (struct video_decoder_context *init_decode)
return -1;
}
+ main_modetest_destroy(init_decode->ppmodetest);
+ init_decode->ppmodetest = NULL;
+ ion_free_fb_buffer(init_decode->ion_fd_fb, init_decode->pfb_buffer);
+ init_decode->pfb_buffer = NULL;
+
if (init_decode->queue_context.ptr_cmdq)
{
free (init_decode->queue_context.ptr_cmdq);
@@ -796,6 +879,64 @@ int deinit_decoder (struct video_decoder_context *init_decode)
return 1;
}
+#define TILED_BLOCK_W 64
+#define TILED_BLOCK_H 32
+#define TILED_BLOCK_AREA (TILED_BLOCK_W*TILED_BLOCK_H)
+static char bound(int val)
+{
+ if (val < 0)
+ {
+ return 0;
+ }
+ else if (val > 255)
+ {
+ return 255;
+ }
+ return (char) val;
+}
+
+static void row_tiled2rgb(unsigned char *luma, unsigned char *chroma, unsigned char *dest, int color_w)
+{
+ unsigned char i = 0;
+ unsigned char a = 0;
+ unsigned char b = 0;
+ unsigned char c = 0;
+
+ for (i = 0; i<TILED_BLOCK_W; i++)
+ {
+ a = luma[i] - 16; // Y - 16
+ b = chroma[i & ~1] - 128; // Cb - 128
+ c = chroma[(i & ~1) + 1] - 128; // Cr - 128
+ // Force No Chroma
+ b=c=0;
+ dest[(i*color_w)] = bound(( 298 * a + 409 * c + 128) >> 8);
+ dest[((i*color_w)+1)] = bound(( 298 * a - 100 * b - 208 * c + 128) >> 8);
+ dest[((i*color_w)+2)] = bound(( 298 * a + 516 * b + 128) >> 8);
+ }
+}
+
+static int fill_block_tiled2rgb(unsigned char *src_luma, unsigned char *src_chroma, unsigned char *dest_rgb, int color_w, int frame_w)
+{
+ int x = 0;
+ int y = 0;
+ unsigned char *luma;
+ unsigned char *chroma;
+ unsigned char *dest;
+
+ for (x=0; x<TILED_BLOCK_H; x++) {
+ luma = &src_luma[x*TILED_BLOCK_W];
+ y = x%2;
+ if(y == 0){
+ chroma = &src_chroma[(x)*(TILED_BLOCK_W/2)];
+ }
+
+ dest = &dest_rgb[x*color_w*frame_w];
+
+ row_tiled2rgb(luma, chroma, dest, color_w);
+ }
+ return 0;
+}
+
static void* video_thread (void *context)
{
struct video_decoder_context *decode_context = NULL;
@@ -941,7 +1082,58 @@ static void* video_thread (void *context)
DEBUG_PRINT("\n Decoder frame failed");
return NULL;
}
-
+ // Make calls to modetest
+ {
+ int i, j, k;
+ unsigned char *src;
+ unsigned char *dest;
+ unsigned char *luma;
+ unsigned char *chroma;
+ unsigned char *pfb_buffer;
+ int p, q, num;
+ // todo: add for more than 70 tiles
+ int ap[10][7] =
+ {
+ 0, 2, 8, 10, 30, 30, 30, 1, 3, 9, 11, 30, 30, 30, 6, 4, 14, 12, 30, 30,
+ 30, 7, 5, 15, 13, 30, 30, 30, 29, 30, 31, 32, 33, 34,35, 36, 37, 38,
+ 39, 40, 41, 42, 43, 44, 44, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
+ 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
+ };
+
+ src = tempbuffer->bufferaddr;
+ for (k=0; k<4; k++) {
+ for (i=0; i<4; i++) {
+ num = ap[k][i];
+ DEBUG_PRINT("\n num %d", num);
+ luma = &src[num*TILED_BLOCK_AREA];
+ chroma = &src[(32*4*64*4)+(num*(TILED_BLOCK_AREA/2))];
+ pfb_buffer = (char *)decode_context->pfb_buffer;
+ dest = &pfb_buffer[(640*320*10)+(i*32*1920*3)+(k*64*3)];
+
+ fill_block_tiled2rgb(luma, chroma, dest, 3, 1920);
+ }
+ }
+ DEBUG_PRINT("\n make drm calls");
+
+ if (decode_context->ppmodetest == NULL) {
+ {
+ char ** myargv;
+
+ myargv = (char**)malloc(sizeof(char*)*5);
+ myargv[0] = "-v";
+ myargv[1] = "-s";
+ myargv[2] = "9@6:1920x1080-25@RG24";
+ myargv[3] = "-P";
+ myargv[4] = "6:1920x1080+0+0*1@RG24";
+
+ decode_context->ppmodetest = (void *) main_modetest_create(5, myargv);
+ free (myargv);
+ }
+ setmsmmode(decode_context->ppmodetest, decode_context->ion_fd_fb, decode_context->pfb_buffer);
+ }
+ }
+ // delay time between frames
+ usleep(30000);
break;
case VDEC_MSG_RESP_FLUSH_INPUT_DONE:
diff --git a/decoder_driver_test.h b/decoder_driver_test.h
index 252532f..c7690a9 100755
--- a/decoder_driver_test.h
+++ b/decoder_driver_test.h
@@ -57,6 +57,9 @@ struct video_decoder_context
struct vdec_output_frameinfo *ptr_respbuffer;
struct video_queue_context queue_context;
int video_driver_fd;
+ int ion_fd_fb;
+ void * pfb_buffer;
+ void * ppmodetest;
struct vdec_ion *ip_buf_ion_info;
struct vdec_ion *op_buf_ion_info;
diff --git a/msmdumb.c b/msmdumb.c
index ac01227..f9eb50f 100755
--- a/msmdumb.c
+++ b/msmdumb.c
@@ -41,6 +41,8 @@
#include "i915_drm.h"
+#include "decoder_driver_test.h"
+
struct dumb_bo
{
struct msm_bo base;
@@ -97,23 +99,18 @@ dumb_bo_create(struct msm_driver *msm,
memset(&arg, 0, sizeof(arg));
/* All BO_TYPE currently are 32bpp formats */
- arg.bpp = 32;
+ arg.bpp =24;
arg.width = width;
arg.height = height;
- ret = drmPrimeFDToHandle(msm->fd, (uint32_t) buf_fd, &prime_handle);
-
- if (ret) {
- fprintf(stderr, "\n drmPrimeHandleToFD failed with error %d ", ret);
- goto err_free;
- }
+ prime_handle = buf_fd;
- bo->base.handle = (unsigned) prime_handle;
- bo->base.msm = msm;
+ bo->base.handle = (unsigned) prime_handle;
+ bo->base.msm = msm;
#define ALIGN(v,a) (((v) + (a) - 1) & ~((a) - 1))
- bo->base.pitch = ((arg.bpp + 7)/8) * (ALIGN(width, 32));
- bo->base.size = ALIGN(bo->base.pitch * height, 0x1000);
-
+ bo->base.pitch = ((arg.bpp + 7)/8) * (ALIGN(width, 8));
+ bo->base.size = ALIGN(bo->base.pitch * height, 0x1000);
+ fprintf(stderr, "bo->base.pitch = %d bo->base.size = %d\n", bo->base.pitch, bo->base.size);
*out = &bo->base;
return 0;
@@ -153,11 +150,12 @@ dumb_bo_map(struct msm_bo *_bo, void **out)
if (ret)
return ret;
- map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.msm->fd, arg.offset);
- if (map == MAP_FAILED)
- return -errno;
+ //map = mmap(0, bo->base.size, PROT_READ | PROT_WRITE, MAP_SHARED, bo->base.msm->fd, arg.offset);
+ //if (map == MAP_FAILED)
+ // return -errno;
- bo->base.ptr = map;
+ //bo->base.ptr = map;
+ bo->base.ptr = NULL;
bo->map_count++;
*out = bo->base.ptr;
@@ -179,7 +177,7 @@ dumb_bo_destroy(struct msm_bo *_bo)
if (bo->base.ptr) {
/* XXX Sanity check map_count */
- munmap(bo->base.ptr, bo->base.size);
+ //munmap(bo->base.ptr, bo->base.size);
bo->base.ptr = NULL;
}
diff --git a/msmmodetest.c b/msmmodetest.c
index 0d8de7d..72e9780 100755
--- a/msmmodetest.c
+++ b/msmmodetest.c
@@ -59,6 +59,8 @@
#include "buffers.h"
+#include "decoder_driver_test.h"
+
struct crtc {
drmModeCrtc *crtc;
drmModeObjectProperties *props;
@@ -102,6 +104,9 @@ struct device {
struct resources *resources;
struct msm_driver *msm;
+ int prime_handle;
+ int ion_fd;
+ void * pmapaddr;
struct {
unsigned int width;
@@ -112,6 +117,14 @@ struct device {
} mode;
};
+struct mymsmmodetest {
+ struct device dev;
+ struct pipe_arg *pipe_args;
+ int count;
+};
+
+struct mymsmmodetest * pme;
+
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
struct type_name {
@@ -986,8 +999,20 @@ static int set_plane(struct device *dev, struct plane_arg *p)
fprintf(stderr, "testing %dx%d@%s overlay plane %u\n",
p->w, p->h, p->format_str, plane_id);
+ {
+ int buf_fd = 0;
+ uint32_t prime_handle = 0;
+ int ret = 0;
+ buf_fd = ion_allocate_buffer_msm(p->w, p->h);
- plane_bo = create_test_buffer(dev->msm, p->fourcc, p->w, p->h, handles,
+ ret = drmPrimeFDToHandle(dev->fd, (uint32_t) buf_fd, &prime_handle);
+ if (ret) {
+ fprintf(stderr, "\n drmPrimeHandleToFD failed with error %d ", ret);
+ }
+ dev->prime_handle = prime_handle;
+ }
+ plane_bo = create_test_buffer(dev->prime_handle, dev->pmapaddr,
+ dev->msm, p->fourcc, p->w, p->h, handles,
pitches, offsets, PATTERN_TILES);
if (plane_bo == NULL)
return -1;
@@ -1047,8 +1072,21 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co
if (dev->mode.height < pipe->mode->vdisplay)
dev->mode.height = pipe->mode->vdisplay;
}
-
- bo = create_test_buffer(dev->msm, pipes[0].fourcc,
+ //if (dev->prime_handle == 0)
+ {
+ int buf_fd = 0;
+ uint32_t prime_handle = 0;
+ int ret = 0;
+ buf_fd = dev->ion_fd;
+ ret = drmPrimeFDToHandle(dev->fd, (uint32_t) buf_fd, &prime_handle);
+ if (ret) {
+ fprintf(stderr, "\n drmPrimeHandleToFD failed with error %d ", ret);
+ }
+ dev->prime_handle = prime_handle;
+ fprintf(stderr, "drmPrimeHandleToFD success \n");
+ }
+ bo = create_test_buffer(dev->prime_handle, dev->pmapaddr,
+ dev->msm, pipes[0].fourcc,
dev->mode.width, dev->mode.height,
handles, pitches, offsets, PATTERN_SMPTE);
if (bo == NULL)
@@ -1092,6 +1130,7 @@ static void set_mode(struct device *dev, struct pipe_arg *pipes, unsigned int co
dev->mode.bo = bo;
dev->mode.fb_id = fb_id;
+ msm_bo_destroy(&dev->mode.bo);
}
static void set_planes(struct device *dev, struct plane_arg *p, unsigned int count)
@@ -1113,7 +1152,20 @@ static void test_page_flip(struct device *dev, struct pipe_arg *pipes, unsigned
unsigned int i;
int ret;
- other_bo = create_test_buffer(dev->msm, pipes[0].fourcc,
+ {
+ int buf_fd = 0;
+ uint32_t prime_handle = 0;
+ int ret = 0;
+ buf_fd = ion_allocate_buffer_msm(dev->mode.width, dev->mode.height);
+ ret = drmPrimeFDToHandle(dev->fd, (uint32_t) buf_fd, &prime_handle);
+ if (ret) {
+ fprintf(stderr, "\n drmPrimeHandleToFD failed with error %d ", ret);
+ }
+ dev->prime_handle = prime_handle;
+ }
+
+ other_bo = create_test_buffer(dev->prime_handle, dev->pmapaddr,
+ dev->msm, pipes[0].fourcc,
dev->mode.width, dev->mode.height,
handles, pitches, offsets, PATTERN_PLAIN);
if (other_bo == NULL)
@@ -1378,9 +1430,9 @@ static int page_flipping_supported(void)
static char optstr[] = "cdD:efM:P:ps:vw:";
-int main(int argc, char **argv)
+void* main_modetest_create(int argc, char **argv)
{
- struct device dev;
+ //struct device dev;
int c;
int encoders = 0, connectors = 0, crtcs = 0, planes = 0, framebuffers = 0;
@@ -1390,7 +1442,8 @@ int main(int argc, char **argv)
char *device = NULL;
char *module = NULL;
unsigned int i;
- int count = 0, plane_count = 0;
+ //int count = 0, plane_count = 0;
+ int plane_count = 0;
unsigned int prop_count = 0;
struct pipe_arg *pipe_args = NULL;
struct plane_arg *plane_args = NULL;
@@ -1398,8 +1451,12 @@ int main(int argc, char **argv)
unsigned int args = 0;
int ret;
- memset(&dev, 0, sizeof dev);
+ pme = malloc(sizeof (struct mymsmmodetest));
+
+ pme->count = 0;
+ memset(&pme->dev, 0, sizeof pme->dev);
+ fprintf(stderr, "main_modetest_create memset \n");
opterr = 0;
while ((c = getopt(argc, argv, optstr)) != -1) {
args++;
@@ -1431,7 +1488,7 @@ int main(int argc, char **argv)
(plane_count + 1) * sizeof *plane_args);
if (plane_args == NULL) {
fprintf(stderr, "memory allocation failed\n");
- return 1;
+ return NULL;
}
if (parse_plane(&plane_args[plane_count], optarg) < 0)
@@ -1445,16 +1502,16 @@ int main(int argc, char **argv)
break;
case 's':
pipe_args = realloc(pipe_args,
- (count + 1) * sizeof *pipe_args);
+ (pme->count + 1) * sizeof *pipe_args);
if (pipe_args == NULL) {
fprintf(stderr, "memory allocation failed\n");
- return 1;
+ return NULL;
}
- if (parse_connector(&pipe_args[count], optarg) < 0)
+ if (parse_connector(&pipe_args[pme->count], optarg) < 0)
usage(argv[0]);
- count++;
+ pme->count++;
break;
case 'v':
test_vsync = 1;
@@ -1464,7 +1521,7 @@ int main(int argc, char **argv)
(prop_count + 1) * sizeof *prop_args);
if (prop_args == NULL) {
fprintf(stderr, "memory allocation failed\n");
- return 1;
+ return NULL;
}
if (parse_property(&prop_args[prop_count], optarg) < 0)
@@ -1482,16 +1539,16 @@ int main(int argc, char **argv)
encoders = connectors = crtcs = planes = framebuffers = 1;
if (module) {
- dev.fd = drmOpen(module, device);
- if (dev.fd < 0) {
+ pme->dev.fd = drmOpen(module, device);
+ if (pme->dev.fd < 0) {
fprintf(stderr, "failed to open device '%s'.\n", module);
- return 1;
+ return NULL;
}
} else {
for (i = 0; i < ARRAY_SIZE(modules); i++) {
printf("trying to open device '%s'...", modules[i]);
- dev.fd = drmOpen(modules[i], device);
- if (dev.fd < 0) {
+ pme->dev.fd = drmOpen(modules[i], device);
+ if (pme->dev.fd < 0) {
printf("failed.\n");
} else {
printf("success.\n");
@@ -1499,66 +1556,94 @@ int main(int argc, char **argv)
}
}
- if (dev.fd < 0) {
+ if (pme->dev.fd < 0) {
fprintf(stderr, "no device found.\n");
- return 1;
+ return NULL;
}
}
if (test_vsync && !page_flipping_supported()) {
fprintf(stderr, "page flipping not supported by drm.\n");
- return -1;
+ return NULL;
}
- if (test_vsync && !count) {
+ if (test_vsync && !pme->count) {
fprintf(stderr, "page flipping requires at least one -s option.\n");
- return -1;
+ return NULL;
}
- dev.resources = get_resources(&dev);
- if (!dev.resources) {
- drmClose(dev.fd);
- return 1;
+ pme->dev.resources = get_resources(&pme->dev);
+ if (!pme->dev.resources) {
+ drmClose(pme->dev.fd);
+ return NULL;
}
#define dump_resource(dev, res) if (res) dump_##res(dev)
- dump_resource(&dev, encoders);
- dump_resource(&dev, connectors);
- dump_resource(&dev, crtcs);
- dump_resource(&dev, planes);
- dump_resource(&dev, framebuffers);
+ dump_resource(&pme->dev, encoders);
+ dump_resource(&pme->dev, connectors);
+ dump_resource(&pme->dev, crtcs);
+ dump_resource(&pme->dev, planes);
+ dump_resource(&pme->dev, framebuffers);
for (i = 0; i < prop_count; ++i)
- set_property(&dev, &prop_args[i]);
+ set_property(&pme->dev, &prop_args[i]);
- if (count || plane_count) {
- ret = msm_create(dev.fd, &dev.msm);
+ if (pme->count || plane_count) {
+ ret = msm_create(pme->dev.fd, &pme->dev.msm);
if (ret) {
fprintf(stderr, "failed to create msm driver: %s\n",
strerror(-ret));
- return 1;
+ return NULL;
}
+ pme->dev.prime_handle = 0;
+ pme->pipe_args = pipe_args;
- if (count)
- set_mode(&dev, pipe_args, count);
+ //if (pme->count)
+ // set_mode(&pme->dev, pipe_args, pme->count);
- if (plane_count)
- set_planes(&dev, plane_args, plane_count);
+ //if (plane_count)
+ // set_planes(&dev, plane_args, plane_count);
- if (test_vsync)
- test_page_flip(&dev, pipe_args, count);
+ //if (test_vsync)
+ // test_page_flip(&dev, pipe_args, count);
- if (drop_master)
- drmDropMaster(dev.fd);
+ //if (drop_master)
+ //drmDropMaster(pme->dev.fd);
- msm_bo_destroy(&dev.mode.bo);
- msm_destroy(&dev.msm);
+ //msm_bo_destroy(&dev.mode.bo);
+ //msm_destroy(&dev.msm);
- getchar();
}
- free_resources(dev.resources);
+ //free_resources(dev.resources);
+ return (void *)pme;
+}
+
+int main_modetest_destroy(void * p)
+{
+ struct mymsmmodetest * pdestroy;
+ pdestroy = (struct mymsmmodetest *)p;
+ if (pme->count)
+ {
+ msm_bo_destroy(&pdestroy->dev.mode.bo);
+ msm_destroy(&pdestroy->dev.msm);
+ }
+
+ free_resources(pdestroy->dev.resources);
+ free (pdestroy);
+ pdestroy = NULL;
+}
+
+int setmsmmode(void * p, int fd, void * pmap_addr)
+{
+ struct mymsmmodetest * pset;
+ pset = (struct mymsmmodetest *)p;
+
+ pset->dev.pmapaddr = pmap_addr;
+ pset->dev.ion_fd = fd;
+ if (pset->count)
+ set_mode(&pset->dev, pset->pipe_args, pset->count);
return 0;
}